diff --git a/desmume/AUTHORS b/AUTHORS similarity index 91% rename from desmume/AUTHORS rename to AUTHORS index 545225e0d..955284518 100644 --- a/desmume/AUTHORS +++ b/AUTHORS @@ -15,7 +15,6 @@ adelikat matusz pa__ gocha -nitsuja Contributors ------------ @@ -41,3 +40,4 @@ Thanks to our super testers for this release nash679 pokefan999 dottorleo +lbalbalba \ No newline at end of file diff --git a/desmume/COPYING b/COPYING similarity index 100% rename from desmume/COPYING rename to COPYING diff --git a/desmume/ChangeLog b/ChangeLog similarity index 92% rename from desmume/ChangeLog rename to ChangeLog index 27ff030cf..9730dd89a 100644 --- a/desmume/ChangeLog +++ b/ChangeLog @@ -1,457 +1,426 @@ -0.9.4 -> ??? (r2437-r???) - -??? introduces an entirely rewritten main emulation loop. -This totally changes the timing, and totally breaks old savestates. - -Highlights: - * win32: lua engine, path configuration, 7z dearchiving support - * rewritten main emulation loop - -General/Core: - bug: fix cflash directory support for non-windows - bug: fix freeze in cart irq - bug: correctly emulate dma to/from tcm - bug: fix in thumb LSR carryflag - enh: add guitar grip emulation - enh: add more powerful antigrain-based drawing library and rewrite OSD system - enh: ideas-style debugging prints - -Graphics: - bug: fixing of obj blending, bmp obj rendering, and some obj window cases - bug: fix backdrop blending with garbage - bug: fix 256B granularity sprite addressing for sub gpu - bug: fix 128-wide captures - bug: fix color overflow in capture blending - bug: fix disp fifo capture - bug: fix simultaneous vram display and capture via same bank - bug: fix 3d overflow acknowledge registers - bug: change 3d cores to use 18bit color - bug: swrast: add clear image and scroll emulation - bug: swrast: add fog emulation - bug: swrast: fixes to shadow rendering - -Windows: - bug: improve map view tool to support more modes - enh: added 2x resizing filters (hq2x, 2xsai, supereagle, scanlines) - enh: soundview can now mute channels - enh: multicore optimization for filters, rotation, OSD - -Linux: - enh: alsa microphone support - enh: hud and osd notification for gtk and cli frontends - -0.9.2 -> 0.9.4 (r1844->r2352->r2437) - -0.9.3 was skipped due to emu news sites sneaking it out of our staging area and -releasing it prematurely while it still had bugs. I was going to curse them -individually, but then I decided that they would just like the publicity. - -Highlights: - * New save autodetection and save file format - * Full rerecording support - -General/Core: - bug: fix many 64 bit and endian issues - bug: fix mic input, which was nearly useless before - bug: fix failures of large dmas - bug: fix in ipc sync which broke devkitpro touch - bug: screenshots now exclude hud and rotation - bug: rewritten vram mapping (fixes corrupted or missing BG) - enh: add universal commandline system (same commandline options on every port) - enh: cheats: added Action Replay code parser - enh: more reliable and useful frameskipping - enh: SPU: speedup: add adpcm caching - enh: SPU: speedup: interpolation is now optional - enh: print svn build number so we can identify people's svn builds from screenshots - -Graphics: - bug: add polygon y-sorting (fixes 3d guis) - bug: fix texcoordgen mode 3; fixes some ortho sprites and some entirely broken games - bug: display capture fixes - bug: fix a number of OBJ modes - bug: fixes to affine BG modes - bug: better emulate some translucent OBJ - bug: more correct handling of color effect windows and backdrop colors - bug: fix matrix stack overrun which crashed emulator - bug: swrast: add clear depth image emulation and other fixes to depth buffering - bug: swrast: fix some toon and highlight cases - bug: fix bug in matrix stack, fixes some broken models - enh: add alternate flush mode HACK 3d config toggle, fixes some entirely broken 3d games - -Windows: - bug: more robust cheats engine and dialog - enh: more solid avi and wav recording - enh: improved tools: memory viewer - enh: added tools: spu viewer, ram watch, ram search - enh: change build configuration system - enh: speedup: add gpu core disabling to hide useless screens - enh: add background pause feature (for when emulator loses focus) - enh: add missing autohold for L and R - enh: add chinese translation - -Gtk frontend: - enh: switch all of menu/toolbar system to GtkAction + GtkUIManager - enh: remove the gtglext 3d code - enh: improve/speedup screen resize and final presentation logic in gtk frontend - enh: minimal rerecording hookups - -Cli frontend: - enh: hooked the frameskip (szigor) - enh: misc usability improvements: auto pause switch for pausing when focus is lost and exit on escape pressing (szigor) - enh: hook the fake noise mic; use m to toggle - -0.9.1 -> 0.9.2 -General/Core: - bug: fix error in SBCS/RSCS flags; fixes many odd behaviors and crashes [zeromus] - bug: add support for sleep mode and power registers [luigi__] - bug: important fixes to RTC so correct time is actually told [luigi__] - bug: fix card reads below 0x8000; fixes some game freezes [normatt] - bug: fix 4 mbit save type; fix non-autodetect savefile dumping [zeromus, matusz] - enh: add sram to GBA game addon emulation for importing savefiles [zeromus] - enh: many improvements and feature hookups in linux ports [matusz, luigi__] - -Graphics: - bug: fix specular texture mapping mode [luigi__] - bug: repairs to some capture modes and vram mapping [zeromus, CrazyMax] - bug: viewports finally correctly handled [zeromus] - enh: add software rasterizer. quirky, but on par with opengl [zeromus] - -Windows: - bug: mitigate bad frameskipper; default to old frameskipping mode [zeromus] - bug: fixes with recent roms and zipfile loading [zeromus] - bug: fix window position memory [zeromus] - enh: bios and firmware may now be used and booted [luigi__] - enh: many display, OSD, and input enhancements [luigi__] - enh: brand new hotkey and controls binding system [zeromus] - enh: configurable screen separation [luigi__] - enh: fast forward key [pa__] - enh: improvements to mic [luigi__] - enh: faster updates in debug tools, up to once per frame [pa__] - -Mac OS X Port: - enh: added Italian translation thanks to Paolo Bernini [jeff] - enh: resurrection of GDB stub [sigmaris] - -0.9 -> 0.9.1 -General/Core: - enh: GBA slot emulation [CrazyMax] - - Rumble support (windows only) - - GBA game - enh: Mic support (windows only?) [luigi__] - enh: Preliminary cheats system [CrazyMax] - enh: Savestates invalidated, as more variables have been added. - bug: Added PSG white noise [luigi__] - bug: fix arm/thumb ROR [zeromus] - bug: [ 2550645 ] Super Princess Peach: crash when starting a puzzle [zeromus] - bug: win32: fix spu wav file writer (regression from 0.8) [zeromus,luigi__] - bug: Much work on FIFOs, still not finished [CrazyMax] - bug: Many fixes to dma [zeromus, CrazyMax] - bug: bios WaitForVblank and WaitForInterrupt fixed [luigi__] - -Graphics: - bug: Added sprite blending [luigi__] - bug: more correct mosaic effects, still imperfect [zeromus] - bug: Many fixes to tile rendering; all graphics tests now pass [luigi__] - bug: fix crashes in some affine BG [zeromus] - bug: Implement some pos test function [luigi__] - bug: fix texture mapping across texture and palette banks and to unmapped banks [zeromus] - bug: fix texture handling for texels with MSB set (fixes some texture corruption) [zeromus] - bug: fix texture coordinate generation, including environment mapping [zeromus] - bug: texture cache invalidates when palettes change, prevents some texture corruption [zeromus] - bug: fix display capturing from 2d+3d source when display mode is display-vram [zeromus] - bug: [ 2488334 ].1 fixes to layer compositing [luigi__] - bug: [ 2488334 ].3 fix bug in support for hdma affine bg parameters [zeromus] - bug: Improvements to 3d h-scrolling [luigi__] - bug: Fix some errors in rendering 512 tall BG [zeromus,CrazyMax] (still not fully resolved) - bug: Add optional fragment shading pipeline (more precision) [luigi__] - bug: Fix bug where some sprites got cut of on x=255 [zeromus] - bug: Implement GXSTAT register [CrazyMax] - -Windows: - bug: resizing and rotating work in vista [luigi__] - enh: 0 frameskip now lets emulator run at excess speed [zeromus] - -Mac OS X Port: - bug: left key setting no longer gets confused with the right key [jeff] - enh: more keys can be mapped - -0.8 -> 0.9 - There have been so many changes that this list can hardly be considered complete. - For this release, we have formatted the list into a high level overview of big changes and bad bugs relative to the previous release. Hopefully what you're interested in. - This list does not include items which are solely performance boosts, for let us just say that virtually every system has been speeded up. - - * The savestate system is totally changed and incompatible with old savestates. - * The 3d system should be considered rewritten. - -General/Core: - enh: Convert to c++ - enh: Add functions for a lid open/close. Holding key (default "Backspace" in Windows port) while game is freeze/non freeze. [CrazyMax] - enh: Add secure area decryption from ndstool [zeromus] - enh: Change savestate code to support loosely bound chunks and more easily other parts of the emu (GE, GPU). - The savestate format is changed, but from now on it is in principle more resilient - (though it will continue to break as we tinker with the internals) [zeromus] - enh: Added SSE2 optimizations for matrices. Since we now make an SSE2 build, more optimizations can be made. [CrazyMax] - enh: Add a preliminary GUI hud system [CrazyMax,zeromus] - -CPU/MMU: - bug: Many fixes in IPC and GE FIFOs. Fixes freezes in NSMB, dsracing, and others. [CrazyMax,luigi__,shash] - bug: Fix ARM instructions SBC and RSC (likewise SBC in thumb) [normatt] - bug: Fixed Thumb LDMIA (fixes ingame Dead'n'Furious) [shash] - bug: Fix repeating DMA (fixes NSMB parallax BG) [zeromus] - bug: Proper handling for unaligned CPU accesses [luigi__] - bug: Proper handling for undefined instruction exceptions [Salva Peiró] - bug: correctly return vram control register values (fixes homebrew 3d games) [zeromus] - enh: Remove 16MB of WRAM at 0x01****** from arm9. Mapped to unused instead. Nobody knows what this was. [zeromus] - enh: Changed instruction execution to 16 at a time blocks (tested and stable) [shash] - -Hardware: - bug: Newer and better sqrt and div emulation; makes SM64DS playable [luigi__,shash,zeromus] - bug: Add preliminary RTC implementations [CrazyMax] - enh: Add cosine interpolation in the SPU (conditionally compiled) [zeromus,luigi__] - enh: Experimental: always one silent non-mixing SPU core at 44.1khz synched with emu, for more precision. - The audible core runs with the host, causing music to slow down but not tear or pitch bend. [zeromus] - -Graphics: - - Overhaul 3d: - . Move entire GE to core emu. - . Move OpenGL renderer to emu core for optional use by platforms, removing ogl_collector. Now every platform shares the same 3d code. - . Reorganize 3d code to defer rendering to after 3d vblank. Eliminates tearing, and texturing artifacts. [zeromus] - . Add optional fragment shading pipeline (more precision) [luigi__] - . Move lighting model to software instead of using opengl's fixed function model [zeromus] - . Render shadow volumes; toon shading and highlight table [zeromus, luigi__] - . Added texture caching! big speed up. [CrazyMax] - - bug: Many assorted tweaks and improvements to 3d and 2d precision [zeromus,CrazyMax,luigi__] - bug: Fixes to GE: command unpacking, projection and pos-vector mode matrix handling, mult and load commands [zeromus] - bug: Fix a bug in texture transformation mode 1 [zeromus] - bug: Fixed GPU rendering bugs in sprites and BG [CrazyMax] - bug: Fixes to texture conversion [CrazyMax,zeromus] - bug: Fixes in capture display (no blinking in many games with dual 3D) [CrazyMax] - bug: Fixes in master brightness (this fixes some games with black screens) [CrazyMax] - bug: Fixes in screen, backdrop, and sprite blending [luigi__] - bug: Changed clear depths and how depth initial values are calculated (fixes SM64DS skybox, Castlevania) [shash,lugi__] - bug: Add 3d layer h-scrolling [zeromus] - bug: Added transparency and fixed material alpha support and alpha testing on the 3D core [shash] - bug: Rewrite VRAM mapping control and rendering (more accurate) [CrazyMax,luigi__] - - bug: convert colors to opengl better to prevent alpha=31 polys from being ever so slightly transparent [zeromus] - enh: Add MMU->GPU signal for when vram mappings change to function as a texture cache invalidate signal [zeromus] - enh: Make matrix 4x4 multiply routines use W-coordinate; carry w coord through pipeline [zeromus] - -Mac OS X port: - bug: Fixed: Filenames and paths with unicode characters now work. [Jeff] - bug: Fixed: Load state from file button works again. [Jeff] - enh: Save State panel now pauses emulation while the file selection box is open. [Jeff] - bug: Fixed: Frozen video output (and/or messed 3d emulation) after loading a state. [Jeff] - bug: Added option to load the most recent file upon launching the program. [Jeff] - enh: Added French translation (thanks to Pierre Rudloff). [Jeff] - enh: Added basic key mapping configuration to application preferences (thanks to Julio GorgŽ). [Jeff] - enh: Added keyboard shortcuts for Execute, Pause and Reset command (thanks to Julio GorgŽ). [Jeff] - enh: Default key mappings are no longer case sensitive. [Jeff] - enh: Added ability to limit speed. [Jeff] - enh: Fixed: Video output should work on software-only 3D renderers. [Jeff] - -Windows port: - bug: Fix a race condition in NDS_3D_Reset and NDS_glInit [zeromus] - bug: Fix the buggy auto frameskip logic which made the emu slow to a crawl. Now it runs fast! [zeromus] - bug: Fix resizing, rotate & aspect ration of main window. [CrazyMax,_zeromus] - bug: Remove multithreading from user interface after finding several synchronization issues [zeromus] - enh: recent roms menu [luigi_] - enh: Changed graphics render core to DirectDraw (work faster) [CrazyMax] - enh: Add an arm9 cpu load average calculator similar to no$. but I dont think it works right. [zeromus] - enh: Rewrite all debug tools (autoupdate works now) [CrazyMax] - enh: Rewrite input core & replace config input dialog [CrazyMax] - enh: Add AVI output [zeromus] - enh: Add pause toggle and frame advance hotkeys [adelikat] - enh: Add frame counter display and hud messages framework [adelikat] - enh: Main window remembers position, size, and a few other emu preferences [adelikat] - enh: Removed directx sdk dependency for easier building. [zeromus] - enh: Savestate doesnt unpause emu if it is already paused [adelikat] - -0.7.3 -> 0.8 - Cocoa: - - Save State As function now works. [Jeff B] - - Recent Items menu now works. [Jeff B] - - Opening NDS files from Finder now works. [Jeff B] - - Added screenshot feature. [Jeff B] - - Added preferences. [Jeff B] - - Many more strings are translatable now. [Jeff B] - - Default screen color is black (better represents being "off" and easier on eyes at night). [Jeff B] - - Added sound. [Jeff B] - - Now is a universal binary. [Jeff B] - - Leopard resolution icon added. [Jeff B] - - Added a Japanese translation. [Jeff B] - - Added an optional status bar (resize handle no longer overlaps screen). [Jeff B] - - New ROM Info and About DeSmuME windows have been added. [Jeff B] - - Fixed several bugs in window resizing. [Jeff B] - - Added FAT image support for homebrew games (thanks to TypeError). [Jeff B] - - Key config can be changed on the command line. Save/load hotkeys changed (so expose doesn't override). [Jeff B] - - Key bindings may work better on non-US keyboards now (needs testing). [Jeff B] - general: - - Encapsulate GDB debug stub to avoid certain problems [shash] - - Fixed CPU LD*/ST* bugs [shash] - - Fixed New SMB mini-games freeze [shash] - - Fixed possible segfault in ROMReader on ia64 and amd64. [evilynux] - - Fixed a crash bug with 2D background corrupting memory [shash] - - Flag check optimization [carlo_bramini] - - Applied some endian fixes in GPU (thanks to Phazz) [Jeff B] - gtk-glade: - - Added DeSmuME version in about dialog. [evilynux] - - Updated website url in about dialog. [evilynux] - - Added Brazilian Portuguese translation by Dreampeppers99. [evilynux] - - Better desktop menu entry following FreeDesktop specifications. [evilynux] - gtk: - - Updated website url in about dialog. [evilynux] - - Better desktop menu entry following FreeDesktop specifications. [evilynux] - windows port: - - Added an "about" box [shash] - - DirectInput control interface with joystick support [CrazyMax] - - Matrix and Light viewer [Acid Burn] - -0.7.2 -> 0.7.3 - gtk-glade: - - Full localization using intltool/gettext. [evilynux] - general: - - Added a README.TRANSLATION documenting the localization process. [evilynux] - MacOS X: - - Initial version of the Mac interface added. [Jeff B] - -0.7.1 -> 0.7.2 - spu: - - big endian fixes. [cyberwarriorx] - gpu: - - big endian fixes. [marcus_c] - gtk-glade: - - opengl improvements. [masscat] - general: - - Added support for setting NDS firmware language value. [masscat] - - Function added for setting firmware language. [masscat] - - Mac/msys compilation fixes. [cyberwarriorx] - - Fix compilation when pkg-config macros are not available [evilynux] - -0.7.0 -> 0.7.1 - general: - - Added GDB debugger stub [masscat] - - Added new/different GBAMP CFlash image reader/writer [masscat] - gpu: - - Major speedup to the 2D core [shash] - gtk-glade: - - Added command line options. [masscat] - - Added FPS limiter [masscat] - cli: - - Added command line options. [masscat] - - Added FPS limiter [masscat] - - Added option to use OpenGl to render window (allows resizing). [masscat] - windows port: - - Added command line options. [masscat] - - Added multiple language support [cyberwarriorx] - - Added Danish language translation [thomas-2007] - -0.6.0 -> 0.7.0 - general: - - Added support for *.duc files [cyberwarriorx] - gpu: - - Added support for sprite rotation/scaling [shash] - - Added support for the 3D core (openGL and null plugins) [shash] - windows port: - - A bunch of fixes [Dmitry Krutskih] - - Fixed a bug in sound that was causing it to still not work for some - people [cyberwarriorx] - gtk: - - Added 3D emulation - - Added command line options. - - Added option to use OpenGL to render window (allows resizing). - gtk-glade: - - Added 3D emulation - -0.5.0 -> 0.6.0 - general: - - Added zipped (based on zziplib) and gzipped (based on zlib) rom support. - arm: - - Added relocation interrupt vector. - - Added region access right checks. - - Enabled LDC/STC instructions. - - Fixed powersave (cp15) IRQ wait. - - Fixed MOV instructions - gpu: - - Added special color effects. - - Added windowing feature. - - Fixed transparent direct color backgrounds. - - Fixed disabled sprites showing. - - Fixed 8/32 bit access to gpu registers. - - Fixed missing backgrounds - - Support for master brightness - wifi: - - Added RF chip interface. - - Added BB chip interface. - windows port: - - Fixed address calculation in disassembler. - - Added Force Maintain Ratio option for window stretching - linux port (cli, gtk and gtk-glade): - all: - - Added joystick support. - - Fixed X and Y buttons. - gtk-glade: - - Added joystick configuration. - - Improved I/O registers viewer tool. - - Added save and load states support. - -0.3.3 -> 0.5.0 - arm: - - Fixed MSR with immediate value opcode. - - Fixed LSR_0 thumb opcode (C flag is correctly set now). - - Fixed LDR*/STR* opcodes. - - Fixed unaligned memory access on THUMB Core. - - Added relocating SWI routines. - bios: - - Added decompression functions. - - Added GetPitchTable function. - - Added GetVolumeTable function. - - Added GetCRC16 function. - - Added experimental SoundBias function. - - Added GetSineTable function. - cart: - - Added CompactFlash/FAT emulation. - - Added Get ROM chip ID Cartridge command. - gpu: - - Added framebuffer emulation. - - Fixed a bug in GPU (xfin could be greater than LG causing a segfault). - - Added support for Display Mode 0(Display Off). - - Added the basic framework for Display Mode 3(Display from Main RAM). - spu: - - Added sound emulation. - - Added sound core system. - - Added WAV write core. - - Added dummy core. - - Added Direct Sound core. - linux port: - - Added GTK+ GUI. - - Added command line interface. - - Added stylus and arm9 keypad support in CLI version. - - Added FPS display. - - Added basic frameskip. - windows port: - - Fixed a bug when displaying a ROM's information. - - Added key configuration. - - Removed the debug key. - - Added new experimental auto frameskip/frame limit code. - - Added sound settings dialog. - - Added a few menu options for accessing the website, forums, and for - submitting bugs. - general: - - Rewrote code in C. - - Fixed warnings. - - Used defines and typedef's to make things more portable and easier to - read. - - Added autotools stuff. - - Changes to logging system. - - Added screenshot function. - - Translated most french to english. - - Added savestate support. - - Added firmware reading support(needs work). - - Added Backup Memory support with autodetection. - - Fixed some endianess issues. - - Fixed things so Visual C++ can compile code. - - Added bsd support. - - Reworked ROM loading so you can load a different rom without any problems. - - Finished NDS_Reset. Now the emulation can be reset even while running. +0.9.4+ + +- [2468] port r2466 from trunk (permit osd on bottom screen, fix stylus input display) +- [2645] port some of small fixes from trunk: + disable autohold while playing a movie (r2624) + fix movie length (r2629) + keyrepeat improvement (r2641-2643) +- [2665] + fix nitsuja's desynch bugreports (SF 2827543) + fix desynch caused by spu_core forgetting to save a variable + +0.9.2 -> 0.9.4 (r1844->r2352->r2437) + +0.9.3 was skipped due to emu news sites sneaking it out of our staging area and +releasing it prematurely while it still had bugs. I was going to curse them +individually, but then I decided that they would just like the publicity. + +Highlights: + * New save autodetection and save file format + * Full rerecording support + +General/Core: + bug: fix many 64 bit and endian issues + bug: fix mic input, which was nearly useless before + bug: fix failures of large dmas + bug: fix in ipc sync which broke devkitpro touch + bug: screenshots now exclude hud and rotation + bug: rewritten vram mapping (fixes corrupted or missing BG) + enh: add universal commandline system (same commandline options on every port) + enh: cheats: added Action Replay code parser + enh: more reliable and useful frameskipping + enh: SPU: speedup: add adpcm caching + enh: SPU: speedup: interpolation is now optional + enh: print svn build number so we can identify people's svn builds from screenshots + +Graphics: + bug: add polygon y-sorting (fixes 3d guis) + bug: fix texcoordgen mode 3; fixes some ortho sprites and some entirely broken games + bug: display capture fixes + bug: fix a number of OBJ modes + bug: fixes to affine BG modes + bug: better emulate some translucent OBJ + bug: more correct handling of color effect windows and backdrop colors + bug: fix matrix stack overrun which crashed emulator + bug: swrast: add clear depth image emulation and other fixes to depth buffering + bug: swrast: fix some toon and highlight cases + bug: fix bug in matrix stack, fixes some broken models + enh: add alternate flush mode HACK 3d config toggle, fixes some entirely broken 3d games + +Windows: + bug: more robust cheats engine and dialog + enh: more solid avi and wav recording + enh: improved tools: memory viewer + enh: added tools: spu viewer, ram watch, ram search + enh: change build configuration system + enh: speedup: add gpu core disabling to hide useless screens + enh: add background pause feature (for when emulator loses focus) + enh: add missing autohold for L and R + enh: add chinese translation + +Gtk frontend: + enh: switch all of menu/toolbar system to GtkAction + GtkUIManager + enh: remove the gtglext 3d code + enh: improve/speedup screen resize and final presentation logic in gtk frontend + enh: minimal rerecording hookups + +Cli frontend: + enh: hooked the frameskip (szigor) + enh: misc usability improvements: auto pause switch for pausing when focus is lost and exit on escape pressing (szigor) + enh: hook the fake noise mic; use m to toggle + +0.9.1 -> 0.9.2 +General/Core: + bug: fix error in SBCS/RSCS flags; fixes many odd behaviors and crashes [zeromus] + bug: add support for sleep mode and power registers [luigi__] + bug: important fixes to RTC so correct time is actually told [luigi__] + bug: fix card reads below 0x8000; fixes some game freezes [normatt] + bug: fix 4 mbit save type; fix non-autodetect savefile dumping [zeromus, matusz] + enh: add sram to GBA game addon emulation for importing savefiles [zeromus] + enh: many improvements and feature hookups in linux ports [matusz, luigi__] + +Graphics: + bug: fix specular texture mapping mode [luigi__] + bug: repairs to some capture modes and vram mapping [zeromus, CrazyMax] + bug: viewports finally correctly handled [zeromus] + enh: add software rasterizer. quirky, but on par with opengl [zeromus] + +Windows: + bug: mitigate bad frameskipper; default to old frameskipping mode [zeromus] + bug: fixes with recent roms and zipfile loading [zeromus] + bug: fix window position memory [zeromus] + enh: bios and firmware may now be used and booted [luigi__] + enh: many display, OSD, and input enhancements [luigi__] + enh: brand new hotkey and controls binding system [zeromus] + enh: configurable screen separation [luigi__] + enh: fast forward key [pa__] + enh: improvements to mic [luigi__] + enh: faster updates in debug tools, up to once per frame [pa__] + +Mac OS X Port: + enh: added Italian translation thanks to Paolo Bernini [jeff] + enh: resurrection of GDB stub [sigmaris] + +0.9 -> 0.9.1 +General/Core: + enh: GBA slot emulation [CrazyMax] + - Rumble support (windows only) + - GBA game + enh: Mic support (windows only?) [luigi__] + enh: Preliminary cheats system [CrazyMax] + enh: Savestates invalidated, as more variables have been added. + bug: Added PSG white noise [luigi__] + bug: fix arm/thumb ROR [zeromus] + bug: [ 2550645 ] Super Princess Peach: crash when starting a puzzle [zeromus] + bug: win32: fix spu wav file writer (regression from 0.8) [zeromus,luigi__] + bug: Much work on FIFOs, still not finished [CrazyMax] + bug: Many fixes to dma [zeromus, CrazyMax] + bug: bios WaitForVblank and WaitForInterrupt fixed [luigi__] + +Graphics: + bug: Added sprite blending [luigi__] + bug: more correct mosaic effects, still imperfect [zeromus] + bug: Many fixes to tile rendering; all graphics tests now pass [luigi__] + bug: fix crashes in some affine BG [zeromus] + bug: Implement some pos test function [luigi__] + bug: fix texture mapping across texture and palette banks and to unmapped banks [zeromus] + bug: fix texture handling for texels with MSB set (fixes some texture corruption) [zeromus] + bug: fix texture coordinate generation, including environment mapping [zeromus] + bug: texture cache invalidates when palettes change, prevents some texture corruption [zeromus] + bug: fix display capturing from 2d+3d source when display mode is display-vram [zeromus] + bug: [ 2488334 ].1 fixes to layer compositing [luigi__] + bug: [ 2488334 ].3 fix bug in support for hdma affine bg parameters [zeromus] + bug: Improvements to 3d h-scrolling [luigi__] + bug: Fix some errors in rendering 512 tall BG [zeromus,CrazyMax] (still not fully resolved) + bug: Add optional fragment shading pipeline (more precision) [luigi__] + bug: Fix bug where some sprites got cut of on x=255 [zeromus] + bug: Implement GXSTAT register [CrazyMax] + +Windows: + bug: resizing and rotating work in vista [luigi__] + enh: 0 frameskip now lets emulator run at excess speed [zeromus] + +Mac OS X Port: + bug: left key setting no longer gets confused with the right key [jeff] + enh: more keys can be mapped + +0.8 -> 0.9 + There have been so many changes that this list can hardly be considered complete. + For this release, we have formatted the list into a high level overview of big changes and bad bugs relative to the previous release. Hopefully what you're interested in. + This list does not include items which are solely performance boosts, for let us just say that virtually every system has been speeded up. + + * The savestate system is totally changed and incompatible with old savestates. + * The 3d system should be considered rewritten. + +General/Core: + enh: Convert to c++ + enh: Add functions for a lid open/close. Holding key (default "Backspace" in Windows port) while game is freeze/non freeze. [CrazyMax] + enh: Add secure area decryption from ndstool [zeromus] + enh: Change savestate code to support loosely bound chunks and more easily other parts of the emu (GE, GPU). + The savestate format is changed, but from now on it is in principle more resilient + (though it will continue to break as we tinker with the internals) [zeromus] + enh: Added SSE2 optimizations for matrices. Since we now make an SSE2 build, more optimizations can be made. [CrazyMax] + enh: Add a preliminary GUI hud system [CrazyMax,zeromus] + +CPU/MMU: + bug: Many fixes in IPC and GE FIFOs. Fixes freezes in NSMB, dsracing, and others. [CrazyMax,luigi__,shash] + bug: Fix ARM instructions SBC and RSC (likewise SBC in thumb) [normatt] + bug: Fixed Thumb LDMIA (fixes ingame Dead'n'Furious) [shash] + bug: Fix repeating DMA (fixes NSMB parallax BG) [zeromus] + bug: Proper handling for unaligned CPU accesses [luigi__] + bug: Proper handling for undefined instruction exceptions [Salva Peiró] + bug: correctly return vram control register values (fixes homebrew 3d games) [zeromus] + enh: Remove 16MB of WRAM at 0x01****** from arm9. Mapped to unused instead. Nobody knows what this was. [zeromus] + enh: Changed instruction execution to 16 at a time blocks (tested and stable) [shash] + +Hardware: + bug: Newer and better sqrt and div emulation; makes SM64DS playable [luigi__,shash,zeromus] + bug: Add preliminary RTC implementations [CrazyMax] + enh: Add cosine interpolation in the SPU (conditionally compiled) [zeromus,luigi__] + enh: Experimental: always one silent non-mixing SPU core at 44.1khz synched with emu, for more precision. + The audible core runs with the host, causing music to slow down but not tear or pitch bend. [zeromus] + +Graphics: + - Overhaul 3d: + . Move entire GE to core emu. + . Move OpenGL renderer to emu core for optional use by platforms, removing ogl_collector. Now every platform shares the same 3d code. + . Reorganize 3d code to defer rendering to after 3d vblank. Eliminates tearing, and texturing artifacts. [zeromus] + . Add optional fragment shading pipeline (more precision) [luigi__] + . Move lighting model to software instead of using opengl's fixed function model [zeromus] + . Render shadow volumes; toon shading and highlight table [zeromus, luigi__] + . Added texture caching! big speed up. [CrazyMax] + + bug: Many assorted tweaks and improvements to 3d and 2d precision [zeromus,CrazyMax,luigi__] + bug: Fixes to GE: command unpacking, projection and pos-vector mode matrix handling, mult and load commands [zeromus] + bug: Fix a bug in texture transformation mode 1 [zeromus] + bug: Fixed GPU rendering bugs in sprites and BG [CrazyMax] + bug: Fixes to texture conversion [CrazyMax,zeromus] + bug: Fixes in capture display (no blinking in many games with dual 3D) [CrazyMax] + bug: Fixes in master brightness (this fixes some games with black screens) [CrazyMax] + bug: Fixes in screen, backdrop, and sprite blending [luigi__] + bug: Changed clear depths and how depth initial values are calculated (fixes SM64DS skybox, Castlevania) [shash,lugi__] + bug: Add 3d layer h-scrolling [zeromus] + bug: Added transparency and fixed material alpha support and alpha testing on the 3D core [shash] + bug: Rewrite VRAM mapping control and rendering (more accurate) [CrazyMax,luigi__] + + bug: convert colors to opengl better to prevent alpha=31 polys from being ever so slightly transparent [zeromus] + enh: Add MMU->GPU signal for when vram mappings change to function as a texture cache invalidate signal [zeromus] + enh: Make matrix 4x4 multiply routines use W-coordinate; carry w coord through pipeline [zeromus] + +Mac OS X port: + bug: Fixed: Filenames and paths with unicode characters now work. [Jeff] + bug: Fixed: Load state from file button works again. [Jeff] + enh: Save State panel now pauses emulation while the file selection box is open. [Jeff] + bug: Fixed: Frozen video output (and/or messed 3d emulation) after loading a state. [Jeff] + bug: Added option to load the most recent file upon launching the program. [Jeff] + enh: Added French translation (thanks to Pierre Rudloff). [Jeff] + enh: Added basic key mapping configuration to application preferences (thanks to Julio GorgŽ). [Jeff] + enh: Added keyboard shortcuts for Execute, Pause and Reset command (thanks to Julio GorgŽ). [Jeff] + enh: Default key mappings are no longer case sensitive. [Jeff] + enh: Added ability to limit speed. [Jeff] + enh: Fixed: Video output should work on software-only 3D renderers. [Jeff] + +Windows port: + bug: Fix a race condition in NDS_3D_Reset and NDS_glInit [zeromus] + bug: Fix the buggy auto frameskip logic which made the emu slow to a crawl. Now it runs fast! [zeromus] + bug: Fix resizing, rotate & aspect ration of main window. [CrazyMax,_zeromus] + bug: Remove multithreading from user interface after finding several synchronization issues [zeromus] + enh: recent roms menu [luigi_] + enh: Changed graphics render core to DirectDraw (work faster) [CrazyMax] + enh: Add an arm9 cpu load average calculator similar to no$. but I dont think it works right. [zeromus] + enh: Rewrite all debug tools (autoupdate works now) [CrazyMax] + enh: Rewrite input core & replace config input dialog [CrazyMax] + enh: Add AVI output [zeromus] + enh: Add pause toggle and frame advance hotkeys [adelikat] + enh: Add frame counter display and hud messages framework [adelikat] + enh: Main window remembers position, size, and a few other emu preferences [adelikat] + enh: Removed directx sdk dependency for easier building. [zeromus] + enh: Savestate doesnt unpause emu if it is already paused [adelikat] + +0.7.3 -> 0.8 + Cocoa: + - Save State As function now works. [Jeff B] + - Recent Items menu now works. [Jeff B] + - Opening NDS files from Finder now works. [Jeff B] + - Added screenshot feature. [Jeff B] + - Added preferences. [Jeff B] + - Many more strings are translatable now. [Jeff B] + - Default screen color is black (better represents being "off" and easier on eyes at night). [Jeff B] + - Added sound. [Jeff B] + - Now is a universal binary. [Jeff B] + - Leopard resolution icon added. [Jeff B] + - Added a Japanese translation. [Jeff B] + - Added an optional status bar (resize handle no longer overlaps screen). [Jeff B] + - New ROM Info and About DeSmuME windows have been added. [Jeff B] + - Fixed several bugs in window resizing. [Jeff B] + - Added FAT image support for homebrew games (thanks to TypeError). [Jeff B] + - Key config can be changed on the command line. Save/load hotkeys changed (so expose doesn't override). [Jeff B] + - Key bindings may work better on non-US keyboards now (needs testing). [Jeff B] + general: + - Encapsulate GDB debug stub to avoid certain problems [shash] + - Fixed CPU LD*/ST* bugs [shash] + - Fixed New SMB mini-games freeze [shash] + - Fixed possible segfault in ROMReader on ia64 and amd64. [evilynux] + - Fixed a crash bug with 2D background corrupting memory [shash] + - Flag check optimization [carlo_bramini] + - Applied some endian fixes in GPU (thanks to Phazz) [Jeff B] + gtk-glade: + - Added DeSmuME version in about dialog. [evilynux] + - Updated website url in about dialog. [evilynux] + - Added Brazilian Portuguese translation by Dreampeppers99. [evilynux] + - Better desktop menu entry following FreeDesktop specifications. [evilynux] + gtk: + - Updated website url in about dialog. [evilynux] + - Better desktop menu entry following FreeDesktop specifications. [evilynux] + windows port: + - Added an "about" box [shash] + - DirectInput control interface with joystick support [CrazyMax] + - Matrix and Light viewer [Acid Burn] + +0.7.2 -> 0.7.3 + gtk-glade: + - Full localization using intltool/gettext. [evilynux] + general: + - Added a README.TRANSLATION documenting the localization process. [evilynux] + MacOS X: + - Initial version of the Mac interface added. [Jeff B] + +0.7.1 -> 0.7.2 + spu: + - big endian fixes. [cyberwarriorx] + gpu: + - big endian fixes. [marcus_c] + gtk-glade: + - opengl improvements. [masscat] + general: + - Added support for setting NDS firmware language value. [masscat] + - Function added for setting firmware language. [masscat] + - Mac/msys compilation fixes. [cyberwarriorx] + - Fix compilation when pkg-config macros are not available [evilynux] + +0.7.0 -> 0.7.1 + general: + - Added GDB debugger stub [masscat] + - Added new/different GBAMP CFlash image reader/writer [masscat] + gpu: + - Major speedup to the 2D core [shash] + gtk-glade: + - Added command line options. [masscat] + - Added FPS limiter [masscat] + cli: + - Added command line options. [masscat] + - Added FPS limiter [masscat] + - Added option to use OpenGl to render window (allows resizing). [masscat] + windows port: + - Added command line options. [masscat] + - Added multiple language support [cyberwarriorx] + - Added Danish language translation [thomas-2007] + +0.6.0 -> 0.7.0 + general: + - Added support for *.duc files [cyberwarriorx] + gpu: + - Added support for sprite rotation/scaling [shash] + - Added support for the 3D core (openGL and null plugins) [shash] + windows port: + - A bunch of fixes [Dmitry Krutskih] + - Fixed a bug in sound that was causing it to still not work for some + people [cyberwarriorx] + gtk: + - Added 3D emulation + - Added command line options. + - Added option to use OpenGL to render window (allows resizing). + gtk-glade: + - Added 3D emulation + +0.5.0 -> 0.6.0 + general: + - Added zipped (based on zziplib) and gzipped (based on zlib) rom support. + arm: + - Added relocation interrupt vector. + - Added region access right checks. + - Enabled LDC/STC instructions. + - Fixed powersave (cp15) IRQ wait. + - Fixed MOV instructions + gpu: + - Added special color effects. + - Added windowing feature. + - Fixed transparent direct color backgrounds. + - Fixed disabled sprites showing. + - Fixed 8/32 bit access to gpu registers. + - Fixed missing backgrounds + - Support for master brightness + wifi: + - Added RF chip interface. + - Added BB chip interface. + windows port: + - Fixed address calculation in disassembler. + - Added Force Maintain Ratio option for window stretching + linux port (cli, gtk and gtk-glade): + all: + - Added joystick support. + - Fixed X and Y buttons. + gtk-glade: + - Added joystick configuration. + - Improved I/O registers viewer tool. + - Added save and load states support. + +0.3.3 -> 0.5.0 + arm: + - Fixed MSR with immediate value opcode. + - Fixed LSR_0 thumb opcode (C flag is correctly set now). + - Fixed LDR*/STR* opcodes. + - Fixed unaligned memory access on THUMB Core. + - Added relocating SWI routines. + bios: + - Added decompression functions. + - Added GetPitchTable function. + - Added GetVolumeTable function. + - Added GetCRC16 function. + - Added experimental SoundBias function. + - Added GetSineTable function. + cart: + - Added CompactFlash/FAT emulation. + - Added Get ROM chip ID Cartridge command. + gpu: + - Added framebuffer emulation. + - Fixed a bug in GPU (xfin could be greater than LG causing a segfault). + - Added support for Display Mode 0(Display Off). + - Added the basic framework for Display Mode 3(Display from Main RAM). + spu: + - Added sound emulation. + - Added sound core system. + - Added WAV write core. + - Added dummy core. + - Added Direct Sound core. + linux port: + - Added GTK+ GUI. + - Added command line interface. + - Added stylus and arm9 keypad support in CLI version. + - Added FPS display. + - Added basic frameskip. + windows port: + - Fixed a bug when displaying a ROM's information. + - Added key configuration. + - Removed the debug key. + - Added new experimental auto frameskip/frame limit code. + - Added sound settings dialog. + - Added a few menu options for accessing the website, forums, and for + submitting bugs. + general: + - Rewrote code in C. + - Fixed warnings. + - Used defines and typedef's to make things more portable and easier to + read. + - Added autotools stuff. + - Changes to logging system. + - Added screenshot function. + - Translated most french to english. + - Added savestate support. + - Added firmware reading support(needs work). + - Added Backup Memory support with autodetection. + - Fixed some endianess issues. + - Fixed things so Visual C++ can compile code. + - Added bsd support. + - Reworked ROM loading so you can load a different rom without any problems. + - Finished NDS_Reset. Now the emulation can be reset even while running. diff --git a/desmume/Makefile.am b/Makefile.am similarity index 100% rename from desmume/Makefile.am rename to Makefile.am diff --git a/desmume/NEWS b/NEWS similarity index 100% rename from desmume/NEWS rename to NEWS diff --git a/desmume/README b/README similarity index 100% rename from desmume/README rename to README diff --git a/desmume/README.LIN b/README.LIN similarity index 100% rename from desmume/README.LIN rename to README.LIN diff --git a/desmume/README.MAC b/README.MAC similarity index 100% rename from desmume/README.MAC rename to README.MAC diff --git a/desmume/README.TRANSLATION b/README.TRANSLATION similarity index 100% rename from desmume/README.TRANSLATION rename to README.TRANSLATION diff --git a/desmume/README.WIN b/README.WIN similarity index 100% rename from desmume/README.WIN rename to README.WIN diff --git a/desmume/TODO b/TODO similarity index 100% rename from desmume/TODO rename to TODO diff --git a/desmume/autogen.sh b/autogen.sh old mode 100755 new mode 100644 similarity index 100% rename from desmume/autogen.sh rename to autogen.sh diff --git a/desmume/autopackage/default.apspec.in b/autopackage/default.apspec.in similarity index 100% rename from desmume/autopackage/default.apspec.in rename to autopackage/default.apspec.in diff --git a/desmume/compile b/compile old mode 100755 new mode 100644 similarity index 100% rename from desmume/compile rename to compile diff --git a/desmume/configure.ac b/configure.ac similarity index 96% rename from desmume/configure.ac rename to configure.ac index 39ddc7fe7..6cc00790d 100644 --- a/desmume/configure.ac +++ b/configure.ac @@ -169,14 +169,10 @@ fi AM_CONDITIONAL([HAVE_LIBAGG], [test "${HAVE_LIBAGG}" = "yes"]) if test "x$HAVE_LIBAGG" = "xyes"; then AC_DEFINE([HAVE_LIBAGG]) -else - AC_MSG_ERROR([Antigrain library is required to build desmume]) fi -dnl - depends on glib, reference pkg-config since it is needed for checking glib -if test "x$FOUND_GLIB" = "xno"; then - AC_MSG_ERROR([Glib and pkg-config are required to build desmume]) -fi +dnl - set conditional for glib, needed to avoid commandline.cpp compilation for cli frontend since it depends on glib +AM_CONDITIONAL([HAVE_GLIB], [test "${FOUND_GLIB}" = "yes"]) dnl - If the gtkGLext package is available define the corresponding C macro if test "x$HAVE_GTKGLEXT" = "xyes"; then @@ -277,8 +273,7 @@ if test "x[$]ENABLE_HARDCORE" = "x1"; then dnl - only valid for C with newer gcc's CPPFLAGS="[$]CPPFLAGS -Wmissing-prototypes" fi - dnl - -Wshadow - CPPFLAGS="[$]CPPFLAGS -Wall -Wextra -D_FORTIFY_SOURCE=2 -Wno-missing-field-initializers -Wpointer-arith -Wcast-align -Wwrite-strings -Wno-unused-parameter -Wmissing-declarations -Wundef -Wmissing-noreturn -Wredundant-decls -Wformat-nonliteral -Wformat-security -Winit-self" + CPPFLAGS="[$]CPPFLAGS -Wall -Wextra -D_FORTIFY_SOURCE=2 -Wno-missing-field-initializers -Wpointer-arith -Wcast-align -Wwrite-strings -Wno-unused-parameter -Wmissing-declarations -Wundef -Wmissing-noreturn -Wshadow -Wredundant-decls -Wformat-nonliteral -Wformat-security -Winit-self" fi dnl - Enable debug mode diff --git a/desmume/src/fat.h b/desmume/src/fat.h deleted file mode 100644 index 7ff4f7cf6..000000000 --- a/desmume/src/fat.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - FAT.H - Mic, 2006 - Structures taken from Michael Chisholm's FAT library -*/ - -#ifndef __FAT_H__ -#define __FAT_H__ - -#include "types.h" -#include "PACKED.h" -#include "PACKED_END.h" - -#define ATTRIB_DIR 0x10 -#define ATTRIB_LFN 0x0F - -#define FILE_FREE 0xE5 -/* Name and extension maximum length */ -#define NAME_LEN 8 -#define EXT_LEN 3 - -// Boot Sector - must be packed -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) -#define DIR_SEP "\\" -#else -#define DIR_SEP "/" -#endif - -#include "PACKED.h" -struct boot_record -{ - u8 jmpBoot[3]; - u8 OEMName[8]; - // BIOS Parameter Block - u16 bytesPerSector; - u8 sectorsPerCluster; - u16 reservedSectors; - u8 numFATs; - u16 rootEntries; - u16 numSectorsSmall; - u8 mediaDesc; - u16 sectorsPerFAT; - u16 sectorsPerTrk; - u16 numHeads; - u32 numHiddenSectors; - u32 numSectors; - - struct - { - // Ext BIOS Parameter Block for FAT16 - u8 driveNumber; - u8 reserved1; - u8 extBootSig; - u32 volumeID; - u8 volumeLabel[11]; - u8 fileSysType[8]; - // Bootcode - u8 bootCode[448]; - u16 signature; - } __PACKED fat16; - -} __PACKED; -typedef struct boot_record BOOT_RECORD; -#include "PACKED_END.h" - -// Directory entry - must be packed -#include "PACKED.h" -struct dir_ent -{ - u8 name[NAME_LEN]; - u8 ext[EXT_LEN]; - u8 attrib; - u8 reserved; - u8 cTime_ms; - u16 cTime; - u16 cDate; - u16 aDate; - u16 startClusterHigh; - u16 mTime; - u16 mDate; - u16 startCluster; - u32 fileSize; -} __PACKED; -typedef struct dir_ent DIR_ENT; -#include "PACKED_END.h" - -#endif // diff --git a/desmume/src/matrix.h b/desmume/src/matrix.h deleted file mode 100644 index 0f15e6269..000000000 --- a/desmume/src/matrix.h +++ /dev/null @@ -1,317 +0,0 @@ -/* Copyright (C) 2006-2007 shash - Copyright (C) 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef MATRIX_H -#define MATRIX_H - -#include -#include - -#include "types.h" -#include "mem.h" - -#ifdef ENABLE_SSE -#include -#endif - -#ifdef ENABLE_SSE2 -#include -#endif - -struct MatrixStack -{ - MatrixStack(int size); - float *matrix; - int position; - int size; -}; - -void MatrixInit (float *matrix); - -//In order to conditionally use these asm optimized functions in visual studio -//without having to make new build types to exclude the assembly files. -//a bit sloppy, but there aint much to it - -float MatrixGetMultipliedIndex (int index, float *matrix, float *rightMatrix); -void MatrixSet (float *matrix, int x, int y, float value); -void MatrixCopy (float * matrixDST, const float * matrixSRC); -int MatrixCompare (const float * matrixDST, const float * matrixSRC); -void MatrixIdentity (float *matrix); - -void MatrixTranspose (float *matrix); -void MatrixStackInit (MatrixStack *stack); -void MatrixStackSetMaxSize (MatrixStack *stack, int size); -void MatrixStackSetStackPosition (MatrixStack *stack, int pos); -void MatrixStackPushMatrix (MatrixStack *stack, const float *ptr); -float* MatrixStackPopMatrix (MatrixStack *stack, int size); -float* MatrixStackGetPos (MatrixStack *stack, int pos); -float* MatrixStackGet (MatrixStack *stack); -void MatrixStackLoadMatrix (MatrixStack *stack, int pos, const float *ptr); - -void Vector2Copy(float *dst, const float *src); -void Vector2Add(float *dst, const float *src); -void Vector2Subtract(float *dst, const float *src); -float Vector2Dot(const float *a, const float *b); -float Vector2Cross(const float *a, const float *b); - -float Vector3Dot(const float *a, const float *b); -void Vector3Cross(float* dst, const float *a, const float *b); -float Vector3Length(const float *a); -void Vector3Add(float *dst, const float *src); -void Vector3Subtract(float *dst, const float *src); -void Vector3Scale(float *dst, const float scale); -void Vector3Copy(float *dst, const float *src); -void Vector3Normalize(float *dst); - -void Vector4Copy(float *dst, const float *src); - -//these functions are an unreliable, inaccurate floor. -//it should only be used for positive numbers -//this isnt as fast as it could be if we used a visual c++ intrinsic, but those appear not to be universally available -FORCEINLINE u32 u32floor(float f) -{ -#ifdef ENABLE_SSE2 - return (u32)_mm_cvtt_ss2si(_mm_set_ss(f)); -#else - return (u32)f; -#endif -} -FORCEINLINE u32 u32floor(double d) -{ -#ifdef ENABLE_SSE2 - return (u32)_mm_cvttsd_si32(_mm_set_sd(d)); -#else - return (u32)d; -#endif -} - -//same as above but works for negative values too. -//be sure that the results are the same thing as floorf! -FORCEINLINE s32 s32floor(float f) -{ -#ifdef ENABLE_SSE2 - return _mm_cvtss_si32( _mm_add_ss(_mm_set_ss(-0.5f),_mm_add_ss(_mm_set_ss(f), _mm_set_ss(f))) ) >> 1; -#else - return (s32)floorf(f); -#endif -} - -//switched SSE2 functions -//------------- -#ifdef ENABLE_SSE - -template -FORCEINLINE void memset_u16_le(void* dst, u16 val) -{ - u32 u32val; - //just for the endian safety - T1WriteWord((u8*)&u32val,0,val); - T1WriteWord((u8*)&u32val,2,val); - ////const __m128i temp = _mm_set_epi32(u32val,u32val,u32val,u32val); - __m128 temp; temp.m128_i32[0] = u32val; - //MACRODO_N(NUM/8,_mm_store_si128((__m128i*)((u8*)dst+(X)*16), temp)); - MACRODO_N(NUM/8,_mm_store_ps1((float*)((u8*)dst+(X)*16), temp)); -} - -#else //no sse2 - -template -static FORCEINLINE void memset_u16_le(void* dst, u16 val) -{ - for(int i=0;i -FORCEINLINE void vector_fix2float(float* matrix, const float divisor) -{ - CTASSERT(NUM_ROWS==3 || NUM_ROWS==4); - - const __m128 val = _mm_set_ps1(divisor); - - _mm_store_ps(matrix,_mm_div_ps(_mm_load_ps(matrix),val)); - _mm_store_ps(matrix+4,_mm_div_ps(_mm_load_ps(matrix+4),val)); - _mm_store_ps(matrix+8,_mm_div_ps(_mm_load_ps(matrix+8),val)); - if(NUM_ROWS==4) - _mm_store_ps(matrix+12,_mm_div_ps(_mm_load_ps(matrix+12),val)); -} - -//WARNING: I do not think this is as fast as a memset, for some reason. -//at least in vc2005 with sse enabled. better figure out why before using it -template -static FORCEINLINE void memset_u8(void* _dst, u8 val) -{ - memset(_dst,val,NUM); - //const u8* dst = (u8*)_dst; - //u32 u32val = (val<<24)|(val<<16)|(val<<8)|val; - //const __m128i temp = _mm_set_epi32(u32val,u32val,u32val,u32val); - //MACRODO_N(NUM/16,_mm_store_si128((__m128i*)(dst+(X)*16), temp)); -} - -#else //no sse - -void MatrixMultVec4x4 (const float *matrix, float *vecPtr); -void MatrixMultVec3x3(const float * matrix, float * vecPtr); -void MatrixMultiply(float * matrix, const float * rightMatrix); -void MatrixTranslate(float *matrix, const float *ptr); -void MatrixScale(float * matrix, const float * ptr); - -FORCEINLINE void MatrixMultVec4x4_M2(const float *matrix, float *vecPtr) -{ - //there are hardly any gains from merging these manually - MatrixMultVec4x4(matrix+16,vecPtr); - MatrixMultVec4x4(matrix,vecPtr); -} - -template -FORCEINLINE void vector_fix2float(float* matrix, const float divisor) -{ - for(int i=0;i -static FORCEINLINE void memset_u8(void* dst, u8 val) -{ - memset(dst,val,NUM); -} - -#endif //switched SSE functions - - -#endif diff --git a/desmume/src/windows/directx/x64/DxErr8.lib b/desmume/src/windows/directx/x64/DxErr8.lib deleted file mode 100644 index 86a762f24..000000000 Binary files a/desmume/src/windows/directx/x64/DxErr8.lib and /dev/null differ diff --git a/desmume/src/windows/directx/x64/ddraw.lib b/desmume/src/windows/directx/x64/ddraw.lib deleted file mode 100644 index c7d77b324..000000000 Binary files a/desmume/src/windows/directx/x64/ddraw.lib and /dev/null differ diff --git a/desmume/src/windows/directx/x64/dinput8.lib b/desmume/src/windows/directx/x64/dinput8.lib deleted file mode 100644 index 38aa63249..000000000 Binary files a/desmume/src/windows/directx/x64/dinput8.lib and /dev/null differ diff --git a/desmume/src/windows/directx/x64/dsound.lib b/desmume/src/windows/directx/x64/dsound.lib deleted file mode 100644 index 12c580d5a..000000000 Binary files a/desmume/src/windows/directx/x64/dsound.lib and /dev/null differ diff --git a/desmume/src/windows/directx/x64/dxguid.lib b/desmume/src/windows/directx/x64/dxguid.lib deleted file mode 100644 index 2b369246c..000000000 Binary files a/desmume/src/windows/directx/x64/dxguid.lib and /dev/null differ diff --git a/desmume/src/windows/mapView.cpp b/desmume/src/windows/mapView.cpp deleted file mode 100644 index 776dbbbd1..000000000 --- a/desmume/src/windows/mapView.cpp +++ /dev/null @@ -1,314 +0,0 @@ -/* Copyright (C) 2006 yopyop -yopyop156@ifrance.com -yopyop156.ifrance.com - -This file is part of DeSmuME - -DeSmuME is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -DeSmuME is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with DeSmuME; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "mapView.h" -#include "resource.h" - -#include -#include "../MMU.h" -#include "../NDSSystem.h" -#include "debug.h" -#include "windriver.h" - -using namespace GPU_EXT; - -struct mapview_struct -{ - u32 autoup_secs; - bool autoup; - - u8 map; - u16 lcd; - u16 bitmap[1024*1024]; - bool clear; - - void render() - { - //we're going to make a copy of the gpu so that we don't wreck affine scroll params - //hopefully we won't mess up anything else - GPU *realGpu; - if(lcd) realGpu = SubScreen.gpu; - else realGpu = MainScreen.gpu; - GPU &gpu = *realGpu; - - //forgive the gyrations, some of this junk in here is to remind us of gyrations we might have to go - //through to avoid breaking the gpu struct - - gpu.currBgNum = map; - gpu.debug = true; - - for(u32 i = 0; i < gpu.BGSize[map][1]; ++i) - { - gpu.currDst = (u8 *)bitmap + i*gpu.BGSize[map][0]*2; - gpu.currLine = i; - gpu.modeRender(map); - } - gpu.debug = false; - - } -}; - -mapview_struct *MapView = NULL; - - -LRESULT MapView_OnPaint(mapview_struct * win, HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - Lock lock; - - HDC hdc; - PAINTSTRUCT ps; - char text[80]; - u32 dispcnt = ((volatile u32 *)MMU.ARM9_REG)[(win->lcd*0x400)]; - u32 bgcnt = ((volatile u16 *)MMU.ARM9_REG)[(8 + (win->map<<1) + (win->lcd*0x1000))>>1]; - BITMAPV4HEADER bmi; - u16 lg; - u16 ht; - BGxPARMS * parms; - - //CreateBitmapIndirect(&bmi); - memset(&bmi, 0, sizeof(bmi)); - bmi.bV4Size = sizeof(bmi); - bmi.bV4Planes = 1; - bmi.bV4BitCount = 16; - bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS; - bmi.bV4RedMask = 0x001F; - bmi.bV4GreenMask = 0x03E0; - bmi.bV4BlueMask = 0x7C00; - - if(win->lcd) - { - lg = SubScreen.gpu->BGSize[win->map][0]; - ht = SubScreen.gpu->BGSize[win->map][1]; - } - else - { - lg = MainScreen.gpu->BGSize[win->map][0]; - ht = MainScreen.gpu->BGSize[win->map][1]; - } - bmi.bV4Width = lg; - bmi.bV4Height = -ht; - - hdc = BeginPaint(hwnd, &ps); - - sprintf(text, "%d %08X, %08X", (int)(dispcnt&7), (int)dispcnt, (int)bgcnt); - SetWindowText(GetDlgItem(hwnd, IDC_MODE), text); - - if(!(bgcnt&(1<<7))) - sprintf(text, "normal 16"); - else - { - if(!(dispcnt&(1<<30))) - sprintf(text, "normal 256"); - else - { - switch(win->map) - { - case 0 : - sprintf(text, "extended slot %d", (bgcnt&(1<<13))?2:0); - break; - case 1 : - sprintf(text, "extended slot %d", (bgcnt&(1<<13))?3:1); - break; - default : - sprintf(text, "extended slot %d", MainScreen.gpu->BGExtPalSlot[win->map]); - break; - } - } - } - SetWindowText(GetDlgItem(hwnd, IDC_PAL), text); - - sprintf(text, "%d", (int)(bgcnt&3)); - SetWindowText(GetDlgItem(hwnd, IDC_PRIO), text); - - - if((dispcnt>>8>>win->map)&1) - SetWindowText(GetDlgItem(hwnd, IDC_VISIBLE), "true"); - else - SetWindowText(GetDlgItem(hwnd, IDC_VISIBLE), "false"); - - sprintf(text, "0x%08X", (int)(0x6000000 + ((bgcnt>>2)&0xF)*0x4000 + win->lcd*0x200000 +((dispcnt>>24)&7)*0x10000)); - SetWindowText(GetDlgItem(hwnd, IDC_CHAR), text); - - sprintf(text, "0x%08X", (int)(0x6000000 + 0x800*((bgcnt>>8)&0x1F) + win->lcd*0x200000 + ((dispcnt>>27)&7)*0x10000)); - SetWindowText(GetDlgItem(hwnd, IDC_SCR), text); - - //sprintf(text, "%d x %d", MainScreen.gpu->BGPA[win->map], MainScreen.gpu->BGPB[win->map]); - sprintf(text, "%d x %d", (int)MainScreen.gpu->BGSize[win->map][0], (int)MainScreen.gpu->BGSize[win->map][1]); - SetWindowText(GetDlgItem(hwnd, IDC_MSIZE), text); - - //if (win->map==2) { - // parms = &(MainScreen.gpu->dispx_st)->dispx_BG2PARMS; - //} else { - // parms = &(MainScreen.gpu->dispx_st)->dispx_BG3PARMS; - //} - //sprintf(text, "%d x %d", parms->BGxX, parms->BGxY); - SetWindowText(GetDlgItem(hwnd, IDC_SCROLL), "useless"); - - for(int i = 0; i < ARRAY_SIZE(win->bitmap); i++) - win->bitmap[i] = 0x7C1F; - - win->render(); - - if(win->clear) - { - RECT r; - r.left = 200; - r.top = 4; - r.right = 200 + 1024; - r.bottom = 200 + 1024; - HBRUSH brush = CreateSolidBrush(GetSysColor(COLOR_3DFACE)); - FillRect(hdc, &r, brush); - DeleteObject(brush); - win->clear = false; - } - - SetDIBitsToDevice(hdc, 200, 4, lg, ht, 0, 0, 0, ht, win->bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); - - EndPaint(hwnd, &ps); - - return 0; -} - -BOOL CALLBACK ViewMapsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - //bail out early if the dialog isnt initialized - if(!MapView && message != WM_INITDIALOG) - return false; - - switch (message) - { - case WM_INITDIALOG : - { - MapView = new mapview_struct; - memset(MapView, 0, sizeof(MapView)); - MapView->clear = true; - MapView->autoup_secs = 1; - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETRANGE, 0, MAKELONG(99, 1)); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETPOS32, 0, MapView->autoup_secs); - HWND combo = GetDlgItem(hwnd, IDC_BG_SELECT); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 3"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub BackGround 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub BackGround 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub BackGround 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub BackGround 3"); - SendMessage(combo, CB_SETCURSEL, 0, 0); - } - return 1; - case WM_CLOSE : - { - if(MapView->autoup) - { - KillTimer(hwnd, IDT_VIEW_MAP); - MapView->autoup = false; - } - if (MapView!=NULL) - { - delete MapView; - MapView = NULL; - } - //INFO("Close Map view dialog\n"); - PostQuitMessage(0); - return 0; - } - case WM_PAINT: - MapView_OnPaint(MapView, hwnd, wParam, lParam); - return 1; - case WM_TIMER: - SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); - return 1; - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDC_FERMER : - SendMessage(hwnd, WM_CLOSE, 0, 0); - return 1; - case IDC_AUTO_UPDATE : - if(MapView->autoup) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); - KillTimer(hwnd, IDT_VIEW_MAP); - MapView->autoup = FALSE; - return 1; - } - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); - MapView->autoup = TRUE; - SetTimer(hwnd, IDT_VIEW_MAP, MapView->autoup_secs*20, (TIMERPROC) NULL); - return 1; - case IDC_AUTO_UPDATE_SECS: - { - int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); - if (!MapView) - { - SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - if (t != MapView->autoup_secs) - { - MapView->autoup_secs = t; - if (MapView->autoup) - SetTimer(hwnd, IDT_VIEW_MAP, - MapView->autoup_secs*20, (TIMERPROC) NULL); - } - } - return 1; - case IDC_REFRESH: - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_BG_SELECT : - switch(HIWORD(wParam)) - { - case CBN_SELCHANGE : - case CBN_CLOSEUP : - { - u32 sel= SendMessage(GetDlgItem(hwnd, IDC_BG_SELECT), CB_GETCURSEL, 0, 0); - switch(sel) - { - case 0 : - case 1 : - case 2 : - case 3 : - MapView->map = sel; - MapView->lcd = 0; - break; - case 4 : - case 5 : - case 6 : - case 7 : - MapView->map = sel-4; - MapView->lcd = 1; - break; - } - } - MapView->clear = true; - InvalidateRect(hwnd, NULL, FALSE); - return 1; - }//switch et case - }//switch - return 1; - } - return false; -} diff --git a/desmume/dsm.txt b/dsm.txt similarity index 100% rename from desmume/dsm.txt rename to dsm.txt diff --git a/desmume/dsv.txt b/dsv.txt similarity index 100% rename from desmume/dsv.txt rename to dsv.txt diff --git a/desmume/faq.htm b/faq.htm similarity index 100% rename from desmume/faq.htm rename to faq.htm diff --git a/desmume/po/ChangeLog b/po/ChangeLog similarity index 100% rename from desmume/po/ChangeLog rename to po/ChangeLog diff --git a/desmume/po/LINGUAS b/po/LINGUAS similarity index 100% rename from desmume/po/LINGUAS rename to po/LINGUAS diff --git a/desmume/po/PACKAGE b/po/PACKAGE similarity index 100% rename from desmume/po/PACKAGE rename to po/PACKAGE diff --git a/desmume/po/POTFILES.in b/po/POTFILES.in similarity index 100% rename from desmume/po/POTFILES.in rename to po/POTFILES.in diff --git a/desmume/po/desmume.pot b/po/desmume.pot similarity index 100% rename from desmume/po/desmume.pot rename to po/desmume.pot diff --git a/desmume/po/fr.po b/po/fr.po similarity index 100% rename from desmume/po/fr.po rename to po/fr.po diff --git a/desmume/po/pt_BR.po b/po/pt_BR.po similarity index 100% rename from desmume/po/pt_BR.po rename to po/pt_BR.po diff --git a/desmume/po/sv.po b/po/sv.po similarity index 100% rename from desmume/po/sv.po rename to po/sv.po diff --git a/desmume/po/windows/en_US.po b/po/windows/en_US.po similarity index 100% rename from desmume/po/windows/en_US.po rename to po/windows/en_US.po diff --git a/desmume/po/windows/fr_FR.po b/po/windows/fr_FR.po similarity index 100% rename from desmume/po/windows/fr_FR.po rename to po/windows/fr_FR.po diff --git a/desmume/po/zh_CN.po b/po/zh_CN.po similarity index 100% rename from desmume/po/zh_CN.po rename to po/zh_CN.po diff --git a/src/ARM9.h b/src/ARM9.h new file mode 100644 index 000000000..2b7e9e1e5 --- /dev/null +++ b/src/ARM9.h @@ -0,0 +1,39 @@ +#ifndef ARM9_H +#define ARM9_H + +#include "types.h" + +struct ALIGN(16) ARM9_struct { + //ARM9 mem + u8 ARM9_ITCM[0x8000]; + u8 ARM9_DTCM[0x4000]; + u8 MAIN_MEM[0x800000]; //this has been expanded to 8MB to support debug consoles + u8 ARM9_REG[0x1000000]; + u8 ARM9_BIOS[0x8000]; + u8 ARM9_VMEM[0x800]; + + #include "PACKED.h" + struct { + u8 ARM9_LCD[0xA4000]; + //an extra 128KB for blank memory, directly after arm9_lcd, so that + //we can easily map things to the end of arm9_lcd to represent + //an unmapped state + u8 blank_memory[0x20000]; + }; + #include "PACKED_END.h" + + u8 ARM9_OAM[0x800]; + + u8* ExtPal[2][4]; + u8* ObjExtPal[2][2]; + + struct TextureInfo { + u8* texPalSlot[6]; + u8* textureSlotAddr[4]; + } texInfo; + +}; + +extern ARM9_struct ARM9Mem; + +#endif diff --git a/desmume/src/Disassembler.cpp b/src/Disassembler.cpp similarity index 96% rename from desmume/src/Disassembler.cpp rename to src/Disassembler.cpp index 47d6534f8..564b37e0f 100644 --- a/desmume/src/Disassembler.cpp +++ b/src/Disassembler.cpp @@ -1,3772 +1,3772 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include "Disassembler.h" -#include "bits.h" - -#define ROR(i, j) ((((u32)(i))>>(j)) | (((u32)(i))<<(32-(j)))) - -const char Condition[16][3] = { - "EQ", - "NE", - "CS", - "CC", - "MI", - "PL", - "VS", - "VC", - "HI", - "LS", - "GE", - "LT", - "GT", - "LE", - "", - "" - }; - -const char Registre[16][4] = { - "R0", - "R1", - "R2", - "R3", - "R4", - "R5", - "R6", - "R7", - "R8", - "R9", - "R10", - "R11", - "R12", - "SP", - "LR", - "PC", - }; - -const char MSR_FIELD[16][5] = { - "", - "c", - "x", - "xc", - "s", - "sc", - "sx", - "sxc", - "f", - "fc", - "fx", - "fxc", - "fs", - "fsc", - "fsx", - "fsxc" - }; - -#define DATAPROC_LSL_IMM(nom, s) char tmp[10] = "";\ - if(((i>>7)&0x1F)!=0)\ - sprintf(tmp, ", LSL #%X", (int)((i>>7)&0x1F));\ - sprintf(txt, "%s%s%s %s, %s, %s%s",\ - #nom,\ - Condition[CONDITION(i)],\ - s,\ - Registre[REG_POS(i,12)],\ - Registre[REG_POS(i,16)],\ - Registre[REG_POS(i,0)],\ - tmp); -#define DATAPROC_ROR_IMM(nom, s) char tmp[10] = "";\ - if(((i>>7)&0x1F)!=0)\ - sprintf(tmp, ", RRX");\ - sprintf(txt, "%s%s%s %s, %s, %s%s",\ - #nom,\ - Condition[CONDITION(i)],\ - s,\ - Registre[REG_POS(i,12)],\ - Registre[REG_POS(i,16)],\ - Registre[REG_POS(i,0)],\ - tmp\ - ); - -#define DATAPROC_REG_SHIFT(nom, shift,s) sprintf(txt, "%s%s%s %s, %s, %s, %s %s",\ - #nom,\ - Condition[CONDITION(i)],\ - s,\ - Registre[REG_POS(i,12)],\ - Registre[REG_POS(i,16)],\ - Registre[REG_POS(i,0)],\ - #shift,\ - Registre[REG_POS(i,8)]\ - ); - -#define DATAPROC_IMM_SHIFT(nom, shift, s) sprintf(txt, "%s%s%s %s, %s, %s, %s #%X",\ - #nom,\ - Condition[CONDITION(i)],\ - s,\ - Registre[REG_POS(i,12)],\ - Registre[REG_POS(i,16)],\ - Registre[REG_POS(i,0)],\ - #shift,\ - (int)((i>>7)&0x1F)\ - ); - -#define DATAPROC_IMM_VALUE(nom,s) u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E);\ - sprintf(txt, "%s%s%s %s, %s, #%X",\ - #nom,\ - Condition[CONDITION(i)],\ - s,\ - Registre[REG_POS(i,12)],\ - Registre[REG_POS(i,16)],\ - (int)shift_op\ - ); - -#define DATAPROC_ONE_OP_LSL_IMM(nom, s, v) char tmp[10] = "";\ - if(((i>>7)&0x1F)!=0)\ - sprintf(tmp, ", LSL #%X", (int)((i>>7)&0x1F));\ - sprintf(txt, "%s%s%s %s, %s%s",\ - #nom,\ - Condition[CONDITION(i)],\ - s,\ - Registre[REG_POS(i,v)],\ - Registre[REG_POS(i,0)],\ - tmp); - -#define DATAPROC_ONE_OP_ROR_IMM(nom, s, v) char tmp[10] = "";\ - if(((i>>7)&0x1F)==0)\ - sprintf(tmp, ", RRX");\ - else\ - sprintf(tmp, ", ROR %d", (int)((i>>7)&0x1F));\ - sprintf(txt, "%s%s%s %s, %s%s",\ - #nom,\ - Condition[CONDITION(i)],\ - s,\ - Registre[REG_POS(i,v)],\ - Registre[REG_POS(i,0)],\ - tmp\ - ); - -#define DATAPROC_ONE_OP_REG_SHIFT(nom, shift,s, v) sprintf(txt, "%s%s%s %s, %s, %s %s",\ - #nom,\ - Condition[CONDITION(i)],\ - s,\ - Registre[REG_POS(i,v)],\ - Registre[REG_POS(i,0)],\ - #shift,\ - Registre[REG_POS(i,8)]\ - ); - -#define DATAPROC_ONE_OP_IMM_SHIFT(nom, shift, s, v) sprintf(txt, "%s%s%s %s, %s, %s #%X",\ - #nom,\ - Condition[CONDITION(i)],\ - s,\ - Registre[REG_POS(i,v)],\ - Registre[REG_POS(i,0)],\ - #shift,\ - (int)((i>>7)&0x1F)\ - ); - -#define DATAPROC_ONE_OP_IMM_VALUE(nom, s, v)\ - u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E);\ - sprintf(txt, "%s%s%s %s, #%X",\ - #nom,\ - Condition[CONDITION(i)],\ - s,\ - Registre[REG_POS(i,v)],\ - (int)shift_op\ - ); - -#define SIGNEXTEND_24(i) (((i)&0xFFFFFF)|(0xFF000000*BIT23(i))) - -#define LDRSTR_LSL_IMM(nom, op, op2, op3) char tmp[10] = "";\ - if(((i>>7)&0x1F)!=0)\ - sprintf(tmp, ", LSL #%X", (int)((i>>7)&0x1F));\ - sprintf(txt, "%s%s %s, [%s%s, %s%s%s%s",\ - #nom,\ - Condition[CONDITION(i)],\ - Registre[REG_POS(i,12)],\ - Registre[REG_POS(i,16)],\ - op2,\ - op,\ - Registre[REG_POS(i,0)],\ - tmp,\ - op3); -#define LDRSTR_ROR_IMM(nom, op, op2, op3) char tmp[10] = "";\ - if(((i>>7)&0x1F)!=0)\ - sprintf(tmp, ", RRX");\ - sprintf(txt, "%s%s %s, [%s%s, %s%s%s%s",\ - #nom,\ - Condition[CONDITION(i)],\ - Registre[REG_POS(i,12)],\ - Registre[REG_POS(i,16)],\ - op2,\ - op,\ - Registre[REG_POS(i,0)],\ - tmp,\ - op3\ - ); - -#define LDRSTR_IMM_SHIFT(nom, shift, op, op2, op3)\ - sprintf(txt, "%s%s %s, [%s%s, %s%s, %s #%X%s",\ - #nom,\ - Condition[CONDITION(i)],\ - Registre[REG_POS(i,12)],\ - Registre[REG_POS(i,16)],\ - op2,\ - op,\ - Registre[REG_POS(i,0)],\ - #shift,\ - (int)((i>>7)&0x1F),\ - op3\ - ); - -#define RegList(nb) char lreg[100] = "";\ - int prec = 0;\ - int j;\ - for(j = 0; j < nb; j++)\ - {\ - if(prec)\ - {\ - if((!BIT_N(i, j+1))||(j==nb-1))\ - {\ - sprintf(lreg + strlen(lreg), "%s,", Registre[j]);\ - prec = 0;\ - }\ - }\ - else\ - {\ - if(BIT_N(i, j))\ - {\ - if((BIT_N(i, j+1))&&(j!=nb-1))\ - {\ - sprintf(lreg + strlen(lreg), "%s-", Registre[j]);\ - prec = 1;\ - }\ - else\ - sprintf(lreg + strlen(lreg), "%s,", Registre[j]);\ - }\ - }\ - }\ - if(*lreg) lreg[strlen(lreg)-1]='\0'; - -static char * OP_UND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "----"); - return txt; -} - -//-----------------------AND------------------------------------ -static char * OP_AND_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(AND, ""); - return txt; -} - -static char * OP_AND_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(AND, LSL, ""); - return txt; -} - -static char * OP_AND_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(AND, LSR, ""); - return txt; -} - -static char * OP_AND_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(AND, LSR, ""); - return txt; -} - -static char * OP_AND_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(AND, ASR, ""); - return txt; -} - -static char * OP_AND_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(AND, ASR, ""); - return txt; -} - -static char * OP_AND_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(AND, ""); - return txt; -} - -static char * OP_AND_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(AND, ROR, ""); - return txt; -} - -static char * OP_AND_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(AND, ""); - return txt; -} - -static char * OP_AND_S_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(AND, "S"); - return txt; -} - -static char * OP_AND_S_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(AND, LSL, "S"); - return txt; -} - -static char * OP_AND_S_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(AND, LSR, "S"); - return txt; -} - -static char * OP_AND_S_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(AND, LSR, "S"); - return txt; -} - -static char * OP_AND_S_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(AND, ASR, "S"); - return txt; -} - -static char * OP_AND_S_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(AND, ASR, "S"); - return txt; -} - -static char * OP_AND_S_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(AND, "S"); - return txt; -} - -static char * OP_AND_S_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(AND, ROR, "S"); - return txt; -} - -static char * OP_AND_S_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(AND, "S"); - return txt; -} - -//--------------EOR------------------------------ -static char * OP_EOR_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(EOR, ""); - return txt; -} - -static char * OP_EOR_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(EOR, LSL, ""); - return txt; -} - -static char * OP_EOR_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(EOR, LSR, ""); - return txt; -} - -static char * OP_EOR_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(EOR, LSR, ""); - return txt; -} - -static char * OP_EOR_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(EOR, ASR, ""); - return txt; -} - -static char * OP_EOR_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(EOR, ASR, ""); - return txt; -} - -static char * OP_EOR_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(EOR, ""); - return txt; -} - -static char * OP_EOR_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(EOR, ROR, ""); - return txt; -} - -static char * OP_EOR_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(EOR, ""); - return txt; -} - -static char * OP_EOR_S_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(EOR, "S"); - return txt; -} - -static char * OP_EOR_S_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(EOR, LSL, "S"); - return txt; -} - -static char * OP_EOR_S_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(EOR, LSR, "S"); - return txt; -} - -static char * OP_EOR_S_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(EOR, LSR, "S"); - return txt; -} - -static char * OP_EOR_S_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(EOR, ASR, "S"); - return txt; -} - -static char * OP_EOR_S_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(EOR, ASR, "S"); - return txt; -} - -static char * OP_EOR_S_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(EOR, "S"); - return txt; -} - -static char * OP_EOR_S_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(EOR, ROR, "S"); - return txt; -} - -static char * OP_EOR_S_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(EOR, "S"); - return txt; -} - -//-------------SUB------------------------------------- - -static char * OP_SUB_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(SUB, ""); - return txt; -} - -static char * OP_SUB_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SUB, LSL, ""); - return txt; -} - -static char * OP_SUB_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(SUB, LSR, ""); - return txt; -} - -static char * OP_SUB_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SUB, LSR, ""); - return txt; -} - -static char * OP_SUB_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(SUB, ASR, ""); - return txt; -} - -static char * OP_SUB_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SUB, ASR, ""); -return txt;} - -static char * OP_SUB_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(SUB, ""); -return txt;} - -static char * OP_SUB_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SUB, ROR, ""); -return txt;} - -static char * OP_SUB_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(SUB, ""); -return txt;} - -static char * OP_SUB_S_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(SUB, "S"); -return txt;} - -static char * OP_SUB_S_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SUB, LSL, "S"); -return txt;} - -static char * OP_SUB_S_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(SUB, LSR, "S"); -return txt;} - -static char * OP_SUB_S_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SUB, LSR, "S"); -return txt;} - -static char * OP_SUB_S_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(SUB, ASR, "S"); -return txt;} - -static char * OP_SUB_S_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SUB, ASR, "S"); -return txt;} - -static char * OP_SUB_S_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(SUB, "S"); -return txt;} - -static char * OP_SUB_S_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SUB, ROR, "S"); -return txt;} - -static char * OP_SUB_S_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(SUB, "S"); -return txt;} - -//------------------RSB------------------------ - -static char * OP_RSB_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(RSB, ""); -return txt;} - -static char * OP_RSB_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSB, LSL, ""); -return txt;} - -static char * OP_RSB_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(RSB, LSR, ""); -return txt;} - -static char * OP_RSB_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSB, LSR, ""); -return txt;} - -static char * OP_RSB_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(RSB, ASR, ""); -return txt;} - -static char * OP_RSB_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSB, ASR, ""); -return txt;} - -static char * OP_RSB_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(RSB, ""); -return txt;} - -static char * OP_RSB_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSB, ROR, ""); -return txt;} - -static char * OP_RSB_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(RSB, ""); -return txt;} - -static char * OP_RSB_S_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(RSB, "S"); -return txt;} - -static char * OP_RSB_S_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSB, LSL, "S"); -return txt;} - -static char * OP_RSB_S_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(RSB, LSR, "S"); -return txt;} - -static char * OP_RSB_S_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSB, LSR, "S"); -return txt;} - -static char * OP_RSB_S_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(RSB, ASR, "S"); -return txt;} - -static char * OP_RSB_S_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSB, ASR, "S"); -return txt;} - -static char * OP_RSB_S_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(RSB, "S"); -return txt;} - -static char * OP_RSB_S_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSB, ROR, "S"); -return txt;} - -static char * OP_RSB_S_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(RSB, "S"); -return txt;} - -//------------------ADD----------------------------------- - -static char * OP_ADD_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(ADD, ""); -return txt;} - -static char * OP_ADD_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADD, LSL, ""); -return txt;} - -static char * OP_ADD_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(ADD, LSR, ""); -return txt;} - -static char * OP_ADD_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADD, LSR, ""); -return txt;} - -static char * OP_ADD_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(ADD, ASR, ""); -return txt;} - -static char * OP_ADD_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADD, ASR, ""); -return txt;} - -static char * OP_ADD_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(ADD, ""); -return txt;} - -static char * OP_ADD_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADD, ROR, ""); -return txt;} - -static char * OP_ADD_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(ADD, ""); -return txt;} - -static char * OP_ADD_S_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(ADD, "S"); -return txt;} - -static char * OP_ADD_S_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADD, LSL, "S"); -return txt;} - -static char * OP_ADD_S_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(ADD, LSR, "S"); -return txt;} - -static char * OP_ADD_S_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADD, LSR, "S"); -return txt;} - -static char * OP_ADD_S_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(ADD, ASR, "S"); -return txt;} - -static char * OP_ADD_S_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADD, ASR, "S"); -return txt;} - -static char * OP_ADD_S_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(ADD, "S"); -return txt;} - -static char * OP_ADD_S_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADD, ROR, "S"); -return txt;} - -static char * OP_ADD_S_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(ADD, "S"); -return txt;} - -//------------------ADC----------------------------------- - -static char * OP_ADC_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(ADC, ""); -return txt;} - -static char * OP_ADC_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADC, LSL, ""); -return txt;} - -static char * OP_ADC_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(ADC, LSR, ""); -return txt;} - -static char * OP_ADC_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADC, LSR, ""); -return txt;} - -static char * OP_ADC_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(ADC, ASR, ""); -return txt;} - -static char * OP_ADC_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADC, ASR, ""); -return txt;} - -static char * OP_ADC_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(ADC, ""); -return txt;} - -static char * OP_ADC_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADC, ROR, ""); -return txt;} - -static char * OP_ADC_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(ADC, ""); -return txt;} - -static char * OP_ADC_S_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(ADC, "S"); -return txt;} - -static char * OP_ADC_S_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADC, LSL, "S"); -return txt;} - -static char * OP_ADC_S_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(ADC, LSR, "S"); -return txt;} - -static char * OP_ADC_S_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADC, LSR, "S"); -return txt;} - -static char * OP_ADC_S_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(ADC, ASR, "S"); -return txt;} - -static char * OP_ADC_S_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADC, ASR, "S"); -return txt;} - -static char * OP_ADC_S_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(ADC, "S"); -return txt;} - -static char * OP_ADC_S_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ADC, ROR, "S"); -return txt;} - -static char * OP_ADC_S_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(ADC, "S"); -return txt;} - -//-------------SBC------------------------------------- - -static char * OP_SBC_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(SBC, ""); -return txt;} - -static char * OP_SBC_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SBC, LSL, ""); -return txt;} - -static char * OP_SBC_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(SBC, LSR, ""); -return txt;} - -static char * OP_SBC_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SBC, LSR, ""); -return txt;} - -static char * OP_SBC_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(SBC, ASR, ""); -return txt;} - -static char * OP_SBC_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SBC, ASR, ""); -return txt;} - -static char * OP_SBC_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(SBC, ""); -return txt;} - -static char * OP_SBC_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SBC, ROR, ""); -return txt;} - -static char * OP_SBC_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(SBC, ""); -return txt;} - -static char * OP_SBC_S_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(SBC, "S"); -return txt;} - -static char * OP_SBC_S_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SBC, LSL, "S"); -return txt;} - -static char * OP_SBC_S_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(SBC, LSR, "S"); -return txt;} - -static char * OP_SBC_S_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SBC, LSR, "S"); -return txt;} - -static char * OP_SBC_S_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(SBC, ASR, "S"); -return txt;} - -static char * OP_SBC_S_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SBC, ASR, "S"); -return txt;} - -static char * OP_SBC_S_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(SBC, "S"); -return txt;} - -static char * OP_SBC_S_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(SBC, ROR, "S"); -return txt;} - -static char * OP_SBC_S_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(SBC, "S"); -return txt;} - -//---------------RSC---------------------------------- - -static char * OP_RSC_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(RSC, ""); -return txt;} - -static char * OP_RSC_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSC, LSL, ""); -return txt;} - -static char * OP_RSC_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(RSC, LSR, ""); -return txt;} - -static char * OP_RSC_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSC, LSR, ""); -return txt;} - -static char * OP_RSC_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(RSC, ASR, ""); -return txt;} - -static char * OP_RSC_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSC, ASR, ""); -return txt;} - -static char * OP_RSC_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(RSC, ""); -return txt;} - -static char * OP_RSC_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSC, ROR, ""); -return txt;} - -static char * OP_RSC_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(RSC, ""); -return txt;} - -static char * OP_RSC_S_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(RSC, "S"); -return txt;} - -static char * OP_RSC_S_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSC, LSL, "S"); -return txt;} - -static char * OP_RSC_S_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(RSC, LSR, "S"); -return txt;} - -static char * OP_RSC_S_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSC, LSR, "S"); -return txt;} - -static char * OP_RSC_S_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(RSC, ASR, "S"); -return txt;} - -static char * OP_RSC_S_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSC, ASR, "S"); -return txt;} - -static char * OP_RSC_S_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(RSC, "S"); -return txt;} - -static char * OP_RSC_S_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(RSC, ROR, "S"); -return txt;} - -static char * OP_RSC_S_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(RSC, "S"); -return txt;} - -//-------------------TST---------------------------- - -static char * OP_TST_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_LSL_IMM(TST, "", 16); -return txt;} - -static char * OP_TST_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(TST, LSL, "", 16); -return txt;} - -static char * OP_TST_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(TST, LSR, "", 16); -return txt;} - -static char * OP_TST_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(TST, LSR, "", 16); -return txt;} - -static char * OP_TST_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(TST, ASR, "", 16); -return txt;} - -static char * OP_TST_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(TST, ASR, "", 16); -return txt;} - -static char * OP_TST_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_ROR_IMM(TST, "", 16); -return txt;} - -static char * OP_TST_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(TST, ROR, "", 16); -return txt;} - -static char * OP_TST_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_VALUE(TST, "", 16); -return txt;} - -//-------------------TEQ---------------------------- - -static char * OP_TEQ_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_LSL_IMM(TEQ, "", 16); -return txt;} - -static char * OP_TEQ_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(TEQ, LSL, "", 16); -return txt;} - -static char * OP_TEQ_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(TEQ, LSR, "", 16); -return txt;} - -static char * OP_TEQ_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(TEQ, LSR, "", 16); -return txt;} - -static char * OP_TEQ_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(TEQ, ASR, "", 16); -return txt;} - -static char * OP_TEQ_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(TEQ, ASR, "", 16); -return txt;} - -static char * OP_TEQ_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_ROR_IMM(TEQ, "", 16); -return txt;} - -static char * OP_TEQ_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(TEQ, ROR, "", 16); -return txt;} - -static char * OP_TEQ_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_VALUE(TEQ, "", 16); -return txt;} - -//-------------CMP------------------------------------- - -static char * OP_CMP_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_LSL_IMM(CMP, "", 16); -return txt;} - -static char * OP_CMP_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(CMP, LSL, "", 16); -return txt;} - -static char * OP_CMP_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(CMP, LSR, "", 16); -return txt;} - -static char * OP_CMP_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(CMP, LSR, "", 16); -return txt;} - -static char * OP_CMP_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(CMP, ASR, "", 16); -return txt;} - -static char * OP_CMP_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(CMP, ASR, "", 16); -return txt;} - -static char * OP_CMP_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_ROR_IMM(CMP, "", 16); -return txt;} - -static char * OP_CMP_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(CMP, ROR, "", 16); -return txt;} - -static char * OP_CMP_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_VALUE(CMP, "", 16); -return txt;} - -//---------------CMN--------------------------- - -static char * OP_CMN_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_LSL_IMM(CMN, "", 16); -return txt;} - -static char * OP_CMN_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(CMN, LSL, "", 16); -return txt;} - -static char * OP_CMN_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(CMP, ASR, "", 16); -return txt;} - -static char * OP_CMN_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(CMN, LSR, "", 16); -return txt;} - -static char * OP_CMN_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(CMN, ASR, "", 16); -return txt;} - -static char * OP_CMN_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(CMN, ASR, "", 16); -return txt;} - -static char * OP_CMN_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_ROR_IMM(CMN, "", 16); -return txt;} - -static char * OP_CMN_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(CMN, ROR, "", 16); -return txt;} - -static char * OP_CMN_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_VALUE(CMN, "", 16); -return txt;} - -//------------------ORR------------------- - -static char * OP_ORR_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(ORR, ""); -return txt;} - -static char * OP_ORR_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ORR, LSL, ""); -return txt;} - -static char * OP_ORR_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(ORR, LSR, ""); -return txt;} - -static char * OP_ORR_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ORR, LSR, ""); -return txt;} - -static char * OP_ORR_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(ORR, ASR, ""); -return txt;} - -static char * OP_ORR_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ORR, ASR, ""); -return txt;} - -static char * OP_ORR_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(ORR, ""); -return txt;} - -static char * OP_ORR_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ORR, ROR, ""); -return txt;} - -static char * OP_ORR_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(ORR, ""); -return txt;} - -static char * OP_ORR_S_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(ORR, "S"); -return txt;} - -static char * OP_ORR_S_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ORR, LSL, "S"); -return txt;} - -static char * OP_ORR_S_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(ORR, LSR, "S"); -return txt;} - -static char * OP_ORR_S_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ORR, LSR, "S"); -return txt;} - -static char * OP_ORR_S_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(ORR, ASR, "S"); -return txt;} - -static char * OP_ORR_S_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ORR, ASR, "S"); -return txt;} - -static char * OP_ORR_S_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(ORR, "S"); -return txt;} - -static char * OP_ORR_S_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(ORR, ROR, "S"); -return txt;} - -static char * OP_ORR_S_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(ORR, "S"); -return txt;} - -//------------------MOV------------------- - -static char * OP_MOV_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_LSL_IMM(MOV, "", 12); -return txt;} - -static char * OP_MOV_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MOV, LSL, "", 12); -return txt;} - -static char * OP_MOV_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(MOV, LSR, "", 12); -return txt;} - -static char * OP_MOV_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MOV, LSR, "", 12); -return txt;} - -static char * OP_MOV_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(MOV, ASR, "", 12); -return txt;} - -static char * OP_MOV_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MOV, ASR, "", 12); -return txt;} - -static char * OP_MOV_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_ROR_IMM(MOV, "", 12); -return txt;} - -static char * OP_MOV_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MOV, ROR, "", 12); -return txt;} - -static char * OP_MOV_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_VALUE(MOV, "", 12); -return txt;} - -static char * OP_MOV_S_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_LSL_IMM(MOV, "S", 12); -return txt;} - -static char * OP_MOV_S_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MOV, LSL, "S", 12); -return txt;} - -static char * OP_MOV_S_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(MOV, LSR, "S", 12); -return txt;} - -static char * OP_MOV_S_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MOV, LSR, "S", 12); -return txt;} - -static char * OP_MOV_S_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(MOV, ASR, "S", 12); -return txt;} - -static char * OP_MOV_S_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MOV, ASR, "S", 12); -return txt;} - -static char * OP_MOV_S_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_ROR_IMM(MOV, "S", 12); -return txt;} - -static char * OP_MOV_S_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MOV, ROR, "S", 12); -return txt;} - -static char * OP_MOV_S_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_VALUE(MOV, "S", 12); -return txt;} - -//------------------BIC------------------- - -static char * OP_BIC_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(BIC, ""); -return txt;} - -static char * OP_BIC_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(BIC, LSL, ""); -return txt;} - -static char * OP_BIC_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(BIC, LSR, ""); -return txt;} - -static char * OP_BIC_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(BIC, LSR, ""); -return txt;} - -static char * OP_BIC_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(BIC, ASR, ""); -return txt;} - -static char * OP_BIC_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(BIC, ASR, ""); -return txt;} - -static char * OP_BIC_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(BIC, ""); -return txt;} - -static char * OP_BIC_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(BIC, ROR, ""); -return txt;} - -static char * OP_BIC_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(BIC, ""); -return txt;} - -static char * OP_BIC_S_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_LSL_IMM(BIC, "S"); -return txt;} - -static char * OP_BIC_S_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(BIC, LSL, "S"); -return txt;} - -static char * OP_BIC_S_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(BIC, LSR, "S"); -return txt;} - -static char * OP_BIC_S_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(BIC, LSR, "S"); -return txt;} - -static char * OP_BIC_S_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_SHIFT(BIC, ASR, "S"); -return txt;} - -static char * OP_BIC_S_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(BIC, ASR, "S"); -return txt;} - -static char * OP_BIC_S_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ROR_IMM(BIC, "S"); -return txt;} - -static char * OP_BIC_S_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_REG_SHIFT(BIC, ROR, "S"); -return txt;} - -static char * OP_BIC_S_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_IMM_VALUE(BIC, "S"); -return txt;} - -//------------------MVN------------------- - -static char * OP_MVN_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_LSL_IMM(MVN, "", 12); -return txt;} - -static char * OP_MVN_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MVN, LSL, "", 12); -return txt;} - -static char * OP_MVN_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(MVN, LSR, "", 12); -return txt;} - -static char * OP_MVN_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MVN, LSR, "", 12); -return txt;} - -static char * OP_MVN_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(MVN, ASR, "", 12); -return txt;} - -static char * OP_MVN_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MVN, ASR, "", 12); -return txt;} - -static char * OP_MVN_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_ROR_IMM(MVN, "", 12); -return txt;} - -static char * OP_MVN_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MVN, ROR, "", 12); -return txt;} - -static char * OP_MVN_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_VALUE(MVN, "", 12); -return txt;} - -static char * OP_MVN_S_LSL_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_LSL_IMM(MVN, "S", 12); -return txt;} - -static char * OP_MVN_S_LSL_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MVN, LSL, "S", 12); -return txt;} - -static char * OP_MVN_S_LSR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(MVN, LSR, "S", 12); -return txt;} - -static char * OP_MVN_S_LSR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MVN, LSR, "S", 12); -return txt;} - -static char * OP_MVN_S_ASR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_SHIFT(MOV, ASR, "S", 12); -return txt;} - -static char * OP_MVN_S_ASR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MVN, ASR, "S", 12); -return txt;} - -static char * OP_MVN_S_ROR_IMM(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_ROR_IMM(MVN, "S", 12); -return txt;} - -static char * OP_MVN_S_ROR_REG(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_REG_SHIFT(MVN, ROR, "S", 12); -return txt;} - -static char * OP_MVN_S_IMM_VAL(u32 adr, u32 i, char * txt) -{ - DATAPROC_ONE_OP_IMM_VALUE(MVN, "S", 12); -return txt;} - - -//-------------MUL------------------------ - -static char * OP_MUL(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MUL%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_MLA(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MLA%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); -return txt;} - -static char * OP_MUL_S(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MUL%sS %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_MLA_S(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MLA%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); -return txt;} - - -//----------UMUL-------------------------- - -static char * OP_UMULL(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "UMULL%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_UMLAL(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "UMLAL%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_UMULL_S(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "UMULL%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_UMLAL_S(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "UMLAL%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -//----------SMUL-------------------------- - -static char * OP_SMULL(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMULL%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_SMLAL(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMLAL%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_SMULL_S(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMULL%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_SMLAL_S(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMLAL%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -//---------------SWP------------------------------ - -static char * OP_SWP(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SWP%s %s, %s, [%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); -return txt;} - -static char * OP_SWPB(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SWPB%s %s, %s, [%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); -return txt;} - -//------------LDRH----------------------------- - -static char * OP_LDRH_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRH_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRH_P_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH%s %s, [%s, %s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRH_M_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH%s %s, [%s, -%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRH_PRE_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRH_PRE_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRH_PRE_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH%s %s, [%s, %s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRH_PRE_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH%s %s, [%s, -%s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRH_POS_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH%s %s, [%s], #%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRH_POS_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH%s %s, [%s], -#%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRH_POS_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH%s %s, [%s], %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRH_POS_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH%s %s, [%s], -%s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -//------------STRH----------------------------- - -static char * OP_STRH_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_STRH_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_STRH_P_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH%s %s, [%s, %s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_STRH_M_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH%s %s, [%s, -%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_STRH_PRE_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_STRH_PRE_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_STRH_PRE_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH%s %s, [%s, %s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_STRH_PRE_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH%s %s, [%s, -%s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_STRH_POS_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH%s %s, [%s], #%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_STRH_POS_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH%s %s, [%s], -#%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_STRH_POS_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH%s %s, [%s], %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_STRH_POS_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH%s %s, [%s], -%s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -//----------------LDRSH-------------------------- - -static char * OP_LDRSH_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRSH_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRSH_P_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH%s %s, [%s, %s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRSH_M_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH%s %s, [%s, -%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRSH_PRE_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRSH_PRE_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRSH_PRE_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH%s %s, [%s, %s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRSH_PRE_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH%s %s, [%s, -%s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRSH_POS_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH%s %s, [%s], #%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRSH_POS_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH%s %s, [%s], -#%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRSH_POS_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH%s %s, [%s], %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRSH_POS_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH%s %s, [%s], -%s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -//----------------------LDRSB---------------------- - -static char * OP_LDRSB_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRSB_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRSB_P_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB%s %s, [%s, %s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRSB_M_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB%s %s, [%s, -%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRSB_PRE_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRSB_PRE_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRSB_PRE_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB%s %s, [%s, %s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRSB_PRE_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB%s %s, [%s, -%s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRSB_POS_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB%s %s, [%s], #%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRSB_POS_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB%s %s, [%s], -#%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); -return txt;} - -static char * OP_LDRSB_POS_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB%s %s, [%s], %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_LDRSB_POS_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB%s %s, [%s], -%s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -//--------------MRS-------------------------------- - -static char * OP_MRS_CPSR(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MRS%s %s, CPSR", Condition[CONDITION(i)], Registre[REG_POS(i,12)]); -return txt;} - -static char * OP_MRS_SPSR(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MRS%s %s, SPSR", Condition[CONDITION(i)], Registre[REG_POS(i,12)]); -return txt;} - -//--------------MSR-------------------------------- - -static char * OP_MSR_CPSR(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MSR%s CPSR_%s, %s", Condition[CONDITION(i)], MSR_FIELD[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_MSR_SPSR(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MSR%s SPSR_%s, %s", Condition[CONDITION(i)], MSR_FIELD[REG_POS(i,16)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_MSR_CPSR_IMM_VAL(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MSR%s CPSR_%s, #%X", Condition[CONDITION(i)], MSR_FIELD[REG_POS(i,16)], (int)ROR((i&0xFF), ((i>>7)&0x1E))); -return txt;} - -static char * OP_MSR_SPSR_IMM_VAL(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MSR%s SPSR_%s, #%X", Condition[CONDITION(i)], MSR_FIELD[REG_POS(i,16)], (int)ROR((i&0xFF), (i>>7)&0x1E)); -return txt;} - -//-----------------BRANCH-------------------------- - -static char * OP_BX(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "BX%s %s", Condition[CONDITION(i)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_BLX_REG(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "BLX%s %s", Condition[CONDITION(i)], Registre[REG_POS(i,0)]); -return txt;} - -static char * OP_B(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "BLX%s %08X", Condition[CONDITION(i)], (int)(adr+(SIGNEXTEND_24(i)<<2)+8)); - return txt;} - sprintf(txt, "B%s %08X", Condition[CONDITION(i)], (int)(adr+(SIGNEXTEND_24(i)<<2)+8)); -return txt;} - -static char * OP_BL(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "BLX%s %08X", Condition[CONDITION(i)], (int)(adr+(SIGNEXTEND_24(i)<<2)+10)); - return txt;} - sprintf(txt, "BL%s %08X", Condition[CONDITION(i)], (int)(adr+(SIGNEXTEND_24(i)<<2)+8)); -return txt;} - -//----------------CLZ------------------------------- - -static char * OP_CLZ(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "CLZ%s %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)]); -return txt;} - - -//--------------------QADD--QSUB------------------------------ - -static char * OP_QADD(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "QADD%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); -return txt;} - -static char * OP_QSUB(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "QSUB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); -return txt;} - -static char * OP_QDADD(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "QDADD%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); -return txt;} - -static char * OP_QDSUB(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "QDSUB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); -return txt;} - -//-----------------SMUL------------------------------- - -static char * OP_SMUL_B_B(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMULBB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_SMUL_B_T(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMULBT%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_SMUL_T_B(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMULTB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_SMUL_T_T(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMULTT%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -//-----------SMLA---------------------------- - -static char * OP_SMLA_B_B(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMLABB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); -return txt;} - -static char * OP_SMLA_B_T(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMLABT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); -return txt;} - -static char * OP_SMLA_T_B(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMLATB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); -return txt;} - -static char * OP_SMLA_T_T(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMLATT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); -return txt;} - -//--------------SMLAL--------------------------------------- - -static char * OP_SMLAL_B_B(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMLABB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_SMLAL_B_T(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMLABT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_SMLAL_T_B(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMLATB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_SMLAL_T_T(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMLATT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -//--------------SMULW-------------------- - -static char * OP_SMULW_B(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMULWB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -static char * OP_SMULW_T(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMULWT%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); -return txt;} - -//--------------SMLAW------------------- -static char * OP_SMLAW_B(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMLAWB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); -return txt;} - -static char * OP_SMLAW_T(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SMLAWT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); -return txt;} - -//------------LDR--------------------------- - -static char * OP_LDR_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - if(REG_POS(i,16) == 15) - sprintf(txt, "LDR%s %s, [%08X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], (adr + 8 + (int)(i&0x7FF))); - else - sprintf(txt, "LDR%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDR_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - if(REG_POS(i,16) == 15) - sprintf(txt, "LDR%s %s, [%08X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], (adr + 8 - (int)(i&0x7FF))); - else - sprintf(txt, "LDR%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDR_P_LSL_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDR, "", "", "]"); -return txt;} - -static char * OP_LDR_M_LSL_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDR, "-", "", "]"); -return txt;} - -static char * OP_LDR_P_LSR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDR, LSR, "", "", "]"); -return txt;} - -static char * OP_LDR_M_LSR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDR, LSR, "M", "", "]"); -return txt;} - -static char * OP_LDR_P_ASR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDR, ASR, "", "", "]"); -return txt;} - -static char * OP_LDR_M_ASR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDR, ASR, "-", "", "]"); -return txt;} - -static char * OP_LDR_P_ROR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDR, "", "", "]"); -return txt;} - -static char * OP_LDR_M_ROR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDR, "-", "", "]"); -return txt;} - -static char * OP_LDR_P_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDR%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDR_M_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDR%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDR_P_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDR, "", "", "]!"); -return txt;} - -static char * OP_LDR_M_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDR, "-", "", "]!"); -return txt;} - -static char * OP_LDR_P_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDR, LSR, "", "", "]!"); -return txt;} - -static char * OP_LDR_M_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDR, LSR, "-", "", "]!"); -return txt;} - -static char * OP_LDR_P_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDR, ASR, "", "", "]!"); -return txt;} - -static char * OP_LDR_M_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDR, ASR, "-", "", "]!"); -return txt;} - -static char * OP_LDR_P_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDR, "", "", "]!"); -return txt;} - -static char * OP_LDR_M_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDR, "-", "", "]!"); -return txt;} - -static char * OP_LDR_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDR%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDR_P_IMM_OFF_POSTIND2(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDR%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDR_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDR%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDR_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDR, "", "]", ""); -return txt;} - -static char * OP_LDR_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDR, "-", "]", ""); -return txt;} - -static char * OP_LDR_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDR, LSR, "", "]", ""); -return txt;} - -static char * OP_LDR_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDR, LSR, "-", "]", ""); -return txt;} - -static char * OP_LDR_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDR, ASR, "", "]", ""); -return txt;} - -static char * OP_LDR_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDR, ASR, "-", "]", ""); -return txt;} - -static char * OP_LDR_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDR, "", "]", ""); -return txt;} - -static char * OP_LDR_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDR, "-", "]", ""); -return txt;} - -//-----------------LDRB------------------------------------------- - -static char * OP_LDRB_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRB%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDRB_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRB%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDRB_P_LSL_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDRB, "", "", "]"); -return txt;} - -static char * OP_LDRB_M_LSL_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDRB, "-", "", "]"); -return txt;} - -static char * OP_LDRB_P_LSR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRB, LSR, "", "", "]"); -return txt;} - -static char * OP_LDRB_M_LSR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRB, LSR, "M", "", "]"); -return txt;} - -static char * OP_LDRB_P_ASR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRB, ASR, "", "", "]"); -return txt;} - -static char * OP_LDRB_M_ASR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRB, ASR, "-", "", "]"); -return txt;} - -static char * OP_LDRB_P_ROR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDRB, "", "", "]"); -return txt;} - -static char * OP_LDRB_M_ROR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDRB, "-", "", "]"); -return txt;} - -static char * OP_LDRB_P_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRB%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDRB_M_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRB%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDRB_P_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDRB, "", "", "]!"); -return txt;} - -static char * OP_LDRB_M_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDRB, "-", "", "]!"); -return txt;} - -static char * OP_LDRB_P_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRB, LSR, "", "", "]!"); -return txt;} - -static char * OP_LDRB_M_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRB, LSR, "-", "", "]!"); -return txt;} - -static char * OP_LDRB_P_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRB, ASR, "", "", "]!"); -return txt;} - -static char * OP_LDRB_M_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRB, ASR, "-", "", "]!"); -return txt;} - -static char * OP_LDRB_P_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDRB, "", "", "]!"); -return txt;} - -static char * OP_LDRB_M_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDRB, "-", "", "]!"); -return txt;} - -static char * OP_LDRB_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRB%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDRB_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRB%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDRB_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDRB, "", "]", ""); -return txt;} - -static char * OP_LDRB_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDRB, "-", "]", ""); -return txt;} - -static char * OP_LDRB_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRB, LSR, "", "]", ""); -return txt;} - -static char * OP_LDRB_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRB, LSR, "-", "]", ""); -return txt;} - -static char * OP_LDRB_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRB, ASR, "", "]", ""); -return txt;} - -static char * OP_LDRB_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRB, ASR, "-", "]", ""); -return txt;} - -static char * OP_LDRB_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDRB, "", "]", ""); -return txt;} - -static char * OP_LDRB_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDRB, "-", "]", ""); -return txt;} - -//----------------------STR-------------------------------- - -static char * OP_STR_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STR%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STR_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STR%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STR_P_LSL_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STR, "", "", "]"); -return txt;} - -static char * OP_STR_M_LSL_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STR, "-", "", "]"); -return txt;} - -static char * OP_STR_P_LSR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STR, LSR, "", "", "]"); -return txt;} - -static char * OP_STR_M_LSR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STR, LSR, "M", "", "]"); -return txt;} - -static char * OP_STR_P_ASR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STR, ASR, "", "", "]"); -return txt;} - -static char * OP_STR_M_ASR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STR, ASR, "-", "", "]"); -return txt;} - -static char * OP_STR_P_ROR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STR, "", "", "]"); -return txt;} - -static char * OP_STR_M_ROR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STR, "-", "", "]"); -return txt;} - -static char * OP_STR_P_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STR%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STR_M_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STR%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STR_P_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STR, "", "", "]!"); -return txt;} - -static char * OP_STR_M_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STR, "-", "", "]!"); -return txt;} - -static char * OP_STR_P_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STR, LSR, "", "", "]!"); -return txt;} - -static char * OP_STR_M_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STR, LSR, "-", "", "]!"); -return txt;} - -static char * OP_STR_P_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STR, ASR, "", "", "]!"); -return txt;} - -static char * OP_STR_M_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STR, ASR, "-", "", "]!"); -return txt;} - -static char * OP_STR_P_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STR, "", "", "]!"); -return txt;} - -static char * OP_STR_M_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STR, "-", "", "]!"); -return txt;} - -static char * OP_STR_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STR%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STR_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STR%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STR_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STR, "", "]", ""); -return txt;} - -static char * OP_STR_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STR, "-", "]", ""); -return txt;} - -static char * OP_STR_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STR, LSR, "", "]", ""); -return txt;} - -static char * OP_STR_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STR, LSR, "-", "]", ""); -return txt;} - -static char * OP_STR_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STR, ASR, "", "]", ""); -return txt;} - -static char * OP_STR_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STR, ASR, "-", "]", ""); -return txt;} - -static char * OP_STR_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STR, "", "]", ""); -return txt;} - -static char * OP_STR_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STR, "-", "]", ""); -return txt;} - -//-----------------------STRB------------------------------------- - -static char * OP_STRB_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRB%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STRB_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRB%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STRB_P_LSL_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STRB, "", "", "]"); -return txt;} - -static char * OP_STRB_M_LSL_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STRB, "-", "", "]"); -return txt;} - -static char * OP_STRB_P_LSR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRB, LSR, "", "", "]"); -return txt;} - -static char * OP_STRB_M_LSR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRB, LSR, "M", "", "]"); -return txt;} - -static char * OP_STRB_P_ASR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRB, ASR, "", "", "]"); -return txt;} - -static char * OP_STRB_M_ASR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRB, ASR, "-", "", "]"); -return txt;} - -static char * OP_STRB_P_ROR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STRB, "", "", "]"); -return txt;} - -static char * OP_STRB_M_ROR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STRB, "-", "", "]"); -return txt;} - -static char * OP_STRB_P_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRB%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STRB_M_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRB%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STRB_P_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STRB, "", "", "]!"); -return txt;} - -static char * OP_STRB_M_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STRB, "-", "", "]!"); -return txt;} - -static char * OP_STRB_P_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRB, LSR, "", "", "]!"); -return txt;} - -static char * OP_STRB_M_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRB, LSR, "-", "", "]!"); -return txt;} - -static char * OP_STRB_P_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRB, ASR, "", "", "]!"); -return txt;} - -static char * OP_STRB_M_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRB, ASR, "-", "", "]!"); -return txt;} - -static char * OP_STRB_P_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STRB, "", "", "]!"); -return txt;} - -static char * OP_STRB_M_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STRB, "-", "", "]!"); -return txt;} - -static char * OP_STRB_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRB%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STRB_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRB%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STRB_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STRB, "", "]", ""); -return txt;} - -static char * OP_STRB_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STRB, "-", "]", ""); -return txt;} - -static char * OP_STRB_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRB, LSR, "", "]", ""); -return txt;} - -static char * OP_STRB_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRB, LSR, "-", "]", ""); -return txt;} - -static char * OP_STRB_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRB, ASR, "", "]", ""); -return txt;} - -static char * OP_STRB_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRB, ASR, "-", "]", ""); -return txt;} - -static char * OP_STRB_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STRB, "", "]", ""); -return txt;} - -static char * OP_STRB_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STRB, "-", "]", ""); -return txt;} - -//-----------------------LDRBT------------------------------------- - -static char * OP_LDRBT_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRBT%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDRBT_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRBT%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_LDRBT_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDRBT, "", "]", ""); -return txt;} - -static char * OP_LDRBT_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(LDRBT, "-", "]", ""); -return txt;} - -static char * OP_LDRBT_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRBT, LSR, "", "]", ""); -return txt;} - -static char * OP_LDRBT_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRBT, LSR, "-", "]", ""); -return txt;} - -static char * OP_LDRBT_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRBT, ASR, "", "]", ""); -return txt;} - -static char * OP_LDRBT_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(LDRBT, ASR, "-", "]", ""); -return txt;} - -static char * OP_LDRBT_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDRBT, "", "]", ""); -return txt;} - -static char * OP_LDRBT_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(LDRBT, "-", "]", ""); -return txt;} - -//----------------------STRBT---------------------------- - -static char * OP_STRBT_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRBT%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STRBT_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRBT%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); -return txt;} - -static char * OP_STRBT_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STRBT, "", "]", ""); -return txt;} - -static char * OP_STRBT_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_LSL_IMM(STRBT, "-", "]", ""); -return txt;} - -static char * OP_STRBT_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRBT, LSR, "", "]", ""); -return txt;} - -static char * OP_STRBT_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRBT, LSR, "-", "]", ""); -return txt;} - -static char * OP_STRBT_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRBT, ASR, "", "]", ""); -return txt;} - -static char * OP_STRBT_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_IMM_SHIFT(STRBT, ASR, "-", "]", ""); -return txt;} - -static char * OP_STRBT_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STRBT, "", "]", ""); -return txt;} - -static char * OP_STRBT_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) -{ - LDRSTR_ROR_IMM(STRBT, "-", "]", ""); -return txt;} - -//---------------------LDM----------------------------- - -static char * OP_LDMIA(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMIA%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_LDMIB(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMIB%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_LDMDA(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMDA%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_LDMDB(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMDB%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_LDMIA_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMIA%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_LDMIB_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMIB%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_LDMDA_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMDA%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_LDMDB_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMDB%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_LDMIA2(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMIA%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_LDMIB2(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMIB%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_LDMDA2(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMDA%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_LDMDB2(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMDB%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_LDMIA2_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMIA%s %s!, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); - if(BIT15(i)==0) sprintf(txt, "%s ?????", txt); -return txt;} - -static char * OP_LDMIB2_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMIB%s %s!, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); - if(BIT15(i)==0) sprintf(txt, "%s ?????", txt); -return txt;} - -static char * OP_LDMDA2_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMDA%s %s!, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); - if(BIT15(i)==0) sprintf(txt, "%s ?????", txt); -return txt;} - -static char * OP_LDMDB2_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "LDMDB%s %s!, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); - if(BIT15(i)==0) sprintf(txt, "%s ?????", txt); -return txt;} - -//------------------------------STM---------------------------------- - -static char * OP_STMIA(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMIA%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMIB(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMIB%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMDA(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMDA%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMDB(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMDB%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMIA_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMIA%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMIB_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMIB%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMDA_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMDA%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMDB_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMDB%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMIA2(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMIA%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMIB2(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMIB%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMDA2(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMDA%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMDB2(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMDB%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMIA2_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMIA%s %s!, {%s}^ ?????", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMIB2_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMIB%s %s!, {%s}^ ?????", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); -return txt;} - -static char * OP_STMDA2_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMDA%s %s!, {%s}^ ?????", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); - return txt; -} - -static char * OP_STMDB2_W(u32 adr, u32 i, char * txt) -{ - RegList(16); - sprintf(txt, "STMDB%s %s!, {%s}^ ?????", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); - return txt; -} - -//---------------------STC---------------------------------- - -static char * OP_STC_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "STC2 CP%X, CR%X, [%s, #%X]", (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)],(int)((i&0xFF)<<2)); - return txt; - } - sprintf(txt, "STC%s %X, CP%X, [%s, #%X]",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)],(int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_STC_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "STC2 CP%X, CR%X, [%s, #-%X]",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)],(int)((i&0xFF)<<2)); - return txt; - } - sprintf(txt, "STC%s CP%X, CR%X, [%s, #-%X]",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_STC_P_PREIND(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "STC2 CP%X, CR%X, [%s, #%X]!",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; - } - sprintf(txt, "STC%s CP%X, CR%X, [%s, #%X]!",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_STC_M_PREIND(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "STC2 CP%X, CR%X, [%s, #-%X]!",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; - } - sprintf(txt, "STC%s CP%X, CR%X, [%s, #-%X]!",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_STC_P_POSTIND(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "STC2 CP%X, CR%X, [%s], #%X",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; - } - sprintf(txt, "STC%s CP%X, CR%X, [%s], #%X",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_STC_M_POSTIND(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "STC2 CP%X, CR%X, [%s], #-%X",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; - } - sprintf(txt, "STC%s CP%X, CR%X, [%s], #-%X",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_STC_OPTION(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "STC2 CP%X, CR%X, [%s], {%X}",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)(i&0xFF)); - return txt; - } - sprintf(txt, "STC%s CP%X, CR%X, [%s], {%X}",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)(i&0xFF)); - return txt; -} - -//---------------------LDC---------------------------------- - -static char * OP_LDC_P_IMM_OFF(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "LDC2 CP%X, CR%X, [%s, #%X]",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; - } - sprintf(txt, "LDC%s CP%X, CR%X, [%s, #%X]",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_LDC_M_IMM_OFF(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "LDC2 CP%X, CR%X, [%s, #-%X]",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; - } - sprintf(txt, "LDC%s CP%X, CR%X, [%s, #-%X]",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_LDC_P_PREIND(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "LDC2 CP%X, CR%X, [%s, #%X]!",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; - } - sprintf(txt, "LDC%s CP%X, CR%X, [%s, #%X]!",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_LDC_M_PREIND(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "LDC2 CP%X, CR%X, [%s, #-%X]!",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; - } - sprintf(txt, "LDC%s CP%X, CR%X, [%s, #-%X]!",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_LDC_P_POSTIND(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "LDC2 CP%X, CR%X, [%s], #%X",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; - } - sprintf(txt, "LDC%s CP%X, CR%X, [%s], #%X",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_LDC_M_POSTIND(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "LDC2 CP%X, CR%X, [%s], #-%X", (int)REG_POS(i, 8), (int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; - } - sprintf(txt, "LDC%s CP%X, CR%X, [%s], #-%X",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_LDC_OPTION(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "LDC2 CP%X, CR%X, [%s], {%X}", (int)REG_POS(i, 8), (int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)(i&0xFF)); - return txt; - } - sprintf(txt, "LDC%s CP%X, CR%X, [%s], {%X}",Condition[CONDITION(i)], (int)REG_POS(i, 8), (int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)(i&0xFF)); - return txt; -} - - -/* - * - * The Enhanced DSP Extension LDRD and STRD instructions. - * - */ -static char * -OP_LDRD_STRD_POST_INDEX(u32 adr, u32 i, char * txt) { - const char *direction = - BIT5(i) ? "STR" : "LDR"; - /* U bit - set = add, clear = sub */ - char sign = BIT23(i) ? '+' : '-'; - int txt_index = 0; - - txt_index += sprintf( &txt[txt_index], "%s%sD R%d, [R%d], ", - direction, Condition[CONDITION(i)], - (int)REG_POS(i, 12), - (int)REG_POS(i, 16)); - - /* I bit - set = immediate, clear = reg */ - if ( BIT22(i)) { - sprintf( &txt[txt_index], "#%c%d", - sign, (int)(((i>>4) & 0xF0) | (i&0xF)) ); - } - else { - sprintf( &txt[txt_index], "%cR%d", - sign, (int)REG_POS(i, 0)); - } - return txt; -} -static char * -OP_LDRD_STRD_OFFSET_PRE_INDEX(u32 adr, u32 i, char * txt) { - const char *direction = - BIT5(i) ? "STR" : "LDR"; - /* U bit - set = add, clear = sub */ - char sign = BIT23(i) ? '+' : '-'; - int txt_index = 0; - - txt_index += sprintf( &txt[txt_index], "%s%sD R%d, [R%d, ", - direction, Condition[CONDITION(i)], - (int)REG_POS(i, 12), - (int)REG_POS(i, 16)); - - /* I bit - set = immediate, clear = reg */ - if ( BIT22(i)) { - if ( BIT21(i)) { - /* pre-index */ - sprintf( &txt[txt_index], "#%c%d]!", - sign, (int)(((i>>4)&0xF0)|(i&0xF))); - } - else { - /* offset */ - sprintf( &txt[txt_index], "#%c%d]", - sign, (int)(((i>>4)&0xF0)|(i&0xF))); - } - } - else { - if ( BIT21(i)) { - /* pre-index */ - sprintf( &txt[txt_index], "%c%d]!", - sign, (int)REG_POS(i, 0)); - } - else { - /* offset */ - sprintf( &txt[txt_index], "%c%d]", - sign, (int)REG_POS(i, 0)); - } - } - - return txt; -} - - -//----------------MCR----------------------- - -static char * OP_MCR(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "MCR2 CP%d, %X, %s, CR%d, CR%d, %X",(int)REG_POS(i, 8), (int)((i>>21)&7), Registre[REG_POS(i, 12)], (int)REG_POS(i, 16), (int)REG_POS(i, 0), (int)((i>>5)&0x7)); - return txt; - } - sprintf(txt, "MCR%s CP%d, %X, %s, CR%d, CR%d, %X",Condition[CONDITION(i)], (int)REG_POS(i, 8), (int)((i>>21)&7), Registre[REG_POS(i, 12)], (int)REG_POS(i, 16), (int)REG_POS(i, 0), (int)((i>>5)&0x7)); - return txt; -} - -//----------------MRC----------------------- - -static char * OP_MRC(u32 adr, u32 i, char * txt) -{ - if(CONDITION(i)==0xF) - { - sprintf(txt, "MRC2 CP%d, %X, %s, CR%d, CR%d, %X",(int)REG_POS(i, 8), (int)((i>>21)&7), Registre[REG_POS(i, 12)], (int)REG_POS(i, 16), (int)REG_POS(i, 0), (int)((i>>5)&0x7)); - return txt; - } - sprintf(txt, "MRC%s CP%d, %X, %s, CR%d, CR%d, %X",Condition[CONDITION(i)], (int)REG_POS(i, 8), (int)((i>>21)&7), Registre[REG_POS(i, 12)], (int)REG_POS(i, 16), (int)REG_POS(i, 0), (int)((i>>5)&0x7)); - return txt; -} - -//--------------SWI-------------------------- - -static char * OP_SWI(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SWI%s %X",Condition[CONDITION(i)], (int)((i&0xFFFFFF)>>16)); - return txt; -} - -//----------------BKPT------------------------- -static char * OP_BKPT(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "BKPT #%X",(int)(((i>>4)&0xFFF)|(i&0xF))); - return txt; -} - -//----------------CDP----------------------- - -static char * OP_CDP(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "CDP-------------------------------"); - return txt; -} - -//------------------------------------------------------------ -// THUMB -//------------------------------------------------------------ -#define REG_NUM(i, n) (((i)>>n)&0x7) - -static char * OP_UND_THUMB(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "----"); - return txt; -} - -static char * OP_LSL_0(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LSL %s, %s, #0", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_LSL(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LSL %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6) & 0x1F)); - return txt; -} - -static char * OP_LSR_0(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LSR %s, %s, #0", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_LSR(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LSR %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6) & 0x1F)); - return txt; -} - -static char * OP_ASR_0(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "ASR %s, %s, #0", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_ASR(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "ASR %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6) & 0x1F)); - return txt; -} - -static char * OP_ADD_REG(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "ADD %s, %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); - return txt; -} - -static char * OP_SUB_REG(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SUB %s, %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); - return txt; -} - -static char * OP_ADD_IMM3(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "ADD %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)REG_NUM(i, 6)); - return txt; -} - -static char * OP_SUB_IMM3(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SUB %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)REG_NUM(i, 6)); - return txt; -} - -static char * OP_MOV_IMM8(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MOV %s, #%X", Registre[REG_NUM(i, 8)], (int)(i&0xFF)); - return txt; -} - -static char * OP_CMP_IMM8(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "CMP %s, #%X", Registre[REG_NUM(i, 8)], (int)(i&0xFF)); - return txt; -} - -static char * OP_ADD_IMM8(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "ADD %s, #%X", Registre[REG_NUM(i, 8)], (int)(i&0xFF)); - return txt; -} - -static char * OP_SUB_IMM8(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SUB %s, #%X", Registre[REG_NUM(i, 8)], (int)(i&0xFF)); - return txt; -} - -static char * OP_AND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "AND %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_EOR(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "EOR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_LSL_REG(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LSL %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_LSR_REG(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LSR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_ASR_REG(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "ASR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_ADC_REG(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "ADC %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_SBC_REG(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SBC %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_ROR_REG(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "ROR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_TST(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "TST %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_NEG(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "NEG %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_CMP(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "CMP %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_CMN(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "CMN %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_ORR(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "ORR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_MUL_REG(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MUL %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_BIC(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "BIC %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_MVN(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "MVN %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); - return txt; -} - -static char * OP_ADD_SPE(u32 adr, u32 i, char * txt) -{ - u8 Rd = (i&7) | ((i>>4)&8); - sprintf(txt, "ADD %s, %s", Registre[Rd], Registre[REG_POS(i, 3)]); - return txt; -} - -static char * OP_CMP_SPE(u32 adr, u32 i, char * txt) -{ - u8 Rd = (i&7) | ((i>>4)&8); - sprintf(txt, "CMP %s, %s", Registre[Rd], Registre[REG_POS(i, 3)]); - return txt; -} - -static char * OP_MOV_SPE(u32 adr, u32 i, char * txt) -{ - u8 Rd = (i&7) | ((i>>4)&8); - sprintf(txt, "MOV %s, %s", Registre[Rd], Registre[REG_POS(i, 3)]); - return txt; -} - -static char * OP_BX_THUMB(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "BX %s", Registre[REG_POS(i, 3)]); - return txt; -} - -static char * OP_BLX_THUMB(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "BLX %s", Registre[REG_POS(i, 3)]); - return txt; -} - -static char * OP_LDR_PCREL(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDR %s, [PC, #%X]", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_STR_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STR %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); - return txt; -} - -static char * OP_STRH_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); - return txt; -} - -static char * OP_STRB_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRB %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); - return txt; -} - -static char * OP_LDRSB_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSB %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); - return txt; -} - -static char * OP_LDR_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDR %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); - return txt; -} - -static char * OP_LDRH_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); - return txt; -} - -static char * OP_LDRB_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRB %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); - return txt; -} - -static char * OP_LDRSH_REG_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRSH %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); - return txt; -} - -static char * OP_STR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STR %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>4)&0x7C)); - return txt; -} - -static char * OP_LDR_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDR %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>4)&0x7C)); - return txt; -} - -static char * OP_STRB_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRB %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6)&0x1F)); - return txt; -} - -static char * OP_LDRB_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRB %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6)&0x1F)); - return txt; -} - -static char * OP_STRH_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STRH %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>5)&0x3E)); - return txt; -} - -static char * OP_LDRH_IMM_OFF(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDRH %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>5)&0x3E)); - return txt; -} - -static char * OP_STR_SPREL(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "STR %s, [SP, #%X]", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_LDR_SPREL(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "LDR %s, [SP, #%X]", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_ADD_2PC(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "ADD %s, PC, #%X", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_ADD_2SP(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "ADD %s, SP, #%X", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); - return txt; -} - -static char * OP_ADJUST_P_SP(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "ADD SP, #%X", (int)((i&0x7F)<<2)); - return txt; -} - -static char * OP_ADJUST_M_SP(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SUB SP, #%X", (int)((i&0x7F)<<2)); - return txt; -} - -static char * OP_PUSH(u32 adr, u32 i, char * txt) -{ - RegList(8); - sprintf(txt, "PUSH {%s}", lreg); - return txt; -} - -static char * OP_PUSH_LR(u32 adr, u32 i, char * txt) -{ - RegList(8); - sprintf(txt, "PUSH {%s, LR}", lreg); - return txt; -} - -static char * OP_POP(u32 adr, u32 i, char * txt) -{ - RegList(8); - sprintf(txt, "POP {%s}", lreg); - return txt; -} - -static char * OP_POP_PC(u32 adr, u32 i, char * txt) -{ - RegList(8); - sprintf(txt, "POP {%s, PC}", lreg); - return txt; -} - -static char * OP_BKPT_THUMB(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "BKPT"); - return txt; -} - -static char * OP_STMIA_THUMB(u32 adr, u32 i, char * txt) -{ - RegList(8); - sprintf(txt, "STMIA %s!, {%s}", Registre[REG_NUM(i, 8)], lreg); - return txt; -} - -static char * OP_LDMIA_THUMB(u32 adr, u32 i, char * txt) -{ - RegList(8); - sprintf(txt, "LDMIA %s!, {%s}", Registre[REG_NUM(i, 8)], lreg); - return txt; -} - -static char * OP_B_COND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "B%s #%X", Condition[(i>>8)&0xF], (int)(adr+(((s32)((signed char)(i&0xFF)))<<1)+4)); - return txt; -} - -static char * OP_SWI_THUMB(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "SWI #%X", (int)(i & 0xFF)); - return txt; -} - -#define SIGNEEXT_IMM11(i) (((i)&0x7FF) | (BIT10(i) * 0xFFFFF800)) - -static char * OP_B_UNCOND(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "B #%X", (int)(adr+(SIGNEEXT_IMM11(i)<<1)+4)); - return txt; -} - -u32 part = 0; - -static char * OP_BLX(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "BLX #%X", (int)(part + ((i&0x7FF)<<1))&0xFFFFFFFC); - return txt; -} - -static char * OP_BL_10(u32 adr, u32 i, char * txt) -{ - part = adr+4 + (SIGNEEXT_IMM11(i)<<12); - sprintf(txt, "calculating high part of the address"); - return txt; - -} - -static char * OP_BL_THUMB(u32 adr, u32 i, char * txt) -{ - sprintf(txt, "BL #%X", (int)(part + ((i&0x7FF)<<1))&0xFFFFFFFC); - return txt; -} - -#define TYPE_RETOUR char * -#define PARAMETRES u32 adr, u32 i, char * txt -#define CALLTYPE -#define NOM_TAB des_arm_instructions_set -#define NOM_THUMB_TAB des_thumb_instructions_set -#define TABDECL(x) x - -#include "instruction_tabdef.inc" -#include "thumb_tabdef.inc" - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include "Disassembler.h" +#include "bits.h" + +#define ROR(i, j) ((((u32)(i))>>(j)) | (((u32)(i))<<(32-(j)))) + +const char Condition[16][3] = { + "EQ", + "NE", + "CS", + "CC", + "MI", + "PL", + "VS", + "VC", + "HI", + "LS", + "GE", + "LT", + "GT", + "LE", + "", + "" + }; + +const char Registre[16][4] = { + "R0", + "R1", + "R2", + "R3", + "R4", + "R5", + "R6", + "R7", + "R8", + "R9", + "R10", + "R11", + "R12", + "SP", + "LR", + "PC", + }; + +const char MSR_FIELD[16][5] = { + "", + "c", + "x", + "xc", + "s", + "sc", + "sx", + "sxc", + "f", + "fc", + "fx", + "fxc", + "fs", + "fsc", + "fsx", + "fsxc" + }; + +#define DATAPROC_LSL_IMM(nom, s) char tmp[10] = "";\ + if(((i>>7)&0x1F)!=0)\ + sprintf(tmp, ", LSL #%X", (int)((i>>7)&0x1F));\ + sprintf(txt, "%s%s%s %s, %s, %s%s",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + Registre[REG_POS(i,0)],\ + tmp); +#define DATAPROC_ROR_IMM(nom, s) char tmp[10] = "";\ + if(((i>>7)&0x1F)!=0)\ + sprintf(tmp, ", RRX");\ + sprintf(txt, "%s%s%s %s, %s, %s%s",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + Registre[REG_POS(i,0)],\ + tmp\ + ); + +#define DATAPROC_REG_SHIFT(nom, shift,s) sprintf(txt, "%s%s%s %s, %s, %s, %s %s",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + Registre[REG_POS(i,0)],\ + #shift,\ + Registre[REG_POS(i,8)]\ + ); + +#define DATAPROC_IMM_SHIFT(nom, shift, s) sprintf(txt, "%s%s%s %s, %s, %s, %s #%X",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + Registre[REG_POS(i,0)],\ + #shift,\ + (int)((i>>7)&0x1F)\ + ); + +#define DATAPROC_IMM_VALUE(nom,s) u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E);\ + sprintf(txt, "%s%s%s %s, %s, #%X",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + (int)shift_op\ + ); + +#define DATAPROC_ONE_OP_LSL_IMM(nom, s, v) char tmp[10] = "";\ + if(((i>>7)&0x1F)!=0)\ + sprintf(tmp, ", LSL #%X", (int)((i>>7)&0x1F));\ + sprintf(txt, "%s%s%s %s, %s%s",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,v)],\ + Registre[REG_POS(i,0)],\ + tmp); + +#define DATAPROC_ONE_OP_ROR_IMM(nom, s, v) char tmp[10] = "";\ + if(((i>>7)&0x1F)==0)\ + sprintf(tmp, ", RRX");\ + else\ + sprintf(tmp, ", ROR %d", (int)((i>>7)&0x1F));\ + sprintf(txt, "%s%s%s %s, %s%s",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,v)],\ + Registre[REG_POS(i,0)],\ + tmp\ + ); + +#define DATAPROC_ONE_OP_REG_SHIFT(nom, shift,s, v) sprintf(txt, "%s%s%s %s, %s, %s %s",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,v)],\ + Registre[REG_POS(i,0)],\ + #shift,\ + Registre[REG_POS(i,8)]\ + ); + +#define DATAPROC_ONE_OP_IMM_SHIFT(nom, shift, s, v) sprintf(txt, "%s%s%s %s, %s, %s #%X",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,v)],\ + Registre[REG_POS(i,0)],\ + #shift,\ + (int)((i>>7)&0x1F)\ + ); + +#define DATAPROC_ONE_OP_IMM_VALUE(nom, s, v)\ + u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E);\ + sprintf(txt, "%s%s%s %s, #%X",\ + #nom,\ + Condition[CONDITION(i)],\ + s,\ + Registre[REG_POS(i,v)],\ + (int)shift_op\ + ); + +#define SIGNEXTEND_24(i) (((i)&0xFFFFFF)|(0xFF000000*BIT23(i))) + +#define LDRSTR_LSL_IMM(nom, op, op2, op3) char tmp[10] = "";\ + if(((i>>7)&0x1F)!=0)\ + sprintf(tmp, ", LSL #%X", (int)((i>>7)&0x1F));\ + sprintf(txt, "%s%s %s, [%s%s, %s%s%s%s",\ + #nom,\ + Condition[CONDITION(i)],\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + op2,\ + op,\ + Registre[REG_POS(i,0)],\ + tmp,\ + op3); +#define LDRSTR_ROR_IMM(nom, op, op2, op3) char tmp[10] = "";\ + if(((i>>7)&0x1F)!=0)\ + sprintf(tmp, ", RRX");\ + sprintf(txt, "%s%s %s, [%s%s, %s%s%s%s",\ + #nom,\ + Condition[CONDITION(i)],\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + op2,\ + op,\ + Registre[REG_POS(i,0)],\ + tmp,\ + op3\ + ); + +#define LDRSTR_IMM_SHIFT(nom, shift, op, op2, op3)\ + sprintf(txt, "%s%s %s, [%s%s, %s%s, %s #%X%s",\ + #nom,\ + Condition[CONDITION(i)],\ + Registre[REG_POS(i,12)],\ + Registre[REG_POS(i,16)],\ + op2,\ + op,\ + Registre[REG_POS(i,0)],\ + #shift,\ + (int)((i>>7)&0x1F),\ + op3\ + ); + +#define RegList(nb) char lreg[100] = "";\ + int prec = 0;\ + int j;\ + for(j = 0; j < nb; j++)\ + {\ + if(prec)\ + {\ + if((!BIT_N(i, j+1))||(j==nb-1))\ + {\ + sprintf(lreg + strlen(lreg), "%s,", Registre[j]);\ + prec = 0;\ + }\ + }\ + else\ + {\ + if(BIT_N(i, j))\ + {\ + if((BIT_N(i, j+1))&&(j!=nb-1))\ + {\ + sprintf(lreg + strlen(lreg), "%s-", Registre[j]);\ + prec = 1;\ + }\ + else\ + sprintf(lreg + strlen(lreg), "%s,", Registre[j]);\ + }\ + }\ + }\ + lreg[strlen(lreg)-1]='\0'; + +static char * OP_UND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "----"); + return txt; +} + +//-----------------------AND------------------------------------ +static char * OP_AND_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(AND, ""); + return txt; +} + +static char * OP_AND_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, LSL, ""); + return txt; +} + +static char * OP_AND_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(AND, LSR, ""); + return txt; +} + +static char * OP_AND_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, LSR, ""); + return txt; +} + +static char * OP_AND_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(AND, ASR, ""); + return txt; +} + +static char * OP_AND_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, ASR, ""); + return txt; +} + +static char * OP_AND_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(AND, ""); + return txt; +} + +static char * OP_AND_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, ROR, ""); + return txt; +} + +static char * OP_AND_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(AND, ""); + return txt; +} + +static char * OP_AND_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(AND, "S"); + return txt; +} + +static char * OP_AND_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, LSL, "S"); + return txt; +} + +static char * OP_AND_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(AND, LSR, "S"); + return txt; +} + +static char * OP_AND_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, LSR, "S"); + return txt; +} + +static char * OP_AND_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(AND, ASR, "S"); + return txt; +} + +static char * OP_AND_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, ASR, "S"); + return txt; +} + +static char * OP_AND_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(AND, "S"); + return txt; +} + +static char * OP_AND_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(AND, ROR, "S"); + return txt; +} + +static char * OP_AND_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(AND, "S"); + return txt; +} + +//--------------EOR------------------------------ +static char * OP_EOR_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(EOR, ""); + return txt; +} + +static char * OP_EOR_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, LSL, ""); + return txt; +} + +static char * OP_EOR_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(EOR, LSR, ""); + return txt; +} + +static char * OP_EOR_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, LSR, ""); + return txt; +} + +static char * OP_EOR_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(EOR, ASR, ""); + return txt; +} + +static char * OP_EOR_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, ASR, ""); + return txt; +} + +static char * OP_EOR_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(EOR, ""); + return txt; +} + +static char * OP_EOR_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, ROR, ""); + return txt; +} + +static char * OP_EOR_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(EOR, ""); + return txt; +} + +static char * OP_EOR_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(EOR, "S"); + return txt; +} + +static char * OP_EOR_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, LSL, "S"); + return txt; +} + +static char * OP_EOR_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(EOR, LSR, "S"); + return txt; +} + +static char * OP_EOR_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, LSR, "S"); + return txt; +} + +static char * OP_EOR_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(EOR, ASR, "S"); + return txt; +} + +static char * OP_EOR_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, ASR, "S"); + return txt; +} + +static char * OP_EOR_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(EOR, "S"); + return txt; +} + +static char * OP_EOR_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(EOR, ROR, "S"); + return txt; +} + +static char * OP_EOR_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(EOR, "S"); + return txt; +} + +//-------------SUB------------------------------------- + +static char * OP_SUB_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(SUB, ""); + return txt; +} + +static char * OP_SUB_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, LSL, ""); + return txt; +} + +static char * OP_SUB_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SUB, LSR, ""); + return txt; +} + +static char * OP_SUB_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, LSR, ""); + return txt; +} + +static char * OP_SUB_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SUB, ASR, ""); + return txt; +} + +static char * OP_SUB_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, ASR, ""); +return txt;} + +static char * OP_SUB_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(SUB, ""); +return txt;} + +static char * OP_SUB_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, ROR, ""); +return txt;} + +static char * OP_SUB_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(SUB, ""); +return txt;} + +static char * OP_SUB_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(SUB, "S"); +return txt;} + +static char * OP_SUB_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, LSL, "S"); +return txt;} + +static char * OP_SUB_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SUB, LSR, "S"); +return txt;} + +static char * OP_SUB_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, LSR, "S"); +return txt;} + +static char * OP_SUB_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SUB, ASR, "S"); +return txt;} + +static char * OP_SUB_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, ASR, "S"); +return txt;} + +static char * OP_SUB_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(SUB, "S"); +return txt;} + +static char * OP_SUB_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SUB, ROR, "S"); +return txt;} + +static char * OP_SUB_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(SUB, "S"); +return txt;} + +//------------------RSB------------------------ + +static char * OP_RSB_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(RSB, ""); +return txt;} + +static char * OP_RSB_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, LSL, ""); +return txt;} + +static char * OP_RSB_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSB, LSR, ""); +return txt;} + +static char * OP_RSB_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, LSR, ""); +return txt;} + +static char * OP_RSB_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSB, ASR, ""); +return txt;} + +static char * OP_RSB_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, ASR, ""); +return txt;} + +static char * OP_RSB_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(RSB, ""); +return txt;} + +static char * OP_RSB_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, ROR, ""); +return txt;} + +static char * OP_RSB_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(RSB, ""); +return txt;} + +static char * OP_RSB_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(RSB, "S"); +return txt;} + +static char * OP_RSB_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, LSL, "S"); +return txt;} + +static char * OP_RSB_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSB, LSR, "S"); +return txt;} + +static char * OP_RSB_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, LSR, "S"); +return txt;} + +static char * OP_RSB_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSB, ASR, "S"); +return txt;} + +static char * OP_RSB_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, ASR, "S"); +return txt;} + +static char * OP_RSB_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(RSB, "S"); +return txt;} + +static char * OP_RSB_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSB, ROR, "S"); +return txt;} + +static char * OP_RSB_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(RSB, "S"); +return txt;} + +//------------------ADD----------------------------------- + +static char * OP_ADD_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(ADD, ""); +return txt;} + +static char * OP_ADD_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, LSL, ""); +return txt;} + +static char * OP_ADD_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADD, LSR, ""); +return txt;} + +static char * OP_ADD_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, LSR, ""); +return txt;} + +static char * OP_ADD_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADD, ASR, ""); +return txt;} + +static char * OP_ADD_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, ASR, ""); +return txt;} + +static char * OP_ADD_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(ADD, ""); +return txt;} + +static char * OP_ADD_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, ROR, ""); +return txt;} + +static char * OP_ADD_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(ADD, ""); +return txt;} + +static char * OP_ADD_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(ADD, "S"); +return txt;} + +static char * OP_ADD_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, LSL, "S"); +return txt;} + +static char * OP_ADD_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADD, LSR, "S"); +return txt;} + +static char * OP_ADD_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, LSR, "S"); +return txt;} + +static char * OP_ADD_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADD, ASR, "S"); +return txt;} + +static char * OP_ADD_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, ASR, "S"); +return txt;} + +static char * OP_ADD_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(ADD, "S"); +return txt;} + +static char * OP_ADD_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADD, ROR, "S"); +return txt;} + +static char * OP_ADD_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(ADD, "S"); +return txt;} + +//------------------ADC----------------------------------- + +static char * OP_ADC_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(ADC, ""); +return txt;} + +static char * OP_ADC_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, LSL, ""); +return txt;} + +static char * OP_ADC_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADC, LSR, ""); +return txt;} + +static char * OP_ADC_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, LSR, ""); +return txt;} + +static char * OP_ADC_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADC, ASR, ""); +return txt;} + +static char * OP_ADC_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, ASR, ""); +return txt;} + +static char * OP_ADC_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(ADC, ""); +return txt;} + +static char * OP_ADC_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, ROR, ""); +return txt;} + +static char * OP_ADC_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(ADC, ""); +return txt;} + +static char * OP_ADC_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(ADC, "S"); +return txt;} + +static char * OP_ADC_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, LSL, "S"); +return txt;} + +static char * OP_ADC_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADC, LSR, "S"); +return txt;} + +static char * OP_ADC_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, LSR, "S"); +return txt;} + +static char * OP_ADC_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ADC, ASR, "S"); +return txt;} + +static char * OP_ADC_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, ASR, "S"); +return txt;} + +static char * OP_ADC_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(ADC, "S"); +return txt;} + +static char * OP_ADC_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ADC, ROR, "S"); +return txt;} + +static char * OP_ADC_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(ADC, "S"); +return txt;} + +//-------------SBC------------------------------------- + +static char * OP_SBC_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(SBC, ""); +return txt;} + +static char * OP_SBC_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, LSL, ""); +return txt;} + +static char * OP_SBC_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SBC, LSR, ""); +return txt;} + +static char * OP_SBC_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, LSR, ""); +return txt;} + +static char * OP_SBC_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SBC, ASR, ""); +return txt;} + +static char * OP_SBC_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, ASR, ""); +return txt;} + +static char * OP_SBC_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(SBC, ""); +return txt;} + +static char * OP_SBC_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, ROR, ""); +return txt;} + +static char * OP_SBC_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(SBC, ""); +return txt;} + +static char * OP_SBC_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(SBC, "S"); +return txt;} + +static char * OP_SBC_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, LSL, "S"); +return txt;} + +static char * OP_SBC_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SBC, LSR, "S"); +return txt;} + +static char * OP_SBC_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, LSR, "S"); +return txt;} + +static char * OP_SBC_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(SBC, ASR, "S"); +return txt;} + +static char * OP_SBC_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, ASR, "S"); +return txt;} + +static char * OP_SBC_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(SBC, "S"); +return txt;} + +static char * OP_SBC_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(SBC, ROR, "S"); +return txt;} + +static char * OP_SBC_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(SBC, "S"); +return txt;} + +//---------------RSC---------------------------------- + +static char * OP_RSC_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(RSC, ""); +return txt;} + +static char * OP_RSC_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, LSL, ""); +return txt;} + +static char * OP_RSC_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSC, LSR, ""); +return txt;} + +static char * OP_RSC_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, LSR, ""); +return txt;} + +static char * OP_RSC_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSC, ASR, ""); +return txt;} + +static char * OP_RSC_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, ASR, ""); +return txt;} + +static char * OP_RSC_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(RSC, ""); +return txt;} + +static char * OP_RSC_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, ROR, ""); +return txt;} + +static char * OP_RSC_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(RSC, ""); +return txt;} + +static char * OP_RSC_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(RSC, "S"); +return txt;} + +static char * OP_RSC_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, LSL, "S"); +return txt;} + +static char * OP_RSC_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSC, LSR, "S"); +return txt;} + +static char * OP_RSC_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, LSR, "S"); +return txt;} + +static char * OP_RSC_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(RSC, ASR, "S"); +return txt;} + +static char * OP_RSC_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, ASR, "S"); +return txt;} + +static char * OP_RSC_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(RSC, "S"); +return txt;} + +static char * OP_RSC_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(RSC, ROR, "S"); +return txt;} + +static char * OP_RSC_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(RSC, "S"); +return txt;} + +//-------------------TST---------------------------- + +static char * OP_TST_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(TST, "", 16); +return txt;} + +static char * OP_TST_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TST, LSL, "", 16); +return txt;} + +static char * OP_TST_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(TST, LSR, "", 16); +return txt;} + +static char * OP_TST_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TST, LSR, "", 16); +return txt;} + +static char * OP_TST_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(TST, ASR, "", 16); +return txt;} + +static char * OP_TST_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TST, ASR, "", 16); +return txt;} + +static char * OP_TST_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(TST, "", 16); +return txt;} + +static char * OP_TST_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TST, ROR, "", 16); +return txt;} + +static char * OP_TST_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(TST, "", 16); +return txt;} + +//-------------------TEQ---------------------------- + +static char * OP_TEQ_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(TEQ, "", 16); +return txt;} + +static char * OP_TEQ_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TEQ, LSL, "", 16); +return txt;} + +static char * OP_TEQ_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(TEQ, LSR, "", 16); +return txt;} + +static char * OP_TEQ_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TEQ, LSR, "", 16); +return txt;} + +static char * OP_TEQ_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(TEQ, ASR, "", 16); +return txt;} + +static char * OP_TEQ_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TEQ, ASR, "", 16); +return txt;} + +static char * OP_TEQ_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(TEQ, "", 16); +return txt;} + +static char * OP_TEQ_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(TEQ, ROR, "", 16); +return txt;} + +static char * OP_TEQ_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(TEQ, "", 16); +return txt;} + +//-------------CMP------------------------------------- + +static char * OP_CMP_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(CMP, "", 16); +return txt;} + +static char * OP_CMP_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMP, LSL, "", 16); +return txt;} + +static char * OP_CMP_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(CMP, LSR, "", 16); +return txt;} + +static char * OP_CMP_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMP, LSR, "", 16); +return txt;} + +static char * OP_CMP_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(CMP, ASR, "", 16); +return txt;} + +static char * OP_CMP_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMP, ASR, "", 16); +return txt;} + +static char * OP_CMP_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(CMP, "", 16); +return txt;} + +static char * OP_CMP_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMP, ROR, "", 16); +return txt;} + +static char * OP_CMP_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(CMP, "", 16); +return txt;} + +//---------------CMN--------------------------- + +static char * OP_CMN_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(CMN, "", 16); +return txt;} + +static char * OP_CMN_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMN, LSL, "", 16); +return txt;} + +static char * OP_CMN_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(CMP, ASR, "", 16); +return txt;} + +static char * OP_CMN_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMN, LSR, "", 16); +return txt;} + +static char * OP_CMN_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(CMN, ASR, "", 16); +return txt;} + +static char * OP_CMN_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMN, ASR, "", 16); +return txt;} + +static char * OP_CMN_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(CMN, "", 16); +return txt;} + +static char * OP_CMN_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(CMN, ROR, "", 16); +return txt;} + +static char * OP_CMN_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(CMN, "", 16); +return txt;} + +//------------------ORR------------------- + +static char * OP_ORR_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(ORR, ""); +return txt;} + +static char * OP_ORR_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, LSL, ""); +return txt;} + +static char * OP_ORR_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ORR, LSR, ""); +return txt;} + +static char * OP_ORR_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, LSR, ""); +return txt;} + +static char * OP_ORR_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ORR, ASR, ""); +return txt;} + +static char * OP_ORR_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, ASR, ""); +return txt;} + +static char * OP_ORR_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(ORR, ""); +return txt;} + +static char * OP_ORR_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, ROR, ""); +return txt;} + +static char * OP_ORR_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(ORR, ""); +return txt;} + +static char * OP_ORR_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(ORR, "S"); +return txt;} + +static char * OP_ORR_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, LSL, "S"); +return txt;} + +static char * OP_ORR_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ORR, LSR, "S"); +return txt;} + +static char * OP_ORR_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, LSR, "S"); +return txt;} + +static char * OP_ORR_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(ORR, ASR, "S"); +return txt;} + +static char * OP_ORR_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, ASR, "S"); +return txt;} + +static char * OP_ORR_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(ORR, "S"); +return txt;} + +static char * OP_ORR_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(ORR, ROR, "S"); +return txt;} + +static char * OP_ORR_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(ORR, "S"); +return txt;} + +//------------------MOV------------------- + +static char * OP_MOV_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(MOV, "", 12); +return txt;} + +static char * OP_MOV_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, LSL, "", 12); +return txt;} + +static char * OP_MOV_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MOV, LSR, "", 12); +return txt;} + +static char * OP_MOV_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, LSR, "", 12); +return txt;} + +static char * OP_MOV_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MOV, ASR, "", 12); +return txt;} + +static char * OP_MOV_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, ASR, "", 12); +return txt;} + +static char * OP_MOV_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(MOV, "", 12); +return txt;} + +static char * OP_MOV_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, ROR, "", 12); +return txt;} + +static char * OP_MOV_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(MOV, "", 12); +return txt;} + +static char * OP_MOV_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(MOV, "S", 12); +return txt;} + +static char * OP_MOV_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, LSL, "S", 12); +return txt;} + +static char * OP_MOV_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MOV, LSR, "S", 12); +return txt;} + +static char * OP_MOV_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, LSR, "S", 12); +return txt;} + +static char * OP_MOV_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MOV, ASR, "S", 12); +return txt;} + +static char * OP_MOV_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, ASR, "S", 12); +return txt;} + +static char * OP_MOV_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(MOV, "S", 12); +return txt;} + +static char * OP_MOV_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MOV, ROR, "S", 12); +return txt;} + +static char * OP_MOV_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(MOV, "S", 12); +return txt;} + +//------------------BIC------------------- + +static char * OP_BIC_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(BIC, ""); +return txt;} + +static char * OP_BIC_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, LSL, ""); +return txt;} + +static char * OP_BIC_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(BIC, LSR, ""); +return txt;} + +static char * OP_BIC_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, LSR, ""); +return txt;} + +static char * OP_BIC_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(BIC, ASR, ""); +return txt;} + +static char * OP_BIC_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, ASR, ""); +return txt;} + +static char * OP_BIC_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(BIC, ""); +return txt;} + +static char * OP_BIC_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, ROR, ""); +return txt;} + +static char * OP_BIC_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(BIC, ""); +return txt;} + +static char * OP_BIC_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_LSL_IMM(BIC, "S"); +return txt;} + +static char * OP_BIC_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, LSL, "S"); +return txt;} + +static char * OP_BIC_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(BIC, LSR, "S"); +return txt;} + +static char * OP_BIC_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, LSR, "S"); +return txt;} + +static char * OP_BIC_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_SHIFT(BIC, ASR, "S"); +return txt;} + +static char * OP_BIC_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, ASR, "S"); +return txt;} + +static char * OP_BIC_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ROR_IMM(BIC, "S"); +return txt;} + +static char * OP_BIC_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_REG_SHIFT(BIC, ROR, "S"); +return txt;} + +static char * OP_BIC_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_IMM_VALUE(BIC, "S"); +return txt;} + +//------------------MVN------------------- + +static char * OP_MVN_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(MVN, "", 12); +return txt;} + +static char * OP_MVN_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, LSL, "", 12); +return txt;} + +static char * OP_MVN_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MVN, LSR, "", 12); +return txt;} + +static char * OP_MVN_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, LSR, "", 12); +return txt;} + +static char * OP_MVN_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MVN, ASR, "", 12); +return txt;} + +static char * OP_MVN_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, ASR, "", 12); +return txt;} + +static char * OP_MVN_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(MVN, "", 12); +return txt;} + +static char * OP_MVN_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, ROR, "", 12); +return txt;} + +static char * OP_MVN_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(MVN, "", 12); +return txt;} + +static char * OP_MVN_S_LSL_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_LSL_IMM(MVN, "S", 12); +return txt;} + +static char * OP_MVN_S_LSL_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, LSL, "S", 12); +return txt;} + +static char * OP_MVN_S_LSR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MVN, LSR, "S", 12); +return txt;} + +static char * OP_MVN_S_LSR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, LSR, "S", 12); +return txt;} + +static char * OP_MVN_S_ASR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_SHIFT(MOV, ASR, "S", 12); +return txt;} + +static char * OP_MVN_S_ASR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, ASR, "S", 12); +return txt;} + +static char * OP_MVN_S_ROR_IMM(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_ROR_IMM(MVN, "S", 12); +return txt;} + +static char * OP_MVN_S_ROR_REG(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_REG_SHIFT(MVN, ROR, "S", 12); +return txt;} + +static char * OP_MVN_S_IMM_VAL(u32 adr, u32 i, char * txt) +{ + DATAPROC_ONE_OP_IMM_VALUE(MVN, "S", 12); +return txt;} + + +//-------------MUL------------------------ + +static char * OP_MUL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MUL%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_MLA(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MLA%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +static char * OP_MUL_S(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MUL%sS %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_MLA_S(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MLA%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + + +//----------UMUL-------------------------- + +static char * OP_UMULL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "UMULL%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_UMLAL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "UMLAL%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_UMULL_S(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "UMULL%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_UMLAL_S(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "UMLAL%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +//----------SMUL-------------------------- + +static char * OP_SMULL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULL%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMLAL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLAL%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMULL_S(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULL%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMLAL_S(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLAL%sS %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +//---------------SWP------------------------------ + +static char * OP_SWP(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SWP%s %s, %s, [%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); +return txt;} + +static char * OP_SWPB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SWPB%s %s, %s, [%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); +return txt;} + +//------------LDRH----------------------------- + +static char * OP_LDRH_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRH_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRH_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, %s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRH_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, -%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRH_PRE_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRH_PRE_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRH_PRE_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, %s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRH_PRE_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s, -%s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRH_POS_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s], #%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRH_POS_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s], -#%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRH_POS_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s], %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRH_POS_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH%s %s, [%s], -%s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +//------------STRH----------------------------- + +static char * OP_STRH_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_STRH_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_STRH_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, %s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_STRH_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, -%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_STRH_PRE_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_STRH_PRE_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_STRH_PRE_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, %s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_STRH_PRE_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s, -%s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_STRH_POS_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s], #%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_STRH_POS_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s], -#%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_STRH_POS_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s], %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_STRH_POS_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH%s %s, [%s], -%s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +//----------------LDRSH-------------------------- + +static char * OP_LDRSH_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSH_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSH_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, %s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSH_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, -%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSH_PRE_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSH_PRE_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSH_PRE_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, %s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSH_PRE_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s, -%s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSH_POS_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s], #%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSH_POS_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s], -#%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSH_POS_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s], %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSH_POS_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH%s %s, [%s], -%s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +//----------------------LDRSB---------------------- + +static char * OP_LDRSB_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSB_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSB_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, %s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSB_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, -%s]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSB_PRE_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSB_PRE_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSB_PRE_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, %s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSB_PRE_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s, -%s]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSB_POS_INDE_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s], #%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSB_POS_INDE_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s], -#%X", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(((i>>4)&0xF0)|(i&0xF))); +return txt;} + +static char * OP_LDRSB_POS_INDE_P_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s], %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_LDRSB_POS_INDE_M_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB%s %s, [%s], -%s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +//--------------MRS-------------------------------- + +static char * OP_MRS_CPSR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MRS%s %s, CPSR", Condition[CONDITION(i)], Registre[REG_POS(i,12)]); +return txt;} + +static char * OP_MRS_SPSR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MRS%s %s, SPSR", Condition[CONDITION(i)], Registre[REG_POS(i,12)]); +return txt;} + +//--------------MSR-------------------------------- + +static char * OP_MSR_CPSR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MSR%s CPSR_%s, %s", Condition[CONDITION(i)], MSR_FIELD[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_MSR_SPSR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MSR%s SPSR_%s, %s", Condition[CONDITION(i)], MSR_FIELD[REG_POS(i,16)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_MSR_CPSR_IMM_VAL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MSR%s CPSR_%s, #%X", Condition[CONDITION(i)], MSR_FIELD[REG_POS(i,16)], (int)ROR((i&0xFF), ((i>>7)&0x1E))); +return txt;} + +static char * OP_MSR_SPSR_IMM_VAL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MSR%s SPSR_%s, #%X", Condition[CONDITION(i)], MSR_FIELD[REG_POS(i,16)], (int)ROR((i&0xFF), (i>>7)&0x1E)); +return txt;} + +//-----------------BRANCH-------------------------- + +static char * OP_BX(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BX%s %s", Condition[CONDITION(i)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_BLX_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BLX%s %s", Condition[CONDITION(i)], Registre[REG_POS(i,0)]); +return txt;} + +static char * OP_B(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "BLX%s %08X", Condition[CONDITION(i)], (int)(adr+(SIGNEXTEND_24(i)<<2)+8)); + return txt;} + sprintf(txt, "B%s %08X", Condition[CONDITION(i)], (int)(adr+(SIGNEXTEND_24(i)<<2)+8)); +return txt;} + +static char * OP_BL(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "BLX%s %08X", Condition[CONDITION(i)], (int)(adr+(SIGNEXTEND_24(i)<<2)+10)); + return txt;} + sprintf(txt, "BL%s %08X", Condition[CONDITION(i)], (int)(adr+(SIGNEXTEND_24(i)<<2)+8)); +return txt;} + +//----------------CLZ------------------------------- + +static char * OP_CLZ(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "CLZ%s %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)]); +return txt;} + + +//--------------------QADD--QSUB------------------------------ + +static char * OP_QADD(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "QADD%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); +return txt;} + +static char * OP_QSUB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "QSUB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); +return txt;} + +static char * OP_QDADD(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "QDADD%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); +return txt;} + +static char * OP_QDSUB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "QDSUB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,0)], Registre[REG_POS(i,16)]); +return txt;} + +//-----------------SMUL------------------------------- + +static char * OP_SMUL_B_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULBB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMUL_B_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULBT%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMUL_T_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULTB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMUL_T_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULTT%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +//-----------SMLA---------------------------- + +static char * OP_SMLA_B_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLABB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +static char * OP_SMLA_B_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLABT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +static char * OP_SMLA_T_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLATB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +static char * OP_SMLA_T_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLATT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +//--------------SMLAL--------------------------------------- + +static char * OP_SMLAL_B_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLABB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMLAL_B_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLABT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMLAL_T_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLATB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMLAL_T_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLATT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +//--------------SMULW-------------------- + +static char * OP_SMULW_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULWB%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +static char * OP_SMULW_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMULWT%s %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)]); +return txt;} + +//--------------SMLAW------------------- +static char * OP_SMLAW_B(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLAWB%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +static char * OP_SMLAW_T(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SMLAWT%s %s, %s, %s, %s", Condition[CONDITION(i)], Registre[REG_POS(i,16)], Registre[REG_POS(i,0)], Registre[REG_POS(i,8)], Registre[REG_POS(i,12)]); +return txt;} + +//------------LDR--------------------------- + +static char * OP_LDR_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + if(REG_POS(i,16) == 15) + sprintf(txt, "LDR%s %s, [%08X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], (adr + 8 + (int)(i&0x7FF))); + else + sprintf(txt, "LDR%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDR_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + if(REG_POS(i,16) == 15) + sprintf(txt, "LDR%s %s, [%08X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], (adr + 8 - (int)(i&0x7FF))); + else + sprintf(txt, "LDR%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDR_P_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDR, "", "", "]"); +return txt;} + +static char * OP_LDR_M_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDR, "-", "", "]"); +return txt;} + +static char * OP_LDR_P_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, LSR, "", "", "]"); +return txt;} + +static char * OP_LDR_M_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, LSR, "M", "", "]"); +return txt;} + +static char * OP_LDR_P_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, ASR, "", "", "]"); +return txt;} + +static char * OP_LDR_M_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, ASR, "-", "", "]"); +return txt;} + +static char * OP_LDR_P_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDR, "", "", "]"); +return txt;} + +static char * OP_LDR_M_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDR, "-", "", "]"); +return txt;} + +static char * OP_LDR_P_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDR_M_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDR_P_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDR, "", "", "]!"); +return txt;} + +static char * OP_LDR_M_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDR, "-", "", "]!"); +return txt;} + +static char * OP_LDR_P_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, LSR, "", "", "]!"); +return txt;} + +static char * OP_LDR_M_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, LSR, "-", "", "]!"); +return txt;} + +static char * OP_LDR_P_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, ASR, "", "", "]!"); +return txt;} + +static char * OP_LDR_M_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, ASR, "-", "", "]!"); +return txt;} + +static char * OP_LDR_P_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDR, "", "", "]!"); +return txt;} + +static char * OP_LDR_M_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDR, "-", "", "]!"); +return txt;} + +static char * OP_LDR_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDR_P_IMM_OFF_POSTIND2(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDR_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDR_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDR, "", "]", ""); +return txt;} + +static char * OP_LDR_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDR, "-", "]", ""); +return txt;} + +static char * OP_LDR_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, LSR, "", "]", ""); +return txt;} + +static char * OP_LDR_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, LSR, "-", "]", ""); +return txt;} + +static char * OP_LDR_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, ASR, "", "]", ""); +return txt;} + +static char * OP_LDR_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDR, ASR, "-", "]", ""); +return txt;} + +static char * OP_LDR_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDR, "", "]", ""); +return txt;} + +static char * OP_LDR_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDR, "-", "]", ""); +return txt;} + +//-----------------LDRB------------------------------------------- + +static char * OP_LDRB_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDRB_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDRB_P_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRB, "", "", "]"); +return txt;} + +static char * OP_LDRB_M_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRB, "-", "", "]"); +return txt;} + +static char * OP_LDRB_P_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, LSR, "", "", "]"); +return txt;} + +static char * OP_LDRB_M_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, LSR, "M", "", "]"); +return txt;} + +static char * OP_LDRB_P_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, ASR, "", "", "]"); +return txt;} + +static char * OP_LDRB_M_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, ASR, "-", "", "]"); +return txt;} + +static char * OP_LDRB_P_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRB, "", "", "]"); +return txt;} + +static char * OP_LDRB_M_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRB, "-", "", "]"); +return txt;} + +static char * OP_LDRB_P_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDRB_M_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDRB_P_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRB, "", "", "]!"); +return txt;} + +static char * OP_LDRB_M_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRB, "-", "", "]!"); +return txt;} + +static char * OP_LDRB_P_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, LSR, "", "", "]!"); +return txt;} + +static char * OP_LDRB_M_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, LSR, "-", "", "]!"); +return txt;} + +static char * OP_LDRB_P_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, ASR, "", "", "]!"); +return txt;} + +static char * OP_LDRB_M_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, ASR, "-", "", "]!"); +return txt;} + +static char * OP_LDRB_P_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRB, "", "", "]!"); +return txt;} + +static char * OP_LDRB_M_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRB, "-", "", "]!"); +return txt;} + +static char * OP_LDRB_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDRB_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDRB_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRB, "", "]", ""); +return txt;} + +static char * OP_LDRB_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRB, "-", "]", ""); +return txt;} + +static char * OP_LDRB_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, LSR, "", "]", ""); +return txt;} + +static char * OP_LDRB_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, LSR, "-", "]", ""); +return txt;} + +static char * OP_LDRB_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, ASR, "", "]", ""); +return txt;} + +static char * OP_LDRB_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRB, ASR, "-", "]", ""); +return txt;} + +static char * OP_LDRB_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRB, "", "]", ""); +return txt;} + +static char * OP_LDRB_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRB, "-", "]", ""); +return txt;} + +//----------------------STR-------------------------------- + +static char * OP_STR_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STR_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STR_P_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STR, "", "", "]"); +return txt;} + +static char * OP_STR_M_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STR, "-", "", "]"); +return txt;} + +static char * OP_STR_P_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, LSR, "", "", "]"); +return txt;} + +static char * OP_STR_M_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, LSR, "M", "", "]"); +return txt;} + +static char * OP_STR_P_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, ASR, "", "", "]"); +return txt;} + +static char * OP_STR_M_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, ASR, "-", "", "]"); +return txt;} + +static char * OP_STR_P_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STR, "", "", "]"); +return txt;} + +static char * OP_STR_M_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STR, "-", "", "]"); +return txt;} + +static char * OP_STR_P_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STR_M_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STR_P_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STR, "", "", "]!"); +return txt;} + +static char * OP_STR_M_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STR, "-", "", "]!"); +return txt;} + +static char * OP_STR_P_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, LSR, "", "", "]!"); +return txt;} + +static char * OP_STR_M_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, LSR, "-", "", "]!"); +return txt;} + +static char * OP_STR_P_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, ASR, "", "", "]!"); +return txt;} + +static char * OP_STR_M_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, ASR, "-", "", "]!"); +return txt;} + +static char * OP_STR_P_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STR, "", "", "]!"); +return txt;} + +static char * OP_STR_M_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STR, "-", "", "]!"); +return txt;} + +static char * OP_STR_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STR_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STR_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STR, "", "]", ""); +return txt;} + +static char * OP_STR_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STR, "-", "]", ""); +return txt;} + +static char * OP_STR_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, LSR, "", "]", ""); +return txt;} + +static char * OP_STR_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, LSR, "-", "]", ""); +return txt;} + +static char * OP_STR_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, ASR, "", "]", ""); +return txt;} + +static char * OP_STR_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STR, ASR, "-", "]", ""); +return txt;} + +static char * OP_STR_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STR, "", "]", ""); +return txt;} + +static char * OP_STR_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STR, "-", "]", ""); +return txt;} + +//-----------------------STRB------------------------------------- + +static char * OP_STRB_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB%s %s, [%s, #%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STRB_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB%s %s, [%s, -#%X]", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STRB_P_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRB, "", "", "]"); +return txt;} + +static char * OP_STRB_M_LSL_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRB, "-", "", "]"); +return txt;} + +static char * OP_STRB_P_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, LSR, "", "", "]"); +return txt;} + +static char * OP_STRB_M_LSR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, LSR, "M", "", "]"); +return txt;} + +static char * OP_STRB_P_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, ASR, "", "", "]"); +return txt;} + +static char * OP_STRB_M_ASR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, ASR, "-", "", "]"); +return txt;} + +static char * OP_STRB_P_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRB, "", "", "]"); +return txt;} + +static char * OP_STRB_M_ROR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRB, "-", "", "]"); +return txt;} + +static char * OP_STRB_P_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB%s %s, [%s, #%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STRB_M_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB%s %s, [%s, -#%X]!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STRB_P_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRB, "", "", "]!"); +return txt;} + +static char * OP_STRB_M_LSL_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRB, "-", "", "]!"); +return txt;} + +static char * OP_STRB_P_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, LSR, "", "", "]!"); +return txt;} + +static char * OP_STRB_M_LSR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, LSR, "-", "", "]!"); +return txt;} + +static char * OP_STRB_P_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, ASR, "", "", "]!"); +return txt;} + +static char * OP_STRB_M_ASR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, ASR, "-", "", "]!"); +return txt;} + +static char * OP_STRB_P_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRB, "", "", "]!"); +return txt;} + +static char * OP_STRB_M_ROR_IMM_OFF_PREIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRB, "-", "", "]!"); +return txt;} + +static char * OP_STRB_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STRB_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STRB_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRB, "", "]", ""); +return txt;} + +static char * OP_STRB_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRB, "-", "]", ""); +return txt;} + +static char * OP_STRB_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, LSR, "", "]", ""); +return txt;} + +static char * OP_STRB_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, LSR, "-", "]", ""); +return txt;} + +static char * OP_STRB_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, ASR, "", "]", ""); +return txt;} + +static char * OP_STRB_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRB, ASR, "-", "]", ""); +return txt;} + +static char * OP_STRB_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRB, "", "]", ""); +return txt;} + +static char * OP_STRB_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRB, "-", "]", ""); +return txt;} + +//-----------------------LDRBT------------------------------------- + +static char * OP_LDRBT_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRBT%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDRBT_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRBT%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_LDRBT_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRBT, "", "]", ""); +return txt;} + +static char * OP_LDRBT_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(LDRBT, "-", "]", ""); +return txt;} + +static char * OP_LDRBT_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRBT, LSR, "", "]", ""); +return txt;} + +static char * OP_LDRBT_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRBT, LSR, "-", "]", ""); +return txt;} + +static char * OP_LDRBT_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRBT, ASR, "", "]", ""); +return txt;} + +static char * OP_LDRBT_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(LDRBT, ASR, "-", "]", ""); +return txt;} + +static char * OP_LDRBT_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRBT, "", "]", ""); +return txt;} + +static char * OP_LDRBT_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(LDRBT, "-", "]", ""); +return txt;} + +//----------------------STRBT---------------------------- + +static char * OP_STRBT_P_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRBT%s %s, [%s], #%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STRBT_M_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRBT%s %s, [%s], -#%X!", Condition[CONDITION(i)], Registre[REG_POS(i,12)], Registre[REG_POS(i,16)], (int)(i&0x7FF)); +return txt;} + +static char * OP_STRBT_P_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRBT, "", "]", ""); +return txt;} + +static char * OP_STRBT_M_LSL_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_LSL_IMM(STRBT, "-", "]", ""); +return txt;} + +static char * OP_STRBT_P_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRBT, LSR, "", "]", ""); +return txt;} + +static char * OP_STRBT_M_LSR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRBT, LSR, "-", "]", ""); +return txt;} + +static char * OP_STRBT_P_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRBT, ASR, "", "]", ""); +return txt;} + +static char * OP_STRBT_M_ASR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_IMM_SHIFT(STRBT, ASR, "-", "]", ""); +return txt;} + +static char * OP_STRBT_P_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRBT, "", "]", ""); +return txt;} + +static char * OP_STRBT_M_ROR_IMM_OFF_POSTIND(u32 adr, u32 i, char * txt) +{ + LDRSTR_ROR_IMM(STRBT, "-", "]", ""); +return txt;} + +//---------------------LDM----------------------------- + +static char * OP_LDMIA(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIA%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMIB(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIB%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMDA(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDA%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMDB(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDB%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMIA_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIA%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMIB_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIB%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMDA_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDA%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMDB_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDB%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMIA2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIA%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMIB2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIB%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMDA2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDA%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMDB2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDB%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_LDMIA2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIA%s %s!, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); + if(BIT15(i)==0) sprintf(txt, "%s ?????", txt); +return txt;} + +static char * OP_LDMIB2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMIB%s %s!, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); + if(BIT15(i)==0) sprintf(txt, "%s ?????", txt); +return txt;} + +static char * OP_LDMDA2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDA%s %s!, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); + if(BIT15(i)==0) sprintf(txt, "%s ?????", txt); +return txt;} + +static char * OP_LDMDB2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "LDMDB%s %s!, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); + if(BIT15(i)==0) sprintf(txt, "%s ?????", txt); +return txt;} + +//------------------------------STM---------------------------------- + +static char * OP_STMIA(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIA%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIB(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIB%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDA(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDA%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDB(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDB%s %s, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIA_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIA%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIB_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIB%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDA_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDA%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDB_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDB%s %s!, {%s}", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIA2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIA%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIB2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIB%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDA2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDA%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDB2(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDB%s %s, {%s}^", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIA2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIA%s %s!, {%s}^ ?????", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMIB2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMIB%s %s!, {%s}^ ?????", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); +return txt;} + +static char * OP_STMDA2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDA%s %s!, {%s}^ ?????", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); + return txt; +} + +static char * OP_STMDB2_W(u32 adr, u32 i, char * txt) +{ + RegList(16); + sprintf(txt, "STMDB%s %s!, {%s}^ ?????", Condition[CONDITION(i)], Registre[REG_POS(i,16)], lreg); + return txt; +} + +//---------------------STC---------------------------------- + +static char * OP_STC_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s, #%X]", (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)],(int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "STC%s %X, CP%X, [%s, #%X]",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)],(int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STC_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s, #-%X]",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)],(int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "STC%s CP%X, CR%X, [%s, #-%X]",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STC_P_PREIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s, #%X]!",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "STC%s CP%X, CR%X, [%s, #%X]!",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STC_M_PREIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s, #-%X]!",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "STC%s CP%X, CR%X, [%s, #-%X]!",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STC_P_POSTIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s], #%X",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "STC%s CP%X, CR%X, [%s], #%X",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STC_M_POSTIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s], #-%X",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "STC%s CP%X, CR%X, [%s], #-%X",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STC_OPTION(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "STC2 CP%X, CR%X, [%s], {%X}",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)(i&0xFF)); + return txt; + } + sprintf(txt, "STC%s CP%X, CR%X, [%s], {%X}",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)(i&0xFF)); + return txt; +} + +//---------------------LDC---------------------------------- + +static char * OP_LDC_P_IMM_OFF(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s, #%X]",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s, #%X]",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDC_M_IMM_OFF(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s, #-%X]",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s, #-%X]",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDC_P_PREIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s, #%X]!",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s, #%X]!",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDC_M_PREIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s, #-%X]!",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s, #-%X]!",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDC_P_POSTIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s], #%X",(int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s], #%X",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDC_M_POSTIND(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s], #-%X", (int)REG_POS(i, 8), (int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s], #-%X",Condition[CONDITION(i)], (int)REG_POS(i, 8),(int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDC_OPTION(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "LDC2 CP%X, CR%X, [%s], {%X}", (int)REG_POS(i, 8), (int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)(i&0xFF)); + return txt; + } + sprintf(txt, "LDC%s CP%X, CR%X, [%s], {%X}",Condition[CONDITION(i)], (int)REG_POS(i, 8), (int)REG_POS(i, 12), Registre[REG_POS(i, 16)], (int)(i&0xFF)); + return txt; +} + + +/* + * + * The Enhanced DSP Extension LDRD and STRD instructions. + * + */ +static char * +OP_LDRD_STRD_POST_INDEX(u32 adr, u32 i, char * txt) { + const char *direction = + BIT5(i) ? "STR" : "LDR"; + /* U bit - set = add, clear = sub */ + char sign = BIT23(i) ? '+' : '-'; + int txt_index = 0; + + txt_index += sprintf( &txt[txt_index], "%s%sD R%d, [R%d], ", + direction, Condition[CONDITION(i)], + (int)REG_POS(i, 12), + (int)REG_POS(i, 16)); + + /* I bit - set = immediate, clear = reg */ + if ( BIT22(i)) { + sprintf( &txt[txt_index], "#%c%d", + sign, (int)(((i>>4) & 0xF0) | (i&0xF)) ); + } + else { + sprintf( &txt[txt_index], "%cR%d", + sign, (int)REG_POS(i, 0)); + } + return txt; +} +static char * +OP_LDRD_STRD_OFFSET_PRE_INDEX(u32 adr, u32 i, char * txt) { + const char *direction = + BIT5(i) ? "STR" : "LDR"; + /* U bit - set = add, clear = sub */ + char sign = BIT23(i) ? '+' : '-'; + int txt_index = 0; + + txt_index += sprintf( &txt[txt_index], "%s%sD R%d, [R%d, ", + direction, Condition[CONDITION(i)], + (int)REG_POS(i, 12), + (int)REG_POS(i, 16)); + + /* I bit - set = immediate, clear = reg */ + if ( BIT22(i)) { + if ( BIT21(i)) { + /* pre-index */ + sprintf( &txt[txt_index], "#%c%d]!", + sign, (int)(((i>>4)&0xF0)|(i&0xF))); + } + else { + /* offset */ + sprintf( &txt[txt_index], "#%c%d]", + sign, (int)(((i>>4)&0xF0)|(i&0xF))); + } + } + else { + if ( BIT21(i)) { + /* pre-index */ + sprintf( &txt[txt_index], "%c%d]!", + sign, (int)REG_POS(i, 0)); + } + else { + /* offset */ + sprintf( &txt[txt_index], "%c%d]", + sign, (int)REG_POS(i, 0)); + } + } + + return txt; +} + + +//----------------MCR----------------------- + +static char * OP_MCR(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "MCR2 CP%d, %X, %s, CR%d, CR%d, %X",(int)REG_POS(i, 8), (int)((i>>21)&7), Registre[REG_POS(i, 12)], (int)REG_POS(i, 16), (int)REG_POS(i, 0), (int)((i>>5)&0x7)); + return txt; + } + sprintf(txt, "MCR%s CP%d, %X, %s, CR%d, CR%d, %X",Condition[CONDITION(i)], (int)REG_POS(i, 8), (int)((i>>21)&7), Registre[REG_POS(i, 12)], (int)REG_POS(i, 16), (int)REG_POS(i, 0), (int)((i>>5)&0x7)); + return txt; +} + +//----------------MRC----------------------- + +static char * OP_MRC(u32 adr, u32 i, char * txt) +{ + if(CONDITION(i)==0xF) + { + sprintf(txt, "MRC2 CP%d, %X, %s, CR%d, CR%d, %X",(int)REG_POS(i, 8), (int)((i>>21)&7), Registre[REG_POS(i, 12)], (int)REG_POS(i, 16), (int)REG_POS(i, 0), (int)((i>>5)&0x7)); + return txt; + } + sprintf(txt, "MRC%s CP%d, %X, %s, CR%d, CR%d, %X",Condition[CONDITION(i)], (int)REG_POS(i, 8), (int)((i>>21)&7), Registre[REG_POS(i, 12)], (int)REG_POS(i, 16), (int)REG_POS(i, 0), (int)((i>>5)&0x7)); + return txt; +} + +//--------------SWI-------------------------- + +static char * OP_SWI(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SWI%s %X",Condition[CONDITION(i)], (int)((i&0xFFFFFF)>>16)); + return txt; +} + +//----------------BKPT------------------------- +static char * OP_BKPT(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BKPT #%X",(int)(((i>>4)&0xFFF)|(i&0xF))); + return txt; +} + +//----------------CDP----------------------- + +static char * OP_CDP(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "CDP-------------------------------"); + return txt; +} + +//------------------------------------------------------------ +// THUMB +//------------------------------------------------------------ +#define REG_NUM(i, n) (((i)>>n)&0x7) + +static char * OP_UND_THUMB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "----"); + return txt; +} + +static char * OP_LSL_0(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LSL %s, %s, #0", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_LSL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LSL %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6) & 0x1F)); + return txt; +} + +static char * OP_LSR_0(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LSR %s, %s, #0", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_LSR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LSR %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6) & 0x1F)); + return txt; +} + +static char * OP_ASR_0(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ASR %s, %s, #0", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_ASR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ASR %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6) & 0x1F)); + return txt; +} + +static char * OP_ADD_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADD %s, %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_SUB_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SUB %s, %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_ADD_IMM3(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADD %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)REG_NUM(i, 6)); + return txt; +} + +static char * OP_SUB_IMM3(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SUB %s, %s, #%X", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)REG_NUM(i, 6)); + return txt; +} + +static char * OP_MOV_IMM8(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MOV %s, #%X", Registre[REG_NUM(i, 8)], (int)(i&0xFF)); + return txt; +} + +static char * OP_CMP_IMM8(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "CMP %s, #%X", Registre[REG_NUM(i, 8)], (int)(i&0xFF)); + return txt; +} + +static char * OP_ADD_IMM8(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADD %s, #%X", Registre[REG_NUM(i, 8)], (int)(i&0xFF)); + return txt; +} + +static char * OP_SUB_IMM8(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SUB %s, #%X", Registre[REG_NUM(i, 8)], (int)(i&0xFF)); + return txt; +} + +static char * OP_AND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "AND %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_EOR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "EOR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_LSL_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LSL %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_LSR_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LSR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_ASR_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ASR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_ADC_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADC %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_SBC_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SBC %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_ROR_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ROR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_TST(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "TST %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_NEG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "NEG %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_CMP(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "CMP %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_CMN(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "CMN %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_ORR(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ORR %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_MUL_REG(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MUL %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_BIC(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BIC %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_MVN(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "MVN %s, %s", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)]); + return txt; +} + +static char * OP_ADD_SPE(u32 adr, u32 i, char * txt) +{ + u8 Rd = (i&7) | ((i>>4)&8); + sprintf(txt, "ADD %s, %s", Registre[Rd], Registre[REG_POS(i, 3)]); + return txt; +} + +static char * OP_CMP_SPE(u32 adr, u32 i, char * txt) +{ + u8 Rd = (i&7) | ((i>>4)&8); + sprintf(txt, "CMP %s, %s", Registre[Rd], Registre[REG_POS(i, 3)]); + return txt; +} + +static char * OP_MOV_SPE(u32 adr, u32 i, char * txt) +{ + u8 Rd = (i&7) | ((i>>4)&8); + sprintf(txt, "MOV %s, %s", Registre[Rd], Registre[REG_POS(i, 3)]); + return txt; +} + +static char * OP_BX_THUMB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BX %s", Registre[REG_POS(i, 3)]); + return txt; +} + +static char * OP_BLX_THUMB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BLX %s", Registre[REG_POS(i, 3)]); + return txt; +} + +static char * OP_LDR_PCREL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR %s, [PC, #%X]", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_STR_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_STRH_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_STRB_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_LDRSB_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSB %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_LDR_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_LDRH_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_LDRB_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_LDRSH_REG_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRSH %s, [%s, %s]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], Registre[REG_NUM(i, 6)]); + return txt; +} + +static char * OP_STR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>4)&0x7C)); + return txt; +} + +static char * OP_LDR_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>4)&0x7C)); + return txt; +} + +static char * OP_STRB_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRB %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6)&0x1F)); + return txt; +} + +static char * OP_LDRB_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRB %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>6)&0x1F)); + return txt; +} + +static char * OP_STRH_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STRH %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>5)&0x3E)); + return txt; +} + +static char * OP_LDRH_IMM_OFF(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDRH %s, [%s, #%X]", Registre[REG_NUM(i, 0)], Registre[REG_NUM(i, 3)], (int)((i>>5)&0x3E)); + return txt; +} + +static char * OP_STR_SPREL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "STR %s, [SP, #%X]", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_LDR_SPREL(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "LDR %s, [SP, #%X]", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_ADD_2PC(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADD %s, PC, #%X", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_ADD_2SP(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADD %s, SP, #%X", Registre[REG_NUM(i, 8)], (int)((i&0xFF)<<2)); + return txt; +} + +static char * OP_ADJUST_P_SP(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "ADD SP, #%X", (int)((i&0x7F)<<2)); + return txt; +} + +static char * OP_ADJUST_M_SP(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SUB SP, #%X", (int)((i&0x7F)<<2)); + return txt; +} + +static char * OP_PUSH(u32 adr, u32 i, char * txt) +{ + RegList(8); + sprintf(txt, "PUSH {%s}", lreg); + return txt; +} + +static char * OP_PUSH_LR(u32 adr, u32 i, char * txt) +{ + RegList(8); + sprintf(txt, "PUSH {%s, LR}", lreg); + return txt; +} + +static char * OP_POP(u32 adr, u32 i, char * txt) +{ + RegList(8); + sprintf(txt, "POP {%s}", lreg); + return txt; +} + +static char * OP_POP_PC(u32 adr, u32 i, char * txt) +{ + RegList(8); + sprintf(txt, "POP {%s, PC}", lreg); + return txt; +} + +static char * OP_BKPT_THUMB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BKPT"); + return txt; +} + +static char * OP_STMIA_THUMB(u32 adr, u32 i, char * txt) +{ + RegList(8); + sprintf(txt, "STMIA %s!, {%s}", Registre[REG_NUM(i, 8)], lreg); + return txt; +} + +static char * OP_LDMIA_THUMB(u32 adr, u32 i, char * txt) +{ + RegList(8); + sprintf(txt, "LDMIA %s!, {%s}", Registre[REG_NUM(i, 8)], lreg); + return txt; +} + +static char * OP_B_COND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "B%s #%X", Condition[(i>>8)&0xF], (int)(adr+(((s32)((signed char)(i&0xFF)))<<1)+4)); + return txt; +} + +static char * OP_SWI_THUMB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "SWI #%X", (int)(i & 0xFF)); + return txt; +} + +#define SIGNEEXT_IMM11(i) (((i)&0x7FF) | (BIT10(i) * 0xFFFFF800)) + +static char * OP_B_UNCOND(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "B #%X", (int)(adr+(SIGNEEXT_IMM11(i)<<1)+4)); + return txt; +} + +u32 part = 0; + +static char * OP_BLX(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BLX #%X", (int)(part + ((i&0x7FF)<<1))&0xFFFFFFFC); + return txt; +} + +static char * OP_BL_10(u32 adr, u32 i, char * txt) +{ + part = adr+4 + (SIGNEEXT_IMM11(i)<<12); + sprintf(txt, "calculating high part of the address"); + return txt; + +} + +static char * OP_BL_THUMB(u32 adr, u32 i, char * txt) +{ + sprintf(txt, "BL #%X", (int)(part + ((i&0x7FF)<<1))&0xFFFFFFFC); + return txt; +} + +#define TYPE_RETOUR char * +#define PARAMETRES u32 adr, u32 i, char * txt +#define CALLTYPE +#define NOM_TAB des_arm_instructions_set +#define NOM_THUMB_TAB des_thumb_instructions_set +#define TABDECL(x) x + +#include "instruction_tabdef.inc" +#include "thumb_tabdef.inc" + diff --git a/desmume/src/Disassembler.h b/src/Disassembler.h similarity index 97% rename from desmume/src/Disassembler.h rename to src/Disassembler.h index 63fa2b818..4fe49b1fd 100644 --- a/desmume/src/Disassembler.h +++ b/src/Disassembler.h @@ -1,32 +1,32 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef DISASSEMBLER_H -#define DISASSEMBLER_H - -#include "types.h" - -extern char * (* des_arm_instructions_set[4096])(u32 adr, u32 i, char * txt); -extern char * (* des_thumb_instructions_set[1024])(u32 adr, u32 i, char * txt); - -#endif - - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef DISASSEMBLER_H +#define DISASSEMBLER_H + +#include "types.h" + +extern char * (* des_arm_instructions_set[4096])(u32 adr, u32 i, char * txt); +extern char * (* des_thumb_instructions_set[1024])(u32 adr, u32 i, char * txt); + +#endif + + diff --git a/desmume/src/FIFO.cpp b/src/FIFO.cpp similarity index 54% rename from desmume/src/FIFO.cpp rename to src/FIFO.cpp index 7bff14f99..bbc83aee6 100644 --- a/desmume/src/FIFO.cpp +++ b/src/FIFO.cpp @@ -1,375 +1,276 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright 2007 shash - Copyright 2007-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "FIFO.h" -#include -#include "armcpu.h" -#include "debug.h" -#include "mem.h" -#include "MMU.h" -#include "NDSSystem.h" - -// ========================================================= IPC FIFO -IPC_FIFO ipc_fifo[2]; // 0 - ARM9 - // 1 - ARM7 - -u8 FORCEINLINE IPC_FIFOgetSize(u8 proc) -{ - if (ipc_fifo[proc].head < ipc_fifo[proc].tail) return (ipc_fifo[proc].tail - ipc_fifo[proc].head); - if (ipc_fifo[proc].head > ipc_fifo[proc].tail) return (16 - (ipc_fifo[proc].head - ipc_fifo[proc].tail)); - return 0; -} - -void IPC_FIFOinit(u8 proc) -{ - memset(&ipc_fifo[proc], 0, sizeof(IPC_FIFO)); - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, 0x00000101); -} - -void IPC_FIFOsend(u8 proc, u32 val) -{ - u16 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184); - if (!(cnt_l & 0x8000)) return; // FIFO disabled - u8 proc_remote = proc ^ 1; - - if (ipc_fifo[proc].size > 15) - { - cnt_l |= 0x4000; - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, cnt_l); - return; - } - - u16 cnt_r = T1ReadWord(MMU.MMU_MEM[proc_remote][0x40], 0x184); - - //LOG("IPC%s send FIFO 0x%08X (l 0x%X, tail %02i) (r 0x%X, tail %02i)\n", - // proc?"7":"9", val, cnt_l, ipc_fifo[proc].tail, cnt_r, ipc_fifo[proc^1].tail); - - cnt_l &= 0xBFFC; // clear send empty bit & full - cnt_r &= 0xBCFF; // set recv empty bit & full - ipc_fifo[proc].buf[ipc_fifo[proc].tail] = val; - ipc_fifo[proc].tail++; - ipc_fifo[proc].size = IPC_FIFOgetSize(proc); - if (ipc_fifo[proc].tail > 15) ipc_fifo[proc].tail = 0; - - if (ipc_fifo[proc].size > 15) - { - cnt_l |= 0x0002; // set send full bit - cnt_r |= 0x0200; // set recv full bit - } - - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, cnt_l); - T1WriteWord(MMU.MMU_MEM[proc_remote][0x40], 0x184, cnt_r); - - setIF(proc_remote, ((cnt_l & 0x0400)<<8)); // IRQ18: recv not empty -} - -u32 IPC_FIFOrecv(u8 proc) -{ - u16 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184); - if (!(cnt_l & 0x8000)) return (0); // FIFO disabled - u8 proc_remote = proc ^ 1; - - u32 val = 0; - - if ( ipc_fifo[proc_remote].size == 0 ) // remote FIFO error - { - cnt_l |= 0x4000; - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, cnt_l); - return (0); - } - - u16 cnt_r = T1ReadWord(MMU.MMU_MEM[proc_remote][0x40], 0x184); - - cnt_l &= 0xBCFF; // clear send full bit & empty - cnt_r &= 0xBFFC; // set recv full bit & empty - - val = ipc_fifo[proc_remote].buf[ipc_fifo[proc_remote].head]; - ipc_fifo[proc_remote].head++; - ipc_fifo[proc_remote].size = IPC_FIFOgetSize(proc_remote); - if (ipc_fifo[proc_remote].head > 15) ipc_fifo[proc_remote].head = 0; - - //LOG("IPC%s recv FIFO 0x%08X (l 0x%X, tail %02i) (r 0x%X, tail %02i)\n", - // proc?"7":"9", val, cnt_l, ipc_fifo[proc].tail, cnt_r, ipc_fifo[proc^1].tail); - - if ( ipc_fifo[proc_remote].size == 0 ) // FIFO empty - { - cnt_l |= 0x0100; - cnt_r |= 0x0001; - } - - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, cnt_l); - T1WriteWord(MMU.MMU_MEM[proc_remote][0x40], 0x184, cnt_r); - - setIF(proc_remote, ((cnt_l & 0x0004)<<15)); // IRQ17: send empty - - return (val); -} - -void IPC_FIFOcnt(u8 proc, u16 val) -{ - u16 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184); - u16 cnt_r = T1ReadWord(MMU.MMU_MEM[proc^1][0x40], 0x184); - - //LOG("IPC%s FIFO context 0x%X (local 0x%04X, remote 0x%04X)\n", proc?"7":"9", val, cnt_l, cnt_r); - if (val & 0x4008) - { - ipc_fifo[proc].tail = 0; - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, (cnt_l & 0x0301) | (val & 0x8404) | 1); - T1WriteWord(MMU.MMU_MEM[proc^1][0x40], 0x184, (cnt_r & 0x8407) | 0x100); - //MMU.reg_IF[proc^1] |= ((val & 0x0004) << 15); - setIF(proc^1, ((val & 0x0004)<<15)); - return; - } - - T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, val); -} - -// ========================================================= GFX FIFO -GFX_PIPE gxPIPE; -GFX_FIFO gxFIFO; - -void GFX_PIPEclear() -{ - gxPIPE.head = 0; - gxPIPE.tail = 0; - gxPIPE.size = 0; -} - -void GFX_FIFOclear() -{ - u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); - gxstat &= 0x0000FFFF; - - gxFIFO.head = 0; - gxFIFO.tail = 0; - gxFIFO.size = 0; - gxstat |= 0x06000000; - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); -} - -void GFX_FIFOsend(u8 cmd, u32 param) -{ - u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); - - //INFO("gxFIFO: send 0x%02X = 0x%08X (size %03i/0x%02X) gxstat 0x%08X\n", cmd, param, gxFIFO.size, gxFIFO.size, gxstat); - - gxstat &= 0xF000FFFF; - - if (gxFIFO.size == 0) // FIFO empty - { - gxstat |= 0x06000000; - if (gxPIPE.size < 4) // pipe not full - { - gxPIPE.cmd[gxPIPE.tail] = cmd; - gxPIPE.param[gxPIPE.tail] = param; - gxPIPE.tail++; - gxPIPE.size++; - if (gxPIPE.tail > 3) gxPIPE.tail = 0; - -#ifdef USE_GEOMETRY_FIFO_EMULATION - gxstat |= 0x08000000; // set busy flag -#endif - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - NDS_RescheduleGXFIFO(); - return; - } - } - - if (gxFIFO.size > 255) - { -#ifdef USE_GEOMETRY_FIFO_EMULATION - gxstat |= 0x01000000; // full - gxstat |= 0x08000000; // busy -#else - gxstat |= 0x02000000; // this is hack (must be removed later) -#endif - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - NDS_RescheduleGXFIFO(); - //INFO("ERROR: gxFIFO is full (cmd 0x%02X = 0x%08X) (prev cmd 0x%02X = 0x%08X)\n", cmd, param, gxFIFO.cmd[255], gxFIFO.param[255]); - return; - } - - gxFIFO.cmd[gxFIFO.tail] = cmd; - gxFIFO.param[gxFIFO.tail] = param; - gxFIFO.tail++; - gxFIFO.size++; - if (gxFIFO.tail > 255) gxFIFO.tail = 0; - -#ifdef USE_GEOMETRY_FIFO_EMULATION - gxstat |= 0x08000000; // set busy flag -#endif - - gxstat |= ((gxFIFO.size & 0x1FF) << 16); - - if (gxFIFO.size < 128) // less half - { - gxstat |= 0x02000000; - } - -#ifndef USE_GEOMETRY_FIFO_EMULATION - gxstat |= 0x02000000; // this is hack (must be removed later) -#endif - - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - - NDS_RescheduleGXFIFO(); -} - -// this function used ONLY in gxFIFO -BOOL GFX_PIPErecv(u8 *cmd, u32 *param) -{ - u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); - gxstat &= 0xF7FFFFFF; // clear busy flag - - if (gxPIPE.size > 0) - { - *cmd = gxPIPE.cmd[gxPIPE.head]; - *param = gxPIPE.param[gxPIPE.head]; - gxPIPE.head++; - gxPIPE.size--; - if (gxPIPE.head > 3) gxPIPE.head = 0; - - if (gxPIPE.size < 3) - { - if (gxFIFO.size > 0) - { - gxstat &= 0xF000FFFF; - - gxPIPE.cmd[gxPIPE.tail] = gxFIFO.cmd[gxFIFO.head]; - gxPIPE.param[gxPIPE.tail] = gxFIFO.param[gxFIFO.head]; - gxPIPE.tail++; - gxPIPE.size++; - if (gxPIPE.tail > 3) gxPIPE.tail = 0; - - gxFIFO.head++; - gxFIFO.size--; - if (gxFIFO.head > 255) gxFIFO.head = 0; - - if (gxFIFO.size > 0) - { - gxPIPE.cmd[gxPIPE.tail] = gxFIFO.cmd[gxFIFO.head]; - gxPIPE.param[gxPIPE.tail] = gxFIFO.param[gxFIFO.head]; - gxPIPE.tail++; - gxPIPE.size++; - if (gxPIPE.tail > 3) gxPIPE.tail = 0; - - gxFIFO.head++; - gxFIFO.size--; - if (gxFIFO.head > 255) gxFIFO.head = 0; - } - - gxstat |= ((gxFIFO.size & 0x1FF) << 16); - - if (gxFIFO.size < 128) - { - gxstat |= 0x02000000; - if (gxstat & 0x40000000) // IRQ: less half - { - setIF(0, (1<<21)); - } - execHardware_doAllDma(EDMAMode_GXFifo); - } - - if (gxFIFO.size == 0) // empty - { - gxstat |= 0x04000000; - if (gxstat & 0x80000000) // IRQ: empty - setIF(0, (1<<21)); - } - } - else // FIFO empty - { - gxstat &= 0xF000FFFF; - gxstat |= 0x06000000; - if (gxstat & 0x80000000) // IRQ: empty - setIF(0, (1<<21)); - } - } - - if (gxPIPE.size > 0) - gxstat |= 0x08000000; // set busy flag - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - return (TRUE); - } - - if (gxstat & 0x80000000) // IRQ: empty - setIF(0, (1<<21)); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - return FALSE; -} - -extern void gfx3d_ClearStack(); -void GFX_FIFOcnt(u32 val) -{ - u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); - //INFO("gxFIFO: write cnt 0x%08X (prev 0x%08X) FIFO size %03i PIPE size %03i\n", val, gxstat, gxFIFO.size, gxPIPE.size); - - if (val & (1<<29)) // clear? (only in homebrew?) - { - GFX_PIPEclear(); - GFX_FIFOclear(); - return; - } - - if (val & (1<<15)) // projection stack pointer reset - { - gfx3d_ClearStack(); - val &= 0xFFFF5FFF; // clear reset (bit15) & stack level (bit13) - } - - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, val); - - if (gxFIFO.size == 0) // empty - { - if (val & 0x80000000) // IRQ: empty - setIF(0, (1<<21)); - } -} - -// ========================================================= DISP FIFO -DISP_FIFO disp_fifo; - -void DISP_FIFOinit() -{ - memset(&disp_fifo, 0, sizeof(DISP_FIFO)); -} - -void DISP_FIFOsend(u32 val) -{ - //INFO("DISP_FIFO send value 0x%08X (head 0x%06X, tail 0x%06X)\n", val, disp_fifo.head, disp_fifo.tail); - disp_fifo.buf[disp_fifo.tail] = val; - disp_fifo.tail++; - if (disp_fifo.tail > 0x5FFF) - disp_fifo.tail = 0; -} - -u32 DISP_FIFOrecv() -{ - //if (disp_fifo.tail == disp_fifo.head) return (0); // FIFO is empty - u32 val = disp_fifo.buf[disp_fifo.head]; - disp_fifo.head++; - if (disp_fifo.head > 0x5FFF) - disp_fifo.head = 0; - return (val); -} +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright 2007 shash + Copyright 2007-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "FIFO.h" +#include +#include "armcpu.h" +#include "debug.h" +#include "mem.h" +#include "MMU.h" + +// ========================================================= IPC FIFO +IPC_FIFO ipc_fifo[2]; // 0 - ARM9 + // 1 - ARM7 + +void IPC_FIFOinit(u8 proc) +{ + memset(&ipc_fifo[proc], 0, sizeof(IPC_FIFO)); + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, 0x00000101); +} + +void IPC_FIFOsend(u8 proc, u32 val) +{ + u16 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184); + if (!(cnt_l & 0x8000)) return; // FIFO disabled + u8 proc_remote = proc ^ 1; + + if (ipc_fifo[proc].tail > 15) + { + cnt_l |= 0x4000; + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, cnt_l); + return; + } + + u16 cnt_r = T1ReadWord(MMU.MMU_MEM[proc_remote][0x40], 0x184); + + //LOG("IPC%s send FIFO 0x%08X (l 0x%X, tail %02i) (r 0x%X, tail %02i)\n", + // proc?"7":"9", val, cnt_l, ipc_fifo[proc].tail, cnt_r, ipc_fifo[proc^1].tail); + + cnt_l &= 0xBFFC; // clear send empty bit & full + cnt_r &= 0xBCFF; // set recv empty bit & full + ipc_fifo[proc].buf[ipc_fifo[proc].tail++] = val; + + if (ipc_fifo[proc].tail > 15) + { + cnt_l |= 0x0002; // set send full bit + cnt_r |= 0x0200; // set recv full bit + } + + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, cnt_l); + T1WriteWord(MMU.MMU_MEM[proc_remote][0x40], 0x184, cnt_r); + + setIF(proc_remote, ((cnt_l & 0x0400)<<8)); +} + +u32 IPC_FIFOrecv(u8 proc) +{ + u16 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184); + if (!(cnt_l & 0x8000)) return (0); // FIFO disabled + u8 proc_remote = proc ^ 1; + + u32 val = 0; + + if ( ipc_fifo[proc_remote].tail == 0 ) // remote FIFO error + { + cnt_l |= 0x4000; + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, cnt_l); + return (0); + } + + u16 cnt_r = T1ReadWord(MMU.MMU_MEM[proc_remote][0x40], 0x184); + + cnt_l &= 0xBCFF; // clear send full bit & empty + cnt_r &= 0xBFFC; // set recv full bit & empty + + val = ipc_fifo[proc_remote].buf[0]; + + //LOG("IPC%s recv FIFO 0x%08X (l 0x%X, tail %02i) (r 0x%X, tail %02i)\n", + // proc?"7":"9", val, cnt_l, ipc_fifo[proc].tail, cnt_r, ipc_fifo[proc^1].tail); + + ipc_fifo[proc_remote].tail--; + for (int i = 0; i < ipc_fifo[proc_remote].tail; i++) + ipc_fifo[proc_remote].buf[i] = ipc_fifo[proc_remote].buf[i+1];; + + if ( ipc_fifo[proc_remote].tail == 0 ) // FIFO empty + { + cnt_l |= 0x0100; + cnt_r |= 0x0001; + } + + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, cnt_l); + T1WriteWord(MMU.MMU_MEM[proc_remote][0x40], 0x184, cnt_r); + + setIF(proc_remote, ((cnt_l & 0x0004)<<15)); + + return (val); +} + +void IPC_FIFOcnt(u8 proc, u16 val) +{ + u16 cnt_l = T1ReadWord(MMU.MMU_MEM[proc][0x40], 0x184); + u16 cnt_r = T1ReadWord(MMU.MMU_MEM[proc^1][0x40], 0x184); + + //LOG("IPC%s FIFO context 0x%X (local 0x%04X, remote 0x%04X)\n", proc?"7":"9", val, cnt_l, cnt_r); + if (val & 0x4008) + { + ipc_fifo[proc].tail = 0; + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, (cnt_l & 0x0301) | (val & 0x8404) | 1); + T1WriteWord(MMU.MMU_MEM[proc^1][0x40], 0x184, (cnt_r & 0x8407) | 0x100); + //MMU.reg_IF[proc^1] |= ((val & 0x0004) << 15); + setIF(proc^1, ((val & 0x0004)<<15)); + return; + } + + T1WriteWord(MMU.MMU_MEM[proc][0x40], 0x184, val); +} + +// ========================================================= GFX FIFO +GFX_FIFO gxFIFO; + +void GFX_FIFOclear() +{ + u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); + gxstat &= 0x0000FFFF; + + gxFIFO.tail = 0; + gxstat |= 0x06000000; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); +} + +void GFX_FIFOsend(u8 cmd, u32 param) +{ + //INFO("GFX FIFO: Send GFX 3D cmd 0x%02X to FIFO - 0x%08X (%03i/%02X)\n", cmd, param, gxFIFO.tail, gxFIFO.tail); + u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); + if (gxstat & 0x01000000) return; // full + + gxstat &= 0xF000FFFF; + + gxFIFO.cmd[gxFIFO.tail] = cmd; + gxFIFO.param[gxFIFO.tail] = param; + gxFIFO.tail++; + +#ifdef USE_GEOMETRY_FIFO_EMULATION + gxstat |= 0x08000000; // set busy flag +#endif + + gxstat |= (gxFIFO.tail << 16); + + if (gxFIFO.tail < 128) + gxstat |= 0x02000000; + +#ifndef USE_GEOMETRY_FIFO_EMULATION + gxstat |= 0x02000000; // this is hack (must be removed later) +#endif + + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); +} + +BOOL GFX_FIFOrecv(u8 *cmd, u32 *param) +{ + u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); +#if 0 + if (gxstat & 0xC0000000) + { + setIF(0, (1<<21)); + } +#endif + if (gxFIFO.tail == 0) // empty + { + gxstat &= 0xF000FFFF; + gxstat |= 0x06000000; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + if ((gxstat & 0x80000000)) // empty + { + setIF(0, (1<<21)); + } + return FALSE; + } + + if (gxstat & 0x40000000) // IRQ: less half + { + if (gxstat & 0x02000000) setIF(0, (1<<21)); + } + + if ((gxstat & 0x80000000)) // IRQ: empty + { + if (gxstat & 0x04000000) setIF(0, (1<<21)); + } + + gxstat &= 0xF000FFFF; + *cmd = gxFIFO.cmd[0]; + *param = gxFIFO.param[0]; + gxFIFO.tail--; + for (int i=0; i < gxFIFO.tail; i++) + { + gxFIFO.cmd[i] = gxFIFO.cmd[i+1]; + gxFIFO.param[i] = gxFIFO.param[i+1]; + } + +#ifdef USE_GEOMETRY_FIFO_EMULATION + gxstat |= 0x08000000; // set busy flag +#endif + + gxstat |= (gxFIFO.tail << 16); + + if (gxFIFO.tail < 128) + gxstat |= 0x02000000; + + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + + return TRUE; +} + +void GFX_FIFOcnt(u32 val) +{ + u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); + //INFO("GFX FIFO: write context 0x%08X (prev 0x%08X) tail %i\n", val, gxstat, gxFIFO.tail); + if (val & (1<<29)) // clear? (homebrew) + { + GFX_FIFOclear(); + return; + } + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + + /*if (gxstat & 0xC0000000) + { + setIF(0, (1<<21)); + }*/ +} + +// ========================================================= DISP FIFO +DISP_FIFO disp_fifo; + +void DISP_FIFOinit() +{ + memset(&disp_fifo, 0, sizeof(DISP_FIFO)); +} + +void DISP_FIFOsend(u32 val) +{ + //INFO("DISP_FIFO send value 0x%08X (head 0x%06X, tail 0x%06X)\n", val, disp_fifo.head, disp_fifo.tail); + disp_fifo.buf[disp_fifo.tail] = val; + disp_fifo.tail++; + if (disp_fifo.tail > 0x5FFF) + disp_fifo.tail = 0; +} + +u32 DISP_FIFOrecv() +{ + //if (disp_fifo.tail == disp_fifo.head) return (0); // FIFO is empty + u32 val = disp_fifo.buf[disp_fifo.head]; + disp_fifo.head++; + if (disp_fifo.head > 0x5FFF) + disp_fifo.head = 0; + return (val); +} diff --git a/desmume/src/FIFO.h b/src/FIFO.h similarity index 82% rename from desmume/src/FIFO.h rename to src/FIFO.h index 1fe1b4ff4..939a6b2bc 100644 --- a/desmume/src/FIFO.h +++ b/src/FIFO.h @@ -1,91 +1,75 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright 2007 shash - Copyright 2007-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#ifndef FIFO_H -#define FIFO_H - -//#define USE_GEOMETRY_FIFO_EMULATION //enable gxFIFO emulation - -#include "types.h" - -//=================================================== IPC FIFO -typedef struct -{ - u32 buf[16]; - - u8 head; - u8 tail; - u8 size; -} IPC_FIFO; - -extern IPC_FIFO ipc_fifo[2]; -extern void IPC_FIFOinit(u8 proc); -extern void IPC_FIFOsend(u8 proc, u32 val); -extern u32 IPC_FIFOrecv(u8 proc); -extern void IPC_FIFOcnt(u8 proc, u16 val); - -//=================================================== GFX FIFO -typedef struct -{ - u8 cmd[256]; - u32 param[256]; - - u16 head; // start position - u16 tail; // tail - u16 size; // size FIFO buffer -} GFX_FIFO; - -typedef struct -{ - u8 cmd[4]; - u32 param[4]; - - u8 head; - u8 tail; - u8 size; -} GFX_PIPE; - -extern GFX_PIPE gxPIPE; -extern GFX_FIFO gxFIFO; -extern void GFX_PIPEclear(); -extern void GFX_FIFOclear(); -extern void GFX_FIFOsend(u8 cmd, u32 param); -extern BOOL GFX_PIPErecv(u8 *cmd, u32 *param); -extern void GFX_FIFOcnt(u32 val); - -//=================================================== Display memory FIFO -typedef struct -{ - u32 buf[0x6000]; // 256x192 32K color - u32 head; // head - u32 tail; // tail -} DISP_FIFO; - -extern DISP_FIFO disp_fifo; -extern void DISP_FIFOinit(); -extern void DISP_FIFOsend(u32 val); -extern u32 DISP_FIFOrecv(); - -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright 2007 shash + Copyright 2007-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + + +#ifndef FIFO_H +#define FIFO_H + +//#define USE_GEOMETRY_FIFO_EMULATION //enables new experimental gxFIFO + +#include "types.h" + +//=================================================== IPC FIFO +typedef struct +{ + u32 buf[16]; + + u8 tail; +} IPC_FIFO; + +extern IPC_FIFO ipc_fifo[2]; +extern void IPC_FIFOinit(u8 proc); +extern void IPC_FIFOsend(u8 proc, u32 val); +extern u32 IPC_FIFOrecv(u8 proc); +extern void IPC_FIFOcnt(u8 proc, u16 val); + +//=================================================== GFX FIFO +typedef struct +{ + u8 cmd[261]; + u32 param[261]; + + u16 tail; // tail +} GFX_FIFO; + +extern GFX_FIFO gxFIFO; +extern void GFX_FIFOclear(); +extern void GFX_FIFOsend(u8 cmd, u32 param); +extern BOOL GFX_FIFOrecv(u8 *cmd, u32 *param); +extern void GFX_FIFOcnt(u32 val); + +//=================================================== Display memory FIFO +typedef struct +{ + u32 buf[0x6000]; // 256x192 32K color + u32 head; // head + u32 tail; // tail +} DISP_FIFO; + +extern DISP_FIFO disp_fifo; +extern void DISP_FIFOinit(); +extern void DISP_FIFOsend(u32 val); +extern u32 DISP_FIFOrecv(); + +#endif diff --git a/desmume/src/GPU.cpp b/src/GPU.cpp similarity index 68% rename from desmume/src/GPU.cpp rename to src/GPU.cpp index 13f177450..49924b41c 100644 --- a/desmume/src/GPU.cpp +++ b/src/GPU.cpp @@ -1,2791 +1,3099 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2006-2007 Theo Berkau - Copyright (C) 2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include -#include -#include -#include "MMU.h" -#include "GPU.h" -#include "debug.h" -#include "render3D.h" -#include "gfx3d.h" -#include "debug.h" -#include "GPU_osd.h" -#include "NDSSystem.h" -#include "readwrite.h" - -//#undef FORCEINLINE -//#define FORCEINLINE -//#define SSE2_NOINTRIN - -extern BOOL click; -NDS_Screen MainScreen; -NDS_Screen SubScreen; - -//instantiate static instance -GPU::MosaicLookup GPU::mosaicLookup; - -//#define DEBUG_TRI - -CACHE_ALIGN u8 GPU_screen[4*256*192]; -u8 *GPU_tempScanline; -CACHE_ALIGN u16 GPU_tempScanlineBuffer[256]; - -CACHE_ALIGN u8 sprWin[256]; - - -u16 gpu_angle = 0; - -const size sprSizeTab[4][4] = -{ - {{8, 8}, {16, 8}, {8, 16}, {8, 8}}, - {{16, 16}, {32, 8}, {8, 32}, {8, 8}}, - {{32, 32}, {32, 16}, {16, 32}, {8, 8}}, - {{64, 64}, {64, 32}, {32, 64}, {8, 8}}, -}; - - - -const BGType GPU_mode2type[8][4] = -{ - {BGType_Text, BGType_Text, BGType_Text, BGType_Text}, - {BGType_Text, BGType_Text, BGType_Text, BGType_Affine}, - {BGType_Text, BGType_Text, BGType_Affine, BGType_Affine}, - {BGType_Text, BGType_Text, BGType_Text, BGType_AffineExt}, - {BGType_Text, BGType_Text, BGType_Affine, BGType_AffineExt}, - {BGType_Text, BGType_Text, BGType_AffineExt, BGType_AffineExt}, - {BGType_Invalid, BGType_Invalid, BGType_Large8bpp, BGType_Invalid}, - {BGType_Invalid, BGType_Invalid, BGType_Invalid, BGType_Invalid} -}; - -const short sizeTab[8][4][2] = -{ - {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, //Invalid - {{256,256}, {512,256}, {256,512}, {512,512}}, //text - {{128,128}, {256,256}, {512,512}, {1024,1024}}, //affine - {{512,1024}, {1024,512}, {0,0}, {0,0}}, //large 8bpp - {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, //affine ext (to be elaborated with another value) - {{128,128}, {256,256}, {512,512}, {1024,1024}}, //affine ext 256x16 - {{128,128}, {256,256}, {512,256}, {512,512}}, //affine ext 256x1 - {{128,128}, {256,256}, {512,256}, {512,512}}, //affine ext direct -}; - -static GraphicsInterface_struct *GFXCore=NULL; - -// This should eventually be moved to the port specific code -GraphicsInterface_struct *GFXCoreList[] = { -&GFXDummy, -NULL -}; - -static const CACHE_ALIGN u8 win_empty[256] = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; -static CACHE_ALIGN u16 fadeInColors[17][0x8000]; -CACHE_ALIGN u16 fadeOutColors[17][0x8000]; - -//this should be public, because it gets used somewhere else -CACHE_ALIGN u8 gpuBlendTable555[17][17][32][32]; - - -/*****************************************************************************/ -// INITIALIZATION -/*****************************************************************************/ - - -static void GPU_InitFadeColors() -{ - /* - NOTE: gbatek (in the reference above) seems to expect 6bit values - per component, but as desmume works with 5bit per component, - we use 31 as top, instead of 63. Testing it on a few games, - using 63 seems to give severe color wraping, and 31 works - nicely, so for now we'll just that, until proven wrong. - - i have seen pics of pokemon ranger getting white with 31, with 63 it is nice. - it could be pb of alpha or blending or... - - MightyMax> created a test NDS to check how the brightness values work, - and 31 seems to be correct. FactorEx is a override for max brighten/darken - See: http://mightymax.org/gfx_test_brightness.nds - The Pokemon Problem could be a problem with 8/32 bit writes not recognized yet, - i'll add that so you can check back. - - */ - - for(int i = 0; i <= 16; i++) - { - for(int j = 0x8000; j < 0x10000; j++) - { - COLOR cur; - - cur.val = j; - cur.bits.red = (cur.bits.red + ((31 - cur.bits.red) * i / 16)); - cur.bits.green = (cur.bits.green + ((31 - cur.bits.green) * i / 16)); - cur.bits.blue = (cur.bits.blue + ((31 - cur.bits.blue) * i / 16)); - cur.bits.alpha = 0; - fadeInColors[i][j & 0x7FFF] = cur.val; - - cur.val = j; - cur.bits.red = (cur.bits.red - (cur.bits.red * i / 16)); - cur.bits.green = (cur.bits.green - (cur.bits.green * i / 16)); - cur.bits.blue = (cur.bits.blue - (cur.bits.blue * i / 16)); - cur.bits.alpha = 0; - fadeOutColors[i][j & 0x7FFF] = cur.val; - } - } - - - for(int c0=0;c0<=31;c0++) - for(int c1=0;c1<=31;c1++) - for(int eva=0;eva<=16;eva++) - for(int evb=0;evb<=16;evb++) - { - int blend = ((c0 * eva) + (c1 * evb) ) / 16; - int final = std::min(31,blend); - gpuBlendTable555[eva][evb][c0][c1] = final; - } -} - -static CACHE_ALIGN GPU GPU_main, GPU_sub; - -GPU * GPU_Init(u8 l) -{ - GPU * g; - - if(l==0) g = &GPU_main; - else g = &GPU_sub; - - GPU_Reset(g, l); - GPU_InitFadeColors(); - - g->curr_win[0] = win_empty; - g->curr_win[1] = win_empty; - g->need_update_winh[0] = true; - g->need_update_winh[1] = true; - g->setFinalColorBck_funcNum = 0; - g->setFinalColor3d_funcNum = 0; - g->setFinalColorSpr_funcNum = 0; - - return g; -} - -void GPU_Reset(GPU *g, u8 l) -{ - memset(g, 0, sizeof(GPU)); - - g->setFinalColorBck_funcNum = 0; - g->setFinalColor3d_funcNum = 0; - g->setFinalColorSpr_funcNum = 0; - g->core = l; - g->BGSize[0][0] = g->BGSize[1][0] = g->BGSize[2][0] = g->BGSize[3][0] = 256; - g->BGSize[0][1] = g->BGSize[1][1] = g->BGSize[2][1] = g->BGSize[3][1] = 256; - g->dispOBJ = g->dispBG[0] = g->dispBG[1] = g->dispBG[2] = g->dispBG[3] = TRUE; - - g->spriteRenderMode = GPU::SPRITE_1D; - - g->bgPrio[4] = 0xFF; - - g->bg0HasHighestPrio = TRUE; - - if(g->core == GPU_SUB) - { - g->oam = (OAM *)(MMU.ARM9_OAM + ADDRESS_STEP_1KB); - g->sprMem = MMU_BOBJ; - // GPU core B - g->dispx_st = (REG_DISPx*)(&MMU.ARM9_REG[REG_DISPB]); - } - else - { - g->oam = (OAM *)(MMU.ARM9_OAM); - g->sprMem = MMU_AOBJ; - // GPU core A - g->dispx_st = (REG_DISPx*)(&MMU.ARM9_REG[0]); - } -} - -void GPU_DeInit(GPU * gpu) -{ - if(gpu==&GPU_main || gpu==&GPU_sub) return; - free(gpu); -} - -static void GPU_resortBGs(GPU *gpu) -{ - int i, prio; - struct _DISPCNT * cnt = &gpu->dispx_st->dispx_DISPCNT.bits; - itemsForPriority_t * item; - - // we don't need to check for windows here... -// if we tick boxes, invisible layers become invisible & vice versa -#define OP ^ ! -// if we untick boxes, layers become invisible -//#define OP && - gpu->LayersEnable[0] = gpu->dispBG[0] OP(cnt->BG0_Enable/* && !(cnt->BG0_3D && (gpu->core==0))*/); - gpu->LayersEnable[1] = gpu->dispBG[1] OP(cnt->BG1_Enable); - gpu->LayersEnable[2] = gpu->dispBG[2] OP(cnt->BG2_Enable); - gpu->LayersEnable[3] = gpu->dispBG[3] OP(cnt->BG3_Enable); - gpu->LayersEnable[4] = gpu->dispOBJ OP(cnt->OBJ_Enable); - - // KISS ! lower priority first, if same then lower num - for (i=0;iitemsForPriority[i]); - item->nbBGs=0; - item->nbPixelsX=0; - } - for (i=NB_BG; i>0; ) { - i--; - if (!gpu->LayersEnable[i]) continue; - prio = (gpu->dispx_st)->dispx_BGxCNT[i].bits.Priority; - item = &(gpu->itemsForPriority[prio]); - item->BGs[item->nbBGs]=i; - item->nbBGs++; - } - - int bg0Prio = gpu->dispx_st->dispx_BGxCNT[0].bits.Priority; - gpu->bg0HasHighestPrio = TRUE; - for(i = 1; i < 4; i++) - { - if(gpu->LayersEnable[i]) - { - if(gpu->dispx_st->dispx_BGxCNT[i].bits.Priority < bg0Prio) - { - gpu->bg0HasHighestPrio = FALSE; - break; - } - } - } - -#if 0 -//debug - for (i=0;iitemsForPriority[i]); - printf("%d : ", i); - for (j=0; jnbBGs) - printf("BG%d ", item->BGs[j]); - else - printf("... ", item->BGs[j]); - } - } - printf("\n"); -#endif -} - -static FORCEINLINE u16 _blend(u16 colA, u16 colB, GPU::TBlendTable* blendTable) -{ - u8 r = (*blendTable)[colA&0x1F][colB&0x1F]; - u8 g = (*blendTable)[(colA>>5)&0x1F][(colB>>5)&0x1F]; - u8 b = (*blendTable)[(colA>>10)&0x1F][(colB>>10)&0x1F]; - - return r|(g<<5)|(b<<10); -} - -FORCEINLINE u16 GPU::blend(u16 colA, u16 colB) -{ - return _blend(colA, colB, blendTable); -} - - -void GPU_setMasterBrightness (GPU *gpu, u16 val) -{ - if(!nds.isInVblank()) { - PROGINFO("Changing master brightness outside of vblank\n"); - } - gpu->MasterBrightFactor = (val & 0x1F); - gpu->MasterBrightMode = (val>>14); - //printf("MASTER BRIGHTNESS %d to %d at %d\n",gpu->core,gpu->MasterBrightFactor,nds.VCount); - -} - -void SetupFinalPixelBlitter (GPU *gpu) -{ - u8 windowUsed = (gpu->WIN0_ENABLED | gpu->WIN1_ENABLED | gpu->WINOBJ_ENABLED); - u8 blendMode = (gpu->BLDCNT >> 6)&3; - - gpu->setFinalColorSpr_funcNum = windowUsed*4 + blendMode; - gpu->setFinalColorBck_funcNum = windowUsed*4 + blendMode; - gpu->setFinalColor3d_funcNum = windowUsed*4 + blendMode; - -} - -//Sets up LCD control variables for Display Engines A and B for quick reading -void GPU_setVideoProp(GPU * gpu, u32 p) -{ - struct _DISPCNT * cnt; - cnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; - - T1WriteLong((u8 *)&(gpu->dispx_st)->dispx_DISPCNT.val, 0, p); - - gpu->WIN0_ENABLED = cnt->Win0_Enable; - gpu->WIN1_ENABLED = cnt->Win1_Enable; - gpu->WINOBJ_ENABLED = cnt->WinOBJ_Enable; - - SetupFinalPixelBlitter (gpu); - - gpu->dispMode = cnt->DisplayMode & ((gpu->core)?1:3); - - gpu->vramBlock = cnt->VRAM_Block; - - switch (gpu->dispMode) - { - case 0: // Display Off - break; - case 1: // Display BG and OBJ layers - break; - case 2: // Display framebuffer - gpu->VRAMaddr = (u8 *)MMU.ARM9_LCD + (gpu->vramBlock * 0x20000); - break; - case 3: // Display from Main RAM - // nothing to be done here - // see GPU_ligne who gets data from FIFO. - break; - } - - if(cnt->OBJ_Tile_mapping) - { - //1-d sprite mapping boundaries: - //32k, 64k, 128k, 256k - gpu->sprBoundary = 5 + cnt->OBJ_Tile_1D_Bound ; - - //do not be deceived: even though a sprBoundary==8 (256KB region) is impossible to fully address - //in GPU_SUB, it is still fully legal to address it with that granularity. - //so don't do this: //if((gpu->core == GPU_SUB) && (cnt->OBJ_Tile_1D_Bound == 3)) gpu->sprBoundary = 7; - - gpu->spriteRenderMode = GPU::SPRITE_1D; - } else { - //2d sprite mapping - //boundary : 32k - gpu->sprBoundary = 5; - gpu->spriteRenderMode = GPU::SPRITE_2D; - } - - if(cnt->OBJ_BMP_1D_Bound && (gpu->core == GPU_MAIN)) - gpu->sprBMPBoundary = 8; - else - gpu->sprBMPBoundary = 7; - - gpu->sprEnable = cnt->OBJ_Enable; - - GPU_setBGProp(gpu, 3, T1ReadWord(MMU.ARM9_REG, gpu->core * ADDRESS_STEP_4KB + 14)); - GPU_setBGProp(gpu, 2, T1ReadWord(MMU.ARM9_REG, gpu->core * ADDRESS_STEP_4KB + 12)); - GPU_setBGProp(gpu, 1, T1ReadWord(MMU.ARM9_REG, gpu->core * ADDRESS_STEP_4KB + 10)); - GPU_setBGProp(gpu, 0, T1ReadWord(MMU.ARM9_REG, gpu->core * ADDRESS_STEP_4KB + 8)); - - //GPU_resortBGs(gpu); -} - -//this handles writing in BGxCNT -void GPU_setBGProp(GPU * gpu, u16 num, u16 p) -{ - struct _BGxCNT * cnt = &((gpu->dispx_st)->dispx_BGxCNT[num].bits); - struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; - - T1WriteWord((u8 *)&(gpu->dispx_st)->dispx_BGxCNT[num].val, 0, p); - - GPU_resortBGs(gpu); - - if(gpu->core == GPU_SUB) - { - gpu->BG_tile_ram[num] = MMU_BBG; - gpu->BG_bmp_ram[num] = MMU_BBG; - gpu->BG_bmp_large_ram[num] = MMU_BBG; - gpu->BG_map_ram[num] = MMU_BBG; - } - else - { - gpu->BG_tile_ram[num] = MMU_ABG + dispCnt->CharacBase_Block * ADDRESS_STEP_64KB ; - gpu->BG_bmp_ram[num] = MMU_ABG; - gpu->BG_bmp_large_ram[num] = MMU_ABG; - gpu->BG_map_ram[num] = MMU_ABG + dispCnt->ScreenBase_Block * ADDRESS_STEP_64KB; - } - - gpu->BG_tile_ram[num] += (cnt->CharacBase_Block * ADDRESS_STEP_16KB); - gpu->BG_bmp_ram[num] += (cnt->ScreenBase_Block * ADDRESS_STEP_16KB); - gpu->BG_map_ram[num] += (cnt->ScreenBase_Block * ADDRESS_STEP_2KB); - - switch(num) - { - case 0: - case 1: - gpu->BGExtPalSlot[num] = cnt->PaletteSet_Wrap * 2 + num ; - break; - - default: - gpu->BGExtPalSlot[num] = (u8)num; - break; - } - - BGType mode = GPU_mode2type[dispCnt->BG_Mode][num]; - - //clarify affine ext modes - if(mode == BGType_AffineExt) - { - //see: http://nocash.emubase.de/gbatek.htm#dsvideobgmodescontrol - u8 affineModeSelection = (cnt->Palette_256 << 1) | (cnt->CharacBase_Block & 1) ; - switch(affineModeSelection) - { - case 0: - case 1: - mode = BGType_AffineExt_256x16; - break; - case 2: - mode = BGType_AffineExt_256x1; - break; - case 3: - mode = BGType_AffineExt_Direct; - break; - } - } - - gpu->BGTypes[num] = mode; - - gpu->BGSize[num][0] = sizeTab[mode][cnt->ScreenSize][0]; - gpu->BGSize[num][1] = sizeTab[mode][cnt->ScreenSize][1]; - - gpu->bgPrio[num] = (p & 0x3); -} - -/*****************************************************************************/ -// ENABLING / DISABLING LAYERS -/*****************************************************************************/ - -void GPU_remove(GPU * gpu, u8 num) -{ - if (num == 4) gpu->dispOBJ = 0; - else gpu->dispBG[num] = 0; - GPU_resortBGs(gpu); -} -void GPU_addBack(GPU * gpu, u8 num) -{ - //REG_DISPx_pack_test(gpu); - if (num == 4) gpu->dispOBJ = 1; - else gpu->dispBG[num] = 1; - GPU_resortBGs(gpu); -} - - -/*****************************************************************************/ -// ROUTINES FOR INSIDE / OUTSIDE WINDOW CHECKS -/*****************************************************************************/ - -template -FORCEINLINE u8 GPU::withinRect(u16 x) const -{ - assert(x<256); //only way to be >256 is in debug views, and mosaic shouldnt be enabled for those - return curr_win[WIN_NUM][x]; -} - - - -// Now assumes that *draw and *effect are different from 0 when called, so we can avoid -// setting some values twice -FORCEINLINE void GPU::renderline_checkWindows(u16 x, bool &draw, bool &effect) const -{ - // Check if win0 if enabled, and only check if it is - // howevever, this has already been taken care of by the window precalculation - //if (WIN0_ENABLED) - { - // it is in win0, do we display ? - // high priority - if (withinRect<0>(x)) - { - //INFO("bg%i passed win0 : (%i %i) was within (%i %i)(%i %i)\n", bgnum, x, gpu->currLine, gpu->WIN0H0, gpu->WIN0V0, gpu->WIN0H1, gpu->WIN0V1); - draw = (WININ0 >> currBgNum)&1; - effect = (WININ0_SPECIAL); - return; - } - } - - // Check if win1 if enabled, and only check if it is - //if (WIN1_ENABLED) - // howevever, this has already been taken care of by the window precalculation - { - // it is in win1, do we display ? - // mid priority - if(withinRect<1>(x)) - { - //INFO("bg%i passed win1 : (%i %i) was within (%i %i)(%i %i)\n", bgnum, x, gpu->currLine, gpu->WIN1H0, gpu->WIN1V0, gpu->WIN1H1, gpu->WIN1V1); - draw = (WININ1 >> currBgNum)&1; - effect = (WININ1_SPECIAL); - return; - } - } - - //if(true) //sprwin test hack - if (WINOBJ_ENABLED) - { - // it is in winOBJ, do we display ? - // low priority - if (sprWin[x]) - { - draw = (WINOBJ >> currBgNum)&1; - effect = (WINOBJ_SPECIAL); - return; - } - } - - if (WINOBJ_ENABLED | WIN1_ENABLED | WIN0_ENABLED) - { - draw = (WINOUT >> currBgNum) & 1; - effect = (WINOUT_SPECIAL); - } -} - -/*****************************************************************************/ -// PIXEL RENDERING -/*****************************************************************************/ - -template -FORCEINLINE FASTCALL void GPU::_master_setFinal3dColor(int dstX, int srcX) -{ - int x = dstX; - int passing = dstX<<1; - u8* color = &_3dColorLine[srcX<<2]; - u8 red = color[0]; - u8 green = color[1]; - u8 blue = color[2]; - u8 alpha = color[3]; - u8* dst = currDst; - u16 final; - - bool windowEffect = true; - - if(WINDOW) - { - bool windowDraw = false; - renderline_checkWindows(dstX, windowDraw, windowEffect); - - //we never have anything more to do if the window rejected us - if(!windowDraw) return; - } - - int bg_under = bgPixels[dstX]; - if(blend2[bg_under]) - { - alpha++; - if(alpha<32) - { - //if the layer underneath is a blend bottom layer, then 3d always alpha blends with it - COLOR c2, cfinal; - - c2.val = T2ReadWord(dst, passing); - - cfinal.bits.red = ((red * alpha) + ((c2.bits.red<<1) * (32 - alpha)))>>6; - cfinal.bits.green = ((green * alpha) + ((c2.bits.green<<1) * (32 - alpha)))>>6; - cfinal.bits.blue = ((blue * alpha) + ((c2.bits.blue<<1) * (32 - alpha)))>>6; - - final = cfinal.val; - } - else final = R6G6B6TORGB15(red,green,blue); - } - else - { - final = R6G6B6TORGB15(red,green,blue); - //perform the special effect - if(windowEffect) - switch(FUNC) { - case Increase: final = currentFadeInColors[final&0x7FFF]; break; - case Decrease: final = currentFadeOutColors[final&0x7FFF]; break; - case None: - case Blend: - break; - } - } - - T2WriteWord(dst, passing, (final | 0x8000)); - bgPixels[x] = 0; -} - - -template -FORCEINLINE FASTCALL bool GPU::_master_setFinalBGColor(u16 &color, const u32 x) -{ - //no further analysis for no special effects. on backdrops. just draw it. - if(FUNC==None && BACKDROP) return true; - - //blend backdrop with what?? this doesn't make sense - if(FUNC==Blend && BACKDROP) return true; - - bool windowEffect = true; - - if(WINDOW) - { - bool windowDraw = false; - renderline_checkWindows(x, windowDraw, windowEffect); - - //backdrop must always be drawn - if(BACKDROP) windowDraw = true; - - //we never have anything more to do if the window rejected us - if(!windowDraw) return false; - } - - //special effects rejected. just draw it. - if(!(blend1 && windowEffect)) - return true; - - const u8 bg_under = bgPixels[x]; - - //perform the special effect - switch(FUNC) { - case Blend: if(blend2[bg_under]) color = blend(color,T2ReadWord(currDst, x<<1)); break; - case Increase: color = currentFadeInColors[color]; break; - case Decrease: color = currentFadeOutColors[color]; break; - case None: break; - } - return true; -} - -template -static FORCEINLINE void _master_setFinalOBJColor(GPU *gpu, u8 *dst, u16 color, u8 alpha, u8 type, u16 x) -{ - bool windowDraw = true, windowEffect = true; - - if(WINDOW) - { - gpu->renderline_checkWindows(x, windowDraw, windowEffect); - if(!windowDraw) - return; - } - - //this inspects the layer beneath the sprite to see if the current blend flags make it a candidate for blending - const int bg_under = gpu->bgPixels[x]; - const bool allowBlend = (bg_under != 4) && gpu->blend2[bg_under]; - - const bool sourceEffectSelected = gpu->blend1; - - //note that the fadein and fadeout is done here before blending, - //so that a fade and blending can be applied at the same time (actually, I don't think that is legal..) - bool forceBlendingForNormal = false; - if(windowEffect && sourceEffectSelected) - switch(FUNC) - { - case Increase: if(!allowBlend) color = gpu->currentFadeInColors[color&0x7FFF]; break; - case Decrease: if(!allowBlend) color = gpu->currentFadeOutColors[color&0x7FFF]; break; - - //only when blend color effect is selected, ordinarily opaque sprites are blended with the color effect params - case Blend: forceBlendingForNormal = true; break; - case None: break; - } - - - if(allowBlend) - { - u16 backColor = T2ReadWord(dst,x<<1); - //this hasn't been tested: this blending occurs without regard to the color effect, - //but rather purely from the sprite's alpha - if(type == GPU_OBJ_MODE_Bitmap) - color = _blend(color,backColor,&gpuBlendTable555[alpha+1][15-alpha]); - else if(type == GPU_OBJ_MODE_Transparent || forceBlendingForNormal) - color = gpu->blend(color,backColor); - } - - T2WriteWord(dst, x<<1, (color | 0x8000)); - gpu->bgPixels[x] = 4; -} - -//FUNCNUM is only set for backdrop, for an optimization of looking it up early -template -FORCEINLINE void GPU::setFinalColorBG(u16 color, const u32 x) -{ - //It is not safe to assert this here. - //This is probably the best place to enforce it, since almost every single color that comes in here - //will be pulled from a palette that needs the top bit stripped off anyway. - //assert((color&0x8000)==0); - if(!BACKDROP) color &= 0x7FFF; //but for the backdrop we can easily guarantee earlier that theres no bit here - - bool draw; - - const int test = BACKDROP?FUNCNUM:setFinalColorBck_funcNum; - switch(test) - { - case 0: draw = _master_setFinalBGColor(color,x); break; - case 1: draw = _master_setFinalBGColor(color,x); break; - case 2: draw = _master_setFinalBGColor(color,x); break; - case 3: draw = _master_setFinalBGColor(color,x); break; - case 4: draw = _master_setFinalBGColor(color,x); break; - case 5: draw = _master_setFinalBGColor(color,x); break; - case 6: draw = _master_setFinalBGColor(color,x); break; - case 7: draw = _master_setFinalBGColor(color,x); break; - }; - - if(BACKDROP || draw) //backdrop must always be drawn - { - T2WriteWord(currDst, x<<1, color | 0x8000); - if(!BACKDROP) bgPixels[x] = currBgNum; //lets do this in the backdrop drawing loop, should be faster - } -} - - -FORCEINLINE void GPU::setFinalColor3d(int dstX, int srcX) -{ - switch(setFinalColor3d_funcNum) - { - case 0x0: _master_setFinal3dColor(dstX,srcX); break; - case 0x1: _master_setFinal3dColor(dstX,srcX); break; - case 0x2: _master_setFinal3dColor(dstX,srcX); break; - case 0x3: _master_setFinal3dColor(dstX,srcX); break; - case 0x4: _master_setFinal3dColor(dstX,srcX); break; - case 0x5: _master_setFinal3dColor(dstX,srcX); break; - case 0x6: _master_setFinal3dColor(dstX,srcX); break; - case 0x7: _master_setFinal3dColor(dstX,srcX); break; - }; -} - -FORCEINLINE void setFinalColorSpr(GPU* gpu, u8 *dst, u16 color, u8 alpha, u8 type, u16 x) -{ - switch(gpu->setFinalColorSpr_funcNum) - { - case 0x0: _master_setFinalOBJColor(gpu, dst, color, alpha, type, x); break; - case 0x1: _master_setFinalOBJColor(gpu, dst, color, alpha, type, x); break; - case 0x2: _master_setFinalOBJColor(gpu, dst, color, alpha, type, x); break; - case 0x3: _master_setFinalOBJColor(gpu, dst, color, alpha, type, x); break; - case 0x4: _master_setFinalOBJColor(gpu, dst, color, alpha, type, x); break; - case 0x5: _master_setFinalOBJColor(gpu, dst, color, alpha, type, x); break; - case 0x6: _master_setFinalOBJColor(gpu, dst, color, alpha, type, x); break; - case 0x7: _master_setFinalOBJColor(gpu, dst, color, alpha, type, x); break; - }; -} - -template -FORCEINLINE void GPU::__setFinalColorBck(u16 color, const u32 x, const int opaque) -{ - return ___setFinalColorBck(color,x,opaque); -} - -//this was forced inline because most of the time it just falls through to setFinalColorBck() and the function call -//overhead was ridiculous and terrible -template -FORCEINLINE void GPU::___setFinalColorBck(u16 color, const u32 x, const int opaque) -{ - //under ordinary circumstances, nobody should pass in something >=256 - //but in fact, someone is going to try. specifically, that is the map viewer debug tools - //which try to render the enter BG. in cases where that is large, it could be up to 1024 wide. - assert(debug || x<256); - - int x_int; - - //due to this early out, we will get incorrect behavior in cases where - //we enable mosaic in the middle of a frame. this is deemed unlikely. - if(!MOSAIC) { - if(opaque) goto finish; - else return; - } - - if(!opaque) color = 0xFFFF; - else color &= 0x7FFF; - - //due to the early out, enabled must always be true - //x_int = enabled ? GPU::mosaicLookup.width[x].trunc : x; - x_int = GPU::mosaicLookup.width[x].trunc; - - if(GPU::mosaicLookup.width[x].begin && GPU::mosaicLookup.height[currLine].begin) {} - else color = mosaicColors.bg[currBgNum][x_int]; - mosaicColors.bg[currBgNum][x] = color; - - if(color != 0xFFFF) - { -finish: - setFinalColorBG(color,x); - } -} - -//this is fantastically inaccurate. -//we do the early return even though it reduces the resulting accuracy -//because we need the speed, and because it is inaccurate anyway -static void mosaicSpriteLinePixel(GPU * gpu, int x, u16 l, u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab) -{ - int x_int; - int y = l; - - _OAM_ * spriteInfo = (_OAM_ *)(gpu->oam + gpu->sprNum[x]); - bool enabled = spriteInfo->Mosaic; - if(!enabled) - return; - - bool opaque = prioTab[x] <= 4; - - GPU::MosaicColor::Obj objColor; - objColor.color = T1ReadWord(dst,x<<1); - objColor.alpha = dst_alpha[x]; - objColor.opaque = opaque; - - x_int = enabled ? GPU::mosaicLookup.width[x].trunc : x; - - if(enabled) - { - if(GPU::mosaicLookup.width[x].begin && GPU::mosaicLookup.height[y].begin) {} - else objColor = gpu->mosaicColors.obj[x_int]; - } - gpu->mosaicColors.obj[x] = objColor; - - T1WriteWord(dst,x<<1,objColor.color); - dst_alpha[x] = objColor.alpha; - if(!objColor.opaque) prioTab[x] = 0xFF; -} - -FORCEINLINE static void mosaicSpriteLine(GPU * gpu, u16 l, u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab) -{ - //don't even try this unless the mosaic is effective - if(gpu->mosaicLookup.widthValue != 0 || gpu->mosaicLookup.heightValue != 0) - for(int i=0;i<256;i++) - mosaicSpriteLinePixel(gpu,i,l,dst,dst_alpha,typeTab,prioTab); -} - -template void lineLarge8bpp(GPU * gpu) -{ - if(gpu->core == 1) { - PROGINFO("Cannot use large 8bpp screen on sub core\n"); - return; - } - - BGxOFS * ofs = &gpu->dispx_st->dispx_BGxOFS[gpu->currBgNum]; - u8 num = gpu->currBgNum; - u16 XBG = T1ReadWord((u8 *)&ofs->BGxHOFS, 0); - u16 YBG = gpu->currLine + T1ReadWord((u8 *)&ofs->BGxVOFS, 0); - u16 lg = gpu->BGSize[num][0]; - u16 ht = gpu->BGSize[num][1]; - u16 wmask = (lg-1); - u16 hmask = (ht-1); - YBG &= hmask; - - //TODO - handle wrapping / out of bounds correctly from rot_scale_op? - - u32 tmp_map = gpu->BG_bmp_large_ram[num] + lg * YBG; - u8* map = MMU_gpu_map(tmp_map); - - u8* pal = MMU.ARM9_VMEM + gpu->core * ADDRESS_STEP_1KB; - - for(int x = 0; x < lg; ++x, ++XBG) - { - XBG &= wmask; - u8 pixel = map[XBG]; - u16 color = T1ReadWord(pal, pixel<<1); - gpu->__setFinalColorBck(color,x,color); - } - -} - -/*****************************************************************************/ -// BACKGROUND RENDERING -TEXT- -/*****************************************************************************/ -// render a text background to the combined pixelbuffer -template INLINE void renderline_textBG(GPU * gpu, u16 XBG, u16 YBG, u16 LG) -{ - u8 num = gpu->currBgNum; - struct _BGxCNT *bgCnt = &(gpu->dispx_st)->dispx_BGxCNT[num].bits; - struct _DISPCNT *dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; - u16 lg = gpu->BGSize[num][0]; - u16 ht = gpu->BGSize[num][1]; - u16 wmask = (lg-1); - u16 hmask = (ht-1); - u16 tmp = ((YBG & hmask) >> 3); - u32 map; - u8 *pal, *line; - u32 tile; - u16 color; - u16 xoff; - u16 yoff; - u32 x = 0; - u32 xfin; - - s8 line_dir = 1; - u32 mapinfo; - TILEENTRY tileentry; - - u32 tmp_map = gpu->BG_map_ram[num] + (tmp&31) * 64; - if(tmp>31) - tmp_map+= ADDRESS_STEP_512B << bgCnt->ScreenSize ; - - map = tmp_map; - tile = gpu->BG_tile_ram[num]; - - xoff = XBG; - pal = MMU.ARM9_VMEM + gpu->core * ADDRESS_STEP_1KB; - - if(!bgCnt->Palette_256) // color: 16 palette entries - { - yoff = ((YBG&7)<<2); - xfin = 8 - (xoff&7); - for(x = 0; x < LG; xfin = std::min(x+8, LG)) - { - u16 tilePalette = 0; - tmp = ((xoff&wmask)>>3); - mapinfo = map + (tmp&0x1F) * 2; - if(tmp>31) mapinfo += 32*32*2; - tileentry.val = T1ReadWord(MMU_gpu_map(mapinfo), 0); - - tilePalette = (tileentry.bits.Palette*16); - - line = (u8*)MMU_gpu_map(tile + (tileentry.bits.TileNum * 0x20) + ((tileentry.bits.VFlip) ? (7*4)-yoff : yoff)); - - if(tileentry.bits.HFlip) - { - line += (3 - ((xoff&7)>>1)); - for(; x < xfin; line --) - { - u8 currLine = *line; - - if(!(xoff&1)) - { - color = T1ReadWord(pal, ((currLine>>4) + tilePalette) << 1); - gpu->__setFinalColorBck(color,x,currLine>>4); - x++; xoff++; - } - - if(x__setFinalColorBck(color,x,currLine&0xF); - x++; xoff++; - } - } - } else { - line += ((xoff&7)>>1); - for(; x < xfin; line ++) - { - u8 currLine = *line; - - if(!(xoff&1)) - { - color = T1ReadWord(pal, ((currLine&0xF) + tilePalette) << 1); - gpu->__setFinalColorBck(color,x,currLine&0xF); - x++; xoff++; - } - - if(x>4) + tilePalette) << 1); - gpu->__setFinalColorBck(color,x,currLine>>4); - x++; xoff++; - } - } - } - } - return; - } - - //256-color BG - - if(dispCnt->ExBGxPalette_Enable) // color: extended palette - { - pal = MMU.ExtPal[gpu->core][gpu->BGExtPalSlot[num]]; - if(!pal) return; - } - - yoff = ((YBG&7)<<3); - - xfin = 8 - (xoff&7); - for(x = 0; x < LG; xfin = std::min(x+8, LG)) - { - tmp = (xoff & (lg-1))>>3; - mapinfo = map + (tmp & 31) * 2; - if(tmp > 31) mapinfo += 32*32*2; - tileentry.val = T1ReadWord(MMU_gpu_map(mapinfo), 0); - - line = (u8*)MMU_gpu_map(tile + (tileentry.bits.TileNum*0x40) + ((tileentry.bits.VFlip) ? (7*8)-yoff : yoff)); - - if(tileentry.bits.HFlip) - { - line += (7 - (xoff&7)); - line_dir = -1; - } else { - line += (xoff&7); - line_dir = 1; - } - for(; x < xfin; ) - { - if(dispCnt->ExBGxPalette_Enable) - color = T1ReadWord(pal, ((*line) + (tileentry.bits.Palette<<8)) << 1); - else - color = T1ReadWord(pal, (*line) << 1); - - gpu->__setFinalColorBck(color,x,*line); - - x++; xoff++; - - line += line_dir; - } - } -} - -/*****************************************************************************/ -// BACKGROUND RENDERING -ROTOSCALE- -/*****************************************************************************/ - -template FORCEINLINE void rot_tiled_8bit_entry(GPU * gpu, s32 auxX, s32 auxY, int lg, u32 map, u32 tile, u8 * pal, int i, u8 extPal) { - u8 palette_entry; - u16 tileindex, x, y, color; - - tileindex = *(u8*)MMU_gpu_map(map + ((auxX>>3) + (auxY>>3) * (lg>>3))); - - x = (auxX&7); - y = (auxY&7); - - palette_entry = *(u8*)MMU_gpu_map(tile + ((tileindex<<6)+(y<<3)+x)); - color = T1ReadWord(pal, palette_entry << 1); - gpu->__setFinalColorBck(color,i,palette_entry); -} - -template FORCEINLINE void rot_tiled_16bit_entry(GPU * gpu, s32 auxX, s32 auxY, int lg, u32 map, u32 tile, u8 * pal, int i, u8 extPal) { - u8 palette_entry; - u16 x, y, color; - TILEENTRY tileentry; - - void* map_addr = MMU_gpu_map(map + (((auxX>>3) + (auxY>>3) * (lg>>3))<<1)); - - tileentry.val = T1ReadWord(map_addr, 0); - - x = (tileentry.bits.HFlip) ? 7 - (auxX&7) : (auxX&7); - y = (tileentry.bits.VFlip) ? 7 - (auxY&7) : (auxY&7); - - palette_entry = *(u8*)MMU_gpu_map(tile + ((tileentry.bits.TileNum<<6)+(y<<3)+x)); - color = T1ReadWord(pal, (palette_entry + (extPal ? (tileentry.bits.Palette<<8) : 0)) << 1); - gpu->__setFinalColorBck(color, i, palette_entry); -} - -template FORCEINLINE void rot_256_map(GPU * gpu, s32 auxX, s32 auxY, int lg, u32 map, u32 tile, u8 * pal, int i, u8 extPal) { - u8 palette_entry; - u16 color; - - u8* adr = (u8*)MMU_gpu_map((map) + ((auxX + auxY * lg))); - - palette_entry = *adr; - color = T1ReadWord(pal, palette_entry << 1); - gpu->__setFinalColorBck(color, i, palette_entry); -} - -template FORCEINLINE void rot_BMP_map(GPU * gpu, s32 auxX, s32 auxY, int lg, u32 map, u32 tile, u8 * pal, int i, u8 extPal) { - u16 color; - void* adr = MMU_gpu_map((map) + ((auxX + auxY * lg) << 1)); - color = T1ReadWord(adr, 0); - gpu->__setFinalColorBck(color, i, color&0x8000); -} - -typedef void (*rot_fun)(GPU * gpu, s32 auxX, s32 auxY, int lg, u32 map, u32 tile, u8 * pal , int i, u8 extPal); - -template -FORCEINLINE void rot_scale_op(GPU * gpu, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, u16 LG, s32 wh, s32 ht, BOOL wrap, u32 map, u32 tile, u8 * pal, u8 extPal) -{ - ROTOCOORD x, y; - x.val = X; - y.val = Y; - - const s32 dx = (s32)PA; - const s32 dy = (s32)PC; - - for(int i = 0; i < LG; ++i) - { - s32 auxX, auxY; - auxX = x.bits.Integer; - auxY = y.bits.Integer; - - bool checkBounds = true; - if(wrap) - { - auxX = auxX & (wh-1); - auxY = auxY & (ht-1); - - //since we just wrapped, we dont need to check bounds - checkBounds = false; - } - - if(!checkBounds || ((auxX >= 0) && (auxX < wh) && (auxY >= 0) && (auxY < ht))) - fun(gpu, auxX, auxY, wh, map, tile, pal, i, extPal); - - x.val += dx; - y.val += dy; - } -} - -template -FORCEINLINE void apply_rot_fun(GPU * gpu, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, u16 LG, u32 map, u32 tile, u8 * pal, u8 extPal) -{ - struct _BGxCNT * bgCnt = &(gpu->dispx_st)->dispx_BGxCNT[gpu->currBgNum].bits; - s32 wh = gpu->BGSize[gpu->currBgNum][0]; - s32 ht = gpu->BGSize[gpu->currBgNum][1]; - rot_scale_op(gpu, X, Y, PA, PB, PC, PD, LG, wh, ht, bgCnt->PaletteSet_Wrap, map, tile, pal, extPal); -} - - -template FORCEINLINE void rotBG2(GPU * gpu, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, u16 LG) -{ - u8 num = gpu->currBgNum; - u8 * pal = MMU.ARM9_VMEM + gpu->core * 0x400; -// printf("rot mode\n"); - apply_rot_fun >(gpu,X,Y,PA,PB,PC,PD,LG, gpu->BG_map_ram[num], gpu->BG_tile_ram[num], pal, 0); -} - -template FORCEINLINE void extRotBG2(GPU * gpu, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, s16 LG) -{ - u8 num = gpu->currBgNum; - struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; - - u8 *pal; - - switch(gpu->BGTypes[num]) - { - case BGType_AffineExt_256x16: - if(dispCnt->ExBGxPalette_Enable) - pal = MMU.ExtPal[gpu->core][gpu->BGExtPalSlot[num]]; - else - pal = MMU.ARM9_VMEM + gpu->core * 0x400; - if (!pal) return; - // 16 bit bgmap entries - apply_rot_fun >(gpu,X,Y,PA,PB,PC,PD,LG, gpu->BG_map_ram[num], gpu->BG_tile_ram[num], pal, dispCnt->ExBGxPalette_Enable); - return; - case BGType_AffineExt_256x1: - // 256 colors - pal = MMU.ARM9_VMEM + gpu->core * 0x400; - apply_rot_fun >(gpu,X,Y,PA,PB,PC,PD,LG, gpu->BG_bmp_ram[num], NULL, pal, 0); - return; - case BGType_AffineExt_Direct: - // direct colors / BMP - apply_rot_fun >(gpu,X,Y,PA,PB,PC,PD,LG, gpu->BG_bmp_ram[num], NULL, NULL, 0); - return; - case BGType_Large8bpp: - // large screen 256 colors - pal = MMU.ARM9_VMEM + gpu->core * 0x400; - apply_rot_fun >(gpu,X,Y,PA,PB,PC,PD,LG, gpu->BG_bmp_large_ram[num], NULL, pal, 0); - return; - default: break; - } -} - -/*****************************************************************************/ -// BACKGROUND RENDERING -HELPER FUNCTIONS- -/*****************************************************************************/ - -#if 0 -static void lineNull(GPU * gpu) -{ -} -#endif - -template void lineText(GPU * gpu) -{ - BGxOFS * ofs = &gpu->dispx_st->dispx_BGxOFS[gpu->currBgNum]; - - - - if(gpu->debug) - { - const s32 wh = gpu->BGSize[gpu->currBgNum][0]; - renderline_textBG(gpu, 0, gpu->currLine, wh); - } - else - { - const u16 vofs = T1ReadWord((u8 *)&ofs->BGxVOFS,0); - const u16 hofs = T1ReadWord((u8 *)&ofs->BGxHOFS,0); - renderline_textBG(gpu, hofs, gpu->currLine + vofs, 256); - } -} - -template void lineRot(GPU * gpu) -{ - BGxPARMS * parms; - if (gpu->currBgNum==2) { - parms = &(gpu->dispx_st)->dispx_BG2PARMS; - } else { - parms = &(gpu->dispx_st)->dispx_BG3PARMS; - } - - if(gpu->debug) - { - s32 wh = gpu->BGSize[gpu->currBgNum][0]; - rotBG2(gpu, 0, (s16)gpu->currLine*256, 256,0, 0,-77, wh); - } - else - { - rotBG2(gpu, - parms->BGxX, - parms->BGxY, - parms->BGxPA, - parms->BGxPB, - parms->BGxPC, - parms->BGxPD, - 256); - parms->BGxX += parms->BGxPB; - parms->BGxY += parms->BGxPD; - } -} - -template void lineExtRot(GPU * gpu) -{ - BGxPARMS * parms; - if (gpu->currBgNum==2) { - parms = &(gpu->dispx_st)->dispx_BG2PARMS; - } else { - parms = &(gpu->dispx_st)->dispx_BG3PARMS; - } - - if(gpu->debug) - { - s32 wh = gpu->BGSize[gpu->currBgNum][0]; - extRotBG2(gpu, 0, (s16)gpu->currLine*256, 256,0, 0,-77, wh); - } - else - { - extRotBG2(gpu, - parms->BGxX, - parms->BGxY, - parms->BGxPA, - parms->BGxPB, - parms->BGxPC, - parms->BGxPD, - 256); - parms->BGxX += parms->BGxPB; - parms->BGxY += parms->BGxPD; - } -} - -/*****************************************************************************/ -// SPRITE RENDERING -HELPER FUNCTIONS- -/*****************************************************************************/ - -#define nbShow 128 - -/* if i understand it correct, and it fixes some sprite problems in chameleon shot */ -/* we have a 15 bit color, and should use the pal entry bits as alpha ?*/ -/* http://nocash.emubase.de/gbatek.htm#dsvideoobjs */ -INLINE void render_sprite_BMP (GPU * gpu, u8 spriteNum, u16 l, u8 * dst, u16 * src, u8 * dst_alpha, u8 * typeTab, u8 * prioTab, - u8 prio, int lg, int sprX, int x, int xdir, u8 alpha) -{ - int i; u16 color; - for(i = 0; i < lg; i++, ++sprX, x+=xdir) - { - color = LE_TO_LOCAL_16(src[x]); - - // alpha bit = invisible - if ((color&0x8000)&&(prio<=prioTab[sprX])) - { - /* if we don't draw, do not set prio, or else */ - // if (gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, color, sprX)) - { - T2WriteWord(dst, (sprX<<1), color); - dst_alpha[sprX] = alpha; - typeTab[sprX] = 3; - prioTab[sprX] = prio; - gpu->sprNum[sprX] = spriteNum; - } - } - } -} - -INLINE void render_sprite_256 ( GPU * gpu, u8 spriteNum, u16 l, u8 * dst, u8 * src, u16 * pal, - u8 * dst_alpha, u8 * typeTab, u8 * prioTab, u8 prio, int lg, int sprX, int x, int xdir, u8 alpha) -{ - int i; - u8 palette_entry; - u16 color; - - for(i = 0; i < lg; i++, ++sprX, x+=xdir) - { - palette_entry = src[(x&0x7) + ((x&0xFFF8)<<3)]; - color = LE_TO_LOCAL_16(pal[palette_entry]); - - // palette entry = 0 means backdrop - if ((palette_entry>0)&&(prio<=prioTab[sprX])) - { - /* if we don't draw, do not set prio, or else */ - //if (gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, color, sprX)) - { - T2WriteWord(dst, (sprX<<1), color); - dst_alpha[sprX] = 16; - typeTab[sprX] = (alpha ? 1 : 0); - prioTab[sprX] = prio; - gpu->sprNum[sprX] = spriteNum; - } - } - } -} - -INLINE void render_sprite_16 ( GPU * gpu, u16 l, u8 * dst, u8 * src, u16 * pal, - u8 * dst_alpha, u8 * typeTab, u8 * prioTab, u8 prio, int lg, int sprX, int x, int xdir, u8 alpha) -{ - int i; - u8 palette, palette_entry; - u16 color, x1; - - for(i = 0; i < lg; i++, ++sprX, x+=xdir) - { - x1 = x>>1; - palette = src[(x1&0x3) + ((x1&0xFFFC)<<3)]; - if (x & 1) palette_entry = palette >> 4; - else palette_entry = palette & 0xF; - color = LE_TO_LOCAL_16(pal[palette_entry]); - - // palette entry = 0 means backdrop - if ((palette_entry>0)&&(prio<=prioTab[sprX])) - { - /* if we don't draw, do not set prio, or else */ - //if (gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, color, sprX )) - { - T2WriteWord(dst, (sprX<<1), color); - dst_alpha[sprX] = 16; - typeTab[sprX] = (alpha ? 1 : 0); - prioTab[sprX] = prio; - } - } - } -} - -INLINE void render_sprite_Win (GPU * gpu, u16 l, u8 * src, - int col256, int lg, int sprX, int x, int xdir) { - int i; u8 palette, palette_entry; - u16 x1; - if (col256) { - for(i = 0; i < lg; i++, sprX++,x+=xdir) - //sprWin[sprX] = (src[x])?1:0; - if(src[x]) - sprWin[sprX] = 1; - } else { - for(i = 0; i < lg; i++, ++sprX, x+=xdir) - { - x1 = x>>1; - palette = src[(x1&0x3) + ((x1&0xFFFC)<<3)]; - if (x & 1) palette_entry = palette >> 4; - else palette_entry = palette & 0xF; - //sprWin[sprX] = (palette_entry)?1:0; - if(palette_entry) - sprWin[sprX] = 1; - } - } -} - -// return val means if the sprite is to be drawn or not -FORCEINLINE BOOL compute_sprite_vars(_OAM_ * spriteInfo, u16 l, - size &sprSize, s32 &sprX, s32 &sprY, s32 &x, s32 &y, s32 &lg, int &xdir) { - - x = 0; - // get sprite location and size - sprX = (spriteInfo->X/*<<23*/)/*>>23*/; - sprY = spriteInfo->Y; - sprSize = sprSizeTab[spriteInfo->Size][spriteInfo->Shape]; - - lg = sprSize.x; - - if (sprY>=192) - sprY = (s32)((s8)(spriteInfo->Y)); - -// FIXME: for rot/scale, a list of entries into the sprite should be maintained, -// that tells us where the first pixel of a screenline starts in the sprite, -// and how a step to the right in a screenline translates within the sprite - - if ((l=sprY+sprSize.y) || /* sprite lines outside of screen */ - (sprX==256)||(sprX+sprSize.x<=0)) /* sprite pixels outside of line */ - return FALSE; /* not to be drawn */ - - // sprite portion out of the screen (LEFT) - if(sprX<0) - { - lg += sprX; - x = -(sprX); - sprX = 0; - } - // sprite portion out of the screen (RIGHT) - if (sprX+sprSize.x >= 256) - lg = 256 - sprX; - - y = l - sprY; /* get the y line within sprite coords */ - - // switch TOP<-->BOTTOM - if (spriteInfo->VFlip) - y = sprSize.y - y -1; - - // switch LEFT<-->RIGHT - if (spriteInfo->HFlip) { - x = sprSize.x - x -1; - xdir = -1; - } else { - xdir = 1; - } - return TRUE; -} - -/*****************************************************************************/ -// SPRITE RENDERING -/*****************************************************************************/ - - -//TODO - refactor this so there isnt as much duped code between rotozoomed and non-rotozoomed versions - -static u8* bmp_sprite_address(GPU* gpu, _OAM_ * spriteInfo, size sprSize, s32 y) -{ - u8* src; - if (spriteInfo->Mode == 3) //sprite is in BMP format - { - if (gpu->dispCnt().OBJ_BMP_mapping) - { - //tested by buffy sacrifice damage blood splatters in corner - src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<sprBMPBoundary) + (y*sprSize.x*2)); - } - else - { - //2d mapping: - //verified in rotozoomed mode by knights in the nightmare intro - - if (gpu->dispCnt().OBJ_BMP_2D_dim) - //256*256, verified by heroes of mana FMV intro - src = (u8 *)MMU_gpu_map(gpu->sprMem + (((spriteInfo->TileIndex&0x3E0) * 64 + (spriteInfo->TileIndex&0x1F) *8 + ( y << 8)) << 1)); - else - //128*512, verified by harry potter and the order of the phoenix conversation portraits - src = (u8 *)MMU_gpu_map(gpu->sprMem + (((spriteInfo->TileIndex&0x3F0) * 64 + (spriteInfo->TileIndex&0x0F) *8 + ( y << 7)) << 1)); - } - } - - return src; -} - - -template -void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab) -{ - u16 l = currLine; - GPU *gpu = this; - - struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; - _OAM_ * spriteInfo = (_OAM_ *)(gpu->oam + (nbShow-1));// + 127; - u8 block = gpu->sprBoundary; - u8 i; - -#ifdef WORDS_BIGENDIAN - *(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15; - *(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14; -#endif - - for(i = 0; i> 15 - ,*(((u16*)(spriteInfo+1))+2) = (*(((u16*)(spriteInfo+1))+2) << 2) | *(((u16*)(spriteInfo+1))+2) >> 14 - ,*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15 - ,*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14 -#endif - ) - { - //for each sprite: - - size sprSize; - s32 sprX, sprY, x, y, lg; - int xdir; - u8 prio, * src; - u16 j; - - // Check if sprite is disabled before everything - if (spriteInfo->RotScale == 2) - continue; - - prio = spriteInfo->Priority; - - - if (spriteInfo->RotScale & 1) - { - s32 fieldX, fieldY, auxX, auxY, realX, realY, offset; - u8 blockparameter, *pal; - s16 dx, dmx, dy, dmy; - u16 colour; - - // Get sprite positions and size - sprX = (spriteInfo->X<<23)>>23; - sprY = spriteInfo->Y; - sprSize = sprSizeTab[spriteInfo->Size][spriteInfo->Shape]; - - lg = sprSize.x; - - if (sprY>=192) - sprY = (s32)((s8)(spriteInfo->Y)); - - // Copy sprite size, to check change it if needed - fieldX = sprSize.x; - fieldY = sprSize.y; - - // If we are using double size mode, double our control vars - if (spriteInfo->RotScale & 2) - { - fieldX <<= 1; - fieldY <<= 1; - lg <<= 1; - } - - // Check if sprite enabled - if ((l = sprY+fieldY) || - (sprX==256) || (sprX+fieldX<=0)) - continue; - - y = l - sprY; - - // Get which four parameter block is assigned to this sprite - blockparameter = (spriteInfo->RotScalIndex + (spriteInfo->HFlip<< 3) + (spriteInfo->VFlip << 4))*4; - - // Get rotation/scale parameters -#ifdef WORDS_BIGENDIAN - dx = ((s16)(gpu->oam + blockparameter+0)->attr31 << 8) | ((s16)(gpu->oam + blockparameter+0)->attr30); - dmx = ((s16)(gpu->oam + blockparameter+1)->attr31 << 8) | ((s16)(gpu->oam + blockparameter+1)->attr30); - dy = ((s16)(gpu->oam + blockparameter+2)->attr31 << 8) | ((s16)(gpu->oam + blockparameter+2)->attr30); - dmy = ((s16)(gpu->oam + blockparameter+3)->attr31 << 8) | ((s16)(gpu->oam + blockparameter+3)->attr30); -#else - dx = (s16)(gpu->oam + blockparameter+0)->attr3; - dmx = (s16)(gpu->oam + blockparameter+1)->attr3; - dy = (s16)(gpu->oam + blockparameter+2)->attr3; - dmy = (s16)(gpu->oam + blockparameter+3)->attr3; -#endif - - // Calculate fixed poitn 8.8 start offsets - realX = ((sprSize.x) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx + y * dmx; - realY = ((sprSize.y) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy + y * dmy; - - if(sprX<0) - { - // If sprite is not in the window - if(sprX + fieldX <= 0) - continue; - - // Otherwise, is partially visible - lg += sprX; - realX -= sprX*dx; - realY -= sprX*dy; - sprX = 0; - } - else - { - if(sprX+fieldX>256) - lg = 256 - sprX; - } - - // If we are using 1 palette of 256 colours - if(spriteInfo->Depth) - { - src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex << block)); - - // If extended palettes are set, use them - if (dispCnt->ExOBJPalette_Enable) - pal = (MMU.ObjExtPal[gpu->core][0]+(spriteInfo->PaletteIndex*0x200)); - else - pal = (MMU.ARM9_VMEM + 0x200 + gpu->core *0x400); - - for(j = 0; j < lg; ++j, ++sprX) - { - // Get the integer part of the fixed point 8.8, and check if it lies inside the sprite data - auxX = (realX>>8); - auxY = (realY>>8); - - if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y) - { - if(MODE == SPRITE_2D) - offset = (auxX&0x7) + ((auxX&0xFFF8)<<3) + ((auxY>>3)<<10) + ((auxY&0x7)*8); - else - offset = (auxX&0x7) + ((auxX&0xFFF8)<<3) + ((auxY>>3)*sprSize.x*8) + ((auxY&0x7)*8); - - colour = src[offset]; - - if (colour && (prioTab[sprX]>=prio)) - { - T2WriteWord(dst, (sprX<<1), T2ReadWord(pal, (colour<<1))); - dst_alpha[sprX] = 16; - typeTab[sprX] = spriteInfo->Mode; - prioTab[sprX] = prio; - } - } - - // Add the rotation/scale coeficients, here the rotation/scaling - // is performed - realX += dx; - realY += dy; - } - - continue; - } - // Rotozoomed direct color - else if(spriteInfo->Mode == 3) - { - src = bmp_sprite_address(this,spriteInfo,sprSize,0); - - for(j = 0; j < lg; ++j, ++sprX) - { - // Get the integer part of the fixed point 8.8, and check if it lies inside the sprite data - auxX = (realX>>8); - auxY = (realY>>8); - - //this is all very slow, and so much dup code with other rotozoomed modes. - //dont bother fixing speed until this whole thing gets reworked - - if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y) - { - if(dispCnt->OBJ_BMP_2D_dim) - //tested by knights in the nightmare - offset = (bmp_sprite_address(this,spriteInfo,sprSize,auxY)-src)/2+auxX; - else //tested by lego indiana jones (somehow?) - //tested by buffy sacrifice damage blood splatters in corner - offset = auxX + (auxY*sprSize.x); - - - colour = T1ReadWord (src, offset<<1); - - if((colour&0x8000) && (prioTab[sprX]>=prio)) - { - T2WriteWord(dst, (sprX<<1), colour); - dst_alpha[sprX] = spriteInfo->PaletteIndex; - typeTab[sprX] = spriteInfo->Mode; - prioTab[sprX] = prio; - } - } - - // Add the rotation/scale coeficients, here the rotation/scaling - // is performed - realX += dx; - realY += dy; - } - - continue; - } - // Rotozoomed 16/16 palette - else - { - if(MODE == SPRITE_2D) - { - src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<<5)); - pal = MMU.ARM9_VMEM + 0x200 + (gpu->core*0x400 + (spriteInfo->PaletteIndex*32)); - } - else - { - src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<sprBoundary)); - pal = MMU.ARM9_VMEM + 0x200 + gpu->core*0x400 + (spriteInfo->PaletteIndex*32); - } - - for(j = 0; j < lg; ++j, ++sprX) - { - // Get the integer part of the fixed point 8.8, and check if it lies inside the sprite data - auxX = (realX>>8); - auxY = (realY>>8); - - if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y) - { - if(MODE == SPRITE_2D) - offset = ((auxX>>1)&0x3) + (((auxX>>1)&0xFFFC)<<3) + ((auxY>>3)<<10) + ((auxY&0x7)*4); - else - offset = ((auxX>>1)&0x3) + (((auxX>>1)&0xFFFC)<<3) + ((auxY>>3)*sprSize.x)*4 + ((auxY&0x7)*4); - - colour = src[offset]; - - // Get 4bits value from the readed 8bits - if (auxX&1) colour >>= 4; - else colour &= 0xF; - - if(colour && (prioTab[sprX]>=prio)) - { - T2WriteWord(dst, (sprX<<1), LE_TO_LOCAL_16(T2ReadWord(pal, colour << 1))); - dst_alpha[sprX] = 16; - typeTab[sprX] = spriteInfo->Mode; - prioTab[sprX] = prio; - } - } - - // Add the rotation/scale coeficients, here the rotation/scaling - // is performed - realX += dx; - realY += dy; - } - - continue; - } - } - else - { - u16 * pal; - - - if (!compute_sprite_vars(spriteInfo, l, sprSize, sprX, sprY, x, y, lg, xdir)) - continue; - - if (spriteInfo->Mode == 2) - { - if(MODE == SPRITE_2D) - { - if (spriteInfo->Depth) - src = (u8 *)MMU_gpu_map(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*8)); - else - src = (u8 *)MMU_gpu_map(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*4)); - } - else - { - if (spriteInfo->Depth) - src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<>3)*sprSize.x*8) + ((y&0x7)*8)); - else - src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<>3)*sprSize.x*4) + ((y&0x7)*4)); - } - - render_sprite_Win (gpu, l, src, spriteInfo->Depth, lg, sprX, x, xdir); - continue; - } - - if (spriteInfo->Mode == 3) //sprite is in BMP format - { - src = bmp_sprite_address(this,spriteInfo,sprSize, y); - - //transparent (i think, dont bother to render?) if alpha is 0 - if(spriteInfo->PaletteIndex == 0) - continue; - - render_sprite_BMP (gpu, i, l, dst, (u16*)src, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->PaletteIndex); - continue; - } - - if(spriteInfo->Depth) /* 256 colors */ - { - if(MODE == SPRITE_2D) - src = (u8 *)MMU_gpu_map(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*8)); - else - src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<>3)*sprSize.x*8) + ((y&0x7)*8)); - - if (dispCnt->ExOBJPalette_Enable) - pal = (u16*)(MMU.ObjExtPal[gpu->core][0]+(spriteInfo->PaletteIndex*0x200)); - else - pal = (u16*)(MMU.ARM9_VMEM + 0x200 + gpu->core *0x400); - - render_sprite_256 (gpu, i, l, dst, src, pal, - dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->Mode == 1); - - continue; - } - // 16 colors - if(MODE == SPRITE_2D) - { - src = (u8 *)MMU_gpu_map(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*4)); - } - else - { - src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<>3)*sprSize.x*4) + ((y&0x7)*4)); - } - - pal = (u16*)(MMU.ARM9_VMEM + 0x200 + gpu->core * 0x400); - - pal += (spriteInfo->PaletteIndex<<4); - - render_sprite_16 (gpu, l, dst, src, pal, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->Mode == 1); - } - } - -#ifdef WORDS_BIGENDIAN - *(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) << 1) | *(((u16*)spriteInfo)+1) >> 15; - *(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) << 2) | *(((u16*)spriteInfo)+2) >> 14; -#endif -} - - -/*****************************************************************************/ -// SCREEN FUNCTIONS -/*****************************************************************************/ - -int Screen_Init(int coreid) -{ - MainScreen.gpu = GPU_Init(0); - SubScreen.gpu = GPU_Init(1); - - memset(GPU_screen, 0, sizeof(GPU_screen)); - for(int i = 0; i < (256*192*2); i++) - ((u16*)GPU_screen)[i] = 0x7FFF; - disp_fifo.head = disp_fifo.tail = 0; - - if (osd) {delete osd; osd =NULL; } - osd = new OSDCLASS(-1); - - return GPU_ChangeGraphicsCore(coreid); -} - -void Screen_Reset(void) -{ - GPU_Reset(MainScreen.gpu, 0); - GPU_Reset(SubScreen.gpu, 1); - - memset(GPU_screen, 0, sizeof(GPU_screen)); - for(int i = 0; i < (256*192*2); i++) - ((u16*)GPU_screen)[i] = 0x7FFF; - - disp_fifo.head = disp_fifo.tail = 0; - osd->clear(); -} - -void Screen_DeInit(void) -{ - GPU_DeInit(MainScreen.gpu); - GPU_DeInit(SubScreen.gpu); - - if (GFXCore) - GFXCore->DeInit(); - - if (osd) {delete osd; osd =NULL; } -} - -/*****************************************************************************/ -// GRAPHICS CORE -/*****************************************************************************/ - -// This is for future graphics core switching. This is by no means set in stone - -int GPU_ChangeGraphicsCore(int coreid) -{ - int i; - - // Make sure the old core is freed - if (GFXCore) - GFXCore->DeInit(); - - // So which core do we want? - if (coreid == GFXCORE_DEFAULT) - coreid = 0; // Assume we want the first one - - // Go through core list and find the id - for (i = 0; GFXCoreList[i] != NULL; i++) - { - if (GFXCoreList[i]->id == coreid) - { - // Set to current core - GFXCore = GFXCoreList[i]; - break; - } - } - - if (GFXCore == NULL) - { - GFXCore = &GFXDummy; - return -1; - } - - if (GFXCore->Init() == -1) - { - // Since it failed, instead of it being fatal, we'll just use the dummy - // core instead - GFXCore = &GFXDummy; - } - - return 0; -} - -int GFXDummyInit(); -void GFXDummyDeInit(); -void GFXDummyResize(int width, int height, BOOL fullscreen); -void GFXDummyOnScreenText(char *string, ...); - -GraphicsInterface_struct GFXDummy = { -GFXCORE_DUMMY, -"Dummy Graphics Interface", -0, -GFXDummyInit, -GFXDummyDeInit, -GFXDummyResize, -GFXDummyOnScreenText -}; - -int GFXDummyInit() -{ - return 0; -} - -void GFXDummyDeInit() -{ -} - -void GFXDummyResize(int width, int height, BOOL fullscreen) -{ -} - -void GFXDummyOnScreenText(char *string, ...) -{ -} - - -/*****************************************************************************/ -// GPU_ligne -/*****************************************************************************/ - -void GPU_set_DISPCAPCNT(u32 val) -{ - GPU * gpu = MainScreen.gpu; - struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; - - gpu->dispCapCnt.val = val; - gpu->dispCapCnt.EVA = std::min((u32)16, (val & 0x1F)); - gpu->dispCapCnt.EVB = std::min((u32)16, ((val >> 8) & 0x1F)); - gpu->dispCapCnt.writeBlock = (val >> 16) & 0x03; - gpu->dispCapCnt.writeOffset = (val >> 18) & 0x03; - gpu->dispCapCnt.readBlock = dispCnt->VRAM_Block; - - if (dispCnt->DisplayMode == 2) - gpu->dispCapCnt.readOffset = 0; - else - gpu->dispCapCnt.readOffset = (val >> 26) & 0x03; - - gpu->dispCapCnt.srcA = (val >> 24) & 0x01; - gpu->dispCapCnt.srcB = (val >> 25) & 0x01; - gpu->dispCapCnt.capSrc = (val >> 29) & 0x03; - - switch((val >> 20) & 0x03) - { - case 0: - gpu->dispCapCnt.capx = DISPCAPCNT::_128; - gpu->dispCapCnt.capy = 128; - break; - case 1: - gpu->dispCapCnt.capx = DISPCAPCNT::_256; - gpu->dispCapCnt.capy = 64; - break; - case 2: - gpu->dispCapCnt.capx = DISPCAPCNT::_256; - gpu->dispCapCnt.capy = 128; - break; - case 3: - gpu->dispCapCnt.capx = DISPCAPCNT::_256; - gpu->dispCapCnt.capy = 192; - break; - } - - /*INFO("Capture 0x%X:\n EVA=%i, EVB=%i, wBlock=%i, wOffset=%i, capX=%i, capY=%i\n rBlock=%i, rOffset=%i, srcCap=%i, dst=0x%X, src=0x%X\n srcA=%i, srcB=%i\n\n", - val, gpu->dispCapCnt.EVA, gpu->dispCapCnt.EVB, gpu->dispCapCnt.writeBlock, gpu->dispCapCnt.writeOffset, - gpu->dispCapCnt.capx, gpu->dispCapCnt.capy, gpu->dispCapCnt.readBlock, gpu->dispCapCnt.readOffset, - gpu->dispCapCnt.capSrc, gpu->dispCapCnt.dst - MMU.ARM9_LCD, gpu->dispCapCnt.src - MMU.ARM9_LCD, - gpu->dispCapCnt.srcA, gpu->dispCapCnt.srcB);*/ -} - -static void GPU_ligne_layer(NDS_Screen * screen, u16 l) -{ - CACHE_ALIGN u8 spr[512]; - CACHE_ALIGN u8 sprAlpha[256]; - CACHE_ALIGN u8 sprType[256]; - CACHE_ALIGN u8 sprPrio[256]; - - GPU * gpu = screen->gpu; - struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; - itemsForPriority_t * item; - u16 i16; - BOOL BG_enabled = TRUE; - - gpu->currentFadeInColors = &fadeInColors[gpu->BLDY_EVY][0]; - gpu->currentFadeOutColors = &fadeOutColors[gpu->BLDY_EVY][0]; - - u16 backdrop_color = T1ReadWord(MMU.ARM9_VMEM, gpu->core * 0x400) & 0x7FFF; - - //we need to write backdrop colors in the same way as we do BG pixels in order to do correct window processing - //this is currently eating up 2fps or so. it is a reasonable candidate for optimization. - gpu->currBgNum = 5; - switch(gpu->setFinalColorBck_funcNum) { - case 0: case 1: //for backdrops, (even with window enabled) none and blend are both the same: just copy the color - memset_u16_le<256>(gpu->currDst,backdrop_color); - break; - case 2: - //for non-windowed fade, we can just fade the color and fill - memset_u16_le<256>(gpu->currDst,gpu->currentFadeInColors[backdrop_color]); - break; - case 3: - //likewise for non-windowed fadeout - memset_u16_le<256>(gpu->currDst,gpu->currentFadeOutColors[backdrop_color]); - break; - - //windowed fades need special treatment - case 4: for(int x=0;x<256;x++) gpu->___setFinalColorBck(backdrop_color,x,1); break; - case 5: for(int x=0;x<256;x++) gpu->___setFinalColorBck(backdrop_color,x,1); break; - case 6: for(int x=0;x<256;x++) gpu->___setFinalColorBck(backdrop_color,x,1); break; - case 7: for(int x=0;x<256;x++) gpu->___setFinalColorBck(backdrop_color,x,1); break; - } - - memset(gpu->bgPixels,5,256); - - // init background color & priorities - memset(sprAlpha, 0, 256); - memset(sprType, 0, 256); - memset(sprPrio, 0xFF, 256); - memset(sprWin, 0, 256); - - // init pixels priorities - assert(NB_PRIORITIES==4); - gpu->itemsForPriority[0].nbPixelsX = 0; - gpu->itemsForPriority[1].nbPixelsX = 0; - gpu->itemsForPriority[2].nbPixelsX = 0; - gpu->itemsForPriority[3].nbPixelsX = 0; - - // for all the pixels in the line - if (gpu->LayersEnable[4]) - { - //n.b. - this is clearing the sprite line buffer to the background color, - //but it has been changed to write u32 instead of u16 for a little speedup - for(int i = 0; i< 128; ++i) T2WriteLong(spr, i << 2, backdrop_color | (backdrop_color<<16)); - //zero 06-may-09: I properly supported window color effects for backdrop, but I am not sure - //how it interacts with this. I wish we knew why we needed this - - gpu->spriteRender(spr, sprAlpha, sprType, sprPrio); - mosaicSpriteLine(gpu, l, spr, sprAlpha, sprType, sprPrio); - - - for(int i = 0; i<256; i++) - { - // assign them to the good priority item - int prio = sprPrio[i]; - if (prio >=4) continue; - - item = &(gpu->itemsForPriority[prio]); - item->PixelsX[item->nbPixelsX]=i; - item->nbPixelsX++; - } - } - - - if (!gpu->LayersEnable[0] && !gpu->LayersEnable[1] && !gpu->LayersEnable[2] && !gpu->LayersEnable[3]) - BG_enabled = FALSE; - - for(int j=0;j<8;j++) - gpu->blend2[j] = (gpu->BLDCNT & (0x100 << j))!=0; - - // paint lower priorities first - // then higher priorities on top - for(int prio=NB_PRIORITIES; prio > 0; ) - { - prio--; - item = &(gpu->itemsForPriority[prio]); - // render BGs - if (BG_enabled) - { - for (int i=0; i < item->nbBGs; i++) - { - i16 = item->BGs[i]; - if (gpu->LayersEnable[i16]) - { - gpu->currBgNum = (u8)i16; - gpu->blend1 = (gpu->BLDCNT & (1 << gpu->currBgNum))!=0; - - struct _BGxCNT *bgCnt = &(gpu->dispx_st)->dispx_BGxCNT[i16].bits; - gpu->curr_mosaic_enabled = bgCnt->Mosaic_Enable; - - if (gpu->core == GPU_MAIN) - { - if (i16 == 0 && dispCnt->BG0_3D) - { - gpu->currBgNum = 0; - - BGxOFS *bgofs = &gpu->dispx_st->dispx_BGxOFS[i16]; - u16 hofs = (T1ReadWord((u8*)&bgofs->BGxHOFS, 0) & 0x1FF); - - gfx3d_GetLineData(l, &gpu->_3dColorLine); - u8* colorLine = gpu->_3dColorLine; - - for(int k = 0; k < 256; k++) - { - int q = ((k + hofs) & 0x1FF); - - if((q < 0) || (q > 255)) - continue; - - if(colorLine[(q<<2)+3]) - gpu->setFinalColor3d(k, q); - } - - continue; - } - } - - //useful for debugging individual layers - //if(gpu->core == 1 || i16 != 2) continue; - - if(gpu->curr_mosaic_enabled) - gpu->modeRender(i16); - else gpu->modeRender(i16); - } //layer enabled - } - } - - // render sprite Pixels - if (gpu->LayersEnable[4]) - { - gpu->currBgNum = 4; - gpu->blend1 = (gpu->BLDCNT & (1 << gpu->currBgNum))!=0; - - for (int i=0; i < item->nbPixelsX; i++) - { - i16=item->PixelsX[i]; - setFinalColorSpr(gpu, gpu->currDst, T2ReadWord(spr, (i16<<1)), sprAlpha[i16], sprType[i16], i16); - } - } - } -} - -template static void GPU_ligne_DispCapture(u16 l) -{ - //this macro takes advantage of the fact that there are only two possible values for capx - #define CAPCOPY(SRC,DST) \ - switch(gpu->dispCapCnt.capx) { \ - case DISPCAPCNT::_128: \ - for (int i = 0; i < 128; i++) \ - T2WriteWord(DST, i << 1, T2ReadWord(SRC, i << 1) | (1<<15)); \ - break; \ - case DISPCAPCNT::_256: \ - for (int i = 0; i < 256; i++) \ - T2WriteWord(DST, i << 1, T2ReadWord(SRC, i << 1) | (1<<15)); \ - break; \ - default: assert(false); \ - } - - GPU * gpu = MainScreen.gpu; - - if (l == 0) - { - if (gpu->dispCapCnt.val & 0x80000000) - { - gpu->dispCapCnt.enabled = TRUE; - T1WriteLong(MMU.ARM9_REG, 0x64, gpu->dispCapCnt.val); - } - } - - bool skip = SKIP; - - if (gpu->dispCapCnt.enabled) - { - //128-wide captures should write linearly into memory, with no gaps - //this is tested by hotel dusk - u32 ofsmul = gpu->dispCapCnt.capx==DISPCAPCNT::_128?256:512; - u32 cap_src_adr = gpu->dispCapCnt.readOffset * 0x8000 + (l * 512); - u32 cap_dst_adr = gpu->dispCapCnt.writeOffset * 0x8000 + (l * ofsmul); - - //Read/Write block wrap to 00000h when exceeding 1FFFFh (128k) - //this has not been tested yet (I thought I needed it for hotel dusk, but it was fixed by the above) - cap_src_adr &= 0x1FFFF; - cap_dst_adr &= 0x1FFFF; - - cap_src_adr += gpu->dispCapCnt.readBlock * 0x20000; - cap_dst_adr += gpu->dispCapCnt.writeBlock * 0x20000; - - u8* cap_src = MMU.ARM9_LCD + cap_src_adr; - u8* cap_dst = MMU.ARM9_LCD + cap_dst_adr; - - //we must block captures when the capture dest is not mapped to LCDC - if(vramConfiguration.banks[gpu->dispCapCnt.writeBlock].purpose != VramConfiguration::LCDC) - skip = true; - - //we must return zero from reads from memory not mapped to lcdc - if(vramConfiguration.banks[gpu->dispCapCnt.readBlock].purpose != VramConfiguration::LCDC) - cap_src = MMU.blank_memory; - - if(!skip) - if (l < gpu->dispCapCnt.capy) - { - switch (gpu->dispCapCnt.capSrc) - { - case 0: // Capture source is SourceA - { - //INFO("Capture source is SourceA\n"); - switch (gpu->dispCapCnt.srcA) - { - case 0: // Capture screen (BG + OBJ + 3D) - { - //INFO("Capture screen (BG + OBJ + 3D)\n"); - - u8 *src; - src = (u8*)(GPU_tempScanline); - CAPCOPY(src,cap_dst); - } - break; - case 1: // Capture 3D - { - //INFO("Capture 3D\n"); - u16* colorLine; - gfx3d_GetLineData15bpp(l, &colorLine); - CAPCOPY(((u8*)colorLine),cap_dst); - } - break; - } - } - break; - case 1: // Capture source is SourceB - { - //INFO("Capture source is SourceB\n"); - switch (gpu->dispCapCnt.srcB) - { - case 0: - //Capture VRAM - CAPCOPY(cap_src,cap_dst); - break; - case 1: - //capture dispfifo - //(not yet tested) - for(int i=0; i < 128; i++) - T1WriteLong(cap_dst, i << 2, DISP_FIFOrecv()); - break; - } - } - break; - default: // Capture source is SourceA+B blended - { - //INFO("Capture source is SourceA+B blended\n"); - u16 *srcA = NULL; - u16 *srcB = NULL; - - if (gpu->dispCapCnt.srcA == 0) - { - // Capture screen (BG + OBJ + 3D) - srcA = (u16*)(GPU_tempScanline); - } - else - { - gfx3d_GetLineData15bpp(l, &srcA); - } - - static u16 fifoLine[256]; - - if (gpu->dispCapCnt.srcB == 0) // VRAM screen - srcB = (u16 *)cap_src; - else - { - //fifo - tested by splinter cell chaos theory thermal view - srcB = fifoLine; - for (int i=0; i < 128; i++) - T1WriteLong((u8*)srcB, i << 2, DISP_FIFOrecv()); - } - - - const int todo = (gpu->dispCapCnt.capx==DISPCAPCNT::_128?128:256); - - for(u16 i = 0; i < todo; i++) - { - u16 a,r,g,b; - - u16 a_alpha = srcA[i] & 0x8000; - u16 b_alpha = srcB[i] & 0x8000; - - if(a_alpha) - { - a = 0x8000; - r = ((srcA[i] & 0x1F) * gpu->dispCapCnt.EVA); - g = (((srcA[i] >> 5) & 0x1F) * gpu->dispCapCnt.EVA); - b = (((srcA[i] >> 10) & 0x1F) * gpu->dispCapCnt.EVA); - } - else - a = r = g = b = 0; - - if(b_alpha) - { - a = 0x8000; - r += ((srcB[i] & 0x1F) * gpu->dispCapCnt.EVB); - g += (((srcB[i] >> 5) & 0x1F) * gpu->dispCapCnt.EVB); - b += (((srcB[i] >> 10) & 0x1F) * gpu->dispCapCnt.EVB); - } - - r >>= 4; - g >>= 4; - b >>= 4; - - //freedom wings sky will overflow while doing some fsaa/motionblur effect without this - r = std::min((u16)31,r); - g = std::min((u16)31,g); - b = std::min((u16)31,b); - - T2WriteWord(cap_dst, i << 1, a | (b << 10) | (g << 5) | r); - } - } - break; - } - } - - if (l>=191) - { - gpu->dispCapCnt.enabled = FALSE; - gpu->dispCapCnt.val &= 0x7FFFFFFF; - T1WriteLong(MMU.ARM9_REG, 0x64, gpu->dispCapCnt.val); - return; - } - } -} - -static INLINE void GPU_ligne_MasterBrightness(NDS_Screen * screen, u16 l) -{ - GPU * gpu = screen->gpu; - - u8 * dst = GPU_screen + (screen->offset + l) * 512; - u16 i16; - - //isn't it odd that we can set uselessly high factors here? - //factors above 16 change nothing. curious. - int factor = gpu->MasterBrightFactor; - if(factor==0) return; - if(factor>16) factor=16; - - - //Apply final brightness adjust (MASTER_BRIGHT) - //http://nocash.emubase.de/gbatek.htm#dsvideo (Under MASTER_BRIGHTNESS) - - switch (gpu->MasterBrightMode) - { - // Disabled - case 0: - break; - - // Bright up - case 1: - { - for(i16 = 0; i16 < 256; ++i16) - { - ((u16*)dst)[i16] = fadeInColors[factor][((u16*)dst)[i16]&0x7FFF]; - } - break; - } - - // Bright down - case 2: - { - for(i16 = 0; i16 < 256; ++i16) - { - ((u16*)dst)[i16] = fadeOutColors[factor][((u16*)dst)[i16]&0x7FFF]; - } - break; - } - - // Reserved - case 3: - break; - } - -} - -template -FORCEINLINE void GPU::setup_windows() -{ - u8 y = currLine; - u16 startY,endY; - - if(WIN_NUM==0) - { - startY = WIN0V0; - endY = WIN0V1; - } - else - { - startY = WIN1V0; - endY = WIN1V1; - } - - if(WIN_NUM == 0 && !WIN0_ENABLED) goto allout; - if(WIN_NUM == 1 && !WIN1_ENABLED) goto allout; - - if(startY > endY) - { - if((y < startY) && (y > endY)) goto allout; - } - else - { - if((y < startY) || (y >= endY)) goto allout; - } - - //the x windows will apply for this scanline - curr_win[WIN_NUM] = h_win[WIN_NUM]; - return; - -allout: - curr_win[WIN_NUM] = win_empty; -} - -void GPU::update_winh(int WIN_NUM) -{ - //dont even waste any time in here if the window isnt enabled - if(WIN_NUM==0 && !WIN0_ENABLED) return; - if(WIN_NUM==1 && !WIN1_ENABLED) return; - - need_update_winh[WIN_NUM] = false; - u16 startX,endX; - - if(WIN_NUM==0) - { - startX = WIN0H0; - endX = WIN0H1; - } - else - { - startX = WIN1H0; - endX = WIN1H1; - } - - //the original logic: if you doubt the window code, please check it against the newer implementation below - //if(startX > endX) - //{ - // if((x < startX) && (x > endX)) return false; - //} - //else - //{ - // if((x < startX) || (x >= endX)) return false; - //} - - if(startX > endX) - { - for(int i=0;i<=endX;i++) - h_win[WIN_NUM][i] = 1; - for(int i=endX+1;igpu; - - //here is some setup which is only done on line 0 - if(l == 0) { - //this is speculative. the idea is as follows: - //whenever the user updates the affine start position regs, it goes into the active regs immediately - //(this is handled on the set event from MMU) - //maybe it shouldnt take effect until the next hblank or something.. - //this is a based on a combination of: - //heroes of mana intro FMV - //SPP level 3-8 rotoscale room - //NSMB raster fx backdrops - //bubble bobble revolution classic mode - //NOTE: - //I am REALLY unsatisfied with this logic now. But it seems to be working.. - gpu->refreshAffineStartRegs(-1,-1); - } - - if(skip) - { - gpu->currLine = l; - if (gpu->core == GPU_MAIN) - { - GPU_ligne_DispCapture(l); - if (l == 191) { disp_fifo.head = disp_fifo.tail = 0; } - } - return; - } - - //blacken the screen if it is turned off by the user - if(!CommonSettings.showGpu.screens[gpu->core]) - { - u8 * dst = GPU_screen + (screen->offset + l) * 512; - memset(dst,0,512); - return; - } - - //cache some parameters which are assumed to be stable throughout the rendering of the entire line - gpu->currLine = l; - u16 mosaic_control = T1ReadWord((u8 *)&gpu->dispx_st->dispx_MISC.MOSAIC, 0); - u16 mosaic_width = (mosaic_control & 0xF); - u16 mosaic_height = ((mosaic_control>>4) & 0xF); - - //mosaic test hacks - //mosaic_width = mosaic_height = 3; - - GPU::mosaicLookup.widthValue = mosaic_width; - GPU::mosaicLookup.heightValue = mosaic_height; - GPU::mosaicLookup.width = &GPU::mosaicLookup.table[mosaic_width][0]; - GPU::mosaicLookup.height = &GPU::mosaicLookup.table[mosaic_height][0]; - - if(gpu->need_update_winh[0]) gpu->update_winh(0); - if(gpu->need_update_winh[1]) gpu->update_winh(1); - - gpu->setup_windows<0>(); - gpu->setup_windows<1>(); - - //generate the 2d engine output - if(gpu->dispMode == 1) { - //optimization: render straight to the output buffer when thats what we are going to end up displaying anyway - GPU_tempScanline = screen->gpu->currDst = (u8 *)(GPU_screen) + (screen->offset + l) * 512; - } else { - //otherwise, we need to go to a temp buffer - GPU_tempScanline = screen->gpu->currDst = (u8 *)GPU_tempScanlineBuffer; - } - - GPU_ligne_layer(screen, l); - - switch (gpu->dispMode) - { - case 0: // Display Off(Display white) - { - u8 * dst = GPU_screen + (screen->offset + l) * 512; - - for (int i=0; i<256; i++) - T2WriteWord(dst, i << 1, 0x7FFF); - } - break; - - case 1: // Display BG and OBJ layers - //do nothing: it has already been generated into the right place - break; - - case 2: // Display vram framebuffer - { - u8 * dst = GPU_screen + (screen->offset + l) * 512; - u8 * src = gpu->VRAMaddr + (l*512); - memcpy (dst, src, 512); - } - break; - case 3: // Display memory FIFO - { - //this has not been tested since the dma timing for dispfifo was changed around the time of - //newemuloop. it may not work. - u8 * dst = GPU_screen + (screen->offset + l) * 512; - for (int i=0; i < 128; i++) - T1WriteLong(dst, i << 2, DISP_FIFOrecv() & 0x7FFF7FFF); - } - break; - } - - //capture after displaying so that we can safely display vram before overwriting it here - if (gpu->core == GPU_MAIN) - { - //BUG!!! if someone is capturing and displaying both from the fifo, then it will have been - //consumed above by the display before we get here - //(is that even legal? i think so) - GPU_ligne_DispCapture(l); - if (l == 191) { disp_fifo.head = disp_fifo.tail = 0; } - } - - - GPU_ligne_MasterBrightness(screen, l); -} - -void gpu_savestate(std::ostream* os) -{ - //version - write32le(1,os); - - os->write((char*)GPU_screen,sizeof(GPU_screen)); - - write32le(MainScreen.gpu->affineInfo[0].x,os); - write32le(MainScreen.gpu->affineInfo[0].y,os); - write32le(MainScreen.gpu->affineInfo[1].x,os); - write32le(MainScreen.gpu->affineInfo[1].y,os); - write32le(SubScreen.gpu->affineInfo[0].x,os); - write32le(SubScreen.gpu->affineInfo[0].y,os); - write32le(SubScreen.gpu->affineInfo[1].x,os); - write32le(SubScreen.gpu->affineInfo[1].y,os); -} - -bool gpu_loadstate(std::istream* is, int size) -{ - //read version - int version; - - //sigh.. shouldve used a new version number - if(size == 256*192*2*2) - version = 0; - else if(size== 0x30024) - { - read32le(&version,is); - version = 1; - } - else - if(read32le(&version,is) != 1) return false; - - - if(version<0||version>1) return false; - - is->read((char*)GPU_screen,sizeof(GPU_screen)); - - if(version==1) - { - read32le(&MainScreen.gpu->affineInfo[0].x,is); - read32le(&MainScreen.gpu->affineInfo[0].y,is); - read32le(&MainScreen.gpu->affineInfo[1].x,is); - read32le(&MainScreen.gpu->affineInfo[1].y,is); - read32le(&SubScreen.gpu->affineInfo[0].x,is); - read32le(&SubScreen.gpu->affineInfo[0].y,is); - read32le(&SubScreen.gpu->affineInfo[1].x,is); - read32le(&SubScreen.gpu->affineInfo[1].y,is); - //removed per nitsuja feedback. anyway, this same thing will happen almost immediately in gpu line=0 - //MainScreen.gpu->refreshAffineStartRegs(-1,-1); - //SubScreen.gpu->refreshAffineStartRegs(-1,-1); - } - - MainScreen.gpu->updateBLDALPHA(); - SubScreen.gpu->updateBLDALPHA(); - return !is->fail(); -} - -u32 GPU::getAffineStart(int layer, int xy) -{ - if(xy==0) return affineInfo[layer-2].x; - else return affineInfo[layer-2].y; -} - -void GPU::setAffineStartWord(int layer, int xy, u16 val, int word) -{ - u32 curr = getAffineStart(layer,xy); - if(word==0) curr = (curr&0xFFFF0000)|val; - else curr = (curr&0x0000FFFF)|(((u32)val)<<16); - setAffineStart(layer,xy,curr); -} - -void GPU::setAffineStart(int layer, int xy, u32 val) -{ - if(xy==0) affineInfo[layer-2].x = val; - else affineInfo[layer-2].y = val; - refreshAffineStartRegs(layer,xy); -} - -void GPU::refreshAffineStartRegs(const int num, const int xy) -{ - if(num==-1) - { - refreshAffineStartRegs(2,xy); - refreshAffineStartRegs(3,xy); - return; - } - - if(xy==-1) - { - refreshAffineStartRegs(num,0); - refreshAffineStartRegs(num,1); - return; - } - - BGxPARMS * parms; - if (num==2) - parms = &(dispx_st)->dispx_BG2PARMS; - else - parms = &(dispx_st)->dispx_BG3PARMS; - - if(xy==0) - parms->BGxX = affineInfo[num-2].x; - else - parms->BGxY = affineInfo[num-2].y; -} - -template void GPU::modeRender(int layer) -{ - switch(GPU_mode2type[dispCnt().BG_Mode][layer]) - { - case BGType_Text: lineText(this); break; - case BGType_Affine: lineRot(this); break; - case BGType_AffineExt: lineExtRot(this); break; - case BGType_Large8bpp: lineExtRot(this); break; - case BGType_Invalid: - PROGINFO("Attempting to render an invalid BG type\n"); - break; - default: - break; - } -} - -void gpu_UpdateRender() -{ - /*int x = 0, y = 0; - u16 *src = (u16*)GPU_screen; - u16 *dst = (u16*)GPU_screen; - - switch (gpu_angle) - { - case 0: - memcpy(dst, src, 256*192*4); - break; - - case 90: - for(y = 0; y < 384; y++) - { - for(x = 0; x < 256; x++) - { - dst[(383 - y) + (x * 384)] = src[x + (y * 256)]; - } - } - break; - case 180: - for(y = 0; y < 384; y++) - { - for(x = 0; x < 256; x++) - { - dst[(255 - x) + ((383 - y) * 256)] = src[x + (y * 256)]; - } - } - break; - case 270: - for(y = 0; y < 384; y++) - { - for(x = 0; x < 256; x++) - { - dst[y + ((255 - x) * 384)] = src[x + (y * 256)]; - } - } - default: - break; - }*/ -} - -void gpu_SetRotateScreen(u16 angle) -{ - gpu_angle = angle; -} - -//here is an old bg mosaic with some old code commented out. I am going to leave it here for a while to look at it -//sometimes in case I find a problem with the mosaic. -//static void __setFinalColorBck(GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, bool opaque) -//{ -// struct _BGxCNT *bgCnt = &(gpu->dispx_st)->dispx_BGxCNT[bgnum].bits; -// bool enabled = bgCnt->Mosaic_Enable; -// -//// if(!opaque) color = 0xFFFF; -//// else color &= 0x7FFF; -// if(!opaque) -// return; -// -// //mosaic test hacks -// enabled = true; -// -// //due to this early out, we will get incorrect behavior in cases where -// //we enable mosaic in the middle of a frame. this is deemed unlikely. -// if(enabled) -// { -// u8 y = gpu->currLine; -// -// //I intend to cache all this at the beginning of line rendering -// -// u16 mosaic_control = T1ReadWord((u8 *)&gpu->dispx_st->dispx_MISC.MOSAIC, 0); -// u8 mw = (mosaic_control & 0xF); -// u8 mh = ((mosaic_control>>4) & 0xF); -// -// //mosaic test hacks -// mw = 3; -// mh = 3; -// -// MosaicLookup::TableEntry &te_x = mosaicLookup.table[mw][x]; -// MosaicLookup::TableEntry &te_y = mosaicLookup.table[mh][y]; -// -// //int x_int; -// //if(enabled) -// int x_int = te_x.trunc; -// //else x_int = x; -// -// if(te_x.begin && te_y.begin) {} -// else color = gpu->MosaicColors.bg[bgnum][x_int]; -// gpu->MosaicColors.bg[bgnum][x] = color; -// } -// -//// if(color != 0xFFFF) -// gpu->setFinalColorBck(gpu,0,bgnum,dst,color,x); -//} +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2006-2007 Theo Berkau + Copyright (C) 2007 shash + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include +#include +#include +#include "MMU.h" +#include "GPU.h" +#include "debug.h" +#include "render3D.h" +#include "gfx3d.h" +#include "debug.h" +#include "GPU_osd.h" +#include "NDSSystem.h" +#include "readwrite.h" + +//#undef FORCEINLINE +//#define FORCEINLINE + +ARM9_struct ARM9Mem; + +extern BOOL click; +NDS_Screen MainScreen; +NDS_Screen SubScreen; + +//instantiate static instance +GPU::MosaicLookup GPU::mosaicLookup; + +//#define DEBUG_TRI + +CACHE_ALIGN u8 GPU_screen[4*256*192]; +CACHE_ALIGN u8 *GPU_tempScanline; + +CACHE_ALIGN u8 sprWin[256]; + + +u16 gpu_angle = 0; + +const size sprSizeTab[4][4] = +{ + {{8, 8}, {16, 8}, {8, 16}, {8, 8}}, + {{16, 16}, {32, 8}, {8, 32}, {8, 8}}, + {{32, 32}, {32, 16}, {16, 32}, {8, 8}}, + {{64, 64}, {64, 32}, {32, 64}, {8, 8}}, +}; + + + +const BGType GPU_mode2type[8][4] = +{ + {BGType_Text, BGType_Text, BGType_Text, BGType_Text}, + {BGType_Text, BGType_Text, BGType_Text, BGType_Affine}, + {BGType_Text, BGType_Text, BGType_Affine, BGType_Affine}, + {BGType_Text, BGType_Text, BGType_Text, BGType_AffineExt}, + {BGType_Text, BGType_Text, BGType_Affine, BGType_AffineExt}, + {BGType_Text, BGType_Text, BGType_AffineExt, BGType_AffineExt}, + {BGType_Invalid, BGType_Invalid, BGType_Large8bpp, BGType_Invalid}, + {BGType_Invalid, BGType_Invalid, BGType_Invalid, BGType_Invalid} +}; + +const short sizeTab[8][4][2] = +{ + {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, //Invalid + {{256,256}, {512,256}, {256,512}, {512,512}}, //text + {{128,128}, {256,256}, {512,512}, {1024,1024}}, //affine + {{512,1024}, {1024,512}, {0,0}, {0,0}}, //large 8bpp + {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, //affine ext (to be elaborated with another value) + {{128,128}, {256,256}, {512,512}, {1024,1024}}, //affine ext 256x16 + {{128,128}, {256,256}, {512,256}, {512,512}}, //affine ext 256x1 + {{128,128}, {256,256}, {512,256}, {512,512}}, //affine ext direct +}; + +static GraphicsInterface_struct *GFXCore=NULL; + +// This should eventually be moved to the port specific code +GraphicsInterface_struct *GFXCoreList[] = { +&GFXDummy, +NULL +}; + +static const CACHE_ALIGN u8 win_empty[256] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +static CACHE_ALIGN u16 fadeInColors[17][0x8000]; +CACHE_ALIGN u16 fadeOutColors[17][0x8000]; + +//this should be public, because it gets used somewhere else +CACHE_ALIGN u8 gpuBlendTable555[17][17][32][32]; + + +/*****************************************************************************/ +// PIXEL RENDERING - 3D +/*****************************************************************************/ + +#define DECL3D \ + int x = dstX; \ + int passing = dstX<<1; \ + u16 color = _3dColorLine[srcX]; \ + u8 alpha = _3dAlphaLine[srcX]; \ + u8* dst = currDst; + +FORCEINLINE void GPU::setFinal3DColorSpecialNone(int dstX, int srcX) +{ + DECL3D; + + // We must blend if the 3D layer has the highest prio + if((alpha < 16)) //zero 30-may-09 - i think 3d always blends && bg0HasHighestPrio) + { + int bg_under = bgPixels[dstX]; + u16 final = color; + + // If the layer we are drawing on is selected as 2nd source, we can blend + if(BLDCNT & (0x100 << bg_under)) + { + { + COLOR c1, c2, cfinal; + + c1.val = color; + c2.val = T2ReadWord(dst, passing); + + cfinal.bits.red = ((c1.bits.red * alpha) + (c2.bits.red * (16 - alpha)))/16; + cfinal.bits.green = ((c1.bits.green * alpha) + (c2.bits.green * (16 - alpha)))/16; + cfinal.bits.blue = ((c1.bits.blue * alpha) + (c2.bits.blue * (16 - alpha)))/16; + + final = cfinal.val; + } + } + + T2WriteWord(dst, passing, (final | 0x8000)); + bgPixels[x] = 0; + } + else + { + T2WriteWord(dst, passing, (color | 0x8000)); + bgPixels[x] = 0; + } +} + +FORCEINLINE void GPU::setFinal3DColorSpecialBlend(int dstX, int srcX) +{ + DECL3D; + + // We can blend if the 3D layer is selected as 1st target, + //but also if the 3D layer has the highest prio. + if((alpha < 16)) //zero 30-may-09 - i think 3d always blends && ((BLDCNT & 0x1) || bg0HasHighestPrio)) + { + int bg_under = bgPixels[x]; + u16 final = color; + + //If the layer we are drawing on is selected as 2nd source, we can blend + if(BLDCNT & (0x100 << bg_under)) + { + { + COLOR c1, c2, cfinal; + + c1.val = color; + c2.val = T2ReadWord(dst, passing); + + cfinal.bits.red = ((c1.bits.red * alpha ) + (c2.bits.red * (16 - alpha) )) / 16; + cfinal.bits.green = ((c1.bits.green * alpha ) + (c2.bits.green * (16 - alpha) )) / 16; + cfinal.bits.blue = ((c1.bits.blue * alpha ) + (c2.bits.blue * (16 - alpha) )) / 16; + + final = cfinal.val; + } + } + + T2WriteWord(dst, passing, (final | 0x8000)); + bgPixels[x] = 0; + } + else + { + T2WriteWord(dst, passing, (color | 0x8000)); + bgPixels[x] = 0; + } +} + +FORCEINLINE void GPU::setFinal3DColorSpecialIncrease(int dstX, int srcX) +{ + DECL3D; + u16 final = color; + + // We must blend if the 3D layer has the highest prio + // But it doesn't seem to have priority over fading, + // unlike semi-transparent sprites + if((alpha < 16)) //zero 30-may-09 - i think 3d always blends && bg0HasHighestPrio) + { + int bg_under = bgPixels[x]; + + /* If the layer we are drawing on is selected as 2nd source, we can blend */ + if(BLDCNT & (0x100 << bg_under)) + { + { + COLOR c1, c2, cfinal; + + c1.val = color; + c2.val = T2ReadWord(dst, passing); + + cfinal.bits.red = ((c1.bits.red * alpha ) + (c2.bits.red * (16 - alpha) ))/16; + cfinal.bits.green = ((c1.bits.green * alpha ) + (c2.bits.green * (16 - alpha) ))/16; + cfinal.bits.blue = ((c1.bits.blue * alpha ) + (c2.bits.blue * (16 - alpha) ))/16; + + final = cfinal.val; + } + } + } + + if(BLDCNT & 0x1) + { + if (BLDY_EVY != 0x0) + { + final = fadeInColors[BLDY_EVY][final&0x7FFF]; + } + + T2WriteWord(dst, passing, (final | 0x8000)); + bgPixels[x] = 0; + } + else + { + T2WriteWord(dst, passing, (final | 0x8000)); + bgPixels[x] = 0; + } +} + +FORCEINLINE void GPU::setFinal3DColorSpecialDecrease(int dstX, int srcX) +{ + DECL3D; + + u16 final = color; + + // We must blend if the 3D layer has the highest prio + // But it doesn't seem to have priority over fading + // unlike semi-transparent sprites + if((alpha < 16)) //zero 30-may-09 - i think 3d always blends && bg0HasHighestPrio) + { + int bg_under = bgPixels[x]; + + // If the layer we are drawing on is selected as 2nd source, we can blend + if(BLDCNT & (0x100 << bg_under)) + { + { + COLOR c1, c2, cfinal; + + c1.val = color; + c2.val = T2ReadWord(dst, passing); + + cfinal.bits.red = ((c1.bits.red * alpha ) + (c2.bits.red * (16 - alpha) ))/16; + cfinal.bits.green = ((c1.bits.green * alpha ) + (c2.bits.green * (16 - alpha) ))/16; + cfinal.bits.blue = ((c1.bits.blue * alpha ) + (c2.bits.blue * (16 - alpha) ))/16; + + final = cfinal.val; + } + } + } + + if(BLDCNT & 0x1) + { + if (BLDY_EVY != 0x0) + { + final = fadeOutColors[BLDY_EVY][final&0x7FFF]; + } + + T2WriteWord(dst, passing, (final | 0x8000)); + bgPixels[x] = 0; + } + else + { + T2WriteWord(dst, passing, (final | 0x8000)); + bgPixels[x] = 0; + } +} + +FORCEINLINE void GPU::setFinal3DColorSpecialNoneWnd(int dstX, int srcX) +{ + DECL3D; + + bool windowDraw = true, windowEffect = true; + + renderline_checkWindows(x, windowDraw, windowEffect); + + if(windowDraw) + { + // We must blend if the 3D layer has the highest prio + if((alpha < 16)) //zero 30-may-09 - i think 3d always blends && bg0HasHighestPrio) + { + int bg_under = bgPixels[x]; + u16 final = color; + + // If the layer we are drawing on is selected as 2nd source, we can blend + if(BLDCNT & (0x100 << bg_under)) + { + { + COLOR c1, c2, cfinal; + + c1.val = color; + c2.val = T2ReadWord(dst, passing); + + cfinal.bits.red = ((c1.bits.red * alpha ) + (c2.bits.red * (16 - alpha) ))/16; + cfinal.bits.green = ((c1.bits.green * alpha ) + (c2.bits.green * (16 - alpha) ))/16; + cfinal.bits.blue = ((c1.bits.blue * alpha ) + (c2.bits.blue * (16 - alpha) ))/16; + + final = cfinal.val; + } + } + + T2WriteWord(dst, passing, (final | 0x8000)); + bgPixels[x] = 0; + } + else + { + T2WriteWord(dst, passing, (color | 0x8000)); + bgPixels[x] = 0; + } + } +} + +FORCEINLINE void GPU::setFinal3DColorSpecialBlendWnd(int dstX, int srcX) +{ + DECL3D; + + bool windowDraw = true, windowEffect = true; + + renderline_checkWindows(x, windowDraw, windowEffect); + + if(windowDraw) + { + // We can blend if the 3D layer is selected as 1st target, + // but also if the 3D layer has the highest prio. + if((alpha < 16)) //zero 30-may-09 - i think 3d always blends && (((BLDCNT & 0x1) && windowEffect) || bg0HasHighestPrio)) + { + int bg_under = bgPixels[x]; + u16 final = color; + + // If the layer we are drawing on is selected as 2nd source, we can blend + if(BLDCNT & (0x100 << bg_under)) + { + { + COLOR c1, c2, cfinal; + + c1.val = color; + c2.val = T2ReadWord(dst, passing); + + cfinal.bits.red = ((c1.bits.red * alpha ) + (c2.bits.red * (16 - alpha) ))/16; + cfinal.bits.green = ((c1.bits.green * alpha ) + (c2.bits.green * (16 - alpha) ))/16; + cfinal.bits.blue = ((c1.bits.blue * alpha ) + (c2.bits.blue * (16 - alpha) ))/16; + + final = cfinal.val; + } + } + + T2WriteWord(dst, passing, (final | 0x8000)); + bgPixels[x] = 0; + } + else + { + T2WriteWord(dst, passing, (color | 0x8000)); + bgPixels[x] = 0; + } + } +} + +FORCEINLINE void GPU::setFinal3DColorSpecialIncreaseWnd(int dstX, int srcX) +{ + DECL3D; + + bool windowDraw = true, windowEffect = true; + u16 final = color; + + renderline_checkWindows(x, windowDraw, windowEffect); + + if(windowDraw) + { + // We must blend if the 3D layer has the highest prio + // But it doesn't seem to have priority over fading, + // unlike semi-transparent sprites + if((alpha < 16)) //zero 30-may-09 - i think 3d always blends && bg0HasHighestPrio) + { + int bg_under = bgPixels[x]; + + // If the layer we are drawing on is selected as 2nd source, we can blend + if(BLDCNT & (0x100 << bg_under)) + { + { + COLOR c1, c2, cfinal; + + c1.val = color; + c2.val = T2ReadWord(dst, passing); + + cfinal.bits.red = ((c1.bits.red * alpha ) + (c2.bits.red * (16 - alpha) ))/16; + cfinal.bits.green = ((c1.bits.green * alpha ) + (c2.bits.green * (16 - alpha) ))/16; + cfinal.bits.blue = ((c1.bits.blue * alpha ) + (c2.bits.blue * (16 - alpha) ))/16; + + final = cfinal.val; + } + } + } + + if((BLDCNT & 0x1) && windowEffect) + { + if (BLDY_EVY != 0x0) + { + final = fadeInColors[BLDY_EVY][final&0x7FFF]; + } + + T2WriteWord(dst, passing, (final | 0x8000)); + bgPixels[x] = 0; + } + else + { + T2WriteWord(dst, passing, (final | 0x8000)); + bgPixels[x] = 0; + } + } +} + +FORCEINLINE void GPU::setFinal3DColorSpecialDecreaseWnd(int dstX, int srcX) +{ + DECL3D; + + bool windowDraw = true, windowEffect = true; + u16 final = color; + + renderline_checkWindows(x, windowDraw, windowEffect); + + if(windowDraw) + { + // We must blend if the 3D layer has the highest prio + // But it doesn't seem to have priority over fading, + // unlike semi-transparent sprites + if((alpha < 16)) ////zero 30-may-09 - i think 3d always blends && bg0HasHighestPrio) + { + int bg_under = bgPixels[x]; + + // If the layer we are drawing on is selected as 2nd source, we can blend + if(BLDCNT & (0x100 << bg_under)) + { + { + COLOR c1, c2, cfinal; + + c1.val = color; + c2.val = T2ReadWord(dst, passing); + + cfinal.bits.red = ((c1.bits.red * alpha ) + (c2.bits.red * (16 - alpha) ))/16; + cfinal.bits.green = ((c1.bits.green * alpha ) + (c2.bits.green * (16 - alpha) ))/16; + cfinal.bits.blue = ((c1.bits.blue * alpha ) + (c2.bits.blue * (16 - alpha) ))/16; + + final = cfinal.val; + } + } + } + + if((BLDCNT & 0x1) && windowEffect) + { + if (BLDY_EVY != 0x0) + { + final = fadeOutColors[BLDY_EVY][final&0x7FFF]; + } + + T2WriteWord(dst, passing, (final | 0x8000)); + bgPixels[x] = 0; + } + else + { + T2WriteWord(dst, passing, (final | 0x8000)); + bgPixels[x] = 0; + } + } +} + + +enum OBJFunc +{ + None, Blend, Increase, Decrease +}; +template +static void _master_setFinalOBJColor(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u8 type, u16 x); + +static void setFinalOBJColorSpecialNoneWnd (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u8 type, u16 x); +static void setFinalOBJColorSpecialBlendWnd (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u8 type, u16 x); +static void setFinalOBJColorSpecialIncreaseWnd (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u8 type, u16 x); +static void setFinalOBJColorSpecialDecreaseWnd (GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u8 type, u16 x); + +const GPU::FinalOBJColFunct pixelBlittersOBJ[8] = { + _master_setFinalOBJColor, + _master_setFinalOBJColor, + _master_setFinalOBJColor, + _master_setFinalOBJColor, + _master_setFinalOBJColor, + _master_setFinalOBJColor, + _master_setFinalOBJColor, + _master_setFinalOBJColor }; + +/*****************************************************************************/ +// INITIALIZATION +/*****************************************************************************/ + + +static void GPU_InitFadeColors() +{ + /* + NOTE: gbatek (in the reference above) seems to expect 6bit values + per component, but as desmume works with 5bit per component, + we use 31 as top, instead of 63. Testing it on a few games, + using 63 seems to give severe color wraping, and 31 works + nicely, so for now we'll just that, until proven wrong. + + i have seen pics of pokemon ranger getting white with 31, with 63 it is nice. + it could be pb of alpha or blending or... + + MightyMax> created a test NDS to check how the brightness values work, + and 31 seems to be correct. FactorEx is a override for max brighten/darken + See: http://mightymax.org/gfx_test_brightness.nds + The Pokemon Problem could be a problem with 8/32 bit writes not recognized yet, + i'll add that so you can check back. + + */ + + for(int i = 0; i <= 16; i++) + { + for(int j = 0x8000; j < 0x10000; j++) + { + COLOR cur; + + cur.val = j; + cur.bits.red = (cur.bits.red + ((31 - cur.bits.red) * i / 16)); + cur.bits.green = (cur.bits.green + ((31 - cur.bits.green) * i / 16)); + cur.bits.blue = (cur.bits.blue + ((31 - cur.bits.blue) * i / 16)); + cur.bits.alpha = 0; + fadeInColors[i][j & 0x7FFF] = cur.val; + + cur.val = j; + cur.bits.red = (cur.bits.red - (cur.bits.red * i / 16)); + cur.bits.green = (cur.bits.green - (cur.bits.green * i / 16)); + cur.bits.blue = (cur.bits.blue - (cur.bits.blue * i / 16)); + cur.bits.alpha = 0; + fadeOutColors[i][j & 0x7FFF] = cur.val; + } + } + + + for(int c0=0;c0<=31;c0++) + for(int c1=0;c1<=31;c1++) + for(int eva=0;eva<=16;eva++) + for(int evb=0;evb<=16;evb++) + { + int blend = ((c0 * eva / 16) + (c1 * evb / 16) ); + int final = std::min(31,blend); + gpuBlendTable555[eva][evb][c0][c1] = final; + } +} + +GPU * GPU_Init(u8 l) +{ + GPU * g; + + if ((g = (GPU *) malloc(sizeof(GPU))) == NULL) + return NULL; + + GPU_Reset(g, l); + GPU_InitFadeColors(); + + g->curr_win[0] = win_empty; + g->curr_win[1] = win_empty; + g->need_update_winh[0] = true; + g->need_update_winh[1] = true; + g->setFinalColorBck_funcNum = 0; + g->setFinalColor3d_funcNum = 0; + g->setFinalColorSpr = _master_setFinalOBJColor; + + + + return g; +} + +void GPU_Reset(GPU *g, u8 l) +{ + memset(g, 0, sizeof(GPU)); + + g->setFinalColorBck_funcNum = 0; + g->setFinalColor3d_funcNum = 0; + g->setFinalColorSpr = _master_setFinalOBJColor; + g->core = l; + g->BGSize[0][0] = g->BGSize[1][0] = g->BGSize[2][0] = g->BGSize[3][0] = 256; + g->BGSize[0][1] = g->BGSize[1][1] = g->BGSize[2][1] = g->BGSize[3][1] = 256; + g->dispOBJ = g->dispBG[0] = g->dispBG[1] = g->dispBG[2] = g->dispBG[3] = TRUE; + + g->spriteRenderMode = GPU::SPRITE_1D; + + g->bgPrio[4] = 0xFF; + + g->bg0HasHighestPrio = TRUE; + + if(g->core == GPU_SUB) + { + g->oam = (OAM *)(ARM9Mem.ARM9_OAM + ADDRESS_STEP_1KB); + g->sprMem = ARM9MEM_BOBJ; + // GPU core B + g->dispx_st = (REG_DISPx*)(&ARM9Mem.ARM9_REG[REG_DISPB]); + } + else + { + g->oam = (OAM *)(ARM9Mem.ARM9_OAM); + g->sprMem = ARM9MEM_AOBJ; + // GPU core A + g->dispx_st = (REG_DISPx*)(&ARM9Mem.ARM9_REG[0]); + } +} + +void GPU_DeInit(GPU * gpu) +{ + free(gpu); +} + +static void GPU_resortBGs(GPU *gpu) +{ + int i, prio; + struct _DISPCNT * cnt = &gpu->dispx_st->dispx_DISPCNT.bits; + itemsForPriority_t * item; + + // we don't need to check for windows here... +// if we tick boxes, invisible layers become invisible & vice versa +#define OP ^ ! +// if we untick boxes, layers become invisible +//#define OP && + gpu->LayersEnable[0] = gpu->dispBG[0] OP(cnt->BG0_Enable/* && !(cnt->BG0_3D && (gpu->core==0))*/); + gpu->LayersEnable[1] = gpu->dispBG[1] OP(cnt->BG1_Enable); + gpu->LayersEnable[2] = gpu->dispBG[2] OP(cnt->BG2_Enable); + gpu->LayersEnable[3] = gpu->dispBG[3] OP(cnt->BG3_Enable); + gpu->LayersEnable[4] = gpu->dispOBJ OP(cnt->OBJ_Enable); + + // KISS ! lower priority first, if same then lower num + for (i=0;iitemsForPriority[i]); + item->nbBGs=0; + item->nbPixelsX=0; + } + for (i=NB_BG; i>0; ) { + i--; + if (!gpu->LayersEnable[i]) continue; + prio = (gpu->dispx_st)->dispx_BGxCNT[i].bits.Priority; + item = &(gpu->itemsForPriority[prio]); + item->BGs[item->nbBGs]=i; + item->nbBGs++; + } + + int bg0Prio = gpu->dispx_st->dispx_BGxCNT[0].bits.Priority; + gpu->bg0HasHighestPrio = TRUE; + for(i = 1; i < 4; i++) + { + if(gpu->LayersEnable[i]) + { + if(gpu->dispx_st->dispx_BGxCNT[i].bits.Priority < bg0Prio) + { + gpu->bg0HasHighestPrio = FALSE; + break; + } + } + } + +#if 0 +//debug + for (i=0;iitemsForPriority[i]); + printf("%d : ", i); + for (j=0; jnbBGs) + printf("BG%d ", item->BGs[j]); + else + printf("... ", item->BGs[j]); + } + } + printf("\n"); +#endif +} + +static FORCEINLINE u16 _blend(u16 colA, u16 colB, GPU::TBlendTable* blendTable) +{ + u8 r = (*blendTable)[colA&0x1F][colB&0x1F]; + u8 g = (*blendTable)[(colA>>5)&0x1F][(colB>>5)&0x1F]; + u8 b = (*blendTable)[(colA>>10)&0x1F][(colB>>10)&0x1F]; + + return r|(g<<5)|(b<<10); +} + +FORCEINLINE u16 GPU::blend(u16 colA, u16 colB) +{ + return _blend(colA, colB, blendTable); +} + + +void GPU_setMasterBrightness (GPU *gpu, u16 val) +{ + if(!nds.isInVblank()) { + PROGINFO("Changing master brightness outside of vblank\n"); + } + gpu->MasterBrightFactor = (val & 0x1F); + gpu->MasterBrightMode = (val>>14); +} + +void SetupFinalPixelBlitter (GPU *gpu) +{ + u8 windowUsed = (gpu->WIN0_ENABLED | gpu->WIN1_ENABLED | gpu->WINOBJ_ENABLED); + u8 blendMode = (gpu->BLDCNT >> 6)&3; + + gpu->setFinalColorSpr = pixelBlittersOBJ[windowUsed*4 + blendMode]; + gpu->setFinalColorBck_funcNum = windowUsed*4 + blendMode; + gpu->setFinalColor3d_funcNum = windowUsed*4 + blendMode; + +} + +//Sets up LCD control variables for Display Engines A and B for quick reading +void GPU_setVideoProp(GPU * gpu, u32 p) +{ + struct _DISPCNT * cnt; + cnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; + + T1WriteLong((u8 *)&(gpu->dispx_st)->dispx_DISPCNT.val, 0, p); + + gpu->WIN0_ENABLED = cnt->Win0_Enable; + gpu->WIN1_ENABLED = cnt->Win1_Enable; + gpu->WINOBJ_ENABLED = cnt->WinOBJ_Enable; + + SetupFinalPixelBlitter (gpu); + + gpu->dispMode = cnt->DisplayMode & ((gpu->core)?1:3); + + gpu->vramBlock = cnt->VRAM_Block; + + switch (gpu->dispMode) + { + case 0: // Display Off + break; + case 1: // Display BG and OBJ layers + break; + case 2: // Display framebuffer + gpu->VRAMaddr = (u8 *)ARM9Mem.ARM9_LCD + (gpu->vramBlock * 0x20000); + break; + case 3: // Display from Main RAM + // nothing to be done here + // see GPU_ligne who gets data from FIFO. + break; + } + + if(cnt->OBJ_Tile_mapping) + { + //1-d sprite mapping boundaries: + //32k, 64k, 128k, 256k + gpu->sprBoundary = 5 + cnt->OBJ_Tile_1D_Bound ; + + //do not be deceived: even though a sprBoundary==8 (256KB region) is impossible to fully address + //in GPU_SUB, it is still fully legal to address it with that granularity. + //so don't do this: //if((gpu->core == GPU_SUB) && (cnt->OBJ_Tile_1D_Bound == 3)) gpu->sprBoundary = 7; + + gpu->spriteRenderMode = GPU::SPRITE_1D; + } else { + //2d sprite mapping + //boundary : 32k + gpu->sprBoundary = 5; + gpu->spriteRenderMode = GPU::SPRITE_2D; + } + + if(cnt->OBJ_BMP_1D_Bound && (gpu->core == GPU_MAIN)) + gpu->sprBMPBoundary = 8; + else + gpu->sprBMPBoundary = 7; + + gpu->sprEnable = cnt->OBJ_Enable; + + GPU_setBGProp(gpu, 3, T1ReadWord(ARM9Mem.ARM9_REG, gpu->core * ADDRESS_STEP_4KB + 14)); + GPU_setBGProp(gpu, 2, T1ReadWord(ARM9Mem.ARM9_REG, gpu->core * ADDRESS_STEP_4KB + 12)); + GPU_setBGProp(gpu, 1, T1ReadWord(ARM9Mem.ARM9_REG, gpu->core * ADDRESS_STEP_4KB + 10)); + GPU_setBGProp(gpu, 0, T1ReadWord(ARM9Mem.ARM9_REG, gpu->core * ADDRESS_STEP_4KB + 8)); + + //GPU_resortBGs(gpu); +} + +//this handles writing in BGxCNT +void GPU_setBGProp(GPU * gpu, u16 num, u16 p) +{ + struct _BGxCNT * cnt = &((gpu->dispx_st)->dispx_BGxCNT[num].bits); + struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; + + T1WriteWord((u8 *)&(gpu->dispx_st)->dispx_BGxCNT[num].val, 0, p); + + GPU_resortBGs(gpu); + + if(gpu->core == GPU_SUB) + { + gpu->BG_tile_ram[num] = ARM9MEM_BBG; + gpu->BG_bmp_ram[num] = ARM9MEM_BBG; + gpu->BG_bmp_large_ram[num] = ARM9MEM_BBG; + gpu->BG_map_ram[num] = ARM9MEM_BBG; + } + else + { + gpu->BG_tile_ram[num] = ARM9MEM_ABG + dispCnt->CharacBase_Block * ADDRESS_STEP_64KB ; + gpu->BG_bmp_ram[num] = ARM9MEM_ABG; + gpu->BG_bmp_large_ram[num] = ARM9MEM_ABG; + gpu->BG_map_ram[num] = ARM9MEM_ABG + dispCnt->ScreenBase_Block * ADDRESS_STEP_64KB; + } + + gpu->BG_tile_ram[num] += (cnt->CharacBase_Block * ADDRESS_STEP_16KB); + gpu->BG_bmp_ram[num] += (cnt->ScreenBase_Block * ADDRESS_STEP_16KB); + gpu->BG_map_ram[num] += (cnt->ScreenBase_Block * ADDRESS_STEP_2KB); + + switch(num) + { + case 0: + case 1: + gpu->BGExtPalSlot[num] = cnt->PaletteSet_Wrap * 2 + num ; + break; + + default: + gpu->BGExtPalSlot[num] = (u8)num; + break; + } + + BGType mode = GPU_mode2type[dispCnt->BG_Mode][num]; + + //clarify affine ext modes + if(mode == BGType_AffineExt) + { + //see: http://nocash.emubase.de/gbatek.htm#dsvideobgmodescontrol + u8 affineModeSelection = (cnt->Palette_256 << 1) | (cnt->CharacBase_Block & 1) ; + switch(affineModeSelection) + { + case 0: + case 1: + mode = BGType_AffineExt_256x16; + break; + case 2: + mode = BGType_AffineExt_256x1; + break; + case 3: + mode = BGType_AffineExt_Direct; + break; + } + } + + gpu->BGTypes[num] = mode; + + gpu->BGSize[num][0] = sizeTab[mode][cnt->ScreenSize][0]; + gpu->BGSize[num][1] = sizeTab[mode][cnt->ScreenSize][1]; + + gpu->bgPrio[num] = (p & 0x3); +} + +/*****************************************************************************/ +// ENABLING / DISABLING LAYERS +/*****************************************************************************/ + +void GPU_remove(GPU * gpu, u8 num) +{ + if (num == 4) gpu->dispOBJ = 0; + else gpu->dispBG[num] = 0; + GPU_resortBGs(gpu); +} +void GPU_addBack(GPU * gpu, u8 num) +{ + //REG_DISPx_pack_test(gpu); + if (num == 4) gpu->dispOBJ = 1; + else gpu->dispBG[num] = 1; + GPU_resortBGs(gpu); +} + + +/*****************************************************************************/ +// ROUTINES FOR INSIDE / OUTSIDE WINDOW CHECKS +/*****************************************************************************/ + +template +FORCEINLINE bool GPU::withinRect(u8 x) const +{ + return curr_win[WIN_NUM][x]; +} + + + +// Now assumes that *draw and *effect are different from 0 when called, so we can avoid +// setting some values twice +FORCEINLINE void GPU::renderline_checkWindows(u16 x, bool &draw, bool &effect) const +{ + // Check if win0 if enabled, and only check if it is + // howevever, this has already been taken care of by the window precalculation + //if (WIN0_ENABLED) + { + // it is in win0, do we display ? + // high priority + if (withinRect<0>(x)) + { + //INFO("bg%i passed win0 : (%i %i) was within (%i %i)(%i %i)\n", bgnum, x, gpu->currLine, gpu->WIN0H0, gpu->WIN0V0, gpu->WIN0H1, gpu->WIN0V1); + draw = (WININ0 >> currBgNum)&1; + effect = (WININ0_SPECIAL); + return; + } + } + + // Check if win1 if enabled, and only check if it is + //if (WIN1_ENABLED) + // howevever, this has already been taken care of by the window precalculation + { + // it is in win1, do we display ? + // mid priority + if(withinRect<1>(x)) + { + //INFO("bg%i passed win1 : (%i %i) was within (%i %i)(%i %i)\n", bgnum, x, gpu->currLine, gpu->WIN1H0, gpu->WIN1V0, gpu->WIN1H1, gpu->WIN1V1); + draw = (WININ1 >> currBgNum)&1; + effect = (WININ1_SPECIAL); + return; + } + } + + //if(true) //sprwin test hack + if (WINOBJ_ENABLED) + { + // it is in winOBJ, do we display ? + // low priority + if (sprWin[x]) + { + draw = (WINOBJ >> currBgNum)&1; + effect = (WINOBJ_SPECIAL); + return; + } + } + + if (WINOBJ_ENABLED | WIN1_ENABLED | WIN0_ENABLED) + { + draw = (WINOUT >> currBgNum) & 1; + effect = (WINOUT_SPECIAL); + } +} + +/*****************************************************************************/ +// PIXEL RENDERING - BGS +/*****************************************************************************/ + +template FORCEINLINE void GPU::setFinalBGColorSpecialNone(u16 &color, const u8 x) +{ +} + +template FORCEINLINE void GPU::setFinalBGColorSpecialBlend(u16 &color, const u8 x) +{ + //blend backdrop with what?? this doesn't make sense + if(BACKDROP) return; + if(blend1) + { + //If the layer we are drawing on is selected as 2nd source, we can blend + int bg_under = bgPixels[x]; + if(blend2[bg_under]) + color = blend(color,T2ReadWord(currDst, x<<1)); + } +} + +template FORCEINLINE void GPU::setFinalBGColorSpecialIncrease (u16 &color, const u8 x) +{ + if(blend1) // the bg to draw has a special color effect + { + color = currentFadeInColors[color]; + } +} + +template FORCEINLINE void GPU::setFinalBGColorSpecialDecrease(u16 &color, const u8 x) +{ + if(blend1) // the bg to draw has a special color effect + { + color = currentFadeOutColors[color]; + } +} + +template FORCEINLINE bool GPU::setFinalBGColorSpecialNoneWnd(u16 &color, const u8 x) +{ + bool windowDraw = true, windowEffect = true; + + renderline_checkWindows(x, windowDraw, windowEffect); + + if(BACKDROP) windowDraw = true; //backdrop must always be drawn + + if (blend1 && windowEffect) // the bg to draw has a special color effect + { + return true; + } + else + { + if ((windowEffect && (BLDCNT & (0x100 << currBgNum))) || windowDraw) + { + return true; + } + } + return false; +} + +template FORCEINLINE bool GPU::setFinalBGColorSpecialBlendWnd(u16 &color, const u8 x) +{ + bool windowDraw = true, windowEffect = true; + + renderline_checkWindows(x, windowDraw, windowEffect); + + if(BACKDROP) windowDraw = true; //backdrop must always be drawn + + if(windowDraw) + { + if(blend1 && windowEffect) + { + int bg_under = bgPixels[x]; + + // If the layer we are drawing on is selected as 2nd source, we can blend + if(blend2[bg_under]) + color = blend(color,T2ReadWord(currDst, x<<1)); + } + return true; + } + return false; +} + +template FORCEINLINE bool GPU::setFinalBGColorSpecialIncreaseWnd(u16 &color, const u8 x) +{ + bool windowDraw = true, windowEffect = true; + + renderline_checkWindows(x, windowDraw, windowEffect); + + if(BACKDROP) windowDraw = true; //backdrop must always be drawn + + if(windowDraw) + { + if(blend1 && windowEffect) + { + color = currentFadeInColors[color]; + } + return true; + } + return false; +} + +template FORCEINLINE bool GPU::setFinalBGColorSpecialDecreaseWnd(u16 &color, const u8 x) +{ + bool windowDraw = true, windowEffect = true; + + renderline_checkWindows(x, windowDraw, windowEffect); + + if(BACKDROP) windowDraw = true; //backdrop must always be drawn + + if(windowDraw) + { + if(blend1 && windowEffect) + { + color = currentFadeOutColors[color]; + } + return true; + } + return false; +} + +/*****************************************************************************/ +// PIXEL RENDERING - OBJS +/*****************************************************************************/ + +template +static void _master_setFinalOBJColor(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u8 type, u16 x) +{ + bool windowDraw = true, windowEffect = true; + + if(WINDOW) + { + gpu->renderline_checkWindows(x, windowDraw, windowEffect); + if(!windowDraw) + return; + } + + //this inspects the layer beneath the sprite to see if the current blend flags make it a candidate for blending + int bg_under = gpu->bgPixels[x]; + bool allowBlend = ((bg_under != 4) && (gpu->BLDCNT & (0x100 << bg_under))); + + bool sourceEffectSelected = (gpu->BLDCNT & 0x10)!=0; + + //note that the fadein and fadeout is done here before blending, + //so that a fade and blending can be applied at the same time + bool forceBlendingForNormal = false; + if(windowEffect && sourceEffectSelected) + switch(FUNC) + { + case Increase: if(!allowBlend) color = fadeInColors[gpu->BLDY_EVY][color&0x7FFF]; break; + case Decrease: if(!allowBlend) color = fadeOutColors[gpu->BLDY_EVY][color&0x7FFF]; break; + + //only when blend color effect is selected, ordinarily opaque sprites are blended with the color effect params + case Blend: forceBlendingForNormal = true; break; + } + + + if(allowBlend) + { + u16 backColor = T2ReadWord(dst,passing); + //this hasn't been tested: this blending occurs without regard to the color effect, + //but rather purely from the sprite's alpha + if(type == GPU_OBJ_MODE_Bitmap) + color = _blend(color,backColor,&gpuBlendTable555[alpha+1][15-alpha]); + else if(type == GPU_OBJ_MODE_Transparent || forceBlendingForNormal) + color = gpu->blend(color,backColor); + } + + T2WriteWord(dst, passing, (color | 0x8000)); + gpu->bgPixels[x] = 4; +} + +template FORCEINLINE void GPU::setFinalColorBG(u16 color, u8 x) +{ + //It is not safe to assert this here. + //This is probably the best place to enforce it, since almost every single color that comes in here + //will be pulled from a palette that needs the top bit stripped off anyway. + //assert((color&0x8000)==0); + color &= 0x7FFF; + + //if someone disagrees with these, they could be reimplemented as a function pointer easily + bool draw=true; + switch(setFinalColorBck_funcNum) + { + case 0x0: setFinalBGColorSpecialNone(color,x); break; + case 0x1: setFinalBGColorSpecialBlend(color,x); break; + case 0x2: setFinalBGColorSpecialIncrease(color,x); break; + case 0x3: setFinalBGColorSpecialDecrease(color,x); break; + case 0x4: draw=setFinalBGColorSpecialNoneWnd(color,x); break; + case 0x5: draw=setFinalBGColorSpecialBlendWnd(color,x); break; + case 0x6: draw=setFinalBGColorSpecialIncreaseWnd(color,x); break; + case 0x7: draw=setFinalBGColorSpecialDecreaseWnd(color,x); break; + }; + + if(draw) + { + T2WriteWord(currDst, x<<1, color | 0x8000); + bgPixels[x] = currBgNum; + } +} + + +FORCEINLINE void GPU::setFinalColor3d(int dstX, int srcX) +{ + //if someone disagrees with these, they could be reimplemented as a function pointer easily + switch(setFinalColor3d_funcNum) + { + case 0x0: setFinal3DColorSpecialNone(dstX,srcX); break; + case 0x1: setFinal3DColorSpecialBlend(dstX,srcX); break; + case 0x2: setFinal3DColorSpecialIncrease(dstX,srcX); break; + case 0x3: setFinal3DColorSpecialDecrease(dstX,srcX); break; + case 0x4: setFinal3DColorSpecialNoneWnd(dstX,srcX); break; + case 0x5: setFinal3DColorSpecialBlendWnd(dstX,srcX); break; + case 0x6: setFinal3DColorSpecialIncreaseWnd(dstX,srcX); break; + case 0x7: setFinal3DColorSpecialDecreaseWnd(dstX,srcX); break; + }; +} + +//this was forced inline because most of the time it just falls through to setFinalColorBck() and the function call +//overhead was ridiculous and terrible +template FORCEINLINE void GPU::__setFinalColorBck(u16 color, const u8 x, const bool opaque) +{ + //I commented out this line to make a point. + //indeed, since x is a u8 we cannot pass in anything >=256 + //but in fact, someone is going to try. specifically, that is the map viewer debug tools + //which try to render the enter BG. in cases where that is large, it could be up to 1024 wide. + //I think it survives this truncation to 8bits. + //assert(x<256); + + int x_int; + + //due to this early out, we will get incorrect behavior in cases where + //we enable mosaic in the middle of a frame. this is deemed unlikely. + if(!MOSAIC) { + if(opaque) goto finish; + else return; + } + + if(!opaque) color = 0xFFFF; + else color &= 0x7FFF; + + //due to the early out, enabled must always be true + //x_int = enabled ? GPU::mosaicLookup.width[x].trunc : x; + x_int = GPU::mosaicLookup.width[x].trunc; + + if(GPU::mosaicLookup.width[x].begin && GPU::mosaicLookup.height[currLine].begin) {} + else color = mosaicColors.bg[currBgNum][x_int]; + mosaicColors.bg[currBgNum][x] = color; + + if(color != 0xFFFF) + { +finish: + setFinalColorBG(color,x); + } +} + +//this is fantastically inaccurate. +//we do the early return even though it reduces the resulting accuracy +//because we need the speed, and because it is inaccurate anyway +static void mosaicSpriteLinePixel(GPU * gpu, int x, u16 l, u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab) +{ + int x_int; + u8 y = l; + + _OAM_ * spriteInfo = (_OAM_ *)(gpu->oam + gpu->sprNum[x]); + bool enabled = spriteInfo->Mosaic; + if(!enabled) + return; + + bool opaque = prioTab[x] <= 4; + + GPU::MosaicColor::Obj objColor; + objColor.color = T1ReadWord(dst,x<<1); + objColor.alpha = dst_alpha[x]; + objColor.opaque = opaque; + + x_int = enabled ? GPU::mosaicLookup.width[x].trunc : x; + + if(enabled) + { + if(GPU::mosaicLookup.width[x].begin && GPU::mosaicLookup.height[y].begin) {} + else objColor = gpu->mosaicColors.obj[x_int]; + } + gpu->mosaicColors.obj[x] = objColor; + + T1WriteWord(dst,x<<1,objColor.color); + dst_alpha[x] = objColor.alpha; + if(!objColor.opaque) prioTab[x] = 0xFF; +} + +static void mosaicSpriteLine(GPU * gpu, u16 l, u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab) +{ + //don't even try this unless the mosaic is effective + if(gpu->mosaicLookup.widthValue != 0 || gpu->mosaicLookup.heightValue != 0) + for(int i=0;i<256;i++) + mosaicSpriteLinePixel(gpu,i,l,dst,dst_alpha,typeTab,prioTab); +} + +template void lineLarge8bpp(GPU * gpu) +{ + if(gpu->core == 1) { + PROGINFO("Cannot use large 8bpp screen on sub core\n"); + return; + } + + BGxOFS * ofs = &gpu->dispx_st->dispx_BGxOFS[gpu->currBgNum]; + u8 num = gpu->currBgNum; + u16 XBG = T1ReadWord((u8 *)&ofs->BGxHOFS, 0); + u16 YBG = gpu->currLine + T1ReadWord((u8 *)&ofs->BGxVOFS, 0); + u16 lg = gpu->BGSize[num][0]; + u16 ht = gpu->BGSize[num][1]; + u16 wmask = (lg-1); + u16 hmask = (ht-1); + YBG &= hmask; + + //TODO - handle wrapping / out of bounds correctly from rot_scale_op? + + u32 tmp_map = gpu->BG_bmp_large_ram[num] + lg * YBG; + u8* map = MMU_RenderMapToLCD(tmp_map); + + u8* pal = ARM9Mem.ARM9_VMEM + gpu->core * ADDRESS_STEP_1KB; + + for(int x = 0; x < lg; ++x, ++XBG) + { + XBG &= wmask; + u8 pixel = map[XBG]; + u16 color = T1ReadWord(pal, pixel<<1); + gpu->__setFinalColorBck(color,x,color!=0); + } + +} + +/*****************************************************************************/ +// BACKGROUND RENDERING -TEXT- +/*****************************************************************************/ +// render a text background to the combined pixelbuffer +template INLINE void renderline_textBG(GPU * gpu, u16 XBG, u16 YBG, u16 LG) +{ + u8 num = gpu->currBgNum; + struct _BGxCNT *bgCnt = &(gpu->dispx_st)->dispx_BGxCNT[num].bits; + struct _DISPCNT *dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; + u16 lg = gpu->BGSize[num][0]; + u16 ht = gpu->BGSize[num][1]; + u16 wmask = (lg-1); + u16 hmask = (ht-1); + u16 tmp = ((YBG & hmask) >> 3); + u32 map; + u8 *pal, *line; + u32 tile; + u16 color; + u16 xoff; + u16 yoff; + u32 x = 0; + u32 xfin; + + s8 line_dir = 1; + u32 mapinfo; + TILEENTRY tileentry; + + u32 tmp_map = gpu->BG_map_ram[num] + (tmp&31) * 64; + if(tmp>31) + tmp_map+= ADDRESS_STEP_512B << bgCnt->ScreenSize ; + + //map = (u8*)MMU_RenderMapToLCD(tmp_map); + map = tmp_map; + //if(!map) return; // no map + + tile = gpu->BG_tile_ram[num]; + //if(!tile) return; // no tiles + + xoff = XBG; + pal = ARM9Mem.ARM9_VMEM + gpu->core * ADDRESS_STEP_1KB; + + if(!bgCnt->Palette_256) // color: 16 palette entries + { + yoff = ((YBG&7)<<2); + xfin = 8 - (xoff&7); + for(x = 0; x < LG; xfin = std::min(x+8, LG)) + { + u16 tilePalette = 0; + tmp = ((xoff&wmask)>>3); + mapinfo = map + (tmp&0x1F) * 2; + if(tmp>31) mapinfo += 32*32*2; + tileentry.val = T1ReadWord(MMU_gpu_map(mapinfo), 0); + + tilePalette = (tileentry.bits.Palette*16); + + line = (u8*)MMU_gpu_map(tile + (tileentry.bits.TileNum * 0x20) + ((tileentry.bits.VFlip) ? (7*4)-yoff : yoff)); + + if(tileentry.bits.HFlip) + { + line += (3 - ((xoff&7)>>1)); + for(; x < xfin; line --) + { + u8 currLine = *line; + + if(!(xoff&1)) + { + color = T1ReadWord(pal, ((currLine>>4) + tilePalette) << 1); + gpu->__setFinalColorBck(color,x,currLine>>4); + x++; xoff++; + } + + color = T1ReadWord(pal, ((currLine&0xF) + tilePalette) << 1); + gpu->__setFinalColorBck(color,x,currLine&0xF); + x++; xoff++; + } + } else { + line += ((xoff&7)>>1); + for(; x < xfin; line ++) + { + u8 currLine = *line; + + if(!(xoff&1)) + { + color = T1ReadWord(pal, ((currLine&0xF) + tilePalette) << 1); + gpu->__setFinalColorBck(color,x,currLine&0xF); + x++; xoff++; + } + + color = T1ReadWord(pal, ((currLine>>4) + tilePalette) << 1); + gpu->__setFinalColorBck(color,x,currLine>>4); + x++; xoff++; + } + } + } + return; + } + + //256-color BG + + if(dispCnt->ExBGxPalette_Enable) // color: extended palette + { + pal = ARM9Mem.ExtPal[gpu->core][gpu->BGExtPalSlot[num]]; + if(!pal) return; + } + + yoff = ((YBG&7)<<3); + + xfin = 8 - (xoff&7); + for(x = 0; x < LG; xfin = std::min(x+8, LG)) + { + tmp = (xoff & (lg-1))>>3; + mapinfo = map + (tmp & 31) * 2; + if(tmp > 31) mapinfo += 32*32*2; + tileentry.val = T1ReadWord(MMU_gpu_map(mapinfo), 0); + + line = (u8*)MMU_gpu_map(tile + (tileentry.bits.TileNum*0x40) + ((tileentry.bits.VFlip) ? (7*8)-yoff : yoff)); + + if(tileentry.bits.HFlip) + { + line += (7 - (xoff&7)); + line_dir = -1; + } else { + line += (xoff&7); + line_dir = 1; + } + for(; x < xfin; ) + { + if(dispCnt->ExBGxPalette_Enable) + color = T1ReadWord(pal, ((*line) + (tileentry.bits.Palette<<8)) << 1); + else + color = T1ReadWord(pal, (*line) << 1); + + gpu->__setFinalColorBck(color,x,*line); + + x++; xoff++; + + line += line_dir; + } + } +} + +/*****************************************************************************/ +// BACKGROUND RENDERING -ROTOSCALE- +/*****************************************************************************/ + +template FORCEINLINE void rot_tiled_8bit_entry(GPU * gpu, s32 auxX, s32 auxY, int lg, u32 map, u32 tile, u8 * pal, int i, u8 extPal) { + u8 palette_entry; + u16 tileindex, x, y, color; + + tileindex = *(u8*)MMU_gpu_map(map + ((auxX>>3) + (auxY>>3) * (lg>>3))); + + x = (auxX&7); + y = (auxY&7); + + palette_entry = *(u8*)MMU_gpu_map(tile + ((tileindex<<6)+(y<<3)+x)); + color = T1ReadWord(pal, palette_entry << 1); + gpu->__setFinalColorBck(color,i,palette_entry); +} + +template FORCEINLINE void rot_tiled_16bit_entry(GPU * gpu, s32 auxX, s32 auxY, int lg, u32 map, u32 tile, u8 * pal, int i, u8 extPal) { + u8 palette_entry; + u16 x, y, color; + TILEENTRY tileentry; + + void* map_addr = MMU_gpu_map(map + (((auxX>>3) + (auxY>>3) * (lg>>3))<<1)); + + tileentry.val = T1ReadWord(map_addr, 0); + + x = (tileentry.bits.HFlip) ? 7 - (auxX&7) : (auxX&7); + y = (tileentry.bits.VFlip) ? 7 - (auxY&7) : (auxY&7); + + palette_entry = *(u8*)MMU_gpu_map(tile + ((tileentry.bits.TileNum<<6)+(y<<3)+x)); + color = T1ReadWord(pal, (palette_entry + (extPal ? (tileentry.bits.Palette<<8) : 0)) << 1); + gpu->__setFinalColorBck(color, i, palette_entry); +} + +template FORCEINLINE void rot_256_map(GPU * gpu, s32 auxX, s32 auxY, int lg, u32 map, u32 tile, u8 * pal, int i, u8 extPal) { + u8 palette_entry; + u16 color; + + u8* adr = (u8*)MMU_gpu_map((map) + ((auxX + auxY * lg))); + + palette_entry = *adr; + color = T1ReadWord(pal, palette_entry << 1); + gpu->__setFinalColorBck(color, i, palette_entry); +} + +template FORCEINLINE void rot_BMP_map(GPU * gpu, s32 auxX, s32 auxY, int lg, u32 map, u32 tile, u8 * pal, int i, u8 extPal) { + u16 color; + void* adr = MMU_gpu_map((map) + ((auxX + auxY * lg) << 1)); + color = T1ReadWord(adr, 0); + gpu->__setFinalColorBck(color, i, color&0x8000); +} + +typedef void (*rot_fun)(GPU * gpu, s32 auxX, s32 auxY, int lg, u32 map, u32 tile, u8 * pal , int i, u8 extPal); + +template +FORCEINLINE void rot_scale_op(GPU * gpu, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, u16 LG, s32 wh, s32 ht, BOOL wrap, u32 map, u32 tile, u8 * pal, u8 extPal) +{ + ROTOCOORD x, y; + x.val = X; + y.val = Y; + + const s32 dx = (s32)PA; + const s32 dy = (s32)PC; + + for(int i = 0; i < LG; ++i) + { + s32 auxX, auxY; + auxX = x.bits.Integer; + auxY = y.bits.Integer; + + bool checkBounds = true; + if(wrap) + { + auxX = auxX & (wh-1); + auxY = auxY & (ht-1); + + //since we just wrapped, we dont need to check bounds + checkBounds = false; + } + + if(!checkBounds || ((auxX >= 0) && (auxX < wh) && (auxY >= 0) && (auxY < ht))) + fun(gpu, auxX, auxY, wh, map, tile, pal, i, extPal); + + x.val += dx; + y.val += dy; + } +} + +template +FORCEINLINE void apply_rot_fun(GPU * gpu, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, u16 LG, u32 map, u32 tile, u8 * pal, u8 extPal) +{ + struct _BGxCNT * bgCnt = &(gpu->dispx_st)->dispx_BGxCNT[gpu->currBgNum].bits; + s32 wh = gpu->BGSize[gpu->currBgNum][0]; + s32 ht = gpu->BGSize[gpu->currBgNum][1]; + rot_scale_op(gpu, X, Y, PA, PB, PC, PD, LG, wh, ht, bgCnt->PaletteSet_Wrap, map, tile, pal, extPal); +} + + +template FORCEINLINE void rotBG2(GPU * gpu, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, u16 LG) +{ + u8 num = gpu->currBgNum; + u8 * pal = ARM9Mem.ARM9_VMEM + gpu->core * 0x400; +// printf("rot mode\n"); + apply_rot_fun >(gpu,X,Y,PA,PB,PC,PD,LG, gpu->BG_map_ram[num], gpu->BG_tile_ram[num], pal, 0); +} + +template FORCEINLINE void extRotBG2(GPU * gpu, s32 X, s32 Y, s16 PA, s16 PB, s16 PC, s16 PD, s16 LG) +{ + u8 num = gpu->currBgNum; + struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; + + u8 *map, *tile, *pal; + + switch(gpu->BGTypes[num]) + { + case BGType_AffineExt_256x16: + if(dispCnt->ExBGxPalette_Enable) + pal = ARM9Mem.ExtPal[gpu->core][gpu->BGExtPalSlot[num]]; + else + pal = ARM9Mem.ARM9_VMEM + gpu->core * 0x400; + if (!pal) return; + // 16 bit bgmap entries + apply_rot_fun >(gpu,X,Y,PA,PB,PC,PD,LG, gpu->BG_map_ram[num], gpu->BG_tile_ram[num], pal, dispCnt->ExBGxPalette_Enable); + return; + case BGType_AffineExt_256x1: + // 256 colors + pal = ARM9Mem.ARM9_VMEM + gpu->core * 0x400; + apply_rot_fun >(gpu,X,Y,PA,PB,PC,PD,LG, gpu->BG_bmp_ram[num], NULL, pal, 0); + return; + case BGType_AffineExt_Direct: + // direct colors / BMP + apply_rot_fun >(gpu,X,Y,PA,PB,PC,PD,LG, gpu->BG_bmp_ram[num], NULL, NULL, 0); + return; + case BGType_Large8bpp: + // large screen 256 colors + pal = ARM9Mem.ARM9_VMEM + gpu->core * 0x400; + apply_rot_fun >(gpu,X,Y,PA,PB,PC,PD,LG, gpu->BG_bmp_large_ram[num], NULL, pal, 0); + return; + default: break; + } +} + +/*****************************************************************************/ +// BACKGROUND RENDERING -HELPER FUNCTIONS- +/*****************************************************************************/ + +#if 0 +static void lineNull(GPU * gpu) +{ +} +#endif + +template void lineText(GPU * gpu) +{ + BGxOFS * ofs = &gpu->dispx_st->dispx_BGxOFS[gpu->currBgNum]; + renderline_textBG(gpu, T1ReadWord((u8 *)&ofs->BGxHOFS, 0), gpu->currLine + T1ReadWord((u8 *)&ofs->BGxVOFS, 0), 256); +} + +template void lineRot(GPU * gpu) +{ + BGxPARMS * parms; + if (gpu->currBgNum==2) { + parms = &(gpu->dispx_st)->dispx_BG2PARMS; + } else { + parms = &(gpu->dispx_st)->dispx_BG3PARMS; + } + if(gpu->debug) + rotBG2(gpu, 0, (s16)gpu->currLine*256, 256,0, -1,-1, 256); + else + { + rotBG2(gpu, + parms->BGxX, + parms->BGxY, + parms->BGxPA, + parms->BGxPB, + parms->BGxPC, + parms->BGxPD, + 256); + parms->BGxX += parms->BGxPB; + parms->BGxY += parms->BGxPD; + } +} + +template void lineExtRot(GPU * gpu) +{ + BGxPARMS * parms; + if (gpu->currBgNum==2) { + parms = &(gpu->dispx_st)->dispx_BG2PARMS; + } else { + parms = &(gpu->dispx_st)->dispx_BG3PARMS; + } + + if(gpu->debug) + extRotBG2(gpu, 0, (s16)gpu->currLine*256, 256,0, -1,-1, 256); + else + { + extRotBG2(gpu, + parms->BGxX, + parms->BGxY, + parms->BGxPA, + parms->BGxPB, + parms->BGxPC, + parms->BGxPD, + 256); + parms->BGxX += parms->BGxPB; + parms->BGxY += parms->BGxPD; + } +} + +/*****************************************************************************/ +// SPRITE RENDERING -HELPER FUNCTIONS- +/*****************************************************************************/ + +#define nbShow 128 + +/* if i understand it correct, and it fixes some sprite problems in chameleon shot */ +/* we have a 15 bit color, and should use the pal entry bits as alpha ?*/ +/* http://nocash.emubase.de/gbatek.htm#dsvideoobjs */ +INLINE void render_sprite_BMP (GPU * gpu, u8 spriteNum, u16 l, u8 * dst, u16 * src, u8 * dst_alpha, u8 * typeTab, u8 * prioTab, + u8 prio, int lg, int sprX, int x, int xdir, u8 alpha) +{ + int i; u16 color; + for(i = 0; i < lg; i++, ++sprX, x+=xdir) + { + color = LE_TO_LOCAL_16(src[x]); + + // alpha bit = invisible + if ((color&0x8000)&&(prio<=prioTab[sprX])) + { + /* if we don't draw, do not set prio, or else */ + // if (gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, color, sprX)) + { + T2WriteWord(dst, (sprX<<1), color); + dst_alpha[sprX] = alpha; + typeTab[sprX] = 3; + prioTab[sprX] = prio; + gpu->sprNum[sprX] = spriteNum; + } + } + } +} + +INLINE void render_sprite_256 ( GPU * gpu, u8 spriteNum, u16 l, u8 * dst, u8 * src, u16 * pal, + u8 * dst_alpha, u8 * typeTab, u8 * prioTab, u8 prio, int lg, int sprX, int x, int xdir, u8 alpha) +{ + int i; + u8 palette_entry; + u16 color; + + for(i = 0; i < lg; i++, ++sprX, x+=xdir) + { + palette_entry = src[(x&0x7) + ((x&0xFFF8)<<3)]; + color = LE_TO_LOCAL_16(pal[palette_entry]); + + // palette entry = 0 means backdrop + if ((palette_entry>0)&&(prio<=prioTab[sprX])) + { + /* if we don't draw, do not set prio, or else */ + //if (gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, color, sprX)) + { + T2WriteWord(dst, (sprX<<1), color); + dst_alpha[sprX] = 16; + typeTab[sprX] = (alpha ? 1 : 0); + prioTab[sprX] = prio; + gpu->sprNum[sprX] = spriteNum; + } + } + } +} + +INLINE void render_sprite_16 ( GPU * gpu, u16 l, u8 * dst, u8 * src, u16 * pal, + u8 * dst_alpha, u8 * typeTab, u8 * prioTab, u8 prio, int lg, int sprX, int x, int xdir, u8 alpha) +{ + int i; + u8 palette, palette_entry; + u16 color, x1; + + for(i = 0; i < lg; i++, ++sprX, x+=xdir) + { + x1 = x>>1; + palette = src[(x1&0x3) + ((x1&0xFFFC)<<3)]; + if (x & 1) palette_entry = palette >> 4; + else palette_entry = palette & 0xF; + color = LE_TO_LOCAL_16(pal[palette_entry]); + + // palette entry = 0 means backdrop + if ((palette_entry>0)&&(prio<=prioTab[sprX])) + { + /* if we don't draw, do not set prio, or else */ + //if (gpu->setFinalColorSpr(gpu, sprX << 1,4,dst, color, sprX )) + { + T2WriteWord(dst, (sprX<<1), color); + dst_alpha[sprX] = 16; + typeTab[sprX] = (alpha ? 1 : 0); + prioTab[sprX] = prio; + } + } + } +} + +INLINE void render_sprite_Win (GPU * gpu, u16 l, u8 * src, + int col256, int lg, int sprX, int x, int xdir) { + int i; u8 palette, palette_entry; + u16 x1; + if (col256) { + for(i = 0; i < lg; i++, sprX++,x+=xdir) + //sprWin[sprX] = (src[x])?1:0; + if(src[x]) + sprWin[sprX] = 1; + } else { + for(i = 0; i < lg; i++, ++sprX, x+=xdir) + { + x1 = x>>1; + palette = src[(x1&0x3) + ((x1&0xFFFC)<<3)]; + if (x & 1) palette_entry = palette >> 4; + else palette_entry = palette & 0xF; + //sprWin[sprX] = (palette_entry)?1:0; + if(palette_entry) + sprWin[sprX] = 1; + } + } +} + +// return val means if the sprite is to be drawn or not +FORCEINLINE BOOL compute_sprite_vars(_OAM_ * spriteInfo, u16 l, + size &sprSize, s32 &sprX, s32 &sprY, s32 &x, s32 &y, s32 &lg, int &xdir) { + + x = 0; + // get sprite location and size + sprX = (spriteInfo->X/*<<23*/)/*>>23*/; + sprY = spriteInfo->Y; + sprSize = sprSizeTab[spriteInfo->Size][spriteInfo->Shape]; + + lg = sprSize.x; + + if (sprY>=192) + sprY = (s32)((s8)(spriteInfo->Y)); + +// FIXME: for rot/scale, a list of entries into the sprite should be maintained, +// that tells us where the first pixel of a screenline starts in the sprite, +// and how a step to the right in a screenline translates within the sprite + + if ((l=sprY+sprSize.y) || /* sprite lines outside of screen */ + (sprX==256)||(sprX+sprSize.x<=0)) /* sprite pixels outside of line */ + return FALSE; /* not to be drawn */ + + // sprite portion out of the screen (LEFT) + if(sprX<0) + { + lg += sprX; + x = -(sprX); + sprX = 0; + } + // sprite portion out of the screen (RIGHT) + if (sprX+sprSize.x >= 256) + lg = 256 - sprX; + + y = l - sprY; /* get the y line within sprite coords */ + + // switch TOP<-->BOTTOM + if (spriteInfo->VFlip) + y = sprSize.y - y -1; + + // switch LEFT<-->RIGHT + if (spriteInfo->HFlip) { + x = sprSize.x - x -1; + xdir = -1; + } else { + xdir = 1; + } + return TRUE; +} + +/*****************************************************************************/ +// SPRITE RENDERING +/*****************************************************************************/ + +void GPU::spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab) +{ + if(spriteRenderMode == SPRITE_1D) + _spriteRender(dst,dst_alpha,typeTab, prioTab); + else + _spriteRender(dst,dst_alpha,typeTab, prioTab); +} + +//TODO - refactor this so there isnt as much duped code between rotozoomed and non-rotozoomed versions + +template +void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab) +{ + u16 l = currLine; + GPU *gpu = this; + + struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; + _OAM_ * spriteInfo = (_OAM_ *)(gpu->oam + (nbShow-1));// + 127; + u8 block = gpu->sprBoundary; + u16 i; + +#ifdef WORDS_BIGENDIAN + *(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15; + *(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14; +#endif + + for(i = 0; i> 15 + ,*(((u16*)(spriteInfo+1))+2) = (*(((u16*)(spriteInfo+1))+2) << 2) | *(((u16*)(spriteInfo+1))+2) >> 14 + ,*(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15 + ,*(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) >> 2) | *(((u16*)spriteInfo)+2) << 14 +#endif + ) + { + //for each sprite: + + size sprSize; + s32 sprX, sprY, x, y, lg; + int xdir; + u8 prio, * src; + u16 j; + + // Check if sprite is disabled before everything + if (spriteInfo->RotScale == 2) + continue; + + prio = spriteInfo->Priority; + + if (spriteInfo->RotScale & 1) + { + s32 fieldX, fieldY, auxX, auxY, realX, realY, offset; + u8 blockparameter, *pal; + s16 dx, dmx, dy, dmy; + u16 colour; + + // Get sprite positions and size + sprX = (spriteInfo->X<<23)>>23; + sprY = spriteInfo->Y; + sprSize = sprSizeTab[spriteInfo->Size][spriteInfo->Shape]; + + lg = sprSize.x; + + if (sprY>=192) + sprY = (s32)((s8)(spriteInfo->Y)); + + // Copy sprite size, to check change it if needed + fieldX = sprSize.x; + fieldY = sprSize.y; + + // If we are using double size mode, double our control vars + if (spriteInfo->RotScale & 2) + { + fieldX <<= 1; + fieldY <<= 1; + lg <<= 1; + } + + // Check if sprite enabled + if ((l = sprY+fieldY) || + (sprX==256) || (sprX+fieldX<=0)) + continue; + + y = l - sprY; + + // Get which four parameter block is assigned to this sprite + blockparameter = (spriteInfo->RotScalIndex + (spriteInfo->HFlip<< 3) + (spriteInfo->VFlip << 4))*4; + + // Get rotation/scale parameters +#ifdef WORDS_BIGENDIAN + dx = ((s16)(gpu->oam + blockparameter+0)->attr31 << 8) | ((s16)(gpu->oam + blockparameter+0)->attr30); + dmx = ((s16)(gpu->oam + blockparameter+1)->attr31 << 8) | ((s16)(gpu->oam + blockparameter+1)->attr30); + dy = ((s16)(gpu->oam + blockparameter+2)->attr31 << 8) | ((s16)(gpu->oam + blockparameter+2)->attr30); + dmy = ((s16)(gpu->oam + blockparameter+3)->attr31 << 8) | ((s16)(gpu->oam + blockparameter+3)->attr30); +#else + dx = (s16)(gpu->oam + blockparameter+0)->attr3; + dmx = (s16)(gpu->oam + blockparameter+1)->attr3; + dy = (s16)(gpu->oam + blockparameter+2)->attr3; + dmy = (s16)(gpu->oam + blockparameter+3)->attr3; +#endif + + // Calculate fixed poitn 8.8 start offsets + realX = ((sprSize.x) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx + y * dmx; + realY = ((sprSize.y) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy + y * dmy; + + if(sprX<0) + { + // If sprite is not in the window + if(sprX + fieldX <= 0) + continue; + + // Otherwise, is partially visible + lg += sprX; + realX -= sprX*dx; + realY -= sprX*dy; + sprX = 0; + } + else + { + if(sprX+fieldX>256) + lg = 256 - sprX; + } + + // If we are using 1 palette of 256 colours + if(spriteInfo->Depth) + { + //2d: src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + ((spriteInfo->TileIndex) << 5)); + src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex << block)); + + // If extended palettes are set, use them + if (dispCnt->ExOBJPalette_Enable) + pal = (ARM9Mem.ObjExtPal[gpu->core][0]+(spriteInfo->PaletteIndex*0x200)); + else + pal = (ARM9Mem.ARM9_VMEM + 0x200 + gpu->core *0x400); + + for(j = 0; j < lg; ++j, ++sprX) + { + // Get the integer part of the fixed point 8.8, and check if it lies inside the sprite data + auxX = (realX>>8); + auxY = (realY>>8); + + if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y) + { + if(MODE == SPRITE_2D) + offset = (auxX&0x7) + ((auxX&0xFFF8)<<3) + ((auxY>>3)<<10) + ((auxY&0x7)*8); + else + offset = (auxX&0x7) + ((auxX&0xFFF8)<<3) + ((auxY>>3)*sprSize.x*8) + ((auxY&0x7)*8); + + colour = src[offset]; + + if (colour && (prioTab[sprX]>=prio)) + { + T2WriteWord(dst, (sprX<<1), T2ReadWord(pal, (colour<<1))); + dst_alpha[sprX] = 16; + typeTab[sprX] = spriteInfo->Mode; + prioTab[sprX] = prio; + } + } + + // Add the rotation/scale coeficients, here the rotation/scaling + // is performed + realX += dx; + realY += dy; + } + + continue; + } + // Rotozoomed direct color + else if(spriteInfo->Mode == 3) + { + if (dispCnt->OBJ_BMP_mapping) + src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<sprMem + (((spriteInfo->TileIndex&0x03E0) * 8) + (spriteInfo->TileIndex&0x001F))*16); + + for(j = 0; j < lg; ++j, ++sprX) + { + // Get the integer part of the fixed point 8.8, and check if it lies inside the sprite data + auxX = (realX>>8); + auxY = (realY>>8); + + if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y) + { + //if(MODE == SPRITE_2D) //tested by buffy sacrifice damage blood splatters in corner + //else //tested by lego indiana jones + offset = auxX + (auxY*sprSize.x); + + colour = T1ReadWord (src, offset<<1); + + if((colour&0x8000) && (prioTab[sprX]>=prio)) + { + T2WriteWord(dst, (sprX<<1), colour); + dst_alpha[sprX] = spriteInfo->PaletteIndex; + typeTab[sprX] = spriteInfo->Mode; + prioTab[sprX] = prio; + } + } + + // Add the rotation/scale coeficients, here the rotation/scaling + // is performed + realX += dx; + realY += dy; + } + + continue; + } + // Rotozoomed 16/16 palette + else + { + if(MODE == SPRITE_2D) + { + src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<<5)); + pal = ARM9Mem.ARM9_VMEM + 0x200 + (gpu->core*0x400 + (spriteInfo->PaletteIndex*32)); + } + else + { + src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<sprBoundary)); + pal = ARM9Mem.ARM9_VMEM + 0x200 + gpu->core*0x400 + (spriteInfo->PaletteIndex*32); + } + + for(j = 0; j < lg; ++j, ++sprX) + { + // Get the integer part of the fixed point 8.8, and check if it lies inside the sprite data + auxX = (realX>>8); + auxY = (realY>>8); + + if (auxX >= 0 && auxY >= 0 && auxX < sprSize.x && auxY < sprSize.y) + { + if(MODE == SPRITE_2D) + offset = ((auxX>>1)&0x3) + (((auxX>>1)&0xFFFC)<<3) + ((auxY>>3)<<10) + ((auxY&0x7)*4); + else + offset = ((auxX>>1)&0x3) + (((auxX>>1)&0xFFFC)<<3) + ((auxY>>3)*sprSize.x)*4 + ((auxY&0x7)*4); + + colour = src[offset]; + + // Get 4bits value from the readed 8bits + if (auxX&1) colour >>= 4; + else colour &= 0xF; + + if(colour && (prioTab[sprX]>=prio)) + { + T2WriteWord(dst, (sprX<<1), LE_TO_LOCAL_16(T2ReadWord(pal, colour << 1))); + dst_alpha[sprX] = 16; + typeTab[sprX] = spriteInfo->Mode; + prioTab[sprX] = prio; + } + } + + // Add the rotation/scale coeficients, here the rotation/scaling + // is performed + realX += dx; + realY += dy; + } + + continue; + } + } + else + { + u16 * pal; + + + if (!compute_sprite_vars(spriteInfo, l, sprSize, sprX, sprY, x, y, lg, xdir)) + continue; + + if (spriteInfo->Mode == 2) + { + if(MODE == SPRITE_2D) + { + if (spriteInfo->Depth) + src = (u8 *)MMU_gpu_map(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*8)); + else + src = (u8 *)MMU_gpu_map(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*4)); + } + else + { + if (spriteInfo->Depth) + src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<>3)*sprSize.x*8) + ((y&0x7)*8)); + else + src = (u8 *)MMU_RenderMapToLCD(gpu->sprMem + (spriteInfo->TileIndex<>3)*sprSize.x*4) + ((y&0x7)*4)); + } + + render_sprite_Win (gpu, l, src, spriteInfo->Depth, lg, sprX, x, xdir); + continue; + } + + if (spriteInfo->Mode == 3) /* sprite is in BMP format */ + { + + //transparent (i think, dont bother to render?) if alpha is 0 + if(spriteInfo->PaletteIndex == 0) + continue; + + if (dispCnt->OBJ_BMP_mapping) + { + //tested by buffy sacrifice damage blood splatters in corner + src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<OBJ_BMP_2D_dim) + //256*256, verified by heroes of mana FMV intro + src = (u8 *)MMU_gpu_map(gpu->sprMem + (((spriteInfo->TileIndex&0x3E0) * 64 + (spriteInfo->TileIndex&0x1F) *8 + ( y << 8)) << 1)); + else + //128*512, verified by harry potter and the order of the phoenix conversation portraits + src = (u8 *)MMU_gpu_map(gpu->sprMem + (((spriteInfo->TileIndex&0x3F0) * 64 + (spriteInfo->TileIndex&0x0F) *8 + ( y << 7)) << 1)); + } + + render_sprite_BMP (gpu, i, l, dst, (u16*)src, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->PaletteIndex); + continue; + } + + if(spriteInfo->Depth) /* 256 colors */ + { + if(MODE == SPRITE_2D) + src = (u8 *)MMU_gpu_map(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*8)); + else + src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<>3)*sprSize.x*8) + ((y&0x7)*8)); + + if (dispCnt->ExOBJPalette_Enable) + pal = (u16*)(ARM9Mem.ObjExtPal[gpu->core][0]+(spriteInfo->PaletteIndex*0x200)); + else + pal = (u16*)(ARM9Mem.ARM9_VMEM + 0x200 + gpu->core *0x400); + + render_sprite_256 (gpu, i, l, dst, src, pal, + dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->Mode == 1); + + continue; + } + // 16 colors + if(MODE == SPRITE_2D) + { + src = (u8 *)MMU_gpu_map(gpu->sprMem + ((spriteInfo->TileIndex)<<5) + ((y>>3)<<10) + ((y&0x7)*4)); + } + else + { + src = (u8 *)MMU_gpu_map(gpu->sprMem + (spriteInfo->TileIndex<>3)*sprSize.x*4) + ((y&0x7)*4)); + } + + pal = (u16*)(ARM9Mem.ARM9_VMEM + 0x200 + gpu->core * 0x400); + + pal += (spriteInfo->PaletteIndex<<4); + + render_sprite_16 (gpu, l, dst, src, pal, dst_alpha, typeTab, prioTab, prio, lg, sprX, x, xdir, spriteInfo->Mode == 1); + } + } + +#ifdef WORDS_BIGENDIAN + *(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) << 1) | *(((u16*)spriteInfo)+1) >> 15; + *(((u16*)spriteInfo)+2) = (*(((u16*)spriteInfo)+2) << 2) | *(((u16*)spriteInfo)+2) >> 14; +#endif +} + + +/*****************************************************************************/ +// SCREEN FUNCTIONS +/*****************************************************************************/ + +int Screen_Init(int coreid) +{ + MainScreen.gpu = GPU_Init(0); + SubScreen.gpu = GPU_Init(1); + + memset(GPU_screen, 0, sizeof(GPU_screen)); + for(int i = 0; i < (256*192*2); i++) + ((u16*)GPU_screen)[i] = 0x7FFF; + disp_fifo.head = disp_fifo.tail = 0; + + if (osd) {delete osd; osd =NULL; } + osd = new OSDCLASS(-1); + + return GPU_ChangeGraphicsCore(coreid); +} + +void Screen_Reset(void) +{ + GPU_Reset(MainScreen.gpu, 0); + GPU_Reset(SubScreen.gpu, 1); + + memset(GPU_screen, 0, sizeof(GPU_screen)); + for(int i = 0; i < (256*192*2); i++) + ((u16*)GPU_screen)[i] = 0x7FFF; + + disp_fifo.head = disp_fifo.tail = 0; + osd->clear(); +} + +void Screen_DeInit(void) +{ + GPU_DeInit(MainScreen.gpu); + GPU_DeInit(SubScreen.gpu); + + if (GFXCore) + GFXCore->DeInit(); + + if (osd) {delete osd; osd =NULL; } +} + +/*****************************************************************************/ +// GRAPHICS CORE +/*****************************************************************************/ + +// This is for future graphics core switching. This is by no means set in stone + +int GPU_ChangeGraphicsCore(int coreid) +{ + int i; + + // Make sure the old core is freed + if (GFXCore) + GFXCore->DeInit(); + + // So which core do we want? + if (coreid == GFXCORE_DEFAULT) + coreid = 0; // Assume we want the first one + + // Go through core list and find the id + for (i = 0; GFXCoreList[i] != NULL; i++) + { + if (GFXCoreList[i]->id == coreid) + { + // Set to current core + GFXCore = GFXCoreList[i]; + break; + } + } + + if (GFXCore == NULL) + { + GFXCore = &GFXDummy; + return -1; + } + + if (GFXCore->Init() == -1) + { + // Since it failed, instead of it being fatal, we'll just use the dummy + // core instead + GFXCore = &GFXDummy; + } + + return 0; +} + +int GFXDummyInit(); +void GFXDummyDeInit(); +void GFXDummyResize(int width, int height, BOOL fullscreen); +void GFXDummyOnScreenText(char *string, ...); + +GraphicsInterface_struct GFXDummy = { +GFXCORE_DUMMY, +"Dummy Graphics Interface", +0, +GFXDummyInit, +GFXDummyDeInit, +GFXDummyResize, +GFXDummyOnScreenText +}; + +int GFXDummyInit() +{ + return 0; +} + +void GFXDummyDeInit() +{ +} + +void GFXDummyResize(int width, int height, BOOL fullscreen) +{ +} + +void GFXDummyOnScreenText(char *string, ...) +{ +} + + +/*****************************************************************************/ +// GPU_ligne +/*****************************************************************************/ + +void GPU_set_DISPCAPCNT(u32 val) +{ + GPU * gpu = MainScreen.gpu; + struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; + + gpu->dispCapCnt.val = val; + gpu->dispCapCnt.EVA = std::min((u32)16, (val & 0x1F)); + gpu->dispCapCnt.EVB = std::min((u32)16, ((val >> 8) & 0x1F)); + gpu->dispCapCnt.writeBlock = (val >> 16) & 0x03; + gpu->dispCapCnt.writeOffset = (val >> 18) & 0x03; + gpu->dispCapCnt.readBlock = dispCnt->VRAM_Block; + + if (dispCnt->DisplayMode == 2) + gpu->dispCapCnt.readOffset = 0; + else + gpu->dispCapCnt.readOffset = (val >> 26) & 0x03; + + gpu->dispCapCnt.srcA = (val >> 24) & 0x01; + gpu->dispCapCnt.srcB = (val >> 25) & 0x01; + gpu->dispCapCnt.capSrc = (val >> 29) & 0x03; + + gpu->dispCapCnt.dst = (ARM9Mem.ARM9_LCD + + (gpu->dispCapCnt.writeBlock * 0x20000) + + (gpu->dispCapCnt.writeOffset * 0x8000) + ); + gpu->dispCapCnt.src = (ARM9Mem.ARM9_LCD + + (gpu->dispCapCnt.readBlock * 0x20000) + + (gpu->dispCapCnt.readOffset * 0x8000) + ); + + switch((val >> 20) & 0x03) + { + case 0: + gpu->dispCapCnt.capx = DISPCAPCNT::_128; + gpu->dispCapCnt.capy = 128; + break; + case 1: + gpu->dispCapCnt.capx = DISPCAPCNT::_256; + gpu->dispCapCnt.capy = 64; + break; + case 2: + gpu->dispCapCnt.capx = DISPCAPCNT::_256; + gpu->dispCapCnt.capy = 128; + break; + case 3: + gpu->dispCapCnt.capx = DISPCAPCNT::_256; + gpu->dispCapCnt.capy = 192; + break; + } + + /*INFO("Capture 0x%X:\n EVA=%i, EVB=%i, wBlock=%i, wOffset=%i, capX=%i, capY=%i\n rBlock=%i, rOffset=%i, srcCap=%i, dst=0x%X, src=0x%X\n srcA=%i, srcB=%i\n\n", + val, gpu->dispCapCnt.EVA, gpu->dispCapCnt.EVB, gpu->dispCapCnt.writeBlock, gpu->dispCapCnt.writeOffset, + gpu->dispCapCnt.capx, gpu->dispCapCnt.capy, gpu->dispCapCnt.readBlock, gpu->dispCapCnt.readOffset, + gpu->dispCapCnt.capSrc, gpu->dispCapCnt.dst - ARM9Mem.ARM9_LCD, gpu->dispCapCnt.src - ARM9Mem.ARM9_LCD, + gpu->dispCapCnt.srcA, gpu->dispCapCnt.srcB);*/ +} +// #define BRIGHT_TABLES + + +static void GPU_ligne_layer(NDS_Screen * screen, u16 l) +{ + GPU * gpu = screen->gpu; + struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; + itemsForPriority_t * item; + u8 spr[512]; + u8 sprAlpha[256]; + u8 sprType[256]; + u8 sprPrio[256]; + u8 prio; + u16 i16; + BOOL BG_enabled = TRUE; + + u16 backdrop_color = T1ReadWord(ARM9Mem.ARM9_VMEM, gpu->core * 0x400) & 0x7FFF; + + //we need to write backdrop colors in the same way as we do BG pixels in order to do correct window processing + //this is currently eating up 2fps or so. it is a reasonable candidate for optimization. + gpu->currBgNum = 5; + for(int x=0;x<256;x++) { + gpu->__setFinalColorBck(backdrop_color,x,1); + } + + //this check isnt really helpful. it just slows us down in the cases where we need the most speed + //if (!gpu->LayersEnable[0] && !gpu->LayersEnable[1] && !gpu->LayersEnable[2] && !gpu->LayersEnable[3] && !gpu->LayersEnable[4]) return; + + // init background color & priorities + memset(sprAlpha, 0, 256); + memset(sprType, 0, 256); + memset(sprPrio, 0xFF, 256); + memset(sprWin, 0, 256); + + // init pixels priorities + for (int i=0; iitemsForPriority[i].nbPixelsX = 0; + } + + // for all the pixels in the line + if (gpu->LayersEnable[4]) + { + //n.b. - this is clearing the sprite line buffer to the background color, + //but it has been changed to write u32 instead of u16 for a little speedup + for(int i = 0; i< 128; ++i) T2WriteLong(spr, i << 2, backdrop_color | (backdrop_color<<16)); + //zero 06-may-09: I properly supported window color effects for backdrop, but I am not sure + //how it interacts with this. I wish we knew why we needed this + + + gpu->spriteRender(spr, sprAlpha, sprType, sprPrio); + mosaicSpriteLine(gpu, l, spr, sprAlpha, sprType, sprPrio); + + + for(int i = 0; i<256; i++) + { + // assign them to the good priority item + prio = sprPrio[i]; + if (prio >=4) continue; + + item = &(gpu->itemsForPriority[prio]); + item->PixelsX[item->nbPixelsX]=i; + item->nbPixelsX++; + } + } + + + if (!gpu->LayersEnable[0] && !gpu->LayersEnable[1] && !gpu->LayersEnable[2] && !gpu->LayersEnable[3]) + BG_enabled = FALSE; + + // paint lower priorities fist + // then higher priorities on top + for(prio=NB_PRIORITIES; prio > 0; ) + { + prio--; + item = &(gpu->itemsForPriority[prio]); + // render BGs + if (BG_enabled) + { + for (int i=0; i < item->nbBGs; i++) + { + i16 = item->BGs[i]; + if (gpu->LayersEnable[i16]) + { + gpu->currBgNum = i16; + gpu->blend1 = gpu->BLDCNT & (1 << gpu->currBgNum); + for(int j=0;j<8;j++) + gpu->blend2[j] = (gpu->BLDCNT & (0x100 << j)); + gpu->currentFadeInColors = &fadeInColors[gpu->BLDY_EVY][0]; + gpu->currentFadeOutColors = &fadeOutColors[gpu->BLDY_EVY][0]; + //gpu->bgFunc = gpu->setFinalColorBck_funcNum; + + struct _BGxCNT *bgCnt = &(gpu->dispx_st)->dispx_BGxCNT[i16].bits; + gpu->curr_mosaic_enabled = bgCnt->Mosaic_Enable; + + //mosaic test hacks + //gpu->curr_mosaic_enabled = true; + + if (gpu->core == GPU_MAIN) + { + if (i16 == 0 && dispCnt->BG0_3D) + { + gpu->currBgNum = 0; + + BGxOFS *bgofs = &gpu->dispx_st->dispx_BGxOFS[i16]; + u16 hofs = (T1ReadWord((u8*)&bgofs->BGxHOFS, 0) & 0x1FF); + + gfx3d_GetLineData(l, &gpu->_3dColorLine, &gpu->_3dAlphaLine); + u16* colorLine = gpu->_3dColorLine; + + for(int k = 0; k < 256; k++) + { + int q = ((k + hofs) & 0x1FF); + + if((q < 0) || (q > 255)) + continue; + + if(colorLine[q] & 0x8000) + gpu->setFinalColor3d(k, q); + } + + continue; + } + } + + //useful for debugging individual layers + //if(gpu->core == 0 && i16 != 1) continue; + + if(gpu->curr_mosaic_enabled) + gpu->modeRender(i16); + else gpu->modeRender(i16); + } //layer enabled + } + } + + // render sprite Pixels + if (gpu->LayersEnable[4]) + { + gpu->currBgNum = 4; + ////analyze mosaic configuration + //u16 mosaic_control = T1ReadWord((u8 *)&gpu->dispx_st->dispx_MISC.MOSAIC, 0); + //gpu->curr_mosaic_enabled + + for (int i=0; i < item->nbPixelsX; i++) + { + i16=item->PixelsX[i]; + // T2WriteWord(dst, i16 << 1, T2ReadWord(spr, i16 << 1)); + // gpu->bgPixels[i16] = 4; + gpu->setFinalColorSpr(gpu, (i16<<1), gpu->currDst, T2ReadWord(spr, (i16<<1)), sprAlpha[i16], sprType[i16], i16); + } + } + } +} + +// TODO: capture emulated not fully +static void GPU_ligne_DispCapture(u16 l) +{ + //this macro takes advantage of the fact that there are only two possible values for capx + #define CAPCOPY(SRC,DST) \ + switch(gpu->dispCapCnt.capx) { \ + case DISPCAPCNT::_128: \ + for (int i = 0; i < 128; i++) \ + T2WriteWord(DST, i << 1, T2ReadWord(SRC, i << 1) | (1<<15)); \ + break; \ + case DISPCAPCNT::_256: \ + for (int i = 0; i < 256; i++) \ + T2WriteWord(DST, i << 1, T2ReadWord(SRC, i << 1) | (1<<15)); \ + break; \ + default: assert(false); \ + } + + GPU * gpu = MainScreen.gpu; + + if (l == 0) + { + if (gpu->dispCapCnt.val & 0x80000000) + { + gpu->dispCapCnt.enabled = TRUE; + T1WriteLong(ARM9Mem.ARM9_REG, 0x64, gpu->dispCapCnt.val); + } + } + + if (gpu->dispCapCnt.enabled) + { + u8 *cap_dst = (u8 *)(gpu->dispCapCnt.dst) + (l * 512); + + if (l < gpu->dispCapCnt.capy) + { + // TODO: Read/Write block wrap to 00000h when exceeding 1FFFFh (128k) + + switch (gpu->dispCapCnt.capSrc) + { + case 0: // Capture source is SourceA + { + //INFO("Capture source is SourceA\n"); + switch (gpu->dispCapCnt.srcA) + { + case 0: // Capture screen (BG + OBJ + 3D) + { + //INFO("Capture screen (BG + OBJ + 3D)\n"); + + u8 *src; + src = (u8*)(GPU_tempScanline); + CAPCOPY(src,cap_dst); + } + break; + case 1: // Capture 3D + { + //INFO("Capture 3D\n"); + u16* colorLine; + gfx3d_GetLineData(l, &colorLine, NULL); + CAPCOPY(((u8*)colorLine),cap_dst); + } + break; + } + } + break; + case 1: // Capture source is SourceB + { + //INFO("Capture source is SourceB\n"); + switch (gpu->dispCapCnt.srcB) + { + case 0: // Capture VRAM + { + //INFO("Capture VRAM\n"); + u8 *src = (u8 *)(gpu->dispCapCnt.src) + (l * 512); + CAPCOPY(src,cap_dst); + } + break; + case 1: // Capture Main Memory Display FIFO + { + //INFO("Capture Main Memory Display FIFO\n"); + } + break; + } + } + break; + default: // Capture source is SourceA+B blended + { + //INFO("Capture source is SourceA+B blended\n"); + u16 *srcA = NULL; + u16 *srcB = NULL; + + if (gpu->dispCapCnt.srcA == 0) + { + // Capture screen (BG + OBJ + 3D) + srcA = (u16*)(GPU_tempScanline); + } + else + { + gfx3d_GetLineData(l, &srcA, NULL); + } + + if (gpu->dispCapCnt.srcB == 0) // VRAM screen + srcB = (u16 *)((gpu->dispCapCnt.src) + (l * 512)); + else + srcB = NULL; // DISP FIFOS + + if ((srcA) && (srcB)) + { + u16 a, r, g, b; + const int todo = (gpu->dispCapCnt.capx==DISPCAPCNT::_128?128:256); + for(u16 i = 0; i < todo; i++) + { + a = r = g = b =0; + + if (gpu->dispCapCnt.EVA && (srcA[i] & 0x8000)) + { + a = 0x8000; + r = ((srcA[i] & 0x1F) * gpu->dispCapCnt.EVA); + g = (((srcA[i] >> 5) & 0x1F) * gpu->dispCapCnt.EVA); + b = (((srcA[i] >> 10) & 0x1F) * gpu->dispCapCnt.EVA); + } + + if (gpu->dispCapCnt.EVB && (srcB[i] & 0x8000)) + { + a = 0x8000; + r += ((srcB[i] & 0x1F) * gpu->dispCapCnt.EVB); + g += (((srcB[i] >> 5) & 0x1F) * gpu->dispCapCnt.EVB); + b += (((srcB[i] >> 10) & 0x1F) * gpu->dispCapCnt.EVB); + } + + r >>= 4; + g >>= 4; + b >>= 4; + + T2WriteWord(cap_dst, i << 1, (u16)(a | (b << 10) | (g << 5) | r)); + } + } + } + break; + } + } + + if (l>=191) + { + gpu->dispCapCnt.enabled = FALSE; + gpu->dispCapCnt.val &= 0x7FFFFFFF; + T1WriteLong(ARM9Mem.ARM9_REG, 0x64, gpu->dispCapCnt.val); + return; + } + } +} + +static INLINE void GPU_ligne_MasterBrightness(NDS_Screen * screen, u16 l) +{ + GPU * gpu = screen->gpu; + + u8 * dst = GPU_screen + (screen->offset + l) * 512; + u16 i16; + + //isn't it odd that we can set uselessly high factors here? + //factors above 16 change nothing. curious. + int factor = gpu->MasterBrightFactor; + if(factor==0) return; + if(factor>16) factor=16; + + +// Apply final brightness adjust (MASTER_BRIGHT) +// Reference: http://nocash.emubase.de/gbatek.htm#dsvideo (Under MASTER_BRIGHTNESS) +/* Mightymax> it should be more effective if the windowmanager applies brightness when drawing */ +/* it will most likly take acceleration, while we are stuck here with CPU power */ + + switch (gpu->MasterBrightMode) + { + // Disabled + case 0: + break; + + // Bright up + case 1: + { + for(i16 = 0; i16 < 256; ++i16) + { + ((u16*)dst)[i16] = fadeInColors[factor][((u16*)dst)[i16]&0x7FFF]; + } + break; + } + + // Bright down + case 2: + { + for(i16 = 0; i16 < 256; ++i16) + { + ((u16*)dst)[i16] = fadeOutColors[factor][((u16*)dst)[i16]&0x7FFF]; + } + break; + } + + // Reserved + case 3: + break; + } + +} + +template +FORCEINLINE void GPU::setup_windows() +{ + u8 y = currLine; + u16 startY,endY; + + if(WIN_NUM==0) + { + startY = WIN0V0; + endY = WIN0V1; + } + else + { + startY = WIN1V0; + endY = WIN1V1; + } + + if(WIN_NUM == 0 && !WIN0_ENABLED) goto allout; + if(WIN_NUM == 1 && !WIN1_ENABLED) goto allout; + + if(startY > endY) + { + if((y < startY) && (y > endY)) goto allout; + } + else + { + if((y < startY) || (y >= endY)) goto allout; + } + + //the x windows will apply for this scanline + curr_win[WIN_NUM] = h_win[WIN_NUM]; + return; + +allout: + curr_win[WIN_NUM] = win_empty; +} + +void GPU::update_winh(int WIN_NUM) +{ + //dont even waste any time in here if the window isnt enabled + if(WIN_NUM==0 && !WIN0_ENABLED) return; + if(WIN_NUM==1 && !WIN1_ENABLED) return; + + need_update_winh[WIN_NUM] = false; + u16 startX,endX; + + if(WIN_NUM==0) + { + startX = WIN0H0; + endX = WIN0H1; + } + else + { + startX = WIN1H0; + endX = WIN1H1; + } + + //the original logic: if you doubt the window code, please check it against the newer implementation below + //if(startX > endX) + //{ + // if((x < startX) && (x > endX)) return false; + //} + //else + //{ + // if((x < startX) || (x >= endX)) return false; + //} + + if(startX > endX) + { + for(int i=0;i<=endX;i++) + h_win[WIN_NUM][i] = 1; + for(int i=endX+1;igpu; + + //here is some setup which is only done on line 0 + if(l == 0) { + //this is speculative. the idea is as follows: + //whenever the user updates the affine start position regs, it goes into the active regs immediately + //(this is handled on the set event from MMU) + //maybe it shouldnt take effect until the next hblank or something.. + //this is a based on a combination of: + //heroes of mana intro FMV + //SPP level 3-8 rotoscale room + //NSMB raster fx backdrops + //bubble bobble revolution classic mode + //NOTE: + //I am REALLY unsatisfied with this logic now. But it seems to be working.. + gpu->refreshAffineStartRegs(-1,-1); + } + + //blacken the screen if it is turned off by the user + if(!CommonSettings.showGpu.screens[gpu->core]) + { + u8 * dst = GPU_screen + (screen->offset + l) * 512; + memset(dst,0,512); + return; + } + + //cache some parameters which are assumed to be stable throughout the rendering of the entire line + gpu->currLine = (u8)l; + u16 mosaic_control = T1ReadWord((u8 *)&gpu->dispx_st->dispx_MISC.MOSAIC, 0); + u16 mosaic_width = (mosaic_control & 0xF); + u16 mosaic_height = ((mosaic_control>>4) & 0xF); + + //mosaic test hacks + //mosaic_width = mosaic_height = 3; + + GPU::mosaicLookup.widthValue = mosaic_width; + GPU::mosaicLookup.heightValue = mosaic_height; + GPU::mosaicLookup.width = &GPU::mosaicLookup.table[mosaic_width][0]; + GPU::mosaicLookup.height = &GPU::mosaicLookup.table[mosaic_height][0]; + + if(gpu->need_update_winh[0]) gpu->update_winh(0); + if(gpu->need_update_winh[1]) gpu->update_winh(1); + + gpu->setup_windows<0>(); + gpu->setup_windows<1>(); + + //always generate the 2d+3d, no matter what we're displaying, since we may need to capture it + //(if this seems inefficient in some cases, consider that the speed in those cases is not really a problem) + GPU_tempScanline = screen->gpu->currDst = (u8 *)(GPU_screen) + (screen->offset + l) * 512; + GPU_ligne_layer(screen, l); + + if (gpu->core == GPU_MAIN) + { + GPU_ligne_DispCapture(l); + if (l == 191) { disp_fifo.head = disp_fifo.tail = 0; } + } + + switch (gpu->dispMode) + { + case 0: // Display Off(Display white) + { + u8 * dst = GPU_screen + (screen->offset + l) * 512; + + for (int i=0; i<256; i++) + T2WriteWord(dst, i << 1, 0x7FFF); + } + break; + + case 1: // Display BG and OBJ layers + //do nothing: it has already been generated into the right place + break; + + case 2: // Display framebuffer + { + u8 * dst = GPU_screen + (screen->offset + l) * 512; + u8 * src = gpu->VRAMaddr + (l*512); + memcpy (dst, src, 512); + } + break; + case 3: // Display memory FIFO + { + u8 * dst = GPU_screen + (screen->offset + l) * 512; + for (int i=0; i < 128; i++) + T1WriteLong(dst, i << 2, DISP_FIFOrecv() & 0x7FFF7FFF); + } + break; + } + + + + GPU_ligne_MasterBrightness(screen, l); +} + +void gpu_savestate(std::ostream* os) +{ + //version + write32le(1,os); + + os->write((char*)GPU_screen,sizeof(GPU_screen)); + + write32le(MainScreen.gpu->affineInfo[0].x,os); + write32le(MainScreen.gpu->affineInfo[0].y,os); + write32le(MainScreen.gpu->affineInfo[1].x,os); + write32le(MainScreen.gpu->affineInfo[1].y,os); + write32le(SubScreen.gpu->affineInfo[0].x,os); + write32le(SubScreen.gpu->affineInfo[0].y,os); + write32le(SubScreen.gpu->affineInfo[1].x,os); + write32le(SubScreen.gpu->affineInfo[1].y,os); +} + +bool gpu_loadstate(std::istream* is, int size) +{ + //read version + int version; + + //sigh.. shouldve used a new version number + if(size == 256*192*2*2) + version = 0; + else if(size== 0x30024) + { + read32le(&version,is); + version = 1; + } + else + if(read32le(&version,is) != 1) return false; + + + if(version<0||version>1) return false; + + is->read((char*)GPU_screen,sizeof(GPU_screen)); + + if(version==1) + { + read32le(&MainScreen.gpu->affineInfo[0].x,is); + read32le(&MainScreen.gpu->affineInfo[0].y,is); + read32le(&MainScreen.gpu->affineInfo[1].x,is); + read32le(&MainScreen.gpu->affineInfo[1].y,is); + read32le(&SubScreen.gpu->affineInfo[0].x,is); + read32le(&SubScreen.gpu->affineInfo[0].y,is); + read32le(&SubScreen.gpu->affineInfo[1].x,is); + read32le(&SubScreen.gpu->affineInfo[1].y,is); + //removed per nitsuja feedback. anyway, this same thing will happen almost immediately in gpu line=0 + //MainScreen.gpu->refreshAffineStartRegs(-1,-1); + //SubScreen.gpu->refreshAffineStartRegs(-1,-1); + } + + MainScreen.gpu->updateBLDALPHA(); + SubScreen.gpu->updateBLDALPHA(); + return !is->fail(); +} + +u32 GPU::getAffineStart(int layer, int xy) +{ + if(xy==0) return affineInfo[layer-2].x; + else return affineInfo[layer-2].y; +} + +void GPU::setAffineStartWord(int layer, int xy, u16 val, int word) +{ + u32 curr = getAffineStart(layer,xy); + if(word==0) curr = (curr&0xFFFF0000)|val; + else curr = (curr&0x0000FFFF)|(((u32)val)<<16); + setAffineStart(layer,xy,curr); +} + +void GPU::setAffineStart(int layer, int xy, u32 val) +{ + if(xy==0) affineInfo[layer-2].x = val; + else affineInfo[layer-2].y = val; + refreshAffineStartRegs(layer,xy); +} + +void GPU::refreshAffineStartRegs(const int num, const int xy) +{ + if(num==-1) + { + refreshAffineStartRegs(2,xy); + refreshAffineStartRegs(3,xy); + return; + } + + if(xy==-1) + { + refreshAffineStartRegs(num,0); + refreshAffineStartRegs(num,1); + return; + } + + BGxPARMS * parms; + if (num==2) + parms = &(dispx_st)->dispx_BG2PARMS; + else + parms = &(dispx_st)->dispx_BG3PARMS; + + if(xy==0) + parms->BGxX = affineInfo[num-2].x; + else + parms->BGxY = affineInfo[num-2].y; +} + +template void GPU::modeRender(int layer) +{ + switch(GPU_mode2type[dispCnt().BG_Mode][layer]) + { + case BGType_Text: lineText(this); break; + case BGType_Affine: lineRot(this); break; + case BGType_AffineExt: lineExtRot(this); break; + case BGType_Large8bpp: lineExtRot(this); break; + case BGType_Invalid: + PROGINFO("Attempting to render an invalid BG type\n"); + break; + default: + break; + } +} + +void gpu_UpdateRender() +{ + /*int x = 0, y = 0; + u16 *src = (u16*)GPU_screen; + u16 *dst = (u16*)GPU_screen; + + switch (gpu_angle) + { + case 0: + memcpy(dst, src, 256*192*4); + break; + + case 90: + for(y = 0; y < 384; y++) + { + for(x = 0; x < 256; x++) + { + dst[(383 - y) + (x * 384)] = src[x + (y * 256)]; + } + } + break; + case 180: + for(y = 0; y < 384; y++) + { + for(x = 0; x < 256; x++) + { + dst[(255 - x) + ((383 - y) * 256)] = src[x + (y * 256)]; + } + } + break; + case 270: + for(y = 0; y < 384; y++) + { + for(x = 0; x < 256; x++) + { + dst[y + ((255 - x) * 384)] = src[x + (y * 256)]; + } + } + default: + break; + }*/ +} + +void gpu_SetRotateScreen(u16 angle) +{ + gpu_angle = angle; +} + +//here is an old bg mosaic with some old code commented out. I am going to leave it here for a while to look at it +//sometimes in case I find a problem with the mosaic. +//static void __setFinalColorBck(GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, bool opaque) +//{ +// struct _BGxCNT *bgCnt = &(gpu->dispx_st)->dispx_BGxCNT[bgnum].bits; +// bool enabled = bgCnt->Mosaic_Enable; +// +//// if(!opaque) color = 0xFFFF; +//// else color &= 0x7FFF; +// if(!opaque) +// return; +// +// //mosaic test hacks +// enabled = true; +// +// //due to this early out, we will get incorrect behavior in cases where +// //we enable mosaic in the middle of a frame. this is deemed unlikely. +// if(enabled) +// { +// u8 y = gpu->currLine; +// +// //I intend to cache all this at the beginning of line rendering +// +// u16 mosaic_control = T1ReadWord((u8 *)&gpu->dispx_st->dispx_MISC.MOSAIC, 0); +// u8 mw = (mosaic_control & 0xF); +// u8 mh = ((mosaic_control>>4) & 0xF); +// +// //mosaic test hacks +// mw = 3; +// mh = 3; +// +// MosaicLookup::TableEntry &te_x = mosaicLookup.table[mw][x]; +// MosaicLookup::TableEntry &te_y = mosaicLookup.table[mh][y]; +// +// //int x_int; +// //if(enabled) +// int x_int = te_x.trunc; +// //else x_int = x; +// +// if(te_x.begin && te_y.begin) {} +// else color = gpu->MosaicColors.bg[bgnum][x_int]; +// gpu->MosaicColors.bg[bgnum][x] = color; +// } +// +//// if(color != 0xFFFF) +// gpu->setFinalColorBck(gpu,0,bgnum,dst,color,x); +//} diff --git a/desmume/src/GPU.h b/src/GPU.h similarity index 88% rename from desmume/src/GPU.h rename to src/GPU.h index 028695acb..06a3ff215 100644 --- a/desmume/src/GPU.h +++ b/src/GPU.h @@ -1,998 +1,995 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2006-2007 Theo Berkau - Copyright (C) 2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef GPU_H -#define GPU_H - -#include -#include "mem.h" -#include "common.h" -#include "registers.h" -#include "FIFO.h" -#include "MMU.h" -#include - -//#undef FORCEINLINE -//#define FORCEINLINE - -void gpu_savestate(std::ostream* os); -bool gpu_loadstate(std::istream* is, int size); - -/******************************************************************************* - this structure is for display control, - it holds flags for general display -*******************************************************************************/ - -#ifdef WORDS_BIGENDIAN -struct _DISPCNT -{ -/* 7*/ u8 ForceBlank:1; // A+B: -/* 6*/ u8 OBJ_BMP_mapping:1; // A+B: 0=2D (128KB), 1=1D (128..256KB) -/* 5*/ u8 OBJ_BMP_2D_dim:1; // A+B: 0=128x512, 1=256x256 pixels -/* 4*/ u8 OBJ_Tile_mapping:1;// A+B: 0=2D (32KB), 1=1D (32..256KB) -/* 3*/ u8 BG0_3D:1; // A : 0=2D, 1=3D -/* 0*/ u8 BG_Mode:3; // A+B: -/*15*/ u8 WinOBJ_Enable:1; // A+B: 0=disable, 1=Enable -/*14*/ u8 Win1_Enable:1; // A+B: 0=disable, 1=Enable -/*13*/ u8 Win0_Enable:1; // A+B: 0=disable, 1=Enable -/*12*/ u8 OBJ_Enable:1; // A+B: 0=disable, 1=Enable -/*11*/ u8 BG3_Enable:1; // A+B: 0=disable, 1=Enable -/*10*/ u8 BG2_Enable:1; // A+B: 0=disable, 1=Enable -/* 9*/ u8 BG1_Enable:1; // A+B: 0=disable, 1=Enable -/* 8*/ u8 BG0_Enable:1; // A+B: 0=disable, 1=Enable -/*23*/ u8 OBJ_HBlank_process:1; // A+B: OBJ processed during HBlank (GBA bit5) -/*22*/ u8 OBJ_BMP_1D_Bound:1; // A : -/*20*/ u8 OBJ_Tile_1D_Bound:2; // A+B: -/*18*/ u8 VRAM_Block:2; // A : VRAM block (0..3=A..D) - -/*16*/ u8 DisplayMode:2; // A+B: coreA(0..3) coreB(0..1) GBA(Green Swap) - // 0=off (white screen) - // 1=on (normal BG & OBJ layers) - // 2=VRAM display (coreA only) - // 3=RAM display (coreA only, DMA transfers) - -/*31*/ u8 ExOBJPalette_Enable:1; // A+B: 0=disable, 1=Enable OBJ extended Palette -/*30*/ u8 ExBGxPalette_Enable:1; // A+B: 0=disable, 1=Enable BG extended Palette -/*27*/ u8 ScreenBase_Block:3; // A : Screen Base (64K step) -/*24*/ u8 CharacBase_Block:3; // A : Character Base (64K step) -}; -#else -struct _DISPCNT -{ -/* 0*/ u8 BG_Mode:3; // A+B: -/* 3*/ u8 BG0_3D:1; // A : 0=2D, 1=3D -/* 4*/ u8 OBJ_Tile_mapping:1; // A+B: 0=2D (32KB), 1=1D (32..256KB) -/* 5*/ u8 OBJ_BMP_2D_dim:1; // A+B: 0=128x512, 1=256x256 pixels -/* 6*/ u8 OBJ_BMP_mapping:1; // A+B: 0=2D (128KB), 1=1D (128..256KB) - - // 7-15 same as GBA -/* 7*/ u8 ForceBlank:1; // A+B: -/* 8*/ u8 BG0_Enable:1; // A+B: 0=disable, 1=Enable -/* 9*/ u8 BG1_Enable:1; // A+B: 0=disable, 1=Enable -/*10*/ u8 BG2_Enable:1; // A+B: 0=disable, 1=Enable -/*11*/ u8 BG3_Enable:1; // A+B: 0=disable, 1=Enable -/*12*/ u8 OBJ_Enable:1; // A+B: 0=disable, 1=Enable -/*13*/ u8 Win0_Enable:1; // A+B: 0=disable, 1=Enable -/*14*/ u8 Win1_Enable:1; // A+B: 0=disable, 1=Enable -/*15*/ u8 WinOBJ_Enable:1; // A+B: 0=disable, 1=Enable - -/*16*/ u8 DisplayMode:2; // A+B: coreA(0..3) coreB(0..1) GBA(Green Swap) - // 0=off (white screen) - // 1=on (normal BG & OBJ layers) - // 2=VRAM display (coreA only) - // 3=RAM display (coreA only, DMA transfers) - -/*18*/ u8 VRAM_Block:2; // A : VRAM block (0..3=A..D) -/*20*/ u8 OBJ_Tile_1D_Bound:2; // A+B: -/*22*/ u8 OBJ_BMP_1D_Bound:1; // A : -/*23*/ u8 OBJ_HBlank_process:1; // A+B: OBJ processed during HBlank (GBA bit5) -/*24*/ u8 CharacBase_Block:3; // A : Character Base (64K step) -/*27*/ u8 ScreenBase_Block:3; // A : Screen Base (64K step) -/*30*/ u8 ExBGxPalette_Enable:1; // A+B: 0=disable, 1=Enable BG extended Palette -/*31*/ u8 ExOBJPalette_Enable:1; // A+B: 0=disable, 1=Enable OBJ extended Palette -}; -#endif - -typedef union -{ - struct _DISPCNT bits; - u32 val; -} DISPCNT; -#define BGxENABLED(cnt,num) ((num<8)? ((cnt.val>>8) & num):0) - - -enum BlendFunc -{ - None, Blend, Increase, Decrease -}; - - -/******************************************************************************* - this structure is for display control of a specific layer, - there are 4 background layers - their priority indicate which one to draw on top of the other - some flags indicate special drawing mode, size, FX -*******************************************************************************/ - -#ifdef WORDS_BIGENDIAN -struct _BGxCNT -{ -/* 7*/ u8 Palette_256:1; // 0=16x16, 1=1*256 palette -/* 6*/ u8 Mosaic_Enable:1; // 0=disable, 1=Enable mosaic -/* 2*/ u8 CharacBase_Block:4; // individual character base offset (n*16KB) -/* 0*/ u8 Priority:2; // 0..3=high..low -/*14*/ u8 ScreenSize:2; // text : 256x256 512x256 256x512 512x512 - // x/rot/s : 128x128 256x256 512x512 1024x1024 - // bmp : 128x128 256x256 512x256 512x512 - // large : 512x1024 1024x512 - - -/*13*/ u8 PaletteSet_Wrap:1; // BG0 extended palette set 0=set0, 1=set2 - // BG1 extended palette set 0=set1, 1=set3 - // BG2 overflow area wraparound 0=off, 1=wrap - // BG3 overflow area wraparound 0=off, 1=wrap -/* 8*/ u8 ScreenBase_Block:5; // individual screen base offset (text n*2KB, BMP n*16KB) -}; -#else -struct _BGxCNT -{ -/* 0*/ u8 Priority:2; // 0..3=high..low -/* 2*/ u8 CharacBase_Block:4; // individual character base offset (n*16KB) -/* 6*/ u8 Mosaic_Enable:1; // 0=disable, 1=Enable mosaic -/* 7*/ u8 Palette_256:1; // 0=16x16, 1=1*256 palette -/* 8*/ u8 ScreenBase_Block:5; // individual screen base offset (text n*2KB, BMP n*16KB) -/*13*/ u8 PaletteSet_Wrap:1; // BG0 extended palette set 0=set0, 1=set2 - // BG1 extended palette set 0=set1, 1=set3 - // BG2 overflow area wraparound 0=off, 1=wrap - // BG3 overflow area wraparound 0=off, 1=wrap -/*14*/ u8 ScreenSize:2; // text : 256x256 512x256 256x512 512x512 - // x/rot/s : 128x128 256x256 512x512 1024x1024 - // bmp : 128x128 256x256 512x256 512x512 - // large : 512x1024 1024x512 - - -}; -#endif - - -typedef union -{ - struct _BGxCNT bits; - u16 val; -} BGxCNT; - -/******************************************************************************* - this structure is for background offset -*******************************************************************************/ - -typedef struct { - u16 BGxHOFS; - u16 BGxVOFS; -} BGxOFS; - -/******************************************************************************* - this structure is for rotoscale parameters -*******************************************************************************/ - -typedef struct { - s16 BGxPA; - s16 BGxPB; - s16 BGxPC; - s16 BGxPD; - s32 BGxX; - s32 BGxY; -} BGxPARMS; - - -/******************************************************************************* - these structures are for window description, - windows are square regions and can "subclass" - background layers or object layers (i.e window controls the layers) - - screen - | - +-- Window0/Window1/OBJwindow/OutOfWindows - | - +-- BG0/BG1/BG2/BG3/OBJ -*******************************************************************************/ - -typedef union { - struct { - u8 end:8; - u8 start:8; - } bits ; - u16 val; -} WINxDIM; - -#ifdef WORDS_BIGENDIAN -typedef struct { -/* 6*/ u8 :2; -/* 5*/ u8 WINx_Effect_Enable:1; -/* 4*/ u8 WINx_OBJ_Enable:1; -/* 3*/ u8 WINx_BG3_Enable:1; -/* 2*/ u8 WINx_BG2_Enable:1; -/* 1*/ u8 WINx_BG1_Enable:1; -/* 0*/ u8 WINx_BG0_Enable:1; -} WINxBIT; -#else -typedef struct { -/* 0*/ u8 WINx_BG0_Enable:1; -/* 1*/ u8 WINx_BG1_Enable:1; -/* 2*/ u8 WINx_BG2_Enable:1; -/* 3*/ u8 WINx_BG3_Enable:1; -/* 4*/ u8 WINx_OBJ_Enable:1; -/* 5*/ u8 WINx_Effect_Enable:1; -/* 6*/ u8 :2; -} WINxBIT; -#endif - -#ifdef WORDS_BIGENDIAN -typedef union { - struct { - WINxBIT win0; - WINxBIT win1; - } bits; - struct { - u8 :3; - u8 win0_en:5; - u8 :3; - u8 win1_en:5; - } packed_bits; - struct { - u8 low; - u8 high; - } bytes; - u16 val ; -} WINxCNT ; -#else -typedef union { - struct { - WINxBIT win0; - WINxBIT win1; - } bits; - struct { - u8 win0_en:5; - u8 :3; - u8 win1_en:5; - u8 :3; - } packed_bits; - struct { - u8 low; - u8 high; - } bytes; - u16 val ; -} WINxCNT ; -#endif - -/* -typedef struct { - WINxDIM WIN0H; - WINxDIM WIN1H; - WINxDIM WIN0V; - WINxDIM WIN1V; - WINxCNT WININ; - WINxCNT WINOUT; -} WINCNT; -*/ - -/******************************************************************************* - this structure is for miscellanous settings - //TODO: needs further description -*******************************************************************************/ - -typedef struct { - u16 MOSAIC; - u16 unused1; - u16 unused2;//BLDCNT; - u16 unused3;//BLDALPHA; - u16 unused4;//BLDY; - u16 unused5; - /* - u16 unused6; - u16 unused7; - u16 unused8; - u16 unused9; - */ -} MISCCNT; - - -/******************************************************************************* - this structure is for 3D settings -*******************************************************************************/ - -struct _DISP3DCNT -{ -/* 0*/ u8 EnableTexMapping:1; // -/* 1*/ u8 PolygonShading:1; // 0=Toon Shading, 1=Highlight Shading -/* 2*/ u8 EnableAlphaTest:1; // see ALPHA_TEST_REF -/* 3*/ u8 EnableAlphaBlending:1; // see various Alpha values -/* 4*/ u8 EnableAntiAliasing:1; // -/* 5*/ u8 EnableEdgeMarking:1; // see EDGE_COLOR -/* 6*/ u8 FogOnlyAlpha:1; // 0=Alpha and Color, 1=Only Alpha (see FOG_COLOR) -/* 7*/ u8 EnableFog:1; // Fog Master Enable -/* 8*/ u8 FogShiftSHR:4; // 0..10 SHR-Divider (see FOG_OFFSET) -/*12*/ u8 AckColorBufferUnderflow:1; // Color Buffer RDLINES Underflow (0=None, 1=Underflow/Acknowledge) -/*13*/ u8 AckVertexRAMOverflow:1; // Polygon/Vertex RAM Overflow (0=None, 1=Overflow/Acknowledge) -/*14*/ u8 RearPlaneMode:1; // 0=Blank, 1=Bitmap -/*15*/ u8 :1; -/*16*/ u16 :16; -}; - -typedef union -{ - struct _DISP3DCNT bits; - u32 val; -} DISP3DCNT; - -/******************************************************************************* - this structure is for capture control (core A only) - - source: - http://nocash.emubase.de/gbatek.htm#dsvideocaptureandmainmemorydisplaymode -*******************************************************************************/ -struct DISPCAPCNT -{ - enum CAPX { - _128, _256 - } capx; - u32 val; - BOOL enabled; - u8 EVA; - u8 EVB; - u8 writeBlock; - u8 writeOffset; - u16 capy; - u8 srcA; - u8 srcB; - u8 readBlock; - u8 readOffset; - u8 capSrc; -} ; - -/******************************************************************************* - this structure holds everything and should be mapped to - * core A : 0x04000000 - * core B : 0x04001000 -*******************************************************************************/ - -typedef struct _reg_dispx { - DISPCNT dispx_DISPCNT; // 0x0400x000 - u16 dispA_DISPSTAT; // 0x04000004 - u16 dispx_VCOUNT; // 0x0400x006 - BGxCNT dispx_BGxCNT[4]; // 0x0400x008 - BGxOFS dispx_BGxOFS[4]; // 0x0400x010 - BGxPARMS dispx_BG2PARMS; // 0x0400x020 - BGxPARMS dispx_BG3PARMS; // 0x0400x030 - u8 filler[12]; // 0x0400x040 - MISCCNT dispx_MISC; // 0x0400x04C - DISP3DCNT dispA_DISP3DCNT; // 0x04000060 - DISPCAPCNT dispA_DISPCAPCNT; // 0x04000064 - u32 dispA_DISPMMEMFIFO; // 0x04000068 -} REG_DISPx ; - - -typedef BOOL (*fun_gl_Begin) (int screen); -typedef void (*fun_gl_End) (int screen); -// the GUI should use this function prior to all gl calls -// if call to beg succeeds opengl draw -void register_gl_fun(fun_gl_Begin beg,fun_gl_End end); - -#define GPU_MAIN 0 -#define GPU_SUB 1 - -/* human readable bitmask names */ -#define ADDRESS_STEP_512B 0x00200 -#define ADDRESS_STEP_1KB 0x00400 -#define ADDRESS_STEP_2KB 0x00800 -#define ADDRESS_STEP_4KB 0x01000 -#define ADDRESS_STEP_8KB 0x02000 -#define ADDRESS_STEP_16KB 0x04000 -#define ADDRESS_STEP_32KB 0x08000 -#define ADDRESS_STEP_64KB 0x10000 -#define ADDRESS_STEP_128KB 0x20000 -#define ADDRESS_STEP_256KB 0x40000 -#define ADDRESS_STEP_512KB 0x80000 -#define ADDRESS_MASK_256KB (ADDRESS_STEP_256KB-1) - -#ifdef WORDS_BIGENDIAN -struct _TILEENTRY -{ -/*14*/ unsigned Palette:4; -/*13*/ unsigned VFlip:1; // VERTICAL FLIP (top<-->bottom) -/*12*/ unsigned HFlip:1; // HORIZONTAL FLIP (left<-->right) -/* 0*/ unsigned TileNum:10; -}; -#else -struct _TILEENTRY -{ -/* 0*/ unsigned TileNum:10; -/*12*/ unsigned HFlip:1; // HORIZONTAL FLIP (left<-->right) -/*13*/ unsigned VFlip:1; // VERTICAL FLIP (top<-->bottom) -/*14*/ unsigned Palette:4; -}; -#endif -typedef union -{ - struct _TILEENTRY bits; - u16 val; -} TILEENTRY; - -struct _ROTOCOORD -{ - u32 Fraction:8; - s32 Integer:20; - u32 pad:4; -}; -typedef union -{ - struct _ROTOCOORD bits; - s32 val; -} ROTOCOORD; - - -/* - this structure is for color representation, - it holds 5 meaningful bits per color channel (red,green,blue) - and 1 meaningful bit for alpha representation - this bit can be unused or used for special FX -*/ - -struct _COLOR { // abgr x555 -#ifdef WORDS_BIGENDIAN - unsigned alpha:1; // sometimes it is unused (pad) - unsigned blue:5; - unsigned green:5; - unsigned red:5; -#else - unsigned red:5; - unsigned green:5; - unsigned blue:5; - unsigned alpha:1; // sometimes it is unused (pad) -#endif -}; -struct _COLORx { // abgr x555 - unsigned bgr:15; - unsigned alpha:1; // sometimes it is unused (pad) -}; - -typedef union -{ - struct _COLOR bits; - struct _COLORx bitx; - u16 val; -} COLOR; - -struct _COLOR32 { // ARGB - unsigned :3; - unsigned blue:5; - unsigned :3; - unsigned green:5; - unsigned :3; - unsigned red:5; - unsigned :7; - unsigned alpha:1; // sometimes it is unused (pad) -}; - -typedef union -{ - struct _COLOR32 bits; - u32 val; -} COLOR32; - -#define COLOR_16_32(w,i) \ - /* doesnt matter who's 16bit who's 32bit */ \ - i.bits.red = w.bits.red; \ - i.bits.green = w.bits.green; \ - i.bits.blue = w.bits.blue; \ - i.bits.alpha = w.bits.alpha; - - - - // (00: Normal, 01: Transparent, 10: Object window, 11: Bitmap) -enum GPU_OBJ_MODE -{ - GPU_OBJ_MODE_Normal = 0, - GPU_OBJ_MODE_Transparent = 1, - GPU_OBJ_MODE_Window = 2, - GPU_OBJ_MODE_Bitmap = 3 -}; - -/* - this structure is for Sprite description, - it holds flags & transformations for 1 sprite - (max 128 OBJs / screen) -ref: http://www.bottledlight.com/ds/index.php/Video/Sprites -*/ - -struct _OAM_ -{ -#ifdef WORDS_BIGENDIAN -// attr0 -/* 0*/ unsigned Y:8; -/*14*/ unsigned Shape:2; // (00: Square, 01: Wide, 10: Tall, 11: Illegal) -/*13*/ unsigned Depth:1; // (0: 16, 1: 256) -/*12*/ unsigned Mosaic:1; // (1: Enabled) -/*10*/ unsigned Mode:2; // (00: Normal, 01: Transparent, 10: Object window, 11: Bitmap) -/* 8*/ unsigned RotScale:2; // (00: Normal, 01: Rot/scale, 10: Disabled, 11: Double-size rot/scale) -// attr1 -/* 0*/ signed X:9; -/*14*/ unsigned Size:2; -/*13*/ unsigned VFlip:1; -/*12*/ unsigned HFlip:1; -/* 9*/ unsigned RotScalIndex:3; // Rot/scale matrix index -// attr2 -/* 0*/ unsigned TileIndex:10; -/*12*/ unsigned PaletteIndex:4; -/*10*/ unsigned Priority:2; -// attr3 - unsigned attr3:16; -#else -// attr0 -/* 0*/ unsigned Y:8; -/* 8*/ unsigned RotScale:2; // (00: Normal, 01: Rot/scale, 10: Disabled, 11: Double-size rot/scale) -/*10*/ unsigned Mode:2; // (00: Normal, 01: Transparent, 10: Object window, 11: Bitmap) -/*12*/ unsigned Mosaic:1; // (1: Enabled) -/*13*/ unsigned Depth:1; // (0: 16, 1: 256) -/*14*/ unsigned Shape:2; // (00: Square, 01: Wide, 10: Tall, 11: Illegal) -// attr1 -/* 0*/ signed X:9; -/* 9*/ unsigned RotScalIndex:3; // Rot/scale matrix index -/*12*/ unsigned HFlip:1; -/*13*/ unsigned VFlip:1; -/*14*/ unsigned Size:2; -// attr2 -/* 0*/ unsigned TileIndex:10; -/*10*/ unsigned Priority:2; -/*12*/ unsigned PaletteIndex:4; -// attr3 - unsigned attr3:16; -#endif -}; - -typedef struct -{ -#ifdef WORDS_BIGENDIAN - u8 attr00; - u8 attr01; - u8 attr10; - u8 attr11; - u8 attr20; - u8 attr21; - u8 attr30; - u8 attr31; -#else - u16 attr0; - u16 attr1; - u16 attr2; - u16 attr3; -#endif -} OAM; - - -typedef struct -{ - s16 x; - s16 y; -} size; - - - - -/* - this structure holds information - for rendering. -*/ - -#define NB_PRIORITIES 4 -#define NB_BG 4 -typedef struct -{ - u8 PixelsX[256]; - u8 BGs[NB_BG], nbBGs; - u8 pad[1]; - u16 nbPixelsX; - //256+8: - u8 pad2[248]; - - //things were slower when i organized this struct this way. whatever. - //u8 PixelsX[256]; - //int BGs[NB_BG], nbBGs; - //int nbPixelsX; - ////<-- 256 + 24 - //u8 pad2[256-24]; -} itemsForPriority_t; -#define MMU_ABG 0x06000000 -#define MMU_BBG 0x06200000 -#define MMU_AOBJ 0x06400000 -#define MMU_BOBJ 0x06600000 -#define MMU_LCDC 0x06800000 - -extern CACHE_ALIGN u8 gpuBlendTable555[17][17][32][32]; - -enum BGType { - BGType_Invalid=0, BGType_Text=1, BGType_Affine=2, BGType_Large8bpp=3, - BGType_AffineExt=4, BGType_AffineExt_256x16=5, BGType_AffineExt_256x1=6, BGType_AffineExt_Direct=7 -}; - -extern const BGType GPU_mode2type[8][4]; - -struct GPU -{ - GPU() - : debug(false) - {} - - // some structs are becoming redundant - // some functions too (no need to recopy some vars as it is done by MMU) - REG_DISPx * dispx_st; - - //this indicates whether this gpu is handling debug tools - bool debug; - - _BGxCNT & bgcnt(int num) { return (dispx_st)->dispx_BGxCNT[num].bits; } - _DISPCNT & dispCnt() { return dispx_st->dispx_DISPCNT.bits; } - template void modeRender(int layer); - - DISPCAPCNT dispCapCnt; - BOOL LayersEnable[5]; - itemsForPriority_t itemsForPriority[NB_PRIORITIES]; - -#define BGBmpBB BG_bmp_ram -#define BGChBB BG_tile_ram - - u32 BG_bmp_large_ram[4]; - u32 BG_bmp_ram[4]; - u32 BG_tile_ram[4]; - u32 BG_map_ram[4]; - - u8 BGExtPalSlot[4]; - u32 BGSize[4][2]; - BGType BGTypes[4]; - - struct MosaicColor { - u16 bg[4][256]; - struct Obj { - u16 color; - u8 alpha, opaque; - } obj[256]; - } mosaicColors; - - u8 sprNum[256]; - u8 h_win[2][256]; - const u8 *curr_win[2]; - void update_winh(int WIN_NUM); - bool need_update_winh[2]; - - template void setup_windows(); - - u8 core; - - u8 dispMode; - u8 vramBlock; - u8 *VRAMaddr; - - //FIFO fifo; - - BOOL dispBG[4]; - BOOL dispOBJ; - - u8 bgPrio[5]; - - BOOL bg0HasHighestPrio; - - OAM * oam; - u32 sprMem; - u8 sprBoundary; - u8 sprBMPBoundary; - u8 sprBMPMode; - u32 sprEnable; - - u8 WIN0H0; - u8 WIN0H1; - u8 WIN0V0; - u8 WIN0V1; - - u8 WIN1H0; - u8 WIN1H1; - u8 WIN1V0; - u8 WIN1V1; - - u8 WININ0; - bool WININ0_SPECIAL; - u8 WININ1; - bool WININ1_SPECIAL; - - u8 WINOUT; - bool WINOUT_SPECIAL; - u8 WINOBJ; - bool WINOBJ_SPECIAL; - - u8 WIN0_ENABLED; - u8 WIN1_ENABLED; - u8 WINOBJ_ENABLED; - - u16 BLDCNT; - u8 BLDALPHA_EVA; - u8 BLDALPHA_EVB; - u8 BLDY_EVY; - u16 *currentFadeInColors, *currentFadeOutColors; - bool blend2[8]; - - u8 MasterBrightMode; - u32 MasterBrightFactor; - - CACHE_ALIGN u8 bgPixels[1024]; //yes indeed, this is oversized. map debug tools try to write to it - - u32 currLine; - u8 currBgNum; - bool blend1; - u8* currDst; - - u8* _3dColorLine; - - - static struct MosaicLookup { - - struct TableEntry { - u8 begin, trunc; - } table[16][256]; - - MosaicLookup() { - for(int m=0;m<16;m++) - for(int i=0;i<256;i++) { - int mosaic = m+1; - TableEntry &te = table[m][i]; - te.begin = (i%mosaic==0); - te.trunc = i/mosaic*mosaic; - } - } - - TableEntry *width, *height; - int widthValue, heightValue; - - } mosaicLookup; - bool curr_mosaic_enabled; - - u16 blend(u16 colA, u16 colB); - - template - FORCEINLINE FASTCALL bool _master_setFinalBGColor(u16 &color, const u32 x); - - template - FORCEINLINE FASTCALL void _master_setFinal3dColor(int dstX, int srcX); - - int setFinalColorBck_funcNum; - int bgFunc; - int setFinalColor3d_funcNum; - int setFinalColorSpr_funcNum; - //Final3DColFunct setFinalColor3D; - enum SpriteRenderMode { - SPRITE_1D, SPRITE_2D - } spriteRenderMode; - - template - void _spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab); - - inline void spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab) - { - if(spriteRenderMode == SPRITE_1D) - _spriteRender(dst,dst_alpha,typeTab, prioTab); - else - _spriteRender(dst,dst_alpha,typeTab, prioTab); - } - - - void setFinalColor3d(int dstX, int srcX); - - template void setFinalColorBG(u16 color, const u32 x); - template FORCEINLINE void __setFinalColorBck(u16 color, const u32 x, const int opaque); - template FORCEINLINE void ___setFinalColorBck(u16 color, const u32 x, const int opaque); - - void setAffineStart(int layer, int xy, u32 val); - void setAffineStartWord(int layer, int xy, u16 val, int word); - u32 getAffineStart(int layer, int xy); - void refreshAffineStartRegs(const int num, const int xy); - - struct AffineInfo { - AffineInfo() : x(0), y(0) {} - u32 x, y; - } affineInfo[2]; - - void renderline_checkWindows(u16 x, bool &draw, bool &effect) const; - - // check whether (x,y) is within the rectangle (including wraparounds) - template - u8 withinRect(u16 x) const; - - void setBLDALPHA(u16 val) - { - BLDALPHA_EVA = (val&0x1f) > 16 ? 16 : (val&0x1f); - BLDALPHA_EVB = ((val>>8)&0x1f) > 16 ? 16 : ((val>>8)&0x1f); - updateBLDALPHA(); - } - - void setBLDALPHA_EVA(u8 val) - { - BLDALPHA_EVA = (val&0x1f) > 16 ? 16 : (val&0x1f); - updateBLDALPHA(); - } - - void setBLDALPHA_EVB(u8 val) - { - BLDALPHA_EVB = (val&0x1f) > 16 ? 16 : (val&0x1f); - updateBLDALPHA(); - } - - typedef u8 TBlendTable[32][32]; - TBlendTable *blendTable; - - void updateBLDALPHA() - { - blendTable = (TBlendTable*)&gpuBlendTable555[BLDALPHA_EVA][BLDALPHA_EVB][0][0]; - } - -}; -#if 0 -// normally should have same addresses -static void REG_DISPx_pack_test(GPU * gpu) -{ - REG_DISPx * r = gpu->dispx_st; - printf ("%08x %02x\n", (u32)r, (u32)(&r->dispx_DISPCNT) - (u32)r); - printf ("\t%02x\n", (u32)(&r->dispA_DISPSTAT) - (u32)r); - printf ("\t%02x\n", (u32)(&r->dispx_VCOUNT) - (u32)r); - printf ("\t%02x\n", (u32)(&r->dispx_BGxCNT[0]) - (u32)r); - printf ("\t%02x\n", (u32)(&r->dispx_BGxOFS[0]) - (u32)r); - printf ("\t%02x\n", (u32)(&r->dispx_BG2PARMS) - (u32)r); - printf ("\t%02x\n", (u32)(&r->dispx_BG3PARMS) - (u32)r); -// printf ("\t%02x\n", (u32)(&r->dispx_WINCNT) - (u32)r); - printf ("\t%02x\n", (u32)(&r->dispx_MISC) - (u32)r); - printf ("\t%02x\n", (u32)(&r->dispA_DISP3DCNT) - (u32)r); - printf ("\t%02x\n", (u32)(&r->dispA_DISPCAPCNT) - (u32)r); - printf ("\t%02x\n", (u32)(&r->dispA_DISPMMEMFIFO) - (u32)r); -} -#endif - -CACHE_ALIGN extern u8 GPU_screen[4*256*192]; - - -GPU * GPU_Init(u8 l); -void GPU_Reset(GPU *g, u8 l); -void GPU_DeInit(GPU *); - -//these are functions used by debug tools which want to render layers etc outside the context of the emulation -namespace GPU_EXT -{ - void textBG(GPU * gpu, u8 num, u8 * DST); //Draw text based background - void rotBG(GPU * gpu, u8 num, u8 * DST); - void extRotBG(GPU * gpu, u8 num, u8 * DST); -}; -void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab); -void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab); - -extern const size sprSizeTab[4][4]; - -typedef struct { - GPU * gpu; - u16 offset; -} NDS_Screen; - -extern NDS_Screen MainScreen; -extern NDS_Screen SubScreen; - -int Screen_Init(int coreid); -void Screen_Reset(void); -void Screen_DeInit(void); - -extern MMU_struct MMU; - - - -#define GFXCORE_DEFAULT -1 -#define GFXCORE_DUMMY 0 - -#define GFXCORE_FULLSCREEN (1 << 0) - -struct GraphicsInterface_struct -{ - int id; // ID number for core(see above defines) - const char *Name; // Name of core - int flags; // What features the core supports(full screen, etc.) - int (*Init)(); // Initializes stuff related to core - void (*DeInit)(); // Deinitializes stuff related to core - void (*Resize)(int width, int height, BOOL fullscreen); // Resizes window or fullscreen - void (*OnScreenText)(char *string, ...); // For handling save state messages, etc. -} ; - -extern GraphicsInterface_struct GFXDummy; - -void GPU_setVideoProp(GPU *, u32 p); -void GPU_setBGProp(GPU *, u16 num, u16 p); - -void GPU_setBLDCNT(GPU *gpu, u16 v) ; -void GPU_setBLDY(GPU *gpu, u16 v) ; -void GPU_setMOSAIC(GPU *gpu, u16 v) ; - - -void GPU_remove(GPU *, u8 num); -void GPU_addBack(GPU *, u8 num); - -int GPU_ChangeGraphicsCore(int coreid); - -void GPU_set_DISPCAPCNT(u32 val) ; -void GPU_ligne(NDS_Screen * screen, u16 l, bool skip = false) ; -void GPU_setMasterBrightness (GPU *gpu, u16 val); - -inline void GPU_setWIN0_H(GPU* gpu, u16 val) { gpu->WIN0H0 = val >> 8; gpu->WIN0H1 = val&0xFF; gpu->need_update_winh[0] = true; } -inline void GPU_setWIN0_H0(GPU* gpu, u8 val) { gpu->WIN0H0 = val; gpu->need_update_winh[0] = true; } -inline void GPU_setWIN0_H1(GPU* gpu, u8 val) { gpu->WIN0H1 = val; gpu->need_update_winh[0] = true; } - -inline void GPU_setWIN0_V(GPU* gpu, u16 val) { gpu->WIN0V0 = val >> 8; gpu->WIN0V1 = val&0xFF;} -inline void GPU_setWIN0_V0(GPU* gpu, u8 val) { gpu->WIN0V0 = val; } -inline void GPU_setWIN0_V1(GPU* gpu, u8 val) { gpu->WIN0V1 = val; } - -inline void GPU_setWIN1_H(GPU* gpu, u16 val) {gpu->WIN1H0 = val >> 8; gpu->WIN1H1 = val&0xFF; gpu->need_update_winh[1] = true; } -inline void GPU_setWIN1_H0(GPU* gpu, u8 val) { gpu->WIN1H0 = val; gpu->need_update_winh[1] = true; } -inline void GPU_setWIN1_H1(GPU* gpu, u8 val) { gpu->WIN1H1 = val; gpu->need_update_winh[1] = true; } - -inline void GPU_setWIN1_V(GPU* gpu, u16 val) { gpu->WIN1V0 = val >> 8; gpu->WIN1V1 = val&0xFF; } -inline void GPU_setWIN1_V0(GPU* gpu, u8 val) { gpu->WIN1V0 = val; } -inline void GPU_setWIN1_V1(GPU* gpu, u8 val) { gpu->WIN1V1 = val; } - -inline void GPU_setWININ(GPU* gpu, u16 val) { - gpu->WININ0=val&0x1F; - gpu->WININ0_SPECIAL=((val>>5)&1)!=0; - gpu->WININ1=(val>>8)&0x1F; - gpu->WININ1_SPECIAL=((val>>13)&1)!=0; -} - -inline void GPU_setWININ0(GPU* gpu, u8 val) { gpu->WININ0 = val&0x1F; gpu->WININ0_SPECIAL = (val>>5)&1; } -inline void GPU_setWININ1(GPU* gpu, u8 val) { gpu->WININ1 = val&0x1F; gpu->WININ1_SPECIAL = (val>>5)&1; } - -inline void GPU_setWINOUT16(GPU* gpu, u16 val) { - gpu->WINOUT=val&0x1F; - gpu->WINOUT_SPECIAL=((val>>5)&1)!=0; - gpu->WINOBJ=(val>>8)&0x1F; - gpu->WINOBJ_SPECIAL=((val>>13)&1)!=0; -} -inline void GPU_setWINOUT(GPU* gpu, u8 val) { gpu->WINOUT = val&0x1F; gpu->WINOUT_SPECIAL = (val>>5)&1; } -inline void GPU_setWINOBJ(GPU* gpu, u8 val) { gpu->WINOBJ = val&0x1F; gpu->WINOBJ_SPECIAL = (val>>5)&1; } - -// Blending -void SetupFinalPixelBlitter (GPU *gpu); -#define GPU_setBLDCNT_LOW(gpu, val) {gpu->BLDCNT = (gpu->BLDCNT&0xFF00) | (val); SetupFinalPixelBlitter (gpu);} -#define GPU_setBLDCNT_HIGH(gpu, val) {gpu->BLDCNT = (gpu->BLDCNT&0xFF) | (val<<8); SetupFinalPixelBlitter (gpu);} -#define GPU_setBLDCNT(gpu, val) {gpu->BLDCNT = (val); SetupFinalPixelBlitter (gpu);} - - - -#define GPU_setBLDY_EVY(gpu, val) {gpu->BLDY_EVY = (val&0x1f) > 16 ? 16 : (val&0x1f);} - -#define GPU_setBGxHOFS(bg, gpu, val) gpu->dispx_st->dispx_BGxOFS[bg].BGxHOFS = (val & 0x1F) -#define GPU_setBGxVOFS(bg, gpu, val) gpu->dispx_st->dispx_BGxOFS[bg].BGxVOFS = (val & 0x1F) - -// render -void gpu_UpdateRender(); -void gpu_SetRotateScreen(u16 angle); - -//#undef FORCEINLINE -//#define FORCEINLINE __forceinline - -#endif - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2006-2007 Theo Berkau + Copyright (C) 2007 shash + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef GPU_H +#define GPU_H + +#include "ARM9.h" +#include +#include "mem.h" +#include "common.h" +#include "registers.h" +#include "FIFO.h" +#include "MMU.h" +#include + +//#undef FORCEINLINE +//#define FORCEINLINE + +void gpu_savestate(std::ostream* os); +bool gpu_loadstate(std::istream* is, int size); + +/******************************************************************************* + this structure is for display control, + it holds flags for general display +*******************************************************************************/ + +#ifdef WORDS_BIGENDIAN +struct _DISPCNT +{ +/* 7*/ u8 ForceBlank:1; // A+B: +/* 6*/ u8 OBJ_BMP_mapping:1; // A+B: 0=2D (128KB), 1=1D (128..256KB) +/* 5*/ u8 OBJ_BMP_2D_dim:1; // A+B: 0=128x512, 1=256x256 pixels +/* 4*/ u8 OBJ_Tile_mapping:1;// A+B: 0=2D (32KB), 1=1D (32..256KB) +/* 3*/ u8 BG0_3D:1; // A : 0=2D, 1=3D +/* 0*/ u8 BG_Mode:3; // A+B: +/*15*/ u8 WinOBJ_Enable:1; // A+B: 0=disable, 1=Enable +/*14*/ u8 Win1_Enable:1; // A+B: 0=disable, 1=Enable +/*13*/ u8 Win0_Enable:1; // A+B: 0=disable, 1=Enable +/*12*/ u8 OBJ_Enable:1; // A+B: 0=disable, 1=Enable +/*11*/ u8 BG3_Enable:1; // A+B: 0=disable, 1=Enable +/*10*/ u8 BG2_Enable:1; // A+B: 0=disable, 1=Enable +/* 9*/ u8 BG1_Enable:1; // A+B: 0=disable, 1=Enable +/* 8*/ u8 BG0_Enable:1; // A+B: 0=disable, 1=Enable +/*23*/ u8 OBJ_HBlank_process:1; // A+B: OBJ processed during HBlank (GBA bit5) +/*22*/ u8 OBJ_BMP_1D_Bound:1; // A : +/*20*/ u8 OBJ_Tile_1D_Bound:2; // A+B: +/*18*/ u8 VRAM_Block:2; // A : VRAM block (0..3=A..D) + +/*16*/ u8 DisplayMode:2; // A+B: coreA(0..3) coreB(0..1) GBA(Green Swap) + // 0=off (white screen) + // 1=on (normal BG & OBJ layers) + // 2=VRAM display (coreA only) + // 3=RAM display (coreA only, DMA transfers) + +/*31*/ u8 ExOBJPalette_Enable:1; // A+B: 0=disable, 1=Enable OBJ extended Palette +/*30*/ u8 ExBGxPalette_Enable:1; // A+B: 0=disable, 1=Enable BG extended Palette +/*27*/ u8 ScreenBase_Block:3; // A : Screen Base (64K step) +/*24*/ u8 CharacBase_Block:3; // A : Character Base (64K step) +}; +#else +struct _DISPCNT +{ +/* 0*/ u8 BG_Mode:3; // A+B: +/* 3*/ u8 BG0_3D:1; // A : 0=2D, 1=3D +/* 4*/ u8 OBJ_Tile_mapping:1; // A+B: 0=2D (32KB), 1=1D (32..256KB) +/* 5*/ u8 OBJ_BMP_2D_dim:1; // A+B: 0=128x512, 1=256x256 pixels +/* 6*/ u8 OBJ_BMP_mapping:1; // A+B: 0=2D (128KB), 1=1D (128..256KB) + + // 7-15 same as GBA +/* 7*/ u8 ForceBlank:1; // A+B: +/* 8*/ u8 BG0_Enable:1; // A+B: 0=disable, 1=Enable +/* 9*/ u8 BG1_Enable:1; // A+B: 0=disable, 1=Enable +/*10*/ u8 BG2_Enable:1; // A+B: 0=disable, 1=Enable +/*11*/ u8 BG3_Enable:1; // A+B: 0=disable, 1=Enable +/*12*/ u8 OBJ_Enable:1; // A+B: 0=disable, 1=Enable +/*13*/ u8 Win0_Enable:1; // A+B: 0=disable, 1=Enable +/*14*/ u8 Win1_Enable:1; // A+B: 0=disable, 1=Enable +/*15*/ u8 WinOBJ_Enable:1; // A+B: 0=disable, 1=Enable + +/*16*/ u8 DisplayMode:2; // A+B: coreA(0..3) coreB(0..1) GBA(Green Swap) + // 0=off (white screen) + // 1=on (normal BG & OBJ layers) + // 2=VRAM display (coreA only) + // 3=RAM display (coreA only, DMA transfers) + +/*18*/ u8 VRAM_Block:2; // A : VRAM block (0..3=A..D) +/*20*/ u8 OBJ_Tile_1D_Bound:2; // A+B: +/*22*/ u8 OBJ_BMP_1D_Bound:1; // A : +/*23*/ u8 OBJ_HBlank_process:1; // A+B: OBJ processed during HBlank (GBA bit5) +/*24*/ u8 CharacBase_Block:3; // A : Character Base (64K step) +/*27*/ u8 ScreenBase_Block:3; // A : Screen Base (64K step) +/*30*/ u8 ExBGxPalette_Enable:1; // A+B: 0=disable, 1=Enable BG extended Palette +/*31*/ u8 ExOBJPalette_Enable:1; // A+B: 0=disable, 1=Enable OBJ extended Palette +}; +#endif + +typedef union +{ + struct _DISPCNT bits; + u32 val; +} DISPCNT; +#define BGxENABLED(cnt,num) ((num<8)? ((cnt.val>>8) & num):0) + + + + +/******************************************************************************* + this structure is for display control of a specific layer, + there are 4 background layers + their priority indicate which one to draw on top of the other + some flags indicate special drawing mode, size, FX +*******************************************************************************/ + +#ifdef WORDS_BIGENDIAN +struct _BGxCNT +{ +/* 7*/ u8 Palette_256:1; // 0=16x16, 1=1*256 palette +/* 6*/ u8 Mosaic_Enable:1; // 0=disable, 1=Enable mosaic +/* 2*/ u8 CharacBase_Block:4; // individual character base offset (n*16KB) +/* 0*/ u8 Priority:2; // 0..3=high..low +/*14*/ u8 ScreenSize:2; // text : 256x256 512x256 256x512 512x512 + // x/rot/s : 128x128 256x256 512x512 1024x1024 + // bmp : 128x128 256x256 512x256 512x512 + // large : 512x1024 1024x512 - - +/*13*/ u8 PaletteSet_Wrap:1; // BG0 extended palette set 0=set0, 1=set2 + // BG1 extended palette set 0=set1, 1=set3 + // BG2 overflow area wraparound 0=off, 1=wrap + // BG3 overflow area wraparound 0=off, 1=wrap +/* 8*/ u8 ScreenBase_Block:5; // individual screen base offset (text n*2KB, BMP n*16KB) +}; +#else +struct _BGxCNT +{ +/* 0*/ u8 Priority:2; // 0..3=high..low +/* 2*/ u8 CharacBase_Block:4; // individual character base offset (n*16KB) +/* 6*/ u8 Mosaic_Enable:1; // 0=disable, 1=Enable mosaic +/* 7*/ u8 Palette_256:1; // 0=16x16, 1=1*256 palette +/* 8*/ u8 ScreenBase_Block:5; // individual screen base offset (text n*2KB, BMP n*16KB) +/*13*/ u8 PaletteSet_Wrap:1; // BG0 extended palette set 0=set0, 1=set2 + // BG1 extended palette set 0=set1, 1=set3 + // BG2 overflow area wraparound 0=off, 1=wrap + // BG3 overflow area wraparound 0=off, 1=wrap +/*14*/ u8 ScreenSize:2; // text : 256x256 512x256 256x512 512x512 + // x/rot/s : 128x128 256x256 512x512 1024x1024 + // bmp : 128x128 256x256 512x256 512x512 + // large : 512x1024 1024x512 - - +}; +#endif + + +typedef union +{ + struct _BGxCNT bits; + u16 val; +} BGxCNT; + +/******************************************************************************* + this structure is for background offset +*******************************************************************************/ + +typedef struct { + u16 BGxHOFS; + u16 BGxVOFS; +} BGxOFS; + +/******************************************************************************* + this structure is for rotoscale parameters +*******************************************************************************/ + +typedef struct { + s16 BGxPA; + s16 BGxPB; + s16 BGxPC; + s16 BGxPD; + s32 BGxX; + s32 BGxY; +} BGxPARMS; + + +/******************************************************************************* + these structures are for window description, + windows are square regions and can "subclass" + background layers or object layers (i.e window controls the layers) + + screen + | + +-- Window0/Window1/OBJwindow/OutOfWindows + | + +-- BG0/BG1/BG2/BG3/OBJ +*******************************************************************************/ + +typedef union { + struct { + u8 end:8; + u8 start:8; + } bits ; + u16 val; +} WINxDIM; + +#ifdef WORDS_BIGENDIAN +typedef struct { +/* 6*/ u8 :2; +/* 5*/ u8 WINx_Effect_Enable:1; +/* 4*/ u8 WINx_OBJ_Enable:1; +/* 3*/ u8 WINx_BG3_Enable:1; +/* 2*/ u8 WINx_BG2_Enable:1; +/* 1*/ u8 WINx_BG1_Enable:1; +/* 0*/ u8 WINx_BG0_Enable:1; +} WINxBIT; +#else +typedef struct { +/* 0*/ u8 WINx_BG0_Enable:1; +/* 1*/ u8 WINx_BG1_Enable:1; +/* 2*/ u8 WINx_BG2_Enable:1; +/* 3*/ u8 WINx_BG3_Enable:1; +/* 4*/ u8 WINx_OBJ_Enable:1; +/* 5*/ u8 WINx_Effect_Enable:1; +/* 6*/ u8 :2; +} WINxBIT; +#endif + +#ifdef WORDS_BIGENDIAN +typedef union { + struct { + WINxBIT win0; + WINxBIT win1; + } bits; + struct { + u8 :3; + u8 win0_en:5; + u8 :3; + u8 win1_en:5; + } packed_bits; + struct { + u8 low; + u8 high; + } bytes; + u16 val ; +} WINxCNT ; +#else +typedef union { + struct { + WINxBIT win0; + WINxBIT win1; + } bits; + struct { + u8 win0_en:5; + u8 :3; + u8 win1_en:5; + u8 :3; + } packed_bits; + struct { + u8 low; + u8 high; + } bytes; + u16 val ; +} WINxCNT ; +#endif + +/* +typedef struct { + WINxDIM WIN0H; + WINxDIM WIN1H; + WINxDIM WIN0V; + WINxDIM WIN1V; + WINxCNT WININ; + WINxCNT WINOUT; +} WINCNT; +*/ + +/******************************************************************************* + this structure is for miscellanous settings + //TODO: needs further description +*******************************************************************************/ + +typedef struct { + u16 MOSAIC; + u16 unused1; + u16 unused2;//BLDCNT; + u16 unused3;//BLDALPHA; + u16 unused4;//BLDY; + u16 unused5; + /* + u16 unused6; + u16 unused7; + u16 unused8; + u16 unused9; + */ +} MISCCNT; + + +/******************************************************************************* + this structure is for 3D settings +*******************************************************************************/ + +struct _DISP3DCNT +{ +/* 0*/ u8 EnableTexMapping:1; // +/* 1*/ u8 PolygonShading:1; // 0=Toon Shading, 1=Highlight Shading +/* 2*/ u8 EnableAlphaTest:1; // see ALPHA_TEST_REF +/* 3*/ u8 EnableAlphaBlending:1; // see various Alpha values +/* 4*/ u8 EnableAntiAliasing:1; // +/* 5*/ u8 EnableEdgeMarking:1; // see EDGE_COLOR +/* 6*/ u8 FogOnlyAlpha:1; // 0=Alpha and Color, 1=Only Alpha (see FOG_COLOR) +/* 7*/ u8 EnableFog:1; // Fog Master Enable +/* 8*/ u8 FogShiftSHR:4; // 0..10 SHR-Divider (see FOG_OFFSET) +/*12*/ u8 AckColorBufferUnderflow:1; // Color Buffer RDLINES Underflow (0=None, 1=Underflow/Acknowledge) +/*13*/ u8 AckVertexRAMOverflow:1; // Polygon/Vertex RAM Overflow (0=None, 1=Overflow/Acknowledge) +/*14*/ u8 RearPlaneMode:1; // 0=Blank, 1=Bitmap +/*15*/ u8 :1; +/*16*/ u16 :16; +}; + +typedef union +{ + struct _DISP3DCNT bits; + u32 val; +} DISP3DCNT; + +/******************************************************************************* + this structure is for capture control (core A only) + + source: + http://nocash.emubase.de/gbatek.htm#dsvideocaptureandmainmemorydisplaymode +*******************************************************************************/ +struct DISPCAPCNT +{ + enum CAPX { + _128, _256 + } capx; + u32 val; + BOOL enabled; + u8 EVA; + u8 EVB; + u8 writeBlock; + u8 writeOffset; + u16 capy; + u8 srcA; + u8 srcB; + u8 readBlock; + u8 readOffset; + u8 capSrc; + u8 *dst; + u8 *src; +} ; + +/******************************************************************************* + this structure holds everything and should be mapped to + * core A : 0x04000000 + * core B : 0x04001000 +*******************************************************************************/ + +typedef struct _reg_dispx { + DISPCNT dispx_DISPCNT; // 0x0400x000 + u16 dispA_DISPSTAT; // 0x04000004 + u16 dispx_VCOUNT; // 0x0400x006 + BGxCNT dispx_BGxCNT[4]; // 0x0400x008 + BGxOFS dispx_BGxOFS[4]; // 0x0400x010 + BGxPARMS dispx_BG2PARMS; // 0x0400x020 + BGxPARMS dispx_BG3PARMS; // 0x0400x030 + u8 filler[12]; // 0x0400x040 + MISCCNT dispx_MISC; // 0x0400x04C + DISP3DCNT dispA_DISP3DCNT; // 0x04000060 + DISPCAPCNT dispA_DISPCAPCNT; // 0x04000064 + u32 dispA_DISPMMEMFIFO; // 0x04000068 +} REG_DISPx ; + + +typedef BOOL (*fun_gl_Begin) (int screen); +typedef void (*fun_gl_End) (int screen); +// the GUI should use this function prior to all gl calls +// if call to beg succeeds opengl draw +void register_gl_fun(fun_gl_Begin beg,fun_gl_End end); + +#define GPU_MAIN 0 +#define GPU_SUB 1 + +/* human readable bitmask names */ +#define ADDRESS_STEP_512B 0x00200 +#define ADDRESS_STEP_1KB 0x00400 +#define ADDRESS_STEP_2KB 0x00800 +#define ADDRESS_STEP_4KB 0x01000 +#define ADDRESS_STEP_8KB 0x02000 +#define ADDRESS_STEP_16KB 0x04000 +#define ADDRESS_STEP_32KB 0x08000 +#define ADDRESS_STEP_64KB 0x10000 +#define ADDRESS_STEP_128KB 0x20000 +#define ADDRESS_STEP_256KB 0x40000 +#define ADDRESS_STEP_512KB 0x80000 +#define ADDRESS_MASK_256KB (ADDRESS_STEP_256KB-1) + +#ifdef WORDS_BIGENDIAN +struct _TILEENTRY +{ +/*14*/ unsigned Palette:4; +/*13*/ unsigned VFlip:1; // VERTICAL FLIP (top<-->bottom) +/*12*/ unsigned HFlip:1; // HORIZONTAL FLIP (left<-->right) +/* 0*/ unsigned TileNum:10; +}; +#else +struct _TILEENTRY +{ +/* 0*/ unsigned TileNum:10; +/*12*/ unsigned HFlip:1; // HORIZONTAL FLIP (left<-->right) +/*13*/ unsigned VFlip:1; // VERTICAL FLIP (top<-->bottom) +/*14*/ unsigned Palette:4; +}; +#endif +typedef union +{ + struct _TILEENTRY bits; + u16 val; +} TILEENTRY; + +struct _ROTOCOORD +{ + u32 Fraction:8; + s32 Integer:20; + u32 pad:4; +}; +typedef union +{ + struct _ROTOCOORD bits; + s32 val; +} ROTOCOORD; + + +/* + this structure is for color representation, + it holds 5 meaningful bits per color channel (red,green,blue) + and 1 meaningful bit for alpha representation + this bit can be unused or used for special FX +*/ + +struct _COLOR { // abgr x555 +#ifdef WORDS_BIGENDIAN + unsigned alpha:1; // sometimes it is unused (pad) + unsigned blue:5; + unsigned green:5; + unsigned red:5; +#else + unsigned red:5; + unsigned green:5; + unsigned blue:5; + unsigned alpha:1; // sometimes it is unused (pad) +#endif +}; +struct _COLORx { // abgr x555 + unsigned bgr:15; + unsigned alpha:1; // sometimes it is unused (pad) +}; + +typedef union +{ + struct _COLOR bits; + struct _COLORx bitx; + u16 val; +} COLOR; + +struct _COLOR32 { // ARGB + unsigned :3; + unsigned blue:5; + unsigned :3; + unsigned green:5; + unsigned :3; + unsigned red:5; + unsigned :7; + unsigned alpha:1; // sometimes it is unused (pad) +}; + +typedef union +{ + struct _COLOR32 bits; + u32 val; +} COLOR32; + +#define COLOR_16_32(w,i) \ + /* doesnt matter who's 16bit who's 32bit */ \ + i.bits.red = w.bits.red; \ + i.bits.green = w.bits.green; \ + i.bits.blue = w.bits.blue; \ + i.bits.alpha = w.bits.alpha; + + + + // (00: Normal, 01: Transparent, 10: Object window, 11: Bitmap) +enum GPU_OBJ_MODE +{ + GPU_OBJ_MODE_Normal = 0, + GPU_OBJ_MODE_Transparent = 1, + GPU_OBJ_MODE_Window = 2, + GPU_OBJ_MODE_Bitmap = 3 +}; + +/* + this structure is for Sprite description, + it holds flags & transformations for 1 sprite + (max 128 OBJs / screen) +ref: http://www.bottledlight.com/ds/index.php/Video/Sprites +*/ + +struct _OAM_ +{ +#ifdef WORDS_BIGENDIAN +// attr0 +/* 0*/ unsigned Y:8; +/*14*/ unsigned Shape:2; // (00: Square, 01: Wide, 10: Tall, 11: Illegal) +/*13*/ unsigned Depth:1; // (0: 16, 1: 256) +/*12*/ unsigned Mosaic:1; // (1: Enabled) +/*10*/ unsigned Mode:2; // (00: Normal, 01: Transparent, 10: Object window, 11: Bitmap) +/* 8*/ unsigned RotScale:2; // (00: Normal, 01: Rot/scale, 10: Disabled, 11: Double-size rot/scale) +// attr1 +/* 0*/ signed X:9; +/*14*/ unsigned Size:2; +/*13*/ unsigned VFlip:1; +/*12*/ unsigned HFlip:1; +/* 9*/ unsigned RotScalIndex:3; // Rot/scale matrix index +// attr2 +/* 0*/ unsigned TileIndex:10; +/*12*/ unsigned PaletteIndex:4; +/*10*/ unsigned Priority:2; +// attr3 + unsigned attr3:16; +#else +// attr0 +/* 0*/ unsigned Y:8; +/* 8*/ unsigned RotScale:2; // (00: Normal, 01: Rot/scale, 10: Disabled, 11: Double-size rot/scale) +/*10*/ unsigned Mode:2; // (00: Normal, 01: Transparent, 10: Object window, 11: Bitmap) +/*12*/ unsigned Mosaic:1; // (1: Enabled) +/*13*/ unsigned Depth:1; // (0: 16, 1: 256) +/*14*/ unsigned Shape:2; // (00: Square, 01: Wide, 10: Tall, 11: Illegal) +// attr1 +/* 0*/ signed X:9; +/* 9*/ unsigned RotScalIndex:3; // Rot/scale matrix index +/*12*/ unsigned HFlip:1; +/*13*/ unsigned VFlip:1; +/*14*/ unsigned Size:2; +// attr2 +/* 0*/ unsigned TileIndex:10; +/*10*/ unsigned Priority:2; +/*12*/ unsigned PaletteIndex:4; +// attr3 + unsigned attr3:16; +#endif +}; + +typedef struct +{ +#ifdef WORDS_BIGENDIAN + u8 attr00; + u8 attr01; + u8 attr10; + u8 attr11; + u8 attr20; + u8 attr21; + u8 attr30; + u8 attr31; +#else + u16 attr0; + u16 attr1; + u16 attr2; + u16 attr3; +#endif +} OAM; + + +typedef struct +{ + s16 x; + s16 y; +} size; + + + + +/* + this structure holds information + for rendering. +*/ + +#define NB_PRIORITIES 4 +#define NB_BG 4 +typedef struct +{ + u8 BGs[NB_BG], nbBGs; + u8 PixelsX[256]; + // doh ! yoda says : 256 pixels we can have... + u16 nbPixelsX; +} itemsForPriority_t; +#define ARM9MEM_ABG 0x06000000 +#define ARM9MEM_BBG 0x06200000 +#define ARM9MEM_AOBJ 0x06400000 +#define ARM9MEM_BOBJ 0x06600000 +#define ARM9MEM_LCDC 0x06800000 + +extern CACHE_ALIGN u8 gpuBlendTable555[17][17][32][32]; + +enum BGType { + BGType_Invalid=0, BGType_Text=1, BGType_Affine=2, BGType_Large8bpp=3, + BGType_AffineExt=4, BGType_AffineExt_256x16=5, BGType_AffineExt_256x1=6, BGType_AffineExt_Direct=7 +}; + +extern const BGType GPU_mode2type[8][4]; + +struct GPU +{ + GPU() + : debug(false) + {} + + // some structs are becoming redundant + // some functions too (no need to recopy some vars as it is done by MMU) + REG_DISPx * dispx_st; + + //this indicates whether this gpu is handling debug tools + bool debug; + + _BGxCNT & bgcnt(int num) { return (dispx_st)->dispx_BGxCNT[num].bits; } + _DISPCNT & dispCnt() { return dispx_st->dispx_DISPCNT.bits; } + template void modeRender(int layer); + + DISPCAPCNT dispCapCnt; + BOOL LayersEnable[5]; + itemsForPriority_t itemsForPriority[NB_PRIORITIES]; + +#define BGBmpBB BG_bmp_ram +#define BGChBB BG_tile_ram + + u32 BG_bmp_large_ram[4]; + u32 BG_bmp_ram[4]; + u32 BG_tile_ram[4]; + u32 BG_map_ram[4]; + + u8 BGExtPalSlot[4]; + u32 BGSize[4][2]; + BGType BGTypes[4]; + + struct MosaicColor { + u16 bg[4][256]; + struct Obj { + u16 color; + u8 alpha, opaque; + } obj[256]; + } mosaicColors; + + u8 sprNum[256]; + u8 h_win[2][256]; + const u8 *curr_win[2]; + void update_winh(int WIN_NUM); + bool need_update_winh[2]; + + template void setup_windows(); + + u8 core; + + u8 dispMode; + u8 vramBlock; + u8 *VRAMaddr; + + //FIFO fifo; + + BOOL dispBG[4]; + BOOL dispOBJ; + + u8 bgPrio[5]; + + BOOL bg0HasHighestPrio; + + OAM * oam; + u32 sprMem; + u8 sprBoundary; + u8 sprBMPBoundary; + u8 sprBMPMode; + u32 sprEnable; + + u8 WIN0H0; + u8 WIN0H1; + u8 WIN0V0; + u8 WIN0V1; + + u8 WIN1H0; + u8 WIN1H1; + u8 WIN1V0; + u8 WIN1V1; + + u8 WININ0; + u8 WININ0_SPECIAL; + u8 WININ1; + u8 WININ1_SPECIAL; + + u8 WINOUT; + u8 WINOUT_SPECIAL; + u8 WINOBJ; + u8 WINOBJ_SPECIAL; + + u8 WIN0_ENABLED; + u8 WIN1_ENABLED; + u8 WINOBJ_ENABLED; + + u16 BLDCNT; + u8 BLDALPHA_EVA; + u8 BLDALPHA_EVB; + u8 BLDY_EVY; + u16 *currentFadeInColors, *currentFadeOutColors; + bool blend2[8]; + + u8 MasterBrightMode; + u32 MasterBrightFactor; + + u8 bgPixels[256]; + + u8 currLine; + u8 currBgNum; + bool blend1; + u8* currDst; + + u16* _3dColorLine; + u8* _3dAlphaLine; + + + static struct MosaicLookup { + + struct TableEntry { + u8 begin, trunc; + } table[16][256]; + + MosaicLookup() { + for(int m=0;m<16;m++) + for(int i=0;i<256;i++) { + int mosaic = m+1; + TableEntry &te = table[m][i]; + te.begin = (i%mosaic==0); + te.trunc = i/mosaic*mosaic; + } + } + + TableEntry *width, *height; + int widthValue, heightValue; + + } mosaicLookup; + bool curr_mosaic_enabled; + + u16 blend(u16 colA, u16 colB); + + typedef void (*FinalOBJColFunct)(GPU *gpu, u32 passing, u8 *dst, u16 color, u8 alpha, u8 type, u16 x); + typedef void (*Final3DColFunct)(GPU *gpu, int dstX, int srcX); + + int setFinalColorBck_funcNum; + int bgFunc; + int setFinalColor3d_funcNum; + FinalOBJColFunct setFinalColorSpr; + //Final3DColFunct setFinalColor3D; + enum SpriteRenderMode { + SPRITE_1D, SPRITE_2D + } spriteRenderMode; + + template + void _spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab); + void spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab); + + template void setFinalColorBG(u16 color, u8 x); + void setFinalColor3d(int dstX, int srcX); + + template FORCEINLINE void setFinalBGColorSpecialNone(u16 &color, u8 x); + template FORCEINLINE void setFinalBGColorSpecialBlend(u16 &color, u8 x); + template FORCEINLINE void setFinalBGColorSpecialIncrease(u16 &color, u8 x); + template FORCEINLINE void setFinalBGColorSpecialDecrease(u16 &color, u8 x); + template FORCEINLINE bool setFinalBGColorSpecialNoneWnd(u16 &color, u8 x); + template FORCEINLINE bool setFinalBGColorSpecialBlendWnd(u16 &color, u8 x); + template FORCEINLINE bool setFinalBGColorSpecialIncreaseWnd(u16 &color, u8 x); + template FORCEINLINE bool setFinalBGColorSpecialDecreaseWnd(u16 &color, u8 x); + + FORCEINLINE void setFinal3DColorSpecialNone(int dstX, int srcX); + FORCEINLINE void setFinal3DColorSpecialBlend(int dstX, int srcX); + FORCEINLINE void setFinal3DColorSpecialIncrease(int dstX, int srcX); + FORCEINLINE void setFinal3DColorSpecialDecrease(int dstX, int srcX); + FORCEINLINE void setFinal3DColorSpecialNoneWnd(int dstX, int srcX); + FORCEINLINE void setFinal3DColorSpecialBlendWnd(int dstX, int srcX); + FORCEINLINE void setFinal3DColorSpecialIncreaseWnd(int dstX, int srcX); + FORCEINLINE void setFinal3DColorSpecialDecreaseWnd(int dstX, int srcX); + + + template void __setFinalColorBck(u16 color, const u8 x, const bool opaque); + void setAffineStart(int layer, int xy, u32 val); + void setAffineStartWord(int layer, int xy, u16 val, int word); + u32 getAffineStart(int layer, int xy); + void refreshAffineStartRegs(const int num, const int xy); + + struct AffineInfo { + AffineInfo() : x(0), y(0) {} + u32 x, y; + } affineInfo[2]; + + void renderline_checkWindows(u16 x, bool &draw, bool &effect) const; + + // check whether (x,y) is within the rectangle (including wraparounds) + template + bool withinRect(u8 x) const; + + void setBLDALPHA(u16 val) + { + BLDALPHA_EVA = (val&0x1f) > 16 ? 16 : (val&0x1f); + BLDALPHA_EVB = ((val>>8)&0x1f) > 16 ? 16 : ((val>>8)&0x1f); + updateBLDALPHA(); + } + + void setBLDALPHA_EVA(u8 val) + { + BLDALPHA_EVA = (val&0x1f) > 16 ? 16 : (val&0x1f); + updateBLDALPHA(); + } + + void setBLDALPHA_EVB(u8 val) + { + BLDALPHA_EVB = (val&0x1f) > 16 ? 16 : (val&0x1f); + updateBLDALPHA(); + } + + typedef u8 TBlendTable[32][32]; + TBlendTable *blendTable; + + void updateBLDALPHA() + { + blendTable = (TBlendTable*)&gpuBlendTable555[BLDALPHA_EVA][BLDALPHA_EVB][0][0]; + } + +}; +#if 0 +// normally should have same addresses +static void REG_DISPx_pack_test(GPU * gpu) +{ + REG_DISPx * r = gpu->dispx_st; + printf ("%08x %02x\n", (u32)r, (u32)(&r->dispx_DISPCNT) - (u32)r); + printf ("\t%02x\n", (u32)(&r->dispA_DISPSTAT) - (u32)r); + printf ("\t%02x\n", (u32)(&r->dispx_VCOUNT) - (u32)r); + printf ("\t%02x\n", (u32)(&r->dispx_BGxCNT[0]) - (u32)r); + printf ("\t%02x\n", (u32)(&r->dispx_BGxOFS[0]) - (u32)r); + printf ("\t%02x\n", (u32)(&r->dispx_BG2PARMS) - (u32)r); + printf ("\t%02x\n", (u32)(&r->dispx_BG3PARMS) - (u32)r); +// printf ("\t%02x\n", (u32)(&r->dispx_WINCNT) - (u32)r); + printf ("\t%02x\n", (u32)(&r->dispx_MISC) - (u32)r); + printf ("\t%02x\n", (u32)(&r->dispA_DISP3DCNT) - (u32)r); + printf ("\t%02x\n", (u32)(&r->dispA_DISPCAPCNT) - (u32)r); + printf ("\t%02x\n", (u32)(&r->dispA_DISPMMEMFIFO) - (u32)r); +} +#endif + +CACHE_ALIGN extern u8 GPU_screen[4*256*192]; + + +GPU * GPU_Init(u8 l); +void GPU_Reset(GPU *g, u8 l); +void GPU_DeInit(GPU *); + +//these are functions used by debug tools which want to render layers etc outside the context of the emulation +namespace GPU_EXT +{ + void textBG(GPU * gpu, u8 num, u8 * DST); //Draw text based background + void rotBG(GPU * gpu, u8 num, u8 * DST); + void extRotBG(GPU * gpu, u8 num, u8 * DST); +}; +void sprite1D(GPU * gpu, u16 l, u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab); +void sprite2D(GPU * gpu, u16 l, u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab); + +extern const size sprSizeTab[4][4]; + +typedef struct { + GPU * gpu; + u16 offset; +} NDS_Screen; + +extern NDS_Screen MainScreen; +extern NDS_Screen SubScreen; + +int Screen_Init(int coreid); +void Screen_Reset(void); +void Screen_DeInit(void); + +extern MMU_struct MMU; + + + +#define GFXCORE_DEFAULT -1 +#define GFXCORE_DUMMY 0 + +#define GFXCORE_FULLSCREEN (1 << 0) + +struct GraphicsInterface_struct +{ + int id; // ID number for core(see above defines) + const char *Name; // Name of core + int flags; // What features the core supports(full screen, etc.) + int (*Init)(); // Initializes stuff related to core + void (*DeInit)(); // Deinitializes stuff related to core + void (*Resize)(int width, int height, BOOL fullscreen); // Resizes window or fullscreen + void (*OnScreenText)(char *string, ...); // For handling save state messages, etc. +} ; + +extern GraphicsInterface_struct GFXDummy; + +void GPU_setVideoProp(GPU *, u32 p); +void GPU_setBGProp(GPU *, u16 num, u16 p); + +void GPU_setBLDCNT(GPU *gpu, u16 v) ; +void GPU_setBLDY(GPU *gpu, u16 v) ; +void GPU_setMOSAIC(GPU *gpu, u16 v) ; + + +void GPU_remove(GPU *, u8 num); +void GPU_addBack(GPU *, u8 num); + +int GPU_ChangeGraphicsCore(int coreid); + +void GPU_set_DISPCAPCNT(u32 val) ; +void GPU_ligne(NDS_Screen * screen, u16 l) ; +void GPU_setMasterBrightness (GPU *gpu, u16 val); + +inline void GPU_setWIN0_H(GPU* gpu, u16 val) { gpu->WIN0H0 = val >> 8; gpu->WIN0H1 = val&0xFF; gpu->need_update_winh[0] = true; } +inline void GPU_setWIN0_H0(GPU* gpu, u8 val) { gpu->WIN0H0 = val; gpu->need_update_winh[0] = true; } +inline void GPU_setWIN0_H1(GPU* gpu, u8 val) { gpu->WIN0H1 = val; gpu->need_update_winh[0] = true; } + +inline void GPU_setWIN0_V(GPU* gpu, u16 val) { gpu->WIN0V0 = val >> 8; gpu->WIN0V1 = val&0xFF;} +inline void GPU_setWIN0_V0(GPU* gpu, u8 val) { gpu->WIN0V0 = val; } +inline void GPU_setWIN0_V1(GPU* gpu, u8 val) { gpu->WIN0V1 = val; } + +inline void GPU_setWIN1_H(GPU* gpu, u16 val) {gpu->WIN1H0 = val >> 8; gpu->WIN1H1 = val&0xFF; gpu->need_update_winh[1] = true; } +inline void GPU_setWIN1_H0(GPU* gpu, u8 val) { gpu->WIN1H0 = val; gpu->need_update_winh[1] = true; } +inline void GPU_setWIN1_H1(GPU* gpu, u8 val) { gpu->WIN1H1 = val; gpu->need_update_winh[1] = true; } + +inline void GPU_setWIN1_V(GPU* gpu, u16 val) { gpu->WIN1V0 = val >> 8; gpu->WIN1V1 = val&0xFF; } +inline void GPU_setWIN1_V0(GPU* gpu, u8 val) { gpu->WIN1V0 = val; } +inline void GPU_setWIN1_V1(GPU* gpu, u8 val) { gpu->WIN1V1 = val; } + +inline void GPU_setWININ(GPU* gpu, u16 val) { + gpu->WININ0=val&0x1F; + gpu->WININ0_SPECIAL=(val>>5)&1; + gpu->WININ1=(val>>8)&0x1F; + gpu->WININ1_SPECIAL=(val>>13)&1; +} + +inline void GPU_setWININ0(GPU* gpu, u8 val) { gpu->WININ0 = val&0x1F; gpu->WININ0_SPECIAL = (val>>5)&1; } +inline void GPU_setWININ1(GPU* gpu, u8 val) { gpu->WININ1 = val&0x1F; gpu->WININ1_SPECIAL = (val>>5)&1; } + +inline void GPU_setWINOUT16(GPU* gpu, u16 val) { + gpu->WINOUT=val&0x1F; + gpu->WINOUT_SPECIAL=(val>>5)&1; + gpu->WINOBJ=(val>>8)&0x1F; + gpu->WINOBJ_SPECIAL=(val>>13)&1; +} +inline void GPU_setWINOUT(GPU* gpu, u8 val) { gpu->WINOUT = val&0x1F; gpu->WINOUT_SPECIAL = (val>>5)&1; } +inline void GPU_setWINOBJ(GPU* gpu, u8 val) { gpu->WINOBJ = val&0x1F; gpu->WINOBJ_SPECIAL = (val>>5)&1; } + +// Blending +void SetupFinalPixelBlitter (GPU *gpu); +#define GPU_setBLDCNT_LOW(gpu, val) {gpu->BLDCNT = (gpu->BLDCNT&0xFF00) | (val); SetupFinalPixelBlitter (gpu);} +#define GPU_setBLDCNT_HIGH(gpu, val) {gpu->BLDCNT = (gpu->BLDCNT&0xFF) | (val<<8); SetupFinalPixelBlitter (gpu);} +#define GPU_setBLDCNT(gpu, val) {gpu->BLDCNT = (val); SetupFinalPixelBlitter (gpu);} + + + +#define GPU_setBLDY_EVY(gpu, val) {gpu->BLDY_EVY = (val&0x1f) > 16 ? 16 : (val&0x1f);} + +#define GPU_setBGxHOFS(bg, gpu, val) gpu->dispx_st->dispx_BGxOFS[bg].BGxHOFS = (val & 0x1F) +#define GPU_setBGxVOFS(bg, gpu, val) gpu->dispx_st->dispx_BGxOFS[bg].BGxVOFS = (val & 0x1F) + +// render +void gpu_UpdateRender(); +void gpu_SetRotateScreen(u16 angle); + +//#undef FORCEINLINE +//#define FORCEINLINE __forceinline + +#endif + diff --git a/desmume/src/GPU_osd.cpp b/src/GPU_osd.cpp similarity index 76% rename from desmume/src/GPU_osd.cpp rename to src/GPU_osd.cpp index a328a913a..a0b68046d 100644 --- a/desmume/src/GPU_osd.cpp +++ b/src/GPU_osd.cpp @@ -1,530 +1,450 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2006-2008 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "GPU_osd.h" -#include "GPU.h" -#include "mem.h" -#include //mem funcs -#include //va_start, etc -#include -#include -#include -#include "debug.h" - -#include "aggdraw.h" -#include "movie.h" -#include "NDSSystem.h" -#include "mic.h" -#include "saves.h" -#include "glib.h" - -bool HudEditorMode = false; -OSDCLASS *osd = NULL; -HudStruct Hud; - -//contains a timer to be used for well-timed hud components -static s64 hudTimer; - -static void SetHudDummy (HudCoordinates *hud) -{ - hud->x=666; - hud->y=666; -} - -static bool IsHudDummy (HudCoordinates *hud) -{ - return (hud->x == 666 && hud->y == 666); -} - -void EditHud(s32 x, s32 y, HudStruct *hudstruct) { - - u32 i = 0; - - while (!IsHudDummy(&hudstruct->hud(i))) { - HudCoordinates &hud = hudstruct->hud(i); - - //reset - if(!hud.clicked) { - hud.storedx=0; - hud.storedy=0; - } - - if((x >= hud.x && x <= hud.x + hud.xsize) && - (y >= hud.y && y <= hud.y + hud.ysize) && !hud.clicked ) { - - hud.clicked=1; - hud.storedx = x - hud.x; - hud.storedy = y - hud.y; - } - - if(hud.clicked) { - hud.x = x - hud.storedx; - hud.y = y - hud.storedy; - } - - //sanity checks - if(hud.x < 0) hud.x = 0; - if(hud.y < 0) hud.y = 0; - if(hud.x > 245)hud.x = 245; //margins - if(hud.y > 384-16)hud.y = 384-16; - - if(hud.clicked) - break;//prevent items from grouping together - - i++; - } -} - -void HudClickRelease(HudStruct *hudstruct) { - - u32 i = 0; - - while (!IsHudDummy(&hudstruct->hud(i))) { - HudCoordinates &hud = hudstruct->hud(i); - hud.clicked=0; - i++; - } -} - -void HudStruct::reset() -{ - FpsDisplay.x=0; - FpsDisplay.y=5; - FpsDisplay.xsize=120; - FpsDisplay.ysize=10; - - FrameCounter.x=0; - FrameCounter.y=25; - FrameCounter.xsize=60; - FrameCounter.ysize=10; - - InputDisplay.x=0; - InputDisplay.y=45; - InputDisplay.xsize=120; - InputDisplay.ysize=10; - - GraphicalInputDisplay.x=8; - GraphicalInputDisplay.y=328; - GraphicalInputDisplay.xsize=100; - GraphicalInputDisplay.ysize=40; - - LagFrameCounter.x=0; - LagFrameCounter.y=65; - LagFrameCounter.xsize=30; - LagFrameCounter.ysize=10; - - Microphone.x=0; - Microphone.y=85; - Microphone.xsize=20; - Microphone.ysize=10; - - SavestateSlots.x = 8; - SavestateSlots.y = 160; - SavestateSlots.xsize = 240; - SavestateSlots.ysize = 24; - - SetHudDummy(&Dummy); -} - -void joyFill(int n) { - - if(nds.pad & (1 << n)) - aggDraw.hud->fillColor(0,0,0,255); - else - aggDraw.hud->fillColor(255,255,255,255); -} - -void joyEllipse(double ex, double ey, int xc, int yc, int x, int y, double ratio, double rad, int button) { - - joyFill(button); - aggDraw.hud->ellipse(x+((xc*ex)*ratio), y+((yc*ey)*ratio), rad*ratio, rad*ratio); -} - -void gradientFill(double x1,double y1,double x2,double y2,AggColor c1,AggColor c2, int n) { - - if(nds.pad & (1 << n)) - aggDraw.hud->fillLinearGradient(x1,y1,x2,y2,c1,c2); - else - aggDraw.hud->fillColor(255,255,255,255); -} - -void drawPad(int x, int y, double ratio) { - - int xc = 41; - int yc = 20; - - aggDraw.hud->lineColor(128,128,128,255); - - aggDraw.hud->fillLinearGradient(x, y, x+(xc*ratio), y+(yc*ratio), agg::rgba8(222,222,222,128), agg::rgba8(255,255,255,255)); - - if(nds.pad & (1 << 2)) - aggDraw.hud->fillLinearGradient(x, y, x+(xc*ratio), y+(yc*ratio), agg::rgba8(0,0,0,128), agg::rgba8(255,255,255,255)); - - if(nds.pad & (1 << 1)) - aggDraw.hud->fillLinearGradient(x+(xc*ratio), y+(yc*ratio), x, y, agg::rgba8(0,0,0,128), agg::rgba8(255,255,255,255)); - - aggDraw.hud->roundedRect (x, y, x+(xc*ratio), y+(yc*ratio), 1); - - aggDraw.hud->fillLinearGradient(x+(xc*.25*ratio), y+(yc*.1*ratio), x+(xc*.75*ratio), y+(yc*.85*ratio), agg::rgba8(128,128,128,128), agg::rgba8(255,255,255,255)); - - aggDraw.hud->roundedRect (x+(xc*.25*ratio), y+(yc*.1*ratio), x+(xc*.75*ratio),y+(yc*.85*ratio), 1); - - joyEllipse(.89,.45,xc,yc,x,y,ratio,1,6);//B - joyEllipse(.89,.22,xc,yc,x,y,ratio,1,3);//X - joyEllipse(.83,.34,xc,yc,x,y,ratio,1,4);//Y - joyEllipse(.95,.34,xc,yc,x,y,ratio,1,5);//A - joyEllipse(.82,.72,xc,yc,x,y,ratio,.5,7);//Start - joyEllipse(.82,.85,xc,yc,x,y,ratio,.5,8);//Select - - aggDraw.hud->noLine(); - aggDraw.hud->fillColor(255,255,255,200); - - //left - gradientFill(x+(xc*.04*ratio), y+(yc*.33*ratio), x+(xc*.17*ratio), y+(yc*.43*ratio), agg::rgba8(0,0,0,255), agg::rgba8(255,255,255,255),11); - - //right - if(nds.pad & (1 << 12)) - aggDraw.hud->fillLinearGradient(x+(xc*.17*ratio), y+(yc*.43*ratio), x+(xc*.04*ratio), y+(yc*.33*ratio), agg::rgba8(0,0,0,255), agg::rgba8(255,255,255,255)); - - aggDraw.hud->roundedRect (x+(xc*.04*ratio), y+(yc*.33*ratio), x+(xc*.17*ratio), y+(yc*.43*ratio), 1); - - //down - gradientFill(x+(xc*.13*ratio), y+(yc*.52*ratio), x+(xc*.08*ratio), y+(yc*.23*ratio), agg::rgba8(0,0,0,255), agg::rgba8(255,255,255,255),10); - - //up - if(nds.pad & (1<< 9)) - aggDraw.hud->fillLinearGradient(x+(xc*.08*ratio), y+(yc*.23*ratio), x+(xc*.13*ratio), y+(yc*.52*ratio), agg::rgba8(0,0,0,255), agg::rgba8(255,255,255,255)); - - aggDraw.hud->roundedRect (x+(xc*.08*ratio), y+(yc*.23*ratio), x+(xc*.13*ratio), y+(yc*.52*ratio), 1); -} - - -struct TouchInfo{ - u16 X; - u16 Y; -}; -static int touchalpha[8]= {31, 63, 95, 127, 159, 191, 223, 255}; -static TouchInfo temptouch; -bool touchshadow = true; -static std::vector touch (8); - - -static void TouchDisplay() { - aggDraw.hud->lineWidth(1.0); - - temptouch.X = nds.touchX >> 4; - temptouch.Y = nds.touchY >> 4; - touch.push_back(temptouch); - - if(touch.size() > 8) touch.erase(touch.begin()); - - if(touchshadow) { - for (int i = 0; i < 8; i++) { - temptouch = touch[i]; - if(temptouch.X != 0 || temptouch.Y != 0) { - aggDraw.hud->lineColor(0, 255, 0, touchalpha[i]); - aggDraw.hud->line(temptouch.X - 256, temptouch.Y + 192, temptouch.X + 256, temptouch.Y + 192); //horiz - aggDraw.hud->line(temptouch.X, temptouch.Y - 256, temptouch.X, temptouch.Y + 384); //vert - aggDraw.hud->fillColor(0, 0, 0, touchalpha[i]); - aggDraw.hud->rectangle(temptouch.X-1, temptouch.Y-1 + 192, temptouch.X+1, temptouch.Y+1 + 192); - } - } - } - else - if(nds.isTouch) { - aggDraw.hud->line(temptouch.X - 256, temptouch.Y + 192, temptouch.X + 256, temptouch.Y + 192); //horiz - aggDraw.hud->line(temptouch.X, temptouch.Y - 256, temptouch.X, temptouch.Y + 384); //vert - } -} - -static int previousslot = 0; -static char number[10]; -static s64 slotTimer=0; - -static void DrawStateSlots(){ - - const int yloc = Hud.SavestateSlots.y; //160 - const int xloc = Hud.SavestateSlots.x; //8 - - s64 fadecounter = 512 - (hudTimer-slotTimer)/4; //change constant to alter fade speed - if(fadecounter < 1) fadecounter = 0; - if(fadecounter>255) fadecounter = 255; - - int alpha = (int)fadecounter; - if(HudEditorMode) - alpha = 255; - - if(alpha!=0) - { - aggDraw.hud->lineWidth(1.0); - aggDraw.hud->lineColor(0, 0, 0, alpha); - aggDraw.hud->fillColor(255, 255, 255, alpha); - - for ( int i = 0, xpos=0; i < 10; xpos=xpos+24) { - - int yheight=0; - - aggDraw.hud->fillLinearGradient(xloc + xpos, yloc - yheight, xloc + 22 + xpos, yloc + 20 + yheight+20, agg::rgba8(100,200,255,alpha), agg::rgba8(255,255,255,0)); - - if(lastSaveState == i) { - yheight = 5; - aggDraw.hud->fillLinearGradient(xloc + xpos, yloc - yheight, 22 + xloc + xpos, yloc + 20 + yheight+20, agg::rgba8(100,255,255,alpha), agg::rgba8(255,255,255,0)); - } - - aggDraw.hud->rectangle(xloc + xpos , yloc - yheight, xloc + 22 + xpos , yloc + 20 + yheight); - snprintf(number, 10, "%d", i); - aggDraw.hud->renderText(xloc + 1 + xpos + 4, yloc+4, std::string(number)); - i++; - } - } - - if(lastSaveState != previousslot) - slotTimer = hudTimer; - - previousslot = lastSaveState; -} - -void DrawHUD() -{ - GTimeVal time; - g_get_current_time(&time); - hudTimer = ((s64)time.tv_sec * 1000) + ((s64)time.tv_usec/1000); - - - if (CommonSettings.hud.ShowInputDisplay) - { - std::stringstream ss; - if(nds.isTouch) - ss << (nds.touchX >> 4) << " " << (nds.touchY >> 4); - osd->addFixed(Hud.InputDisplay.x, Hud.InputDisplay.y, "%s",(InputDisplayString + ss.str()).c_str()); - TouchDisplay(); - } - - if (CommonSettings.hud.FpsDisplay) - { - osd->addFixed(Hud.FpsDisplay.x, Hud.FpsDisplay.y, "Fps:%02d/%02d", Hud.fps, Hud.fps3d); - } - - if (CommonSettings.hud.FrameCounterDisplay) - { - if (movieMode == MOVIEMODE_PLAY) - osd->addFixed(Hud.FrameCounter.x, Hud.FrameCounter.y, "%d/%d",currFrameCounter,currMovieData.records.size()); - else if(movieMode == MOVIEMODE_RECORD) - osd->addFixed(Hud.FrameCounter.x, Hud.FrameCounter.y, "%d",currFrameCounter); - else - osd->addFixed(Hud.FrameCounter.x, Hud.FrameCounter.y, "%d (no movie)",currFrameCounter); - } - - if (CommonSettings.hud.ShowLagFrameCounter) - { - osd->addFixed(Hud.LagFrameCounter.x, Hud.LagFrameCounter.y, "%d",TotalLagFrames); - } - - if (CommonSettings.hud.ShowGraphicalInputDisplay) - drawPad(Hud.GraphicalInputDisplay.x, Hud.GraphicalInputDisplay.y, 2.5); - - #ifdef WIN32 - if (CommonSettings.hud.ShowMicrophone) - { - osd->addFixed(Hud.Microphone.x, Hud.Microphone.y, "%d",MicDisplay); - } - #endif - - DrawStateSlots(); -} - - - -OSDCLASS::OSDCLASS(u8 core) -{ - memset(name,0,7); - - mode=core; - offset=0; - - lastLineText=0; - lineText_x = 5; - lineText_y = 120; - lineText_color = AggColor(255, 255, 255); - for (int i=0; i < OSD_MAX_LINES+1; i++) - { - lineText[i] = new char[1024]; - memset(lineText[i], 0, 1024); - lineTimer[i] = 0; - lineColor[i] = lineText_color; - } - - rotAngle = 0; - - needUpdate = false; - - if (core==0) - strcpy(name,"Core A"); - else - if (core==1) - strcpy(name,"Core B"); - else - { - strcpy(name,"Main"); - mode=255; - } - - //border(false); - - LOG("OSD_Init (%s)\n",name); -} - -OSDCLASS::~OSDCLASS() -{ - LOG("OSD_Deinit (%s)\n",name); - - for (int i=0; i < OSD_MAX_LINES+1; i++) - { - if (lineText[i]) - delete [] lineText[i]; - lineText[i] = NULL; - } -} - -void OSDCLASS::setOffset(u16 ofs) -{ - offset=ofs; -} - -void OSDCLASS::setRotate(u16 angle) -{ - rotAngle = angle; -} - -void OSDCLASS::clear() -{ - needUpdate=false; -} - -bool OSDCLASS::checkTimers() -{ - if (lastLineText == 0) return false; - - time_t tmp_time = time(NULL); - - for (int i=0; i < lastLineText; i++) - { - if (tmp_time > (lineTimer[i] + OSD_TIMER_SECS) ) - { - if (i < lastLineText) - { - for (int j=i; j < lastLineText; j++) - { - strcpy(lineText[j], lineText[j+1]); - lineTimer[j] = lineTimer[j+1]; - lineColor[j] = lineColor[j+1]; - } - } - lineTimer[lastLineText] = 0; - lastLineText--; - if (lastLineText == 0) return false; - } - } - return true; -} - -void OSDCLASS::update() -{ - if ( (!needUpdate) && (!lastLineText) ) return; // don't update if buffer empty (speed up) - if (lastLineText) - { - if (checkTimers()) - { - for (int i=0; i < lastLineText; i++) - { - aggDraw.hud->lineColor(lineColor[i]); - aggDraw.hud->renderTextDropshadowed(lineText_x,lineText_y+(i*16),lineText[i]); - } - } - else - { - if (!needUpdate) return; - } - } -} - -void OSDCLASS::setListCoord(u16 x, u16 y) -{ - lineText_x = x; - lineText_y = y; -} - -void OSDCLASS::setLineColor(u8 r=255, u8 b=255, u8 g=255) -{ - lineText_color = AggColor(r,g,b); -} - -void OSDCLASS::addLine(const char *fmt, ...) -{ - va_list list; - - if (lastLineText > OSD_MAX_LINES) lastLineText = OSD_MAX_LINES; - if (lastLineText == OSD_MAX_LINES) // full - { - lastLineText--; - for (int j=0; j < lastLineText; j++) - { - strcpy(lineText[j], lineText[j+1]); - lineTimer[j] = lineTimer[j+1]; - lineColor[j] = lineColor[j+1]; - } - } - - va_start(list,fmt); -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) - _vsnprintf(lineText[lastLineText],1023,fmt,list); -#else - vsnprintf(lineText[lastLineText],1023,fmt,list); -#endif - va_end(list); - lineColor[lastLineText] = lineText_color; - lineTimer[lastLineText] = time(NULL); - needUpdate = true; - - lastLineText++; -} - -void OSDCLASS::addFixed(u16 x, u16 y, const char *fmt, ...) -{ - va_list list; - char msg[1024]; - - va_start(list,fmt); - vsnprintf(msg,1023,fmt,list); - va_end(list); - - aggDraw.hud->lineColor(255,255,255); - aggDraw.hud->renderTextDropshadowed(x,y,msg); - - needUpdate = true; -} - -void OSDCLASS::border(bool enabled) -{ - //render51.setTextBoxBorder(enabled); -} +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2006-2008 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "GPU_osd.h" +#include "GPU.h" +#include "mem.h" +#include //mem funcs +#include //va_start, etc +#include +#include +#include +#include "debug.h" + +#include "aggdraw.h" +#include "movie.h" +#include "NDSSystem.h" +#include "mic.h" +#include "saves.h" +#include "glib.h" + +bool HudEditorMode = false; +OSDCLASS *osd = NULL; +HudStruct Hud; + +//contains a timer to be used for well-timed hud components +static s64 hudTimer; + +void SetHudDummy (HudCoordinates *hud) +{ + hud->x=666; + hud->y=666; +} + +bool IsHudDummy (HudCoordinates *hud) +{ + return (hud->x == 666 && hud->y == 666); +} + +void EditHud(s32 x, s32 y, HudStruct *hudstruct) { + + u32 i = 0; + + while (!IsHudDummy(&hudstruct->hud(i))) { + HudCoordinates &hud = hudstruct->hud(i); + + //reset + if(!hud.clicked) { + hud.storedx=0; + hud.storedy=0; + } + + if((x >= hud.x && x <= hud.x + hud.xsize) && + (y >= hud.y && y <= hud.y + hud.ysize) && !hud.clicked ) { + + hud.clicked=1; + hud.storedx = x - hud.x; + hud.storedy = y - hud.y; + } + + if(hud.clicked) { + hud.x = x - hud.storedx; + hud.y = y - hud.storedy; + } + + //sanity checks + if(hud.x < 0) hud.x = 0; + if(hud.y < 0) hud.y = 0; + if(hud.x > 245)hud.x = 245; //margins + if(hud.y > 384-16)hud.y = 384-16; + + if(hud.clicked) + break;//prevent items from grouping together + + i++; + } +} + +void HudClickRelease(HudStruct *hudstruct) { + + u32 i = 0; + + while (!IsHudDummy(&hudstruct->hud(i))) { + HudCoordinates &hud = hudstruct->hud(i); + hud.clicked=0; + i++; + } +} + +void HudStruct::reset() +{ + FpsDisplay.x=0; + FpsDisplay.y=5; + FpsDisplay.xsize=120; + FpsDisplay.ysize=10; + + FrameCounter.x=0; + FrameCounter.y=25; + FrameCounter.xsize=60; + FrameCounter.ysize=10; + + InputDisplay.x=0; + InputDisplay.y=45; + InputDisplay.xsize=120; + InputDisplay.ysize=10; + + LagFrameCounter.x=0; + LagFrameCounter.y=65; + LagFrameCounter.xsize=30; + LagFrameCounter.ysize=10; + + Microphone.x=0; + Microphone.y=85; + Microphone.xsize=20; + Microphone.ysize=10; + + SavestateSlots.x = 8; + SavestateSlots.y = 160; + SavestateSlots.xsize = 240; + SavestateSlots.ysize = 24; + + SetHudDummy(&Dummy); +} + + +struct TouchInfo{ + u16 X; + u16 Y; +}; +static int touchalpha[8]= {31, 63, 95, 127, 159, 191, 223, 255}; +static TouchInfo temptouch; +bool touchshadow = true; +static std::vector touch (8); + + +static void TouchDisplay() { + aggDraw.hud->lineWidth(1.0); + + temptouch.X = nds.touchX >> 4; + temptouch.Y = nds.touchY >> 4; + touch.push_back(temptouch); + + if(touch.size() > 8) touch.erase(touch.begin()); + + if(touchshadow) { + for (int i = 0; i < 8; i++) { + temptouch = touch[i]; + if(temptouch.X != 0 || temptouch.Y != 0) { + aggDraw.hud->lineColor(0, 255, 0, touchalpha[i]); + aggDraw.hud->line(temptouch.X - 256, temptouch.Y + 192, temptouch.X + 256, temptouch.Y + 192); //horiz + aggDraw.hud->line(temptouch.X, temptouch.Y - 256, temptouch.X, temptouch.Y + 384); //vert + aggDraw.hud->fillColor(0, 0, 0, touchalpha[i]); + aggDraw.hud->rectangle(temptouch.X-1, temptouch.Y-1 + 192, temptouch.X+1, temptouch.Y+1 + 192); + } + } + } + else + if(nds.isTouch) { + aggDraw.hud->line(temptouch.X - 256, temptouch.Y + 192, temptouch.X + 256, temptouch.Y + 192); //horiz + aggDraw.hud->line(temptouch.X, temptouch.Y - 256, temptouch.X, temptouch.Y + 384); //vert + } +} + +static int previousslot = 0; +static char number[10]; +static s64 slotTimer=0; + +static void DrawStateSlots(){ + + const int yloc = Hud.SavestateSlots.y; //160 + const int xloc = Hud.SavestateSlots.x; //8 + + s64 fadecounter = 512 - (hudTimer-slotTimer)/4; //change constant to alter fade speed + if(fadecounter < 1) fadecounter = 0; + if(fadecounter>255) fadecounter = 255; + + int alpha = (int)fadecounter; + if(HudEditorMode) + alpha = 255; + + if(alpha!=0) + { + aggDraw.hud->lineWidth(1.0); + aggDraw.hud->lineColor(0, 0, 0, alpha); + aggDraw.hud->fillColor(255, 255, 255, alpha); + + for ( int i = 0, xpos=0; i < 10; xpos=xpos+24) { + + int yheight=0; + + aggDraw.hud->fillLinearGradient(xloc + xpos, yloc - yheight, xloc + 22 + xpos, yloc + 20 + yheight+20, agg::rgba8(100,200,255,alpha), agg::rgba8(255,255,255,0)); + + if(lastSaveState == i) { + yheight = 5; + aggDraw.hud->fillLinearGradient(xloc + xpos, yloc - yheight, 22 + xloc + xpos, yloc + 20 + yheight+20, agg::rgba8(100,255,255,alpha), agg::rgba8(255,255,255,0)); + } + + aggDraw.hud->rectangle(xloc + xpos , yloc - yheight, xloc + 22 + xpos , yloc + 20 + yheight); + snprintf(number, 10, "%d", i); + aggDraw.hud->renderText(xloc + 1 + xpos + 4, yloc+4, std::string(number)); + i++; + } + } + + if(lastSaveState != previousslot) + slotTimer = hudTimer; + + previousslot = lastSaveState; +} + +void DrawHUD() +{ + GTimeVal time; + g_get_current_time(&time); + hudTimer = ((s64)time.tv_sec * 1000) + ((s64)time.tv_usec/1000); + + + if (CommonSettings.hud.ShowInputDisplay) + { + std::stringstream ss; + if(nds.isTouch) + ss << (nds.touchX >> 4) << " " << (nds.touchY >> 4); + osd->addFixed(Hud.InputDisplay.x, Hud.InputDisplay.y, "%s",(InputDisplayString + ss.str()).c_str()); + TouchDisplay(); + } + + if (CommonSettings.hud.FpsDisplay) + { + osd->addFixed(Hud.FpsDisplay.x, Hud.FpsDisplay.y, "Fps:%02d/%02d", Hud.fps, Hud.fps3d); + } + + if (CommonSettings.hud.FrameCounterDisplay) + { + if (movieMode == MOVIEMODE_PLAY) + osd->addFixed(Hud.FrameCounter.x, Hud.FrameCounter.y, "%d/%d",currFrameCounter,currMovieData.records.size()); + else if(movieMode == MOVIEMODE_RECORD) + osd->addFixed(Hud.FrameCounter.x, Hud.FrameCounter.y, "%d",currFrameCounter); + else + osd->addFixed(Hud.FrameCounter.x, Hud.FrameCounter.y, "%d (no movie)",currFrameCounter); + } + + if (CommonSettings.hud.ShowLagFrameCounter) + { + osd->addFixed(Hud.LagFrameCounter.x, Hud.LagFrameCounter.y, "%d",TotalLagFrames); + } + + #ifdef WIN32 + if (CommonSettings.hud.ShowMicrophone) + { + osd->addFixed(Hud.Microphone.x, Hud.Microphone.y, "%d",MicDisplay); + } + #endif + + DrawStateSlots(); +} + + + +OSDCLASS::OSDCLASS(u8 core) +{ + memset(name,0,7); + + mode=core; + offset=0; + + lastLineText=0; + lineText_x = 5; + lineText_y = 120; + lineText_color = AggColor(255, 255, 255); + for (int i=0; i < OSD_MAX_LINES+1; i++) + { + lineText[i] = new char[1024]; + memset(lineText[i], 0, 1024); + lineTimer[i] = 0; + lineColor[i] = lineText_color; + } + + rotAngle = 0; + + needUpdate = false; + + if (core==0) + strcpy(name,"Core A"); + else + if (core==1) + strcpy(name,"Core B"); + else + { + strcpy(name,"Main"); + mode=255; + } + + //border(false); + + LOG("OSD_Init (%s)\n",name); +} + +OSDCLASS::~OSDCLASS() +{ + LOG("OSD_Deinit (%s)\n",name); + + for (int i=0; i < OSD_MAX_LINES+1; i++) + { + if (lineText[i]) + delete [] lineText[i]; + lineText[i] = NULL; + } +} + +void OSDCLASS::setOffset(u16 ofs) +{ + offset=ofs; +} + +void OSDCLASS::setRotate(u16 angle) +{ + rotAngle = angle; +} + +void OSDCLASS::clear() +{ + needUpdate=false; +} + +bool OSDCLASS::checkTimers() +{ + if (lastLineText == 0) return false; + + time_t tmp_time = time(NULL); + + for (int i=0; i < lastLineText; i++) + { + if (tmp_time > (lineTimer[i] + OSD_TIMER_SECS) ) + { + if (i < lastLineText) + { + for (int j=i; j < lastLineText; j++) + { + strcpy(lineText[j], lineText[j+1]); + lineTimer[j] = lineTimer[j+1]; + lineColor[j] = lineColor[j+1]; + } + } + lineTimer[lastLineText] = 0; + lastLineText--; + if (lastLineText == 0) return false; + } + } + return true; +} + +void OSDCLASS::update() +{ + if ( (!needUpdate) && (!lastLineText) ) return; // don't update if buffer empty (speed up) + if (lastLineText) + { + if (checkTimers()) + { + for (int i=0; i < lastLineText; i++) + { + aggDraw.hud->lineColor(lineColor[i]); + aggDraw.hud->renderTextDropshadowed(lineText_x,lineText_y+(i*16),lineText[i]); + } + } + else + { + if (!needUpdate) return; + } + } +} + +void OSDCLASS::setListCoord(u16 x, u16 y) +{ + lineText_x = x; + lineText_y = y; +} + +void OSDCLASS::setLineColor(u8 r=255, u8 b=255, u8 g=255) +{ + lineText_color = AggColor(r,g,b); +} + +void OSDCLASS::addLine(const char *fmt, ...) +{ + va_list list; + + if (lastLineText > OSD_MAX_LINES) lastLineText = OSD_MAX_LINES; + if (lastLineText == OSD_MAX_LINES) // full + { + lastLineText--; + for (int j=0; j < lastLineText; j++) + { + strcpy(lineText[j], lineText[j+1]); + lineTimer[j] = lineTimer[j+1]; + lineColor[j] = lineColor[j+1]; + } + } + + va_start(list,fmt); +#if defined(_MSC_VER) || defined(__INTEL_COMPILER) + _vsnprintf(lineText[lastLineText],1023,fmt,list); +#else + vsnprintf(lineText[lastLineText],1023,fmt,list); +#endif + va_end(list); + lineColor[lastLineText] = lineText_color; + lineTimer[lastLineText] = time(NULL); + needUpdate = true; + + lastLineText++; +} + +void OSDCLASS::addFixed(u16 x, u16 y, const char *fmt, ...) +{ + va_list list; + char msg[1024]; + + va_start(list,fmt); + vsnprintf(msg,1023,fmt,list); + va_end(list); + + aggDraw.hud->lineColor(255,255,255); + aggDraw.hud->renderTextDropshadowed(x,y,msg); + + needUpdate = true; +} + +void OSDCLASS::border(bool enabled) +{ + //render51.setTextBoxBorder(enabled); +} diff --git a/desmume/src/GPU_osd.h b/src/GPU_osd.h similarity index 94% rename from desmume/src/GPU_osd.h rename to src/GPU_osd.h index a97343a83..625e8018d 100644 --- a/desmume/src/GPU_osd.h +++ b/src/GPU_osd.h @@ -1,114 +1,114 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2006-2008 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __GPU_OSD_ -#define __GPU_OSD_ - -#include -#include -#include "types.h" - -#include "aggdraw.h" - -#define OSD_MAX_LINES 4 -#define OSD_TIMER_SECS 2 - - -struct HudCoordinates{ - int x; - int y; - int xsize; - int ysize; - int storedx; - int storedy; - int clicked; -}; - -struct HudStruct -{ -public: - HudStruct() - : fps(0) - , fps3d(0) - {} - - HudCoordinates SavestateSlots; - HudCoordinates FpsDisplay; - HudCoordinates FrameCounter; - HudCoordinates InputDisplay; - HudCoordinates GraphicalInputDisplay; - HudCoordinates LagFrameCounter; - HudCoordinates Microphone; - HudCoordinates Dummy; - - HudCoordinates &hud(int i) { return ((HudCoordinates*)this)[i]; } - void reset(); - - int fps, fps3d; -}; - -void EditHud(s32 x, s32 y, HudStruct *hudstruct); -void HudClickRelease(HudStruct *hudstruct); - -void DrawHUD(); - -extern HudStruct Hud; -extern bool HudEditorMode; - -class OSDCLASS -{ -private: - u64 offset; - u8 mode; - - u16 rotAngle; - - u16 lineText_x; - u16 lineText_y; - AggColor lineText_color; - u8 lastLineText; - char *lineText[OSD_MAX_LINES+1]; - time_t lineTimer[OSD_MAX_LINES+1]; - AggColor lineColor[OSD_MAX_LINES+1]; - - bool needUpdate; - - bool checkTimers(); -public: - char name[7]; // for debuging - OSDCLASS(u8 core); - ~OSDCLASS(); - - void setOffset(u16 ofs); - void setRotate(u16 angle); - void update(); - void clear(); - void setListCoord(u16 x, u16 y); - void setLineColor(u8 r, u8 b, u8 g); - void addLine(const char *fmt, ...); - void addFixed(u16 x, u16 y, const char *fmt, ...); - void border(bool enabled); -}; - -extern OSDCLASS *osd; -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2006-2008 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __GPU_OSD_ +#define __GPU_OSD_ + +#include +#include +#include "types.h" + +#include "aggdraw.h" + +#define OSD_MAX_LINES 4 +#define OSD_TIMER_SECS 2 + + +struct HudCoordinates{ + int x; + int y; + int xsize; + int ysize; + int storedx; + int storedy; + int clicked; +}; + +struct HudStruct +{ +public: + HudStruct() + : fps(0) + , fps3d(0) + {} + + HudCoordinates SavestateSlots; + HudCoordinates FpsDisplay; + HudCoordinates FrameCounter; + HudCoordinates InputDisplay; + HudCoordinates LagFrameCounter; + HudCoordinates Microphone; + HudCoordinates Dummy; + + HudCoordinates &hud(int i) { return ((HudCoordinates*)this)[i]; } + void reset(); + + int fps, fps3d; +}; + +void ResetHud(HudStruct *hudstruct); +void EditHud(s32 x, s32 y, HudStruct *hudstruct); +void HudClickRelease(HudStruct *hudstruct); + +void DrawHUD(); + +extern HudStruct Hud; +extern bool HudEditorMode; + +class OSDCLASS +{ +private: + u64 offset; + u8 mode; + + u16 rotAngle; + + u16 lineText_x; + u16 lineText_y; + AggColor lineText_color; + u8 lastLineText; + char *lineText[OSD_MAX_LINES+1]; + time_t lineTimer[OSD_MAX_LINES+1]; + AggColor lineColor[OSD_MAX_LINES+1]; + + bool needUpdate; + + bool checkTimers(); +public: + char name[7]; // for debuging + OSDCLASS(u8 core); + ~OSDCLASS(); + + void setOffset(u16 ofs); + void setRotate(u16 angle); + void update(); + void clear(); + void setListCoord(u16 x, u16 y); + void setLineColor(u8 r, u8 b, u8 g); + void addLine(const char *fmt, ...); + void addFixed(u16 x, u16 y, const char *fmt, ...); + void border(bool enabled); +}; + +extern OSDCLASS *osd; +#endif diff --git a/desmume/src/MMU.cpp b/src/MMU.cpp similarity index 71% rename from desmume/src/MMU.cpp rename to src/MMU.cpp index 5ce69b56a..698f0e2fe 100644 --- a/desmume/src/MMU.cpp +++ b/src/MMU.cpp @@ -1,3970 +1,4282 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2007 shash - Copyright (C) 2007-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -//#define NEW_IRQ 1 - -#include -#include -#include -#include -#include - -#include "common.h" -#include "debug.h" -#include "NDSSystem.h" -#include "cp15.h" -#include "wifi.h" -#include "registers.h" -#include "render3D.h" -#include "gfx3d.h" -#include "rtc.h" -#include "GPU_osd.h" -#include "mc.h" -#include "addons.h" -#include "mic.h" -#include "movie.h" - -#ifdef DO_ASSERT_UNALIGNED -#define ASSERT_UNALIGNED(x) assert(x) -#else -#define ASSERT_UNALIGNED(x) -#endif - -//http://home.utah.edu/~nahaj/factoring/isqrt.c.html -static u64 isqrt (u64 x) { - u64 squaredbit, remainder, root; - - if (x<1) return 0; - - /* Load the binary constant 01 00 00 ... 00, where the number - * of zero bits to the right of the single one bit - * is even, and the one bit is as far left as is consistant - * with that condition.) - */ - squaredbit = (u64) ((((u64) ~0LL) >> 1) & - ~(((u64) ~0LL) >> 2)); - /* This portable load replaces the loop that used to be - * here, and was donated by legalize@xmission.com - */ - - /* Form bits of the answer. */ - remainder = x; root = 0; - while (squaredbit > 0) { - if (remainder >= (squaredbit | root)) { - remainder -= (squaredbit | root); - root >>= 1; root |= squaredbit; - } else { - root >>= 1; - } - squaredbit >>= 2; - } - - return root; -} - -u32 partie = 1; -u32 _MMU_MAIN_MEM_MASK = 0x3FFFFF; - -#define ROM_MASK 3 - -//#define _MMU_DEBUG - -#ifdef _MMU_DEBUG - -#include -void mmu_log_debug_ARM9(u32 adr, const char *fmt, ...) -{ - if (adr < 0x4000000) return; - if (adr > 0x4100014) return; - - if (adr >= 0x4000000 && adr <= 0x400006E) return; // Display Engine A - if (adr >= 0x40000B0 && adr <= 0x4000134) return; // DMA, Timers and Keypad - if (adr >= 0x4000180 && adr <= 0x40001BC) return; // IPC/ROM - if (adr >= 0x4000204 && adr <= 0x400024A) return; // Memory & IRQ control - if (adr >= 0x4000280 && adr <= 0x4000306) return; // Maths - if (adr >= 0x4000320 && adr <= 0x40006A3) return; // 3D dispaly engine - if (adr >= 0x4001000 && adr <= 0x400106E) return; // Display Engine B - if (adr >= 0x4100000 && adr <= 0x4100014) return; // IPC/ROM - - va_list list; - char msg[512]; - - memset(msg,0,512); - - va_start(list,fmt); - _vsnprintf(msg,511,fmt,list); - va_end(list); - - INFO("MMU ARM9 0x%08X: %s\n", adr, msg); -} - -void mmu_log_debug_ARM7(u32 adr, const char *fmt, ...) -{ - if (adr < 0x4000004) return; - if (adr > 0x4808FFF) return; - - if (adr >= 0x4000004 && adr <= 0x40001C4) return; // ARM7 I/O Map - if (adr >= 0x4000204 && adr <= 0x400030C) return; // Memory and IRQ Control - if (adr >= 0x4000400 && adr <= 0x400051E) return; // Sound Registers - if (adr >= 0x4100000 && adr <= 0x4100014) return; // IPC/ROM - //if (adr >= 0x4800000 && adr <= 0x4808FFF) return; // WLAN Registers - - va_list list; - char msg[512]; - - memset(msg,0,512); - - va_start(list,fmt); - _vsnprintf(msg,511,fmt,list); - va_end(list); - - INFO("MMU ARM7 0x%08X: %s\n", adr, msg); - -} -#else -#define mmu_log_debug_ARM9(...) -#define mmu_log_debug_ARM7(...) -#endif - - -//#define LOG_CARD -//#define LOG_GPU -//#define LOG_DMA -//#define LOG_DMA2 -//#define LOG_DIV - -#define DUP2(x) x, x -#define DUP4(x) x, x, x, x -#define DUP8(x) x, x, x, x, x, x, x, x -#define DUP16(x) x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x - -MMU_struct MMU; -MMU_struct_new MMU_new; - -u8 * MMU_struct::MMU_MEM[2][256] = { - //arm9 - { - /* 0X*/ DUP16(MMU.ARM9_ITCM), - /* 1X*/ //DUP16(MMU.ARM9_ITCM) - /* 1X*/ DUP16(MMU.UNUSED_RAM), - /* 2X*/ DUP16(MMU.MAIN_MEM), - /* 3X*/ DUP16(MMU.SWIRAM), - /* 4X*/ DUP16(MMU.ARM9_REG), - /* 5X*/ DUP16(MMU.ARM9_VMEM), - /* 6X*/ DUP16(MMU.ARM9_LCD), - /* 7X*/ DUP16(MMU.ARM9_OAM), - /* 8X*/ DUP16(NULL), - /* 9X*/ DUP16(NULL), - /* AX*/ DUP16(MMU.CART_RAM), - /* BX*/ DUP16(MMU.UNUSED_RAM), - /* CX*/ DUP16(MMU.UNUSED_RAM), - /* DX*/ DUP16(MMU.UNUSED_RAM), - /* EX*/ DUP16(MMU.UNUSED_RAM), - /* FX*/ DUP16(MMU.ARM9_BIOS) - }, - //arm7 - { - /* 0X*/ DUP16(MMU.ARM7_BIOS), - /* 1X*/ DUP16(MMU.UNUSED_RAM), - /* 2X*/ DUP16(MMU.MAIN_MEM), - /* 3X*/ DUP8(MMU.SWIRAM), - DUP8(MMU.ARM7_ERAM), - /* 4X*/ DUP8(MMU.ARM7_REG), - DUP8(MMU.ARM7_WIRAM), - /* 5X*/ DUP16(MMU.UNUSED_RAM), - /* 6X*/ DUP16(MMU.ARM9_LCD), - /* 7X*/ DUP16(MMU.UNUSED_RAM), - /* 8X*/ DUP16(NULL), - /* 9X*/ DUP16(NULL), - /* AX*/ DUP16(MMU.CART_RAM), - /* BX*/ DUP16(MMU.UNUSED_RAM), - /* CX*/ DUP16(MMU.UNUSED_RAM), - /* DX*/ DUP16(MMU.UNUSED_RAM), - /* EX*/ DUP16(MMU.UNUSED_RAM), - /* FX*/ DUP16(MMU.UNUSED_RAM) - } -}; - -u32 MMU_struct::MMU_MASK[2][256] = { - //arm9 - { - /* 0X*/ DUP16(0x00007FFF), - /* 1X*/ //DUP16(0x00007FFF) - /* 1X*/ DUP16(0x00000003), - /* 2X*/ DUP16(0x003FFFFF), - /* 3X*/ DUP16(0x00007FFF), - /* 4X*/ DUP16(0x00FFFFFF), - /* 5X*/ DUP16(0x000007FF), - /* 6X*/ DUP16(0x00FFFFFF), - /* 7X*/ DUP16(0x000007FF), - /* 8X*/ DUP16(ROM_MASK), - /* 9X*/ DUP16(ROM_MASK), - /* AX*/ DUP16(0x0000FFFF), - /* BX*/ DUP16(0x00000003), - /* CX*/ DUP16(0x00000003), - /* DX*/ DUP16(0x00000003), - /* EX*/ DUP16(0x00000003), - /* FX*/ DUP16(0x00007FFF) - }, - //arm7 - { - /* 0X*/ DUP16(0x00003FFF), - /* 1X*/ DUP16(0x00000003), - /* 2X*/ DUP16(0x003FFFFF), - /* 3X*/ DUP8(0x00007FFF), - DUP8(0x0000FFFF), - /* 4X*/ DUP8(0x00FFFFFF), - DUP8(0x0000FFFF), - /* 5X*/ DUP16(0x00000003), - /* 6X*/ DUP16(0x00FFFFFF), - /* 7X*/ DUP16(0x00000003), - /* 8X*/ DUP16(ROM_MASK), - /* 9X*/ DUP16(ROM_MASK), - /* AX*/ DUP16(0x0000FFFF), - /* BX*/ DUP16(0x00000003), - /* CX*/ DUP16(0x00000003), - /* DX*/ DUP16(0x00000003), - /* EX*/ DUP16(0x00000003), - /* FX*/ DUP16(0x00000003) - } -}; - -CACHE_ALIGN -TWaitState MMU_struct::MMU_WAIT16[2][16] = { - { 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1, 1, 1 }, //arm9 - { 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1, 1, 1 }, //arm7 -}; - -CACHE_ALIGN -TWaitState MMU_struct::MMU_WAIT32[2][16] = { - { 1, 1, 1, 1, 1, 2, 2, 1, 8, 8, 5, 1, 1, 1, 1, 1 }, //arm9 - { 1, 1, 1, 1, 1, 1, 1, 1, 8, 8, 5, 1, 1, 1, 1, 1 }, //arm7 -}; - -////////////////////////////////////////////////////////////// - -//------------- -//VRAM MEMORY MAPPING -//------------- -//(Everything is mapped through to ARM9_LCD in blocks of 16KB) - -//for all of the below, values = 41 indicate unmapped memory -#define VRAM_PAGE_UNMAPPED 41 - -#define VRAM_LCDC_PAGES 41 -u8 vram_lcdc_map[VRAM_LCDC_PAGES]; - -//in the range of 0x06000000 - 0x06800000 in 16KB pages (the ARM9 vram mappable area) -//this maps to 16KB pages in the LCDC buffer which is what will actually contain the data -u8 vram_arm9_map[VRAM_ARM9_PAGES]; - -//this chooses which banks are mapped in the 128K banks starting at 0x06000000 in ARM7 -u8 vram_arm7_map[2]; - -//-----> -//consider these later, for better recordkeeping, instead of using the u8* in MMU - -////for each 128KB texture slot, this maps to a 16KB starting page in the LCDC buffer -//#define VRAM_TEX_SLOTS 4 -//u8 vram_tex_map[VRAM_TEX_SLOTS]; -// -////for each 16KB tex palette slot, this maps to a 16KB starting page in the LCDC buffer -//#define VRAM_TEX_PALETTE_SLOTS 6 -//u8 vram_tex_palette_map[VRAM_TEX_PALETTE_SLOTS]; - -//<--------- - - -void MMU_VRAM_unmap_all(); - -struct TVramBankInfo { - u8 page_addr, num_pages; -}; - -static const TVramBankInfo vram_bank_info[VRAM_BANKS] = { - {0,8}, - {8,8}, - {16,8}, - {24,8}, - {32,4}, - {36,1}, - {37,1}, - {38,2}, - {40,1} -}; - -//this is to remind you that the LCDC mapping returns a strange value (not 0x06800000) as you would expect -//in order to play nicely with the MMU address and mask tables -#define LCDC_HACKY_LOCATION 0x06000000 - -//maps an ARM9 BG/OBJ or LCDC address into an LCDC address, and informs the caller of whether it isn't mapped -//TODO - in cases where this does some mapping work, we could bypass the logic at the end of the _read* and _write* routines -//this is a good optimization to consider -template -static FORCEINLINE u32 MMU_LCDmap(u32 addr, bool& unmapped) -{ - unmapped = false; - - //in case the address is entirely outside of the interesting ranges - if(addr < 0x06000000) return addr; - if(addr >= 0x07000000) return addr; - - //shared wram mapping for arm7 - if(PROCNUM==ARMCPU_ARM7) - { - //necessary? not sure - //addr &= 0x3FFFF; - //addr += 0x06000000; - u32 ofs = addr & 0x1FFFF; - u32 bank = (addr >> 17)&1; - if(vram_arm7_map[bank] == VRAM_PAGE_UNMAPPED) - { - unmapped = true; - return 0; - } - return LCDC_HACKY_LOCATION + (vram_arm7_map[bank]<<14) + ofs; - } - - //handle LCD memory mirroring - if(addr>=0x068A4000) - addr = 0x06800000 + - //(addr%0xA4000); //yuck!! is this even how it mirrors? but we have to keep from overrunning the buffer somehow - (addr&0x80000); //just as likely to be right (I have no clue how it should work) but faster. - - u32 vram_page; - u32 ofs = addr & 0x3FFF; - - //return addresses in LCDC range - if(addr>=0x06800000) - { - //already in LCDC range. just look it up to see whether it is unmapped - vram_page = (addr>>14)&63; - assert(vram_page>14)&(VRAM_ARM9_PAGES-1); - assert(vram_page= VRAM_BANK_H) block++; - - u8 VRAMBankCnt = T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x240 + block); - - //do nothing if the bank isnt enabled - u8 en = VRAMBankCnt & 0x80; - if(!en) return; - - int mst,ofs=0; - switch(bank) { - case VRAM_BANK_A: - case VRAM_BANK_B: - mst = VRAMBankCnt & 3; - ofs = (VRAMBankCnt>>3) & 3; - switch(mst) - { - case 0: //LCDC - vramConfiguration.banks[bank].purpose = VramConfiguration::LCDC; - MMU_vram_lcdc(bank); - if(ofs != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); - break; - case 1: //ABG - vramConfiguration.banks[bank].purpose = VramConfiguration::ABG; - //MMU_vram_lcdc(bank); - MMU_vram_arm9(bank,VRAM_PAGE_ABG+ofs*8); - break; - case 2: //AOBJ - vramConfiguration.banks[bank].purpose = VramConfiguration::AOBJ; - switch(ofs) { - case 0: - case 1: - //MMU_vram_lcdc(bank); - MMU_vram_arm9(bank,VRAM_PAGE_AOBJ+ofs*8); - break; - default: - PROGINFO("Unsupported ofs setting %d for engine A OBJ vram bank %c\n", ofs, 'A'+bank); - } - break; - case 3: //texture - vramConfiguration.banks[bank].purpose = VramConfiguration::TEX; - MMU.texInfo.textureSlotAddr[ofs] = MMU_vram_physical(vram_bank_info[bank].page_addr); - break; - default: goto unsupported_mst; - } - break; - - case VRAM_BANK_C: - case VRAM_BANK_D: - mst = VRAMBankCnt & 7; - ofs = (VRAMBankCnt>>3) & 3; - switch(mst) - { - case 0: //LCDC - vramConfiguration.banks[bank].purpose = VramConfiguration::LCDC; - MMU_vram_lcdc(bank); - if(ofs != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); - break; - case 1: //ABG - vramConfiguration.banks[bank].purpose = VramConfiguration::ABG; - //MMU_vram_lcdc(bank); - MMU_vram_arm9(bank,VRAM_PAGE_ABG+ofs*8); - break; - case 2: //arm7 - vramConfiguration.banks[bank].purpose = VramConfiguration::ARM7; - if(bank == 2) T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x240, T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x240) | 2); - if(bank == 3) T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x240, T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x240) | 1); - switch(ofs) { - case 0: - case 1: - vram_arm7_map[ofs] = vram_bank_info[bank].page_addr; - break; - default: - PROGINFO("Unsupported ofs setting %d for arm7 vram bank %c\n", ofs, 'A'+bank); - } - - break; - case 3: //texture - vramConfiguration.banks[bank].purpose = VramConfiguration::TEX; - MMU.texInfo.textureSlotAddr[ofs] = MMU_vram_physical(vram_bank_info[bank].page_addr); - break; - case 4: //BGB or BOBJ - //MMU_vram_lcdc(bank); - if(bank == VRAM_BANK_C) { - vramConfiguration.banks[bank].purpose = VramConfiguration::BBG; - MMU_vram_arm9(bank,VRAM_PAGE_BBG); //BBG - } else { - vramConfiguration.banks[bank].purpose = VramConfiguration::BOBJ; - MMU_vram_arm9(bank,VRAM_PAGE_BOBJ); //BOBJ - } - if(ofs != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); - break; - default: goto unsupported_mst; - } - break; - - case VRAM_BANK_E: - mst = VRAMBankCnt & 7; - if(((VRAMBankCnt>>3)&3) != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); - switch(mst) { - case 0: //LCDC - vramConfiguration.banks[bank].purpose = VramConfiguration::LCDC; - MMU_vram_lcdc(bank); - break; - case 1: //ABG - vramConfiguration.banks[bank].purpose = VramConfiguration::ABG; - //MMU_vram_lcdc(bank); - MMU_vram_arm9(bank,VRAM_PAGE_ABG); - break; - case 2: //AOBJ - //MMU_vram_lcdc(bank); - vramConfiguration.banks[bank].purpose = VramConfiguration::AOBJ; - MMU_vram_arm9(bank,VRAM_PAGE_AOBJ); - break; - case 3: //texture palette - vramConfiguration.banks[bank].purpose = VramConfiguration::TEXPAL; - MMU.texInfo.texPalSlot[0] = MMU_vram_physical(vram_bank_info[bank].page_addr); - MMU.texInfo.texPalSlot[1] = MMU_vram_physical(vram_bank_info[bank].page_addr+1); - MMU.texInfo.texPalSlot[2] = MMU_vram_physical(vram_bank_info[bank].page_addr+2); - MMU.texInfo.texPalSlot[3] = MMU_vram_physical(vram_bank_info[bank].page_addr+3); - break; - case 4: //A BG extended palette - vramConfiguration.banks[bank].purpose = VramConfiguration::ABGEXTPAL; - MMU.ExtPal[0][0] = MMU_vram_physical(vram_bank_info[bank].page_addr); - MMU.ExtPal[0][1] = MMU.ExtPal[0][0] + ADDRESS_STEP_8KB; - MMU.ExtPal[0][2] = MMU.ExtPal[0][1] + ADDRESS_STEP_8KB; - MMU.ExtPal[0][3] = MMU.ExtPal[0][2] + ADDRESS_STEP_8KB; - break; - default: goto unsupported_mst; - } - break; - - case VRAM_BANK_F: - case VRAM_BANK_G: { - mst = VRAMBankCnt & 7; - ofs = (VRAMBankCnt>>3) & 3; - const int pageofslut[] = {0,1,4,5}; - const int pageofs = pageofslut[ofs]; - switch(mst) - { - case 0: //LCDC - vramConfiguration.banks[bank].purpose = VramConfiguration::LCDC; - MMU_vram_lcdc(bank); - if(ofs != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); - break; - case 1: //ABG - vramConfiguration.banks[bank].purpose = VramConfiguration::ABG; - //MMU_vram_lcdc(bank); - MMU_vram_arm9(bank,VRAM_PAGE_ABG+pageofs); - MMU_vram_arm9(bank,VRAM_PAGE_ABG+pageofs+2); //unexpected mirroring (required by spyro eternal night) - break; - case 2: //AOBJ - vramConfiguration.banks[bank].purpose = VramConfiguration::AOBJ; - //MMU_vram_lcdc(bank); - MMU_vram_arm9(bank,VRAM_PAGE_AOBJ+pageofs); - MMU_vram_arm9(bank,VRAM_PAGE_AOBJ+pageofs+2); //unexpected mirroring - I have no proof, but it is inferred from the ABG above - break; - case 3: //texture palette - vramConfiguration.banks[bank].purpose = VramConfiguration::TEXPAL; - MMU.texInfo.texPalSlot[pageofs] = MMU_vram_physical(vram_bank_info[bank].page_addr); - break; - case 4: //A BG extended palette - switch(ofs) { - case 0: - case 1: - vramConfiguration.banks[bank].purpose = VramConfiguration::ABGEXTPAL; - MMU.ExtPal[0][ofs*2] = MMU_vram_physical(vram_bank_info[bank].page_addr); - MMU.ExtPal[0][ofs*2+1] = MMU.ExtPal[0][ofs*2] + ADDRESS_STEP_8KB; - break; - default: - vramConfiguration.banks[bank].purpose = VramConfiguration::INVALID; - PROGINFO("Unsupported ofs setting %d for engine A bgextpal vram bank %c\n", ofs, 'A'+bank); - break; - } - break; - case 5: //A OBJ extended palette - vramConfiguration.banks[bank].purpose = VramConfiguration::AOBJEXTPAL; - MMU.ObjExtPal[0][0] = MMU_vram_physical(vram_bank_info[bank].page_addr); - MMU.ObjExtPal[0][1] = MMU.ObjExtPal[0][1] + ADDRESS_STEP_8KB; - if(ofs != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); - break; - default: goto unsupported_mst; - } - break; - } - - case VRAM_BANK_H: - mst = VRAMBankCnt & 3; - if(((VRAMBankCnt>>3)&3) != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); - switch(mst) - { - case 0: //LCDC - vramConfiguration.banks[bank].purpose = VramConfiguration::LCDC; - MMU_vram_lcdc(bank); - break; - case 1: //BBG - vramConfiguration.banks[bank].purpose = VramConfiguration::BBG; - //MMU_vram_lcdc(bank); - MMU_vram_arm9(bank,VRAM_PAGE_BBG); - MMU_vram_arm9(bank,VRAM_PAGE_BBG + 4); //unexpected mirroring - break; - case 2: //B BG extended palette - vramConfiguration.banks[bank].purpose = VramConfiguration::BBGEXTPAL; - MMU.ExtPal[1][0] = MMU_vram_physical(vram_bank_info[bank].page_addr); - MMU.ExtPal[1][1] = MMU.ExtPal[1][0] + ADDRESS_STEP_8KB; - MMU.ExtPal[1][2] = MMU.ExtPal[1][1] + ADDRESS_STEP_8KB; - MMU.ExtPal[1][3] = MMU.ExtPal[1][2] + ADDRESS_STEP_8KB; - break; - default: goto unsupported_mst; - } - break; - - case VRAM_BANK_I: - mst = VRAMBankCnt & 3; - if(((VRAMBankCnt>>3)&3) != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); - switch(mst) - { - case 0: //LCDC - vramConfiguration.banks[bank].purpose = VramConfiguration::LCDC; - MMU_vram_lcdc(bank); - break; - case 1: //BBG - vramConfiguration.banks[bank].purpose = VramConfiguration::BBG; - //MMU_vram_lcdc(bank); - MMU_vram_arm9(bank,VRAM_PAGE_BBG+2); - MMU_vram_arm9(bank,VRAM_PAGE_BBG+3); //unexpected mirroring - break; - case 2: //BOBJ - vramConfiguration.banks[bank].purpose = VramConfiguration::BOBJ; - //MMU_vram_lcdc(bank); - MMU_vram_arm9(bank,VRAM_PAGE_BOBJ); - break; - case 3: //B OBJ extended palette - vramConfiguration.banks[bank].purpose = VramConfiguration::BOBJEXTPAL; - MMU.ObjExtPal[1][0] = MMU_vram_physical(vram_bank_info[bank].page_addr); - MMU.ObjExtPal[1][1] = MMU.ObjExtPal[1][1] + ADDRESS_STEP_8KB; - break; - default: goto unsupported_mst; - } - break; - - - } //switch(bank) - - vramConfiguration.banks[bank].ofs = ofs; - - return; - -unsupported_mst: - vramConfiguration.banks[bank].purpose = VramConfiguration::INVALID; - PROGINFO("Unsupported mst setting %d for vram bank %c\n", mst, 'A'+bank); -} - -void MMU_VRAM_unmap_all() -{ - vramConfiguration.clear(); - - vram_arm7_map[0] = VRAM_PAGE_UNMAPPED; - vram_arm7_map[1] = VRAM_PAGE_UNMAPPED; - - for(int i=0;iNDS_3D_VramReconfigureSignal(); - } - - //------------------------------- - //set up arm9 mirrorings - //these are probably not entirely accurate. more study will be necessary. - //in general, we find that it is not uncommon at all for games to accidentally do this. - // - //being able to easily do these experiments was one of the primary motivations for this remake of the vram mapping system - - //see the "unexpected mirroring" comments above for some more mirroring - //so far "unexpected mirrorings" are tested by combining these games: - //despereaux - storybook subtitles - //NSMB - world map sub screen - //drill spirits EU - mission select (just for control purposes, as it doesnt use H or I) - //... - //note that the "unexpected mirroring" items above may at some point rely on being executed in a certain order. - //(sequentially A..I) - - const int types[] = {VRAM_PAGE_ABG,VRAM_PAGE_BBG,VRAM_PAGE_AOBJ,VRAM_PAGE_BOBJ}; - const int sizes[] = {32,8,16,8}; - for(int t=0;t<4;t++) - { - //the idea here is to pad out the mirrored space with copies of the mappable area, - //without respect to what is mapped within that mappable area. - //we hope that this is correct in all cases - //required for driller spirits in mission select (mapping is simple A,B,C,D to each purpose) - const int size = sizes[t]; - const int mask = size-1; - const int type = types[t]; - for(int i=size;i<128;i++) - { - const int page = type + i; - vram_arm9_map[page] = vram_arm9_map[type+(i&mask)]; - } - - //attempt #1: screen corruption in drill spirits EU - //it seems like these shouldnt pad out 128K banks (space beyond those should have remained unmapped) - //int mirrorMask = -1; - //int type = types[t]; - ////if(type==VRAM_PAGE_BOBJ) continue; - //if(type==VRAM_PAGE_AOBJ) continue; - //for(int i=0;i<128;i++) - //{ - // int page = type + i; - // if(vram_arm9_map[page] == VRAM_PAGE_UNMAPPED) - // { - // if(i==0) break; //can't mirror anything if theres nothing mapped! - // if(mirrorMask == -1) - // mirrorMask = i-1; - // vram_arm9_map[page] = vram_arm9_map[type+(i&mirrorMask)]; - // } - //} - } - - //------------------------------- -} - -////////////////////////////////////////////////////////////// -//end vram -////////////////////////////////////////////////////////////// - - - -void MMU_Init(void) { - int i; - - LOG("MMU init\n"); - - memset(&MMU, 0, sizeof(MMU_struct)); - - MMU.CART_ROM = MMU.UNUSED_RAM; - - for(i = 0x80; i<0xA0; ++i) - { - MMU_struct::MMU_MEM[0][i] = MMU.CART_ROM; - MMU_struct::MMU_MEM[1][i] = MMU.CART_ROM; - } - - MMU.DTCMRegion = 0x027C0000; - MMU.ITCMRegion = 0x00000000; - - IPC_FIFOinit(ARMCPU_ARM9); - IPC_FIFOinit(ARMCPU_ARM7); - GFX_PIPEclear(); - GFX_FIFOclear(); - DISP_FIFOinit(); - - mc_init(&MMU.fw, MC_TYPE_FLASH); /* init fw device */ - mc_alloc(&MMU.fw, NDS_FW_SIZE_V1); - MMU.fw.fp = NULL; - - // Init Backup Memory device, this should really be done when the rom is loaded - //mc_init(&MMU.bupmem, MC_TYPE_AUTODETECT); - //mc_alloc(&MMU.bupmem, 1); - //MMU.bupmem.fp = NULL; - rtcInit(); - addonsInit(); - if(Mic_Init() == FALSE) - INFO("Microphone init failed.\n"); - else - INFO("Microphone successfully inited.\n"); -} - -void MMU_DeInit(void) { - LOG("MMU deinit\n"); - if (MMU.fw.fp) - fclose(MMU.fw.fp); - mc_free(&MMU.fw); - //if (MMU.bupmem.fp) - // fclose(MMU.bupmem.fp); - //mc_free(&MMU.bupmem); - addonsClose(); - Mic_DeInit(); -} - -//Card rom & ram - -u32 rom_mask = 0; - -u32 DMASrc[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}}; -u32 DMADst[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}}; - -void MMU_Reset() -{ - memset(MMU.ARM9_DTCM, 0, sizeof(MMU.ARM9_DTCM)); - memset(MMU.ARM9_ITCM, 0, sizeof(MMU.ARM9_ITCM)); - memset(MMU.ARM9_LCD, 0, sizeof(MMU.ARM9_LCD)); - memset(MMU.ARM9_OAM, 0, sizeof(MMU.ARM9_OAM)); - memset(MMU.ARM9_REG, 0, sizeof(MMU.ARM9_REG)); - memset(MMU.ARM9_VMEM, 0, sizeof(MMU.ARM9_VMEM)); - memset(MMU.MAIN_MEM, 0, sizeof(MMU.MAIN_MEM)); - - memset(MMU.blank_memory, 0, sizeof(MMU.blank_memory)); - - memset(MMU.ARM7_ERAM, 0, sizeof(MMU.ARM7_ERAM)); - memset(MMU.ARM7_REG, 0, sizeof(MMU.ARM7_REG)); - memset(MMU.ARM7_WIRAM, 0, sizeof(MMU.ARM7_WIRAM)); - memset(MMU.SWIRAM, 0, sizeof(MMU.SWIRAM)); - - IPC_FIFOinit(ARMCPU_ARM9); - IPC_FIFOinit(ARMCPU_ARM7); - GFX_PIPEclear(); - GFX_FIFOclear(); - DISP_FIFOinit(); - - MMU.DTCMRegion = 0x027C0000; - MMU.ITCMRegion = 0x00000000; - - memset(MMU.timer, 0, sizeof(u16) * 2 * 4); - memset(MMU.timerMODE, 0, sizeof(s32) * 2 * 4); - memset(MMU.timerON, 0, sizeof(u32) * 2 * 4); - memset(MMU.timerRUN, 0, sizeof(u32) * 2 * 4); - memset(MMU.timerReload, 0, sizeof(u16) * 2 * 4); - - memset(MMU.reg_IME, 0, sizeof(u32) * 2); - memset(MMU.reg_IE, 0, sizeof(u32) * 2); - memset(MMU.reg_IF, 0, sizeof(u32) * 2); - - memset(MMU.DMAStartTime, 0, sizeof(u32) * 2 * 4); - memset(MMU.DMACycle, 0, sizeof(MMU.DMACycle)); - memset(MMU.DMACrt, 0, sizeof(u32) * 2 * 4); - memset(MMU.DMAing, 0, sizeof(BOOL) * 2 * 4); - memset(MMU.DMACompleted, 0, sizeof(BOOL) * 2 * 4); - - memset(MMU.dscard, 0, sizeof(nds_dscard) * 2); - - MMU.SPI_CNT = 0; - MMU.AUX_SPI_CNT = 0; - - // Enable the sound speakers - T1WriteWord(MMU.ARM7_REG, 0x304, 0x0001); - - MainScreen.offset = 0; - SubScreen.offset = 192; - - MMU_VRAM_unmap_all(); - - MMU.powerMan_CntReg = 0x00; - MMU.powerMan_CntRegWritten = FALSE; - MMU.powerMan_Reg[0] = 0x0B; - MMU.powerMan_Reg[1] = 0x00; - MMU.powerMan_Reg[2] = 0x01; - MMU.powerMan_Reg[3] = 0x00; - - rtcInit(); - partie = 1; - addonsReset(); - Mic_Reset(); - MMU.gfx3dCycles = 0; - - memset(MMU.dscard[ARMCPU_ARM9].command, 0, 8); - MMU.dscard[ARMCPU_ARM9].address = 0; - MMU.dscard[ARMCPU_ARM9].transfer_count = 0; - MMU.dscard[ARMCPU_ARM9].mode = CardMode_Normal; - - memset(MMU.dscard[ARMCPU_ARM7].command, 0, 8); - MMU.dscard[ARMCPU_ARM7].address = 0; - MMU.dscard[ARMCPU_ARM7].transfer_count = 0; - MMU.dscard[ARMCPU_ARM7].mode = CardMode_Normal; -} - -void MMU_setRom(u8 * rom, u32 mask) -{ - unsigned int i; - MMU.CART_ROM = rom; - MMU.CART_ROM_MASK = mask; - - for(i = 0x80; i<0xA0; ++i) - { - MMU_struct::MMU_MEM[0][i] = rom; - MMU_struct::MMU_MEM[1][i] = rom; - MMU_struct::MMU_MASK[0][i] = mask; - MMU_struct::MMU_MASK[1][i] = mask; - } - rom_mask = mask; -} - -void MMU_unsetRom() -{ - unsigned int i; - MMU.CART_ROM=MMU.UNUSED_RAM; - - for(i = 0x80; i<0xA0; ++i) - { - MMU_struct::MMU_MEM[0][i] = MMU.UNUSED_RAM; - MMU_struct::MMU_MEM[1][i] = MMU.UNUSED_RAM; - MMU_struct::MMU_MASK[0][i] = ROM_MASK; - MMU_struct::MMU_MASK[1][i] = ROM_MASK; - } - rom_mask = ROM_MASK; -} -char txt[80]; - -static void execsqrt() { - u32 ret; - u16 cnt = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B0); - - if (cnt&1) { - u64 v = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8); - ret = (u32)isqrt(v); - } else { - u32 v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8); - ret = (u32)isqrt(v); - } - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B4, 0); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B0, cnt | 0x8000); - - MMU.sqrtCycles = nds_timer + 26; - MMU.sqrtResult = ret; - MMU.sqrtCnt = (cnt & 0x7FFF); - MMU.sqrtRunning = TRUE; - NDS_Reschedule(); -} - -static void execdiv() { - u16 cnt = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x280); - s64 num,den; - s64 res,mod; - - switch(cnt&3) - { - case 0: - num = (s64) (s32) T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290); - den = (s64) (s32) T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298); - MMU.divCycles = nds_timer + 36; - break; - case 1: - case 3: //gbatek says this is same as mode 1 - num = (s64) T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290); - den = (s64) (s32) T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298); - MMU.divCycles = nds_timer + 68; - break; - case 2: - default: - num = (s64) T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290); - den = (s64) T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298); - MMU.divCycles = nds_timer + 68; - break; - } - - if(den==0) - { - res = ((num < 0) ? 1 : -1); - mod = num; - cnt |= 0x4000; - cnt &= 0x7FFF; - } - else - { - res = num / den; - mod = num % den; - cnt &= 0x3FFF; - } - - DIVLOG("DIV %08X%08X / %08X%08X = %08X%08X\r\n", (u32)(num>>32), (u32)num, - (u32)(den>>32), (u32)den, - (u32)(res>>32), (u32)res); - - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A0, 0); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A4, 0); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A8, 0); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2AC, 0); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x280, ((cnt & 0xBFFF) | 0x8000)); - - MMU.divResult = res; - MMU.divMod = mod; - MMU.divCnt = (cnt & 0x7FFF); - MMU.divRunning = TRUE; - NDS_Reschedule(); -} - -template -void FASTCALL MMU_writeToGCControl(u32 val) -{ - nds_dscard& card = MMU.dscard[PROCNUM]; - - if(!(val & 0x80000000)) - { - card.address = 0; - card.transfer_count = 0; - - val &= 0x7F7FFFFF; - T1WriteLong(MMU.MMU_MEM[PROCNUM][0x40], 0x1A4, val); - return; - } - - memcpy(&card.command[0], &MMU.MMU_MEM[PROCNUM][0x40][0x1A8], 8); - - switch (card.mode) - { - case CardMode_Normal: - break; - - case CardMode_KEY1: - { - // TODO - INFO("Cartridge: KEY1 mode unsupported.\n"); - - card.address = 0; - card.transfer_count = 0; - - val &= 0x7F7FFFFF; - T1WriteLong(MMU.MMU_MEM[PROCNUM][0x40], 0x1A4, val); - return; - } - break; - case CardMode_KEY2: - break; - } - - switch(card.command[0]) - { - // Dummy - case 0x9F: - { - card.address = 0; - card.transfer_count = 0x800; - } - break; - - // Nand Init - case 0x94: - { - card.address = 0; - card.transfer_count = 0x80; - } - break; - - // Nand Error? - case 0xD6: - { - card.address = 0; - card.transfer_count = 1; - } - break; - - // Data read - case 0x00: - case 0xB7: - { - card.address = (card.command[1] << 24) | (card.command[2] << 16) | (card.command[3] << 8) | card.command[4]; - card.transfer_count = 0x80; - } - break; - - // Get ROM chip ID - case 0x90: - case 0xB8: - { - card.address = 0; - card.transfer_count = 1; - } - break; - - // Switch to KEY1 mode - case 0x3C: - { - card.address = 0; - card.transfer_count = 0; - card.mode = CardMode_KEY1; - } - break; - - default: - { - LOG("WRITE CARD command: %02X%02X%02X%02X%02X%02X%02X%02X\t", - card.command[0], card.command[1], card.command[2], card.command[3], - card.command[4], card.command[5], card.command[6], card.command[7]); - LOG("FROM: %08X\n", (PROCNUM ? NDS_ARM7:NDS_ARM9).instruct_adr); - - card.address = 0; - card.transfer_count = 0; - } - break; - } - - if(card.transfer_count == 0) - { - val &= 0x7F7FFFFF; - T1WriteLong(MMU.MMU_MEM[PROCNUM][0x40], 0x1A4, val); - return; - } - - val |= 0x00800000; - T1WriteLong(MMU.MMU_MEM[PROCNUM][0x40], 0x1A4, val); - - // Launch DMA if start flag was set to "DS Cart" - if(MMU.DMAStartTime[PROCNUM][0] == EDMAMode_Card) MMU_doDMA(0); - if(MMU.DMAStartTime[PROCNUM][1] == EDMAMode_Card) MMU_doDMA(1); - if(MMU.DMAStartTime[PROCNUM][2] == EDMAMode_Card) MMU_doDMA(2); - if(MMU.DMAStartTime[PROCNUM][3] == EDMAMode_Card) MMU_doDMA(3); -} - -template -u32 MMU_readFromGC() -{ - nds_dscard& card = MMU.dscard[PROCNUM]; - u32 val = 0; - - if(card.transfer_count == 0) - return 0; - - switch(card.command[0]) - { - // Dummy - case 0x9F: - { - val = 0xFFFFFFFF; - } - break; - - // Nand Init? - case 0x94: - { - val = 0; //Unsure what to return here so return 0 for now - } - break; - - // Nand Error? - case 0xD6: - { - val = 0x80; //0x80 == ok? - } - break; - - // Data read - case 0x00: - case 0xB7: - { - // TODO: prevent read if the address is out of range - // Make sure any reads below 0x8000 redirect to 0x8000+(adr&0x1FF) as on real cart - if((card.command[0] == 0xB7) && (card.address < 0x8000)) - { - LOG("Read below 0x8000 (0x%04X) from: ARM%s %08X\n", - card.address, (PROCNUM ? "7":"9"), (PROCNUM ? NDS_ARM7:NDS_ARM9).instruct_adr); - - card.address = (0x8000 + (card.address&0x1FF)); - } - val = T1ReadLong(MMU.CART_ROM, card.address & MMU.CART_ROM_MASK); - } - break; - - // Get ROM chip ID - case 0x90: - case 0xB8: - { - // Note: the BIOS stores the chip ID in main memory - // Most games continuously compare the chip ID with - // the value in memory, probably to know if the card - // was removed. - // As DeSmuME boots directly from the game, the chip - // ID in main mem is zero and this value needs to be - // zero too. - val = 0x00000000; - } - break; - - // Switch to KEY1 mode - case 0x3C: - { - val = 0xFFFFFFFF; - } - break; - - default: - LOG("READ CARD command: %02X%02X%02X%02X%02X%02X%02X%02X\t", - card.command[0], card.command[1], card.command[2], card.command[3], - card.command[4], card.command[5], card.command[6], card.command[7]); - LOG("FROM: %08X\n", (PROCNUM ? NDS_ARM7:NDS_ARM9).instruct_adr); - break; - - } - - card.address += 4; // increment address - - card.transfer_count--; // update transfer counter - if(card.transfer_count) // if transfer is not ended - return val; // return data - - // transfer is done - T1WriteLong(MMU.MMU_MEM[PROCNUM][0x40], 0x1A4, - T1ReadLong(MMU.MMU_MEM[PROCNUM][0x40], 0x1A4) & 0x7F7FFFFF); - - // if needed, throw irq for the end of transfer - if(MMU.AUX_SPI_CNT & 0x4000) - NDS_makeInt(PROCNUM, 19); - - return val; -} - -template -void FASTCALL MMU_doDMA(u32 num) -{ -#ifdef USE_GEOMETRY_FIFO_EMULATION - if (MMU.DMAStartTime[PROCNUM][num] == EDMAMode_GXFifo) - if (MMU.DMACompleted[PROCNUM][num]) return; -#endif - u32 src = DMASrc[PROCNUM][num]; - u32 dst = DMADst[PROCNUM][num]; - u32 taille = 0; - bool paused = false; - -#ifdef USE_GEOMETRY_FIFO_EMULATION - if (MMU.DMAStartTime[PROCNUM][num]== EDMAMode_GXFifo) - { - if (gxFIFO.size > 127) return; - } -#endif - - if(src==dst) - { - T1WriteLong(MMU.MMU_MEM[PROCNUM][0x40], 0xB8 + (0xC*num), T1ReadLong(MMU.MMU_MEM[PROCNUM][0x40], 0xB8 + (0xC*num)) & 0x7FFFFFFF); - return; - } - - if((!(MMU.DMACrt[PROCNUM][num]&(1<<31)))&&(!(MMU.DMACrt[PROCNUM][num]&(1<<25)))) - { /* not enabled and not to be repeated */ - MMU.DMAStartTime[PROCNUM][num] = 0; - MMU.DMACycle[PROCNUM][num] = 0; - //MMU.DMAing[PROCNUM][num] = FALSE; - return; - } - - //word count - taille = (MMU.DMACrt[PROCNUM][num]&0x1FFFFF); - if(taille == 0) taille = 0x200000; //according to gbatek.. - - //for main memory display fifo dmas, check for normal conditions and then dma all 128 bytes at once - //(theyll get sent to the fifo, which can handle more than it ought to be able to) - if ((MMU.DMAStartTime[PROCNUM][num]==EDMAMode_MemDisplay) && - (taille==4) && - (((MMU.DMACrt[PROCNUM][num]>>26)&1) == 1)) - taille = 128; - - if(MMU.DMAStartTime[PROCNUM][num] == EDMAMode_Card) - taille *= 0x80; - - MMU.DMACycle[PROCNUM][num] = taille + nds_timer; //TODO - surely this is a gross simplification - - MMU.DMAing[PROCNUM][num] = TRUE; - MMU.CheckDMAs |= (1<<(num+(PROCNUM<<2))); - - DMALOG("ARM%c: DMA%d run src=%08X dst=%08X start=%d taille=%d repeat=%s %08X\r\n", - (PROCNUM==0)?'9':'7', num, src, dst, MMU.DMAStartTime[PROCNUM][num], taille, - (MMU.DMACrt[PROCNUM][num]&(1<<25))?"on":"off",MMU.DMACrt[PROCNUM][num]); - -#ifndef USE_GEOMETRY_FIFO_EMULATION - if(!(MMU.DMACrt[PROCNUM][num]&(1<<25))) - MMU.DMAStartTime[PROCNUM][num] = 0; -#endif - - NDS_RescheduleDMA(); - - // transfer - { - u32 i=0; - // 32 bit or 16 bit transfer ? - int sz = ((MMU.DMACrt[PROCNUM][num]>>26)&1)? 4 : 2; - int dstinc,srcinc; - int u=(MMU.DMACrt[PROCNUM][num]>>21); - switch(u & 0x3) { - case 0 : dstinc = sz; break; - case 1 : dstinc = -sz; break; - case 2 : dstinc = 0; break; - case 3 : dstinc = sz; break; //reload - default: - return; - } - switch((u >> 2)&0x3) { - case 0 : srcinc = sz; break; - case 1 : srcinc = -sz; break; - case 2 : srcinc = 0; break; - case 3 : // reserved - return; - default: - return; - } - - //if these do not use MMU_AT_DMA and the corresponding code in the read/write routines, - //then danny phantom title screen will be filled with a garbage char which is made by - //dmaing from 0x00000000 to 0x06000000 - if ((MMU.DMACrt[PROCNUM][num]>>26)&1) - for(; i < taille; ++i) - { -#ifdef USE_GEOMETRY_FIFO_EMULATION - if (MMU.DMAStartTime[PROCNUM][num] == EDMAMode_GXFifo) - { - if ( gxFIFO.size > 255 ) - { - if (i >= taille) break; - - paused = true; - MMU.DMACrt[PROCNUM][num] &= 0xFFE00000; - MMU.DMACrt[PROCNUM][num] |= ((taille-i) & 0x1FFFFF); - MMU.DMAing[PROCNUM][num] = FALSE; - MMU.DMACycle[PROCNUM][num] = nds_timer+1; - break; - } - } -#endif - _MMU_write32(dst, _MMU_read32(src)); - dst += dstinc; - src += srcinc; - } - else - for(; i < taille; ++i) - { - _MMU_write16(dst, _MMU_read16(src)); - dst += dstinc; - src += srcinc; - } - - //write back the addresses - DMASrc[PROCNUM][num] = src; - if((u & 0x3)!=3) //but dont write back dst if we were supposed to reload - DMADst[PROCNUM][num] = dst; - - //this is probably not the best place to do it, but the dma code in ndssystem is so bad i didnt want to touch it - //until it all gets rewritten. so this is here as a reminder, at least. - //(there is no proof for this code, but it is reasonable) - T1WriteLong(MMU.MMU_MEM[PROCNUM][0x40], 0xB0+12*num, DMASrc[PROCNUM][num]); - T1WriteLong(MMU.MMU_MEM[PROCNUM][0x40], 0xB4+12*num, DMADst[PROCNUM][num]); - - if (!paused) - MMU.DMACompleted[PROCNUM][num] = true; - } -} - -#ifdef MMU_ENABLE_ACL - -INLINE void check_access(u32 adr, u32 access) { - /* every other mode: sys */ - access |= 1; - if ((NDS_ARM9.CPSR.val & 0x1F) == 0x10) { - /* is user mode access */ - access ^= 1 ; - } - if (armcp15_isAccessAllowed((armcp15_t *)NDS_ARM9.coproc[15],adr,access)==FALSE) { - execute = FALSE ; - } -} -INLINE void check_access_write(u32 adr) { - u32 access = CP15_ACCESS_WRITE; - check_access(adr, access) -} - -u8 FASTCALL MMU_read8_acl(u32 proc, u32 adr, u32 access) -{ - /* on arm9 we need to check the MPU regions */ - if (proc == ARMCPU_ARM9) - check_access(u32 adr, u32 access); - return MMU_read8(proc,adr); -} -u16 FASTCALL MMU_read16_acl(u32 proc, u32 adr, u32 access) -{ - /* on arm9 we need to check the MPU regions */ - if (proc == ARMCPU_ARM9) - check_access(u32 adr, u32 access); - return MMU_read16(proc,adr); -} -u32 FASTCALL MMU_read32_acl(u32 proc, u32 adr, u32 access) -{ - /* on arm9 we need to check the MPU regions */ - if (proc == ARMCPU_ARM9) - check_access(u32 adr, u32 access); - return MMU_read32(proc,adr); -} - -void FASTCALL MMU_write8_acl(u32 proc, u32 adr, u8 val) -{ - /* check MPU region on ARM9 */ - if (proc == ARMCPU_ARM9) - check_access_write(adr); - MMU_write8(proc,adr,val); -} -void FASTCALL MMU_write16_acl(u32 proc, u32 adr, u16 val) -{ - /* check MPU region on ARM9 */ - if (proc == ARMCPU_ARM9) - check_access_write(adr); - MMU_write16(proc,adr,val) ; -} -void FASTCALL MMU_write32_acl(u32 proc, u32 adr, u32 val) -{ - /* check MPU region on ARM9 */ - if (proc == ARMCPU_ARM9) - check_access_write(adr); - MMU_write32(proc,adr,val) ; -} -#endif - -//a stub for memory profiler, if we choose to re-add it -#define PROFILE_PREFETCH 1 -#define profile_memory_access(X,Y,Z) - - -static INLINE void MMU_IPCSync(u8 proc, u32 val) -{ - //INFO("IPC%s sync 0x%04X (0x%02X|%02X)\n", proc?"7":"9", val, val >> 8, val & 0xFF); - u32 sync_l = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x180) & 0xFFFF; - u32 sync_r = T1ReadLong(MMU.MMU_MEM[proc^1][0x40], 0x180) & 0xFFFF; - - sync_l = ( sync_l & 0x000F ) | ( val & 0x0F00 ); - sync_r = ( sync_r & 0x6F00 ) | ( (val >> 8) & 0x000F ); - - sync_l |= val & 0x6000; - - T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x180, sync_l); - T1WriteLong(MMU.MMU_MEM[proc^1][0x40], 0x180, sync_r); - - if ((sync_l & 0x2000) && (sync_r & 0x4000)) - setIF(proc^1, ( 1 << 16 )); -} - -static INLINE u16 read_timer(int proc, int timerIndex) -{ - //chained timers are always up to date - if(MMU.timerMODE[proc][timerIndex] == 0xFFFF) - return MMU.timer[proc][timerIndex]; - - //sometimes a timer will be read when it is not enabled. - //we should have the value cached - if(!MMU.timerON[proc][timerIndex]) - return MMU.timer[proc][timerIndex]; - - //for unchained timers, we do not keep the timer up to date. its value will need to be calculated here - s32 diff = (s32)(nds.timerCycle[proc][timerIndex] - nds_timer); - assert(diff>=0); - if(diff<0) - printf("NEW EMULOOP BAD NEWS PLEASE REPORT: TIME READ DIFF < 0 (%d) (%d) (%d)\n",diff,timerIndex,MMU.timerMODE[proc][timerIndex]); - - s32 units = diff / (1<65536) { - printf("NEW EMULOOP BAD NEWS PLEASE REPORT: UNITS %d:%d = %d\n",proc,timerIndex,units); - ret = 0; - } - else ret = 65535 - units; - - return ret; -} - -static INLINE void write_timer(int proc, int timerIndex, u16 val) -{ -#if 0 - int mask = ((val&0x80)>>7) << timerIndex; - MMU.CheckTimers = (MMU.CheckTimers & (~mask)) | mask; -#endif - - if(val&0x80) - MMU.timer[proc][timerIndex] = MMU.timerReload[proc][timerIndex]; - else - { - if(MMU.timerON[proc][timerIndex]) - //read the timer value one last time - MMU.timer[proc][timerIndex] = read_timer(proc,timerIndex); - } - - MMU.timerON[proc][timerIndex] = val & 0x80; - - switch(val&7) - { - case 0 : - MMU.timerMODE[proc][timerIndex] = 0+1; - break; - case 1 : - MMU.timerMODE[proc][timerIndex] = 6+1; - break; - case 2 : - MMU.timerMODE[proc][timerIndex] = 8+1; - break; - case 3 : - MMU.timerMODE[proc][timerIndex] = 10+1; - break; - default : - MMU.timerMODE[proc][timerIndex] = 0xFFFF; - break; - } - - int remain = 65536 - MMU.timerReload[proc][timerIndex]; - nds.timerCycle[proc][timerIndex] = nds_timer + (remain< static INLINE void write_dma_hictrl(const int dmanum, const u16 val) -{ - u32 baseAddr = 0xB0 + dmanum*12; - - //write this control value - T1WriteWord(MMU.MMU_MEM[proc][0x40], baseAddr+10, val); - - //read back the src and dst addr - DMASrc[proc][dmanum] = T1ReadLong(MMU.MMU_MEM[proc][0x40], baseAddr); - DMADst[proc][dmanum] = T1ReadLong(MMU.MMU_MEM[proc][0x40], baseAddr+4); - - //analyze the control value - u32 v = T1ReadLong(MMU.MMU_MEM[proc][0x40], baseAddr+8); - if(proc==ARMCPU_ARM9) MMU.DMAStartTime[proc][dmanum] = (v>>27) & 0x7; - else { - static const EDMAMode lookup[] = {EDMAMode_Immediate,EDMAMode_VBlank,EDMAMode_Card,EDMAMode7_Wifi}; - MMU.DMAStartTime[proc][dmanum] = lookup[(v>>28) & 0x3]; - if(MMU.DMAStartTime[proc][dmanum] == EDMAMode7_Wifi && (dmanum==1 || dmanum==3)) - MMU.DMAStartTime[proc][dmanum] = EDMAMode7_GBASlot; - } - MMU.DMACrt[proc][dmanum] = v; - MMU.DMACompleted[proc][dmanum] = false; - MMU.DMAing[proc][dmanum] = false; - -#ifdef USE_GEOMETRY_FIFO_EMULATION - if(MMU.DMAStartTime[proc][dmanum] == EDMAMode_Immediate) - { - MMU_doDMA(dmanum); - } - - if (MMU.DMAStartTime[proc][dmanum] == EDMAMode_GXFifo) - { -#ifdef _3DINFO - INFO("ARM%c: DMA%d control src=0x%08X dst=0x%08X %s (gxFIFO tail %03i)\n", (proc==0)?'9':'7', dmanum, DMASrc[proc][dmanum], DMADst[proc][dmanum], ((val>>15)&0x01)?"ON":"OFF", gxFIFO.tail); -#endif - MMU_doDMA(dmanum); - } -#else - if(MMU.DMAStartTime[proc][dmanum] == EDMAMode_Immediate - || MMU.DMAStartTime[proc][dmanum] == EDMAMode_GXFifo) - { - MMU_doDMA(dmanum); - } -#endif - - DMALOG("ARM%c: DMA%d control src=0x%08X dst=0x%08X %s\n", (proc==0)?'9':'7', dmanum, DMASrc[proc][dmanum], DMADst[proc][dmanum], ((val>>15)&0x01)?"ON":"OFF"); - - NDS_RescheduleDMA(); -} - -static INLINE void write_auxspicnt(const int proc, const int size, const int adr, const int val) -{ - //why val==0 to reset? is it a particular bit? its not bit 6... - switch(size) { - case 16: - MMU.AUX_SPI_CNT = val; - if (val == 0) MMU_new.backupDevice.reset_command(); - break; - case 8: - switch(adr) { - case 0: - T1WriteByte((u8*)&MMU.AUX_SPI_CNT,0,val); - if (val == 0) MMU_new.backupDevice.reset_command(); - break; - case 1: - T1WriteByte((u8*)&MMU.AUX_SPI_CNT,1,val); - break; - } - } -} - - -//================================================================================================== ARM9 * -//========================================================================================================= -//========================================================================================================= -//================================================= MMU write 08 -void FASTCALL _MMU_ARM9_write08(u32 adr, u8 val) -{ - mmu_log_debug_ARM9(adr, "(write08) %0x%X", val); - - if(adr < 0x02000000) - { - T1WriteByte(MMU.ARM9_ITCM, adr&0x7FFF, val); - return; - } - - if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) - { - addon.write08(adr, val); - return; - } - - adr &= 0x0FFFFFFF; - - if (adr >> 24 == 4) - { - switch(adr) - { - case REG_DISPA_DISP3DCNT: - { - u32 &disp3dcnt = MainScreen.gpu->dispx_st->dispA_DISP3DCNT.val; - disp3dcnt = (disp3dcnt&0xFF00) | val; - gfx3d_Control(disp3dcnt); - break; - } - case REG_DISPA_DISP3DCNT+1: - { - u32 &disp3dcnt = MainScreen.gpu->dispx_st->dispA_DISP3DCNT.val; - val = (val & ~0x30) | (~val & ((disp3dcnt>>8) & 0x30)); // bits 12,13 are ack bits - disp3dcnt = (disp3dcnt&0x00FF) | (val<<8); - gfx3d_Control(disp3dcnt); - break; - } - - case REG_DISPA_WIN0H: - GPU_setWIN0_H1(MainScreen.gpu, val); - break ; - case REG_DISPA_WIN0H+1: - GPU_setWIN0_H0 (MainScreen.gpu, val); - break ; - case REG_DISPA_WIN1H: - GPU_setWIN1_H1 (MainScreen.gpu,val); - break ; - case REG_DISPA_WIN1H+1: - GPU_setWIN1_H0 (MainScreen.gpu,val); - break ; - - case REG_DISPB_WIN0H: - GPU_setWIN0_H1(SubScreen.gpu,val); - break ; - case REG_DISPB_WIN0H+1: - GPU_setWIN0_H0(SubScreen.gpu,val); - break ; - case REG_DISPB_WIN1H: - GPU_setWIN1_H1(SubScreen.gpu,val); - break ; - case REG_DISPB_WIN1H+1: - GPU_setWIN1_H0(SubScreen.gpu,val); - break ; - - case REG_DISPA_WIN0V: - GPU_setWIN0_V1(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WIN0V+1: - GPU_setWIN0_V0(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WIN1V: - GPU_setWIN1_V1(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WIN1V+1: - GPU_setWIN1_V0(MainScreen.gpu,val) ; - break ; - - case REG_DISPB_WIN0V: - GPU_setWIN0_V1(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WIN0V+1: - GPU_setWIN0_V0(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WIN1V: - GPU_setWIN1_V1(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WIN1V+1: - GPU_setWIN1_V0(SubScreen.gpu,val) ; - break ; - - case REG_DISPA_WININ: - GPU_setWININ0(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WININ+1: - GPU_setWININ1(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WINOUT: - GPU_setWINOUT(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WINOUT+1: - GPU_setWINOBJ(MainScreen.gpu,val); - break ; - - case REG_DISPB_WININ: - GPU_setWININ0(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WININ+1: - GPU_setWININ1(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WINOUT: - GPU_setWINOUT(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WINOUT+1: - GPU_setWINOBJ(SubScreen.gpu,val) ; - break ; - - case REG_DISPA_BLDCNT: - GPU_setBLDCNT_HIGH(MainScreen.gpu,val); - break; - case REG_DISPA_BLDCNT+1: - GPU_setBLDCNT_LOW (MainScreen.gpu,val); - break; - - case REG_DISPB_BLDCNT: - GPU_setBLDCNT_HIGH (SubScreen.gpu,val); - break; - case REG_DISPB_BLDCNT+1: - GPU_setBLDCNT_LOW (SubScreen.gpu,val); - break; - - case REG_DISPA_BLDALPHA: - MainScreen.gpu->setBLDALPHA_EVB(val); - break; - case REG_DISPA_BLDALPHA+1: - MainScreen.gpu->setBLDALPHA_EVA(val); - break; - - case REG_DISPB_BLDALPHA: - SubScreen.gpu->setBLDALPHA_EVB(val); - break; - case REG_DISPB_BLDALPHA+1: - SubScreen.gpu->setBLDALPHA_EVA(val); - break; - - case REG_DISPA_BLDY: - GPU_setBLDY_EVY(MainScreen.gpu,val) ; - break ; - case REG_DISPB_BLDY: - GPU_setBLDY_EVY(SubScreen.gpu,val) ; - break; - - case REG_AUXSPICNT: - write_auxspicnt(9,8,0,val); - return; - case REG_AUXSPICNT+1: - write_auxspicnt(9,8,1,val); - return; - - - case 0x4000247: - /* Update WRAMSTAT at the ARM7 side */ - T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x241, val); - break; - - case REG_VRAMCNTA: - case REG_VRAMCNTB: - case REG_VRAMCNTC: - case REG_VRAMCNTD: - case REG_VRAMCNTE: - case REG_VRAMCNTF: - case REG_VRAMCNTG: - case REG_VRAMCNTH: - case REG_VRAMCNTI: - MMU_VRAMmapControl(adr-REG_VRAMCNTA, val); - break; - case REG_DISPA_DISPMMEMFIFO: - { - DISP_FIFOsend(val); - return; - } - #ifdef LOG_CARD - case 0x040001A0 : /* TODO (clear): ??? */ - case 0x040001A1 : - case 0x040001A2 : - case 0x040001A8 : - case 0x040001A9 : - case 0x040001AA : - case 0x040001AB : - case 0x040001AC : - case 0x040001AD : - case 0x040001AE : - case 0x040001AF : - LOG("%08X : %02X\r\n", adr, val); - #endif - } - - MMU.MMU_MEM[ARMCPU_ARM9][0x40][adr&MMU.MMU_MASK[ARMCPU_ARM9][adr>>20]]=val; - return; - } - - bool unmapped; - adr = MMU_LCDmap(adr, unmapped); - if(unmapped) return; - - // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [shash] - MMU.MMU_MEM[ARMCPU_ARM9][adr>>20][adr&MMU.MMU_MASK[ARMCPU_ARM9][adr>>20]]=val; -} - -//================================================= MMU ARM9 write 16 -void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val) -{ - mmu_log_debug_ARM9(adr, "(write16) %0x%X", val); - - if (adr < 0x02000000) - { - T1WriteWord(MMU.ARM9_ITCM, adr&0x7FFF, val); - return; - } - - if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) - { - addon.write16(adr, val); - return; - } - - adr &= 0x0FFFFFFF; - - if((adr >> 24) == 4) - { - switch (adr >> 4) - { - //toon table - case 0x0400038: - case 0x0400039: - case 0x040003A: - case 0x040003B: - ((u16 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF)>>1] = val; - gfx3d_UpdateToonTable((adr & 0x3F) >> 1, val); - return; - } - // Address is an IO register - switch(adr) - { - case REG_DISPA_BG2XL: MainScreen.gpu->setAffineStartWord(2,0,val,0); break; - case REG_DISPA_BG2XH: MainScreen.gpu->setAffineStartWord(2,0,val,1); break; - case REG_DISPA_BG2YL: MainScreen.gpu->setAffineStartWord(2,1,val,0); break; - case REG_DISPA_BG2YH: MainScreen.gpu->setAffineStartWord(2,1,val,1); break; - case REG_DISPA_BG3XL: MainScreen.gpu->setAffineStartWord(3,0,val,0); break; - case REG_DISPA_BG3XH: MainScreen.gpu->setAffineStartWord(3,0,val,1); break; - case REG_DISPA_BG3YL: MainScreen.gpu->setAffineStartWord(3,1,val,0); break; - case REG_DISPA_BG3YH: MainScreen.gpu->setAffineStartWord(3,1,val,1); break; - case REG_DISPB_BG2XL: SubScreen.gpu->setAffineStartWord(2,0,val,0); break; - case REG_DISPB_BG2XH: SubScreen.gpu->setAffineStartWord(2,0,val,1); break; - case REG_DISPB_BG2YL: SubScreen.gpu->setAffineStartWord(2,1,val,0); break; - case REG_DISPB_BG2YH: SubScreen.gpu->setAffineStartWord(2,1,val,1); break; - case REG_DISPB_BG3XL: SubScreen.gpu->setAffineStartWord(3,0,val,0); break; - case REG_DISPB_BG3XH: SubScreen.gpu->setAffineStartWord(3,0,val,1); break; - case REG_DISPB_BG3YL: SubScreen.gpu->setAffineStartWord(3,1,val,0); break; - case REG_DISPB_BG3YH: SubScreen.gpu->setAffineStartWord(3,1,val,1); break; - - case REG_DISPA_DISP3DCNT: - { - u32 &disp3dcnt = MainScreen.gpu->dispx_st->dispA_DISP3DCNT.val; - val = (val & ~0x3000) | (~val & (disp3dcnt & 0x3000)); // bits 12,13 are ack bits - disp3dcnt = val; - gfx3d_Control(val); - break; - } - - // Alpha test reference value - Parameters:1 - case 0x04000340: - { - ((u16 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x340>>1] = val; - gfx3d_glAlphaFunc(val); - return; - } - // Clear background color setup - Parameters:2 - case 0x04000350: - { - ((u16 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x350>>1] = val; - gfx3d_glClearColor(val); - return; - } - // Clear background depth setup - Parameters:2 - case 0x04000354: - { - ((u16 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x354>>1] = val; - gfx3d_glClearDepth(val); - return; - } - // Fog Color - Parameters:4b - case 0x04000358: - { - ((u16 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x358>>1] = val; - gfx3d_glFogColor(val); - return; - } - case 0x0400035C: - { - ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x35C>>1] = val; - gfx3d_glFogOffset(val); - return; - } - - case REG_DISPA_BLDCNT: - GPU_setBLDCNT(MainScreen.gpu,val) ; - break ; - case REG_DISPB_BLDCNT: - GPU_setBLDCNT(SubScreen.gpu,val) ; - break ; - case REG_DISPA_BLDALPHA: - MainScreen.gpu->setBLDALPHA(val); - break ; - case REG_DISPB_BLDALPHA: - SubScreen.gpu->setBLDALPHA(val); - break ; - case REG_DISPA_BLDY: - GPU_setBLDY_EVY(MainScreen.gpu,val) ; - break ; - case REG_DISPB_BLDY: - GPU_setBLDY_EVY(SubScreen.gpu,val) ; - break; - case REG_DISPA_MASTERBRIGHT: - GPU_setMasterBrightness (MainScreen.gpu, val); - break; - /* - case REG_DISPA_MOSAIC: - GPU_setMOSAIC(MainScreen.gpu,val) ; - break ; - case REG_DISPB_MOSAIC: - GPU_setMOSAIC(SubScreen.gpu,val) ; - break ; - */ - case REG_DISPA_BG0HOFS: - GPU_setBGxHOFS(0, MainScreen.gpu, val); - break; - case REG_DISPA_BG0VOFS: - GPU_setBGxVOFS(0, MainScreen.gpu, val); - break; - case REG_DISPA_BG1HOFS: - GPU_setBGxHOFS(1, MainScreen.gpu, val); - break; - case REG_DISPA_BG1VOFS: - GPU_setBGxVOFS(1, MainScreen.gpu, val); - break; - case REG_DISPA_BG2HOFS: - GPU_setBGxHOFS(2, MainScreen.gpu, val); - break; - case REG_DISPA_BG2VOFS: - GPU_setBGxVOFS(2, MainScreen.gpu, val); - break; - case REG_DISPA_BG3HOFS: - GPU_setBGxHOFS(3, MainScreen.gpu, val); - break; - case REG_DISPA_BG3VOFS: - GPU_setBGxVOFS(3, MainScreen.gpu, val); - break; - - case REG_DISPA_WIN0H: - GPU_setWIN0_H (MainScreen.gpu,val) ; - break ; - case REG_DISPA_WIN1H: - GPU_setWIN1_H(MainScreen.gpu,val) ; - break ; - case REG_DISPB_WIN0H: - GPU_setWIN0_H(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WIN1H: - GPU_setWIN1_H(SubScreen.gpu,val) ; - break ; - case REG_DISPA_WIN0V: - GPU_setWIN0_V(MainScreen.gpu,val) ; - break ; - case REG_DISPA_WIN1V: - GPU_setWIN1_V(MainScreen.gpu,val) ; - break ; - case REG_DISPB_WIN0V: - GPU_setWIN0_V(SubScreen.gpu,val) ; - break ; - case REG_DISPB_WIN1V: - GPU_setWIN1_V(SubScreen.gpu,val) ; - break ; - case REG_DISPA_WININ: - GPU_setWININ(MainScreen.gpu, val) ; - break ; - case REG_DISPA_WINOUT: - GPU_setWINOUT16(MainScreen.gpu, val) ; - break ; - - case REG_DISPB_BG0HOFS: - GPU_setBGxHOFS(0, SubScreen.gpu, val); - break; - case REG_DISPB_BG0VOFS: - GPU_setBGxVOFS(0, SubScreen.gpu, val); - break; - case REG_DISPB_BG1HOFS: - GPU_setBGxHOFS(1, SubScreen.gpu, val); - break; - case REG_DISPB_BG1VOFS: - GPU_setBGxVOFS(1, SubScreen.gpu, val); - break; - case REG_DISPB_BG2HOFS: - GPU_setBGxHOFS(2, SubScreen.gpu, val); - break; - case REG_DISPB_BG2VOFS: - GPU_setBGxVOFS(2, SubScreen.gpu, val); - break; - case REG_DISPB_BG3HOFS: - GPU_setBGxHOFS(3, SubScreen.gpu, val); - break; - case REG_DISPB_BG3VOFS: - GPU_setBGxVOFS(3, SubScreen.gpu, val); - break; - case REG_DISPB_WININ: - GPU_setWININ(SubScreen.gpu, val) ; - break ; - case REG_DISPB_WINOUT: - GPU_setWINOUT16(SubScreen.gpu, val) ; - break ; - - case REG_DISPB_MASTERBRIGHT: - GPU_setMasterBrightness (SubScreen.gpu, val); - break; - - case REG_POWCNT1 : - { -// TODO: make this later -#if 0 - u8 _LCD = (val) & 0x01; - u8 _2DEngineA = (val>>1) & 0x01; - u8 _2DEngineB = (val>>9) & 0x01; - u8 _3DRender = (val>>2) & 0x01; - u8 _3DGeometry = (val>>3) & 0x01; -#endif - if(val & (1<<15)) - { - //LOG("Main core on top\n"); - MainScreen.offset = 0; - SubScreen.offset = 192; - } - else - { - //LOG("Main core on bottom\n"); - MainScreen.offset = 192; - SubScreen.offset = 0; - } - - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x304, val); - } - - return; - - case REG_EXMEMCNT: - { - u16 oldval = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x204); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x204, val); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x204, (val & 0xFF80) | (oldval & 0x7F)); - return; - } - - case REG_AUXSPICNT: - write_auxspicnt(9,16,0,val); - return; - - case REG_AUXSPIDATA: - if(val!=0) - MMU.AUX_SPI_CMD = val & 0xFF; - - //T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU.bupmem, val)); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, MMU_new.backupDevice.data_command((u8)val)); - return; - - case REG_DISPA_BG0CNT : - //GPULOG("MAIN BG0 SETPROP 16B %08X\r\n", val); - GPU_setBGProp(MainScreen.gpu, 0, val); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x8, val); - return; - case REG_DISPA_BG1CNT : - //GPULOG("MAIN BG1 SETPROP 16B %08X\r\n", val); - GPU_setBGProp(MainScreen.gpu, 1, val); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xA, val); - return; - case REG_DISPA_BG2CNT : - //GPULOG("MAIN BG2 SETPROP 16B %08X\r\n", val); - GPU_setBGProp(MainScreen.gpu, 2, val); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xC, val); - return; - case REG_DISPA_BG3CNT : - //GPULOG("MAIN BG3 SETPROP 16B %08X\r\n", val); - GPU_setBGProp(MainScreen.gpu, 3, val); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xE, val); - return; - case REG_DISPB_BG0CNT : - //GPULOG("SUB BG0 SETPROP 16B %08X\r\n", val); - GPU_setBGProp(SubScreen.gpu, 0, val); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1008, val); - return; - case REG_DISPB_BG1CNT : - //GPULOG("SUB BG1 SETPROP 16B %08X\r\n", val); - GPU_setBGProp(SubScreen.gpu, 1, val); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x100A, val); - return; - case REG_DISPB_BG2CNT : - //GPULOG("SUB BG2 SETPROP 16B %08X\r\n", val); - GPU_setBGProp(SubScreen.gpu, 2, val); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x100C, val); - return; - case REG_DISPB_BG3CNT : - //GPULOG("SUB BG3 SETPROP 16B %08X\r\n", val); - GPU_setBGProp(SubScreen.gpu, 3, val); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x100E, val); - return; - - case REG_VRAMCNTA: - case REG_VRAMCNTC: - case REG_VRAMCNTE: - MMU_VRAMmapControl(adr-REG_VRAMCNTA, val & 0xFF); - MMU_VRAMmapControl(adr-REG_VRAMCNTA+1, val >> 8); - break; - case REG_VRAMCNTG: - MMU_VRAMmapControl(adr-REG_VRAMCNTA, val & 0xFF); - /* Update WRAMSTAT at the ARM7 side */ - T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x241, val >> 8); - break; - case REG_VRAMCNTH: - MMU_VRAMmapControl(adr-REG_VRAMCNTA, val & 0xFF); - MMU_VRAMmapControl(adr-REG_VRAMCNTA+1, val >> 8); - break; - - case REG_IME: - { - NDS_Reschedule(); - u32 old_val = MMU.reg_IME[ARMCPU_ARM9]; - u32 new_val = val & 0x01; - MMU.reg_IME[ARMCPU_ARM9] = new_val; - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x208, val); -#ifndef NEW_IRQ - if ( new_val && old_val != new_val) - { - // raise an interrupt request to the CPU if needed - if ( MMU.reg_IE[ARMCPU_ARM9] & MMU.reg_IF[ARMCPU_ARM9]) - { - NDS_ARM9.wIRQ = TRUE; - NDS_ARM9.waitIRQ = FALSE; - } - } -#endif - return; - } - case REG_IE : - NDS_Reschedule(); - MMU.reg_IE[ARMCPU_ARM9] = (MMU.reg_IE[ARMCPU_ARM9]&0xFFFF0000) | val; -#ifndef NEW_IRQ - if ( MMU.reg_IME[ARMCPU_ARM9]) - { - // raise an interrupt request to the CPU if needed - if ( MMU.reg_IE[ARMCPU_ARM9] & MMU.reg_IF[ARMCPU_ARM9]) - { - NDS_ARM9.wIRQ = TRUE; - NDS_ARM9.waitIRQ = FALSE; - } - } -#endif - return; - case REG_IE + 2 : - NDS_Reschedule(); - MMU.reg_IE[ARMCPU_ARM9] = (MMU.reg_IE[ARMCPU_ARM9]&0xFFFF) | (((u32)val)<<16); -#ifndef NEW_IRQ - if ( MMU.reg_IME[ARMCPU_ARM9]) - { - // raise an interrupt request to the CPU if needed - if ( MMU.reg_IE[ARMCPU_ARM9] & MMU.reg_IF[ARMCPU_ARM9]) - { - NDS_ARM9.wIRQ = TRUE; - NDS_ARM9.waitIRQ = FALSE; - } - } -#endif - return; - - case REG_IF : - NDS_Reschedule(); - MMU.reg_IF[ARMCPU_ARM9] &= (~((u32)val)); - return; - case REG_IF + 2 : - NDS_Reschedule(); - MMU.reg_IF[ARMCPU_ARM9] &= (~(((u32)val)<<16)); - return; - - case REG_IPCSYNC : - MMU_IPCSync(ARMCPU_ARM9, val); - return; - - case REG_IPCFIFOCNT : - IPC_FIFOcnt(ARMCPU_ARM9, val); - return; - case REG_TM0CNTL : - case REG_TM1CNTL : - case REG_TM2CNTL : - case REG_TM3CNTL : - MMU.timerReload[ARMCPU_ARM9][(adr>>2)&3] = val; - return; - case REG_TM0CNTH : - case REG_TM1CNTH : - case REG_TM2CNTH : - case REG_TM3CNTH : - { - int timerIndex = ((adr-2)>>2)&0x3; - write_timer(ARMCPU_ARM9, timerIndex, val); - return; - } - - case REG_DISPA_DISPCNT : - { - u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0) & 0xFFFF0000) | val; - GPU_setVideoProp(MainScreen.gpu, v); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0, v); - return; - } - case REG_DISPA_DISPCNT+2 : - { - u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0) & 0xFFFF) | ((u32) val << 16); - GPU_setVideoProp(MainScreen.gpu, v); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0, v); - } - return; - case REG_DISPA_DISPCAPCNT : - { - u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x64) & 0xFFFF0000) | val; - GPU_set_DISPCAPCNT(v); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x64, v); - return; - } - case REG_DISPA_DISPCAPCNT + 2: - { - u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x64) & 0xFFFF) | ((u32)val << 16); - GPU_set_DISPCAPCNT(v); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x64, v); - return; - } - - case REG_DISPB_DISPCNT : - { - u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000) & 0xFFFF0000) | val; - GPU_setVideoProp(SubScreen.gpu, v); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000, v); - return; - } - case REG_DISPB_DISPCNT+2 : - { - //emu_halt(); - u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000) & 0xFFFF) | ((u32) val << 16); - GPU_setVideoProp(SubScreen.gpu, v); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000, v); - return; - } - - case REG_DMA0CNTH : - write_dma_hictrl(0,val); - return; - case REG_DMA1CNTH : - write_dma_hictrl(1,val); - return; - case REG_DMA2CNTH : - write_dma_hictrl(2,val); - return; - case REG_DMA3CNTH : - write_dma_hictrl(3,val); - return; - case REG_DISPA_DISPMMEMFIFO: - { - DISP_FIFOsend(val); - return; - } - } - - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr&MMU.MMU_MASK[ARMCPU_ARM9][adr>>20], val); - return; - } - - bool unmapped; - adr = MMU_LCDmap(adr, unmapped); - if(unmapped) return; - - // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [shash] - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][adr>>20], adr&MMU.MMU_MASK[ARMCPU_ARM9][adr>>20], val); -} - -//================================================= MMU ARM9 write 32 -void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val) -{ - mmu_log_debug_ARM9(adr, "(write32) %0x%X", val); - - if(adr<0x02000000) - { - T1WriteLong(MMU.ARM9_ITCM, adr&0x7FFF, val); - return ; - } - - if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) - { - addon.write32(adr, val); - return; - } - - adr &= 0x0FFFFFFF; - -#if 0 - if ((adr & 0xFF800000) == 0x04800000) { - // access to non regular hw registers - // return to not overwrite valid data - return ; - } -#endif - - if((adr>>24)==4) - { - - // MightyMax: no need to do several ifs, when only one can happen - // switch/case instead - // both comparison >=,< per if can be replaced by one bit comparison since - // they are 2^4 aligned and 2^4n wide - // this looks ugly but should reduce load on register writes, they are done as - // lookups by the compiler - switch (adr >> 4) - { - case 0x400033: //edge color table - ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val; - return; - case 0x400036: //fog table - case 0x400037: - ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val; - return; - - case 0x400038: - case 0x400039: - case 0x40003A: - case 0x40003B: //toon table - ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val; - gfx3d_UpdateToonTable((adr & 0x3F) >> 1, val); - return; - - case 0x400040: - case 0x400041: - case 0x400042: - case 0x400043: // FIFO Commands - ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val; - gfx3d_sendCommandToFIFO(val); - return; - - case 0x400044: - case 0x400045: - case 0x400046: - case 0x400047: - case 0x400048: - case 0x400049: - case 0x40004A: - case 0x40004B: - case 0x40004C: - case 0x40004D: - case 0x40004E: - case 0x40004F: - case 0x400050: - case 0x400051: - case 0x400052: - case 0x400053: - case 0x400054: - case 0x400055: - case 0x400056: - case 0x400057: - case 0x400058: - case 0x400059: - case 0x40005A: - case 0x40005B: - case 0x40005C: // Individual Commands - ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val; - gfx3d_sendCommand(adr, val); - return; - default: - break; - } - - switch(adr) - { - case REG_DISPA_BG2XL: - MainScreen.gpu->setAffineStart(2,0,val); - return; - case REG_DISPA_BG2YL: - MainScreen.gpu->setAffineStart(2,1,val); - return; - case REG_DISPB_BG2XL: - SubScreen.gpu->setAffineStart(2,0,val); - return; - case REG_DISPB_BG2YL: - SubScreen.gpu->setAffineStart(2,1,val); - return; - case REG_DISPA_BG3XL: - MainScreen.gpu->setAffineStart(3,0,val); - return; - case REG_DISPA_BG3YL: - MainScreen.gpu->setAffineStart(3,1,val); - return; - case REG_DISPB_BG3XL: - SubScreen.gpu->setAffineStart(3,0,val); - return; - case REG_DISPB_BG3YL: - SubScreen.gpu->setAffineStart(3,1,val); - return; - - case 0x04000600: - GFX_FIFOcnt(val); - return; - - // Alpha test reference value - Parameters:1 - case 0x04000340: - { - ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x340>>2] = val; - gfx3d_glAlphaFunc(val); - return; - } - // Clear background color setup - Parameters:2 - case 0x04000350: - { - ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x350>>2] = val; - gfx3d_glClearColor(val); - return; - } - // Clear background depth setup - Parameters:2 - case 0x04000354: - { - ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x354>>2] = val; - gfx3d_glClearDepth(val); - return; - } - // Fog Color - Parameters:4b - case 0x04000358: - { - ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x358>>2] = val; - gfx3d_glFogColor(val); - return; - } - case 0x0400035C: - { - ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x35C>>2] = val; - gfx3d_glFogOffset(val); - return; - } - - case REG_DISPA_WININ: - { - GPU_setWININ(MainScreen.gpu, val & 0xFFFF) ; - GPU_setWINOUT16(MainScreen.gpu, (val >> 16) & 0xFFFF) ; - break; - } - case REG_DISPB_WININ: - { - GPU_setWININ(SubScreen.gpu, val & 0xFFFF) ; - GPU_setWINOUT16(SubScreen.gpu, (val >> 16) & 0xFFFF) ; - break; - } - - case REG_DISPA_WIN0H: - { - GPU_setWIN0_H(MainScreen.gpu, val&0xFFFF); - GPU_setWIN1_H(MainScreen.gpu, val>>16); - break; - } - case REG_DISPA_WIN0V: - { - GPU_setWIN0_V(MainScreen.gpu, val&0xFFFF); - GPU_setWIN1_V(MainScreen.gpu, val>>16); - break; - } - case REG_DISPB_WIN0H: - { - GPU_setWIN0_H(SubScreen.gpu, val&0xFFFF); - GPU_setWIN1_H(SubScreen.gpu, val>>16); - break; - } - case REG_DISPB_WIN0V: - { - GPU_setWIN0_V(SubScreen.gpu, val&0xFFFF); - GPU_setWIN1_V(SubScreen.gpu, val>>16); - break; - } - - case REG_DISPA_MASTERBRIGHT: - GPU_setMasterBrightness(MainScreen.gpu, val & 0xFFFF); - break; - case REG_DISPB_MASTERBRIGHT: - GPU_setMasterBrightness(SubScreen.gpu, val & 0xFFFF); - break; - - case REG_DISPA_BLDCNT: - { - GPU_setBLDCNT (MainScreen.gpu,val&0xffff); - MainScreen.gpu->setBLDALPHA(val>>16); - break; - } - case REG_DISPB_BLDCNT: - { - GPU_setBLDCNT (SubScreen.gpu,val&0xffff); - SubScreen.gpu->setBLDALPHA(val>>16); - break; - } - case REG_DISPA_DISPCNT : - GPU_setVideoProp(MainScreen.gpu, val); - //GPULOG("MAIN INIT 32B %08X\r\n", val); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0, val); - return; - - case REG_DISPB_DISPCNT : - GPU_setVideoProp(SubScreen.gpu, val); - //GPULOG("SUB INIT 32B %08X\r\n", val); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000, val); - return; - - case REG_VRAMCNTA: - MMU_VRAMmapControl(adr-REG_VRAMCNTA, val & 0xFF); - MMU_VRAMmapControl(adr-REG_VRAMCNTA+1, (val >> 8) & 0xFF); - MMU_VRAMmapControl(adr-REG_VRAMCNTA+2, (val >> 16) & 0xFF); - MMU_VRAMmapControl(adr-REG_VRAMCNTA+3, (val >> 24) & 0xFF); - break; - case REG_VRAMCNTE: - MMU_VRAMmapControl(adr-REG_VRAMCNTA, val & 0xFF); - MMU_VRAMmapControl(adr-REG_VRAMCNTA+1, (val >> 8) & 0xFF); - MMU_VRAMmapControl(adr-REG_VRAMCNTA+2, (val >> 16) & 0xFF); - /* Update WRAMSTAT at the ARM7 side */ - T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x241, (val >> 24) & 0xFF); - break; - case REG_VRAMCNTH: - MMU_VRAMmapControl(adr-REG_VRAMCNTA, val & 0xFF); - MMU_VRAMmapControl(adr-REG_VRAMCNTA+1, (val >> 8) & 0xFF); - break; - - case REG_IME : - { - NDS_Reschedule(); - u32 old_val = MMU.reg_IME[ARMCPU_ARM9]; - u32 new_val = val & 0x01; - MMU.reg_IME[ARMCPU_ARM9] = new_val; - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x208, val); -#ifndef NEW_IRQ - if ( new_val && old_val != new_val) - { - // raise an interrupt request to the CPU if needed - if ( MMU.reg_IE[ARMCPU_ARM9] & MMU.reg_IF[ARMCPU_ARM9]) - { - NDS_ARM9.wIRQ = TRUE; - NDS_ARM9.waitIRQ = FALSE; - } - } -#endif - } - return; - - case REG_IE : - NDS_Reschedule(); - MMU.reg_IE[ARMCPU_ARM9] = val; -#ifndef NEW_IRQ - if ( MMU.reg_IME[ARMCPU_ARM9]) - { - // raise an interrupt request to the CPU if needed - if ( MMU.reg_IE[ARMCPU_ARM9] & MMU.reg_IF[ARMCPU_ARM9]) - { - NDS_ARM9.wIRQ = TRUE; - NDS_ARM9.waitIRQ = FALSE; - } - } -#endif - return; - - case REG_IF : - NDS_Reschedule(); - MMU.reg_IF[ARMCPU_ARM9] &= (~val); - return; - - case REG_TM0CNTL: - case REG_TM1CNTL: - case REG_TM2CNTL: - case REG_TM3CNTL: - { - int timerIndex = (adr>>2)&0x3; - MMU.timerReload[ARMCPU_ARM9][timerIndex] = (u16)val; - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & 0xFFF, val); - write_timer(ARMCPU_ARM9, timerIndex, val>>16); - return; - } - - case REG_DIVDENOM : - { - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298, val); - execdiv(); - return; - } - case REG_DIVDENOM+4 : - { - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x29C, val); - execdiv(); - return; - } - - case REG_SQRTPARAM : - { - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8, val); - execsqrt(); - return; - } - case REG_SQRTPARAM+4 : - { - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2BC, val); - execsqrt(); - return; - } - case REG_IPCSYNC : - MMU_IPCSync(ARMCPU_ARM9, val); - return; - - case REG_IPCFIFOSEND : - IPC_FIFOsend(ARMCPU_ARM9, val); - return; - - case REG_DMA0CNTL : - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xB8, val); //write the low word - write_dma_hictrl(0,val>>16); - return; - case REG_DMA1CNTL: - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xC4, val); //write the low word - write_dma_hictrl(1,val>>16); - return; - case REG_DMA2CNTL : - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xD0, val); //write the low word - write_dma_hictrl(2,val>>16); - return; - case REG_DMA3CNTL : - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xDC, val); //write the low word - write_dma_hictrl(3,val>>16); - return; - case REG_GCROMCTRL : - MMU_writeToGCControl(val); - return; - case REG_DISPA_DISPCAPCNT : - //INFO("MMU write32: REG_DISPA_DISPCAPCNT 0x%X\n", val); - GPU_set_DISPCAPCNT(val); - T1WriteLong(MMU.ARM9_REG, 0x64, val); - return; - - case REG_DISPA_BG0CNT : - GPU_setBGProp(MainScreen.gpu, 0, (val&0xFFFF)); - GPU_setBGProp(MainScreen.gpu, 1, (val>>16)); - //if((val>>16)==0x400) emu_halt(); - T1WriteLong(MMU.ARM9_REG, 8, val); - return; - case REG_DISPA_BG2CNT : - GPU_setBGProp(MainScreen.gpu, 2, (val&0xFFFF)); - GPU_setBGProp(MainScreen.gpu, 3, (val>>16)); - T1WriteLong(MMU.ARM9_REG, 0xC, val); - return; - case REG_DISPB_BG0CNT : - GPU_setBGProp(SubScreen.gpu, 0, (val&0xFFFF)); - GPU_setBGProp(SubScreen.gpu, 1, (val>>16)); - T1WriteLong(MMU.ARM9_REG, 0x1008, val); - return; - case REG_DISPB_BG2CNT : - GPU_setBGProp(SubScreen.gpu, 2, (val&0xFFFF)); - GPU_setBGProp(SubScreen.gpu, 3, (val>>16)); - T1WriteLong(MMU.ARM9_REG, 0x100C, val); - return; - case REG_DISPA_DISPMMEMFIFO: - { - DISP_FIFOsend(val); - return; - } - } - - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & MMU.MMU_MASK[ARMCPU_ARM9][adr>>20], val); - return; - } - - bool unmapped; - adr = MMU_LCDmap(adr, unmapped); - if(unmapped) return; - - // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [shash] - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][adr>>20], adr&MMU.MMU_MASK[ARMCPU_ARM9][adr>>20], val); -} - -//================================================= MMU ARM9 read 08 -u8 FASTCALL _MMU_ARM9_read08(u32 adr) -{ - mmu_log_debug_ARM9(adr, "(read08) %0x%X", MMU.MMU_MEM[ARMCPU_ARM9][(adr>>20)&0xFF][adr&MMU.MMU_MASK[ARMCPU_ARM9][(adr>>20)&0xFF]]); - - if(adr<0x02000000) - return T1ReadByte(MMU.ARM9_ITCM, adr&0x7FFF); - - if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) - return addon.read08(adr); - - bool unmapped; - adr = MMU_LCDmap(adr, unmapped); - if(unmapped) return 0; - - return MMU.MMU_MEM[ARMCPU_ARM9][(adr>>20)&0xFF][adr&MMU.MMU_MASK[ARMCPU_ARM9][(adr>>20)&0xFF]]; -} - -//================================================= MMU ARM9 read 16 -u16 FASTCALL _MMU_ARM9_read16(u32 adr) -{ - mmu_log_debug_ARM9(adr, "(read16) %0x%X", T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20) & 0xFF])); - - if(adr<0x02000000) - return T1ReadWord(MMU.ARM9_ITCM, adr & 0x7FFF); - - if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) - return addon.read16(adr); - - adr &= 0x0FFFFFFF; - - if (adr >> 24 == 4) - { - // Address is an IO register - switch(adr) - { - // ============================================= 3D - case 0x04000604: - return (gfx3d_GetNumPolys()); - case 0x04000606: - return (gfx3d_GetNumVertex()); - case 0x04000630: - case 0x04000632: - case 0x04000634: - return gfx3d_glGetVecRes((adr & 0xF) >> 1); - // ============================================= 3D end - case REG_IME : - return (u16)MMU.reg_IME[ARMCPU_ARM9]; - - case REG_IE : - return (u16)MMU.reg_IE[ARMCPU_ARM9]; - case REG_IE + 2 : - return (u16)(MMU.reg_IE[ARMCPU_ARM9]>>16); - - case REG_IF : - return (u16)MMU.reg_IF[ARMCPU_ARM9]; - case REG_IF + 2 : - return (u16)(MMU.reg_IF[ARMCPU_ARM9]>>16); - - case REG_TM0CNTL : - case REG_TM1CNTL : - case REG_TM2CNTL : - case REG_TM3CNTL : - return read_timer(ARMCPU_ARM9,(adr&0xF)>>2); - - case REG_AUXSPICNT: - return MMU.AUX_SPI_CNT; - - case 0x04000130: - case 0x04000136: - //not sure whether these should trigger from byte reads - LagFrameFlag=0; - break; - - case REG_POSTFLG : - return 1; - } - - return T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20) & 0xFF]); - } - - bool unmapped; - adr = MMU_LCDmap(adr,unmapped); - if(unmapped) return 0; - - return T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20) & 0xFF]); -} - -//================================================= MMU ARM9 read 32 -u32 FASTCALL _MMU_ARM9_read32(u32 adr) -{ - mmu_log_debug_ARM9(adr, "(read32) %0x%X", T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20)])); - - if(adr<0x02000000) - return T1ReadLong(MMU.ARM9_ITCM, adr&0x7FFF); - - if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) - return addon.read32(adr); - - adr &= 0x0FFFFFFF; - - // Address is an IO register - if((adr >> 24) == 4) - { - switch(adr) - { - case 0x04000640: - case 0x04000644: - case 0x04000648: - case 0x0400064C: - case 0x04000650: - case 0x04000654: - case 0x04000658: - case 0x0400065C: - case 0x04000660: - case 0x04000664: - case 0x04000668: - case 0x0400066C: - case 0x04000670: - case 0x04000674: - case 0x04000678: - case 0x0400067C: - { - //LOG("4000640h..67Fh - CLIPMTX_RESULT - Read Current Clip Coordinates Matrix (R)"); - return gfx3d_GetClipMatrix ((adr-0x04000640)/4); - } - case 0x04000680: - case 0x04000684: - case 0x04000688: - case 0x0400068C: - case 0x04000690: - case 0x04000694: - case 0x04000698: - case 0x0400069C: - case 0x040006A0: - { - //LOG("4000680h..6A3h - VECMTX_RESULT - Read Current Directional Vector Matrix (R)"); - return gfx3d_GetDirectionalMatrix ((adr-0x04000680)/4); - } - - case 0x4000604: - { - return (gfx3d_GetNumPolys()) | ((gfx3d_GetNumVertex()) << 16); - //LOG ("read32 - RAM_COUNT -> 0x%X", ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][(adr>>20)&0xFF]))[(adr&MMU.MMU_MASK[ARMCPU_ARM9][(adr>>20)&0xFF])>>2]); - } - - case 0x04000620: - case 0x04000624: - case 0x04000628: - case 0x0400062C: - { - return gfx3d_glGetPosRes((adr & 0xF) >> 2); - } - // ======================================== 3D end - - case REG_IME : - return MMU.reg_IME[ARMCPU_ARM9]; - case REG_IE : - return MMU.reg_IE[ARMCPU_ARM9]; - case REG_IF : - return MMU.reg_IF[ARMCPU_ARM9]; - case REG_IPCFIFORECV : - return IPC_FIFOrecv(ARMCPU_ARM9); - case REG_TM0CNTL : - case REG_TM1CNTL : - case REG_TM2CNTL : - case REG_TM3CNTL : - { - u32 val = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], (adr + 2) & 0xFFF); - return MMU.timer[ARMCPU_ARM9][(adr&0xF)>>2] | (val<<16); - } - /* - case 0x04000640 : // TODO (clear): again, ??? - LOG("read proj\r\n"); - return 0; - case 0x04000680 : - LOG("read roat\r\n"); - return 0; - case 0x04000620 : - LOG("point res\r\n"); - return 0; - */ - case REG_GCDATAIN: - return MMU_readFromGC(); - } - return T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20)]); - } - - bool unmapped; - adr = MMU_LCDmap(adr,unmapped); - if(unmapped) return 0; - - // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [zeromus, inspired by shash] - return T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][(adr >> 20)], adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20)]); -} -//================================================================================================== ARM7 * -//========================================================================================================= -//========================================================================================================= -//================================================= MMU ARM7 write 08 -void FASTCALL _MMU_ARM7_write08(u32 adr, u8 val) -{ - mmu_log_debug_ARM7(adr, "(write08) %0x%X", val); - - if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) - { - addon.write08(adr, val); - return; - } - - adr &= 0x0FFFFFFF; - // This is bad, remove it - if ((adr>=0x04000400)&&(adr<0x0400051D)) - { - SPU_WriteByte(adr, val); - return; - } - - adr &= 0x0FFFFFFF; - - if(adr == 0x04000301) - { - switch(val) - { - case 0xC0: NDS_Sleep(); break; - default: break; - } - } - -#ifdef EXPERIMENTAL_WIFI - if ((adr & 0xFF800000) == 0x04800000) - { - /* is wifi hardware, dont intermix with regular hardware registers */ - // 8-bit writes to wifi I/O and RAM are ignored - // Reference: http://nocash.emubase.de/gbatek.htm#dswifiiomap - return ; - } -#endif - - if (adr >> 24 == 4) - { - switch(adr) - { - case REG_RTC: - rtcWrite(val); - return; - - case REG_AUXSPICNT: - write_auxspicnt(9,8,0,val); - return; - case REG_AUXSPICNT+1: - write_auxspicnt(9,8,1,val); - return; - } - } - - bool unmapped; - adr = MMU_LCDmap(adr,unmapped); - if(unmapped) return; - - // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [shash] - MMU.MMU_MEM[ARMCPU_ARM7][adr>>20][adr&MMU.MMU_MASK[ARMCPU_ARM7][adr>>20]]=val; -} - -//================================================= MMU ARM7 write 16 -void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val) -{ - mmu_log_debug_ARM7(adr, "(write16) %0x%X", val); - - if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) - { - addon.write16(adr, val); - return; - } - -#ifdef EXPERIMENTAL_WIFI - - /* wifi mac access */ - if ((adr>=0x04800000)&&(adr<0x05000000)) - { - WIFI_write16(adr,val); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x48], adr&MMU.MMU_MASK[ARMCPU_ARM7][0x48], val); - return; - } -#else - //if ((adr>=0x04800000)&&(adr<0x05000000)) return ; -#endif - - adr &= 0x0FFFFFFF; - - // This is bad, remove it - if ((adr>=0x04000400)&&(adr<0x0400051D)) - { - SPU_WriteWord(adr, val); - return; - } - - if((adr >> 24) == 4) - { - /* Address is an IO register */ - switch(adr) - { - case REG_RTC: - rtcWrite(val); - break; - - case REG_EXMEMCNT: - { - u16 oldval = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x204); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x204, (val & 0x7F) | (oldval & 0xFF80)); - } - return; - - case REG_AUXSPICNT: - write_auxspicnt(7,16,0,val); - return; - - case REG_AUXSPIDATA: - if(val!=0) - MMU.AUX_SPI_CMD = val & 0xFF; - - //T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU.bupmem, val)); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, MMU_new.backupDevice.data_command((u8)val)); - return; - - case REG_SPICNT : - { - int reset_firmware = 1; - - if ( ((MMU.SPI_CNT >> 8) & 0x3) == 1) - { - if ( ((val >> 8) & 0x3) == 1) - { - if ( BIT11(MMU.SPI_CNT)) - { - // select held - reset_firmware = 0; - } - } - } - - //MMU.fw.com == 0; // reset fw device communication - if ( reset_firmware) - { - // reset fw device communication - fw_reset_com(&MMU.fw); - } - MMU.SPI_CNT = val; - - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPICNT >> 20) & 0xff], REG_SPICNT & 0xfff, val); - } - return; - - case REG_SPIDATA : - { - u16 spicnt; - - if(val!=0) - MMU.SPI_CMD = val; - - spicnt = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPICNT >> 20) & 0xff], REG_SPICNT & 0xfff); - - switch((spicnt >> 8) & 0x3) - { - case 0 : - { - if(!MMU.powerMan_CntRegWritten) - { - MMU.powerMan_CntReg = (val & 0xFF); - MMU.powerMan_CntRegWritten = TRUE; - } - else - { - if(MMU.powerMan_CntReg & 0x80) - { - val = MMU.powerMan_Reg[MMU.powerMan_CntReg & 0x3]; - } - else - { - MMU.powerMan_Reg[MMU.powerMan_CntReg & 0x3] = (u8)val; - } - - MMU.powerMan_CntRegWritten = FALSE; - } - } - break; - - case 1 : /* firmware memory device */ - if((spicnt & 0x3) != 0) /* check SPI baudrate (must be 4mhz) */ - { - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, 0); - break; - } - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, fw_transfer(&MMU.fw, (u8)val)); - return; - - case 2 : - switch(MMU.SPI_CMD & 0x70) - { - case 0x00 : - val = 0; - break; - case 0x10 : - //emu_halt(); - if(MMU.SPI_CNT&(1<<11)) - { - if(partie) - { - val = ((nds.touchY<<3)&0x7FF); - partie = 0; - //emu_halt(); - break; - } - val = (nds.touchY>>5); - partie = 1; - break; - } - val = ((nds.touchY<<3)&0x7FF); - partie = 1; - break; - case 0x20 : - val = 0; - break; - case 0x30 : - val = 0; - break; - case 0x40 : - val = 0; - break; - case 0x50 : - if(spicnt & 0x800) - { - if(partie) - { - val = ((nds.touchX<<3)&0x7FF); - partie = 0; - break; - } - val = (nds.touchX>>5); - partie = 1; - break; - } - val = ((nds.touchX<<3)&0x7FF); - partie = 1; - break; - case 0x60 : - if(!(val & 0x80)) - val = (Mic_ReadSample() & 0xFF); - else - val = 0; - break; - case 0x70 : - val = 0; - break; - } - break; - - case 3 : - /* NOTICE: Device 3 of SPI is reserved (unused and unusable) */ - break; - } - } - - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, val); - return; - - /* NOTICE: Perhaps we have to use gbatek-like reg names instead of libnds-like ones ...*/ - - case REG_IME : - { - NDS_Reschedule(); - u32 old_val = MMU.reg_IME[ARMCPU_ARM7]; - u32 new_val = val & 1; - MMU.reg_IME[ARMCPU_ARM7] = new_val; - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x208, val); -#ifndef NEW_IRQ - if ( new_val && old_val != new_val) - { - /* raise an interrupt request to the CPU if needed */ - if ( MMU.reg_IE[ARMCPU_ARM7] & MMU.reg_IF[ARMCPU_ARM7]) - { - NDS_ARM7.wIRQ = TRUE; - NDS_ARM7.waitIRQ = FALSE; - } - } -#endif - return; - } - case REG_IE : - NDS_Reschedule(); - MMU.reg_IE[ARMCPU_ARM7] = (MMU.reg_IE[ARMCPU_ARM7]&0xFFFF0000) | val; -#ifndef NEW_IRQ - if ( MMU.reg_IME[ARMCPU_ARM7]) - { - /* raise an interrupt request to the CPU if needed */ - if ( MMU.reg_IE[ARMCPU_ARM7] & MMU.reg_IF[ARMCPU_ARM7]) - { - NDS_ARM7.wIRQ = TRUE; - NDS_ARM7.waitIRQ = FALSE; - } - } -#endif - return; - case REG_IE + 2 : - NDS_Reschedule(); - //emu_halt(); - MMU.reg_IE[ARMCPU_ARM7] = (MMU.reg_IE[ARMCPU_ARM7]&0xFFFF) | (((u32)val)<<16); -#ifndef NEW_IRQ - if ( MMU.reg_IME[ARMCPU_ARM7]) - { - /* raise an interrupt request to the CPU if needed */ - if ( MMU.reg_IE[ARMCPU_ARM7] & MMU.reg_IF[ARMCPU_ARM7]) - { - NDS_ARM7.wIRQ = TRUE; - NDS_ARM7.waitIRQ = FALSE; - } - } -#endif - return; - - case REG_IF : - NDS_Reschedule(); - //emu_halt(); - MMU.reg_IF[ARMCPU_ARM7] &= (~((u32)val)); - return; - case REG_IF + 2 : - NDS_Reschedule(); - //emu_halt(); - MMU.reg_IF[ARMCPU_ARM7] &= (~(((u32)val)<<16)); - return; - - case REG_IPCSYNC : - MMU_IPCSync(ARMCPU_ARM7, val); - return; - - case REG_IPCFIFOCNT : - IPC_FIFOcnt(ARMCPU_ARM7, val); - return; - case REG_TM0CNTL : - case REG_TM1CNTL : - case REG_TM2CNTL : - case REG_TM3CNTL : - MMU.timerReload[ARMCPU_ARM7][(adr>>2)&3] = val; - return; - case REG_TM0CNTH : - case REG_TM1CNTH : - case REG_TM2CNTH : - case REG_TM3CNTH : - { - int timerIndex = ((adr-2)>>2)&0x3; - write_timer(ARMCPU_ARM7, timerIndex, val); - return; - } - - case REG_DMA0CNTH : - write_dma_hictrl(0,val); - return; - case REG_DMA1CNTH : - write_dma_hictrl(1,val); - return; - case REG_DMA2CNTH : - write_dma_hictrl(2,val); - return; - case REG_DMA3CNTH : - write_dma_hictrl(3,val); - return; - } - - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], adr&MMU.MMU_MASK[ARMCPU_ARM7][adr>>20], val); - return; - } - - bool unmapped; - adr = MMU_LCDmap(adr,unmapped); - if(unmapped) return; - - // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [shash] - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][adr>>20], adr&MMU.MMU_MASK[ARMCPU_ARM7][adr>>20], val); -} -//================================================= MMU ARM7 write 32 -void FASTCALL _MMU_ARM7_write32(u32 adr, u32 val) -{ - mmu_log_debug_ARM7(adr, "(write32) %0x%X", val); - - if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) - { - addon.write32(adr, val); - return; - } - -#ifdef EXPERIMENTAL_WIFI - if ((adr & 0xFF800000) == 0x04800000) - { - // access to non regular hw registers - // return to not overwrite valid data - WIFI_write16(adr, val & 0xFFFF); - WIFI_write16(adr+2, val >> 16); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x48], adr&MMU.MMU_MASK[ARMCPU_ARM7][0x48], val); - return; - } -#endif - - adr &= 0x0FFFFFFF; - - // This is bad, remove it - if ((adr>=0x04000400)&&(adr<0x0400051D)) - { - SPU_WriteLong(adr, val); - return; - } - - if((adr>>24)==4) - { - switch(adr) - { - case REG_RTC: - rtcWrite((u16)val); - break; - - case REG_IME : - { - NDS_Reschedule(); - u32 old_val = MMU.reg_IME[ARMCPU_ARM7]; - u32 new_val = val & 1; - MMU.reg_IME[ARMCPU_ARM7] = new_val; - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x208, val); -#ifndef NEW_IRQ - if ( new_val && old_val != new_val) - { - // raise an interrupt request to the CPU if needed - if ( MMU.reg_IE[ARMCPU_ARM7] & MMU.reg_IF[ARMCPU_ARM7]) - { - NDS_ARM7.wIRQ = TRUE; - NDS_ARM7.waitIRQ = FALSE; - } - } -#endif - return; - } - - case REG_IE : - NDS_Reschedule(); - MMU.reg_IE[ARMCPU_ARM7] = val; -#ifndef NEW_IRQ - if ( MMU.reg_IME[ARMCPU_ARM7]) - { - /* raise an interrupt request to the CPU if needed */ - if ( MMU.reg_IE[ARMCPU_ARM7] & MMU.reg_IF[ARMCPU_ARM7]) - { - NDS_ARM7.wIRQ = TRUE; - NDS_ARM7.waitIRQ = FALSE; - } - } -#endif - return; - - case REG_IF : - NDS_Reschedule(); - MMU.reg_IF[ARMCPU_ARM7] &= (~val); - return; - - case REG_TM0CNTL: - case REG_TM1CNTL: - case REG_TM2CNTL: - case REG_TM3CNTL: - { - int timerIndex = (adr>>2)&0x3; - MMU.timerReload[ARMCPU_ARM7][timerIndex] = (u16)val; - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], adr & 0xFFF, val); - write_timer(ARMCPU_ARM7, timerIndex, val>>16); - return; - } - - - case REG_IPCSYNC : - MMU_IPCSync(ARMCPU_ARM7, val); - return; - - case REG_IPCFIFOSEND : - IPC_FIFOsend(ARMCPU_ARM7, val); - return; - - case REG_DMA0CNTL : - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xB8, val); //write the low word - write_dma_hictrl(0,val>>16); - return; - case REG_DMA1CNTL: - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xC4, val); //write the low word - write_dma_hictrl(1,val>>16); - return; - case REG_DMA2CNTL : - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xD0, val); //write the low word - write_dma_hictrl(2,val>>16); - return; - case REG_DMA3CNTL : - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xDC, val); //write the low word - write_dma_hictrl(3,val>>16); - return; - - case REG_GCROMCTRL : - MMU_writeToGCControl(val); - return; - } - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], adr & MMU.MMU_MASK[ARMCPU_ARM7][adr>>20], val); - return; - } - - bool unmapped; - adr = MMU_LCDmap(adr,unmapped); - if(unmapped) return; - - // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [shash] - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][adr>>20], adr&MMU.MMU_MASK[ARMCPU_ARM7][adr>>20], val); -} - -//================================================= MMU ARM7 read 08 -u8 FASTCALL _MMU_ARM7_read08(u32 adr) -{ - mmu_log_debug_ARM7(adr, "(read08) %0x%X", MMU.MMU_MEM[ARMCPU_ARM7][(adr>>20)&0xFF][adr&MMU.MMU_MASK[ARMCPU_ARM7][(adr>>20)&0xFF]]); - -#ifdef EXPERIMENTAL_WIFI - /* wifi mac access */ - if ((adr>=0x04800000)&&(adr<0x05000000)) - { - if (adr & 1) - return (WIFI_read16(adr-1) >> 8) & 0xFF; - else - return WIFI_read16(adr) & 0xFF; - } -#endif - - if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) - return addon.read08(adr); - - if (adr == REG_RTC) return (u8)rtcRead(); - - bool unmapped; - adr = MMU_LCDmap(adr,unmapped); - if(unmapped) return 0; - - return MMU.MMU_MEM[ARMCPU_ARM7][(adr>>20)&0xFF][adr&MMU.MMU_MASK[ARMCPU_ARM7][(adr>>20)&0xFF]]; -} -//================================================= MMU ARM7 read 16 -u16 FASTCALL _MMU_ARM7_read16(u32 adr) -{ - mmu_log_debug_ARM7(adr, "(read16) %0x%X", T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20) & 0xFF])); - -#ifdef EXPERIMENTAL_WIFI - /* wifi mac access */ - if ((adr>=0x04800000)&&(adr<0x05000000)) - return WIFI_read16(adr) ; -#endif - - if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) - return addon.read16(adr); - - adr &= 0x0FFFFFFF; - - if(adr>>24==4) - { - /* Address is an IO register */ - switch(adr) - { - case REG_RTC: - return rtcRead(); - - case REG_IME : - return (u16)MMU.reg_IME[ARMCPU_ARM7]; - - case REG_IE : - return (u16)MMU.reg_IE[ARMCPU_ARM7]; - case REG_IE + 2 : - return (u16)(MMU.reg_IE[ARMCPU_ARM7]>>16); - - case REG_IF : - return (u16)MMU.reg_IF[ARMCPU_ARM7]; - case REG_IF + 2 : - return (u16)(MMU.reg_IF[ARMCPU_ARM7]>>16); - - case REG_TM0CNTL : - case REG_TM1CNTL : - case REG_TM2CNTL : - case REG_TM3CNTL : - return read_timer(ARMCPU_ARM7,(adr&0xF)>>2); - - case REG_AUXSPICNT: - return MMU.AUX_SPI_CNT; - - case 0x04000130: - case 0x04000136: - //here is an example of what not to do: - //since the arm7 polls this every frame, we shouldnt count this as an input check - //LagFrameFlag=0; - break; - - case REG_POSTFLG : - return 1; - } - return T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20) & 0xFF]); - } - - bool unmapped; - adr = MMU_LCDmap(adr,unmapped); - if(unmapped) return 0; - - /* Returns data from memory */ - return T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20) & 0xFF]); -} -//================================================= MMU ARM7 read 32 -u32 FASTCALL _MMU_ARM7_read32(u32 adr) -{ - mmu_log_debug_ARM7(adr, "(read32) %0x%X", T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20) & 0xFF])); - -#ifdef EXPERIMENTAL_WIFI - /* wifi mac access */ - if ((adr>=0x04800000)&&(adr<0x05000000)) - return (WIFI_read16(adr) | (WIFI_read16(adr+2) << 16)); -#endif - - if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) - return addon.read32(adr); - - adr &= 0x0FFFFFFF; - - if((adr >> 24) == 4) - { - /* Address is an IO register */ - switch(adr) - { - case REG_RTC: - return (u32)rtcRead(); - - case REG_IME : - return MMU.reg_IME[ARMCPU_ARM7]; - case REG_IE : - return MMU.reg_IE[ARMCPU_ARM7]; - case REG_IF : - return MMU.reg_IF[ARMCPU_ARM7]; - case REG_IPCFIFORECV : - return IPC_FIFOrecv(ARMCPU_ARM7); - case REG_TM0CNTL : - case REG_TM1CNTL : - case REG_TM2CNTL : - case REG_TM3CNTL : - { - u32 val = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], (adr + 2) & 0xFFF); - return MMU.timer[ARMCPU_ARM7][(adr&0xF)>>2] | (val<<16); - } - case REG_GCROMCTRL: - { - //INFO("arm7 romctrl read\n"); - break; - } - case REG_GCDATAIN: - return MMU_readFromGC(); - } - return T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20)], adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20)]); - } - - bool unmapped; - adr = MMU_LCDmap(adr,unmapped); - if(unmapped) return 0; - - //Returns data from memory - // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [zeromus, inspired by shash] - return T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20)], adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20)]); -} - -//========================================================================================================= - -u32 FASTCALL MMU_read32(u32 proc, u32 adr) -{ - ASSERT_UNALIGNED((adr&3)==0); - - if(proc==0) - return _MMU_ARM9_read32(adr); - else - return _MMU_ARM7_read32(adr); -} - -u16 FASTCALL MMU_read16(u32 proc, u32 adr) -{ - ASSERT_UNALIGNED((adr&1)==0); - - if(proc==0) - return _MMU_ARM9_read16(adr); - else - return _MMU_ARM7_read16(adr); -} - -u8 FASTCALL MMU_read8(u32 proc, u32 adr) -{ - if(proc==0) - return _MMU_ARM9_read08(adr); - else - return _MMU_ARM7_read08(adr); -} - -void FASTCALL MMU_write32(u32 proc, u32 adr, u32 val) -{ - ASSERT_UNALIGNED((adr&3)==0); - - if(proc==0) - _MMU_ARM9_write32(adr, val); - else - _MMU_ARM7_write32(adr,val); -} - -void FASTCALL MMU_write16(u32 proc, u32 adr, u16 val) -{ - ASSERT_UNALIGNED((adr&1)==0); - - if(proc==0) - _MMU_ARM9_write16(adr, val); - else - _MMU_ARM7_write16(adr,val); -} - -void FASTCALL MMU_write8(u32 proc, u32 adr, u8 val) -{ - if(proc==0) - _MMU_ARM9_write08(adr, val); - else - - _MMU_ARM7_write08(adr,val); -} - -void FASTCALL MMU_DumpMemBlock(u8 proc, u32 address, u32 size, u8 *buffer) -{ - u32 i; - u32 curaddr; - - for(i = 0, curaddr = address; i < size; i++, curaddr++) - { - buffer[i] = _MMU_read08(proc,MMU_AT_GPU,curaddr); - } -} - -//////////////////////////////////////////////////////////// -//function pointer handlers for gdb stub stuff - -static u16 FASTCALL arm9_prefetch16( void *data, u32 adr) { - profile_memory_access( 1, adr, PROFILE_PREFETCH); - return _MMU_read16(adr); -} - -static u32 FASTCALL arm9_prefetch32( void *data, u32 adr) { - profile_memory_access( 1, adr, PROFILE_PREFETCH); - return _MMU_read32(adr); -} - -static u8 FASTCALL arm9_read8( void *data, u32 adr) { - profile_memory_access( 1, adr, PROFILE_READ); - return _MMU_read08(adr); -} - -static u16 FASTCALL arm9_read16( void *data, u32 adr) { - profile_memory_access( 1, adr, PROFILE_READ); - return _MMU_read16(adr); -} - -static u32 FASTCALL arm9_read32( void *data, u32 adr) { - profile_memory_access( 1, adr, PROFILE_READ); - return _MMU_read32(adr); -} - -static void FASTCALL arm9_write8(void *data, u32 adr, u8 val) { - profile_memory_access( 1, adr, PROFILE_WRITE); - _MMU_write08(adr, val); -} - -static void FASTCALL arm9_write16(void *data, u32 adr, u16 val) { - profile_memory_access( 1, adr, PROFILE_WRITE); - _MMU_write16(adr, val); -} - -static void FASTCALL arm9_write32(void *data, u32 adr, u32 val) { - profile_memory_access( 1, adr, PROFILE_WRITE); - _MMU_write32(adr, val); -} - -static u16 FASTCALL arm7_prefetch16( void *data, u32 adr) { - profile_memory_access( 0, adr, PROFILE_PREFETCH); - return _MMU_read16(adr); -} - -static u32 FASTCALL arm7_prefetch32( void *data, u32 adr) { - profile_memory_access( 0, adr, PROFILE_PREFETCH); - return _MMU_read32(adr); -} - -static u8 FASTCALL arm7_read8( void *data, u32 adr) { - profile_memory_access( 0, adr, PROFILE_READ); - return _MMU_read08(adr); -} - -static u16 FASTCALL arm7_read16( void *data, u32 adr) { - profile_memory_access( 0, adr, PROFILE_READ); - return _MMU_read16(adr); -} - -static u32 FASTCALL arm7_read32( void *data, u32 adr) { - profile_memory_access( 0, adr, PROFILE_READ); - return _MMU_read32(adr); -} - -static void FASTCALL arm7_write8(void *data, u32 adr, u8 val) { - profile_memory_access( 0, adr, PROFILE_WRITE); - _MMU_write08(adr, val); -} - -static void FASTCALL arm7_write16(void *data, u32 adr, u16 val) { - profile_memory_access( 0, adr, PROFILE_WRITE); - _MMU_write16(adr, val); -} - -static void FASTCALL arm7_write32(void *data, u32 adr, u32 val) { - profile_memory_access( 0, adr, PROFILE_WRITE); - _MMU_write32(adr, val); -} - - - -/* - * the base memory interfaces - */ -struct armcpu_memory_iface arm9_base_memory_iface = { - arm9_prefetch32, - arm9_prefetch16, - - arm9_read8, - arm9_read16, - arm9_read32, - - arm9_write8, - arm9_write16, - arm9_write32 -}; - -struct armcpu_memory_iface arm7_base_memory_iface = { - arm7_prefetch32, - arm7_prefetch16, - - arm7_read8, - arm7_read16, - arm7_read32, - - arm7_write8, - arm7_write16, - arm7_write32 -}; - -/* - * The direct memory interface for the ARM9. - * This avoids the ARM9 protection unit when accessing - * memory. - */ -struct armcpu_memory_iface arm9_direct_memory_iface = { - NULL, - NULL, - - arm9_read8, - arm9_read16, - arm9_read32, - - arm9_write8, - arm9_write16, - arm9_write32 -}; - - -///////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////// - -//#ifdef PROFILE_MEMORY_ACCESS -// -//#define PROFILE_PREFETCH 0 -//#define PROFILE_READ 1 -//#define PROFILE_WRITE 2 -// -//struct mem_access_profile { -// u64 num_accesses; -// u32 address_mask; -// u32 masked_value; -//}; -// -//#define PROFILE_NUM_MEM_ACCESS_PROFILES 4 -// -//static u64 profile_num_accesses[2][3]; -//static u64 profile_unknown_addresses[2][3]; -//static struct mem_access_profile -//profile_memory_accesses[2][3][PROFILE_NUM_MEM_ACCESS_PROFILES]; -// -//static void -//setup_profiling( void) { -// int i; -// -// for ( i = 0; i < 2; i++) { -// int access_type; -// -// for ( access_type = 0; access_type < 3; access_type++) { -// profile_num_accesses[i][access_type] = 0; -// profile_unknown_addresses[i][access_type] = 0; -// -// /* -// * Setup the access testing structures -// */ -// profile_memory_accesses[i][access_type][0].address_mask = 0x0e000000; -// profile_memory_accesses[i][access_type][0].masked_value = 0x00000000; -// profile_memory_accesses[i][access_type][0].num_accesses = 0; -// -// /* main memory */ -// profile_memory_accesses[i][access_type][1].address_mask = 0x0f000000; -// profile_memory_accesses[i][access_type][1].masked_value = 0x02000000; -// profile_memory_accesses[i][access_type][1].num_accesses = 0; -// -// /* shared memory */ -// profile_memory_accesses[i][access_type][2].address_mask = 0x0f800000; -// profile_memory_accesses[i][access_type][2].masked_value = 0x03000000; -// profile_memory_accesses[i][access_type][2].num_accesses = 0; -// -// /* arm7 memory */ -// profile_memory_accesses[i][access_type][3].address_mask = 0x0f800000; -// profile_memory_accesses[i][access_type][3].masked_value = 0x03800000; -// profile_memory_accesses[i][access_type][3].num_accesses = 0; -// } -// } -//} -// -//static void -//profile_memory_access( int arm9, u32 adr, int access_type) { -// static int first = 1; -// int mem_profile; -// int address_found = 0; -// -// if ( first) { -// setup_profiling(); -// first = 0; -// } -// -// profile_num_accesses[arm9][access_type] += 1; -// -// for ( mem_profile = 0; -// mem_profile < PROFILE_NUM_MEM_ACCESS_PROFILES && -// !address_found; -// mem_profile++) { -// if ( (adr & profile_memory_accesses[arm9][access_type][mem_profile].address_mask) == -// profile_memory_accesses[arm9][access_type][mem_profile].masked_value) { -// /*printf( "adr %08x mask %08x res %08x expected %08x\n", -// adr, -// profile_memory_accesses[arm9][access_type][mem_profile].address_mask, -// adr & profile_memory_accesses[arm9][access_type][mem_profile].address_mask, -// profile_memory_accesses[arm9][access_type][mem_profile].masked_value);*/ -// address_found = 1; -// profile_memory_accesses[arm9][access_type][mem_profile].num_accesses += 1; -// } -// } -// -// if ( !address_found) { -// profile_unknown_addresses[arm9][access_type] += 1; -// } -//} -// -// -//static const char *access_type_strings[] = { -// "prefetch", -// "read ", -// "write " -//}; -// -//void -//print_memory_profiling( void) { -// int arm; -// -// printf("------ Memory access profile ------\n"); -// -// for ( arm = 0; arm < 2; arm++) { -// int access_type; -// -// for ( access_type = 0; access_type < 3; access_type++) { -// int mem_profile; -// printf("ARM%c: num of %s %lld\n", -// arm ? '9' : '7', -// access_type_strings[access_type], -// profile_num_accesses[arm][access_type]); -// -// for ( mem_profile = 0; -// mem_profile < PROFILE_NUM_MEM_ACCESS_PROFILES; -// mem_profile++) { -// printf( "address %08x: %lld\n", -// profile_memory_accesses[arm][access_type][mem_profile].masked_value, -// profile_memory_accesses[arm][access_type][mem_profile].num_accesses); -// } -// -// printf( "unknown addresses %lld\n", -// profile_unknown_addresses[arm][access_type]); -// -// printf( "\n"); -// } -// } -// -// printf("------ End of Memory access profile ------\n\n"); -//} -//#else -//void -//print_memory_profiling( void) { -//} -//#endif /* End of PROFILE_MEMORY_ACCESS area */ +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2007 shash + Copyright (C) 2007-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//#define NEW_IRQ 1 + +#include +#include +#include +#include +#include + +#include "common.h" +#include "debug.h" +#include "NDSSystem.h" +#include "cp15.h" +#include "wifi.h" +#include "registers.h" +#include "render3D.h" +#include "gfx3d.h" +#include "rtc.h" +#include "GPU_osd.h" +#include "mc.h" +#include "addons.h" +#include "mic.h" +#include "movie.h" + +#ifdef DO_ASSERT_UNALIGNED +#define ASSERT_UNALIGNED(x) assert(x) +#else +#define ASSERT_UNALIGNED(x) +#endif + +//http://home.utah.edu/~nahaj/factoring/isqrt.c.html +static u64 isqrt (u64 x) { + u64 squaredbit, remainder, root; + + if (x<1) return 0; + + /* Load the binary constant 01 00 00 ... 00, where the number + * of zero bits to the right of the single one bit + * is even, and the one bit is as far left as is consistant + * with that condition.) + */ + squaredbit = (u64) ((((u64) ~0LL) >> 1) & + ~(((u64) ~0LL) >> 2)); + /* This portable load replaces the loop that used to be + * here, and was donated by legalize@xmission.com + */ + + /* Form bits of the answer. */ + remainder = x; root = 0; + while (squaredbit > 0) { + if (remainder >= (squaredbit | root)) { + remainder -= (squaredbit | root); + root >>= 1; root |= squaredbit; + } else { + root >>= 1; + } + squaredbit >>= 2; + } + + return root; +} + +u32 partie = 1; +u32 _MMU_MAIN_MEM_MASK = 0x3FFFFF; + +#define ROM_MASK 3 + +//#define _MMU_DEBUG + +#ifdef _MMU_DEBUG + +#include +void mmu_log_debug_ARM9(u32 adr, const char *fmt, ...) +{ + if (adr < 0x4000000) return; + if (adr > 0x4100014) return; + + if (adr >= 0x4000000 && adr <= 0x400006E) return; // Display Engine A + if (adr >= 0x40000B0 && adr <= 0x4000134) return; // DMA, Timers and Keypad + if (adr >= 0x4000180 && adr <= 0x40001BC) return; // IPC/ROM + if (adr >= 0x4000204 && adr <= 0x400024A) return; // Memory & IRQ control + if (adr >= 0x4000280 && adr <= 0x4000306) return; // Maths + if (adr >= 0x4000320 && adr <= 0x40006A3) return; // 3D dispaly engine + if (adr >= 0x4001000 && adr <= 0x400106E) return; // Display Engine B + if (adr >= 0x4100000 && adr <= 0x4100014) return; // IPC/ROM + + va_list list; + char msg[512]; + + memset(msg,0,512); + + va_start(list,fmt); + _vsnprintf(msg,511,fmt,list); + va_end(list); + + INFO("MMU ARM9 0x%08X: %s\n", adr, msg); +} + +void mmu_log_debug_ARM7(u32 adr, const char *fmt, ...) +{ + if (adr < 0x4000004) return; + if (adr > 0x4808FFF) return; + + if (adr >= 0x4000004 && adr <= 0x40001C4) return; // ARM7 I/O Map + if (adr >= 0x4000204 && adr <= 0x400030C) return; // Memory and IRQ Control + if (adr >= 0x4000400 && adr <= 0x400051E) return; // Sound Registers + if (adr >= 0x4100000 && adr <= 0x4100014) return; // IPC/ROM + //if (adr >= 0x4800000 && adr <= 0x4808FFF) return; // WLAN Registers + + va_list list; + char msg[512]; + + memset(msg,0,512); + + va_start(list,fmt); + _vsnprintf(msg,511,fmt,list); + va_end(list); + + INFO("MMU ARM7 0x%08X: %s\n", adr, msg); + +} +#else +#define mmu_log_debug_ARM9(...) +#define mmu_log_debug_ARM7(...) +#endif + + +//#define LOG_CARD +//#define LOG_GPU +//#define LOG_DMA +//#define LOG_DMA2 +//#define LOG_DIV + +#define DUP2(x) x, x +#define DUP4(x) x, x, x, x +#define DUP8(x) x, x, x, x, x, x, x, x +#define DUP16(x) x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x + +MMU_struct MMU; +MMU_struct_new MMU_new; + +u8 * MMU_struct::MMU_MEM[2][256] = { + //arm9 + { + /* 0X*/ DUP16(ARM9Mem.ARM9_ITCM), + /* 1X*/ //DUP16(ARM9Mem.ARM9_ITCM) + /* 1X*/ DUP16(MMU.UNUSED_RAM), + /* 2X*/ DUP16(ARM9Mem.MAIN_MEM), + /* 3X*/ DUP16(MMU.SWIRAM), + /* 4X*/ DUP16(ARM9Mem.ARM9_REG), + /* 5X*/ DUP16(ARM9Mem.ARM9_VMEM), + /* 6X*/ DUP16(ARM9Mem.ARM9_LCD), + /* 7X*/ DUP16(ARM9Mem.ARM9_OAM), + /* 8X*/ DUP16(NULL), + /* 9X*/ DUP16(NULL), + /* AX*/ DUP16(MMU.CART_RAM), + /* BX*/ DUP16(MMU.UNUSED_RAM), + /* CX*/ DUP16(MMU.UNUSED_RAM), + /* DX*/ DUP16(MMU.UNUSED_RAM), + /* EX*/ DUP16(MMU.UNUSED_RAM), + /* FX*/ DUP16(ARM9Mem.ARM9_BIOS) + }, + //arm7 + { + /* 0X*/ DUP16(MMU.ARM7_BIOS), + /* 1X*/ DUP16(MMU.UNUSED_RAM), + /* 2X*/ DUP16(ARM9Mem.MAIN_MEM), + /* 3X*/ DUP8(MMU.SWIRAM), + DUP8(MMU.ARM7_ERAM), + /* 4X*/ DUP8(MMU.ARM7_REG), + DUP8(MMU.ARM7_WIRAM), + /* 5X*/ DUP16(MMU.UNUSED_RAM), + /* 6X*/ DUP16(ARM9Mem.ARM9_LCD), + /* 7X*/ DUP16(MMU.UNUSED_RAM), + /* 8X*/ DUP16(NULL), + /* 9X*/ DUP16(NULL), + /* AX*/ DUP16(MMU.CART_RAM), + /* BX*/ DUP16(MMU.UNUSED_RAM), + /* CX*/ DUP16(MMU.UNUSED_RAM), + /* DX*/ DUP16(MMU.UNUSED_RAM), + /* EX*/ DUP16(MMU.UNUSED_RAM), + /* FX*/ DUP16(MMU.UNUSED_RAM) + } +}; + +u32 MMU_struct::MMU_MASK[2][256] = { + //arm9 + { + /* 0X*/ DUP16(0x00007FFF), + /* 1X*/ //DUP16(0x00007FFF) + /* 1X*/ DUP16(0x00000003), + /* 2X*/ DUP16(0x003FFFFF), + /* 3X*/ DUP16(0x00007FFF), + /* 4X*/ DUP16(0x00FFFFFF), + /* 5X*/ DUP16(0x000007FF), + /* 6X*/ DUP16(0x00FFFFFF), + /* 7X*/ DUP16(0x000007FF), + /* 8X*/ DUP16(ROM_MASK), + /* 9X*/ DUP16(ROM_MASK), + /* AX*/ DUP16(0x0000FFFF), + /* BX*/ DUP16(0x00000003), + /* CX*/ DUP16(0x00000003), + /* DX*/ DUP16(0x00000003), + /* EX*/ DUP16(0x00000003), + /* FX*/ DUP16(0x00007FFF) + }, + //arm7 + { + /* 0X*/ DUP16(0x00003FFF), + /* 1X*/ DUP16(0x00000003), + /* 2X*/ DUP16(0x003FFFFF), + /* 3X*/ DUP8(0x00007FFF), + DUP8(0x0000FFFF), + /* 4X*/ DUP8(0x00FFFFFF), + DUP8(0x0000FFFF), + /* 5X*/ DUP16(0x00000003), + /* 6X*/ DUP16(0x00FFFFFF), + /* 7X*/ DUP16(0x00000003), + /* 8X*/ DUP16(ROM_MASK), + /* 9X*/ DUP16(ROM_MASK), + /* AX*/ DUP16(0x0000FFFF), + /* BX*/ DUP16(0x00000003), + /* CX*/ DUP16(0x00000003), + /* DX*/ DUP16(0x00000003), + /* EX*/ DUP16(0x00000003), + /* FX*/ DUP16(0x00000003) + } +}; + +CACHE_ALIGN +TWaitState MMU_struct::MMU_WAIT16[2][16] = { + { 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1, 1, 1 }, //arm9 + { 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1, 1, 1 }, //arm7 +}; + +CACHE_ALIGN +TWaitState MMU_struct::MMU_WAIT32[2][16] = { + { 1, 1, 1, 1, 1, 2, 2, 1, 8, 8, 5, 1, 1, 1, 1, 1 }, //arm9 + { 1, 1, 1, 1, 1, 1, 1, 1, 8, 8, 5, 1, 1, 1, 1, 1 }, //arm7 +}; + +////////////////////////////////////////////////////////////// + +//------------- +//VRAM MEMORY MAPPING +//------------- +//(Everything is mapped through to ARM9_LCD in blocks of 16KB) + +//for all of the below, values = 41 indicate unmapped memory +#define VRAM_PAGE_UNMAPPED 41 + +#define VRAM_LCDC_PAGES 41 +u8 vram_lcdc_map[VRAM_LCDC_PAGES]; + +//in the range of 0x06000000 - 0x06800000 in 16KB pages (the ARM9 vram mappable area) +//this maps to 16KB pages in the LCDC buffer which is what will actually contain the data +u8 vram_arm9_map[VRAM_ARM9_PAGES]; + +//this chooses which banks are mapped in the 128K banks starting at 0x06000000 in ARM7 +u8 vram_arm7_map[2]; + +//-----> +//consider these later, for better recordkeeping, instead of using the u8* in ARM9Mem + +////for each 128KB texture slot, this maps to a 16KB starting page in the LCDC buffer +//#define VRAM_TEX_SLOTS 4 +//u8 vram_tex_map[VRAM_TEX_SLOTS]; +// +////for each 16KB tex palette slot, this maps to a 16KB starting page in the LCDC buffer +//#define VRAM_TEX_PALETTE_SLOTS 6 +//u8 vram_tex_palette_map[VRAM_TEX_PALETTE_SLOTS]; + +//<--------- + +#define VRAM_BANKS 9 +#define VRAM_BANK_A 0 +#define VRAM_BANK_B 1 +#define VRAM_BANK_C 2 +#define VRAM_BANK_D 3 +#define VRAM_BANK_E 4 +#define VRAM_BANK_F 5 +#define VRAM_BANK_G 6 +#define VRAM_BANK_H 7 +#define VRAM_BANK_I 8 + +#define VRAM_PAGE_ABG 0 +#define VRAM_PAGE_BBG 128 +#define VRAM_PAGE_AOBJ 256 +#define VRAM_PAGE_BOBJ 384 + +void MMU_VRAM_unmap_all(); + +struct TVramBankInfo { + u8 page_addr, num_pages; +}; + +static const TVramBankInfo vram_bank_info[VRAM_BANKS] = { + {0,8}, + {8,8}, + {16,8}, + {24,8}, + {32,4}, + {36,1}, + {37,1}, + {38,2}, + {40,1} +}; + +//this is to remind you that the LCDC mapping returns a strange value (not 0x06800000) as you would expect +//in order to play nicely with the MMU address and mask tables +#define LCDC_HACKY_LOCATION 0x06000000 + +//maps an ARM9 BG/OBJ or LCDC address into an LCDC address, and informs the caller of whether it isn't mapped +//TODO - in cases where this does some mapping work, we could bypass the logic at the end of the _read* and _write* routines +//this is a good optimization to consider +template +static FORCEINLINE u32 MMU_LCDmap(u32 addr, bool& unmapped) +{ + unmapped = false; + + //in case the address is entirely outside of the interesting ranges + if(addr < 0x06000000) return addr; + if(addr >= 0x07000000) return addr; + + //shared wram mapping for arm7 + if(PROCNUM==ARMCPU_ARM7) + { + //necessary? not sure + //addr &= 0x3FFFF; + //addr += 0x06000000; + u32 ofs = addr & 0x1FFFF; + u32 bank = (addr >> 17)&1; + if(vram_arm7_map[bank] == VRAM_PAGE_UNMAPPED) + { + unmapped = true; + return 0; + } + return LCDC_HACKY_LOCATION + (vram_arm7_map[bank]<<14) + ofs; + } + + //handle LCD memory mirroring + if(addr>=0x068A4000) + addr = 0x06800000 + + //(addr%0xA4000); //yuck!! is this even how it mirrors? but we have to keep from overrunning the buffer somehow + (addr&0x80000); //just as likely to be right (I have no clue how it should work) but faster. + + u32 vram_page; + u32 ofs = addr & 0x3FFF; + + //return addresses in LCDC range + if(addr>=0x06800000) + { + //already in LCDC range. just look it up to see whether it is unmapped + vram_page = (addr>>14)&63; + assert(vram_page>14)&(VRAM_ARM9_PAGES-1); + assert(vram_page(vram_addr,unmapped); + if(unmapped) return 0; + else return ARM9Mem.ARM9_LCD + (vram_addr - LCDC_HACKY_LOCATION); +} + + +template +void DMAtoVRAMmapping() +{ + //THIS IS ALSO DANGEROUS!!!!!! + //but i dont think it needs to be done + + /*u32 dst = DMADst[ARMCPU_ARM9][DMA_CHANNEL]; + + bool unmapped; + dst = MMU_LCDmap(dst,unmapped); + + DMADst[ARMCPU_ARM9][DMA_CHANNEL] = dst;*/ +} + +#define LOG_VRAM_ERROR() LOG("No data for block %i MST %i\n", block, VRAMBankCnt & 0x07); + + +struct VramConfiguration { + + enum Purpose { + OFF, INVALID, ABG, BBG, AOBJ, BOBJ, LCDC, ARM7, TEX, TEXPAL, ABGEXTPAL, BBGEXTPAL, AOBJEXTPAL, BOBJEXTPAL + }; + + struct BankInfo { + Purpose purpose; + int ofs; + } banks[VRAM_BANKS]; + + void clear() { + for(int i=0;i= VRAM_BANK_H) block++; + + u8 VRAMBankCnt = T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x240 + block); + + //do nothing if the bank isnt enabled + u8 en = VRAMBankCnt & 0x80; + if(!en) return; + + int mst,ofs=0; + switch(bank) { + case VRAM_BANK_A: + case VRAM_BANK_B: + mst = VRAMBankCnt & 3; + ofs = (VRAMBankCnt>>3) & 3; + switch(mst) + { + case 0: //LCDC + vramConfiguration.banks[bank].purpose = VramConfiguration::LCDC; + MMU_vram_lcdc(bank); + if(ofs != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); + break; + case 1: //ABG + vramConfiguration.banks[bank].purpose = VramConfiguration::ABG; + //MMU_vram_lcdc(bank); + MMU_vram_arm9(bank,VRAM_PAGE_ABG+ofs*8); + break; + case 2: //AOBJ + vramConfiguration.banks[bank].purpose = VramConfiguration::AOBJ; + switch(ofs) { + case 0: + case 1: + //MMU_vram_lcdc(bank); + MMU_vram_arm9(bank,VRAM_PAGE_AOBJ+ofs*8); + break; + default: + PROGINFO("Unsupported ofs setting %d for engine A OBJ vram bank %c\n", ofs, 'A'+bank); + } + break; + case 3: //texture + vramConfiguration.banks[bank].purpose = VramConfiguration::TEX; + ARM9Mem.texInfo.textureSlotAddr[ofs] = MMU_vram_physical(vram_bank_info[bank].page_addr); + break; + default: goto unsupported_mst; + } + break; + + case VRAM_BANK_C: + case VRAM_BANK_D: + mst = VRAMBankCnt & 7; + ofs = (VRAMBankCnt>>3) & 3; + switch(mst) + { + case 0: //LCDC + vramConfiguration.banks[bank].purpose = VramConfiguration::LCDC; + MMU_vram_lcdc(bank); + if(ofs != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); + break; + case 1: //ABG + vramConfiguration.banks[bank].purpose = VramConfiguration::ABG; + //MMU_vram_lcdc(bank); + MMU_vram_arm9(bank,VRAM_PAGE_ABG+ofs*8); + break; + case 2: //arm7 + vramConfiguration.banks[bank].purpose = VramConfiguration::ARM7; + if(bank == 2) T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x240, T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x240) | 2); + if(bank == 3) T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x240, T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x240) | 1); + switch(ofs) { + case 0: + case 1: + vram_arm7_map[ofs] = vram_bank_info[bank].page_addr; + break; + default: + PROGINFO("Unsupported ofs setting %d for arm7 vram bank %c\n", ofs, 'A'+bank); + } + + break; + case 3: //texture + vramConfiguration.banks[bank].purpose = VramConfiguration::TEX; + ARM9Mem.texInfo.textureSlotAddr[ofs] = MMU_vram_physical(vram_bank_info[bank].page_addr); + break; + case 4: //BGB or BOBJ + //MMU_vram_lcdc(bank); + if(bank == VRAM_BANK_C) { + vramConfiguration.banks[bank].purpose = VramConfiguration::BBG; + MMU_vram_arm9(bank,VRAM_PAGE_BBG); //BBG + } else { + vramConfiguration.banks[bank].purpose = VramConfiguration::BOBJ; + MMU_vram_arm9(bank,VRAM_PAGE_BOBJ); //BOBJ + } + if(ofs != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); + break; + default: goto unsupported_mst; + } + break; + + case VRAM_BANK_E: + mst = VRAMBankCnt & 7; + if(((VRAMBankCnt>>3)&3) != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); + switch(mst) { + case 0: //LCDC + vramConfiguration.banks[bank].purpose = VramConfiguration::LCDC; + MMU_vram_lcdc(bank); + break; + case 1: //ABG + vramConfiguration.banks[bank].purpose = VramConfiguration::ABG; + //MMU_vram_lcdc(bank); + MMU_vram_arm9(bank,VRAM_PAGE_ABG); + break; + case 2: //AOBJ + //MMU_vram_lcdc(bank); + vramConfiguration.banks[bank].purpose = VramConfiguration::AOBJ; + MMU_vram_arm9(bank,VRAM_PAGE_AOBJ); + break; + case 3: //texture palette + vramConfiguration.banks[bank].purpose = VramConfiguration::TEXPAL; + ARM9Mem.texInfo.texPalSlot[0] = MMU_vram_physical(vram_bank_info[bank].page_addr); + ARM9Mem.texInfo.texPalSlot[1] = MMU_vram_physical(vram_bank_info[bank].page_addr+1); + ARM9Mem.texInfo.texPalSlot[2] = MMU_vram_physical(vram_bank_info[bank].page_addr+2); + ARM9Mem.texInfo.texPalSlot[3] = MMU_vram_physical(vram_bank_info[bank].page_addr+3); + break; + case 4: //A BG extended palette + vramConfiguration.banks[bank].purpose = VramConfiguration::ABGEXTPAL; + ARM9Mem.ExtPal[0][0] = MMU_vram_physical(vram_bank_info[bank].page_addr); + ARM9Mem.ExtPal[0][1] = ARM9Mem.ExtPal[0][0] + ADDRESS_STEP_8KB; + ARM9Mem.ExtPal[0][2] = ARM9Mem.ExtPal[0][1] + ADDRESS_STEP_8KB; + ARM9Mem.ExtPal[0][3] = ARM9Mem.ExtPal[0][2] + ADDRESS_STEP_8KB; + break; + default: goto unsupported_mst; + } + break; + + case VRAM_BANK_F: + case VRAM_BANK_G: { + mst = VRAMBankCnt & 7; + ofs = (VRAMBankCnt>>3) & 3; + const int pageofslut[] = {0,1,4,5}; + const int pageofs = pageofslut[ofs]; + switch(mst) + { + case 0: //LCDC + vramConfiguration.banks[bank].purpose = VramConfiguration::LCDC; + MMU_vram_lcdc(bank); + if(ofs != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); + break; + case 1: //ABG + vramConfiguration.banks[bank].purpose = VramConfiguration::ABG; + //MMU_vram_lcdc(bank); + MMU_vram_arm9(bank,VRAM_PAGE_ABG+pageofs); + MMU_vram_arm9(bank,VRAM_PAGE_ABG+pageofs+2); //unexpected mirroring (required by spyro eternal night) + break; + case 2: //AOBJ + vramConfiguration.banks[bank].purpose = VramConfiguration::AOBJ; + //MMU_vram_lcdc(bank); + MMU_vram_arm9(bank,VRAM_PAGE_AOBJ+pageofs); + MMU_vram_arm9(bank,VRAM_PAGE_AOBJ+pageofs+2); //unexpected mirroring - I have no proof, but it is inferred from the ABG above + break; + case 3: //texture palette + vramConfiguration.banks[bank].purpose = VramConfiguration::TEXPAL; + ARM9Mem.texInfo.texPalSlot[pageofs] = MMU_vram_physical(vram_bank_info[bank].page_addr); + break; + case 4: //A BG extended palette + switch(ofs) { + case 0: + case 1: + vramConfiguration.banks[bank].purpose = VramConfiguration::ABGEXTPAL; + ARM9Mem.ExtPal[0][ofs*2] = MMU_vram_physical(vram_bank_info[bank].page_addr); + ARM9Mem.ExtPal[0][ofs*2+1] = ARM9Mem.ExtPal[0][ofs*2] + ADDRESS_STEP_8KB; + break; + default: + vramConfiguration.banks[bank].purpose = VramConfiguration::INVALID; + PROGINFO("Unsupported ofs setting %d for engine A bgextpal vram bank %c\n", ofs, 'A'+bank); + break; + } + break; + case 5: //A OBJ extended palette + vramConfiguration.banks[bank].purpose = VramConfiguration::AOBJEXTPAL; + ARM9Mem.ObjExtPal[0][0] = MMU_vram_physical(vram_bank_info[bank].page_addr); + ARM9Mem.ObjExtPal[0][1] = ARM9Mem.ObjExtPal[0][1] + ADDRESS_STEP_8KB; + if(ofs != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); + break; + default: goto unsupported_mst; + } + break; + } + + case VRAM_BANK_H: + mst = VRAMBankCnt & 3; + if(((VRAMBankCnt>>3)&3) != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); + switch(mst) + { + case 0: //LCDC + vramConfiguration.banks[bank].purpose = VramConfiguration::LCDC; + MMU_vram_lcdc(bank); + break; + case 1: //BBG + vramConfiguration.banks[bank].purpose = VramConfiguration::BBG; + //MMU_vram_lcdc(bank); + MMU_vram_arm9(bank,VRAM_PAGE_BBG); + MMU_vram_arm9(bank,VRAM_PAGE_BBG + 4); //unexpected mirroring + break; + case 2: //B BG extended palette + vramConfiguration.banks[bank].purpose = VramConfiguration::BBGEXTPAL; + ARM9Mem.ExtPal[1][0] = MMU_vram_physical(vram_bank_info[bank].page_addr); + ARM9Mem.ExtPal[1][1] = ARM9Mem.ExtPal[1][0] + ADDRESS_STEP_8KB; + ARM9Mem.ExtPal[1][2] = ARM9Mem.ExtPal[1][1] + ADDRESS_STEP_8KB; + ARM9Mem.ExtPal[1][3] = ARM9Mem.ExtPal[1][2] + ADDRESS_STEP_8KB; + break; + default: goto unsupported_mst; + } + break; + + case VRAM_BANK_I: + mst = VRAMBankCnt & 3; + if(((VRAMBankCnt>>3)&3) != 0) PROGINFO("Bank %i: MST %i OFS %i\n", mst, ofs); + switch(mst) + { + case 0: //LCDC + vramConfiguration.banks[bank].purpose = VramConfiguration::LCDC; + MMU_vram_lcdc(bank); + break; + case 1: //BBG + vramConfiguration.banks[bank].purpose = VramConfiguration::BBG; + //MMU_vram_lcdc(bank); + MMU_vram_arm9(bank,VRAM_PAGE_BBG+2); + MMU_vram_arm9(bank,VRAM_PAGE_BBG+3); //unexpected mirroring + break; + case 2: //BOBJ + vramConfiguration.banks[bank].purpose = VramConfiguration::BOBJ; + //MMU_vram_lcdc(bank); + MMU_vram_arm9(bank,VRAM_PAGE_BOBJ); + break; + case 3: //B OBJ extended palette + vramConfiguration.banks[bank].purpose = VramConfiguration::BOBJEXTPAL; + ARM9Mem.ObjExtPal[1][0] = MMU_vram_physical(vram_bank_info[bank].page_addr); + ARM9Mem.ObjExtPal[1][1] = ARM9Mem.ObjExtPal[1][1] + ADDRESS_STEP_8KB; + break; + default: goto unsupported_mst; + } + break; + + + } //switch(bank) + + vramConfiguration.banks[bank].ofs = ofs; + + return; + +unsupported_mst: + vramConfiguration.banks[bank].purpose = VramConfiguration::INVALID; + PROGINFO("Unsupported mst setting %d for vram bank %c\n", mst, 'A'+bank); +} + +void MMU_VRAM_unmap_all() +{ + vramConfiguration.clear(); + + vram_arm7_map[0] = VRAM_PAGE_UNMAPPED; + vram_arm7_map[1] = VRAM_PAGE_UNMAPPED; + + for(int i=0;iNDS_3D_VramReconfigureSignal(); + } + + //------------------------------- + //set up arm9 mirrorings + //these are probably not entirely accurate. more study will be necessary. + //in general, we find that it is not uncommon at all for games to accidentally do this. + // + //being able to easily do these experiments was one of the primary motivations for this remake of the vram mapping system + + //see the "unexpected mirroring" comments above for some more mirroring + //so far "unexpected mirrorings" are tested by combining these games: + //despereaux - storybook subtitles + //NSMB - world map sub screen + //drill spirits EU - mission select (just for control purposes, as it doesnt use H or I) + //... + //note that the "unexpected mirroring" items above may at some point rely on being executed in a certain order. + //(sequentially A..I) + + const int types[] = {VRAM_PAGE_ABG,VRAM_PAGE_BBG,VRAM_PAGE_AOBJ,VRAM_PAGE_BOBJ}; + const int sizes[] = {32,8,16,8}; + for(int t=0;t<4;t++) + { + //the idea here is to pad out the mirrored space with copies of the mappable area, + //without respect to what is mapped within that mappable area. + //we hope that this is correct in all cases + //required for driller spirits in mission select (mapping is simple A,B,C,D to each purpose) + const int size = sizes[t]; + const int mask = size-1; + const int type = types[t]; + for(int i=size;i<128;i++) + { + const int page = type + i; + vram_arm9_map[page] = vram_arm9_map[type+(i&mask)]; + } + + //attempt #1: screen corruption in drill spirits EU + //it seems like these shouldnt pad out 128K banks (space beyond those should have remained unmapped) + //int mirrorMask = -1; + //int type = types[t]; + ////if(type==VRAM_PAGE_BOBJ) continue; + //if(type==VRAM_PAGE_AOBJ) continue; + //for(int i=0;i<128;i++) + //{ + // int page = type + i; + // if(vram_arm9_map[page] == VRAM_PAGE_UNMAPPED) + // { + // if(i==0) break; //can't mirror anything if theres nothing mapped! + // if(mirrorMask == -1) + // mirrorMask = i-1; + // vram_arm9_map[page] = vram_arm9_map[type+(i&mirrorMask)]; + // } + //} + } + + //------------------------------- +} + +////////////////////////////////////////////////////////////// +//end vram +////////////////////////////////////////////////////////////// + + + +void MMU_Init(void) { + int i; + + LOG("MMU init\n"); + + memset(&MMU, 0, sizeof(MMU_struct)); + + MMU.CART_ROM = MMU.UNUSED_RAM; + + for(i = 0x80; i<0xA0; ++i) + { + MMU_struct::MMU_MEM[0][i] = MMU.CART_ROM; + MMU_struct::MMU_MEM[1][i] = MMU.CART_ROM; + } + + MMU.DTCMRegion = 0x027C0000; + MMU.ITCMRegion = 0x00000000; + + IPC_FIFOinit(ARMCPU_ARM9); + IPC_FIFOinit(ARMCPU_ARM7); + GFX_FIFOclear(); + DISP_FIFOinit(); + + mc_init(&MMU.fw, MC_TYPE_FLASH); /* init fw device */ + mc_alloc(&MMU.fw, NDS_FW_SIZE_V1); + MMU.fw.fp = NULL; + + // Init Backup Memory device, this should really be done when the rom is loaded + //mc_init(&MMU.bupmem, MC_TYPE_AUTODETECT); + //mc_alloc(&MMU.bupmem, 1); + //MMU.bupmem.fp = NULL; + rtcInit(); + addonsInit(); + if(Mic_Init() == FALSE) + INFO("Microphone init failed.\n"); + else + INFO("Microphone successfully inited.\n"); +} + +void MMU_DeInit(void) { + LOG("MMU deinit\n"); + if (MMU.fw.fp) + fclose(MMU.fw.fp); + mc_free(&MMU.fw); + //if (MMU.bupmem.fp) + // fclose(MMU.bupmem.fp); + //mc_free(&MMU.bupmem); + addonsClose(); + Mic_DeInit(); +} + +//Card rom & ram + +u32 rom_mask = 0; + +u32 DMASrc[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}}; +u32 DMADst[2][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}}; + +void MMU_clearMem() +{ + memset(ARM9Mem.ARM9_DTCM, 0, sizeof(ARM9Mem.ARM9_DTCM)); + memset(ARM9Mem.ARM9_ITCM, 0, sizeof(ARM9Mem.ARM9_ITCM)); + memset(ARM9Mem.ARM9_LCD, 0, sizeof(ARM9Mem.ARM9_LCD)); + memset(ARM9Mem.ARM9_OAM, 0, sizeof(ARM9Mem.ARM9_OAM)); + memset(ARM9Mem.ARM9_REG, 0, sizeof(ARM9Mem.ARM9_REG)); + memset(ARM9Mem.ARM9_VMEM, 0, sizeof(ARM9Mem.ARM9_VMEM)); + memset(ARM9Mem.MAIN_MEM, 0, sizeof(ARM9Mem.MAIN_MEM)); + + memset(ARM9Mem.blank_memory, 0, sizeof(ARM9Mem.blank_memory)); + + memset(MMU.ARM7_ERAM, 0, sizeof(MMU.ARM7_ERAM)); + memset(MMU.ARM7_REG, 0, sizeof(MMU.ARM7_REG)); + memset(MMU.ARM7_WIRAM, 0, sizeof(MMU.ARM7_WIRAM)); + memset(MMU.SWIRAM, 0, sizeof(MMU.SWIRAM)); + + IPC_FIFOinit(ARMCPU_ARM9); + IPC_FIFOinit(ARMCPU_ARM7); + GFX_FIFOclear(); + DISP_FIFOinit(); + + MMU.DTCMRegion = 0x027C0000; + MMU.ITCMRegion = 0x00000000; + + memset(MMU.timer, 0, sizeof(u16) * 2 * 4); + memset(MMU.timerMODE, 0, sizeof(s32) * 2 * 4); + memset(MMU.timerON, 0, sizeof(u32) * 2 * 4); + memset(MMU.timerRUN, 0, sizeof(u32) * 2 * 4); + memset(MMU.timerReload, 0, sizeof(u16) * 2 * 4); + + memset(MMU.reg_IME, 0, sizeof(u32) * 2); + memset(MMU.reg_IE, 0, sizeof(u32) * 2); + memset(MMU.reg_IF, 0, sizeof(u32) * 2); + + memset(MMU.DMAStartTime, 0, sizeof(u32) * 2 * 4); + memset(MMU.DMACycle, 0, sizeof(s32) * 2 * 4); + memset(MMU.DMACrt, 0, sizeof(u32) * 2 * 4); + memset(MMU.DMAing, 0, sizeof(BOOL) * 2 * 4); + + memset(MMU.dscard, 0, sizeof(nds_dscard) * 2); + + MMU.SPI_CNT = 0; + MMU.AUX_SPI_CNT = 0; + + // Enable the sound speakers + T1WriteWord(MMU.ARM7_REG, 0x304, 0x0001); + + MainScreen.offset = 0; + SubScreen.offset = 192; + + MMU_VRAM_unmap_all(); + + MMU.powerMan_CntReg = 0x00; + MMU.powerMan_CntRegWritten = FALSE; + MMU.powerMan_Reg[0] = 0x0B; + MMU.powerMan_Reg[1] = 0x00; + MMU.powerMan_Reg[2] = 0x01; + MMU.powerMan_Reg[3] = 0x00; + + rtcInit(); + partie = 1; + addonsReset(); + Mic_Reset(); +#ifdef USE_GEOMETRY_FIFO_EMULATION + MMU.gfx3dCycles = 0; +#endif +} + +void MMU_setRom(u8 * rom, u32 mask) +{ + unsigned int i; + MMU.CART_ROM = rom; + MMU.CART_ROM_MASK = mask; + + for(i = 0x80; i<0xA0; ++i) + { + MMU_struct::MMU_MEM[0][i] = rom; + MMU_struct::MMU_MEM[1][i] = rom; + MMU_struct::MMU_MASK[0][i] = mask; + MMU_struct::MMU_MASK[1][i] = mask; + } + rom_mask = mask; +} + +void MMU_unsetRom() +{ + unsigned int i; + MMU.CART_ROM=MMU.UNUSED_RAM; + + for(i = 0x80; i<0xA0; ++i) + { + MMU_struct::MMU_MEM[0][i] = MMU.UNUSED_RAM; + MMU_struct::MMU_MEM[1][i] = MMU.UNUSED_RAM; + MMU_struct::MMU_MASK[0][i] = ROM_MASK; + MMU_struct::MMU_MASK[1][i] = ROM_MASK; + } + rom_mask = ROM_MASK; +} +char txt[80]; + +static void execsqrt() { + u32 ret; + u16 cnt = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B0); + + if (cnt&1) { + u64 v = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8); + ret = isqrt(v); + } else { + u32 v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8); + ret = isqrt(v); + } + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B4, 0); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B0, cnt | 0x8000); + + MMU.sqrtCycles = (nds.cycles + 26); + MMU.sqrtResult = ret; + MMU.sqrtCnt = (cnt & 0x7FFF); + MMU.sqrtRunning = TRUE; +} + +static void execdiv() { + u16 cnt = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x280); + s64 num,den; + s64 res,mod; + + switch(cnt&3) + { + case 0: + num = (s64) (s32) T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290); + den = (s64) (s32) T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298); + MMU.divCycles = (nds.cycles + 36); + break; + case 1: + case 3: //gbatek says this is same as mode 1 + num = (s64) T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290); + den = (s64) (s32) T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298); + MMU.divCycles = (nds.cycles + 68); + break; + case 2: + default: + num = (s64) T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x290); + den = (s64) T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298); + MMU.divCycles = (nds.cycles + 68); + break; + } + + if(den==0) + { + res = ((num < 0) ? 1 : -1); + mod = num; + cnt |= 0x4000; + cnt &= 0x7FFF; + } + else + { + res = num / den; + mod = num % den; + cnt &= 0x3FFF; + } + + DIVLOG("DIV %08X%08X / %08X%08X = %08X%08X\r\n", (u32)(num>>32), (u32)num, + (u32)(den>>32), (u32)den, + (u32)(res>>32), (u32)res); + + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A0, 0); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A4, 0); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A8, 0); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2AC, 0); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x280, ((cnt & 0xBFFF) | 0x8000)); + + MMU.divResult = res; + MMU.divMod = mod; + MMU.divCnt = (cnt & 0x7FFF); + MMU.divRunning = TRUE; +} + +template +void FASTCALL MMU_doDMA(u32 num) +{ + u32 src = DMASrc[PROCNUM][num]; + u32 dst = DMADst[PROCNUM][num]; + u32 taille; + + if(src==dst) + { + T1WriteLong(MMU.MMU_MEM[PROCNUM][0x40], 0xB8 + (0xC*num), T1ReadLong(MMU.MMU_MEM[PROCNUM][0x40], 0xB8 + (0xC*num)) & 0x7FFFFFFF); + return; + } + + if((!(MMU.DMACrt[PROCNUM][num]&(1<<31)))&&(!(MMU.DMACrt[PROCNUM][num]&(1<<25)))) + { /* not enabled and not to be repeated */ + MMU.DMAStartTime[PROCNUM][num] = 0; + MMU.DMACycle[PROCNUM][num] = 0; + //MMU.DMAing[PROCNUM][num] = FALSE; + return; + } + + + //word count + taille = (MMU.DMACrt[PROCNUM][num]&0x1FFFFF); + if(taille == 0) taille = 0x200000; //according to gbatek.. + + // If we are in "Main memory display" mode just copy an entire + // screen (256x192 pixels). + // Reference: http://nocash.emubase.de/gbatek.htm#dsvideocaptureandmainmemorydisplaymode + // (under DISP_MMEM_FIFO) + if ((MMU.DMAStartTime[PROCNUM][num]==4) && // Must be in main memory display mode + (taille==4) && // Word must be 4 + (((MMU.DMACrt[PROCNUM][num]>>26)&1) == 1)) // Transfer mode must be 32bit wide + taille = 24576; //256*192/2; + + if(MMU.DMAStartTime[PROCNUM][num] == 5) + taille *= 0x80; + + MMU.DMACycle[PROCNUM][num] = taille + nds.cycles; + MMU.DMAing[PROCNUM][num] = TRUE; + MMU.CheckDMAs |= (1<<(num+(PROCNUM<<2))); + + DMALOG("PROCNUM %d, dma %d src %08X dst %08X start %d taille %d repeat %s %08X\r\n", + PROCNUM, num, src, dst, MMU.DMAStartTime[PROCNUM][num], taille, + (MMU.DMACrt[PROCNUM][num]&(1<<25))?"on":"off",MMU.DMACrt[PROCNUM][num]); + + if(!(MMU.DMACrt[PROCNUM][num]&(1<<25))) + MMU.DMAStartTime[PROCNUM][num] = 0; + + // transfer + { + u32 i=0; + // 32 bit or 16 bit transfer ? + int sz = ((MMU.DMACrt[PROCNUM][num]>>26)&1)? 4 : 2; + int dstinc,srcinc; + int u=(MMU.DMACrt[PROCNUM][num]>>21); + switch(u & 0x3) { + case 0 : dstinc = sz; break; + case 1 : dstinc = -sz; break; + case 2 : dstinc = 0; break; + case 3 : dstinc = sz; break; //reload + default: + return; + } + switch((u >> 2)&0x3) { + case 0 : srcinc = sz; break; + case 1 : srcinc = -sz; break; + case 2 : srcinc = 0; break; + case 3 : // reserved + return; + default: + return; + } + + //if these do not use MMU_AT_DMA and the corresponding code in the read/write routines, + //then danny phantom title screen will be filled with a garbage char which is made by + //dmaing from 0x00000000 to 0x06000000 + if ((MMU.DMACrt[PROCNUM][num]>>26)&1) + for(; i < taille; ++i) + { + _MMU_write32(dst, _MMU_read32(src)); + dst += dstinc; + src += srcinc; + } + else + for(; i < taille; ++i) + { + _MMU_write16(dst, _MMU_read16(src)); + dst += dstinc; + src += srcinc; + } + + //write back the addresses + DMASrc[PROCNUM][num] = src; + if((u & 0x3)!=3) //but dont write back dst if we were supposed to reload + DMADst[PROCNUM][num] = dst; + + //this is probably not the best place to do it, but the dma code in ndssystem is so bad i didnt want to touch it + //until it all gets rewritten. so this is here as a reminder, at least. + //(there is no proof for this code, but it is reasonable) + T1WriteLong(MMU.MMU_MEM[PROCNUM][0x40], 0xB0+12*num, DMASrc[PROCNUM][num]); + T1WriteLong(MMU.MMU_MEM[PROCNUM][0x40], 0xB4+12*num, DMADst[PROCNUM][num]); + } +} + +#ifdef MMU_ENABLE_ACL + +INLINE void check_access(u32 adr, u32 access) { + /* every other mode: sys */ + access |= 1; + if ((NDS_ARM9.CPSR.val & 0x1F) == 0x10) { + /* is user mode access */ + access ^= 1 ; + } + if (armcp15_isAccessAllowed((armcp15_t *)NDS_ARM9.coproc[15],adr,access)==FALSE) { + execute = FALSE ; + } +} +INLINE void check_access_write(u32 adr) { + u32 access = CP15_ACCESS_WRITE; + check_access(adr, access) +} + +u8 FASTCALL MMU_read8_acl(u32 proc, u32 adr, u32 access) +{ + /* on arm9 we need to check the MPU regions */ + if (proc == ARMCPU_ARM9) + check_access(u32 adr, u32 access); + return MMU_read8(proc,adr); +} +u16 FASTCALL MMU_read16_acl(u32 proc, u32 adr, u32 access) +{ + /* on arm9 we need to check the MPU regions */ + if (proc == ARMCPU_ARM9) + check_access(u32 adr, u32 access); + return MMU_read16(proc,adr); +} +u32 FASTCALL MMU_read32_acl(u32 proc, u32 adr, u32 access) +{ + /* on arm9 we need to check the MPU regions */ + if (proc == ARMCPU_ARM9) + check_access(u32 adr, u32 access); + return MMU_read32(proc,adr); +} + +void FASTCALL MMU_write8_acl(u32 proc, u32 adr, u8 val) +{ + /* check MPU region on ARM9 */ + if (proc == ARMCPU_ARM9) + check_access_write(adr); + MMU_write8(proc,adr,val); +} +void FASTCALL MMU_write16_acl(u32 proc, u32 adr, u16 val) +{ + /* check MPU region on ARM9 */ + if (proc == ARMCPU_ARM9) + check_access_write(adr); + MMU_write16(proc,adr,val) ; +} +void FASTCALL MMU_write32_acl(u32 proc, u32 adr, u32 val) +{ + /* check MPU region on ARM9 */ + if (proc == ARMCPU_ARM9) + check_access_write(adr); + MMU_write32(proc,adr,val) ; +} +#endif + +//a stub for memory profiler, if we choose to re-add it +#define PROFILE_PREFETCH 1 +#define profile_memory_access(X,Y,Z) + + +static INLINE void MMU_IPCSync(u8 proc, u32 val) +{ + //INFO("IPC%s sync 0x%04X (0x%02X|%02X)\n", proc?"7":"9", val, val >> 8, val & 0xFF); + u32 sync_l = T1ReadLong(MMU.MMU_MEM[proc][0x40], 0x180) & 0xFFFF; + u32 sync_r = T1ReadLong(MMU.MMU_MEM[proc^1][0x40], 0x180) & 0xFFFF; + + sync_l = ( sync_l & 0x000F ) | ( val & 0x0F00 ); + sync_r = ( sync_r & 0x6F00 ) | ( (val >> 8) & 0x000F ); + + sync_l |= val & 0x6000; + + T1WriteLong(MMU.MMU_MEM[proc][0x40], 0x180, sync_l); + T1WriteLong(MMU.MMU_MEM[proc^1][0x40], 0x180, sync_r); + + if ((sync_l & 0x2000) && (sync_r & 0x4000)) + setIF(proc^1, ( 1 << 16 )); +} + +static INLINE void write_auxspicnt(const int proc, const int size, const int adr, const int val) +{ + //why val==0 to reset? is it a particular bit? its not bit 6... + switch(size) { + case 16: + MMU.AUX_SPI_CNT = val; + if (val == 0) MMU_new.backupDevice.reset_command(); + break; + case 8: + switch(adr) { + case 0: + T1WriteByte((u8*)&MMU.AUX_SPI_CNT,0,val); + if (val == 0) MMU_new.backupDevice.reset_command(); + break; + case 1: + T1WriteByte((u8*)&MMU.AUX_SPI_CNT,1,val); + break; + } + } +} + + +//================================================================================================== ARM9 * +//========================================================================================================= +//========================================================================================================= +//================================================= MMU write 08 +void FASTCALL _MMU_ARM9_write08(u32 adr, u8 val) +{ + mmu_log_debug_ARM9(adr, "(write08) %0x%X", val); + + if(adr < 0x02000000) + { + T1WriteByte(ARM9Mem.ARM9_ITCM, adr&0x7FFF, val); + return; + } + + if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) + { + addon.write08(adr, val); + return; + } + + adr &= 0x0FFFFFFF; + + if (adr >> 24 == 4) + { + switch(adr) + { + case REG_DISPA_DISP3DCNT: + { + u32 &disp3dcnt = MainScreen.gpu->dispx_st->dispA_DISP3DCNT.val; + disp3dcnt = (disp3dcnt&0xFF00) | val; + gfx3d_Control(disp3dcnt); + break; + } + case REG_DISPA_DISP3DCNT+1: + { + u32 &disp3dcnt = MainScreen.gpu->dispx_st->dispA_DISP3DCNT.val; + disp3dcnt = (disp3dcnt&0x00FF) | (val<<8); + gfx3d_Control(disp3dcnt); + break; + } + + case REG_DISPA_WIN0H: + GPU_setWIN0_H1(MainScreen.gpu, val); + break ; + case REG_DISPA_WIN0H+1: + GPU_setWIN0_H0 (MainScreen.gpu, val); + break ; + case REG_DISPA_WIN1H: + GPU_setWIN1_H1 (MainScreen.gpu,val); + break ; + case REG_DISPA_WIN1H+1: + GPU_setWIN1_H0 (MainScreen.gpu,val); + break ; + + case REG_DISPB_WIN0H: + GPU_setWIN0_H1(SubScreen.gpu,val); + break ; + case REG_DISPB_WIN0H+1: + GPU_setWIN0_H0(SubScreen.gpu,val); + break ; + case REG_DISPB_WIN1H: + GPU_setWIN1_H1(SubScreen.gpu,val); + break ; + case REG_DISPB_WIN1H+1: + GPU_setWIN1_H0(SubScreen.gpu,val); + break ; + + case REG_DISPA_WIN0V: + GPU_setWIN0_V1(MainScreen.gpu,val) ; + break ; + case REG_DISPA_WIN0V+1: + GPU_setWIN0_V0(MainScreen.gpu,val) ; + break ; + case REG_DISPA_WIN1V: + GPU_setWIN1_V1(MainScreen.gpu,val) ; + break ; + case REG_DISPA_WIN1V+1: + GPU_setWIN1_V0(MainScreen.gpu,val) ; + break ; + + case REG_DISPB_WIN0V: + GPU_setWIN0_V1(SubScreen.gpu,val) ; + break ; + case REG_DISPB_WIN0V+1: + GPU_setWIN0_V0(SubScreen.gpu,val) ; + break ; + case REG_DISPB_WIN1V: + GPU_setWIN1_V1(SubScreen.gpu,val) ; + break ; + case REG_DISPB_WIN1V+1: + GPU_setWIN1_V0(SubScreen.gpu,val) ; + break ; + + case REG_DISPA_WININ: + GPU_setWININ0(MainScreen.gpu,val) ; + break ; + case REG_DISPA_WININ+1: + GPU_setWININ1(MainScreen.gpu,val) ; + break ; + case REG_DISPA_WINOUT: + GPU_setWINOUT(MainScreen.gpu,val) ; + break ; + case REG_DISPA_WINOUT+1: + GPU_setWINOBJ(MainScreen.gpu,val); + break ; + + case REG_DISPB_WININ: + GPU_setWININ0(SubScreen.gpu,val) ; + break ; + case REG_DISPB_WININ+1: + GPU_setWININ1(SubScreen.gpu,val) ; + break ; + case REG_DISPB_WINOUT: + GPU_setWINOUT(SubScreen.gpu,val) ; + break ; + case REG_DISPB_WINOUT+1: + GPU_setWINOBJ(SubScreen.gpu,val) ; + break ; + + case REG_DISPA_BLDCNT: + GPU_setBLDCNT_HIGH(MainScreen.gpu,val); + break; + case REG_DISPA_BLDCNT+1: + GPU_setBLDCNT_LOW (MainScreen.gpu,val); + break; + + case REG_DISPB_BLDCNT: + GPU_setBLDCNT_HIGH (SubScreen.gpu,val); + break; + case REG_DISPB_BLDCNT+1: + GPU_setBLDCNT_LOW (SubScreen.gpu,val); + break; + + case REG_DISPA_BLDALPHA: + MainScreen.gpu->setBLDALPHA_EVB(val); + break; + case REG_DISPA_BLDALPHA+1: + MainScreen.gpu->setBLDALPHA_EVA(val); + break; + + case REG_DISPB_BLDALPHA: + SubScreen.gpu->setBLDALPHA_EVB(val); + break; + case REG_DISPB_BLDALPHA+1: + SubScreen.gpu->setBLDALPHA_EVA(val); + break; + + case REG_DISPA_BLDY: + GPU_setBLDY_EVY(MainScreen.gpu,val) ; + break ; + case REG_DISPB_BLDY: + GPU_setBLDY_EVY(SubScreen.gpu,val) ; + break; + + case REG_AUXSPICNT: + write_auxspicnt(9,8,0,val); + return; + case REG_AUXSPICNT+1: + write_auxspicnt(9,8,1,val); + return; + + + case 0x4000247: + /* Update WRAMSTAT at the ARM7 side */ + T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x241, val); + break; + + case REG_VRAMCNTA: + case REG_VRAMCNTB: + case REG_VRAMCNTC: + case REG_VRAMCNTD: + case REG_VRAMCNTE: + case REG_VRAMCNTF: + case REG_VRAMCNTG: + case REG_VRAMCNTH: + case REG_VRAMCNTI: + MMU_VRAMmapControl(adr-REG_VRAMCNTA, val); + break; + case REG_DISPA_DISPMMEMFIFO: + { + DISP_FIFOsend(val); + return; + } + #ifdef LOG_CARD + case 0x040001A0 : /* TODO (clear): ??? */ + case 0x040001A1 : + case 0x040001A2 : + case 0x040001A8 : + case 0x040001A9 : + case 0x040001AA : + case 0x040001AB : + case 0x040001AC : + case 0x040001AD : + case 0x040001AE : + case 0x040001AF : + LOG("%08X : %02X\r\n", adr, val); + #endif + } + + MMU.MMU_MEM[ARMCPU_ARM9][0x40][adr&MMU.MMU_MASK[ARMCPU_ARM9][adr>>20]]=val; + return; + } + + bool unmapped; + adr = MMU_LCDmap(adr, unmapped); + if(unmapped) return; + + // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [shash] + MMU.MMU_MEM[ARMCPU_ARM9][adr>>20][adr&MMU.MMU_MASK[ARMCPU_ARM9][adr>>20]]=val; +} + +//================================================= MMU ARM9 write 16 +void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val) +{ + mmu_log_debug_ARM9(adr, "(write16) %0x%X", val); + + if (adr < 0x02000000) + { + T1WriteWord(ARM9Mem.ARM9_ITCM, adr&0x7FFF, val); + return; + } + + if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) + { + addon.write16(adr, val); + return; + } + + adr &= 0x0FFFFFFF; + + if((adr >> 24) == 4) + { + switch (adr >> 4) + { + //toon table + case 0x0400038: + case 0x0400039: + case 0x040003A: + case 0x040003B: + ((u16 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF)>>1] = val; + gfx3d_UpdateToonTable((adr & 0x3F) >> 1, val); + return; + } + // Address is an IO register + switch(adr) + { + case REG_DISPA_BG2XL: MainScreen.gpu->setAffineStartWord(2,0,val,0); break; + case REG_DISPA_BG2XH: MainScreen.gpu->setAffineStartWord(2,0,val,1); break; + case REG_DISPA_BG2YL: MainScreen.gpu->setAffineStartWord(2,1,val,0); break; + case REG_DISPA_BG2YH: MainScreen.gpu->setAffineStartWord(2,1,val,1); break; + case REG_DISPA_BG3XL: MainScreen.gpu->setAffineStartWord(3,0,val,0); break; + case REG_DISPA_BG3XH: MainScreen.gpu->setAffineStartWord(3,0,val,1); break; + case REG_DISPA_BG3YL: MainScreen.gpu->setAffineStartWord(3,1,val,0); break; + case REG_DISPA_BG3YH: MainScreen.gpu->setAffineStartWord(3,1,val,1); break; + case REG_DISPB_BG2XL: SubScreen.gpu->setAffineStartWord(2,0,val,0); break; + case REG_DISPB_BG2XH: SubScreen.gpu->setAffineStartWord(2,0,val,1); break; + case REG_DISPB_BG2YL: SubScreen.gpu->setAffineStartWord(2,1,val,0); break; + case REG_DISPB_BG2YH: SubScreen.gpu->setAffineStartWord(2,1,val,1); break; + case REG_DISPB_BG3XL: SubScreen.gpu->setAffineStartWord(3,0,val,0); break; + case REG_DISPB_BG3XH: SubScreen.gpu->setAffineStartWord(3,0,val,1); break; + case REG_DISPB_BG3YL: SubScreen.gpu->setAffineStartWord(3,1,val,0); break; + case REG_DISPB_BG3YH: SubScreen.gpu->setAffineStartWord(3,1,val,1); break; + + case REG_DISPA_DISP3DCNT: + { + MainScreen.gpu->dispx_st->dispA_DISP3DCNT.val = val; + gfx3d_Control(val); + break; + } + + // Alpha test reference value - Parameters:1 + case 0x04000340: + { + ((u16 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x340>>1] = val; + gfx3d_glAlphaFunc(val); + return; + } + // Clear background color setup - Parameters:2 + case 0x04000350: + { + ((u16 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x350>>1] = val; + gfx3d_glClearColor(val); + return; + } + // Clear background depth setup - Parameters:2 + case 0x04000354: + { + ((u16 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x354>>1] = val; + gfx3d_glClearDepth(val); + return; + } + // Fog Color - Parameters:4b + case 0x04000358: + { + ((u16 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x358>>1] = val; + gfx3d_glFogColor(val); + return; + } + case 0x0400035C: + { + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x35C>>1] = val; + gfx3d_glFogOffset(val); + return; + } + + case REG_DISPA_BLDCNT: + GPU_setBLDCNT(MainScreen.gpu,val) ; + break ; + case REG_DISPB_BLDCNT: + GPU_setBLDCNT(SubScreen.gpu,val) ; + break ; + case REG_DISPA_BLDALPHA: + MainScreen.gpu->setBLDALPHA(val); + break ; + case REG_DISPB_BLDALPHA: + SubScreen.gpu->setBLDALPHA(val); + break ; + case REG_DISPA_BLDY: + GPU_setBLDY_EVY(MainScreen.gpu,val) ; + break ; + case REG_DISPB_BLDY: + GPU_setBLDY_EVY(SubScreen.gpu,val) ; + break; + case REG_DISPA_MASTERBRIGHT: + GPU_setMasterBrightness (MainScreen.gpu, val); + break; + /* + case REG_DISPA_MOSAIC: + GPU_setMOSAIC(MainScreen.gpu,val) ; + break ; + case REG_DISPB_MOSAIC: + GPU_setMOSAIC(SubScreen.gpu,val) ; + break ; + */ + case REG_DISPA_BG0HOFS: + GPU_setBGxHOFS(0, MainScreen.gpu, val); + break; + case REG_DISPA_BG0VOFS: + GPU_setBGxVOFS(0, MainScreen.gpu, val); + break; + case REG_DISPA_BG1HOFS: + GPU_setBGxHOFS(1, MainScreen.gpu, val); + break; + case REG_DISPA_BG1VOFS: + GPU_setBGxVOFS(1, MainScreen.gpu, val); + break; + case REG_DISPA_BG2HOFS: + GPU_setBGxHOFS(2, MainScreen.gpu, val); + break; + case REG_DISPA_BG2VOFS: + GPU_setBGxVOFS(2, MainScreen.gpu, val); + break; + case REG_DISPA_BG3HOFS: + GPU_setBGxHOFS(3, MainScreen.gpu, val); + break; + case REG_DISPA_BG3VOFS: + GPU_setBGxVOFS(3, MainScreen.gpu, val); + break; + + case REG_DISPA_WIN0H: + GPU_setWIN0_H (MainScreen.gpu,val) ; + break ; + case REG_DISPA_WIN1H: + GPU_setWIN1_H(MainScreen.gpu,val) ; + break ; + case REG_DISPB_WIN0H: + GPU_setWIN0_H(SubScreen.gpu,val) ; + break ; + case REG_DISPB_WIN1H: + GPU_setWIN1_H(SubScreen.gpu,val) ; + break ; + case REG_DISPA_WIN0V: + GPU_setWIN0_V(MainScreen.gpu,val) ; + break ; + case REG_DISPA_WIN1V: + GPU_setWIN1_V(MainScreen.gpu,val) ; + break ; + case REG_DISPB_WIN0V: + GPU_setWIN0_V(SubScreen.gpu,val) ; + break ; + case REG_DISPB_WIN1V: + GPU_setWIN1_V(SubScreen.gpu,val) ; + break ; + case REG_DISPA_WININ: + GPU_setWININ(MainScreen.gpu, val) ; + break ; + case REG_DISPA_WINOUT: + GPU_setWINOUT16(MainScreen.gpu, val) ; + break ; + + case REG_DISPB_BG0HOFS: + GPU_setBGxHOFS(0, SubScreen.gpu, val); + break; + case REG_DISPB_BG0VOFS: + GPU_setBGxVOFS(0, SubScreen.gpu, val); + break; + case REG_DISPB_BG1HOFS: + GPU_setBGxHOFS(1, SubScreen.gpu, val); + break; + case REG_DISPB_BG1VOFS: + GPU_setBGxVOFS(1, SubScreen.gpu, val); + break; + case REG_DISPB_BG2HOFS: + GPU_setBGxHOFS(2, SubScreen.gpu, val); + break; + case REG_DISPB_BG2VOFS: + GPU_setBGxVOFS(2, SubScreen.gpu, val); + break; + case REG_DISPB_BG3HOFS: + GPU_setBGxHOFS(3, SubScreen.gpu, val); + break; + case REG_DISPB_BG3VOFS: + GPU_setBGxVOFS(3, SubScreen.gpu, val); + break; + case REG_DISPB_WININ: + GPU_setWININ(SubScreen.gpu, val) ; + break ; + case REG_DISPB_WINOUT: + GPU_setWINOUT16(SubScreen.gpu, val) ; + break ; + + case REG_DISPB_MASTERBRIGHT: + GPU_setMasterBrightness (SubScreen.gpu, val); + break; + + case REG_POWCNT1 : + { +// TODO: make this later +#if 0 + u8 _LCD = (val) & 0x01; + u8 _2DEngineA = (val>>1) & 0x01; + u8 _2DEngineB = (val>>9) & 0x01; + u8 _3DRender = (val>>2) & 0x01; + u8 _3DGeometry = (val>>3) & 0x01; +#endif + if(val & (1<<15)) + { + //LOG("Main core on top\n"); + MainScreen.offset = 0; + SubScreen.offset = 192; + } + else + { + //LOG("Main core on bottom\n"); + MainScreen.offset = 192; + SubScreen.offset = 0; + } + + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x304, val); + } + + return; + + case REG_EXMEMCNT: + { + u16 oldval = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x204); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x204, val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x204, (val & 0xFF80) | (oldval & 0x7F)); + return; + } + + case REG_AUXSPICNT: + write_auxspicnt(9,16,0,val); + return; + + case REG_AUXSPIDATA: + if(val!=0) + MMU.AUX_SPI_CMD = val & 0xFF; + + //T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU.bupmem, val)); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, MMU_new.backupDevice.data_command((u8)val)); + return; + + case REG_DISPA_BG0CNT : + //GPULOG("MAIN BG0 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(MainScreen.gpu, 0, val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x8, val); + return; + case REG_DISPA_BG1CNT : + //GPULOG("MAIN BG1 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(MainScreen.gpu, 1, val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xA, val); + return; + case REG_DISPA_BG2CNT : + //GPULOG("MAIN BG2 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(MainScreen.gpu, 2, val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xC, val); + return; + case REG_DISPA_BG3CNT : + //GPULOG("MAIN BG3 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(MainScreen.gpu, 3, val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xE, val); + return; + case REG_DISPB_BG0CNT : + //GPULOG("SUB BG0 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(SubScreen.gpu, 0, val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1008, val); + return; + case REG_DISPB_BG1CNT : + //GPULOG("SUB BG1 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(SubScreen.gpu, 1, val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x100A, val); + return; + case REG_DISPB_BG2CNT : + //GPULOG("SUB BG2 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(SubScreen.gpu, 2, val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x100C, val); + return; + case REG_DISPB_BG3CNT : + //GPULOG("SUB BG3 SETPROP 16B %08X\r\n", val); + GPU_setBGProp(SubScreen.gpu, 3, val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x100E, val); + return; + + case REG_VRAMCNTA: + case REG_VRAMCNTC: + case REG_VRAMCNTE: + MMU_VRAMmapControl(adr-REG_VRAMCNTA, val & 0xFF); + MMU_VRAMmapControl(adr-REG_VRAMCNTA+1, val >> 8); + break; + case REG_VRAMCNTG: + MMU_VRAMmapControl(adr-REG_VRAMCNTA, val & 0xFF); + /* Update WRAMSTAT at the ARM7 side */ + T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x241, val >> 8); + break; + case REG_VRAMCNTH: + MMU_VRAMmapControl(adr-REG_VRAMCNTA, val & 0xFF); + MMU_VRAMmapControl(adr-REG_VRAMCNTA+1, val >> 8); + break; + + case REG_IME: + { + u32 old_val = MMU.reg_IME[ARMCPU_ARM9]; + u32 new_val = val & 0x01; + MMU.reg_IME[ARMCPU_ARM9] = new_val; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x208, val); +#ifndef NEW_IRQ + if ( new_val && old_val != new_val) + { + // raise an interrupt request to the CPU if needed + if ( MMU.reg_IE[ARMCPU_ARM9] & MMU.reg_IF[ARMCPU_ARM9]) + { + NDS_ARM9.wIRQ = TRUE; + NDS_ARM9.waitIRQ = FALSE; + } + } +#endif + return; + } + case REG_IE : + MMU.reg_IE[ARMCPU_ARM9] = (MMU.reg_IE[ARMCPU_ARM9]&0xFFFF0000) | val; +#ifndef NEW_IRQ + if ( MMU.reg_IME[ARMCPU_ARM9]) + { + // raise an interrupt request to the CPU if needed + if ( MMU.reg_IE[ARMCPU_ARM9] & MMU.reg_IF[ARMCPU_ARM9]) + { + NDS_ARM9.wIRQ = TRUE; + NDS_ARM9.waitIRQ = FALSE; + } + } +#endif + return; + case REG_IE + 2 : + MMU.reg_IE[ARMCPU_ARM9] = (MMU.reg_IE[ARMCPU_ARM9]&0xFFFF) | (((u32)val)<<16); +#ifndef NEW_IRQ + if ( MMU.reg_IME[ARMCPU_ARM9]) + { + // raise an interrupt request to the CPU if needed + if ( MMU.reg_IE[ARMCPU_ARM9] & MMU.reg_IF[ARMCPU_ARM9]) + { + NDS_ARM9.wIRQ = TRUE; + NDS_ARM9.waitIRQ = FALSE; + } + } +#endif + return; + + case REG_IF : + MMU.reg_IF[ARMCPU_ARM9] &= (~((u32)val)); + return; + case REG_IF + 2 : + MMU.reg_IF[ARMCPU_ARM9] &= (~(((u32)val)<<16)); + return; + + case REG_IPCSYNC : + MMU_IPCSync(ARMCPU_ARM9, val); + return; + + case REG_IPCFIFOCNT : + IPC_FIFOcnt(ARMCPU_ARM9, val); + return; + case REG_TM0CNTL : + case REG_TM1CNTL : + case REG_TM2CNTL : + case REG_TM3CNTL : + MMU.timerReload[ARMCPU_ARM9][(adr>>2)&3] = val; + return; + case REG_TM0CNTH : + case REG_TM1CNTH : + case REG_TM2CNTH : + case REG_TM3CNTH : + { + int timerIndex = ((adr-2)>>2)&0x3; + int mask = ((val&0x80)>>7) << timerIndex; + MMU.CheckTimers = (MMU.CheckTimers & (~mask)) | mask; + + if(val&0x80) + MMU.timer[ARMCPU_ARM9][timerIndex] = MMU.timerReload[ARMCPU_ARM9][((adr-2)>>2)&0x3]; + + MMU.timerON[ARMCPU_ARM9][((adr-2)>>2)&0x3] = val & 0x80; + + switch(val&7) + { + case 0 : + MMU.timerMODE[ARMCPU_ARM9][timerIndex] = 0+1;//ARMCPU_ARM9; + break; + case 1 : + MMU.timerMODE[ARMCPU_ARM9][timerIndex] = 6+1;//ARMCPU_ARM9; + break; + case 2 : + MMU.timerMODE[ARMCPU_ARM9][timerIndex] = 8+1;//ARMCPU_ARM9; + break; + case 3 : + MMU.timerMODE[ARMCPU_ARM9][timerIndex] = 10+1;//ARMCPU_ARM9; + break; + default : + MMU.timerMODE[ARMCPU_ARM9][timerIndex] = 0xFFFF; + break; + } + + if(!(val & 0x80)) + MMU.timerRUN[ARMCPU_ARM9][timerIndex] = FALSE; + + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & 0xFFF, val); + return; + } + + case REG_DISPA_DISPCNT : + { + u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0) & 0xFFFF0000) | val; + GPU_setVideoProp(MainScreen.gpu, v); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0, v); + return; + } + case REG_DISPA_DISPCNT+2 : + { + u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0) & 0xFFFF) | ((u32) val << 16); + GPU_setVideoProp(MainScreen.gpu, v); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0, v); + } + return; + case REG_DISPA_DISPCAPCNT : + { + u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x64) & 0xFFFF0000) | val; + GPU_set_DISPCAPCNT(v); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x64, v); + return; + } + case REG_DISPA_DISPCAPCNT + 2: + { + u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x64) & 0xFFFF) | ((u32)val << 16); + GPU_set_DISPCAPCNT(v); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x64, v); + return; + } + + case REG_DISPB_DISPCNT : + { + u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000) & 0xFFFF0000) | val; + GPU_setVideoProp(SubScreen.gpu, v); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000, v); + return; + } + case REG_DISPB_DISPCNT+2 : + { + //emu_halt(); + u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000) & 0xFFFF) | ((u32) val << 16); + GPU_setVideoProp(SubScreen.gpu, v); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000, v); + return; + } + + case REG_DMA0CNTH : + { + u32 v; + //if(val&0x8000) emu_halt(); + //LOG("16 bit dma0 %04X\r\n", val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xBA, val); + DMASrc[ARMCPU_ARM9][0] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xB0); + DMADst[ARMCPU_ARM9][0] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xB4); + DMAtoVRAMmapping<0>(); + v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xB8); + MMU.DMAStartTime[ARMCPU_ARM9][0] = (v>>27) & 0x7; + MMU.DMACrt[ARMCPU_ARM9][0] = v; + if(MMU.DMAStartTime[ARMCPU_ARM9][0] == 0) + MMU_doDMA(0); + #ifdef LOG_DMA2 + //else + { + LOG("ARMCPU_ARM9 %d, dma %d src %08X dst %08X %s\r\n", ARMCPU_ARM9, 0, DMASrc[ARMCPU_ARM9][0], DMADst[ARMCPU_ARM9][0], (val&(1<<25))?"ON":"OFF"); + } + #endif + } + return; + case REG_DMA1CNTH : + { + u32 v; + //if(val&0x8000) emu_halt(); + //LOG("16 bit dma1 %04X\r\n", val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xC6, val); + DMASrc[ARMCPU_ARM9][1] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xBC); + DMADst[ARMCPU_ARM9][1] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xC0); + DMAtoVRAMmapping<1>(); + v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xC4); + MMU.DMAStartTime[ARMCPU_ARM9][1] = (v>>27) & 0x7; + MMU.DMACrt[ARMCPU_ARM9][1] = v; + if(MMU.DMAStartTime[ARMCPU_ARM9][1] == 0) + MMU_doDMA(1); + #ifdef LOG_DMA2 + //else + { + LOG("ARMCPU_ARM9 %d, dma %d src %08X dst %08X %s\r\n", ARMCPU_ARM9, 1, DMASrc[ARMCPU_ARM9][1], DMADst[ARMCPU_ARM9][1], (val&(1<<25))?"ON":"OFF"); + } + #endif + } + return; + case REG_DMA2CNTH : + { + u32 v; + //if(val&0x8000) emu_halt(); + //LOG("16 bit dma2 %04X\r\n", val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xD2, val); + DMASrc[ARMCPU_ARM9][2] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xC8); + DMADst[ARMCPU_ARM9][2] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xCC); + DMAtoVRAMmapping<2>(); + v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xD0); + MMU.DMAStartTime[ARMCPU_ARM9][2] = (v>>27) & 0x7; + MMU.DMACrt[ARMCPU_ARM9][2] = v; + if(MMU.DMAStartTime[ARMCPU_ARM9][2] == 0) + MMU_doDMA(2); + #ifdef LOG_DMA2 + //else + { + LOG("ARMCPU_ARM9 %d, dma %d src %08X dst %08X %s\r\n", ARMCPU_ARM9, 2, DMASrc[ARMCPU_ARM9][2], DMADst[ARMCPU_ARM9][2], (val&(1<<25))?"ON":"OFF"); + } + #endif + } + return; + case REG_DMA3CNTH : + { + u32 v; + //if(val&0x8000) emu_halt(); + //LOG("16 bit dma3 %04X\r\n", val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xDE, val); + DMASrc[ARMCPU_ARM9][3] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xD4); + DMADst[ARMCPU_ARM9][3] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xD8); + DMAtoVRAMmapping<3>(); + v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xDC); + MMU.DMAStartTime[ARMCPU_ARM9][3] = (v>>27) & 0x7; + MMU.DMACrt[ARMCPU_ARM9][3] = v; + + if(MMU.DMAStartTime[ARMCPU_ARM9][3] == 0) + MMU_doDMA(3); + #ifdef LOG_DMA2 + //else + { + LOG("ARMCPU_ARM9 %d, dma %d src %08X dst %08X %s\r\n", ARMCPU_ARM9, 3, DMASrc[ARMCPU_ARM9][3], DMADst[ARMCPU_ARM9][3], (val&(1<<25))?"ON":"OFF"); + } + #endif + } + return; + //case REG_AUXSPICNT : emu_halt(); + case REG_DISPA_DISPMMEMFIFO: + { + DISP_FIFOsend(val); + return; + } + } + + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr&MMU.MMU_MASK[ARMCPU_ARM9][adr>>20], val); + return; + } + + bool unmapped; + adr = MMU_LCDmap(adr, unmapped); + if(unmapped) return; + + // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [shash] + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][adr>>20], adr&MMU.MMU_MASK[ARMCPU_ARM9][adr>>20], val); +} + +//================================================= MMU ARM9 write 32 +void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val) +{ + mmu_log_debug_ARM9(adr, "(write32) %0x%X", val); + + if(adr<0x02000000) + { + T1WriteLong(ARM9Mem.ARM9_ITCM, adr&0x7FFF, val); + return ; + } + + if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) + { + addon.write32(adr, val); + return; + } + + adr &= 0x0FFFFFFF; + +#if 0 + if ((adr & 0xFF800000) == 0x04800000) { + // access to non regular hw registers + // return to not overwrite valid data + return ; + } +#endif + + if((adr>>24)==4) + { + + // MightyMax: no need to do several ifs, when only one can happen + // switch/case instead + // both comparison >=,< per if can be replaced by one bit comparison since + // they are 2^4 aligned and 2^4n wide + // this looks ugly but should reduce load on register writes, they are done as + // lookups by the compiler + switch (adr >> 4) + { + case 0x400033: //edge color table + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val; + return; + case 0x400036: //fog table + case 0x400037: + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val; + return; + + case 0x400038: + case 0x400039: + case 0x40003A: + case 0x40003B: //toon table + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val; + gfx3d_UpdateToonTable((adr & 0x3F) >> 1, val); + return; + + case 0x400040: + case 0x400041: + case 0x400042: + case 0x400043: // FIFO Commands + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val; + gfx3d_sendCommandToFIFO(val); + return; + + case 0x400044: + case 0x400045: + case 0x400046: + case 0x400047: + case 0x400048: + case 0x400049: + case 0x40004A: + case 0x40004B: + case 0x40004C: + case 0x40004D: + case 0x40004E: + case 0x40004F: + case 0x400050: + case 0x400051: + case 0x400052: + case 0x400053: + case 0x400054: + case 0x400055: + case 0x400056: + case 0x400057: + case 0x400058: + case 0x400059: + case 0x40005A: + case 0x40005B: + case 0x40005C: // Individual Commands + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[(adr & 0xFFF) >> 2] = val; + gfx3d_sendCommand(adr, val); + return; + default: + break; + } + + switch(adr) + { + case REG_DISPA_BG2XL: + MainScreen.gpu->setAffineStart(2,0,val); + return; + case REG_DISPA_BG2YL: + MainScreen.gpu->setAffineStart(2,1,val); + return; + case REG_DISPB_BG2XL: + SubScreen.gpu->setAffineStart(2,0,val); + return; + case REG_DISPB_BG2YL: + SubScreen.gpu->setAffineStart(2,1,val); + return; + case REG_DISPA_BG3XL: + MainScreen.gpu->setAffineStart(3,0,val); + return; + case REG_DISPA_BG3YL: + MainScreen.gpu->setAffineStart(3,1,val); + return; + case REG_DISPB_BG3XL: + SubScreen.gpu->setAffineStart(3,0,val); + return; + case REG_DISPB_BG3YL: + SubScreen.gpu->setAffineStart(3,1,val); + return; + + case 0x04000600: + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x600>>2] = val; + GFX_FIFOcnt(val); + return; + // Alpha test reference value - Parameters:1 + case 0x04000340: + { + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x340>>2] = val; + gfx3d_glAlphaFunc(val); + return; + } + // Clear background color setup - Parameters:2 + case 0x04000350: + { + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x350>>2] = val; + gfx3d_glClearColor(val); + return; + } + // Clear background depth setup - Parameters:2 + case 0x04000354: + { + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x354>>2] = val; + gfx3d_glClearDepth(val); + return; + } + // Fog Color - Parameters:4b + case 0x04000358: + { + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x358>>2] = val; + gfx3d_glFogColor(val); + return; + } + case 0x0400035C: + { + ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x35C>>2] = val; + gfx3d_glFogOffset(val); + return; + } + + case REG_DISPA_WININ: + { + GPU_setWININ(MainScreen.gpu, val & 0xFFFF) ; + GPU_setWINOUT16(MainScreen.gpu, (val >> 16) & 0xFFFF) ; + break; + } + case REG_DISPB_WININ: + { + GPU_setWININ(SubScreen.gpu, val & 0xFFFF) ; + GPU_setWINOUT16(SubScreen.gpu, (val >> 16) & 0xFFFF) ; + break; + } + + case REG_DISPA_WIN0H: + { + GPU_setWIN0_H(MainScreen.gpu, val&0xFFFF); + GPU_setWIN1_H(MainScreen.gpu, val>>16); + break; + } + case REG_DISPA_WIN0V: + { + GPU_setWIN0_V(MainScreen.gpu, val&0xFFFF); + GPU_setWIN1_V(MainScreen.gpu, val>>16); + break; + } + case REG_DISPB_WIN0H: + { + GPU_setWIN0_H(SubScreen.gpu, val&0xFFFF); + GPU_setWIN1_H(SubScreen.gpu, val>>16); + break; + } + case REG_DISPB_WIN0V: + { + GPU_setWIN0_V(SubScreen.gpu, val&0xFFFF); + GPU_setWIN1_V(SubScreen.gpu, val>>16); + break; + } + + case REG_DISPA_MASTERBRIGHT: + GPU_setMasterBrightness(MainScreen.gpu, val & 0xFFFF); + break; + case REG_DISPB_MASTERBRIGHT: + GPU_setMasterBrightness(SubScreen.gpu, val & 0xFFFF); + break; + + case REG_DISPA_BLDCNT: + { + GPU_setBLDCNT (MainScreen.gpu,val&0xffff); + MainScreen.gpu->setBLDALPHA(val>>16); + break; + } + case REG_DISPB_BLDCNT: + { + GPU_setBLDCNT (SubScreen.gpu,val&0xffff); + SubScreen.gpu->setBLDALPHA(val>>16); + break; + } + case REG_DISPA_DISPCNT : + GPU_setVideoProp(MainScreen.gpu, val); + //GPULOG("MAIN INIT 32B %08X\r\n", val); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0, val); + return; + + case REG_DISPB_DISPCNT : + GPU_setVideoProp(SubScreen.gpu, val); + //GPULOG("SUB INIT 32B %08X\r\n", val); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000, val); + return; + + case REG_VRAMCNTA: + MMU_VRAMmapControl(adr-REG_VRAMCNTA, val & 0xFF); + MMU_VRAMmapControl(adr-REG_VRAMCNTA+1, (val >> 8) & 0xFF); + MMU_VRAMmapControl(adr-REG_VRAMCNTA+2, (val >> 16) & 0xFF); + MMU_VRAMmapControl(adr-REG_VRAMCNTA+3, (val >> 24) & 0xFF); + break; + case REG_VRAMCNTE: + MMU_VRAMmapControl(adr-REG_VRAMCNTA, val & 0xFF); + MMU_VRAMmapControl(adr-REG_VRAMCNTA+1, (val >> 8) & 0xFF); + MMU_VRAMmapControl(adr-REG_VRAMCNTA+2, (val >> 16) & 0xFF); + /* Update WRAMSTAT at the ARM7 side */ + T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x241, (val >> 24) & 0xFF); + break; + case REG_VRAMCNTH: + MMU_VRAMmapControl(adr-REG_VRAMCNTA, val & 0xFF); + MMU_VRAMmapControl(adr-REG_VRAMCNTA+1, (val >> 8) & 0xFF); + break; + + case REG_IME : + { + u32 old_val = MMU.reg_IME[ARMCPU_ARM9]; + u32 new_val = val & 0x01; + MMU.reg_IME[ARMCPU_ARM9] = new_val; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x208, val); +#ifndef NEW_IRQ + if ( new_val && old_val != new_val) + { + // raise an interrupt request to the CPU if needed + if ( MMU.reg_IE[ARMCPU_ARM9] & MMU.reg_IF[ARMCPU_ARM9]) + { + NDS_ARM9.wIRQ = TRUE; + NDS_ARM9.waitIRQ = FALSE; + } + } +#endif + } + return; + + case REG_IE : + MMU.reg_IE[ARMCPU_ARM9] = val; +#ifndef NEW_IRQ + if ( MMU.reg_IME[ARMCPU_ARM9]) + { + // raise an interrupt request to the CPU if needed + if ( MMU.reg_IE[ARMCPU_ARM9] & MMU.reg_IF[ARMCPU_ARM9]) + { + NDS_ARM9.wIRQ = TRUE; + NDS_ARM9.waitIRQ = FALSE; + } + } +#endif + return; + + case REG_IF : + MMU.reg_IF[ARMCPU_ARM9] &= (~val); + return; + + case REG_TM0CNTL: + case REG_TM1CNTL: + case REG_TM2CNTL: + case REG_TM3CNTL: + { + int timerIndex = (adr>>2)&0x3; + int mask = ((val & 0x800000)>>(16+7)) << timerIndex; + MMU.CheckTimers = (MMU.CheckTimers & (~mask)) | mask; + + MMU.timerReload[ARMCPU_ARM9][timerIndex] = (u16)val; + if(val&0x800000) + MMU.timer[ARMCPU_ARM9][timerIndex] = MMU.timerReload[ARMCPU_ARM9][(adr>>2)&0x3]; + + MMU.timerON[ARMCPU_ARM9][timerIndex] = val & 0x800000; + switch((val>>16)&7) + { + case 0 : + MMU.timerMODE[ARMCPU_ARM9][timerIndex] = 0+1;//ARMCPU_ARM9; + break; + case 1 : + MMU.timerMODE[ARMCPU_ARM9][timerIndex] = 6+1;//ARMCPU_ARM9; + break; + case 2 : + MMU.timerMODE[ARMCPU_ARM9][timerIndex] = 8+1;//ARMCPU_ARM9; + break; + case 3 : + MMU.timerMODE[ARMCPU_ARM9][timerIndex] = 10+1;//ARMCPU_ARM9; + break; + default : + MMU.timerMODE[ARMCPU_ARM9][timerIndex] = 0xFFFF; + break; + } + if(!(val & 0x800000)) + MMU.timerRUN[ARMCPU_ARM9][timerIndex] = FALSE; + + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & 0xFFF, val); + return; + } + + case REG_DIVDENOM : + { + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x298, val); + execdiv(); + return; + } + case REG_DIVDENOM+4 : + { + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x29C, val); + execdiv(); + return; + } + + case REG_SQRTPARAM : + { + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8, val); + execsqrt(); + return; + } + case REG_SQRTPARAM+4 : + { + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2BC, val); + execsqrt(); + return; + } + case REG_IPCSYNC : + MMU_IPCSync(ARMCPU_ARM9, val); + return; + + case REG_IPCFIFOSEND : + IPC_FIFOsend(ARMCPU_ARM9, val); + return; + + case REG_DMA0CNTL : + //LOG("32 bit dma0 %04X\r\n", val); + DMASrc[ARMCPU_ARM9][0] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xB0); + DMADst[ARMCPU_ARM9][0] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xB4); + DMAtoVRAMmapping<0>(); + MMU.DMAStartTime[ARMCPU_ARM9][0] = (val>>27) & 0x7; + MMU.DMACrt[ARMCPU_ARM9][0] = val; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xB8, val); + if( MMU.DMAStartTime[ARMCPU_ARM9][0] == 0 || + MMU.DMAStartTime[ARMCPU_ARM9][0] == 7) // Start Immediately + MMU_doDMA(0); + #ifdef LOG_DMA2 + else + { + LOG("ARMCPU_ARM9 %d, dma %d src %08X dst %08X start taille %d %d\r\n", ARMCPU_ARM9, 0, DMASrc[ARMCPU_ARM9][0], DMADst[ARMCPU_ARM9][0], 0, ((MMU.DMACrt[ARMCPU_ARM9][0]>>27)&7)); + } + #endif + //emu_halt(); + return; + case REG_DMA1CNTL: + //LOG("32 bit dma1 %04X\r\n", val); + DMASrc[ARMCPU_ARM9][1] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xBC); + DMADst[ARMCPU_ARM9][1] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xC0); + DMAtoVRAMmapping<1>(); + MMU.DMAStartTime[ARMCPU_ARM9][1] = (val>>27) & 0x7; + MMU.DMACrt[ARMCPU_ARM9][1] = val; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xC4, val); + if(MMU.DMAStartTime[ARMCPU_ARM9][1] == 0 || + MMU.DMAStartTime[ARMCPU_ARM9][1] == 7) // Start Immediately + MMU_doDMA(1); + #ifdef LOG_DMA2 + else + { + LOG("ARMCPU_ARM9 %d, dma %d src %08X dst %08X start taille %d %d\r\n", ARMCPU_ARM9, 1, DMASrc[ARMCPU_ARM9][1], DMADst[ARMCPU_ARM9][1], 0, ((MMU.DMACrt[ARMCPU_ARM9][1]>>27)&7)); + } + #endif + return; + case REG_DMA2CNTL : + //LOG("32 bit dma2 %04X\r\n", val); + DMASrc[ARMCPU_ARM9][2] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xC8); + DMADst[ARMCPU_ARM9][2] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xCC); + DMAtoVRAMmapping<2>(); + MMU.DMAStartTime[ARMCPU_ARM9][2] = (val>>27) & 0x7; + MMU.DMACrt[ARMCPU_ARM9][2] = val; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xD0, val); + if(MMU.DMAStartTime[ARMCPU_ARM9][2] == 0 || + MMU.DMAStartTime[ARMCPU_ARM9][2] == 7) // Start Immediately + MMU_doDMA(2); + #ifdef LOG_DMA2 + else + { + LOG("ARMCPU_ARM9 %d, dma %d src %08X dst %08X start taille %d %d\r\n", ARMCPU_ARM9, 2, DMASrc[ARMCPU_ARM9][2], DMADst[ARMCPU_ARM9][2], 0, ((MMU.DMACrt[ARMCPU_ARM9][2]>>27)&7)); + } + #endif + return; + case REG_DMA3CNTL : + //LOG("32 bit dma3 %04X\r\n", val); + DMASrc[ARMCPU_ARM9][3] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xD4); + DMADst[ARMCPU_ARM9][3] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xD8); + DMAtoVRAMmapping<3>(); + MMU.DMAStartTime[ARMCPU_ARM9][3] = (val>>27) & 0x7; + MMU.DMACrt[ARMCPU_ARM9][3] = val; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xDC, val); + if( MMU.DMAStartTime[ARMCPU_ARM9][3] == 0 || + MMU.DMAStartTime[ARMCPU_ARM9][3] == 7) // Start Immediately + MMU_doDMA(3); + #ifdef LOG_DMA2 + else + { + LOG("ARMCPU_ARM9 %d, dma %d src %08X dst %08X start taille %d %d\r\n", ARMCPU_ARM9, 3, DMASrc[ARMCPU_ARM9][3], DMADst[ARMCPU_ARM9][3], 0, ((MMU.DMACrt[ARMCPU_ARM9][3]>>27)&7)); + } + #endif + return; + case REG_GCROMCTRL : + { + if(!(val & 0x80000000)) + { + MMU.dscard[ARMCPU_ARM9].address = 0; + MMU.dscard[ARMCPU_ARM9].transfer_count = 0; + + val &= 0x7F7FFFFF; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1A4, val); + return; + } + + switch(MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT)) + { + /* Dummy */ + case 0x9F: + { + MMU.dscard[ARMCPU_ARM9].address = 0; + MMU.dscard[ARMCPU_ARM9].transfer_count = 0x800; + } + break; + + /* Nand Init */ + case 0x94: + { + MMU.dscard[ARMCPU_ARM9].address = 0; + MMU.dscard[ARMCPU_ARM9].transfer_count = 0x80; + } + break; + + /* Nand Error? */ + case 0xD6: + { + MMU.dscard[ARMCPU_ARM9].address = 0; + MMU.dscard[ARMCPU_ARM9].transfer_count = 1; + } + break; + + /* Data read */ + case 0x00: + case 0xB7: + { + MMU.dscard[ARMCPU_ARM9].address = (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+1) << 24) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+2) << 16) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+3) << 8) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+4)); + MMU.dscard[ARMCPU_ARM9].transfer_count = 0x80; + } + break; + + /* Get ROM chip ID */ + case 0x90: + case 0xB8: + { + MMU.dscard[ARMCPU_ARM9].address = 0; + MMU.dscard[ARMCPU_ARM9].transfer_count = 1; + } + break; + + default: + { + LOG("WRITE CARD command: %08X %08X\t", ((MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT) << 24) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+1) << 16) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+2) << 8) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+3))),((MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+4) << 24) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+5) << 16) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+6) << 8) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+7)))); + LOG("FROM: %08X\n", NDS_ARM9.instruct_adr); + MMU.dscard[ARMCPU_ARM9].address = 0; + MMU.dscard[ARMCPU_ARM9].transfer_count = 0; + } + break; + } + + if(MMU.dscard[ARMCPU_ARM9].transfer_count == 0) + { + val &= 0x7F7FFFFF; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1A4, val); + return; + } + + val |= 0x00800000; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1A4, val); + + /* launch DMA if start flag was set to "DS Cart" */ + if(MMU.DMAStartTime[ARMCPU_ARM9][0] == 5) + { + MMU_doDMA(0); + } + if(MMU.DMAStartTime[ARMCPU_ARM9][1] == 5) + { + MMU_doDMA(1); + } + if(MMU.DMAStartTime[ARMCPU_ARM9][2] == 5) + { + MMU_doDMA(2); + } + if(MMU.DMAStartTime[ARMCPU_ARM9][3] == 5) + { + MMU_doDMA(3); + } + } + return; + case REG_DISPA_DISPCAPCNT : + //INFO("MMU write32: REG_DISPA_DISPCAPCNT 0x%X\n", val); + GPU_set_DISPCAPCNT(val); + T1WriteLong(ARM9Mem.ARM9_REG, 0x64, val); + return; + + case REG_DISPA_BG0CNT : + GPU_setBGProp(MainScreen.gpu, 0, (val&0xFFFF)); + GPU_setBGProp(MainScreen.gpu, 1, (val>>16)); + //if((val>>16)==0x400) emu_halt(); + T1WriteLong(ARM9Mem.ARM9_REG, 8, val); + return; + case REG_DISPA_BG2CNT : + GPU_setBGProp(MainScreen.gpu, 2, (val&0xFFFF)); + GPU_setBGProp(MainScreen.gpu, 3, (val>>16)); + T1WriteLong(ARM9Mem.ARM9_REG, 0xC, val); + return; + case REG_DISPB_BG0CNT : + GPU_setBGProp(SubScreen.gpu, 0, (val&0xFFFF)); + GPU_setBGProp(SubScreen.gpu, 1, (val>>16)); + T1WriteLong(ARM9Mem.ARM9_REG, 0x1008, val); + return; + case REG_DISPB_BG2CNT : + GPU_setBGProp(SubScreen.gpu, 2, (val&0xFFFF)); + GPU_setBGProp(SubScreen.gpu, 3, (val>>16)); + T1WriteLong(ARM9Mem.ARM9_REG, 0x100C, val); + return; + case REG_DISPA_DISPMMEMFIFO: + { + DISP_FIFOsend(val); + return; + } + } + + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & MMU.MMU_MASK[ARMCPU_ARM9][adr>>20], val); + return; + } + + bool unmapped; + adr = MMU_LCDmap(adr, unmapped); + if(unmapped) return; + + // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [shash] + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][adr>>20], adr&MMU.MMU_MASK[ARMCPU_ARM9][adr>>20], val); +} + +//================================================= MMU ARM9 read 08 +u8 FASTCALL _MMU_ARM9_read08(u32 adr) +{ + mmu_log_debug_ARM9(adr, "(read08) %0x%X", MMU.MMU_MEM[ARMCPU_ARM9][(adr>>20)&0xFF][adr&MMU.MMU_MASK[ARMCPU_ARM9][(adr>>20)&0xFF]]); + + if(adr<0x02000000) + return T1ReadByte(ARM9Mem.ARM9_ITCM, adr&0x7FFF); + + if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) + return addon.read08(adr); + + bool unmapped; + adr = MMU_LCDmap(adr, unmapped); + if(unmapped) return 0; + + return MMU.MMU_MEM[ARMCPU_ARM9][(adr>>20)&0xFF][adr&MMU.MMU_MASK[ARMCPU_ARM9][(adr>>20)&0xFF]]; +} + +//================================================= MMU ARM9 read 16 +u16 FASTCALL _MMU_ARM9_read16(u32 adr) +{ + mmu_log_debug_ARM9(adr, "(read16) %0x%X", T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20) & 0xFF])); + + if(adr<0x02000000) + return T1ReadWord(ARM9Mem.ARM9_ITCM, adr & 0x7FFF); + + if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) + return addon.read16(adr); + + adr &= 0x0FFFFFFF; + + if (adr >> 24 == 4) + { + // Address is an IO register + switch(adr) + { + // ============================================= 3D + case 0x04000604: + return (gfx3d_GetNumPolys()); + case 0x04000606: + return (gfx3d_GetNumVertex()); + case 0x04000630: + case 0x04000632: + case 0x04000634: + return gfx3d_glGetVecRes((adr & 0xF) >> 1); + // ============================================= 3D end + case REG_IME : + return (u16)MMU.reg_IME[ARMCPU_ARM9]; + + case REG_IE : + return (u16)MMU.reg_IE[ARMCPU_ARM9]; + case REG_IE + 2 : + return (u16)(MMU.reg_IE[ARMCPU_ARM9]>>16); + + case REG_IF : + return (u16)MMU.reg_IF[ARMCPU_ARM9]; + case REG_IF + 2 : + return (u16)(MMU.reg_IF[ARMCPU_ARM9]>>16); + + case REG_TM0CNTL : + case REG_TM1CNTL : + case REG_TM2CNTL : + case REG_TM3CNTL : + return MMU.timer[ARMCPU_ARM9][(adr&0xF)>>2]; + + case REG_AUXSPICNT: + return MMU.AUX_SPI_CNT; + + case 0x04000130: + case 0x04000136: + //not sure whether these should trigger from byte reads + LagFrameFlag=0; + break; + + case REG_POSTFLG : + return 1; + } + + return T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20) & 0xFF]); + } + + bool unmapped; + adr = MMU_LCDmap(adr,unmapped); + if(unmapped) return 0; + + return T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20) & 0xFF]); +} + +//================================================= MMU ARM9 read 32 +u32 FASTCALL _MMU_ARM9_read32(u32 adr) +{ + mmu_log_debug_ARM9(adr, "(read32) %0x%X", T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20)])); + + if(adr<0x02000000) + return T1ReadLong(ARM9Mem.ARM9_ITCM, adr&0x7FFF); + + if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) + return addon.read32(adr); + + adr &= 0x0FFFFFFF; + + // Address is an IO register + if((adr >> 24) == 4) + { + switch(adr) + { + case 0x04000640: + case 0x04000644: + case 0x04000648: + case 0x0400064C: + case 0x04000650: + case 0x04000654: + case 0x04000658: + case 0x0400065C: + case 0x04000660: + case 0x04000664: + case 0x04000668: + case 0x0400066C: + case 0x04000670: + case 0x04000674: + case 0x04000678: + case 0x0400067C: + { + //LOG("4000640h..67Fh - CLIPMTX_RESULT - Read Current Clip Coordinates Matrix (R)"); + return gfx3d_GetClipMatrix ((adr-0x04000640)/4); + } + case 0x04000680: + case 0x04000684: + case 0x04000688: + case 0x0400068C: + case 0x04000690: + case 0x04000694: + case 0x04000698: + case 0x0400069C: + case 0x040006A0: + { + //LOG("4000680h..6A3h - VECMTX_RESULT - Read Current Directional Vector Matrix (R)"); + return gfx3d_GetDirectionalMatrix ((adr-0x04000680)/4); + } + + case 0x4000604: + { + return (gfx3d_GetNumPolys()) & ((gfx3d_GetNumVertex()) << 16); + //LOG ("read32 - RAM_COUNT -> 0x%X", ((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][(adr>>20)&0xFF]))[(adr&MMU.MMU_MASK[ARMCPU_ARM9][(adr>>20)&0xFF])>>2]); + } + + case 0x04000620: + case 0x04000624: + case 0x04000628: + case 0x0400062C: + { + return gfx3d_glGetPosRes((adr & 0xF) >> 2); + } + // ======================================== 3D end + + case REG_IME : + return MMU.reg_IME[ARMCPU_ARM9]; + case REG_IE : + return MMU.reg_IE[ARMCPU_ARM9]; + case REG_IF : + return MMU.reg_IF[ARMCPU_ARM9]; + case REG_IPCFIFORECV : + return IPC_FIFOrecv(ARMCPU_ARM9); + case REG_TM0CNTL : + case REG_TM1CNTL : + case REG_TM2CNTL : + case REG_TM3CNTL : + { + u32 val = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], (adr + 2) & 0xFFF); + return MMU.timer[ARMCPU_ARM9][(adr&0xF)>>2] | (val<<16); + } + /* + case 0x04000640 : // TODO (clear): again, ??? + LOG("read proj\r\n"); + return 0; + case 0x04000680 : + LOG("read roat\r\n"); + return 0; + case 0x04000620 : + LOG("point res\r\n"); + return 0; + */ + case REG_GCDATAIN: + { + u32 val = 0; + + if(MMU.dscard[ARMCPU_ARM9].transfer_count == 0) + return 0; + + switch(MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT)) + { + /* Dummy */ + case 0x9F: + { + val = 0xFFFFFFFF; + } + break; + + /* Nand Init? */ + case 0x94: + { + val = 0; //Unsure what to return here so return 0 for now + } + break; + /* Nand Error? */ + case 0xD6: + { + val = 0x80; //0x80 == ok? + } + break; + + /* Data read */ + case 0x00: + case 0xB7: + { + /* TODO: prevent read if the address is out of range */ + /* Make sure any reads below 0x8000 redirect to 0x8000+(adr&0x1FF) as on real cart */ + if((MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT) == 0xB7) && (MMU.dscard[ARMCPU_ARM9].address < 0x8000)) + { + MMU.dscard[ARMCPU_ARM9].address = (0x8000 + (MMU.dscard[ARMCPU_ARM9].address&0x1FF)); + INFO("Read below 0x8000 from: %08X\n", NDS_ARM9.instruct_adr); + } + val = T1ReadLong(MMU.CART_ROM, MMU.dscard[ARMCPU_ARM9].address & MMU.CART_ROM_MASK); + } + break; + + /* Get ROM chip ID */ + case 0x90: + case 0xB8: + { + /* TODO */ + val = 0x00000000; + } + break; + default: + LOG("READ CARD command: %08X %08X\t", ((MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT) << 24) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+1) << 16) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+2) << 8) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+3))),((MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+4) << 24) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+5) << 16) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+6) << 8) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM9], REG_GCCMDOUT+7)))); + LOG("FROM: %08X\n", NDS_ARM9.instruct_adr); + break; + + } + + MMU.dscard[ARMCPU_ARM9].address += 4; // increment address + + MMU.dscard[ARMCPU_ARM9].transfer_count--; // update transfer counter + if(MMU.dscard[ARMCPU_ARM9].transfer_count) // if transfer is not ended + return val; // return data + + // transfer is done + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1A4, + T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1A4) & 0x7F7FFFFF); + + // if needed, throw irq for the end of transfer + if(MMU.AUX_SPI_CNT & 0x4000) + NDS_makeInt(ARMCPU_ARM9, 19); + + return val; + } + } + return T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20)]); + } + + bool unmapped; + adr = MMU_LCDmap(adr,unmapped); + if(unmapped) return 0; + + // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [zeromus, inspired by shash] + return T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][(adr >> 20)], adr & MMU.MMU_MASK[ARMCPU_ARM9][(adr >> 20)]); +} +//================================================================================================== ARM7 * +//========================================================================================================= +//========================================================================================================= +//================================================= MMU ARM7 write 08 +void FASTCALL _MMU_ARM7_write08(u32 adr, u8 val) +{ + mmu_log_debug_ARM7(adr, "(write08) %0x%X", val); + + if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) + { + addon.write08(adr, val); + return; + } + + adr &= 0x0FFFFFFF; + // This is bad, remove it + if ((adr>=0x04000400)&&(adr<0x0400051D)) + { + SPU_WriteByte(adr, val); + return; + } + + adr &= 0x0FFFFFFF; + + if(adr == 0x04000301) + { + switch(val) + { + case 0xC0: NDS_Sleep(); break; + default: break; + } + } + +#ifdef EXPERIMENTAL_WIFI + if ((adr & 0xFF800000) == 0x04800000) + { + /* is wifi hardware, dont intermix with regular hardware registers */ + /* FIXME handle 8 bit writes */ + return ; + } +#endif + + if (adr >> 24 == 4) + { + switch(adr) + { + case REG_RTC: + rtcWrite(val); + return; + + case REG_AUXSPICNT: + write_auxspicnt(9,8,0,val); + return; + case REG_AUXSPICNT+1: + write_auxspicnt(9,8,1,val); + return; + } + } + + bool unmapped; + adr = MMU_LCDmap(adr,unmapped); + if(unmapped) return; + + // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [shash] + MMU.MMU_MEM[ARMCPU_ARM7][adr>>20][adr&MMU.MMU_MASK[ARMCPU_ARM7][adr>>20]]=val; +} + +//================================================= MMU ARM7 write 16 +void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val) +{ + mmu_log_debug_ARM7(adr, "(write16) %0x%X", val); + + if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) + { + addon.write16(adr, val); + return; + } + +#ifdef EXPERIMENTAL_WIFI + + /* wifi mac access */ + if ((adr>=0x04800000)&&(adr<0x05000000)) + { + WIFI_write16(&wifiMac,adr,val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x48], adr&MMU.MMU_MASK[ARMCPU_ARM7][0x48], val); + return; + } +#else + //if ((adr>=0x04800000)&&(adr<0x05000000)) return ; +#endif + + adr &= 0x0FFFFFFF; + + // This is bad, remove it + if ((adr>=0x04000400)&&(adr<0x0400051D)) + { + SPU_WriteWord(adr, val); + return; + } + + if((adr >> 24) == 4) + { + /* Address is an IO register */ + switch(adr) + { + case REG_RTC: + rtcWrite(val); + break; + + case REG_EXMEMCNT: + { + u16 oldval = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x204); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x204, (val & 0x7F) | (oldval & 0xFF80)); + } + return; + + case REG_AUXSPICNT: + write_auxspicnt(7,16,0,val); + return; + + case REG_AUXSPIDATA: + if(val!=0) + MMU.AUX_SPI_CMD = val & 0xFF; + + //T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU.bupmem, val)); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, MMU_new.backupDevice.data_command((u8)val)); + return; + + case REG_SPICNT : + { + int reset_firmware = 1; + + if ( ((MMU.SPI_CNT >> 8) & 0x3) == 1) + { + if ( ((val >> 8) & 0x3) == 1) + { + if ( BIT11(MMU.SPI_CNT)) + { + // select held + reset_firmware = 0; + } + } + } + + //MMU.fw.com == 0; // reset fw device communication + if ( reset_firmware) + { + // reset fw device communication + fw_reset_com(&MMU.fw); + } + MMU.SPI_CNT = val; + + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPICNT >> 20) & 0xff], REG_SPICNT & 0xfff, val); + } + return; + + case REG_SPIDATA : + { + u16 spicnt; + + if(val!=0) + MMU.SPI_CMD = val; + + spicnt = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPICNT >> 20) & 0xff], REG_SPICNT & 0xfff); + + switch((spicnt >> 8) & 0x3) + { + case 0 : + { + if(!MMU.powerMan_CntRegWritten) + { + MMU.powerMan_CntReg = (val & 0xFF); + MMU.powerMan_CntRegWritten = TRUE; + } + else + { + if(MMU.powerMan_CntReg & 0x80) + { + val = MMU.powerMan_Reg[MMU.powerMan_CntReg & 0x3]; + } + else + { + MMU.powerMan_Reg[MMU.powerMan_CntReg & 0x3] = (u8)val; + } + + MMU.powerMan_CntRegWritten = FALSE; + } + } + break; + + case 1 : /* firmware memory device */ + if((spicnt & 0x3) != 0) /* check SPI baudrate (must be 4mhz) */ + { + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, 0); + break; + } + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, fw_transfer(&MMU.fw, (u8)val)); + return; + + case 2 : + switch(MMU.SPI_CMD & 0x70) + { + case 0x00 : + val = 0; + break; + case 0x10 : + //emu_halt(); + if(MMU.SPI_CNT&(1<<11)) + { + if(partie) + { + val = ((nds.touchY<<3)&0x7FF); + partie = 0; + //emu_halt(); + break; + } + val = (nds.touchY>>5); + partie = 1; + break; + } + val = ((nds.touchY<<3)&0x7FF); + partie = 1; + break; + case 0x20 : + val = 0; + break; + case 0x30 : + val = 0; + break; + case 0x40 : + val = 0; + break; + case 0x50 : + if(spicnt & 0x800) + { + if(partie) + { + val = ((nds.touchX<<3)&0x7FF); + partie = 0; + break; + } + val = (nds.touchX>>5); + partie = 1; + break; + } + val = ((nds.touchX<<3)&0x7FF); + partie = 1; + break; + case 0x60 : + if(!(val & 0x80)) + val = (Mic_ReadSample() & 0xFF); + else + val = 0; + break; + case 0x70 : + val = 0; + break; + } + break; + + case 3 : + /* NOTICE: Device 3 of SPI is reserved (unused and unusable) */ + break; + } + } + + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_SPIDATA >> 20) & 0xff], REG_SPIDATA & 0xfff, val); + return; + + /* NOTICE: Perhaps we have to use gbatek-like reg names instead of libnds-like ones ...*/ + + case REG_IME : + { + u32 old_val = MMU.reg_IME[ARMCPU_ARM7]; + u32 new_val = val & 1; + MMU.reg_IME[ARMCPU_ARM7] = new_val; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x208, val); +#ifndef NEW_IRQ + if ( new_val && old_val != new_val) + { + /* raise an interrupt request to the CPU if needed */ + if ( MMU.reg_IE[ARMCPU_ARM7] & MMU.reg_IF[ARMCPU_ARM7]) + { + NDS_ARM7.wIRQ = TRUE; + NDS_ARM7.waitIRQ = FALSE; + } + } +#endif + return; + } + case REG_IE : + MMU.reg_IE[ARMCPU_ARM7] = (MMU.reg_IE[ARMCPU_ARM7]&0xFFFF0000) | val; +#ifndef NEW_IRQ + if ( MMU.reg_IME[ARMCPU_ARM7]) + { + /* raise an interrupt request to the CPU if needed */ + if ( MMU.reg_IE[ARMCPU_ARM7] & MMU.reg_IF[ARMCPU_ARM7]) + { + NDS_ARM7.wIRQ = TRUE; + NDS_ARM7.waitIRQ = FALSE; + } + } +#endif + return; + case REG_IE + 2 : + //emu_halt(); + MMU.reg_IE[ARMCPU_ARM7] = (MMU.reg_IE[ARMCPU_ARM7]&0xFFFF) | (((u32)val)<<16); +#ifndef NEW_IRQ + if ( MMU.reg_IME[ARMCPU_ARM7]) + { + /* raise an interrupt request to the CPU if needed */ + if ( MMU.reg_IE[ARMCPU_ARM7] & MMU.reg_IF[ARMCPU_ARM7]) + { + NDS_ARM7.wIRQ = TRUE; + NDS_ARM7.waitIRQ = FALSE; + } + } +#endif + return; + + case REG_IF : + //emu_halt(); + MMU.reg_IF[ARMCPU_ARM7] &= (~((u32)val)); + return; + case REG_IF + 2 : + //emu_halt(); + MMU.reg_IF[ARMCPU_ARM7] &= (~(((u32)val)<<16)); + return; + + case REG_IPCSYNC : + MMU_IPCSync(ARMCPU_ARM7, val); + return; + + case REG_IPCFIFOCNT : + IPC_FIFOcnt(ARMCPU_ARM7, val); + return; + case REG_TM0CNTL : + case REG_TM1CNTL : + case REG_TM2CNTL : + case REG_TM3CNTL : + MMU.timerReload[ARMCPU_ARM7][(adr>>2)&3] = val; + return; + case REG_TM0CNTH : + case REG_TM1CNTH : + case REG_TM2CNTH : + case REG_TM3CNTH : + { + int timerIndex = ((adr-2)>>2)&0x3; + int mask = ((val&0x80)>>7) << (timerIndex+(ARMCPU_ARM7<<2)); + MMU.CheckTimers = (MMU.CheckTimers & (~mask)) | mask; + + if(val&0x80) + MMU.timer[ARMCPU_ARM7][timerIndex] = MMU.timerReload[ARMCPU_ARM7][((adr-2)>>2)&0x3]; + + MMU.timerON[ARMCPU_ARM7][((adr-2)>>2)&0x3] = val & 0x80; + + switch(val&7) + { + case 0 : + MMU.timerMODE[ARMCPU_ARM7][timerIndex] = 0+1;//ARMCPU_ARM7; + break; + case 1 : + MMU.timerMODE[ARMCPU_ARM7][timerIndex] = 6+1;//ARMCPU_ARM7; + break; + case 2 : + MMU.timerMODE[ARMCPU_ARM7][timerIndex] = 8+1;//ARMCPU_ARM7; + break; + case 3 : + MMU.timerMODE[ARMCPU_ARM7][timerIndex] = 10+1;//ARMCPU_ARM7; + break; + default : + MMU.timerMODE[ARMCPU_ARM7][timerIndex] = 0xFFFF; + break; + } + + if(!(val & 0x80)) + MMU.timerRUN[ARMCPU_ARM7][timerIndex] = FALSE; + + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], adr & 0xFFF, val); + return; + } + + case REG_DMA0CNTH : + { + u32 v; + + //if(val&0x8000) emu_halt(); + //LOG("16 bit dma0 %04X\r\n", val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xBA, val); + DMASrc[ARMCPU_ARM7][0] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xB0); + DMADst[ARMCPU_ARM7][0] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xB4); + v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xB8); + MMU.DMAStartTime[ARMCPU_ARM7][0] = (v>>28) & 0x3; + MMU.DMACrt[ARMCPU_ARM7][0] = v; + if(MMU.DMAStartTime[ARMCPU_ARM7][0] == 0) + MMU_doDMA(0); + #ifdef LOG_DMA2 + //else + { + LOG("ARMCPU_ARM7 %d, dma %d src %08X dst %08X %s\r\n", ARMCPU_ARM7, 0, DMASrc[ARMCPU_ARM7][0], DMADst[ARMCPU_ARM7][0], (val&(1<<25))?"ON":"OFF"); + } + #endif + } + return; + case REG_DMA1CNTH : + { + u32 v; + //if(val&0x8000) emu_halt(); + //LOG("16 bit dma1 %04X\r\n", val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xC6, val); + DMASrc[ARMCPU_ARM7][1] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xBC); + DMADst[ARMCPU_ARM7][1] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xC0); + v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xC4); + MMU.DMAStartTime[ARMCPU_ARM7][1] = (v>>28) & 0x3; + MMU.DMACrt[ARMCPU_ARM7][1] = v; + if(MMU.DMAStartTime[ARMCPU_ARM7][1] == 0) + MMU_doDMA(1); + #ifdef LOG_DMA2 + //else + { + LOG("ARMCPU_ARM7 %d, dma %d src %08X dst %08X %s\r\n", ARMCPU_ARM7, 1, DMASrc[ARMCPU_ARM7][1], DMADst[ARMCPU_ARM7][1], (val&(1<<25))?"ON":"OFF"); + } + #endif + } + return; + case REG_DMA2CNTH : + { + u32 v; + //if(val&0x8000) emu_halt(); + //LOG("16 bit dma2 %04X\r\n", val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xD2, val); + DMASrc[ARMCPU_ARM7][2] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xC8); + DMADst[ARMCPU_ARM7][2] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xCC); + v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xD0); + MMU.DMAStartTime[ARMCPU_ARM7][2] = (v>>28) & 0x3; + MMU.DMACrt[ARMCPU_ARM7][2] = v; + if(MMU.DMAStartTime[ARMCPU_ARM7][2] == 0) + MMU_doDMA(2); + #ifdef LOG_DMA2 + //else + { + LOG("ARMCPU_ARM7 %d, dma %d src %08X dst %08X %s\r\n", ARMCPU_ARM7, 2, DMASrc[ARMCPU_ARM7][2], DMADst[ARMCPU_ARM7][2], (val&(1<<25))?"ON":"OFF"); + } + #endif + } + return; + case REG_DMA3CNTH : + { + u32 v; + //if(val&0x8000) emu_halt(); + //LOG("16 bit dma3 %04X\r\n", val); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xDE, val); + DMASrc[ARMCPU_ARM7][3] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xD4); + DMADst[ARMCPU_ARM7][3] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xD8); + v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xDC); + MMU.DMAStartTime[ARMCPU_ARM7][3] = (v>>28) & 0x3; + MMU.DMACrt[ARMCPU_ARM7][3] = v; + + if(MMU.DMAStartTime[ARMCPU_ARM7][3] == 0) + MMU_doDMA(3); + #ifdef LOG_DMA2 + //else + { + LOG("ARMCPU_ARM7 %d, dma %d src %08X dst %08X %s\r\n", ARMCPU_ARM7, 3, DMASrc[ARMCPU_ARM7][3], DMADst[ARMCPU_ARM7][3], (val&(1<<25))?"ON":"OFF"); + } + #endif + } + return; + //case REG_AUXSPICNT : emu_halt(); + } + + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], adr&MMU.MMU_MASK[ARMCPU_ARM7][adr>>20], val); + return; + } + + bool unmapped; + adr = MMU_LCDmap(adr,unmapped); + if(unmapped) return; + + // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [shash] + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][adr>>20], adr&MMU.MMU_MASK[ARMCPU_ARM7][adr>>20], val); +} +//================================================= MMU ARM7 write 32 +void FASTCALL _MMU_ARM7_write32(u32 adr, u32 val) +{ + mmu_log_debug_ARM7(adr, "(write32) %0x%X", val); + + if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) + { + addon.write32(adr, val); + return; + } + +#ifdef EXPERIMENTAL_WIFI + if ((adr & 0xFF800000) == 0x04800000) + { + // access to non regular hw registers + // return to not overwrite valid data + WIFI_write16(&wifiMac, adr, val & 0xFFFF); + WIFI_write16(&wifiMac, adr+2, val >> 16); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x48], adr&MMU.MMU_MASK[ARMCPU_ARM7][0x48], val); + return; + } +#endif + + adr &= 0x0FFFFFFF; + + // This is bad, remove it + if ((adr>=0x04000400)&&(adr<0x0400051D)) + { + SPU_WriteLong(adr, val); + return; + } + + if((adr>>24)==4) + { + switch(adr) + { + case REG_RTC: + rtcWrite((u16)val); + break; + + case REG_IME : + { + u32 old_val = MMU.reg_IME[ARMCPU_ARM7]; + u32 new_val = val & 1; + MMU.reg_IME[ARMCPU_ARM7] = new_val; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x208, val); +#ifndef NEW_IRQ + if ( new_val && old_val != new_val) + { + // raise an interrupt request to the CPU if needed + if ( MMU.reg_IE[ARMCPU_ARM7] & MMU.reg_IF[ARMCPU_ARM7]) + { + NDS_ARM7.wIRQ = TRUE; + NDS_ARM7.waitIRQ = FALSE; + } + } +#endif + return; + } + + case REG_IE : + MMU.reg_IE[ARMCPU_ARM7] = val; +#ifndef NEW_IRQ + if ( MMU.reg_IME[ARMCPU_ARM7]) + { + /* raise an interrupt request to the CPU if needed */ + if ( MMU.reg_IE[ARMCPU_ARM7] & MMU.reg_IF[ARMCPU_ARM7]) + { + NDS_ARM7.wIRQ = TRUE; + NDS_ARM7.waitIRQ = FALSE; + } + } +#endif + return; + + case REG_IF : + MMU.reg_IF[ARMCPU_ARM7] &= (~val); + return; + + case REG_TM0CNTL: + case REG_TM1CNTL: + case REG_TM2CNTL: + case REG_TM3CNTL: + { + int timerIndex = (adr>>2)&0x3; + int mask = ((val & 0x800000)>>(16+7)) << (timerIndex+(ARMCPU_ARM7<<2)); + MMU.CheckTimers = (MMU.CheckTimers & (~mask)) | mask; + + MMU.timerReload[ARMCPU_ARM7][timerIndex] = (u16)val; + if(val&0x800000) + MMU.timer[ARMCPU_ARM7][timerIndex] = MMU.timerReload[ARMCPU_ARM7][(adr>>2)&0x3]; + + MMU.timerON[ARMCPU_ARM7][timerIndex] = val & 0x800000; + switch((val>>16)&7) + { + case 0 : + MMU.timerMODE[ARMCPU_ARM7][timerIndex] = 0+1;//ARMCPU_ARM7; + break; + case 1 : + MMU.timerMODE[ARMCPU_ARM7][timerIndex] = 6+1;//ARMCPU_ARM7; + break; + case 2 : + MMU.timerMODE[ARMCPU_ARM7][timerIndex] = 8+1;//ARMCPU_ARM7; + break; + case 3 : + MMU.timerMODE[ARMCPU_ARM7][timerIndex] = 10+1;//ARMCPU_ARM7; + break; + default : + MMU.timerMODE[ARMCPU_ARM7][timerIndex] = 0xFFFF; + break; + } + if(!(val & 0x800000)) + MMU.timerRUN[ARMCPU_ARM7][timerIndex] = FALSE; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], adr & 0xFFF, val); + return; + } + + case REG_IPCSYNC : + MMU_IPCSync(ARMCPU_ARM7, val); + return; + + case REG_IPCFIFOSEND : + IPC_FIFOsend(ARMCPU_ARM7, val); + return; + case REG_DMA0CNTL : + //LOG("32 bit dma0 %04X\r\n", val); + DMASrc[ARMCPU_ARM7][0] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xB0); + DMADst[ARMCPU_ARM7][0] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xB4); + MMU.DMAStartTime[ARMCPU_ARM7][0] = (val>>28) & 0x3; + MMU.DMACrt[ARMCPU_ARM7][0] = val; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xB8, val); + if( MMU.DMAStartTime[ARMCPU_ARM7][0] == 0 || + MMU.DMAStartTime[ARMCPU_ARM7][0] == 7) // Start Immediately + MMU_doDMA(0); + #ifdef LOG_DMA2 + else + { + LOG("ARMCPU_ARM7 %d, dma %d src %08X dst %08X start taille %d %d\r\n", ARMCPU_ARM7, 0, DMASrc[ARMCPU_ARM7][0], DMADst[ARMCPU_ARM7][0], 0, ((MMU.DMACrt[ARMCPU_ARM7][0]>>27)&7)); + } + #endif + //emu_halt(); + return; + case REG_DMA1CNTL: + //LOG("32 bit dma1 %04X\r\n", val); + DMASrc[ARMCPU_ARM7][1] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xBC); + DMADst[ARMCPU_ARM7][1] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xC0); + MMU.DMAStartTime[ARMCPU_ARM7][1] = (val>>28) & 0x3; + MMU.DMACrt[ARMCPU_ARM7][1] = val; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xC4, val); + if(MMU.DMAStartTime[ARMCPU_ARM7][1] == 0 || + MMU.DMAStartTime[ARMCPU_ARM7][1] == 7) // Start Immediately + MMU_doDMA(1); + #ifdef LOG_DMA2 + else + { + LOG("ARMCPU_ARM7 %d, dma %d src %08X dst %08X start taille %d %d\r\n", ARMCPU_ARM7, 1, DMASrc[ARMCPU_ARM7][1], DMADst[ARMCPU_ARM7][1], 0, ((MMU.DMACrt[ARMCPU_ARM7][1]>>27)&7)); + } + #endif + return; + case REG_DMA2CNTL : + //LOG("32 bit dma2 %04X\r\n", val); + DMASrc[ARMCPU_ARM7][2] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xC8); + DMADst[ARMCPU_ARM7][2] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xCC); + MMU.DMAStartTime[ARMCPU_ARM7][2] = (val>>28) & 0x3; + MMU.DMACrt[ARMCPU_ARM7][2] = val; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xD0, val); + if(MMU.DMAStartTime[ARMCPU_ARM7][2] == 0 || + MMU.DMAStartTime[ARMCPU_ARM7][2] == 7) // Start Immediately + MMU_doDMA(2); + #ifdef LOG_DMA2 + else + { + LOG("ARMCPU_ARM7 %d, dma %d src %08X dst %08X start taille %d %d\r\n", ARMCPU_ARM7, 2, DMASrc[ARMCPU_ARM7][2], DMADst[ARMCPU_ARM7][2], 0, ((MMU.DMACrt[ARMCPU_ARM7][2]>>27)&7)); + } + #endif + return; + case REG_DMA3CNTL : + //LOG("32 bit dma3 %04X\r\n", val); + DMASrc[ARMCPU_ARM7][3] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xD4); + DMADst[ARMCPU_ARM7][3] = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xD8); + MMU.DMAStartTime[ARMCPU_ARM7][3] = (val>>28) & 0x3; + MMU.DMACrt[ARMCPU_ARM7][3] = val; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0xDC, val); + if( MMU.DMAStartTime[ARMCPU_ARM7][3] == 0 || + MMU.DMAStartTime[ARMCPU_ARM7][3] == 7) // Start Immediately + MMU_doDMA(3); + #ifdef LOG_DMA2 + else + { + LOG("ARMCPU_ARM7 %d, dma %d src %08X dst %08X start taille %d %d\r\n", ARMCPU_ARM7, 3, DMASrc[ARMCPU_ARM7][3], DMADst[ARMCPU_ARM7][3], 0, ((MMU.DMACrt[ARMCPU_ARM7][3]>>27)&7)); + } + #endif + return; + case REG_GCROMCTRL : + { + if(!(val & 0x80000000)) + { + MMU.dscard[ARMCPU_ARM7].address = 0; + MMU.dscard[ARMCPU_ARM7].transfer_count = 0; + + val &= 0x7F7FFFFF; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x1A4, val); + return; + } + + switch(MEM_8(MMU.MMU_MEM[ARMCPU_ARM7], REG_GCCMDOUT)) + { + /* Dummy */ + case 0x9F: + { + MMU.dscard[ARMCPU_ARM7].address = 0; + MMU.dscard[ARMCPU_ARM7].transfer_count = 0x800; + } + break; + + /* Data read */ + case 0x00: + case 0xB7: + { + MMU.dscard[ARMCPU_ARM7].address = (MEM_8(MMU.MMU_MEM[ARMCPU_ARM7], REG_GCCMDOUT+1) << 24) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM7], REG_GCCMDOUT+2) << 16) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM7], REG_GCCMDOUT+3) << 8) | (MEM_8(MMU.MMU_MEM[ARMCPU_ARM7], REG_GCCMDOUT+4)); + MMU.dscard[ARMCPU_ARM7].transfer_count = 0x80; + } + break; + + /* Get ROM chip ID */ + case 0x90: + case 0xB8: + { + MMU.dscard[ARMCPU_ARM7].address = 0; + MMU.dscard[ARMCPU_ARM7].transfer_count = 1; + } + break; + + default: + { + LOG("CARD command: %02X\n", MEM_8(MMU.MMU_MEM[ARMCPU_ARM7], REG_GCCMDOUT)); + MMU.dscard[ARMCPU_ARM7].address = 0; + MMU.dscard[ARMCPU_ARM7].transfer_count = 0; + } + break; + } + + if(MMU.dscard[ARMCPU_ARM7].transfer_count == 0) + { + val &= 0x7F7FFFFF; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x1A4, val); + return; + } + + val |= 0x00800000; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x1A4, val); + + /* launch DMA if start flag was set to "DS Cart" */ + + if(MMU.DMAStartTime[ARMCPU_ARM7][2] == 2) + { + MMU_doDMA(2); + } + if(MMU.DMAStartTime[ARMCPU_ARM7][3] == 2) + { + MMU_doDMA(3); + } + + return; + + } + return; + } + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], adr & MMU.MMU_MASK[ARMCPU_ARM7][adr>>20], val); + return; + } + + bool unmapped; + adr = MMU_LCDmap(adr,unmapped); + if(unmapped) return; + + // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [shash] + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][adr>>20], adr&MMU.MMU_MASK[ARMCPU_ARM7][adr>>20], val); +} + +//================================================= MMU ARM7 read 08 +u8 FASTCALL _MMU_ARM7_read08(u32 adr) +{ + mmu_log_debug_ARM7(adr, "(read08) %0x%X", MMU.MMU_MEM[ARMCPU_ARM7][(adr>>20)&0xFF][adr&MMU.MMU_MASK[ARMCPU_ARM7][(adr>>20)&0xFF]]); + +#ifdef EXPERIMENTAL_WIFI + /* wifi mac access */ + if ((adr>=0x04800000)&&(adr<0x05000000)) + { + if (adr & 1) + return (WIFI_read16(&wifiMac,adr-1) >> 8) & 0xFF; + else + return WIFI_read16(&wifiMac,adr) & 0xFF; + } +#endif + + if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) + return addon.read08(adr); + + if (adr == REG_RTC) return (u8)rtcRead(); + + bool unmapped; + adr = MMU_LCDmap(adr,unmapped); + if(unmapped) return 0; + + return MMU.MMU_MEM[ARMCPU_ARM7][(adr>>20)&0xFF][adr&MMU.MMU_MASK[ARMCPU_ARM7][(adr>>20)&0xFF]]; +} +//================================================= MMU ARM7 read 16 +u16 FASTCALL _MMU_ARM7_read16(u32 adr) +{ + mmu_log_debug_ARM7(adr, "(read16) %0x%X", T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20) & 0xFF])); + +#ifdef EXPERIMENTAL_WIFI + /* wifi mac access */ + if ((adr>=0x04800000)&&(adr<0x05000000)) + return WIFI_read16(&wifiMac,adr) ; +#endif + + if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) + return addon.read16(adr); + + adr &= 0x0FFFFFFF; + + if(adr>>24==4) + { + /* Address is an IO register */ + switch(adr) + { + case REG_RTC: + return rtcRead(); + + case REG_IME : + return (u16)MMU.reg_IME[ARMCPU_ARM7]; + + case REG_IE : + return (u16)MMU.reg_IE[ARMCPU_ARM7]; + case REG_IE + 2 : + return (u16)(MMU.reg_IE[ARMCPU_ARM7]>>16); + + case REG_IF : + return (u16)MMU.reg_IF[ARMCPU_ARM7]; + case REG_IF + 2 : + return (u16)(MMU.reg_IF[ARMCPU_ARM7]>>16); + + case REG_TM0CNTL : + case REG_TM1CNTL : + case REG_TM2CNTL : + case REG_TM3CNTL : + return MMU.timer[ARMCPU_ARM7][(adr&0xF)>>2]; + + case REG_AUXSPICNT: + return MMU.AUX_SPI_CNT; + + case 0x04000130: + case 0x04000136: + //here is an example of what not to do: + //since the arm7 polls this every frame, we shouldnt count this as an input check + //LagFrameFlag=0; + break; + + case REG_POSTFLG : + return 1; + } + return T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20) & 0xFF]); + } + + bool unmapped; + adr = MMU_LCDmap(adr,unmapped); + if(unmapped) return 0; + + /* Returns data from memory */ + return T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20) & 0xFF]); +} +//================================================= MMU ARM7 read 32 +u32 FASTCALL _MMU_ARM7_read32(u32 adr) +{ + mmu_log_debug_ARM7(adr, "(read32) %0x%X", T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20) & 0xFF], adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20) & 0xFF])); + +#ifdef EXPERIMENTAL_WIFI + /* wifi mac access */ + if ((adr>=0x04800000)&&(adr<0x05000000)) + return (WIFI_read16(&wifiMac,adr) | (WIFI_read16(&wifiMac,adr+2) << 16)); +#endif + + if ( (adr >= 0x08000000) && (adr < 0x0A010000) ) + return addon.read32(adr); + + adr &= 0x0FFFFFFF; + + if((adr >> 24) == 4) + { + /* Address is an IO register */ + switch(adr) + { + case REG_RTC: + return (u32)rtcRead(); + + case REG_IME : + return MMU.reg_IME[ARMCPU_ARM7]; + case REG_IE : + return MMU.reg_IE[ARMCPU_ARM7]; + case REG_IF : + return MMU.reg_IF[ARMCPU_ARM7]; + case REG_IPCFIFORECV : + return IPC_FIFOrecv(ARMCPU_ARM7); + case REG_TM0CNTL : + case REG_TM1CNTL : + case REG_TM2CNTL : + case REG_TM3CNTL : + { + u32 val = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][0x40], (adr + 2) & 0xFFF); + return MMU.timer[ARMCPU_ARM7][(adr&0xF)>>2] | (val<<16); + } + case REG_GCROMCTRL: + { + //INFO("arm7 romctrl read\n"); + break; + } + case REG_GCDATAIN: + { + u32 val = 0; + + if(MMU.dscard[ARMCPU_ARM7].transfer_count == 0) + return 0; + + switch(MEM_8(MMU.MMU_MEM[ARMCPU_ARM7], REG_GCCMDOUT)) + { + /* Dummy */ + case 0x9F: + { + val = 0xFFFFFFFF; + } + break; + + /* Data read */ + case 0x00: + case 0xB7: + { + /* TODO: prevent read if the address is out of range */ + /* Make sure any reads below 0x8000 redirect to 0x8000+(adr&0x1FF) as on real cart */ + if((MEM_8(MMU.MMU_MEM[ARMCPU_ARM7], REG_GCCMDOUT) == 0xB7) && (MMU.dscard[ARMCPU_ARM7].address < 0x8000)) + { + MMU.dscard[ARMCPU_ARM7].address = (0x8000 + (MMU.dscard[ARMCPU_ARM7].address&0x1FF)); + } + val = T1ReadLong(MMU.CART_ROM, MMU.dscard[ARMCPU_ARM7].address & MMU.CART_ROM_MASK); + } + break; + + /* Get ROM chip ID */ + case 0x90: + case 0xB8: + { + /* TODO */ + val = 0x00000FC2; + } + break; + } + + MMU.dscard[ARMCPU_ARM7].address += 4; // increment address + + MMU.dscard[ARMCPU_ARM7].transfer_count--; // update transfer counter + if(MMU.dscard[ARMCPU_ARM7].transfer_count) // if transfer is not ended + return val; // return data + + // transfer is done + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x1A4, + T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][0x40], 0x1A4) & 0x7F7FFFFF); + + // if needed, throw irq for the end of transfer + if(MMU.AUX_SPI_CNT & 0x4000) + NDS_makeInt(ARMCPU_ARM7, 19); + + return val; + } + } + return T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20)], adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20)]); + } + + bool unmapped; + adr = MMU_LCDmap(adr,unmapped); + if(unmapped) return 0; + + //Returns data from memory + // Removed the &0xFF as they are implicit with the adr&0x0FFFFFFFF [zeromus, inspired by shash] + return T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20)], adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20)]); +} + +//========================================================================================================= + +u32 FASTCALL MMU_read32(u32 proc, u32 adr) +{ + ASSERT_UNALIGNED((adr&3)==0); + + if(proc==0) + return _MMU_ARM9_read32(adr); + else + return _MMU_ARM7_read32(adr); +} + +u16 FASTCALL MMU_read16(u32 proc, u32 adr) +{ + ASSERT_UNALIGNED((adr&1)==0); + + if(proc==0) + return _MMU_ARM9_read16(adr); + else + return _MMU_ARM7_read16(adr); +} + +u8 FASTCALL MMU_read8(u32 proc, u32 adr) +{ + if(proc==0) + return _MMU_ARM9_read08(adr); + else + return _MMU_ARM7_read08(adr); +} + +void FASTCALL MMU_write32(u32 proc, u32 adr, u32 val) +{ + ASSERT_UNALIGNED((adr&3)==0); + if(proc==0) + _MMU_ARM9_write32(adr, val); + else + _MMU_ARM7_write32(adr,val); +} + +void FASTCALL MMU_write16(u32 proc, u32 adr, u16 val) +{ + ASSERT_UNALIGNED((adr&1)==0); + if(proc==0) + _MMU_ARM9_write16(adr, val); + else + _MMU_ARM7_write16(adr,val); +} + +void FASTCALL MMU_write8(u32 proc, u32 adr, u8 val) +{ + if(proc==0) + _MMU_ARM9_write08(adr, val); + else + + _MMU_ARM7_write08(adr,val); +} + +void FASTCALL MMU_DumpMemBlock(u8 proc, u32 address, u32 size, u8 *buffer) +{ + u32 i; + u32 curaddr; + + for(i = 0, curaddr = address; i < size; i++, curaddr++) + { + buffer[i] = _MMU_read08(proc,MMU_AT_GPU,curaddr); + } +} + +//////////////////////////////////////////////////////////// +//function pointer handlers for gdb stub stuff + +static u16 FASTCALL arm9_prefetch16( void *data, u32 adr) { + profile_memory_access( 1, adr, PROFILE_PREFETCH); + return _MMU_read16(adr); +} + +static u32 FASTCALL arm9_prefetch32( void *data, u32 adr) { + profile_memory_access( 1, adr, PROFILE_PREFETCH); + return _MMU_read32(adr); +} + +static u8 FASTCALL arm9_read8( void *data, u32 adr) { + profile_memory_access( 1, adr, PROFILE_READ); + return _MMU_read08(adr); +} + +static u16 FASTCALL arm9_read16( void *data, u32 adr) { + profile_memory_access( 1, adr, PROFILE_READ); + return _MMU_read16(adr); +} + +static u32 FASTCALL arm9_read32( void *data, u32 adr) { + profile_memory_access( 1, adr, PROFILE_READ); + return _MMU_read32(adr); +} + +static void FASTCALL arm9_write8(void *data, u32 adr, u8 val) { + profile_memory_access( 1, adr, PROFILE_WRITE); + _MMU_write08(adr, val); +} + +static void FASTCALL arm9_write16(void *data, u32 adr, u16 val) { + profile_memory_access( 1, adr, PROFILE_WRITE); + _MMU_write16(adr, val); +} + +static void FASTCALL arm9_write32(void *data, u32 adr, u32 val) { + profile_memory_access( 1, adr, PROFILE_WRITE); + _MMU_write32(adr, val); +} + +static u16 FASTCALL arm7_prefetch16( void *data, u32 adr) { + profile_memory_access( 0, adr, PROFILE_PREFETCH); + return _MMU_read16(adr); +} + +static u32 FASTCALL arm7_prefetch32( void *data, u32 adr) { + profile_memory_access( 0, adr, PROFILE_PREFETCH); + return _MMU_read32(adr); +} + +static u8 FASTCALL arm7_read8( void *data, u32 adr) { + profile_memory_access( 0, adr, PROFILE_READ); + return _MMU_read08(adr); +} + +static u16 FASTCALL arm7_read16( void *data, u32 adr) { + profile_memory_access( 0, adr, PROFILE_READ); + return _MMU_read16(adr); +} + +static u32 FASTCALL arm7_read32( void *data, u32 adr) { + profile_memory_access( 0, adr, PROFILE_READ); + return _MMU_read32(adr); +} + +static void FASTCALL arm7_write8(void *data, u32 adr, u8 val) { + profile_memory_access( 0, adr, PROFILE_WRITE); + _MMU_write08(adr, val); +} + +static void FASTCALL arm7_write16(void *data, u32 adr, u16 val) { + profile_memory_access( 0, adr, PROFILE_WRITE); + _MMU_write16(adr, val); +} + +static void FASTCALL arm7_write32(void *data, u32 adr, u32 val) { + profile_memory_access( 0, adr, PROFILE_WRITE); + _MMU_write32(adr, val); +} + + + +/* + * the base memory interfaces + */ +struct armcpu_memory_iface arm9_base_memory_iface = { + arm9_prefetch32, + arm9_prefetch16, + + arm9_read8, + arm9_read16, + arm9_read32, + + arm9_write8, + arm9_write16, + arm9_write32 +}; + +struct armcpu_memory_iface arm7_base_memory_iface = { + arm7_prefetch32, + arm7_prefetch16, + + arm7_read8, + arm7_read16, + arm7_read32, + + arm7_write8, + arm7_write16, + arm7_write32 +}; + +/* + * The direct memory interface for the ARM9. + * This avoids the ARM9 protection unit when accessing + * memory. + */ +struct armcpu_memory_iface arm9_direct_memory_iface = { + NULL, + NULL, + + arm9_read8, + arm9_read16, + arm9_read32, + + arm9_write8, + arm9_write16, + arm9_write32 +}; + + +///////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////// + +//#ifdef PROFILE_MEMORY_ACCESS +// +//#define PROFILE_PREFETCH 0 +//#define PROFILE_READ 1 +//#define PROFILE_WRITE 2 +// +//struct mem_access_profile { +// u64 num_accesses; +// u32 address_mask; +// u32 masked_value; +//}; +// +//#define PROFILE_NUM_MEM_ACCESS_PROFILES 4 +// +//static u64 profile_num_accesses[2][3]; +//static u64 profile_unknown_addresses[2][3]; +//static struct mem_access_profile +//profile_memory_accesses[2][3][PROFILE_NUM_MEM_ACCESS_PROFILES]; +// +//static void +//setup_profiling( void) { +// int i; +// +// for ( i = 0; i < 2; i++) { +// int access_type; +// +// for ( access_type = 0; access_type < 3; access_type++) { +// profile_num_accesses[i][access_type] = 0; +// profile_unknown_addresses[i][access_type] = 0; +// +// /* +// * Setup the access testing structures +// */ +// profile_memory_accesses[i][access_type][0].address_mask = 0x0e000000; +// profile_memory_accesses[i][access_type][0].masked_value = 0x00000000; +// profile_memory_accesses[i][access_type][0].num_accesses = 0; +// +// /* main memory */ +// profile_memory_accesses[i][access_type][1].address_mask = 0x0f000000; +// profile_memory_accesses[i][access_type][1].masked_value = 0x02000000; +// profile_memory_accesses[i][access_type][1].num_accesses = 0; +// +// /* shared memory */ +// profile_memory_accesses[i][access_type][2].address_mask = 0x0f800000; +// profile_memory_accesses[i][access_type][2].masked_value = 0x03000000; +// profile_memory_accesses[i][access_type][2].num_accesses = 0; +// +// /* arm7 memory */ +// profile_memory_accesses[i][access_type][3].address_mask = 0x0f800000; +// profile_memory_accesses[i][access_type][3].masked_value = 0x03800000; +// profile_memory_accesses[i][access_type][3].num_accesses = 0; +// } +// } +//} +// +//static void +//profile_memory_access( int arm9, u32 adr, int access_type) { +// static int first = 1; +// int mem_profile; +// int address_found = 0; +// +// if ( first) { +// setup_profiling(); +// first = 0; +// } +// +// profile_num_accesses[arm9][access_type] += 1; +// +// for ( mem_profile = 0; +// mem_profile < PROFILE_NUM_MEM_ACCESS_PROFILES && +// !address_found; +// mem_profile++) { +// if ( (adr & profile_memory_accesses[arm9][access_type][mem_profile].address_mask) == +// profile_memory_accesses[arm9][access_type][mem_profile].masked_value) { +// /*printf( "adr %08x mask %08x res %08x expected %08x\n", +// adr, +// profile_memory_accesses[arm9][access_type][mem_profile].address_mask, +// adr & profile_memory_accesses[arm9][access_type][mem_profile].address_mask, +// profile_memory_accesses[arm9][access_type][mem_profile].masked_value);*/ +// address_found = 1; +// profile_memory_accesses[arm9][access_type][mem_profile].num_accesses += 1; +// } +// } +// +// if ( !address_found) { +// profile_unknown_addresses[arm9][access_type] += 1; +// } +//} +// +// +//static const char *access_type_strings[] = { +// "prefetch", +// "read ", +// "write " +//}; +// +//void +//print_memory_profiling( void) { +// int arm; +// +// printf("------ Memory access profile ------\n"); +// +// for ( arm = 0; arm < 2; arm++) { +// int access_type; +// +// for ( access_type = 0; access_type < 3; access_type++) { +// int mem_profile; +// printf("ARM%c: num of %s %lld\n", +// arm ? '9' : '7', +// access_type_strings[access_type], +// profile_num_accesses[arm][access_type]); +// +// for ( mem_profile = 0; +// mem_profile < PROFILE_NUM_MEM_ACCESS_PROFILES; +// mem_profile++) { +// printf( "address %08x: %lld\n", +// profile_memory_accesses[arm][access_type][mem_profile].masked_value, +// profile_memory_accesses[arm][access_type][mem_profile].num_accesses); +// } +// +// printf( "unknown addresses %lld\n", +// profile_unknown_addresses[arm][access_type]); +// +// printf( "\n"); +// } +// } +// +// printf("------ End of Memory access profile ------\n\n"); +//} +//#else +//void +//print_memory_profiling( void) { +//} +//#endif /* End of PROFILE_MEMORY_ACCESS area */ diff --git a/desmume/src/MMU.h b/src/MMU.h similarity index 77% rename from desmume/src/MMU.h rename to src/MMU.h index c54b3fd03..e60a23c70 100644 --- a/desmume/src/MMU.h +++ b/src/MMU.h @@ -1,595 +1,508 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2007 shash - Copyright (C) 2007-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef MMU_H -#define MMU_H - -#include "FIFO.h" -#include "mem.h" - -#include "mc.h" - -#define ARMCPU_ARM7 1 -#define ARMCPU_ARM9 0 -#define ARMPROC (PROCNUM ? NDS_ARM7:NDS_ARM9) - -typedef const u8 TWaitState; - -enum ECardMode -{ - CardMode_Normal = 0, - CardMode_KEY1, - CardMode_KEY2, -}; - -typedef struct -{ - - u8 command[8]; - - u32 address; - u32 transfer_count; - - ECardMode mode; - -} nds_dscard; - -struct MMU_struct -{ - //ARM9 mem - u8 ARM9_ITCM[0x8000]; - u8 ARM9_DTCM[0x4000]; - u8 MAIN_MEM[0x800000]; //this has been expanded to 8MB to support debug consoles - u8 ARM9_REG[0x1000000]; - u8 ARM9_BIOS[0x8000]; - u8 ARM9_VMEM[0x800]; - - #include "PACKED.h" - struct { - u8 ARM9_LCD[0xA4000]; - //an extra 128KB for blank memory, directly after arm9_lcd, so that - //we can easily map things to the end of arm9_lcd to represent - //an unmapped state - u8 blank_memory[0x20000]; - }; - #include "PACKED_END.h" - - u8 ARM9_OAM[0x800]; - - u8* ExtPal[2][4]; - u8* ObjExtPal[2][2]; - - struct TextureInfo { - u8* texPalSlot[6]; - u8* textureSlotAddr[4]; - } texInfo; - - //ARM7 mem - u8 ARM7_BIOS[0x4000]; - u8 ARM7_ERAM[0x10000]; - u8 ARM7_REG[0x10000]; - u8 ARM7_WIRAM[0x10000]; - - // VRAM mapping - u8 VRAM_MAP[4][32]; - u32 LCD_VRAM_ADDR[10]; - u8 LCDCenable[10]; - - //Shared ram - u8 SWIRAM[0x8000]; - - //Card rom & ram - u8 * CART_ROM; - u32 CART_ROM_MASK; - u8 CART_RAM[0x10000]; - - //Unused ram - u8 UNUSED_RAM[4]; - - //this is here so that we can trap glitchy emulator code - //which is accessing offsets 5,6,7 of unused ram due to unaligned accesses - //(also since the emulator doesn't prevent unaligned accesses) - u8 MORE_UNUSED_RAM[4]; - - static u8 * MMU_MEM[2][256]; - static u32 MMU_MASK[2][256]; - - u8 ARM9_RW_MODE; - - static CACHE_ALIGN TWaitState MMU_WAIT16[2][16]; - static CACHE_ALIGN TWaitState MMU_WAIT32[2][16]; - - u32 DTCMRegion; - u32 ITCMRegion; - - u16 timer[2][4]; - s32 timerMODE[2][4]; - u32 timerON[2][4]; - u32 timerRUN[2][4]; - u16 timerReload[2][4]; - - u32 reg_IME[2]; - u32 reg_IE[2]; - u32 reg_IF[2]; - - u32 DMAStartTime[2][4]; - u64 DMACycle[2][4]; - u32 DMACrt[2][4]; - BOOL DMAing[2][4]; - BOOL DMACompleted[2][4]; - - BOOL divRunning; - s64 divResult; - s64 divMod; - u32 divCnt; - u64 divCycles; - - BOOL sqrtRunning; - u32 sqrtResult; - u32 sqrtCnt; - u64 sqrtCycles; - - u16 SPI_CNT; - u16 SPI_CMD; - u16 AUX_SPI_CNT; - u16 AUX_SPI_CMD; - - u64 gfx3dCycles; - - u8 powerMan_CntReg; - BOOL powerMan_CntRegWritten; - u8 powerMan_Reg[4]; - - memory_chip_t fw; - - nds_dscard dscard[2]; - u32 CheckTimers; - u32 CheckDMAs; -}; - -struct MMU_struct_new -{ - BackupDevice backupDevice; -}; - -extern MMU_struct MMU; -extern MMU_struct_new MMU_new; - - -struct armcpu_memory_iface { - /** the 32 bit instruction prefetch */ - u32 FASTCALL (*prefetch32)( void *data, u32 adr); - - /** the 16 bit instruction prefetch */ - u16 FASTCALL (*prefetch16)( void *data, u32 adr); - - /** read 8 bit data value */ - u8 FASTCALL (*read8)( void *data, u32 adr); - /** read 16 bit data value */ - u16 FASTCALL (*read16)( void *data, u32 adr); - /** read 32 bit data value */ - u32 FASTCALL (*read32)( void *data, u32 adr); - - /** write 8 bit data value */ - void FASTCALL (*write8)( void *data, u32 adr, u8 val); - /** write 16 bit data value */ - void FASTCALL (*write16)( void *data, u32 adr, u16 val); - /** write 32 bit data value */ - void FASTCALL (*write32)( void *data, u32 adr, u32 val); - - void *data; -}; - - -void MMU_Init(void); -void MMU_DeInit(void); - -void MMU_Reset( void); - -void MMU_setRom(u8 * rom, u32 mask); -void MMU_unsetRom( void); - -void print_memory_profiling( void); - -// Memory reading/writing (old) -u8 FASTCALL MMU_read8(u32 proc, u32 adr); -u16 FASTCALL MMU_read16(u32 proc, u32 adr); -u32 FASTCALL MMU_read32(u32 proc, u32 adr); -void FASTCALL MMU_write8(u32 proc, u32 adr, u8 val); -void FASTCALL MMU_write16(u32 proc, u32 adr, u16 val); -void FASTCALL MMU_write32(u32 proc, u32 adr, u32 val); - -template void FASTCALL MMU_doDMA(u32 num); - -//The base ARM memory interfaces -extern struct armcpu_memory_iface arm9_base_memory_iface; -extern struct armcpu_memory_iface arm7_base_memory_iface; -extern struct armcpu_memory_iface arm9_direct_memory_iface; - -#define VRAM_BANKS 9 -#define VRAM_BANK_A 0 -#define VRAM_BANK_B 1 -#define VRAM_BANK_C 2 -#define VRAM_BANK_D 3 -#define VRAM_BANK_E 4 -#define VRAM_BANK_F 5 -#define VRAM_BANK_G 6 -#define VRAM_BANK_H 7 -#define VRAM_BANK_I 8 - -#define VRAM_PAGE_ABG 0 -#define VRAM_PAGE_BBG 128 -#define VRAM_PAGE_AOBJ 256 -#define VRAM_PAGE_BOBJ 384 - - -struct VramConfiguration { - - enum Purpose { - OFF, INVALID, ABG, BBG, AOBJ, BOBJ, LCDC, ARM7, TEX, TEXPAL, ABGEXTPAL, BBGEXTPAL, AOBJEXTPAL, BOBJEXTPAL - }; - - struct BankInfo { - Purpose purpose; - int ofs; - } banks[VRAM_BANKS]; - - inline void clear() { - for(int i=0;i>14)&(VRAM_ARM9_PAGES-1); - u32 ofs = vram_addr & 0x3FFF; - vram_page = vram_arm9_map[vram_page]; - //blank pages are handled by the extra 16KB of blank memory at the end of ARM9_LCD - //and the fact that blank pages are mapped to appear at that location - return MMU.ARM9_LCD + (vram_page<<14) + ofs; -} - - -enum MMU_ACCESS_TYPE -{ - MMU_AT_CODE, MMU_AT_DATA, MMU_AT_GPU, MMU_AT_DMA -}; - -template u8 _MMU_read08(u32 addr); -template u16 _MMU_read16(u32 addr); -template u32 _MMU_read32(u32 addr); -template void _MMU_write08(u32 addr, u8 val); -template void _MMU_write16(u32 addr, u16 val); -template void _MMU_write32(u32 addr, u32 val); - -template u8 _MMU_read08(u32 addr) { return _MMU_read08(addr); } -template u16 _MMU_read16(u32 addr) { return _MMU_read16(addr); } -template u32 _MMU_read32(u32 addr) { return _MMU_read32(addr); } -template void _MMU_write08(u32 addr, u8 val) { _MMU_write08(addr,val); } -template void _MMU_write16(u32 addr, u16 val) { _MMU_write16(addr,val); } -template void _MMU_write32(u32 addr, u32 val) { _MMU_write32(addr,val); } - -void FASTCALL _MMU_ARM9_write08(u32 adr, u8 val); -void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val); -void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val); -u8 FASTCALL _MMU_ARM9_read08(u32 adr); -u16 FASTCALL _MMU_ARM9_read16(u32 adr); -u32 FASTCALL _MMU_ARM9_read32(u32 adr); - -void FASTCALL _MMU_ARM7_write08(u32 adr, u8 val); -void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val); -void FASTCALL _MMU_ARM7_write32(u32 adr, u32 val); -u8 FASTCALL _MMU_ARM7_read08(u32 adr); -u16 FASTCALL _MMU_ARM7_read16(u32 adr); -u32 FASTCALL _MMU_ARM7_read32(u32 adr); - -extern u32 partie; - -extern u32 _MMU_MAIN_MEM_MASK; -inline void SetupMMU(BOOL debugConsole) { - if(debugConsole) _MMU_MAIN_MEM_MASK = 0x7FFFFF; - else _MMU_MAIN_MEM_MASK = 0x3FFFFF; -} - -//TODO: at one point some of the early access code included this. consider re-adding it - //ARM7 private memory - //if ( (adr & 0x0f800000) == 0x03800000) { - //T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20) & 0xFF], - // adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20) & 0xFF]); - -enum EDMAMode -{ - EDMAMode_Immediate = 0, - EDMAMode_VBlank = 1, - EDMAMode_HBlank = 2, - EDMAMode_HStart = 3, - EDMAMode_MemDisplay = 4, - EDMAMode_Card = 5, - EDMAMode_GBASlot = 6, - EDMAMode_GXFifo = 7, - EDMAMode7_Wifi = 8, - EDMAMode7_GBASlot = 9, -}; - -FORCEINLINE u8 _MMU_read08(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr) -{ - //special handling for DMA: read 0 from TCM - if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_DMA) - { - if(addr<0x02000000) return 0; //itcm - if((addr&(~0x3FFF)) == MMU.DTCMRegion) return 0; //dtcm - } - - if(PROCNUM==ARMCPU_ARM9) - if((addr&(~0x3FFF)) == MMU.DTCMRegion) - { - //Returns data from DTCM (ARM9 only) - return T1ReadByte(MMU.ARM9_DTCM, addr & 0x3FFF); - } - - if ( (addr & 0x0F000000) == 0x02000000) - return T1ReadByte( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK); - - if(PROCNUM==ARMCPU_ARM9) return _MMU_ARM9_read08(addr); - else return _MMU_ARM7_read08(addr); -} - -FORCEINLINE u16 _MMU_read16(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr) -{ - //special handling for DMA: read 0 from TCM - if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_DMA) - { - if(addr<0x02000000) return 0; //itcm - if((addr&(~0x3FFF)) == MMU.DTCMRegion) return 0; //dtcm - } - - //special handling for execution from arm9, since we spend so much time in there - if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_CODE) - { - if ((addr & 0x0F000000) == 0x02000000) - return T1ReadWord_guaranteedAligned( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK); - - if(addr<0x02000000) - return T1ReadWord_guaranteedAligned(MMU.ARM9_ITCM, addr&0x7FFF); - - goto dunno; - } - - if(PROCNUM==ARMCPU_ARM9) - if((addr&(~0x3FFF)) == MMU.DTCMRegion) - { - //Returns data from DTCM (ARM9 only) - return T1ReadWord(MMU.ARM9_DTCM, addr & 0x3FFF); - } - - if ( (addr & 0x0F000000) == 0x02000000) - return T1ReadWord( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK); - -dunno: - if(PROCNUM==ARMCPU_ARM9) return _MMU_ARM9_read16(addr); - else return _MMU_ARM7_read16(addr); -} - -FORCEINLINE u32 _MMU_read32(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr) -{ - //special handling for DMA: read 0 from TCM - if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_DMA) - { - if(addr<0x02000000) return 0; //itcm - if((addr&(~0x3FFF)) == MMU.DTCMRegion) return 0; //dtcm - } - - //special handling for execution from arm9, since we spend so much time in there - if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_CODE) - { - if ( (addr & 0x0F000000) == 0x02000000) - return T1ReadLong_guaranteedAligned( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK); - - if(addr<0x02000000) - return T1ReadLong_guaranteedAligned(MMU.ARM9_ITCM, addr&0x7FFF); - - goto dunno; - } - - //special handling for execution from arm7. try reading from main memory first - if(PROCNUM==ARMCPU_ARM7) - { - if ( (addr & 0x0F000000) == 0x02000000) - return T1ReadLong_guaranteedAligned( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK); - else if((addr & 0xFF800000) == 0x03800000) - return T1ReadLong_guaranteedAligned(MMU.ARM7_ERAM, addr&0xFFFF); - else if((addr & 0xFF800000) == 0x03000000) - return T1ReadLong_guaranteedAligned(MMU.SWIRAM, addr&0x7FFF); - } - - - //for other arm9 cases, we have to check from dtcm first because it is patched on top of the main memory range - if(PROCNUM==ARMCPU_ARM9) - { - if((addr&(~0x3FFF)) == MMU.DTCMRegion) - { - //Returns data from DTCM (ARM9 only) - return T1ReadLong(MMU.ARM9_DTCM, addr & 0x3FFF); - } - - if ( (addr & 0x0F000000) == 0x02000000) - return T1ReadLong( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK); - } - -dunno: - if(PROCNUM==ARMCPU_ARM9) return _MMU_ARM9_read32(addr); - else return _MMU_ARM7_read32(addr); -} - -FORCEINLINE void _MMU_write08(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr, u8 val) -{ - //special handling for DMA: discard writes to TCM - if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_DMA) - { - if(addr<0x02000000) return; //itcm - if((addr&(~0x3FFF)) == MMU.DTCMRegion) return; //dtcm - } - - if(PROCNUM==ARMCPU_ARM9) - if((addr&(~0x3FFF)) == MMU.DTCMRegion) - { - T1WriteByte(MMU.ARM9_DTCM, addr & 0x3FFF, val); - return; - } - - if ( (addr & 0x0F000000) == 0x02000000) { - T1WriteByte( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK, val); - return; - } - - if(PROCNUM==ARMCPU_ARM9) _MMU_ARM9_write08(addr,val); - else _MMU_ARM7_write08(addr,val); -} - -FORCEINLINE void _MMU_write16(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr, u16 val) -{ - //special handling for DMA: discard writes to TCM - if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_DMA) - { - if(addr<0x02000000) return; //itcm - if((addr&(~0x3FFF)) == MMU.DTCMRegion) return; //dtcm - } - - if(PROCNUM==ARMCPU_ARM9) - if((addr&(~0x3FFF)) == MMU.DTCMRegion) - { - T1WriteWord(MMU.ARM9_DTCM, addr & 0x3FFF, val); - return; - } - - if ( (addr & 0x0F000000) == 0x02000000) { - T1WriteWord( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK, val); - return; - } - - if(PROCNUM==ARMCPU_ARM9) _MMU_ARM9_write16(addr,val); - else _MMU_ARM7_write16(addr,val); -} - -FORCEINLINE void _MMU_write32(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr, u32 val) -{ - //special handling for DMA: discard writes to TCM - if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_DMA) - { - if(addr<0x02000000) return; //itcm - if((addr&(~0x3FFF)) == MMU.DTCMRegion) return; //dtcm - } - - if(PROCNUM==ARMCPU_ARM9) - if((addr&(~0x3FFF)) == MMU.DTCMRegion) - { - T1WriteLong(MMU.ARM9_DTCM, addr & 0x3FFF, val); - return; - } - - if ( (addr & 0x0F000000) == 0x02000000) { - T1WriteLong( MMU.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK, val); - return; - } - - if(PROCNUM==ARMCPU_ARM9) _MMU_ARM9_write32(addr,val); - else _MMU_ARM7_write32(addr,val); -} - - -#ifdef MMU_ENABLE_ACL - void FASTCALL MMU_write8_acl(u32 proc, u32 adr, u8 val); - void FASTCALL MMU_write16_acl(u32 proc, u32 adr, u16 val); - void FASTCALL MMU_write32_acl(u32 proc, u32 adr, u32 val); - u8 FASTCALL MMU_read8_acl(u32 proc, u32 adr, u32 access); - u16 FASTCALL MMU_read16_acl(u32 proc, u32 adr, u32 access); - u32 FASTCALL MMU_read32_acl(u32 proc, u32 adr, u32 access); -#else - #define MMU_write8_acl(proc, adr, val) _MMU_write08(adr, val) - #define MMU_write16_acl(proc, adr, val) _MMU_write16(adr, val) - #define MMU_write32_acl(proc, adr, val) _MMU_write32(adr, val) - #define MMU_read8_acl(proc,adr,access) _MMU_read08(adr) - #define MMU_read16_acl(proc,adr,access) ((access==CP15_ACCESS_EXECUTE)?_MMU_read16(adr):_MMU_read16(adr)) - #define MMU_read32_acl(proc,adr,access) ((access==CP15_ACCESS_EXECUTE)?_MMU_read32(adr):_MMU_read32(adr)) -#endif - -// Use this macros for reading/writing, so the GDB stub isn't broken -#ifdef GDB_STUB - #define READ32(a,b) cpu->mem_if->read32(a,(b) & 0xFFFFFFFC) - #define WRITE32(a,b,c) cpu->mem_if->write32(a,(b) & 0xFFFFFFFC,c) - #define READ16(a,b) cpu->mem_if->read16(a,(b) & 0xFFFFFFFE) - #define WRITE16(a,b,c) cpu->mem_if->write16(a,(b) & 0xFFFFFFFE,c) - #define READ8(a,b) cpu->mem_if->read8(a,b) - #define WRITE8(a,b,c) cpu->mem_if->write8(a,b,c) -#else - #define READ32(a,b) _MMU_read32((b) & 0xFFFFFFFC) - #define WRITE32(a,b,c) _MMU_write32((b) & 0xFFFFFFFC,c) - #define READ16(a,b) _MMU_read16((b) & 0xFFFFFFFE) - #define WRITE16(a,b,c) _MMU_write16((b) & 0xFFFFFFFE,c) - #define READ8(a,b) _MMU_read08(b) - #define WRITE8(a,b,c) _MMU_write08(b, c) -#endif - -template -FORCEINLINE u8 _MMU_read08(u32 addr) { return _MMU_read08(PROCNUM, AT, addr); } - -template -FORCEINLINE u16 _MMU_read16(u32 addr) { return _MMU_read16(PROCNUM, AT, addr); } - -template -FORCEINLINE u32 _MMU_read32(u32 addr) { return _MMU_read32(PROCNUM, AT, addr); } - -template -FORCEINLINE void _MMU_write08(u32 addr, u8 val) { _MMU_write08(PROCNUM, AT, addr, val); } - -template -FORCEINLINE void _MMU_write16(u32 addr, u16 val) { _MMU_write16(PROCNUM, AT, addr, val); } - -template -FORCEINLINE void _MMU_write32(u32 addr, u32 val) { _MMU_write32(PROCNUM, AT, addr, val); } - -void FASTCALL MMU_DumpMemBlock(u8 proc, u32 address, u32 size, u8 *buffer); - -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2007 shash + Copyright (C) 2007-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef MMU_H +#define MMU_H + +#include "FIFO.h" +#include "dscard.h" +#include "mem.h" + +#include "ARM9.h" +#include "mc.h" + +//HACK!!!! REMOVE ME SOON! +#ifndef ARMCPU_ARM7 +#define ARMCPU_ARM7 1 +#define ARMCPU_ARM9 0 +#define ARMPROC (PROCNUM?NDS_ARM7:NDS_ARM9) +#endif + +/* theses macros are designed for reading/writing in memory (m is a pointer to memory, like MMU.MMU_MEM[proc], and a is an address, like 0x04000000 */ +#define MEM_8(m, a) (((u8*)(m[((a)>>20)&0xff]))[((a)&0xfff)]) + +/* theses ones for reading in rom data */ +#define ROM_8(m, a) (((u8*)(m))[(a)]) + +typedef const u8 TWaitState; + +struct MMU_struct { + //ARM7 mem + u8 ARM7_BIOS[0x4000]; + u8 ARM7_ERAM[0x10000]; + u8 ARM7_REG[0x10000]; + u8 ARM7_WIRAM[0x10000]; + + // VRAM mapping + u8 VRAM_MAP[4][32]; + u32 LCD_VRAM_ADDR[10]; + u8 LCDCenable[10]; + + //Shared ram + u8 SWIRAM[0x8000]; + + //Card rom & ram + u8 * CART_ROM; + u32 CART_ROM_MASK; + u8 CART_RAM[0x10000]; + + //Unused ram + u8 UNUSED_RAM[4]; + + //this is here so that we can trap glitchy emulator code + //which is accessing offsets 5,6,7 of unused ram due to unaligned accesses + //(also since the emulator doesn't prevent unaligned accesses) + u8 MORE_UNUSED_RAM[4]; + + static u8 * MMU_MEM[2][256]; + static u32 MMU_MASK[2][256]; + + u8 ARM9_RW_MODE; + + static CACHE_ALIGN TWaitState MMU_WAIT16[2][16]; + static CACHE_ALIGN TWaitState MMU_WAIT32[2][16]; + + u32 DTCMRegion; + u32 ITCMRegion; + + u16 timer[2][4]; + s32 timerMODE[2][4]; + u32 timerON[2][4]; + u32 timerRUN[2][4]; + u16 timerReload[2][4]; + + u32 reg_IME[2]; + u32 reg_IE[2]; + u32 reg_IF[2]; + + u32 DMAStartTime[2][4]; + s32 DMACycle[2][4]; + u32 DMACrt[2][4]; + BOOL DMAing[2][4]; + + BOOL divRunning; + s64 divResult; + s64 divMod; + u32 divCnt; + s32 divCycles; + + BOOL sqrtRunning; + u32 sqrtResult; + u32 sqrtCnt; + s32 sqrtCycles; + + u16 SPI_CNT; + u16 SPI_CMD; + u16 AUX_SPI_CNT; + u16 AUX_SPI_CMD; + +#ifdef USE_GEOMETRY_FIFO_EMULATION + s32 gfx3dCycles; +#endif + + u8 powerMan_CntReg; + BOOL powerMan_CntRegWritten; + u8 powerMan_Reg[4]; + + memory_chip_t fw; + + nds_dscard dscard[2]; + u32 CheckTimers; + u32 CheckDMAs; +}; + +struct MMU_struct_new +{ + BackupDevice backupDevice; +}; + +extern MMU_struct MMU; +extern MMU_struct_new MMU_new; + + +struct armcpu_memory_iface { + /** the 32 bit instruction prefetch */ + u32 FASTCALL (*prefetch32)( void *data, u32 adr); + + /** the 16 bit instruction prefetch */ + u16 FASTCALL (*prefetch16)( void *data, u32 adr); + + /** read 8 bit data value */ + u8 FASTCALL (*read8)( void *data, u32 adr); + /** read 16 bit data value */ + u16 FASTCALL (*read16)( void *data, u32 adr); + /** read 32 bit data value */ + u32 FASTCALL (*read32)( void *data, u32 adr); + + /** write 8 bit data value */ + void FASTCALL (*write8)( void *data, u32 adr, u8 val); + /** write 16 bit data value */ + void FASTCALL (*write16)( void *data, u32 adr, u16 val); + /** write 32 bit data value */ + void FASTCALL (*write32)( void *data, u32 adr, u32 val); + + void *data; +}; + + +void MMU_Init(void); +void MMU_DeInit(void); + +void MMU_clearMem( void); + +void MMU_setRom(u8 * rom, u32 mask); +void MMU_unsetRom( void); + +void print_memory_profiling( void); + +// Memory reading/writing (old) +u8 FASTCALL MMU_read8(u32 proc, u32 adr); +u16 FASTCALL MMU_read16(u32 proc, u32 adr); +u32 FASTCALL MMU_read32(u32 proc, u32 adr); +void FASTCALL MMU_write8(u32 proc, u32 adr, u8 val); +void FASTCALL MMU_write16(u32 proc, u32 adr, u16 val); +void FASTCALL MMU_write32(u32 proc, u32 adr, u32 val); + +template void FASTCALL MMU_doDMA(u32 num); + +//The base ARM memory interfaces +extern struct armcpu_memory_iface arm9_base_memory_iface; +extern struct armcpu_memory_iface arm7_base_memory_iface; +extern struct armcpu_memory_iface arm9_direct_memory_iface; + +extern u8 *MMU_RenderMapToLCD(u32 vram_addr); + +#define VRAM_ARM9_PAGES 512 +extern u8 vram_arm9_map[VRAM_ARM9_PAGES]; +FORCEINLINE void* MMU_gpu_map(u32 vram_addr) +{ + //THIS FUNCTION IS NOT AS DANGEROUS! + //as an alternative to the above, use this: + //it is supposed to map a single gpu vram address to emulator host memory + //but it returns a pointer to some zero memory in case of accesses to unmapped memory. + //this correctly handles the case with tile accesses to unmapped memory. + //it could also potentially go through a different LUT than vram_arm9_map in case we discover + //that it needs to be set up with different or no mirroring + //(I think it is a reasonable possibility that only the cpu has the nutty mirroring rules) + // + //if this system isn't used, Fantasy Aquarium displays garbage in the first ingame screen + //due to it storing 0x0F0F or somesuch in screen memory which points to a ridiculously big tile + //which should contain all 0 pixels + + u32 vram_page = (vram_addr>>14)&(VRAM_ARM9_PAGES-1); + u32 ofs = vram_addr & 0x3FFF; + vram_page = vram_arm9_map[vram_page]; + //blank pages are handled by the extra 16KB of blank memory at the end of ARM9_LCD + //and the fact that blank pages are mapped to appear at that location + return ARM9Mem.ARM9_LCD + (vram_page<<14) + ofs; +} + + +enum MMU_ACCESS_TYPE +{ + MMU_AT_CODE, MMU_AT_DATA, MMU_AT_GPU, MMU_AT_DMA +}; + +template u8 _MMU_read08(u32 addr); +template u16 _MMU_read16(u32 addr); +template u32 _MMU_read32(u32 addr); +template void _MMU_write08(u32 addr, u8 val); +template void _MMU_write16(u32 addr, u16 val); +template void _MMU_write32(u32 addr, u32 val); + +template u8 _MMU_read08(u32 addr) { return _MMU_read08(addr); } +template u16 _MMU_read16(u32 addr) { return _MMU_read16(addr); } +template u32 _MMU_read32(u32 addr) { return _MMU_read32(addr); } +template void _MMU_write08(u32 addr, u8 val) { _MMU_write08(addr,val); } +template void _MMU_write16(u32 addr, u16 val) { _MMU_write16(addr,val); } +template void _MMU_write32(u32 addr, u32 val) { _MMU_write32(addr,val); } + +void FASTCALL _MMU_ARM9_write08(u32 adr, u8 val); +void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val); +void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val); +u8 FASTCALL _MMU_ARM9_read08(u32 adr); +u16 FASTCALL _MMU_ARM9_read16(u32 adr); +u32 FASTCALL _MMU_ARM9_read32(u32 adr); + +void FASTCALL _MMU_ARM7_write08(u32 adr, u8 val); +void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val); +void FASTCALL _MMU_ARM7_write32(u32 adr, u32 val); +u8 FASTCALL _MMU_ARM7_read08(u32 adr); +u16 FASTCALL _MMU_ARM7_read16(u32 adr); +u32 FASTCALL _MMU_ARM7_read32(u32 adr); + +extern u32 partie; + +extern u32 _MMU_MAIN_MEM_MASK; +inline void SetupMMU(bool debugConsole) { + if(debugConsole) _MMU_MAIN_MEM_MASK = 0x7FFFFF; + else _MMU_MAIN_MEM_MASK = 0x3FFFFF; +} + +//TODO: at one point some of the early access code included this. consider re-adding it + //ARM7 private memory + //if ( (adr & 0x0f800000) == 0x03800000) { + //T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM7][(adr >> 20) & 0xFF], + // adr & MMU.MMU_MASK[ARMCPU_ARM7][(adr >> 20) & 0xFF]); + +FORCEINLINE u8 _MMU_read08(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr) +{ + //special handling for DMA: read 0 from TCM + if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_DMA) + { + if(addr<0x02000000) return 0; //itcm + if((addr&(~0x3FFF)) == MMU.DTCMRegion) return 0; //dtcm + } + + if(PROCNUM==ARMCPU_ARM9) + if((addr&(~0x3FFF)) == MMU.DTCMRegion) + { + //Returns data from DTCM (ARM9 only) + return T1ReadByte(ARM9Mem.ARM9_DTCM, addr & 0x3FFF); + } + + if ( (addr & 0x0F000000) == 0x02000000) + return T1ReadByte( ARM9Mem.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK); + + if(PROCNUM==ARMCPU_ARM9) return _MMU_ARM9_read08(addr); + else return _MMU_ARM7_read08(addr); +} + +FORCEINLINE u16 _MMU_read16(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr) +{ + //special handling for DMA: read 0 from TCM + if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_DMA) + { + if(addr<0x02000000) return 0; //itcm + if((addr&(~0x3FFF)) == MMU.DTCMRegion) return 0; //dtcm + } + + //special handling for execution from arm9, since we spend so much time in there + if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_CODE) + { + if ((addr & 0x0F000000) == 0x02000000) + return T1ReadWord_guaranteedAligned( ARM9Mem.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK); + + if(addr<0x02000000) + return T1ReadWord_guaranteedAligned(ARM9Mem.ARM9_ITCM, addr&0x7FFF); + + goto dunno; + } + + if(PROCNUM==ARMCPU_ARM9) + if((addr&(~0x3FFF)) == MMU.DTCMRegion) + { + //Returns data from DTCM (ARM9 only) + return T1ReadWord(ARM9Mem.ARM9_DTCM, addr & 0x3FFF); + } + + if ( (addr & 0x0F000000) == 0x02000000) + return T1ReadWord( ARM9Mem.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK); + +dunno: + if(PROCNUM==ARMCPU_ARM9) return _MMU_ARM9_read16(addr); + else return _MMU_ARM7_read16(addr); +} + +FORCEINLINE u32 _MMU_read32(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr) +{ + //special handling for DMA: read 0 from TCM + if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_DMA) + { + if(addr<0x02000000) return 0; //itcm + if((addr&(~0x3FFF)) == MMU.DTCMRegion) return 0; //dtcm + } + + //special handling for execution from arm9, since we spend so much time in there + if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_CODE) + { + if ( (addr & 0x0F000000) == 0x02000000) + return T1ReadLong_guaranteedAligned( ARM9Mem.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK); + + if(addr<0x02000000) + return T1ReadLong_guaranteedAligned(ARM9Mem.ARM9_ITCM, addr&0x7FFF); + + goto dunno; + } + + //special handling for execution from arm7. try reading from main memory first + if(PROCNUM==ARMCPU_ARM7) + { + if ( (addr & 0x0F000000) == 0x02000000) + return T1ReadLong_guaranteedAligned( ARM9Mem.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK); + else if((addr & 0xFF800000) == 0x03800000) + return T1ReadLong_guaranteedAligned(MMU.ARM7_ERAM, addr&0xFFFF); + else if((addr & 0xFF800000) == 0x03000000) + return T1ReadLong_guaranteedAligned(MMU.SWIRAM, addr&0x7FFF); + } + + + //for other arm9 cases, we have to check from dtcm first because it is patched on top of the main memory range + if(PROCNUM==ARMCPU_ARM9) + { + if((addr&(~0x3FFF)) == MMU.DTCMRegion) + { + //Returns data from DTCM (ARM9 only) + return T1ReadLong(ARM9Mem.ARM9_DTCM, addr & 0x3FFF); + } + + if ( (addr & 0x0F000000) == 0x02000000) + return T1ReadLong( ARM9Mem.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK); + } + +dunno: + if(PROCNUM==ARMCPU_ARM9) return _MMU_ARM9_read32(addr); + else return _MMU_ARM7_read32(addr); +} + +FORCEINLINE void _MMU_write08(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr, u8 val) +{ + //special handling for DMA: discard writes to TCM + if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_DMA) + { + if(addr<0x02000000) return; //itcm + if((addr&(~0x3FFF)) == MMU.DTCMRegion) return; //dtcm + } + + if(PROCNUM==ARMCPU_ARM9) + if((addr&(~0x3FFF)) == MMU.DTCMRegion) + { + T1WriteByte(ARM9Mem.ARM9_DTCM, addr & 0x3FFF, val); + return; + } + + if ( (addr & 0x0F000000) == 0x02000000) { + T1WriteByte( ARM9Mem.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK, val); + return; + } + + if(PROCNUM==ARMCPU_ARM9) _MMU_ARM9_write08(addr,val); + else _MMU_ARM7_write08(addr,val); +} + +FORCEINLINE void _MMU_write16(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr, u16 val) +{ + //special handling for DMA: discard writes to TCM + if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_DMA) + { + if(addr<0x02000000) return; //itcm + if((addr&(~0x3FFF)) == MMU.DTCMRegion) return; //dtcm + } + + if(PROCNUM==ARMCPU_ARM9) + if((addr&(~0x3FFF)) == MMU.DTCMRegion) + { + T1WriteWord(ARM9Mem.ARM9_DTCM, addr & 0x3FFF, val); + return; + } + + if ( (addr & 0x0F000000) == 0x02000000) { + T1WriteWord( ARM9Mem.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK, val); + return; + } + + if(PROCNUM==ARMCPU_ARM9) _MMU_ARM9_write16(addr,val); + else _MMU_ARM7_write16(addr,val); +} + +FORCEINLINE void _MMU_write32(const int PROCNUM, const MMU_ACCESS_TYPE AT, const u32 addr, u32 val) +{ + //special handling for DMA: discard writes to TCM + if(PROCNUM==ARMCPU_ARM9 && AT == MMU_AT_DMA) + { + if(addr<0x02000000) return; //itcm + if((addr&(~0x3FFF)) == MMU.DTCMRegion) return; //dtcm + } + + if(PROCNUM==ARMCPU_ARM9) + if((addr&(~0x3FFF)) == MMU.DTCMRegion) + { + T1WriteLong(ARM9Mem.ARM9_DTCM, addr & 0x3FFF, val); + return; + } + + if ( (addr & 0x0F000000) == 0x02000000) { + T1WriteLong( ARM9Mem.MAIN_MEM, addr & _MMU_MAIN_MEM_MASK, val); + return; + } + + if(PROCNUM==ARMCPU_ARM9) _MMU_ARM9_write32(addr,val); + else _MMU_ARM7_write32(addr,val); +} + + +#ifdef MMU_ENABLE_ACL + void FASTCALL MMU_write8_acl(u32 proc, u32 adr, u8 val); + void FASTCALL MMU_write16_acl(u32 proc, u32 adr, u16 val); + void FASTCALL MMU_write32_acl(u32 proc, u32 adr, u32 val); + u8 FASTCALL MMU_read8_acl(u32 proc, u32 adr, u32 access); + u16 FASTCALL MMU_read16_acl(u32 proc, u32 adr, u32 access); + u32 FASTCALL MMU_read32_acl(u32 proc, u32 adr, u32 access); +#else + #define MMU_write8_acl(proc, adr, val) _MMU_write08(adr, val) + #define MMU_write16_acl(proc, adr, val) _MMU_write16(adr, val) + #define MMU_write32_acl(proc, adr, val) _MMU_write32(adr, val) + #define MMU_read8_acl(proc,adr,access) _MMU_read08(adr) + #define MMU_read16_acl(proc,adr,access) ((access==CP15_ACCESS_EXECUTE)?_MMU_read16(adr):_MMU_read16(adr)) + #define MMU_read32_acl(proc,adr,access) ((access==CP15_ACCESS_EXECUTE)?_MMU_read32(adr):_MMU_read32(adr)) +#endif + +// Use this macros for reading/writing, so the GDB stub isn't broken +#ifdef GDB_STUB + #define READ32(a,b) cpu->mem_if->read32(a,(b) & 0xFFFFFFFC) + #define WRITE32(a,b,c) cpu->mem_if->write32(a,(b) & 0xFFFFFFFC,c) + #define READ16(a,b) cpu->mem_if->read16(a,(b) & 0xFFFFFFFE) + #define WRITE16(a,b,c) cpu->mem_if->write16(a,(b) & 0xFFFFFFFE,c) + #define READ8(a,b) cpu->mem_if->read8(a,b) + #define WRITE8(a,b,c) cpu->mem_if->write8(a,b,c) +#else + #define READ32(a,b) _MMU_read32((b) & 0xFFFFFFFC) + #define WRITE32(a,b,c) _MMU_write32((b) & 0xFFFFFFFC,c) + #define READ16(a,b) _MMU_read16((b) & 0xFFFFFFFE) + #define WRITE16(a,b,c) _MMU_write16((b) & 0xFFFFFFFE,c) + #define READ8(a,b) _MMU_read08(b) + #define WRITE8(a,b,c) _MMU_write08(b, c) +#endif + +template +u8 _MMU_read08(u32 addr) { return _MMU_read08(PROCNUM, AT, addr); } + +template +u16 _MMU_read16(u32 addr) { return _MMU_read16(PROCNUM, AT, addr); } + +template +u32 _MMU_read32(u32 addr) { return _MMU_read32(PROCNUM, AT, addr); } + +template +void _MMU_write08(u32 addr, u8 val) { _MMU_write08(PROCNUM, AT, addr, val); } + +template +void _MMU_write16(u32 addr, u16 val) { _MMU_write16(PROCNUM, AT, addr, val); } + +template +void _MMU_write32(u32 addr, u32 val) { _MMU_write32(PROCNUM, AT, addr, val); } + +void FASTCALL MMU_DumpMemBlock(u8 proc, u32 address, u32 size, u8 *buffer); + +#endif diff --git a/desmume/src/Makefile.am b/src/Makefile.am similarity index 88% rename from desmume/src/Makefile.am rename to src/Makefile.am index 8e6a218fb..6655c86a0 100644 --- a/desmume/src/Makefile.am +++ b/src/Makefile.am @@ -1,67 +1,70 @@ -include $(top_srcdir)/src/desmume.mk - -AM_CPPFLAGS += $(SDL_CFLAGS) $(GTK_CFLAGS) $(GTHREAD_CFLAGS) $(X_CFLAGS) $(LUA_CFLAGS) $(ALSA_CFLAGS) $(LIBAGG_CFLAGS) - -EXTRA_DIST = build.bat instruction_tabdef.inc thumb_tabdef.inc fs-linux.cpp fs-windows.cpp -if HAVE_GDB_STUB -SUBDIRS = . gdbstub $(UI_DIR) -else -SUBDIRS = . $(UI_DIR) -endif -DIST_SUBDIRS = . gdbstub cli cocoa gtk gtk-glade windows -noinst_LIBRARIES = libdesmume.a -libdesmume_a_SOURCES = \ - armcpu.cpp armcpu.h ARM9.h \ - arm_instructions.cpp arm_instructions.h \ - bios.cpp bios.h bits.h cp15.cpp cp15.h \ - commandline.h commandline.cpp \ - common.cpp common.h \ - debug.cpp debug.h driver.h \ - Disassembler.cpp Disassembler.h \ - dscard.h fat.h FIFO.cpp FIFO.h \ - GPU.cpp GPU.h \ - GPU_osd.cpp GPU_osd.h \ - mem.h mc.cpp mc.h \ - memorystream.h \ - path.h \ - readwrite.cpp readwrite.h \ - wifi.cpp wifi.h \ - MMU.cpp MMU.h NDSSystem.cpp NDSSystem.h registers.h \ - OGLRender.cpp OGLRender.h \ - ROMReader.cpp ROMReader.h \ - render3D.cpp render3D.h \ - rtc.cpp rtc.h \ - saves.cpp saves.h \ - SPU.cpp SPU.h \ - matrix.cpp matrix.h \ - gfx3d.cpp gfx3d.h \ - texcache.cpp texcache.h \ - thumb_instructions.cpp thumb_instructions.h types.h \ - shaders.h \ - movie.cpp movie.h \ - PACKED.h PACKED_END.h \ - utils/ConvertUTF.c utils/ConvertUTF.h utils/guid.cpp utils/guid.h \ - utils/md5.cpp utils/md5.h utils/valuearray.h utils/xstring.cpp utils/xstring.h \ - utils/decrypt/crc.cpp utils/decrypt/crc.h utils/decrypt/decrypt.cpp \ - utils/decrypt/decrypt.h utils/decrypt/header.cpp utils/decrypt/header.h \ - addons.cpp addons.h \ - addons/compactFlash.cpp addons/gbagame.cpp addons/none.cpp addons/rumblepak.cpp addons/guitarGrip.cpp fs.h \ - cheatSystem.cpp cheatSystem.h \ - texcache.cpp texcache.h rasterize.cpp rasterize.h \ - version.h - -if HAVE_ALSA -libdesmume_a_SOURCES += mic_alsa.cpp -else -libdesmume_a_SOURCES += mic.cpp -endif -if HAVE_LIBAGG -libdesmume_a_SOURCES += aggdraw.cpp -endif -if HAVE_LUA -libdesmume_a_SOURCES += lua-engine.cpp -endif -if HAVE_GDB_STUB -libdesmume_a_SOURCES += gdbstub.h -endif -libdesmume_a_LIBADD = fs-$(desmume_arch).$(OBJEXT) +include $(top_srcdir)/src/desmume.mk + +AM_CPPFLAGS += $(SDL_CFLAGS) $(GTK_CFLAGS) $(GTHREAD_CFLAGS) $(X_CFLAGS) $(LUA_CFLAGS) $(ALSA_CFLAGS) $(LIBAGG_CFLAGS) + +EXTRA_DIST = build.bat instruction_tabdef.inc thumb_tabdef.inc fs-linux.cpp fs-windows.cpp \ + matrix_sse2-x64.asm matrix_sse2-x86.asm +if HAVE_GDB_STUB +SUBDIRS = . gdbstub $(UI_DIR) +else +SUBDIRS = . $(UI_DIR) +endif +DIST_SUBDIRS = . gdbstub cli cocoa gtk gtk-glade windows +noinst_LIBRARIES = libdesmume.a +libdesmume_a_SOURCES = \ + armcpu.cpp armcpu.h ARM9.h \ + arm_instructions.cpp arm_instructions.h \ + bios.cpp bios.h bits.h cp15.cpp cp15.h \ + common.cpp common.h \ + debug.cpp debug.h driver.h \ + Disassembler.cpp Disassembler.h \ + dscard.h fat.h FIFO.cpp FIFO.h \ + GPU.cpp GPU.h \ + GPU_osd.cpp GPU_osd.h \ + mem.h mc.cpp mc.h \ + memorystream.h \ + path.h \ + readwrite.cpp readwrite.h \ + wifi.cpp wifi.h \ + MMU.cpp MMU.h NDSSystem.cpp NDSSystem.h registers.h \ + OGLRender.cpp OGLRender.h \ + ROMReader.cpp ROMReader.h \ + render3D.cpp render3D.h \ + rtc.cpp rtc.h \ + saves.cpp saves.h \ + SPU.cpp SPU.h \ + matrix.cpp matrix.h \ + gfx3d.cpp gfx3d.h \ + texcache.cpp texcache.h \ + thumb_instructions.cpp thumb_instructions.h types.h \ + shaders.h \ + movie.cpp movie.h \ + PACKED.h PACKED_END.h \ + utils/ConvertUTF.c utils/ConvertUTF.h utils/guid.cpp utils/guid.h \ + utils/md5.cpp utils/md5.h utils/valuearray.h utils/xstring.cpp utils/xstring.h \ + utils/decrypt/crc.cpp utils/decrypt/crc.h utils/decrypt/decrypt.cpp \ + utils/decrypt/decrypt.h utils/decrypt/header.cpp utils/decrypt/header.h \ + addons.cpp addons.h \ + addons/compactFlash.cpp addons/gbagame.cpp addons/none.cpp addons/rumblepak.cpp addons/guitarGrip.cpp fs.h \ + cheatSystem.cpp cheatSystem.h \ + texcache.cpp texcache.h rasterize.cpp rasterize.h \ + version.h + +if HAVE_GLIB +libdesmume_a_SOURCES += commandline.h commandline.cpp +endif +if HAVE_ALSA +libdesmume_a_SOURCES += mic_alsa.cpp +else +libdesmume_a_SOURCES += mic.cpp +endif +if HAVE_LIBAGG +libdesmume_a_SOURCES += aggdraw.cpp +endif +if HAVE_LUA +libdesmume_a_SOURCES += lua-engine.cpp +endif +if HAVE_GDB_STUB +libdesmume_a_SOURCES += gdbstub.h +endif +libdesmume_a_LIBADD = fs-$(desmume_arch).$(OBJEXT) diff --git a/desmume/src/NDSSystem.cpp b/src/NDSSystem.cpp similarity index 57% rename from desmume/src/NDSSystem.cpp rename to src/NDSSystem.cpp index b75148b06..8bfa1e40d 100644 --- a/desmume/src/NDSSystem.cpp +++ b/src/NDSSystem.cpp @@ -1,2728 +1,2800 @@ - -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2008-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include -#include -#include -#include -#include - -#include "common.h" -#include "NDSSystem.h" -#include "render3D.h" -#include "MMU.h" -#include "ROMReader.h" -#include "gfx3d.h" -#include "utils/decrypt/decrypt.h" -#include "utils/decrypt/crc.h" -#include "bios.h" -#include "debug.h" -#include "cheatSystem.h" -#include "movie.h" -#include "Disassembler.h" -#include "readwrite.h" - -#include "path.h" - -PathInfo path; - -#if 0 - #ifndef PUBLIC_RELEASE - #undef EXPERIMENTAL_WIFI - #endif -#endif - -TCommonSettings CommonSettings; -static BaseDriver _stub_driver; -BaseDriver* driver = &_stub_driver; -std::string InputDisplayString; - -static BOOL LidClosed = FALSE; -static u8 countLid = 0; - - -GameInfo gameInfo; - -// the count of bytes copied from the firmware into memory -#define NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT 0x70 - -BOOL fw_success = FALSE; - -NDSSystem nds; - -using std::min; -using std::max; - -int lagframecounter; -int LagFrameFlag; -int lastLag; -int TotalLagFrames; - -TSCalInfo TSCal; - -/* ------------------------------------------------------------------------- */ -/* FIRMWARE DECRYPTION */ - -static u32 keyBuf[0x412]; -static u32 keyCode[3]; - -#define DWNUM(i) ((i) >> 2) - -static u32 bswap32(u32 val) -{ - return (((val & 0x000000FF) << 24) | ((val & 0x0000FF00) << 8) | ((val & 0x00FF0000) >> 8) | ((val & 0xFF000000) >> 24)); -} - -static BOOL getKeyBuf() -{ - int dummy; - FILE *file = fopen(CommonSettings.ARM7BIOS, "rb"); - - if(file == NULL) - return FALSE; - - fseek(file, 0x30, SEEK_SET); - dummy = fread(keyBuf, 0x412, 4, file); - - fclose(file); - return TRUE; -} - -static void crypt64BitUp(u32 *ptr) -{ - u32 Y = ptr[0]; - u32 X = ptr[1]; - - for(u32 i = 0x00; i <= 0x0F; i++) - { - u32 Z = (keyBuf[i] ^ X); - X = keyBuf[DWNUM(0x048 + (((Z >> 24) & 0xFF) << 2))]; - X = (keyBuf[DWNUM(0x448 + (((Z >> 16) & 0xFF) << 2))] + X); - X = (keyBuf[DWNUM(0x848 + (((Z >> 8) & 0xFF) << 2))] ^ X); - X = (keyBuf[DWNUM(0xC48 + ((Z & 0xFF) << 2))] + X); - X = (Y ^ X); - Y = Z; - } - - ptr[0] = (X ^ keyBuf[DWNUM(0x40)]); - ptr[1] = (Y ^ keyBuf[DWNUM(0x44)]); -} - -static void crypt64BitDown(u32 *ptr) -{ - u32 Y = ptr[0]; - u32 X = ptr[1]; - - for(u32 i = 0x11; i >= 0x02; i--) - { - u32 Z = (keyBuf[i] ^ X); - X = keyBuf[DWNUM(0x048 + (((Z >> 24) & 0xFF) << 2))]; - X = (keyBuf[DWNUM(0x448 + (((Z >> 16) & 0xFF) << 2))] + X); - X = (keyBuf[DWNUM(0x848 + (((Z >> 8) & 0xFF) << 2))] ^ X); - X = (keyBuf[DWNUM(0xC48 + ((Z & 0xFF) << 2))] + X); - X = (Y ^ X); - Y = Z; - } - - ptr[0] = (X ^ keyBuf[DWNUM(0x04)]); - ptr[1] = (Y ^ keyBuf[DWNUM(0x00)]); -} - -static void applyKeycode(u32 modulo) -{ - crypt64BitUp(&keyCode[1]); - crypt64BitUp(&keyCode[0]); - - u32 scratch[2] = {0x00000000, 0x00000000}; - - for(u32 i = 0; i <= 0x44; i += 4) - { - keyBuf[DWNUM(i)] = (keyBuf[DWNUM(i)] ^ bswap32(keyCode[DWNUM(i % modulo)])); - } - - for(u32 i = 0; i <= 0x1040; i += 8) - { - crypt64BitUp(scratch); - keyBuf[DWNUM(i)] = scratch[1]; - keyBuf[DWNUM(i+4)] = scratch[0]; - } -} - -static BOOL initKeycode(u32 idCode, int level, u32 modulo) -{ - if(getKeyBuf() == FALSE) - return FALSE; - - keyCode[0] = idCode; - keyCode[1] = (idCode >> 1); - keyCode[2] = (idCode << 1); - - if(level >= 1) applyKeycode(modulo); - if(level >= 2) applyKeycode(modulo); - - keyCode[1] <<= 1; - keyCode[2] >>= 1; - - if(level >= 3) applyKeycode(modulo); - - return TRUE; -} - -static u16 getBootCodeCRC16() -{ - unsigned int i, j; - u32 crc = 0xFFFF; - const u16 val[8] = {0xC0C1, 0xC181, 0xC301, 0xC601, 0xCC01, 0xD801, 0xF001, 0xA001}; - - for(i = 0; i < nds.FW_ARM9BootCodeSize; i++) - { - crc = (crc ^ nds.FW_ARM9BootCode[i]); - - for(j = 0; j < 8; j++) - { - if(crc & 0x0001) - crc = ((crc >> 1) ^ (val[j] << (7-j))); - else - crc = (crc >> 1); - } - } - - for(i = 0; i < nds.FW_ARM7BootCodeSize; i++) - { - crc = (crc ^ nds.FW_ARM7BootCode[i]); - - for(j = 0; j < 8; j++) - { - if(crc & 0x0001) - crc = ((crc >> 1) ^ (val[j] << (7-j))); - else - crc = (crc >> 1); - } - } - - return (crc & 0xFFFF); -} - -static u32 * decryptFirmwareBlock(const char *blockName, u32 *src, u32 &size) -{ - u32 curBlock[2]; - u32 *dst; - u32 i, j; - u32 xIn = 4, xOut = 0; - u32 len; - u32 offset; - u32 windowOffset; - u32 xLen; - u8 d; - u16 data; - - memcpy(curBlock, src, 8); - crypt64BitDown(curBlock); - - u32 blockSize = (curBlock[0] >> 8); - size = blockSize; - - INFO("Firmware: %s final size: %i bytes\n", blockName, blockSize); - - dst = (u32*)new u8[blockSize]; - - xLen = blockSize; - - while(xLen > 0) - { - d = T1ReadByte((u8*)curBlock, (xIn % 8)); - xIn++; - if((xIn % 8) == 0) - { - memcpy(curBlock, (((u8*)src) + xIn), 8); - crypt64BitDown(curBlock); - } - - for(i = 0; i < 8; i++) - { - if(d & 0x80) - { - data = (T1ReadByte((u8*)curBlock, (xIn % 8)) << 8); - xIn++; - if((xIn % 8) == 0) - { - memcpy(curBlock, (((u8*)src) + xIn), 8); - crypt64BitDown(curBlock); - } - data |= T1ReadByte((u8*)curBlock, (xIn % 8)); - xIn++; - if((xIn % 8) == 0) - { - memcpy(curBlock, (((u8*)src) + xIn), 8); - crypt64BitDown(curBlock); - } - - len = (data >> 12) + 3; - offset = (data & 0xFFF); - windowOffset = (xOut - offset - 1); - - for(j = 0; j < len; j++) - { - T1WriteByte((u8*)dst, xOut, T1ReadByte((u8*)dst, windowOffset)); - xOut++; - windowOffset++; - - xLen--; - if(xLen == 0) - goto lz77End; - } - } - else - { - T1WriteByte((u8*)dst, xOut, T1ReadByte((u8*)curBlock, (xIn % 8))); - xOut++; - xIn++; - if((xIn % 8) == 0) - { - memcpy(curBlock, (((u8*)src) + xIn), 8); - crypt64BitDown(curBlock); - } - - xLen--; - if(xLen == 0) - goto lz77End; - } - - d = ((d << 1) & 0xFF); - } - } - -lz77End: - - return dst; -} - -static BOOL decryptFirmware(u8 *data) -{ - u16 shifts; - u16 shift1, shift2, shift3, shift4; - u32 part1addr, part2addr, part3addr, part4addr, part5addr; - u32 part1ram, part2ram; - - shifts = T1ReadWord(data, 0x14); - shift1 = (shifts & 0x7); - shift2 = ((shifts >> 3) & 0x7); - shift3 = ((shifts >> 6) & 0x7); - shift4 = ((shifts >> 9) & 0x7); - - part1addr = T1ReadWord(data, 0x0C); - part1addr = (part1addr << (2+shift1)); - - INFO("Firmware: ARM9 boot code address: %05X\n", part1addr); - - part1ram = T1ReadWord(data, 0x0E); - part1ram = (0x02800000 - (part1ram << (2+shift2))); - - INFO("Firmware: ARM9 boot code RAM address: %08X\n", part1ram); - - part2addr = T1ReadWord(data, 0x10); - part2addr = (part2addr << (2+shift3)); - - INFO("Firmware: ARM7 boot code address: %05X\n", part2addr); - - part2ram = T1ReadWord(data, 0x12); - part2ram = (0x03810000 - (part2ram << (2+shift4))); - - INFO("Firmware: ARM7 boot code RAM address: %08X\n", part2ram); - - part3addr = T1ReadWord(data, 0x00); - part3addr = (part3addr << 3); - - INFO("Firmware: ARM9 GUI code address: %05X\n", part3addr); - - part4addr = T1ReadWord(data, 0x02); - part4addr = (part4addr << 3); - - INFO("Firmware: ARM7 GUI code address: %05X\n", part4addr); - - part5addr = T1ReadWord(data, 0x16); - part5addr = (part5addr << 3); - - INFO("Firmware: data/gfx address: %05X\n", part5addr); - - if(initKeycode(T1ReadLong(data, 0x08), 1, 0xC) == FALSE) return FALSE; - crypt64BitDown((u32*)&data[0x18]); - if(initKeycode(T1ReadLong(data, 0x08), 2, 0xC) == FALSE) return FALSE; - - nds.FW_ARM9BootCode = (u8*)decryptFirmwareBlock("ARM9 boot code", (u32*)&data[part1addr], nds.FW_ARM9BootCodeSize); - nds.FW_ARM7BootCode = (u8*)decryptFirmwareBlock("ARM7 boot code", (u32*)&data[part2addr], nds.FW_ARM7BootCodeSize); - - nds.FW_ARM9BootCodeAddr = part1ram; - nds.FW_ARM7BootCodeAddr = part2ram; - - u16 crc16_header = T1ReadWord(data, 0x06); - u16 crc16_mine = getBootCodeCRC16(); - if(crc16_header != crc16_mine) - { - INFO("Firmware: error: the boot code CRC16 (%04X) doesn't match the value in the firmware header (%04X).\n", - crc16_mine, crc16_header); - return FALSE; - } - - return TRUE; -} - -/* ------------------------------------------------------------------------- */ - -static u32 -calc_CRC16( u32 start, const u8 *data, int count) { - int i,j; - u32 crc = start & 0xffff; - const u16 val[8] = { 0xC0C1,0xC181,0xC301,0xC601,0xCC01,0xD801,0xF001,0xA001 }; - for(i = 0; i < count; i++) - { - crc = crc ^ data[i]; - - for(j = 0; j < 8; j++) { - int do_bit = 0; - - if ( crc & 0x1) - do_bit = 1; - - crc = crc >> 1; - - if ( do_bit) { - crc = crc ^ (val[j] << (7-j)); - } - } - } - return crc; -} - -static int -copy_firmware_user_data( u8 *dest_buffer, const u8 *fw_data) { - /* - * Determine which of the two user settings in the firmware is the current - * and valid one and then copy this into the destination buffer. - * - * The current setting will have a greater count. - * Settings are only valid if its CRC16 is correct. - */ - int user1_valid = 0; - int user2_valid = 0; - u32 user_settings_offset; - u32 fw_crc; - u32 crc; - int copy_good = 0; - - user_settings_offset = fw_data[0x20]; - user_settings_offset |= fw_data[0x21] << 8; - user_settings_offset <<= 3; - - if ( user_settings_offset <= 0x3FE00) { - s32 copy_settings_offset = -1; - - crc = calc_CRC16( 0xffff, &fw_data[user_settings_offset], - NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT); - fw_crc = fw_data[user_settings_offset + 0x72]; - fw_crc |= fw_data[user_settings_offset + 0x73] << 8; - if ( crc == fw_crc) { - user1_valid = 1; - } - - crc = calc_CRC16( 0xffff, &fw_data[user_settings_offset + 0x100], - NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT); - fw_crc = fw_data[user_settings_offset + 0x100 + 0x72]; - fw_crc |= fw_data[user_settings_offset + 0x100 + 0x73] << 8; - if ( crc == fw_crc) { - user2_valid = 1; - } - - if ( user1_valid) { - if ( user2_valid) { - u16 count1, count2; - - count1 = fw_data[user_settings_offset + 0x70]; - count1 |= fw_data[user_settings_offset + 0x71] << 8; - - count2 = fw_data[user_settings_offset + 0x100 + 0x70]; - count2 |= fw_data[user_settings_offset + 0x100 + 0x71] << 8; - - if ( count2 > count1) { - copy_settings_offset = user_settings_offset + 0x100; - } - else { - copy_settings_offset = user_settings_offset; - } - } - else { - copy_settings_offset = user_settings_offset; - } - } - else if ( user2_valid) { - /* copy the second user settings */ - copy_settings_offset = user_settings_offset + 0x100; - } - - if ( copy_settings_offset > 0) { - memcpy( dest_buffer, &fw_data[copy_settings_offset], - NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT); - copy_good = 1; - } - } - - return copy_good; -} - -void Desmume_InitOnce() -{ - static bool initOnce = false; - if(initOnce) return; - initOnce = true; - - extern void Agg_init(); //no need to include just for this - Agg_init(); -} - -#ifdef GDB_STUB -int NDS_Init( struct armcpu_memory_iface *arm9_mem_if, -struct armcpu_ctrl_iface **arm9_ctrl_iface, -struct armcpu_memory_iface *arm7_mem_if, -struct armcpu_ctrl_iface **arm7_ctrl_iface) { -#else -int NDS_Init( void) { -#endif - nds.idleFrameCounter = 0; - memset(nds.runCycleCollector,0,sizeof(nds.runCycleCollector)); - MMU_Init(); - nds.VCount = 0; - - nds.sleeping = FALSE; - - if (Screen_Init(GFXCORE_DUMMY) != 0) - return -1; - - gfx3d_init(); - -#ifdef GDB_STUB - armcpu_new(&NDS_ARM7,1, arm7_mem_if, arm7_ctrl_iface); - armcpu_new(&NDS_ARM9,0, arm9_mem_if, arm9_ctrl_iface); -#else - armcpu_new(&NDS_ARM7,1); - armcpu_new(&NDS_ARM9,0); -#endif - - if (SPU_Init(SNDCORE_DUMMY, 740) != 0) - return -1; - -#ifdef EXPERIMENTAL_WIFI - WIFI_Init() ; -#endif - - nds.FW_ARM9BootCode = NULL; - nds.FW_ARM7BootCode = NULL; - - // Init calibration info - TSCal.adc.x1 = 0x0200; - TSCal.adc.y1 = 0x0200; - TSCal.scr.x1 = 0x20; - TSCal.scr.y1 = 0x20; - TSCal.adc.x2 = 0x0E00; - TSCal.adc.y2 = 0x0800; - TSCal.scr.x2 = 0xE0; - TSCal.scr.y2 = 0x80; - - return 0; -} - -void NDS_DeInit(void) { - if(MMU.CART_ROM != MMU.UNUSED_RAM) - NDS_FreeROM(); - - SPU_DeInit(); - Screen_DeInit(); - MMU_DeInit(); - gpu3D->NDS_3D_Close(); - -#ifdef EXPERIMENTAL_WIFI - WIFI_DeInit(); -#endif - cheatsSearchClose(); -} - -BOOL NDS_SetROM(u8 * rom, u32 mask) -{ - MMU_setRom(rom, mask); - - return TRUE; -} - -NDS_header * NDS_getROMHeader(void) -{ - NDS_header * header = new NDS_header; - - memcpy(header->gameTile, MMU.CART_ROM, 12); - memcpy(header->gameCode, MMU.CART_ROM + 12, 4); - header->makerCode = T1ReadWord(MMU.CART_ROM, 16); - header->unitCode = MMU.CART_ROM[18]; - header->deviceCode = MMU.CART_ROM[19]; - header->cardSize = MMU.CART_ROM[20]; - memcpy(header->cardInfo, MMU.CART_ROM + 21, 8); - header->flags = MMU.CART_ROM[29]; - header->ARM9src = T1ReadLong(MMU.CART_ROM, 32); - header->ARM9exe = T1ReadLong(MMU.CART_ROM, 36); - header->ARM9cpy = T1ReadLong(MMU.CART_ROM, 40); - header->ARM9binSize = T1ReadLong(MMU.CART_ROM, 44); - header->ARM7src = T1ReadLong(MMU.CART_ROM, 48); - header->ARM7exe = T1ReadLong(MMU.CART_ROM, 52); - header->ARM7cpy = T1ReadLong(MMU.CART_ROM, 56); - header->ARM7binSize = T1ReadLong(MMU.CART_ROM, 60); - header->FNameTblOff = T1ReadLong(MMU.CART_ROM, 64); - header->FNameTblSize = T1ReadLong(MMU.CART_ROM, 68); - header->FATOff = T1ReadLong(MMU.CART_ROM, 72); - header->FATSize = T1ReadLong(MMU.CART_ROM, 76); - header->ARM9OverlayOff = T1ReadLong(MMU.CART_ROM, 80); - header->ARM9OverlaySize = T1ReadLong(MMU.CART_ROM, 84); - header->ARM7OverlayOff = T1ReadLong(MMU.CART_ROM, 88); - header->ARM7OverlaySize = T1ReadLong(MMU.CART_ROM, 92); - header->unknown2a = T1ReadLong(MMU.CART_ROM, 96); - header->unknown2b = T1ReadLong(MMU.CART_ROM, 100); - header->IconOff = T1ReadLong(MMU.CART_ROM, 104); - header->CRC16 = T1ReadWord(MMU.CART_ROM, 108); - header->ROMtimeout = T1ReadWord(MMU.CART_ROM, 110); - header->ARM9unk = T1ReadLong(MMU.CART_ROM, 112); - header->ARM7unk = T1ReadLong(MMU.CART_ROM, 116); - memcpy(header->unknown3c, MMU.CART_ROM + 120, 8); - header->ROMSize = T1ReadLong(MMU.CART_ROM, 128); - header->HeaderSize = T1ReadLong(MMU.CART_ROM, 132); - memcpy(header->unknown5, MMU.CART_ROM + 136, 56); - memcpy(header->logo, MMU.CART_ROM + 192, 156); - header->logoCRC16 = T1ReadWord(MMU.CART_ROM, 348); - header->headerCRC16 = T1ReadWord(MMU.CART_ROM, 350); - memcpy(header->reserved, MMU.CART_ROM + 352, 160); - - return header; -} - - -INLINE u16 NDS_getADCTouchPosX(u16 scrX) -{ - return (scrX - TSCal.scr.x1 + 1) * (TSCal.adc.x2 - TSCal.adc.x1) / (TSCal.scr.x2 - TSCal.scr.x1) + TSCal.adc.x1; -} - -INLINE u16 NDS_getADCTouchPosY(u16 scrY) -{ - return (scrY - TSCal.scr.y1 + 1) * (TSCal.adc.y2 - TSCal.adc.y1) / (TSCal.scr.y2 - TSCal.scr.y1) + TSCal.adc.y1; -} - -void NDS_setTouchPos(u16 x, u16 y) -{ - //nds.touchX = (x <<4); - //nds.touchY = (y <<4); - nds.touchX = NDS_getADCTouchPosX(x); - nds.touchY = NDS_getADCTouchPosY(y); - nds.isTouch = 1; - - MMU.ARM7_REG[0x136] &= 0xBF; -} - -void NDS_releaseTouch(void) -{ - nds.touchX = 0; - nds.touchY = 0; - nds.isTouch = 0; - - MMU.ARM7_REG[0x136] |= 0x40; -} - - -void debug() -{ - //if(NDS_ARM9.R[15]==0x020520DC) emu_halt(); - //DSLinux - //if(NDS_ARM9.CPSR.bits.mode == 0) emu_halt(); - //if((NDS_ARM9.R[15]&0xFFFFF000)==0) emu_halt(); - //if((NDS_ARM9.R[15]==0x0201B4F4)/*&&(NDS_ARM9.R[1]==0x0)*/) emu_halt(); - //AOE - //if((NDS_ARM9.R[15]==0x01FFE194)&&(NDS_ARM9.R[0]==0)) emu_halt(); - //if((NDS_ARM9.R[15]==0x01FFE134)&&(NDS_ARM9.R[0]==0)) emu_halt(); - - //BBMAN - //if(NDS_ARM9.R[15]==0x02098B4C) emu_halt(); - //if(NDS_ARM9.R[15]==0x02004924) emu_halt(); - //if(NDS_ARM9.R[15]==0x02004890) emu_halt(); - - //if(NDS_ARM9.R[15]==0x0202B800) emu_halt(); - //if(NDS_ARM9.R[15]==0x0202B3DC) emu_halt(); - //if((NDS_ARM9.R[1]==0x9AC29AC1)&&(!fait)) {emu_halt();fait = TRUE;} - //if(NDS_ARM9.R[1]==0x0400004A) {emu_halt();fait = TRUE;} - /*if(NDS_ARM9.R[4]==0x2E33373C) emu_halt(); - if(NDS_ARM9.R[15]==0x02036668) //emu_halt(); - { - nds.logcount++; - sprintf(logbuf, "%d %08X", nds.logcount, NDS_ARM9.R[13]); - log::ajouter(logbuf); - if(nds.logcount==89) execute=FALSE; - }*/ - //if(NDS_ARM9.instruction==0) emu_halt(); - //if((NDS_ARM9.R[15]>>28)) emu_halt(); -} - -#define DSGBA_LOADER_SIZE 512 -enum -{ - ROM_NDS = 0, - ROM_DSGBA -}; - -#if 0 /* not used */ -//http://www.aggregate.org/MAGIC/#Population%20Count%20(Ones%20Count) -static u32 ones32(u32 x) -{ - /* 32-bit recursive reduction using SWAR... - but first step is mapping 2-bit values - into sum of 2 1-bit values in sneaky way - */ - x -= ((x >> 1) & 0x55555555); - x = (((x >> 2) & 0x33333333) + (x & 0x33333333)); - x = (((x >> 4) + x) & 0x0f0f0f0f); - x += (x >> 8); - x += (x >> 16); - return(x & 0x0000003f); -} -#endif - -void GameInfo::populate() -{ - NDS_header * _header = NDS_getROMHeader(); - header = *_header; - delete _header; - - if ( - // ??? in all Homebrews game title have is 2E0000EA - //( - //(header->gameTile[0] == 0x2E) && - //(header->gameTile[1] == 0x00) && - //(header->gameTile[2] == 0x00) && - //(header->gameTile[3] == 0xEA) - //) && - ( - ((header.gameCode[0] == 0x23) && - (header.gameCode[1] == 0x23) && - (header.gameCode[2] == 0x23) && - (header.gameCode[3] == 0x23) - ) || - (header.gameCode[0] == 0x00) - ) - && - header.makerCode == 0x0 - ) - { - memset(ROMserial, 0, sizeof(ROMserial)); - strcpy(ROMserial, "Homebrew"); - } - else - { - memset(ROMserial, '_', sizeof(ROMserial)); - memcpy(ROMserial, header.gameTile, strlen(header.gameTile) < 12 ? strlen(header.gameTile) : 12); - memcpy(ROMserial+12+1, header.gameCode, 4); - memcpy(ROMserial+12+1+4, &header.makerCode, 2); - memset(ROMserial+19, '\0', 1); - } -} -#ifdef WIN32 -#include "memorystream.h" -#include - -static std::vector buffer; -static std::vector v; - -static void loadrom(std::vector* buf, std::string fname) { - - FILE* inf = fopen(fname.c_str(),"rb"); - if(!inf) return; - - fseek(inf,0,SEEK_END); - int size = ftell(inf); - fseek(inf,0,SEEK_SET); - - gameInfo.resize(size); - fread(gameInfo.romdata,1,size,inf); - - fclose(inf); -} - -int NDS_LoadROM(const char *filename, const char *logicalFilename) -{ - int type; - u32 mask; - char buf[MAX_PATH]; - - if (filename == NULL) - return -1; - - path.init(filename); - - if ( path.isdsgba(path.path)) { - type = ROM_DSGBA; - loadrom(&buffer, path.path); - gameInfo.romsize = buffer.size(); - } - else if ( !strcasecmp(path.extension().c_str(), "nds")) { - loadrom(NULL, path.path); //n.b. this does nothing if the file can't be found (i.e. if it was an extracted tempfile)... - //...but since the data was extracted to gameInfo then it is ok - type = ROM_NDS; - } - //ds.gba in archives, it's already been loaded into memory at this point - else if (path.isdsgba(std::string(logicalFilename))) { - - std::vector v(gameInfo.romdata, gameInfo.romdata + gameInfo.romsize); - v.erase(v.begin(),v.begin()+DSGBA_LOADER_SIZE); - buffer.assign( v.begin(), v.end() ); - gameInfo.romdata = &buffer[0]; - gameInfo.romsize = buffer.size(); - } - - if(type == ROM_DSGBA) - { - buffer.erase(buffer.begin(),buffer.begin()+DSGBA_LOADER_SIZE); - gameInfo.romdata = &buffer[0]; - gameInfo.romsize = buffer.size(); - } - - //check that size is at least the size of the header - if (gameInfo.romsize < 352+160) { - return -1; - } - - //zero 25-dec-08 - this used to yield a mask which was 2x large - //mask = size; - mask = gameInfo.romsize-1; - mask |= (mask >>1); - mask |= (mask >>2); - mask |= (mask >>4); - mask |= (mask >>8); - mask |= (mask >>16); - - //decrypt if necessary.. - //but this is untested and suspected to fail on big endian, so lets not support this on big endian - -#ifndef WORDS_BIGENDIAN - bool okRom = DecryptSecureArea((u8*)gameInfo.romdata,gameInfo.romsize); - - if(!okRom) { - printf("Specified file is not a valid rom\n"); - return -1; - } -#endif - - cheatsSearchClose(); - MMU_unsetRom(); - NDS_SetROM((u8*)gameInfo.romdata, mask); - NDS_Reset(); - - memset(buf, 0, MAX_PATH); - - path.getpathnoext(path.BATTERY, buf); - - strcat(buf, ".dsv"); // DeSmuME memory card :) - - MMU_new.backupDevice.load_rom(buf); - - memset(buf, 0, MAX_PATH); - - path.getpathnoext(path.CHEATS, buf); - - strcat(buf, ".dct"); // DeSmuME cheat :) - cheatsInit(buf); - - gameInfo.populate(); - gameInfo.crc = crc32(0,(u8*)gameInfo.romdata,gameInfo.romsize); - INFO("\nROM crc: %08X\n\n", gameInfo.crc); - INFO("\nROM serial: %s\n", gameInfo.ROMserial); - - return 1; -} -#else -int NDS_LoadROM(const char *filename, const char *logicalFilename) -{ - int ret; - int type; - ROMReader_struct *reader; - void *file; - u32 size, mask; - u8 *data; - char *noext; - char buf[MAX_PATH]; - - if (filename == NULL) - return -1; - - noext = strdup(filename); - reader = ROMReaderInit(&noext); - - if(logicalFilename) path.init(logicalFilename); - else path.init(filename); - if(!strcasecmp(path.extension().c_str(), "zip")) type = ROM_NDS; - else if ( !strcasecmp(path.extension().c_str(), "nds")) - type = ROM_NDS; - else if ( path.isdsgba(path.path)) - type = ROM_DSGBA; - else - type = ROM_NDS; - - file = reader->Init(filename); - if (!file) - { - reader->DeInit(file); - free(noext); - return -1; - } - - size = reader->Size(file); - - if(type == ROM_DSGBA) - { - reader->Seek(file, DSGBA_LOADER_SIZE, SEEK_SET); - size -= DSGBA_LOADER_SIZE; - } - - //check that size is at least the size of the header - if (size < 352+160) { - reader->DeInit(file); - free(noext); - return -1; - } - - //zero 25-dec-08 - this used to yield a mask which was 2x large - //mask = size; - mask = size-1; - mask |= (mask >>1); - mask |= (mask >>2); - mask |= (mask >>4); - mask |= (mask >>8); - mask |= (mask >>16); - - // Make sure old ROM is freed first(at least this way we won't be eating - // up a ton of ram before the old ROM is freed) - if(MMU.CART_ROM != MMU.UNUSED_RAM) - NDS_FreeROM(); - - data = new u8[mask + 1]; - if (!data) - { - reader->DeInit(file); - free(noext); - return -1; - } - - ret = reader->Read(file, data, size); - reader->DeInit(file); - - //decrypt if necessary.. - //but this is untested and suspected to fail on big endian, so lets not support this on big endian -#ifndef WORDS_BIGENDIAN - bool okRom = DecryptSecureArea(data,size); - - if(!okRom) { - printf("Specified file is not a valid rom\n"); - return -1; - } -#endif - - - cheatsSearchClose(); - MMU_unsetRom(); - NDS_SetROM(data, mask); - NDS_Reset(); - - free(noext); - - memset(buf, 0, MAX_PATH); - - path.getpathnoext(path.BATTERY, buf); - - strcat(buf, ".dsv"); // DeSmuME memory card :) - - MMU_new.backupDevice.load_rom(buf); - - memset(buf, 0, MAX_PATH); - - path.getpathnoext(path.CHEATS, buf); - - strcat(buf, ".dct"); // DeSmuME cheat :) - cheatsInit(buf); - - gameInfo.populate(); - gameInfo.crc = crc32(0,data,size); - INFO("\nROM crc: %08X\n\n", gameInfo.crc); - INFO("\nROM serial: %s\n", gameInfo.ROMserial); - - return ret; -} -#endif -void NDS_FreeROM(void) -{ - if (MMU.CART_ROM != MMU.UNUSED_RAM) - delete [] MMU.CART_ROM; - MMU_unsetRom(); -} - - - -int NDS_ImportSave(const char *filename) -{ - if (strlen(filename) < 4) - return 0; - - if (memcmp(filename+strlen(filename)-4, ".duc", 4) == 0) - return MMU_new.backupDevice.load_duc(filename); - else - return MMU_new.backupDevice.load_raw(filename); - - return 0; -} - -bool NDS_ExportSave(const char *filename) -{ - if (strlen(filename) < 4) - return false; - - if (memcmp(filename+strlen(filename)-4, ".sav", 4) == 0) - return MMU_new.backupDevice.save_raw(filename); - - return false; -} - -static int WritePNGChunk(FILE *fp, uint32 size, const char *type, const uint8 *data) -{ - uint32 crc; - - uint8 tempo[4]; - - tempo[0]=size>>24; - tempo[1]=size>>16; - tempo[2]=size>>8; - tempo[3]=size; - - if(fwrite(tempo,4,1,fp)!=1) - return 0; - if(fwrite(type,4,1,fp)!=1) - return 0; - - if(size) - if(fwrite(data,1,size,fp)!=size) - return 0; - - crc = crc32(0,(uint8 *)type,4); - if(size) - crc = crc32(crc,data,size); - - tempo[0]=crc>>24; - tempo[1]=crc>>16; - tempo[2]=crc>>8; - tempo[3]=crc; - - if(fwrite(tempo,4,1,fp)!=1) - return 0; - return 1; -} -int NDS_WritePNG(const char *fname) -{ - int x, y; - int width=256; - int height=192*2; - u16 * bmp = (u16 *)GPU_screen; - FILE *pp=NULL; - uint8 *compmem = NULL; - uLongf compmemsize = (uLongf)( (height * (width + 1) * 3 * 1.001 + 1) + 12 ); - - if(!(compmem=(uint8 *)malloc(compmemsize))) - return 0; - - if(!(pp=fopen(fname, "wb"))) - { - return 0; - } - { - static uint8 header[8]={137,80,78,71,13,10,26,10}; - if(fwrite(header,8,1,pp)!=1) - goto PNGerr; - } - - { - uint8 chunko[13]; - - chunko[0] = width >> 24; // Width - chunko[1] = width >> 16; - chunko[2] = width >> 8; - chunko[3] = width; - - chunko[4] = height >> 24; // Height - chunko[5] = height >> 16; - chunko[6] = height >> 8; - chunko[7] = height; - - chunko[8]=8; // 8 bits per sample(24 bits per pixel) - chunko[9]=2; // Color type; RGB triplet - chunko[10]=0; // compression: deflate - chunko[11]=0; // Basic adapative filter set(though none are used). - chunko[12]=0; // No interlace. - - if(!WritePNGChunk(pp,13,"IHDR",chunko)) - goto PNGerr; - } - - { - uint8 *tmp_buffer; - uint8 *tmp_inc; - tmp_inc = tmp_buffer = (uint8 *)malloc((width * 3 + 1) * height); - - for(y=0;y>10; - pixel-=r<<10; - g = pixel>>5; - pixel-=g<<5; - b = pixel; - r*=255/31; - g*=255/31; - b*=255/31; - tmp_inc[0] = b; - tmp_inc[1] = g; - tmp_inc[2] = r; - tmp_inc += 3; - } - } - - if(compress(compmem, &compmemsize, tmp_buffer, height * (width * 3 + 1))!=Z_OK) - { - if(tmp_buffer) free(tmp_buffer); - goto PNGerr; - } - if(tmp_buffer) free(tmp_buffer); - if(!WritePNGChunk(pp,compmemsize,"IDAT",compmem)) - goto PNGerr; - } - if(!WritePNGChunk(pp,0,"IEND",0)) - goto PNGerr; - - free(compmem); - fclose(pp); - - return 1; - -PNGerr: - if(compmem) - free(compmem); - if(pp) - fclose(pp); - return(0); -} - -typedef struct -{ - u32 size; - s32 width; - s32 height; - u16 planes; - u16 bpp; - u32 cmptype; - u32 imgsize; - s32 hppm; - s32 vppm; - u32 numcol; - u32 numimpcol; -} bmpimgheader_struct; - -#include "PACKED.h" -typedef struct -{ - u16 id __PACKED; - u32 size __PACKED; - u16 reserved1 __PACKED; - u16 reserved2 __PACKED; - u32 imgoffset __PACKED; -} bmpfileheader_struct; -#include "PACKED_END.h" - -int NDS_WriteBMP(const char *filename) -{ - bmpfileheader_struct fileheader; - bmpimgheader_struct imageheader; - FILE *file; - int i,j; - u16 * bmp = (u16 *)GPU_screen; - size_t elems_written = 0; - - memset(&fileheader, 0, sizeof(fileheader)); - fileheader.size = sizeof(fileheader); - fileheader.id = 'B' | ('M' << 8); - fileheader.imgoffset = sizeof(fileheader)+sizeof(imageheader); - - memset(&imageheader, 0, sizeof(imageheader)); - imageheader.size = sizeof(imageheader); - imageheader.width = 256; - imageheader.height = 192*2; - imageheader.planes = 1; - imageheader.bpp = 24; - imageheader.cmptype = 0; // None - imageheader.imgsize = imageheader.width * imageheader.height * 3; - - if ((file = fopen(filename,"wb")) == NULL) - return 0; - - elems_written += fwrite(&fileheader, 1, sizeof(fileheader), file); - elems_written += fwrite(&imageheader, 1, sizeof(imageheader), file); - - for(j=0;j<192*2;j++) - { - for(i=0;i<256;i++) - { - u8 r,g,b; - u16 pixel = bmp[(192*2-j-1)*256+i]; - r = pixel>>10; - pixel-=r<<10; - g = pixel>>5; - pixel-=g<<5; - b = (u8)pixel; - r*=255/31; - g*=255/31; - b*=255/31; - elems_written += fwrite(&r, 1, sizeof(u8), file); - elems_written += fwrite(&g, 1, sizeof(u8), file); - elems_written += fwrite(&b, 1, sizeof(u8), file); - } - } - fclose(file); - - return 1; -} - -int NDS_WriteBMP_32bppBuffer(int width, int height, const void* buf, const char *filename) -{ - bmpfileheader_struct fileheader; - bmpimgheader_struct imageheader; - FILE *file; - size_t elems_written = 0; - memset(&fileheader, 0, sizeof(fileheader)); - fileheader.size = sizeof(fileheader); - fileheader.id = 'B' | ('M' << 8); - fileheader.imgoffset = sizeof(fileheader)+sizeof(imageheader); - - memset(&imageheader, 0, sizeof(imageheader)); - imageheader.size = sizeof(imageheader); - imageheader.width = width; - imageheader.height = height; - imageheader.planes = 1; - imageheader.bpp = 32; - imageheader.cmptype = 0; // None - imageheader.imgsize = imageheader.width * imageheader.height * 4; - - if ((file = fopen(filename,"wb")) == NULL) - return 0; - - elems_written += fwrite(&fileheader, 1, sizeof(fileheader), file); - elems_written += fwrite(&imageheader, 1, sizeof(imageheader), file); - - for(int i=0;ifav_colour; - - // birthday month and day - data[0x03] = user_settings->birth_month; - data[0x04] = user_settings->birth_day; - - //nickname and length - for ( i = 0; i < MAX_FW_NICKNAME_LENGTH; i++) { - data[0x06 + (i * 2)] = user_settings->nickname[i] & 0xff; - data[0x06 + (i * 2) + 1] = (user_settings->nickname[i] >> 8) & 0xff; - } - - data[0x1a] = user_settings->nickname_len; - - //Message - for ( i = 0; i < MAX_FW_MESSAGE_LENGTH; i++) { - data[0x1c + (i * 2)] = user_settings->message[i] & 0xff; - data[0x1c + (i * 2) + 1] = (user_settings->message[i] >> 8) & 0xff; - } - - data[0x50] = user_settings->message_len; - - //touch screen calibration - ts_cal_data_area = &data[0x58]; - for ( i = 0; i < 2; i++) { - // ADC x y - *ts_cal_data_area++ = user_settings->touch_cal[i].adc_x & 0xff; - *ts_cal_data_area++ = (user_settings->touch_cal[i].adc_x >> 8) & 0xff; - *ts_cal_data_area++ = user_settings->touch_cal[i].adc_y & 0xff; - *ts_cal_data_area++ = (user_settings->touch_cal[i].adc_y >> 8) & 0xff; - - //screen x y - *ts_cal_data_area++ = user_settings->touch_cal[i].screen_x; - *ts_cal_data_area++ = user_settings->touch_cal[i].screen_y; - } - - //language and flags - data[0x64] = user_settings->language; - data[0x65] = 0xfc; - - //update count and crc - data[0x70] = count & 0xff; - data[0x71] = (count >> 8) & 0xff; - - crc = calc_CRC16( 0xffff, data, 0x70); - data[0x72] = crc & 0xff; - data[0x73] = (crc >> 8) & 0xff; - - memset( &data[0x74], 0xff, 0x100 - 0x74); -} - -// creates an firmware flash image, which contains all needed info to initiate a wifi connection -int NDS_CreateDummyFirmware( struct NDS_fw_config_data *user_settings) -{ - //Create the firmware header - - memset( MMU.fw.data, 0, 0x40000); - - //firmware identifier - MMU.fw.data[0x8] = 'M'; - MMU.fw.data[0x8 + 1] = 'A'; - MMU.fw.data[0x8 + 2] = 'C'; - MMU.fw.data[0x8 + 3] = 'P'; - - // DS type - if ( user_settings->ds_type == NDS_FW_DS_TYPE_LITE) - MMU.fw.data[0x1d] = 0x20; - else - MMU.fw.data[0x1d] = 0xff; - - //User Settings offset 0x3fe00 / 8 - MMU.fw.data[0x20] = 0xc0; - MMU.fw.data[0x21] = 0x7f; - - - //User settings (at 0x3FE00 and 0x3FF00) - - fill_user_data_area( user_settings, &MMU.fw.data[ 0x3FE00], 0); - fill_user_data_area( user_settings, &MMU.fw.data[ 0x3FF00], 1); - - // Wifi config length - MMU.fw.data[0x2C] = 0x38; - MMU.fw.data[0x2D] = 0x01; - - MMU.fw.data[0x2E] = 0x00; - - //Wifi version - MMU.fw.data[0x2F] = 0x00; - - //MAC address - memcpy((MMU.fw.data + 0x36), FW_Mac, sizeof(FW_Mac)); - - //Enabled channels - MMU.fw.data[0x3C] = 0xFE; - MMU.fw.data[0x3D] = 0x3F; - - MMU.fw.data[0x3E] = 0xFF; - MMU.fw.data[0x3F] = 0xFF; - - //RF related - MMU.fw.data[0x40] = 0x02; - MMU.fw.data[0x41] = 0x18; - MMU.fw.data[0x42] = 0x0C; - - MMU.fw.data[0x43] = 0x01; - - //Wifi I/O init values - memcpy((MMU.fw.data + 0x44), FW_WIFIInit, sizeof(FW_WIFIInit)); - - //Wifi BB init values - memcpy((MMU.fw.data + 0x64), FW_BBInit, sizeof(FW_BBInit)); - - //Wifi RF init values - memcpy((MMU.fw.data + 0xCE), FW_RFInit, sizeof(FW_RFInit)); - - //Wifi channel-related init values - memcpy((MMU.fw.data + 0xF2), FW_RFChannel, sizeof(FW_RFChannel)); - memcpy((MMU.fw.data + 0x146), FW_BBChannel, sizeof(FW_BBChannel)); - memset((MMU.fw.data + 0x154), 0x10, 0xE); - - //WFC profiles - memcpy((MMU.fw.data + 0x3FA40), &FW_WFCProfile1, sizeof(FW_WFCProfile)); - memcpy((MMU.fw.data + 0x3FB40), &FW_WFCProfile2, sizeof(FW_WFCProfile)); - memcpy((MMU.fw.data + 0x3FC40), &FW_WFCProfile3, sizeof(FW_WFCProfile)); - (*(u16*)(MMU.fw.data + 0x3FAFE)) = (u16)calc_CRC16(0, (MMU.fw.data + 0x3FA00), 0xFE); - (*(u16*)(MMU.fw.data + 0x3FBFE)) = (u16)calc_CRC16(0, (MMU.fw.data + 0x3FB00), 0xFE); - (*(u16*)(MMU.fw.data + 0x3FCFE)) = (u16)calc_CRC16(0, (MMU.fw.data + 0x3FC00), 0xFE); - - - MMU.fw.data[0x162] = 0x19; - memset((MMU.fw.data + 0x163), 0xFF, 0x9D); - - //Wifi settings CRC16 - (*(u16*)(MMU.fw.data + 0x2A)) = calc_CRC16(0, (MMU.fw.data + 0x2C), 0x138); - - return TRUE ; -} - -void NDS_FillDefaultFirmwareConfigData( struct NDS_fw_config_data *fw_config) { - const char *default_nickname = "yopyop"; - const char *default_message = "DeSmuME makes you happy!"; - int i; - int str_length; - - memset( fw_config, 0, sizeof( struct NDS_fw_config_data)); - fw_config->ds_type = NDS_FW_DS_TYPE_FAT; - - fw_config->fav_colour = 7; - - fw_config->birth_day = 23; - fw_config->birth_month = 6; - - str_length = strlen( default_nickname); - for ( i = 0; i < str_length; i++) { - fw_config->nickname[i] = default_nickname[i]; - } - fw_config->nickname_len = str_length; - - str_length = strlen( default_message); - for ( i = 0; i < str_length; i++) { - fw_config->message[i] = default_message[i]; - } - fw_config->message_len = str_length; - - /* default to English */ - fw_config->language = 1; - - /* default touchscreen calibration */ - fw_config->touch_cal[0].adc_x = 0x200; - fw_config->touch_cal[0].adc_y = 0x200; - fw_config->touch_cal[0].screen_x = 0x20; - fw_config->touch_cal[0].screen_y = 0x20; - - fw_config->touch_cal[1].adc_x = 0xe00; - fw_config->touch_cal[1].adc_y = 0x800; - fw_config->touch_cal[1].screen_x = 0xe0; - fw_config->touch_cal[1].screen_y = 0x80; -} - -int NDS_LoadFirmware(const char *filename) -{ - int i; - unsigned long size; - //FILE *file; - - if ((MMU.fw.fp = fopen(filename, "rb+")) == NULL) - return -1; - - fseek(MMU.fw.fp, 0, SEEK_END); - size = ftell(MMU.fw.fp); - fseek(MMU.fw.fp, 0, SEEK_SET); - - if(size > MMU.fw.size) - { - fclose(MMU.fw.fp); - fw_success = FALSE; - return -1; - } - - i = fread(MMU.fw.data, size, 1, MMU.fw.fp); - //fclose(file); - - INFO("Firmware: decrypting NDS firmware %s...\n", filename); - - if(decryptFirmware(MMU.fw.data) == FALSE) - { - INFO("Firmware: decryption failed.\n"); - fw_success = FALSE; - } - else - { - INFO("Firmware: decryption successful.\n"); - fw_success = TRUE; - } - - return i; -} - -void NDS_Sleep() { nds.sleeping = TRUE; } - -bool SkipCur2DFrame = false, SkipNext2DFrame = false; -bool SkipCur3DFrame = false; - -void NDS_SkipNextFrame() { SkipNext2DFrame = true; SkipCur3DFrame = true; } - -#define INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF)) - -static void execHardware_doDma(int procnum, int chan, EDMAMode modeNum) -{ - if(MMU.DMAStartTime[procnum][chan] == modeNum) - { - if(procnum == ARMCPU_ARM9) MMU_doDMA(chan); - else MMU_doDMA(chan); - //MMU.DMAStartTime[procnum][chan] = 0; //this was here for main mem dma - } -} - -void execHardware_doAllDma(EDMAMode modeNum) -{ - for(int i=0;i<2;i++) - for(int j=0;j<4;j++) - execHardware_doDma(i,j,modeNum); -} - -enum ESI_DISPCNT -{ - ESI_DISPCNT_HStart, ESI_DISPCNT_HBlank -}; - -u64 nds_timer; -u64 nds_arm9_timer, nds_arm7_timer; - -static const u64 kNever = 0xFFFFFFFFFFFFFFFFULL; - -struct TSequenceItem -{ - u64 timestamp; - u32 param; - bool enabled; - - virtual void save(std::ostream* os) - { - write64le(timestamp,os); - write32le(param,os); - writebool(enabled,os); - } - - virtual bool load(std::istream* is) - { - if(read64le(×tamp,is) != 1) return false; - if(read32le(¶m,is) != 1) return false; - if(readbool(&enabled,is) != 1) return false; - return true; - } - - FORCEINLINE bool isTriggered() - { - return enabled && nds_timer >= timestamp; - } - - FORCEINLINE u64 next() - { - if(enabled) return timestamp; - else return kNever; - } -}; - -struct TSequenceItem_GXFIFO : public TSequenceItem -{ - FORCEINLINE bool isTriggered() - { - #ifndef USE_GEOMETRY_FIFO_EMULATION - return false; - #else - return enabled && nds_timer >= MMU.gfx3dCycles; - #endif - } - - FORCEINLINE void exec() - { - #ifdef USE_GEOMETRY_FIFO_EMULATION - enabled = false; //do this first, because gfx3d_execute3D() will cause more scheduled events if necessary - gfx3d_execute3D(); - MMU.gfx3dCycles = max(MMU.gfx3dCycles,nds_timer); //uhh i dont entirely understand why this was necessary - //i need to learn more about how the new gxfifo works, but I am leaving that to you for now crazymax ^_^ - #endif - - } - - FORCEINLINE u64 next() - { - if(enabled) return MMU.gfx3dCycles; - else return kNever; - } -}; - -template struct TSequenceItem_Timer : public TSequenceItem -{ - FORCEINLINE bool isTriggered() - { - return enabled && nds_timer >= nds.timerCycle[procnum][num]; - } - - FORCEINLINE void schedule() - { - enabled = MMU.timerON[procnum][num] && MMU.timerMODE[procnum][num] != 0xFFFF; - } - - FORCEINLINE u64 next() - { - //todo - change this to go through an entire overflow cycle instead of a single increment - //however, in order to do this, we need to change the counter read emulation to calculate its value - //instead of just plucking the uptodate value (which would no longer be kept uptodate) - return nds.timerCycle[procnum][num]; - } - - FORCEINLINE void exec() - { - u8* regs = procnum==0?MMU.ARM9_REG:MMU.ARM7_REG; - bool first = true, over; - //we'll need to check chained timers.. - for(int i=num;i<4;i++) - { - //maybe too many checks if this is here, but we need it here for now - if(!MMU.timerON[procnum][i]) return; - - if(MMU.timerMODE[procnum][i] == 0xFFFF) - { - ++(MMU.timer[procnum][i]); - over = !MMU.timer[procnum][i]; - } - else - { - if(!first) break; //this timer isn't chained. break the chain - first = false; - - over = true; - int remain = 65536 - MMU.timerReload[procnum][i]; - int ctr=0; - while(nds.timerCycle[procnum][i] <= nds_timer) { - nds.timerCycle[procnum][i] += (remain << MMU.timerMODE[procnum][i]); - ctr++; - } - if(ctr>1) { - printf("yikes!!!!! please report!\n"); - } - } - - if(over) - { - MMU.timer[procnum][i] = MMU.timerReload[procnum][i]; - if(T1ReadWord(regs, 0x102 + i*4) & 0x40) - { - if(procnum==0) NDS_makeARM9Int(3 + i); - else NDS_makeARM7Int(3 + i); - } - } - else - break; //no more chained timers to trigger. we're done here - } - } -}; - -template struct TSequenceItem_DMA : public TSequenceItem -{ - FORCEINLINE bool isTriggered() - { - return (MMU.DMAing[procnum][chan])&&nds_timer>=(MMU.DMACycle[procnum][chan]); - } - - FORCEINLINE u64 next() - { - if(!MMU.DMAing[procnum][chan]) return kNever; - return MMU.DMACycle[procnum][chan]; - } - - FORCEINLINE void exec() - { - if (MMU.DMACompleted[procnum][chan]) - { - u8* regs = procnum==0?MMU.ARM9_REG:MMU.ARM7_REG; - T1WriteLong(regs, 0xB8 + (0xC*chan), T1ReadLong(regs, 0xB8 + (0xC*chan)) & 0x7FFFFFFF); - if((MMU.DMACrt[procnum][chan])&(1<<30)) { - if(procnum==0) NDS_makeARM9Int(8+chan); - else NDS_makeARM7Int(8+chan); - } - MMU.DMAing[procnum][chan] = FALSE; - } - } -}; - -struct TSequenceItem_divider : public TSequenceItem -{ - FORCEINLINE bool isTriggered() - { - return MMU.divRunning && nds_timer >= MMU.divCycles; - } - - FORCEINLINE u64 next() - { - if(!MMU.divRunning) return kNever; - return MMU.divCycles; - } - - void exec() - { - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A0, (u32)MMU.divResult); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A4, (u32)(MMU.divResult >> 32)); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A8, (u32)MMU.divMod); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2AC, (u32)(MMU.divMod >> 32)); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x280, MMU.divCnt); - MMU.divRunning = FALSE; - } - -}; - -struct TSequenceItem_sqrtunit : public TSequenceItem -{ - FORCEINLINE bool isTriggered() - { - return MMU.sqrtRunning && nds_timer >= MMU.sqrtCycles; - } - - FORCEINLINE u64 next() - { - if(!MMU.sqrtRunning) return kNever; - return MMU.sqrtCycles; - } - - FORCEINLINE void exec() - { - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B4, MMU.sqrtResult); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B0, MMU.sqrtCnt); - MMU.sqrtRunning = FALSE; - } - -}; - -struct Sequencer -{ - bool nds_vblankEnded; - bool reschedule; - TSequenceItem dispcnt; - TSequenceItem wifi; - TSequenceItem_divider divider; - TSequenceItem_sqrtunit sqrtunit; - TSequenceItem_GXFIFO gxfifo; - TSequenceItem_DMA<0,0> dma_0_0; TSequenceItem_DMA<0,1> dma_0_1; - TSequenceItem_DMA<0,2> dma_0_2; TSequenceItem_DMA<0,3> dma_0_3; - TSequenceItem_DMA<1,0> dma_1_0; TSequenceItem_DMA<1,1> dma_1_1; - TSequenceItem_DMA<1,2> dma_1_2; TSequenceItem_DMA<1,3> dma_1_3; - TSequenceItem_Timer<0,0> timer_0_0; TSequenceItem_Timer<0,1> timer_0_1; - TSequenceItem_Timer<0,2> timer_0_2; TSequenceItem_Timer<0,3> timer_0_3; - TSequenceItem_Timer<1,0> timer_1_0; TSequenceItem_Timer<1,1> timer_1_1; - TSequenceItem_Timer<1,2> timer_1_2; TSequenceItem_Timer<1,3> timer_1_3; - - void init(); - - void execHardware(); - u64 findNext(); - - void save(std::ostream* os) - { - write64le(nds_timer,os); - write64le(nds_arm9_timer,os); - write64le(nds_arm7_timer,os); - dispcnt.save(os); - divider.save(os); - sqrtunit.save(os); - gxfifo.save(os); - wifi.save(os); -#define SAVE(I,X,Y) I##_##X##_##Y .save(os); - SAVE(timer,0,0); SAVE(timer,0,1); SAVE(timer,0,2); SAVE(timer,0,3); - SAVE(timer,1,0); SAVE(timer,1,1); SAVE(timer,1,2); SAVE(timer,1,3); - SAVE(dma,0,0); SAVE(dma,0,1); SAVE(dma,0,2); SAVE(dma,0,3); - SAVE(dma,1,0); SAVE(dma,1,1); SAVE(dma,1,2); SAVE(dma,1,3); -#undef SAVE - } - - bool load(std::istream* is, int version) - { - if(read64le(&nds_timer,is) != 1) return false; - if(read64le(&nds_arm9_timer,is) != 1) return false; - if(read64le(&nds_arm7_timer,is) != 1) return false; - if(!dispcnt.load(is)) return false; - if(!divider.load(is)) return false; - if(!sqrtunit.load(is)) return false; - if(!gxfifo.load(is)) return false; - if(version >= 1) if(!wifi.load(is)) return false; -#define LOAD(I,X,Y) if(!I##_##X##_##Y .load(is)) return false; - LOAD(timer,0,0); LOAD(timer,0,1); LOAD(timer,0,2); LOAD(timer,0,3); - LOAD(timer,1,0); LOAD(timer,1,1); LOAD(timer,1,2); LOAD(timer,1,3); - LOAD(dma,0,0); LOAD(dma,0,1); LOAD(dma,0,2); LOAD(dma,0,3); - LOAD(dma,1,0); LOAD(dma,1,1); LOAD(dma,1,2); LOAD(dma,1,3); -#undef LOAD - - return true; - } - -} sequencer; - -void NDS_RescheduleGXFIFO() -{ -#ifdef USE_GEOMETRY_FIFO_EMULATION - sequencer.gxfifo.enabled = true; - NDS_Reschedule(); -#endif -} - -void NDS_RescheduleTimers() -{ -#define check(X,Y) sequencer.timer_##X##_##Y .schedule(); - check(0,0); check(0,1); check(0,2); check(0,3); - check(1,0); check(1,1); check(1,2); check(1,3); -#undef check - - NDS_Reschedule(); -} - -void NDS_RescheduleDMA() -{ - //TBD - NDS_Reschedule(); -} - -static void initSchedule() -{ - sequencer.init(); - - //begin at the very end of the last scanline - //so that at t=0 we can increment to scanline=0 - nds.VCount = 262; - - sequencer.nds_vblankEnded = false; -} - - -// 2196372 ~= (ARM7_CLOCK << 16) / 1000000 -// This value makes more sense to me, because: -// ARM7_CLOCK = 33.51 mhz -// = 33513982 cycles per second -// = 33.513982 cycles per microsecond -const u64 kWifiCycles = 34*2; -//(this isn't very precise. I don't think it needs to be) - -void Sequencer::init() -{ - NDS_RescheduleTimers(); - NDS_RescheduleDMA(); - - reschedule = false; - nds_timer = 0; - nds_arm9_timer = 0; - nds_arm7_timer = 0; - - dispcnt.enabled = true; - dispcnt.param = ESI_DISPCNT_HStart; - dispcnt.timestamp = 0; - - gxfifo.enabled = false; - - - #ifdef EXPERIMENTAL_WIFI - wifi.enabled = true; - wifi.timestamp = kWifiCycles; - #else - wifi.enabled = false; - #endif -} - - -static void execHardware_hblank() -{ - //turn on hblank status bit - T1WriteWord(MMU.ARM9_REG, 4, T1ReadWord(MMU.ARM9_REG, 4) | 2); - T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 2); - - //fire hblank interrupts if necessary - NDS_ARM9HBlankInt(); - NDS_ARM7HBlankInt(); - - //emulation housekeeping. for some reason we always do this at hblank, - //even though it sounds more reasonable to do it at hstart - SPU_Emulate_core(); - driver->AVI_SoundUpdate(SPU_core->outbuf,spu_core_samples); - WAV_WavSoundUpdate(SPU_core->outbuf,spu_core_samples); - - //this logic was formerly at hblank time. it was moved to the beginning of the scanline on a whim - if(nds.VCount<192) - { - //so, we have chosen to do the line drawing at hblank time. - //this is the traditional time for it in desmume. - //while it may seem more ruthlessly accurate to do it at hstart, - //in practice we need to be more forgiving, in case things have overrun the scanline start. - //this should be safe since games cannot do anything timing dependent until this next - //scanline begins, anyway (as this scanline was in the middle of drawing) - GPU_ligne(&MainScreen, nds.VCount, SkipCur2DFrame); - GPU_ligne(&SubScreen, nds.VCount, SkipCur2DFrame); - - //trigger hblank dmas - //but notice, we do that just after we finished drawing the line - //(values copied by this hdma should not be used until the next scanline) - execHardware_doAllDma(EDMAMode_HBlank); - } -} - -static void execHardware_hstart_vblankEnd() -{ - nds.VCount = 0; - sequencer.nds_vblankEnded = true; - sequencer.reschedule = true; - - //turn off vblank status bit - T1WriteWord(MMU.ARM9_REG, 4, T1ReadWord(MMU.ARM9_REG, 4) & 0xFFFE); - T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) & 0xFFFE); -} - -static void execHardware_hstart_vblankStart() -{ - //turn on vblank status bit - T1WriteWord(MMU.ARM9_REG, 4, T1ReadWord(MMU.ARM9_REG, 4) | 1); - T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 1); - - //fire vblank interrupts if necessary - NDS_ARM9VBlankInt(); - NDS_ARM7VBlankInt(); - - //some emulation housekeeping - gfx3d_VBlankSignal(); - if(SkipNext2DFrame) - { - SkipCur2DFrame = true; - SkipNext2DFrame = false; - } - else - SkipCur2DFrame = false; - - //trigger vblank dmas - execHardware_doAllDma(EDMAMode_VBlank); -} - -static void execHardware_hstart_vcount() -{ - u16 vmatch = T1ReadWord(MMU.ARM9_REG, 4); - if(nds.VCount==((vmatch>>8)|((vmatch<<1)&(1<<8)))) - { - T1WriteWord(MMU.ARM9_REG, 4, T1ReadWord(MMU.ARM9_REG, 4) | 4); - if(T1ReadWord(MMU.ARM9_REG, 4) & 32) - NDS_makeARM9Int(2); - } - else - T1WriteWord(MMU.ARM9_REG, 4, T1ReadWord(MMU.ARM9_REG, 4) & 0xFFFB); - - vmatch = T1ReadWord(MMU.ARM7_REG, 4); - if(nds.VCount==((vmatch>>8)|((vmatch<<1)&(1<<8)))) - { - T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 4); - if(T1ReadWord(MMU.ARM7_REG, 4) & 32) - NDS_makeARM7Int(2); - } - else - T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) & 0xFFFB); -} - -static void execHardware_hstart() -{ - nds.VCount++; - - if(nds.VCount==263) - { - execHardware_hstart_vblankEnd(); - } else if(nds.VCount==192) - { - execHardware_hstart_vblankStart(); - } - - //write the new vcount - T1WriteWord(MMU.ARM9_REG, 6, nds.VCount); - T1WriteWord(MMU.ARM9_REG, 0x1006, nds.VCount); - T1WriteWord(MMU.ARM7_REG, 6, nds.VCount); - T1WriteWord(MMU.ARM7_REG, 0x1006, nds.VCount); - - //turn off hblank status bit - T1WriteWord(MMU.ARM9_REG, 4, T1ReadWord(MMU.ARM9_REG, 4) & 0xFFFD); - T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) & 0xFFFD); - - //handle vcount status - execHardware_hstart_vcount(); - - //trigger hstart dmas - execHardware_doAllDma(EDMAMode_HStart); - - if(nds.VCount<192) - { - //this is hacky. - //there is a corresponding hack in doDMA. - //it should be driven by a fifo (and generate just in time as the scanline is displayed) - //but that isnt even possible until we have some sort of sub-scanline timing. - //it may not be necessary. - execHardware_doAllDma(EDMAMode_MemDisplay); - } - - //end of 3d vblank - if(nds.VCount==214) - { - gfx3d_VBlankEndSignal(SkipCur3DFrame); - SkipCur3DFrame = false; - } -} - -void NDS_Reschedule() -{ - sequencer.reschedule = true; -} - -u64 Sequencer::findNext() -{ - u64 next = kNever; - next = min(next,dispcnt.next()); - next = min(next,divider.next()); - next = min(next,sqrtunit.next()); - next = min(next,gxfifo.next()); - -#ifdef EXPERIMENTAL_WIFI - next = min(next,wifi.next()); -#endif - -#define test(X,Y) next = min(next,dma_##X##_##Y .next()); - test(0,0); test(0,1); test(0,2); test(0,3); - test(1,0); test(1,1); test(1,2); test(1,3); -#undef test -#define test(X,Y) if(timer_##X##_##Y .enabled) next = min(next,timer_##X##_##Y .next()); - test(0,0); test(0,1); test(0,2); test(0,3); - test(1,0); test(1,1); test(1,2); test(1,3); -#undef test - - return next; -} - -void Sequencer::execHardware() -{ - if(dispcnt.isTriggered()) - { - switch(dispcnt.param) - { - case ESI_DISPCNT_HStart: - execHardware_hstart(); - dispcnt.timestamp += 3168; - dispcnt.param = ESI_DISPCNT_HBlank; - break; - case ESI_DISPCNT_HBlank: - execHardware_hblank(); - dispcnt.timestamp += 1092; - dispcnt.param = ESI_DISPCNT_HStart; - break; - } - } - -#ifndef PUBLIC_RELEASE -#ifdef EXPERIMENTAL_WIFI - if(wifi.isTriggered()) - { - WIFI_usTrigger(); - wifi.timestamp += kWifiCycles; - } -#endif -#endif - - if(divider.isTriggered()) divider.exec(); - if(sqrtunit.isTriggered()) sqrtunit.exec(); - if(gxfifo.isTriggered()) gxfifo.exec(); - - -#define test(X,Y) if(dma_##X##_##Y .isTriggered()) dma_##X##_##Y .exec(); - test(0,0); test(0,1); test(0,2); test(0,3); - test(1,0); test(1,1); test(1,2); test(1,3); -#undef test -#define test(X,Y) if(timer_##X##_##Y .enabled) if(timer_##X##_##Y .isTriggered()) timer_##X##_##Y .exec(); - test(0,0); test(0,1); test(0,2); test(0,3); - test(1,0); test(1,1); test(1,2); test(1,3); -#undef test -} - -void execHardware_interrupts(); - -void nds_savestate(std::ostream* os) -{ - //version - write32le(1,os); - - sequencer.save(os); -} - -bool nds_loadstate(std::istream* is, int size) -{ - //read version - int version; - if(read32le(&version,is) != 1) return false; - - if(version > 1) return false; - - return sequencer.load(is, version); -} - -//#define LOG_ARM9 -//#define LOG_ARM7 -//static bool dolog = false; - -FORCEINLINE void arm9log() -{ -#ifdef LOG_ARM9 - if(dolog) - { - char dasmbuf[4096]; - if(NDS_ARM9.CPSR.bits.T) - des_thumb_instructions_set[((NDS_ARM9.instruction)>>6)&1023](NDS_ARM9.instruct_adr, NDS_ARM9.instruction, dasmbuf); - else - des_arm_instructions_set[INDEX(NDS_ARM9.instruction)](NDS_ARM9.instruct_adr, NDS_ARM9.instruction, dasmbuf); - - printf("%05d %12lld 9:%08X %08X %-30s R00:%08X R01:%08X R02:%08X R03:%08X R04:%08X R05:%08X R06:%08X R07:%08X R08:%08X R09:%08X R10:%08X R11:%08X R12:%08X R13:%08X R14:%08X R15:%08X\n", - currFrameCounter, nds_timer, - NDS_ARM9.instruct_adr,NDS_ARM9.instruction, dasmbuf, - NDS_ARM9.R[0], NDS_ARM9.R[1], NDS_ARM9.R[2], NDS_ARM9.R[3], NDS_ARM9.R[4], NDS_ARM9.R[5], NDS_ARM9.R[6], NDS_ARM9.R[7], - NDS_ARM9.R[8], NDS_ARM9.R[9], NDS_ARM9.R[10], NDS_ARM9.R[11], NDS_ARM9.R[12], NDS_ARM9.R[13], NDS_ARM9.R[14], NDS_ARM9.R[15]); - } -#endif -} - -FORCEINLINE void arm7log() -{ - #ifdef LOG_ARM7 - if(dolog) - { - char dasmbuf[4096]; - if(NDS_ARM7.CPSR.bits.T) - des_thumb_instructions_set[((NDS_ARM7.instruction)>>6)&1023](NDS_ARM7.instruct_adr, NDS_ARM7.instruction, dasmbuf); - else - des_arm_instructions_set[INDEX(NDS_ARM7.instruction)](NDS_ARM7.instruct_adr, NDS_ARM7.instruction, dasmbuf); - - printf("%05d %12lld 7:%08X %08X %-30s R00:%08X R01:%08X R02:%08X R03:%08X R04:%08X R05:%08X R06:%08X R07:%08X R08:%08X R09:%08X R10:%08X R11:%08X R12:%08X R13:%08X R14:%08X R15:%08X\n", - currFrameCounter, nds_timer, - NDS_ARM7.instruct_adr,NDS_ARM7.instruction, dasmbuf, - NDS_ARM7.R[0], NDS_ARM7.R[1], NDS_ARM7.R[2], NDS_ARM7.R[3], NDS_ARM7.R[4], NDS_ARM7.R[5], NDS_ARM7.R[6], NDS_ARM7.R[7], - NDS_ARM7.R[8], NDS_ARM7.R[9], NDS_ARM7.R[10], NDS_ARM7.R[11], NDS_ARM7.R[12], NDS_ARM7.R[13], NDS_ARM7.R[14], NDS_ARM7.R[15]); - } - #endif -} - -template -void NDS_exec(s32 nb) -{ - //TODO - singlestep is broken - - LagFrameFlag=1; - - if((currFrameCounter&63) == 0) - MMU_new.backupDevice.lazy_flush(); - - sequencer.nds_vblankEnded = false; - - //these have not been tuned very well yet. - const int kMaxWork = 4000; - const int kIrqWait = 4000; - - if(nds.sleeping) - { - gpu_UpdateRender(); - if((MMU.reg_IE[1] & MMU.reg_IF[1]) & (1<<22)) - { - nds.sleeping = FALSE; - } - } - else - { - for(;;) - { - sequencer.execHardware(); - - //break out once per frame - if(sequencer.nds_vblankEnded) break; - //it should be benign to execute execHardware in the next frame, - //since there won't be anything for it to do (everything should be scheduled in the future) - - execHardware_interrupts(); - - //find next work unit: - u64 next = sequencer.findNext(); - next = min(next,nds_timer+kMaxWork); //lets set an upper limit for now - - //printf("%d\n",(next-nds_timer)); - - sequencer.reschedule = false; - - u64 nds_timer_base = nds_timer; - s32 arm9 = (s32)(nds_arm9_timer-nds_timer); - s32 arm7 = (s32)(nds_arm7_timer-nds_timer); - s32 timer = 0; - s32 s32next = (s32)(next-nds_timer); - while(timer(); - } - - } - if(arm7<=timer) - { - if(NDS_ARM7.waitIRQ) - arm7 = min(s32next,arm7 + kIrqWait); - else { - arm7log(); - arm7 += (armcpu_exec()<<1); - } - } - - timer = min(arm7,arm9); - nds_timer = nds_timer_base+timer; - } - - nds_arm7_timer = nds_timer_base+arm7; - nds_arm9_timer = nds_timer_base+arm9; - - //what we find here is dependent on the timing constants above - if(nds_timer>next && (nds_timer-next)>22) - printf("curious. please report: over by %d\n",(int)(nds_timer-next)); - - //if we were waiting for an irq, don't wait too long: - //let's re-analyze it after this hardware event - if(NDS_ARM9.waitIRQ) nds_arm9_timer = nds_timer; - if(NDS_ARM7.waitIRQ) nds_arm7_timer = nds_timer; - } - } - - //end of frame emulation housekeeping - if(LagFrameFlag) - { - lagframecounter++; - TotalLagFrames++; - } - else - { - lastLag = lagframecounter; - lagframecounter = 0; - } - currFrameCounter++; - cheatsProcess(); -} - -void execHardware_interrupts() -{ - //THIS IS A HACK but it is necessary until we have gxfifo emulation - #ifndef USE_GEOMETRY_FIFO_EMULATION - if(MMU.reg_IE[ARMCPU_ARM9]&(1<<21)) - NDS_makeARM9Int(21); // GX geometry - #endif - - if((MMU.reg_IF[0]&MMU.reg_IE[0]) && (MMU.reg_IME[0])) - { -#ifdef GDB_STUB - if ( armcpu_flagIrq( &NDS_ARM9)) -#else - if ( armcpu_irqException(&NDS_ARM9)) -#endif - { - //nds.ARM9Cycle = nds.cycles; - } - } - - if((MMU.reg_IF[1]&MMU.reg_IE[1]) && (MMU.reg_IME[1])) - { -#ifdef GDB_STUB - if ( armcpu_flagIrq( &NDS_ARM7)) -#else - if ( armcpu_irqException(&NDS_ARM7)) -#endif - { - //nds.ARM7Cycle = nds.cycles; - } - } -} - -bool _HACK_DONT_STOPMOVIE = false; -void NDS_Reset() -{ - u32 src; - u32 dst; - FILE* inf = 0; - NDS_header * header = NDS_getROMHeader(); - - if (!header) return ; - - nds_timer = 0; - nds_arm9_timer = 0; - nds_arm7_timer = 0; - - if(movieMode != MOVIEMODE_INACTIVE && !_HACK_DONT_STOPMOVIE) - movie_reset_command = true; - - if(movieMode == MOVIEMODE_INACTIVE) { - currFrameCounter = 0; - lagframecounter = 0; - LagFrameFlag = 0; - lastLag = 0; - TotalLagFrames = 0; - } - - MMU_Reset(); - MMU_new.backupDevice.reset(); - - //ARM7 BIOS IRQ HANDLER - if(CommonSettings.UseExtBIOS == true) - inf = fopen(CommonSettings.ARM7BIOS,"rb"); - else - inf = NULL; - - if(inf) { - fread(MMU.ARM7_BIOS,1,16384,inf); - fclose(inf); - if(CommonSettings.SWIFromBIOS == true) NDS_ARM7.swi_tab = 0; - else NDS_ARM7.swi_tab = ARM7_swi_tab; - INFO("ARM7 BIOS is loaded.\n"); - } else { - NDS_ARM7.swi_tab = ARM7_swi_tab; - _MMU_write32(0x00, 0xE25EF002); - _MMU_write32(0x04, 0xEAFFFFFE); - _MMU_write32(0x18, 0xEA000000); - _MMU_write32(0x20, 0xE92D500F); - _MMU_write32(0x24, 0xE3A00301); - _MMU_write32(0x28, 0xE28FE000); - _MMU_write32(0x2C, 0xE510F004); - _MMU_write32(0x30, 0xE8BD500F); - _MMU_write32(0x34, 0xE25EF004); - } - - //ARM9 BIOS IRQ HANDLER - if(CommonSettings.UseExtBIOS == true) - inf = fopen(CommonSettings.ARM9BIOS,"rb"); - else - inf = NULL; - //memcpy(MMU.ARM9_BIOS + 0x20, gba_header_data_0x04, 156); - - if(inf) { - fread(MMU.ARM9_BIOS,1,4096,inf); - fclose(inf); - if(CommonSettings.SWIFromBIOS == true) NDS_ARM9.swi_tab = 0; - else NDS_ARM9.swi_tab = ARM9_swi_tab; - INFO("ARM9 BIOS is loaded.\n"); - } else { - NDS_ARM9.swi_tab = ARM9_swi_tab; - _MMU_write32(0xFFFF0018, 0xEA000000); - _MMU_write32(0xFFFF0020, 0xE92D500F); - _MMU_write32(0xFFFF0024, 0xEE190F11); - _MMU_write32(0xFFFF0028, 0xE1A00620); - _MMU_write32(0xFFFF002C, 0xE1A00600); - _MMU_write32(0xFFFF0030, 0xE2800C40); - _MMU_write32(0xFFFF0034, 0xE28FE000); - _MMU_write32(0xFFFF0038, 0xE510F004); - _MMU_write32(0xFFFF003C, 0xE8BD500F); - _MMU_write32(0xFFFF0040, 0xE25EF004); - } - - if(CommonSettings.UseExtFirmware == true) - NDS_LoadFirmware(CommonSettings.Firmware); - - if((CommonSettings.UseExtBIOS == true) && (CommonSettings.UseExtFirmware == true) && (CommonSettings.BootFromFirmware == true) && (fw_success == TRUE)) - { - // Copy firmware boot codes to their respective locations - - src = 0; - dst = nds.FW_ARM9BootCodeAddr; - for(u32 i = 0; i < (nds.FW_ARM9BootCodeSize >> 2); i++) - { - _MMU_write32(dst, T1ReadLong(nds.FW_ARM9BootCode, src)); - src += 4; dst += 4; - } - - src = 0; - dst = nds.FW_ARM7BootCodeAddr; - for(u32 i = 0; i < (nds.FW_ARM7BootCodeSize >> 2); i++) - { - _MMU_write32(dst, T1ReadLong(nds.FW_ARM7BootCode, src)); - src += 4; dst += 4; - } - - // Copy secure area to memory if needed - if ((header->ARM9src >= 0x4000) && (header->ARM9src < 0x8000)) - { - src = header->ARM9src; - dst = header->ARM9cpy; - u32 size = (0x8000 - src) >> 2; - for (u32 i = 0; i < size; i++) - { - _MMU_write32(dst, T1ReadLong(MMU.CART_ROM, src)); - src += 4; dst += 4; - } - } - - armcpu_init(&NDS_ARM9, nds.FW_ARM9BootCodeAddr); - armcpu_init(&NDS_ARM7, nds.FW_ARM7BootCodeAddr); - //armcpu_init(&NDS_ARM9, 0xFFFF0000); - //armcpu_init(&NDS_ARM7, 0x00000000); - } - else - { - src = header->ARM9src; - dst = header->ARM9cpy; - - for(u32 i = 0; i < (header->ARM9binSize>>2); ++i) - { - _MMU_write32(dst, T1ReadLong(MMU.CART_ROM, src)); - dst += 4; - src += 4; - } - - src = header->ARM7src; - dst = header->ARM7cpy; - - for(u32 i = 0; i < (header->ARM7binSize>>2); ++i) - { - _MMU_write32(dst, T1ReadLong(MMU.CART_ROM, src)); - dst += 4; - src += 4; - } - - armcpu_init(&NDS_ARM7, header->ARM7exe); - armcpu_init(&NDS_ARM9, header->ARM9exe); - } - - nds.wifiCycle = 0; - memset(nds.timerCycle, 0, sizeof(u64) * 2 * 4); - nds.VCount = 0; - nds.old = 0; - nds.touchX = nds.touchY = 0; - nds.isTouch = 0; - nds.debugConsole = CommonSettings.DebugConsole; - SetupMMU(nds.debugConsole); - - _MMU_write16(0x04000130, 0x3FF); - _MMU_write16(0x04000130, 0x3FF); - _MMU_write08(0x04000136, 0x43); - - LidClosed = FALSE; - countLid = 0; - - /* - * Setup a copy of the firmware user settings in memory. - * (this is what the DS firmware would do). - */ - { - u8 temp_buffer[NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT]; - int fw_index; - - if ( copy_firmware_user_data( temp_buffer, MMU.fw.data)) { - for ( fw_index = 0; fw_index < NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT; fw_index++) - _MMU_write08(0x027FFC80 + fw_index, temp_buffer[fw_index]); - } - } - - // Copy the whole header to Main RAM 0x27FFE00 on startup. - // Reference: http://nocash.emubase.de/gbatek.htm#dscartridgeheader - //zero 27-jun-09 : why did this copy 0x90 more? gbatek says its not stored in ram. - //for (i = 0; i < ((0x170+0x90)/4); i++) { - for (int i = 0; i < ((0x170)/4); i++) { - _MMU_write32(0x027FFE00+i*4, LE_TO_LOCAL_32(((u32*)MMU.CART_ROM)[i])); - } - - // Write the header checksum to memory (the firmware needs it to see the cart) - _MMU_write16(0x027FF808, T1ReadWord(MMU.CART_ROM, 0x15E)); - - // Save touchscreen calibration info in a structure - // so we can easily access it at any time - TSCal.adc.x1 = _MMU_read16(0x027FFC80 + 0x58); - TSCal.adc.y1 = _MMU_read16(0x027FFC80 + 0x5A); - TSCal.scr.x1 = _MMU_read08(0x027FFC80 + 0x5C); - TSCal.scr.y1 = _MMU_read08(0x027FFC80 + 0x5D); - TSCal.adc.x2 = _MMU_read16(0x027FFC80 + 0x5E); - TSCal.adc.y2 = _MMU_read16(0x027FFC80 + 0x60); - TSCal.scr.x2 = _MMU_read08(0x027FFC80 + 0x62); - TSCal.scr.y2 = _MMU_read08(0x027FFC80 + 0x63); - - MainScreen.offset = 0; - SubScreen.offset = 192; - - //_MMU_write32[ARMCPU_ARM9](0x02007FFC, 0xE92D4030); - - delete header; - - Screen_Reset(); - gfx3d_reset(); - gpu3D->NDS_3D_Reset(); - SPU_Reset(); - -#ifdef EXPERIMENTAL_WIFI - WIFI_Reset(); -#endif - - memcpy(FW_Mac, (MMU.fw.data + 0x36), 6); - - initSchedule(); -} - -static std::string MakeInputDisplayString(u16 pad, const std::string* Buttons, int count) { - std::string s; - for (int x = 0; x < count; x++) { - if (pad & (1 << x)) - s.append(Buttons[x].size(), ' '); - else - s += Buttons[x]; - } - return s; -} - -static std::string MakeInputDisplayString(u16 pad, u16 padExt) { - const std::string Buttons[] = {"A", "B", "Sl", "St", "R", "L", "U", "D", "Rs", "Ls"}; - const std::string Ext[] = {"X", "Y"}; - - std::string s = MakeInputDisplayString(pad, Ext, ARRAY_SIZE(Ext)); - s += MakeInputDisplayString(padExt, Buttons, ARRAY_SIZE(Buttons)); - - return s; -} - -void ClearAutoHold(void) { - - for (int i=0; i < 12; i++) { - AutoHold.hold(i)=false; - } -} - -void NDS_setPadFromMovie(u16 pad) -{ -#define FIX(b,n) (((pad>>n)&1)!=0) - NDS_setPad( - FIX(pad,12), //R - FIX(pad,11), //L - FIX(pad,10), //D - FIX(pad,9), //U - FIX(pad,7), //Select - FIX(pad,8), //Start - FIX(pad,6), //B - FIX(pad,5), //A - FIX(pad,4), //Y - FIX(pad,3), //X - FIX(pad,2), - FIX(pad,1), - FIX(pad,0), - movie_lid - ); -#undef FIX - -} - -turbo Turbo; -turbotime TurboTime; - -static void SetTurbo(bool (&pad) [12]) { - - bool turbo[4] = {true, false, true, false}; - bool currentbutton; - - for (int i=0; i < 12; i++) { - currentbutton=Turbo.button(i); - - if(currentbutton && movieMode != MOVIEMODE_PLAY) { - pad[i]=turbo[TurboTime.time(i)-1]; - - if(TurboTime.time(i) >= (int)ARRAY_SIZE(turbo)) - TurboTime.time(i)=0; - } - else - TurboTime.time(i)=0; //reset timer if the button isn't pressed - } - for (int i=0; i<12; i++) - TurboTime.time(i)++; -} - -autohold AutoHold; - -void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,bool X,bool W,bool E,bool G, bool F) -{ - - bool padarray[12] = {R, L, D, U, T, S, B, A, Y, X, W, E}; - - SetTurbo(padarray); - - R=padarray[0]; - L=padarray[1]; - D=padarray[2]; - U=padarray[3]; - T=padarray[4]; - S=padarray[5]; - B=padarray[6]; - A=padarray[7]; - Y=padarray[8]; - X=padarray[9]; - W=padarray[10]; - E=padarray[11]; - - if (movieMode != MOVIEMODE_PLAY) { - if(AutoHold.Right) R=!padarray[0]; - if(AutoHold.Left) L=!padarray[1]; - if(AutoHold.Down) D=!padarray[2]; - if(AutoHold.Up) U=!padarray[3]; - if(AutoHold.Select)T=!padarray[4]; - if(AutoHold.Start) S=!padarray[5]; - if(AutoHold.B) B=!padarray[6]; - if(AutoHold.A) A=!padarray[7]; - if(AutoHold.Y) Y=!padarray[8]; - if(AutoHold.X) X=!padarray[9]; - if(AutoHold.L) W=!padarray[10]; - if(AutoHold.R) E=!padarray[11]; - } - - //this macro is the opposite of what you would expect -#define FIX(b) (b?0:0x80) - - int r = FIX(R); - int l = FIX(L); - int d = FIX(D); - int u = FIX(U); - int t = FIX(T); - int s = FIX(S); - int b = FIX(B); - int a = FIX(A); - int y = FIX(Y); - int x = FIX(X); - int w = FIX(W); - int e = FIX(E); - int g = FIX(G); - int f = FIX(F); - - u16 pad = (0 | - ((a) >> 7) | - ((b) >> 6) | - ((s) >> 5) | - ((t) >> 4) | - ((r) >> 3) | - ((l) >> 2) | - ((u) >> 1) | - ((d)) | - ((e) << 1) | - ((w) << 2)) ; - - ((u16 *)MMU.ARM9_REG)[0x130>>1] = (u16)pad; - ((u16 *)MMU.ARM7_REG)[0x130>>1] = (u16)pad; - - if (!f && !countLid) - { - LidClosed = (!LidClosed) & 0x01; - if (!LidClosed) - { - // SPU_Pause(FALSE); - NDS_makeARM7Int(22); - - } - //else - //SPU_Pause(TRUE); - - countLid = 30; - } - else - { - if (countLid > 0) - countLid--; - } - - u16 padExt = (((u16 *)MMU.ARM7_REG)[0x136>>1] & 0x0070) | - ((x) >> 7) | - ((y) >> 6) | - ((g) >> 4) | - ((LidClosed) << 7) | - 0x0034; - - ((u16 *)MMU.ARM7_REG)[0x136>>1] = (u16)padExt; - - InputDisplayString=MakeInputDisplayString(padExt, pad); - - //put into the format we want for the movie system - //RLDUTSBAYXWEGF -#undef FIX -#define FIX(b) (b?1:0) - - r = FIX(R); - l = FIX(L); - d = FIX(D); - u = FIX(U); - t = FIX(T); - s = FIX(S); - b = FIX(B); - a = FIX(A); - y = FIX(Y); - x = FIX(X); - w = FIX(W); - e = FIX(E); - g = FIX(G); - f = FIX(F); - - if(f) movie_lid=true; - else movie_lid=false; - - nds.pad = - (FIX(r)<<12)| - (FIX(l)<<11)| - (FIX(d)<<10)| - (FIX(u)<<9)| - (FIX(s)<<8)| - (FIX(t)<<7)| - (FIX(b)<<6)| - (FIX(a)<<5)| - (FIX(y)<<4)| - (FIX(x)<<3)| - (FIX(w)<<2)| - (FIX(e)<<1); - - // TODO: low power IRQ -} - - -void emu_halt() { - //printf("halting emu: ARM9 PC=%08X/%08X, ARM7 PC=%08X/%08X\n", NDS_ARM9.R[15], NDS_ARM9.instruct_adr, NDS_ARM7.R[15], NDS_ARM7.instruct_adr); - execute = false; -} - -//these templates needed to be instantiated manually -template void NDS_exec(s32 nb); -template void NDS_exec(s32 nb); + +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include +#include +#include +#include + +#include "common.h" +#include "NDSSystem.h" +#include "render3D.h" +#include "MMU.h" +#include "ROMReader.h" +#include "gfx3d.h" +#include "utils/decrypt/decrypt.h" +#include "utils/decrypt/crc.h" +#include "bios.h" +#include "debug.h" +#include "cheatSystem.h" +#include "movie.h" +#include "Disassembler.h" + +#include "path.h" + +PathInfo path; + +TCommonSettings CommonSettings; +static BaseDriver _stub_driver; +BaseDriver* driver = &_stub_driver; +std::string InputDisplayString; + +static BOOL LidClosed = FALSE; +static u8 countLid = 0; + + +GameInfo gameInfo; + +/* the count of bytes copied from the firmware into memory */ +#define NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT 0x70 + +BOOL fw_success = FALSE; + +NDSSystem nds; + +int lagframecounter; +int LagFrameFlag; +int lastLag; +int TotalLagFrames; + +/* ------------------------------------------------------------------------- */ +/* FIRMWARE DECRYPTION */ + +static u32 keyBuf[0x412]; +static u32 keyCode[3]; + +#define DWNUM(i) ((i) >> 2) + +static u32 bswap32(u32 val) +{ + return (((val & 0x000000FF) << 24) | ((val & 0x0000FF00) << 8) | ((val & 0x00FF0000) >> 8) | ((val & 0xFF000000) >> 24)); +} + +static BOOL getKeyBuf() +{ + int dummy; + FILE *file = fopen(CommonSettings.ARM7BIOS, "rb"); + + if(file == NULL) + return FALSE; + + fseek(file, 0x30, SEEK_SET); + dummy = fread(keyBuf, 0x412, 4, file); + + fclose(file); + return TRUE; +} + +static void crypt64BitUp(u32 *ptr) +{ + u32 Y = ptr[0]; + u32 X = ptr[1]; + + for(u32 i = 0x00; i <= 0x0F; i++) + { + u32 Z = (keyBuf[i] ^ X); + X = keyBuf[DWNUM(0x048 + (((Z >> 24) & 0xFF) << 2))]; + X = (keyBuf[DWNUM(0x448 + (((Z >> 16) & 0xFF) << 2))] + X); + X = (keyBuf[DWNUM(0x848 + (((Z >> 8) & 0xFF) << 2))] ^ X); + X = (keyBuf[DWNUM(0xC48 + ((Z & 0xFF) << 2))] + X); + X = (Y ^ X); + Y = Z; + } + + ptr[0] = (X ^ keyBuf[DWNUM(0x40)]); + ptr[1] = (Y ^ keyBuf[DWNUM(0x44)]); +} + +static void crypt64BitDown(u32 *ptr) +{ + u32 Y = ptr[0]; + u32 X = ptr[1]; + + for(u32 i = 0x11; i >= 0x02; i--) + { + u32 Z = (keyBuf[i] ^ X); + X = keyBuf[DWNUM(0x048 + (((Z >> 24) & 0xFF) << 2))]; + X = (keyBuf[DWNUM(0x448 + (((Z >> 16) & 0xFF) << 2))] + X); + X = (keyBuf[DWNUM(0x848 + (((Z >> 8) & 0xFF) << 2))] ^ X); + X = (keyBuf[DWNUM(0xC48 + ((Z & 0xFF) << 2))] + X); + X = (Y ^ X); + Y = Z; + } + + ptr[0] = (X ^ keyBuf[DWNUM(0x04)]); + ptr[1] = (Y ^ keyBuf[DWNUM(0x00)]); +} + +static void applyKeycode(u32 modulo) +{ + crypt64BitUp(&keyCode[1]); + crypt64BitUp(&keyCode[0]); + + u32 scratch[2] = {0x00000000, 0x00000000}; + + for(u32 i = 0; i <= 0x44; i += 4) + { + keyBuf[DWNUM(i)] = (keyBuf[DWNUM(i)] ^ bswap32(keyCode[DWNUM(i % modulo)])); + } + + for(u32 i = 0; i <= 0x1040; i += 8) + { + crypt64BitUp(scratch); + keyBuf[DWNUM(i)] = scratch[1]; + keyBuf[DWNUM(i+4)] = scratch[0]; + } +} + +static BOOL initKeycode(u32 idCode, int level, u32 modulo) +{ + if(getKeyBuf() == FALSE) + return FALSE; + + keyCode[0] = idCode; + keyCode[1] = (idCode >> 1); + keyCode[2] = (idCode << 1); + + if(level >= 1) applyKeycode(modulo); + if(level >= 2) applyKeycode(modulo); + + keyCode[1] <<= 1; + keyCode[2] >>= 1; + + if(level >= 3) applyKeycode(modulo); + + return TRUE; +} + +static u16 getBootCodeCRC16() +{ + unsigned int i, j; + u32 crc = 0xFFFF; + const u16 val[8] = {0xC0C1, 0xC181, 0xC301, 0xC601, 0xCC01, 0xD801, 0xF001, 0xA001}; + + for(i = 0; i < nds.FW_ARM9BootCodeSize; i++) + { + crc = (crc ^ nds.FW_ARM9BootCode[i]); + + for(j = 0; j < 8; j++) + { + if(crc & 0x0001) + crc = ((crc >> 1) ^ (val[j] << (7-j))); + else + crc = (crc >> 1); + } + } + + for(i = 0; i < nds.FW_ARM7BootCodeSize; i++) + { + crc = (crc ^ nds.FW_ARM7BootCode[i]); + + for(j = 0; j < 8; j++) + { + if(crc & 0x0001) + crc = ((crc >> 1) ^ (val[j] << (7-j))); + else + crc = (crc >> 1); + } + } + + return (crc & 0xFFFF); +} + +static u32 * decryptFirmwareBlock(const char *blockName, u32 *src, u32 &size) +{ + u32 curBlock[2]; + u32 *dst; + u32 i, j; + u32 xIn = 4, xOut = 0; + u32 len; + u32 offset; + u32 windowOffset; + u32 xLen; + u8 d; + u16 data; + + memcpy(curBlock, src, 8); + crypt64BitDown(curBlock); + + u32 blockSize = (curBlock[0] >> 8); + size = blockSize; + + INFO("Firmware: %s final size: %i bytes\n", blockName, blockSize); + + dst = (u32*)new u8[blockSize]; + + xLen = blockSize; + + while(xLen > 0) + { + d = T1ReadByte((u8*)curBlock, (xIn % 8)); + xIn++; + if((xIn % 8) == 0) + { + memcpy(curBlock, (((u8*)src) + xIn), 8); + crypt64BitDown(curBlock); + } + + for(i = 0; i < 8; i++) + { + if(d & 0x80) + { + data = (T1ReadByte((u8*)curBlock, (xIn % 8)) << 8); + xIn++; + if((xIn % 8) == 0) + { + memcpy(curBlock, (((u8*)src) + xIn), 8); + crypt64BitDown(curBlock); + } + data |= T1ReadByte((u8*)curBlock, (xIn % 8)); + xIn++; + if((xIn % 8) == 0) + { + memcpy(curBlock, (((u8*)src) + xIn), 8); + crypt64BitDown(curBlock); + } + + len = (data >> 12) + 3; + offset = (data & 0xFFF); + windowOffset = (xOut - offset - 1); + + for(j = 0; j < len; j++) + { + T1WriteByte((u8*)dst, xOut, T1ReadByte((u8*)dst, windowOffset)); + xOut++; + windowOffset++; + + xLen--; + if(xLen == 0) + goto lz77End; + } + } + else + { + T1WriteByte((u8*)dst, xOut, T1ReadByte((u8*)curBlock, (xIn % 8))); + xOut++; + xIn++; + if((xIn % 8) == 0) + { + memcpy(curBlock, (((u8*)src) + xIn), 8); + crypt64BitDown(curBlock); + } + + xLen--; + if(xLen == 0) + goto lz77End; + } + + d = ((d << 1) & 0xFF); + } + } + +lz77End: + + return dst; +} + +static BOOL decryptFirmware(u8 *data) +{ + u16 shifts; + u16 shift1, shift2, shift3, shift4; + u32 part1addr, part2addr, part3addr, part4addr, part5addr; + u32 part1ram, part2ram; + + shifts = T1ReadWord(data, 0x14); + shift1 = (shifts & 0x7); + shift2 = ((shifts >> 3) & 0x7); + shift3 = ((shifts >> 6) & 0x7); + shift4 = ((shifts >> 9) & 0x7); + + part1addr = T1ReadWord(data, 0x0C); + part1addr = (part1addr << (2+shift1)); + + INFO("Firmware: ARM9 boot code address: %05X\n", part1addr); + + part1ram = T1ReadWord(data, 0x0E); + part1ram = (0x02800000 - (part1ram << (2+shift2))); + + INFO("Firmware: ARM9 boot code RAM address: %08X\n", part1ram); + + part2addr = T1ReadWord(data, 0x10); + part2addr = (part2addr << (2+shift3)); + + INFO("Firmware: ARM7 boot code address: %05X\n", part2addr); + + part2ram = T1ReadWord(data, 0x12); + part2ram = (0x03810000 - (part2ram << (2+shift4))); + + INFO("Firmware: ARM7 boot code RAM address: %08X\n", part2ram); + + part3addr = T1ReadWord(data, 0x00); + part3addr = (part3addr << 3); + + INFO("Firmware: ARM9 GUI code address: %05X\n", part3addr); + + part4addr = T1ReadWord(data, 0x02); + part4addr = (part4addr << 3); + + INFO("Firmware: ARM7 GUI code address: %05X\n", part4addr); + + part5addr = T1ReadWord(data, 0x16); + part5addr = (part5addr << 3); + + INFO("Firmware: data/gfx address: %05X\n", part5addr); + + if(initKeycode(T1ReadLong(data, 0x08), 1, 0xC) == FALSE) return FALSE; + crypt64BitDown((u32*)&data[0x18]); + if(initKeycode(T1ReadLong(data, 0x08), 2, 0xC) == FALSE) return FALSE; + + nds.FW_ARM9BootCode = (u8*)decryptFirmwareBlock("ARM9 boot code", (u32*)&data[part1addr], nds.FW_ARM9BootCodeSize); + nds.FW_ARM7BootCode = (u8*)decryptFirmwareBlock("ARM7 boot code", (u32*)&data[part2addr], nds.FW_ARM7BootCodeSize); + + nds.FW_ARM9BootCodeAddr = part1ram; + nds.FW_ARM7BootCodeAddr = part2ram; + + u16 crc16_header = T1ReadWord(data, 0x06); + u16 crc16_mine = getBootCodeCRC16(); + if(crc16_header != crc16_mine) + { + INFO("Firmware: error: the boot code CRC16 (%04X) doesn't match the value in the firmware header (%04X).\n", + crc16_mine, crc16_header); + return FALSE; + } + + return TRUE; +} + +/* ------------------------------------------------------------------------- */ + +static u32 +calc_CRC16( u32 start, const u8 *data, int count) { + int i,j; + u32 crc = start & 0xffff; + const u16 val[8] = { 0xC0C1,0xC181,0xC301,0xC601,0xCC01,0xD801,0xF001,0xA001 }; + for(i = 0; i < count; i++) + { + crc = crc ^ data[i]; + + for(j = 0; j < 8; j++) { + int do_bit = 0; + + if ( crc & 0x1) + do_bit = 1; + + crc = crc >> 1; + + if ( do_bit) { + crc = crc ^ (val[j] << (7-j)); + } + } + } + return crc; +} + +static int +copy_firmware_user_data( u8 *dest_buffer, const u8 *fw_data) { + /* + * Determine which of the two user settings in the firmware is the current + * and valid one and then copy this into the destination buffer. + * + * The current setting will have a greater count. + * Settings are only valid if its CRC16 is correct. + */ + int user1_valid = 0; + int user2_valid = 0; + u32 user_settings_offset; + u32 fw_crc; + u32 crc; + int copy_good = 0; + + user_settings_offset = fw_data[0x20]; + user_settings_offset |= fw_data[0x21] << 8; + user_settings_offset <<= 3; + + if ( user_settings_offset <= 0x3FE00) { + s32 copy_settings_offset = -1; + + crc = calc_CRC16( 0xffff, &fw_data[user_settings_offset], + NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT); + fw_crc = fw_data[user_settings_offset + 0x72]; + fw_crc |= fw_data[user_settings_offset + 0x73] << 8; + if ( crc == fw_crc) { + user1_valid = 1; + } + + crc = calc_CRC16( 0xffff, &fw_data[user_settings_offset + 0x100], + NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT); + fw_crc = fw_data[user_settings_offset + 0x100 + 0x72]; + fw_crc |= fw_data[user_settings_offset + 0x100 + 0x73] << 8; + if ( crc == fw_crc) { + user2_valid = 1; + } + + if ( user1_valid) { + if ( user2_valid) { + u16 count1, count2; + + count1 = fw_data[user_settings_offset + 0x70]; + count1 |= fw_data[user_settings_offset + 0x71] << 8; + + count2 = fw_data[user_settings_offset + 0x100 + 0x70]; + count2 |= fw_data[user_settings_offset + 0x100 + 0x71] << 8; + + if ( count2 > count1) { + copy_settings_offset = user_settings_offset + 0x100; + } + else { + copy_settings_offset = user_settings_offset; + } + } + else { + copy_settings_offset = user_settings_offset; + } + } + else if ( user2_valid) { + /* copy the second user settings */ + copy_settings_offset = user_settings_offset + 0x100; + } + + if ( copy_settings_offset > 0) { + memcpy( dest_buffer, &fw_data[copy_settings_offset], + NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT); + copy_good = 1; + } + } + + return copy_good; +} + +void Desmume_InitOnce() +{ + static bool initOnce = false; + if(initOnce) return; + initOnce = true; + + extern void Agg_init(); //no need to include just for this + Agg_init(); +} + +#ifdef GDB_STUB +int NDS_Init( struct armcpu_memory_iface *arm9_mem_if, +struct armcpu_ctrl_iface **arm9_ctrl_iface, +struct armcpu_memory_iface *arm7_mem_if, +struct armcpu_ctrl_iface **arm7_ctrl_iface) { +#else +int NDS_Init( void) { +#endif + nds.ARM9Cycle = 0; + nds.ARM7Cycle = 0; + nds.cycles = 0; + nds.idleFrameCounter = 0; + memset(nds.runCycleCollector,0,sizeof(nds.runCycleCollector)); + MMU_Init(); + nds.nextHBlank = 3168; + nds.VCount = 0; + nds.lignerendu = FALSE; + + nds.sleeping = FALSE; + + if (Screen_Init(GFXCORE_DUMMY) != 0) + return -1; + + gfx3d_init(); + +#ifdef GDB_STUB + armcpu_new(&NDS_ARM7,1, arm7_mem_if, arm7_ctrl_iface); + armcpu_new(&NDS_ARM9,0, arm9_mem_if, arm9_ctrl_iface); +#else + armcpu_new(&NDS_ARM7,1); + armcpu_new(&NDS_ARM9,0); +#endif + + if (SPU_Init(SNDCORE_DUMMY, 740) != 0) + return -1; + +#ifdef EXPERIMENTAL_WIFI + WIFI_Init(&wifiMac) ; + WIFI_SoftAP_Init(&wifiMac); +#endif + + nds.FW_ARM9BootCode = NULL; + nds.FW_ARM7BootCode = NULL; + + return 0; +} + +void NDS_DeInit(void) { + if(MMU.CART_ROM != MMU.UNUSED_RAM) + NDS_FreeROM(); + + nds.nextHBlank = 3168; + SPU_DeInit(); + Screen_DeInit(); + MMU_DeInit(); + gpu3D->NDS_3D_Close(); + +#ifdef EXPERIMENTAL_WIFI + WIFI_SoftAP_Shutdown(&wifiMac); +#endif + cheatsSearchClose(); +} + +BOOL NDS_SetROM(u8 * rom, u32 mask) +{ + MMU_setRom(rom, mask); + + return TRUE; +} + +NDS_header * NDS_getROMHeader(void) +{ + NDS_header * header = new NDS_header; + + memcpy(header->gameTile, MMU.CART_ROM, 12); + memcpy(header->gameCode, MMU.CART_ROM + 12, 4); + header->makerCode = T1ReadWord(MMU.CART_ROM, 16); + header->unitCode = MMU.CART_ROM[18]; + header->deviceCode = MMU.CART_ROM[19]; + header->cardSize = MMU.CART_ROM[20]; + memcpy(header->cardInfo, MMU.CART_ROM + 21, 8); + header->flags = MMU.CART_ROM[29]; + header->ARM9src = T1ReadLong(MMU.CART_ROM, 32); + header->ARM9exe = T1ReadLong(MMU.CART_ROM, 36); + header->ARM9cpy = T1ReadLong(MMU.CART_ROM, 40); + header->ARM9binSize = T1ReadLong(MMU.CART_ROM, 44); + header->ARM7src = T1ReadLong(MMU.CART_ROM, 48); + header->ARM7exe = T1ReadLong(MMU.CART_ROM, 52); + header->ARM7cpy = T1ReadLong(MMU.CART_ROM, 56); + header->ARM7binSize = T1ReadLong(MMU.CART_ROM, 60); + header->FNameTblOff = T1ReadLong(MMU.CART_ROM, 64); + header->FNameTblSize = T1ReadLong(MMU.CART_ROM, 68); + header->FATOff = T1ReadLong(MMU.CART_ROM, 72); + header->FATSize = T1ReadLong(MMU.CART_ROM, 76); + header->ARM9OverlayOff = T1ReadLong(MMU.CART_ROM, 80); + header->ARM9OverlaySize = T1ReadLong(MMU.CART_ROM, 84); + header->ARM7OverlayOff = T1ReadLong(MMU.CART_ROM, 88); + header->ARM7OverlaySize = T1ReadLong(MMU.CART_ROM, 92); + header->unknown2a = T1ReadLong(MMU.CART_ROM, 96); + header->unknown2b = T1ReadLong(MMU.CART_ROM, 100); + header->IconOff = T1ReadLong(MMU.CART_ROM, 104); + header->CRC16 = T1ReadWord(MMU.CART_ROM, 108); + header->ROMtimeout = T1ReadWord(MMU.CART_ROM, 110); + header->ARM9unk = T1ReadLong(MMU.CART_ROM, 112); + header->ARM7unk = T1ReadLong(MMU.CART_ROM, 116); + memcpy(header->unknown3c, MMU.CART_ROM + 120, 8); + header->ROMSize = T1ReadLong(MMU.CART_ROM, 128); + header->HeaderSize = T1ReadLong(MMU.CART_ROM, 132); + memcpy(header->unknown5, MMU.CART_ROM + 136, 56); + memcpy(header->logo, MMU.CART_ROM + 192, 156); + header->logoCRC16 = T1ReadWord(MMU.CART_ROM, 348); + header->headerCRC16 = T1ReadWord(MMU.CART_ROM, 350); + memcpy(header->reserved, MMU.CART_ROM + 352, 160); + + return header; +} + +void NDS_setTouchPos(u16 x, u16 y) +{ + nds.touchX = (x <<4); + nds.touchY = (y <<4); + nds.isTouch = 1; + + MMU.ARM7_REG[0x136] &= 0xBF; +} + +void NDS_releaseTouch(void) +{ + nds.touchX = 0; + nds.touchY = 0; + nds.isTouch = 0; + + MMU.ARM7_REG[0x136] |= 0x40; +} + +void debug() +{ + //if(NDS_ARM9.R[15]==0x020520DC) emu_halt(); + //DSLinux + //if(NDS_ARM9.CPSR.bits.mode == 0) emu_halt(); + //if((NDS_ARM9.R[15]&0xFFFFF000)==0) emu_halt(); + //if((NDS_ARM9.R[15]==0x0201B4F4)/*&&(NDS_ARM9.R[1]==0x0)*/) emu_halt(); + //AOE + //if((NDS_ARM9.R[15]==0x01FFE194)&&(NDS_ARM9.R[0]==0)) emu_halt(); + //if((NDS_ARM9.R[15]==0x01FFE134)&&(NDS_ARM9.R[0]==0)) emu_halt(); + + //BBMAN + //if(NDS_ARM9.R[15]==0x02098B4C) emu_halt(); + //if(NDS_ARM9.R[15]==0x02004924) emu_halt(); + //if(NDS_ARM9.R[15]==0x02004890) emu_halt(); + + //if(NDS_ARM9.R[15]==0x0202B800) emu_halt(); + //if(NDS_ARM9.R[15]==0x0202B3DC) emu_halt(); + //if((NDS_ARM9.R[1]==0x9AC29AC1)&&(!fait)) {emu_halt();fait = TRUE;} + //if(NDS_ARM9.R[1]==0x0400004A) {emu_halt();fait = TRUE;} + /*if(NDS_ARM9.R[4]==0x2E33373C) emu_halt(); + if(NDS_ARM9.R[15]==0x02036668) //emu_halt(); + { + nds.logcount++; + sprintf(logbuf, "%d %08X", nds.logcount, NDS_ARM9.R[13]); + log::ajouter(logbuf); + if(nds.logcount==89) execute=FALSE; + }*/ + //if(NDS_ARM9.instruction==0) emu_halt(); + //if((NDS_ARM9.R[15]>>28)) emu_halt(); +} + +#define DSGBA_LOADER_SIZE 512 +enum +{ + ROM_NDS = 0, + ROM_DSGBA +}; + +#if 0 /* not used */ +//http://www.aggregate.org/MAGIC/#Population%20Count%20(Ones%20Count) +static u32 ones32(u32 x) +{ + /* 32-bit recursive reduction using SWAR... + but first step is mapping 2-bit values + into sum of 2 1-bit values in sneaky way + */ + x -= ((x >> 1) & 0x55555555); + x = (((x >> 2) & 0x33333333) + (x & 0x33333333)); + x = (((x >> 4) + x) & 0x0f0f0f0f); + x += (x >> 8); + x += (x >> 16); + return(x & 0x0000003f); +} +#endif + +void GameInfo::populate() +{ + NDS_header * _header = NDS_getROMHeader(); + header = *_header; + delete _header; + + if ( + // ??? in all Homebrews game title have is 2E0000EA + //( + //(header->gameTile[0] == 0x2E) && + //(header->gameTile[1] == 0x00) && + //(header->gameTile[2] == 0x00) && + //(header->gameTile[3] == 0xEA) + //) && + ( + ((header.gameCode[0] == 0x23) && + (header.gameCode[1] == 0x23) && + (header.gameCode[2] == 0x23) && + (header.gameCode[3] == 0x23) + ) || + (header.gameCode[0] == 0x00) + ) + && + header.makerCode == 0x0 + ) + { + memset(ROMserial, 0, sizeof(ROMserial)); + strcpy(ROMserial, "Homebrew"); + } + else + { + memset(ROMserial, '_', sizeof(ROMserial)); + memcpy(ROMserial, header.gameTile, strlen(header.gameTile) < 12 ? strlen(header.gameTile) : 12); + memcpy(ROMserial+12+1, header.gameCode, 4); + memcpy(ROMserial+12+1+4, &header.makerCode, 2); + memset(ROMserial+19, '\0', 1); + } +} +#ifdef WIN32 +#include "memorystream.h" +#include + +static std::vector buffer; +static std::vector v; + +static void loadrom(std::vector* buf, std::string fname) { + + FILE* inf = fopen(fname.c_str(),"rb"); + if(!inf) return; + + fseek(inf,0,SEEK_END); + int size = ftell(inf); + fseek(inf,0,SEEK_SET); + + gameInfo.resize(size); + fread(gameInfo.romdata,1,size,inf); + + fclose(inf); +} + +int NDS_LoadROM(const char *filename, const char *logicalFilename) +{ + int type; + u32 mask; + char buf[MAX_PATH]; + + if (filename == NULL) + return -1; + + path.init(filename); + + if ( path.isdsgba(path.path)) { + type = ROM_DSGBA; + loadrom(&buffer, path.path); + gameInfo.romsize = buffer.size(); + } + else if ( !strcasecmp(path.extension().c_str(), "nds")) { + loadrom(NULL, path.path); //n.b. this does nothing if the file can't be found (i.e. if it was an extracted tempfile)... + //...but since the data was extracted to gameInfo then it is ok + type = ROM_NDS; + } + //ds.gba in archives, it's already been loaded into memory at this point + else if (path.isdsgba(std::string(logicalFilename))) { + + std::vector v(gameInfo.romdata, gameInfo.romdata + gameInfo.romsize); + v.erase(v.begin(),v.begin()+DSGBA_LOADER_SIZE); + buffer.assign( v.begin(), v.end() ); + gameInfo.romdata = &buffer[0]; + gameInfo.romsize = buffer.size(); + } + + if(type == ROM_DSGBA) + { + buffer.erase(buffer.begin(),buffer.begin()+DSGBA_LOADER_SIZE); + gameInfo.romdata = &buffer[0]; + gameInfo.romsize = buffer.size(); + } + + //check that size is at least the size of the header + if (gameInfo.romsize < 352+160) { + return -1; + } + + //zero 25-dec-08 - this used to yield a mask which was 2x large + //mask = size; + mask = gameInfo.romsize-1; + mask |= (mask >>1); + mask |= (mask >>2); + mask |= (mask >>4); + mask |= (mask >>8); + mask |= (mask >>16); + + //decrypt if necessary.. + //but this is untested and suspected to fail on big endian, so lets not support this on big endian + +#ifndef WORDS_BIGENDIAN + bool okRom = DecryptSecureArea((u8*)gameInfo.romdata,gameInfo.romsize); + + if(!okRom) { + printf("Specified file is not a valid rom\n"); + return -1; + } +#endif + + cheatsSearchClose(); + MMU_unsetRom(); + NDS_SetROM((u8*)gameInfo.romdata, mask); + NDS_Reset(); + + memset(buf, 0, MAX_PATH); + + path.getpathnoext(path.BATTERY, buf); + + strcat(buf, ".dsv"); // DeSmuME memory card :) + + MMU_new.backupDevice.load_rom(buf); + + memset(buf, 0, MAX_PATH); + + path.getpathnoext(path.CHEATS, buf); + + strcat(buf, ".dct"); // DeSmuME cheat :) + cheatsInit(buf); + + gameInfo.populate(); + gameInfo.crc = crc32(0,(u8*)gameInfo.romdata,gameInfo.romsize); + INFO("\nROM crc: %08X\n\n", gameInfo.crc); + INFO("\nROM serial: %s\n", gameInfo.ROMserial); + + return 1; +} +#else +int NDS_LoadROM(const char *filename, const char *logicalFilename) +{ + int ret; + int type; + ROMReader_struct *reader; + void *file; + u32 size, mask; + u8 *data; + char *noext; + char buf[MAX_PATH]; + + if (filename == NULL) + return -1; + + noext = strdup(filename); + reader = ROMReaderInit(&noext); + + if(logicalFilename) path.init(logicalFilename); + else path.init(filename); + if(!strcasecmp(path.extension().c_str(), "zip")) type = ROM_NDS; + else if ( !strcasecmp(path.extension().c_str(), "nds")) + type = ROM_NDS; + else if ( path.isdsgba()) + type = ROM_DSGBA; + else + type = ROM_NDS; + + file = reader->Init(filename); + if (!file) + { + reader->DeInit(file); + free(noext); + return -1; + } + + size = reader->Size(file); + + if(type == ROM_DSGBA) + { + reader->Seek(file, DSGBA_LOADER_SIZE, SEEK_SET); + size -= DSGBA_LOADER_SIZE; + } + + //check that size is at least the size of the header + if (size < 352+160) { + reader->DeInit(file); + free(noext); + return -1; + } + + //zero 25-dec-08 - this used to yield a mask which was 2x large + //mask = size; + mask = size-1; + mask |= (mask >>1); + mask |= (mask >>2); + mask |= (mask >>4); + mask |= (mask >>8); + mask |= (mask >>16); + + // Make sure old ROM is freed first(at least this way we won't be eating + // up a ton of ram before the old ROM is freed) + if(MMU.CART_ROM != MMU.UNUSED_RAM) + NDS_FreeROM(); + + data = new u8[mask + 1]; + if (!data) + { + reader->DeInit(file); + free(noext); + return -1; + } + + ret = reader->Read(file, data, size); + reader->DeInit(file); + + //decrypt if necessary.. + //but this is untested and suspected to fail on big endian, so lets not support this on big endian +#ifndef WORDS_BIGENDIAN + bool okRom = DecryptSecureArea(data,size); + + if(!okRom) { + printf("Specified file is not a valid rom\n"); + return -1; + } +#endif + + + cheatsSearchClose(); + MMU_unsetRom(); + NDS_SetROM(data, mask); + NDS_Reset(); + + free(noext); + + memset(buf, 0, MAX_PATH); + + path.getpathnoext(path.BATTERY, buf); + + strcat(buf, ".dsv"); // DeSmuME memory card :) + + MMU_new.backupDevice.load_rom(buf); + + memset(buf, 0, MAX_PATH); + + path.getpathnoext(path.CHEATS, buf); + + strcat(buf, ".dct"); // DeSmuME cheat :) + cheatsInit(buf); + + gameInfo.populate(); + gameInfo.crc = crc32(0,data,size); + INFO("\nROM crc: %08X\n\n", gameInfo.crc); + INFO("\nROM serial: %s\n", gameInfo.ROMserial); + + return ret; +} +#endif +void NDS_FreeROM(void) +{ + if (MMU.CART_ROM != MMU.UNUSED_RAM) + delete [] MMU.CART_ROM; + MMU_unsetRom(); +} + +bool _HACK_DONT_STOPMOVIE = false; +void NDS_Reset() +{ + unsigned int i; + u32 src; + u32 dst; + FILE* inf = 0; + NDS_header * header = NDS_getROMHeader(); + + if (!header) return ; + + if(movieMode != MOVIEMODE_INACTIVE && !_HACK_DONT_STOPMOVIE) + movie_reset_command = true; + + if(movieMode == MOVIEMODE_INACTIVE) { + currFrameCounter = 0; + lagframecounter = 0; + LagFrameFlag = 0; + lastLag = 0; + TotalLagFrames = 0; + } + + MMU_clearMem(); + MMU_new.backupDevice.reset(); + + //ARM7 BIOS IRQ HANDLER + if(CommonSettings.UseExtBIOS == true) + inf = fopen(CommonSettings.ARM7BIOS,"rb"); + else + inf = NULL; + + if(inf) { + fread(MMU.ARM7_BIOS,1,16384,inf); + fclose(inf); + if(CommonSettings.SWIFromBIOS == true) NDS_ARM7.swi_tab = 0; + else NDS_ARM7.swi_tab = ARM7_swi_tab; + INFO("ARM7 BIOS is loaded.\n"); + } else { + NDS_ARM7.swi_tab = ARM7_swi_tab; + _MMU_write32(0x00, 0xE25EF002); + _MMU_write32(0x04, 0xEAFFFFFE); + _MMU_write32(0x18, 0xEA000000); + _MMU_write32(0x20, 0xE92D500F); + _MMU_write32(0x24, 0xE3A00301); + _MMU_write32(0x28, 0xE28FE000); + _MMU_write32(0x2C, 0xE510F004); + _MMU_write32(0x30, 0xE8BD500F); + _MMU_write32(0x34, 0xE25EF004); + } + + //ARM9 BIOS IRQ HANDLER + if(CommonSettings.UseExtBIOS == true) + inf = fopen(CommonSettings.ARM9BIOS,"rb"); + else + inf = NULL; + //memcpy(ARM9Mem.ARM9_BIOS + 0x20, gba_header_data_0x04, 156); + + if(inf) { + fread(ARM9Mem.ARM9_BIOS,1,4096,inf); + fclose(inf); + if(CommonSettings.SWIFromBIOS == true) NDS_ARM9.swi_tab = 0; + else NDS_ARM9.swi_tab = ARM9_swi_tab; + INFO("ARM9 BIOS is loaded.\n"); + } else { + NDS_ARM9.swi_tab = ARM9_swi_tab; + _MMU_write32(0xFFFF0018, 0xEA000000); + _MMU_write32(0xFFFF0020, 0xE92D500F); + _MMU_write32(0xFFFF0024, 0xEE190F11); + _MMU_write32(0xFFFF0028, 0xE1A00620); + _MMU_write32(0xFFFF002C, 0xE1A00600); + _MMU_write32(0xFFFF0030, 0xE2800C40); + _MMU_write32(0xFFFF0034, 0xE28FE000); + _MMU_write32(0xFFFF0038, 0xE510F004); + _MMU_write32(0xFFFF003C, 0xE8BD500F); + _MMU_write32(0xFFFF0040, 0xE25EF004); + } + + /* Is it really needed ??? */ + _MMU_write32(0x0000004, 0xE3A0010E); + _MMU_write32(0x0000008, 0xE3A01020); + // _MMU_write32(0x000000C, 0xE1B02110); + _MMU_write32(0x000000C, 0xE1B02040); + _MMU_write32(0x0000010, 0xE3B02020); + // _MMU_write32(0x0000010, 0xE2100202); + + if(CommonSettings.UseExtFirmware == true) + NDS_LoadFirmware(CommonSettings.Firmware); + + if((CommonSettings.UseExtBIOS == true) && (CommonSettings.UseExtFirmware == true) && (CommonSettings.BootFromFirmware == true) && (fw_success == TRUE)) + { + for(i = 0; i < nds.FW_ARM9BootCodeSize; i += 4) + { + _MMU_write32((nds.FW_ARM9BootCodeAddr + i), T1ReadLong(nds.FW_ARM9BootCode, i)); + } + + for(i = 0; i < nds.FW_ARM7BootCodeSize; i += 4) + { + _MMU_write32((nds.FW_ARM7BootCodeAddr + i), T1ReadLong(nds.FW_ARM7BootCode, i)); + } + + armcpu_init(&NDS_ARM9, nds.FW_ARM9BootCodeAddr); + armcpu_init(&NDS_ARM7, nds.FW_ARM7BootCodeAddr); + //armcpu_init(&NDS_ARM9, 0xFFFF0000); + //armcpu_init(&NDS_ARM7, 0x00000000); + } + else + { + src = header->ARM9src; + dst = header->ARM9cpy; + + for(i = 0; i < (header->ARM9binSize>>2); ++i) + { + _MMU_write32(dst, T1ReadLong(MMU.CART_ROM, src)); + dst += 4; + src += 4; + } + + src = header->ARM7src; + dst = header->ARM7cpy; + + for(i = 0; i < (header->ARM7binSize>>2); ++i) + { + _MMU_write32(dst, T1ReadLong(MMU.CART_ROM, src)); + dst += 4; + src += 4; + } + + armcpu_init(&NDS_ARM7, header->ARM7exe); + armcpu_init(&NDS_ARM9, header->ARM9exe); + } + + nds.ARM9Cycle = 0; + nds.ARM7Cycle = 0; + nds.wifiCycle = 0; + nds.cycles = 0; + memset(nds.timerCycle, 0, sizeof(s32) * 2 * 4); + memset(nds.timerOver, 0, sizeof(BOOL) * 2 * 4); + nds.nextHBlank = 3168; + nds.VCount = 0; + nds.old = 0; + nds.diff = 0; + nds.lignerendu = FALSE; + nds.touchX = nds.touchY = 0; + nds.isTouch = 0; + nds.debugConsole = CommonSettings.DebugConsole; + SetupMMU(nds.debugConsole); + + _MMU_write16(0x04000130, 0x3FF); + _MMU_write16(0x04000130, 0x3FF); + _MMU_write08(0x04000136, 0x43); + + LidClosed = FALSE; + countLid = 0; + + /* + * Setup a copy of the firmware user settings in memory. + * (this is what the DS firmware would do). + */ + { + u8 temp_buffer[NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT]; + int fw_index; + + if ( copy_firmware_user_data( temp_buffer, MMU.fw.data)) { + for ( fw_index = 0; fw_index < NDS_FW_USER_SETTINGS_MEM_BYTE_COUNT; fw_index++) + _MMU_write08(0x027FFC80 + fw_index, temp_buffer[fw_index]); + } + } + + // Copy the whole header to Main RAM 0x27FFE00 on startup. + // Reference: http://nocash.emubase.de/gbatek.htm#dscartridgeheader + //zero 27-jun-09 : why did this copy 0x90 more? gbatek says its not stored in ram. + //for (i = 0; i < ((0x170+0x90)/4); i++) { + for (i = 0; i < ((0x170)/4); i++) { + _MMU_write32(0x027FFE00+i*4, LE_TO_LOCAL_32(((u32*)MMU.CART_ROM)[i])); + } + + // Write the header checksum to memory (the firmware needs it to see the cart) + _MMU_write16(0x027FF808, T1ReadWord(MMU.CART_ROM, 0x15E)); + + MainScreen.offset = 0; + SubScreen.offset = 192; + + //_MMU_write32[ARMCPU_ARM9](0x02007FFC, 0xE92D4030); + + delete header; + + Screen_Reset(); + gfx3d_reset(); + gpu3D->NDS_3D_Reset(); + SPU_Reset(); + +#ifdef EXPERIMENTAL_WIFI + WIFI_Init(&wifiMac); + + WIFI_SoftAP_Shutdown(&wifiMac); + WIFI_SoftAP_Init(&wifiMac); +#endif + + memcpy(FW_Mac, (MMU.fw.data + 0x36), 6); +} + +int NDS_ImportSave(const char *filename) +{ + if (strlen(filename) < 4) + return 0; + + if (memcmp(filename+strlen(filename)-4, ".duc", 4) == 0) + return MMU_new.backupDevice.load_duc(filename); + else + return MMU_new.backupDevice.load_raw(filename); + + return 0; +} + +bool NDS_ExportSave(const char *filename) +{ + if (strlen(filename) < 4) + return false; + + if (memcmp(filename+strlen(filename)-4, ".sav", 4) == 0) + return MMU_new.backupDevice.save_raw(filename); + + return false; +} + +static int WritePNGChunk(FILE *fp, uint32 size, const char *type, const uint8 *data) +{ + uint32 crc; + + uint8 tempo[4]; + + tempo[0]=size>>24; + tempo[1]=size>>16; + tempo[2]=size>>8; + tempo[3]=size; + + if(fwrite(tempo,4,1,fp)!=1) + return 0; + if(fwrite(type,4,1,fp)!=1) + return 0; + + if(size) + if(fwrite(data,1,size,fp)!=size) + return 0; + + crc = crc32(0,(uint8 *)type,4); + if(size) + crc = crc32(crc,data,size); + + tempo[0]=crc>>24; + tempo[1]=crc>>16; + tempo[2]=crc>>8; + tempo[3]=crc; + + if(fwrite(tempo,4,1,fp)!=1) + return 0; + return 1; +} +int NDS_WritePNG(const char *fname) +{ + int x, y; + int width=256; + int height=192*2; + u16 * bmp = (u16 *)GPU_screen; + FILE *pp=NULL; + uint8 *compmem = NULL; + uLongf compmemsize = (uLongf)( (height * (width + 1) * 3 * 1.001 + 1) + 12 ); + + if(!(compmem=(uint8 *)malloc(compmemsize))) + return 0; + + if(!(pp=fopen(fname, "wb"))) + { + return 0; + } + { + static uint8 header[8]={137,80,78,71,13,10,26,10}; + if(fwrite(header,8,1,pp)!=1) + goto PNGerr; + } + + { + uint8 chunko[13]; + + chunko[0] = width >> 24; // Width + chunko[1] = width >> 16; + chunko[2] = width >> 8; + chunko[3] = width; + + chunko[4] = height >> 24; // Height + chunko[5] = height >> 16; + chunko[6] = height >> 8; + chunko[7] = height; + + chunko[8]=8; // 8 bits per sample(24 bits per pixel) + chunko[9]=2; // Color type; RGB triplet + chunko[10]=0; // compression: deflate + chunko[11]=0; // Basic adapative filter set(though none are used). + chunko[12]=0; // No interlace. + + if(!WritePNGChunk(pp,13,"IHDR",chunko)) + goto PNGerr; + } + + { + uint8 *tmp_buffer; + uint8 *tmp_inc; + tmp_inc = tmp_buffer = (uint8 *)malloc((width * 3 + 1) * height); + + for(y=0;y>10; + pixel-=r<<10; + g = pixel>>5; + pixel-=g<<5; + b = pixel; + r*=255/31; + g*=255/31; + b*=255/31; + tmp_inc[0] = b; + tmp_inc[1] = g; + tmp_inc[2] = r; + tmp_inc += 3; + } + } + + if(compress(compmem, &compmemsize, tmp_buffer, height * (width * 3 + 1))!=Z_OK) + { + if(tmp_buffer) free(tmp_buffer); + goto PNGerr; + } + if(tmp_buffer) free(tmp_buffer); + if(!WritePNGChunk(pp,compmemsize,"IDAT",compmem)) + goto PNGerr; + } + if(!WritePNGChunk(pp,0,"IEND",0)) + goto PNGerr; + + free(compmem); + fclose(pp); + + return 1; + +PNGerr: + if(compmem) + free(compmem); + if(pp) + fclose(pp); + return(0); +} + +typedef struct +{ + u32 size; + s32 width; + s32 height; + u16 planes; + u16 bpp; + u32 cmptype; + u32 imgsize; + s32 hppm; + s32 vppm; + u32 numcol; + u32 numimpcol; +} bmpimgheader_struct; + +#include "PACKED.h" +typedef struct +{ + u16 id __PACKED; + u32 size __PACKED; + u16 reserved1 __PACKED; + u16 reserved2 __PACKED; + u32 imgoffset __PACKED; +} bmpfileheader_struct; +#include "PACKED_END.h" + +int NDS_WriteBMP(const char *filename) +{ + bmpfileheader_struct fileheader; + bmpimgheader_struct imageheader; + FILE *file; + int i,j; + u16 * bmp = (u16 *)GPU_screen; + size_t elems_written = 0; + + memset(&fileheader, 0, sizeof(fileheader)); + fileheader.size = sizeof(fileheader); + fileheader.id = 'B' | ('M' << 8); + fileheader.imgoffset = sizeof(fileheader)+sizeof(imageheader); + + memset(&imageheader, 0, sizeof(imageheader)); + imageheader.size = sizeof(imageheader); + imageheader.width = 256; + imageheader.height = 192*2; + imageheader.planes = 1; + imageheader.bpp = 24; + imageheader.cmptype = 0; // None + imageheader.imgsize = imageheader.width * imageheader.height * 3; + + if ((file = fopen(filename,"wb")) == NULL) + return 0; + + elems_written += fwrite(&fileheader, 1, sizeof(fileheader), file); + elems_written += fwrite(&imageheader, 1, sizeof(imageheader), file); + + for(j=0;j<192*2;j++) + { + for(i=0;i<256;i++) + { + u8 r,g,b; + u16 pixel = bmp[(192*2-j-1)*256+i]; + r = pixel>>10; + pixel-=r<<10; + g = pixel>>5; + pixel-=g<<5; + b = pixel; + r*=255/31; + g*=255/31; + b*=255/31; + elems_written += fwrite(&r, 1, sizeof(u8), file); + elems_written += fwrite(&g, 1, sizeof(u8), file); + elems_written += fwrite(&b, 1, sizeof(u8), file); + } + } + fclose(file); + + return 1; +} + +int NDS_WriteBMP_32bppBuffer(int width, int height, const void* buf, const char *filename) +{ + bmpfileheader_struct fileheader; + bmpimgheader_struct imageheader; + FILE *file; + size_t elems_written = 0; + memset(&fileheader, 0, sizeof(fileheader)); + fileheader.size = sizeof(fileheader); + fileheader.id = 'B' | ('M' << 8); + fileheader.imgoffset = sizeof(fileheader)+sizeof(imageheader); + + memset(&imageheader, 0, sizeof(imageheader)); + imageheader.size = sizeof(imageheader); + imageheader.width = width; + imageheader.height = height; + imageheader.planes = 1; + imageheader.bpp = 32; + imageheader.cmptype = 0; // None + imageheader.imgsize = imageheader.width * imageheader.height * 4; + + if ((file = fopen(filename,"wb")) == NULL) + return 0; + + elems_written += fwrite(&fileheader, 1, sizeof(fileheader), file); + elems_written += fwrite(&imageheader, 1, sizeof(imageheader), file); + + for(int i=0;ifav_colour; + + /* birthday month and day */ + data[0x03] = user_settings->birth_month; + data[0x04] = user_settings->birth_day; + + /* nickname and length */ + for ( i = 0; i < MAX_FW_NICKNAME_LENGTH; i++) { + data[0x06 + (i * 2)] = user_settings->nickname[i] & 0xff; + data[0x06 + (i * 2) + 1] = (user_settings->nickname[i] >> 8) & 0xff; + } + + data[0x1a] = user_settings->nickname_len; + + /* Message */ + for ( i = 0; i < MAX_FW_MESSAGE_LENGTH; i++) { + data[0x1c + (i * 2)] = user_settings->message[i] & 0xff; + data[0x1c + (i * 2) + 1] = (user_settings->message[i] >> 8) & 0xff; + } + + data[0x50] = user_settings->message_len; + + /* + * touch screen calibration + */ + ts_cal_data_area = &data[0x58]; + for ( i = 0; i < 2; i++) { + /* ADC x y */ + *ts_cal_data_area++ = user_settings->touch_cal[i].adc_x & 0xff; + *ts_cal_data_area++ = (user_settings->touch_cal[i].adc_x >> 8) & 0xff; + *ts_cal_data_area++ = user_settings->touch_cal[i].adc_y & 0xff; + *ts_cal_data_area++ = (user_settings->touch_cal[i].adc_y >> 8) & 0xff; + + /* screen x y */ + *ts_cal_data_area++ = user_settings->touch_cal[i].screen_x; + *ts_cal_data_area++ = user_settings->touch_cal[i].screen_y; + } + + /* language and flags */ + data[0x64] = user_settings->language; + data[0x65] = 0xfc; + + /* update count and crc */ + data[0x70] = count & 0xff; + data[0x71] = (count >> 8) & 0xff; + + crc = calc_CRC16( 0xffff, data, 0x70); + data[0x72] = crc & 0xff; + data[0x73] = (crc >> 8) & 0xff; + + memset( &data[0x74], 0xff, 0x100 - 0x74); +} + +/* creates an firmware flash image, which contains all needed info to initiate a wifi connection */ +int NDS_CreateDummyFirmware( struct NDS_fw_config_data *user_settings) +{ + /* + * Create the firmware header + */ + memset( MMU.fw.data, 0, 0x40000); + + /* firmware identifier */ + MMU.fw.data[0x8] = 'M'; + MMU.fw.data[0x8 + 1] = 'A'; + MMU.fw.data[0x8 + 2] = 'C'; + MMU.fw.data[0x8 + 3] = 'P'; + + /* DS type */ + if ( user_settings->ds_type == NDS_FW_DS_TYPE_LITE) + MMU.fw.data[0x1d] = 0x20; + else + MMU.fw.data[0x1d] = 0xff; + + /* User Settings offset 0x3fe00 / 8 */ + MMU.fw.data[0x20] = 0xc0; + MMU.fw.data[0x21] = 0x7f; + + + /* + * User settings (at 0x3FE00 and 0x3FF00) + */ + fill_user_data_area( user_settings, &MMU.fw.data[ 0x3FE00], 0); + fill_user_data_area( user_settings, &MMU.fw.data[ 0x3FF00], 1); + + /* Wifi config length */ + MMU.fw.data[0x2C] = 0x38; + MMU.fw.data[0x2D] = 0x01; + + MMU.fw.data[0x2E] = 0x00; + + /* Wifi version */ + MMU.fw.data[0x2F] = 0x00; + + /* MAC address */ + memcpy((MMU.fw.data + 0x36), FW_Mac, sizeof(FW_Mac)); + + /* Enabled channels */ + MMU.fw.data[0x3C] = 0xFE; + MMU.fw.data[0x3D] = 0x3F; + + MMU.fw.data[0x3E] = 0xFF; + MMU.fw.data[0x3F] = 0xFF; + + /* RF related */ + MMU.fw.data[0x40] = 0x02; + MMU.fw.data[0x41] = 0x18; + MMU.fw.data[0x42] = 0x0C; + + MMU.fw.data[0x43] = 0x01; + + /* Wifi I/O init values */ + memcpy((MMU.fw.data + 0x44), FW_WIFIInit, sizeof(FW_WIFIInit)); + + /* Wifi BB init values */ + memcpy((MMU.fw.data + 0x64), FW_BBInit, sizeof(FW_BBInit)); + + /* Wifi RF init values */ + memcpy((MMU.fw.data + 0xCE), FW_RFInit, sizeof(FW_RFInit)); + + /* Wifi channel-related init values */ + memcpy((MMU.fw.data + 0xF2), FW_RFChannel, sizeof(FW_RFChannel)); + memcpy((MMU.fw.data + 0x146), FW_BBChannel, sizeof(FW_BBChannel)); + memset((MMU.fw.data + 0x154), 0x10, 0xE); + + /* WFC profiles */ + memcpy((MMU.fw.data + 0x3FA40), &FW_WFCProfile1, sizeof(FW_WFCProfile)); + memcpy((MMU.fw.data + 0x3FB40), &FW_WFCProfile2, sizeof(FW_WFCProfile)); + memcpy((MMU.fw.data + 0x3FC40), &FW_WFCProfile3, sizeof(FW_WFCProfile)); + (*(u16*)(MMU.fw.data + 0x3FAFE)) = (u16)calc_CRC16(0, (MMU.fw.data + 0x3FA00), 0xFE); + (*(u16*)(MMU.fw.data + 0x3FBFE)) = (u16)calc_CRC16(0, (MMU.fw.data + 0x3FB00), 0xFE); + (*(u16*)(MMU.fw.data + 0x3FCFE)) = (u16)calc_CRC16(0, (MMU.fw.data + 0x3FC00), 0xFE); + + + MMU.fw.data[0x162] = 0x19; + memset((MMU.fw.data + 0x163), 0xFF, 0x9D); + + /* Wifi settings CRC16 */ + (*(u16*)(MMU.fw.data + 0x2A)) = calc_CRC16(0, (MMU.fw.data + 0x2C), 0x138); + + return TRUE ; +} + +void +NDS_FillDefaultFirmwareConfigData( struct NDS_fw_config_data *fw_config) { + const char *default_nickname = "yopyop"; + const char *default_message = "DeSmuME makes you happy!"; + int i; + int str_length; + + memset( fw_config, 0, sizeof( struct NDS_fw_config_data)); + fw_config->ds_type = NDS_FW_DS_TYPE_FAT; + + fw_config->fav_colour = 7; + + fw_config->birth_day = 23; + fw_config->birth_month = 6; + + str_length = strlen( default_nickname); + for ( i = 0; i < str_length; i++) { + fw_config->nickname[i] = default_nickname[i]; + } + fw_config->nickname_len = str_length; + + str_length = strlen( default_message); + for ( i = 0; i < str_length; i++) { + fw_config->message[i] = default_message[i]; + } + fw_config->message_len = str_length; + + /* default to English */ + fw_config->language = 1; + + /* default touchscreen calibration */ + fw_config->touch_cal[0].adc_x = 0x200; + fw_config->touch_cal[0].adc_y = 0x200; + fw_config->touch_cal[0].screen_x = 0x20; + fw_config->touch_cal[0].screen_y = 0x20; + + fw_config->touch_cal[1].adc_x = 0xe00; + fw_config->touch_cal[1].adc_y = 0x800; + fw_config->touch_cal[1].screen_x = 0xe0; + fw_config->touch_cal[1].screen_y = 0x80; +} + +int NDS_LoadFirmware(const char *filename) +{ + int i; + unsigned long size; + //FILE *file; + + if ((MMU.fw.fp = fopen(filename, "rb+")) == NULL) + return -1; + + fseek(MMU.fw.fp, 0, SEEK_END); + size = ftell(MMU.fw.fp); + fseek(MMU.fw.fp, 0, SEEK_SET); + + if(size > MMU.fw.size) + { + fclose(MMU.fw.fp); + fw_success = FALSE; + return -1; + } + + i = fread(MMU.fw.data, size, 1, MMU.fw.fp); + //fclose(file); + + INFO("Firmware: decrypting NDS firmware %s...\n", filename); + + if(decryptFirmware(MMU.fw.data) == FALSE) + { + INFO("Firmware: decryption failed.\n"); + fw_success = FALSE; + } + else + { + INFO("Firmware: decryption successful.\n"); + fw_success = TRUE; + } + + return i; +} + +void NDS_Sleep() { nds.sleeping = TRUE; } + +bool SkipCur2DFrame = false, SkipNext2DFrame = false; +bool SkipCur3DFrame = false; + +void NDS_SkipNextFrame() { SkipNext2DFrame = true; SkipCur3DFrame = true; } + +#define INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF)) + +//#define LOG_ARM9 +//#define LOG_ARM7 +//static bool dolog = false; + +template +void NDS_exec(s32 nb) +{ + int i, j; + + LagFrameFlag=1; + + if((currFrameCounter&63) == 0) + MMU_new.backupDevice.lazy_flush(); + + //increase this to execute more instructions in each batch (reducing overhead) + //the value of 4 seems to optimize speed.. do lower values increase precision? + //answer: YES, MAYBE. and after 0.9.3 we need to study it (spider-man) + const int INSTRUCTIONS_PER_BATCH = 4; + + //decreasing this should increase precision at the cost of speed + //the traditional value was somewhere between 100 and 400 depending on circumstances + const int CYCLES_TO_WAIT_FOR_IRQ = 400; + + for(; (nb >= nds.cycles) && ((FORCE)||(execute)); ) + { + for (j = 0; j < INSTRUCTIONS_PER_BATCH && (!FORCE) && (execute); j++) + { + if(nds.ARM9Cycle<=nds.cycles) + { + for (i = 0; i < INSTRUCTIONS_PER_BATCH && (!FORCE) && (execute); i++) + { + if(nds.sleeping) { + break; + } else + if(NDS_ARM9.waitIRQ) { + nds.ARM9Cycle += CYCLES_TO_WAIT_FOR_IRQ; + nds.idleCycles += CYCLES_TO_WAIT_FOR_IRQ; + break; //it is rather pointless to do this more than once + } else { + #ifdef LOG_ARM9 + if(dolog) + { + char dasmbuf[1024]; + char zlogbuf[4096]; + if(NDS_ARM9.CPSR.bits.T) + des_thumb_instructions_set[((NDS_ARM9.instruction)>>6)&1023](NDS_ARM9.instruct_adr, NDS_ARM9.instruction, dasmbuf); + else + des_arm_instructions_set[INDEX(NDS_ARM9.instruction)](NDS_ARM9.instruct_adr, NDS_ARM9.instruction, dasmbuf); + + printf("%05d %08d 9:%08X %08X %-30s R00:%08X R01:%08X R02:%08X R03:%08X R04:%08X R05:%08X R06:%08X R07:%08X R08:%08X R09:%08X R10:%08X R11:%08X R12:%08X R13:%08X R14:%08X R15:%08X\n", + currFrameCounter, nds.cycles, + NDS_ARM9.instruct_adr,NDS_ARM9.instruction, dasmbuf, + NDS_ARM9.R[0], NDS_ARM9.R[1], NDS_ARM9.R[2], NDS_ARM9.R[3], NDS_ARM9.R[4], NDS_ARM9.R[5], NDS_ARM9.R[6], NDS_ARM9.R[7], + NDS_ARM9.R[8], NDS_ARM9.R[9], NDS_ARM9.R[10], NDS_ARM9.R[11], NDS_ARM9.R[12], NDS_ARM9.R[13], NDS_ARM9.R[14], NDS_ARM9.R[15]); + //strcpy(logbufptr,zlogbuf); + //logbufptr += strlen(zlogbuf); + } + #endif + + nds.ARM9Cycle += armcpu_exec(); + } + } +#ifdef _WIN32 +#ifdef DEVELOPER + DisassemblerTools_Refresh(); +#endif +#endif + } + +#ifdef EXPERIMENTAL_WIFI +#if 0 + + if((nds.ARM7Cycle % 0x3F03) == 0) + { + /* 3F03 arm7 cycles = ~1usec */ + // WRONG!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // 1 usec = ~33 ARM7 cycles because ARM7 runs at 33.51 mhz + // 33.51 mhz = 33.51 million cycles per second = 33.51 cycles per usec + WIFI_usTrigger(&wifiMac) ; + } +#endif + + int nds7old = nds.ARM7Cycle; +#endif + + if(nds.ARM7Cycle<=nds.cycles) + { + for (i = 0; i < INSTRUCTIONS_PER_BATCH && (!FORCE) && (execute); i++) + { + if(nds.sleeping) { + break; + } else + if(NDS_ARM7.waitIRQ) + { + nds.ARM7Cycle += CYCLES_TO_WAIT_FOR_IRQ; + break; //it is rather pointless to do this more than once + } + else + { + #ifdef LOG_ARM7 + if(dolog) + { + char dasmbuf[1024]; + char zlogbuf[4096]; + if(NDS_ARM7.CPSR.bits.T) + des_thumb_instructions_set[((NDS_ARM7.instruction)>>6)&1023](NDS_ARM7.instruct_adr, NDS_ARM7.instruction, dasmbuf); + else + des_arm_instructions_set[INDEX(NDS_ARM7.instruction)](NDS_ARM7.instruct_adr, NDS_ARM7.instruction, dasmbuf); + printf("%05d %08d 7:%08X %08X %-30s R00:%08X R01:%08X R02:%08X R03:%08X R04:%08X R05:%08X R06:%08X R07:%08X R08:%08X R09:%08X R10:%08X R11:%08X R12:%08X R13:%08X R14:%08X R15:%08X\n", + currFrameCounter, nds.cycles, + NDS_ARM7.instruct_adr,NDS_ARM7.instruction, dasmbuf, + NDS_ARM7.R[0], NDS_ARM7.R[1], NDS_ARM7.R[2], NDS_ARM7.R[3], NDS_ARM7.R[4], NDS_ARM7.R[5], NDS_ARM7.R[6], NDS_ARM7.R[7], + NDS_ARM7.R[8], NDS_ARM7.R[9], NDS_ARM7.R[10], NDS_ARM7.R[11], NDS_ARM7.R[12], NDS_ARM7.R[13], NDS_ARM7.R[14], NDS_ARM7.R[15], + NDS_ARM7.CPSR, NDS_ARM7.SPSR); + //strcpy(logbufptr,zlogbuf); + //logbufptr += strlen(zlogbuf); + } + #endif + nds.ARM7Cycle += (armcpu_exec()<<1); + } + } +#ifdef _WIN32 +#ifdef DEVELOPER + DisassemblerTools_Refresh(); +#endif +#endif + } + +//this doesnt work anyway. why take a speed hit for public releases? +// Luigi__: I don't agree. We should start include wifi emulation in public releases +// because it already allows games to not hang during wifi operations +// and thus games that perform wifi checks upon boot shouldn't hang with wifi +// emulation turned on. +#ifndef PUBLIC_RELEASE +#ifdef EXPERIMENTAL_WIFI + // FIXME: the wifi stuff isn't actually clocked by the ARM7 clock, + // but by a 22 mhz oscillator. + // But do we really care? while we're triggering wifi core every microsecond, + // everything is fine, isn't it? + + //zeromus way: i did this in a rush and it is not perfect, but it is more like what it needs to be + //nds.wifiCycle += (nds.ARM7Cycle-nds7old)<<16; + //while(nds.wifiCycle > 0) + //{ + // nds.wifiCycle -= 946453; //22*22000000*65536/ARM7_CLOCK; + // WIFI_usTrigger(&wifiMac); + // WIFI_SoftAP_usTrigger(&wifiMac); + //} + // + //luigi's way> + // new one, more like zeromus way + // but I can't understand why it uses that value (22*22000000*65536/ARM7_CLOCK) + nds.wifiCycle += (nds.ARM7Cycle - nds7old) << 16; + while (nds.wifiCycle > 0) + { + // 2196372 ~= (ARM7_CLOCK << 16) / 1000000 + // This value makes more sense to me, because: + // ARM7_CLOCK = 33.51 mhz + // = 33513982 cycles per second + // = 33.513982 cycles per microsecond + // The value is left shifted by 16 for more precision. + nds.wifiCycle -= (2196372 << 1); + + WIFI_usTrigger(&wifiMac); + WIFI_SoftAP_usTrigger(&wifiMac); + } +#endif +#endif + } // for (j = 0; j < INSTRUCTIONS_PER_BATCH && (!FORCE) && (execute); j++) + + if(!nds.sleeping) + { + + // for(i = 0; i < INSTRUCTIONS_PER_BATCH && (!FORCE) && (execute); i++) + // { + + nds.cycles = std::min(nds.ARM9Cycle,nds.ARM7Cycle); + + //debug(); + + if(nds.cycles>=nds.nextHBlank) + { + if(!nds.lignerendu) + { + T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) | 2); + T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 2); + NDS_ARM9HBlankInt(); + NDS_ARM7HBlankInt(); + SPU_Emulate_core(); + driver->AVI_SoundUpdate(SPU_core->outbuf,spu_core_samples); + WAV_WavSoundUpdate(SPU_core->outbuf,spu_core_samples); + if(nds.VCount<192) + { + if(!SkipCur2DFrame) + { + GPU_ligne(&MainScreen, nds.VCount); + GPU_ligne(&SubScreen, nds.VCount); + } + + if(MMU.DMAStartTime[0][0] == 2) + MMU_doDMA(0); + if(MMU.DMAStartTime[0][1] == 2) + MMU_doDMA(1); + if(MMU.DMAStartTime[0][2] == 2) + MMU_doDMA(2); + if(MMU.DMAStartTime[0][3] == 2) + MMU_doDMA(3); + } + nds.lignerendu = TRUE; + } + if(nds.cycles>=nds.nextHBlank+1092) + { + u32 vmatch; + + ++nds.VCount; + nds.nextHBlank += 4260; + T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0xFFFD); + T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) & 0xFFFD); + + if(MMU.DMAStartTime[0][0] == 3) + MMU_doDMA(0); + if(MMU.DMAStartTime[0][1] == 3) + MMU_doDMA(1); + if(MMU.DMAStartTime[0][2] == 3) + MMU_doDMA(2); + if(MMU.DMAStartTime[0][3] == 3) + MMU_doDMA(3); + + // Main memory display + if(MMU.DMAStartTime[0][0] == 4) + { + MMU_doDMA(0); + MMU.DMAStartTime[0][0] = 0; + } + if(MMU.DMAStartTime[0][1] == 4) + { + MMU_doDMA(1); + MMU.DMAStartTime[0][1] = 0; + } + if(MMU.DMAStartTime[0][2] == 4) + { + MMU_doDMA(2); + MMU.DMAStartTime[0][2] = 0; + } + if(MMU.DMAStartTime[0][3] == 4) + { + MMU_doDMA(3); + MMU.DMAStartTime[0][3] = 0; + } + + if(MMU.DMAStartTime[1][0] == 4) + { + MMU_doDMA(0); + MMU.DMAStartTime[1][0] = 0; + } + if(MMU.DMAStartTime[1][1] == 4) + { + MMU_doDMA(1); + MMU.DMAStartTime[0][1] = 0; + } + if(MMU.DMAStartTime[1][2] == 4) + { + MMU_doDMA(2); + MMU.DMAStartTime[1][2] = 0; + } + if(MMU.DMAStartTime[1][3] == 4) + { + MMU_doDMA(3); + MMU.DMAStartTime[1][3] = 0; + } + + nds.lignerendu = FALSE; + if(nds.VCount==192) + { + //osdA->update(); + gfx3d_VBlankSignal(); + + if(SkipNext2DFrame) + { + SkipCur2DFrame = true; + SkipNext2DFrame = false; + } + else + SkipCur2DFrame = false; + + T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) | 1); + T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 1); + NDS_ARM9VBlankInt(); + NDS_ARM7VBlankInt(); + + nds.runCycleCollector[nds.idleFrameCounter] = 1120380-nds.idleCycles; + nds.idleFrameCounter++; + nds.idleFrameCounter &= 15; + nds.idleCycles = 0; + + + if(MMU.DMAStartTime[0][0] == 1) + MMU_doDMA(0); + if(MMU.DMAStartTime[0][1] == 1) + MMU_doDMA(1); + if(MMU.DMAStartTime[0][2] == 1) + MMU_doDMA(2); + if(MMU.DMAStartTime[0][3] == 1) + MMU_doDMA(3); + + if(MMU.DMAStartTime[1][0] == 1) + MMU_doDMA(0); + if(MMU.DMAStartTime[1][1] == 1) + MMU_doDMA(1); + if(MMU.DMAStartTime[1][2] == 1) + MMU_doDMA(2); + if(MMU.DMAStartTime[1][3] == 1) + MMU_doDMA(3); + } + else if(nds.VCount==214) + { + gfx3d_VBlankEndSignal(SkipCur3DFrame); + SkipCur3DFrame = false; + } + else if(nds.VCount==263) + { + //osd->update(); + //osdB->update(); + gpu_UpdateRender(); + + nds.nextHBlank = 3168; + nds.VCount = 0; + T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0xFFFE); + T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) & 0xFFFE); + + nds.cycles -= (560190<<1); + nds.ARM9Cycle -= (560190<<1); + nds.ARM7Cycle -= (560190<<1); + nb -= (560190<<1); + +#ifdef USE_GEOMETRY_FIFO_EMULATION + MMU.gfx3dCycles -= (560190 << 1); +#endif + + if(MMU.divRunning) + { + MMU.divCycles -= (560190 << 1); + } + + if(MMU.sqrtRunning) + { + MMU.sqrtCycles -= (560190 << 1); + } + + if (MMU.CheckTimers) + { + if(MMU.timerON[0][0]) nds.timerCycle[0][0] -= (560190<<1); + if(MMU.timerON[0][1]) nds.timerCycle[0][1] -= (560190<<1); + if(MMU.timerON[0][2]) nds.timerCycle[0][2] -= (560190<<1); + if(MMU.timerON[0][3]) nds.timerCycle[0][3] -= (560190<<1); + + if(MMU.timerON[1][0]) nds.timerCycle[1][0] -= (560190<<1); + if(MMU.timerON[1][1]) nds.timerCycle[1][1] -= (560190<<1); + if(MMU.timerON[1][2]) nds.timerCycle[1][2] -= (560190<<1); + if(MMU.timerON[1][3]) nds.timerCycle[1][3] -= (560190<<1); + } + + if (MMU.CheckDMAs) + { + if(MMU.DMAing[0][0]) MMU.DMACycle[0][0] -= (560190<<1); + if(MMU.DMAing[0][1]) MMU.DMACycle[0][1] -= (560190<<1); + if(MMU.DMAing[0][2]) MMU.DMACycle[0][2] -= (560190<<1); + if(MMU.DMAing[0][3]) MMU.DMACycle[0][3] -= (560190<<1); + + if(MMU.DMAing[1][0]) MMU.DMACycle[1][0] -= (560190<<1); + if(MMU.DMAing[1][1]) MMU.DMACycle[1][1] -= (560190<<1); + if(MMU.DMAing[1][2]) MMU.DMACycle[1][2] -= (560190<<1); + if(MMU.DMAing[1][3]) MMU.DMACycle[1][3] -= (560190<<1); + } + } + + T1WriteWord(ARM9Mem.ARM9_REG, 6, nds.VCount); + T1WriteWord(ARM9Mem.ARM9_REG, 0x1006, nds.VCount); + T1WriteWord(MMU.ARM7_REG, 6, nds.VCount); + T1WriteWord(MMU.ARM7_REG, 0x1006, nds.VCount); + + vmatch = T1ReadWord(ARM9Mem.ARM9_REG, 4); + if(nds.VCount==((vmatch>>8)|((vmatch<<1)&(1<<8)))) + { + T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) | 4); + if(T1ReadWord(ARM9Mem.ARM9_REG, 4) & 32) + NDS_makeARM9Int(2); + } + else + T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0xFFFB); + + vmatch = T1ReadWord(MMU.ARM7_REG, 4); + if(nds.VCount==((vmatch>>8)|((vmatch<<1)&(1<<8)))) + { + T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) | 4); + if(T1ReadWord(MMU.ARM7_REG, 4) & 32) + NDS_makeARM7Int(2); + } + else + T1WriteWord(MMU.ARM7_REG, 4, T1ReadWord(MMU.ARM7_REG, 4) & 0xFFFB); + } + } // if(nds.cycles >= nds.nextHBlank) + + /* } // for(i = 0; i < INSTRUCTIONS_PER_BATCH && (!FORCE) && (execute); i++) + + } // if(!nds.sleeping) + + } // for (j = 0; j < INSTRUCTIONS_PER_BATCH && (!FORCE) && (execute); j++) + + if(!nds.sleeping) + {*/ + +#ifdef USE_GEOMETRY_FIFO_EMULATION + if (nds.cycles > MMU.gfx3dCycles) + gfx3d_execute3D(); +#endif + + if(MMU.divRunning) + { + if(nds.cycles > MMU.divCycles) + { + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A0, (u32)MMU.divResult); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A4, (u32)(MMU.divResult >> 32)); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2A8, (u32)MMU.divMod); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2AC, (u32)(MMU.divMod >> 32)); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x280, MMU.divCnt); + + MMU.divRunning = FALSE; + } + } + + if(MMU.sqrtRunning) + { + if(nds.cycles > MMU.sqrtCycles) + { + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B4, MMU.sqrtResult); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B0, MMU.sqrtCnt); + + MMU.sqrtRunning = FALSE; + } + } + + if (MMU.CheckTimers) + { + /* assume the timers have not expired */ + nds.timerOver[0][0] = 0; + nds.timerOver[0][1] = 0; + nds.timerOver[0][2] = 0; + nds.timerOver[0][3] = 0; + nds.timerOver[1][0] = 0; + nds.timerOver[1][1] = 0; + nds.timerOver[1][2] = 0; + nds.timerOver[1][3] = 0; + if(MMU.timerON[0][0]) + { + if(MMU.timerRUN[0][0]) + { + switch(MMU.timerMODE[0][0]) + { + case 0xFFFF : + break; + default : + { + nds.diff = (nds.cycles - nds.timerCycle[0][0])>>MMU.timerMODE[0][0]; + nds.old = MMU.timer[0][0]; + MMU.timer[0][0] += nds.diff; + nds.timerCycle[0][0] += (nds.diff << MMU.timerMODE[0][0]); + nds.timerOver[0][0] = nds.old>MMU.timer[0][0]; + if(nds.timerOver[0][0]) + { + if(T1ReadWord(ARM9Mem.ARM9_REG, 0x102) & 0x40) + NDS_makeARM9Int(3); + MMU.timer[0][0] = MMU.timerReload[0][0]; + } + } + break; + } + } + else + { + MMU.timerRUN[0][0] = TRUE; + nds.timerCycle[0][0] = nds.cycles; + } + } + if(MMU.timerON[0][1]) + { + if(MMU.timerRUN[0][1]) + { + switch(MMU.timerMODE[0][1]) + { + case 0xFFFF : + if(nds.timerOver[0][0]) + { + ++(MMU.timer[0][1]); + nds.timerOver[0][1] = !MMU.timer[0][1]; + if (nds.timerOver[0][1]) + { + if(T1ReadWord(ARM9Mem.ARM9_REG, 0x106) & 0x40) + NDS_makeARM9Int(4); + MMU.timer[0][1] = MMU.timerReload[0][1]; + } + } + break; + default : + { + nds.diff = (nds.cycles - nds.timerCycle[0][1])>>MMU.timerMODE[0][1]; + nds.old = MMU.timer[0][1]; + MMU.timer[0][1] += nds.diff; + nds.timerCycle[0][1] += nds.diff << MMU.timerMODE[0][1]; + nds.timerOver[0][1] = nds.old>MMU.timer[0][1]; + if(nds.timerOver[0][1]) + { + if(T1ReadWord(ARM9Mem.ARM9_REG, 0x106) & 0x40) + NDS_makeARM9Int(4); + MMU.timer[0][1] = MMU.timerReload[0][1]; + } + } + break; + + } + } + else + { + MMU.timerRUN[0][1] = TRUE; + nds.timerCycle[0][1] = nds.cycles; + } + } + if(MMU.timerON[0][2]) + { + if(MMU.timerRUN[0][2]) + { + switch(MMU.timerMODE[0][2]) + { + case 0xFFFF : + if(nds.timerOver[0][1]) + { + ++(MMU.timer[0][2]); + nds.timerOver[0][2] = !MMU.timer[0][2]; + if (nds.timerOver[0][2]) + { + if(T1ReadWord(ARM9Mem.ARM9_REG, 0x10A) & 0x40) + NDS_makeARM9Int(5); + MMU.timer[0][2] = MMU.timerReload[0][2]; + } + } + break; + default : + { + nds.diff = (nds.cycles - nds.timerCycle[0][2])>>MMU.timerMODE[0][2]; + nds.old = MMU.timer[0][2]; + MMU.timer[0][2] += nds.diff; + nds.timerCycle[0][2] += nds.diff << MMU.timerMODE[0][2]; + nds.timerOver[0][2] = nds.old>MMU.timer[0][2]; + if(nds.timerOver[0][2]) + { + if(T1ReadWord(ARM9Mem.ARM9_REG, 0x10A) & 0x40) + NDS_makeARM9Int(5); + MMU.timer[0][2] = MMU.timerReload[0][2]; + } + } + break; + } + } + else + { + MMU.timerRUN[0][2] = TRUE; + nds.timerCycle[0][2] = nds.cycles; + } + } + if(MMU.timerON[0][3]) + { + if(MMU.timerRUN[0][3]) + { + switch(MMU.timerMODE[0][3]) + { + case 0xFFFF : + if(nds.timerOver[0][2]) + { + ++(MMU.timer[0][3]); + nds.timerOver[0][3] = !MMU.timer[0][3]; + if (nds.timerOver[0][3]) + { + if(T1ReadWord(ARM9Mem.ARM9_REG, 0x10E) & 0x40) + NDS_makeARM9Int(6); + MMU.timer[0][3] = MMU.timerReload[0][3]; + } + } + break; + default : + { + nds.diff = (nds.cycles - nds.timerCycle[0][3])>>MMU.timerMODE[0][3]; + nds.old = MMU.timer[0][3]; + MMU.timer[0][3] += nds.diff; + nds.timerCycle[0][3] += nds.diff << MMU.timerMODE[0][3]; + nds.timerOver[0][3] = nds.old>MMU.timer[0][3]; + if(nds.timerOver[0][3]) + { + if(T1ReadWord(ARM9Mem.ARM9_REG, 0x10E) & 0x40) + NDS_makeARM9Int(6); + MMU.timer[0][3] = MMU.timerReload[0][3]; + } + } + break; + } + } + else + { + MMU.timerRUN[0][3] = TRUE; + nds.timerCycle[0][3] = nds.cycles; + } + } + + if(MMU.timerON[1][0]) + { + if(MMU.timerRUN[1][0]) + { + switch(MMU.timerMODE[1][0]) + { + case 0xFFFF : + break; + default : + { + nds.diff = (nds.cycles - nds.timerCycle[1][0])>>MMU.timerMODE[1][0]; + nds.old = MMU.timer[1][0]; + MMU.timer[1][0] += nds.diff; + nds.timerCycle[1][0] += nds.diff << MMU.timerMODE[1][0]; + nds.timerOver[1][0] = nds.old>MMU.timer[1][0]; + if(nds.timerOver[1][0]) + { + if(T1ReadWord(MMU.ARM7_REG, 0x102) & 0x40) + NDS_makeARM7Int(3); + MMU.timer[1][0] = MMU.timerReload[1][0]; + } + } + break; + } + } + else + { + MMU.timerRUN[1][0] = TRUE; + nds.timerCycle[1][0] = nds.cycles; + } + } + if(MMU.timerON[1][1]) + { + if(MMU.timerRUN[1][1]) + { + switch(MMU.timerMODE[1][1]) + { + case 0xFFFF : + if(nds.timerOver[1][0]) + { + ++(MMU.timer[1][1]); + nds.timerOver[1][1] = !MMU.timer[1][1]; + if (nds.timerOver[1][1]) + { + if(T1ReadWord(MMU.ARM7_REG, 0x106) & 0x40) + NDS_makeARM7Int(4); + MMU.timer[1][1] = MMU.timerReload[1][1]; + } + } + break; + default : + { + nds.diff = (nds.cycles - nds.timerCycle[1][1])>>MMU.timerMODE[1][1]; + nds.old = MMU.timer[1][1]; + MMU.timer[1][1] += nds.diff; + nds.timerCycle[1][1] += nds.diff << MMU.timerMODE[1][1]; + nds.timerOver[1][1] = nds.old>MMU.timer[1][1]; + if(nds.timerOver[1][1]) + { + if(T1ReadWord(MMU.ARM7_REG, 0x106) & 0x40) + NDS_makeARM7Int(4); + MMU.timer[1][1] = MMU.timerReload[1][1]; + } + } + break; + } + } + else + { + MMU.timerRUN[1][1] = TRUE; + nds.timerCycle[1][1] = nds.cycles; + } + } + if(MMU.timerON[1][2]) + { + if(MMU.timerRUN[1][2]) + { + switch(MMU.timerMODE[1][2]) + { + case 0xFFFF : + if(nds.timerOver[1][1]) + { + ++(MMU.timer[1][2]); + nds.timerOver[1][2] = !MMU.timer[1][2]; + if (nds.timerOver[1][2]) + { + if(T1ReadWord(MMU.ARM7_REG, 0x10A) & 0x40) + NDS_makeARM7Int(5); + MMU.timer[1][2] = MMU.timerReload[1][2]; + } + } + break; + default : + { + nds.diff = (nds.cycles - nds.timerCycle[1][2])>>MMU.timerMODE[1][2]; + nds.old = MMU.timer[1][2]; + MMU.timer[1][2] += nds.diff; + nds.timerCycle[1][2] += nds.diff << MMU.timerMODE[1][2]; + nds.timerOver[1][2] = nds.old>MMU.timer[1][2]; + if(nds.timerOver[1][2]) + { + if(T1ReadWord(MMU.ARM7_REG, 0x10A) & 0x40) + NDS_makeARM7Int(5); + MMU.timer[1][2] = MMU.timerReload[1][2]; + } + } + break; + } + } + else + { + MMU.timerRUN[1][2] = TRUE; + nds.timerCycle[1][2] = nds.cycles; + } + } + if(MMU.timerON[1][3]) + { + if(MMU.timerRUN[1][3]) + { + switch(MMU.timerMODE[1][3]) + { + case 0xFFFF : + if(nds.timerOver[1][2]) + { + ++(MMU.timer[1][3]); + nds.timerOver[1][3] = !MMU.timer[1][3]; + if (nds.timerOver[1][3]) + { + if(T1ReadWord(MMU.ARM7_REG, 0x10E) & 0x40) + NDS_makeARM7Int(6); + MMU.timer[1][3] += MMU.timerReload[1][3]; + } + } + break; + default : + { + nds.diff = (nds.cycles - nds.timerCycle[1][3])>>MMU.timerMODE[1][3]; + nds.old = MMU.timer[1][3]; + MMU.timer[1][3] += nds.diff; + nds.timerCycle[1][3] += nds.diff << MMU.timerMODE[1][3]; + nds.timerOver[1][3] = nds.old>MMU.timer[1][3]; + if(nds.timerOver[1][3]) + { + if(T1ReadWord(MMU.ARM7_REG, 0x10E) & 0x40) + NDS_makeARM7Int(6); + MMU.timer[1][3] += MMU.timerReload[1][3]; + } + } + break; + } + } + else + { + MMU.timerRUN[1][3] = TRUE; + nds.timerCycle[1][3] = nds.cycles; + } + } + } + + if (MMU.CheckDMAs) + { + + if((MMU.DMAing[0][0])&&(MMU.DMACycle[0][0]<=nds.cycles)) + { + T1WriteLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*0), T1ReadLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*0)) & 0x7FFFFFFF); + if((MMU.DMACrt[0][0])&(1<<30)) NDS_makeARM9Int(8); + MMU.DMAing[0][0] = FALSE; + MMU.CheckDMAs &= ~(1<<(0+(0<<2))); + } + + if((MMU.DMAing[0][1])&&(MMU.DMACycle[0][1]<=nds.cycles)) + { + T1WriteLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*1), T1ReadLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*1)) & 0x7FFFFFFF); + if((MMU.DMACrt[0][1])&(1<<30)) NDS_makeARM9Int(9); + MMU.DMAing[0][1] = FALSE; + MMU.CheckDMAs &= ~(1<<(1+(0<<2))); + } + + if((MMU.DMAing[0][2])&&(MMU.DMACycle[0][2]<=nds.cycles)) + { + T1WriteLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*2), T1ReadLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*2)) & 0x7FFFFFFF); + if((MMU.DMACrt[0][2])&(1<<30)) NDS_makeARM9Int(10); + MMU.DMAing[0][2] = FALSE; + MMU.CheckDMAs &= ~(1<<(2+(0<<2))); + } + + if((MMU.DMAing[0][3])&&(MMU.DMACycle[0][3]<=nds.cycles)) + { + T1WriteLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*3), T1ReadLong(ARM9Mem.ARM9_REG, 0xB8 + (0xC*3)) & 0x7FFFFFFF); + if((MMU.DMACrt[0][3])&(1<<30)) NDS_makeARM9Int(11); + MMU.DMAing[0][3] = FALSE; + MMU.CheckDMAs &= ~(1<<(3+(0<<2))); + } + + if((MMU.DMAing[1][0])&&(MMU.DMACycle[1][0]<=nds.cycles)) + { + T1WriteLong(MMU.ARM7_REG, 0xB8 + (0xC*0), T1ReadLong(MMU.ARM7_REG, 0xB8 + (0xC*0)) & 0x7FFFFFFF); + if((MMU.DMACrt[1][0])&(1<<30)) NDS_makeARM7Int(8); + MMU.DMAing[1][0] = FALSE; + MMU.CheckDMAs &= ~(1<<(0+(1<<2))); + } + + if((MMU.DMAing[1][1])&&(MMU.DMACycle[1][1]<=nds.cycles)) + { + T1WriteLong(MMU.ARM7_REG, 0xB8 + (0xC*1), T1ReadLong(MMU.ARM7_REG, 0xB8 + (0xC*1)) & 0x7FFFFFFF); + if((MMU.DMACrt[1][1])&(1<<30)) NDS_makeARM7Int(9); + MMU.DMAing[1][1] = FALSE; + MMU.CheckDMAs &= ~(1<<(1+(1<<2))); + } + + if((MMU.DMAing[1][2])&&(MMU.DMACycle[1][2]<=nds.cycles)) + { + T1WriteLong(MMU.ARM7_REG, 0xB8 + (0xC*2), T1ReadLong(MMU.ARM7_REG, 0xB8 + (0xC*2)) & 0x7FFFFFFF); + if((MMU.DMACrt[1][2])&(1<<30)) NDS_makeARM7Int(10); + MMU.DMAing[1][2] = FALSE; + MMU.CheckDMAs &= ~(1<<(2+(1<<2))); + } + + if((MMU.DMAing[1][3])&&(MMU.DMACycle[1][3]<=nds.cycles)) + { + T1WriteLong(MMU.ARM7_REG, 0xB8 + (0xC*3), T1ReadLong(MMU.ARM7_REG, 0xB8 + (0xC*3)) & 0x7FFFFFFF); + if((MMU.DMACrt[1][3])&(1<<30)) NDS_makeARM7Int(11); + MMU.DMAing[1][3] = FALSE; + MMU.CheckDMAs &= ~(1<<(3+(1<<2))); + } + } + +#ifndef USE_GEOMETRY_FIFO_EMULATION + if(MMU.reg_IE[ARMCPU_ARM9]&(1<<21)) + NDS_makeARM9Int(21); // GX geometry +#endif + + if((MMU.reg_IF[0]&MMU.reg_IE[0]) && (MMU.reg_IME[0])) + { +#ifdef GDB_STUB + if ( armcpu_flagIrq( &NDS_ARM9)) +#else + if ( armcpu_irqException(&NDS_ARM9)) +#endif + { + nds.ARM9Cycle = nds.cycles; + } + } + + if((MMU.reg_IF[1]&MMU.reg_IE[1]) && (MMU.reg_IME[1])) + { +#ifdef GDB_STUB + if ( armcpu_flagIrq( &NDS_ARM7)) +#else + if ( armcpu_irqException(&NDS_ARM7)) +#endif + { + nds.ARM7Cycle = nds.cycles; + } + } + + } // if(!nds.sleeping) + else + { + gpu_UpdateRender(); + if((MMU.reg_IE[1] & MMU.reg_IF[1]) & (1<<22)) + { + nds.sleeping = FALSE; + } + break; + } + } + + if(LagFrameFlag) + { + lagframecounter++; + TotalLagFrames++; + } + else + { + lastLag = lagframecounter; + lagframecounter = 0; + } + + currFrameCounter++; + cheatsProcess(); +} + +static std::string MakeInputDisplayString(u16 pad, const std::string* Buttons, int count) { + std::string s; + for (int x = 0; x < count; x++) { + if (pad & (1 << x)) + s.append(Buttons[x].size(), ' '); + else + s += Buttons[x]; + } + return s; +} + +static std::string MakeInputDisplayString(u16 pad, u16 padExt) { + const std::string Buttons[] = {"A", "B", "Sl", "St", "R", "L", "U", "D", "Rs", "Ls"}; + const std::string Ext[] = {"X", "Y"}; + + std::string s = MakeInputDisplayString(pad, Ext, ARRAY_SIZE(Ext)); + s += MakeInputDisplayString(padExt, Buttons, ARRAY_SIZE(Buttons)); + + return s; +} + +void ClearAutoHold(void) { + + for (int i=0; i < 12; i++) { + AutoHold.hold(i)=false; + } +} + +void NDS_setPadFromMovie(u16 pad) +{ +#define FIX(b,n) (((pad>>n)&1)!=0) + NDS_setPad( + FIX(pad,12), //R + FIX(pad,11), //L + FIX(pad,10), //D + FIX(pad,9), //U + FIX(pad,7), //Select + FIX(pad,8), //Start + FIX(pad,6), //B + FIX(pad,5), //A + FIX(pad,4), //Y + FIX(pad,3), //X + FIX(pad,2), + FIX(pad,1), + FIX(pad,0), + movie_lid + ); +#undef FIX + +} + +turbo Turbo; +turbotime TurboTime; + +static void SetTurbo(bool (&pad) [12]) { + + bool turbo[4] = {true, false, true, false}; + bool currentbutton; + + for (int i=0; i < 12; i++) { + currentbutton=Turbo.button(i); + + if(currentbutton && movieMode != MOVIEMODE_PLAY) { + pad[i]=turbo[TurboTime.time(i)-1]; + + if(TurboTime.time(i) >= (int)ARRAY_SIZE(turbo)) + TurboTime.time(i)=0; + } + else + TurboTime.time(i)=0; //reset timer if the button isn't pressed + } + for (int i=0; i<12; i++) + TurboTime.time(i)++; +} + +autohold AutoHold; + +void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,bool X,bool W,bool E,bool G, bool F) +{ + + bool padarray[12] = {R, L, D, U, T, S, B, A, Y, X, W, E}; + + SetTurbo(padarray); + + R=padarray[0]; + L=padarray[1]; + D=padarray[2]; + U=padarray[3]; + T=padarray[4]; + S=padarray[5]; + B=padarray[6]; + A=padarray[7]; + Y=padarray[8]; + X=padarray[9]; + W=padarray[10]; + E=padarray[11]; + + if (movieMode != MOVIEMODE_PLAY) { + if(AutoHold.Right) R=!padarray[0]; + if(AutoHold.Left) L=!padarray[1]; + if(AutoHold.Down) D=!padarray[2]; + if(AutoHold.Up) U=!padarray[3]; + if(AutoHold.Select)T=!padarray[4]; + if(AutoHold.Start) S=!padarray[5]; + if(AutoHold.B) B=!padarray[6]; + if(AutoHold.A) A=!padarray[7]; + if(AutoHold.Y) Y=!padarray[8]; + if(AutoHold.X) X=!padarray[9]; + if(AutoHold.L) W=!padarray[10]; + if(AutoHold.R) E=!padarray[11]; + } + + //this macro is the opposite of what you would expect +#define FIX(b) (b?0:0x80) + + int r = FIX(R); + int l = FIX(L); + int d = FIX(D); + int u = FIX(U); + int t = FIX(T); + int s = FIX(S); + int b = FIX(B); + int a = FIX(A); + int y = FIX(Y); + int x = FIX(X); + int w = FIX(W); + int e = FIX(E); + int g = FIX(G); + int f = FIX(F); + + u16 pad = (0 | + ((a) >> 7) | + ((b) >> 6) | + ((s) >> 5) | + ((t) >> 4) | + ((r) >> 3) | + ((l) >> 2) | + ((u) >> 1) | + ((d)) | + ((e) << 1) | + ((w) << 2)) ; + + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] = (u16)pad; + ((u16 *)MMU.ARM7_REG)[0x130>>1] = (u16)pad; + + if (!f && !countLid) + { + LidClosed = (!LidClosed) & 0x01; + if (!LidClosed) + { + // SPU_Pause(FALSE); + NDS_makeARM7Int(22); + + } + //else + //SPU_Pause(TRUE); + + countLid = 30; + } + else + { + if (countLid > 0) + countLid--; + } + + u16 padExt = (((u16 *)MMU.ARM7_REG)[0x136>>1] & 0x0070) | + ((x) >> 7) | + ((y) >> 6) | + ((g) >> 4) | + ((LidClosed) << 7) | + 0x0034; + + ((u16 *)MMU.ARM7_REG)[0x136>>1] = (u16)padExt; + + InputDisplayString=MakeInputDisplayString(padExt, pad); + + //put into the format we want for the movie system + //RLDUTSBAYXWEGF +#undef FIX +#define FIX(b) (b?1:0) + + r = FIX(R); + l = FIX(L); + d = FIX(D); + u = FIX(U); + t = FIX(T); + s = FIX(S); + b = FIX(B); + a = FIX(A); + y = FIX(Y); + x = FIX(X); + w = FIX(W); + e = FIX(E); + g = FIX(G); + f = FIX(F); + + if(f) movie_lid=true; + else movie_lid=false; + + nds.pad = + (FIX(r)<<12)| + (FIX(l)<<11)| + (FIX(d)<<10)| + (FIX(u)<<9)| + (FIX(s)<<8)| + (FIX(t)<<7)| + (FIX(b)<<6)| + (FIX(a)<<5)| + (FIX(y)<<4)| + (FIX(x)<<3)| + (FIX(w)<<2)| + (FIX(e)<<1); + + // TODO: low power IRQ +} + + +void emu_halt() { + execute = false; +} + +//these templates needed to be instantiated manually +template void NDS_exec(s32 nb); +template void NDS_exec(s32 nb); diff --git a/desmume/src/NDSSystem.h b/src/NDSSystem.h similarity index 90% rename from desmume/src/NDSSystem.h rename to src/NDSSystem.h index 3e1d90500..857312025 100644 --- a/desmume/src/NDSSystem.h +++ b/src/NDSSystem.h @@ -1,488 +1,451 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2008-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef NDSSYSTEM_H -#define NDSSYSTEM_H - -#include -#include "armcpu.h" -#include "MMU.h" -#include "driver.h" -#include "GPU.h" -#include "SPU.h" -#include "mem.h" -#include "wifi.h" - -#include - -#ifdef WIN32 -#include "pathsettings.h" -#endif - -struct turbo { - bool Right; - bool Left; - bool Down; - bool Up; - bool Start; - bool Select; - bool B; - bool A; - bool Y; - bool X; - bool L; - bool R; - - bool &button(int i) { return ((bool*)this)[i]; } -}; - -extern turbo Turbo; - -struct turbotime { - int Right; - int Left; - int Down; - int Up; - int Start; - int Select; - int B; - int A; - int Y; - int X; - int L; - int R; - - int &time(int i) { return ((int*)this)[i]; } -}; - -extern turbotime TurboTime; - -struct autohold { - bool Right; - bool Left; - bool Down; - bool Up; - bool Start; - bool Select; - bool B; - bool A; - bool Y; - bool X; - bool L; - bool R; - - bool &hold(int i) { return ((bool*)this)[i]; } -}; - -extern autohold AutoHold; - -int NDS_WritePNG(const char *fname); - -extern volatile bool execute; -extern BOOL click; - -/* - * The firmware language values - */ -#define NDS_FW_LANG_JAP 0 -#define NDS_FW_LANG_ENG 1 -#define NDS_FW_LANG_FRE 2 -#define NDS_FW_LANG_GER 3 -#define NDS_FW_LANG_ITA 4 -#define NDS_FW_LANG_SPA 5 -#define NDS_FW_LANG_CHI 6 -#define NDS_FW_LANG_RES 7 - - -//#define LOG_ARM9 -//#define LOG_ARM7 - -struct NDS_header -{ - char gameTile[12]; - char gameCode[4]; - u16 makerCode; - u8 unitCode; - u8 deviceCode; - u8 cardSize; - u8 cardInfo[8]; - u8 flags; - - u32 ARM9src; - u32 ARM9exe; - u32 ARM9cpy; - u32 ARM9binSize; - - u32 ARM7src; - u32 ARM7exe; - u32 ARM7cpy; - u32 ARM7binSize; - - u32 FNameTblOff; - u32 FNameTblSize; - - u32 FATOff; - u32 FATSize; - - u32 ARM9OverlayOff; - u32 ARM9OverlaySize; - u32 ARM7OverlayOff; - u32 ARM7OverlaySize; - - u32 unknown2a; - u32 unknown2b; - - u32 IconOff; - u16 CRC16; - u16 ROMtimeout; - u32 ARM9unk; - u32 ARM7unk; - - u8 unknown3c[8]; - u32 ROMSize; - u32 HeaderSize; - u8 unknown5[56]; - u8 logo[156]; - u16 logoCRC16; - u16 headerCRC16; - u8 reserved[160]; -}; - -extern void debug(); -void emu_halt(); - -extern u64 nds_timer; -void NDS_Reschedule(); -void NDS_RescheduleGXFIFO(); -void NDS_RescheduleDMA(); -void NDS_RescheduleTimers(); - -typedef struct -{ - s32 wifiCycle; - s32 cycles; - u64 timerCycle[2][4]; - u32 VCount; - u32 old; - - u16 touchX; - u16 touchY; - BOOL isTouch; - u16 pad; - - u8 *FW_ARM9BootCode; - u8 *FW_ARM7BootCode; - u32 FW_ARM9BootCodeAddr; - u32 FW_ARM7BootCodeAddr; - u32 FW_ARM9BootCodeSize; - u32 FW_ARM7BootCodeSize; - - BOOL sleeping; - - //this is not essential NDS runtime state. - //it was perhaps a mistake to put it here. - //it is far less important than the above. - //maybe I should move it. - s32 idleCycles; - s32 runCycleCollector[16]; - s32 idleFrameCounter; - - //if the game was booted on a debug console, this is set - BOOL debugConsole; - - bool isInVblank() const { return VCount >= 192; } - bool isIn3dVblank() const { return VCount >= 192 && VCount<215; } -} NDSSystem; - -/** /brief A touchscreen calibration point. - */ -struct NDS_fw_touchscreen_cal { - u16 adc_x; - u16 adc_y; - - u8 screen_x; - u8 screen_y; -}; - -/** /brief The type of DS - */ -enum nds_fw_ds_type { - NDS_FW_DS_TYPE_FAT, - NDS_FW_DS_TYPE_LITE, - NDS_FW_DS_TYPE_iQue -}; - -#define MAX_FW_NICKNAME_LENGTH 10 -#define MAX_FW_MESSAGE_LENGTH 26 - -struct NDS_fw_config_data { - enum nds_fw_ds_type ds_type; - - u8 fav_colour; - u8 birth_month; - u8 birth_day; - - u16 nickname[MAX_FW_NICKNAME_LENGTH]; - u8 nickname_len; - - u16 message[MAX_FW_MESSAGE_LENGTH]; - u8 message_len; - - u8 language; - - /* touchscreen calibration */ - struct NDS_fw_touchscreen_cal touch_cal[2]; -}; - -extern NDSSystem nds; - -#ifdef GDB_STUB -int NDS_Init( struct armcpu_memory_iface *arm9_mem_if, - struct armcpu_ctrl_iface **arm9_ctrl_iface, - struct armcpu_memory_iface *arm7_mem_if, - struct armcpu_ctrl_iface **arm7_ctrl_iface); -#else -int NDS_Init ( void); -#endif - -void Desmume_InitOnce(); - -void NDS_DeInit(void); -void -NDS_FillDefaultFirmwareConfigData( struct NDS_fw_config_data *fw_config); - -BOOL NDS_SetROM(u8 * rom, u32 mask); -NDS_header * NDS_getROMHeader(void); - -struct GameInfo -{ - GameInfo() - : romdata(NULL) - {} - - void resize(int size) { - if(romdata != NULL) delete[] romdata; - romdata = new char[size]; - romsize = size; - } - u32 crc; - NDS_header header; - char ROMserial[20]; - void populate(); - char* romdata; - int romsize; -}; - -typedef struct TSCalInfo -{ - struct adc - { - u16 x1, x2; - u16 y1, y2; - } adc; - - struct scr - { - u8 x1, x2; - u8 y1, y2; - } scr; - -} TSCalInfo; - -extern GameInfo gameInfo; -void NDS_setTouchPos(u16 x, u16 y); -void NDS_releaseTouch(void); -void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,bool X,bool W,bool E,bool G, bool F); -void NDS_setPadFromMovie(u16 pad); - -int NDS_LoadROM(const char *filename, const char* logicalFilename=0); -void NDS_FreeROM(void); -void NDS_Reset(); -int NDS_ImportSave(const char *filename); -bool NDS_ExportSave(const char *filename); - -void nds_savestate(std::ostream* os); -bool nds_loadstate(std::istream* is, int size); - -int NDS_WriteBMP(const char *filename); -int NDS_LoadFirmware(const char *filename); -int NDS_CreateDummyFirmware( struct NDS_fw_config_data *user_settings); - -void NDS_Sleep(); - -void NDS_SkipNextFrame(); -#define NDS_SkipFrame(s) if(s) NDS_SkipNext2DFrame(); - -void execHardware_doAllDma(EDMAMode modeNum); - -template void NDS_exec(s32 nb = 560190<<1); - -extern int lagframecounter; - -static INLINE void NDS_ARM9HBlankInt(void) -{ - if(T1ReadWord(MMU.ARM9_REG, 4) & 0x10) - { - //MMU.reg_IF[0] |= 2;// & (MMU.reg_IME[0] << 1);// (MMU.reg_IE[0] & (1<<1)); - setIF(0, 2); - NDS_ARM9.wIRQ = TRUE; - } -} - -static INLINE void NDS_ARM7HBlankInt(void) -{ - if(T1ReadWord(MMU.ARM7_REG, 4) & 0x10) - { - // MMU.reg_IF[1] |= 2;// & (MMU.reg_IME[1] << 1);// (MMU.reg_IE[1] & (1<<1)); - setIF(1, 2); - NDS_ARM7.wIRQ = TRUE; - } -} - -static INLINE void NDS_ARM9VBlankInt(void) -{ - if(T1ReadWord(MMU.ARM9_REG, 4) & 0x8) - { - // MMU.reg_IF[0] |= 1;// & (MMU.reg_IME[0]);// (MMU.reg_IE[0] & 1); - setIF(0, 1); - NDS_ARM9.wIRQ = TRUE; - //emu_halt(); - /*logcount++;*/ - } -} - -static INLINE void NDS_ARM7VBlankInt(void) -{ - if(T1ReadWord(MMU.ARM7_REG, 4) & 0x8) - // MMU.reg_IF[1] |= 1;// & (MMU.reg_IME[1]);// (MMU.reg_IE[1] & 1); - setIF(1, 1); - NDS_ARM7.wIRQ = TRUE; - //emu_halt(); -} - -static INLINE void NDS_swapScreen(void) -{ - u16 tmp = MainScreen.offset; - MainScreen.offset = SubScreen.offset; - SubScreen.offset = tmp; -} - -int NDS_WriteBMP_32bppBuffer(int width, int height, const void* buf, const char *filename); - - - -extern struct TCommonSettings { - TCommonSettings() - : HighResolutionInterpolateColor(true) - , UseExtBIOS(false) - , SWIFromBIOS(false) - , UseExtFirmware(false) - , BootFromFirmware(false) - , DebugConsole(false) - , single_core(true) - , spuInterpolationMode(SPUInterpolation_Linear) - , spuAdpcmCache(false) - , gfx3d_flushMode(0) - , manualBackupType(0) - { - strcpy(ARM9BIOS, "biosnds9.bin"); - strcpy(ARM7BIOS, "biosnds7.bin"); - strcpy(Firmware, "firmware.bin"); - - wifi.mode = 0; - wifi.adhocMode = 0; - strcpy(wifi.adhocServerName, ""); - wifi.infraBridgeAdapter = 0; - - for(int i=0;i<16;i++) - spu_muteChannels[i] = false; - } - bool HighResolutionInterpolateColor; - - bool UseExtBIOS; - char ARM9BIOS[256]; - char ARM7BIOS[256]; - bool SWIFromBIOS; - - bool UseExtFirmware; - char Firmware[256]; - bool BootFromFirmware; - - bool DebugConsole; - - bool single_core; - - struct _Wifi { - int mode; - - int adhocMode; - char adhocServerName[64]; - - int infraBridgeAdapter; - } wifi; - - SPUInterpolationMode spuInterpolationMode; - bool spuAdpcmCache; - - //this is a temporary hack until we straighten out the flushing logic and/or gxfifo - int gfx3d_flushMode; - - //this is the user's choice of manual backup type, for cases when the autodetection can't be trusted - int manualBackupType; - - bool spu_muteChannels[16]; - - struct _ShowGpu { - _ShowGpu() : main(true), sub(true) {} - union { - struct { bool main,sub; }; - bool screens[2]; - }; - } showGpu; - - struct _Hud { - _Hud() - : ShowInputDisplay(false) - , ShowGraphicalInputDisplay(false) - , FpsDisplay(false) - , FrameCounterDisplay(false) - , ShowLagFrameCounter(false) - , ShowMicrophone(false) - {} - bool ShowInputDisplay, ShowGraphicalInputDisplay, FpsDisplay, FrameCounterDisplay, ShowLagFrameCounter, ShowMicrophone; - } hud; - -} CommonSettings; - - -extern std::string InputDisplayString; -extern int LagFrameFlag; -extern int lastLag, TotalLagFrames; - -void MovieSRAM(); - -void ClearAutoHold(void); - -#endif - - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef NDSSYSTEM_H +#define NDSSYSTEM_H + +#include +#include "armcpu.h" +#include "MMU.h" +#include "driver.h" +#include "GPU.h" +#include "SPU.h" +#include "mem.h" +#include "wifi.h" + +#include + +#ifdef WIN32 +#include "pathsettings.h" +#endif + +struct turbo { + bool Right; + bool Left; + bool Down; + bool Up; + bool Start; + bool Select; + bool B; + bool A; + bool Y; + bool X; + bool L; + bool R; + + bool &button(int i) { return ((bool*)this)[i]; } +}; + +extern turbo Turbo; + +struct turbotime { + int Right; + int Left; + int Down; + int Up; + int Start; + int Select; + int B; + int A; + int Y; + int X; + int L; + int R; + + int &time(int i) { return ((int*)this)[i]; } +}; + +extern turbotime TurboTime; + +struct autohold { + bool Right; + bool Left; + bool Down; + bool Up; + bool Start; + bool Select; + bool B; + bool A; + bool Y; + bool X; + bool L; + bool R; + + bool &hold(int i) { return ((bool*)this)[i]; } +}; + +extern autohold AutoHold; + +int NDS_WritePNG(const char *fname); + +extern volatile BOOL execute; +extern BOOL click; + +/* + * The firmware language values + */ +#define NDS_FW_LANG_JAP 0 +#define NDS_FW_LANG_ENG 1 +#define NDS_FW_LANG_FRE 2 +#define NDS_FW_LANG_GER 3 +#define NDS_FW_LANG_ITA 4 +#define NDS_FW_LANG_SPA 5 +#define NDS_FW_LANG_CHI 6 +#define NDS_FW_LANG_RES 7 + + +//#define LOG_ARM9 +//#define LOG_ARM7 + +struct NDS_header +{ + char gameTile[12]; + char gameCode[4]; + u16 makerCode; + u8 unitCode; + u8 deviceCode; + u8 cardSize; + u8 cardInfo[8]; + u8 flags; + + u32 ARM9src; + u32 ARM9exe; + u32 ARM9cpy; + u32 ARM9binSize; + + u32 ARM7src; + u32 ARM7exe; + u32 ARM7cpy; + u32 ARM7binSize; + + u32 FNameTblOff; + u32 FNameTblSize; + + u32 FATOff; + u32 FATSize; + + u32 ARM9OverlayOff; + u32 ARM9OverlaySize; + u32 ARM7OverlayOff; + u32 ARM7OverlaySize; + + u32 unknown2a; + u32 unknown2b; + + u32 IconOff; + u16 CRC16; + u16 ROMtimeout; + u32 ARM9unk; + u32 ARM7unk; + + u8 unknown3c[8]; + u32 ROMSize; + u32 HeaderSize; + u8 unknown5[56]; + u8 logo[156]; + u16 logoCRC16; + u16 headerCRC16; + u8 reserved[160]; +}; + +extern void debug(); +void emu_halt(); + +typedef struct +{ + s32 ARM9Cycle; + s32 ARM7Cycle; + s32 wifiCycle; + s32 cycles; + s32 timerCycle[2][4]; + BOOL timerOver[2][4]; + s32 nextHBlank; + u32 VCount; + u32 old; + s32 diff; + BOOL lignerendu; + + u16 touchX; + u16 touchY; + BOOL isTouch; + u16 pad; + + u8 *FW_ARM9BootCode; + u8 *FW_ARM7BootCode; + u32 FW_ARM9BootCodeAddr; + u32 FW_ARM7BootCodeAddr; + u32 FW_ARM9BootCodeSize; + u32 FW_ARM7BootCodeSize; + + BOOL sleeping; + + //this is not essential NDS runtime state. + //it was perhaps a mistake to put it here. + //it is far less important than the above. + //maybe I should move it. + s32 idleCycles; + s32 runCycleCollector[16]; + s32 idleFrameCounter; + + //if the game was booted on a debug console, this is set + BOOL debugConsole; + + bool isInVblank() const { return VCount >= 192; } + bool isIn3dVblank() const { return VCount >= 192 && VCount<215; } +} NDSSystem; + +/** /brief A touchscreen calibration point. + */ +struct NDS_fw_touchscreen_cal { + u16 adc_x; + u16 adc_y; + + u8 screen_x; + u8 screen_y; +}; + +/** /brief The type of DS + */ +enum nds_fw_ds_type { + NDS_FW_DS_TYPE_FAT, + NDS_FW_DS_TYPE_LITE, + NDS_FW_DS_TYPE_iQue +}; + +#define MAX_FW_NICKNAME_LENGTH 10 +#define MAX_FW_MESSAGE_LENGTH 26 + +struct NDS_fw_config_data { + enum nds_fw_ds_type ds_type; + + u8 fav_colour; + u8 birth_month; + u8 birth_day; + + u16 nickname[MAX_FW_NICKNAME_LENGTH]; + u8 nickname_len; + + u16 message[MAX_FW_MESSAGE_LENGTH]; + u8 message_len; + + u8 language; + + /* touchscreen calibration */ + struct NDS_fw_touchscreen_cal touch_cal[2]; +}; + +extern NDSSystem nds; + +#ifdef GDB_STUB +int NDS_Init( struct armcpu_memory_iface *arm9_mem_if, + struct armcpu_ctrl_iface **arm9_ctrl_iface, + struct armcpu_memory_iface *arm7_mem_if, + struct armcpu_ctrl_iface **arm7_ctrl_iface); +#else +int NDS_Init ( void); +#endif + +void Desmume_InitOnce(); + +void NDS_DeInit(void); +void +NDS_FillDefaultFirmwareConfigData( struct NDS_fw_config_data *fw_config); + +BOOL NDS_SetROM(u8 * rom, u32 mask); +NDS_header * NDS_getROMHeader(void); + +struct GameInfo +{ + GameInfo() + : romdata(NULL) + {} + + void resize(int size) { + if(romdata != NULL) delete[] romdata; + romdata = new char[size]; + romsize = size; + } + u32 crc; + NDS_header header; + char ROMserial[20]; + void populate(); + char* romdata; + int romsize; +}; + +extern GameInfo gameInfo; +void NDS_setTouchPos(u16 x, u16 y); +void NDS_releaseTouch(void); +void NDS_setPad(bool R,bool L,bool D,bool U,bool T,bool S,bool B,bool A,bool Y,bool X,bool W,bool E,bool G, bool F); +void NDS_setPadFromMovie(u16 pad); + +int NDS_LoadROM(const char *filename, const char* logicalFilename=0); +void NDS_FreeROM(void); +void NDS_Reset(); +int NDS_ImportSave(const char *filename); +bool NDS_ExportSave(const char *filename); + +int NDS_WriteBMP(const char *filename); +int NDS_LoadFirmware(const char *filename); +int NDS_CreateDummyFirmware( struct NDS_fw_config_data *user_settings); + +void NDS_Sleep(); + +void NDS_SkipNextFrame(); +#define NDS_SkipFrame(s) if(s) NDS_SkipNext2DFrame(); + +template void NDS_exec(s32 nb = 560190<<1); + +extern int lagframecounter; + +static INLINE void NDS_ARM9HBlankInt(void) +{ + if(T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0x10) + { + //MMU.reg_IF[0] |= 2;// & (MMU.reg_IME[0] << 1);// (MMU.reg_IE[0] & (1<<1)); + setIF(0, 2); + NDS_ARM9.wIRQ = TRUE; + } +} + +static INLINE void NDS_ARM7HBlankInt(void) +{ + if(T1ReadWord(MMU.ARM7_REG, 4) & 0x10) + { + // MMU.reg_IF[1] |= 2;// & (MMU.reg_IME[1] << 1);// (MMU.reg_IE[1] & (1<<1)); + setIF(1, 2); + NDS_ARM7.wIRQ = TRUE; + } +} + +static INLINE void NDS_ARM9VBlankInt(void) +{ + if(T1ReadWord(ARM9Mem.ARM9_REG, 4) & 0x8) + { + // MMU.reg_IF[0] |= 1;// & (MMU.reg_IME[0]);// (MMU.reg_IE[0] & 1); + setIF(0, 1); + NDS_ARM9.wIRQ = TRUE; + //emu_halt(); + /*logcount++;*/ + } +} + +static INLINE void NDS_ARM7VBlankInt(void) +{ + if(T1ReadWord(MMU.ARM7_REG, 4) & 0x8) + // MMU.reg_IF[1] |= 1;// & (MMU.reg_IME[1]);// (MMU.reg_IE[1] & 1); + setIF(1, 1); + NDS_ARM7.wIRQ = TRUE; + //emu_halt(); +} + +static INLINE void NDS_swapScreen(void) +{ + u16 tmp = MainScreen.offset; + MainScreen.offset = SubScreen.offset; + SubScreen.offset = tmp; +} + +int NDS_WriteBMP_32bppBuffer(int width, int height, const void* buf, const char *filename); + + + +extern struct TCommonSettings { + TCommonSettings() + : HighResolutionInterpolateColor(true) + , UseExtBIOS(false) + , SWIFromBIOS(false) + , UseExtFirmware(false) + , BootFromFirmware(false) + , DebugConsole(false) + , wifiBridgeAdapterNum(0) + , spuInterpolationMode(SPUInterpolation_Linear) + , spuAdpcmCache(false) + , gfx3d_flushMode(0) + , manualBackupType(0) + { + strcpy(ARM9BIOS, "biosnds9.bin"); + strcpy(ARM7BIOS, "biosnds7.bin"); + strcpy(Firmware, "firmware.bin"); + for(int i=0;i<16;i++) + spu_muteChannels[i] = false; + } + bool HighResolutionInterpolateColor; + + bool UseExtBIOS; + char ARM9BIOS[256]; + char ARM7BIOS[256]; + bool SWIFromBIOS; + + bool UseExtFirmware; + char Firmware[256]; + bool BootFromFirmware; + + bool DebugConsole; + + int wifiBridgeAdapterNum; + + SPUInterpolationMode spuInterpolationMode; + bool spuAdpcmCache; + + //this is a temporary hack until we straighten out the flushing logic and/or gxfifo + int gfx3d_flushMode; + + //this is the user's choice of manual backup type, for cases when the autodetection can't be trusted + int manualBackupType; + + bool spu_muteChannels[16]; + + struct _ShowGpu { + _ShowGpu() : main(true), sub(true) {} + union { + struct { bool main,sub; }; + bool screens[2]; + }; + } showGpu; + + struct _Hud { + _Hud() + : ShowInputDisplay(false) + , FpsDisplay(false) + , FrameCounterDisplay(false) + , ShowLagFrameCounter(false) + , ShowMicrophone(false) + {} + bool ShowInputDisplay, FpsDisplay, FrameCounterDisplay, ShowLagFrameCounter, ShowMicrophone; + } hud; + +} CommonSettings; + + +extern std::string InputDisplayString; +extern int LagFrameFlag; +extern int lastLag, TotalLagFrames; + +void MovieSRAM(); + +void ClearAutoHold(void); + +#endif + + diff --git a/desmume/src/OGLRender.cpp b/src/OGLRender.cpp similarity index 93% rename from desmume/src/OGLRender.cpp rename to src/OGLRender.cpp index 473db91b0..d5a230732 100644 --- a/desmume/src/OGLRender.cpp +++ b/src/OGLRender.cpp @@ -1,921 +1,897 @@ -/* - Copyright (C) 2006 yopyop - Copyright (C) 2006-2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -//problem - alpha-on-alpha texture rendering might work but the dest alpha buffer isnt tracked correctly -//due to zeromus not having any idea how to set dest alpha blending in opengl. -//so, it doesnt composite to 2d correctly. -//(re: new super mario brothers renders the stormclouds at the beginning) - -#include "OGLRender.h" -#include "debug.h" - -bool (*oglrender_init)() = 0; -bool (*oglrender_beginOpenGL)() = 0; -void (*oglrender_endOpenGL)() = 0; - -static bool BEGINGL() { - if(oglrender_beginOpenGL) - return oglrender_beginOpenGL(); - else return true; -} - -static void ENDGL() { - if(oglrender_endOpenGL) - oglrender_endOpenGL(); -} - -#ifdef _WIN32 - #define WIN32_LEAN_AND_MEAN - #include - #include - #include -#else -#ifdef DESMUME_COCOA - #include - #include -#else - #include - #include - /* This is a workaround needed to compile against nvidia GL headers */ - #ifndef GL_ALPHA_BLEND_EQUATION_ATI - #undef GL_VERSION_1_3 - #endif -#endif -#endif - -#include "types.h" -#include "debug.h" -#include "MMU.h" -#include "bits.h" -#include "matrix.h" -#include "NDSSystem.h" -#include "OGLRender.h" -#include "gfx3d.h" - -#include "shaders.h" -#include "texcache.h" - -static ALIGN(16) u8 GPU_screen3D [256*192*4]; - -static const unsigned short map3d_cull[4] = {GL_FRONT_AND_BACK, GL_FRONT, GL_BACK, 0}; -static const int texEnv[4] = { GL_MODULATE, GL_DECAL, GL_MODULATE, GL_MODULATE }; -static const int depthFunc[2] = { GL_LESS, GL_EQUAL }; - -//derived values extracted from polyattr etc -static bool wireframe=false, alpha31=false; -static unsigned int polyID=0; -static unsigned int depthFuncMode=0; -static unsigned int envMode=0; -static unsigned int lastEnvMode=0; -static unsigned int cullingMask=0; -static bool alphaDepthWrite; -static unsigned int lightMask=0; -static bool isTranslucent; - -static u32 textureFormat=0, texturePalette=0; - -//------------------------------------------------------------ - -#define OGLEXT(x,y) x y = 0; - -#ifdef _WIN32 -#define INITOGLEXT(x,y) y = (x)wglGetProcAddress(#y); -#elif !defined(DESMUME_COCOA) -#include -#define INITOGLEXT(x,y) y = (x)glXGetProcAddress((const GLubyte *) #y); -#endif - -#ifndef DESMUME_COCOA -OGLEXT(PFNGLCREATESHADERPROC,glCreateShader) -//zero: i dont understand this at all. my glext.h has the wrong thing declared here... so I have to do it myself -typedef void (APIENTRYP X_PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, const GLchar **source, GLsizei *length); -OGLEXT(X_PFNGLGETSHADERSOURCEPROC,glShaderSource) -OGLEXT(PFNGLCOMPILESHADERPROC,glCompileShader) -OGLEXT(PFNGLCREATEPROGRAMPROC,glCreateProgram) -OGLEXT(PFNGLATTACHSHADERPROC,glAttachShader) -OGLEXT(PFNGLDETACHSHADERPROC,glDetachShader) -OGLEXT(PFNGLLINKPROGRAMPROC,glLinkProgram) -OGLEXT(PFNGLUSEPROGRAMPROC,glUseProgram) -OGLEXT(PFNGLGETSHADERIVPROC,glGetShaderiv) -OGLEXT(PFNGLGETSHADERINFOLOGPROC,glGetShaderInfoLog) -OGLEXT(PFNGLDELETESHADERPROC,glDeleteShader) -OGLEXT(PFNGLDELETEPROGRAMPROC,glDeleteProgram) -OGLEXT(PFNGLGETPROGRAMIVPROC,glGetProgramiv) -OGLEXT(PFNGLGETPROGRAMINFOLOGPROC,glGetProgramInfoLog) -OGLEXT(PFNGLVALIDATEPROGRAMPROC,glValidateProgram) -OGLEXT(PFNGLBLENDFUNCSEPARATEEXTPROC,glBlendFuncSeparateEXT) -OGLEXT(PFNGLGETUNIFORMLOCATIONPROC,glGetUniformLocation) -OGLEXT(PFNGLUNIFORM1IPROC,glUniform1i) -OGLEXT(PFNGLUNIFORM1IVPROC,glUniform1iv) -#endif - -#if !defined(GL_VERSION_1_3) || defined(_MSC_VER) || defined(__INTEL_COMPILER) -OGLEXT(PFNGLACTIVETEXTUREPROC,glActiveTexture) -#endif - - -//opengl state caching: -//This is of dubious performance assistance, but it is easy to take out so I am leaving it for now. -//every function that is xgl* can be replaced with gl* if we decide to rip this out or if anyone else -//doesnt feel like sticking with it (or if it causes trouble) - -static void xglDepthFunc(GLenum func) { - static GLenum oldfunc = -1; - if(oldfunc == func) return; - glDepthFunc(oldfunc=func); -} - -static void xglPolygonMode(GLenum face,GLenum mode) { - static GLenum oldmodes[2] = {-1,-1}; - switch(face) { - case GL_FRONT: if(oldmodes[0]==mode) return; else glPolygonMode(GL_FRONT,oldmodes[0]=mode); return; - case GL_BACK: if(oldmodes[1]==mode) return; else glPolygonMode(GL_BACK,oldmodes[1]=mode); return; - case GL_FRONT_AND_BACK: if(oldmodes[0]==mode && oldmodes[1]==mode) return; else glPolygonMode(GL_FRONT_AND_BACK,oldmodes[0]=oldmodes[1]=mode); - } -} - -#if 0 -#ifdef _WIN32 -static void xglUseProgram(GLuint program) { - if(!glUseProgram) return; - static GLuint oldprogram = -1; - if(oldprogram==program) return; - glUseProgram(oldprogram=program); -} -#else -#if 0 /* not used */ -static void xglUseProgram(GLuint program) { - (void)program; - return; -} -#endif -#endif -#endif - -static void xglDepthMask (GLboolean flag) { - static GLboolean oldflag = -1; - if(oldflag==flag) return; - glDepthMask(oldflag=flag); -} - -struct GLCaps { - u8 caps[0x100]; - GLCaps() { - memset(caps,0xFF,sizeof(caps)); - } -}; -static GLCaps glcaps; - -static void _xglEnable(GLenum cap) { - cap -= 0x0B00; - if(glcaps.caps[cap] == 0xFF || glcaps.caps[cap] == 0) { - glEnable(cap+0x0B00); - glcaps.caps[cap] = 1; - } -} - -static void _xglDisable(GLenum cap) { - cap -= 0x0B00; - if(glcaps.caps[cap]) { - glDisable(cap+0x0B00); - glcaps.caps[cap] = 0; - } -} - -#define xglEnable(cap) { \ - CTASSERT((cap-0x0B00)<0x100); \ - _xglEnable(cap); } - -#define xglDisable(cap) {\ - CTASSERT((cap-0x0B00)<0x100); \ - _xglDisable(cap); } - - - -GLenum oglTempTextureID[MAX_TEXTURE]; -GLenum oglToonTableTextureID; - -#define NOSHADERS(s) { hasShaders = false; INFO("Shaders aren't supported on your system, using fixed pipeline\n(%s)\n", s); return; } - -#define SHADER_COMPCHECK(s, t) { \ - GLint status = GL_TRUE; \ - glGetShaderiv(s, GL_COMPILE_STATUS, &status); \ - if(status != GL_TRUE) \ - { \ - GLint logSize; \ - GLchar *log; \ - glGetShaderiv(s, GL_INFO_LOG_LENGTH, &logSize); \ - log = new GLchar[logSize]; \ - glGetShaderInfoLog(s, logSize, &logSize, log); \ - INFO("SEVERE : FAILED TO COMPILE GL SHADER : %s\n", log); \ - delete log; \ - if(s)glDeleteShader(s); \ - NOSHADERS("Failed to compile the "t" shader."); \ - } \ -} - -#define PROGRAM_COMPCHECK(p, s1, s2) { \ - GLint status = GL_TRUE; \ - glGetProgramiv(p, GL_LINK_STATUS, &status); \ - if(status != GL_TRUE) \ - { \ - GLint logSize; \ - GLchar *log; \ - glGetProgramiv(p, GL_INFO_LOG_LENGTH, &logSize); \ - log = new GLchar[logSize]; \ - glGetProgramInfoLog(p, logSize, &logSize, log); \ - INFO("SEVERE : FAILED TO LINK GL SHADER PROGRAM : %s\n", log); \ - delete log; \ - if(s1)glDeleteShader(s1); \ - if(s2)glDeleteShader(s2); \ - NOSHADERS("Failed to link the shader program."); \ - } \ -} - -bool hasShaders = false; - -/* Vertex shader */ -GLuint vertexShaderID; -/* Fragment shader */ -GLuint fragmentShaderID; -/* Shader program */ -GLuint shaderProgram; - -static GLuint hasTexLoc; -static GLuint texBlendLoc; -static bool hasTexture = false; - -/* Shaders init */ - -static void createShaders() -{ - hasShaders = true; - -#ifdef HAVE_LIBOSMESA - NOSHADERS("Shaders aren't supported by OSMesa."); -#endif - - /* This check is just plain wrong. */ - /* It will always pass if you've OpenGL 2.0 or later, */ - /* even if your GFX card doesn't support shaders. */ -/* if (glCreateShader == NULL || //use ==NULL instead of !func to avoid always true warnings for some systems - glShaderSource == NULL || - glCompileShader == NULL || - glCreateProgram == NULL || - glAttachShader == NULL || - glLinkProgram == NULL || - glUseProgram == NULL || - glGetShaderInfoLog == NULL) - NOSHADERS("Shaders aren't supported by your system.");*/ - - const char *extString = (const char*)glGetString(GL_EXTENSIONS); - if ((strstr(extString, "GL_ARB_shader_objects") == NULL) || - (strstr(extString, "GL_ARB_vertex_shader") == NULL) || - (strstr(extString, "GL_ARB_fragment_shader") == NULL)) - NOSHADERS("Shaders aren't supported by your system."); - - vertexShaderID = glCreateShader(GL_VERTEX_SHADER); - if(!vertexShaderID) - NOSHADERS("Failed to create the vertex shader."); - - glShaderSource(vertexShaderID, 1, (const GLchar**)&vertexShader, NULL); - glCompileShader(vertexShaderID); - SHADER_COMPCHECK(vertexShaderID, "vertex"); - - fragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER); - if(!fragmentShaderID) - NOSHADERS("Failed to create the fragment shader."); - - glShaderSource(fragmentShaderID, 1, (const GLchar**)&fragmentShader, NULL); - glCompileShader(fragmentShaderID); - SHADER_COMPCHECK(fragmentShaderID, "fragment"); - - shaderProgram = glCreateProgram(); - if(!shaderProgram) - NOSHADERS("Failed to create the shader program."); - - glAttachShader(shaderProgram, vertexShaderID); - glAttachShader(shaderProgram, fragmentShaderID); - - glLinkProgram(shaderProgram); - PROGRAM_COMPCHECK(shaderProgram, vertexShaderID, fragmentShaderID); - - glValidateProgram(shaderProgram); - glUseProgram(shaderProgram); - - INFO("Successfully created OpenGL shaders.\n"); -} - -//================================================= - -static void OGLReset() -{ - if(hasShaders) - { - glUniform1i(hasTexLoc, 0); - hasTexture = false; - glUniform1i(texBlendLoc, 0); - - } - - TexCache_Reset(); - - for (int i = 0; i < MAX_TEXTURE; i++) - texcache[i].id=oglTempTextureID[i]; - -// memset(GPU_screenStencil,0,sizeof(GPU_screenStencil)); - memset(GPU_screen3D,0,sizeof(GPU_screen3D)); -} - - - - -static void BindTexture(u32 tx) -{ - glBindTexture(GL_TEXTURE_2D,(GLuint)texcache[tx].id); - glMatrixMode (GL_TEXTURE); - glLoadIdentity (); - glScaled (texcache[tx].invSizeX, texcache[tx].invSizeY, 1.0f); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (BIT16(texcache[tx].frm) ? (BIT18(texcache[tx].frm)?GL_MIRRORED_REPEAT:GL_REPEAT) : GL_CLAMP)); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (BIT17(texcache[tx].frm) ? (BIT19(texcache[tx].frm)?GL_MIRRORED_REPEAT:GL_REPEAT) : GL_CLAMP)); -} - -static void BindTextureData(u32 tx, u8* data) -{ - BindTexture(tx); - -#if 0 - for (int i=0; i < texcache[tx].sizeX * texcache[tx].sizeY*4; i++) - data[i] = 0xFF; -#endif - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, - texcache[tx].sizeX, texcache[tx].sizeY, 0, - GL_RGBA, GL_UNSIGNED_BYTE, data); -} - - -static char OGLInit(void) -{ - GLuint loc = 0; - - if(!oglrender_init) - return 0; - if(!oglrender_init()) - return 0; - - if(!BEGINGL()) - return 0; - - TexCache_BindTexture = BindTexture; - TexCache_BindTextureData = BindTextureData; - glGenTextures (MAX_TEXTURE, &oglTempTextureID[0]); - - glPixelStorei(GL_PACK_ALIGNMENT,8); - - xglEnable (GL_NORMALIZE); - xglEnable (GL_DEPTH_TEST); - glEnable (GL_TEXTURE_1D); - glEnable (GL_TEXTURE_2D); - - glAlphaFunc (GL_GREATER, 0); - xglEnable (GL_ALPHA_TEST); - - glViewport(0, 0, 256, 192); - if (glGetError() != GL_NO_ERROR) - return 0; - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - -#ifndef DESMUME_COCOA - INITOGLEXT(PFNGLCREATESHADERPROC,glCreateShader) - INITOGLEXT(X_PFNGLGETSHADERSOURCEPROC,glShaderSource) - INITOGLEXT(PFNGLCOMPILESHADERPROC,glCompileShader) - INITOGLEXT(PFNGLCREATEPROGRAMPROC,glCreateProgram) - INITOGLEXT(PFNGLATTACHSHADERPROC,glAttachShader) - INITOGLEXT(PFNGLDETACHSHADERPROC,glDetachShader) - INITOGLEXT(PFNGLLINKPROGRAMPROC,glLinkProgram) - INITOGLEXT(PFNGLUSEPROGRAMPROC,glUseProgram) - INITOGLEXT(PFNGLGETSHADERIVPROC,glGetShaderiv) - INITOGLEXT(PFNGLGETSHADERINFOLOGPROC,glGetShaderInfoLog) - INITOGLEXT(PFNGLDELETESHADERPROC,glDeleteShader) - INITOGLEXT(PFNGLDELETEPROGRAMPROC,glDeleteProgram) - INITOGLEXT(PFNGLGETPROGRAMIVPROC,glGetProgramiv) - INITOGLEXT(PFNGLGETPROGRAMINFOLOGPROC,glGetProgramInfoLog) - INITOGLEXT(PFNGLVALIDATEPROGRAMPROC,glValidateProgram) -#ifdef HAVE_LIBOSMESA - glBlendFuncSeparateEXT = NULL; -#else - INITOGLEXT(PFNGLBLENDFUNCSEPARATEEXTPROC,glBlendFuncSeparateEXT) -#endif - INITOGLEXT(PFNGLGETUNIFORMLOCATIONPROC,glGetUniformLocation) - INITOGLEXT(PFNGLUNIFORM1IPROC,glUniform1i) - INITOGLEXT(PFNGLUNIFORM1IVPROC,glUniform1iv) -#endif -#if !defined(GL_VERSION_1_3) || defined(_MSC_VER) || defined(__INTEL_COMPILER) - INITOGLEXT(PFNGLACTIVETEXTUREPROC,glActiveTexture) -#endif - - /* Create the shaders */ - createShaders(); - - /* Assign the texture units : 0 for main textures, 1 for toon table */ - /* Also init the locations for some variables in the shaders */ - if(hasShaders) - { - loc = glGetUniformLocation(shaderProgram, "tex2d"); - glUniform1i(loc, 0); - - loc = glGetUniformLocation(shaderProgram, "toonTable"); - glUniform1i(loc, 1); - - hasTexLoc = glGetUniformLocation(shaderProgram, "hasTexture"); - - texBlendLoc = glGetUniformLocation(shaderProgram, "texBlending"); - } - - //we want to use alpha destination blending so we can track the last-rendered alpha value - if(glBlendFuncSeparateEXT != NULL) - { - glBlendFuncSeparateEXT(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_DST_ALPHA); - // glBlendFuncSeparateEXT(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - } - - if(hasShaders) - { - glGenTextures (1, &oglToonTableTextureID); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_1D, oglToonTableTextureID); - glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP); //clamp so that we dont run off the edges due to 1.0 -> [0,31] math - } - - OGLReset(); - - ENDGL(); - - return 1; -} - -static void OGLClose() -{ - if(!BEGINGL()) - return; - - if(hasShaders) - { - glUseProgram(0); - - glDetachShader(shaderProgram, vertexShaderID); - glDetachShader(shaderProgram, fragmentShaderID); - - glDeleteProgram(shaderProgram); - glDeleteShader(vertexShaderID); - glDeleteShader(fragmentShaderID); - - hasShaders = false; - } - - glDeleteTextures(MAX_TEXTURE, &oglTempTextureID[0]); - glDeleteTextures(1, &oglToonTableTextureID); - - ENDGL(); -} - -static void setTexture(unsigned int format, unsigned int texpal) -{ - textureFormat = format; - texturePalette = texpal; - - u32 textureMode = (unsigned short)((format>>26)&0x07); - - if (format==0) - { - if(hasShaders && hasTexture) { glUniform1i(hasTexLoc, 0); hasTexture = false; } - return; - } - if (textureMode==0) - { - if(hasShaders && hasTexture) { glUniform1i(hasTexLoc, 0); hasTexture = false; } - return; - } - - if(hasShaders) - { - if(!hasTexture) { glUniform1i(hasTexLoc, 1); hasTexture = true; } - glActiveTexture(GL_TEXTURE0); - } - - - TexCache_SetTexture(format, texpal); -} - - - -//controls states: -//glStencilFunc -//glStencilOp -//glColorMask -static u32 stencilStateSet = -1; - -static u32 polyalpha=0; - -static void BeginRenderPoly() -{ - bool enableDepthWrite = true; - - xglDepthFunc (depthFuncMode); - - // Cull face - if (cullingMask != 0xC0) - { - xglEnable(GL_CULL_FACE); - glCullFace(map3d_cull[cullingMask>>6]); - } - else - xglDisable(GL_CULL_FACE); - - if (!wireframe) - { - xglPolygonMode (GL_FRONT_AND_BACK, GL_FILL); - } - else - { - xglPolygonMode (GL_FRONT_AND_BACK, GL_LINE); - } - - setTexture(textureFormat, texturePalette); - - if(isTranslucent) - enableDepthWrite = alphaDepthWrite; - - //handle shadow polys - if(envMode == 3) - { - xglEnable(GL_STENCIL_TEST); - if(polyID == 0) { - enableDepthWrite = false; - if(stencilStateSet!=0) { - stencilStateSet = 0; - //when the polyID is zero, we are writing the shadow mask. - //set stencilbuf = 1 where the shadow volume is obstructed by geometry. - //do not write color or depth information. - glStencilFunc(GL_ALWAYS,65,255); - glStencilOp(GL_KEEP,GL_REPLACE,GL_KEEP); - glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); - } - } else { - enableDepthWrite = true; - if(stencilStateSet!=1) { - stencilStateSet = 1; - //when the polyid is nonzero, we are drawing the shadow poly. - //only draw the shadow poly where the stencilbuf==1. - //I am not sure whether to update the depth buffer here--so I chose not to. - glStencilFunc(GL_EQUAL,65,255); - glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); - glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); - } - } - } else { - xglEnable(GL_STENCIL_TEST); - if(isTranslucent) - { - stencilStateSet = 3; - glStencilFunc(GL_NOTEQUAL,polyID,255); - glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE); - glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); - } - else - if(stencilStateSet!=2) { - stencilStateSet=2; - glStencilFunc(GL_ALWAYS,64,255); - glStencilOp(GL_REPLACE,GL_REPLACE,GL_REPLACE); - glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); - } - } - - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, texEnv[envMode]); - - if(hasShaders) - { - if(envMode != lastEnvMode) - { - lastEnvMode = envMode; - - int _envModes[4] = {0, 1, (2 + gfx3d.shading), 0}; - glUniform1i(texBlendLoc, _envModes[envMode]); - } - } - - xglDepthMask(enableDepthWrite?GL_TRUE:GL_FALSE); -} - -static void InstallPolygonAttrib(unsigned long val) -{ - // Light enable/disable - lightMask = (val&0xF); - - // texture environment - envMode = (val&0x30)>>4; - - // overwrite depth on alpha pass - alphaDepthWrite = BIT11(val)!=0; - - // depth test function - depthFuncMode = depthFunc[BIT14(val)]; - - // back face culling - cullingMask = (val&0xC0); - - alpha31 = ((val>>16)&0x1F)==31; - - // Alpha value, actually not well handled, 0 should be wireframe - wireframe = ((val>>16)&0x1F)==0; - - polyalpha = ((val>>16)&0x1F); - - // polyID - polyID = (val>>24)&0x3F; -} - -static void Control() -{ - if(gfx3d.enableTexturing) glEnable (GL_TEXTURE_2D); - else glDisable (GL_TEXTURE_2D); - - if(gfx3d.enableAlphaTest) - glAlphaFunc (GL_GREATER, gfx3d.alphaTestRef/31.f); - else - glAlphaFunc (GL_GREATER, 0); - - if(gfx3d.enableAlphaBlending) - { - glEnable (GL_BLEND); - } - else - { - glDisable (GL_BLEND); - } -} - - -static void GL_ReadFramebuffer() -{ - if(!BEGINGL()) return; - glFinish(); -// glReadPixels(0,0,256,192,GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, GPU_screenStencil); - glReadPixels(0,0,256,192,GL_BGRA_EXT, GL_UNSIGNED_BYTE, GPU_screen3D); - ENDGL(); - - //convert the pixels to a different format which is more convenient - //is it safe to modify the screen buffer? if not, we could make a temp copy - for(int i=0,y=191;y>=0;y--) - { - u8* dst = gfx3d_convertedScreen + (y<<(8+2)); - - for(int x=0;x<256;x++,i++) - { - u32 &u32screen3D = ((u32*)GPU_screen3D)[i]; - u32screen3D>>=2; - u32screen3D &= 0x3F3F3F3F; - - const int t = i<<2; - const u8 a = GPU_screen3D[t+3] >> 1; - const u8 r = GPU_screen3D[t+2]; - const u8 g = GPU_screen3D[t+1]; - const u8 b = GPU_screen3D[t+0]; - *dst++ = r; - *dst++ = g; - *dst++ = b; - *dst++ = a; - } - } - -#if 0 - //convert the pixels to a different format which is more convenient - //is it safe to modify the screen buffer? if not, we could make a temp copy - for(int i=0,y=191;y>=0;y--) - { - u16* dst = gfx3d_convertedScreen + (y<<8); - u8* dstAlpha = gfx3d_convertedAlpha + (y<<8); - - //I dont know much about this kind of stuff, but this seems to help - //for some reason I couldnt make the intrinsics work - //u8* u8screen3D = (u8*)&((u32*)GPU_screen3D)[i]; - /*#define PREFETCH32(X,Y) __asm { prefetchnta [u8screen3D+32*0x##X##Y] } - #define PREFETCH128(X) PREFETCH32(X,0) PREFETCH32(X,1) PREFETCH32(X,2) PREFETCH32(X,3) \ - PREFETCH32(X,4) PREFETCH32(X,5) PREFETCH32(X,6) PREFETCH32(X,7) \ - PREFETCH32(X,8) PREFETCH32(X,9) PREFETCH32(X,A) PREFETCH32(X,B) \ - PREFETCH32(X,C) PREFETCH32(X,D) PREFETCH32(X,E) PREFETCH32(X,F) - PREFETCH128(0); PREFETCH128(1);*/ - - for(int x=0;x<256;x++,i++) - { - u32 &u32screen3D = ((u32*)GPU_screen3D)[i]; - u32screen3D>>=3; - u32screen3D &= 0x1F1F1F1F; - - const int t = i<<2; - const u8 a = GPU_screen3D[t+3]; - const u8 r = GPU_screen3D[t+2]; - const u8 g = GPU_screen3D[t+1]; - const u8 b = GPU_screen3D[t+0]; - dst[x] = R5G5B5TORGB15(r,g,b) | alpha_lookup[a]; - dstAlpha[x] = a; - } - } -#endif -} - - -static void OGLRender() -{ - if(!BEGINGL()) return; - - Control(); - - if(hasShaders) - { - //TODO - maybe this should only happen if the toon table is stale (for a slight speedup) - - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_1D, oglToonTableTextureID); - - //generate a 8888 toon table from the ds format one and store it in a texture - u32 rgbToonTable[32]; - for(int i=0;i<32;i++) rgbToonTable[i] = RGB15TO32(gfx3d.u16ToonTable[i], 255); - glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbToonTable); - } - - xglDepthMask(GL_TRUE); - - float clearColor[4] = { - ((float)(gfx3d.clearColor&0x1F))/31.0f, - ((float)((gfx3d.clearColor>>5)&0x1F))/31.0f, - ((float)((gfx3d.clearColor>>10)&0x1F))/31.0f, - ((float)((gfx3d.clearColor>>16)&0x1F))/31.0f, - }; - glClearColor(clearColor[0],clearColor[1],clearColor[2],clearColor[3]); - glClearDepth(gfx3d.clearDepth); - glClearStencil((gfx3d.clearColor >> 24) & 0x3F); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - - //render display list - //TODO - properly doublebuffer the display lists - { - - u32 lastTextureFormat = 0, lastTexturePalette = 0, lastPolyAttr = 0, lastViewport = 0xFFFFFFFF; - // int lastProjIndex = -1; - - for(int i=0;icount;i++) { - POLY *poly = &gfx3d.polylist->list[gfx3d.indexlist[i]]; - int type = poly->type; - - //a very macro-level state caching approach: - //these are the only things which control the GPU rendering state. - if(i==0 || lastTextureFormat != poly->texParam || lastTexturePalette != poly->texPalette || lastPolyAttr != poly->polyAttr) - { - isTranslucent = poly->isTranslucent(); - InstallPolygonAttrib(lastPolyAttr=poly->polyAttr); - lastTextureFormat = textureFormat = poly->texParam; - lastTexturePalette = texturePalette = poly->texPalette; - lastPolyAttr = poly->polyAttr; - BeginRenderPoly(); - } - - //since we havent got the whole pipeline working yet, lets use opengl for the projection - /* if(lastProjIndex != poly->projIndex) { - glMatrixMode(GL_PROJECTION); - glLoadMatrixf(gfx3d.projlist->projMatrix[poly->projIndex]); - lastProjIndex = poly->projIndex; - }*/ - - /* glBegin(type==3?GL_TRIANGLES:GL_QUADS); - for(int j=0;jlist[poly->vertIndexes[j]]; - u8 color[4] = { - material_5bit_to_8bit[vert->color[0]], - material_5bit_to_8bit[vert->color[1]], - material_5bit_to_8bit[vert->color[2]], - material_5bit_to_8bit[vert->color[3]] - }; - - //float tempCoord[4]; - //Vector4Copy(tempCoord, vert->coord); - //we havent got the whole pipeline working yet, so we cant do this - ////convert from ds device coords to opengl - //tempCoord[0] *= 2; - //tempCoord[1] *= 2; - //tempCoord[0] -= 1; - //tempCoord[1] -= 1; - - //todo - edge flag? - glTexCoord2fv(vert->texcoord); - glColor4ubv((GLubyte*)color); - //glVertex4fv(tempCoord); - glVertex4fv(vert->coord); - } - glEnd();*/ - - if(lastViewport != poly->viewport) - { - VIEWPORT viewport; - viewport.decode(poly->viewport); - glViewport(viewport.x,viewport.y,viewport.width,viewport.height); - lastViewport = poly->viewport; - } - - glBegin(GL_TRIANGLES); - - VERT *vert0 = &gfx3d.vertlist->list[poly->vertIndexes[0]]; - u8 alpha = material_5bit_to_8bit[poly->getAlpha()]; - if(wireframe) alpha = 255; - u8 color0[4] = { - vert0->color[0]<<2, - vert0->color[1]<<2, - vert0->color[2]<<2, - alpha - }; - - //this draws things as a fan to prepare for the day when the clipping is done in gfx3d - //and funny shaped polys find their way into here. - //of course it could really be drawn as a fan, i suppose.. i dont remember why we did it this way - for(int j = 1; j < (type-1); j++) - { - VERT *vert1 = &gfx3d.vertlist->list[poly->vertIndexes[j]]; - VERT *vert2 = &gfx3d.vertlist->list[poly->vertIndexes[j+1]]; - - u8 color1[4] = { - vert1->color[0]<<2, - vert1->color[1]<<2, - vert1->color[2]<<2, - alpha - }; - u8 color2[4] = { - vert2->color[0]<<2, - vert2->color[1]<<2, - vert2->color[2]<<2, - alpha - }; - - glTexCoord2fv(vert0->texcoord); - glColor4ubv((GLubyte*)color0); - glVertex4fv(vert0->coord); - - glTexCoord2fv(vert1->texcoord); - glColor4ubv((GLubyte*)color1); - glVertex4fv(vert1->coord); - - glTexCoord2fv(vert2->texcoord); - glColor4ubv((GLubyte*)color2); - glVertex4fv(vert2->coord); - } - - glEnd(); - } - } - - ENDGL(); - - GL_ReadFramebuffer(); -} - -static void OGLVramReconfigureSignal() -{ - TexCache_Invalidate(); -} - -GPU3DInterface gpu3Dgl = { - "OpenGL", - OGLInit, - OGLReset, - OGLClose, - OGLRender, - OGLVramReconfigureSignal, -}; +/* + Copyright (C) 2006 yopyop + Copyright (C) 2006-2007 shash + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +//problem - alpha-on-alpha texture rendering might work but the dest alpha buffer isnt tracked correctly +//due to zeromus not having any idea how to set dest alpha blending in opengl. +//so, it doesnt composite to 2d correctly. +//(re: new super mario brothers renders the stormclouds at the beginning) + +#include "OGLRender.h" +#include "debug.h" + +bool (*oglrender_init)() = 0; +bool (*oglrender_beginOpenGL)() = 0; +void (*oglrender_endOpenGL)() = 0; + +static bool BEGINGL() { + if(oglrender_beginOpenGL) + return oglrender_beginOpenGL(); + else return true; +} + +static void ENDGL() { + if(oglrender_endOpenGL) + oglrender_endOpenGL(); +} + +#ifdef _WIN32 + #define WIN32_LEAN_AND_MEAN + #include + #include + #include +#else +#ifdef DESMUME_COCOA + #include + #include +#else + #include + #include + /* This is a workaround needed to compile against nvidia GL headers */ + #ifndef GL_ALPHA_BLEND_EQUATION_ATI + #undef GL_VERSION_1_3 + #endif +#endif +#endif + +#include "types.h" +#include "debug.h" +#include "MMU.h" +#include "bits.h" +#include "matrix.h" +#include "NDSSystem.h" +#include "OGLRender.h" +#include "gfx3d.h" + +#include "shaders.h" +#include "texcache.h" + + + +#ifndef CTASSERT +#define CTASSERT(x) typedef char __assert ## y[(x) ? 1 : -1] +#endif + +static ALIGN(16) u8 GPU_screen3D [256*192*4]; + + +static const unsigned short map3d_cull[4] = {GL_FRONT_AND_BACK, GL_FRONT, GL_BACK, 0}; +static const int texEnv[4] = { GL_MODULATE, GL_DECAL, GL_MODULATE, GL_MODULATE }; +static const int depthFunc[2] = { GL_LESS, GL_EQUAL }; + +//derived values extracted from polyattr etc +static bool wireframe=false, alpha31=false; +static unsigned int polyID=0; +static unsigned int depthFuncMode=0; +static unsigned int envMode=0; +static unsigned int lastEnvMode=0; +static unsigned int cullingMask=0; +static bool alphaDepthWrite; +static unsigned int lightMask=0; +static bool isTranslucent; + +static u32 textureFormat=0, texturePalette=0; + +//------------------------------------------------------------ + +#define OGLEXT(x,y) x y = 0; + +#ifdef _WIN32 +#define INITOGLEXT(x,y) y = (x)wglGetProcAddress(#y); +#elif !defined(DESMUME_COCOA) +#include +#define INITOGLEXT(x,y) y = (x)glXGetProcAddress((const GLubyte *) #y); +#endif + +#ifndef DESMUME_COCOA +OGLEXT(PFNGLCREATESHADERPROC,glCreateShader) +//zero: i dont understand this at all. my glext.h has the wrong thing declared here... so I have to do it myself +typedef void (APIENTRYP X_PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, const GLchar **source, GLsizei *length); +OGLEXT(X_PFNGLGETSHADERSOURCEPROC,glShaderSource) +OGLEXT(PFNGLCOMPILESHADERPROC,glCompileShader) +OGLEXT(PFNGLCREATEPROGRAMPROC,glCreateProgram) +OGLEXT(PFNGLATTACHSHADERPROC,glAttachShader) +OGLEXT(PFNGLDETACHSHADERPROC,glDetachShader) +OGLEXT(PFNGLLINKPROGRAMPROC,glLinkProgram) +OGLEXT(PFNGLUSEPROGRAMPROC,glUseProgram) +OGLEXT(PFNGLGETSHADERIVPROC,glGetShaderiv) +OGLEXT(PFNGLGETSHADERINFOLOGPROC,glGetShaderInfoLog) +OGLEXT(PFNGLDELETESHADERPROC,glDeleteShader) +OGLEXT(PFNGLDELETEPROGRAMPROC,glDeleteProgram) +OGLEXT(PFNGLGETPROGRAMIVPROC,glGetProgramiv) +OGLEXT(PFNGLGETPROGRAMINFOLOGPROC,glGetProgramInfoLog) +OGLEXT(PFNGLVALIDATEPROGRAMPROC,glValidateProgram) +OGLEXT(PFNGLBLENDFUNCSEPARATEEXTPROC,glBlendFuncSeparateEXT) +OGLEXT(PFNGLGETUNIFORMLOCATIONPROC,glGetUniformLocation) +OGLEXT(PFNGLUNIFORM1IPROC,glUniform1i) +OGLEXT(PFNGLUNIFORM1IVPROC,glUniform1iv) +#endif + +#if !defined(GL_VERSION_1_3) || defined(_MSC_VER) || defined(__INTEL_COMPILER) +OGLEXT(PFNGLACTIVETEXTUREPROC,glActiveTexture) +#endif + + +//opengl state caching: +//This is of dubious performance assistance, but it is easy to take out so I am leaving it for now. +//every function that is xgl* can be replaced with gl* if we decide to rip this out or if anyone else +//doesnt feel like sticking with it (or if it causes trouble) + +static void xglDepthFunc(GLenum func) { + static GLenum oldfunc = -1; + if(oldfunc == func) return; + glDepthFunc(oldfunc=func); +} + +static void xglPolygonMode(GLenum face,GLenum mode) { + static GLenum oldmodes[2] = {-1,-1}; + switch(face) { + case GL_FRONT: if(oldmodes[0]==mode) return; else glPolygonMode(GL_FRONT,oldmodes[0]=mode); return; + case GL_BACK: if(oldmodes[1]==mode) return; else glPolygonMode(GL_BACK,oldmodes[1]=mode); return; + case GL_FRONT_AND_BACK: if(oldmodes[0]==mode && oldmodes[1]==mode) return; else glPolygonMode(GL_FRONT_AND_BACK,oldmodes[0]=oldmodes[1]=mode); + } +} + +#if 0 +#ifdef _WIN32 +static void xglUseProgram(GLuint program) { + if(!glUseProgram) return; + static GLuint oldprogram = -1; + if(oldprogram==program) return; + glUseProgram(oldprogram=program); +} +#else +#if 0 /* not used */ +static void xglUseProgram(GLuint program) { + (void)program; + return; +} +#endif +#endif +#endif + +static void xglDepthMask (GLboolean flag) { + static GLboolean oldflag = -1; + if(oldflag==flag) return; + glDepthMask(oldflag=flag); +} + +struct GLCaps { + u8 caps[0x100]; + GLCaps() { + memset(caps,0xFF,sizeof(caps)); + } +}; +static GLCaps glcaps; + +static void _xglEnable(GLenum cap) { + cap -= 0x0B00; + if(glcaps.caps[cap] == 0xFF || glcaps.caps[cap] == 0) { + glEnable(cap+0x0B00); + glcaps.caps[cap] = 1; + } +} + +static void _xglDisable(GLenum cap) { + cap -= 0x0B00; + if(glcaps.caps[cap]) { + glDisable(cap+0x0B00); + glcaps.caps[cap] = 0; + } +} + +#define xglEnable(cap) { \ + CTASSERT((cap-0x0B00)<0x100); \ + _xglEnable(cap); } + +#define xglDisable(cap) {\ + CTASSERT((cap-0x0B00)<0x100); \ + _xglDisable(cap); } + + + +GLenum oglTempTextureID[MAX_TEXTURE]; +GLenum oglToonTableTextureID; + +#define NOSHADERS(s) { hasShaders = false; INFO("Shaders aren't supported on your system, using fixed pipeline\n(%s)\n", s); return; } + +#define SHADER_COMPCHECK(s, t) { \ + GLint status = GL_TRUE; \ + glGetShaderiv(s, GL_COMPILE_STATUS, &status); \ + if(status != GL_TRUE) \ + { \ + GLint logSize; \ + GLchar *log; \ + glGetShaderiv(s, GL_INFO_LOG_LENGTH, &logSize); \ + log = new GLchar[logSize]; \ + glGetShaderInfoLog(s, logSize, &logSize, log); \ + INFO("SEVERE : FAILED TO COMPILE GL SHADER : %s\n", log); \ + delete log; \ + if(s)glDeleteShader(s); \ + NOSHADERS("Failed to compile the "t" shader."); \ + } \ +} + +#define PROGRAM_COMPCHECK(p, s1, s2) { \ + GLint status = GL_TRUE; \ + glGetProgramiv(p, GL_LINK_STATUS, &status); \ + if(status != GL_TRUE) \ + { \ + GLint logSize; \ + GLchar *log; \ + glGetProgramiv(p, GL_INFO_LOG_LENGTH, &logSize); \ + log = new GLchar[logSize]; \ + glGetProgramInfoLog(p, logSize, &logSize, log); \ + INFO("SEVERE : FAILED TO LINK GL SHADER PROGRAM : %s\n", log); \ + delete log; \ + if(s1)glDeleteShader(s1); \ + if(s2)glDeleteShader(s2); \ + NOSHADERS("Failed to link the shader program."); \ + } \ +} + +bool hasShaders = false; + +/* Vertex shader */ +GLuint vertexShaderID; +/* Fragment shader */ +GLuint fragmentShaderID; +/* Shader program */ +GLuint shaderProgram; + +static GLuint hasTexLoc; +static GLuint texBlendLoc; +static bool hasTexture = false; + +/* Shaders init */ + +static void createShaders() +{ + hasShaders = true; + +#ifdef HAVE_LIBOSMESA + NOSHADERS("Shaders aren't supported by OSMesa."); +#endif + + /* This check is just plain wrong. */ + /* It will always pass if you've OpenGL 2.0 or later, */ + /* even if your GFX card doesn't support shaders. */ +/* if (glCreateShader == NULL || //use ==NULL instead of !func to avoid always true warnings for some systems + glShaderSource == NULL || + glCompileShader == NULL || + glCreateProgram == NULL || + glAttachShader == NULL || + glLinkProgram == NULL || + glUseProgram == NULL || + glGetShaderInfoLog == NULL) + NOSHADERS("Shaders aren't supported by your system.");*/ + + const char *extString = (const char*)glGetString(GL_EXTENSIONS); + if ((strstr(extString, "GL_ARB_shader_objects") == NULL) || + (strstr(extString, "GL_ARB_vertex_shader") == NULL) || + (strstr(extString, "GL_ARB_fragment_shader") == NULL)) + NOSHADERS("Shaders aren't supported by your system."); + + vertexShaderID = glCreateShader(GL_VERTEX_SHADER); + if(!vertexShaderID) + NOSHADERS("Failed to create the vertex shader."); + + glShaderSource(vertexShaderID, 1, (const GLchar**)&vertexShader, NULL); + glCompileShader(vertexShaderID); + SHADER_COMPCHECK(vertexShaderID, "vertex"); + + fragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER); + if(!fragmentShaderID) + NOSHADERS("Failed to create the fragment shader."); + + glShaderSource(fragmentShaderID, 1, (const GLchar**)&fragmentShader, NULL); + glCompileShader(fragmentShaderID); + SHADER_COMPCHECK(fragmentShaderID, "fragment"); + + shaderProgram = glCreateProgram(); + if(!shaderProgram) + NOSHADERS("Failed to create the shader program."); + + glAttachShader(shaderProgram, vertexShaderID); + glAttachShader(shaderProgram, fragmentShaderID); + + glLinkProgram(shaderProgram); + PROGRAM_COMPCHECK(shaderProgram, vertexShaderID, fragmentShaderID); + + glValidateProgram(shaderProgram); + glUseProgram(shaderProgram); + + INFO("Successfully created OpenGL shaders.\n"); +} + +//================================================= + +static void OGLReset() +{ + if(hasShaders) + { + glUniform1i(hasTexLoc, 0); + hasTexture = false; + glUniform1i(texBlendLoc, 0); + + } + + TexCache_Reset(); + + for (int i = 0; i < MAX_TEXTURE; i++) + texcache[i].id=oglTempTextureID[i]; + +// memset(GPU_screenStencil,0,sizeof(GPU_screenStencil)); + memset(GPU_screen3D,0,sizeof(GPU_screen3D)); +} + + + + +static void BindTexture(u32 tx) +{ + glBindTexture(GL_TEXTURE_2D,(GLuint)texcache[tx].id); + glMatrixMode (GL_TEXTURE); + glLoadIdentity (); + glScaled (texcache[tx].invSizeX, texcache[tx].invSizeY, 1.0f); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (BIT16(texcache[tx].frm) ? (BIT18(texcache[tx].frm)?GL_MIRRORED_REPEAT:GL_REPEAT) : GL_CLAMP)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (BIT17(texcache[tx].frm) ? (BIT19(texcache[tx].frm)?GL_MIRRORED_REPEAT:GL_REPEAT) : GL_CLAMP)); +} + +static void BindTextureData(u32 tx, u8* data) +{ + BindTexture(tx); + +#if 0 + for (int i=0; i < texcache[tx].sizeX * texcache[tx].sizeY*4; i++) + data[i] = 0xFF; +#endif + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, + texcache[tx].sizeX, texcache[tx].sizeY, 0, + GL_RGBA, GL_UNSIGNED_BYTE, data); +} + + +static char OGLInit(void) +{ + GLuint loc = 0; + + if(!oglrender_init) + return 0; + if(!oglrender_init()) + return 0; + + if(!BEGINGL()) + return 0; + + TexCache_BindTexture = BindTexture; + TexCache_BindTextureData = BindTextureData; + glGenTextures (MAX_TEXTURE, &oglTempTextureID[0]); + + glPixelStorei(GL_PACK_ALIGNMENT,8); + + xglEnable (GL_NORMALIZE); + xglEnable (GL_DEPTH_TEST); + glEnable (GL_TEXTURE_1D); + glEnable (GL_TEXTURE_2D); + + glAlphaFunc (GL_GREATER, 0); + xglEnable (GL_ALPHA_TEST); + + glViewport(0, 0, 256, 192); + if (glGetError() != GL_NO_ERROR) + return 0; + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + +#ifndef DESMUME_COCOA + INITOGLEXT(PFNGLCREATESHADERPROC,glCreateShader) + INITOGLEXT(X_PFNGLGETSHADERSOURCEPROC,glShaderSource) + INITOGLEXT(PFNGLCOMPILESHADERPROC,glCompileShader) + INITOGLEXT(PFNGLCREATEPROGRAMPROC,glCreateProgram) + INITOGLEXT(PFNGLATTACHSHADERPROC,glAttachShader) + INITOGLEXT(PFNGLDETACHSHADERPROC,glDetachShader) + INITOGLEXT(PFNGLLINKPROGRAMPROC,glLinkProgram) + INITOGLEXT(PFNGLUSEPROGRAMPROC,glUseProgram) + INITOGLEXT(PFNGLGETSHADERIVPROC,glGetShaderiv) + INITOGLEXT(PFNGLGETSHADERINFOLOGPROC,glGetShaderInfoLog) + INITOGLEXT(PFNGLDELETESHADERPROC,glDeleteShader) + INITOGLEXT(PFNGLDELETEPROGRAMPROC,glDeleteProgram) + INITOGLEXT(PFNGLGETPROGRAMIVPROC,glGetProgramiv) + INITOGLEXT(PFNGLGETPROGRAMINFOLOGPROC,glGetProgramInfoLog) + INITOGLEXT(PFNGLVALIDATEPROGRAMPROC,glValidateProgram) +#ifdef HAVE_LIBOSMESA + glBlendFuncSeparateEXT = NULL; +#else + INITOGLEXT(PFNGLBLENDFUNCSEPARATEEXTPROC,glBlendFuncSeparateEXT) +#endif + INITOGLEXT(PFNGLGETUNIFORMLOCATIONPROC,glGetUniformLocation) + INITOGLEXT(PFNGLUNIFORM1IPROC,glUniform1i) + INITOGLEXT(PFNGLUNIFORM1IVPROC,glUniform1iv) +#endif +#if !defined(GL_VERSION_1_3) || defined(_MSC_VER) || defined(__INTEL_COMPILER) + INITOGLEXT(PFNGLACTIVETEXTUREPROC,glActiveTexture) +#endif + + /* Create the shaders */ + createShaders(); + + /* Assign the texture units : 0 for main textures, 1 for toon table */ + /* Also init the locations for some variables in the shaders */ + if(hasShaders) + { + loc = glGetUniformLocation(shaderProgram, "tex2d"); + glUniform1i(loc, 0); + + loc = glGetUniformLocation(shaderProgram, "toonTable"); + glUniform1i(loc, 1); + + hasTexLoc = glGetUniformLocation(shaderProgram, "hasTexture"); + + texBlendLoc = glGetUniformLocation(shaderProgram, "texBlending"); + } + + //we want to use alpha destination blending so we can track the last-rendered alpha value + if(glBlendFuncSeparateEXT != NULL) + { + glBlendFuncSeparateEXT(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_DST_ALPHA); + // glBlendFuncSeparateEXT(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + } + + if(hasShaders) + { + glGenTextures (1, &oglToonTableTextureID); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_1D, oglToonTableTextureID); + glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP); //clamp so that we dont run off the edges due to 1.0 -> [0,31] math + } + + OGLReset(); + + ENDGL(); + + return 1; +} + +static void OGLClose() +{ + if(!BEGINGL()) + return; + + if(hasShaders) + { + glUseProgram(0); + + glDetachShader(shaderProgram, vertexShaderID); + glDetachShader(shaderProgram, fragmentShaderID); + + glDeleteProgram(shaderProgram); + glDeleteShader(vertexShaderID); + glDeleteShader(fragmentShaderID); + + hasShaders = false; + } + + glDeleteTextures(MAX_TEXTURE, &oglTempTextureID[0]); + glDeleteTextures(1, &oglToonTableTextureID); + + ENDGL(); +} + +static void setTexture(unsigned int format, unsigned int texpal) +{ + textureFormat = format; + texturePalette = texpal; + + u32 textureMode = (unsigned short)((format>>26)&0x07); + + if (format==0) + { + if(hasShaders && hasTexture) { glUniform1i(hasTexLoc, 0); hasTexture = false; } + return; + } + if (textureMode==0) + { + if(hasShaders && hasTexture) { glUniform1i(hasTexLoc, 0); hasTexture = false; } + return; + } + + if(hasShaders) + { + if(!hasTexture) { glUniform1i(hasTexLoc, 1); hasTexture = true; } + glActiveTexture(GL_TEXTURE0); + } + + + TexCache_SetTexture(format, texpal); +} + + + +//controls states: +//glStencilFunc +//glStencilOp +//glColorMask +static u32 stencilStateSet = -1; + +static u32 polyalpha=0; + +static void BeginRenderPoly() +{ + bool enableDepthWrite = true; + + xglDepthFunc (depthFuncMode); + + // Cull face + if (cullingMask != 0xC0) + { + xglEnable(GL_CULL_FACE); + glCullFace(map3d_cull[cullingMask>>6]); + } + else + xglDisable(GL_CULL_FACE); + + if (!wireframe) + { + xglPolygonMode (GL_FRONT_AND_BACK, GL_FILL); + } + else + { + xglPolygonMode (GL_FRONT_AND_BACK, GL_LINE); + } + + setTexture(textureFormat, texturePalette); + + if(isTranslucent) + enableDepthWrite = alphaDepthWrite; + + //handle shadow polys + if(envMode == 3) + { + xglEnable(GL_STENCIL_TEST); + if(polyID == 0) { + enableDepthWrite = false; + if(stencilStateSet!=0) { + stencilStateSet = 0; + //when the polyID is zero, we are writing the shadow mask. + //set stencilbuf = 1 where the shadow volume is obstructed by geometry. + //do not write color or depth information. + glStencilFunc(GL_ALWAYS,65,255); + glStencilOp(GL_KEEP,GL_REPLACE,GL_KEEP); + glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); + } + } else { + enableDepthWrite = true; + if(stencilStateSet!=1) { + stencilStateSet = 1; + //when the polyid is nonzero, we are drawing the shadow poly. + //only draw the shadow poly where the stencilbuf==1. + //I am not sure whether to update the depth buffer here--so I chose not to. + glStencilFunc(GL_EQUAL,65,255); + glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); + glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); + } + } + } else { + xglEnable(GL_STENCIL_TEST); + if(isTranslucent) + { + stencilStateSet = 3; + glStencilFunc(GL_NOTEQUAL,polyID,255); + glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE); + glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); + } + else + if(stencilStateSet!=2) { + stencilStateSet=2; + glStencilFunc(GL_ALWAYS,64,255); + glStencilOp(GL_REPLACE,GL_REPLACE,GL_REPLACE); + glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); + } + } + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, texEnv[envMode]); + + if(hasShaders) + { + if(envMode != lastEnvMode) + { + lastEnvMode = envMode; + + int _envModes[4] = {0, 1, (2 + gfx3d.shading), 0}; + glUniform1i(texBlendLoc, _envModes[envMode]); + } + } + + xglDepthMask(enableDepthWrite?GL_TRUE:GL_FALSE); +} + +static void InstallPolygonAttrib(unsigned long val) +{ + // Light enable/disable + lightMask = (val&0xF); + + // texture environment + envMode = (val&0x30)>>4; + + // overwrite depth on alpha pass + alphaDepthWrite = BIT11(val)!=0; + + // depth test function + depthFuncMode = depthFunc[BIT14(val)]; + + // back face culling + cullingMask = (val&0xC0); + + alpha31 = ((val>>16)&0x1F)==31; + + // Alpha value, actually not well handled, 0 should be wireframe + wireframe = ((val>>16)&0x1F)==0; + + polyalpha = ((val>>16)&0x1F); + + // polyID + polyID = (val>>24)&0x3F; +} + +static void Control() +{ + if(gfx3d.enableTexturing) glEnable (GL_TEXTURE_2D); + else glDisable (GL_TEXTURE_2D); + + if(gfx3d.enableAlphaTest) + glAlphaFunc (GL_GREATER, gfx3d.alphaTestRef/31.f); + else + glAlphaFunc (GL_GREATER, 0); + + if(gfx3d.enableAlphaBlending) + { + glEnable (GL_BLEND); + } + else + { + glDisable (GL_BLEND); + } +} + + +static void GL_ReadFramebuffer() +{ + if(!BEGINGL()) return; + glFinish(); +// glReadPixels(0,0,256,192,GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, GPU_screenStencil); + glReadPixels(0,0,256,192,GL_BGRA_EXT, GL_UNSIGNED_BYTE, GPU_screen3D); + ENDGL(); + + //convert the pixels to a different format which is more convenient + //is it safe to modify the screen buffer? if not, we could make a temp copy + for(int i=0,y=191;y>=0;y--) + { + u16* dst = gfx3d_convertedScreen + (y<<8); + u8* dstAlpha = gfx3d_convertedAlpha + (y<<8); + + #ifndef NOSSE2 + //I dont know much about this kind of stuff, but this seems to help + //for some reason I couldnt make the intrinsics work + u8* wanx = (u8*)&((u32*)GPU_screen3D)[i]; + #define ASS(X,Y) __asm { prefetchnta [wanx+32*0x##X##Y] } + #define PUNK(X) ASS(X,0) ASS(X,1) ASS(X,2) ASS(X,3) ASS(X,4) ASS(X,5) ASS(X,6) ASS(X,7) ASS(X,8) ASS(X,9) ASS(X,A) ASS(X,B) ASS(X,C) ASS(X,D) ASS(X,E) ASS(X,F) + PUNK(0); PUNK(1); + #endif + + for(int x=0;x<256;x++,i++) + { + u32 &u32screen3D = ((u32*)GPU_screen3D)[i]; + u32screen3D>>=3; + u32screen3D &= 0x1F1F1F1F; + + const int t = i<<2; + const u8 a = GPU_screen3D[t+3]; + const u8 r = GPU_screen3D[t+2]; + const u8 g = GPU_screen3D[t+1]; + const u8 b = GPU_screen3D[t+0]; + dst[x] = R5G5B5TORGB15(r,g,b) | alpha_lookup[a]; + dstAlpha[x] = alpha_5bit_to_4bit[a]; + } + } +} + + +static void OGLRender() +{ + if(!BEGINGL()) return; + + Control(); + + if(hasShaders) + { + //TODO - maybe this should only happen if the toon table is stale (for a slight speedup) + + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_1D, oglToonTableTextureID); + + //generate a 8888 toon table from the ds format one and store it in a texture + u32 rgbToonTable[32]; + for(int i=0;i<32;i++) rgbToonTable[i] = RGB15TO32(gfx3d.u16ToonTable[i], 255); + glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgbToonTable); + } + + xglDepthMask(GL_TRUE); + + float clearColor[4] = { + ((float)(gfx3d.clearColor&0x1F))/31.0f, + ((float)((gfx3d.clearColor>>5)&0x1F))/31.0f, + ((float)((gfx3d.clearColor>>10)&0x1F))/31.0f, + ((float)((gfx3d.clearColor>>16)&0x1F))/31.0f, + }; + glClearColor(clearColor[0],clearColor[1],clearColor[2],clearColor[3]); + glClearDepth(gfx3d.clearDepth); + glClearStencil((gfx3d.clearColor >> 24) & 0x3F); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + + //render display list + //TODO - properly doublebuffer the display lists + { + + u32 lastTextureFormat = 0, lastTexturePalette = 0, lastPolyAttr = 0, lastViewport = 0xFFFFFFFF; + // int lastProjIndex = -1; + + for(int i=0;icount;i++) { + POLY *poly = &gfx3d.polylist->list[gfx3d.indexlist[i]]; + int type = poly->type; + + //a very macro-level state caching approach: + //these are the only things which control the GPU rendering state. + if(i==0 || lastTextureFormat != poly->texParam || lastTexturePalette != poly->texPalette || lastPolyAttr != poly->polyAttr) + { + isTranslucent = poly->isTranslucent(); + InstallPolygonAttrib(lastPolyAttr=poly->polyAttr); + lastTextureFormat = textureFormat = poly->texParam; + lastTexturePalette = texturePalette = poly->texPalette; + lastPolyAttr = poly->polyAttr; + BeginRenderPoly(); + } + + //since we havent got the whole pipeline working yet, lets use opengl for the projection + /* if(lastProjIndex != poly->projIndex) { + glMatrixMode(GL_PROJECTION); + glLoadMatrixf(gfx3d.projlist->projMatrix[poly->projIndex]); + lastProjIndex = poly->projIndex; + }*/ + + /* glBegin(type==3?GL_TRIANGLES:GL_QUADS); + for(int j=0;jlist[poly->vertIndexes[j]]; + u8 color[4] = { + material_5bit_to_8bit[vert->color[0]], + material_5bit_to_8bit[vert->color[1]], + material_5bit_to_8bit[vert->color[2]], + material_5bit_to_8bit[vert->color[3]] + }; + + //float tempCoord[4]; + //Vector4Copy(tempCoord, vert->coord); + //we havent got the whole pipeline working yet, so we cant do this + ////convert from ds device coords to opengl + //tempCoord[0] *= 2; + //tempCoord[1] *= 2; + //tempCoord[0] -= 1; + //tempCoord[1] -= 1; + + //todo - edge flag? + glTexCoord2fv(vert->texcoord); + glColor4ubv((GLubyte*)color); + //glVertex4fv(tempCoord); + glVertex4fv(vert->coord); + } + glEnd();*/ + + if(lastViewport != poly->viewport) + { + VIEWPORT viewport; + viewport.decode(poly->viewport); + glViewport(viewport.x,viewport.y,viewport.width,viewport.height); + lastViewport = poly->viewport; + } + + glBegin(GL_TRIANGLES); + + VERT *vert0 = &gfx3d.vertlist->list[poly->vertIndexes[0]]; + u8 alpha = material_5bit_to_8bit[poly->getAlpha()]; + u8 color0[4] = { + material_5bit_to_8bit[vert0->color[0]], + material_5bit_to_8bit[vert0->color[1]], + material_5bit_to_8bit[vert0->color[2]], + alpha + }; + + for(int j = 1; j < (type-1); j++) + { + VERT *vert1 = &gfx3d.vertlist->list[poly->vertIndexes[j]]; + VERT *vert2 = &gfx3d.vertlist->list[poly->vertIndexes[j+1]]; + + u8 color1[4] = { + material_5bit_to_8bit[vert1->color[0]], + material_5bit_to_8bit[vert1->color[1]], + material_5bit_to_8bit[vert1->color[2]], + alpha + }; + u8 color2[4] = { + material_5bit_to_8bit[vert2->color[0]], + material_5bit_to_8bit[vert2->color[1]], + material_5bit_to_8bit[vert2->color[2]], + alpha + }; + + glTexCoord2fv(vert0->texcoord); + glColor4ubv((GLubyte*)color0); + glVertex4fv(vert0->coord); + + glTexCoord2fv(vert1->texcoord); + glColor4ubv((GLubyte*)color1); + glVertex4fv(vert1->coord); + + glTexCoord2fv(vert2->texcoord); + glColor4ubv((GLubyte*)color2); + glVertex4fv(vert2->coord); + } + + glEnd(); + } + } + + ENDGL(); + + GL_ReadFramebuffer(); +} + +static void OGLVramReconfigureSignal() +{ + TexCache_Invalidate(); +} + +GPU3DInterface gpu3Dgl = { + "OpenGL", + OGLInit, + OGLReset, + OGLClose, + OGLRender, + OGLVramReconfigureSignal, +}; diff --git a/desmume/src/OGLRender.h b/src/OGLRender.h similarity index 96% rename from desmume/src/OGLRender.h rename to src/OGLRender.h index 940b108a9..25cc93af4 100644 --- a/desmume/src/OGLRender.h +++ b/src/OGLRender.h @@ -1,48 +1,48 @@ -/* - Copyright (C) 2006 yopyop - Copyright (C) 2006-2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef OGLRENDER_H -#define OGLRENDER_H - -#include "common.h" -#include -#include -#include -#include -#include -#include "debug.h" -#include "render3D.h" - -extern GPU3DInterface gpu3Dgl; - -//This is called by OGLRender whenever it initializes. -//Platforms, please be sure to set this up. -//return true if you successfully init. -extern bool (*oglrender_init)(); - -//This is called by OGLRender before it uses opengl. -//return true if youre OK with using opengl -extern bool (*oglrender_beginOpenGL)(); - -//This is called by OGLRender after it is done using opengl. -extern void (*oglrender_endOpenGL)(); - -#endif +/* + Copyright (C) 2006 yopyop + Copyright (C) 2006-2007 shash + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef OGLRENDER_H +#define OGLRENDER_H + +#include "common.h" +#include +#include +#include +#include +#include +#include "debug.h" +#include "render3D.h" + +extern GPU3DInterface gpu3Dgl; + +//This is called by OGLRender whenever it initializes. +//Platforms, please be sure to set this up. +//return true if you successfully init. +extern bool (*oglrender_init)(); + +//This is called by OGLRender before it uses opengl. +//return true if youre OK with using opengl +extern bool (*oglrender_beginOpenGL)(); + +//This is called by OGLRender after it is done using opengl. +extern void (*oglrender_endOpenGL)(); + +#endif diff --git a/desmume/src/PACKED.h b/src/PACKED.h similarity index 94% rename from desmume/src/PACKED.h rename to src/PACKED.h index dabd31ce7..eaef0c7a4 100644 --- a/desmume/src/PACKED.h +++ b/src/PACKED.h @@ -1,12 +1,12 @@ -#ifndef __GNUC__ -#pragma pack(push, 1) -#pragma warning(disable : 4103) -#endif - -#ifndef __PACKED - #ifdef __GNUC__ - #define __PACKED __attribute__((__packed__)) - #else - #define __PACKED - #endif -#endif +#ifndef __GNUC__ +#pragma pack(push, 1) +#pragma warning(disable : 4103) +#endif + +#ifndef __PACKED + #ifdef __GNUC__ + #define __PACKED __attribute__((__packed__)) + #else + #define __PACKED + #endif +#endif diff --git a/desmume/src/PACKED_END.h b/src/PACKED_END.h similarity index 93% rename from desmume/src/PACKED_END.h rename to src/PACKED_END.h index 4c0798dd0..6eb7bd7c1 100644 --- a/desmume/src/PACKED_END.h +++ b/src/PACKED_END.h @@ -1,3 +1,3 @@ -#ifndef __GNUC__ -#pragma pack(pop) -#endif +#ifndef __GNUC__ +#pragma pack(pop) +#endif diff --git a/desmume/src/ROMReader.cpp b/src/ROMReader.cpp similarity index 95% rename from desmume/src/ROMReader.cpp rename to src/ROMReader.cpp index 66b8d8900..91bc02a61 100644 --- a/desmume/src/ROMReader.cpp +++ b/src/ROMReader.cpp @@ -1,236 +1,236 @@ -/* Copyright 2007 Guillaume Duhamel - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "ROMReader.h" - -#include -#include -#include -#ifdef HAVE_LIBZZIP -#include -#endif - -#ifdef WIN32 -#define stat(...) _stat(__VA_ARGS__) -#define S_IFMT _S_IFMT -#define S_IFREG _S_IFREG -#endif - -ROMReader_struct * ROMReaderInit(char ** filename) -{ -#ifdef HAVE_LIBZ - if(!strcasecmp(".gz", *filename + (strlen(*filename) - 3))) - { - (*filename)[strlen(*filename) - 3] = '\0'; - return &GZIPROMReader; - } -#endif -#ifdef HAVE_LIBZZIP - if (!strcasecmp(".zip", *filename + (strlen(*filename) - 4))) - { - (*filename)[strlen(*filename) - 4] = '\0'; - return &ZIPROMReader; - } -#endif - return &STDROMReader; -} - -void * STDROMReaderInit(const char * filename); -void STDROMReaderDeInit(void *); -u32 STDROMReaderSize(void *); -int STDROMReaderSeek(void *, int, int); -int STDROMReaderRead(void *, void *, u32); - -ROMReader_struct STDROMReader = -{ - ROMREADER_STD, - "Standard ROM Reader", - STDROMReaderInit, - STDROMReaderDeInit, - STDROMReaderSize, - STDROMReaderSeek, - STDROMReaderRead -}; - -void * STDROMReaderInit(const char * filename) -{ -#ifdef WIN32 - struct _stat sb; -#else - struct stat sb; -#endif - if (stat(filename, &sb) == -1) - return 0; - - if ((sb.st_mode & S_IFMT) != S_IFREG) - return 0; - - return (void *) fopen(filename, "rb"); -} - -void STDROMReaderDeInit(void * file) -{ - if (!file) return ; - fclose((FILE*)file); -} - -u32 STDROMReaderSize(void * file) -{ - u32 size; - - if (!file) return 0 ; - - fseek((FILE*)file, 0, SEEK_END); - size = ftell((FILE*)file); - fseek((FILE*)file, 0, SEEK_SET); - - return size; -} - -int STDROMReaderSeek(void * file, int offset, int whence) -{ - if (!file) return 0 ; - return fseek((FILE*)file, offset, whence); -} - -int STDROMReaderRead(void * file, void * buffer, u32 size) -{ - if (!file) return 0 ; - return fread(buffer, 1, size, (FILE*)file); -} - -#ifdef HAVE_LIBZ -void * GZIPROMReaderInit(const char * filename); -void GZIPROMReaderDeInit(void *); -u32 GZIPROMReaderSize(void *); -int GZIPROMReaderSeek(void *, int, int); -int GZIPROMReaderRead(void *, void *, u32); - -ROMReader_struct GZIPROMReader = -{ - ROMREADER_GZIP, - "Gzip ROM Reader", - GZIPROMReaderInit, - GZIPROMReaderDeInit, - GZIPROMReaderSize, - GZIPROMReaderSeek, - GZIPROMReaderRead -}; - -void * GZIPROMReaderInit(const char * filename) -{ - return (void*)gzopen(filename, "rb"); -} - -void GZIPROMReaderDeInit(void * file) -{ - gzclose(file); -} - -u32 GZIPROMReaderSize(void * file) -{ - char useless[1024]; - u32 size = 0; - - /* FIXME this function should first save the current - * position and restore it after size calculation */ - gzrewind(file); - while (gzeof (file) == 0) - size += gzread(file, useless, 1024); - gzrewind(file); - - return size; -} - -int GZIPROMReaderSeek(void * file, int offset, int whence) -{ - return gzseek(file, offset, whence); -} - -int GZIPROMReaderRead(void * file, void * buffer, u32 size) -{ - return gzread(file, buffer, size); -} -#endif - -#ifdef HAVE_LIBZZIP -void * ZIPROMReaderInit(const char * filename); -void ZIPROMReaderDeInit(void *); -u32 ZIPROMReaderSize(void *); -int ZIPROMReaderSeek(void *, int, int); -int ZIPROMReaderRead(void *, void *, u32); - -ROMReader_struct ZIPROMReader = -{ - ROMREADER_ZIP, - "Zip ROM Reader", - ZIPROMReaderInit, - ZIPROMReaderDeInit, - ZIPROMReaderSize, - ZIPROMReaderSeek, - ZIPROMReaderRead -}; - -void * ZIPROMReaderInit(const char * filename) -{ - ZZIP_DIR * dir = zzip_opendir(filename); - ZZIP_DIRENT * dirent = zzip_readdir(dir); - if (dir != NULL) - { - char tmp1[1024]; - char tmp2[1024]; - memset(tmp1,0,sizeof(tmp1)); - memset(tmp2,0,sizeof(tmp2)); - strncpy(tmp1, filename, strlen(filename) - 4); - sprintf(tmp2, "%s/%s", tmp1, dirent->d_name); - return zzip_fopen(tmp2, "rb"); - } - return NULL; -} - -void ZIPROMReaderDeInit(void * file) -{ - zzip_close((ZZIP_FILE*)file); -} - -u32 ZIPROMReaderSize(void * file) -{ - u32 size; - - zzip_seek((ZZIP_FILE*)file, 0, SEEK_END); - size = zzip_tell((ZZIP_FILE*)file); - zzip_seek((ZZIP_FILE*)file, 0, SEEK_SET); - - return size; -} - -int ZIPROMReaderSeek(void * file, int offset, int whence) -{ - return zzip_seek((ZZIP_FILE*)file, offset, whence); -} - -int ZIPROMReaderRead(void * file, void * buffer, u32 size) -{ -#ifdef ZZIP_OLD_READ - return zzip_read((ZZIP_FILE*)file, (char *) buffer, size); -#else - return zzip_read((ZZIP_FILE*)file, buffer, size); -#endif -} -#endif +/* Copyright 2007 Guillaume Duhamel + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "ROMReader.h" + +#include +#include +#include +#ifdef HAVE_LIBZZIP +#include +#endif + +#ifdef WIN32 +#define stat(...) _stat(__VA_ARGS__) +#define S_IFMT _S_IFMT +#define S_IFREG _S_IFREG +#endif + +ROMReader_struct * ROMReaderInit(char ** filename) +{ +#ifdef HAVE_LIBZ + if(!strcasecmp(".gz", *filename + (strlen(*filename) - 3))) + { + (*filename)[strlen(*filename) - 3] = '\0'; + return &GZIPROMReader; + } +#endif +#ifdef HAVE_LIBZZIP + if (!strcasecmp(".zip", *filename + (strlen(*filename) - 4))) + { + (*filename)[strlen(*filename) - 4] = '\0'; + return &ZIPROMReader; + } +#endif + return &STDROMReader; +} + +void * STDROMReaderInit(const char * filename); +void STDROMReaderDeInit(void *); +u32 STDROMReaderSize(void *); +int STDROMReaderSeek(void *, int, int); +int STDROMReaderRead(void *, void *, u32); + +ROMReader_struct STDROMReader = +{ + ROMREADER_STD, + "Standard ROM Reader", + STDROMReaderInit, + STDROMReaderDeInit, + STDROMReaderSize, + STDROMReaderSeek, + STDROMReaderRead +}; + +void * STDROMReaderInit(const char * filename) +{ +#ifdef WIN32 + struct _stat sb; +#else + struct stat sb; +#endif + if (stat(filename, &sb) == -1) + return 0; + + if ((sb.st_mode & S_IFMT) != S_IFREG) + return 0; + + return (void *) fopen(filename, "rb"); +} + +void STDROMReaderDeInit(void * file) +{ + if (!file) return ; + fclose((FILE*)file); +} + +u32 STDROMReaderSize(void * file) +{ + u32 size; + + if (!file) return 0 ; + + fseek((FILE*)file, 0, SEEK_END); + size = ftell((FILE*)file); + fseek((FILE*)file, 0, SEEK_SET); + + return size; +} + +int STDROMReaderSeek(void * file, int offset, int whence) +{ + if (!file) return 0 ; + return fseek((FILE*)file, offset, whence); +} + +int STDROMReaderRead(void * file, void * buffer, u32 size) +{ + if (!file) return 0 ; + return fread(buffer, 1, size, (FILE*)file); +} + +#ifdef HAVE_LIBZ +void * GZIPROMReaderInit(const char * filename); +void GZIPROMReaderDeInit(void *); +u32 GZIPROMReaderSize(void *); +int GZIPROMReaderSeek(void *, int, int); +int GZIPROMReaderRead(void *, void *, u32); + +ROMReader_struct GZIPROMReader = +{ + ROMREADER_GZIP, + "Gzip ROM Reader", + GZIPROMReaderInit, + GZIPROMReaderDeInit, + GZIPROMReaderSize, + GZIPROMReaderSeek, + GZIPROMReaderRead +}; + +void * GZIPROMReaderInit(const char * filename) +{ + return (void*)gzopen(filename, "rb"); +} + +void GZIPROMReaderDeInit(void * file) +{ + gzclose(file); +} + +u32 GZIPROMReaderSize(void * file) +{ + char useless[1024]; + u32 size = 0; + + /* FIXME this function should first save the current + * position and restore it after size calculation */ + gzrewind(file); + while (gzeof (file) == 0) + size += gzread(file, useless, 1024); + gzrewind(file); + + return size; +} + +int GZIPROMReaderSeek(void * file, int offset, int whence) +{ + return gzseek(file, offset, whence); +} + +int GZIPROMReaderRead(void * file, void * buffer, u32 size) +{ + return gzread(file, buffer, size); +} +#endif + +#ifdef HAVE_LIBZZIP +void * ZIPROMReaderInit(const char * filename); +void ZIPROMReaderDeInit(void *); +u32 ZIPROMReaderSize(void *); +int ZIPROMReaderSeek(void *, int, int); +int ZIPROMReaderRead(void *, void *, u32); + +ROMReader_struct ZIPROMReader = +{ + ROMREADER_ZIP, + "Zip ROM Reader", + ZIPROMReaderInit, + ZIPROMReaderDeInit, + ZIPROMReaderSize, + ZIPROMReaderSeek, + ZIPROMReaderRead +}; + +void * ZIPROMReaderInit(const char * filename) +{ + ZZIP_DIR * dir = zzip_opendir(filename); + ZZIP_DIRENT * dirent = zzip_readdir(dir); + if (dir != NULL) + { + char tmp1[1024]; + char tmp2[1024]; + memset(tmp1,0,sizeof(tmp1)); + memset(tmp2,0,sizeof(tmp2)); + strncpy(tmp1, filename, strlen(filename) - 4); + sprintf(tmp2, "%s/%s", tmp1, dirent->d_name); + return zzip_fopen(tmp2, "rb"); + } + return NULL; +} + +void ZIPROMReaderDeInit(void * file) +{ + zzip_close((ZZIP_FILE*)file); +} + +u32 ZIPROMReaderSize(void * file) +{ + u32 size; + + zzip_seek((ZZIP_FILE*)file, 0, SEEK_END); + size = zzip_tell((ZZIP_FILE*)file); + zzip_seek((ZZIP_FILE*)file, 0, SEEK_SET); + + return size; +} + +int ZIPROMReaderSeek(void * file, int offset, int whence) +{ + return zzip_seek((ZZIP_FILE*)file, offset, whence); +} + +int ZIPROMReaderRead(void * file, void * buffer, u32 size) +{ +#ifdef ZZIP_OLD_READ + return zzip_read((ZZIP_FILE*)file, (char *) buffer, size); +#else + return zzip_read((ZZIP_FILE*)file, buffer, size); +#endif +} +#endif diff --git a/desmume/src/ROMReader.h b/src/ROMReader.h similarity index 96% rename from desmume/src/ROMReader.h rename to src/ROMReader.h index a606a5cbf..ab2e2314d 100644 --- a/desmume/src/ROMReader.h +++ b/src/ROMReader.h @@ -1,51 +1,51 @@ -/* Copyright 2007 Guillaume Duhamel - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifdef HAVE_LIBZ -#include -#endif -#include - -#include "types.h" - -#define ROMREADER_DEFAULT -1 -#define ROMREADER_STD 0 -#define ROMREADER_GZIP 1 -#define ROMREADER_ZIP 2 - -typedef struct -{ - int id; - const char * Name; - void * (*Init)(const char * filename); - void (*DeInit)(void * file); - u32 (*Size)(void * file); - int (*Seek)(void * file, int offset, int whence); - int (*Read)(void * file, void * buffer, u32 size); -} ROMReader_struct; - -extern ROMReader_struct STDROMReader; -#ifdef HAVE_LIBZ -extern ROMReader_struct GZIPROMReader; -#endif -#ifdef HAVE_LIBZZIP -extern ROMReader_struct ZIPROMReader; -#endif - -ROMReader_struct * ROMReaderInit(char ** filename); +/* Copyright 2007 Guillaume Duhamel + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifdef HAVE_LIBZ +#include +#endif +#include + +#include "types.h" + +#define ROMREADER_DEFAULT -1 +#define ROMREADER_STD 0 +#define ROMREADER_GZIP 1 +#define ROMREADER_ZIP 2 + +typedef struct +{ + int id; + const char * Name; + void * (*Init)(const char * filename); + void (*DeInit)(void * file); + u32 (*Size)(void * file); + int (*Seek)(void * file, int offset, int whence); + int (*Read)(void * file, void * buffer, u32 size); +} ROMReader_struct; + +extern ROMReader_struct STDROMReader; +#ifdef HAVE_LIBZ +extern ROMReader_struct GZIPROMReader; +#endif +#ifdef HAVE_LIBZZIP +extern ROMReader_struct ZIPROMReader; +#endif + +ROMReader_struct * ROMReaderInit(char ** filename); diff --git a/desmume/src/SPU.cpp b/src/SPU.cpp similarity index 96% rename from desmume/src/SPU.cpp rename to src/SPU.cpp index bbc0b92b4..2cf0e10a8 100644 --- a/desmume/src/SPU.cpp +++ b/src/SPU.cpp @@ -1,1349 +1,1349 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - Copyright (C) 2006 Theo Berkau - Copyright (C) 2008-2009 DeSmuME team - - Ideas borrowed from Stephane Dallongeville's SCSP core - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include -#include - -#define _USE_MATH_DEFINES -#include -#ifndef M_PI -#define M_PI 3.1415926535897932386 -#endif - -#include "debug.h" -#include "MMU.h" -#include "SPU.h" -#include "mem.h" -#include "readwrite.h" -#include "armcpu.h" -#include "NDSSystem.h" -#include "matrix.h" - -//#undef FORCEINLINE -//#define FORCEINLINE - -SPU_struct *SPU_core = 0; -SPU_struct *SPU_user = 0; -int SPU_currentCoreNum = SNDCORE_DUMMY; - -static SoundInterface_struct *SNDCore=NULL; -extern SoundInterface_struct *SNDCoreList[]; - -//const int shift = (FORMAT == 0 ? 2 : 1); -static const int format_shift[] = { 2, 1, 3, 0 }; - -static const s8 indextbl[8] = -{ - -1, -1, -1, -1, 2, 4, 6, 8 -}; - -static const u16 adpcmtbl[89] = -{ - 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x0010, - 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F, 0x0022, 0x0025, - 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042, 0x0049, 0x0050, 0x0058, - 0x0061, 0x006B, 0x0076, 0x0082, 0x008F, 0x009D, 0x00AD, 0x00BE, 0x00D1, - 0x00E6, 0x00FD, 0x0117, 0x0133, 0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, - 0x0220, 0x0256, 0x0292, 0x02D4, 0x031C, 0x036C, 0x03C3, 0x0424, 0x048E, - 0x0502, 0x0583, 0x0610, 0x06AB, 0x0756, 0x0812, 0x08E0, 0x09C3, 0x0ABD, - 0x0BD0, 0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, 0x1706, 0x1954, - 0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B, 0x3BB9, - 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF -}; - -static const s16 wavedutytbl[8][8] = { - { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF }, - { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF }, - { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, - { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, - { -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, - { -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, - { -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, - { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF } -}; - -static s32 precalcdifftbl[89][16]; -static u8 precalcindextbl[89][8]; - -static const double ARM7_CLOCK = 33513982; - -////////////////////////////////////////////////////////////////////////////// - -template -static FORCEINLINE T MinMax(T val, T min, T max) -{ - if (val < min) - return min; - else if (val > max) - return max; - - return val; -} - -////////////////////////////////////////////////////////////////////////////// - -class ADPCMCacheItem -{ -public: - ADPCMCacheItem() - : raw_copy(NULL) - , decoded(NULL) - , next(NULL) - , prev(NULL) - , lockCount(0) - {} - ~ADPCMCacheItem() { - delete[] raw_copy; - delete[] decoded; - } - void unlock() { - lockCount--; - } - void lock() { - lockCount++; - } - u32 addr; - s8* raw_copy; //for memcmp - u32 raw_len; - u32 decode_len; - s16* decoded; //s16 decoded samples - ADPCMCacheItem *next, *prev; //double linked list - int lockCount; -}; - -//notes on the cache: -//I am really unhappy with the ref counting. this needs to be automatic. -//We could do something better than a linear search through cache items, but it may not be worth it. -//Also we may need to rescan more often (every time a sample loops) -class ADPCMCache -{ -public: - ADPCMCache() - : list_front(NULL) - , list_back(NULL) - , cache_size(0) - {} - - ADPCMCacheItem *list_front, *list_back; - - //this ought to be enough for anyone - static const u32 kMaxCacheSize = 8*1024*1024; - //this is not really precise, it is off by a constant factor - u32 cache_size; - - void evict(const u32 target = kMaxCacheSize) { - //evicts old cache items until it is less than the max cache size - //this means we actually can exceed the cache by the size of the next item. - //if we really wanted to hold ourselves to it, we could evict to kMaxCacheSize-nextItemSize - while(cache_size > target) - { - ADPCMCacheItem *oldest = list_back; - while(oldest && oldest->lockCount>0) oldest = oldest->prev; //find an unlocked one - if(!oldest) - { - //nothing we can do, everything in the cache is locked. maybe we're leaking. - //just quit trying to evict - return; - } - list_remove(oldest); - cache_size -= oldest->raw_len*2; - //printf("evicting! totalsize:%d\n",cache_size); - delete oldest; - } - } - - //DO NOT USE THIS METHOD WITHOUT MAKING SURE YOU HAVE - //FREED THE CURRENT ADPCMCacheItem FIRST! - //we should do this with some kind of smart pointers, but i am too lazy - ADPCMCacheItem* scan(channel_struct *chan) - { - u32 addr = chan->addr; - s8* raw = chan->buf8; - u32 raw_len = chan->totlength * 4; - for(ADPCMCacheItem* curr = list_front;curr;curr=curr->next) - { - if(curr->addr != addr) continue; - if(curr->raw_len != raw_len) continue; - if(memcmp(curr->raw_copy,raw,raw_len)) - { - //we found a cached item for the current address, but the data is stale. - //for a variety of complicated reasons, we need to throw it out right this instant. - list_remove(curr); - delete curr; - break; - } - - curr->lock(); - list_remove(curr); - list_push_front(curr); - return curr; - } - - //item was not found. recruit an existing one (the oldest), or create a new one - evict(); //reduce the size of the cache if necessary - ADPCMCacheItem* newitem = new ADPCMCacheItem(); - newitem->lock(); - newitem->addr = addr; - newitem->raw_len = raw_len; - newitem->raw_copy = new s8[raw_len]; - memcpy(newitem->raw_copy,chan->buf8,raw_len); - u32 decode_len = newitem->decode_len = raw_len*2; - cache_size += newitem->decode_len; - newitem->decoded = new s16[decode_len]; - - int index = chan->buf8[2] & 0x7F; - s16 pcm16b = (s16)((chan->buf8[1] << 8) | chan->buf8[0]); - s16 pcm16b_last = pcm16b; - - for(u32 i = 8; i < decode_len; i++) - { - const u32 shift = (i&1)<<2; - const u32 data4bit = (((u32)chan->buf8[i >> 1]) >> shift); - - const s32 diff = precalcdifftbl[index][data4bit & 0xF]; - index = precalcindextbl[index][data4bit & 0x7]; - - pcm16b_last = pcm16b; - pcm16b = MinMax(pcm16b+diff, -0x8000, 0x7FFF); - newitem->decoded[i] = pcm16b; - } - - //printf("new cacheitem! totalsize:%d\n",cache_size); - list_push_front(newitem); - return newitem; - } - - void list_remove(ADPCMCacheItem* item) { - if(item->next) item->next->prev = item->prev; - if(item->prev) item->prev->next = item->next; - if(item == list_front) list_front = item->next; - if(item == list_back) list_back = item->prev; - } - - void list_push_front(ADPCMCacheItem* item) - { - item->next = list_front; - if(list_front) list_front->prev = item; - else list_back = item; - item->prev = NULL; - list_front = item; - } - -} adpcmCache; - -////////////////////////////////////////////////////////////////////////////// - -int SPU_ChangeSoundCore(int coreid, int buffersize) -{ - int i; - - delete SPU_user; SPU_user = 0; - - // Make sure the old core is freed - if (SNDCore) - SNDCore->DeInit(); - - // So which core do we want? - if (coreid == SNDCORE_DEFAULT) - coreid = 0; // Assume we want the first one - - SPU_currentCoreNum = coreid; - - // Go through core list and find the id - for (i = 0; SNDCoreList[i] != NULL; i++) - { - if (SNDCoreList[i]->id == coreid) - { - // Set to current core - SNDCore = SNDCoreList[i]; - break; - } - } - - //If the user picked the dummy core, disable the user spu - if(SNDCore == &SNDDummy) - return 0; - - //If the core wasnt found in the list for some reason, disable the user spu - if (SNDCore == NULL) - return -1; - - // Since it failed, instead of it being fatal, disable the user spu - if (SNDCore->Init(buffersize * 2) == -1) - { - SNDCore = 0; - return -1; - } - - //enable the user spu - SPU_user = new SPU_struct(buffersize); - - return 0; -} - -SoundInterface_struct *SPU_SoundCore() -{ - return SNDCore; -} - -////////////////////////////////////////////////////////////////////////////// - -//static double cos_lut[256]; - -int SPU_Init(int coreid, int buffersize) -{ - int i, j; - - //for(int i=0;i<256;i++) - // cos_lut[i] = cos(i/256.0*M_PI); - - SPU_core = new SPU_struct(740); - SPU_Reset(); - - for(i = 0; i < 16; i++) - { - for(j = 0; j < 89; j++) - { - precalcdifftbl[j][i] = (((i & 0x7) * 2 + 1) * adpcmtbl[j] / 8); - if(i & 0x8) precalcdifftbl[j][i] = -precalcdifftbl[j][i]; - } - } - - for(i = 0; i < 8; i++) - { - for(j = 0; j < 89; j++) - { - precalcindextbl[j][i] = MinMax((j + indextbl[i]), 0, 88); - } - } - - return SPU_ChangeSoundCore(coreid, buffersize); -} - -////////////////////////////////////////////////////////////////////////////// - -void SPU_Pause(int pause) -{ - if (SNDCore == NULL) return; - - if(pause) - SNDCore->MuteAudio(); - else - SNDCore->UnMuteAudio(); -} - -////////////////////////////////////////////////////////////////////////////// - -void SPU_SetVolume(int volume) -{ - if (SNDCore) - SNDCore->SetVolume(volume); -} - -////////////////////////////////////////////////////////////////////////////// - - -void SPU_Reset(void) -{ - int i; - - SPU_core->reset(); - if(SPU_user) SPU_user->reset(); - - if(SNDCore && SPU_user) { - SNDCore->DeInit(); - SNDCore->Init(SPU_user->bufsize*2); - //todo - check success? - } - - //keep the cache tidy - adpcmCache.evict(0); - - // Reset Registers - for (i = 0x400; i < 0x51D; i++) - T1WriteByte(MMU.ARM7_REG, i, 0); -} - -void SPU_struct::reset() -{ - memset(sndbuf,0,bufsize*2*4); - memset(outbuf,0,bufsize*2*2); - - for(int i = 0; i < 16; i++) - { - if(channels[i].cacheItem) - channels[i].cacheItem->unlock(); - } - - memset((void *)channels, 0, sizeof(channel_struct) * 16); - - for(int i = 0; i < 16; i++) - { - channels[i].num = i; - } -} - -SPU_struct::SPU_struct(int buffersize) - : bufpos(0) - , buflength(0) - , sndbuf(0) - , outbuf(0) - , bufsize(buffersize) -{ - sndbuf = new s32[buffersize*2]; - outbuf = new s16[buffersize*2]; - reset(); -} - -SPU_struct::~SPU_struct() -{ - if(sndbuf) delete[] sndbuf; - if(outbuf) delete[] outbuf; - for(int i = 0; i < 16; i++) - { - if(channels[i].cacheItem) - channels[i].cacheItem->unlock(); - } -} - -void SPU_DeInit(void) -{ - if(SNDCore) - SNDCore->DeInit(); - SNDCore = 0; - - delete SPU_core; SPU_core=0; - delete SPU_user; SPU_user=0; -} - -////////////////////////////////////////////////////////////////////////////// - -void SPU_struct::ShutUp() -{ - for(int i=0;i<16;i++) - channels[i].status = CHANSTAT_STOPPED; -} - -static FORCEINLINE void adjust_channel_timer(channel_struct *chan) -{ - chan->sampinc = (((double)ARM7_CLOCK) / (44100 * 2)) / (double)(0x10000 - chan->timer); -} - -void SPU_struct::KeyOn(int channel) -{ - channel_struct &thischan = channels[channel]; - - adjust_channel_timer(&thischan); - - // LOG("Channel %d key on: vol = %d, datashift = %d, hold = %d, pan = %d, waveduty = %d, repeat = %d, format = %d, source address = %07X, timer = %04X, loop start = %04X, length = %06X, MMU.ARM7_REG[0x501] = %02X\n", channel, chan->vol, chan->datashift, chan->hold, chan->pan, chan->waveduty, chan->repeat, chan->format, chan->addr, chan->timer, chan->loopstart, chan->length, T1ReadByte(MMU.ARM7_REG, 0x501)); - switch(thischan.format) - { - case 0: // 8-bit - thischan.buf8 = (s8*)&MMU.MMU_MEM[1][(thischan.addr>>20)&0xFF][(thischan.addr & MMU.MMU_MASK[1][(thischan.addr >> 20) & 0xFF])]; - // thischan.loopstart = thischan.loopstart << 2; - // thischan.length = (thischan.length << 2) + thischan.loopstart; - thischan.sampcnt = 0; - break; - case 1: // 16-bit - thischan.buf16 = (s16 *)&MMU.MMU_MEM[1][(thischan.addr>>20)&0xFF][(thischan.addr & MMU.MMU_MASK[1][(thischan.addr >> 20) & 0xFF])]; - // thischan.loopstart = thischan.loopstart << 1; - // thischan.length = (thischan.length << 1) + thischan.loopstart; - thischan.sampcnt = 0; - break; - case 2: // ADPCM - { - thischan.buf8 = (s8*)&MMU.MMU_MEM[1][(thischan.addr>>20)&0xFF][(thischan.addr & MMU.MMU_MASK[1][(thischan.addr >> 20) & 0xFF])]; - thischan.pcm16b = (s16)((thischan.buf8[1] << 8) | thischan.buf8[0]); - thischan.pcm16b_last = thischan.pcm16b; - thischan.index = thischan.buf8[2] & 0x7F; - thischan.lastsampcnt = 7; - thischan.sampcnt = 8; - // thischan.loopstart = thischan.loopstart << 3; - // thischan.length = (thischan.length << 3) + thischan.loopstart; - if(thischan.cacheItem) thischan.cacheItem->unlock(); - thischan.cacheItem = NULL; - if(CommonSettings.spuAdpcmCache) - if(this != SPU_core) - thischan.cacheItem = adpcmCache.scan(&thischan); - break; - } - case 3: // PSG - { - thischan.x = 0x7FFF; - break; - } - default: break; - } - - if(thischan.format != 3) - { - if(thischan.double_totlength_shifted == 0) - { - printf("INFO: Stopping channel %d due to zero length\n",channel); - thischan.status = CHANSTAT_STOPPED; - } - } - - thischan.double_totlength_shifted = (double)(thischan.totlength << format_shift[thischan.format]); -} - -////////////////////////////////////////////////////////////////////////////// - -u32 SPU_ReadLong(u32 addr) -{ - addr &= 0xFFF; - - return T1ReadLong(MMU.ARM7_REG, addr); -} - -////////////////////////////////////////////////////////////////////////////// - -void SPU_struct::WriteByte(u32 addr, u8 val) -{ - channel_struct &thischan=channels[(addr >> 4) & 0xF]; - switch(addr & 0xF) { - case 0x0: - thischan.vol = val & 0x7F; - break; - case 0x1: { - thischan.datashift = val & 0x3; - if (thischan.datashift == 3) - thischan.datashift = 4; - thischan.hold = (val >> 7) & 0x1; - break; - } - case 0x2: - thischan.pan = val & 0x7F; - break; - case 0x3: { - thischan.waveduty = val & 0x7; - thischan.repeat = (val >> 3) & 0x3; - thischan.format = (val >> 5) & 0x3; - thischan.status = (val >> 7) & 0x1; - if(thischan.status) - KeyOn((addr >> 4) & 0xF); - break; - } - } - -} - -void SPU_WriteByte(u32 addr, u8 val) -{ - addr &= 0xFFF; - - if (addr < 0x500) - { - SPU_core->WriteByte(addr,val); - if(SPU_user) SPU_user->WriteByte(addr,val); - } - - T1WriteByte(MMU.ARM7_REG, addr, val); -} - -////////////////////////////////////////////////////////////////////////////// - -void SPU_struct::WriteWord(u32 addr, u16 val) -{ - channel_struct &thischan=channels[(addr >> 4) & 0xF]; - switch(addr & 0xF) - { - case 0x0: - thischan.vol = val & 0x7F; - thischan.datashift = (val >> 8) & 0x3; - if (thischan.datashift == 3) - thischan.datashift = 4; - thischan.hold = (val >> 15) & 0x1; - break; - case 0x2: - thischan.pan = val & 0x7F; - thischan.waveduty = (val >> 8) & 0x7; - thischan.repeat = (val >> 11) & 0x3; - thischan.format = (val >> 13) & 0x3; - thischan.status = (val >> 15) & 0x1; - if (thischan.status) - KeyOn((addr >> 4) & 0xF); - break; - case 0x8: - thischan.timer = val & 0xFFFF; - adjust_channel_timer(&thischan); - break; - case 0xA: - thischan.loopstart = val; - thischan.totlength = thischan.length + thischan.loopstart; - thischan.double_totlength_shifted = (double)(thischan.totlength << format_shift[thischan.format]); - break; - case 0xC: - WriteLong(addr,((u32)T1ReadWord(MMU.ARM7_REG, addr+2) << 16) | val); - break; - case 0xE: - WriteLong(addr,((u32)T1ReadWord(MMU.ARM7_REG, addr-2)) | ((u32)val<<16)); - break; - } -} - -void SPU_WriteWord(u32 addr, u16 val) -{ - addr &= 0xFFF; - - if (addr < 0x500) - { - SPU_core->WriteWord(addr,val); - if(SPU_user) SPU_user->WriteWord(addr,val); - } - - T1WriteWord(MMU.ARM7_REG, addr, val); -} - -////////////////////////////////////////////////////////////////////////////// - -void SPU_struct::WriteLong(u32 addr, u32 val) -{ - channel_struct &thischan=channels[(addr >> 4) & 0xF]; - switch(addr & 0xF) - { - case 0x0: - thischan.vol = val & 0x7F; - thischan.datashift = (val >> 8) & 0x3; - if (thischan.datashift == 3) - thischan.datashift = 4; - thischan.hold = (val >> 15) & 0x1; - thischan.pan = (val >> 16) & 0x7F; - thischan.waveduty = (val >> 24) & 0x7; - thischan.repeat = (val >> 27) & 0x3; - thischan.format = (val >> 29) & 0x3; - thischan.status = (val >> 31) & 0x1; - if (thischan.status) - KeyOn((addr >> 4) & 0xF); - break; - case 0x4: - thischan.addr = val & 0x7FFFFFF; - break; - case 0x8: - thischan.timer = val & 0xFFFF; - thischan.loopstart = val >> 16; - adjust_channel_timer(&thischan); - break; - case 0xC: - thischan.length = val & 0x3FFFFF; - thischan.totlength = thischan.length + thischan.loopstart; - thischan.double_totlength_shifted = (double)(thischan.totlength << format_shift[thischan.format]); - break; - } -} - -void SPU_WriteLong(u32 addr, u32 val) -{ - addr &= 0xFFF; - - if (addr < 0x500) - { - SPU_core->WriteLong(addr,val); - if(SPU_user) SPU_user->WriteLong(addr,val); - } - - T1WriteLong(MMU.ARM7_REG, addr, val); -} - -////////////////////////////////////////////////////////////////////////////// - -template static FORCEINLINE s32 Interpolate(s32 a, s32 b, double _ratio) -{ - float ratio = (float)_ratio; - if(INTERPOLATE_MODE == SPUInterpolation_Cosine) - { - //why did we change it away from the lookup table? somebody should research that - ratio = ratio - (int)ratio; - double ratio2 = ((1.0 - cos(ratio * M_PI)) * 0.5); - //double ratio2 = (1.0f - cos_lut[((int)(ratio*256.0))&0xFF]) / 2.0f; - return (s32)(((1-ratio2)*a) + (ratio2*b)); - } - else - { - //linear interpolation - ratio = ratio - sputrunc(ratio); - return s32floor((1-ratio)*a + ratio*b); - } -} - -////////////////////////////////////////////////////////////////////////////// - -template static FORCEINLINE void Fetch8BitData(channel_struct *chan, s32 *data) -{ - u32 loc = sputrunc(chan->sampcnt); - if(INTERPOLATE_MODE != SPUInterpolation_None) - { - s32 a = (s32)(chan->buf8[loc] << 8); - if(loc < (chan->totlength << 2) - 1) { - s32 b = (s32)(chan->buf8[loc + 1] << 8); - a = Interpolate(a, b, chan->sampcnt); - } - *data = a; - } - else - *data = (s32)chan->buf8[loc] << 8; -} - -template static FORCEINLINE void Fetch16BitData(const channel_struct * const chan, s32 *data) -{ - const s16* const buf16 = ADPCM_CACHED ? chan->cacheItem->decoded : chan->buf16; - const int shift = ADPCM_CACHED ? 3 : 1; - if(INTERPOLATE_MODE != SPUInterpolation_None) - { - u32 loc = sputrunc(chan->sampcnt); - s32 a = (s32)buf16[loc], b; - if(loc < (chan->totlength << shift) - 1) - { - b = (s32)buf16[loc + 1]; - a = Interpolate(a, b, chan->sampcnt); - } - *data = a; - } - else - *data = (s32)buf16[sputrunc(chan->sampcnt)]; -} - -template static FORCEINLINE void FetchADPCMData(channel_struct * const chan, s32 * const data) -{ - if(ADPCM_CACHED) - { - return Fetch16BitData(chan, data); - } - - // No sense decoding, just return the last sample - if (chan->lastsampcnt != sputrunc(chan->sampcnt)){ - - const u32 endExclusive = sputrunc(chan->sampcnt+1); - for (u32 i = chan->lastsampcnt+1; i < endExclusive; i++) - { - const u32 shift = (i&1)<<2; - const u32 data4bit = (((u32)chan->buf8[i >> 1]) >> shift); - - const s32 diff = precalcdifftbl[chan->index][data4bit & 0xF]; - chan->index = precalcindextbl[chan->index][data4bit & 0x7]; - - chan->pcm16b_last = chan->pcm16b; - chan->pcm16b = MinMax(chan->pcm16b+diff, -0x8000, 0x7FFF); - } - - chan->lastsampcnt = sputrunc(chan->sampcnt); - } - - if(INTERPOLATE_MODE != SPUInterpolation_None) - *data = Interpolate((s32)chan->pcm16b_last,(s32)chan->pcm16b,chan->sampcnt); - else - *data = (s32)chan->pcm16b; -} - -static FORCEINLINE void FetchPSGData(channel_struct *chan, s32 *data) -{ - if(chan->num < 8) - { - *data = 0; - } - else if(chan->num < 14) - { - *data = (s32)wavedutytbl[chan->waveduty][(sputrunc(chan->sampcnt)) & 0x7]; - } - else - { - if(chan->lastsampcnt == sputrunc(chan->sampcnt)) - { - *data = (s32)chan->psgnoise_last; - return; - } - - u32 max = sputrunc(chan->sampcnt); - for(u32 i = chan->lastsampcnt; i < max; i++) - { - if(chan->x & 0x1) - { - chan->x = (chan->x >> 1); - chan->psgnoise_last = -0x7FFF; - } - else - { - chan->x = ((chan->x >> 1) ^ 0x6000); - chan->psgnoise_last = 0x7FFF; - } - } - - chan->lastsampcnt = sputrunc(chan->sampcnt); - - *data = (s32)chan->psgnoise_last; - } -} - -////////////////////////////////////////////////////////////////////////////// - -static FORCEINLINE void MixL(SPU_struct* SPU, channel_struct *chan, s32 data) -{ - data = spumuldiv7(data, chan->vol) >> chan->datashift; - SPU->sndbuf[SPU->bufpos<<1] += data; -} - -static FORCEINLINE void MixR(SPU_struct* SPU, channel_struct *chan, s32 data) -{ - data = spumuldiv7(data, chan->vol) >> chan->datashift; - SPU->sndbuf[(SPU->bufpos<<1)+1] += data; -} - -static FORCEINLINE void MixLR(SPU_struct* SPU, channel_struct *chan, s32 data) -{ - data = spumuldiv7(data, chan->vol) >> chan->datashift; - SPU->sndbuf[SPU->bufpos<<1] += spumuldiv7(data, 127 - chan->pan); - SPU->sndbuf[(SPU->bufpos<<1)+1] += spumuldiv7(data, chan->pan); -} - -////////////////////////////////////////////////////////////////////////////// - -template static FORCEINLINE void TestForLoop(SPU_struct *SPU, channel_struct *chan) -{ - const int shift = (FORMAT == 0 ? 2 : 1); - - chan->sampcnt += chan->sampinc; - - if (chan->sampcnt > chan->double_totlength_shifted) - { - // Do we loop? Or are we done? - if (chan->repeat == 1) - { - while (chan->sampcnt > chan->double_totlength_shifted) - chan->sampcnt -= chan->double_totlength_shifted - (double)(chan->loopstart << shift); - //chan->sampcnt = (double)(chan->loopstart << shift); - } - else - { - chan->status = CHANSTAT_STOPPED; - - if(SPU == SPU_core) - MMU.ARM7_REG[0x403 + (((chan-SPU->channels) ) * 0x10)] &= 0x7F; - SPU->bufpos = SPU->buflength; - } - } -} - -static FORCEINLINE void TestForLoop2(SPU_struct *SPU, channel_struct *chan) -{ - chan->sampcnt += chan->sampinc; - - if (chan->sampcnt > chan->double_totlength_shifted) - { - // Do we loop? Or are we done? - if (chan->repeat == 1) - { - while (chan->sampcnt > chan->double_totlength_shifted) - chan->sampcnt -= chan->double_totlength_shifted - (double)(chan->loopstart << 3); - //chan->sampcnt = (double)(chan->loopstart << 3); - chan->pcm16b = (s16)((chan->buf8[1] << 8) | chan->buf8[0]); - chan->index = chan->buf8[2] & 0x7F; - chan->lastsampcnt = 7; - } - else - { - chan->status = CHANSTAT_STOPPED; - if(SPU == SPU_core) - MMU.ARM7_REG[0x403 + (((chan-SPU->channels) ) * 0x10)] &= 0x7F; - SPU->bufpos = SPU->buflength; - } - } -} - -template FORCEINLINE static void SPU_Mix(SPU_struct* SPU, channel_struct *chan, s32 data) -{ - switch(CHANNELS) - { - case 0: MixL(SPU, chan, data); break; - case 1: MixLR(SPU, chan, data); break; - case 2: MixR(SPU, chan, data); break; - } -} - -template - FORCEINLINE static void _____SPU_ChanUpdate(SPU_struct* const SPU, channel_struct* const chan) -{ - for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) - { - if(CHANNELS != -1) - { - s32 data; - switch(FORMAT) - { - case 0: Fetch8BitData(chan, &data); break; - case 1: Fetch16BitData(chan, &data); break; - case 2: FetchADPCMData(chan, &data); break; - case 3: FetchPSGData(chan, &data); break; - } - SPU_Mix(SPU, chan, data); - } - - switch(FORMAT) { - case 0: case 1: TestForLoop(SPU, chan); break; - case 2: TestForLoop2(SPU, chan); break; - case 3: chan->sampcnt += chan->sampinc; break; - } - } -} - -template - FORCEINLINE static void ____SPU_ChanUpdate(SPU_struct* const SPU, channel_struct* const chan) -{ - if(FORMAT == 2 && chan->cacheItem) - _____SPU_ChanUpdate(SPU,chan); - else _____SPU_ChanUpdate(SPU,chan); -} - -template - FORCEINLINE static void ___SPU_ChanUpdate(const bool actuallyMix, SPU_struct* const SPU, channel_struct* const chan) -{ - if(!actuallyMix) - ____SPU_ChanUpdate(SPU,chan); - else if (chan->pan == 0) - ____SPU_ChanUpdate(SPU,chan); - else if (chan->pan == 127) - ____SPU_ChanUpdate(SPU,chan); - else - ____SPU_ChanUpdate(SPU,chan); -} - -template - FORCEINLINE static void __SPU_ChanUpdate(const bool actuallyMix, SPU_struct* const SPU, channel_struct* const chan) -{ - switch(chan->format) - { - case 0: ___SPU_ChanUpdate<0,INTERPOLATE_MODE>(actuallyMix, SPU, chan); break; - case 1: ___SPU_ChanUpdate<1,INTERPOLATE_MODE>(actuallyMix, SPU, chan); break; - case 2: ___SPU_ChanUpdate<2,INTERPOLATE_MODE>(actuallyMix, SPU, chan); break; - case 3: ___SPU_ChanUpdate<3,INTERPOLATE_MODE>(actuallyMix, SPU, chan); break; - default: assert(false); - } -} - -FORCEINLINE static void _SPU_ChanUpdate(const bool actuallyMix, SPU_struct* const SPU, channel_struct* const chan) -{ - switch(CommonSettings.spuInterpolationMode) - { - case SPUInterpolation_None: __SPU_ChanUpdate(actuallyMix, SPU, chan); break; - case SPUInterpolation_Linear: __SPU_ChanUpdate(actuallyMix, SPU, chan); break; - case SPUInterpolation_Cosine: __SPU_ChanUpdate(actuallyMix, SPU, chan); break; - default: assert(false); - } -} - -template -static void SPU_MixAudio(SPU_struct *SPU, int length) -{ - u8 vol; - - if(actuallyMix) - { - memset(SPU->sndbuf, 0, length*4*2); - memset(SPU->outbuf, 0, length*2*2); - } - - // If the sound speakers are disabled, don't output audio - if(!(T1ReadWord(MMU.ARM7_REG, 0x304) & 0x01)) - return; - - // If Master Enable isn't set, don't output audio - if (!(T1ReadByte(MMU.ARM7_REG, 0x501) & 0x80)) - return; - - vol = T1ReadByte(MMU.ARM7_REG, 0x500) & 0x7F; - - for(int i=0;i<16;i++) - { - channel_struct *chan = &SPU->channels[i]; - - if (chan->status != CHANSTAT_PLAY) - continue; - - SPU->bufpos = 0; - SPU->buflength = length; - - // Mix audio - _SPU_ChanUpdate(!CommonSettings.spu_muteChannels[i] && actuallyMix, SPU, chan); - } - - // convert from 32-bit->16-bit - if(actuallyMix) - for (int i = 0; i < length*2; i++) - { - // Apply Master Volume - SPU->sndbuf[i] = spumuldiv7(SPU->sndbuf[i], vol); - - if (SPU->sndbuf[i] > 0x7FFF) - SPU->outbuf[i] = 0x7FFF; - else if (SPU->sndbuf[i] < -0x8000) - SPU->outbuf[i] = -0x8000; - else - SPU->outbuf[i] = (s16)SPU->sndbuf[i]; - } -} - -////////////////////////////////////////////////////////////////////////////// - - -//emulates one frame of the cpu core. -//this will produce a variable number of samples, calculated to keep a 44100hz output -//in sync with the emulator framerate -static double samples = 0; -static const double time_per_frame = (double)1.0/((double)ARM7_CLOCK/6/355); //(double)1.0/(double)59.8261; // ((double)ARM7_CLOCK/6/355/263) -static const double samples_per_frame = time_per_frame * 44100; -int spu_core_samples = 0; -void SPU_Emulate_core() -{ - samples += samples_per_frame; - spu_core_samples = (int)(samples); - samples -= spu_core_samples; - - if(driver->AVI_IsRecording() || driver->WAV_IsRecording()) - SPU_MixAudio(SPU_core,spu_core_samples); - else - SPU_MixAudio(SPU_core,spu_core_samples); -} - -void SPU_Emulate_user() -{ - if(!SPU_user) - return; - - u32 audiosize; - - // Check to see how much free space there is - // If there is some, fill up the buffer - audiosize = SNDCore->GetAudioSpace(); - - if (audiosize > 0) - { - //printf("mix %i samples\n", audiosize); - if (audiosize > SPU_user->bufsize) - audiosize = SPU_user->bufsize; - SPU_MixAudio(SPU_user,audiosize); - SNDCore->UpdateAudio(SPU_user->outbuf, audiosize); - } -} - -////////////////////////////////////////////////////////////////////////////// -// Dummy Sound Interface -////////////////////////////////////////////////////////////////////////////// - -int SNDDummyInit(int buffersize); -void SNDDummyDeInit(); -void SNDDummyUpdateAudio(s16 *buffer, u32 num_samples); -u32 SNDDummyGetAudioSpace(); -void SNDDummyMuteAudio(); -void SNDDummyUnMuteAudio(); -void SNDDummySetVolume(int volume); - -SoundInterface_struct SNDDummy = { - SNDCORE_DUMMY, - "Dummy Sound Interface", - SNDDummyInit, - SNDDummyDeInit, - SNDDummyUpdateAudio, - SNDDummyGetAudioSpace, - SNDDummyMuteAudio, - SNDDummyUnMuteAudio, - SNDDummySetVolume -}; - -////////////////////////////////////////////////////////////////////////////// - -int SNDDummyInit(int buffersize) -{ - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDummyDeInit() -{ -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDummyUpdateAudio(s16 *buffer, u32 num_samples) -{ -} - -////////////////////////////////////////////////////////////////////////////// - -u32 SNDDummyGetAudioSpace() -{ - return 740; -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDummyMuteAudio() -{ -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDummyUnMuteAudio() -{ -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDummySetVolume(int volume) -{ -} - -////////////////////////////////////////////////////////////////////////////// - -typedef struct { - char id[4]; - u32 size; -} chunk_struct; - -typedef struct { - chunk_struct riff; - char rifftype[4]; -} waveheader_struct; - -typedef struct { - chunk_struct chunk; - u16 compress; - u16 numchan; - u32 rate; - u32 bytespersec; - u16 blockalign; - u16 bitspersample; -} fmt_struct; - -WavWriter::WavWriter() -: spufp(NULL) -{ -} -bool WavWriter::open(const std::string & fname) -{ - waveheader_struct waveheader; - fmt_struct fmt; - chunk_struct data; - size_t elems_written = 0; - - if ((spufp = fopen(fname.c_str(), "wb")) == NULL) - return false; - - // Do wave header - memcpy(waveheader.riff.id, "RIFF", 4); - waveheader.riff.size = 0; // we'll fix this after the file is closed - memcpy(waveheader.rifftype, "WAVE", 4); - elems_written += fwrite((void *)&waveheader, 1, sizeof(waveheader_struct), spufp); - - // fmt chunk - memcpy(fmt.chunk.id, "fmt ", 4); - fmt.chunk.size = 16; // we'll fix this at the end - fmt.compress = 1; // PCM - fmt.numchan = 2; // Stereo - fmt.rate = 44100; - fmt.bitspersample = 16; - fmt.blockalign = fmt.bitspersample / 8 * fmt.numchan; - fmt.bytespersec = fmt.rate * fmt.blockalign; - elems_written += fwrite((void *)&fmt, 1, sizeof(fmt_struct), spufp); - - // data chunk - memcpy(data.id, "data", 4); - data.size = 0; // we'll fix this at the end - elems_written += fwrite((void *)&data, 1, sizeof(chunk_struct), spufp); - - return true; -} - -void WavWriter::close() -{ - if(!spufp) return; - size_t elems_written = 0; - long length = ftell(spufp); - - // Let's fix the riff chunk size and the data chunk size - fseek(spufp, sizeof(waveheader_struct)-0x8, SEEK_SET); - length -= 0x8; - elems_written += fwrite((void *)&length, 1, 4, spufp); - - fseek(spufp, sizeof(waveheader_struct)+sizeof(fmt_struct)+0x4, SEEK_SET); - length -= sizeof(waveheader_struct)+sizeof(fmt_struct); - elems_written += fwrite((void *)&length, 1, 4, spufp); - fclose(spufp); - spufp = NULL; -} - -void WavWriter::update(void* soundData, int numSamples) -{ - if(!spufp) return; - //TODO - big endian for the s16 samples?? - size_t elems_written = fwrite(soundData, numSamples*2, 2, spufp); -} - -bool WavWriter::isRecording() const -{ - return spufp != NULL; -} - - -static WavWriter wavWriter; - -void WAV_End() -{ - wavWriter.close(); -} - -bool WAV_Begin(const char* fname) -{ - WAV_End(); - - if(!wavWriter.open(fname)) - return false; - - driver->USR_InfoMessage("WAV recording started."); - - return true; -} - -bool WAV_IsRecording() -{ - return wavWriter.isRecording(); -} - -void WAV_WavSoundUpdate(void* soundData, int numSamples) -{ - wavWriter.update(soundData, numSamples); -} - - - -////////////////////////////////////////////////////////////////////////////// - -void spu_savestate(std::ostream* os) -{ - //version - write32le(2,os); - - SPU_struct *spu = SPU_core; - - for(int j=0;j<16;j++) { - channel_struct &chan = spu->channels[j]; - write32le(chan.num,os); - write8le(chan.vol,os); - write8le(chan.datashift,os); - write8le(chan.hold,os); - write8le(chan.pan,os); - write8le(chan.waveduty,os); - write8le(chan.repeat,os); - write8le(chan.format,os); - write8le(chan.status,os); - write32le(chan.addr,os); - write16le(chan.timer,os); - write16le(chan.loopstart,os); - write32le(chan.length,os); - write64le(double_to_u64(chan.sampcnt),os); - write64le(double_to_u64(chan.sampinc),os); - write32le(chan.lastsampcnt,os); - write16le(chan.pcm16b,os); - write16le(chan.pcm16b_last,os); - write32le(chan.index,os); - write16le(chan.x,os); - write16le(chan.psgnoise_last,os); - } - - write64le(double_to_u64(samples),os); -} - -bool spu_loadstate(std::istream* is, int size) -{ - u64 temp64; - - //read version - int version; - if(read32le(&version,is) != 1) return false; - - SPU_struct *spu = SPU_core; - - for(int j=0;j<16;j++) { - channel_struct &chan = spu->channels[j]; - read32le(&chan.num,is); - read8le(&chan.vol,is); - read8le(&chan.datashift,is); - read8le(&chan.hold,is); - read8le(&chan.pan,is); - read8le(&chan.waveduty,is); - read8le(&chan.repeat,is); - read8le(&chan.format,is); - read8le(&chan.status,is); - read32le(&chan.addr,is); - read16le(&chan.timer,is); - read16le(&chan.loopstart,is); - read32le(&chan.length,is); - chan.totlength = chan.length + chan.loopstart; - chan.double_totlength_shifted = (double)(chan.totlength << format_shift[chan.format]); - if(version != 1) - { - read64le(&temp64,is); chan.sampcnt = u64_to_double(temp64); - read64le(&temp64,is); chan.sampinc = u64_to_double(temp64); - } - else - { - read32le((u32*)&chan.sampcnt,is); - read32le((u32*)&chan.sampinc,is); - } - read32le(&chan.lastsampcnt,is); - read16le(&chan.pcm16b,is); - read16le(&chan.pcm16b_last,is); - read32le(&chan.index,is); - read16le(&chan.x,is); - read16le(&chan.psgnoise_last,is); - - //fixup the pointers which we had are supposed to keep cached - chan.buf8 = (s8*)&MMU.MMU_MEM[1][(chan.addr>>20)&0xFF][(chan.addr & MMU.MMU_MASK[1][(chan.addr >> 20) & 0xFF])]; - } - - if(version==2) { - read64le(&temp64,is); samples = u64_to_double(temp64); - } - - //copy the core spu (the more accurate) to the user spu - if(SPU_user) { - for(int i=0;i<16;i++) - { - channel_struct &chan = SPU_user->channels[i]; - if(chan.cacheItem) chan.cacheItem->unlock(); - } - - memcpy(SPU_user->channels,SPU_core->channels,sizeof(SPU_core->channels)); - - if(CommonSettings.spuAdpcmCache) - for(int i=0;i<16;i++) - { - channel_struct &chan = SPU_user->channels[i]; - if(chan.format == 2) - chan.cacheItem = adpcmCache.scan(&chan); - } - } - - return true; -} +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + Copyright (C) 2006 Theo Berkau + Copyright (C) 2008-2009 DeSmuME team + + Ideas borrowed from Stephane Dallongeville's SCSP core + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include + +#define _USE_MATH_DEFINES +#include +#ifndef M_PI +#define M_PI 3.1415926535897932386 +#endif + +#include "debug.h" +#include "ARM9.h" +#include "MMU.h" +#include "SPU.h" +#include "mem.h" +#include "readwrite.h" +#include "armcpu.h" +#include "NDSSystem.h" +#include "matrix.h" + +//#undef FORCEINLINE +//#define FORCEINLINE + +SPU_struct *SPU_core = 0; +SPU_struct *SPU_user = 0; +int SPU_currentCoreNum = SNDCORE_DUMMY; + +static SoundInterface_struct *SNDCore=NULL; +extern SoundInterface_struct *SNDCoreList[]; + +//const int shift = (FORMAT == 0 ? 2 : 1); +static const int format_shift[] = { 2, 1, 3, 0 }; + +static const s8 indextbl[8] = +{ + -1, -1, -1, -1, 2, 4, 6, 8 +}; + +static const u16 adpcmtbl[89] = +{ + 0x0007, 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x0010, + 0x0011, 0x0013, 0x0015, 0x0017, 0x0019, 0x001C, 0x001F, 0x0022, 0x0025, + 0x0029, 0x002D, 0x0032, 0x0037, 0x003C, 0x0042, 0x0049, 0x0050, 0x0058, + 0x0061, 0x006B, 0x0076, 0x0082, 0x008F, 0x009D, 0x00AD, 0x00BE, 0x00D1, + 0x00E6, 0x00FD, 0x0117, 0x0133, 0x0151, 0x0173, 0x0198, 0x01C1, 0x01EE, + 0x0220, 0x0256, 0x0292, 0x02D4, 0x031C, 0x036C, 0x03C3, 0x0424, 0x048E, + 0x0502, 0x0583, 0x0610, 0x06AB, 0x0756, 0x0812, 0x08E0, 0x09C3, 0x0ABD, + 0x0BD0, 0x0CFF, 0x0E4C, 0x0FBA, 0x114C, 0x1307, 0x14EE, 0x1706, 0x1954, + 0x1BDC, 0x1EA5, 0x21B6, 0x2515, 0x28CA, 0x2CDF, 0x315B, 0x364B, 0x3BB9, + 0x41B2, 0x4844, 0x4F7E, 0x5771, 0x602F, 0x69CE, 0x7462, 0x7FFF +}; + +static const s16 wavedutytbl[8][8] = { + { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF }, + { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF }, + { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, + { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, + { -0x7FFF, -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, + { -0x7FFF, -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, + { -0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF }, + { -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF, -0x7FFF } +}; + +static s32 precalcdifftbl[89][16]; +static u8 precalcindextbl[89][8]; + +static const double ARM7_CLOCK = 33513982; + +////////////////////////////////////////////////////////////////////////////// + +template +static FORCEINLINE T MinMax(T val, T min, T max) +{ + if (val < min) + return min; + else if (val > max) + return max; + + return val; +} + +////////////////////////////////////////////////////////////////////////////// + +class ADPCMCacheItem +{ +public: + ADPCMCacheItem() + : raw_copy(NULL) + , decoded(NULL) + , next(NULL) + , prev(NULL) + , lockCount(0) + {} + ~ADPCMCacheItem() { + delete[] raw_copy; + delete[] decoded; + } + void unlock() { + lockCount--; + } + void lock() { + lockCount++; + } + u32 addr; + s8* raw_copy; //for memcmp + u32 raw_len; + u32 decode_len; + s16* decoded; //s16 decoded samples + ADPCMCacheItem *next, *prev; //double linked list + int lockCount; +}; + +//notes on the cache: +//I am really unhappy with the ref counting. this needs to be automatic. +//We could do something better than a linear search through cache items, but it may not be worth it. +//Also we may need to rescan more often (every time a sample loops) +class ADPCMCache +{ +public: + ADPCMCache() + : list_front(NULL) + , list_back(NULL) + , cache_size(0) + {} + + ADPCMCacheItem *list_front, *list_back; + + //this ought to be enough for anyone + static const u32 kMaxCacheSize = 8*1024*1024; + //this is not really precise, it is off by a constant factor + u32 cache_size; + + void evict(const u32 target = kMaxCacheSize) { + //evicts old cache items until it is less than the max cache size + //this means we actually can exceed the cache by the size of the next item. + //if we really wanted to hold ourselves to it, we could evict to kMaxCacheSize-nextItemSize + while(cache_size > target) + { + ADPCMCacheItem *oldest = list_back; + while(oldest && oldest->lockCount>0) oldest = oldest->prev; //find an unlocked one + if(!oldest) + { + //nothing we can do, everything in the cache is locked. maybe we're leaking. + //just quit trying to evict + return; + } + list_remove(oldest); + cache_size -= oldest->raw_len*2; + //printf("evicting! totalsize:%d\n",cache_size); + delete oldest; + } + } + + //DO NOT USE THIS METHOD WITHOUT MAKING SURE YOU HAVE + //FREED THE CURRENT ADPCMCacheItem FIRST! + //we should do this with some kind of smart pointers, but i am too lazy + ADPCMCacheItem* scan(channel_struct *chan) + { + u32 addr = chan->addr; + s8* raw = chan->buf8; + u32 raw_len = chan->totlength * 4; + for(ADPCMCacheItem* curr = list_front;curr;curr=curr->next) + { + if(curr->addr != addr) continue; + if(curr->raw_len != raw_len) continue; + if(memcmp(curr->raw_copy,raw,raw_len)) + { + //we found a cached item for the current address, but the data is stale. + //for a variety of complicated reasons, we need to throw it out right this instant. + list_remove(curr); + delete curr; + break; + } + + curr->lock(); + list_remove(curr); + list_push_front(curr); + return curr; + } + + //item was not found. recruit an existing one (the oldest), or create a new one + evict(); //reduce the size of the cache if necessary + ADPCMCacheItem* newitem = new ADPCMCacheItem(); + newitem->lock(); + newitem->addr = addr; + newitem->raw_len = raw_len; + newitem->raw_copy = new s8[raw_len]; + memcpy(newitem->raw_copy,chan->buf8,raw_len); + u32 decode_len = newitem->decode_len = raw_len*2; + cache_size += newitem->decode_len; + newitem->decoded = new s16[decode_len]; + + int index = chan->buf8[2] & 0x7F; + s16 pcm16b = (s16)((chan->buf8[1] << 8) | chan->buf8[0]); + s16 pcm16b_last = pcm16b; + + for(u32 i = 8; i < decode_len; i++) + { + const u32 shift = (i&1)<<2; + const u32 data4bit = (((u32)chan->buf8[i >> 1]) >> shift); + + const s32 diff = precalcdifftbl[index][data4bit & 0xF]; + index = precalcindextbl[index][data4bit & 0x7]; + + pcm16b_last = pcm16b; + pcm16b = MinMax(pcm16b+diff, -0x8000, 0x7FFF); + newitem->decoded[i] = pcm16b; + } + + //printf("new cacheitem! totalsize:%d\n",cache_size); + list_push_front(newitem); + return newitem; + } + + void list_remove(ADPCMCacheItem* item) { + if(item->next) item->next->prev = item->prev; + if(item->prev) item->prev->next = item->next; + if(item == list_front) list_front = item->next; + if(item == list_back) list_back = item->prev; + } + + void list_push_front(ADPCMCacheItem* item) + { + item->next = list_front; + if(list_front) list_front->prev = item; + else list_back = item; + item->prev = NULL; + list_front = item; + } + +} adpcmCache; + +////////////////////////////////////////////////////////////////////////////// + +int SPU_ChangeSoundCore(int coreid, int buffersize) +{ + int i; + + delete SPU_user; SPU_user = 0; + + // Make sure the old core is freed + if (SNDCore) + SNDCore->DeInit(); + + // So which core do we want? + if (coreid == SNDCORE_DEFAULT) + coreid = 0; // Assume we want the first one + + SPU_currentCoreNum = coreid; + + // Go through core list and find the id + for (i = 0; SNDCoreList[i] != NULL; i++) + { + if (SNDCoreList[i]->id == coreid) + { + // Set to current core + SNDCore = SNDCoreList[i]; + break; + } + } + + //If the user picked the dummy core, disable the user spu + if(SNDCore == &SNDDummy) + return 0; + + //If the core wasnt found in the list for some reason, disable the user spu + if (SNDCore == NULL) + return -1; + + // Since it failed, instead of it being fatal, disable the user spu + if (SNDCore->Init(buffersize * 2) == -1) + { + SNDCore = 0; + return -1; + } + + //enable the user spu + SPU_user = new SPU_struct(buffersize); + + return 0; +} + +SoundInterface_struct *SPU_SoundCore() +{ + return SNDCore; +} + +////////////////////////////////////////////////////////////////////////////// + +//static double cos_lut[256]; + +int SPU_Init(int coreid, int buffersize) +{ + int i, j; + + //for(int i=0;i<256;i++) + // cos_lut[i] = cos(i/256.0*M_PI); + + SPU_core = new SPU_struct(740); + SPU_Reset(); + + for(i = 0; i < 16; i++) + { + for(j = 0; j < 89; j++) + { + precalcdifftbl[j][i] = (((i & 0x7) * 2 + 1) * adpcmtbl[j] / 8); + if(i & 0x8) precalcdifftbl[j][i] = -precalcdifftbl[j][i]; + } + } + + for(i = 0; i < 8; i++) + { + for(j = 0; j < 89; j++) + { + precalcindextbl[j][i] = MinMax((j + indextbl[i]), 0, 88); + } + } + + return SPU_ChangeSoundCore(coreid, buffersize); +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_Pause(int pause) +{ + if (SNDCore == NULL) return; + + if(pause) + SNDCore->MuteAudio(); + else + SNDCore->UnMuteAudio(); +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_SetVolume(int volume) +{ + if (SNDCore) + SNDCore->SetVolume(volume); +} + +////////////////////////////////////////////////////////////////////////////// + + +void SPU_Reset(void) +{ + int i; + + SPU_core->reset(); + if(SPU_user) SPU_user->reset(); + + if(SNDCore && SPU_user) { + SNDCore->DeInit(); + SNDCore->Init(SPU_user->bufsize*2); + //todo - check success? + } + + //keep the cache tidy + adpcmCache.evict(0); + + // Reset Registers + for (i = 0x400; i < 0x51D; i++) + T1WriteByte(MMU.ARM7_REG, i, 0); +} + +void SPU_struct::reset() +{ + memset(sndbuf,0,bufsize*2*4); + memset(outbuf,0,bufsize*2*2); + + for(int i = 0; i < 16; i++) + { + if(channels[i].cacheItem) + channels[i].cacheItem->unlock(); + } + + memset((void *)channels, 0, sizeof(channel_struct) * 16); + + for(int i = 0; i < 16; i++) + { + channels[i].num = i; + } +} + +SPU_struct::SPU_struct(int buffersize) + : bufpos(0) + , buflength(0) + , sndbuf(0) + , outbuf(0) + , bufsize(buffersize) +{ + sndbuf = new s32[buffersize*2]; + outbuf = new s16[buffersize*2]; + reset(); +} + +SPU_struct::~SPU_struct() +{ + if(sndbuf) delete[] sndbuf; + if(outbuf) delete[] outbuf; + for(int i = 0; i < 16; i++) + { + if(channels[i].cacheItem) + channels[i].cacheItem->unlock(); + } +} + +void SPU_DeInit(void) +{ + if(SNDCore) + SNDCore->DeInit(); + SNDCore = 0; + + delete SPU_core; SPU_core=0; + delete SPU_user; SPU_user=0; +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_struct::ShutUp() +{ + for(int i=0;i<16;i++) + channels[i].status = CHANSTAT_STOPPED; +} + +static FORCEINLINE void adjust_channel_timer(channel_struct *chan) +{ + chan->sampinc = (((double)ARM7_CLOCK) / (44100 * 2)) / (double)(0x10000 - chan->timer); +} + +void SPU_struct::KeyOn(int channel) +{ + channel_struct &thischan = channels[channel]; + + adjust_channel_timer(&thischan); + + // LOG("Channel %d key on: vol = %d, datashift = %d, hold = %d, pan = %d, waveduty = %d, repeat = %d, format = %d, source address = %07X, timer = %04X, loop start = %04X, length = %06X, MMU.ARM7_REG[0x501] = %02X\n", channel, chan->vol, chan->datashift, chan->hold, chan->pan, chan->waveduty, chan->repeat, chan->format, chan->addr, chan->timer, chan->loopstart, chan->length, T1ReadByte(MMU.ARM7_REG, 0x501)); + switch(thischan.format) + { + case 0: // 8-bit + thischan.buf8 = (s8*)&MMU.MMU_MEM[1][(thischan.addr>>20)&0xFF][(thischan.addr & MMU.MMU_MASK[1][(thischan.addr >> 20) & 0xFF])]; + // thischan.loopstart = thischan.loopstart << 2; + // thischan.length = (thischan.length << 2) + thischan.loopstart; + thischan.sampcnt = 0; + break; + case 1: // 16-bit + thischan.buf16 = (s16 *)&MMU.MMU_MEM[1][(thischan.addr>>20)&0xFF][(thischan.addr & MMU.MMU_MASK[1][(thischan.addr >> 20) & 0xFF])]; + // thischan.loopstart = thischan.loopstart << 1; + // thischan.length = (thischan.length << 1) + thischan.loopstart; + thischan.sampcnt = 0; + break; + case 2: // ADPCM + { + thischan.buf8 = (s8*)&MMU.MMU_MEM[1][(thischan.addr>>20)&0xFF][(thischan.addr & MMU.MMU_MASK[1][(thischan.addr >> 20) & 0xFF])]; + thischan.pcm16b = (s16)((thischan.buf8[1] << 8) | thischan.buf8[0]); + thischan.pcm16b_last = thischan.pcm16b; + thischan.index = thischan.buf8[2] & 0x7F; + thischan.lastsampcnt = 7; + thischan.sampcnt = 8; + // thischan.loopstart = thischan.loopstart << 3; + // thischan.length = (thischan.length << 3) + thischan.loopstart; + if(thischan.cacheItem) thischan.cacheItem->unlock(); + thischan.cacheItem = NULL; + if(CommonSettings.spuAdpcmCache) + if(this != SPU_core) + thischan.cacheItem = adpcmCache.scan(&thischan); + break; + } + case 3: // PSG + { + thischan.x = 0x7FFF; + break; + } + default: break; + } + + if(thischan.format != 3) + { + if(thischan.double_totlength_shifted == 0) + { + printf("INFO: Stopping channel %d due to zero length\n",channel); + thischan.status = CHANSTAT_STOPPED; + } + } + + thischan.double_totlength_shifted = (double)(thischan.totlength << format_shift[thischan.format]); +} + +////////////////////////////////////////////////////////////////////////////// + +u32 SPU_ReadLong(u32 addr) +{ + addr &= 0xFFF; + + return T1ReadLong(MMU.ARM7_REG, addr); +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_struct::WriteByte(u32 addr, u8 val) +{ + channel_struct &thischan=channels[(addr >> 4) & 0xF]; + switch(addr & 0xF) { + case 0x0: + thischan.vol = val & 0x7F; + break; + case 0x1: { + thischan.datashift = val & 0x3; + if (thischan.datashift == 3) + thischan.datashift = 4; + thischan.hold = (val >> 7) & 0x1; + break; + } + case 0x2: + thischan.pan = val & 0x7F; + break; + case 0x3: { + thischan.waveduty = val & 0x7; + thischan.repeat = (val >> 3) & 0x3; + thischan.format = (val >> 5) & 0x3; + thischan.status = (val >> 7) & 0x1; + if(thischan.status) + KeyOn((addr >> 4) & 0xF); + break; + } + } + +} + +void SPU_WriteByte(u32 addr, u8 val) +{ + addr &= 0xFFF; + + if (addr < 0x500) + { + SPU_core->WriteByte(addr,val); + if(SPU_user) SPU_user->WriteByte(addr,val); + } + + T1WriteByte(MMU.ARM7_REG, addr, val); +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_struct::WriteWord(u32 addr, u16 val) +{ + channel_struct &thischan=channels[(addr >> 4) & 0xF]; + switch(addr & 0xF) + { + case 0x0: + thischan.vol = val & 0x7F; + thischan.datashift = (val >> 8) & 0x3; + if (thischan.datashift == 3) + thischan.datashift = 4; + thischan.hold = (val >> 15) & 0x1; + break; + case 0x2: + thischan.pan = val & 0x7F; + thischan.waveduty = (val >> 8) & 0x7; + thischan.repeat = (val >> 11) & 0x3; + thischan.format = (val >> 13) & 0x3; + thischan.status = (val >> 15) & 0x1; + if (thischan.status) + KeyOn((addr >> 4) & 0xF); + break; + case 0x8: + thischan.timer = val & 0xFFFF; + adjust_channel_timer(&thischan); + break; + case 0xA: + thischan.loopstart = val; + thischan.totlength = thischan.length + thischan.loopstart; + thischan.double_totlength_shifted = (double)(thischan.totlength << format_shift[thischan.format]); + break; + case 0xC: + WriteLong(addr,((u32)T1ReadWord(MMU.ARM7_REG, addr+2) << 16) | val); + break; + case 0xE: + WriteLong(addr,((u32)T1ReadWord(MMU.ARM7_REG, addr-2)) | ((u32)val<<16)); + break; + } +} + +void SPU_WriteWord(u32 addr, u16 val) +{ + addr &= 0xFFF; + + if (addr < 0x500) + { + SPU_core->WriteWord(addr,val); + if(SPU_user) SPU_user->WriteWord(addr,val); + } + + T1WriteWord(MMU.ARM7_REG, addr, val); +} + +////////////////////////////////////////////////////////////////////////////// + +void SPU_struct::WriteLong(u32 addr, u32 val) +{ + channel_struct &thischan=channels[(addr >> 4) & 0xF]; + switch(addr & 0xF) + { + case 0x0: + thischan.vol = val & 0x7F; + thischan.datashift = (val >> 8) & 0x3; + if (thischan.datashift == 3) + thischan.datashift = 4; + thischan.hold = (val >> 15) & 0x1; + thischan.pan = (val >> 16) & 0x7F; + thischan.waveduty = (val >> 24) & 0x7; + thischan.repeat = (val >> 27) & 0x3; + thischan.format = (val >> 29) & 0x3; + thischan.status = (val >> 31) & 0x1; + if (thischan.status) + KeyOn((addr >> 4) & 0xF); + break; + case 0x4: + thischan.addr = val & 0x7FFFFFF; + break; + case 0x8: + thischan.timer = val & 0xFFFF; + thischan.loopstart = val >> 16; + adjust_channel_timer(&thischan); + break; + case 0xC: + thischan.length = val & 0x3FFFFF; + thischan.totlength = thischan.length + thischan.loopstart; + thischan.double_totlength_shifted = (double)(thischan.totlength << format_shift[thischan.format]); + break; + } +} + +void SPU_WriteLong(u32 addr, u32 val) +{ + addr &= 0xFFF; + + if (addr < 0x500) + { + SPU_core->WriteLong(addr,val); + if(SPU_user) SPU_user->WriteLong(addr,val); + } + + T1WriteLong(MMU.ARM7_REG, addr, val); +} + +////////////////////////////////////////////////////////////////////////////// + +template static FORCEINLINE s32 Interpolate(s32 a, s32 b, double _ratio) +{ + float ratio = (float)_ratio; + if(INTERPOLATE_MODE == SPUInterpolation_Cosine) + { + //why did we change it away from the lookup table? somebody should research that + ratio = ratio - (int)ratio; + double ratio2 = ((1.0 - cos(ratio * M_PI)) * 0.5); + //double ratio2 = (1.0f - cos_lut[((int)(ratio*256.0))&0xFF]) / 2.0f; + return (((1-ratio2)*a) + (ratio2*b)); + } + else + { + //linear interpolation + ratio = ratio - sputrunc(ratio); + return s32floor((1-ratio)*a + ratio*b); + } +} + +////////////////////////////////////////////////////////////////////////////// + +template static FORCEINLINE void Fetch8BitData(channel_struct *chan, s32 *data) +{ + u32 loc = sputrunc(chan->sampcnt); + if(INTERPOLATE_MODE != SPUInterpolation_None) + { + s32 a = (s32)(chan->buf8[loc] << 8); + if(loc < (chan->totlength << 2) - 1) { + s32 b = (s32)(chan->buf8[loc + 1] << 8); + a = Interpolate(a, b, chan->sampcnt); + } + *data = a; + } + else + *data = (s32)chan->buf8[loc] << 8; +} + +template static FORCEINLINE void Fetch16BitData(const channel_struct * const chan, s32 *data) +{ + const s16* const buf16 = ADPCM_CACHED ? chan->cacheItem->decoded : chan->buf16; + const int shift = ADPCM_CACHED ? 3 : 1; + if(INTERPOLATE_MODE != SPUInterpolation_None) + { + u32 loc = sputrunc(chan->sampcnt); + s32 a = (s32)buf16[loc], b; + if(loc < (chan->totlength << shift) - 1) + { + b = (s32)buf16[loc + 1]; + a = Interpolate(a, b, chan->sampcnt); + } + *data = a; + } + else + *data = (s32)buf16[sputrunc(chan->sampcnt)]; +} + +template static FORCEINLINE void FetchADPCMData(channel_struct * const chan, s32 * const data) +{ + if(ADPCM_CACHED) + { + return Fetch16BitData(chan, data); + } + + // No sense decoding, just return the last sample + if (chan->lastsampcnt != sputrunc(chan->sampcnt)){ + + const u32 endExclusive = sputrunc(chan->sampcnt+1); + for (u32 i = chan->lastsampcnt+1; i < endExclusive; i++) + { + const u32 shift = (i&1)<<2; + const u32 data4bit = (((u32)chan->buf8[i >> 1]) >> shift); + + const s32 diff = precalcdifftbl[chan->index][data4bit & 0xF]; + chan->index = precalcindextbl[chan->index][data4bit & 0x7]; + + chan->pcm16b_last = chan->pcm16b; + chan->pcm16b = MinMax(chan->pcm16b+diff, -0x8000, 0x7FFF); + } + + chan->lastsampcnt = sputrunc(chan->sampcnt); + } + + if(INTERPOLATE_MODE != SPUInterpolation_None) + *data = Interpolate((s32)chan->pcm16b_last,(s32)chan->pcm16b,chan->sampcnt); + else + *data = (s32)chan->pcm16b; +} + +static FORCEINLINE void FetchPSGData(channel_struct *chan, s32 *data) +{ + if(chan->num < 8) + { + *data = 0; + } + else if(chan->num < 14) + { + *data = (s32)wavedutytbl[chan->waveduty][(sputrunc(chan->sampcnt)) & 0x7]; + } + else + { + if(chan->lastsampcnt == sputrunc(chan->sampcnt)) + { + *data = (s32)chan->psgnoise_last; + return; + } + + u32 max = sputrunc(chan->sampcnt); + for(u32 i = chan->lastsampcnt; i < max; i++) + { + if(chan->x & 0x1) + { + chan->x = (chan->x >> 1); + chan->psgnoise_last = -0x7FFF; + } + else + { + chan->x = ((chan->x >> 1) ^ 0x6000); + chan->psgnoise_last = 0x7FFF; + } + } + + chan->lastsampcnt = sputrunc(chan->sampcnt); + + *data = (s32)chan->psgnoise_last; + } +} + +////////////////////////////////////////////////////////////////////////////// + +static FORCEINLINE void MixL(SPU_struct* SPU, channel_struct *chan, s32 data) +{ + data = spumuldiv7(data, chan->vol) >> chan->datashift; + SPU->sndbuf[SPU->bufpos<<1] += data; +} + +static FORCEINLINE void MixR(SPU_struct* SPU, channel_struct *chan, s32 data) +{ + data = spumuldiv7(data, chan->vol) >> chan->datashift; + SPU->sndbuf[(SPU->bufpos<<1)+1] += data; +} + +static FORCEINLINE void MixLR(SPU_struct* SPU, channel_struct *chan, s32 data) +{ + data = spumuldiv7(data, chan->vol) >> chan->datashift; + SPU->sndbuf[SPU->bufpos<<1] += spumuldiv7(data, 127 - chan->pan); + SPU->sndbuf[(SPU->bufpos<<1)+1] += spumuldiv7(data, chan->pan); +} + +////////////////////////////////////////////////////////////////////////////// + +template static FORCEINLINE void TestForLoop(SPU_struct *SPU, channel_struct *chan) +{ + const int shift = (FORMAT == 0 ? 2 : 1); + + chan->sampcnt += chan->sampinc; + + if (chan->sampcnt > chan->double_totlength_shifted) + { + // Do we loop? Or are we done? + if (chan->repeat == 1) + { + while (chan->sampcnt > chan->double_totlength_shifted) + chan->sampcnt -= chan->double_totlength_shifted - (double)(chan->loopstart << shift); + //chan->sampcnt = (double)(chan->loopstart << shift); + } + else + { + chan->status = CHANSTAT_STOPPED; + + if(SPU == SPU_core) + MMU.ARM7_REG[0x403 + (((chan-SPU->channels) ) * 0x10)] &= 0x7F; + SPU->bufpos = SPU->buflength; + } + } +} + +static FORCEINLINE void TestForLoop2(SPU_struct *SPU, channel_struct *chan) +{ + chan->sampcnt += chan->sampinc; + + if (chan->sampcnt > chan->double_totlength_shifted) + { + // Do we loop? Or are we done? + if (chan->repeat == 1) + { + while (chan->sampcnt > chan->double_totlength_shifted) + chan->sampcnt -= chan->double_totlength_shifted - (double)(chan->loopstart << 3); + //chan->sampcnt = (double)(chan->loopstart << 3); + chan->pcm16b = (s16)((chan->buf8[1] << 8) | chan->buf8[0]); + chan->index = chan->buf8[2] & 0x7F; + chan->lastsampcnt = 7; + } + else + { + chan->status = CHANSTAT_STOPPED; + if(SPU == SPU_core) + MMU.ARM7_REG[0x403 + (((chan-SPU->channels) ) * 0x10)] &= 0x7F; + SPU->bufpos = SPU->buflength; + } + } +} + +template FORCEINLINE static void SPU_Mix(SPU_struct* SPU, channel_struct *chan, s32 data) +{ + switch(CHANNELS) + { + case 0: MixL(SPU, chan, data); break; + case 1: MixLR(SPU, chan, data); break; + case 2: MixR(SPU, chan, data); break; + } +} + +template + FORCEINLINE static void _____SPU_ChanUpdate(SPU_struct* const SPU, channel_struct* const chan) +{ + for (; SPU->bufpos < SPU->buflength; SPU->bufpos++) + { + if(CHANNELS != -1) + { + s32 data; + switch(FORMAT) + { + case 0: Fetch8BitData(chan, &data); break; + case 1: Fetch16BitData(chan, &data); break; + case 2: FetchADPCMData(chan, &data); break; + case 3: FetchPSGData(chan, &data); break; + } + SPU_Mix(SPU, chan, data); + } + + switch(FORMAT) { + case 0: case 1: TestForLoop(SPU, chan); break; + case 2: TestForLoop2(SPU, chan); break; + case 3: chan->sampcnt += chan->sampinc; break; + } + } +} + +template + FORCEINLINE static void ____SPU_ChanUpdate(SPU_struct* const SPU, channel_struct* const chan) +{ + if(FORMAT == 2 && chan->cacheItem) + _____SPU_ChanUpdate(SPU,chan); + else _____SPU_ChanUpdate(SPU,chan); +} + +template + FORCEINLINE static void ___SPU_ChanUpdate(const bool actuallyMix, SPU_struct* const SPU, channel_struct* const chan) +{ + if(!actuallyMix) + ____SPU_ChanUpdate(SPU,chan); + else if (chan->pan == 0) + ____SPU_ChanUpdate(SPU,chan); + else if (chan->pan == 127) + ____SPU_ChanUpdate(SPU,chan); + else + ____SPU_ChanUpdate(SPU,chan); +} + +template + FORCEINLINE static void __SPU_ChanUpdate(const bool actuallyMix, SPU_struct* const SPU, channel_struct* const chan) +{ + switch(chan->format) + { + case 0: ___SPU_ChanUpdate<0,INTERPOLATE_MODE>(actuallyMix, SPU, chan); break; + case 1: ___SPU_ChanUpdate<1,INTERPOLATE_MODE>(actuallyMix, SPU, chan); break; + case 2: ___SPU_ChanUpdate<2,INTERPOLATE_MODE>(actuallyMix, SPU, chan); break; + case 3: ___SPU_ChanUpdate<3,INTERPOLATE_MODE>(actuallyMix, SPU, chan); break; + default: assert(false); + } +} + +FORCEINLINE static void _SPU_ChanUpdate(const bool actuallyMix, SPU_struct* const SPU, channel_struct* const chan) +{ + switch(CommonSettings.spuInterpolationMode) + { + case SPUInterpolation_None: __SPU_ChanUpdate(actuallyMix, SPU, chan); break; + case SPUInterpolation_Linear: __SPU_ChanUpdate(actuallyMix, SPU, chan); break; + case SPUInterpolation_Cosine: __SPU_ChanUpdate(actuallyMix, SPU, chan); break; + default: assert(false); + } +} + +template +static void SPU_MixAudio(SPU_struct *SPU, int length) +{ + u8 vol; + + if(actuallyMix) + { + memset(SPU->sndbuf, 0, length*4*2); + memset(SPU->outbuf, 0, length*2*2); + } + + // If the sound speakers are disabled, don't output audio + if(!(T1ReadWord(MMU.ARM7_REG, 0x304) & 0x01)) + return; + + // If Master Enable isn't set, don't output audio + if (!(T1ReadByte(MMU.ARM7_REG, 0x501) & 0x80)) + return; + + vol = T1ReadByte(MMU.ARM7_REG, 0x500) & 0x7F; + + for(int i=0;i<16;i++) + { + channel_struct *chan = &SPU->channels[i]; + + if (chan->status != CHANSTAT_PLAY) + continue; + + SPU->bufpos = 0; + SPU->buflength = length; + + // Mix audio + _SPU_ChanUpdate(!CommonSettings.spu_muteChannels[i] && actuallyMix, SPU, chan); + } + + // convert from 32-bit->16-bit + if(actuallyMix) + for (int i = 0; i < length*2; i++) + { + // Apply Master Volume + SPU->sndbuf[i] = spumuldiv7(SPU->sndbuf[i], vol); + + if (SPU->sndbuf[i] > 0x7FFF) + SPU->outbuf[i] = 0x7FFF; + else if (SPU->sndbuf[i] < -0x8000) + SPU->outbuf[i] = -0x8000; + else + SPU->outbuf[i] = (s16)SPU->sndbuf[i]; + } +} + +////////////////////////////////////////////////////////////////////////////// + + +//emulates one frame of the cpu core. +//this will produce a variable number of samples, calculated to keep a 44100hz output +//in sync with the emulator framerate +static double samples = 0; +static const double time_per_frame = (double)1.0/((double)ARM7_CLOCK/6/355); //(double)1.0/(double)59.8261; // ((double)ARM7_CLOCK/6/355/263) +static const double samples_per_frame = time_per_frame * 44100; +int spu_core_samples = 0; +void SPU_Emulate_core() +{ + samples += samples_per_frame; + spu_core_samples = (int)(samples); + samples -= spu_core_samples; + + if(driver->AVI_IsRecording() || driver->WAV_IsRecording()) + SPU_MixAudio(SPU_core,spu_core_samples); + else + SPU_MixAudio(SPU_core,spu_core_samples); +} + +void SPU_Emulate_user() +{ + if(!SPU_user) + return; + + u32 audiosize; + + // Check to see how much free space there is + // If there is some, fill up the buffer + audiosize = SNDCore->GetAudioSpace(); + + if (audiosize > 0) + { + if (audiosize > SPU_user->bufsize) + audiosize = SPU_user->bufsize; + SPU_MixAudio(SPU_user,audiosize); + SNDCore->UpdateAudio(SPU_user->outbuf, audiosize); + } +} + +////////////////////////////////////////////////////////////////////////////// +// Dummy Sound Interface +////////////////////////////////////////////////////////////////////////////// + +int SNDDummyInit(int buffersize); +void SNDDummyDeInit(); +void SNDDummyUpdateAudio(s16 *buffer, u32 num_samples); +u32 SNDDummyGetAudioSpace(); +void SNDDummyMuteAudio(); +void SNDDummyUnMuteAudio(); +void SNDDummySetVolume(int volume); + +SoundInterface_struct SNDDummy = { + SNDCORE_DUMMY, + "Dummy Sound Interface", + SNDDummyInit, + SNDDummyDeInit, + SNDDummyUpdateAudio, + SNDDummyGetAudioSpace, + SNDDummyMuteAudio, + SNDDummyUnMuteAudio, + SNDDummySetVolume +}; + +////////////////////////////////////////////////////////////////////////////// + +int SNDDummyInit(int buffersize) +{ + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDummyDeInit() +{ +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDummyUpdateAudio(s16 *buffer, u32 num_samples) +{ +} + +////////////////////////////////////////////////////////////////////////////// + +u32 SNDDummyGetAudioSpace() +{ + return 740; +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDummyMuteAudio() +{ +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDummyUnMuteAudio() +{ +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDummySetVolume(int volume) +{ +} + +////////////////////////////////////////////////////////////////////////////// + +typedef struct { + char id[4]; + u32 size; +} chunk_struct; + +typedef struct { + chunk_struct riff; + char rifftype[4]; +} waveheader_struct; + +typedef struct { + chunk_struct chunk; + u16 compress; + u16 numchan; + u32 rate; + u32 bytespersec; + u16 blockalign; + u16 bitspersample; +} fmt_struct; + +WavWriter::WavWriter() +: spufp(NULL) +{ +} +bool WavWriter::open(const std::string & fname) +{ + waveheader_struct waveheader; + fmt_struct fmt; + chunk_struct data; + size_t elems_written = 0; + + if ((spufp = fopen(fname.c_str(), "wb")) == NULL) + return false; + + // Do wave header + memcpy(waveheader.riff.id, "RIFF", 4); + waveheader.riff.size = 0; // we'll fix this after the file is closed + memcpy(waveheader.rifftype, "WAVE", 4); + elems_written += fwrite((void *)&waveheader, 1, sizeof(waveheader_struct), spufp); + + // fmt chunk + memcpy(fmt.chunk.id, "fmt ", 4); + fmt.chunk.size = 16; // we'll fix this at the end + fmt.compress = 1; // PCM + fmt.numchan = 2; // Stereo + fmt.rate = 44100; + fmt.bitspersample = 16; + fmt.blockalign = fmt.bitspersample / 8 * fmt.numchan; + fmt.bytespersec = fmt.rate * fmt.blockalign; + elems_written += fwrite((void *)&fmt, 1, sizeof(fmt_struct), spufp); + + // data chunk + memcpy(data.id, "data", 4); + data.size = 0; // we'll fix this at the end + elems_written += fwrite((void *)&data, 1, sizeof(chunk_struct), spufp); + + return true; +} + +void WavWriter::close() +{ + if(!spufp) return; + size_t elems_written = 0; + long length = ftell(spufp); + + // Let's fix the riff chunk size and the data chunk size + fseek(spufp, sizeof(waveheader_struct)-0x8, SEEK_SET); + length -= 0x8; + elems_written += fwrite((void *)&length, 1, 4, spufp); + + fseek(spufp, sizeof(waveheader_struct)+sizeof(fmt_struct)+0x4, SEEK_SET); + length -= sizeof(waveheader_struct)+sizeof(fmt_struct); + elems_written += fwrite((void *)&length, 1, 4, spufp); + fclose(spufp); + spufp = NULL; +} + +void WavWriter::update(void* soundData, int numSamples) +{ + if(!spufp) return; + //TODO - big endian for the s16 samples?? + size_t elems_written = fwrite(soundData, numSamples*2, 2, spufp); +} + +bool WavWriter::isRecording() const +{ + return spufp != NULL; +} + + +static WavWriter wavWriter; + +void WAV_End() +{ + wavWriter.close(); +} + +bool WAV_Begin(const char* fname) +{ + WAV_End(); + + if(!wavWriter.open(fname)) + return false; + + driver->USR_InfoMessage("WAV recording started."); + + return true; +} + +bool WAV_IsRecording() +{ + return wavWriter.isRecording(); +} + +void WAV_WavSoundUpdate(void* soundData, int numSamples) +{ + wavWriter.update(soundData, numSamples); +} + + + +////////////////////////////////////////////////////////////////////////////// + +void spu_savestate(std::ostream* os) +{ + //version + write32le(2,os); + + SPU_struct *spu = SPU_core; + + for(int j=0;j<16;j++) { + channel_struct &chan = spu->channels[j]; + write32le(chan.num,os); + write8le(chan.vol,os); + write8le(chan.datashift,os); + write8le(chan.hold,os); + write8le(chan.pan,os); + write8le(chan.waveduty,os); + write8le(chan.repeat,os); + write8le(chan.format,os); + write8le(chan.status,os); + write32le(chan.addr,os); + write16le(chan.timer,os); + write16le(chan.loopstart,os); + write32le(chan.length,os); + write64le(double_to_u64(chan.sampcnt),os); + write64le(double_to_u64(chan.sampinc),os); + write32le(chan.lastsampcnt,os); + write16le(chan.pcm16b,os); + write16le(chan.pcm16b_last,os); + write32le(chan.index,os); + write16le(chan.x,os); + write16le(chan.psgnoise_last,os); + } + + write64le(double_to_u64(samples),os); +} + +bool spu_loadstate(std::istream* is, int size) +{ + u64 temp64; + + //read version + int version; + if(read32le(&version,is) != 1) return false; + + SPU_struct *spu = SPU_core; + + for(int j=0;j<16;j++) { + channel_struct &chan = spu->channels[j]; + read32le(&chan.num,is); + read8le(&chan.vol,is); + read8le(&chan.datashift,is); + read8le(&chan.hold,is); + read8le(&chan.pan,is); + read8le(&chan.waveduty,is); + read8le(&chan.repeat,is); + read8le(&chan.format,is); + read8le(&chan.status,is); + read32le(&chan.addr,is); + read16le(&chan.timer,is); + read16le(&chan.loopstart,is); + read32le(&chan.length,is); + chan.totlength = chan.length + chan.loopstart; + chan.double_totlength_shifted = (double)(chan.totlength << format_shift[chan.format]); + if(version != 1) + { + read64le(&temp64,is); chan.sampcnt = u64_to_double(temp64); + read64le(&temp64,is); chan.sampinc = u64_to_double(temp64); + } + else + { + read32le((u32*)&chan.sampcnt,is); + read32le((u32*)&chan.sampinc,is); + } + read32le(&chan.lastsampcnt,is); + read16le(&chan.pcm16b,is); + read16le(&chan.pcm16b_last,is); + read32le(&chan.index,is); + read16le(&chan.x,is); + read16le(&chan.psgnoise_last,is); + + //fixup the pointers which we had are supposed to keep cached + chan.buf8 = (s8*)&MMU.MMU_MEM[1][(chan.addr>>20)&0xFF][(chan.addr & MMU.MMU_MASK[1][(chan.addr >> 20) & 0xFF])]; + } + + if(version==2) { + read64le(&temp64,is); samples = u64_to_double(temp64); + } + + //copy the core spu (the more accurate) to the user spu + if(SPU_user) { + for(int i=0;i<16;i++) + { + channel_struct &chan = SPU_user->channels[i]; + if(chan.cacheItem) chan.cacheItem->unlock(); + } + + memcpy(SPU_user->channels,SPU_core->channels,sizeof(SPU_core->channels)); + + if(CommonSettings.spuAdpcmCache) + for(int i=0;i<16;i++) + { + channel_struct &chan = SPU_user->channels[i]; + if(chan.format == 2) + chan.cacheItem = adpcmCache.scan(&chan); + } + } + + return true; +} diff --git a/desmume/src/SPU.h b/src/SPU.h similarity index 95% rename from desmume/src/SPU.h rename to src/SPU.h index 493f62bfd..b7e1bc3ec 100644 --- a/desmume/src/SPU.h +++ b/src/SPU.h @@ -1,168 +1,168 @@ -/* SPU.h - - Copyright 2006 Theo Berkau - Copyright (C) 2006-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef SPU_H -#define SPU_H - -#include "types.h" -#include "matrix.h" -#include -#include -#include - -#define SNDCORE_DEFAULT -1 -#define SNDCORE_DUMMY 0 - -#define CHANSTAT_STOPPED 0 -#define CHANSTAT_PLAY 1 - -static FORCEINLINE u32 sputrunc(float f) { return u32floor(f); } -static FORCEINLINE u32 sputrunc(double d) { return u32floor(d); } -static FORCEINLINE s32 spumuldiv7(s32 val, u8 multiplier) { - assert(multiplier <= 127); - return (multiplier == 127) ? val : ((val * multiplier) >> 7); -} - -enum SPUInterpolationMode -{ - SPUInterpolation_None = 0, - SPUInterpolation_Linear = 1, - SPUInterpolation_Cosine = 2 -}; - -struct SoundInterface_struct -{ - int id; - const char *Name; - int (*Init)(int buffersize); - void (*DeInit)(); - void (*UpdateAudio)(s16 *buffer, u32 num_samples); - u32 (*GetAudioSpace)(); - void (*MuteAudio)(); - void (*UnMuteAudio)(); - void (*SetVolume)(int volume); -}; - -extern SoundInterface_struct SNDDummy; -extern SoundInterface_struct SNDFile; -extern int SPU_currentCoreNum; - -class ADPCMCacheItem; - -struct channel_struct -{ - channel_struct() - : cacheItem(NULL) - {} - int num; - u8 vol; - u8 datashift; - u8 hold; - u8 pan; - u8 waveduty; - u8 repeat; - u8 format; - u8 status; - u32 addr; - u16 timer; - u16 loopstart; - u32 length; - u32 totlength; - double double_totlength_shifted; - union { - s8 *buf8; - s16 *buf16; - }; - double sampcnt; - double sampinc; - // ADPCM specific - u32 lastsampcnt; - s16 pcm16b, pcm16b_last; - int index; - u16 x; - s16 psgnoise_last; - ADPCMCacheItem *cacheItem; -} ; - -class SPU_struct -{ -public: - SPU_struct(int buffersize); - u32 bufpos; - u32 buflength; - s32 *sndbuf; - s16 *outbuf; - u32 bufsize; - channel_struct channels[16]; - - void reset(); - ~SPU_struct(); - void KeyOn(int channel); - void WriteByte(u32 addr, u8 val); - void WriteWord(u32 addr, u16 val); - void WriteLong(u32 addr, u32 val); - - //kills all channels but leaves SPU otherwise running normally - void ShutUp(); -}; - -int SPU_ChangeSoundCore(int coreid, int buffersize); -SoundInterface_struct *SPU_SoundCore(); - -int SPU_Init(int coreid, int buffersize); -void SPU_Pause(int pause); -void SPU_SetVolume(int volume); -void SPU_Reset(void); -void SPU_DeInit(void); -void SPU_KeyOn(int channel); -void SPU_WriteByte(u32 addr, u8 val); -void SPU_WriteWord(u32 addr, u16 val); -void SPU_WriteLong(u32 addr, u32 val); -u32 SPU_ReadLong(u32 addr); -void SPU_Emulate_core(void); -void SPU_Emulate_user(void); - -extern SPU_struct *SPU_core, *SPU_user; -extern int spu_core_samples; - -void spu_savestate(std::ostream* os); -bool spu_loadstate(std::istream* is, int size); - -class WavWriter -{ -public: - WavWriter(); - bool open(const std::string & fname); - void close(); - void update(void* soundData, int numSamples); - bool isRecording() const; -private: - FILE *spufp; -}; - - -void WAV_End(); -bool WAV_Begin(const char* fname); -bool WAV_IsRecording(); -void WAV_WavSoundUpdate(void* soundData, int numSamples); - -#endif +/* SPU.h + + Copyright 2006 Theo Berkau + Copyright (C) 2006-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef SPU_H +#define SPU_H + +#include "types.h" +#include "matrix.h" +#include +#include +#include + +#define SNDCORE_DEFAULT -1 +#define SNDCORE_DUMMY 0 + +#define CHANSTAT_STOPPED 0 +#define CHANSTAT_PLAY 1 + +static FORCEINLINE u32 sputrunc(float f) { return u32floor(f); } +static FORCEINLINE u32 sputrunc(double d) { return u32floor(d); } +static FORCEINLINE s32 spumuldiv7(s32 val, u8 multiplier) { + assert(multiplier <= 127); + return (multiplier == 127) ? val : ((val * multiplier) >> 7); +} + +enum SPUInterpolationMode +{ + SPUInterpolation_None = 0, + SPUInterpolation_Linear = 1, + SPUInterpolation_Cosine = 2 +}; + +struct SoundInterface_struct +{ + int id; + const char *Name; + int (*Init)(int buffersize); + void (*DeInit)(); + void (*UpdateAudio)(s16 *buffer, u32 num_samples); + u32 (*GetAudioSpace)(); + void (*MuteAudio)(); + void (*UnMuteAudio)(); + void (*SetVolume)(int volume); +}; + +extern SoundInterface_struct SNDDummy; +extern SoundInterface_struct SNDFile; +extern int SPU_currentCoreNum; + +class ADPCMCacheItem; + +struct channel_struct +{ + channel_struct() + : cacheItem(NULL) + {} + int num; + u8 vol; + u8 datashift; + u8 hold; + u8 pan; + u8 waveduty; + u8 repeat; + u8 format; + u8 status; + u32 addr; + u16 timer; + u16 loopstart; + u32 length; + u32 totlength; + double double_totlength_shifted; + union { + s8 *buf8; + s16 *buf16; + }; + double sampcnt; + double sampinc; + // ADPCM specific + u32 lastsampcnt; + s16 pcm16b, pcm16b_last; + int index; + u16 x; + s16 psgnoise_last; + ADPCMCacheItem *cacheItem; +} ; + +class SPU_struct +{ +public: + SPU_struct(int buffersize); + u32 bufpos; + u32 buflength; + s32 *sndbuf; + s16 *outbuf; + u32 bufsize; + channel_struct channels[16]; + + void reset(); + ~SPU_struct(); + void KeyOn(int channel); + void WriteByte(u32 addr, u8 val); + void WriteWord(u32 addr, u16 val); + void WriteLong(u32 addr, u32 val); + + //kills all channels but leaves SPU otherwise running normally + void ShutUp(); +}; + +int SPU_ChangeSoundCore(int coreid, int buffersize); +SoundInterface_struct *SPU_SoundCore(); + +int SPU_Init(int coreid, int buffersize); +void SPU_Pause(int pause); +void SPU_SetVolume(int volume); +void SPU_Reset(void); +void SPU_DeInit(void); +void SPU_KeyOn(int channel); +void SPU_WriteByte(u32 addr, u8 val); +void SPU_WriteWord(u32 addr, u16 val); +void SPU_WriteLong(u32 addr, u32 val); +u32 SPU_ReadLong(u32 addr); +void SPU_Emulate_core(void); +void SPU_Emulate_user(void); + +extern SPU_struct *SPU_core, *SPU_user; +extern int spu_core_samples; + +void spu_savestate(std::ostream* os); +bool spu_loadstate(std::istream* is, int size); + +class WavWriter +{ +public: + WavWriter(); + bool open(const std::string & fname); + void close(); + void update(void* soundData, int numSamples); + bool isRecording() const; +private: + FILE *spufp; +}; + + +void WAV_End(); +bool WAV_Begin(const char* fname); +bool WAV_IsRecording(); +void WAV_WavSoundUpdate(void* soundData, int numSamples); + +#endif diff --git a/desmume/src/addons.cpp b/src/addons.cpp similarity index 95% rename from desmume/src/addons.cpp rename to src/addons.cpp index 41100a168..0d6ae953f 100644 --- a/desmume/src/addons.cpp +++ b/src/addons.cpp @@ -1,81 +1,81 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2009 CrazyMax - Copyright (C) 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "addons.h" -#include - -std::string CFlash_Path; -ADDON_CFLASH_MODE CFlash_Mode; - - -//char CFlashName[MAX_PATH]; -//char CFlashPath[MAX_PATH]; -//u8 CFlashUseRomPath = TRUE; -//u8 CFlashUsePath = TRUE; - -char GBAgameName[MAX_PATH]; - -extern ADDONINTERFACE addonNone; -extern ADDONINTERFACE addonCFlash; -extern ADDONINTERFACE addonRumblePak; -extern ADDONINTERFACE addonGBAgame; -extern ADDONINTERFACE addonGuitarGrip; -//extern ADDONINTERFACE addonExternalMic; - -ADDONINTERFACE addonList[NDS_ADDON_COUNT] = { - addonNone, - addonCFlash, - addonRumblePak, - addonGBAgame, - addonGuitarGrip -}; - -ADDONINTERFACE addon = addonCFlash; // default none pak -u8 addon_type = NDS_ADDON_CFLASH; - -BOOL addonsInit() -{ - return addon.init(); -} - -void addonsClose() -{ - addon.close(); -} - -void addonsReset() -{ - addon.reset(); -} - -BOOL addonsChangePak(u8 type) -{ - printf("addonsChangePak\n"); - if (type > NDS_ADDON_COUNT) return FALSE; - addon.close(); - addon = addonList[type]; - addon_type = type; - return addon.init(); -} - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2009 CrazyMax + Copyright (C) 2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "addons.h" +#include + +std::string CFlash_Path; +ADDON_CFLASH_MODE CFlash_Mode; + + +//char CFlashName[MAX_PATH]; +//char CFlashPath[MAX_PATH]; +//u8 CFlashUseRomPath = TRUE; +//u8 CFlashUsePath = TRUE; + +char GBAgameName[MAX_PATH]; + +extern ADDONINTERFACE addonNone; +extern ADDONINTERFACE addonCFlash; +extern ADDONINTERFACE addonRumblePak; +extern ADDONINTERFACE addonGBAgame; +extern ADDONINTERFACE addonGuitarGrip; +//extern ADDONINTERFACE addonExternalMic; + +ADDONINTERFACE addonList[NDS_ADDON_COUNT] = { + addonNone, + addonCFlash, + addonRumblePak, + addonGBAgame, + addonGuitarGrip +}; + +ADDONINTERFACE addon = addonCFlash; // default none pak +u8 addon_type = NDS_ADDON_CFLASH; + +BOOL addonsInit() +{ + return addon.init(); +} + +void addonsClose() +{ + addon.close(); +} + +void addonsReset() +{ + addon.reset(); +} + +BOOL addonsChangePak(u8 type) +{ + printf("addonsChangePak\n"); + if (type > NDS_ADDON_COUNT) return FALSE; + addon.close(); + addon = addonList[type]; + addon_type = type; + return addon.init(); +} + diff --git a/desmume/src/addons.h b/src/addons.h similarity index 96% rename from desmume/src/addons.h rename to src/addons.h index 4b6a7b2ff..0e5746fb0 100644 --- a/desmume/src/addons.h +++ b/src/addons.h @@ -1,96 +1,96 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2009 CrazyMax - Copyright (C) 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef __ADDONS_H__ -#define __ADDONS_H__ - -#include "common.h" -#include "types.h" -#include "debug.h" - -typedef struct -{ - // The name of the plugin, this name will appear in the plugins list - const char * name; - - //called once when the plugin starts up - BOOL (*init)(void); - - //called when the emulator resets - void (*reset)(void); - - //called when the plugin shuts down - void (*close)(void); - - //called when the user configurating plugin - void (*config)(void); - - //called when the emulator write to addon - void (*write08)(u32 adr, u8 val); - void (*write16)(u32 adr, u16 val); - void (*write32)(u32 adr, u32 val); - - //called when the emulator read from addon - u8 (*read08)(u32 adr); - u16 (*read16)(u32 adr); - u32 (*read32)(u32 adr); - - //called when the user get info about addon pak (description) - void (*info)(char *info); -} ADDONINTERFACE; - -enum { - NDS_ADDON_NONE, - NDS_ADDON_CFLASH, // compact flash - NDS_ADDON_RUMBLEPAK, // rumble pack - NDS_ADDON_GBAGAME, // gba game in slot - NDS_ADDON_GUITARGRIP, // Guitar Grip - //NDS_ADDON_EXTERNALMIC, - NDS_ADDON_COUNT // use for counter addons - MUST TO BE LAST!!! -}; - -enum ADDON_CFLASH_MODE -{ - ADDON_CFLASH_MODE_Path, ADDON_CFLASH_MODE_File, ADDON_CFLASH_MODE_RomPath -}; - -extern ADDON_CFLASH_MODE CFlash_Mode; -extern std::string CFlash_Path; -inline bool CFlash_IsUsingPath() { return CFlash_Mode==ADDON_CFLASH_MODE_Path || CFlash_Mode==ADDON_CFLASH_MODE_RomPath; } - -extern ADDONINTERFACE addon; // current pak -extern ADDONINTERFACE addonList[NDS_ADDON_COUNT]; // lists pointer on paks -extern u8 addon_type; // current type pak - -extern char GBAgameName[MAX_PATH]; // file name for GBA game (rom) -extern void (*FeedbackON)(BOOL enable); // feedback on/off - -extern BOOL addonsInit(); // Init addons -extern void addonsClose(); // Shutdown addons -extern void addonsReset(); // Reset addon -extern BOOL addonsChangePak(u8 type); // change current adddon - -extern void guitarGrip_setKey(bool green, bool red, bool yellow, bool blue); // Guitar grip keys - -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2009 CrazyMax + Copyright (C) 2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef __ADDONS_H__ +#define __ADDONS_H__ + +#include "common.h" +#include "types.h" +#include "debug.h" + +typedef struct +{ + // The name of the plugin, this name will appear in the plugins list + const char * name; + + //called once when the plugin starts up + BOOL (*init)(void); + + //called when the emulator resets + void (*reset)(void); + + //called when the plugin shuts down + void (*close)(void); + + //called when the user configurating plugin + void (*config)(void); + + //called when the emulator write to addon + void (*write08)(u32 adr, u8 val); + void (*write16)(u32 adr, u16 val); + void (*write32)(u32 adr, u32 val); + + //called when the emulator read from addon + u8 (*read08)(u32 adr); + u16 (*read16)(u32 adr); + u32 (*read32)(u32 adr); + + //called when the user get info about addon pak (description) + void (*info)(char *info); +} ADDONINTERFACE; + +enum { + NDS_ADDON_NONE, + NDS_ADDON_CFLASH, // compact flash + NDS_ADDON_RUMBLEPAK, // rumble pack + NDS_ADDON_GBAGAME, // gba game in slot + NDS_ADDON_GUITARGRIP, // Guitar Grip + //NDS_ADDON_EXTERNALMIC, + NDS_ADDON_COUNT // use for counter addons - MUST TO BE LAST!!! +}; + +enum ADDON_CFLASH_MODE +{ + ADDON_CFLASH_MODE_Path, ADDON_CFLASH_MODE_File, ADDON_CFLASH_MODE_RomPath +}; + +extern ADDON_CFLASH_MODE CFlash_Mode; +extern std::string CFlash_Path; +inline bool CFlash_IsUsingPath() { return CFlash_Mode==ADDON_CFLASH_MODE_Path || CFlash_Mode==ADDON_CFLASH_MODE_RomPath; } + +extern ADDONINTERFACE addon; // current pak +extern ADDONINTERFACE addonList[NDS_ADDON_COUNT]; // lists pointer on paks +extern u8 addon_type; // current type pak + +extern char GBAgameName[MAX_PATH]; // file name for GBA game (rom) +extern void (*FeedbackON)(BOOL enable); // feedback on/off + +extern BOOL addonsInit(); // Init addons +extern void addonsClose(); // Shutdown addons +extern void addonsReset(); // Reset addon +extern BOOL addonsChangePak(u8 type); // change current adddon + +extern void guitarGrip_setKey(bool green, bool red, bool yellow, bool blue); // Guitar grip keys + +#endif diff --git a/desmume/src/addons/compactFlash.cpp b/src/addons/compactFlash.cpp similarity index 95% rename from desmume/src/addons/compactFlash.cpp rename to src/addons/compactFlash.cpp index 37f0341ed..41df8e3cf 100644 --- a/desmume/src/addons/compactFlash.cpp +++ b/src/addons/compactFlash.cpp @@ -1,1025 +1,1025 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2006 Mic - Copyright (C) 2009 CrazyMax - Copyright (C) 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "../addons.h" -#include -#include -#include "debug.h" -#include -#include -#include - -#include -#include -#ifdef WIN32 -#include -#define OPEN_MODE _O_RDWR | _O_BINARY - -#define OPEN_FN _open -#define CLOSE_FN _close -#define LSEEK_FN _lseek -#define WRITE_FN _write -#define READ_FN _read -#else -#include -#define OPEN_MODE O_RDWR - -#define OPEN_FN open -#define CLOSE_FN close -#define LSEEK_FN lseek -#define WRITE_FN write -#define READ_FN read -#endif - -#include "types.h" -#include "../fat.h" -#include "../fs.h" -#include "MMU.h" -#include "NDSSystem.h" -#include "../path.h" - -typedef struct { - int level,parent,filesInDir; -} FILE_INFO; - -// Set up addresses for GBAMP -#define CF_REG_DATA 0x9000000 -#define CF_REG_ERR 0x9020000 -#define CF_REG_SEC 0x9040000 -#define CF_REG_LBA1 0x9060000 -#define CF_REG_LBA2 0x9080000 -#define CF_REG_LBA3 0x90A0000 -#define CF_REG_LBA4 0x90C0000 -#define CF_REG_CMD 0x90E0000 -#define CF_REG_STS 0x98C0000 - -// CF Card commands -#define CF_CMD_LBA 0xE0 -#define CF_CMD_READ 0x20 -#define CF_CMD_WRITE 0x30 - -static int disk_image = -1; -static off_t file_size; - -static u16 cf_reg_sts, - cf_reg_lba1, - cf_reg_lba2, - cf_reg_lba3, - cf_reg_lba4, - cf_reg_cmd; -static off_t currLBA; - -static const int lfnPos[13] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; - -#define SECPERFAT 128 -#define SECPERCLUS 16 -#define MAXFILES 32768 -#define SECRESV 2 -#define NUMSECTORS 0x80000 -#define NUMCLUSTERS (NUMSECTORS/SECPERCLUS) -#define BYTESPERCLUS (512*SECPERCLUS) -#define DIRENTSPERCLUS ((BYTESPERCLUS)/32) - -BOOT_RECORD MBR; -static DIR_ENT *files,*dirEntries,**dirEntryPtr; -static FILE_INFO *fileLink,*dirEntryLink; -static u32 filesysFAT,filesysRootDir,filesysData; -static u16 FAT16[SECPERFAT*256]; -static u16 numExtraEntries[SECPERFAT*256]; -static DIR_ENT *extraDirEntries[SECPERFAT*256]; -static int numFiles,maxLevel,numRootFiles; -static int *dirEntriesInCluster, clusterNum, firstDirEntCluster, - lastDirEntCluster, lastFileDataCluster; -static int activeDirEnt=-1; -static u32 bufferStart; -static u32 fileStartLBA,fileEndLBA; -static u16 freadBuffer[256]; -static FILE * hFile; -static char fpath[255+1]; -static BOOL cflashDeviceEnabled = FALSE; - -static std::string sFlashPath; - -// =========================== -BOOL inited; - -static int lfn_checksum( void) -{ - int i; - u8 chk = 0; - - for (i=0; i < (NAME_LEN + EXT_LEN); i++) - { - chk = ((chk & 1) ? 0x80 : 0) + (chk >> 1) + - (i < NAME_LEN ? files[numFiles].name[i] : files[numFiles].ext[i - NAME_LEN]); - } - return chk; -} - -// Add a DIR_ENT for the files -static void add_file(char *fname, FsEntry * entry, int fileLevel) -{ - int i,j,k,n; - u8 chk; - - if (numFiles < MAXFILES-1) - { - if (strcmp(fname,"..") != 0) - { - for (i=strlen(fname)-1; i>=0; i--) - if (fname[i]=='.') break; - if ((i==0)&&(strcmp(fname,".")==0)) i = 1; - if (i<0) i = strlen(fname); - for (j=0; j=strlen(fname)) break; - files[numFiles].ext[j] = fname[j+i+1]; - } - for (; j<3; j++) - files[numFiles].ext[j] = 0x20; - - fileLink[fileLevel].filesInDir += 1; - - // See if LFN entries need to be added - if (strlen(entry->cAlternateFileName)>0) - { - char *p = NULL; - - chk = lfn_checksum(); - k = (strlen(entry->cFileName)/13) + (((strlen(entry->cFileName)%13)!=0)?1:0); - numFiles += k; - - fileLink[fileLevel].filesInDir += k; - - n = 0; - j = 13; - for (i=0; (size_t)icFileName); i++) - { - if (j == 13) - { - n++; - p = (char*)&files[numFiles-n].name[0]; - fileLink[numFiles-n].parent = fileLevel; - p[0] = n; - ((DIR_ENT*)p)->attrib = ATTRIB_LFN; - p[0xD] = chk; - j = 0; - } - *(p + lfnPos[j]) = entry->cFileName[i]; - *(p + lfnPos[j]+1) = 0; - j++; - } - for (; j<13; j++) - { - *(p + lfnPos[j]) = entry->cFileName[i]; - *(p + lfnPos[j]+1) = 0; - } - if (p != NULL) - p[0] |= 0x40; // END - for (i=strlen(fname)-1; i>=0; i--) - if (fname[i]=='.') break; - if ((i==0)&&(strcmp(fname,".")==0)) i = 1; - if (i<0) i = strlen(fname); - for (j=0; j=strlen(fname)) break; - files[numFiles].ext[j] = fname[j+i+1]; - } - for (; j<3; j++) - files[numFiles].ext[j] = 0x20; - } - - files[numFiles].fileSize = entry->fileSize; - - if (entry->flags & FS_IS_DIR) - { - if (strcmp(fname,".")==0) - fileLink[numFiles].level = maxLevel; - else - fileLink[numFiles].level = maxLevel+1; - files[numFiles].attrib = ATTRIB_DIR; - } - else - files[numFiles].attrib = 0; - - fileLink[numFiles].parent = fileLevel; - - numFiles++; - } - else - if (fileLevel > 0) - { - fileLink[fileLevel].filesInDir += 1; - strncpy((char*)&files[numFiles].name[0],".. ",NAME_LEN); - strncpy((char*)&files[numFiles].ext[0]," ",EXT_LEN); - fileLink[numFiles].parent = fileLevel; - files[numFiles].attrib = 0x10; - numFiles++; - } - } -} - -// List all files and subdirectories recursively -static void list_files(const char *filepath) -{ - char DirSpec[255+1], SubDir[255+1]; - FsEntry entry; - void * hFind; - char *fname; - u32 dwError; - int fileLevel; - - maxLevel++; - fileLevel = maxLevel; - - strncpy(DirSpec, filepath, ARRAY_SIZE(DirSpec)); - DirSpec[255] = 0 ; // hard limit the string here - - hFind = FsReadFirst(DirSpec, &entry); - if (hFind == NULL) return; - - fname = (strlen(entry.cAlternateFileName)>0) ? entry.cAlternateFileName : entry.cFileName; - add_file(fname, &entry, fileLevel); - - while (FsReadNext(hFind, &entry) != 0) - { - fname = (strlen(entry.cAlternateFileName)>0) ? entry.cAlternateFileName : entry.cFileName; - add_file(fname, &entry, fileLevel); - CFLASHLOG("cflash added %s\n",fname); - - if (numFiles==MAXFILES-1) break; - - if ((entry.flags & FS_IS_DIR) && (strcmp(fname, ".")) && (strcmp(fname, ".."))) - { - if (strlen(fname)+strlen(filepath)+2 < 256) - { - sprintf(SubDir, "%s%c%s", filepath, FS_SEPARATOR, fname); - list_files(SubDir); - } - } - } - - dwError = FsError(); - FsClose(hFind); - if (dwError != FS_ERR_NO_MORE_FILES) return; - - if (numFiles < MAXFILES) - { - fileLink[numFiles].parent = fileLevel; - files[numFiles++].name[0] = 0; - } -} - -// Set up the MBR, FAT and DIR_ENTs -static BOOL cflash_build_fat() -{ - int i,j,k,l, - clust,numClusters, - clusterNum2,rootCluster; - int fileLevel; - - numFiles = 0; - fileLevel = -1; - maxLevel = -1; - - files = (DIR_ENT *) malloc(MAXFILES*sizeof(DIR_ENT)); - if (files == NULL) return FALSE; - fileLink = (FILE_INFO *) malloc(MAXFILES*sizeof(FILE_INFO)); - if (fileLink == NULL) - { - free(files); - return FALSE; - } - - for (i=0; i>8; - clust += l; - numClusters += l; - } - } - else - dirEntries[k-1].startCluster = clusterNum; - } - if (i==0) numRootFiles++; - dirEntriesInCluster[clusterNum]++; - if (dirEntriesInCluster[clusterNum]==256) - clusterNum++; - } - } - clusterNum = clusterNum2 + ((fileLink[i].filesInDir)>>8) + 1; - numClusters++; - } - - // Free the file indexing buffer - free(files); - free(fileLink); - - // Set up the MBR - MBR.bytesPerSector = 512; - MBR.numFATs = 1; - // replaced strcpy with strncpy. It doesnt matter here, as the strings are constant - // but we should extingish all unrestricted strcpy,strcat from the project - strncpy((char*)&MBR.OEMName[0],"DESMUM",8); - strncpy((char*)&MBR.fat16.fileSysType[0],"FAT16 ",8); - MBR.reservedSectors = SECRESV; - MBR.numSectors = 524288; - MBR.numSectorsSmall = 0; - MBR.sectorsPerCluster = SECPERCLUS; - MBR.sectorsPerFAT = SECPERFAT; - MBR.rootEntries = 512; - MBR.fat16.signature = 0xAA55; - MBR.mediaDesc = 1; - - filesysFAT = 0 + MBR.reservedSectors; - filesysRootDir = filesysFAT + (MBR.numFATs * MBR.sectorsPerFAT); - filesysData = filesysRootDir + ((MBR.rootEntries * sizeof(DIR_ENT)) / 512); - - // Set up the cluster values for all subdirectories - clust = filesysData / SECPERCLUS; - firstDirEntCluster = clust; - for (i=1; i rootCluster) - dirEntries[i].startCluster += clust-rootCluster; - } - } - lastDirEntCluster = clust+numClusters-1; - - // Set up the cluster values for all files - clust += numClusters; //clusterNum; - for (i=0; i 0) - { - if (dirEntries[i].startCluster+j < MAXFILES) - FAT16[dirEntries[i].startCluster+j] = dirEntries[i].startCluster+j+1; - j++; - l -= (512*16); - } - if ((dirEntries[i].attrib & ATTRIB_DIR)==0) - { - if (dirEntries[i].startCluster+j < MAXFILES) - FAT16[dirEntries[i].startCluster+j] = 0xFFFF; - } - k = dirEntries[i].startCluster+j; - } - } - - for (i=(filesysData/SECPERCLUS); iname[i] == ' ') break; - out[i] = pd->name[i]; - } - if ((pd->attrib & 0x10)==0) - { - out[i++] = '.'; - for (j=0; jext[j] == ' ') break; - out[i++] = pd->ext[j]; - } - } - out[i] = '\0'; -} - -// Resolve the path of a files by working backwards through the directory entries -static void resolve_path(int dirent) -{ - int i; - char dirname[128]; - - while (dirEntryLink[dirent].parent > 0) - { - for (i=0; i= bufferStart + 512)) - { - if (!hFile) - { - CFLASHLOG("fread_buffered with hFile null with offset %lu and bufferStart %lu\n", - offset, bufferStart); - return 0; - } - fseek(hFile, offset, SEEK_SET); - elems_read += fread(&freadBuffer, 1, 512, hFile); - bufferStart = offset; - } - - return freadBuffer[(offset-bufferStart)>>1]; - } - if (activeDirEnt != -1) - fclose(hFile); - - strncpy(fpath,sFlashPath.c_str(),ARRAY_SIZE(fpath)); - strncat(fpath,DIR_SEP,ARRAY_SIZE(fpath)-strlen(fpath)); - - resolve_path(dirent); - - fatstring_to_asciiz(dirent,fname,NULL); - strncat(fpath,fname,ARRAY_SIZE(fpath)-strlen(fpath)); - - CFLASHLOG("CFLASH Opening %s\n",fpath); - hFile = fopen(fpath, "rb"); - if (!hFile) return 0; - bufferStart = offset; - fseek(hFile, offset, SEEK_SET); - elems_read += fread(&freadBuffer, 1, 512, hFile); - - bufferStart = offset; - activeDirEnt = dirent; - fileStartLBA = (dirEntries[dirent].startCluster*512*SECPERCLUS); - fileEndLBA = fileStartLBA + dirEntries[dirent].fileSize; - - return freadBuffer[(offset-bufferStart)>>1]; -} - -static unsigned int cflash_read(unsigned int address) -{ - unsigned int ret_value = 0; - size_t elems_read = 0; -#if 0 /* used by next if 0 block */ -#define BUFFERED_BLOCK_SIZE 512 - static u8 block_buffer[BUFFERED_BLOCK_SIZE]; - static s32 buffered_start_index = -1; -#endif - - switch (address) - { - case CF_REG_STS: - ret_value = cf_reg_sts; - break; - - case CF_REG_DATA: - if (cf_reg_cmd == CF_CMD_READ) - { - if (!CFlash_IsUsingPath()) - { - if ( disk_image != -1) - { - u8 data[2]; -#if 0 - if (currLBA < buffered_start_index || currLBA >= (buffered_start_index + BUFFERED_BLOCK_SIZE)) - { - size_t read_bytes = 0; - LSEEK_FN( disk_image, currLBA, SEEK_SET); - - while (read_bytes < BUFFERED_BLOCK_SIZE) - { - size_t cur_read = READ_FN( disk_image, &block_buffer[read_bytes], - BUFFERED_BLOCK_SIZE - read_bytes); - - if ( cur_read == -1) - { - CFLASHLOG( "Error during read: %s\n", strerror(errno) ); - break; - } - read_bytes += cur_read; - } - - CFLASHLOG( "Read %d bytes\n", read_bytes); - - buffered_start_index = currLBA; - } - data[0] = block_buffer[currLBA - buffered_start_index]; - data[1] = block_buffer[currLBA + 1 - buffered_start_index]; -#else - LSEEK_FN( disk_image, currLBA, SEEK_SET); - elems_read += READ_FN( disk_image, data, 2); -#endif - ret_value = data[1] << 8 | data[0]; - } - currLBA += 2; - } - else // use path - { - unsigned char *p; - int i; - u32 cluster,cluster2,cluster3,fileLBA; - cluster = (currLBA / (512 * SECPERCLUS)); - cluster2 = (((currLBA/512) - filesysData) / SECPERCLUS) + 2; - - // Reading from the MBR - if (currLBA < 512) - { - p = (unsigned char*)&MBR; - ret_value = T1ReadWord(p, currLBA); - - // Reading the FAT - } - else - if (((u32)currLBA >= filesysFAT*512) && ((u32)currLBA < filesysRootDir*512)) - { - p = (unsigned char*)&FAT16[0]; - ret_value = T1ReadWord(p, currLBA - filesysFAT * 512); - - // Reading directory entries - } - else - if (((u32)currLBA >= filesysRootDir*512) && (cluster <= (u32)lastDirEntCluster)) - { - cluster3 = ((currLBA - (SECRESV * 512)) / (512 * SECPERCLUS)); - i = (currLBA-(((cluster3-(filesysRootDir/SECPERCLUS))*SECPERCLUS+filesysRootDir)*512)); //(currLBA - cluster*BYTESPERCLUS); - if (i < (dirEntriesInCluster[cluster3]*32)) - { - p = (unsigned char*)dirEntryPtr[cluster3]; - ret_value = T1ReadWord(p, i); - } - else - { - i /= 32; - i -= dirEntriesInCluster[cluster3]; - if ((i>=0)&&(i (u32)lastDirEntCluster) && (cluster2 <= (u32)lastFileDataCluster)) - { - //else if ((cluster>lastDirEntCluster)&&(cluster<=lastFileDataCluster)) { - fileLBA = currLBA - (filesysData-32)*512; // 32 = # sectors used for the root entries - - // Check if the read is from the currently opened file - if ((fileLBA >= fileStartLBA) && (fileLBA < fileEndLBA)) - { - cluster = (fileLBA / (512 * SECPERCLUS)); - ret_value = fread_buffered(activeDirEnt,cluster-dirEntries[activeDirEnt].startCluster,(fileLBA-fileStartLBA)&(BYTESPERCLUS-1)); - } - else - { - for (i=0; i=(u32)(dirEntries[i].startCluster*512*SECPERCLUS)) && - (fileLBA <(dirEntries[i].startCluster*512*SECPERCLUS)+dirEntries[i].fileSize) && - ((dirEntries[i].attrib & (ATTRIB_DIR|ATTRIB_LFN))==0)) - { - cluster = (fileLBA / (512 * SECPERCLUS)); - ret_value = fread_buffered(i,cluster-dirEntries[i].startCluster,fileLBA&(BYTESPERCLUS-1)); - break; - } - } - } - } - currLBA += 2; - } - } - break; - - case CF_REG_CMD: - break; - - case CF_REG_LBA1: - ret_value = cf_reg_lba1; - break; - } - - return ret_value; -} - -static void cflash_write(unsigned int address,unsigned int data) -{ - static u8 sector_data[512]; - static u32 sector_write_index = 0; - - switch (address) - { - case CF_REG_STS: - cf_reg_sts = data&0xFFFF; - break; - - case CF_REG_DATA: - if (cf_reg_cmd == CF_CMD_WRITE) - { - if (!CFlash_IsUsingPath()) - { - sector_data[sector_write_index] = (data >> 0) & 0xff; - sector_data[sector_write_index + 1] = (data >> 8) & 0xff; - - sector_write_index += 2; - - if (sector_write_index == 512) - { - CFLASHLOG( "Write sector to %ld\n", currLBA); - size_t written = 0; - - if (currLBA + 512 < file_size) - { - if (disk_image != -1) - { - LSEEK_FN( disk_image, currLBA, SEEK_SET); - - while(written < 512) - { - size_t cur_write = - WRITE_FN( disk_image, §or_data[written], 512 - written); - written += cur_write; - - if ( cur_write == (size_t)-1) break; - } - } - } - - CFLASHLOG("Wrote %u bytes\n", written); - } - currLBA += 512; - sector_write_index = 0; - } - else // TODO: write to real partition - { - } - } - break; - - case CF_REG_CMD: - cf_reg_cmd = data&0xFF; - cf_reg_sts = 0x58; // READY - break; - - case CF_REG_LBA1: - cf_reg_lba1 = data&0xFF; - currLBA = (currLBA&0xFFFFFF00)| cf_reg_lba1; - break; - - case CF_REG_LBA2: - cf_reg_lba2 = data&0xFF; - currLBA = (currLBA&0xFFFF00FF)|(cf_reg_lba2<<8); - break; - - case CF_REG_LBA3: - cf_reg_lba3 = data&0xFF; - currLBA = (currLBA&0xFF00FFFF)|(cf_reg_lba3<<16); - break; - - case CF_REG_LBA4: - cf_reg_lba4 = data&0xFF; - - if ((cf_reg_lba4 & 0xf0) == CF_CMD_LBA) - { - currLBA = (currLBA&0x00FFFFFF)|((cf_reg_lba4&0x0F)<<24); - currLBA *= 512; - sector_write_index = 0; - } - break; - } -} - -static void cflash_close( void) -{ - if (!inited) return; - if (!CFlash_IsUsingPath()) - { - if (disk_image != -1) - { - CLOSE_FN(disk_image); - disk_image = -1; - } - } - else - { - int i; - - if (cflashDeviceEnabled) - { - cflashDeviceEnabled = FALSE; - - for (i=0; i +#include +#include "debug.h" +#include +#include +#include + +#include +#include +#ifdef WIN32 +#include +#define OPEN_MODE _O_RDWR | _O_BINARY + +#define OPEN_FN _open +#define CLOSE_FN _close +#define LSEEK_FN _lseek +#define WRITE_FN _write +#define READ_FN _read +#else +#include +#define OPEN_MODE O_RDWR + +#define OPEN_FN open +#define CLOSE_FN close +#define LSEEK_FN lseek +#define WRITE_FN write +#define READ_FN read +#endif + +#include "types.h" +#include "../fat.h" +#include "../fs.h" +#include "MMU.h" +#include "NDSSystem.h" +#include "../path.h" + +typedef struct { + int level,parent,filesInDir; +} FILE_INFO; + +// Set up addresses for GBAMP +#define CF_REG_DATA 0x9000000 +#define CF_REG_ERR 0x9020000 +#define CF_REG_SEC 0x9040000 +#define CF_REG_LBA1 0x9060000 +#define CF_REG_LBA2 0x9080000 +#define CF_REG_LBA3 0x90A0000 +#define CF_REG_LBA4 0x90C0000 +#define CF_REG_CMD 0x90E0000 +#define CF_REG_STS 0x98C0000 + +// CF Card commands +#define CF_CMD_LBA 0xE0 +#define CF_CMD_READ 0x20 +#define CF_CMD_WRITE 0x30 + +static int disk_image = -1; +static off_t file_size; + +static u16 cf_reg_sts, + cf_reg_lba1, + cf_reg_lba2, + cf_reg_lba3, + cf_reg_lba4, + cf_reg_cmd; +static off_t currLBA; + +static const int lfnPos[13] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; + +#define SECPERFAT 128 +#define SECPERCLUS 16 +#define MAXFILES 32768 +#define SECRESV 2 +#define NUMSECTORS 0x80000 +#define NUMCLUSTERS (NUMSECTORS/SECPERCLUS) +#define BYTESPERCLUS (512*SECPERCLUS) +#define DIRENTSPERCLUS ((BYTESPERCLUS)/32) + +BOOT_RECORD MBR; +static DIR_ENT *files,*dirEntries,**dirEntryPtr; +static FILE_INFO *fileLink,*dirEntryLink; +static u32 filesysFAT,filesysRootDir,filesysData; +static u16 FAT16[SECPERFAT*256]; +static u16 numExtraEntries[SECPERFAT*256]; +static DIR_ENT *extraDirEntries[SECPERFAT*256]; +static int numFiles,maxLevel,numRootFiles; +static int *dirEntriesInCluster, clusterNum, firstDirEntCluster, + lastDirEntCluster, lastFileDataCluster; +static int activeDirEnt=-1; +static u32 bufferStart; +static u32 fileStartLBA,fileEndLBA; +static u16 freadBuffer[256]; +static FILE * hFile; +static char fpath[255+1]; +static BOOL cflashDeviceEnabled = FALSE; + +static std::string sFlashPath; + +// =========================== +BOOL inited; + +static int lfn_checksum( void) +{ + int i; + u8 chk = 0; + + for (i=0; i < (NAME_LEN + EXT_LEN); i++) + { + chk = ((chk & 1) ? 0x80 : 0) + (chk >> 1) + + (i < NAME_LEN ? files[numFiles].name[i] : files[numFiles].ext[i - NAME_LEN]); + } + return chk; +} + +// Add a DIR_ENT for the files +static void add_file(char *fname, FsEntry * entry, int fileLevel) +{ + int i,j,k,n; + u8 chk; + + if (numFiles < MAXFILES-1) + { + if (strcmp(fname,"..") != 0) + { + for (i=strlen(fname)-1; i>=0; i--) + if (fname[i]=='.') break; + if ((i==0)&&(strcmp(fname,".")==0)) i = 1; + if (i<0) i = strlen(fname); + for (j=0; j=strlen(fname)) break; + files[numFiles].ext[j] = fname[j+i+1]; + } + for (; j<3; j++) + files[numFiles].ext[j] = 0x20; + + fileLink[fileLevel].filesInDir += 1; + + // See if LFN entries need to be added + if (strlen(entry->cAlternateFileName)>0) + { + char *p = NULL; + + chk = lfn_checksum(); + k = (strlen(entry->cFileName)/13) + (((strlen(entry->cFileName)%13)!=0)?1:0); + numFiles += k; + + fileLink[fileLevel].filesInDir += k; + + n = 0; + j = 13; + for (i=0; (size_t)icFileName); i++) + { + if (j == 13) + { + n++; + p = (char*)&files[numFiles-n].name[0]; + fileLink[numFiles-n].parent = fileLevel; + p[0] = n; + ((DIR_ENT*)p)->attrib = ATTRIB_LFN; + p[0xD] = chk; + j = 0; + } + *(p + lfnPos[j]) = entry->cFileName[i]; + *(p + lfnPos[j]+1) = 0; + j++; + } + for (; j<13; j++) + { + *(p + lfnPos[j]) = entry->cFileName[i]; + *(p + lfnPos[j]+1) = 0; + } + if (p != NULL) + p[0] |= 0x40; // END + for (i=strlen(fname)-1; i>=0; i--) + if (fname[i]=='.') break; + if ((i==0)&&(strcmp(fname,".")==0)) i = 1; + if (i<0) i = strlen(fname); + for (j=0; j=strlen(fname)) break; + files[numFiles].ext[j] = fname[j+i+1]; + } + for (; j<3; j++) + files[numFiles].ext[j] = 0x20; + } + + files[numFiles].fileSize = entry->fileSize; + + if (entry->flags & FS_IS_DIR) + { + if (strcmp(fname,".")==0) + fileLink[numFiles].level = maxLevel; + else + fileLink[numFiles].level = maxLevel+1; + files[numFiles].attrib = ATTRIB_DIR; + } + else + files[numFiles].attrib = 0; + + fileLink[numFiles].parent = fileLevel; + + numFiles++; + } + else + if (fileLevel > 0) + { + fileLink[fileLevel].filesInDir += 1; + strncpy((char*)&files[numFiles].name[0],".. ",NAME_LEN); + strncpy((char*)&files[numFiles].ext[0]," ",EXT_LEN); + fileLink[numFiles].parent = fileLevel; + files[numFiles].attrib = 0x10; + numFiles++; + } + } +} + +// List all files and subdirectories recursively +static void list_files(const char *filepath) +{ + char DirSpec[255+1], SubDir[255+1]; + FsEntry entry; + void * hFind; + char *fname; + u32 dwError; + int fileLevel; + + maxLevel++; + fileLevel = maxLevel; + + strncpy(DirSpec, filepath, ARRAY_SIZE(DirSpec)); + DirSpec[255] = 0 ; // hard limit the string here + + hFind = FsReadFirst(DirSpec, &entry); + if (hFind == NULL) return; + + fname = (strlen(entry.cAlternateFileName)>0) ? entry.cAlternateFileName : entry.cFileName; + add_file(fname, &entry, fileLevel); + + while (FsReadNext(hFind, &entry) != 0) + { + fname = (strlen(entry.cAlternateFileName)>0) ? entry.cAlternateFileName : entry.cFileName; + add_file(fname, &entry, fileLevel); + CFLASHLOG("cflash added %s\n",fname); + + if (numFiles==MAXFILES-1) break; + + if ((entry.flags & FS_IS_DIR) && (strcmp(fname, ".")) && (strcmp(fname, ".."))) + { + if (strlen(fname)+strlen(filepath)+2 < 256) + { + sprintf(SubDir, "%s%c%s", filepath, FS_SEPARATOR, fname); + list_files(SubDir); + } + } + } + + dwError = FsError(); + FsClose(hFind); + if (dwError != FS_ERR_NO_MORE_FILES) return; + + if (numFiles < MAXFILES) + { + fileLink[numFiles].parent = fileLevel; + files[numFiles++].name[0] = 0; + } +} + +// Set up the MBR, FAT and DIR_ENTs +static BOOL cflash_build_fat() +{ + int i,j,k,l, + clust,numClusters, + clusterNum2,rootCluster; + int fileLevel; + + numFiles = 0; + fileLevel = -1; + maxLevel = -1; + + files = (DIR_ENT *) malloc(MAXFILES*sizeof(DIR_ENT)); + if (files == NULL) return FALSE; + fileLink = (FILE_INFO *) malloc(MAXFILES*sizeof(FILE_INFO)); + if (fileLink == NULL) + { + free(files); + return FALSE; + } + + for (i=0; i>8; + clust += l; + numClusters += l; + } + } + else + dirEntries[k-1].startCluster = clusterNum; + } + if (i==0) numRootFiles++; + dirEntriesInCluster[clusterNum]++; + if (dirEntriesInCluster[clusterNum]==256) + clusterNum++; + } + } + clusterNum = clusterNum2 + ((fileLink[i].filesInDir)>>8) + 1; + numClusters++; + } + + // Free the file indexing buffer + free(files); + free(fileLink); + + // Set up the MBR + MBR.bytesPerSector = 512; + MBR.numFATs = 1; + // replaced strcpy with strncpy. It doesnt matter here, as the strings are constant + // but we should extingish all unrestricted strcpy,strcat from the project + strncpy((char*)&MBR.OEMName[0],"DESMUM",8); + strncpy((char*)&MBR.fat16.fileSysType[0],"FAT16 ",8); + MBR.reservedSectors = SECRESV; + MBR.numSectors = 524288; + MBR.numSectorsSmall = 0; + MBR.sectorsPerCluster = SECPERCLUS; + MBR.sectorsPerFAT = SECPERFAT; + MBR.rootEntries = 512; + MBR.fat16.signature = 0xAA55; + MBR.mediaDesc = 1; + + filesysFAT = 0 + MBR.reservedSectors; + filesysRootDir = filesysFAT + (MBR.numFATs * MBR.sectorsPerFAT); + filesysData = filesysRootDir + ((MBR.rootEntries * sizeof(DIR_ENT)) / 512); + + // Set up the cluster values for all subdirectories + clust = filesysData / SECPERCLUS; + firstDirEntCluster = clust; + for (i=1; i rootCluster) + dirEntries[i].startCluster += clust-rootCluster; + } + } + lastDirEntCluster = clust+numClusters-1; + + // Set up the cluster values for all files + clust += numClusters; //clusterNum; + for (i=0; i 0) + { + if (dirEntries[i].startCluster+j < MAXFILES) + FAT16[dirEntries[i].startCluster+j] = dirEntries[i].startCluster+j+1; + j++; + l -= (512*16); + } + if ((dirEntries[i].attrib & ATTRIB_DIR)==0) + { + if (dirEntries[i].startCluster+j < MAXFILES) + FAT16[dirEntries[i].startCluster+j] = 0xFFFF; + } + k = dirEntries[i].startCluster+j; + } + } + + for (i=(filesysData/SECPERCLUS); iname[i] == ' ') break; + out[i] = pd->name[i]; + } + if ((pd->attrib & 0x10)==0) + { + out[i++] = '.'; + for (j=0; jext[j] == ' ') break; + out[i++] = pd->ext[j]; + } + } + out[i] = '\0'; +} + +// Resolve the path of a files by working backwards through the directory entries +static void resolve_path(int dirent) +{ + int i; + char dirname[128]; + + while (dirEntryLink[dirent].parent > 0) + { + for (i=0; i= bufferStart + 512)) + { + if (!hFile) + { + CFLASHLOG("fread_buffered with hFile null with offset %lu and bufferStart %lu\n", + offset, bufferStart); + return 0; + } + fseek(hFile, offset, SEEK_SET); + elems_read += fread(&freadBuffer, 1, 512, hFile); + bufferStart = offset; + } + + return freadBuffer[(offset-bufferStart)>>1]; + } + if (activeDirEnt != -1) + fclose(hFile); + + strncpy(fpath,sFlashPath.c_str(),ARRAY_SIZE(fpath)); + strncat(fpath,DIR_SEP,ARRAY_SIZE(fpath)-strlen(fpath)); + + resolve_path(dirent); + + fatstring_to_asciiz(dirent,fname,NULL); + strncat(fpath,fname,ARRAY_SIZE(fpath)-strlen(fpath)); + + CFLASHLOG("CFLASH Opening %s\n",fpath); + hFile = fopen(fpath, "rb"); + if (!hFile) return 0; + bufferStart = offset; + fseek(hFile, offset, SEEK_SET); + elems_read += fread(&freadBuffer, 1, 512, hFile); + + bufferStart = offset; + activeDirEnt = dirent; + fileStartLBA = (dirEntries[dirent].startCluster*512*SECPERCLUS); + fileEndLBA = fileStartLBA + dirEntries[dirent].fileSize; + + return freadBuffer[(offset-bufferStart)>>1]; +} + +static unsigned int cflash_read(unsigned int address) +{ + unsigned int ret_value = 0; + size_t elems_read = 0; +#if 0 /* used by next if 0 block */ +#define BUFFERED_BLOCK_SIZE 512 + static u8 block_buffer[BUFFERED_BLOCK_SIZE]; + static s32 buffered_start_index = -1; +#endif + + switch (address) + { + case CF_REG_STS: + ret_value = cf_reg_sts; + break; + + case CF_REG_DATA: + if (cf_reg_cmd == CF_CMD_READ) + { + if (!CFlash_IsUsingPath()) + { + if ( disk_image != -1) + { + u8 data[2]; +#if 0 + if (currLBA < buffered_start_index || currLBA >= (buffered_start_index + BUFFERED_BLOCK_SIZE)) + { + size_t read_bytes = 0; + LSEEK_FN( disk_image, currLBA, SEEK_SET); + + while (read_bytes < BUFFERED_BLOCK_SIZE) + { + size_t cur_read = READ_FN( disk_image, &block_buffer[read_bytes], + BUFFERED_BLOCK_SIZE - read_bytes); + + if ( cur_read == -1) + { + CFLASHLOG( "Error during read: %s\n", strerror(errno) ); + break; + } + read_bytes += cur_read; + } + + CFLASHLOG( "Read %d bytes\n", read_bytes); + + buffered_start_index = currLBA; + } + data[0] = block_buffer[currLBA - buffered_start_index]; + data[1] = block_buffer[currLBA + 1 - buffered_start_index]; +#else + LSEEK_FN( disk_image, currLBA, SEEK_SET); + elems_read += READ_FN( disk_image, data, 2); +#endif + ret_value = data[1] << 8 | data[0]; + } + currLBA += 2; + } + else // use path + { + unsigned char *p; + int i; + u32 cluster,cluster2,cluster3,fileLBA; + cluster = (currLBA / (512 * SECPERCLUS)); + cluster2 = (((currLBA/512) - filesysData) / SECPERCLUS) + 2; + + // Reading from the MBR + if (currLBA < 512) + { + p = (unsigned char*)&MBR; + ret_value = T1ReadWord(p, currLBA); + + // Reading the FAT + } + else + if (((u32)currLBA >= filesysFAT*512) && ((u32)currLBA < filesysRootDir*512)) + { + p = (unsigned char*)&FAT16[0]; + ret_value = T1ReadWord(p, currLBA - filesysFAT * 512); + + // Reading directory entries + } + else + if (((u32)currLBA >= filesysRootDir*512) && (cluster <= (u32)lastDirEntCluster)) + { + cluster3 = ((currLBA - (SECRESV * 512)) / (512 * SECPERCLUS)); + i = (currLBA-(((cluster3-(filesysRootDir/SECPERCLUS))*SECPERCLUS+filesysRootDir)*512)); //(currLBA - cluster*BYTESPERCLUS); + if (i < (dirEntriesInCluster[cluster3]*32)) + { + p = (unsigned char*)dirEntryPtr[cluster3]; + ret_value = T1ReadWord(p, i); + } + else + { + i /= 32; + i -= dirEntriesInCluster[cluster3]; + if ((i>=0)&&(i (u32)lastDirEntCluster) && (cluster2 <= (u32)lastFileDataCluster)) + { + //else if ((cluster>lastDirEntCluster)&&(cluster<=lastFileDataCluster)) { + fileLBA = currLBA - (filesysData-32)*512; // 32 = # sectors used for the root entries + + // Check if the read is from the currently opened file + if ((fileLBA >= fileStartLBA) && (fileLBA < fileEndLBA)) + { + cluster = (fileLBA / (512 * SECPERCLUS)); + ret_value = fread_buffered(activeDirEnt,cluster-dirEntries[activeDirEnt].startCluster,(fileLBA-fileStartLBA)&(BYTESPERCLUS-1)); + } + else + { + for (i=0; i=(u32)(dirEntries[i].startCluster*512*SECPERCLUS)) && + (fileLBA <(dirEntries[i].startCluster*512*SECPERCLUS)+dirEntries[i].fileSize) && + ((dirEntries[i].attrib & (ATTRIB_DIR|ATTRIB_LFN))==0)) + { + cluster = (fileLBA / (512 * SECPERCLUS)); + ret_value = fread_buffered(i,cluster-dirEntries[i].startCluster,fileLBA&(BYTESPERCLUS-1)); + break; + } + } + } + } + currLBA += 2; + } + } + break; + + case CF_REG_CMD: + break; + + case CF_REG_LBA1: + ret_value = cf_reg_lba1; + break; + } + + return ret_value; +} + +static void cflash_write(unsigned int address,unsigned int data) +{ + static u8 sector_data[512]; + static u32 sector_write_index = 0; + + switch (address) + { + case CF_REG_STS: + cf_reg_sts = data&0xFFFF; + break; + + case CF_REG_DATA: + if (cf_reg_cmd == CF_CMD_WRITE) + { + if (!CFlash_IsUsingPath()) + { + sector_data[sector_write_index] = (data >> 0) & 0xff; + sector_data[sector_write_index + 1] = (data >> 8) & 0xff; + + sector_write_index += 2; + + if (sector_write_index == 512) + { + CFLASHLOG( "Write sector to %ld\n", currLBA); + size_t written = 0; + + if (currLBA + 512 < file_size) + { + if (disk_image != -1) + { + LSEEK_FN( disk_image, currLBA, SEEK_SET); + + while(written < 512) + { + size_t cur_write = + WRITE_FN( disk_image, §or_data[written], 512 - written); + written += cur_write; + + if ( cur_write == (size_t)-1) break; + } + } + } + + CFLASHLOG("Wrote %u bytes\n", written); + } + currLBA += 512; + sector_write_index = 0; + } + else // TODO: write to real partition + { + } + } + break; + + case CF_REG_CMD: + cf_reg_cmd = data&0xFF; + cf_reg_sts = 0x58; // READY + break; + + case CF_REG_LBA1: + cf_reg_lba1 = data&0xFF; + currLBA = (currLBA&0xFFFFFF00)| cf_reg_lba1; + break; + + case CF_REG_LBA2: + cf_reg_lba2 = data&0xFF; + currLBA = (currLBA&0xFFFF00FF)|(cf_reg_lba2<<8); + break; + + case CF_REG_LBA3: + cf_reg_lba3 = data&0xFF; + currLBA = (currLBA&0xFF00FFFF)|(cf_reg_lba3<<16); + break; + + case CF_REG_LBA4: + cf_reg_lba4 = data&0xFF; + + if ((cf_reg_lba4 & 0xf0) == CF_CMD_LBA) + { + currLBA = (currLBA&0x00FFFFFF)|((cf_reg_lba4&0x0F)<<24); + currLBA *= 512; + sector_write_index = 0; + } + break; + } +} + +static void cflash_close( void) +{ + if (!inited) return; + if (!CFlash_IsUsingPath()) + { + if (disk_image != -1) + { + CLOSE_FN(disk_image); + disk_image = -1; + } + } + else + { + int i; + + if (cflashDeviceEnabled) + { + cflashDeviceEnabled = FALSE; + + for (i=0; i -#include "../MMU.h" - -//SRAM is going to be stored just above the rom. -//that is convenient for us, since it mirrors the nds memory map - -static u8 *GBArom = NULL; - -#define GBA_ROMSIZE (32 * 1024 * 1024) -#define GBA_RAMSIZE (64 * 1024) -#define GBA_SIZE (GBA_ROMSIZE+GBA_RAMSIZE) - -static BOOL GBAgame_init(void) -{ - GBArom = new u8 [GBA_SIZE]; - return (TRUE); -} - -static void GBAgame_reset(void) -{ - memset(GBArom, 0, GBA_SIZE); - - if (!strlen(GBAgameName)) return; - FILE *fgame = 0; - - fgame = fopen(GBAgameName,"rb"); - if (!fgame) return; - INFO("Loaded \"%s\" in GBA slot\n", GBAgameName); - fseek(fgame, 0, SEEK_END); - u32 size = ftell(fgame); - rewind(fgame); - - if (!fread(GBArom, 1, size, fgame)) - { - fclose(fgame); - return; - } - - fclose(fgame); - - //try loading the sram - char * dot = strrchr(GBAgameName,'.'); - if(!dot) return; - std::string sram_fname = GBAgameName; - sram_fname.resize(dot-GBAgameName); - sram_fname += ".sav"; - fgame = fopen(sram_fname.c_str(),"rb"); - if(fgame) - { - fread(GBArom+GBA_ROMSIZE,1,GBA_RAMSIZE,fgame); - fclose(fgame); - } -} - -static void GBAgame_close(void) -{ - delete[] GBArom; - GBArom = NULL; -} - -static void GBAgame_config(void) {} -static void GBAgame_write08(u32 adr, u8 val){} -static void GBAgame_write16(u32 adr, u16 val) {} -static void GBAgame_write32(u32 adr, u32 val) {} - -static u8 GBAgame_read08(u32 adr) -{ - //INFO("Read08 at 0x%08X value 0x%02X\n", adr, (u8)T1ReadByte(GBArom, (adr - 0x08000000))); - if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) - return MMU.MMU_MEM[0][0xFF][(adr +0x1C) & MMU.MMU_MASK[0][0xFF]]; - return (u8)T1ReadByte(GBArom, (adr - 0x08000000)); -} - -static u16 GBAgame_read16(u32 adr) -{ - //INFO("Read16 at 0x%08X value 0x%04X\n", adr, (u16)T1ReadWord(GBArom, (adr - 0x08000000))); - if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) - return T1ReadWord(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]); - return (u16)T1ReadWord(GBArom, (adr - 0x08000000)); -} - -static u32 GBAgame_read32(u32 adr) -{ - //INFO("Read32 at 0x%08X value 0x%08X\n", adr, (u32)T1ReadLong(GBArom, (adr - 0x08000000))); - if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) - return T1ReadLong(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]); - return (u32)T1ReadLong(GBArom, (adr - 0x08000000)); -} - -static void GBAgame_info(char *info) -{ - strcpy(info, "GBA game in slot"); -} - -ADDONINTERFACE addonGBAgame = { - "GBA game", - GBAgame_init, - GBAgame_reset, - GBAgame_close, - GBAgame_config, - GBAgame_write08, - GBAgame_write16, - GBAgame_write32, - GBAgame_read08, - GBAgame_read16, - GBAgame_read32, - GBAgame_info}; +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2009 CrazyMax + Copyright (C) 2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "../addons.h" +#include "../mem.h" +#include +#include "../MMU.h" + +//SRAM is going to be stored just above the rom. +//that is convenient for us, since it mirrors the nds memory map + +static u8 *GBArom = NULL; + +#define GBA_ROMSIZE (32 * 1024 * 1024) +#define GBA_RAMSIZE (64 * 1024) +#define GBA_SIZE (GBA_ROMSIZE+GBA_RAMSIZE) + +static BOOL GBAgame_init(void) +{ + GBArom = new u8 [GBA_SIZE]; + return (TRUE); +} + +static void GBAgame_reset(void) +{ + memset(GBArom, 0, GBA_SIZE); + + if (!strlen(GBAgameName)) return; + FILE *fgame = 0; + + fgame = fopen(GBAgameName,"rb"); + if (!fgame) return; + INFO("Loaded \"%s\" in GBA slot\n", GBAgameName); + fseek(fgame, 0, SEEK_END); + u32 size = ftell(fgame); + rewind(fgame); + + if (!fread(GBArom, 1, size, fgame)) + { + fclose(fgame); + return; + } + + fclose(fgame); + + //try loading the sram + char * dot = strrchr(GBAgameName,'.'); + if(!dot) return; + std::string sram_fname = GBAgameName; + sram_fname.resize(dot-GBAgameName); + sram_fname += ".sav"; + fgame = fopen(sram_fname.c_str(),"rb"); + if(fgame) + { + fread(GBArom+GBA_ROMSIZE,1,GBA_RAMSIZE,fgame); + fclose(fgame); + } +} + +static void GBAgame_close(void) +{ + delete[] GBArom; + GBArom = NULL; +} + +static void GBAgame_config(void) {} +static void GBAgame_write08(u32 adr, u8 val){} +static void GBAgame_write16(u32 adr, u16 val) {} +static void GBAgame_write32(u32 adr, u32 val) {} + +static u8 GBAgame_read08(u32 adr) +{ + //INFO("Read08 at 0x%08X value 0x%02X\n", adr, (u8)T1ReadByte(GBArom, (adr - 0x08000000))); + if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) + return MMU.MMU_MEM[0][0xFF][(adr +0x1C) & MMU.MMU_MASK[0][0xFF]]; + return (u8)T1ReadByte(GBArom, (adr - 0x08000000)); +} + +static u16 GBAgame_read16(u32 adr) +{ + //INFO("Read16 at 0x%08X value 0x%04X\n", adr, (u16)T1ReadWord(GBArom, (adr - 0x08000000))); + if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) + return T1ReadWord(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]); + return (u16)T1ReadWord(GBArom, (adr - 0x08000000)); +} + +static u32 GBAgame_read32(u32 adr) +{ + //INFO("Read32 at 0x%08X value 0x%08X\n", adr, (u32)T1ReadLong(GBArom, (adr - 0x08000000))); + if ( (adr >= 0x08000004) && (adr < 0x080000A0) ) + return T1ReadLong(MMU.MMU_MEM[0][0xFF], (adr +0x1C) & MMU.MMU_MASK[0][0xFF]); + return (u32)T1ReadLong(GBArom, (adr - 0x08000000)); +} + +static void GBAgame_info(char *info) +{ + strcpy(info, "GBA game in slot"); +} + +ADDONINTERFACE addonGBAgame = { + "GBA game", + GBAgame_init, + GBAgame_reset, + GBAgame_close, + GBAgame_config, + GBAgame_write08, + GBAgame_write16, + GBAgame_write32, + GBAgame_read08, + GBAgame_read16, + GBAgame_read32, + GBAgame_info}; diff --git a/desmume/src/addons/guitarGrip.cpp b/src/addons/guitarGrip.cpp similarity index 100% rename from desmume/src/addons/guitarGrip.cpp rename to src/addons/guitarGrip.cpp diff --git a/desmume/src/addons/none.cpp b/src/addons/none.cpp similarity index 96% rename from desmume/src/addons/none.cpp rename to src/addons/none.cpp index 1393fbe7e..b2f320762 100644 --- a/desmume/src/addons/none.cpp +++ b/src/addons/none.cpp @@ -1,52 +1,52 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2009 CrazyMax - Copyright (C) 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "../addons.h" -#include - -static BOOL None_init(void) { return (TRUE); } -static void None_reset(void) {} -static void None_close(void) {} -static void None_config(void) {} -static void None_write08(u32 adr, u8 val) {} -static void None_write16(u32 adr, u16 val) {} -static void None_write32(u32 adr, u32 val) {} -static u8 None_read08(u32 adr){ return (0); } -static u16 None_read16(u32 adr){ return (0); } -static u32 None_read32(u32 adr){ return (0); } -static void None_info(char *info) { strcpy(info, "Nothing in GBA slot"); } - -ADDONINTERFACE addonNone = { - "NONE", - None_init, - None_reset, - None_close, - None_config, - None_write08, - None_write16, - None_write32, - None_read08, - None_read16, - None_read32, - None_info}; +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2009 CrazyMax + Copyright (C) 2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "../addons.h" +#include + +static BOOL None_init(void) { return (TRUE); } +static void None_reset(void) {} +static void None_close(void) {} +static void None_config(void) {} +static void None_write08(u32 adr, u8 val) {} +static void None_write16(u32 adr, u16 val) {} +static void None_write32(u32 adr, u32 val) {} +static u8 None_read08(u32 adr){ return (0); } +static u16 None_read16(u32 adr){ return (0); } +static u32 None_read32(u32 adr){ return (0); } +static void None_info(char *info) { strcpy(info, "Nothing in GBA slot"); } + +ADDONINTERFACE addonNone = { + "NONE", + None_init, + None_reset, + None_close, + None_config, + None_write08, + None_write16, + None_write32, + None_read08, + None_read16, + None_read32, + None_info}; diff --git a/desmume/src/addons/rumblepak.cpp b/src/addons/rumblepak.cpp similarity index 95% rename from desmume/src/addons/rumblepak.cpp rename to src/addons/rumblepak.cpp index 6c31fb19c..7a0654ed4 100644 --- a/desmume/src/addons/rumblepak.cpp +++ b/src/addons/rumblepak.cpp @@ -1,97 +1,97 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2009 CrazyMax - Copyright (C) 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "../addons.h" -#include "../mem.h" -#include "../MMU.h" -#include - -void (*FeedbackON)(BOOL enable) = NULL; - -static BOOL RumblePak_init(void) { return (TRUE); } - -static void RumblePak_reset(void) -{ -} - -static void RumblePak_close(void) {} - -static void RumblePak_config(void) {} - -static void RumblePak_write08(u32 adr, u8 val) -{ -} - -static void RumblePak_write16(u32 adr, u16 val) -{ - if (!FeedbackON) return; - - // CrazyMax 17/01/2009 - // i don't know how send to feedback (PC) impulse with small latency. - if (adr == 0x08000000) - FeedbackON(val); - if (adr == 0x08001000) - FeedbackON(val); -} - -static void RumblePak_write32(u32 adr, u32 val) -{ -} - -static u8 RumblePak_read08(u32 adr) -{ - return (0); -} - -static u16 RumblePak_read16(u32 adr) -{ - u16 val = ( (adr & 0x1FFFF) >> 1 ) & 0xFFFD; - if (adr == 0x0801FFFE) val = 0x005D; // hack!!! anybody have docs for RumblePak? - - return ((u16)val); -} - -static u32 RumblePak_read32(u32 adr) -{ - return (0); -} - -static void RumblePak_info(char *info) -{ - strcpy(info, "NDS Rumble Pak (need joystick with Feedback)"); -} - -ADDONINTERFACE addonRumblePak = { - "Rumble Pak", - RumblePak_init, - RumblePak_reset, - RumblePak_close, - RumblePak_config, - RumblePak_write08, - RumblePak_write16, - RumblePak_write32, - RumblePak_read08, - RumblePak_read16, - RumblePak_read32, - RumblePak_info}; +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2009 CrazyMax + Copyright (C) 2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "../addons.h" +#include "../mem.h" +#include "../MMU.h" +#include + +void (*FeedbackON)(BOOL enable) = NULL; + +static BOOL RumblePak_init(void) { return (TRUE); } + +static void RumblePak_reset(void) +{ +} + +static void RumblePak_close(void) {} + +static void RumblePak_config(void) {} + +static void RumblePak_write08(u32 adr, u8 val) +{ +} + +static void RumblePak_write16(u32 adr, u16 val) +{ + if (!FeedbackON) return; + + // CrazyMax 17/01/2009 + // i don't know how send to feedback (PC) impulse with small latency. + if (adr == 0x08000000) + FeedbackON(val); + if (adr == 0x08001000) + FeedbackON(val); +} + +static void RumblePak_write32(u32 adr, u32 val) +{ +} + +static u8 RumblePak_read08(u32 adr) +{ + return (0); +} + +static u16 RumblePak_read16(u32 adr) +{ + u16 val = ( (adr & 0x1FFFF) >> 1 ) & 0xFFFD; + if (adr == 0x0801FFFE) val = 0x005D; // hack!!! anybody have docs for RumblePak? + + return ((u16)val); +} + +static u32 RumblePak_read32(u32 adr) +{ + return (0); +} + +static void RumblePak_info(char *info) +{ + strcpy(info, "NDS Rumble Pak (need joystick with Feedback)"); +} + +ADDONINTERFACE addonRumblePak = { + "Rumble Pak", + RumblePak_init, + RumblePak_reset, + RumblePak_close, + RumblePak_config, + RumblePak_write08, + RumblePak_write16, + RumblePak_write32, + RumblePak_read08, + RumblePak_read16, + RumblePak_read32, + RumblePak_info}; diff --git a/desmume/src/agg2d.h b/src/agg2d.h similarity index 100% rename from desmume/src/agg2d.h rename to src/agg2d.h diff --git a/desmume/src/agg2d.inl b/src/agg2d.inl similarity index 100% rename from desmume/src/agg2d.inl rename to src/agg2d.inl diff --git a/desmume/src/aggdraw.cpp b/src/aggdraw.cpp similarity index 97% rename from desmume/src/aggdraw.cpp rename to src/aggdraw.cpp index 745d4c588..643b47992 100644 --- a/desmume/src/aggdraw.cpp +++ b/src/aggdraw.cpp @@ -144,7 +144,7 @@ void Agg_init() aggDraw.target = targets[0]; //if we're single core, we don't want to waste time compositing - if(CommonSettings.single_core) + //if(CommonSettings.single_core) aggDraw.hud = &agg_targetScreen; //and the more clever compositing isnt supported in non-windows diff --git a/desmume/src/aggdraw.h b/src/aggdraw.h similarity index 100% rename from desmume/src/aggdraw.h rename to src/aggdraw.h diff --git a/desmume/src/arm_instructions.cpp b/src/arm_instructions.cpp similarity index 96% rename from desmume/src/arm_instructions.cpp rename to src/arm_instructions.cpp index 484672220..8b457f38d 100644 --- a/desmume/src/arm_instructions.cpp +++ b/src/arm_instructions.cpp @@ -1,7792 +1,7792 @@ -/* Copyright (C) 2006 yopyop - Copyright (C) 2006 shash - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2006-2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "cp15.h" -#include "debug.h" -#include "MMU.h" -#include "armcpu.h" -#include "NDSSystem.h" - -#define cpu (&ARMPROC) -#define TEMPLATE template - -extern volatile bool execute; - -#define LSL_IMM shift_op = cpu->R[REG_POS(i,0)]<<((i>>7)&0x1F); - -#define S_LSL_IMM u32 shift_op = ((i>>7)&0x1F);\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - shift_op=cpu->R[REG_POS(i,0)];\ - else\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], 32-shift_op);\ - shift_op = cpu->R[REG_POS(i,0)]<<((i>>7)&0x1F);\ - } - -#define LSL_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - if(shift_op>=32)\ - shift_op=0;\ - else\ - shift_op=cpu->R[REG_POS(i,0)]<R[REG_POS(i,8)])&0xFF;\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - shift_op=cpu->R[REG_POS(i,0)];\ - else\ - if(shift_op<32)\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], 32-shift_op);\ - shift_op = cpu->R[REG_POS(i,0)]<R[REG_POS(i,0)]);\ - }\ - else\ - {\ - shift_op = 0;\ - c = 0;\ - } - -#define LSR_IMM shift_op = ((i>>7)&0x1F);\ - if(shift_op!=0)\ - shift_op = cpu->R[REG_POS(i,0)]>>shift_op; - -#define S_LSR_IMM u32 shift_op = ((i>>7)&0x1F);\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - {\ - c = BIT31(cpu->R[REG_POS(i,0)]);\ - }\ - else\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ - shift_op = cpu->R[REG_POS(i,0)]>>shift_op;\ - } - -#define LSR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - if(shift_op>=32)\ - shift_op = 0;\ - else\ - shift_op = cpu->R[REG_POS(i,0)]>>shift_op; - -#define S_LSR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - {\ - shift_op = cpu->R[REG_POS(i,0)];\ - }\ - else\ - if(shift_op<32)\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ - shift_op = cpu->R[REG_POS(i,0)]>>shift_op;\ - }\ - else\ - if(shift_op==32)\ - {\ - c = BIT31(cpu->R[REG_POS(i,0)]);\ - shift_op = 0;\ - }\ - else\ - {\ - c = 0;\ - shift_op = 0;\ - } - -#define ASR_IMM shift_op = ((i>>7)&0x1F);\ - if(shift_op==0)\ - shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF;\ - else\ - shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op); - -#define S_ASR_IMM u32 shift_op = ((i>>7)&0x1F);\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - {\ - shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF;\ - c = BIT31(cpu->R[REG_POS(i,0)]);\ - }\ - else\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ - shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op);\ - } - -#define ASR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - if(shift_op==0)\ - shift_op=cpu->R[REG_POS(i,0)];\ - else\ - if(shift_op<32)\ - shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op);\ - else\ - shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF; - -#define S_ASR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - shift_op=cpu->R[REG_POS(i,0)];\ - else\ - if(shift_op<32)\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ - shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op);\ - }\ - else\ - {\ - c = BIT31(cpu->R[REG_POS(i,0)]);\ - shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF;\ - } - -#define ROR_IMM shift_op = ((i>>7)&0x1F);\ - if(shift_op==0)\ - {\ - u32 tmp = cpu->CPSR.bits.C;\ - shift_op = (tmp<<31)|(cpu->R[REG_POS(i,0)]>>1);\ - }\ - else\ - shift_op = ROR(cpu->R[REG_POS(i,0)],shift_op); - -#define S_ROR_IMM u32 shift_op = ((i>>7)&0x1F);\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - {\ - u32 tmp = cpu->CPSR.bits.C;\ - shift_op = (tmp<<31)|(cpu->R[REG_POS(i,0)]>>1);\ - c = BIT0(cpu->R[REG_POS(i,0)]);\ - }\ - else\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ - shift_op = ROR(cpu->R[REG_POS(i,0)],shift_op);\ - } - -#define ROR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - if((shift_op==0)||((shift_op&0x1F)==0))\ - shift_op=cpu->R[REG_POS(i,0)];\ - else\ - shift_op = ROR(cpu->R[REG_POS(i,0)],(shift_op&0x1F)); - -#define S_ROR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ - u32 c = cpu->CPSR.bits.C;\ - if(shift_op==0)\ - shift_op=cpu->R[REG_POS(i,0)];\ - else\ - {\ - shift_op&=0x1F;\ - if(shift_op==0)\ - {\ - shift_op=cpu->R[REG_POS(i,0)];\ - c = BIT31(cpu->R[REG_POS(i,0)]);\ - }\ - else\ - {\ - c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ - shift_op = ROR(cpu->R[REG_POS(i,0)],(shift_op&0x1F));\ - }\ - } - -#define IMM_VALUE u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E); - -#define S_IMM_VALUE u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E);\ - u32 c = cpu->CPSR.bits.C;\ - if((i>>8)&0xF)\ - c = BIT31(shift_op); - -#define IMM_OFF (((i>>4)&0xF0)+(i&0xF)) - -#define IMM_OFF_12 ((i)&0xFFF) - -TEMPLATE static u32 FASTCALL OP_UND() -{ - LOG("Undefined instruction: %08X from %08X\n", cpu->instruction, cpu->instruct_adr); - emu_halt(); - LOG("Stopped (OP_UND)\n"); - return 1; -} - -#define TRAPUNDEF() \ - LOG("Undefined instruction: %#08X PC = %#08X\n", cpu->instruction, cpu->instruct_adr); \ - \ - if (((cpu->intVector != 0) ^ (PROCNUM == ARMCPU_ARM9))){ \ - Status_Reg tmp = cpu->CPSR; \ - armcpu_switchMode(cpu, UND); /* enter und mode */ \ - cpu->R[14] = cpu->R[15] - 4; /* jump to und Vector */ \ - cpu->SPSR = tmp; /* save old CPSR as new SPSR */ \ - cpu->CPSR.bits.T = 0; /* handle as ARM32 code */ \ - cpu->CPSR.bits.I = cpu->SPSR.bits.I; /* keep int disable flag */ \ - cpu->R[15] = cpu->intVector + 0x04; \ - cpu->next_instruction = cpu->R[15]; \ - return 4; \ - } \ - else \ - { \ - emu_halt(); \ - return 4; \ - } \ - -//-----------------------AND------------------------------------ - -#define OP_AND(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -#define OP_ANDS(a, b)\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR;\ - cpu->R[15] = cpu->R[REG_POS(i,16)] & shift_op;\ - SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & shift_op;\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - return a; - -TEMPLATE static u32 FASTCALL OP_AND_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_AND(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_AND_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OP_AND(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_AND_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_AND(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_AND_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OP_AND(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_AND_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_AND(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_AND_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OP_AND(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_AND_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_AND(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_AND_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OP_AND(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_AND_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OP_AND(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_AND_S_LSL_IMM() -{ - const u32 &i = cpu->instruction; - S_LSL_IMM; - OP_ANDS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_AND_S_LSL_REG() -{ - const u32 &i = cpu->instruction; - S_LSL_REG; - OP_ANDS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_AND_S_LSR_IMM() -{ - const u32 &i = cpu->instruction; - S_LSR_IMM; - OP_ANDS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_AND_S_LSR_REG() -{ - const u32 &i = cpu->instruction; - S_LSR_REG; - OP_ANDS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_AND_S_ASR_IMM() -{ - const u32 &i = cpu->instruction; - S_ASR_IMM; - OP_ANDS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_AND_S_ASR_REG() -{ - const u32 &i = cpu->instruction; - S_ASR_REG; - OP_ANDS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_AND_S_ROR_IMM() -{ - const u32 &i = cpu->instruction; - S_ROR_IMM; - OP_ANDS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_AND_S_ROR_REG() -{ - const u32 &i = cpu->instruction; - S_ROR_REG; - OP_ANDS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_AND_S_IMM_VAL() -{ - const u32 &i = cpu->instruction; - S_IMM_VALUE; - OP_ANDS(2, 4); -} - -//--------------EOR------------------------------ - -#define OP_EOR(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] ^ shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -#define OP_EORS(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] ^ shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - return a; - -TEMPLATE static u32 FASTCALL OP_EOR_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_EOR(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_EOR_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OP_EOR(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_EOR_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_EOR(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_EOR_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OP_EOR(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_EOR_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_EOR(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_EOR_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OP_EOR(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_EOR_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_EOR(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_EOR_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OP_EOR(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_EOR_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OP_EOR(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_EOR_S_LSL_IMM() -{ - const u32 &i = cpu->instruction; - S_LSL_IMM; - OP_EORS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_EOR_S_LSL_REG() -{ - const u32 &i = cpu->instruction; - S_LSL_REG; - OP_EORS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_EOR_S_LSR_IMM() -{ - const u32 &i = cpu->instruction; - S_LSR_IMM; - OP_EORS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_EOR_S_LSR_REG() -{ - const u32 &i = cpu->instruction; - S_LSR_REG; - OP_EORS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_EOR_S_ASR_IMM() -{ - const u32 &i = cpu->instruction; - S_ASR_IMM; - OP_EORS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_EOR_S_ASR_REG() -{ - const u32 &i = cpu->instruction; - S_ASR_REG; - OP_EORS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_EOR_S_ROR_IMM() -{ - const u32 &i = cpu->instruction; - S_ROR_IMM; - OP_EORS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_EOR_S_ROR_REG() -{ - const u32 &i = cpu->instruction; - S_ROR_REG; - OP_EORS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_EOR_S_IMM_VAL() -{ - const u32 &i = cpu->instruction; - S_IMM_VALUE; - OP_EORS(2, 4); -} - -//-------------SUB------------------------------------- - -#define OP_SUB(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] - shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -#define OPSUBS(a, b) cpu->R[REG_POS(i,12)] = v - shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ - return a; - -TEMPLATE static u32 FASTCALL OP_SUB_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_SUB(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_SUB_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OP_SUB(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SUB_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_SUB(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_SUB_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OP_SUB(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SUB_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_SUB(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_SUB_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OP_SUB(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SUB_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_SUB(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_SUB_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OP_SUB(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SUB_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OP_SUB(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_SUB_S_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSL_IMM; - OPSUBS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SUB_S_LSL_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSL_REG; - OPSUBS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_SUB_S_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSR_IMM; - OPSUBS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SUB_S_LSR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSR_REG; - OPSUBS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_SUB_S_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ASR_IMM; - OPSUBS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SUB_S_ASR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ASR_REG; - OPSUBS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_SUB_S_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ROR_IMM; - OPSUBS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SUB_S_ROR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ROR_REG; - OPSUBS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_SUB_S_IMM_VAL() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - IMM_VALUE; - OPSUBS(2, 4); -} - -//------------------RSB------------------------ - -#define OP_RSB(a, b) cpu->R[REG_POS(i,12)] = shift_op - cpu->R[REG_POS(i,16)];\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -#define OP_RSBS(a, b) cpu->R[REG_POS(i,12)] = shift_op - v;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(shift_op, v, cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(shift_op, v, cpu->R[REG_POS(i,12)]);\ - return a; - -TEMPLATE static u32 FASTCALL OP_RSB_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_RSB(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_RSB_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OP_RSB(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_RSB_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_RSB(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_RSB_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OP_RSB(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_RSB_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_RSB(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_RSB_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OP_RSB(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_RSB_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_RSB(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_RSB_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OP_RSB(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_RSB_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OP_RSB(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_RSB_S_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSL_IMM; - OP_RSBS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_RSB_S_LSL_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSL_REG; - OP_RSBS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_RSB_S_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSR_IMM; - OP_RSBS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_RSB_S_LSR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSR_REG; - OP_RSBS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_RSB_S_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ASR_IMM; - OP_RSBS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_RSB_S_ASR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ASR_REG; - OP_RSBS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_RSB_S_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ROR_IMM; - OP_RSBS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_RSB_S_ROR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ROR_REG; - OP_RSBS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_RSB_S_IMM_VAL() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - IMM_VALUE; - OP_RSBS(2, 4); -} - -//------------------ADD----------------------------------- - -#define OP_ADD(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] + shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -TEMPLATE static u32 FASTCALL OP_ADD_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_ADD(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_ADD_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OP_ADD(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADD_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_ADD(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_ADD_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OP_ADD(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADD_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_ADD(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_ADD_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OP_ADD(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADD_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_ADD(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_ADD_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OP_ADD(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADD_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OP_ADD(1, 3); -} - -#define OP_ADDS(a, b) cpu->R[REG_POS(i,12)] = v + shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.V = SIGNED_OVERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ - return a; - -TEMPLATE static u32 FASTCALL OP_ADD_S_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSL_IMM; - OP_ADDS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADD_S_LSL_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSL_REG; - OP_ADDS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_ADD_S_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSR_IMM; - OP_ADDS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADD_S_LSR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSR_REG; - OP_ADDS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_ADD_S_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ASR_IMM; - OP_ADDS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADD_S_ASR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ASR_REG; - OP_ADDS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_ADD_S_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ROR_IMM; - OP_ADDS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADD_S_ROR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ROR_REG; - OP_ADDS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_ADD_S_IMM_VAL() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - IMM_VALUE; - OP_ADDS(2, 4); -} - -//------------------ADC----------------------------------- - -#define OP_ADC(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] + shift_op + cpu->CPSR.bits.C;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -TEMPLATE static u32 FASTCALL OP_ADC_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_ADC(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_ADC_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OP_ADC(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADC_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_ADC(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_ADC_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OP_ADC(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADC_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_ADC(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_ADC_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OP_ADC(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADC_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_ADC(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_ADC_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OP_ADC(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADC_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OP_ADC(1, 3); -} - -#define OP_ADCS(a, b) \ - { \ - u32 tmp = shift_op + cpu->CPSR.bits.C;\ - cpu->R[REG_POS(i,12)] = v + tmp;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(shift_op, (u32) cpu->CPSR.bits.C, tmp) | UNSIGNED_OVERFLOW(v, tmp, cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.V = SIGNED_OVERFLOW(shift_op, (u32) cpu->CPSR.bits.C, tmp) | SIGNED_OVERFLOW(v, tmp, cpu->R[REG_POS(i,12)]);\ - return a; \ - } - -TEMPLATE static u32 FASTCALL OP_ADC_S_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSL_IMM; - OP_ADCS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADC_S_LSL_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSL_REG; - OP_ADCS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_ADC_S_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSR_IMM; - OP_ADCS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADC_S_LSR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSR_REG; - OP_ADCS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_ADC_S_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ASR_IMM; - OP_ADCS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADC_S_ASR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ASR_REG; - OP_ADCS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_ADC_S_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ROR_IMM; - OP_ADCS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ADC_S_ROR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ROR_REG; - OP_ADCS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_ADC_S_IMM_VAL() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - IMM_VALUE; - OP_ADCS(2, 4); -} - -//-------------SBC------------------------------------- - -#define OP_SBC(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] - shift_op - (!cpu->CPSR.bits.C);\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -TEMPLATE static u32 FASTCALL OP_SBC_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_SBC(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_SBC_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OP_SBC(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SBC_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_SBC(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_SBC_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OP_SBC(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SBC_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_SBC(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_SBC_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OP_SBC(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SBC_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_SBC(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_SBC_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OP_SBC(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SBC_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OP_SBC(1, 3); -} - -//zero 14-feb-2009 - reverting flag logic to fix zoning bug in ff4 -#define OP_SBCS(a, b) \ - { \ - u32 tmp = v - (!cpu->CPSR.bits.C);\ - cpu->R[REG_POS(i,12)] = tmp - shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - cpu->CPSR.bits.C = (!UNSIGNED_UNDERFLOW(v, (u32)(!cpu->CPSR.bits.C), tmp)) & (!UNSIGNED_UNDERFLOW(tmp, shift_op, cpu->R[REG_POS(i,12)]));\ - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(v, (u32)(!cpu->CPSR.bits.C), tmp) | SIGNED_UNDERFLOW(tmp, shift_op, cpu->R[REG_POS(i,12)]);\ - return a; \ - } - - -TEMPLATE static u32 FASTCALL OP_SBC_S_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSL_IMM; - OP_SBCS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SBC_S_LSL_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSL_REG; - OP_SBCS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_SBC_S_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSR_IMM; - OP_SBCS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SBC_S_LSR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSR_REG; - OP_SBCS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_SBC_S_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ASR_IMM; - OP_SBCS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SBC_S_ASR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ASR_REG; - OP_SBCS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_SBC_S_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ROR_IMM; - OP_SBCS(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_SBC_S_ROR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ROR_REG; - OP_SBCS(3, 5); -} - -TEMPLATE static u32 FASTCALL OP_SBC_S_IMM_VAL() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - IMM_VALUE; - OP_SBCS(2, 4); -} - -//---------------RSC---------------------------------- - -#define OP_RSC(a, b) cpu->R[REG_POS(i,12)] = shift_op - cpu->R[REG_POS(i,16)] - (!cpu->CPSR.bits.C);\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -TEMPLATE static u32 FASTCALL OP_RSC_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_RSC(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_RSC_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OP_RSC(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_RSC_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_RSC(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_RSC_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OP_RSC(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_RSC_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_RSC(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_RSC_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OP_RSC(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_RSC_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_RSC(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_RSC_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OP_RSC(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_RSC_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OP_RSC(1, 3); -} - -//zero 14-feb-2009 - reverting flag logic to fix zoning bug in ff4 -#define OP_RSCS(a,b) \ - { \ - u32 tmp = shift_op - (!cpu->CPSR.bits.C);\ - cpu->R[REG_POS(i,12)] = tmp - v;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - cpu->CPSR.bits.C = (!UNSIGNED_UNDERFLOW(shift_op, (u32)(!cpu->CPSR.bits.C), (u32)tmp)) & (!UNSIGNED_UNDERFLOW(tmp, v, cpu->R[REG_POS(i,12)]));\ - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(shift_op, (u32)(!cpu->CPSR.bits.C), (u32)tmp) | SIGNED_UNDERFLOW(tmp, v, cpu->R[REG_POS(i,12)]);\ - return a; \ - } - -TEMPLATE static u32 FASTCALL OP_RSC_S_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSL_IMM; - OP_RSCS(2,4); -} - -TEMPLATE static u32 FASTCALL OP_RSC_S_LSL_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSL_REG; - OP_RSCS(3,5); -} - -TEMPLATE static u32 FASTCALL OP_RSC_S_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - LSR_IMM; - OP_RSCS(2,4); -} - -TEMPLATE static u32 FASTCALL OP_RSC_S_LSR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - LSR_REG; - OP_RSCS(3,5); -} - -TEMPLATE static u32 FASTCALL OP_RSC_S_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ASR_IMM; - OP_RSCS(2,4); -} - -TEMPLATE static u32 FASTCALL OP_RSC_S_ASR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ASR_REG; - OP_RSCS(3,5); -} - -TEMPLATE static u32 FASTCALL OP_RSC_S_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - u32 shift_op; - ROR_IMM; - OP_RSCS(2,4); -} - -TEMPLATE static u32 FASTCALL OP_RSC_S_ROR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - ROR_REG; - OP_RSCS(3,5); -} - -TEMPLATE static u32 FASTCALL OP_RSC_S_IMM_VAL() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,16)]; - IMM_VALUE; - OP_RSCS(2,4); -} - -//-------------------TST---------------------------- - -#define OP_TST(a) \ - { \ - unsigned tmp = cpu->R[REG_POS(i,16)] & shift_op;\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(tmp);\ - cpu->CPSR.bits.Z = (tmp==0);\ - return a; \ - } - -TEMPLATE static u32 FASTCALL OP_TST_LSL_IMM() -{ - const u32 &i = cpu->instruction; - S_LSL_IMM; - OP_TST(1); -} - -TEMPLATE static u32 FASTCALL OP_TST_LSL_REG() -{ - const u32 &i = cpu->instruction; - S_LSL_REG; - OP_TST(2); -} - -TEMPLATE static u32 FASTCALL OP_TST_LSR_IMM() -{ - const u32 &i = cpu->instruction; - S_LSR_IMM; - OP_TST(1); -} - -TEMPLATE static u32 FASTCALL OP_TST_LSR_REG() -{ - const u32 &i = cpu->instruction; - S_LSR_REG; - OP_TST(2); -} - -TEMPLATE static u32 FASTCALL OP_TST_ASR_IMM() -{ - const u32 &i = cpu->instruction; - S_ASR_IMM; - OP_TST(1); -} - -TEMPLATE static u32 FASTCALL OP_TST_ASR_REG() -{ - const u32 &i = cpu->instruction; - S_ASR_REG; - OP_TST(2); -} - -TEMPLATE static u32 FASTCALL OP_TST_ROR_IMM() -{ - const u32 &i = cpu->instruction; - S_ROR_IMM; - OP_TST(1); -} - -TEMPLATE static u32 FASTCALL OP_TST_ROR_REG() -{ - const u32 &i = cpu->instruction; - S_ROR_REG; - OP_TST(2); -} - -TEMPLATE static u32 FASTCALL OP_TST_IMM_VAL() -{ - const u32 &i = cpu->instruction; - S_IMM_VALUE; - OP_TST(1); -} - -//-------------------TEQ---------------------------- - -#define OP_TEQ(a) \ - { \ - unsigned tmp = cpu->R[REG_POS(i,16)] ^ shift_op;\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(tmp);\ - cpu->CPSR.bits.Z = (tmp==0);\ - return a; \ - } - -TEMPLATE static u32 FASTCALL OP_TEQ_LSL_IMM() -{ - const u32 &i = cpu->instruction; - S_LSL_IMM; - OP_TEQ(1); -} - -TEMPLATE static u32 FASTCALL OP_TEQ_LSL_REG() -{ - const u32 &i = cpu->instruction; - S_LSL_REG; - OP_TEQ(2); -} - -TEMPLATE static u32 FASTCALL OP_TEQ_LSR_IMM() -{ - const u32 &i = cpu->instruction; - S_LSR_IMM; - OP_TEQ(1); -} - -TEMPLATE static u32 FASTCALL OP_TEQ_LSR_REG() -{ - const u32 &i = cpu->instruction; - S_LSR_REG; - OP_TEQ(2); -} - -TEMPLATE static u32 FASTCALL OP_TEQ_ASR_IMM() -{ - const u32 &i = cpu->instruction; - S_ASR_IMM; - OP_TEQ(1); -} - -TEMPLATE static u32 FASTCALL OP_TEQ_ASR_REG() -{ - const u32 &i = cpu->instruction; - S_ASR_REG; - OP_TEQ(2); -} - -TEMPLATE static u32 FASTCALL OP_TEQ_ROR_IMM() -{ - const u32 &i = cpu->instruction; - S_ROR_IMM; - OP_TEQ(1); -} - -TEMPLATE static u32 FASTCALL OP_TEQ_ROR_REG() -{ - const u32 &i = cpu->instruction; - S_ROR_REG; - OP_TEQ(2); -} - -TEMPLATE static u32 FASTCALL OP_TEQ_IMM_VAL() -{ - const u32 &i = cpu->instruction; - S_IMM_VALUE; - OP_TEQ(1); -} - -//-------------CMP------------------------------------- - -#define OP_CMP(a) \ - { \ - u32 tmp = cpu->R[REG_POS(i,16)] - shift_op;\ - cpu->CPSR.bits.N = BIT31(tmp);\ - cpu->CPSR.bits.Z = (tmp==0);\ - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ - return a; \ - } - -TEMPLATE static u32 FASTCALL OP_CMP_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_CMP(1); -} - -TEMPLATE static u32 FASTCALL OP_CMP_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OP_CMP(2); -} - -TEMPLATE static u32 FASTCALL OP_CMP_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_CMP(1); -} - -TEMPLATE static u32 FASTCALL OP_CMP_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OP_CMP(2); -} - -TEMPLATE static u32 FASTCALL OP_CMP_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_CMP(1); -} - -TEMPLATE static u32 FASTCALL OP_CMP_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OP_CMP(2); -} - -TEMPLATE static u32 FASTCALL OP_CMP_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_CMP(1); -} - -TEMPLATE static u32 FASTCALL OP_CMP_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OP_CMP(2); -} - -TEMPLATE static u32 FASTCALL OP_CMP_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OP_CMP(1); -} - -//---------------CMN--------------------------- - -#define OP_CMN(a) \ - { \ - u32 tmp = cpu->R[REG_POS(i,16)] + shift_op;\ - cpu->CPSR.bits.N = BIT31(tmp);\ - cpu->CPSR.bits.Z = (tmp==0);\ - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ - cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ - return a; \ - } - -TEMPLATE static u32 FASTCALL OP_CMN_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_CMN(1); -} - -TEMPLATE static u32 FASTCALL OP_CMN_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OP_CMN(2); -} - -TEMPLATE static u32 FASTCALL OP_CMN_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_CMN(1); -} - -TEMPLATE static u32 FASTCALL OP_CMN_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OP_CMN(2); -} - -TEMPLATE static u32 FASTCALL OP_CMN_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_CMN(1); -} - -TEMPLATE static u32 FASTCALL OP_CMN_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OP_CMN(2); -} - -TEMPLATE static u32 FASTCALL OP_CMN_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_CMN(1); -} - -TEMPLATE static u32 FASTCALL OP_CMN_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OP_CMN(2); -} - -TEMPLATE static u32 FASTCALL OP_CMN_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OP_CMN(1); -} - -//------------------ORR------------------- - -#define OP_ORR(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -TEMPLATE static u32 FASTCALL OP_ORR_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_ORR(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_ORR_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OP_ORR(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ORR_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_ORR(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_ORR_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OP_ORR(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ORR_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_ORR(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_ORR_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OP_ORR(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ORR_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_ORR(1, 3); -} - -TEMPLATE static u32 FASTCALL OP_ORR_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OP_ORR(2, 4); -} - -TEMPLATE static u32 FASTCALL OP_ORR_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OP_ORR(1, 3); -} - -#define OP_ORRS(a,b) \ - { \ - cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; \ - if(REG_POS(i,12)==15) \ - { \ - Status_Reg SPSR = cpu->SPSR; \ - armcpu_switchMode(cpu, SPSR.bits.mode); \ - cpu->CPSR=SPSR; \ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1)); \ - cpu->next_instruction = cpu->R[15]; \ - return b; \ - } \ - cpu->CPSR.bits.C = c; \ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); \ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); \ - return a; \ - } - -TEMPLATE static u32 FASTCALL OP_ORR_S_LSL_IMM() -{ - const u32 &i = cpu->instruction; - S_LSL_IMM; - OP_ORRS(2,4); -} - -TEMPLATE static u32 FASTCALL OP_ORR_S_LSL_REG() -{ - const u32 &i = cpu->instruction; - S_LSL_REG; - OP_ORRS(3,5); -} - -TEMPLATE static u32 FASTCALL OP_ORR_S_LSR_IMM() -{ - const u32 &i = cpu->instruction; - S_LSR_IMM; - OP_ORRS(2,4); -} - -TEMPLATE static u32 FASTCALL OP_ORR_S_LSR_REG() -{ - const u32 &i = cpu->instruction; - S_LSR_REG; - OP_ORRS(3,5); -} - -TEMPLATE static u32 FASTCALL OP_ORR_S_ASR_IMM() -{ - const u32 &i = cpu->instruction; - S_ASR_IMM; - OP_ORRS(2,4); -} - -TEMPLATE static u32 FASTCALL OP_ORR_S_ASR_REG() -{ - const u32 &i = cpu->instruction; - S_ASR_REG; - OP_ORRS(3,5); -} - -TEMPLATE static u32 FASTCALL OP_ORR_S_ROR_IMM() -{ - const u32 &i = cpu->instruction; - S_ROR_IMM; - OP_ORRS(2,4); -} - -TEMPLATE static u32 FASTCALL OP_ORR_S_ROR_REG() -{ - const u32 &i = cpu->instruction; - S_ROR_REG; - OP_ORRS(3,5); -} - -TEMPLATE static u32 FASTCALL OP_ORR_S_IMM_VAL() -{ - const u32 &i = cpu->instruction; - S_IMM_VALUE; - OP_ORRS(2,4); -} - -//------------------MOV------------------- - -#define OP_MOV(a, b) cpu->R[REG_POS(i,12)] = shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = shift_op;\ - return b;\ - }\ - return a; - -#define OP_MOV_S(a, b) cpu->R[REG_POS(i,12)] = shift_op;\ - if(BIT20(i) && REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - return a;\ - -TEMPLATE static u32 FASTCALL OP_MOV_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OP_MOV(1,3); -} - -TEMPLATE static u32 FASTCALL OP_MOV_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - if (REG_POS(i,0) == 15) shift_op += 4; - OP_MOV(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MOV_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OP_MOV(1,3); -} - -TEMPLATE static u32 FASTCALL OP_MOV_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - if (REG_POS(i,0) == 15) shift_op += 4; - OP_MOV(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MOV_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OP_MOV(1,3); -} - -TEMPLATE static u32 FASTCALL OP_MOV_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OP_MOV(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MOV_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OP_MOV(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MOV_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OP_MOV(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MOV_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OP_MOV(1,3); -} - -TEMPLATE static u32 FASTCALL OP_MOV_S_LSL_IMM() -{ - const u32 &i = cpu->instruction; - S_LSL_IMM; - OP_MOV_S(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MOV_S_LSL_REG() -{ - const u32 &i = cpu->instruction; - S_LSL_REG; - if (REG_POS(i,0) == 15) shift_op += 4; - OP_MOV_S(3,5); -} - -TEMPLATE static u32 FASTCALL OP_MOV_S_LSR_IMM() -{ - const u32 &i = cpu->instruction; - S_LSR_IMM; - OP_MOV_S(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MOV_S_LSR_REG() -{ - const u32 &i = cpu->instruction; - S_LSR_REG; - if (REG_POS(i,0) == 15) shift_op += 4; - OP_MOV_S(3,5); -} - -TEMPLATE static u32 FASTCALL OP_MOV_S_ASR_IMM() -{ - const u32 &i = cpu->instruction; - S_ASR_IMM; - OP_MOV_S(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MOV_S_ASR_REG() -{ - const u32 &i = cpu->instruction; - S_ASR_REG; - OP_MOV_S(3,5); -} - -TEMPLATE static u32 FASTCALL OP_MOV_S_ROR_IMM() -{ - const u32 &i = cpu->instruction; - S_ROR_IMM; - OP_MOV_S(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MOV_S_ROR_REG() -{ - const u32 &i = cpu->instruction; - S_ROR_REG; - OP_MOV_S(3,5); -} - -TEMPLATE static u32 FASTCALL OP_MOV_S_IMM_VAL() -{ - const u32 &i = cpu->instruction; - S_IMM_VALUE; - OP_MOV_S(2,4); -} - -//------------------BIC------------------- -#define OPP_BIC(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & (~shift_op);\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -#define OPP_BIC_S(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & (~shift_op);\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - return a; - -TEMPLATE static u32 FASTCALL OP_BIC_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OPP_BIC(1,3); -} - -TEMPLATE static u32 FASTCALL OP_BIC_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OPP_BIC(2,4); -} - -TEMPLATE static u32 FASTCALL OP_BIC_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OPP_BIC(1,3); -} - -TEMPLATE static u32 FASTCALL OP_BIC_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OPP_BIC(2,4); -} - -TEMPLATE static u32 FASTCALL OP_BIC_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OPP_BIC(1,3); -} - -TEMPLATE static u32 FASTCALL OP_BIC_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OPP_BIC(2,4); -} - -TEMPLATE static u32 FASTCALL OP_BIC_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OPP_BIC(1,3); -} - -TEMPLATE static u32 FASTCALL OP_BIC_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OPP_BIC(2,4); -} - -TEMPLATE static u32 FASTCALL OP_BIC_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OPP_BIC(1,3); -} - -TEMPLATE static u32 FASTCALL OP_BIC_S_LSL_IMM() -{ - const u32 &i = cpu->instruction; - S_LSL_IMM; - OPP_BIC_S(2,4); -} - -TEMPLATE static u32 FASTCALL OP_BIC_S_LSL_REG() -{ - const u32 &i = cpu->instruction; - S_LSL_REG; - OPP_BIC_S(3,5); -} - -TEMPLATE static u32 FASTCALL OP_BIC_S_LSR_IMM() -{ - const u32 &i = cpu->instruction; - S_LSR_IMM; - OPP_BIC_S(2,4); -} - -TEMPLATE static u32 FASTCALL OP_BIC_S_LSR_REG() -{ - const u32 &i = cpu->instruction; - S_LSR_REG; - OPP_BIC_S(3,5); -} - -TEMPLATE static u32 FASTCALL OP_BIC_S_ASR_IMM() -{ - const u32 &i = cpu->instruction; - S_ASR_IMM; - OPP_BIC_S(2,4); -} - -TEMPLATE static u32 FASTCALL OP_BIC_S_ASR_REG() -{ - const u32 &i = cpu->instruction; - S_ASR_REG; - OPP_BIC_S(3,5); -} - -TEMPLATE static u32 FASTCALL OP_BIC_S_ROR_IMM() -{ - const u32 &i = cpu->instruction; - S_ROR_IMM; - OPP_BIC_S(2,4); -} - -TEMPLATE static u32 FASTCALL OP_BIC_S_ROR_REG() -{ - const u32 &i = cpu->instruction; - S_ROR_REG; - OPP_BIC_S(3,5); -} - -TEMPLATE static u32 FASTCALL OP_BIC_S_IMM_VAL() -{ - const u32 &i = cpu->instruction; - S_IMM_VALUE; - OPP_BIC_S(2,4); -} - -//------------------MVN------------------- -#define OPP_MVN(a, b) cpu->R[REG_POS(i,12)] = ~shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - return a; - -#define OPP_MVN_S(a, b) cpu->R[REG_POS(i,12)] = ~shift_op;\ - if(REG_POS(i,12)==15)\ - {\ - Status_Reg SPSR = cpu->SPSR;\ - armcpu_switchMode(cpu, SPSR.bits.mode);\ - cpu->CPSR=SPSR;\ - cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ - cpu->next_instruction = cpu->R[15];\ - return b;\ - }\ - cpu->CPSR.bits.C = c;\ - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ - return a; - -TEMPLATE static u32 FASTCALL OP_MVN_LSL_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSL_IMM; - OPP_MVN(1,3); -} - -TEMPLATE static u32 FASTCALL OP_MVN_LSL_REG() -{ - const u32 &i = cpu->instruction; - LSL_REG; - OPP_MVN(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MVN_LSR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - LSR_IMM; - OPP_MVN(1,3); -} - -TEMPLATE static u32 FASTCALL OP_MVN_LSR_REG() -{ - const u32 &i = cpu->instruction; - LSR_REG; - OPP_MVN(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MVN_ASR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ASR_IMM; - OPP_MVN(1,3); -} - -TEMPLATE static u32 FASTCALL OP_MVN_ASR_REG() -{ - const u32 &i = cpu->instruction; - ASR_REG; - OPP_MVN(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MVN_ROR_IMM() -{ - const u32 &i = cpu->instruction; - u32 shift_op; - ROR_IMM; - OPP_MVN(1,3); -} - -TEMPLATE static u32 FASTCALL OP_MVN_ROR_REG() -{ - const u32 &i = cpu->instruction; - ROR_REG; - OPP_MVN(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MVN_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - OPP_MVN(1,3); -} - -TEMPLATE static u32 FASTCALL OP_MVN_S_LSL_IMM() -{ - const u32 &i = cpu->instruction; - S_LSL_IMM; - OPP_MVN_S(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MVN_S_LSL_REG() -{ - const u32 &i = cpu->instruction; - S_LSL_REG; - OPP_MVN_S(3,5); -} - -TEMPLATE static u32 FASTCALL OP_MVN_S_LSR_IMM() -{ - const u32 &i = cpu->instruction; - S_LSR_IMM; - OPP_MVN_S(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MVN_S_LSR_REG() -{ - const u32 &i = cpu->instruction; - S_LSR_REG; - OPP_MVN_S(3,5); -} - -TEMPLATE static u32 FASTCALL OP_MVN_S_ASR_IMM() -{ - const u32 &i = cpu->instruction; - S_ASR_IMM; - OPP_MVN_S(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MVN_S_ASR_REG() -{ - const u32 &i = cpu->instruction; - S_ASR_REG; - OPP_MVN_S(3,5); -} - -TEMPLATE static u32 FASTCALL OP_MVN_S_ROR_IMM() -{ - const u32 &i = cpu->instruction; - S_ROR_IMM; - OPP_MVN_S(2,4); -} - -TEMPLATE static u32 FASTCALL OP_MVN_S_ROR_REG() -{ - const u32 &i = cpu->instruction; - S_ROR_REG; - OPP_MVN_S(3,5); -} - -TEMPLATE static u32 FASTCALL OP_MVN_S_IMM_VAL() -{ - const u32 &i = cpu->instruction; - S_IMM_VALUE; - OPP_MVN_S(2,4); -} - -//-------------MUL------------------------ -#define OPP_M(a,b) v >>= 8;\ - if((v==0)||(v==0xFFFFFF))\ - return b;\ - v >>= 8;\ - if((v==0)||(v==0xFFFF))\ - return b+1;\ - v >>= 8;\ - if((v==0)||(v==0xFF))\ - return b+2;\ - return a;\ - -TEMPLATE static u32 FASTCALL OP_MUL() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,16)] = cpu->R[REG_POS(i,8)] * v; - OPP_M(5,2); -} - -TEMPLATE static u32 FASTCALL OP_MLA() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - u32 a = cpu->R[REG_POS(i,8)]; - u32 b = cpu->R[REG_POS(i,12)]; - cpu->R[REG_POS(i,16)] = a * v + b; - - OPP_M(6,3); -} - -TEMPLATE static u32 FASTCALL OP_MUL_S() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,16)] = cpu->R[REG_POS(i,8)] * v; - - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0); - - OPP_M(6,3); -} - -TEMPLATE static u32 FASTCALL OP_MLA_S() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,16)] = cpu->R[REG_POS(i,8)] * v + cpu->R[REG_POS(i,12)]; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0); - OPP_M(7,4); -} - -//----------UMUL-------------------------- - -TEMPLATE static u32 FASTCALL OP_UMULL() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)]; - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] = (u32)(res>>32); - - OPP_M(6,3); -} - -TEMPLATE static u32 FASTCALL OP_UMLAL() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)] + (u64)cpu->R[REG_POS(i,12)]; - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] += (u32)(res>>32); - - OPP_M(7,4); -} - -TEMPLATE static u32 FASTCALL OP_UMULL_S() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)]; - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] = (u32)(res>>32); - - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); - - OPP_M(7,4); -} - -TEMPLATE static u32 FASTCALL OP_UMLAL_S() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_POS(i,0)]; - u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)] + (u64)cpu->R[REG_POS(i,12)]; - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] += (u32)(res>>32); - - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); - - OPP_M(8,5); -} - -//----------SMUL-------------------------- - -TEMPLATE static u32 FASTCALL OP_SMULL() -{ - const u32 &i = cpu->instruction; - s64 v = (s32)cpu->R[REG_POS(i,0)]; - s64 b = (s32)cpu->R[REG_POS(i,8)]; - s64 res = v * b; - - cpu->R[REG_POS(i,12)] = (u32)(res&0xFFFFFFFF); - cpu->R[REG_POS(i,16)] = (u32)(res>>32); - - v &= 0xFFFFFFFF; - - OPP_M(6,3); -} - -TEMPLATE static u32 FASTCALL OP_SMLAL() -{ - const u32 &i = cpu->instruction; - - s64 v = (s32)cpu->R[REG_POS(i,0)]; - s64 b = (s32)cpu->R[REG_POS(i,8)]; - s64 res = v * b + (u64)cpu->R[REG_POS(i,12)]; - - //LOG("%08X * %08X + %08X%08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], cpu->R[REG_POS(i,16)], cpu->R[REG_POS(i,12)]); - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] += (u32)(res>>32); - - //LOG("= %08X%08X %08X%08X\r\n", cpu->R[REG_POS(i,16)], cpu->R[REG_POS(i,12)], res); - - v &= 0xFFFFFFFF; - - OPP_M(7,4); -} - -TEMPLATE static u32 FASTCALL OP_SMULL_S() -{ - const u32 &i = cpu->instruction; - s64 v = (s32)cpu->R[REG_POS(i,0)]; - s64 b = (s32)cpu->R[REG_POS(i,8)]; - s64 res = v * b; - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] = (u32)(res>>32); - - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); - - v &= 0xFFFFFFFF; - - OPP_M(7,4); -} - -TEMPLATE static u32 FASTCALL OP_SMLAL_S() -{ - const u32 &i = cpu->instruction; - s64 v = (s32)cpu->R[REG_POS(i,0)]; - s64 b = (s32)cpu->R[REG_POS(i,8)]; - s64 res = v * b + (u64)cpu->R[REG_POS(i,12)]; - - cpu->R[REG_POS(i,12)] = (u32)res; - cpu->R[REG_POS(i,16)] += (u32)(res>>32); - - cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); - cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); - - v &= 0xFFFFFFFF; - - OPP_M(8,5); -} - -//---------------SWP------------------------------ - -TEMPLATE static u32 FASTCALL OP_SWP() -{ - u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - u32 tmp = ROR(READ32(cpu->mem_if->data, adr), ((cpu->R[REG_POS(i,16)]&3)<<3)); - - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,0)]); - cpu->R[REG_POS(i,12)] = tmp; - - return 4 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]*2; -} - -TEMPLATE static u32 FASTCALL OP_SWPB() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - u8 tmp = READ8(cpu->mem_if->data, adr); - WRITE8(cpu->mem_if->data, adr, (u8)(cpu->R[REG_POS(i,0)]&0xFF)); - cpu->R[REG_POS(i,12)] = tmp; - - return 4 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]*2; -} - -//------------LDRH----------------------------- - -TEMPLATE static u32 FASTCALL OP_LDRH_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_P_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_M_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_PRE_INDE_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_PRE_INDE_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_PRE_INDE_P_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] =(u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_PRE_INDE_M_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_POS_INDE_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] += IMM_OFF; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_POS_INDE_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] -= IMM_OFF; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_POS_INDE_P_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_POS_INDE_M_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -//------------STRH----------------------------- - -TEMPLATE static u32 FASTCALL OP_STRH_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_P_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_M_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_PRE_INDE_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,16)] = adr; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_PRE_INDE_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_PRE_INDE_P_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_PRE_INDE_M_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_POS_INDE_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] += IMM_OFF; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_POS_INDE_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] -= IMM_OFF; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_POS_INDE_P_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_POS_INDE_M_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -//----------------LDRSH-------------------------- - -TEMPLATE static u32 FASTCALL OP_LDRSH_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSH_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSH_P_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSH_M_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSH_PRE_INDE_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSH_PRE_INDE_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSH_PRE_INDE_P_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSH_PRE_INDE_M_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSH_POS_INDE_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] += IMM_OFF; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSH_POS_INDE_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] -= IMM_OFF; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSH_POS_INDE_P_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSH_POS_INDE_M_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -//----------------------LDRSB---------------------- - -TEMPLATE static u32 FASTCALL OP_LDRSB_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSB_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSB_P_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSB_M_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSB_PRE_INDE_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSB_PRE_INDE_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSB_PRE_INDE_P_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSB_PRE_INDE_M_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSB_POS_INDE_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] += IMM_OFF; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSB_POS_INDE_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] -= IMM_OFF; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSB_POS_INDE_P_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSB_POS_INDE_M_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -//--------------MRS-------------------------------- - -TEMPLATE static u32 FASTCALL OP_MRS_CPSR() -{ - cpu->R[REG_POS(cpu->instruction,12)] = cpu->CPSR.val; - - return 1; -} - -TEMPLATE static u32 FASTCALL OP_MRS_SPSR() -{ - cpu->R[REG_POS(cpu->instruction,12)] = cpu->SPSR.val; - - return 1; -} - -//--------------MSR-------------------------------- - -TEMPLATE static u32 FASTCALL OP_MSR_CPSR() -{ - const u32 &i = cpu->instruction; - u32 operand = cpu->R[REG_POS(i,0)]; - - if(cpu->CPSR.bits.mode!=USR) - { - if(BIT16(i)) - { - armcpu_switchMode(cpu, operand & 0x1F); - cpu->CPSR.val = (cpu->CPSR.val & 0xFFFFFF00) | (operand & 0xFF); - } - if(BIT17(i)) - cpu->CPSR.val = (cpu->CPSR.val & 0xFFFF00FF) | (operand & 0xFF00); - if(BIT18(i)) - cpu->CPSR.val = (cpu->CPSR.val & 0xFF00FFFF) | (operand & 0xFF0000); - } - if(BIT19(i)) - cpu->CPSR.val = (cpu->CPSR.val & 0x00FFFFFF) | (operand & 0xFF000000); - - return 1; -} - -TEMPLATE static u32 FASTCALL OP_MSR_SPSR() -{ - const u32 &i = cpu->instruction; - u32 operand = cpu->R[REG_POS(i,0)]; - - if(cpu->CPSR.bits.mode!=USR) - { - if(BIT16(i)) - { - cpu->SPSR.val = (cpu->SPSR.val & 0xFFFFFF00) | (operand & 0XFF); - } - if(BIT17(i)) - cpu->SPSR.val = (cpu->SPSR.val & 0xFFFF00FF) | (operand & 0XFF00); - if(BIT18(i)) - cpu->SPSR.val = (cpu->SPSR.val & 0xFF00FFFF) | (operand & 0XFF0000); - } - if(BIT19(i)) - cpu->SPSR.val = (cpu->SPSR.val & 0x00FFFFFF) | (operand & 0XFF000000); - - return 1; -} - -TEMPLATE static u32 FASTCALL OP_MSR_CPSR_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - - if(cpu->CPSR.bits.mode!=USR) - { - if(BIT16(i)) - { - armcpu_switchMode(cpu, shift_op & 0x1F); - cpu->CPSR.val = (cpu->CPSR.val & 0xFFFFFF00) | (shift_op & 0XFF); - } - if(BIT17(i)) - cpu->CPSR.val = (cpu->CPSR.val & 0xFFFF00FF) | (shift_op & 0XFF00); - if(BIT18(i)) - cpu->CPSR.val = (cpu->CPSR.val & 0xFF00FFFF) | (shift_op & 0XFF0000); - } - if(BIT19(i)) - { - //cpu->CPSR.val = (cpu->CPSR.val & 0xFF000000) | (shift_op & 0XFF000000); - cpu->CPSR.val = (cpu->CPSR.val & 0x00FFFFFF) | (shift_op & 0xFF000000); - } - - return 1; -} - -TEMPLATE static u32 FASTCALL OP_MSR_SPSR_IMM_VAL() -{ - const u32 &i = cpu->instruction; - IMM_VALUE; - - if(cpu->CPSR.bits.mode!=USR) - { - if(BIT16(i)) - { - cpu->SPSR.val = (cpu->SPSR.val & 0xFFFFFF00) | (shift_op & 0XFF); - } - if(BIT17(i)) - cpu->SPSR.val = (cpu->SPSR.val & 0xFFFF00FF) | (shift_op & 0XFF00); - if(BIT18(i)) - cpu->SPSR.val = (cpu->SPSR.val & 0xFF00FFFF) | (shift_op & 0XFF0000); - } - if(BIT19(i)) - cpu->SPSR.val = (cpu->SPSR.val & 0xFF000000) | (shift_op & 0XFF000000); - - return 1; -} - -//-----------------BRANCH-------------------------- - -TEMPLATE static u32 FASTCALL OP_BX() -{ - u32 tmp = cpu->R[REG_POS(cpu->instruction, 0)]; - - cpu->CPSR.bits.T = BIT0(tmp); - cpu->R[15] = tmp & 0xFFFFFFFE; - cpu->next_instruction = cpu->R[15]; - return 3; -} - -TEMPLATE static u32 FASTCALL OP_BLX_REG() -{ - u32 tmp = cpu->R[REG_POS(cpu->instruction, 0)]; - - cpu->R[14] = cpu->next_instruction; - cpu->CPSR.bits.T = BIT0(tmp); - cpu->R[15] = tmp & 0xFFFFFFFE; - cpu->next_instruction = cpu->R[15]; - return 3; -} - -#define SIGNEXTEND_24(i) (((s32)((i)<<8))>>8) - -TEMPLATE static u32 FASTCALL OP_B() -{ - u32 off = SIGNEXTEND_24(cpu->instruction); - if(CONDITION(cpu->instruction)==0xF) - { - cpu->R[14] = cpu->next_instruction; - cpu->CPSR.bits.T = 1; - } - cpu->R[15] += (off<<2); - cpu->next_instruction = cpu->R[15]; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_BL() -{ - u32 off = SIGNEXTEND_24(cpu->instruction); - if(CONDITION(cpu->instruction)==0xF) - { - cpu->CPSR.bits.T = 1; - cpu->R[15] += 2; - } - cpu->R[14] = cpu->next_instruction; - cpu->R[15] += (off<<2); - cpu->next_instruction = cpu->R[15]; - - return 3; -} - -//----------------CLZ------------------------------- - -u8 CLZ_TAB[16]= -{ - 0, // 0000 - 1, // 0001 - 2, 2, // 001X - 3, 3, 3, 3, // 01XX - 4, 4, 4, 4, 4, 4, 4, 4 // 1XXX -}; - -TEMPLATE static u32 FASTCALL OP_CLZ() -{ - const u32 &i = cpu->instruction; - u32 Rm = cpu->R[REG_POS(i,0)]; - u32 pos; - - if(Rm==0) - { - cpu->R[REG_POS(i,12)]=32; - return 2; - } - - Rm |= (Rm >>1); - Rm |= (Rm >>2); - Rm |= (Rm >>4); - Rm |= (Rm >>8); - Rm |= (Rm >>16); - - pos = - CLZ_TAB[Rm&0xF] + - CLZ_TAB[(Rm>>4)&0xF] + - CLZ_TAB[(Rm>>8)&0xF] + - CLZ_TAB[(Rm>>12)&0xF] + - CLZ_TAB[(Rm>>16)&0xF] + - CLZ_TAB[(Rm>>20)&0xF] + - CLZ_TAB[(Rm>>24)&0xF] + - CLZ_TAB[(Rm>>28)&0xF]; - - cpu->R[REG_POS(i,12)]=32 - pos; - - return 2; -} - -//--------------------QADD--QSUB------------------------------ - -TEMPLATE static u32 FASTCALL OP_QADD() -{ - const u32 &i = cpu->instruction; - u32 res = cpu->R[REG_POS(i,16)]+cpu->R[REG_POS(i,0)]; - - LOG("spe add\r\n"); - if(SIGNED_OVERFLOW(cpu->R[REG_POS(i,16)],cpu->R[REG_POS(i,0)], res)) - { - cpu->CPSR.bits.Q=1; - cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); - return 2; - } - cpu->R[REG_POS(i,12)]=res; - if(REG_POS(i,12)==15) - { - cpu->R[15] &= 0XFFFFFFFC; - cpu->next_instruction = cpu->R[15]; - return 3; - } - return 2; -} - -TEMPLATE static u32 FASTCALL OP_QSUB() -{ - const u32 &i = cpu->instruction; - u32 res = cpu->R[REG_POS(i,0)]-cpu->R[REG_POS(i,16)]; - - LOG("spe add\r\n"); - if(SIGNED_UNDERFLOW(cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,16)], res)) - { - cpu->CPSR.bits.Q=1; - cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); - return 2; - } - cpu->R[REG_POS(i,12)]=res; - if(REG_POS(i,12)==15) - { - cpu->R[15] &= 0XFFFFFFFC; - cpu->next_instruction = cpu->R[15]; - return 3; - } - return 2; -} - -TEMPLATE static u32 FASTCALL OP_QDADD() -{ - const u32 &i = cpu->instruction; - u32 mul = cpu->R[REG_POS(i,16)]<<1; - u32 res; - - - LOG("spe add\r\n"); - if(BIT31(cpu->R[REG_POS(i,16)])!=BIT31(mul)) - { - cpu->CPSR.bits.Q=1; - mul = 0x80000000-BIT31(mul); - } - - res = mul + cpu->R[REG_POS(i,0)]; - if(SIGNED_OVERFLOW(cpu->R[REG_POS(i,0)],mul, res)) - { - cpu->CPSR.bits.Q=1; - cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); - return 2; - } - cpu->R[REG_POS(i,12)]=res; - if(REG_POS(i,12)==15) - { - cpu->R[15] &= 0XFFFFFFFC; - cpu->next_instruction = cpu->R[15]; - return 3; - } - return 2; -} - -TEMPLATE static u32 FASTCALL OP_QDSUB() -{ - const u32 &i = cpu->instruction; - u32 mul = cpu->R[REG_POS(i,16)]<<1; - u32 res; - - - LOG("spe add\r\n"); - if(BIT31(cpu->R[REG_POS(i,16)])!=BIT31(mul)) - { - cpu->CPSR.bits.Q=1; - mul = 0x80000000-BIT31(mul); - } - - res = cpu->R[REG_POS(i,0)] - mul; - if(SIGNED_UNDERFLOW(cpu->R[REG_POS(i,0)], mul, res)) - { - cpu->CPSR.bits.Q=1; - cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); - return 2; - } - cpu->R[REG_POS(i,12)]=res; - if(REG_POS(i,12)==15) - { - cpu->R[15] &= 0XFFFFFFFC; - cpu->next_instruction = cpu->R[15]; - return 3; - } - return 2; -} - -//-----------------SMUL------------------------------- - -#define HWORD(i) ((s32)(((s32)(i))>>16)) -#define LWORD(i) (s32)(((s32)((i)<<16))>>16) - -TEMPLATE static u32 FASTCALL OP_SMUL_B_B() -{ - const u32 &i = cpu->instruction; - - cpu->R[REG_POS(i,16)] = (u32)(LWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SMUL_B_T() -{ - const u32 &i = cpu->instruction; - - cpu->R[REG_POS(i,16)] = (u32)(LWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SMUL_T_B() -{ - const u32 &i = cpu->instruction; - - cpu->R[REG_POS(i,16)] = (u32)(HWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SMUL_T_T() -{ - const u32 &i = cpu->instruction; - - cpu->R[REG_POS(i,16)] = (u32)(HWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); - - return 2; -} - -//-----------SMLA---------------------------- - -TEMPLATE static u32 FASTCALL OP_SMLA_B_B() -{ - const u32 &i = cpu->instruction; - u32 tmp = (u32)(LWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); - u32 a = cpu->R[REG_POS(i,12)]; - - //LOG("SMLABB %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); - cpu->R[REG_POS(i,16)] = tmp + a; - - if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) - cpu->CPSR.bits.Q = 1; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SMLA_B_T() -{ - const u32 &i = cpu->instruction; - u32 tmp = (u32)(LWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); - u32 a = cpu->R[REG_POS(i,12)]; - - //LOG("SMLABT %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); - cpu->R[REG_POS(i,16)] = tmp + a; - - if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) - cpu->CPSR.bits.Q = 1; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SMLA_T_B() -{ - const u32 &i = cpu->instruction; - u32 tmp = (u32)(HWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); - u32 a = cpu->R[REG_POS(i,12)]; - - //LOG("SMLATB %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); - cpu->R[REG_POS(i,16)] = tmp + a; - - if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) - cpu->CPSR.bits.Q = 1; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SMLA_T_T() -{ - const u32 &i = cpu->instruction; - u32 tmp = (u32)(HWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); - u32 a = cpu->R[REG_POS(i,12)]; - - //LOG("SMLATT %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); - cpu->R[REG_POS(i,16)] = tmp + a; - - if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) - cpu->CPSR.bits.Q = 1; - - return 2; -} - -//--------------SMLAL--------------------------------------- - -TEMPLATE static u32 FASTCALL OP_SMLAL_B_B() -{ - const u32 &i = cpu->instruction; - s64 tmp = (s64)(LWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); - u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; - - LOG("SMLALBB %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + (res + ((tmp<0)*0xFFFFFFFF))), (int)(u32) res); - - cpu->R[REG_POS(i,12)] = (u32) res; - cpu->R[REG_POS(i,16)] += (res + ((tmp<0)*0xFFFFFFFF)); - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SMLAL_B_T() -{ - const u32 &i = cpu->instruction; - s64 tmp = (s64)(LWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); - u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; - - LOG("SMLALBT %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + res + ((tmp<0)*0xFFFFFFFF)), (int)(u32) res); - - cpu->R[REG_POS(i,12)] = (u32) res; - cpu->R[REG_POS(i,16)] += res + ((tmp<0)*0xFFFFFFFF); - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SMLAL_T_B() -{ - const u32 &i = cpu->instruction; - s64 tmp = (s64)(HWORD(cpu->R[REG_POS(i,0)])* (s64)LWORD(cpu->R[REG_POS(i,8)])); - u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; - - LOG("SMLALTB %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + res + ((tmp<0)*0xFFFFFFFF)), (int)(u32) res); - - cpu->R[REG_POS(i,12)] = (u32) res; - cpu->R[REG_POS(i,16)] += res + ((tmp<0)*0xFFFFFFFF); - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SMLAL_T_T() -{ - const u32 &i = cpu->instruction; - s64 tmp = (s64)(HWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); - u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; - - LOG("SMLALTT %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + res + ((tmp<0)*0xFFFFFFFF)), (int)(u32) res); - - cpu->R[REG_POS(i,12)] = (u32) res; - cpu->R[REG_POS(i,16)] += res + ((tmp<0)*0xFFFFFFFF); - - return 2; -} - -//--------------SMULW-------------------- - -TEMPLATE static u32 FASTCALL OP_SMULW_B() -{ - const u32 &i = cpu->instruction; - s64 tmp = (s64)LWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); - - //LOG("SMULWB %08X * %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], ((tmp>>16)&0xFFFFFFFF); - - cpu->R[REG_POS(i,16)] = ((tmp>>16)&0xFFFFFFFF); - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SMULW_T() -{ - const u32 &i = cpu->instruction; - s64 tmp = (s64)HWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); - - //LOG("SMULWT %08X * %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], ((tmp>>16)&0xFFFFFFFF)); - - cpu->R[REG_POS(i,16)] = ((tmp>>16)&0xFFFFFFFF); - - return 2; -} - -//--------------SMLAW------------------- -TEMPLATE static u32 FASTCALL OP_SMLAW_B() -{ - const u32 &i = cpu->instruction; - s64 tmp = (s64)LWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); - u32 a = cpu->R[REG_POS(i,12)]; - - //LOG("SMLAWB %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, (tmp>>16) + a); - - tmp = (tmp>>16); - - cpu->R[REG_POS(i,16)] = tmp + a; - - if(SIGNED_OVERFLOW((u32)tmp, a, cpu->R[REG_POS(i,16)])) - cpu->CPSR.bits.Q = 1; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SMLAW_T() -{ - const u32 &i = cpu->instruction; - s64 tmp = (s64)HWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); - u32 a = cpu->R[REG_POS(i,12)]; - - //LOG("SMLAWT %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, ((tmp>>16)&0xFFFFFFFF) + a); - - tmp = ((tmp>>16)&0xFFFFFFFF); - cpu->R[REG_POS(i,16)] = tmp + a; - - if(SIGNED_OVERFLOW((u32)tmp, a, cpu->R[REG_POS(i,16)])) - cpu->CPSR.bits.Q = 1; - - return 2; -} - -//------------LDR--------------------------- - -TEMPLATE static u32 FASTCALL OP_LDR_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - u32 val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - u32 val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_LSL_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_LSL_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_LSR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_LSR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_ASR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_ASR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_ROR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_ROR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - u32 val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - u32 val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_LSL_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_LSL_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_LSR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_LSR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_ASR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_ASR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_ROR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_ROR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - u32 val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -//------------------------------------------------------------ -TEMPLATE static u32 FASTCALL OP_LDR_P_IMM_OFF_POSTIND2() -{ - const u32 &i = cpu->instruction; - - u32 adr = cpu->R[REG_POS(i,16)]; - u32 val = READ32(cpu->mem_if->data, adr); - u32 old; - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - old = armcpu_switchMode(cpu, USR); - cpu->R[REG_POS(i,12)] = val; - armcpu_switchMode(cpu, old); - - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -//------------------------------------------------------------ - -TEMPLATE static u32 FASTCALL OP_LDR_M_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - u32 val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_LSL_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr + shift_op; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_LSL_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr - shift_op; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_LSR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr + shift_op; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_LSR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr - shift_op; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_ASR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr + shift_op; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_ASR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr - shift_op; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_P_ROR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr + shift_op; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_M_ROR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ32(cpu->mem_if->data, adr); - - val = ROR(val, 8*(adr&3)); - - if(REG_POS(i,12)==15) - { - cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); - cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; - cpu->next_instruction = cpu->R[15]; - cpu->R[REG_POS(i,16)] = adr - shift_op; - return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - } - - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -//-----------------LDRB------------------------------------------- - -TEMPLATE static u32 FASTCALL OP_LDRB_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - u32 val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - u32 val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_LSL_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_LSL_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_LSR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_LSR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_ASR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_ASR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_ROR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_ROR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - u32 val = READ8(cpu->mem_if->data, adr); - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - u32 val = READ8(cpu->mem_if->data, adr); - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_LSL_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_LSL_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_LSR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_LSR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_ASR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_ASR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_ROR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_ROR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - u32 val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - u32 val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_LSL_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_LSL_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_LSR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_LSR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_ASR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_ASR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_P_ROR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr + shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_M_ROR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 val; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,16)] = adr - shift_op; - cpu->R[REG_POS(i,12)] = val; - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -//----------------------STR-------------------------------- - -TEMPLATE static u32 FASTCALL OP_STR_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - -// emu_halt(); - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_LSL_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_LSL_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_LSR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_LSR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_ASR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_ASR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_ROR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_ROR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_LSL_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_LSL_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_LSR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_LSR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_ASR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_ASR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_ROR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_ROR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_LSL_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_LSL_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_LSR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_LSR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_ASR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_ASR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_P_ROR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_M_ROR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -//-----------------------STRB------------------------------------- - -TEMPLATE static u32 FASTCALL OP_STRB_P_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_LSL_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_LSL_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_LSR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_LSR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_ASR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_ASR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_ROR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_ROR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; - WRITE8(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_LSL_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_LSL_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_LSR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_LSR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_ASR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_ASR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_ROR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] + shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_ROR_IMM_OFF_PREIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)] - shift_op; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_LSL_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_LSL_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_LSR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_LSR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_ASR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_ASR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_P_ROR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_M_ROR_IMM_OFF_POSTIND() -{ - const u32 &i = cpu->instruction; - u32 adr; - u32 shift_op; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -//-----------------------LDRBT------------------------------------- - -TEMPLATE static u32 FASTCALL OP_LDRBT_P_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRBT_M_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_M_IMM_OFF_POSTIND\n"); - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRBT_P_REG_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_P_REG_OFF_POSTIND\n"); - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr + cpu->R[REG_POS(i,0)]; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRBT_P_LSL_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_P_LSL_IMM_OFF_POSTIND\n"); - - i = cpu->instruction; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRBT_M_LSL_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_M_LSL_IMM_OFF_POSTIND\n"); - - i = cpu->instruction; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRBT_P_LSR_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_P_LSR_IMM_OFF_POSTIND\n"); - - i = cpu->instruction; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRBT_M_LSR_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_M_LSR_IMM_OFF_POSTIND\n"); - - i = cpu->instruction; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRBT_P_ASR_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_P_ASR_IMM_OFF_POSTIND\n"); - - - i = cpu->instruction; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRBT_M_ASR_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_M_ASR_IMM_OFF_POSTIND\n"); - - - i = cpu->instruction; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRBT_P_ROR_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_P_ROR_IMM_OFF_POSTIND\n"); - - - i = cpu->instruction; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRBT_M_ROR_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 val; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_M_ROR_IMM_OFF_POSTIND\n"); - - - i = cpu->instruction; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - val = READ8(cpu->mem_if->data, adr); - cpu->R[REG_POS(i,12)] = val; - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -//----------------------STRBT---------------------------- - -TEMPLATE static u32 FASTCALL OP_STRBT_P_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRBT_M_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRBT_P_REG_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + cpu->R[REG_POS(i,0)]; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRBT_M_REG_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - cpu->R[REG_POS(i,0)]; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRBT_P_LSL_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRBT_M_LSL_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - LSL_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRBT_P_LSR_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRBT_M_LSR_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - LSR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRBT_P_ASR_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRBT_M_ASR_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - ASR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRBT_P_ROR_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr + shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRBT_M_ROR_IMM_OFF_POSTIND() -{ - u32 oldmode; - u32 i; - u32 adr; - u32 shift_op; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - oldmode = armcpu_switchMode(cpu, SYS); - - - i = cpu->instruction; - ROR_IMM; - adr = cpu->R[REG_POS(i,16)]; - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); - cpu->R[REG_POS(i,16)] = adr - shift_op; - - armcpu_switchMode(cpu, oldmode); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -//---------------------LDM----------------------------- - -#define OP_L_IA(reg, adr) if(BIT##reg(i))\ - {\ - registres[reg] = READ32(cpu->mem_if->data, start);\ - c += waitState[(start>>24)&0xF];\ - adr += 4;\ - } - -#define OP_L_IB(reg, adr) if(BIT##reg(i))\ - {\ - adr += 4;\ - registres[reg] = READ32(cpu->mem_if->data, start);\ - c += waitState[(start>>24)&0xF];\ - } - -#define OP_L_DA(reg, adr) if(BIT##reg(i))\ - {\ - registres[reg] = READ32(cpu->mem_if->data, start);\ - c += waitState[(start>>24)&0xF];\ - adr -= 4;\ - } - -#define OP_L_DB(reg, adr) if(BIT##reg(i))\ - {\ - adr -= 4;\ - registres[reg] = READ32(cpu->mem_if->data, start);\ - c += waitState[(start>>24)&0xF];\ - } - -TEMPLATE static u32 FASTCALL OP_LDMIA() -{ - const u32 &i = cpu->instruction; - u32 c = 0; - u32 start = cpu->R[REG_POS(i,16)]; - - u32 * registres = cpu->R; - TWaitState* waitState = MMU.MMU_WAIT32[PROCNUM]; - - OP_L_IA(0, start); - OP_L_IA(1, start); - OP_L_IA(2, start); - OP_L_IA(3, start); - OP_L_IA(4, start); - OP_L_IA(5, start); - OP_L_IA(6, start); - OP_L_IA(7, start); - OP_L_IA(8, start); - OP_L_IA(9, start); - OP_L_IA(10, start); - OP_L_IA(11, start); - OP_L_IA(12, start); - OP_L_IA(13, start); - OP_L_IA(14, start); - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - //start += 4; - cpu->next_instruction = registres[15]; - c += waitState[(start>>24)&0xF]; - } - - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMIB() -{ - const u32 &i = cpu->instruction; - u32 c = 0; - u32 start = cpu->R[REG_POS(i,16)]; - - u32 * registres = cpu->R; - TWaitState* waitState = MMU.MMU_WAIT32[PROCNUM]; - - OP_L_IB(0, start); - OP_L_IB(1, start); - OP_L_IB(2, start); - OP_L_IB(3, start); - OP_L_IB(4, start); - OP_L_IB(5, start); - OP_L_IB(6, start); - OP_L_IB(7, start); - OP_L_IB(8, start); - OP_L_IB(9, start); - OP_L_IB(10, start); - OP_L_IB(11, start); - OP_L_IB(12, start); - OP_L_IB(13, start); - OP_L_IB(14, start); - - if(BIT15(i)) - { - u32 tmp; - start += 4; - c += waitState[(start>>24)&0xF]; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - cpu->next_instruction = registres[15]; - c += 2 + (c==0); - } - - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMDA() -{ - const u32 &i = cpu->instruction; - u32 c = 0; - u32 start = cpu->R[REG_POS(i,16)]; - - u32 * registres = cpu->R; - TWaitState * waitState = MMU.MMU_WAIT32[PROCNUM]; - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - c += waitState[(start>>24)&0xF]; - start -= 4; - cpu->next_instruction = registres[15]; - } - - OP_L_DA(14, start); - OP_L_DA(13, start); - OP_L_DA(12, start); - OP_L_DA(11, start); - OP_L_DA(10, start); - OP_L_DA(9, start); - OP_L_DA(8, start); - OP_L_DA(7, start); - OP_L_DA(6, start); - OP_L_DA(5, start); - OP_L_DA(4, start); - OP_L_DA(3, start); - OP_L_DA(2, start); - OP_L_DA(1, start); - OP_L_DA(0, start); - - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMDB() -{ - const u32 &i = cpu->instruction; - u32 c = 0; - u32 start = cpu->R[REG_POS(i,16)]; - - u32 * registres = cpu->R; - TWaitState* waitState = MMU.MMU_WAIT32[PROCNUM]; - - if(BIT15(i)) - { - u32 tmp; - start -= 4; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - cpu->next_instruction = registres[15]; - c += waitState[(start>>24)&0xF]; - } - - OP_L_DB(14, start); - OP_L_DB(13, start); - OP_L_DB(12, start); - OP_L_DB(11, start); - OP_L_DB(10, start); - OP_L_DB(9, start); - OP_L_DB(8, start); - OP_L_DB(7, start); - OP_L_DB(6, start); - OP_L_DB(5, start); - OP_L_DB(4, start); - OP_L_DB(3, start); - OP_L_DB(2, start); - OP_L_DB(1, start); - OP_L_DB(0, start); - - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMIA_W() -{ - const u32 &i = cpu->instruction; - u32 c = 0; - u32 start = cpu->R[REG_POS(i,16)]; - u32 bitList = (~((2 << REG_POS(i,16))-1)) & 0xFFFF; - - u32 * registres = cpu->R; - TWaitState* waitState = MMU.MMU_WAIT32[PROCNUM]; - - OP_L_IA(0, start); - OP_L_IA(1, start); - OP_L_IA(2, start); - OP_L_IA(3, start); - OP_L_IA(4, start); - OP_L_IA(5, start); - OP_L_IA(6, start); - OP_L_IA(7, start); - OP_L_IA(8, start); - OP_L_IA(9, start); - OP_L_IA(10, start); - OP_L_IA(11, start); - OP_L_IA(12, start); - OP_L_IA(13, start); - OP_L_IA(14, start); - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - c += waitState[(start>>24)&0xF]; - start += 4; - cpu->next_instruction = registres[15]; - } - - if(i & (1 << REG_POS(i,16))) { - if(i & bitList) - cpu->R[REG_POS(i,16)] = start; - } - else - cpu->R[REG_POS(i,16)] = start; - - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMIB_W() -{ - const u32 &i = cpu->instruction; - u32 c = 0; - u32 start = cpu->R[REG_POS(i,16)]; - u32 bitList = (~((2 << REG_POS(i,16))-1)) & 0xFFFF; - - u32 * registres = cpu->R; - TWaitState* waitState = MMU.MMU_WAIT32[PROCNUM]; - - OP_L_IB(0, start); - OP_L_IB(1, start); - OP_L_IB(2, start); - OP_L_IB(3, start); - OP_L_IB(4, start); - OP_L_IB(5, start); - OP_L_IB(6, start); - OP_L_IB(7, start); - OP_L_IB(8, start); - OP_L_IB(9, start); - OP_L_IB(10, start); - OP_L_IB(11, start); - OP_L_IB(12, start); - OP_L_IB(13, start); - OP_L_IB(14, start); - - if(BIT15(i)) - { - u32 tmp; - start += 4; - c += waitState[(start>>24)&0xF]; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - cpu->next_instruction = registres[15]; - c += 2 + (c==0); - } - - if(i & (1 << REG_POS(i,16))) { - if(i & bitList) - cpu->R[REG_POS(i,16)] = start; - } - else - cpu->R[REG_POS(i,16)] = start; - - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMDA_W() -{ - const u32 &i = cpu->instruction; - u32 c = 0; - u32 start = cpu->R[REG_POS(i,16)]; - u32 bitList = (~((2 << REG_POS(i,16))-1)) & 0xFFFF; - - u32 * registres = cpu->R; - TWaitState * waitState = MMU.MMU_WAIT32[PROCNUM]; - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - c += waitState[(start>>24)&0xF]; - start -= 4; - cpu->next_instruction = registres[15]; - } - - OP_L_DA(14, start); - OP_L_DA(13, start); - OP_L_DA(12, start); - OP_L_DA(11, start); - OP_L_DA(10, start); - OP_L_DA(9, start); - OP_L_DA(8, start); - OP_L_DA(7, start); - OP_L_DA(6, start); - OP_L_DA(5, start); - OP_L_DA(4, start); - OP_L_DA(3, start); - OP_L_DA(2, start); - OP_L_DA(1, start); - OP_L_DA(0, start); - - if(i & (1 << REG_POS(i,16))) { - if(i & bitList) - cpu->R[REG_POS(i,16)] = start; - } - else - cpu->R[REG_POS(i,16)] = start; - - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMDB_W() -{ - const u32 &i = cpu->instruction; - u32 c = 0; - u32 start = cpu->R[REG_POS(i,16)]; - u32 bitList = (~((2 << REG_POS(i,16))-1)) & 0xFFFF; - u32 * registres = cpu->R; - TWaitState* waitState = MMU.MMU_WAIT32[PROCNUM]; - - if(BIT15(i)) - { - u32 tmp; - start -= 4; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR.bits.T = BIT0(tmp); - cpu->next_instruction = registres[15]; - c += waitState[(start>>24)&0xF]; - } - - OP_L_DB(14, start); - OP_L_DB(13, start); - OP_L_DB(12, start); - OP_L_DB(11, start); - OP_L_DB(10, start); - OP_L_DB(9, start); - OP_L_DB(8, start); - OP_L_DB(7, start); - OP_L_DB(6, start); - OP_L_DB(5, start); - OP_L_DB(4, start); - OP_L_DB(3, start); - OP_L_DB(2, start); - OP_L_DB(1, start); - OP_L_DB(0, start); - - if(i & (1 << REG_POS(i,16))) { - if(i & bitList) - cpu->R[REG_POS(i,16)] = start; - } - else - cpu->R[REG_POS(i,16)] = start; - - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMIA2() -{ - const u32 &i = cpu->instruction; - u32 oldmode = 0; - - u32 c = 0; - - u32 start = cpu->R[REG_POS(i,16)]; - u32 * registres; - TWaitState* waitState; - - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 1; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[PROCNUM]; - - OP_L_IA(0, start); - OP_L_IA(1, start); - OP_L_IA(2, start); - OP_L_IA(3, start); - OP_L_IA(4, start); - OP_L_IA(5, start); - OP_L_IA(6, start); - OP_L_IA(7, start); - OP_L_IA(8, start); - OP_L_IA(9, start); - OP_L_IA(10, start); - OP_L_IA(11, start); - OP_L_IA(12, start); - OP_L_IA(13, start); - OP_L_IA(14, start); - - if(BIT15(i) == 0) - { - armcpu_switchMode(cpu, oldmode); - } - else - { - - u32 tmp = READ32(cpu->mem_if->data, start); - Status_Reg SPSR; - cpu->R[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - //start += 4; - cpu->next_instruction = cpu->R[15]; - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - } - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMIB2() -{ - const u32 &i = cpu->instruction; - u32 oldmode = 0; - u32 c = 0; - - u32 start = cpu->R[REG_POS(i,16)]; - u32 * registres; - TWaitState* waitState; - - UNTESTEDOPCODELOG("Untested opcode: OP_LDMIB2\n"); - - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[PROCNUM]; - - OP_L_IB(0, start); - OP_L_IB(1, start); - OP_L_IB(2, start); - OP_L_IB(3, start); - OP_L_IB(4, start); - OP_L_IB(5, start); - OP_L_IB(6, start); - OP_L_IB(7, start); - OP_L_IB(8, start); - OP_L_IB(9, start); - OP_L_IB(10, start); - OP_L_IB(11, start); - OP_L_IB(12, start); - OP_L_IB(13, start); - OP_L_IB(14, start); - - if(BIT15(i) == 0) - { - armcpu_switchMode(cpu, oldmode); - } - else - { - u32 tmp; - Status_Reg SPSR; - start += 4; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->next_instruction = registres[15]; - c += waitState[(start>>24)&0xF]; - } - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMDA2() -{ - const u32 &i = cpu->instruction; - - u32 oldmode = 0; - u32 c = 0; - u32 * registres; - TWaitState* waitState; - - u32 start = cpu->R[REG_POS(i,16)]; - - UNTESTEDOPCODELOG("Untested opcode: OP_LDMDA2\n"); - - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[PROCNUM]; - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR = cpu->SPSR; - c += waitState[(start>>24)&0xF]; - start -= 4; - cpu->next_instruction = registres[15]; - } - - OP_L_DA(14, start); - OP_L_DA(13, start); - OP_L_DA(12, start); - OP_L_DA(11, start); - OP_L_DA(10, start); - OP_L_DA(9, start); - OP_L_DA(8, start); - OP_L_DA(7, start); - OP_L_DA(6, start); - OP_L_DA(5, start); - OP_L_DA(4, start); - OP_L_DA(3, start); - OP_L_DA(2, start); - OP_L_DA(1, start); - OP_L_DA(0, start); - - if(BIT15(i)==0) - { - armcpu_switchMode(cpu, oldmode); - } - else - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - } - - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMDB2() -{ - const u32 &i = cpu->instruction; - - u32 oldmode = 0; - u32 c = 0; - u32 * registres; - TWaitState* waitState; - - u32 start = cpu->R[REG_POS(i,16)]; - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[PROCNUM]; - - if(BIT15(i)) - { - u32 tmp; - start -= 4; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR = cpu->SPSR; - cpu->next_instruction = registres[15]; - c += waitState[(start>>24)&0xF]; - } - - OP_L_DB(14, start); - OP_L_DB(13, start); - OP_L_DB(12, start); - OP_L_DB(11, start); - OP_L_DB(10, start); - OP_L_DB(9, start); - OP_L_DB(8, start); - OP_L_DB(7, start); - OP_L_DB(6, start); - OP_L_DB(5, start); - OP_L_DB(4, start); - OP_L_DB(3, start); - OP_L_DB(2, start); - OP_L_DB(1, start); - OP_L_DB(0, start); - - if(BIT15(i)==0) - { - armcpu_switchMode(cpu, oldmode); - } - else - { - Status_Reg SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - } - - return 2 + c; -} - -TEMPLATE static u32 FASTCALL OP_LDMIA2_W() -{ - const u32 &i = cpu->instruction; - u32 c = 0; - - u32 oldmode = 0; - u32 start = cpu->R[REG_POS(i,16)]; - u32 * registres; - TWaitState* waitState; - u32 tmp; - Status_Reg SPSR; -// emu_halt(); - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[PROCNUM]; - - OP_L_IA(0, start); - OP_L_IA(1, start); - OP_L_IA(2, start); - OP_L_IA(3, start); - OP_L_IA(4, start); - OP_L_IA(5, start); - OP_L_IA(6, start); - OP_L_IA(7, start); - OP_L_IA(8, start); - OP_L_IA(9, start); - OP_L_IA(10, start); - OP_L_IA(11, start); - OP_L_IA(12, start); - OP_L_IA(13, start); - OP_L_IA(14, start); - - if(BIT15(i)==0) - { - registres[REG_POS(i,16)] = start; - armcpu_switchMode(cpu, oldmode); - return c + 2; - } - - registres[REG_POS(i,16)] = start + 4; - tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - cpu->next_instruction = registres[15]; - c += waitState[(start>>24)&0xF]; - - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMIB2_W() -{ - const u32 &i = cpu->instruction; - u32 c = 0; - - u32 oldmode = 0; - u32 start = cpu->R[REG_POS(i,16)]; - u32 * registres; - TWaitState* waitState; - u32 tmp; - Status_Reg SPSR; - - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[PROCNUM]; - - OP_L_IB(0, start); - OP_L_IB(1, start); - OP_L_IB(2, start); - OP_L_IB(3, start); - OP_L_IB(4, start); - OP_L_IB(5, start); - OP_L_IB(6, start); - OP_L_IB(7, start); - OP_L_IB(8, start); - OP_L_IB(9, start); - OP_L_IB(10, start); - OP_L_IB(11, start); - OP_L_IB(12, start); - OP_L_IB(13, start); - OP_L_IB(14, start); - - if(BIT15(i)==0) - { - armcpu_switchMode(cpu, oldmode); - registres[REG_POS(i,16)] = start; - - return c + 2; - } - - registres[REG_POS(i,16)] = start + 4; - tmp = READ32(cpu->mem_if->data, start + 4); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR = cpu->SPSR; - cpu->next_instruction = registres[15]; - SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - c += waitState[(start>>24)&0xF]; - - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMDA2_W() -{ - const u32 &i = cpu->instruction; - u32 c = 0; - - u32 oldmode = 0; - u32 start = cpu->R[REG_POS(i,16)]; - u32 * registres; - TWaitState * waitState; - Status_Reg SPSR; -// emu_halt(); - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[PROCNUM]; - - if(BIT15(i)) - { - u32 tmp = READ32(cpu->mem_if->data, start); - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - c += waitState[(start>>24)&0xF]; - start -= 4; - cpu->next_instruction = registres[15]; - } - - OP_L_DA(14, start); - OP_L_DA(13, start); - OP_L_DA(12, start); - OP_L_DA(11, start); - OP_L_DA(10, start); - OP_L_DA(9, start); - OP_L_DA(8, start); - OP_L_DA(7, start); - OP_L_DA(6, start); - OP_L_DA(5, start); - OP_L_DA(4, start); - OP_L_DA(3, start); - OP_L_DA(2, start); - OP_L_DA(1, start); - OP_L_DA(0, start); - - registres[REG_POS(i,16)] = start; - - if(BIT15(i)==0) - { - armcpu_switchMode(cpu, oldmode); - return c + 2; - } - - SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMDB2_W() -{ - const u32 &i = cpu->instruction; - u32 c = 0; - - u32 oldmode = 0; - u32 start = cpu->R[REG_POS(i,16)]; - u32 * registres; - TWaitState* waitState; - Status_Reg SPSR; -// emu_halt(); - if(BIT15(i)==0) - { - if(cpu->CPSR.bits.mode==USR) - return 2; - oldmode = armcpu_switchMode(cpu, SYS); - } - - registres = cpu->R; - waitState = MMU.MMU_WAIT32[PROCNUM]; - - if(BIT15(i)) - { - u32 tmp; - start -= 4; - tmp = READ32(cpu->mem_if->data, start); - c += waitState[(start>>24)&0xF]; - registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); - cpu->CPSR = cpu->SPSR; - cpu->next_instruction = registres[15]; - } - - OP_L_DB(14, start); - OP_L_DB(13, start); - OP_L_DB(12, start); - OP_L_DB(11, start); - OP_L_DB(10, start); - OP_L_DB(9, start); - OP_L_DB(8, start); - OP_L_DB(7, start); - OP_L_DB(6, start); - OP_L_DB(5, start); - OP_L_DB(4, start); - OP_L_DB(3, start); - OP_L_DB(2, start); - OP_L_DB(1, start); - OP_L_DB(0, start); - - registres[REG_POS(i,16)] = start; - - if(BIT15(i)==0) - { - armcpu_switchMode(cpu, oldmode); - return c + 2; - } - - SPSR = cpu->SPSR; - armcpu_switchMode(cpu, SPSR.bits.mode); - cpu->CPSR=SPSR; - return c + 2; -} - -//------------------------------STM---------------------------------- - -TEMPLATE static u32 FASTCALL OP_STMIA() -{ - const u32 &i = cpu->instruction; - u32 c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - start += 4; - } - } - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMIB() -{ - const u32 &i = cpu->instruction; - u32 c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - start += 4; - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - } - } - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMDA() -{ - const u32 &i = cpu->instruction; - u32 c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - start -= 4; - } - } - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMDB() -{ - const u32 &i = cpu->instruction; - u32 c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - start -= 4; - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - } - } - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMIA_W() -{ - const u32 &i = cpu->instruction; - u32 c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - start += 4; - } - } - - cpu->R[REG_POS(i,16)] = start; - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMIB_W() -{ - const u32 &i = cpu->instruction; - u32 c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - start += 4; - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - } - } - cpu->R[REG_POS(i,16)] = start; - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMDA_W() -{ - const u32 &i = cpu->instruction; - u32 c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - start -= 4; - } - } - - cpu->R[REG_POS(i,16)] = start; - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMDB_W() -{ - const u32 &i = cpu->instruction; - u32 c = 0, b; - u32 start = cpu->R[REG_POS(i,16)]; - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - start -= 4; - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - } - } - - cpu->R[REG_POS(i,16)] = start; - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMIA2() -{ - const u32 &i = cpu->instruction; - u32 c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - c = 0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_STMIA2\n"); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - start += 4; - } - } - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMIB2() -{ - const u32 &i = cpu->instruction; - u32 c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - c = 0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_STMIB2\n"); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - start += 4; - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - } - } - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMDA2() -{ - const u32 &i=cpu->instruction; - u32 c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - c = 0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_STMDA2\n"); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - start -= 4; - } - } - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMDB2() -{ - const u32 &i = cpu->instruction; - u32 c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - c=0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - start -= 4; - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - } - } - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMIA2_W() -{ - u32 i, c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - i = cpu->instruction; - c=0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_STMIA2_W\n"); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - start += 4; - } - } - - cpu->R[REG_POS(i,16)] = start; - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMIB2_W() -{ - u32 i, c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - i = cpu->instruction; - c=0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, b)) - { - start += 4; - WRITE32(cpu->mem_if->data, start, cpu->R[b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - } - } - armcpu_switchMode(cpu, oldmode); - cpu->R[REG_POS(i,16)] = start; - - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMDA2_W() -{ - u32 i, c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - i = cpu->instruction; - c = 0; - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_STMDA2_W\n"); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - start -= 4; - } - } - - cpu->R[REG_POS(i,16)] = start; - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -TEMPLATE static u32 FASTCALL OP_STMDB2_W() -{ - u32 i, c, b; - u32 start; - u32 oldmode; - - if(cpu->CPSR.bits.mode==USR) - return 2; - - i = cpu->instruction; - c = 0; - - start = cpu->R[REG_POS(i,16)]; - oldmode = armcpu_switchMode(cpu, SYS); - - UNTESTEDOPCODELOG("Untested opcode: OP_STMDB2_W\n"); - - for(b=0; b<16; ++b) - { - if(BIT_N(i, 15-b)) - { - start -= 4; - WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); - c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; - } - } - - cpu->R[REG_POS(i,16)] = start; - - armcpu_switchMode(cpu, oldmode); - return c + 1; -} - -/* - * - * The Enhanced DSP Extension LDRD and STRD instructions. - * - */ -TEMPLATE static u32 FASTCALL -OP_LDRD_STRD_POST_INDEX( ) { - const u32 &i = cpu->instruction; - u32 Rd_num = REG_POS( i, 12); - u32 addr = cpu->R[REG_POS(i,16)]; - u32 index; - - /* I bit - immediate or register */ - if ( BIT22(i)) - index = IMM_OFF; - else - index = cpu->R[REG_POS(i,0)]; - - /* U bit - add or subtract */ - if ( BIT23(i)) - cpu->R[REG_POS(i,16)] += index; - else - cpu->R[REG_POS(i,16)] -= index; - - if ( !(Rd_num & 0x1)) { - /* Store/Load */ - if ( BIT5(i)) { - WRITE32(cpu->mem_if->data, addr, cpu->R[Rd_num]); - WRITE32(cpu->mem_if->data, addr + 4, cpu->R[Rd_num + 1]); - } - else { - cpu->R[Rd_num] = READ32(cpu->mem_if->data, addr); - cpu->R[Rd_num + 1] = READ32(cpu->mem_if->data, addr + 4); - } - } - - return 3 + (MMU.MMU_WAIT32[PROCNUM][(addr>>24)&0xF] * 2); -} - -TEMPLATE static u32 FASTCALL -OP_LDRD_STRD_OFFSET_PRE_INDEX( ) { - const u32 &i = cpu->instruction; - u32 Rd_num = REG_POS( i, 12); - u32 addr = cpu->R[REG_POS(i,16)]; - u32 index; - - /* I bit - immediate or register */ - if ( BIT22(i)) - index = IMM_OFF; - else - index = cpu->R[REG_POS(i,0)]; - - /* U bit - add or subtract */ - if ( BIT23(i)) { - addr += index; - - /* W bit - writeback */ - if ( BIT21(i)) - cpu->R[REG_POS(i,16)] = addr; - } - else { - addr -= index; - - /* W bit - writeback */ - if ( BIT21(i)) - cpu->R[REG_POS(i,16)] = addr; - } - - if ( !(Rd_num & 0x1)) { - /* Store/Load */ - if ( BIT5(i)) { - WRITE32(cpu->mem_if->data, addr, cpu->R[Rd_num]); - WRITE32(cpu->mem_if->data, addr + 4, cpu->R[Rd_num + 1]); - } - else { - cpu->R[Rd_num] = READ32(cpu->mem_if->data, addr); - cpu->R[Rd_num + 1] = READ32(cpu->mem_if->data, addr + 4); - } - } - - return 3 + (MMU.MMU_WAIT32[PROCNUM][(addr>>24)&0xF] * 2); -} - - - -//---------------------STC---------------------------------- -/* the NDS has no coproc that responses to a STC, no feedback is given to the arm */ - -TEMPLATE static u32 FASTCALL OP_STC_P_IMM_OFF() -{ - TRAPUNDEF(); -} - -TEMPLATE static u32 FASTCALL OP_STC_M_IMM_OFF() -{ - TRAPUNDEF(); -} - -TEMPLATE static u32 FASTCALL OP_STC_P_PREIND() -{ - TRAPUNDEF(); -} - -TEMPLATE static u32 FASTCALL OP_STC_M_PREIND() -{ - TRAPUNDEF(); -} - -TEMPLATE static u32 FASTCALL OP_STC_P_POSTIND() -{ - TRAPUNDEF(); -} - -TEMPLATE static u32 FASTCALL OP_STC_M_POSTIND() -{ - TRAPUNDEF(); -} - -TEMPLATE static u32 FASTCALL OP_STC_OPTION() -{ - TRAPUNDEF(); -} - -//---------------------LDC---------------------------------- -/* the NDS has no coproc that responses to a LDC, no feedback is given to the arm */ - -TEMPLATE static u32 FASTCALL OP_LDC_P_IMM_OFF() -{ - TRAPUNDEF(); -} - -TEMPLATE static u32 FASTCALL OP_LDC_M_IMM_OFF() -{ - TRAPUNDEF(); -} - -TEMPLATE static u32 FASTCALL OP_LDC_P_PREIND() -{ - TRAPUNDEF(); -} - -TEMPLATE static u32 FASTCALL OP_LDC_M_PREIND() -{ - TRAPUNDEF(); -} - -TEMPLATE static u32 FASTCALL OP_LDC_P_POSTIND() -{ - TRAPUNDEF(); -} - -TEMPLATE static u32 FASTCALL OP_LDC_M_POSTIND() -{ - TRAPUNDEF(); -} - -TEMPLATE static u32 FASTCALL OP_LDC_OPTION() -{ - TRAPUNDEF(); - return 2; -} - -//----------------MCR----------------------- - -TEMPLATE static u32 FASTCALL OP_MCR() -{ - const u32 &i = cpu->instruction; - u32 cpnum = REG_POS(i, 8); - - if(!cpu->coproc[cpnum]) - { - emu_halt(); - LOG("Stopped (OP_MCR)\n"); - return 2; - } - - armcp15_moveARM2CP((armcp15_t*)cpu->coproc[cpnum], cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); - //cpu->coproc[cpnum]->moveARM2CP(cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); - return 2; -} - -//----------------MRC----------------------- - -TEMPLATE static u32 FASTCALL OP_MRC() -{ - const u32 &i = cpu->instruction; - u32 cpnum = REG_POS(i, 8); - - if(!cpu->coproc[cpnum]) - { - emu_halt(); - LOG("Stopped (OP_MRC)\n"); - return 2; - } - - armcp15_moveCP2ARM((armcp15_t*)cpu->coproc[cpnum], &cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); - //cpu->coproc[cpnum]->moveCP2ARM(&cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); - return 4; -} - -//--------------SWI------------------------------- -TEMPLATE static u32 FASTCALL OP_SWI() -{ - u32 swinum = (cpu->instruction>>16)&0xFF; - - //ideas-style debug prints - if(swinum==0xFC) { - IdeasLog(cpu); - return 0; - } - - if(cpu->swi_tab) { - swinum &= 0x1F; - return cpu->swi_tab[swinum]() + 3; - } else { - /* TODO (#1#): translocated SWI vectors */ - /* we use an irq thats not in the irq tab, as - it was replaced duie to a changed intVector */ - Status_Reg tmp = cpu->CPSR; - armcpu_switchMode(cpu, SVC); /* enter svc mode */ - cpu->R[14] = cpu->next_instruction; - cpu->SPSR = tmp; /* save old CPSR as new SPSR */ - cpu->CPSR.bits.T = 0; /* handle as ARM32 code */ - cpu->CPSR.bits.I = 1; - cpu->R[15] = cpu->intVector + 0x08; - cpu->next_instruction = cpu->R[15]; - return 4; - } -} - -//----------------BKPT------------------------- -TEMPLATE static u32 FASTCALL OP_BKPT() -{ - /*LOG("Stopped (OP_BKPT)\n"); - TRAPUNDEF();*/ - return 4; -} - -//----------------CDP----------------------- - -TEMPLATE static u32 FASTCALL OP_CDP() -{ - LOG("Stopped (OP_CDP)\n"); - TRAPUNDEF(); -} - -#define TYPE_RETOUR u32 -#define PARAMETRES -#define CALLTYPE FASTCALL -#define NOM_TAB arm_instructions_set_0 -#define TABDECL(x) x<0> - -#include "instruction_tabdef.inc" - -#undef TYPE_RETOUR -#undef PARAMETRES -#undef CALLTYPE -#undef NOM_TAB -#undef TABDECL - -#define TYPE_RETOUR u32 -#define PARAMETRES -#define CALLTYPE FASTCALL -#define NOM_TAB arm_instructions_set_1 -#define TABDECL(x) x<1> - -#include "instruction_tabdef.inc" +/* Copyright (C) 2006 yopyop + Copyright (C) 2006 shash + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2006-2007 shash + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "cp15.h" +#include "debug.h" +#include "MMU.h" +#include "armcpu.h" +#include "NDSSystem.h" + +#define cpu (&ARMPROC) +#define TEMPLATE template + +extern volatile BOOL execute; + +#define LSL_IMM shift_op = cpu->R[REG_POS(i,0)]<<((i>>7)&0x1F); + +#define S_LSL_IMM u32 shift_op = ((i>>7)&0x1F);\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + shift_op=cpu->R[REG_POS(i,0)];\ + else\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], 32-shift_op);\ + shift_op = cpu->R[REG_POS(i,0)]<<((i>>7)&0x1F);\ + } + +#define LSL_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + if(shift_op>=32)\ + shift_op=0;\ + else\ + shift_op=cpu->R[REG_POS(i,0)]<R[REG_POS(i,8)])&0xFF;\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + shift_op=cpu->R[REG_POS(i,0)];\ + else\ + if(shift_op<32)\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], 32-shift_op);\ + shift_op = cpu->R[REG_POS(i,0)]<R[REG_POS(i,0)]);\ + }\ + else\ + {\ + shift_op = 0;\ + c = 0;\ + } + +#define LSR_IMM shift_op = ((i>>7)&0x1F);\ + if(shift_op!=0)\ + shift_op = cpu->R[REG_POS(i,0)]>>shift_op; + +#define S_LSR_IMM u32 shift_op = ((i>>7)&0x1F);\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + {\ + c = BIT31(cpu->R[REG_POS(i,0)]);\ + }\ + else\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ + shift_op = cpu->R[REG_POS(i,0)]>>shift_op;\ + } + +#define LSR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + if(shift_op>=32)\ + shift_op = 0;\ + else\ + shift_op = cpu->R[REG_POS(i,0)]>>shift_op; + +#define S_LSR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + {\ + shift_op = cpu->R[REG_POS(i,0)];\ + }\ + else\ + if(shift_op<32)\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ + shift_op = cpu->R[REG_POS(i,0)]>>shift_op;\ + }\ + else\ + if(shift_op==32)\ + {\ + c = BIT31(cpu->R[REG_POS(i,0)]);\ + shift_op = 0;\ + }\ + else\ + {\ + c = 0;\ + shift_op = 0;\ + } + +#define ASR_IMM shift_op = ((i>>7)&0x1F);\ + if(shift_op==0)\ + shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF;\ + else\ + shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op); + +#define S_ASR_IMM u32 shift_op = ((i>>7)&0x1F);\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + {\ + shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF;\ + c = BIT31(cpu->R[REG_POS(i,0)]);\ + }\ + else\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ + shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op);\ + } + +#define ASR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + if(shift_op==0)\ + shift_op=cpu->R[REG_POS(i,0)];\ + else\ + if(shift_op<32)\ + shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op);\ + else\ + shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF; + +#define S_ASR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + shift_op=cpu->R[REG_POS(i,0)];\ + else\ + if(shift_op<32)\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ + shift_op = (u32)(((s32)(cpu->R[REG_POS(i,0)]))>>shift_op);\ + }\ + else\ + {\ + c = BIT31(cpu->R[REG_POS(i,0)]);\ + shift_op=BIT31(cpu->R[REG_POS(i,0)])*0xFFFFFFFF;\ + } + +#define ROR_IMM shift_op = ((i>>7)&0x1F);\ + if(shift_op==0)\ + {\ + u32 tmp = cpu->CPSR.bits.C;\ + shift_op = (tmp<<31)|(cpu->R[REG_POS(i,0)]>>1);\ + }\ + else\ + shift_op = ROR(cpu->R[REG_POS(i,0)],shift_op); + +#define S_ROR_IMM u32 shift_op = ((i>>7)&0x1F);\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + {\ + u32 tmp = cpu->CPSR.bits.C;\ + shift_op = (tmp<<31)|(cpu->R[REG_POS(i,0)]>>1);\ + c = BIT0(cpu->R[REG_POS(i,0)]);\ + }\ + else\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ + shift_op = ROR(cpu->R[REG_POS(i,0)],shift_op);\ + } + +#define ROR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + if((shift_op==0)||((shift_op&0x1F)==0))\ + shift_op=cpu->R[REG_POS(i,0)];\ + else\ + shift_op = ROR(cpu->R[REG_POS(i,0)],(shift_op&0x1F)); + +#define S_ROR_REG u32 shift_op = (cpu->R[REG_POS(i,8)])&0xFF;\ + u32 c = cpu->CPSR.bits.C;\ + if(shift_op==0)\ + shift_op=cpu->R[REG_POS(i,0)];\ + else\ + {\ + shift_op&=0x1F;\ + if(shift_op==0)\ + {\ + shift_op=cpu->R[REG_POS(i,0)];\ + c = BIT31(cpu->R[REG_POS(i,0)]);\ + }\ + else\ + {\ + c = BIT_N(cpu->R[REG_POS(i,0)], shift_op-1);\ + shift_op = ROR(cpu->R[REG_POS(i,0)],(shift_op&0x1F));\ + }\ + } + +#define IMM_VALUE u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E); + +#define S_IMM_VALUE u32 shift_op = ROR((i&0xFF), (i>>7)&0x1E);\ + u32 c = cpu->CPSR.bits.C;\ + if((i>>8)&0xF)\ + c = BIT31(shift_op); + +#define IMM_OFF (((i>>4)&0xF0)+(i&0xF)) + +#define IMM_OFF_12 ((i)&0xFFF) + +TEMPLATE static u32 FASTCALL OP_UND() +{ + LOG("Undefined instruction: %08X from %08X\n", cpu->instruction, cpu->instruct_adr); + emu_halt(); + LOG("Stopped (OP_UND)\n"); + return 1; +} + +#define TRAPUNDEF() \ + LOG("Undefined instruction: %#08X PC = %#08X\n", cpu->instruction, cpu->instruct_adr); \ + \ + if (((cpu->intVector != 0) ^ (PROCNUM == ARMCPU_ARM9))){ \ + Status_Reg tmp = cpu->CPSR; \ + armcpu_switchMode(cpu, UND); /* enter und mode */ \ + cpu->R[14] = cpu->R[15] - 4; /* jump to und Vector */ \ + cpu->SPSR = tmp; /* save old CPSR as new SPSR */ \ + cpu->CPSR.bits.T = 0; /* handle as ARM32 code */ \ + cpu->CPSR.bits.I = cpu->SPSR.bits.I; /* keep int disable flag */ \ + cpu->R[15] = cpu->intVector + 0x04; \ + cpu->next_instruction = cpu->R[15]; \ + return 4; \ + } \ + else \ + { \ + emu_halt(); \ + return 4; \ + } \ + +//-----------------------AND------------------------------------ + +#define OP_AND(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +#define OP_ANDS(a, b)\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR;\ + cpu->R[15] = cpu->R[REG_POS(i,16)] & shift_op;\ + SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & shift_op;\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + return a; + +TEMPLATE static u32 FASTCALL OP_AND_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_AND(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_AND_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OP_AND(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_AND_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_AND(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_AND_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OP_AND(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_AND_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_AND(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_AND_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OP_AND(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_AND_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_AND(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_AND_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OP_AND(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_AND_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OP_AND(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_AND_S_LSL_IMM() +{ + const u32 &i = cpu->instruction; + S_LSL_IMM; + OP_ANDS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_AND_S_LSL_REG() +{ + const u32 &i = cpu->instruction; + S_LSL_REG; + OP_ANDS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_AND_S_LSR_IMM() +{ + const u32 &i = cpu->instruction; + S_LSR_IMM; + OP_ANDS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_AND_S_LSR_REG() +{ + const u32 &i = cpu->instruction; + S_LSR_REG; + OP_ANDS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_AND_S_ASR_IMM() +{ + const u32 &i = cpu->instruction; + S_ASR_IMM; + OP_ANDS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_AND_S_ASR_REG() +{ + const u32 &i = cpu->instruction; + S_ASR_REG; + OP_ANDS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_AND_S_ROR_IMM() +{ + const u32 &i = cpu->instruction; + S_ROR_IMM; + OP_ANDS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_AND_S_ROR_REG() +{ + const u32 &i = cpu->instruction; + S_ROR_REG; + OP_ANDS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_AND_S_IMM_VAL() +{ + const u32 &i = cpu->instruction; + S_IMM_VALUE; + OP_ANDS(2, 4); +} + +//--------------EOR------------------------------ + +#define OP_EOR(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] ^ shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +#define OP_EORS(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] ^ shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + return a; + +TEMPLATE static u32 FASTCALL OP_EOR_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_EOR(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_EOR_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OP_EOR(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_EOR_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_EOR(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_EOR_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OP_EOR(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_EOR_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_EOR(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_EOR_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OP_EOR(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_EOR_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_EOR(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_EOR_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OP_EOR(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_EOR_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OP_EOR(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_EOR_S_LSL_IMM() +{ + const u32 &i = cpu->instruction; + S_LSL_IMM; + OP_EORS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_EOR_S_LSL_REG() +{ + const u32 &i = cpu->instruction; + S_LSL_REG; + OP_EORS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_EOR_S_LSR_IMM() +{ + const u32 &i = cpu->instruction; + S_LSR_IMM; + OP_EORS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_EOR_S_LSR_REG() +{ + const u32 &i = cpu->instruction; + S_LSR_REG; + OP_EORS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_EOR_S_ASR_IMM() +{ + const u32 &i = cpu->instruction; + S_ASR_IMM; + OP_EORS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_EOR_S_ASR_REG() +{ + const u32 &i = cpu->instruction; + S_ASR_REG; + OP_EORS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_EOR_S_ROR_IMM() +{ + const u32 &i = cpu->instruction; + S_ROR_IMM; + OP_EORS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_EOR_S_ROR_REG() +{ + const u32 &i = cpu->instruction; + S_ROR_REG; + OP_EORS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_EOR_S_IMM_VAL() +{ + const u32 &i = cpu->instruction; + S_IMM_VALUE; + OP_EORS(2, 4); +} + +//-------------SUB------------------------------------- + +#define OP_SUB(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] - shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +#define OPSUBS(a, b) cpu->R[REG_POS(i,12)] = v - shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ + return a; + +TEMPLATE static u32 FASTCALL OP_SUB_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_SUB(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_SUB_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OP_SUB(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SUB_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_SUB(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_SUB_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OP_SUB(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SUB_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_SUB(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_SUB_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OP_SUB(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SUB_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_SUB(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_SUB_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OP_SUB(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SUB_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OP_SUB(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_SUB_S_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSL_IMM; + OPSUBS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SUB_S_LSL_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSL_REG; + OPSUBS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_SUB_S_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSR_IMM; + OPSUBS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SUB_S_LSR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSR_REG; + OPSUBS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_SUB_S_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ASR_IMM; + OPSUBS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SUB_S_ASR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ASR_REG; + OPSUBS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_SUB_S_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ROR_IMM; + OPSUBS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SUB_S_ROR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ROR_REG; + OPSUBS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_SUB_S_IMM_VAL() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + IMM_VALUE; + OPSUBS(2, 4); +} + +//------------------RSB------------------------ + +#define OP_RSB(a, b) cpu->R[REG_POS(i,12)] = shift_op - cpu->R[REG_POS(i,16)];\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +#define OP_RSBS(a, b) cpu->R[REG_POS(i,12)] = shift_op - v;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(shift_op, v, cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(shift_op, v, cpu->R[REG_POS(i,12)]);\ + return a; + +TEMPLATE static u32 FASTCALL OP_RSB_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_RSB(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_RSB_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OP_RSB(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_RSB_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_RSB(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_RSB_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OP_RSB(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_RSB_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_RSB(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_RSB_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OP_RSB(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_RSB_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_RSB(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_RSB_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OP_RSB(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_RSB_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OP_RSB(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_RSB_S_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSL_IMM; + OP_RSBS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_RSB_S_LSL_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSL_REG; + OP_RSBS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_RSB_S_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSR_IMM; + OP_RSBS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_RSB_S_LSR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSR_REG; + OP_RSBS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_RSB_S_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ASR_IMM; + OP_RSBS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_RSB_S_ASR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ASR_REG; + OP_RSBS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_RSB_S_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ROR_IMM; + OP_RSBS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_RSB_S_ROR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ROR_REG; + OP_RSBS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_RSB_S_IMM_VAL() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + IMM_VALUE; + OP_RSBS(2, 4); +} + +//------------------ADD----------------------------------- + +#define OP_ADD(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] + shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +TEMPLATE static u32 FASTCALL OP_ADD_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_ADD(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_ADD_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OP_ADD(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADD_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_ADD(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_ADD_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OP_ADD(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADD_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_ADD(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_ADD_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OP_ADD(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADD_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_ADD(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_ADD_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OP_ADD(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADD_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OP_ADD(1, 3); +} + +#define OP_ADDS(a, b) cpu->R[REG_POS(i,12)] = v + shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.V = SIGNED_OVERFLOW(v, shift_op, cpu->R[REG_POS(i,12)]);\ + return a; + +TEMPLATE static u32 FASTCALL OP_ADD_S_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSL_IMM; + OP_ADDS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADD_S_LSL_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSL_REG; + OP_ADDS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_ADD_S_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSR_IMM; + OP_ADDS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADD_S_LSR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSR_REG; + OP_ADDS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_ADD_S_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ASR_IMM; + OP_ADDS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADD_S_ASR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ASR_REG; + OP_ADDS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_ADD_S_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ROR_IMM; + OP_ADDS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADD_S_ROR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ROR_REG; + OP_ADDS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_ADD_S_IMM_VAL() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + IMM_VALUE; + OP_ADDS(2, 4); +} + +//------------------ADC----------------------------------- + +#define OP_ADC(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] + shift_op + cpu->CPSR.bits.C;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +TEMPLATE static u32 FASTCALL OP_ADC_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_ADC(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_ADC_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OP_ADC(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADC_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_ADC(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_ADC_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OP_ADC(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADC_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_ADC(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_ADC_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OP_ADC(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADC_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_ADC(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_ADC_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OP_ADC(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADC_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OP_ADC(1, 3); +} + +#define OP_ADCS(a, b) \ + { \ + u32 tmp = shift_op + cpu->CPSR.bits.C;\ + cpu->R[REG_POS(i,12)] = v + tmp;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(shift_op, (u32) cpu->CPSR.bits.C, tmp) | UNSIGNED_OVERFLOW(v, tmp, cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.V = SIGNED_OVERFLOW(shift_op, (u32) cpu->CPSR.bits.C, tmp) | SIGNED_OVERFLOW(v, tmp, cpu->R[REG_POS(i,12)]);\ + return a; \ + } + +TEMPLATE static u32 FASTCALL OP_ADC_S_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSL_IMM; + OP_ADCS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADC_S_LSL_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSL_REG; + OP_ADCS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_ADC_S_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSR_IMM; + OP_ADCS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADC_S_LSR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSR_REG; + OP_ADCS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_ADC_S_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ASR_IMM; + OP_ADCS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADC_S_ASR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ASR_REG; + OP_ADCS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_ADC_S_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ROR_IMM; + OP_ADCS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ADC_S_ROR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ROR_REG; + OP_ADCS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_ADC_S_IMM_VAL() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + IMM_VALUE; + OP_ADCS(2, 4); +} + +//-------------SBC------------------------------------- + +#define OP_SBC(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] - shift_op - (!cpu->CPSR.bits.C);\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +TEMPLATE static u32 FASTCALL OP_SBC_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_SBC(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_SBC_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OP_SBC(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SBC_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_SBC(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_SBC_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OP_SBC(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SBC_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_SBC(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_SBC_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OP_SBC(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SBC_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_SBC(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_SBC_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OP_SBC(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SBC_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OP_SBC(1, 3); +} + +//zero 14-feb-2009 - reverting flag logic to fix zoning bug in ff4 +#define OP_SBCS(a, b) \ + { \ + u32 tmp = v - (!cpu->CPSR.bits.C);\ + cpu->R[REG_POS(i,12)] = tmp - shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + cpu->CPSR.bits.C = (!UNSIGNED_UNDERFLOW(v, (u32)(!cpu->CPSR.bits.C), tmp)) & (!UNSIGNED_UNDERFLOW(tmp, shift_op, cpu->R[REG_POS(i,12)]));\ + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(v, (u32)(!cpu->CPSR.bits.C), tmp) | SIGNED_UNDERFLOW(tmp, shift_op, cpu->R[REG_POS(i,12)]);\ + return a; \ + } + + +TEMPLATE static u32 FASTCALL OP_SBC_S_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSL_IMM; + OP_SBCS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SBC_S_LSL_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSL_REG; + OP_SBCS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_SBC_S_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSR_IMM; + OP_SBCS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SBC_S_LSR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSR_REG; + OP_SBCS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_SBC_S_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ASR_IMM; + OP_SBCS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SBC_S_ASR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ASR_REG; + OP_SBCS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_SBC_S_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ROR_IMM; + OP_SBCS(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_SBC_S_ROR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ROR_REG; + OP_SBCS(3, 5); +} + +TEMPLATE static u32 FASTCALL OP_SBC_S_IMM_VAL() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + IMM_VALUE; + OP_SBCS(2, 4); +} + +//---------------RSC---------------------------------- + +#define OP_RSC(a, b) cpu->R[REG_POS(i,12)] = shift_op - cpu->R[REG_POS(i,16)] - (!cpu->CPSR.bits.C);\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +TEMPLATE static u32 FASTCALL OP_RSC_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_RSC(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_RSC_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OP_RSC(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_RSC_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_RSC(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_RSC_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OP_RSC(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_RSC_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_RSC(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_RSC_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OP_RSC(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_RSC_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_RSC(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_RSC_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OP_RSC(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_RSC_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OP_RSC(1, 3); +} + +//zero 14-feb-2009 - reverting flag logic to fix zoning bug in ff4 +#define OP_RSCS(a,b) \ + { \ + u32 tmp = shift_op - (!cpu->CPSR.bits.C);\ + cpu->R[REG_POS(i,12)] = tmp - v;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + cpu->CPSR.bits.C = (!UNSIGNED_UNDERFLOW(shift_op, (u32)(!cpu->CPSR.bits.C), (u32)tmp)) & (!UNSIGNED_UNDERFLOW(tmp, v, cpu->R[REG_POS(i,12)]));\ + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(shift_op, (u32)(!cpu->CPSR.bits.C), (u32)tmp) | SIGNED_UNDERFLOW(tmp, v, cpu->R[REG_POS(i,12)]);\ + return a; \ + } + +TEMPLATE static u32 FASTCALL OP_RSC_S_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSL_IMM; + OP_RSCS(2,4); +} + +TEMPLATE static u32 FASTCALL OP_RSC_S_LSL_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSL_REG; + OP_RSCS(3,5); +} + +TEMPLATE static u32 FASTCALL OP_RSC_S_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + LSR_IMM; + OP_RSCS(2,4); +} + +TEMPLATE static u32 FASTCALL OP_RSC_S_LSR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + LSR_REG; + OP_RSCS(3,5); +} + +TEMPLATE static u32 FASTCALL OP_RSC_S_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ASR_IMM; + OP_RSCS(2,4); +} + +TEMPLATE static u32 FASTCALL OP_RSC_S_ASR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ASR_REG; + OP_RSCS(3,5); +} + +TEMPLATE static u32 FASTCALL OP_RSC_S_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + u32 shift_op; + ROR_IMM; + OP_RSCS(2,4); +} + +TEMPLATE static u32 FASTCALL OP_RSC_S_ROR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + ROR_REG; + OP_RSCS(3,5); +} + +TEMPLATE static u32 FASTCALL OP_RSC_S_IMM_VAL() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,16)]; + IMM_VALUE; + OP_RSCS(2,4); +} + +//-------------------TST---------------------------- + +#define OP_TST(a) \ + { \ + unsigned tmp = cpu->R[REG_POS(i,16)] & shift_op;\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(tmp);\ + cpu->CPSR.bits.Z = (tmp==0);\ + return a; \ + } + +TEMPLATE static u32 FASTCALL OP_TST_LSL_IMM() +{ + const u32 &i = cpu->instruction; + S_LSL_IMM; + OP_TST(1); +} + +TEMPLATE static u32 FASTCALL OP_TST_LSL_REG() +{ + const u32 &i = cpu->instruction; + S_LSL_REG; + OP_TST(2); +} + +TEMPLATE static u32 FASTCALL OP_TST_LSR_IMM() +{ + const u32 &i = cpu->instruction; + S_LSR_IMM; + OP_TST(1); +} + +TEMPLATE static u32 FASTCALL OP_TST_LSR_REG() +{ + const u32 &i = cpu->instruction; + S_LSR_REG; + OP_TST(2); +} + +TEMPLATE static u32 FASTCALL OP_TST_ASR_IMM() +{ + const u32 &i = cpu->instruction; + S_ASR_IMM; + OP_TST(1); +} + +TEMPLATE static u32 FASTCALL OP_TST_ASR_REG() +{ + const u32 &i = cpu->instruction; + S_ASR_REG; + OP_TST(2); +} + +TEMPLATE static u32 FASTCALL OP_TST_ROR_IMM() +{ + const u32 &i = cpu->instruction; + S_ROR_IMM; + OP_TST(1); +} + +TEMPLATE static u32 FASTCALL OP_TST_ROR_REG() +{ + const u32 &i = cpu->instruction; + S_ROR_REG; + OP_TST(2); +} + +TEMPLATE static u32 FASTCALL OP_TST_IMM_VAL() +{ + const u32 &i = cpu->instruction; + S_IMM_VALUE; + OP_TST(1); +} + +//-------------------TEQ---------------------------- + +#define OP_TEQ(a) \ + { \ + unsigned tmp = cpu->R[REG_POS(i,16)] ^ shift_op;\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(tmp);\ + cpu->CPSR.bits.Z = (tmp==0);\ + return a; \ + } + +TEMPLATE static u32 FASTCALL OP_TEQ_LSL_IMM() +{ + const u32 &i = cpu->instruction; + S_LSL_IMM; + OP_TEQ(1); +} + +TEMPLATE static u32 FASTCALL OP_TEQ_LSL_REG() +{ + const u32 &i = cpu->instruction; + S_LSL_REG; + OP_TEQ(2); +} + +TEMPLATE static u32 FASTCALL OP_TEQ_LSR_IMM() +{ + const u32 &i = cpu->instruction; + S_LSR_IMM; + OP_TEQ(1); +} + +TEMPLATE static u32 FASTCALL OP_TEQ_LSR_REG() +{ + const u32 &i = cpu->instruction; + S_LSR_REG; + OP_TEQ(2); +} + +TEMPLATE static u32 FASTCALL OP_TEQ_ASR_IMM() +{ + const u32 &i = cpu->instruction; + S_ASR_IMM; + OP_TEQ(1); +} + +TEMPLATE static u32 FASTCALL OP_TEQ_ASR_REG() +{ + const u32 &i = cpu->instruction; + S_ASR_REG; + OP_TEQ(2); +} + +TEMPLATE static u32 FASTCALL OP_TEQ_ROR_IMM() +{ + const u32 &i = cpu->instruction; + S_ROR_IMM; + OP_TEQ(1); +} + +TEMPLATE static u32 FASTCALL OP_TEQ_ROR_REG() +{ + const u32 &i = cpu->instruction; + S_ROR_REG; + OP_TEQ(2); +} + +TEMPLATE static u32 FASTCALL OP_TEQ_IMM_VAL() +{ + const u32 &i = cpu->instruction; + S_IMM_VALUE; + OP_TEQ(1); +} + +//-------------CMP------------------------------------- + +#define OP_CMP(a) \ + { \ + u32 tmp = cpu->R[REG_POS(i,16)] - shift_op;\ + cpu->CPSR.bits.N = BIT31(tmp);\ + cpu->CPSR.bits.Z = (tmp==0);\ + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ + return a; \ + } + +TEMPLATE static u32 FASTCALL OP_CMP_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_CMP(1); +} + +TEMPLATE static u32 FASTCALL OP_CMP_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OP_CMP(2); +} + +TEMPLATE static u32 FASTCALL OP_CMP_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_CMP(1); +} + +TEMPLATE static u32 FASTCALL OP_CMP_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OP_CMP(2); +} + +TEMPLATE static u32 FASTCALL OP_CMP_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_CMP(1); +} + +TEMPLATE static u32 FASTCALL OP_CMP_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OP_CMP(2); +} + +TEMPLATE static u32 FASTCALL OP_CMP_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_CMP(1); +} + +TEMPLATE static u32 FASTCALL OP_CMP_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OP_CMP(2); +} + +TEMPLATE static u32 FASTCALL OP_CMP_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OP_CMP(1); +} + +//---------------CMN--------------------------- + +#define OP_CMN(a) \ + { \ + u32 tmp = cpu->R[REG_POS(i,16)] + shift_op;\ + cpu->CPSR.bits.N = BIT31(tmp);\ + cpu->CPSR.bits.Z = (tmp==0);\ + cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ + cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_POS(i,16)], shift_op, tmp);\ + return a; \ + } + +TEMPLATE static u32 FASTCALL OP_CMN_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_CMN(1); +} + +TEMPLATE static u32 FASTCALL OP_CMN_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OP_CMN(2); +} + +TEMPLATE static u32 FASTCALL OP_CMN_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_CMN(1); +} + +TEMPLATE static u32 FASTCALL OP_CMN_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OP_CMN(2); +} + +TEMPLATE static u32 FASTCALL OP_CMN_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_CMN(1); +} + +TEMPLATE static u32 FASTCALL OP_CMN_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OP_CMN(2); +} + +TEMPLATE static u32 FASTCALL OP_CMN_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_CMN(1); +} + +TEMPLATE static u32 FASTCALL OP_CMN_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OP_CMN(2); +} + +TEMPLATE static u32 FASTCALL OP_CMN_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OP_CMN(1); +} + +//------------------ORR------------------- + +#define OP_ORR(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +TEMPLATE static u32 FASTCALL OP_ORR_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_ORR(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_ORR_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OP_ORR(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ORR_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_ORR(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_ORR_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OP_ORR(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ORR_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_ORR(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_ORR_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OP_ORR(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ORR_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_ORR(1, 3); +} + +TEMPLATE static u32 FASTCALL OP_ORR_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OP_ORR(2, 4); +} + +TEMPLATE static u32 FASTCALL OP_ORR_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OP_ORR(1, 3); +} + +#define OP_ORRS(a,b) \ + { \ + cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] | shift_op; \ + if(REG_POS(i,12)==15) \ + { \ + Status_Reg SPSR = cpu->SPSR; \ + armcpu_switchMode(cpu, SPSR.bits.mode); \ + cpu->CPSR=SPSR; \ + cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1)); \ + cpu->next_instruction = cpu->R[15]; \ + return b; \ + } \ + cpu->CPSR.bits.C = c; \ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]); \ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0); \ + return a; \ + } + +TEMPLATE static u32 FASTCALL OP_ORR_S_LSL_IMM() +{ + const u32 &i = cpu->instruction; + S_LSL_IMM; + OP_ORRS(2,4); +} + +TEMPLATE static u32 FASTCALL OP_ORR_S_LSL_REG() +{ + const u32 &i = cpu->instruction; + S_LSL_REG; + OP_ORRS(3,5); +} + +TEMPLATE static u32 FASTCALL OP_ORR_S_LSR_IMM() +{ + const u32 &i = cpu->instruction; + S_LSR_IMM; + OP_ORRS(2,4); +} + +TEMPLATE static u32 FASTCALL OP_ORR_S_LSR_REG() +{ + const u32 &i = cpu->instruction; + S_LSR_REG; + OP_ORRS(3,5); +} + +TEMPLATE static u32 FASTCALL OP_ORR_S_ASR_IMM() +{ + const u32 &i = cpu->instruction; + S_ASR_IMM; + OP_ORRS(2,4); +} + +TEMPLATE static u32 FASTCALL OP_ORR_S_ASR_REG() +{ + const u32 &i = cpu->instruction; + S_ASR_REG; + OP_ORRS(3,5); +} + +TEMPLATE static u32 FASTCALL OP_ORR_S_ROR_IMM() +{ + const u32 &i = cpu->instruction; + S_ROR_IMM; + OP_ORRS(2,4); +} + +TEMPLATE static u32 FASTCALL OP_ORR_S_ROR_REG() +{ + const u32 &i = cpu->instruction; + S_ROR_REG; + OP_ORRS(3,5); +} + +TEMPLATE static u32 FASTCALL OP_ORR_S_IMM_VAL() +{ + const u32 &i = cpu->instruction; + S_IMM_VALUE; + OP_ORRS(2,4); +} + +//------------------MOV------------------- + +#define OP_MOV(a, b) cpu->R[REG_POS(i,12)] = shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = shift_op;\ + return b;\ + }\ + return a; + +#define OP_MOV_S(a, b) cpu->R[REG_POS(i,12)] = shift_op;\ + if(BIT20(i) && REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + return a;\ + +TEMPLATE static u32 FASTCALL OP_MOV_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OP_MOV(1,3); +} + +TEMPLATE static u32 FASTCALL OP_MOV_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + if (REG_POS(i,0) == 15) shift_op += 4; + OP_MOV(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MOV_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OP_MOV(1,3); +} + +TEMPLATE static u32 FASTCALL OP_MOV_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + if (REG_POS(i,0) == 15) shift_op += 4; + OP_MOV(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MOV_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OP_MOV(1,3); +} + +TEMPLATE static u32 FASTCALL OP_MOV_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OP_MOV(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MOV_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OP_MOV(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MOV_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OP_MOV(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MOV_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OP_MOV(1,3); +} + +TEMPLATE static u32 FASTCALL OP_MOV_S_LSL_IMM() +{ + const u32 &i = cpu->instruction; + S_LSL_IMM; + OP_MOV_S(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MOV_S_LSL_REG() +{ + const u32 &i = cpu->instruction; + S_LSL_REG; + if (REG_POS(i,0) == 15) shift_op += 4; + OP_MOV_S(3,5); +} + +TEMPLATE static u32 FASTCALL OP_MOV_S_LSR_IMM() +{ + const u32 &i = cpu->instruction; + S_LSR_IMM; + OP_MOV_S(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MOV_S_LSR_REG() +{ + const u32 &i = cpu->instruction; + S_LSR_REG; + if (REG_POS(i,0) == 15) shift_op += 4; + OP_MOV_S(3,5); +} + +TEMPLATE static u32 FASTCALL OP_MOV_S_ASR_IMM() +{ + const u32 &i = cpu->instruction; + S_ASR_IMM; + OP_MOV_S(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MOV_S_ASR_REG() +{ + const u32 &i = cpu->instruction; + S_ASR_REG; + OP_MOV_S(3,5); +} + +TEMPLATE static u32 FASTCALL OP_MOV_S_ROR_IMM() +{ + const u32 &i = cpu->instruction; + S_ROR_IMM; + OP_MOV_S(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MOV_S_ROR_REG() +{ + const u32 &i = cpu->instruction; + S_ROR_REG; + OP_MOV_S(3,5); +} + +TEMPLATE static u32 FASTCALL OP_MOV_S_IMM_VAL() +{ + const u32 &i = cpu->instruction; + S_IMM_VALUE; + OP_MOV_S(2,4); +} + +//------------------BIC------------------- +#define OPP_BIC(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & (~shift_op);\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +#define OPP_BIC_S(a, b) cpu->R[REG_POS(i,12)] = cpu->R[REG_POS(i,16)] & (~shift_op);\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + return a; + +TEMPLATE static u32 FASTCALL OP_BIC_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OPP_BIC(1,3); +} + +TEMPLATE static u32 FASTCALL OP_BIC_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OPP_BIC(2,4); +} + +TEMPLATE static u32 FASTCALL OP_BIC_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OPP_BIC(1,3); +} + +TEMPLATE static u32 FASTCALL OP_BIC_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OPP_BIC(2,4); +} + +TEMPLATE static u32 FASTCALL OP_BIC_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OPP_BIC(1,3); +} + +TEMPLATE static u32 FASTCALL OP_BIC_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OPP_BIC(2,4); +} + +TEMPLATE static u32 FASTCALL OP_BIC_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OPP_BIC(1,3); +} + +TEMPLATE static u32 FASTCALL OP_BIC_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OPP_BIC(2,4); +} + +TEMPLATE static u32 FASTCALL OP_BIC_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OPP_BIC(1,3); +} + +TEMPLATE static u32 FASTCALL OP_BIC_S_LSL_IMM() +{ + const u32 &i = cpu->instruction; + S_LSL_IMM; + OPP_BIC_S(2,4); +} + +TEMPLATE static u32 FASTCALL OP_BIC_S_LSL_REG() +{ + const u32 &i = cpu->instruction; + S_LSL_REG; + OPP_BIC_S(3,5); +} + +TEMPLATE static u32 FASTCALL OP_BIC_S_LSR_IMM() +{ + const u32 &i = cpu->instruction; + S_LSR_IMM; + OPP_BIC_S(2,4); +} + +TEMPLATE static u32 FASTCALL OP_BIC_S_LSR_REG() +{ + const u32 &i = cpu->instruction; + S_LSR_REG; + OPP_BIC_S(3,5); +} + +TEMPLATE static u32 FASTCALL OP_BIC_S_ASR_IMM() +{ + const u32 &i = cpu->instruction; + S_ASR_IMM; + OPP_BIC_S(2,4); +} + +TEMPLATE static u32 FASTCALL OP_BIC_S_ASR_REG() +{ + const u32 &i = cpu->instruction; + S_ASR_REG; + OPP_BIC_S(3,5); +} + +TEMPLATE static u32 FASTCALL OP_BIC_S_ROR_IMM() +{ + const u32 &i = cpu->instruction; + S_ROR_IMM; + OPP_BIC_S(2,4); +} + +TEMPLATE static u32 FASTCALL OP_BIC_S_ROR_REG() +{ + const u32 &i = cpu->instruction; + S_ROR_REG; + OPP_BIC_S(3,5); +} + +TEMPLATE static u32 FASTCALL OP_BIC_S_IMM_VAL() +{ + const u32 &i = cpu->instruction; + S_IMM_VALUE; + OPP_BIC_S(2,4); +} + +//------------------MVN------------------- +#define OPP_MVN(a, b) cpu->R[REG_POS(i,12)] = ~shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + return a; + +#define OPP_MVN_S(a, b) cpu->R[REG_POS(i,12)] = ~shift_op;\ + if(REG_POS(i,12)==15)\ + {\ + Status_Reg SPSR = cpu->SPSR;\ + armcpu_switchMode(cpu, SPSR.bits.mode);\ + cpu->CPSR=SPSR;\ + cpu->R[15] &= (0XFFFFFFFC|(((u32)SPSR.bits.T)<<1));\ + cpu->next_instruction = cpu->R[15];\ + return b;\ + }\ + cpu->CPSR.bits.C = c;\ + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,12)]);\ + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,12)]==0);\ + return a; + +TEMPLATE static u32 FASTCALL OP_MVN_LSL_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSL_IMM; + OPP_MVN(1,3); +} + +TEMPLATE static u32 FASTCALL OP_MVN_LSL_REG() +{ + const u32 &i = cpu->instruction; + LSL_REG; + OPP_MVN(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MVN_LSR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + LSR_IMM; + OPP_MVN(1,3); +} + +TEMPLATE static u32 FASTCALL OP_MVN_LSR_REG() +{ + const u32 &i = cpu->instruction; + LSR_REG; + OPP_MVN(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MVN_ASR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ASR_IMM; + OPP_MVN(1,3); +} + +TEMPLATE static u32 FASTCALL OP_MVN_ASR_REG() +{ + const u32 &i = cpu->instruction; + ASR_REG; + OPP_MVN(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MVN_ROR_IMM() +{ + const u32 &i = cpu->instruction; + u32 shift_op; + ROR_IMM; + OPP_MVN(1,3); +} + +TEMPLATE static u32 FASTCALL OP_MVN_ROR_REG() +{ + const u32 &i = cpu->instruction; + ROR_REG; + OPP_MVN(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MVN_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + OPP_MVN(1,3); +} + +TEMPLATE static u32 FASTCALL OP_MVN_S_LSL_IMM() +{ + const u32 &i = cpu->instruction; + S_LSL_IMM; + OPP_MVN_S(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MVN_S_LSL_REG() +{ + const u32 &i = cpu->instruction; + S_LSL_REG; + OPP_MVN_S(3,5); +} + +TEMPLATE static u32 FASTCALL OP_MVN_S_LSR_IMM() +{ + const u32 &i = cpu->instruction; + S_LSR_IMM; + OPP_MVN_S(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MVN_S_LSR_REG() +{ + const u32 &i = cpu->instruction; + S_LSR_REG; + OPP_MVN_S(3,5); +} + +TEMPLATE static u32 FASTCALL OP_MVN_S_ASR_IMM() +{ + const u32 &i = cpu->instruction; + S_ASR_IMM; + OPP_MVN_S(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MVN_S_ASR_REG() +{ + const u32 &i = cpu->instruction; + S_ASR_REG; + OPP_MVN_S(3,5); +} + +TEMPLATE static u32 FASTCALL OP_MVN_S_ROR_IMM() +{ + const u32 &i = cpu->instruction; + S_ROR_IMM; + OPP_MVN_S(2,4); +} + +TEMPLATE static u32 FASTCALL OP_MVN_S_ROR_REG() +{ + const u32 &i = cpu->instruction; + S_ROR_REG; + OPP_MVN_S(3,5); +} + +TEMPLATE static u32 FASTCALL OP_MVN_S_IMM_VAL() +{ + const u32 &i = cpu->instruction; + S_IMM_VALUE; + OPP_MVN_S(2,4); +} + +//-------------MUL------------------------ +#define OPP_M(a,b) v >>= 8;\ + if((v==0)||(v==0xFFFFFF))\ + return b;\ + v >>= 8;\ + if((v==0)||(v==0xFFFF))\ + return b+1;\ + v >>= 8;\ + if((v==0)||(v==0xFF))\ + return b+2;\ + return a;\ + +TEMPLATE static u32 FASTCALL OP_MUL() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,16)] = cpu->R[REG_POS(i,8)] * v; + OPP_M(5,2); +} + +TEMPLATE static u32 FASTCALL OP_MLA() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + u32 a = cpu->R[REG_POS(i,8)]; + u32 b = cpu->R[REG_POS(i,12)]; + cpu->R[REG_POS(i,16)] = a * v + b; + + OPP_M(6,3); +} + +TEMPLATE static u32 FASTCALL OP_MUL_S() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,16)] = cpu->R[REG_POS(i,8)] * v; + + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0); + + OPP_M(6,3); +} + +TEMPLATE static u32 FASTCALL OP_MLA_S() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,16)] = cpu->R[REG_POS(i,8)] * v + cpu->R[REG_POS(i,12)]; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0); + OPP_M(7,4); +} + +//----------UMUL-------------------------- + +TEMPLATE static u32 FASTCALL OP_UMULL() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)]; + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] = (u32)(res>>32); + + OPP_M(6,3); +} + +TEMPLATE static u32 FASTCALL OP_UMLAL() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)] + (u64)cpu->R[REG_POS(i,12)]; + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] += (u32)(res>>32); + + OPP_M(7,4); +} + +TEMPLATE static u32 FASTCALL OP_UMULL_S() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)]; + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] = (u32)(res>>32); + + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); + + OPP_M(7,4); +} + +TEMPLATE static u32 FASTCALL OP_UMLAL_S() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_POS(i,0)]; + u64 res = (u64)v * (u64)cpu->R[REG_POS(i,8)] + (u64)cpu->R[REG_POS(i,12)]; + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] += (u32)(res>>32); + + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); + + OPP_M(8,5); +} + +//----------SMUL-------------------------- + +TEMPLATE static u32 FASTCALL OP_SMULL() +{ + const u32 &i = cpu->instruction; + s64 v = (s32)cpu->R[REG_POS(i,0)]; + s64 b = (s32)cpu->R[REG_POS(i,8)]; + s64 res = v * b; + + cpu->R[REG_POS(i,12)] = (u32)(res&0xFFFFFFFF); + cpu->R[REG_POS(i,16)] = (u32)(res>>32); + + v &= 0xFFFFFFFF; + + OPP_M(6,3); +} + +TEMPLATE static u32 FASTCALL OP_SMLAL() +{ + const u32 &i = cpu->instruction; + + s64 v = (s32)cpu->R[REG_POS(i,0)]; + s64 b = (s32)cpu->R[REG_POS(i,8)]; + s64 res = v * b + (u64)cpu->R[REG_POS(i,12)]; + + //LOG("%08X * %08X + %08X%08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], cpu->R[REG_POS(i,16)], cpu->R[REG_POS(i,12)]); + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] += (u32)(res>>32); + + //LOG("= %08X%08X %08X%08X\r\n", cpu->R[REG_POS(i,16)], cpu->R[REG_POS(i,12)], res); + + v &= 0xFFFFFFFF; + + OPP_M(7,4); +} + +TEMPLATE static u32 FASTCALL OP_SMULL_S() +{ + const u32 &i = cpu->instruction; + s64 v = (s32)cpu->R[REG_POS(i,0)]; + s64 b = (s32)cpu->R[REG_POS(i,8)]; + s64 res = v * b; + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] = (u32)(res>>32); + + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); + + v &= 0xFFFFFFFF; + + OPP_M(7,4); +} + +TEMPLATE static u32 FASTCALL OP_SMLAL_S() +{ + const u32 &i = cpu->instruction; + s64 v = (s32)cpu->R[REG_POS(i,0)]; + s64 b = (s32)cpu->R[REG_POS(i,8)]; + s64 res = v * b + (u64)cpu->R[REG_POS(i,12)]; + + cpu->R[REG_POS(i,12)] = (u32)res; + cpu->R[REG_POS(i,16)] += (u32)(res>>32); + + cpu->CPSR.bits.N = BIT31(cpu->R[REG_POS(i,16)]); + cpu->CPSR.bits.Z = (cpu->R[REG_POS(i,16)]==0) & (cpu->R[REG_POS(i,12)]==0); + + v &= 0xFFFFFFFF; + + OPP_M(8,5); +} + +//---------------SWP------------------------------ + +TEMPLATE static u32 FASTCALL OP_SWP() +{ + u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + u32 tmp = ROR(READ32(cpu->mem_if->data, adr), ((cpu->R[REG_POS(i,16)]&3)<<3)); + + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,0)]); + cpu->R[REG_POS(i,12)] = tmp; + + return 4 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]*2; +} + +TEMPLATE static u32 FASTCALL OP_SWPB() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + u8 tmp = READ8(cpu->mem_if->data, adr); + WRITE8(cpu->mem_if->data, adr, (u8)(cpu->R[REG_POS(i,0)]&0xFF)); + cpu->R[REG_POS(i,12)] = tmp; + + return 4 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]*2; +} + +//------------LDRH----------------------------- + +TEMPLATE static u32 FASTCALL OP_LDRH_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_P_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_M_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_PRE_INDE_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_PRE_INDE_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); + + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_PRE_INDE_P_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] =(u32)READ16(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_PRE_INDE_M_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_POS_INDE_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] += IMM_OFF; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_POS_INDE_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] -= IMM_OFF; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_POS_INDE_P_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_POS_INDE_M_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (u32)READ16(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +//------------STRH----------------------------- + +TEMPLATE static u32 FASTCALL OP_STRH_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_P_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_M_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_PRE_INDE_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,16)] = adr; + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_PRE_INDE_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_PRE_INDE_P_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_PRE_INDE_M_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_POS_INDE_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] += IMM_OFF; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_POS_INDE_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] -= IMM_OFF; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_POS_INDE_P_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_POS_INDE_M_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +//----------------LDRSH-------------------------- + +TEMPLATE static u32 FASTCALL OP_LDRSH_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSH_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSH_P_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSH_M_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSH_PRE_INDE_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSH_PRE_INDE_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSH_PRE_INDE_P_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSH_PRE_INDE_M_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSH_POS_INDE_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] += IMM_OFF; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSH_POS_INDE_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] -= IMM_OFF; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSH_POS_INDE_P_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSH_POS_INDE_M_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +//----------------------LDRSB---------------------- + +TEMPLATE static u32 FASTCALL OP_LDRSB_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSB_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSB_P_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSB_M_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSB_PRE_INDE_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSB_PRE_INDE_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF; + cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSB_PRE_INDE_P_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSB_PRE_INDE_M_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - cpu->R[REG_POS(i,0)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSB_POS_INDE_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] += IMM_OFF; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSB_POS_INDE_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] -= IMM_OFF; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSB_POS_INDE_P_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] += cpu->R[REG_POS(i,0)]; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSB_POS_INDE_M_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + cpu->R[REG_POS(i,12)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + cpu->R[REG_POS(i,16)] -= cpu->R[REG_POS(i,0)]; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +//--------------MRS-------------------------------- + +TEMPLATE static u32 FASTCALL OP_MRS_CPSR() +{ + cpu->R[REG_POS(cpu->instruction,12)] = cpu->CPSR.val; + + return 1; +} + +TEMPLATE static u32 FASTCALL OP_MRS_SPSR() +{ + cpu->R[REG_POS(cpu->instruction,12)] = cpu->SPSR.val; + + return 1; +} + +//--------------MSR-------------------------------- + +TEMPLATE static u32 FASTCALL OP_MSR_CPSR() +{ + const u32 &i = cpu->instruction; + u32 operand = cpu->R[REG_POS(i,0)]; + + if(cpu->CPSR.bits.mode!=USR) + { + if(BIT16(i)) + { + armcpu_switchMode(cpu, operand & 0x1F); + cpu->CPSR.val = (cpu->CPSR.val & 0xFFFFFF00) | (operand & 0xFF); + } + if(BIT17(i)) + cpu->CPSR.val = (cpu->CPSR.val & 0xFFFF00FF) | (operand & 0xFF00); + if(BIT18(i)) + cpu->CPSR.val = (cpu->CPSR.val & 0xFF00FFFF) | (operand & 0xFF0000); + } + if(BIT19(i)) + cpu->CPSR.val = (cpu->CPSR.val & 0x00FFFFFF) | (operand & 0xFF000000); + + return 1; +} + +TEMPLATE static u32 FASTCALL OP_MSR_SPSR() +{ + const u32 &i = cpu->instruction; + u32 operand = cpu->R[REG_POS(i,0)]; + + if(cpu->CPSR.bits.mode!=USR) + { + if(BIT16(i)) + { + cpu->SPSR.val = (cpu->SPSR.val & 0xFFFFFF00) | (operand & 0XFF); + } + if(BIT17(i)) + cpu->SPSR.val = (cpu->SPSR.val & 0xFFFF00FF) | (operand & 0XFF00); + if(BIT18(i)) + cpu->SPSR.val = (cpu->SPSR.val & 0xFF00FFFF) | (operand & 0XFF0000); + } + if(BIT19(i)) + cpu->SPSR.val = (cpu->SPSR.val & 0x00FFFFFF) | (operand & 0XFF000000); + + return 1; +} + +TEMPLATE static u32 FASTCALL OP_MSR_CPSR_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + + if(cpu->CPSR.bits.mode!=USR) + { + if(BIT16(i)) + { + armcpu_switchMode(cpu, shift_op & 0x1F); + cpu->CPSR.val = (cpu->CPSR.val & 0xFFFFFF00) | (shift_op & 0XFF); + } + if(BIT17(i)) + cpu->CPSR.val = (cpu->CPSR.val & 0xFFFF00FF) | (shift_op & 0XFF00); + if(BIT18(i)) + cpu->CPSR.val = (cpu->CPSR.val & 0xFF00FFFF) | (shift_op & 0XFF0000); + } + if(BIT19(i)) + { + //cpu->CPSR.val = (cpu->CPSR.val & 0xFF000000) | (shift_op & 0XFF000000); + cpu->CPSR.val = (cpu->CPSR.val & 0x00FFFFFF) | (shift_op & 0xFF000000); + } + + return 1; +} + +TEMPLATE static u32 FASTCALL OP_MSR_SPSR_IMM_VAL() +{ + const u32 &i = cpu->instruction; + IMM_VALUE; + + if(cpu->CPSR.bits.mode!=USR) + { + if(BIT16(i)) + { + cpu->SPSR.val = (cpu->SPSR.val & 0xFFFFFF00) | (shift_op & 0XFF); + } + if(BIT17(i)) + cpu->SPSR.val = (cpu->SPSR.val & 0xFFFF00FF) | (shift_op & 0XFF00); + if(BIT18(i)) + cpu->SPSR.val = (cpu->SPSR.val & 0xFF00FFFF) | (shift_op & 0XFF0000); + } + if(BIT19(i)) + cpu->SPSR.val = (cpu->SPSR.val & 0xFF000000) | (shift_op & 0XFF000000); + + return 1; +} + +//-----------------BRANCH-------------------------- + +TEMPLATE static u32 FASTCALL OP_BX() +{ + u32 tmp = cpu->R[REG_POS(cpu->instruction, 0)]; + + cpu->CPSR.bits.T = BIT0(tmp); + cpu->R[15] = tmp & 0xFFFFFFFE; + cpu->next_instruction = cpu->R[15]; + return 3; +} + +TEMPLATE static u32 FASTCALL OP_BLX_REG() +{ + u32 tmp = cpu->R[REG_POS(cpu->instruction, 0)]; + + cpu->R[14] = cpu->next_instruction; + cpu->CPSR.bits.T = BIT0(tmp); + cpu->R[15] = tmp & 0xFFFFFFFE; + cpu->next_instruction = cpu->R[15]; + return 3; +} + +#define SIGNEXTEND_24(i) (((s32)((i)<<8))>>8) + +TEMPLATE static u32 FASTCALL OP_B() +{ + u32 off = SIGNEXTEND_24(cpu->instruction); + if(CONDITION(cpu->instruction)==0xF) + { + cpu->R[14] = cpu->next_instruction; + cpu->CPSR.bits.T = 1; + } + cpu->R[15] += (off<<2); + cpu->next_instruction = cpu->R[15]; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_BL() +{ + u32 off = SIGNEXTEND_24(cpu->instruction); + if(CONDITION(cpu->instruction)==0xF) + { + cpu->CPSR.bits.T = 1; + cpu->R[15] += 2; + } + cpu->R[14] = cpu->next_instruction; + cpu->R[15] += (off<<2); + cpu->next_instruction = cpu->R[15]; + + return 3; +} + +//----------------CLZ------------------------------- + +u8 CLZ_TAB[16]= +{ + 0, // 0000 + 1, // 0001 + 2, 2, // 001X + 3, 3, 3, 3, // 01XX + 4, 4, 4, 4, 4, 4, 4, 4 // 1XXX +}; + +TEMPLATE static u32 FASTCALL OP_CLZ() +{ + const u32 &i = cpu->instruction; + u32 Rm = cpu->R[REG_POS(i,0)]; + u32 pos; + + if(Rm==0) + { + cpu->R[REG_POS(i,12)]=32; + return 2; + } + + Rm |= (Rm >>1); + Rm |= (Rm >>2); + Rm |= (Rm >>4); + Rm |= (Rm >>8); + Rm |= (Rm >>16); + + pos = + CLZ_TAB[Rm&0xF] + + CLZ_TAB[(Rm>>4)&0xF] + + CLZ_TAB[(Rm>>8)&0xF] + + CLZ_TAB[(Rm>>12)&0xF] + + CLZ_TAB[(Rm>>16)&0xF] + + CLZ_TAB[(Rm>>20)&0xF] + + CLZ_TAB[(Rm>>24)&0xF] + + CLZ_TAB[(Rm>>28)&0xF]; + + cpu->R[REG_POS(i,12)]=32 - pos; + + return 2; +} + +//--------------------QADD--QSUB------------------------------ + +TEMPLATE static u32 FASTCALL OP_QADD() +{ + const u32 &i = cpu->instruction; + u32 res = cpu->R[REG_POS(i,16)]+cpu->R[REG_POS(i,0)]; + + LOG("spe add\r\n"); + if(SIGNED_OVERFLOW(cpu->R[REG_POS(i,16)],cpu->R[REG_POS(i,0)], res)) + { + cpu->CPSR.bits.Q=1; + cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); + return 2; + } + cpu->R[REG_POS(i,12)]=res; + if(REG_POS(i,12)==15) + { + cpu->R[15] &= 0XFFFFFFFC; + cpu->next_instruction = cpu->R[15]; + return 3; + } + return 2; +} + +TEMPLATE static u32 FASTCALL OP_QSUB() +{ + const u32 &i = cpu->instruction; + u32 res = cpu->R[REG_POS(i,0)]-cpu->R[REG_POS(i,16)]; + + LOG("spe add\r\n"); + if(SIGNED_UNDERFLOW(cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,16)], res)) + { + cpu->CPSR.bits.Q=1; + cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); + return 2; + } + cpu->R[REG_POS(i,12)]=res; + if(REG_POS(i,12)==15) + { + cpu->R[15] &= 0XFFFFFFFC; + cpu->next_instruction = cpu->R[15]; + return 3; + } + return 2; +} + +TEMPLATE static u32 FASTCALL OP_QDADD() +{ + const u32 &i = cpu->instruction; + u32 mul = cpu->R[REG_POS(i,16)]<<1; + u32 res; + + + LOG("spe add\r\n"); + if(BIT31(cpu->R[REG_POS(i,16)])!=BIT31(mul)) + { + cpu->CPSR.bits.Q=1; + mul = 0x80000000-BIT31(mul); + } + + res = mul + cpu->R[REG_POS(i,0)]; + if(SIGNED_OVERFLOW(cpu->R[REG_POS(i,0)],mul, res)) + { + cpu->CPSR.bits.Q=1; + cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); + return 2; + } + cpu->R[REG_POS(i,12)]=res; + if(REG_POS(i,12)==15) + { + cpu->R[15] &= 0XFFFFFFFC; + cpu->next_instruction = cpu->R[15]; + return 3; + } + return 2; +} + +TEMPLATE static u32 FASTCALL OP_QDSUB() +{ + const u32 &i = cpu->instruction; + u32 mul = cpu->R[REG_POS(i,16)]<<1; + u32 res; + + + LOG("spe add\r\n"); + if(BIT31(cpu->R[REG_POS(i,16)])!=BIT31(mul)) + { + cpu->CPSR.bits.Q=1; + mul = 0x80000000-BIT31(mul); + } + + res = cpu->R[REG_POS(i,0)] - mul; + if(SIGNED_UNDERFLOW(cpu->R[REG_POS(i,0)], mul, res)) + { + cpu->CPSR.bits.Q=1; + cpu->R[REG_POS(i,12)]=0x80000000-BIT31(res); + return 2; + } + cpu->R[REG_POS(i,12)]=res; + if(REG_POS(i,12)==15) + { + cpu->R[15] &= 0XFFFFFFFC; + cpu->next_instruction = cpu->R[15]; + return 3; + } + return 2; +} + +//-----------------SMUL------------------------------- + +#define HWORD(i) ((s32)(((s32)(i))>>16)) +#define LWORD(i) (s32)(((s32)((i)<<16))>>16) + +TEMPLATE static u32 FASTCALL OP_SMUL_B_B() +{ + const u32 &i = cpu->instruction; + + cpu->R[REG_POS(i,16)] = (u32)(LWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SMUL_B_T() +{ + const u32 &i = cpu->instruction; + + cpu->R[REG_POS(i,16)] = (u32)(LWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SMUL_T_B() +{ + const u32 &i = cpu->instruction; + + cpu->R[REG_POS(i,16)] = (u32)(HWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SMUL_T_T() +{ + const u32 &i = cpu->instruction; + + cpu->R[REG_POS(i,16)] = (u32)(HWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); + + return 2; +} + +//-----------SMLA---------------------------- + +TEMPLATE static u32 FASTCALL OP_SMLA_B_B() +{ + const u32 &i = cpu->instruction; + u32 tmp = (u32)(LWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); + u32 a = cpu->R[REG_POS(i,12)]; + + //LOG("SMLABB %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); + cpu->R[REG_POS(i,16)] = tmp + a; + + if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) + cpu->CPSR.bits.Q = 1; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SMLA_B_T() +{ + const u32 &i = cpu->instruction; + u32 tmp = (u32)(LWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); + u32 a = cpu->R[REG_POS(i,12)]; + + //LOG("SMLABT %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); + cpu->R[REG_POS(i,16)] = tmp + a; + + if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) + cpu->CPSR.bits.Q = 1; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SMLA_T_B() +{ + const u32 &i = cpu->instruction; + u32 tmp = (u32)(HWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); + u32 a = cpu->R[REG_POS(i,12)]; + + //LOG("SMLATB %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); + cpu->R[REG_POS(i,16)] = tmp + a; + + if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) + cpu->CPSR.bits.Q = 1; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SMLA_T_T() +{ + const u32 &i = cpu->instruction; + u32 tmp = (u32)(HWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); + u32 a = cpu->R[REG_POS(i,12)]; + + //LOG("SMLATT %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, tmp + a); + cpu->R[REG_POS(i,16)] = tmp + a; + + if(SIGNED_OVERFLOW(tmp, a, cpu->R[REG_POS(i,16)])) + cpu->CPSR.bits.Q = 1; + + return 2; +} + +//--------------SMLAL--------------------------------------- + +TEMPLATE static u32 FASTCALL OP_SMLAL_B_B() +{ + const u32 &i = cpu->instruction; + s64 tmp = (s64)(LWORD(cpu->R[REG_POS(i,0)])* LWORD(cpu->R[REG_POS(i,8)])); + u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; + + LOG("SMLALBB %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + (res + ((tmp<0)*0xFFFFFFFF))), (int)(u32) res); + + cpu->R[REG_POS(i,12)] = (u32) res; + cpu->R[REG_POS(i,16)] += (res + ((tmp<0)*0xFFFFFFFF)); + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SMLAL_B_T() +{ + const u32 &i = cpu->instruction; + s64 tmp = (s64)(LWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); + u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; + + LOG("SMLALBT %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + res + ((tmp<0)*0xFFFFFFFF)), (int)(u32) res); + + cpu->R[REG_POS(i,12)] = (u32) res; + cpu->R[REG_POS(i,16)] += res + ((tmp<0)*0xFFFFFFFF); + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SMLAL_T_B() +{ + const u32 &i = cpu->instruction; + s64 tmp = (s64)(HWORD(cpu->R[REG_POS(i,0)])* (s64)LWORD(cpu->R[REG_POS(i,8)])); + u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; + + LOG("SMLALTB %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + res + ((tmp<0)*0xFFFFFFFF)), (int)(u32) res); + + cpu->R[REG_POS(i,12)] = (u32) res; + cpu->R[REG_POS(i,16)] += res + ((tmp<0)*0xFFFFFFFF); + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SMLAL_T_T() +{ + const u32 &i = cpu->instruction; + s64 tmp = (s64)(HWORD(cpu->R[REG_POS(i,0)])* HWORD(cpu->R[REG_POS(i,8)])); + u64 res = (u64)tmp + cpu->R[REG_POS(i,12)]; + + LOG("SMLALTT %08X * %08X + %08X%08X = %08X%08X\r\n", (int)cpu->R[REG_POS(i,0)], (int)cpu->R[REG_POS(i,8)], (int)cpu->R[REG_POS(i,16)], (int)cpu->R[REG_POS(i,12)], (int)(cpu->R[REG_POS(i,16)] + res + ((tmp<0)*0xFFFFFFFF)), (int)(u32) res); + + cpu->R[REG_POS(i,12)] = (u32) res; + cpu->R[REG_POS(i,16)] += res + ((tmp<0)*0xFFFFFFFF); + + return 2; +} + +//--------------SMULW-------------------- + +TEMPLATE static u32 FASTCALL OP_SMULW_B() +{ + const u32 &i = cpu->instruction; + s64 tmp = (s64)LWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); + + //LOG("SMULWB %08X * %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], ((tmp>>16)&0xFFFFFFFF); + + cpu->R[REG_POS(i,16)] = ((tmp>>16)&0xFFFFFFFF); + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SMULW_T() +{ + const u32 &i = cpu->instruction; + s64 tmp = (s64)HWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); + + //LOG("SMULWT %08X * %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], ((tmp>>16)&0xFFFFFFFF)); + + cpu->R[REG_POS(i,16)] = ((tmp>>16)&0xFFFFFFFF); + + return 2; +} + +//--------------SMLAW------------------- +TEMPLATE static u32 FASTCALL OP_SMLAW_B() +{ + const u32 &i = cpu->instruction; + s64 tmp = (s64)LWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); + u32 a = cpu->R[REG_POS(i,12)]; + + //LOG("SMLAWB %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, (tmp>>16) + a); + + tmp = (tmp>>16); + + cpu->R[REG_POS(i,16)] = tmp + a; + + if(SIGNED_OVERFLOW((u32)tmp, a, cpu->R[REG_POS(i,16)])) + cpu->CPSR.bits.Q = 1; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SMLAW_T() +{ + const u32 &i = cpu->instruction; + s64 tmp = (s64)HWORD(cpu->R[REG_POS(i,8)]) * (s64)((s32)cpu->R[REG_POS(i,0)]); + u32 a = cpu->R[REG_POS(i,12)]; + + //LOG("SMLAWT %08X * %08X + %08X = %08X\r\n", cpu->R[REG_POS(i,0)], cpu->R[REG_POS(i,8)], a, ((tmp>>16)&0xFFFFFFFF) + a); + + tmp = ((tmp>>16)&0xFFFFFFFF); + cpu->R[REG_POS(i,16)] = tmp + a; + + if(SIGNED_OVERFLOW((u32)tmp, a, cpu->R[REG_POS(i,16)])) + cpu->CPSR.bits.Q = 1; + + return 2; +} + +//------------LDR--------------------------- + +TEMPLATE static u32 FASTCALL OP_LDR_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + u32 val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + u32 val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_LSL_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_LSL_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_LSR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_LSR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_ASR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_ASR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_ROR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_ROR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + u32 val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + u32 val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_LSL_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_LSL_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_LSR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_LSR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_ASR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_ASR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_ROR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_ROR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + u32 val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +//------------------------------------------------------------ +TEMPLATE static u32 FASTCALL OP_LDR_P_IMM_OFF_POSTIND2() +{ + const u32 &i = cpu->instruction; + + u32 adr = cpu->R[REG_POS(i,16)]; + u32 val = READ32(cpu->mem_if->data, adr); + u32 old; + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + old = armcpu_switchMode(cpu, USR); + cpu->R[REG_POS(i,12)] = val; + armcpu_switchMode(cpu, old); + + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +//------------------------------------------------------------ + +TEMPLATE static u32 FASTCALL OP_LDR_M_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + u32 val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_LSL_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr + shift_op; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_LSL_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr - shift_op; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_LSR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr + shift_op; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_LSR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr - shift_op; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_ASR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr + shift_op; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_ASR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr - shift_op; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_P_ROR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr + shift_op; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_M_ROR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ32(cpu->mem_if->data, adr); + + val = ROR(val, 8*(adr&3)); + + if(REG_POS(i,12)==15) + { + cpu->R[15] = val & (0XFFFFFFFC | (((u32)cpu->LDTBit)<<1)); + cpu->CPSR.bits.T = BIT0(val) & cpu->LDTBit; + cpu->next_instruction = cpu->R[15]; + cpu->R[REG_POS(i,16)] = adr - shift_op; + return 5 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + } + + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +//-----------------LDRB------------------------------------------- + +TEMPLATE static u32 FASTCALL OP_LDRB_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + u32 val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + u32 val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_LSL_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_LSL_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_LSR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_LSR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_ASR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_ASR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_ROR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_ROR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + u32 val = READ8(cpu->mem_if->data, adr); + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + u32 val = READ8(cpu->mem_if->data, adr); + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_LSL_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ8(cpu->mem_if->data, adr); + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_LSL_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ8(cpu->mem_if->data, adr); + + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_LSR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_LSR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_ASR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_ASR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_ROR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_ROR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + u32 val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + u32 val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_LSL_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_LSL_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_LSR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_LSR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_ASR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_ASR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_P_ROR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr + shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_M_ROR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 val; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,16)] = adr - shift_op; + cpu->R[REG_POS(i,12)] = val; + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +//----------------------STR-------------------------------- + +TEMPLATE static u32 FASTCALL OP_STR_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + +// emu_halt(); + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_LSL_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_LSL_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_LSR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_LSR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_ASR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_ASR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_ROR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_ROR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_LSL_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_LSL_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_LSR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_LSR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_ASR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_ASR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_ROR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_ROR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_LSL_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_LSL_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_LSR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_LSR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_ASR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_ASR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_P_ROR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_M_ROR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +//-----------------------STRB------------------------------------- + +TEMPLATE static u32 FASTCALL OP_STRB_P_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_LSL_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_LSL_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_LSR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_LSR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_ASR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_ASR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_ROR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_ROR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] + IMM_OFF_12; + WRITE8(cpu->mem_if->data, adr, cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)] - IMM_OFF_12; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_LSL_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_LSL_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_LSR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_LSR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_ASR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_ASR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_ROR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] + shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_ROR_IMM_OFF_PREIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)] - shift_op; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_LSL_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_LSL_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_LSR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_LSR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_ASR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_ASR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_P_ROR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_M_ROR_IMM_OFF_POSTIND() +{ + const u32 &i = cpu->instruction; + u32 adr; + u32 shift_op; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +//-----------------------LDRBT------------------------------------- + +TEMPLATE static u32 FASTCALL OP_LDRBT_P_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRBT_M_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_M_IMM_OFF_POSTIND\n"); + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRBT_P_REG_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_P_REG_OFF_POSTIND\n"); + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr + cpu->R[REG_POS(i,0)]; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRBT_P_LSL_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_P_LSL_IMM_OFF_POSTIND\n"); + + i = cpu->instruction; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRBT_M_LSL_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_M_LSL_IMM_OFF_POSTIND\n"); + + i = cpu->instruction; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRBT_P_LSR_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_P_LSR_IMM_OFF_POSTIND\n"); + + i = cpu->instruction; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRBT_M_LSR_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_M_LSR_IMM_OFF_POSTIND\n"); + + i = cpu->instruction; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRBT_P_ASR_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_P_ASR_IMM_OFF_POSTIND\n"); + + + i = cpu->instruction; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRBT_M_ASR_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_M_ASR_IMM_OFF_POSTIND\n"); + + + i = cpu->instruction; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRBT_P_ROR_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_P_ROR_IMM_OFF_POSTIND\n"); + + + i = cpu->instruction; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRBT_M_ROR_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 val; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_LDRBT_M_ROR_IMM_OFF_POSTIND\n"); + + + i = cpu->instruction; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + val = READ8(cpu->mem_if->data, adr); + cpu->R[REG_POS(i,12)] = val; + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +//----------------------STRBT---------------------------- + +TEMPLATE static u32 FASTCALL OP_STRBT_P_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + IMM_OFF_12; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRBT_M_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - IMM_OFF_12; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRBT_P_REG_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + cpu->R[REG_POS(i,0)]; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRBT_M_REG_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - cpu->R[REG_POS(i,0)]; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRBT_P_LSL_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRBT_M_LSL_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + LSL_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRBT_P_LSR_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRBT_M_LSR_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + LSR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRBT_P_ASR_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRBT_M_ASR_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + ASR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRBT_P_ROR_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr + shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRBT_M_ROR_IMM_OFF_POSTIND() +{ + u32 oldmode; + u32 i; + u32 adr; + u32 shift_op; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + oldmode = armcpu_switchMode(cpu, SYS); + + + i = cpu->instruction; + ROR_IMM; + adr = cpu->R[REG_POS(i,16)]; + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_POS(i,12)]); + cpu->R[REG_POS(i,16)] = adr - shift_op; + + armcpu_switchMode(cpu, oldmode); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +//---------------------LDM----------------------------- + +#define OP_L_IA(reg, adr) if(BIT##reg(i))\ + {\ + registres[reg] = READ32(cpu->mem_if->data, start);\ + c += waitState[(start>>24)&0xF];\ + adr += 4;\ + } + +#define OP_L_IB(reg, adr) if(BIT##reg(i))\ + {\ + adr += 4;\ + registres[reg] = READ32(cpu->mem_if->data, start);\ + c += waitState[(start>>24)&0xF];\ + } + +#define OP_L_DA(reg, adr) if(BIT##reg(i))\ + {\ + registres[reg] = READ32(cpu->mem_if->data, start);\ + c += waitState[(start>>24)&0xF];\ + adr -= 4;\ + } + +#define OP_L_DB(reg, adr) if(BIT##reg(i))\ + {\ + adr -= 4;\ + registres[reg] = READ32(cpu->mem_if->data, start);\ + c += waitState[(start>>24)&0xF];\ + } + +TEMPLATE static u32 FASTCALL OP_LDMIA() +{ + const u32 &i = cpu->instruction; + u32 c = 0; + u32 start = cpu->R[REG_POS(i,16)]; + + u32 * registres = cpu->R; + TWaitState* waitState = MMU.MMU_WAIT32[PROCNUM]; + + OP_L_IA(0, start); + OP_L_IA(1, start); + OP_L_IA(2, start); + OP_L_IA(3, start); + OP_L_IA(4, start); + OP_L_IA(5, start); + OP_L_IA(6, start); + OP_L_IA(7, start); + OP_L_IA(8, start); + OP_L_IA(9, start); + OP_L_IA(10, start); + OP_L_IA(11, start); + OP_L_IA(12, start); + OP_L_IA(13, start); + OP_L_IA(14, start); + + if(BIT15(i)) + { + u32 tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + //start += 4; + cpu->next_instruction = registres[15]; + c += waitState[(start>>24)&0xF]; + } + + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMIB() +{ + const u32 &i = cpu->instruction; + u32 c = 0; + u32 start = cpu->R[REG_POS(i,16)]; + + u32 * registres = cpu->R; + TWaitState* waitState = MMU.MMU_WAIT32[PROCNUM]; + + OP_L_IB(0, start); + OP_L_IB(1, start); + OP_L_IB(2, start); + OP_L_IB(3, start); + OP_L_IB(4, start); + OP_L_IB(5, start); + OP_L_IB(6, start); + OP_L_IB(7, start); + OP_L_IB(8, start); + OP_L_IB(9, start); + OP_L_IB(10, start); + OP_L_IB(11, start); + OP_L_IB(12, start); + OP_L_IB(13, start); + OP_L_IB(14, start); + + if(BIT15(i)) + { + u32 tmp; + start += 4; + c += waitState[(start>>24)&0xF]; + tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + cpu->next_instruction = registres[15]; + c += 2 + (c==0); + } + + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMDA() +{ + const u32 &i = cpu->instruction; + u32 c = 0; + u32 start = cpu->R[REG_POS(i,16)]; + + u32 * registres = cpu->R; + TWaitState * waitState = MMU.MMU_WAIT32[PROCNUM]; + + if(BIT15(i)) + { + u32 tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + c += waitState[(start>>24)&0xF]; + start -= 4; + cpu->next_instruction = registres[15]; + } + + OP_L_DA(14, start); + OP_L_DA(13, start); + OP_L_DA(12, start); + OP_L_DA(11, start); + OP_L_DA(10, start); + OP_L_DA(9, start); + OP_L_DA(8, start); + OP_L_DA(7, start); + OP_L_DA(6, start); + OP_L_DA(5, start); + OP_L_DA(4, start); + OP_L_DA(3, start); + OP_L_DA(2, start); + OP_L_DA(1, start); + OP_L_DA(0, start); + + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMDB() +{ + const u32 &i = cpu->instruction; + u32 c = 0; + u32 start = cpu->R[REG_POS(i,16)]; + + u32 * registres = cpu->R; + TWaitState* waitState = MMU.MMU_WAIT32[PROCNUM]; + + if(BIT15(i)) + { + u32 tmp; + start -= 4; + tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + cpu->next_instruction = registres[15]; + c += waitState[(start>>24)&0xF]; + } + + OP_L_DB(14, start); + OP_L_DB(13, start); + OP_L_DB(12, start); + OP_L_DB(11, start); + OP_L_DB(10, start); + OP_L_DB(9, start); + OP_L_DB(8, start); + OP_L_DB(7, start); + OP_L_DB(6, start); + OP_L_DB(5, start); + OP_L_DB(4, start); + OP_L_DB(3, start); + OP_L_DB(2, start); + OP_L_DB(1, start); + OP_L_DB(0, start); + + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMIA_W() +{ + const u32 &i = cpu->instruction; + u32 c = 0; + u32 start = cpu->R[REG_POS(i,16)]; + u32 bitList = (~((2 << REG_POS(i,16))-1)) & 0xFFFF; + + u32 * registres = cpu->R; + TWaitState* waitState = MMU.MMU_WAIT32[PROCNUM]; + + OP_L_IA(0, start); + OP_L_IA(1, start); + OP_L_IA(2, start); + OP_L_IA(3, start); + OP_L_IA(4, start); + OP_L_IA(5, start); + OP_L_IA(6, start); + OP_L_IA(7, start); + OP_L_IA(8, start); + OP_L_IA(9, start); + OP_L_IA(10, start); + OP_L_IA(11, start); + OP_L_IA(12, start); + OP_L_IA(13, start); + OP_L_IA(14, start); + + if(BIT15(i)) + { + u32 tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + c += waitState[(start>>24)&0xF]; + start += 4; + cpu->next_instruction = registres[15]; + } + + if(i & (1 << REG_POS(i,16))) { + if(i & bitList) + cpu->R[REG_POS(i,16)] = start; + } + else + cpu->R[REG_POS(i,16)] = start; + + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMIB_W() +{ + const u32 &i = cpu->instruction; + u32 c = 0; + u32 start = cpu->R[REG_POS(i,16)]; + u32 bitList = (~((2 << REG_POS(i,16))-1)) & 0xFFFF; + + u32 * registres = cpu->R; + TWaitState* waitState = MMU.MMU_WAIT32[PROCNUM]; + + OP_L_IB(0, start); + OP_L_IB(1, start); + OP_L_IB(2, start); + OP_L_IB(3, start); + OP_L_IB(4, start); + OP_L_IB(5, start); + OP_L_IB(6, start); + OP_L_IB(7, start); + OP_L_IB(8, start); + OP_L_IB(9, start); + OP_L_IB(10, start); + OP_L_IB(11, start); + OP_L_IB(12, start); + OP_L_IB(13, start); + OP_L_IB(14, start); + + if(BIT15(i)) + { + u32 tmp; + start += 4; + c += waitState[(start>>24)&0xF]; + tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + cpu->next_instruction = registres[15]; + c += 2 + (c==0); + } + + if(i & (1 << REG_POS(i,16))) { + if(i & bitList) + cpu->R[REG_POS(i,16)] = start; + } + else + cpu->R[REG_POS(i,16)] = start; + + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMDA_W() +{ + const u32 &i = cpu->instruction; + u32 c = 0; + u32 start = cpu->R[REG_POS(i,16)]; + u32 bitList = (~((2 << REG_POS(i,16))-1)) & 0xFFFF; + + u32 * registres = cpu->R; + TWaitState * waitState = MMU.MMU_WAIT32[PROCNUM]; + + if(BIT15(i)) + { + u32 tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + c += waitState[(start>>24)&0xF]; + start -= 4; + cpu->next_instruction = registres[15]; + } + + OP_L_DA(14, start); + OP_L_DA(13, start); + OP_L_DA(12, start); + OP_L_DA(11, start); + OP_L_DA(10, start); + OP_L_DA(9, start); + OP_L_DA(8, start); + OP_L_DA(7, start); + OP_L_DA(6, start); + OP_L_DA(5, start); + OP_L_DA(4, start); + OP_L_DA(3, start); + OP_L_DA(2, start); + OP_L_DA(1, start); + OP_L_DA(0, start); + + if(i & (1 << REG_POS(i,16))) { + if(i & bitList) + cpu->R[REG_POS(i,16)] = start; + } + else + cpu->R[REG_POS(i,16)] = start; + + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMDB_W() +{ + const u32 &i = cpu->instruction; + u32 c = 0; + u32 start = cpu->R[REG_POS(i,16)]; + u32 bitList = (~((2 << REG_POS(i,16))-1)) & 0xFFFF; + u32 * registres = cpu->R; + TWaitState* waitState = MMU.MMU_WAIT32[PROCNUM]; + + if(BIT15(i)) + { + u32 tmp; + start -= 4; + tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR.bits.T = BIT0(tmp); + cpu->next_instruction = registres[15]; + c += waitState[(start>>24)&0xF]; + } + + OP_L_DB(14, start); + OP_L_DB(13, start); + OP_L_DB(12, start); + OP_L_DB(11, start); + OP_L_DB(10, start); + OP_L_DB(9, start); + OP_L_DB(8, start); + OP_L_DB(7, start); + OP_L_DB(6, start); + OP_L_DB(5, start); + OP_L_DB(4, start); + OP_L_DB(3, start); + OP_L_DB(2, start); + OP_L_DB(1, start); + OP_L_DB(0, start); + + if(i & (1 << REG_POS(i,16))) { + if(i & bitList) + cpu->R[REG_POS(i,16)] = start; + } + else + cpu->R[REG_POS(i,16)] = start; + + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMIA2() +{ + const u32 &i = cpu->instruction; + u32 oldmode = 0; + + u32 c = 0; + + u32 start = cpu->R[REG_POS(i,16)]; + u32 * registres; + TWaitState* waitState; + + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 1; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[PROCNUM]; + + OP_L_IA(0, start); + OP_L_IA(1, start); + OP_L_IA(2, start); + OP_L_IA(3, start); + OP_L_IA(4, start); + OP_L_IA(5, start); + OP_L_IA(6, start); + OP_L_IA(7, start); + OP_L_IA(8, start); + OP_L_IA(9, start); + OP_L_IA(10, start); + OP_L_IA(11, start); + OP_L_IA(12, start); + OP_L_IA(13, start); + OP_L_IA(14, start); + + if(BIT15(i) == 0) + { + armcpu_switchMode(cpu, oldmode); + } + else + { + + u32 tmp = READ32(cpu->mem_if->data, start); + Status_Reg SPSR; + cpu->R[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + //start += 4; + cpu->next_instruction = cpu->R[15]; + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + } + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMIB2() +{ + const u32 &i = cpu->instruction; + u32 oldmode = 0; + u32 c = 0; + + u32 start = cpu->R[REG_POS(i,16)]; + u32 * registres; + TWaitState* waitState; + + UNTESTEDOPCODELOG("Untested opcode: OP_LDMIB2\n"); + + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[PROCNUM]; + + OP_L_IB(0, start); + OP_L_IB(1, start); + OP_L_IB(2, start); + OP_L_IB(3, start); + OP_L_IB(4, start); + OP_L_IB(5, start); + OP_L_IB(6, start); + OP_L_IB(7, start); + OP_L_IB(8, start); + OP_L_IB(9, start); + OP_L_IB(10, start); + OP_L_IB(11, start); + OP_L_IB(12, start); + OP_L_IB(13, start); + OP_L_IB(14, start); + + if(BIT15(i) == 0) + { + armcpu_switchMode(cpu, oldmode); + } + else + { + u32 tmp; + Status_Reg SPSR; + start += 4; + tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->next_instruction = registres[15]; + c += waitState[(start>>24)&0xF]; + } + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMDA2() +{ + const u32 &i = cpu->instruction; + + u32 oldmode = 0; + u32 c = 0; + u32 * registres; + TWaitState* waitState; + + u32 start = cpu->R[REG_POS(i,16)]; + + UNTESTEDOPCODELOG("Untested opcode: OP_LDMDA2\n"); + + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[PROCNUM]; + + if(BIT15(i)) + { + u32 tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR = cpu->SPSR; + c += waitState[(start>>24)&0xF]; + start -= 4; + cpu->next_instruction = registres[15]; + } + + OP_L_DA(14, start); + OP_L_DA(13, start); + OP_L_DA(12, start); + OP_L_DA(11, start); + OP_L_DA(10, start); + OP_L_DA(9, start); + OP_L_DA(8, start); + OP_L_DA(7, start); + OP_L_DA(6, start); + OP_L_DA(5, start); + OP_L_DA(4, start); + OP_L_DA(3, start); + OP_L_DA(2, start); + OP_L_DA(1, start); + OP_L_DA(0, start); + + if(BIT15(i)==0) + { + armcpu_switchMode(cpu, oldmode); + } + else + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + } + + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMDB2() +{ + const u32 &i = cpu->instruction; + + u32 oldmode = 0; + u32 c = 0; + u32 * registres; + TWaitState* waitState; + + u32 start = cpu->R[REG_POS(i,16)]; + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[PROCNUM]; + + if(BIT15(i)) + { + u32 tmp; + start -= 4; + tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR = cpu->SPSR; + cpu->next_instruction = registres[15]; + c += waitState[(start>>24)&0xF]; + } + + OP_L_DB(14, start); + OP_L_DB(13, start); + OP_L_DB(12, start); + OP_L_DB(11, start); + OP_L_DB(10, start); + OP_L_DB(9, start); + OP_L_DB(8, start); + OP_L_DB(7, start); + OP_L_DB(6, start); + OP_L_DB(5, start); + OP_L_DB(4, start); + OP_L_DB(3, start); + OP_L_DB(2, start); + OP_L_DB(1, start); + OP_L_DB(0, start); + + if(BIT15(i)==0) + { + armcpu_switchMode(cpu, oldmode); + } + else + { + Status_Reg SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + } + + return 2 + c; +} + +TEMPLATE static u32 FASTCALL OP_LDMIA2_W() +{ + const u32 &i = cpu->instruction; + u32 c = 0; + + u32 oldmode = 0; + u32 start = cpu->R[REG_POS(i,16)]; + u32 * registres; + TWaitState* waitState; + u32 tmp; + Status_Reg SPSR; +// emu_halt(); + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[PROCNUM]; + + OP_L_IA(0, start); + OP_L_IA(1, start); + OP_L_IA(2, start); + OP_L_IA(3, start); + OP_L_IA(4, start); + OP_L_IA(5, start); + OP_L_IA(6, start); + OP_L_IA(7, start); + OP_L_IA(8, start); + OP_L_IA(9, start); + OP_L_IA(10, start); + OP_L_IA(11, start); + OP_L_IA(12, start); + OP_L_IA(13, start); + OP_L_IA(14, start); + + if(BIT15(i)==0) + { + registres[REG_POS(i,16)] = start; + armcpu_switchMode(cpu, oldmode); + return c + 2; + } + + registres[REG_POS(i,16)] = start + 4; + tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + cpu->next_instruction = registres[15]; + c += waitState[(start>>24)&0xF]; + + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMIB2_W() +{ + const u32 &i = cpu->instruction; + u32 c = 0; + + u32 oldmode = 0; + u32 start = cpu->R[REG_POS(i,16)]; + u32 * registres; + TWaitState* waitState; + u32 tmp; + Status_Reg SPSR; + + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[PROCNUM]; + + OP_L_IB(0, start); + OP_L_IB(1, start); + OP_L_IB(2, start); + OP_L_IB(3, start); + OP_L_IB(4, start); + OP_L_IB(5, start); + OP_L_IB(6, start); + OP_L_IB(7, start); + OP_L_IB(8, start); + OP_L_IB(9, start); + OP_L_IB(10, start); + OP_L_IB(11, start); + OP_L_IB(12, start); + OP_L_IB(13, start); + OP_L_IB(14, start); + + if(BIT15(i)==0) + { + armcpu_switchMode(cpu, oldmode); + registres[REG_POS(i,16)] = start; + + return c + 2; + } + + registres[REG_POS(i,16)] = start + 4; + tmp = READ32(cpu->mem_if->data, start + 4); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR = cpu->SPSR; + cpu->next_instruction = registres[15]; + SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + c += waitState[(start>>24)&0xF]; + + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMDA2_W() +{ + const u32 &i = cpu->instruction; + u32 c = 0; + + u32 oldmode = 0; + u32 start = cpu->R[REG_POS(i,16)]; + u32 * registres; + TWaitState * waitState; + Status_Reg SPSR; +// emu_halt(); + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[PROCNUM]; + + if(BIT15(i)) + { + u32 tmp = READ32(cpu->mem_if->data, start); + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + c += waitState[(start>>24)&0xF]; + start -= 4; + cpu->next_instruction = registres[15]; + } + + OP_L_DA(14, start); + OP_L_DA(13, start); + OP_L_DA(12, start); + OP_L_DA(11, start); + OP_L_DA(10, start); + OP_L_DA(9, start); + OP_L_DA(8, start); + OP_L_DA(7, start); + OP_L_DA(6, start); + OP_L_DA(5, start); + OP_L_DA(4, start); + OP_L_DA(3, start); + OP_L_DA(2, start); + OP_L_DA(1, start); + OP_L_DA(0, start); + + registres[REG_POS(i,16)] = start; + + if(BIT15(i)==0) + { + armcpu_switchMode(cpu, oldmode); + return c + 2; + } + + SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMDB2_W() +{ + const u32 &i = cpu->instruction; + u32 c = 0; + + u32 oldmode = 0; + u32 start = cpu->R[REG_POS(i,16)]; + u32 * registres; + TWaitState* waitState; + Status_Reg SPSR; +// emu_halt(); + if(BIT15(i)==0) + { + if(cpu->CPSR.bits.mode==USR) + return 2; + oldmode = armcpu_switchMode(cpu, SYS); + } + + registres = cpu->R; + waitState = MMU.MMU_WAIT32[PROCNUM]; + + if(BIT15(i)) + { + u32 tmp; + start -= 4; + tmp = READ32(cpu->mem_if->data, start); + c += waitState[(start>>24)&0xF]; + registres[15] = tmp & (0XFFFFFFFC | (BIT0(tmp)<<1)); + cpu->CPSR = cpu->SPSR; + cpu->next_instruction = registres[15]; + } + + OP_L_DB(14, start); + OP_L_DB(13, start); + OP_L_DB(12, start); + OP_L_DB(11, start); + OP_L_DB(10, start); + OP_L_DB(9, start); + OP_L_DB(8, start); + OP_L_DB(7, start); + OP_L_DB(6, start); + OP_L_DB(5, start); + OP_L_DB(4, start); + OP_L_DB(3, start); + OP_L_DB(2, start); + OP_L_DB(1, start); + OP_L_DB(0, start); + + registres[REG_POS(i,16)] = start; + + if(BIT15(i)==0) + { + armcpu_switchMode(cpu, oldmode); + return c + 2; + } + + SPSR = cpu->SPSR; + armcpu_switchMode(cpu, SPSR.bits.mode); + cpu->CPSR=SPSR; + return c + 2; +} + +//------------------------------STM---------------------------------- + +TEMPLATE static u32 FASTCALL OP_STMIA() +{ + const u32 &i = cpu->instruction; + u32 c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + WRITE32(cpu->mem_if->data, start, cpu->R[b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + start += 4; + } + } + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMIB() +{ + const u32 &i = cpu->instruction; + u32 c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + start += 4; + WRITE32(cpu->mem_if->data, start, cpu->R[b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + } + } + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMDA() +{ + const u32 &i = cpu->instruction; + u32 c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + start -= 4; + } + } + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMDB() +{ + const u32 &i = cpu->instruction; + u32 c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + start -= 4; + WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + } + } + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMIA_W() +{ + const u32 &i = cpu->instruction; + u32 c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + WRITE32(cpu->mem_if->data, start, cpu->R[b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + start += 4; + } + } + + cpu->R[REG_POS(i,16)] = start; + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMIB_W() +{ + const u32 &i = cpu->instruction; + u32 c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + start += 4; + WRITE32(cpu->mem_if->data, start, cpu->R[b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + } + } + cpu->R[REG_POS(i,16)] = start; + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMDA_W() +{ + const u32 &i = cpu->instruction; + u32 c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + start -= 4; + } + } + + cpu->R[REG_POS(i,16)] = start; + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMDB_W() +{ + const u32 &i = cpu->instruction; + u32 c = 0, b; + u32 start = cpu->R[REG_POS(i,16)]; + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + start -= 4; + WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + } + } + + cpu->R[REG_POS(i,16)] = start; + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMIA2() +{ + const u32 &i = cpu->instruction; + u32 c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + c = 0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_STMIA2\n"); + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + WRITE32(cpu->mem_if->data, start, cpu->R[b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + start += 4; + } + } + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMIB2() +{ + const u32 &i = cpu->instruction; + u32 c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + c = 0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_STMIB2\n"); + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + start += 4; + WRITE32(cpu->mem_if->data, start, cpu->R[b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + } + } + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMDA2() +{ + const u32 &i=cpu->instruction; + u32 c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + c = 0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_STMDA2\n"); + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + start -= 4; + } + } + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMDB2() +{ + const u32 &i = cpu->instruction; + u32 c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + c=0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + start -= 4; + WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + } + } + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMIA2_W() +{ + u32 i, c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + i = cpu->instruction; + c=0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_STMIA2_W\n"); + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + WRITE32(cpu->mem_if->data, start, cpu->R[b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + start += 4; + } + } + + cpu->R[REG_POS(i,16)] = start; + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMIB2_W() +{ + u32 i, c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + i = cpu->instruction; + c=0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + for(b=0; b<16; ++b) + { + if(BIT_N(i, b)) + { + start += 4; + WRITE32(cpu->mem_if->data, start, cpu->R[b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + } + } + armcpu_switchMode(cpu, oldmode); + cpu->R[REG_POS(i,16)] = start; + + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMDA2_W() +{ + u32 i, c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + i = cpu->instruction; + c = 0; + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_STMDA2_W\n"); + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + start -= 4; + } + } + + cpu->R[REG_POS(i,16)] = start; + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +TEMPLATE static u32 FASTCALL OP_STMDB2_W() +{ + u32 i, c, b; + u32 start; + u32 oldmode; + + if(cpu->CPSR.bits.mode==USR) + return 2; + + i = cpu->instruction; + c = 0; + + start = cpu->R[REG_POS(i,16)]; + oldmode = armcpu_switchMode(cpu, SYS); + + UNTESTEDOPCODELOG("Untested opcode: OP_STMDB2_W\n"); + + for(b=0; b<16; ++b) + { + if(BIT_N(i, 15-b)) + { + start -= 4; + WRITE32(cpu->mem_if->data, start, cpu->R[15-b]); + c += MMU.MMU_WAIT32[PROCNUM][(start>>24)&0xF]; + } + } + + cpu->R[REG_POS(i,16)] = start; + + armcpu_switchMode(cpu, oldmode); + return c + 1; +} + +/* + * + * The Enhanced DSP Extension LDRD and STRD instructions. + * + */ +TEMPLATE static u32 FASTCALL +OP_LDRD_STRD_POST_INDEX( ) { + const u32 &i = cpu->instruction; + u32 Rd_num = REG_POS( i, 12); + u32 addr = cpu->R[REG_POS(i,16)]; + u32 index; + + /* I bit - immediate or register */ + if ( BIT22(i)) + index = IMM_OFF; + else + index = cpu->R[REG_POS(i,0)]; + + /* U bit - add or subtract */ + if ( BIT23(i)) + cpu->R[REG_POS(i,16)] += index; + else + cpu->R[REG_POS(i,16)] -= index; + + if ( !(Rd_num & 0x1)) { + /* Store/Load */ + if ( BIT5(i)) { + WRITE32(cpu->mem_if->data, addr, cpu->R[Rd_num]); + WRITE32(cpu->mem_if->data, addr + 4, cpu->R[Rd_num + 1]); + } + else { + cpu->R[Rd_num] = READ32(cpu->mem_if->data, addr); + cpu->R[Rd_num + 1] = READ32(cpu->mem_if->data, addr + 4); + } + } + + return 3 + (MMU.MMU_WAIT32[PROCNUM][(addr>>24)&0xF] * 2); +} + +TEMPLATE static u32 FASTCALL +OP_LDRD_STRD_OFFSET_PRE_INDEX( ) { + const u32 &i = cpu->instruction; + u32 Rd_num = REG_POS( i, 12); + u32 addr = cpu->R[REG_POS(i,16)]; + u32 index; + + /* I bit - immediate or register */ + if ( BIT22(i)) + index = IMM_OFF; + else + index = cpu->R[REG_POS(i,0)]; + + /* U bit - add or subtract */ + if ( BIT23(i)) { + addr += index; + + /* W bit - writeback */ + if ( BIT21(i)) + cpu->R[REG_POS(i,16)] = addr; + } + else { + addr -= index; + + /* W bit - writeback */ + if ( BIT21(i)) + cpu->R[REG_POS(i,16)] = addr; + } + + if ( !(Rd_num & 0x1)) { + /* Store/Load */ + if ( BIT5(i)) { + WRITE32(cpu->mem_if->data, addr, cpu->R[Rd_num]); + WRITE32(cpu->mem_if->data, addr + 4, cpu->R[Rd_num + 1]); + } + else { + cpu->R[Rd_num] = READ32(cpu->mem_if->data, addr); + cpu->R[Rd_num + 1] = READ32(cpu->mem_if->data, addr + 4); + } + } + + return 3 + (MMU.MMU_WAIT32[PROCNUM][(addr>>24)&0xF] * 2); +} + + + +//---------------------STC---------------------------------- +/* the NDS has no coproc that responses to a STC, no feedback is given to the arm */ + +TEMPLATE static u32 FASTCALL OP_STC_P_IMM_OFF() +{ + TRAPUNDEF(); +} + +TEMPLATE static u32 FASTCALL OP_STC_M_IMM_OFF() +{ + TRAPUNDEF(); +} + +TEMPLATE static u32 FASTCALL OP_STC_P_PREIND() +{ + TRAPUNDEF(); +} + +TEMPLATE static u32 FASTCALL OP_STC_M_PREIND() +{ + TRAPUNDEF(); +} + +TEMPLATE static u32 FASTCALL OP_STC_P_POSTIND() +{ + TRAPUNDEF(); +} + +TEMPLATE static u32 FASTCALL OP_STC_M_POSTIND() +{ + TRAPUNDEF(); +} + +TEMPLATE static u32 FASTCALL OP_STC_OPTION() +{ + TRAPUNDEF(); +} + +//---------------------LDC---------------------------------- +/* the NDS has no coproc that responses to a LDC, no feedback is given to the arm */ + +TEMPLATE static u32 FASTCALL OP_LDC_P_IMM_OFF() +{ + TRAPUNDEF(); +} + +TEMPLATE static u32 FASTCALL OP_LDC_M_IMM_OFF() +{ + TRAPUNDEF(); +} + +TEMPLATE static u32 FASTCALL OP_LDC_P_PREIND() +{ + TRAPUNDEF(); +} + +TEMPLATE static u32 FASTCALL OP_LDC_M_PREIND() +{ + TRAPUNDEF(); +} + +TEMPLATE static u32 FASTCALL OP_LDC_P_POSTIND() +{ + TRAPUNDEF(); +} + +TEMPLATE static u32 FASTCALL OP_LDC_M_POSTIND() +{ + TRAPUNDEF(); +} + +TEMPLATE static u32 FASTCALL OP_LDC_OPTION() +{ + TRAPUNDEF(); + return 2; +} + +//----------------MCR----------------------- + +TEMPLATE static u32 FASTCALL OP_MCR() +{ + const u32 &i = cpu->instruction; + u32 cpnum = REG_POS(i, 8); + + if(!cpu->coproc[cpnum]) + { + emu_halt(); + LOG("Stopped (OP_MCR)\n"); + return 2; + } + + armcp15_moveARM2CP((armcp15_t*)cpu->coproc[cpnum], cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); + //cpu->coproc[cpnum]->moveARM2CP(cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); + return 2; +} + +//----------------MRC----------------------- + +TEMPLATE static u32 FASTCALL OP_MRC() +{ + const u32 &i = cpu->instruction; + u32 cpnum = REG_POS(i, 8); + + if(!cpu->coproc[cpnum]) + { + emu_halt(); + LOG("Stopped (OP_MRC)\n"); + return 2; + } + + armcp15_moveCP2ARM((armcp15_t*)cpu->coproc[cpnum], &cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); + //cpu->coproc[cpnum]->moveCP2ARM(&cpu->R[REG_POS(i, 12)], REG_POS(i, 16), REG_POS(i, 0), (i>>21)&7, (i>>5)&7); + return 4; +} + +//--------------SWI------------------------------- +TEMPLATE static u32 FASTCALL OP_SWI() +{ + u32 swinum = (cpu->instruction>>16)&0xFF; + + //ideas-style debug prints + if(swinum==0xFC) { + IdeasLog(cpu); + return 0; + } + + if(cpu->swi_tab) { + swinum &= 0x1F; + return cpu->swi_tab[swinum]() + 3; + } else { + /* TODO (#1#): translocated SWI vectors */ + /* we use an irq thats not in the irq tab, as + it was replaced duie to a changed intVector */ + Status_Reg tmp = cpu->CPSR; + armcpu_switchMode(cpu, SVC); /* enter svc mode */ + cpu->R[14] = cpu->next_instruction; + cpu->SPSR = tmp; /* save old CPSR as new SPSR */ + cpu->CPSR.bits.T = 0; /* handle as ARM32 code */ + cpu->CPSR.bits.I = 1; + cpu->R[15] = cpu->intVector + 0x08; + cpu->next_instruction = cpu->R[15]; + return 4; + } +} + +//----------------BKPT------------------------- +TEMPLATE static u32 FASTCALL OP_BKPT() +{ + /*LOG("Stopped (OP_BKPT)\n"); + TRAPUNDEF();*/ + return 4; +} + +//----------------CDP----------------------- + +TEMPLATE static u32 FASTCALL OP_CDP() +{ + LOG("Stopped (OP_CDP)\n"); + TRAPUNDEF(); +} + +#define TYPE_RETOUR u32 +#define PARAMETRES +#define CALLTYPE FASTCALL +#define NOM_TAB arm_instructions_set_0 +#define TABDECL(x) x<0> + +#include "instruction_tabdef.inc" + +#undef TYPE_RETOUR +#undef PARAMETRES +#undef CALLTYPE +#undef NOM_TAB +#undef TABDECL + +#define TYPE_RETOUR u32 +#define PARAMETRES +#define CALLTYPE FASTCALL +#define NOM_TAB arm_instructions_set_1 +#define TABDECL(x) x<1> + +#include "instruction_tabdef.inc" diff --git a/desmume/src/arm_instructions.h b/src/arm_instructions.h similarity index 97% rename from desmume/src/arm_instructions.h rename to src/arm_instructions.h index fab719263..cb8ef20a6 100644 --- a/desmume/src/arm_instructions.h +++ b/src/arm_instructions.h @@ -1,32 +1,32 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef ARMINSTRUCTION_H -#define ARMINSTRUCTION_H - -#include "types.h" -#include "armcpu.h" - -extern u32 (FASTCALL* arm_instructions_set_0[4096])(); -extern u32 (FASTCALL* arm_instructions_set_1[4096])(); - -#endif - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef ARMINSTRUCTION_H +#define ARMINSTRUCTION_H + +#include "types.h" +#include "armcpu.h" + +extern u32 (FASTCALL* arm_instructions_set_0[4096])(); +extern u32 (FASTCALL* arm_instructions_set_1[4096])(); + +#endif + diff --git a/desmume/src/armcpu.cpp b/src/armcpu.cpp similarity index 94% rename from desmume/src/armcpu.cpp rename to src/armcpu.cpp index c2aeba1bb..aea747307 100644 --- a/desmume/src/armcpu.cpp +++ b/src/armcpu.cpp @@ -1,569 +1,567 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include -#include "types.h" -#include "arm_instructions.h" -#include "thumb_instructions.h" -#include "cp15.h" -#include "bios.h" -#include "debug.h" -#include "Disassembler.h" - - -template static u32 armcpu_prefetch(); - -FORCEINLINE u32 armcpu_prefetch(armcpu_t *armcpu) { - if(armcpu->proc_ID==0) return armcpu_prefetch<0>(); - else return armcpu_prefetch<1>(); -} - -const unsigned char arm_cond_table[16*16] = { - /* N=0, Z=0, C=0, V=0 */ - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, - 0x00,0xFF,0xFF,0x00,0xFF,0x00,0xFF,0x20, - /* N=0, Z=0, C=0, V=1 */ - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x00, - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=0, Z=0, C=1, V=0 */ - 0x00,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF, - 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x20, - /* N=0, Z=0, C=1, V=1 */ - 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00, - 0xFF,0x00,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=0, Z=1, C=0, V=0 */ - 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF, - 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20, - /* N=0, Z=1, C=0, V=1 */ - 0xFF,0x00,0x00,0xFF,0x00,0xFF,0xFF,0x00, - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=0, Z=1, C=1, V=0 */ - 0xFF,0x00,0xFF,0x00,0x00,0xFF,0x00,0xFF, - 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20, - /* N=0, Z=1, C=1, V=1 */ - 0xFF,0x00,0xFF,0x00,0x00,0xFF,0xFF,0x00, - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=1, Z=0, C=0, V=0 */ - 0x00,0xFF,0x00,0xFF,0xFF,0x00,0x00,0xFF, - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=1, Z=0, C=0, V=1 */ - 0x00,0xFF,0x00,0xFF,0xFF,0x00,0xFF,0x00, - 0x00,0xFF,0xFF,0x00,0xFF,0x00,0xFF,0x20, - /* N=1, Z=0, C=1, V=0 */ - 0x00,0xFF,0xFF,0x00,0xFF,0x00,0x00,0xFF, - 0xFF,0x00,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=1, Z=0, C=1, V=1 */ - 0x00,0xFF,0xFF,0x00,0xFF,0x00,0xFF,0x00, - 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x20, - /* N=1, Z=1, C=0, V=0 */ - 0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF, - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=1, Z=1, C=0, V=1 */ - 0xFF,0x00,0x00,0xFF,0xFF,0x00,0xFF,0x00, - 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20, - /* N=1, Z=1, C=1, V=0 */ - 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x00,0xFF, - 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, - /* N=1, Z=1, C=1, V=1 */ - 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, - 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20, -}; - -armcpu_t NDS_ARM7; -armcpu_t NDS_ARM9; - -#define SWAP(a, b, c) do \ - { \ - c=a; \ - a=b; \ - b=c; \ - } \ - while(0) - -#ifdef GDB_STUB - -#define STALLED_CYCLE_COUNT 10 - -static void -stall_cpu( void *instance) { - armcpu_t *armcpu = (armcpu_t *)instance; - - armcpu->stalled = 1; -} - -static void -unstall_cpu( void *instance) { - armcpu_t *armcpu = (armcpu_t *)instance; - - armcpu->stalled = 0; -} - -static void -install_post_exec_fn( void *instance, - void (*ex_fn)( void *, u32 adr, int thumb), - void *fn_data) { - armcpu_t *armcpu = (armcpu_t *)instance; - - armcpu->post_ex_fn = ex_fn; - armcpu->post_ex_fn_data = fn_data; -} - -static void -remove_post_exec_fn( void *instance) { - armcpu_t *armcpu = (armcpu_t *)instance; - - armcpu->post_ex_fn = NULL; -} -#endif - -#ifdef GDB_STUB -static u32 -read_cpu_reg( void *instance, u32 reg_num) { - armcpu_t *armcpu = (armcpu_t *)instance; - u32 reg_value = 0; - - if ( reg_num <= 14) { - reg_value = armcpu->R[reg_num]; - } - else if ( reg_num == 15) { - reg_value = armcpu->next_instruction; - } - else if ( reg_num == 16) { - /* CPSR */ - reg_value = armcpu->CPSR.val; - } - - return reg_value; -} - -static void -set_cpu_reg( void *instance, u32 reg_num, u32 value) { - armcpu_t *armcpu = (armcpu_t *)instance; - - if ( reg_num <= 14) { - armcpu->R[reg_num] = value; - } - else if ( reg_num == 15) { - armcpu->next_instruction = value; - } - else if ( reg_num == 16) { - /* FIXME: setting the CPSR */ - } -} -#endif - -#ifdef GDB_STUB -int armcpu_new( armcpu_t *armcpu, u32 id, - struct armcpu_memory_iface *mem_if, - struct armcpu_ctrl_iface **ctrl_iface_ret) -#else -int armcpu_new( armcpu_t *armcpu, u32 id) -#endif -{ - armcpu->proc_ID = id; - -#ifdef GDB_STUB - armcpu->mem_if = mem_if; - - /* populate the control interface */ - armcpu->ctrl_iface.stall = stall_cpu; - armcpu->ctrl_iface.unstall = unstall_cpu; - armcpu->ctrl_iface.read_reg = read_cpu_reg; - armcpu->ctrl_iface.set_reg = set_cpu_reg; - armcpu->ctrl_iface.install_post_ex_fn = install_post_exec_fn; - armcpu->ctrl_iface.remove_post_ex_fn = remove_post_exec_fn; - armcpu->ctrl_iface.data = armcpu; - - *ctrl_iface_ret = &armcpu->ctrl_iface; - - armcpu->stalled = 0; - armcpu->post_ex_fn = NULL; -#endif - - armcpu_init(armcpu, 0); - - return 0; -} - -void armcpu_init(armcpu_t *armcpu, u32 adr) -{ - u32 i; - - armcpu->LDTBit = (armcpu->proc_ID==0); //Si ARM9 utiliser le syte v5 pour le load - armcpu->intVector = 0xFFFF0000 * (armcpu->proc_ID==0); - armcpu->waitIRQ = FALSE; - armcpu->wirq = FALSE; - - armcpu->newIrqFlags = 0; - -#ifdef GDB_STUB - armcpu->irq_flag = 0; -#endif - - if(armcpu->coproc[15]) free(armcpu->coproc[15]); - - for(i = 0; i < 15; ++i) - { - armcpu->R[i] = 0; - armcpu->coproc[i] = NULL; - } - - armcpu->CPSR.val = armcpu->SPSR.val = SYS; - - armcpu->R13_usr = armcpu->R14_usr = 0; - armcpu->R13_svc = armcpu->R14_svc = 0; - armcpu->R13_abt = armcpu->R14_abt = 0; - armcpu->R13_und = armcpu->R14_und = 0; - armcpu->R13_irq = armcpu->R14_irq = 0; - armcpu->R8_fiq = armcpu->R9_fiq = armcpu->R10_fiq = armcpu->R11_fiq = armcpu->R12_fiq = armcpu->R13_fiq = armcpu->R14_fiq = 0; - - armcpu->SPSR_svc.val = armcpu->SPSR_abt.val = armcpu->SPSR_und.val = armcpu->SPSR_irq.val = armcpu->SPSR_fiq.val = 0; - -#ifdef GDB_STUB - armcpu->instruct_adr = adr; - armcpu->R[15] = adr + 8; -#else - armcpu->R[15] = adr; -#endif - - armcpu->next_instruction = adr; - - armcpu->coproc[15] = (armcp_t*)armcp15_new(armcpu); - -#ifndef GDB_STUB - armcpu_prefetch(armcpu); -#endif -} - -u32 armcpu_switchMode(armcpu_t *armcpu, u8 mode) -{ - u32 oldmode = armcpu->CPSR.bits.mode; - - switch(oldmode) - { - case USR : - case SYS : - armcpu->R13_usr = armcpu->R[13]; - armcpu->R14_usr = armcpu->R[14]; - break; - - case FIQ : - { - u32 tmp; - SWAP(armcpu->R[8], armcpu->R8_fiq, tmp); - SWAP(armcpu->R[9], armcpu->R9_fiq, tmp); - SWAP(armcpu->R[10], armcpu->R10_fiq, tmp); - SWAP(armcpu->R[11], armcpu->R11_fiq, tmp); - SWAP(armcpu->R[12], armcpu->R12_fiq, tmp); - armcpu->R13_fiq = armcpu->R[13]; - armcpu->R14_fiq = armcpu->R[14]; - armcpu->SPSR_fiq = armcpu->SPSR; - break; - } - case IRQ : - armcpu->R13_irq = armcpu->R[13]; - armcpu->R14_irq = armcpu->R[14]; - armcpu->SPSR_irq = armcpu->SPSR; - break; - - case SVC : - armcpu->R13_svc = armcpu->R[13]; - armcpu->R14_svc = armcpu->R[14]; - armcpu->SPSR_svc = armcpu->SPSR; - break; - - case ABT : - armcpu->R13_abt = armcpu->R[13]; - armcpu->R14_abt = armcpu->R[14]; - armcpu->SPSR_abt = armcpu->SPSR; - break; - - case UND : - armcpu->R13_und = armcpu->R[13]; - armcpu->R14_und = armcpu->R[14]; - armcpu->SPSR_und = armcpu->SPSR; - break; - default : - break; - } - - switch(mode) - { - case USR : - case SYS : - armcpu->R[13] = armcpu->R13_usr; - armcpu->R[14] = armcpu->R14_usr; - //SPSR = CPSR; - break; - - case FIQ : - { - u32 tmp; - SWAP(armcpu->R[8], armcpu->R8_fiq, tmp); - SWAP(armcpu->R[9], armcpu->R9_fiq, tmp); - SWAP(armcpu->R[10], armcpu->R10_fiq, tmp); - SWAP(armcpu->R[11], armcpu->R11_fiq, tmp); - SWAP(armcpu->R[12], armcpu->R12_fiq, tmp); - armcpu->R[13] = armcpu->R13_fiq; - armcpu->R[14] = armcpu->R14_fiq; - armcpu->SPSR = armcpu->SPSR_fiq; - break; - } - - case IRQ : - armcpu->R[13] = armcpu->R13_irq; - armcpu->R[14] = armcpu->R14_irq; - armcpu->SPSR = armcpu->SPSR_irq; - break; - - case SVC : - armcpu->R[13] = armcpu->R13_svc; - armcpu->R[14] = armcpu->R14_svc; - armcpu->SPSR = armcpu->SPSR_svc; - break; - - case ABT : - armcpu->R[13] = armcpu->R13_abt; - armcpu->R[14] = armcpu->R14_abt; - armcpu->SPSR = armcpu->SPSR_abt; - break; - - case UND : - armcpu->R[13] = armcpu->R13_und; - armcpu->R[14] = armcpu->R14_und; - armcpu->SPSR = armcpu->SPSR_und; - break; - - default : - break; - } - - armcpu->CPSR.bits.mode = mode & 0x1F; - return oldmode; -} - -template -FORCEINLINE static u32 armcpu_prefetch() -{ - armcpu_t* const armcpu = &ARMPROC; -#ifdef GDB_STUB - u32 temp_instruction; -#endif - - if(armcpu->CPSR.bits.T == 0) - { -#ifdef GDB_STUB - temp_instruction = - armcpu->mem_if->prefetch32( armcpu->mem_if->data, - armcpu->next_instruction); - - if ( !armcpu->stalled) { - armcpu->instruction = temp_instruction; - armcpu->instruct_adr = armcpu->next_instruction; - armcpu->next_instruction += 4; - armcpu->R[15] = armcpu->next_instruction + 4; - } -#else - armcpu->instruction = MMU_read32_acl(PROCNUM, armcpu->next_instruction&0xFFFFFFFC,CP15_ACCESS_EXECUTE); - - armcpu->instruct_adr = armcpu->next_instruction; - armcpu->next_instruction += 4; - armcpu->R[15] = armcpu->next_instruction + 4; -#endif - - return MMU.MMU_WAIT32[PROCNUM][(armcpu->instruct_adr>>24)&0xF]; - } - -#ifdef GDB_STUB - temp_instruction = - armcpu->mem_if->prefetch16( armcpu->mem_if->data, - armcpu->next_instruction); - - if ( !armcpu->stalled) { - armcpu->instruction = temp_instruction; - armcpu->instruct_adr = armcpu->next_instruction; - armcpu->next_instruction = armcpu->next_instruction + 2; - armcpu->R[15] = armcpu->next_instruction + 2; - } -#else - armcpu->instruction = MMU_read16_acl(PROCNUM, armcpu->next_instruction&0xFFFFFFFE,CP15_ACCESS_EXECUTE); - - armcpu->instruct_adr = armcpu->next_instruction; - armcpu->next_instruction += 2; - armcpu->R[15] = armcpu->next_instruction + 2; -#endif - - return MMU.MMU_WAIT16[PROCNUM][(armcpu->instruct_adr>>24)&0xF]; -} - -#if 0 /* not used */ -static BOOL FASTCALL test_EQ(Status_Reg CPSR) { return ( CPSR.bits.Z); } -static BOOL FASTCALL test_NE(Status_Reg CPSR) { return (!CPSR.bits.Z); } -static BOOL FASTCALL test_CS(Status_Reg CPSR) { return ( CPSR.bits.C); } -static BOOL FASTCALL test_CC(Status_Reg CPSR) { return (!CPSR.bits.C); } -static BOOL FASTCALL test_MI(Status_Reg CPSR) { return ( CPSR.bits.N); } -static BOOL FASTCALL test_PL(Status_Reg CPSR) { return (!CPSR.bits.N); } -static BOOL FASTCALL test_VS(Status_Reg CPSR) { return ( CPSR.bits.V); } -static BOOL FASTCALL test_VC(Status_Reg CPSR) { return (!CPSR.bits.V); } -static BOOL FASTCALL test_HI(Status_Reg CPSR) { return (CPSR.bits.C) && (!CPSR.bits.Z); } -static BOOL FASTCALL test_LS(Status_Reg CPSR) { return (CPSR.bits.Z) || (!CPSR.bits.C); } -static BOOL FASTCALL test_GE(Status_Reg CPSR) { return (CPSR.bits.N==CPSR.bits.V); } -static BOOL FASTCALL test_LT(Status_Reg CPSR) { return (CPSR.bits.N!=CPSR.bits.V); } -static BOOL FASTCALL test_GT(Status_Reg CPSR) { return (!CPSR.bits.Z) && (CPSR.bits.N==CPSR.bits.V); } -static BOOL FASTCALL test_LE(Status_Reg CPSR) { return ( CPSR.bits.Z) || (CPSR.bits.N!=CPSR.bits.V); } -static BOOL FASTCALL test_AL(Status_Reg CPSR) { return 1; } - -static BOOL (FASTCALL* test_conditions[])(Status_Reg CPSR)= { - test_EQ , test_NE , - test_CS , test_CC , - test_MI , test_PL , - test_VS , test_VC , - test_HI , test_LS , - test_GE , test_LT , - test_GT , test_LE , - test_AL -}; -#define TEST_COND2(cond, CPSR) \ - (cond<15&&test_conditions[cond](CPSR)) -#endif - - -BOOL armcpu_irqException(armcpu_t *armcpu) -{ - Status_Reg tmp; - - if(armcpu->CPSR.bits.I) return FALSE; - -#ifdef GDB_STUB - armcpu->irq_flag = 0; -#endif - - tmp = armcpu->CPSR; - armcpu_switchMode(armcpu, IRQ); - -#ifdef GDB_STUB - armcpu->R[14] = armcpu->next_instruction + 4; -#else - armcpu->R[14] = armcpu->instruct_adr + 4; -#endif - armcpu->SPSR = tmp; - armcpu->CPSR.bits.T = 0; - armcpu->CPSR.bits.I = 1; - armcpu->next_instruction = armcpu->intVector + 0x18; - armcpu->waitIRQ = 0; - -#ifndef GDB_STUB - armcpu->R[15] = armcpu->next_instruction + 8; - armcpu_prefetch(armcpu); -#endif - - return TRUE; -} - -BOOL -armcpu_flagIrq( armcpu_t *armcpu) { - if(armcpu->CPSR.bits.I) return FALSE; - - armcpu->waitIRQ = 0; - -#ifdef GDB_STUB - armcpu->irq_flag = 1; -#endif - - return TRUE; -} - - -template -u32 armcpu_exec() -{ - u32 c = 1; - - //this assert is annoying. but sometimes it is handy. - //assert(ARMPROC.instruct_adr!=0x00000000); - -#ifdef GDB_STUB - if (ARMPROC.stalled) - return STALLED_CYCLE_COUNT; - - /* check for interrupts */ - if ( ARMPROC.irq_flag) { - armcpu_irqException( &ARMPROC); - } - - c = armcpu_prefetch(&ARMPROC); - - if ( ARMPROC.stalled) { - return c; - } -#endif - - if(ARMPROC.CPSR.bits.T == 0) - { - if( - CONDITION(ARMPROC.instruction) == 0x0E //fast path for unconditional instructions - || (TEST_COND(CONDITION(ARMPROC.instruction), CODE(ARMPROC.instruction), ARMPROC.CPSR)) //handles any condition - ) - { - if(PROCNUM==0) { -#ifdef WANTASMLISTING - char txt[128]; - des_arm_instructions_set[INSTRUCTION_INDEX(ARMPROC.instruction)](ARMPROC.instruct_adr,ARMPROC.instruction,txt); - printf("%X: %X - %s\n", ARMPROC.instruct_adr,ARMPROC.instruction, txt); -#endif - c += arm_instructions_set_0[INSTRUCTION_INDEX(ARMPROC.instruction)](); - } - else - c += arm_instructions_set_1[INSTRUCTION_INDEX(ARMPROC.instruction)](); - } -#ifdef GDB_STUB - if ( ARMPROC.post_ex_fn != NULL) { - /* call the external post execute function */ - ARMPROC.post_ex_fn( ARMPROC.post_ex_fn_data, - ARMPROC.instruct_adr, 0); - } -#else - c += armcpu_prefetch(); -#endif - return c; - } - - if(PROCNUM==0) - c += thumb_instructions_set_0[ARMPROC.instruction>>6](); - else - c += thumb_instructions_set_1[ARMPROC.instruction>>6](); - -#ifdef GDB_STUB - if ( ARMPROC.post_ex_fn != NULL) { - /* call the external post execute function */ - ARMPROC.post_ex_fn( ARMPROC.post_ex_fn_data, ARMPROC.instruct_adr, 1); - } -#else - c += armcpu_prefetch(); -#endif - return c; -} - -//these templates needed to be instantiated manually -template u32 armcpu_exec<0>(); -template u32 armcpu_exec<1>(); +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include +#include "types.h" +#include "arm_instructions.h" +#include "thumb_instructions.h" +#include "cp15.h" +#include "bios.h" +#include "debug.h" +#include "Disassembler.h" + + +template static u32 armcpu_prefetch(); + +inline u32 armcpu_prefetch(armcpu_t *armcpu) { + if(armcpu->proc_ID==0) return armcpu_prefetch<0>(); + else return armcpu_prefetch<1>(); +} + +const unsigned char arm_cond_table[16*16] = { + /* N=0, Z=0, C=0, V=0 */ + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0xFF,0x00,0xFF,0x00,0xFF,0x20, + /* N=0, Z=0, C=0, V=1 */ + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, + /* N=0, Z=0, C=1, V=0 */ + 0x00,0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x20, + /* N=0, Z=0, C=1, V=1 */ + 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x00, + 0xFF,0x00,0x00,0xFF,0x00,0xFF,0xFF,0x20, + /* N=0, Z=1, C=0, V=0 */ + 0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20, + /* N=0, Z=1, C=0, V=1 */ + 0xFF,0x00,0x00,0xFF,0x00,0xFF,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, + /* N=0, Z=1, C=1, V=0 */ + 0xFF,0x00,0xFF,0x00,0x00,0xFF,0x00,0xFF, + 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20, + /* N=0, Z=1, C=1, V=1 */ + 0xFF,0x00,0xFF,0x00,0x00,0xFF,0xFF,0x00, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, + /* N=1, Z=0, C=0, V=0 */ + 0x00,0xFF,0x00,0xFF,0xFF,0x00,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, + /* N=1, Z=0, C=0, V=1 */ + 0x00,0xFF,0x00,0xFF,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0xFF,0x00,0xFF,0x00,0xFF,0x20, + /* N=1, Z=0, C=1, V=0 */ + 0x00,0xFF,0xFF,0x00,0xFF,0x00,0x00,0xFF, + 0xFF,0x00,0x00,0xFF,0x00,0xFF,0xFF,0x20, + /* N=1, Z=0, C=1, V=1 */ + 0x00,0xFF,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x20, + /* N=1, Z=1, C=0, V=0 */ + 0xFF,0x00,0x00,0xFF,0xFF,0x00,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, + /* N=1, Z=1, C=0, V=1 */ + 0xFF,0x00,0x00,0xFF,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20, + /* N=1, Z=1, C=1, V=0 */ + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0x00,0xFF, + 0x00,0xFF,0x00,0xFF,0x00,0xFF,0xFF,0x20, + /* N=1, Z=1, C=1, V=1 */ + 0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00, + 0x00,0xFF,0xFF,0x00,0x00,0xFF,0xFF,0x20, +}; + +armcpu_t NDS_ARM7; +armcpu_t NDS_ARM9; + +#define SWAP(a, b, c) do \ + { \ + c=a; \ + a=b; \ + b=c; \ + } \ + while(0) + +#ifdef GDB_STUB + +#define STALLED_CYCLE_COUNT 10 + +static void +stall_cpu( void *instance) { + armcpu_t *armcpu = (armcpu_t *)instance; + + armcpu->stalled = 1; +} + +static void +unstall_cpu( void *instance) { + armcpu_t *armcpu = (armcpu_t *)instance; + + armcpu->stalled = 0; +} + +static void +install_post_exec_fn( void *instance, + void (*ex_fn)( void *, u32 adr, int thumb), + void *fn_data) { + armcpu_t *armcpu = (armcpu_t *)instance; + + armcpu->post_ex_fn = ex_fn; + armcpu->post_ex_fn_data = fn_data; +} + +static void +remove_post_exec_fn( void *instance) { + armcpu_t *armcpu = (armcpu_t *)instance; + + armcpu->post_ex_fn = NULL; +} +#endif + +#ifdef GDB_STUB +static u32 +read_cpu_reg( void *instance, u32 reg_num) { + armcpu_t *armcpu = (armcpu_t *)instance; + u32 reg_value = 0; + + if ( reg_num <= 14) { + reg_value = armcpu->R[reg_num]; + } + else if ( reg_num == 15) { + reg_value = armcpu->next_instruction; + } + else if ( reg_num == 16) { + /* CPSR */ + reg_value = armcpu->CPSR.val; + } + + return reg_value; +} + +static void +set_cpu_reg( void *instance, u32 reg_num, u32 value) { + armcpu_t *armcpu = (armcpu_t *)instance; + + if ( reg_num <= 14) { + armcpu->R[reg_num] = value; + } + else if ( reg_num == 15) { + armcpu->next_instruction = value; + } + else if ( reg_num == 16) { + /* FIXME: setting the CPSR */ + } +} +#endif + +#ifdef GDB_STUB +int armcpu_new( armcpu_t *armcpu, u32 id, + struct armcpu_memory_iface *mem_if, + struct armcpu_ctrl_iface **ctrl_iface_ret) +#else +int armcpu_new( armcpu_t *armcpu, u32 id) +#endif +{ + armcpu->proc_ID = id; + +#ifdef GDB_STUB + armcpu->mem_if = mem_if; + + /* populate the control interface */ + armcpu->ctrl_iface.stall = stall_cpu; + armcpu->ctrl_iface.unstall = unstall_cpu; + armcpu->ctrl_iface.read_reg = read_cpu_reg; + armcpu->ctrl_iface.set_reg = set_cpu_reg; + armcpu->ctrl_iface.install_post_ex_fn = install_post_exec_fn; + armcpu->ctrl_iface.remove_post_ex_fn = remove_post_exec_fn; + armcpu->ctrl_iface.data = armcpu; + + *ctrl_iface_ret = &armcpu->ctrl_iface; + + armcpu->stalled = 0; + armcpu->post_ex_fn = NULL; +#endif + + armcpu_init(armcpu, 0); + + return 0; +} + +void armcpu_init(armcpu_t *armcpu, u32 adr) +{ + u32 i; + + armcpu->LDTBit = (armcpu->proc_ID==0); //Si ARM9 utiliser le syte v5 pour le load + armcpu->intVector = 0xFFFF0000 * (armcpu->proc_ID==0); + armcpu->waitIRQ = FALSE; + armcpu->wirq = FALSE; + + armcpu->newIrqFlags = 0; + +#ifdef GDB_STUB + armcpu->irq_flag = 0; +#endif + + if(armcpu->coproc[15]) free(armcpu->coproc[15]); + + for(i = 0; i < 15; ++i) + { + armcpu->R[i] = 0; + armcpu->coproc[i] = NULL; + } + + armcpu->CPSR.val = armcpu->SPSR.val = SYS; + + armcpu->R13_usr = armcpu->R14_usr = 0; + armcpu->R13_svc = armcpu->R14_svc = 0; + armcpu->R13_abt = armcpu->R14_abt = 0; + armcpu->R13_und = armcpu->R14_und = 0; + armcpu->R13_irq = armcpu->R14_irq = 0; + armcpu->R8_fiq = armcpu->R9_fiq = armcpu->R10_fiq = armcpu->R11_fiq = armcpu->R12_fiq = armcpu->R13_fiq = armcpu->R14_fiq = 0; + + armcpu->SPSR_svc.val = armcpu->SPSR_abt.val = armcpu->SPSR_und.val = armcpu->SPSR_irq.val = armcpu->SPSR_fiq.val = 0; + +#ifdef GDB_STUB + armcpu->instruct_adr = adr; + armcpu->R[15] = adr + 8; +#else + armcpu->R[15] = adr; +#endif + + armcpu->next_instruction = adr; + + armcpu->coproc[15] = (armcp_t*)armcp15_new(armcpu); + +#ifndef GDB_STUB + armcpu_prefetch(armcpu); +#endif +} + +u32 armcpu_switchMode(armcpu_t *armcpu, u8 mode) +{ + u32 oldmode = armcpu->CPSR.bits.mode; + + switch(oldmode) + { + case USR : + case SYS : + armcpu->R13_usr = armcpu->R[13]; + armcpu->R14_usr = armcpu->R[14]; + break; + + case FIQ : + { + u32 tmp; + SWAP(armcpu->R[8], armcpu->R8_fiq, tmp); + SWAP(armcpu->R[9], armcpu->R9_fiq, tmp); + SWAP(armcpu->R[10], armcpu->R10_fiq, tmp); + SWAP(armcpu->R[11], armcpu->R11_fiq, tmp); + SWAP(armcpu->R[12], armcpu->R12_fiq, tmp); + armcpu->R13_fiq = armcpu->R[13]; + armcpu->R14_fiq = armcpu->R[14]; + armcpu->SPSR_fiq = armcpu->SPSR; + break; + } + case IRQ : + armcpu->R13_irq = armcpu->R[13]; + armcpu->R14_irq = armcpu->R[14]; + armcpu->SPSR_irq = armcpu->SPSR; + break; + + case SVC : + armcpu->R13_svc = armcpu->R[13]; + armcpu->R14_svc = armcpu->R[14]; + armcpu->SPSR_svc = armcpu->SPSR; + break; + + case ABT : + armcpu->R13_abt = armcpu->R[13]; + armcpu->R14_abt = armcpu->R[14]; + armcpu->SPSR_abt = armcpu->SPSR; + break; + + case UND : + armcpu->R13_und = armcpu->R[13]; + armcpu->R14_und = armcpu->R[14]; + armcpu->SPSR_und = armcpu->SPSR; + break; + default : + break; + } + + switch(mode) + { + case USR : + case SYS : + armcpu->R[13] = armcpu->R13_usr; + armcpu->R[14] = armcpu->R14_usr; + //SPSR = CPSR; + break; + + case FIQ : + { + u32 tmp; + SWAP(armcpu->R[8], armcpu->R8_fiq, tmp); + SWAP(armcpu->R[9], armcpu->R9_fiq, tmp); + SWAP(armcpu->R[10], armcpu->R10_fiq, tmp); + SWAP(armcpu->R[11], armcpu->R11_fiq, tmp); + SWAP(armcpu->R[12], armcpu->R12_fiq, tmp); + armcpu->R[13] = armcpu->R13_fiq; + armcpu->R[14] = armcpu->R14_fiq; + armcpu->SPSR = armcpu->SPSR_fiq; + break; + } + + case IRQ : + armcpu->R[13] = armcpu->R13_irq; + armcpu->R[14] = armcpu->R14_irq; + armcpu->SPSR = armcpu->SPSR_irq; + break; + + case SVC : + armcpu->R[13] = armcpu->R13_svc; + armcpu->R[14] = armcpu->R14_svc; + armcpu->SPSR = armcpu->SPSR_svc; + break; + + case ABT : + armcpu->R[13] = armcpu->R13_abt; + armcpu->R[14] = armcpu->R14_abt; + armcpu->SPSR = armcpu->SPSR_abt; + break; + + case UND : + armcpu->R[13] = armcpu->R13_und; + armcpu->R[14] = armcpu->R14_und; + armcpu->SPSR = armcpu->SPSR_und; + break; + + default : + break; + } + + armcpu->CPSR.bits.mode = mode & 0x1F; + return oldmode; +} + +template +static u32 +armcpu_prefetch() +{ + armcpu_t* const armcpu = &ARMPROC; +#ifdef GDB_STUB + u32 temp_instruction; +#endif + + if(armcpu->CPSR.bits.T == 0) + { +#ifdef GDB_STUB + temp_instruction = + armcpu->mem_if->prefetch32( armcpu->mem_if->data, + armcpu->next_instruction); + + if ( !armcpu->stalled) { + armcpu->instruction = temp_instruction; + armcpu->instruct_adr = armcpu->next_instruction; + armcpu->next_instruction += 4; + armcpu->R[15] = armcpu->next_instruction + 4; + } +#else + armcpu->instruction = MMU_read32_acl(PROCNUM, armcpu->next_instruction&0xFFFFFFFC,CP15_ACCESS_EXECUTE); + + armcpu->instruct_adr = armcpu->next_instruction; + armcpu->next_instruction += 4; + armcpu->R[15] = armcpu->next_instruction + 4; +#endif + + return MMU.MMU_WAIT32[PROCNUM][(armcpu->instruct_adr>>24)&0xF]; + } + +#ifdef GDB_STUB + temp_instruction = + armcpu->mem_if->prefetch16( armcpu->mem_if->data, + armcpu->next_instruction); + + if ( !armcpu->stalled) { + armcpu->instruction = temp_instruction; + armcpu->instruct_adr = armcpu->next_instruction; + armcpu->next_instruction = armcpu->next_instruction + 2; + armcpu->R[15] = armcpu->next_instruction + 2; + } +#else + armcpu->instruction = MMU_read16_acl(PROCNUM, armcpu->next_instruction&0xFFFFFFFE,CP15_ACCESS_EXECUTE); + + armcpu->instruct_adr = armcpu->next_instruction; + armcpu->next_instruction += 2; + armcpu->R[15] = armcpu->next_instruction + 2; +#endif + + return MMU.MMU_WAIT16[PROCNUM][(armcpu->instruct_adr>>24)&0xF]; +} + +#if 0 /* not used */ +static BOOL FASTCALL test_EQ(Status_Reg CPSR) { return ( CPSR.bits.Z); } +static BOOL FASTCALL test_NE(Status_Reg CPSR) { return (!CPSR.bits.Z); } +static BOOL FASTCALL test_CS(Status_Reg CPSR) { return ( CPSR.bits.C); } +static BOOL FASTCALL test_CC(Status_Reg CPSR) { return (!CPSR.bits.C); } +static BOOL FASTCALL test_MI(Status_Reg CPSR) { return ( CPSR.bits.N); } +static BOOL FASTCALL test_PL(Status_Reg CPSR) { return (!CPSR.bits.N); } +static BOOL FASTCALL test_VS(Status_Reg CPSR) { return ( CPSR.bits.V); } +static BOOL FASTCALL test_VC(Status_Reg CPSR) { return (!CPSR.bits.V); } +static BOOL FASTCALL test_HI(Status_Reg CPSR) { return (CPSR.bits.C) && (!CPSR.bits.Z); } +static BOOL FASTCALL test_LS(Status_Reg CPSR) { return (CPSR.bits.Z) || (!CPSR.bits.C); } +static BOOL FASTCALL test_GE(Status_Reg CPSR) { return (CPSR.bits.N==CPSR.bits.V); } +static BOOL FASTCALL test_LT(Status_Reg CPSR) { return (CPSR.bits.N!=CPSR.bits.V); } +static BOOL FASTCALL test_GT(Status_Reg CPSR) { return (!CPSR.bits.Z) && (CPSR.bits.N==CPSR.bits.V); } +static BOOL FASTCALL test_LE(Status_Reg CPSR) { return ( CPSR.bits.Z) || (CPSR.bits.N!=CPSR.bits.V); } +static BOOL FASTCALL test_AL(Status_Reg CPSR) { return 1; } + +static BOOL (FASTCALL* test_conditions[])(Status_Reg CPSR)= { + test_EQ , test_NE , + test_CS , test_CC , + test_MI , test_PL , + test_VS , test_VC , + test_HI , test_LS , + test_GE , test_LT , + test_GT , test_LE , + test_AL +}; +#define TEST_COND2(cond, CPSR) \ + (cond<15&&test_conditions[cond](CPSR)) +#endif + + +BOOL armcpu_irqException(armcpu_t *armcpu) +{ + Status_Reg tmp; + + if(armcpu->CPSR.bits.I) return FALSE; + +#ifdef GDB_STUB + armcpu->irq_flag = 0; +#endif + + tmp = armcpu->CPSR; + armcpu_switchMode(armcpu, IRQ); + +#ifdef GDB_STUB + armcpu->R[14] = armcpu->next_instruction + 4; +#else + armcpu->R[14] = armcpu->instruct_adr + 4; +#endif + armcpu->SPSR = tmp; + armcpu->CPSR.bits.T = 0; + armcpu->CPSR.bits.I = 1; + armcpu->next_instruction = armcpu->intVector + 0x18; + armcpu->waitIRQ = 0; + +#ifndef GDB_STUB + armcpu->R[15] = armcpu->next_instruction + 8; + armcpu_prefetch(armcpu); +#endif + + return TRUE; +} + +BOOL +armcpu_flagIrq( armcpu_t *armcpu) { + if(armcpu->CPSR.bits.I) return FALSE; + + armcpu->waitIRQ = 0; + +#ifdef GDB_STUB + armcpu->irq_flag = 1; +#endif + + return TRUE; +} + + +template +u32 armcpu_exec() +{ + u32 c = 1; + + //this assert is annoying. but sometimes it is handy. + //assert(ARMPROC.instruct_adr!=0x00000000); + +#ifdef GDB_STUB + if (ARMPROC.stalled) + return STALLED_CYCLE_COUNT; + + /* check for interrupts */ + if ( ARMPROC.irq_flag) { + armcpu_irqException( &ARMPROC); + } + + c = armcpu_prefetch(&ARMPROC); + + if ( ARMPROC.stalled) { + return c; + } +#endif + + if(ARMPROC.CPSR.bits.T == 0) + { + if((TEST_COND(CONDITION(ARMPROC.instruction), CODE(ARMPROC.instruction), ARMPROC.CPSR))) + { + if(PROCNUM==0) { +#ifdef WANTASMLISTING + char txt[128]; + des_arm_instructions_set[INSTRUCTION_INDEX(ARMPROC.instruction)](ARMPROC.instruct_adr,ARMPROC.instruction,txt); + printf("%X: %X - %s\n", ARMPROC.instruct_adr,ARMPROC.instruction, txt); +#endif + c += arm_instructions_set_0[INSTRUCTION_INDEX(ARMPROC.instruction)](); + } + else + c += arm_instructions_set_1[INSTRUCTION_INDEX(ARMPROC.instruction)](); + } +#ifdef GDB_STUB + if ( ARMPROC.post_ex_fn != NULL) { + /* call the external post execute function */ + ARMPROC.post_ex_fn( ARMPROC.post_ex_fn_data, + ARMPROC.instruct_adr, 0); + } +#else + c += armcpu_prefetch(); +#endif + return c; + } + + if(PROCNUM==0) + c += thumb_instructions_set_0[ARMPROC.instruction>>6](); + else + c += thumb_instructions_set_1[ARMPROC.instruction>>6](); + +#ifdef GDB_STUB + if ( ARMPROC.post_ex_fn != NULL) { + /* call the external post execute function */ + ARMPROC.post_ex_fn( ARMPROC.post_ex_fn_data, ARMPROC.instruct_adr, 1); + } +#else + c += armcpu_prefetch(); +#endif + return c; +} + +//these templates needed to be instantiated manually +template u32 armcpu_exec<0>(); +template u32 armcpu_exec<1>(); diff --git a/desmume/src/armcpu.h b/src/armcpu.h similarity index 87% rename from desmume/src/armcpu.h rename to src/armcpu.h index 420f453f4..39390a8aa 100644 --- a/desmume/src/armcpu.h +++ b/src/armcpu.h @@ -1,278 +1,280 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef ARM_CPU -#define ARM_CPU - -#include "types.h" -#include "bits.h" -#include "MMU.h" - -#define CODE(i) (((i)>>25)&0x7) -#define OPCODE(i) (((i)>>21)&0xF) -#define SIGNEBIT(i) BIT_N(i,20) - -#define INSTRUCTION_INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF)) - -inline u32 ROR(u32 i, u32 j) { return ((((u32)(i))>>(j)) | (((u32)(i))<<(32-(j)))); } - -template -inline T UNSIGNED_OVERFLOW(T a,T b,T c) { return ((BIT31(a)&BIT31(b)) | - ((BIT31(a)|BIT31(b))&BIT31(~c))); } - -template -inline T UNSIGNED_UNDERFLOW(T a,T b,T c) { return ((BIT31(~a)&BIT31(b)) | - ((BIT31(~a)|BIT31(b))&BIT31(c))); } - -template -inline T SIGNED_OVERFLOW(T a,T b,T c) { return ((BIT31(a)&BIT31(b)&BIT31(~c))| - (BIT31(~a)&BIT31(~(b))&BIT31(c))); } - -template -inline T SIGNED_UNDERFLOW(T a,T b,T c) { return ((BIT31(a)&BIT31(~(b))&BIT31(~c))| - (BIT31(~a)&BIT31(b)&BIT31(c))); } - -//zero 15-feb-2009 - these werent getting used and they were getting in my way -//#define EQ 0x0 -//#define NE 0x1 -//#define CS 0x2 -//#define CC 0x3 -//#define MI 0x4 -//#define PL 0x5 -//#define VS 0x6 -//#define VC 0x7 -//#define HI 0x8 -//#define LS 0x9 -//#define GE 0xA -//#define LT 0xB -//#define GT 0xC -//#define LE 0xD -//#define AL 0xE - -extern const unsigned char arm_cond_table[16*16]; - -#define TEST_COND(cond, inst, CPSR) ((arm_cond_table[((CPSR.val >> 24) & 0xf0)+(cond)] >> (inst)) & 1) - - -enum Mode -{ - USR = 0x10, - FIQ = 0x11, - IRQ = 0x12, - SVC = 0x13, - ABT = 0x17, - UND = 0x1B, - SYS = 0x1F -}; - -#ifdef WORDS_BIGENDIAN -typedef union -{ - struct - { - u32 N : 1, - Z : 1, - C : 1, - V : 1, - Q : 1, - RAZ : 19, - I : 1, - F : 1, - T : 1, - mode : 5; - } bits; - u32 val; -} Status_Reg; -#else -typedef union -{ - struct - { - u32 mode : 5, - T : 1, - F : 1, - I : 1, - RAZ : 19, - Q : 1, - V : 1, - C : 1, - Z : 1, - N : 1; - } bits; - u32 val; -} Status_Reg; -#endif - -/** - * The control interface to a CPU - */ -struct armcpu_ctrl_iface { - /** stall the processor */ - void (*stall)( void *instance); - - /** unstall the processor */ - void (*unstall)( void *instance); - - /** read a register value */ - u32 (*read_reg)( void *instance, u32 reg_num); - - /** set a register value */ - void (*set_reg)( void *instance, u32 reg_num, u32 value); - - /** install the post execute function */ - void (*install_post_ex_fn)( void *instance, - void (*fn)( void *, u32 adr, int thumb), - void *fn_data); - - /** remove the post execute function */ - void (*remove_post_ex_fn)( void *instance); - - /** the private data passed to all interface functions */ - void *data; -}; - - -typedef void* armcp_t; - -typedef struct armcpu_t -{ - u32 proc_ID; - u32 instruction; //4 - u32 instruct_adr; //8 - u32 next_instruction; //12 - - u32 R[16]; //16 - Status_Reg CPSR; //80 - Status_Reg SPSR; - - u32 R13_usr, R14_usr; - u32 R13_svc, R14_svc; - u32 R13_abt, R14_abt; - u32 R13_und, R14_und; - u32 R13_irq, R14_irq; - u32 R8_fiq, R9_fiq, R10_fiq, R11_fiq, R12_fiq, R13_fiq, R14_fiq; - Status_Reg SPSR_svc, SPSR_abt, SPSR_und, SPSR_irq, SPSR_fiq; - - armcp_t *coproc[16]; - - u32 intVector; - u8 LDTBit; //1 : ARMv5 style 0 : non ARMv5 - BOOL waitIRQ; - BOOL wIRQ; - BOOL wirq; - - u32 newIrqFlags; - - u32 (* *swi_tab)(); - -#ifdef GDB_STUB - /** there is a pending irq for the cpu */ - int irq_flag; - - /** the post executed function (if installed) */ - void (*post_ex_fn)( void *, u32 adr, int thumb); - - /** data for the post executed function */ - void *post_ex_fn_data; - - - /** flag indicating if the processor is stalled */ - int stalled; - - /** the memory interface */ - struct armcpu_memory_iface *mem_if; - - /** the ctrl interface */ - struct armcpu_ctrl_iface ctrl_iface; -#endif -} armcpu_t; - -#ifdef GDB_STUB -int armcpu_new( armcpu_t *armcpu, u32 id, struct armcpu_memory_iface *mem_if, - struct armcpu_ctrl_iface **ctrl_iface_ret); -#else -int armcpu_new( armcpu_t *armcpu, u32 id); -#endif -void armcpu_init(armcpu_t *armcpu, u32 adr); -u32 armcpu_switchMode(armcpu_t *armcpu, u8 mode); - - -template u32 armcpu_exec(); - -BOOL armcpu_irqException(armcpu_t *armcpu); -BOOL armcpu_flagIrq( armcpu_t *armcpu); - -extern armcpu_t NDS_ARM7; -extern armcpu_t NDS_ARM9; - - -static INLINE void setIF(int PROCNUM, u32 flag) -{ - MMU.reg_IF[PROCNUM] |= flag; - - if(ARMPROC.waitIRQ) - ARMPROC.newIrqFlags |= flag; - extern void NDS_Reschedule(); - NDS_Reschedule(); -} - -static INLINE void NDS_makeARM9Int(u32 num) -{ - /* flag the interrupt request source */ - // MMU.reg_IF[0] |= (1<>25)&0x7) +#define OPCODE(i) (((i)>>21)&0xF) +#define SIGNEBIT(i) BIT_N(i,20) + +#define INSTRUCTION_INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF)) + +inline u32 ROR(u32 i, u32 j) { return ((((u32)(i))>>(j)) | (((u32)(i))<<(32-(j)))); } + +template +inline T UNSIGNED_OVERFLOW(T a,T b,T c) { return ((BIT31(a)&BIT31(b)) | + ((BIT31(a)|BIT31(b))&BIT31(~c))); } + +template +inline T UNSIGNED_UNDERFLOW(T a,T b,T c) { return ((BIT31(~a)&BIT31(b)) | + ((BIT31(~a)|BIT31(b))&BIT31(c))); } + +template +inline T SIGNED_OVERFLOW(T a,T b,T c) { return ((BIT31(a)&BIT31(b)&BIT31(~c))| + (BIT31(~a)&BIT31(~(b))&BIT31(c))); } + +template +inline T SIGNED_UNDERFLOW(T a,T b,T c) { return ((BIT31(a)&BIT31(~(b))&BIT31(~c))| + (BIT31(~a)&BIT31(b)&BIT31(c))); } + +//zero 15-feb-2009 - these werent getting used and they were getting in my way +//#define EQ 0x0 +//#define NE 0x1 +//#define CS 0x2 +//#define CC 0x3 +//#define MI 0x4 +//#define PL 0x5 +//#define VS 0x6 +//#define VC 0x7 +//#define HI 0x8 +//#define LS 0x9 +//#define GE 0xA +//#define LT 0xB +//#define GT 0xC +//#define LE 0xD +//#define AL 0xE + +extern const unsigned char arm_cond_table[16*16]; + +#define TEST_COND(cond, inst, CPSR) ((arm_cond_table[((CPSR.val >> 24) & 0xf0)+(cond)] >> (inst)) & 1) + + +enum Mode +{ + USR = 0x10, + FIQ = 0x11, + IRQ = 0x12, + SVC = 0x13, + ABT = 0x17, + UND = 0x1B, + SYS = 0x1F +}; + +#ifdef WORDS_BIGENDIAN +typedef union +{ + struct + { + u32 N : 1, + Z : 1, + C : 1, + V : 1, + Q : 1, + RAZ : 19, + I : 1, + F : 1, + T : 1, + mode : 5; + } bits; + u32 val; +} Status_Reg; +#else +typedef union +{ + struct + { + u32 mode : 5, + T : 1, + F : 1, + I : 1, + RAZ : 19, + Q : 1, + V : 1, + C : 1, + Z : 1, + N : 1; + } bits; + u32 val; +} Status_Reg; +#endif + +/** + * The control interface to a CPU + */ +struct armcpu_ctrl_iface { + /** stall the processor */ + void (*stall)( void *instance); + + /** unstall the processor */ + void (*unstall)( void *instance); + + /** read a register value */ + u32 (*read_reg)( void *instance, u32 reg_num); + + /** set a register value */ + void (*set_reg)( void *instance, u32 reg_num, u32 value); + + /** install the post execute function */ + void (*install_post_ex_fn)( void *instance, + void (*fn)( void *, u32 adr, int thumb), + void *fn_data); + + /** remove the post execute function */ + void (*remove_post_ex_fn)( void *instance); + + /** the private data passed to all interface functions */ + void *data; +}; + + +typedef void* armcp_t; + +typedef struct armcpu_t +{ + u32 proc_ID; + u32 instruction; //4 + u32 instruct_adr; //8 + u32 next_instruction; //12 + + u32 R[16]; //16 + Status_Reg CPSR; //80 + Status_Reg SPSR; + + u32 R13_usr, R14_usr; + u32 R13_svc, R14_svc; + u32 R13_abt, R14_abt; + u32 R13_und, R14_und; + u32 R13_irq, R14_irq; + u32 R8_fiq, R9_fiq, R10_fiq, R11_fiq, R12_fiq, R13_fiq, R14_fiq; + Status_Reg SPSR_svc, SPSR_abt, SPSR_und, SPSR_irq, SPSR_fiq; + + armcp_t *coproc[16]; + + u32 intVector; + u8 LDTBit; //1 : ARMv5 style 0 : non ARMv5 + BOOL waitIRQ; + BOOL wIRQ; + BOOL wirq; + + u32 newIrqFlags; + + u32 (* *swi_tab)(); + +#ifdef GDB_STUB + /** there is a pending irq for the cpu */ + int irq_flag; + + /** the post executed function (if installed) */ + void (*post_ex_fn)( void *, u32 adr, int thumb); + + /** data for the post executed function */ + void *post_ex_fn_data; + + + /** flag indicating if the processor is stalled */ + int stalled; + + /** the memory interface */ + struct armcpu_memory_iface *mem_if; + + /** the ctrl interface */ + struct armcpu_ctrl_iface ctrl_iface; +#endif +} armcpu_t; + +#ifdef GDB_STUB +int armcpu_new( armcpu_t *armcpu, u32 id, struct armcpu_memory_iface *mem_if, + struct armcpu_ctrl_iface **ctrl_iface_ret); +#else +int armcpu_new( armcpu_t *armcpu, u32 id); +#endif +void armcpu_init(armcpu_t *armcpu, u32 adr); +u32 armcpu_switchMode(armcpu_t *armcpu, u8 mode); + + +template u32 armcpu_exec(); + +BOOL armcpu_irqException(armcpu_t *armcpu); +BOOL armcpu_flagIrq( armcpu_t *armcpu); + +extern armcpu_t NDS_ARM7; +extern armcpu_t NDS_ARM9; + + +static INLINE void setIF(int PROCNUM, u32 flag) +{ + MMU.reg_IF[PROCNUM] |= flag; + + if(ARMPROC.waitIRQ) + ARMPROC.newIrqFlags |= flag; +} + +static INLINE void NDS_makeARM9Int(u32 num) +{ + /* flag the interrupt request source */ + // MMU.reg_IF[0] |= (1< -#include "MMU.h" -#include "SPU.h" -#include "debug.h" - -#define cpu (&ARMPROC) -#define TEMPLATE template - -extern BOOL execute; - -static const u16 getsinetbl[] = { -0x0000, 0x0324, 0x0648, 0x096A, 0x0C8C, 0x0FAB, 0x12C8, 0x15E2, -0x18F9, 0x1C0B, 0x1F1A, 0x2223, 0x2528, 0x2826, 0x2B1F, 0x2E11, -0x30FB, 0x33DF, 0x36BA, 0x398C, 0x3C56, 0x3F17, 0x41CE, 0x447A, -0x471C, 0x49B4, 0x4C3F, 0x4EBF, 0x5133, 0x539B, 0x55F5, 0x5842, -0x5A82, 0x5CB3, 0x5ED7, 0x60EB, 0x62F1, 0x64E8, 0x66CF, 0x68A6, -0x6A6D, 0x6C23, 0x6DC9, 0x6F5E, 0x70E2, 0x7254, 0x73B5, 0x7504, -0x7641, 0x776B, 0x7884, 0x7989, 0x7A7C, 0x7B5C, 0x7C29, 0x7CE3, -0x7D89, 0x7E1D, 0x7E9C, 0x7F09, 0x7F61, 0x7FA6, 0x7FD8, 0x7FF5 -}; - -static const u16 getpitchtbl[] = { -0x0000, 0x003B, 0x0076, 0x00B2, 0x00ED, 0x0128, 0x0164, 0x019F, -0x01DB, 0x0217, 0x0252, 0x028E, 0x02CA, 0x0305, 0x0341, 0x037D, -0x03B9, 0x03F5, 0x0431, 0x046E, 0x04AA, 0x04E6, 0x0522, 0x055F, -0x059B, 0x05D8, 0x0614, 0x0651, 0x068D, 0x06CA, 0x0707, 0x0743, -0x0780, 0x07BD, 0x07FA, 0x0837, 0x0874, 0x08B1, 0x08EF, 0x092C, -0x0969, 0x09A7, 0x09E4, 0x0A21, 0x0A5F, 0x0A9C, 0x0ADA, 0x0B18, -0x0B56, 0x0B93, 0x0BD1, 0x0C0F, 0x0C4D, 0x0C8B, 0x0CC9, 0x0D07, -0x0D45, 0x0D84, 0x0DC2, 0x0E00, 0x0E3F, 0x0E7D, 0x0EBC, 0x0EFA, -0x0F39, 0x0F78, 0x0FB6, 0x0FF5, 0x1034, 0x1073, 0x10B2, 0x10F1, -0x1130, 0x116F, 0x11AE, 0x11EE, 0x122D, 0x126C, 0x12AC, 0x12EB, -0x132B, 0x136B, 0x13AA, 0x13EA, 0x142A, 0x146A, 0x14A9, 0x14E9, -0x1529, 0x1569, 0x15AA, 0x15EA, 0x162A, 0x166A, 0x16AB, 0x16EB, -0x172C, 0x176C, 0x17AD, 0x17ED, 0x182E, 0x186F, 0x18B0, 0x18F0, -0x1931, 0x1972, 0x19B3, 0x19F5, 0x1A36, 0x1A77, 0x1AB8, 0x1AFA, -0x1B3B, 0x1B7D, 0x1BBE, 0x1C00, 0x1C41, 0x1C83, 0x1CC5, 0x1D07, -0x1D48, 0x1D8A, 0x1DCC, 0x1E0E, 0x1E51, 0x1E93, 0x1ED5, 0x1F17, -0x1F5A, 0x1F9C, 0x1FDF, 0x2021, 0x2064, 0x20A6, 0x20E9, 0x212C, -0x216F, 0x21B2, 0x21F5, 0x2238, 0x227B, 0x22BE, 0x2301, 0x2344, -0x2388, 0x23CB, 0x240E, 0x2452, 0x2496, 0x24D9, 0x251D, 0x2561, -0x25A4, 0x25E8, 0x262C, 0x2670, 0x26B4, 0x26F8, 0x273D, 0x2781, -0x27C5, 0x280A, 0x284E, 0x2892, 0x28D7, 0x291C, 0x2960, 0x29A5, -0x29EA, 0x2A2F, 0x2A74, 0x2AB9, 0x2AFE, 0x2B43, 0x2B88, 0x2BCD, -0x2C13, 0x2C58, 0x2C9D, 0x2CE3, 0x2D28, 0x2D6E, 0x2DB4, 0x2DF9, -0x2E3F, 0x2E85, 0x2ECB, 0x2F11, 0x2F57, 0x2F9D, 0x2FE3, 0x302A, -0x3070, 0x30B6, 0x30FD, 0x3143, 0x318A, 0x31D0, 0x3217, 0x325E, -0x32A5, 0x32EC, 0x3332, 0x3379, 0x33C1, 0x3408, 0x344F, 0x3496, -0x34DD, 0x3525, 0x356C, 0x35B4, 0x35FB, 0x3643, 0x368B, 0x36D3, -0x371A, 0x3762, 0x37AA, 0x37F2, 0x383A, 0x3883, 0x38CB, 0x3913, -0x395C, 0x39A4, 0x39ED, 0x3A35, 0x3A7E, 0x3AC6, 0x3B0F, 0x3B58, -0x3BA1, 0x3BEA, 0x3C33, 0x3C7C, 0x3CC5, 0x3D0E, 0x3D58, 0x3DA1, -0x3DEA, 0x3E34, 0x3E7D, 0x3EC7, 0x3F11, 0x3F5A, 0x3FA4, 0x3FEE, -0x4038, 0x4082, 0x40CC, 0x4116, 0x4161, 0x41AB, 0x41F5, 0x4240, -0x428A, 0x42D5, 0x431F, 0x436A, 0x43B5, 0x4400, 0x444B, 0x4495, -0x44E1, 0x452C, 0x4577, 0x45C2, 0x460D, 0x4659, 0x46A4, 0x46F0, -0x473B, 0x4787, 0x47D3, 0x481E, 0x486A, 0x48B6, 0x4902, 0x494E, -0x499A, 0x49E6, 0x4A33, 0x4A7F, 0x4ACB, 0x4B18, 0x4B64, 0x4BB1, -0x4BFE, 0x4C4A, 0x4C97, 0x4CE4, 0x4D31, 0x4D7E, 0x4DCB, 0x4E18, -0x4E66, 0x4EB3, 0x4F00, 0x4F4E, 0x4F9B, 0x4FE9, 0x5036, 0x5084, -0x50D2, 0x5120, 0x516E, 0x51BC, 0x520A, 0x5258, 0x52A6, 0x52F4, -0x5343, 0x5391, 0x53E0, 0x542E, 0x547D, 0x54CC, 0x551A, 0x5569, -0x55B8, 0x5607, 0x5656, 0x56A5, 0x56F4, 0x5744, 0x5793, 0x57E2, -0x5832, 0x5882, 0x58D1, 0x5921, 0x5971, 0x59C1, 0x5A10, 0x5A60, -0x5AB0, 0x5B01, 0x5B51, 0x5BA1, 0x5BF1, 0x5C42, 0x5C92, 0x5CE3, -0x5D34, 0x5D84, 0x5DD5, 0x5E26, 0x5E77, 0x5EC8, 0x5F19, 0x5F6A, -0x5FBB, 0x600D, 0x605E, 0x60B0, 0x6101, 0x6153, 0x61A4, 0x61F6, -0x6248, 0x629A, 0x62EC, 0x633E, 0x6390, 0x63E2, 0x6434, 0x6487, -0x64D9, 0x652C, 0x657E, 0x65D1, 0x6624, 0x6676, 0x66C9, 0x671C, -0x676F, 0x67C2, 0x6815, 0x6869, 0x68BC, 0x690F, 0x6963, 0x69B6, -0x6A0A, 0x6A5E, 0x6AB1, 0x6B05, 0x6B59, 0x6BAD, 0x6C01, 0x6C55, -0x6CAA, 0x6CFE, 0x6D52, 0x6DA7, 0x6DFB, 0x6E50, 0x6EA4, 0x6EF9, -0x6F4E, 0x6FA3, 0x6FF8, 0x704D, 0x70A2, 0x70F7, 0x714D, 0x71A2, -0x71F7, 0x724D, 0x72A2, 0x72F8, 0x734E, 0x73A4, 0x73FA, 0x7450, -0x74A6, 0x74FC, 0x7552, 0x75A8, 0x75FF, 0x7655, 0x76AC, 0x7702, -0x7759, 0x77B0, 0x7807, 0x785E, 0x78B4, 0x790C, 0x7963, 0x79BA, -0x7A11, 0x7A69, 0x7AC0, 0x7B18, 0x7B6F, 0x7BC7, 0x7C1F, 0x7C77, -0x7CCF, 0x7D27, 0x7D7F, 0x7DD7, 0x7E2F, 0x7E88, 0x7EE0, 0x7F38, -0x7F91, 0x7FEA, 0x8042, 0x809B, 0x80F4, 0x814D, 0x81A6, 0x81FF, -0x8259, 0x82B2, 0x830B, 0x8365, 0x83BE, 0x8418, 0x8472, 0x84CB, -0x8525, 0x857F, 0x85D9, 0x8633, 0x868E, 0x86E8, 0x8742, 0x879D, -0x87F7, 0x8852, 0x88AC, 0x8907, 0x8962, 0x89BD, 0x8A18, 0x8A73, -0x8ACE, 0x8B2A, 0x8B85, 0x8BE0, 0x8C3C, 0x8C97, 0x8CF3, 0x8D4F, -0x8DAB, 0x8E07, 0x8E63, 0x8EBF, 0x8F1B, 0x8F77, 0x8FD4, 0x9030, -0x908C, 0x90E9, 0x9146, 0x91A2, 0x91FF, 0x925C, 0x92B9, 0x9316, -0x9373, 0x93D1, 0x942E, 0x948C, 0x94E9, 0x9547, 0x95A4, 0x9602, -0x9660, 0x96BE, 0x971C, 0x977A, 0x97D8, 0x9836, 0x9895, 0x98F3, -0x9952, 0x99B0, 0x9A0F, 0x9A6E, 0x9ACD, 0x9B2C, 0x9B8B, 0x9BEA, -0x9C49, 0x9CA8, 0x9D08, 0x9D67, 0x9DC7, 0x9E26, 0x9E86, 0x9EE6, -0x9F46, 0x9FA6, 0xA006, 0xA066, 0xA0C6, 0xA127, 0xA187, 0xA1E8, -0xA248, 0xA2A9, 0xA30A, 0xA36B, 0xA3CC, 0xA42D, 0xA48E, 0xA4EF, -0xA550, 0xA5B2, 0xA613, 0xA675, 0xA6D6, 0xA738, 0xA79A, 0xA7FC, -0xA85E, 0xA8C0, 0xA922, 0xA984, 0xA9E7, 0xAA49, 0xAAAC, 0xAB0E, -0xAB71, 0xABD4, 0xAC37, 0xAC9A, 0xACFD, 0xAD60, 0xADC3, 0xAE27, -0xAE8A, 0xAEED, 0xAF51, 0xAFB5, 0xB019, 0xB07C, 0xB0E0, 0xB145, -0xB1A9, 0xB20D, 0xB271, 0xB2D6, 0xB33A, 0xB39F, 0xB403, 0xB468, -0xB4CD, 0xB532, 0xB597, 0xB5FC, 0xB662, 0xB6C7, 0xB72C, 0xB792, -0xB7F7, 0xB85D, 0xB8C3, 0xB929, 0xB98F, 0xB9F5, 0xBA5B, 0xBAC1, -0xBB28, 0xBB8E, 0xBBF5, 0xBC5B, 0xBCC2, 0xBD29, 0xBD90, 0xBDF7, -0xBE5E, 0xBEC5, 0xBF2C, 0xBF94, 0xBFFB, 0xC063, 0xC0CA, 0xC132, -0xC19A, 0xC202, 0xC26A, 0xC2D2, 0xC33A, 0xC3A2, 0xC40B, 0xC473, -0xC4DC, 0xC544, 0xC5AD, 0xC616, 0xC67F, 0xC6E8, 0xC751, 0xC7BB, -0xC824, 0xC88D, 0xC8F7, 0xC960, 0xC9CA, 0xCA34, 0xCA9E, 0xCB08, -0xCB72, 0xCBDC, 0xCC47, 0xCCB1, 0xCD1B, 0xCD86, 0xCDF1, 0xCE5B, -0xCEC6, 0xCF31, 0xCF9C, 0xD008, 0xD073, 0xD0DE, 0xD14A, 0xD1B5, -0xD221, 0xD28D, 0xD2F8, 0xD364, 0xD3D0, 0xD43D, 0xD4A9, 0xD515, -0xD582, 0xD5EE, 0xD65B, 0xD6C7, 0xD734, 0xD7A1, 0xD80E, 0xD87B, -0xD8E9, 0xD956, 0xD9C3, 0xDA31, 0xDA9E, 0xDB0C, 0xDB7A, 0xDBE8, -0xDC56, 0xDCC4, 0xDD32, 0xDDA0, 0xDE0F, 0xDE7D, 0xDEEC, 0xDF5B, -0xDFC9, 0xE038, 0xE0A7, 0xE116, 0xE186, 0xE1F5, 0xE264, 0xE2D4, -0xE343, 0xE3B3, 0xE423, 0xE493, 0xE503, 0xE573, 0xE5E3, 0xE654, -0xE6C4, 0xE735, 0xE7A5, 0xE816, 0xE887, 0xE8F8, 0xE969, 0xE9DA, -0xEA4B, 0xEABC, 0xEB2E, 0xEB9F, 0xEC11, 0xEC83, 0xECF5, 0xED66, -0xEDD9, 0xEE4B, 0xEEBD, 0xEF2F, 0xEFA2, 0xF014, 0xF087, 0xF0FA, -0xF16D, 0xF1E0, 0xF253, 0xF2C6, 0xF339, 0xF3AD, 0xF420, 0xF494, -0xF507, 0xF57B, 0xF5EF, 0xF663, 0xF6D7, 0xF74C, 0xF7C0, 0xF834, -0xF8A9, 0xF91E, 0xF992, 0xFA07, 0xFA7C, 0xFAF1, 0xFB66, 0xFBDC, -0xFC51, 0xFCC7, 0xFD3C, 0xFDB2, 0xFE28, 0xFE9E, 0xFF14, 0xFF8A -}; - -static const u8 getvoltbl[] = { -0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, -0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, -0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, -0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, -0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, -0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, -0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, -0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, -0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, -0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, -0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, -0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, -0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, -0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x10, -0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x14, -0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x18, -0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1A, 0x1B, 0x1B, 0x1B, 0x1C, 0x1C, 0x1C, -0x1D, 0x1D, 0x1D, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, -0x22, 0x23, 0x23, 0x24, 0x24, 0x24, 0x25, 0x25, 0x26, 0x26, 0x27, 0x27, 0x27, 0x28, 0x28, 0x29, -0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2C, 0x2C, 0x2D, 0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, 0x31, 0x31, -0x32, 0x32, 0x33, 0x33, 0x34, 0x35, 0x35, 0x36, 0x36, 0x37, 0x38, 0x38, 0x39, 0x3A, 0x3A, 0x3B, -0x3C, 0x3C, 0x3D, 0x3E, 0x3F, 0x3F, 0x40, 0x41, 0x42, 0x42, 0x43, 0x44, 0x45, 0x45, 0x46, 0x47, -0x48, 0x49, 0x4A, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x52, 0x53, 0x54, 0x55, -0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x67, -0x68, 0x69, 0x6A, 0x6B, 0x6D, 0x6E, 0x6F, 0x71, 0x72, 0x73, 0x75, 0x76, 0x77, 0x79, 0x7A, 0x7B, -0x7D, 0x7E, 0x7F, 0x20, 0x21, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x23, 0x24, 0x24, 0x25, 0x25, -0x26, 0x26, 0x26, 0x27, 0x27, 0x28, 0x28, 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2C, 0x2C, 0x2D, -0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, 0x30, 0x31, 0x31, 0x32, 0x33, 0x33, 0x34, 0x34, 0x35, 0x36, -0x36, 0x37, 0x37, 0x38, 0x39, 0x39, 0x3A, 0x3B, 0x3B, 0x3C, 0x3D, 0x3E, 0x3E, 0x3F, 0x40, 0x40, -0x41, 0x42, 0x43, 0x43, 0x44, 0x45, 0x46, 0x47, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4D, -0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, -0x5E, 0x5F, 0x60, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6F, 0x70, -0x71, 0x73, 0x74, 0x75, 0x77, 0x78, 0x79, 0x7B, 0x7C, 0x7E, 0x7E, 0x40, 0x41, 0x42, 0x43, 0x43, -0x44, 0x45, 0x46, 0x47, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, -0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, -0x62, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6B, 0x6C, 0x6D, 0x6E, 0x70, 0x71, 0x72, 0x74, 0x75, -0x76, 0x78, 0x79, 0x7B, 0x7C, 0x7D, 0x7E, 0x40, 0x41, 0x42, 0x42, 0x43, 0x44, 0x45, 0x46, 0x46, -0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, -0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x65, 0x66, -0x67, 0x68, 0x69, 0x6A, 0x6C, 0x6D, 0x6E, 0x6F, 0x71, 0x72, 0x73, 0x75, 0x76, 0x77, 0x79, 0x7A, -0x7C, 0x7D, 0x7E, 0x7F -}; - -TEMPLATE static u32 bios_nop() -{ - if (cpu->proc_ID == ARMCPU_ARM9) - { - LOG("Unimplemented bios function %02X(ARM9) was used. R0:%08X\n", (cpu->instruction)&0x1F, cpu->R[0]); - } - else - { - LOG("Unimplemented bios function %02X(ARM7) was used. R0:%08X\n", (cpu->instruction)&0x1F, cpu->R[0]); - } - return 3; -} - -TEMPLATE static u32 delayLoop() -{ - return cpu->R[0] * 4; -} - -//u32 oldmode[2]; - -TEMPLATE u32 intrWaitARM() -{ - u32 intrFlagAdr;// = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; - u32 intr; - u32 intrFlag = 0; - - BOOL noDiscard = ((cpu->R[0] == 0) && (PROCNUM == 1)); - - //emu_halt(); - if(cpu->proc_ID) - { - intrFlagAdr = 0x380FFF8; - } else { - intrFlagAdr = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; - } - intr = _MMU_read32(intrFlagAdr); - intrFlag = (cpu->R[1] & intr); - - if(!noDiscard) - intrFlag &= ARMPROC.newIrqFlags; - - if(intrFlag) - { - // si une(ou plusieurs) des interruptions que l'on attend s'est(se sont) produite(s) - // on efface son(les) occurence(s). - intr ^= intrFlag; - cpu->newIrqFlags ^= intrFlag; - _MMU_write32(intrFlagAdr, intr); - //cpu->switchMode(oldmode[cpu->proc_ID]); - return 1; - } - - cpu->R[15] = cpu->instruct_adr; - cpu->next_instruction = cpu->R[15]; - cpu->waitIRQ = 1; - //oldmode[cpu->proc_ID] = cpu->switchMode(SVC); - - return 1; -} - -TEMPLATE static u32 waitVBlankARM() -{ - cpu->R[0] = 1; - cpu->R[1] = 1; - return intrWaitARM(); -#if 0 - u32 intrFlagAdr;// = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; - u32 intr; - u32 intrFlag = 0; - - //emu_halt(); - if(cpu->proc_ID) - { - intrFlagAdr = 0x380FFF8; - } else { - intrFlagAdr = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; - } - intr = _MMU_read32(intrFlagAdr); - intrFlag = 1 & intr; - - // if(intrFlag) - { - // si une(ou plusieurs) des interruptions que l'on attend s'est(se sont) produite(s) - // on efface son(les) occurence(s). - intr ^= intrFlag; - _MMU_write32(intrFlagAdr, intr); - //cpu->switchMode(oldmode[cpu->proc_ID]); - return 1; - } - - cpu->R[15] = cpu->instruct_adr; - cpu->next_instruction = cpu->R[15]; - cpu->waitIRQ = 1; - //oldmode[cpu->proc_ID] = cpu->switchMode(SVC); - - return 1; -#endif -} - -TEMPLATE static u32 wait4IRQ() -{ - //execute= FALSE; - if(cpu->wirq) - { - if(!cpu->waitIRQ) - { - cpu->waitIRQ = 0; - cpu->wirq = 0; - //cpu->switchMode(oldmode[cpu->proc_ID]); - return 1; - } - cpu->R[15] = cpu->instruct_adr; - cpu->next_instruction = cpu->R[15]; - return 1; - } - cpu->waitIRQ = 1; - cpu->wirq = 1; - cpu->R[15] = cpu->instruct_adr; - cpu->next_instruction = cpu->R[15]; - //oldmode[cpu->proc_ID] = cpu->switchMode(SVC); - return 1; -} - -TEMPLATE static u32 sleep() -{ - _MMU_write08(0x04000301, 0xC0); - return 1; -} - -TEMPLATE static u32 divide() -{ - s32 num = (s32)cpu->R[0]; - s32 dnum = (s32)cpu->R[1]; - - if(dnum==0) return 0; - - cpu->R[0] = (u32)(num / dnum); - cpu->R[1] = (u32)(num % dnum); - cpu->R[3] = (u32) (((s32)cpu->R[0])<0 ? -(s32)cpu->R[0] : cpu->R[0]); - - return 6; -} - -TEMPLATE static u32 copy() -{ - u32 src = cpu->R[0]; - u32 dst = cpu->R[1]; - u32 cnt = cpu->R[2]; - - //INFO("swi copy from %08X to %08X, cnt=%08X\n", src, dst, cnt); - - switch(BIT26(cnt)) - { - case 0: - src &= 0xFFFFFFFE; - dst &= 0xFFFFFFFE; - switch(BIT24(cnt)) - { - case 0: - cnt &= 0x1FFFFF; - while(cnt) - { - _MMU_write16(dst, _MMU_read16(src)); - cnt--; - dst+=2; - src+=2; - } - break; - case 1: - { - u32 val = _MMU_read16(src); - cnt &= 0x1FFFFF; - while(cnt) - { - _MMU_write16(dst, val); - cnt--; - dst+=2; - } - } - break; - } - break; - case 1: - src &= 0xFFFFFFFC; - dst &= 0xFFFFFFFC; - switch(BIT24(cnt)) - { - case 0: - cnt &= 0x1FFFFF; - while(cnt) - { - _MMU_write32(dst, _MMU_read32(src)); - cnt--; - dst+=4; - src+=4; - } - break; - case 1: - { - u32 val = _MMU_read32(src); - cnt &= 0x1FFFFF; - while(cnt) - { - _MMU_write32(dst, val); - cnt--; - dst+=4; - } - } - break; - } - break; - } - return 1; -} - -TEMPLATE static u32 fastCopy() -{ - u32 src = cpu->R[0] & 0xFFFFFFFC; - u32 dst = cpu->R[1] & 0xFFFFFFFC; - u32 cnt = cpu->R[2]; - - //INFO("swi fastcopy from %08X to %08X, cnt=%08X\n", src, dst, cnt); - - switch(BIT24(cnt)) - { - case 0: - cnt &= 0x1FFFFF; - while(cnt) - { - _MMU_write32(dst, _MMU_read32(src)); - cnt--; - dst+=4; - src+=4; - } - break; - case 1: - { - u32 val = _MMU_read32(src); - cnt &= 0x1FFFFF; - while(cnt) - { - _MMU_write32(dst, val); - cnt--; - dst+=4; - } - } - break; - } - return 1; -} - -TEMPLATE static u32 LZ77UnCompVram() -{ - int i1, i2; - int byteCount; - int byteShift; - u32 writeValue; - int len; - u32 source = cpu->R[0]; - u32 dest = cpu->R[1]; - u32 header = _MMU_read32(source); - source += 4; - - //INFO("swi lz77uncompvram\n"); - - if(((source & 0xe000000) == 0) || - ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) - return 0; - - byteCount = 0; - byteShift = 0; - writeValue = 0; - - len = header >> 8; - - while(len > 0) { - u8 d = _MMU_read08(source++); - - if(d) { - for(i1 = 0; i1 < 8; i1++) { - if(d & 0x80) { - int length; - int offset; - u32 windowOffset; - u16 data = _MMU_read08(source++) << 8; - data |= _MMU_read08(source++); - length = (data >> 12) + 3; - offset = (data & 0x0FFF); - windowOffset = dest + byteCount - offset - 1; - for(i2 = 0; i2 < length; i2++) { - writeValue |= (_MMU_read08(windowOffset++) << byteShift); - byteShift += 8; - byteCount++; - - if(byteCount == 2) { - _MMU_write16(dest, writeValue); - dest += 2; - byteCount = 0; - byteShift = 0; - writeValue = 0; - } - len--; - if(len == 0) - return 0; - } - } else { - writeValue |= (_MMU_read08(source++) << byteShift); - byteShift += 8; - byteCount++; - if(byteCount == 2) { - _MMU_write16(dest, writeValue); - dest += 2; - byteCount = 0; - byteShift = 0; - writeValue = 0; - } - len--; - if(len == 0) - return 0; - } - d <<= 1; - } - } else { - for(i1 = 0; i1 < 8; i1++) { - writeValue |= (_MMU_read08(source++) << byteShift); - byteShift += 8; - byteCount++; - if(byteCount == 2) { - _MMU_write16(dest, writeValue); - dest += 2; - byteShift = 0; - byteCount = 0; - writeValue = 0; - } - len--; - if(len == 0) - return 0; - } - } - } - return 1; -} - -TEMPLATE static u32 LZ77UnCompWram() -{ - int i1, i2; - int len; - u32 source = cpu->R[0]; - u32 dest = cpu->R[1]; - - u32 header = _MMU_read32(source); - source += 4; - - //INFO("swi lz77uncompwram\n"); - - if(((source & 0xe000000) == 0) || - ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) - return 0; - - len = header >> 8; - - while(len > 0) { - u8 d = _MMU_read08(source++); - - if(d) { - for(i1 = 0; i1 < 8; i1++) { - if(d & 0x80) { - int length; - int offset; - u32 windowOffset; - u16 data = _MMU_read08(source++) << 8; - data |= _MMU_read08(source++); - length = (data >> 12) + 3; - offset = (data & 0x0FFF); - windowOffset = dest - offset - 1; - for(i2 = 0; i2 < length; i2++) { - _MMU_write08(dest++, _MMU_read08(windowOffset++)); - len--; - if(len == 0) - return 0; - } - } else { - _MMU_write08(dest++, _MMU_read08(source++)); - len--; - if(len == 0) - return 0; - } - d <<= 1; - } - } else { - for(i1 = 0; i1 < 8; i1++) { - _MMU_write08(dest++, _MMU_read08(source++)); - len--; - if(len == 0) - return 0; - } - } - } - return 1; -} - -TEMPLATE static u32 RLUnCompVram() -{ - int i; - int len; - int byteCount; - int byteShift; - u32 writeValue; - u32 source = cpu->R[0]; - u32 dest = cpu->R[1]; - - u32 header = _MMU_read32(source); - source += 4; - - //INFO("swi rluncompvram\n"); - - if(((source & 0xe000000) == 0) || - ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) - return 0; - - len = header >> 8; - byteCount = 0; - byteShift = 0; - writeValue = 0; - - while(len > 0) { - u8 d = _MMU_read08(source++); - int l = d & 0x7F; - if(d & 0x80) { - u8 data = _MMU_read08(source++); - l += 3; - for(i = 0;i < l; i++) { - writeValue |= (data << byteShift); - byteShift += 8; - byteCount++; - - if(byteCount == 2) { - _MMU_write16(dest, writeValue); - dest += 2; - byteCount = 0; - byteShift = 0; - writeValue = 0; - } - len--; - if(len == 0) - return 0; - } - } else { - l++; - for(i = 0; i < l; i++) { - writeValue |= (_MMU_read08(source++) << byteShift); - byteShift += 8; - byteCount++; - if(byteCount == 2) { - _MMU_write16(dest, writeValue); - dest += 2; - byteCount = 0; - byteShift = 0; - writeValue = 0; - } - len--; - if(len == 0) - return 0; - } - } - } - return 1; -} - -TEMPLATE static u32 RLUnCompWram() -{ - int i; - int len; - u32 source = cpu->R[0]; - u32 dest = cpu->R[1]; - - u32 header = _MMU_read32(source); - source += 4; - - //INFO("swi rluncompwram\n"); - - if(((source & 0xe000000) == 0) || - ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) - return 0; - - len = header >> 8; - - while(len > 0) { - u8 d = _MMU_read08(source++); - int l = d & 0x7F; - if(d & 0x80) { - u8 data = _MMU_read08(source++); - l += 3; - for(i = 0;i < l; i++) { - _MMU_write08(dest++, data); - len--; - if(len == 0) - return 0; - } - } else { - l++; - for(i = 0; i < l; i++) { - _MMU_write08(dest++, _MMU_read08(source++)); - len--; - if(len == 0) - return 0; - } - } - } - return 1; -} - -TEMPLATE static u32 UnCompHuffman() -{ - u32 source, dest, writeValue, header, treeStart, mask; - u32 data; - u8 treeSize, currentNode, rootNode; - int byteCount, byteShift, len, pos; - int writeData; - - source = cpu->R[0]; - dest = cpu->R[1]; - - header = _MMU_read08(source); - source += 4; - - //INFO("swi uncomphuffman\n"); - - if(((source & 0xe000000) == 0) || - ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) - return 0; - - treeSize = _MMU_read08(source++); - - treeStart = source; - - source += ((treeSize+1)<<1)-1; // minus because we already skipped one byte - - len = header >> 8; - - mask = 0x80000000; - data = _MMU_read08(source); - source += 4; - - pos = 0; - rootNode = _MMU_read08(treeStart); - currentNode = rootNode; - writeData = 0; - byteShift = 0; - byteCount = 0; - writeValue = 0; - - if((header & 0x0F) == 8) { - while(len > 0) { - // take left - if(pos == 0) - pos++; - else - pos += (((currentNode & 0x3F)+1)<<1); - - if(data & mask) { - // right - if(currentNode & 0x40) - writeData = 1; - currentNode = _MMU_read08(treeStart+pos+1); - } else { - // left - if(currentNode & 0x80) - writeData = 1; - currentNode = _MMU_read08(treeStart+pos); - } - - if(writeData) { - writeValue |= (currentNode << byteShift); - byteCount++; - byteShift += 8; - - pos = 0; - currentNode = rootNode; - writeData = 0; - - if(byteCount == 4) { - byteCount = 0; - byteShift = 0; - _MMU_write08(dest, writeValue); - writeValue = 0; - dest += 4; - len -= 4; - } - } - mask >>= 1; - if(mask == 0) { - mask = 0x80000000; - data = _MMU_read08(source); - source += 4; - } - } - } else { - int halfLen = 0; - int value = 0; - while(len > 0) { - // take left - if(pos == 0) - pos++; - else - pos += (((currentNode & 0x3F)+1)<<1); - - if((data & mask)) { - // right - if(currentNode & 0x40) - writeData = 1; - currentNode = _MMU_read08(treeStart+pos+1); - } else { - // left - if(currentNode & 0x80) - writeData = 1; - currentNode = _MMU_read08(treeStart+pos); - } - - if(writeData) { - if(halfLen == 0) - value |= currentNode; - else - value |= (currentNode<<4); - - halfLen += 4; - if(halfLen == 8) { - writeValue |= (value << byteShift); - byteCount++; - byteShift += 8; - - halfLen = 0; - value = 0; - - if(byteCount == 4) { - byteCount = 0; - byteShift = 0; - _MMU_write08(dest, writeValue); - dest += 4; - writeValue = 0; - len -= 4; - } - } - pos = 0; - currentNode = rootNode; - writeData = 0; - } - mask >>= 1; - if(mask == 0) { - mask = 0x80000000; - data = _MMU_read08(source); - source += 4; - } - } - } - return 1; -} - -TEMPLATE static u32 BitUnPack() -{ - u32 source,dest,header,base,d,temp; - int len,bits,revbits,dataSize,data,bitwritecount,mask,bitcount,addBase; - u8 b; - - source = cpu->R[0]; - dest = cpu->R[1]; - header = cpu->R[2]; - - //INFO("swi bitunpack\n"); - - len = _MMU_read16(header); - // check address - bits = _MMU_read08(header+2); - revbits = 8 - bits; - // u32 value = 0; - base = _MMU_read08(header+4); - addBase = (base & 0x80000000) ? 1 : 0; - base &= 0x7fffffff; - dataSize = _MMU_read08(header+3); - - data = 0; - bitwritecount = 0; - while(1) { - len -= 1; - if(len < 0) - break; - mask = 0xff >> revbits; - b = _MMU_read08(source); - source++; - bitcount = 0; - while(1) { - if(bitcount >= 8) - break; - d = b & mask; - temp = d >> bitcount; - if(!temp && addBase) { - temp += base; - } - data |= temp << bitwritecount; - bitwritecount += dataSize; - if(bitwritecount >= 32) { - _MMU_write08(dest, data); - dest += 4; - data = 0; - bitwritecount = 0; - } - mask <<= bits; - bitcount += bits; - } - } - return 1; -} - -TEMPLATE static u32 Diff8bitUnFilterWram() -{ - u32 source,dest,header; - u8 data,diff; - int len; - - source = cpu->R[0]; - dest = cpu->R[1]; - - header = _MMU_read08(source); - source += 4; - - //INFO("swi diff8bitunfilterwram\n"); - - if(((source & 0xe000000) == 0) || - (( (source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)) - return 0; - - len = header >> 8; - - data = _MMU_read08(source++); - _MMU_write08(dest++, data); - len--; - - while(len > 0) { - diff = _MMU_read08(source++); - data += diff; - _MMU_write08(dest++, data); - len--; - } - return 1; -} - -TEMPLATE static u32 Diff16bitUnFilter() -{ - u32 source,dest,header; - u16 data; - int len; - - source = cpu->R[0]; - dest = cpu->R[1]; - - //INFO("swi diff16bitunfilter\n"); - - header = _MMU_read08(source); - source += 4; - - if(((source & 0xe000000) == 0) || - ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) - return 0; - - len = header >> 8; - - data = _MMU_read16(source); - source += 2; - _MMU_write16(dest, data); - dest += 2; - len -= 2; - - while(len >= 2) { - u16 diff = _MMU_read16(source); - source += 2; - data += diff; - _MMU_write16(dest, data); - dest += 2; - len -= 2; - } - return 1; -} - -TEMPLATE static u32 bios_sqrt() -{ - cpu->R[0] = (u32)sqrt((double)(cpu->R[0])); - return 1; -} - -TEMPLATE static u32 setHaltCR() -{ - _MMU_write08(0x4000300+cpu->proc_ID, cpu->R[0]); - return 1; -} - -TEMPLATE static u32 getSineTab() -{ - cpu->R[0] = getsinetbl[cpu->R[0]]; - return 1; -} - -TEMPLATE static u32 getPitchTab() -{ - cpu->R[0] = getpitchtbl[cpu->R[0]]; - return 1; -} - -TEMPLATE static u32 getVolumeTab() -{ - cpu->R[0] = getvoltbl[cpu->R[0]]; - return 1; -} - -TEMPLATE static u32 getCRC16() -{ - unsigned int i,j; - - u32 crc = cpu->R[0]; - u32 datap = cpu->R[1]; - u32 size = cpu->R[2]; - - const u16 val[] = { 0xC0C1,0xC181,0xC301,0xC601,0xCC01,0xD801,0xF001,0xA001 }; - for(i = 0; i < size; i++) - { - crc = crc ^ _MMU_read08(datap + i); - - for(j = 0; j < 8; j++) { - int do_bit = 0; - - if ( crc & 0x1) - do_bit = 1; - - crc = crc >> 1; - - if ( do_bit) { - crc = crc ^ (val[j] << (7-j)); - } - } - } - cpu->R[0] = crc; - return 1; -} - -TEMPLATE static u32 isDebugger() -{ - //gbatek has additional specifications which are not emulated here -#ifdef DEVELOPER - cpu->R[0] = 1; -#else - cpu->R[0] = 0; -#endif - return 1; -} - -TEMPLATE static u32 SoundBias() -{ - u32 current = SPU_ReadLong(0x4000504); - if (cpu->R[0] > current) - SPU_WriteLong(0x4000504, current + 0x1); - else - SPU_WriteLong(0x4000504, current - 0x1); - return cpu->R[1]; -} - -TEMPLATE static u32 getBootProcs() -{ - cpu->R[0] = 0x00000A2E; - cpu->R[1] = 0x00002C3C; - cpu->R[3] = 0x000005FF; - return 1; -} - -u32 (* ARM9_swi_tab[32])()={ - bios_nop, // 0x00 - bios_nop, // 0x01 - bios_nop, // 0x02 - delayLoop, // 0x03 - intrWaitARM, // 0x04 - waitVBlankARM, // 0x05 - wait4IRQ, // 0x06 - bios_nop, // 0x07 - bios_nop, // 0x08 - divide, // 0x09 - bios_nop, // 0x0A - copy, // 0x0B - fastCopy, // 0x0C - bios_sqrt, // 0x0D - getCRC16, // 0x0E - isDebugger, // 0x0F - BitUnPack, // 0x10 - LZ77UnCompWram, // 0x11 - LZ77UnCompVram, // 0x12 - UnCompHuffman, // 0x13 - RLUnCompWram, // 0x14 - RLUnCompVram, // 0x15 - Diff8bitUnFilterWram, // 0x16 - bios_nop, // 0x17 - Diff16bitUnFilter, // 0x18 - bios_nop, // 0x19 - bios_nop, // 0x1A - bios_nop, // 0x1B - bios_nop, // 0x1C - bios_nop, // 0x1D - bios_nop, // 0x1E - setHaltCR, // 0x1F -}; - -u32 (* ARM7_swi_tab[32])()={ - bios_nop, // 0x00 - bios_nop, // 0x01 - bios_nop, // 0x02 - delayLoop, // 0x03 - intrWaitARM, // 0x04 - waitVBlankARM, // 0x05 - wait4IRQ, // 0x06 - sleep, // 0x07 - SoundBias, // 0x08 - divide, // 0x09 - bios_nop, // 0x0A - copy, // 0x0B - fastCopy, // 0x0C - bios_sqrt, // 0x0D - getCRC16, // 0x0E - isDebugger, // 0x0F - BitUnPack, // 0x10 - LZ77UnCompWram, // 0x11 - LZ77UnCompVram, // 0x12 - UnCompHuffman, // 0x13 - RLUnCompWram, // 0x14 - RLUnCompVram, // 0x15 - Diff8bitUnFilterWram, // 0x16 - bios_nop, // 0x17 - bios_nop, // 0x18 - bios_nop, // 0x19 - getSineTab, // 0x1A - getPitchTab, // 0x1B - getVolumeTab, // 0x1C - getBootProcs, // 0x1D - bios_nop, // 0x1E - setHaltCR, // 0x1F -}; +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "cp15.h" +#include +#include "MMU.h" +#include "SPU.h" +#include "debug.h" + +#define cpu (&ARMPROC) +#define TEMPLATE template + +extern BOOL execute; + +static const u16 getsinetbl[] = { +0x0000, 0x0324, 0x0648, 0x096A, 0x0C8C, 0x0FAB, 0x12C8, 0x15E2, +0x18F9, 0x1C0B, 0x1F1A, 0x2223, 0x2528, 0x2826, 0x2B1F, 0x2E11, +0x30FB, 0x33DF, 0x36BA, 0x398C, 0x3C56, 0x3F17, 0x41CE, 0x447A, +0x471C, 0x49B4, 0x4C3F, 0x4EBF, 0x5133, 0x539B, 0x55F5, 0x5842, +0x5A82, 0x5CB3, 0x5ED7, 0x60EB, 0x62F1, 0x64E8, 0x66CF, 0x68A6, +0x6A6D, 0x6C23, 0x6DC9, 0x6F5E, 0x70E2, 0x7254, 0x73B5, 0x7504, +0x7641, 0x776B, 0x7884, 0x7989, 0x7A7C, 0x7B5C, 0x7C29, 0x7CE3, +0x7D89, 0x7E1D, 0x7E9C, 0x7F09, 0x7F61, 0x7FA6, 0x7FD8, 0x7FF5 +}; + +static const u16 getpitchtbl[] = { +0x0000, 0x003B, 0x0076, 0x00B2, 0x00ED, 0x0128, 0x0164, 0x019F, +0x01DB, 0x0217, 0x0252, 0x028E, 0x02CA, 0x0305, 0x0341, 0x037D, +0x03B9, 0x03F5, 0x0431, 0x046E, 0x04AA, 0x04E6, 0x0522, 0x055F, +0x059B, 0x05D8, 0x0614, 0x0651, 0x068D, 0x06CA, 0x0707, 0x0743, +0x0780, 0x07BD, 0x07FA, 0x0837, 0x0874, 0x08B1, 0x08EF, 0x092C, +0x0969, 0x09A7, 0x09E4, 0x0A21, 0x0A5F, 0x0A9C, 0x0ADA, 0x0B18, +0x0B56, 0x0B93, 0x0BD1, 0x0C0F, 0x0C4D, 0x0C8B, 0x0CC9, 0x0D07, +0x0D45, 0x0D84, 0x0DC2, 0x0E00, 0x0E3F, 0x0E7D, 0x0EBC, 0x0EFA, +0x0F39, 0x0F78, 0x0FB6, 0x0FF5, 0x1034, 0x1073, 0x10B2, 0x10F1, +0x1130, 0x116F, 0x11AE, 0x11EE, 0x122D, 0x126C, 0x12AC, 0x12EB, +0x132B, 0x136B, 0x13AA, 0x13EA, 0x142A, 0x146A, 0x14A9, 0x14E9, +0x1529, 0x1569, 0x15AA, 0x15EA, 0x162A, 0x166A, 0x16AB, 0x16EB, +0x172C, 0x176C, 0x17AD, 0x17ED, 0x182E, 0x186F, 0x18B0, 0x18F0, +0x1931, 0x1972, 0x19B3, 0x19F5, 0x1A36, 0x1A77, 0x1AB8, 0x1AFA, +0x1B3B, 0x1B7D, 0x1BBE, 0x1C00, 0x1C41, 0x1C83, 0x1CC5, 0x1D07, +0x1D48, 0x1D8A, 0x1DCC, 0x1E0E, 0x1E51, 0x1E93, 0x1ED5, 0x1F17, +0x1F5A, 0x1F9C, 0x1FDF, 0x2021, 0x2064, 0x20A6, 0x20E9, 0x212C, +0x216F, 0x21B2, 0x21F5, 0x2238, 0x227B, 0x22BE, 0x2301, 0x2344, +0x2388, 0x23CB, 0x240E, 0x2452, 0x2496, 0x24D9, 0x251D, 0x2561, +0x25A4, 0x25E8, 0x262C, 0x2670, 0x26B4, 0x26F8, 0x273D, 0x2781, +0x27C5, 0x280A, 0x284E, 0x2892, 0x28D7, 0x291C, 0x2960, 0x29A5, +0x29EA, 0x2A2F, 0x2A74, 0x2AB9, 0x2AFE, 0x2B43, 0x2B88, 0x2BCD, +0x2C13, 0x2C58, 0x2C9D, 0x2CE3, 0x2D28, 0x2D6E, 0x2DB4, 0x2DF9, +0x2E3F, 0x2E85, 0x2ECB, 0x2F11, 0x2F57, 0x2F9D, 0x2FE3, 0x302A, +0x3070, 0x30B6, 0x30FD, 0x3143, 0x318A, 0x31D0, 0x3217, 0x325E, +0x32A5, 0x32EC, 0x3332, 0x3379, 0x33C1, 0x3408, 0x344F, 0x3496, +0x34DD, 0x3525, 0x356C, 0x35B4, 0x35FB, 0x3643, 0x368B, 0x36D3, +0x371A, 0x3762, 0x37AA, 0x37F2, 0x383A, 0x3883, 0x38CB, 0x3913, +0x395C, 0x39A4, 0x39ED, 0x3A35, 0x3A7E, 0x3AC6, 0x3B0F, 0x3B58, +0x3BA1, 0x3BEA, 0x3C33, 0x3C7C, 0x3CC5, 0x3D0E, 0x3D58, 0x3DA1, +0x3DEA, 0x3E34, 0x3E7D, 0x3EC7, 0x3F11, 0x3F5A, 0x3FA4, 0x3FEE, +0x4038, 0x4082, 0x40CC, 0x4116, 0x4161, 0x41AB, 0x41F5, 0x4240, +0x428A, 0x42D5, 0x431F, 0x436A, 0x43B5, 0x4400, 0x444B, 0x4495, +0x44E1, 0x452C, 0x4577, 0x45C2, 0x460D, 0x4659, 0x46A4, 0x46F0, +0x473B, 0x4787, 0x47D3, 0x481E, 0x486A, 0x48B6, 0x4902, 0x494E, +0x499A, 0x49E6, 0x4A33, 0x4A7F, 0x4ACB, 0x4B18, 0x4B64, 0x4BB1, +0x4BFE, 0x4C4A, 0x4C97, 0x4CE4, 0x4D31, 0x4D7E, 0x4DCB, 0x4E18, +0x4E66, 0x4EB3, 0x4F00, 0x4F4E, 0x4F9B, 0x4FE9, 0x5036, 0x5084, +0x50D2, 0x5120, 0x516E, 0x51BC, 0x520A, 0x5258, 0x52A6, 0x52F4, +0x5343, 0x5391, 0x53E0, 0x542E, 0x547D, 0x54CC, 0x551A, 0x5569, +0x55B8, 0x5607, 0x5656, 0x56A5, 0x56F4, 0x5744, 0x5793, 0x57E2, +0x5832, 0x5882, 0x58D1, 0x5921, 0x5971, 0x59C1, 0x5A10, 0x5A60, +0x5AB0, 0x5B01, 0x5B51, 0x5BA1, 0x5BF1, 0x5C42, 0x5C92, 0x5CE3, +0x5D34, 0x5D84, 0x5DD5, 0x5E26, 0x5E77, 0x5EC8, 0x5F19, 0x5F6A, +0x5FBB, 0x600D, 0x605E, 0x60B0, 0x6101, 0x6153, 0x61A4, 0x61F6, +0x6248, 0x629A, 0x62EC, 0x633E, 0x6390, 0x63E2, 0x6434, 0x6487, +0x64D9, 0x652C, 0x657E, 0x65D1, 0x6624, 0x6676, 0x66C9, 0x671C, +0x676F, 0x67C2, 0x6815, 0x6869, 0x68BC, 0x690F, 0x6963, 0x69B6, +0x6A0A, 0x6A5E, 0x6AB1, 0x6B05, 0x6B59, 0x6BAD, 0x6C01, 0x6C55, +0x6CAA, 0x6CFE, 0x6D52, 0x6DA7, 0x6DFB, 0x6E50, 0x6EA4, 0x6EF9, +0x6F4E, 0x6FA3, 0x6FF8, 0x704D, 0x70A2, 0x70F7, 0x714D, 0x71A2, +0x71F7, 0x724D, 0x72A2, 0x72F8, 0x734E, 0x73A4, 0x73FA, 0x7450, +0x74A6, 0x74FC, 0x7552, 0x75A8, 0x75FF, 0x7655, 0x76AC, 0x7702, +0x7759, 0x77B0, 0x7807, 0x785E, 0x78B4, 0x790C, 0x7963, 0x79BA, +0x7A11, 0x7A69, 0x7AC0, 0x7B18, 0x7B6F, 0x7BC7, 0x7C1F, 0x7C77, +0x7CCF, 0x7D27, 0x7D7F, 0x7DD7, 0x7E2F, 0x7E88, 0x7EE0, 0x7F38, +0x7F91, 0x7FEA, 0x8042, 0x809B, 0x80F4, 0x814D, 0x81A6, 0x81FF, +0x8259, 0x82B2, 0x830B, 0x8365, 0x83BE, 0x8418, 0x8472, 0x84CB, +0x8525, 0x857F, 0x85D9, 0x8633, 0x868E, 0x86E8, 0x8742, 0x879D, +0x87F7, 0x8852, 0x88AC, 0x8907, 0x8962, 0x89BD, 0x8A18, 0x8A73, +0x8ACE, 0x8B2A, 0x8B85, 0x8BE0, 0x8C3C, 0x8C97, 0x8CF3, 0x8D4F, +0x8DAB, 0x8E07, 0x8E63, 0x8EBF, 0x8F1B, 0x8F77, 0x8FD4, 0x9030, +0x908C, 0x90E9, 0x9146, 0x91A2, 0x91FF, 0x925C, 0x92B9, 0x9316, +0x9373, 0x93D1, 0x942E, 0x948C, 0x94E9, 0x9547, 0x95A4, 0x9602, +0x9660, 0x96BE, 0x971C, 0x977A, 0x97D8, 0x9836, 0x9895, 0x98F3, +0x9952, 0x99B0, 0x9A0F, 0x9A6E, 0x9ACD, 0x9B2C, 0x9B8B, 0x9BEA, +0x9C49, 0x9CA8, 0x9D08, 0x9D67, 0x9DC7, 0x9E26, 0x9E86, 0x9EE6, +0x9F46, 0x9FA6, 0xA006, 0xA066, 0xA0C6, 0xA127, 0xA187, 0xA1E8, +0xA248, 0xA2A9, 0xA30A, 0xA36B, 0xA3CC, 0xA42D, 0xA48E, 0xA4EF, +0xA550, 0xA5B2, 0xA613, 0xA675, 0xA6D6, 0xA738, 0xA79A, 0xA7FC, +0xA85E, 0xA8C0, 0xA922, 0xA984, 0xA9E7, 0xAA49, 0xAAAC, 0xAB0E, +0xAB71, 0xABD4, 0xAC37, 0xAC9A, 0xACFD, 0xAD60, 0xADC3, 0xAE27, +0xAE8A, 0xAEED, 0xAF51, 0xAFB5, 0xB019, 0xB07C, 0xB0E0, 0xB145, +0xB1A9, 0xB20D, 0xB271, 0xB2D6, 0xB33A, 0xB39F, 0xB403, 0xB468, +0xB4CD, 0xB532, 0xB597, 0xB5FC, 0xB662, 0xB6C7, 0xB72C, 0xB792, +0xB7F7, 0xB85D, 0xB8C3, 0xB929, 0xB98F, 0xB9F5, 0xBA5B, 0xBAC1, +0xBB28, 0xBB8E, 0xBBF5, 0xBC5B, 0xBCC2, 0xBD29, 0xBD90, 0xBDF7, +0xBE5E, 0xBEC5, 0xBF2C, 0xBF94, 0xBFFB, 0xC063, 0xC0CA, 0xC132, +0xC19A, 0xC202, 0xC26A, 0xC2D2, 0xC33A, 0xC3A2, 0xC40B, 0xC473, +0xC4DC, 0xC544, 0xC5AD, 0xC616, 0xC67F, 0xC6E8, 0xC751, 0xC7BB, +0xC824, 0xC88D, 0xC8F7, 0xC960, 0xC9CA, 0xCA34, 0xCA9E, 0xCB08, +0xCB72, 0xCBDC, 0xCC47, 0xCCB1, 0xCD1B, 0xCD86, 0xCDF1, 0xCE5B, +0xCEC6, 0xCF31, 0xCF9C, 0xD008, 0xD073, 0xD0DE, 0xD14A, 0xD1B5, +0xD221, 0xD28D, 0xD2F8, 0xD364, 0xD3D0, 0xD43D, 0xD4A9, 0xD515, +0xD582, 0xD5EE, 0xD65B, 0xD6C7, 0xD734, 0xD7A1, 0xD80E, 0xD87B, +0xD8E9, 0xD956, 0xD9C3, 0xDA31, 0xDA9E, 0xDB0C, 0xDB7A, 0xDBE8, +0xDC56, 0xDCC4, 0xDD32, 0xDDA0, 0xDE0F, 0xDE7D, 0xDEEC, 0xDF5B, +0xDFC9, 0xE038, 0xE0A7, 0xE116, 0xE186, 0xE1F5, 0xE264, 0xE2D4, +0xE343, 0xE3B3, 0xE423, 0xE493, 0xE503, 0xE573, 0xE5E3, 0xE654, +0xE6C4, 0xE735, 0xE7A5, 0xE816, 0xE887, 0xE8F8, 0xE969, 0xE9DA, +0xEA4B, 0xEABC, 0xEB2E, 0xEB9F, 0xEC11, 0xEC83, 0xECF5, 0xED66, +0xEDD9, 0xEE4B, 0xEEBD, 0xEF2F, 0xEFA2, 0xF014, 0xF087, 0xF0FA, +0xF16D, 0xF1E0, 0xF253, 0xF2C6, 0xF339, 0xF3AD, 0xF420, 0xF494, +0xF507, 0xF57B, 0xF5EF, 0xF663, 0xF6D7, 0xF74C, 0xF7C0, 0xF834, +0xF8A9, 0xF91E, 0xF992, 0xFA07, 0xFA7C, 0xFAF1, 0xFB66, 0xFBDC, +0xFC51, 0xFCC7, 0xFD3C, 0xFDB2, 0xFE28, 0xFE9E, 0xFF14, 0xFF8A +}; + +static const u8 getvoltbl[] = { +0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, +0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, +0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, +0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, +0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, +0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, +0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, +0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, +0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, +0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, +0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, +0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, +0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, +0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, +0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, +0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, +0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, +0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, +0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x10, +0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x14, +0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x18, +0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1A, 0x1B, 0x1B, 0x1B, 0x1C, 0x1C, 0x1C, +0x1D, 0x1D, 0x1D, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, +0x22, 0x23, 0x23, 0x24, 0x24, 0x24, 0x25, 0x25, 0x26, 0x26, 0x27, 0x27, 0x27, 0x28, 0x28, 0x29, +0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2C, 0x2C, 0x2D, 0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, 0x31, 0x31, +0x32, 0x32, 0x33, 0x33, 0x34, 0x35, 0x35, 0x36, 0x36, 0x37, 0x38, 0x38, 0x39, 0x3A, 0x3A, 0x3B, +0x3C, 0x3C, 0x3D, 0x3E, 0x3F, 0x3F, 0x40, 0x41, 0x42, 0x42, 0x43, 0x44, 0x45, 0x45, 0x46, 0x47, +0x48, 0x49, 0x4A, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x52, 0x53, 0x54, 0x55, +0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x67, +0x68, 0x69, 0x6A, 0x6B, 0x6D, 0x6E, 0x6F, 0x71, 0x72, 0x73, 0x75, 0x76, 0x77, 0x79, 0x7A, 0x7B, +0x7D, 0x7E, 0x7F, 0x20, 0x21, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x23, 0x24, 0x24, 0x25, 0x25, +0x26, 0x26, 0x26, 0x27, 0x27, 0x28, 0x28, 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B, 0x2C, 0x2C, 0x2D, +0x2D, 0x2E, 0x2E, 0x2F, 0x2F, 0x30, 0x30, 0x31, 0x31, 0x32, 0x33, 0x33, 0x34, 0x34, 0x35, 0x36, +0x36, 0x37, 0x37, 0x38, 0x39, 0x39, 0x3A, 0x3B, 0x3B, 0x3C, 0x3D, 0x3E, 0x3E, 0x3F, 0x40, 0x40, +0x41, 0x42, 0x43, 0x43, 0x44, 0x45, 0x46, 0x47, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4D, +0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, +0x5E, 0x5F, 0x60, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6F, 0x70, +0x71, 0x73, 0x74, 0x75, 0x77, 0x78, 0x79, 0x7B, 0x7C, 0x7E, 0x7E, 0x40, 0x41, 0x42, 0x43, 0x43, +0x44, 0x45, 0x46, 0x47, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, +0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, +0x62, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6B, 0x6C, 0x6D, 0x6E, 0x70, 0x71, 0x72, 0x74, 0x75, +0x76, 0x78, 0x79, 0x7B, 0x7C, 0x7D, 0x7E, 0x40, 0x41, 0x42, 0x42, 0x43, 0x44, 0x45, 0x46, 0x46, +0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, +0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x65, 0x66, +0x67, 0x68, 0x69, 0x6A, 0x6C, 0x6D, 0x6E, 0x6F, 0x71, 0x72, 0x73, 0x75, 0x76, 0x77, 0x79, 0x7A, +0x7C, 0x7D, 0x7E, 0x7F +}; + +TEMPLATE static u32 bios_nop() +{ + if (cpu->proc_ID == ARMCPU_ARM9) + { + LOG("Unimplemented bios function %02X(ARM9) was used. R0:%08X\n", (cpu->instruction)&0x1F, cpu->R[0]); + } + else + { + LOG("Unimplemented bios function %02X(ARM7) was used. R0:%08X\n", (cpu->instruction)&0x1F, cpu->R[0]); + } + return 3; +} + +TEMPLATE static u32 delayLoop() +{ + return cpu->R[0] * 4; +} + +//u32 oldmode[2]; + +TEMPLATE u32 intrWaitARM() +{ + u32 intrFlagAdr;// = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; + u32 intr; + u32 intrFlag = 0; + + BOOL noDiscard = ((cpu->R[0] == 0) && (PROCNUM == 1)); + + //emu_halt(); + if(cpu->proc_ID) + { + intrFlagAdr = 0x380FFF8; + } else { + intrFlagAdr = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; + } + intr = _MMU_read32(intrFlagAdr); + intrFlag = (cpu->R[1] & intr); + + if(!noDiscard) + intrFlag &= ARMPROC.newIrqFlags; + + if(intrFlag) + { + // si une(ou plusieurs) des interruptions que l'on attend s'est(se sont) produite(s) + // on efface son(les) occurence(s). + intr ^= intrFlag; + cpu->newIrqFlags ^= intrFlag; + _MMU_write32(intrFlagAdr, intr); + //cpu->switchMode(oldmode[cpu->proc_ID]); + return 1; + } + + cpu->R[15] = cpu->instruct_adr; + cpu->next_instruction = cpu->R[15]; + cpu->waitIRQ = 1; + //oldmode[cpu->proc_ID] = cpu->switchMode(SVC); + + return 1; +} + +TEMPLATE static u32 waitVBlankARM() +{ + cpu->R[0] = 1; + cpu->R[1] = 1; + return intrWaitARM(); +#if 0 + u32 intrFlagAdr;// = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; + u32 intr; + u32 intrFlag = 0; + + //emu_halt(); + if(cpu->proc_ID) + { + intrFlagAdr = 0x380FFF8; + } else { + intrFlagAdr = (((armcp15_t *)(cpu->coproc[15]))->DTCMRegion&0xFFFFF000)+0x3FF8; + } + intr = _MMU_read32(intrFlagAdr); + intrFlag = 1 & intr; + + // if(intrFlag) + { + // si une(ou plusieurs) des interruptions que l'on attend s'est(se sont) produite(s) + // on efface son(les) occurence(s). + intr ^= intrFlag; + _MMU_write32(intrFlagAdr, intr); + //cpu->switchMode(oldmode[cpu->proc_ID]); + return 1; + } + + cpu->R[15] = cpu->instruct_adr; + cpu->next_instruction = cpu->R[15]; + cpu->waitIRQ = 1; + //oldmode[cpu->proc_ID] = cpu->switchMode(SVC); + + return 1; +#endif +} + +TEMPLATE static u32 wait4IRQ() +{ + //execute= FALSE; + if(cpu->wirq) + { + if(!cpu->waitIRQ) + { + cpu->waitIRQ = 0; + cpu->wirq = 0; + //cpu->switchMode(oldmode[cpu->proc_ID]); + return 1; + } + cpu->R[15] = cpu->instruct_adr; + cpu->next_instruction = cpu->R[15]; + return 1; + } + cpu->waitIRQ = 1; + cpu->wirq = 1; + cpu->R[15] = cpu->instruct_adr; + cpu->next_instruction = cpu->R[15]; + //oldmode[cpu->proc_ID] = cpu->switchMode(SVC); + return 1; +} + +TEMPLATE static u32 sleep() +{ + _MMU_write08(0x04000301, 0xC0); + return 1; +} + +TEMPLATE static u32 divide() +{ + s32 num = (s32)cpu->R[0]; + s32 dnum = (s32)cpu->R[1]; + + if(dnum==0) return 0; + + cpu->R[0] = (u32)(num / dnum); + cpu->R[1] = (u32)(num % dnum); + cpu->R[3] = (u32) (((s32)cpu->R[0])<0 ? -cpu->R[0] : cpu->R[0]); + + return 6; +} + +TEMPLATE static u32 copy() +{ + u32 src = cpu->R[0]; + u32 dst = cpu->R[1]; + u32 cnt = cpu->R[2]; + + //INFO("swi copy from %08X to %08X, cnt=%08X\n", src, dst, cnt); + + switch(BIT26(cnt)) + { + case 0: + src &= 0xFFFFFFFE; + dst &= 0xFFFFFFFE; + switch(BIT24(cnt)) + { + case 0: + cnt &= 0x1FFFFF; + while(cnt) + { + _MMU_write16(dst, _MMU_read16(src)); + cnt--; + dst+=2; + src+=2; + } + break; + case 1: + { + u32 val = _MMU_read16(src); + cnt &= 0x1FFFFF; + while(cnt) + { + _MMU_write16(dst, val); + cnt--; + dst+=2; + } + } + break; + } + break; + case 1: + src &= 0xFFFFFFFC; + dst &= 0xFFFFFFFC; + switch(BIT24(cnt)) + { + case 0: + cnt &= 0x1FFFFF; + while(cnt) + { + _MMU_write32(dst, _MMU_read32(src)); + cnt--; + dst+=4; + src+=4; + } + break; + case 1: + { + u32 val = _MMU_read32(src); + cnt &= 0x1FFFFF; + while(cnt) + { + _MMU_write32(dst, val); + cnt--; + dst+=4; + } + } + break; + } + break; + } + return 1; +} + +TEMPLATE static u32 fastCopy() +{ + u32 src = cpu->R[0] & 0xFFFFFFFC; + u32 dst = cpu->R[1] & 0xFFFFFFFC; + u32 cnt = cpu->R[2]; + + //INFO("swi fastcopy from %08X to %08X, cnt=%08X\n", src, dst, cnt); + + switch(BIT24(cnt)) + { + case 0: + cnt &= 0x1FFFFF; + while(cnt) + { + _MMU_write32(dst, _MMU_read32(src)); + cnt--; + dst+=4; + src+=4; + } + break; + case 1: + { + u32 val = _MMU_read32(src); + cnt &= 0x1FFFFF; + while(cnt) + { + _MMU_write32(dst, val); + cnt--; + dst+=4; + } + } + break; + } + return 1; +} + +TEMPLATE static u32 LZ77UnCompVram() +{ + int i1, i2; + int byteCount; + int byteShift; + u32 writeValue; + int len; + u32 source = cpu->R[0]; + u32 dest = cpu->R[1]; + u32 header = _MMU_read32(source); + source += 4; + + //INFO("swi lz77uncompvram\n"); + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return 0; + + byteCount = 0; + byteShift = 0; + writeValue = 0; + + len = header >> 8; + + while(len > 0) { + u8 d = _MMU_read08(source++); + + if(d) { + for(i1 = 0; i1 < 8; i1++) { + if(d & 0x80) { + int length; + int offset; + u32 windowOffset; + u16 data = _MMU_read08(source++) << 8; + data |= _MMU_read08(source++); + length = (data >> 12) + 3; + offset = (data & 0x0FFF); + windowOffset = dest + byteCount - offset - 1; + for(i2 = 0; i2 < length; i2++) { + writeValue |= (_MMU_read08(windowOffset++) << byteShift); + byteShift += 8; + byteCount++; + + if(byteCount == 2) { + _MMU_write16(dest, writeValue); + dest += 2; + byteCount = 0; + byteShift = 0; + writeValue = 0; + } + len--; + if(len == 0) + return 0; + } + } else { + writeValue |= (_MMU_read08(source++) << byteShift); + byteShift += 8; + byteCount++; + if(byteCount == 2) { + _MMU_write16(dest, writeValue); + dest += 2; + byteCount = 0; + byteShift = 0; + writeValue = 0; + } + len--; + if(len == 0) + return 0; + } + d <<= 1; + } + } else { + for(i1 = 0; i1 < 8; i1++) { + writeValue |= (_MMU_read08(source++) << byteShift); + byteShift += 8; + byteCount++; + if(byteCount == 2) { + _MMU_write16(dest, writeValue); + dest += 2; + byteShift = 0; + byteCount = 0; + writeValue = 0; + } + len--; + if(len == 0) + return 0; + } + } + } + return 1; +} + +TEMPLATE static u32 LZ77UnCompWram() +{ + int i1, i2; + int len; + u32 source = cpu->R[0]; + u32 dest = cpu->R[1]; + + u32 header = _MMU_read32(source); + source += 4; + + //INFO("swi lz77uncompwram\n"); + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return 0; + + len = header >> 8; + + while(len > 0) { + u8 d = _MMU_read08(source++); + + if(d) { + for(i1 = 0; i1 < 8; i1++) { + if(d & 0x80) { + int length; + int offset; + u32 windowOffset; + u16 data = _MMU_read08(source++) << 8; + data |= _MMU_read08(source++); + length = (data >> 12) + 3; + offset = (data & 0x0FFF); + windowOffset = dest - offset - 1; + for(i2 = 0; i2 < length; i2++) { + _MMU_write08(dest++, _MMU_read08(windowOffset++)); + len--; + if(len == 0) + return 0; + } + } else { + _MMU_write08(dest++, _MMU_read08(source++)); + len--; + if(len == 0) + return 0; + } + d <<= 1; + } + } else { + for(i1 = 0; i1 < 8; i1++) { + _MMU_write08(dest++, _MMU_read08(source++)); + len--; + if(len == 0) + return 0; + } + } + } + return 1; +} + +TEMPLATE static u32 RLUnCompVram() +{ + int i; + int len; + int byteCount; + int byteShift; + u32 writeValue; + u32 source = cpu->R[0]; + u32 dest = cpu->R[1]; + + u32 header = _MMU_read32(source); + source += 4; + + //INFO("swi rluncompvram\n"); + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return 0; + + len = header >> 8; + byteCount = 0; + byteShift = 0; + writeValue = 0; + + while(len > 0) { + u8 d = _MMU_read08(source++); + int l = d & 0x7F; + if(d & 0x80) { + u8 data = _MMU_read08(source++); + l += 3; + for(i = 0;i < l; i++) { + writeValue |= (data << byteShift); + byteShift += 8; + byteCount++; + + if(byteCount == 2) { + _MMU_write16(dest, writeValue); + dest += 2; + byteCount = 0; + byteShift = 0; + writeValue = 0; + } + len--; + if(len == 0) + return 0; + } + } else { + l++; + for(i = 0; i < l; i++) { + writeValue |= (_MMU_read08(source++) << byteShift); + byteShift += 8; + byteCount++; + if(byteCount == 2) { + _MMU_write16(dest, writeValue); + dest += 2; + byteCount = 0; + byteShift = 0; + writeValue = 0; + } + len--; + if(len == 0) + return 0; + } + } + } + return 1; +} + +TEMPLATE static u32 RLUnCompWram() +{ + int i; + int len; + u32 source = cpu->R[0]; + u32 dest = cpu->R[1]; + + u32 header = _MMU_read32(source); + source += 4; + + //INFO("swi rluncompwram\n"); + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return 0; + + len = header >> 8; + + while(len > 0) { + u8 d = _MMU_read08(source++); + int l = d & 0x7F; + if(d & 0x80) { + u8 data = _MMU_read08(source++); + l += 3; + for(i = 0;i < l; i++) { + _MMU_write08(dest++, data); + len--; + if(len == 0) + return 0; + } + } else { + l++; + for(i = 0; i < l; i++) { + _MMU_write08(dest++, _MMU_read08(source++)); + len--; + if(len == 0) + return 0; + } + } + } + return 1; +} + +TEMPLATE static u32 UnCompHuffman() +{ + u32 source, dest, writeValue, header, treeStart, mask; + u32 data; + u8 treeSize, currentNode, rootNode; + int byteCount, byteShift, len, pos; + int writeData; + + source = cpu->R[0]; + dest = cpu->R[1]; + + header = _MMU_read08(source); + source += 4; + + //INFO("swi uncomphuffman\n"); + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return 0; + + treeSize = _MMU_read08(source++); + + treeStart = source; + + source += ((treeSize+1)<<1)-1; // minus because we already skipped one byte + + len = header >> 8; + + mask = 0x80000000; + data = _MMU_read08(source); + source += 4; + + pos = 0; + rootNode = _MMU_read08(treeStart); + currentNode = rootNode; + writeData = 0; + byteShift = 0; + byteCount = 0; + writeValue = 0; + + if((header & 0x0F) == 8) { + while(len > 0) { + // take left + if(pos == 0) + pos++; + else + pos += (((currentNode & 0x3F)+1)<<1); + + if(data & mask) { + // right + if(currentNode & 0x40) + writeData = 1; + currentNode = _MMU_read08(treeStart+pos+1); + } else { + // left + if(currentNode & 0x80) + writeData = 1; + currentNode = _MMU_read08(treeStart+pos); + } + + if(writeData) { + writeValue |= (currentNode << byteShift); + byteCount++; + byteShift += 8; + + pos = 0; + currentNode = rootNode; + writeData = 0; + + if(byteCount == 4) { + byteCount = 0; + byteShift = 0; + _MMU_write08(dest, writeValue); + writeValue = 0; + dest += 4; + len -= 4; + } + } + mask >>= 1; + if(mask == 0) { + mask = 0x80000000; + data = _MMU_read08(source); + source += 4; + } + } + } else { + int halfLen = 0; + int value = 0; + while(len > 0) { + // take left + if(pos == 0) + pos++; + else + pos += (((currentNode & 0x3F)+1)<<1); + + if((data & mask)) { + // right + if(currentNode & 0x40) + writeData = 1; + currentNode = _MMU_read08(treeStart+pos+1); + } else { + // left + if(currentNode & 0x80) + writeData = 1; + currentNode = _MMU_read08(treeStart+pos); + } + + if(writeData) { + if(halfLen == 0) + value |= currentNode; + else + value |= (currentNode<<4); + + halfLen += 4; + if(halfLen == 8) { + writeValue |= (value << byteShift); + byteCount++; + byteShift += 8; + + halfLen = 0; + value = 0; + + if(byteCount == 4) { + byteCount = 0; + byteShift = 0; + _MMU_write08(dest, writeValue); + dest += 4; + writeValue = 0; + len -= 4; + } + } + pos = 0; + currentNode = rootNode; + writeData = 0; + } + mask >>= 1; + if(mask == 0) { + mask = 0x80000000; + data = _MMU_read08(source); + source += 4; + } + } + } + return 1; +} + +TEMPLATE static u32 BitUnPack() +{ + u32 source,dest,header,base,d,temp; + int len,bits,revbits,dataSize,data,bitwritecount,mask,bitcount,addBase; + u8 b; + + source = cpu->R[0]; + dest = cpu->R[1]; + header = cpu->R[2]; + + //INFO("swi bitunpack\n"); + + len = _MMU_read16(header); + // check address + bits = _MMU_read08(header+2); + revbits = 8 - bits; + // u32 value = 0; + base = _MMU_read08(header+4); + addBase = (base & 0x80000000) ? 1 : 0; + base &= 0x7fffffff; + dataSize = _MMU_read08(header+3); + + data = 0; + bitwritecount = 0; + while(1) { + len -= 1; + if(len < 0) + break; + mask = 0xff >> revbits; + b = _MMU_read08(source); + source++; + bitcount = 0; + while(1) { + if(bitcount >= 8) + break; + d = b & mask; + temp = d >> bitcount; + if(!temp && addBase) { + temp += base; + } + data |= temp << bitwritecount; + bitwritecount += dataSize; + if(bitwritecount >= 32) { + _MMU_write08(dest, data); + dest += 4; + data = 0; + bitwritecount = 0; + } + mask <<= bits; + bitcount += bits; + } + } + return 1; +} + +TEMPLATE static u32 Diff8bitUnFilterWram() +{ + u32 source,dest,header; + u8 data,diff; + int len; + + source = cpu->R[0]; + dest = cpu->R[1]; + + header = _MMU_read08(source); + source += 4; + + //INFO("swi diff8bitunfilterwram\n"); + + if(((source & 0xe000000) == 0) || + (( (source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0)) + return 0; + + len = header >> 8; + + data = _MMU_read08(source++); + _MMU_write08(dest++, data); + len--; + + while(len > 0) { + diff = _MMU_read08(source++); + data += diff; + _MMU_write08(dest++, data); + len--; + } + return 1; +} + +TEMPLATE static u32 Diff16bitUnFilter() +{ + u32 source,dest,header; + u16 data; + int len; + + source = cpu->R[0]; + dest = cpu->R[1]; + + //INFO("swi diff16bitunfilter\n"); + + header = _MMU_read08(source); + source += 4; + + if(((source & 0xe000000) == 0) || + ((source + ((header >> 8) & 0x1fffff)) & 0xe000000) == 0) + return 0; + + len = header >> 8; + + data = _MMU_read16(source); + source += 2; + _MMU_write16(dest, data); + dest += 2; + len -= 2; + + while(len >= 2) { + u16 diff = _MMU_read16(source); + source += 2; + data += diff; + _MMU_write16(dest, data); + dest += 2; + len -= 2; + } + return 1; +} + +TEMPLATE static u32 bios_sqrt() +{ + cpu->R[0] = (u32)sqrt((double)(cpu->R[0])); + return 1; +} + +TEMPLATE static u32 setHaltCR() +{ + _MMU_write08(0x4000300+cpu->proc_ID, cpu->R[0]); + return 1; +} + +TEMPLATE static u32 getSineTab() +{ + cpu->R[0] = getsinetbl[cpu->R[0]]; + return 1; +} + +TEMPLATE static u32 getPitchTab() +{ + cpu->R[0] = getpitchtbl[cpu->R[0]]; + return 1; +} + +TEMPLATE static u32 getVolumeTab() +{ + cpu->R[0] = getvoltbl[cpu->R[0]]; + return 1; +} + +TEMPLATE static u32 getCRC16() +{ + unsigned int i,j; + + u32 crc = cpu->R[0]; + u32 datap = cpu->R[1]; + u32 size = cpu->R[2]; + + const u16 val[] = { 0xC0C1,0xC181,0xC301,0xC601,0xCC01,0xD801,0xF001,0xA001 }; + for(i = 0; i < size; i++) + { + crc = crc ^ _MMU_read08(datap + i); + + for(j = 0; j < 8; j++) { + int do_bit = 0; + + if ( crc & 0x1) + do_bit = 1; + + crc = crc >> 1; + + if ( do_bit) { + crc = crc ^ (val[j] << (7-j)); + } + } + } + cpu->R[0] = crc; + return 1; +} + +TEMPLATE static u32 isDebugger() +{ + //gbatek has additional specifications which are not emulated here +#ifdef DEVELOPER + cpu->R[0] = 1; +#else + cpu->R[0] = 0; +#endif + return 1; +} + +TEMPLATE static u32 SoundBias() +{ + u32 current = SPU_ReadLong(0x4000504); + if (cpu->R[0] > current) + SPU_WriteLong(0x4000504, current + 0x1); + else + SPU_WriteLong(0x4000504, current - 0x1); + return cpu->R[1]; +} + +TEMPLATE static u32 getBootProcs() +{ + cpu->R[0] = 0x00000A2E; + cpu->R[1] = 0x00002C3C; + cpu->R[3] = 0x000005FF; + return 1; +} + +u32 (* ARM9_swi_tab[32])()={ + bios_nop, // 0x00 + bios_nop, // 0x01 + bios_nop, // 0x02 + delayLoop, // 0x03 + intrWaitARM, // 0x04 + waitVBlankARM, // 0x05 + wait4IRQ, // 0x06 + bios_nop, // 0x07 + bios_nop, // 0x08 + divide, // 0x09 + bios_nop, // 0x0A + copy, // 0x0B + fastCopy, // 0x0C + bios_sqrt, // 0x0D + getCRC16, // 0x0E + isDebugger, // 0x0F + BitUnPack, // 0x10 + LZ77UnCompWram, // 0x11 + LZ77UnCompVram, // 0x12 + UnCompHuffman, // 0x13 + RLUnCompWram, // 0x14 + RLUnCompVram, // 0x15 + Diff8bitUnFilterWram, // 0x16 + bios_nop, // 0x17 + Diff16bitUnFilter, // 0x18 + bios_nop, // 0x19 + bios_nop, // 0x1A + bios_nop, // 0x1B + bios_nop, // 0x1C + bios_nop, // 0x1D + bios_nop, // 0x1E + setHaltCR, // 0x1F +}; + +u32 (* ARM7_swi_tab[32])()={ + bios_nop, // 0x00 + bios_nop, // 0x01 + bios_nop, // 0x02 + delayLoop, // 0x03 + intrWaitARM, // 0x04 + waitVBlankARM, // 0x05 + wait4IRQ, // 0x06 + sleep, // 0x07 + SoundBias, // 0x08 + divide, // 0x09 + bios_nop, // 0x0A + copy, // 0x0B + fastCopy, // 0x0C + bios_sqrt, // 0x0D + getCRC16, // 0x0E + isDebugger, // 0x0F + BitUnPack, // 0x10 + LZ77UnCompWram, // 0x11 + LZ77UnCompVram, // 0x12 + UnCompHuffman, // 0x13 + RLUnCompWram, // 0x14 + RLUnCompVram, // 0x15 + Diff8bitUnFilterWram, // 0x16 + bios_nop, // 0x17 + bios_nop, // 0x18 + bios_nop, // 0x19 + getSineTab, // 0x1A + getPitchTab, // 0x1B + getVolumeTab, // 0x1C + getBootProcs, // 0x1D + bios_nop, // 0x1E + setHaltCR, // 0x1F +}; diff --git a/desmume/src/bios.h b/src/bios.h similarity index 96% rename from desmume/src/bios.h rename to src/bios.h index f7107fa2c..35471448d 100644 --- a/desmume/src/bios.h +++ b/src/bios.h @@ -1,31 +1,31 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef BIOS_H -#define BIOS_H - -#include "armcpu.h" - -extern u32 (* ARM9_swi_tab[32])(); -extern u32 (* ARM7_swi_tab[32])(); - -#endif - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef BIOS_H +#define BIOS_H + +#include "armcpu.h" + +extern u32 (* ARM9_swi_tab[32])(); +extern u32 (* ARM7_swi_tab[32])(); + +#endif + diff --git a/desmume/src/bits.h b/src/bits.h similarity index 96% rename from desmume/src/bits.h rename to src/bits.h index be64f65d7..9259573a0 100644 --- a/desmume/src/bits.h +++ b/src/bits.h @@ -1,44 +1,44 @@ -#ifndef BITS_H -#define BITS_H - -#define BIT(n) (1<<(n)) - -#define BIT_N(i,n) (((i)>>(n))&1) -#define BIT0(i) ((i)&1) -#define BIT1(i) BIT_N(i,1) -#define BIT2(i) BIT_N(i,2) -#define BIT3(i) BIT_N(i,3) -#define BIT4(i) BIT_N(i,4) -#define BIT5(i) BIT_N(i,5) -#define BIT6(i) BIT_N(i,6) -#define BIT7(i) BIT_N(i,7) -#define BIT8(i) BIT_N(i,8) -#define BIT9(i) BIT_N(i,9) -#define BIT10(i) BIT_N(i,10) -#define BIT11(i) BIT_N(i,11) -#define BIT12(i) BIT_N(i,12) -#define BIT13(i) BIT_N(i,13) -#define BIT14(i) BIT_N(i,14) -#define BIT15(i) BIT_N(i,15) -#define BIT16(i) BIT_N(i,16) -#define BIT17(i) BIT_N(i,17) -#define BIT18(i) BIT_N(i,18) -#define BIT19(i) BIT_N(i,19) -#define BIT20(i) BIT_N(i,20) -#define BIT21(i) BIT_N(i,21) -#define BIT22(i) BIT_N(i,22) -#define BIT23(i) BIT_N(i,23) -#define BIT24(i) BIT_N(i,24) -#define BIT25(i) BIT_N(i,25) -#define BIT26(i) BIT_N(i,26) -#define BIT27(i) BIT_N(i,27) -#define BIT28(i) BIT_N(i,28) -#define BIT29(i) BIT_N(i,29) -#define BIT30(i) BIT_N(i,30) -#define BIT31(i) ((i)>>31) - -#define CONDITION(i) (i)>>28 - -#define REG_POS(i,n) (((i)>>n)&0xF) - -#endif +#ifndef BITS_H +#define BITS_H + +#define BIT(n) (1<<(n)) + +#define BIT_N(i,n) (((i)>>(n))&1) +#define BIT0(i) ((i)&1) +#define BIT1(i) BIT_N(i,1) +#define BIT2(i) BIT_N(i,2) +#define BIT3(i) BIT_N(i,3) +#define BIT4(i) BIT_N(i,4) +#define BIT5(i) BIT_N(i,5) +#define BIT6(i) BIT_N(i,6) +#define BIT7(i) BIT_N(i,7) +#define BIT8(i) BIT_N(i,8) +#define BIT9(i) BIT_N(i,9) +#define BIT10(i) BIT_N(i,10) +#define BIT11(i) BIT_N(i,11) +#define BIT12(i) BIT_N(i,12) +#define BIT13(i) BIT_N(i,13) +#define BIT14(i) BIT_N(i,14) +#define BIT15(i) BIT_N(i,15) +#define BIT16(i) BIT_N(i,16) +#define BIT17(i) BIT_N(i,17) +#define BIT18(i) BIT_N(i,18) +#define BIT19(i) BIT_N(i,19) +#define BIT20(i) BIT_N(i,20) +#define BIT21(i) BIT_N(i,21) +#define BIT22(i) BIT_N(i,22) +#define BIT23(i) BIT_N(i,23) +#define BIT24(i) BIT_N(i,24) +#define BIT25(i) BIT_N(i,25) +#define BIT26(i) BIT_N(i,26) +#define BIT27(i) BIT_N(i,27) +#define BIT28(i) BIT_N(i,28) +#define BIT29(i) BIT_N(i,29) +#define BIT30(i) BIT_N(i,30) +#define BIT31(i) ((i)>>31) + +#define CONDITION(i) (i)>>28 + +#define REG_POS(i,n) (((i)>>n)&0xF) + +#endif diff --git a/desmume/src/build.bat b/src/build.bat similarity index 100% rename from desmume/src/build.bat rename to src/build.bat diff --git a/desmume/src/cheatSystem.cpp b/src/cheatSystem.cpp similarity index 95% rename from desmume/src/cheatSystem.cpp rename to src/cheatSystem.cpp index e04143cca..92b3a363f 100644 --- a/desmume/src/cheatSystem.cpp +++ b/src/cheatSystem.cpp @@ -1,1047 +1,1047 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include -#include "cheatSystem.h" -#include "NDSSystem.h" -#include "mem.h" -#include "MMU.h" -#include "debug.h" - -static CHEATS_LIST cheats[MAX_CHEAT_LIST]; -static u16 cheatsNum = 0; -static u8 cheatFilename[MAX_PATH]; -static u32 cheatsCurrentGet = 0; - -static u8 *cheatsStack = NULL; -static u16 cheatsNumStack = 0; - -static void cheatsClear() -{ - memset(cheats, 0, sizeof(cheats)); - for (int i = 0; i < MAX_CHEAT_LIST; i++) - cheats[i].type = 0xFF; - cheatsNum = 0; - cheatsCurrentGet = 0; -} - -void cheatsInit(char *path) -{ - cheatsClear(); - strcpy((char *)cheatFilename, path); - - if (cheatsStack) delete [] cheatsStack; - cheatsStack = NULL; - - cheatsLoad(); -} - -BOOL cheatsAdd(u8 size, u32 address, u32 val, char *description, BOOL enabled) -{ - if (cheatsNum == MAX_CHEAT_LIST) return FALSE; - cheats[cheatsNum].hi[0] = address & 0x00FFFFFF; - cheats[cheatsNum].lo[0] = val; - cheats[cheatsNum].num = 1; - cheats[cheatsNum].type = 0; - cheats[cheatsNum].size = size; - strcpy(cheats[cheatsNum].description, description); - cheats[cheatsNum].enabled = enabled; - cheatsNum++; - return TRUE; -} - -BOOL cheatsUpdate(u8 size, u32 address, u32 val, char *description, BOOL enabled, u32 pos) -{ - if (pos > cheatsNum) return FALSE; - cheats[pos].hi[0] = address & 0x00FFFFFF; - cheats[pos].lo[0] = val; - cheats[pos].num = 1; - cheats[pos].type = 0; - cheats[pos].size = size; - strcpy(cheats[pos].description, description); - cheats[pos].enabled = enabled; - return TRUE; -} - -static void cheats_ARparser(CHEATS_LIST cheat) -{ - u8 type = 0; - u8 subtype = 0; - u32 hi = 0; - u32 lo = 0; - u32 addr = 0; - u32 val = 0; - // AR temporary vars & flags - u32 offset = 0; - u32 datareg = 0; - u32 loopcount = 0; - u32 counter = 0; - u32 if_flag = 0; - s32 loopbackline = 0; - u32 loop_flag = 0; - - for (int i=0; i < cheat.num; i++) - { - type = cheat.hi[i] >> 28; - subtype = (cheat.hi[i] >> 24) & 0x0F; - - hi = cheat.hi[i] & 0x0FFFFFFF; - lo = cheat.lo[i]; - - if (if_flag > 0) - { - if ( (type == 0x0D) && (subtype == 0)) if_flag--; // ENDIF - if ( (type == 0x0D) && (subtype == 2)) // NEXT & Flush - { - if (loop_flag) - i = (loopbackline-1); - else - { - offset = 0; - datareg = 0; - loopcount = 0; - counter = 0; - if_flag = 0; - loop_flag = 0; - } - } - continue; - } - - switch (type) - { - case 0x00: - { - if (hi==0) - { - //manual hook - } - else - if ((hi==0x0000AA99) && (lo==0)) - { - //parameter bytes 9..10 for above code (padded with 00s) - } - else - { - addr = hi + offset; - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20], lo); - } - } - break; - - case 0x01: - addr = hi + offset; - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20], lo & 0x0000FFFF); - break; - - case 0x02: - addr = hi + offset; - T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20], lo & 0x000000FF); - break; - - case 0x03: - val = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]); - if ( lo > val ) - { - if (if_flag > 0) if_flag--; - } - else - { - if_flag++; - } - break; - - case 0x04: - val = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]); - if ( lo < val ) - { - if (if_flag > 0) if_flag--; - } - else - { - if_flag++; - } - break; - - case 0x05: - val = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]); - if ( lo == val ) - { - if (if_flag > 0) if_flag--; - } - else - { - if_flag++; - } - break; - - case 0x06: - val = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]); - if ( lo != val ) - { - if (if_flag > 0) if_flag--; - } - else - { - if_flag++; - } - break; - - case 0x07: - val = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]) & 0x0000FFFF; - if ( (lo & 0xFFFF) > ( (~(lo >> 16)) & val) ) - { - if (if_flag > 0) if_flag--; - } - else - { - if_flag++; - } - break; - - case 0x08: - val = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]) & 0x0000FFFF; - if ( (lo & 0xFFFF) < ( (~(lo >> 16)) & val) ) - { - if (if_flag > 0) if_flag--; - } - else - { - if_flag++; - } - break; - - case 0x09: - val = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]); - if ( (lo & 0xFFFF) == ( (~(lo >> 16)) & val) ) - { - if (if_flag > 0) if_flag--; - } - else - { - if_flag++; - } - break; - - case 0x0A: - val = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]) & 0x0000FFFF; - if ( (lo & 0xFFFF) != ( (~(lo >> 16)) & val) ) - { - if (if_flag > 0) if_flag--; - } - else - { - if_flag++; - } - break; - - case 0x0B: - addr = hi + offset; - offset = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20]); - break; - - case 0x0C: - switch (subtype) - { - case 0x0: - if (loopcount < (lo+1)) - loop_flag = 1; - else - loop_flag = 0; - loopcount++; - loopbackline = i; - break; - - case 0x4: - break; - - case 0x5: - counter++; - if ( (counter & (lo & 0xFFFF)) == ((lo >> 8) & 0xFFFF) ) - { - if (if_flag > 0) if_flag--; - } - else - { - if_flag++; - } - break; - - case 0x6: - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][lo>>20], lo & MMU.MMU_MASK[ARMCPU_ARM9][lo>>20], offset); - break; - } - break; - - case 0x0D: - { - switch (subtype) - { - case 0x0: - break; - - case 0x1: - if (loop_flag) - i = (loopbackline-1); - break; - - case 0x2: - if (loop_flag) - i = (loopbackline-1); - else - { - offset = 0; - datareg = 0; - loopcount = 0; - counter = 0; - if_flag = 0; - loop_flag = 0; - } - break; - - case 0x3: - offset = lo; - break; - - case 0x4: - datareg += lo; - break; - - case 0x5: - datareg = lo; - break; - - case 0x6: - addr = lo + offset; - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20], datareg); - offset += 4; - break; - - case 0x7: - addr = lo + offset; - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20], datareg & 0x0000FFFF); - offset += 2; - break; - - case 0x8: - addr = lo + offset; - T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20], datareg & 0x000000FF); - offset += 1; - break; - - case 0x9: - addr = lo + offset; - datareg = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20]); - break; - - case 0xA: - addr = lo + offset; - datareg = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20]) & 0x0000FFFF; - break; - - case 0xB: - addr = lo + offset; - datareg = T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20]) & 0x000000FF; - break; - - case 0xC: - offset += lo; - break; - } - } - break; - - case 0xE: - for (u32 t = 0; t < lo; t++) - { - u8 tmp = T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][(hi+t)>>20], (hi+t) & MMU.MMU_MASK[ARMCPU_ARM9][(hi+t)>>20]); - T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM9][(offset+t)>>20], (offset+t) & MMU.MMU_MASK[ARMCPU_ARM9][(offset+t)>>20], tmp); - } - break; - - case 0xF: - for (u32 t = 0; t < lo; t++) - { - u8 tmp = T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][(offset+t)>>20], (offset+t) & MMU.MMU_MASK[ARMCPU_ARM9][(offset+t)>>20]); - T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM9][(hi+t)>>20], (hi+t) & MMU.MMU_MASK[ARMCPU_ARM9][(hi+t)>>20], tmp); - } - break; - //default: INFO("AR: ERROR uknown command 0x%2X at %08X:%08X\n", type, hi, lo); break; - } - } -} - -static BOOL cheatsXXcodePreparser(CHEATS_LIST *cheat, char *code) -{ - int count = 0; - u16 t = 0; - char tmp_buf[sizeof(cheat->hi)+sizeof(cheat->lo)]; - - memset(tmp_buf, 0, sizeof(tmp_buf)); - // remove wrong chars - for (unsigned int i=0; i < strlen(code); i++) - { - switch (code[i]) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'a': - case 'B': - case 'b': - case 'C': - case 'c': - case 'D': - case 'd': - case 'E': - case 'e': - case 'F': - case 'f': - tmp_buf[t] = code[i]; - t++; - break; - } - } - - if ((strlen(tmp_buf) % 8) != 0) return FALSE; // error - if ((strlen(tmp_buf) % 16) != 0) return FALSE; // error - - // TODO: syntax check - count = (strlen(tmp_buf) / 16); - for (int i=0; i < count; i++) - { - char buf[8] = {0}; - strncpy(buf, tmp_buf+(i*16), 8); - sscanf_s(buf, "%x", &cheat->hi[i]); - strncpy(buf, tmp_buf+(i*16) + 8, 8); - sscanf_s(buf, "%x", &cheat->lo[i]); - } - - cheat->num = count; - cheat->size = 0; - return TRUE; -} - -BOOL cheatsAdd_AR(char *code, char *description, BOOL enabled) -{ - if (cheatsNum == MAX_CHEAT_LIST) return FALSE; - - if (!cheatsXXcodePreparser(&cheats[cheatsNum], code)) return FALSE; - - cheats[cheatsNum].type = 1; - - strcpy(cheats[cheatsNum].description, description); - cheats[cheatsNum].enabled = enabled; - cheatsNum++; - return TRUE; -} - -BOOL cheatsUpdate_AR(char *code, char *description, BOOL enabled, u32 pos) -{ - if (pos > cheatsNum) return FALSE; - - if (code != NULL) - { - if (!cheatsXXcodePreparser(&cheats[pos], code)) return FALSE; - strcpy(cheats[pos].description, description); - cheats[pos].type = 1; - } - - cheats[pos].enabled = enabled; - return TRUE; -} - -BOOL cheatsAdd_CB(char *code, char *description, BOOL enabled) -{ - if (cheatsNum == MAX_CHEAT_LIST) return FALSE; - - if (!cheatsXXcodePreparser(&cheats[cheatsNum], code)) return FALSE; - - cheats[cheatsNum].type = 2; - - strcpy(cheats[cheatsNum].description, description); - cheats[cheatsNum].enabled = enabled; - cheatsNum++; - return TRUE; -} - -BOOL cheatsUpdate_CB(char *code, char *description, BOOL enabled, u32 pos) -{ - if (pos > cheatsNum) return FALSE; - - if (code != NULL) - { - if (!cheatsXXcodePreparser(&cheats[pos], code)) return FALSE; - cheats[pos].type = 2; - strcpy(cheats[pos].description, description); - } - cheats[pos].enabled = enabled; - return TRUE; -} - -BOOL cheatsRemove(u32 pos) -{ - if (pos > cheatsNum) return FALSE; - if (cheatsNum == 0) return FALSE; - - for (int i = pos; i < cheatsNum; i++) - memcpy(&cheats[i], &cheats[i+1], sizeof(CHEATS_LIST)); - - memset(&cheats[cheatsNum], 0, sizeof(CHEATS_LIST)); - - cheatsNum--; - return TRUE; -} - -void cheatsGetListReset() -{ - cheatsCurrentGet = 0; - return; -} - -BOOL cheatsGetList(CHEATS_LIST *cheat) -{ - if (cheatsCurrentGet > cheatsNum) - { - cheatsCurrentGet = 0; - return FALSE; - } - memcpy(cheat, &cheats[cheatsCurrentGet++], sizeof(CHEATS_LIST)); - if (cheatsCurrentGet > cheatsNum) - { - cheatsCurrentGet = 0; - return FALSE; - } - return TRUE; -} - -BOOL cheatsGet(CHEATS_LIST *cheat, u32 pos) -{ - if (pos > cheatsNum) return FALSE; - memcpy(cheat, &cheats[pos], sizeof(CHEATS_LIST)); - return TRUE; -} - -u32 cheatsGetSize() -{ - return cheatsNum; -} - -BOOL cheatsSave() -{ - FILE *fcheat = fopen((char *)cheatFilename, "w"); - - if (fcheat) - { - fprintf(fcheat, "; DeSmuME cheat file. VERSION %i.%03i\n", CHEAT_VERSION_MAJOR, CHEAT_VERSION_MINOR); - fprintf(fcheat, "Name=%s\n", gameInfo.ROMserial); - fputs("; cheats list\n", fcheat); - for (int i = 0; i < cheatsNum; i++) - { - fprintf(fcheat, "Desc=%s\n", cheats[i].description); - fprintf(fcheat, "Info=%i,%i,%i,%i\n", cheats[i].type, cheats[i].num, cheats[i].enabled, cheats[i].size); - - if (cheats[i].num > 0) - { - fprintf(fcheat, "Data="); - for (int t = 0; t < cheats[i].num; t++) - { - fprintf(fcheat, "%08X%08X", cheats[i].hi[t], cheats[i].lo[t]); - if (t < (cheats[i].num - 1)) fputs(",", fcheat); - } - fputs("\n", fcheat); - } - fputs("\n", fcheat); - } - - fclose(fcheat); - return TRUE; - } - - return FALSE; -} - -BOOL cheatsLoad() -{ - FILE *fcheat = fopen((char *)cheatFilename, "r"); - char buf[1024]; - int last=0; - if (fcheat) - { - cheatsClear(); - memset(buf, 0, 1024); - - while (!feof(fcheat)) - { - fgets(buf, 1024, fcheat); - if (buf[0] == ';') continue; - removeCR((char *)&buf); - if (!strlen_ws(buf)) continue; - if ( (buf[0] == 'D') && - (buf[1] == 'e') && - (buf[2] == 's') && - (buf[3] == 'c') && - (buf[4] == '=') ) // new cheat block - { - strncpy((char *)cheats[last].description, (char *)buf+5, strlen(buf)-5); - fgets(buf, 1024, fcheat); - if ( (buf[0] == 'I') && - (buf[1] == 'n') && - (buf[2] == 'f') && - (buf[3] == 'o') && - (buf[4] == '=') ) // Info cheat - { - u32 dstart = 5; - u32 dsize = 0; - char bf[4] = { 0 }; - - while ( (buf[dstart+dsize] != ',') && (buf[dstart+dsize]!=0)) { dsize++; }; - if (buf[dstart+dsize]==0) continue; // error - strncpy(bf, (char*)buf+dstart, dsize); - cheats[last].type=atoi(bf); - dstart += (dsize+1); dsize=0; - while ( (buf[dstart+dsize] != ',') && (buf[dstart+dsize]!=0)) { dsize++; }; - if (buf[dstart+dsize]==0) continue; // error - strncpy(bf, (char*)buf+dstart, dsize); - dstart += (dsize+1); dsize=0; - cheats[last].num=atoi(bf); - while ( (buf[dstart+dsize] != ',') && (buf[dstart+dsize]!=0)) { dsize++; }; - if (buf[dstart+dsize]==0) continue; // error - strncpy(bf, (char*)(buf+dstart), dsize); - dstart += (dsize+1); dsize=0; - cheats[last].enabled=atoi(bf); - while ( (buf[dstart+dsize] != ',') && (buf[dstart+dsize]!=0)) { dsize++; }; - strncpy(bf, (char*)buf+dstart, dsize); - cheats[last].size=atoi(bf); - fgets(buf, 1024, fcheat); - if ( (buf[0] == 'D') && - (buf[1] == 'a') && - (buf[2] == 't') && - (buf[3] == 'a') && - (buf[4] == '=') ) // Data cheat - { - int offs = 5; - char tmp_buf[9]; - memset(tmp_buf, 0, 9); - - for (int j=0; j> 3); - u32 offs = (i % 8); - if (searchStatMem[addr] & (1<> 3); - u32 offs = (i % 8); - if (searchStatMem[addr] & (3<> 3); - u32 offs = (i % 8); - if (searchStatMem[addr] & (0x7<> 3); - u32 offs = (i % 8); - if (searchStatMem[addr] & (0xF<> 3); - u32 offs = (i % 8); - if (searchStatMem[addr] & (1< T1ReadByte(searchMem, i)); break; - case 1: res=(T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) < T1ReadByte(searchMem, i)); break; - case 2: res=(T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) == T1ReadByte(searchMem, i)); break; - case 3: res=(T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) != T1ReadByte(searchMem, i)); break; - default: res = FALSE; break; - } - if ( res ) - { - searchStatMem[addr] |= (1<> 3); - u32 offs = (i % 8); - if (searchStatMem[addr] & (3< T1ReadWord(searchMem, i)); break; - case 1: res=(T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) < T1ReadWord(searchMem, i)); break; - case 2: res=(T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) == T1ReadWord(searchMem, i)); break; - case 3: res=(T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) != T1ReadWord(searchMem, i)); break; - default: res = FALSE; break; - } - if ( res ) - { - searchStatMem[addr] |= (3<> 3); - u32 offs = (i % 8); - if (searchStatMem[addr] & (7< (T1ReadLong(searchMem, i) & 0x00FFFFFF) ); break; - case 1: res=((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) & 0x00FFFFFF) < (T1ReadLong(searchMem, i) & 0x00FFFFFF) ); break; - case 2: res=((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) & 0x00FFFFFF) == (T1ReadLong(searchMem, i) & 0x00FFFFFF) ); break; - case 3: res=((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) & 0x00FFFFFF) != (T1ReadLong(searchMem, i) & 0x00FFFFFF) ); break; - default: res = FALSE; break; - } - if ( res ) - { - searchStatMem[addr] |= (7<> 3); - u32 offs = (i % 8); - if (searchStatMem[addr] & (0xF< T1ReadLong(searchMem, i)); break; - case 1: res=(T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) < T1ReadLong(searchMem, i)); break; - case 2: res=(T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) == T1ReadLong(searchMem, i)); break; - case 3: res=(T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) != T1ReadLong(searchMem, i)); break; - default: res = FALSE; break; - } - if ( res ) - { - searchStatMem[addr] |= (0xF<> 3); - u32 offs = (i % 8); - if (searchStatMem[addr] & (stepMem< +#include "cheatSystem.h" +#include "NDSSystem.h" +#include "mem.h" +#include "MMU.h" +#include "debug.h" + +static CHEATS_LIST cheats[MAX_CHEAT_LIST]; +static u16 cheatsNum = 0; +static u8 cheatFilename[MAX_PATH]; +static u32 cheatsCurrentGet = 0; + +static u8 *cheatsStack = NULL; +static u16 cheatsNumStack = 0; + +static void cheatsClear() +{ + memset(cheats, 0, sizeof(cheats)); + for (int i = 0; i < MAX_CHEAT_LIST; i++) + cheats[i].type = 0xFF; + cheatsNum = 0; + cheatsCurrentGet = 0; +} + +void cheatsInit(char *path) +{ + cheatsClear(); + strcpy((char *)cheatFilename, path); + + if (cheatsStack) delete [] cheatsStack; + cheatsStack = NULL; + + cheatsLoad(); +} + +BOOL cheatsAdd(u8 size, u32 address, u32 val, char *description, BOOL enabled) +{ + if (cheatsNum == MAX_CHEAT_LIST) return FALSE; + cheats[cheatsNum].hi[0] = address & 0x00FFFFFF; + cheats[cheatsNum].lo[0] = val; + cheats[cheatsNum].num = 1; + cheats[cheatsNum].type = 0; + cheats[cheatsNum].size = size; + strcpy(cheats[cheatsNum].description, description); + cheats[cheatsNum].enabled = enabled; + cheatsNum++; + return TRUE; +} + +BOOL cheatsUpdate(u8 size, u32 address, u32 val, char *description, BOOL enabled, u32 pos) +{ + if (pos > cheatsNum) return FALSE; + cheats[pos].hi[0] = address & 0x00FFFFFF; + cheats[pos].lo[0] = val; + cheats[pos].num = 1; + cheats[pos].type = 0; + cheats[pos].size = size; + strcpy(cheats[pos].description, description); + cheats[pos].enabled = enabled; + return TRUE; +} + +static void cheats_ARparser(CHEATS_LIST cheat) +{ + u8 type = 0; + u8 subtype = 0; + u32 hi = 0; + u32 lo = 0; + u32 addr = 0; + u32 val = 0; + // AR temporary vars & flags + u32 offset = 0; + u32 datareg = 0; + u32 loopcount = 0; + u32 counter = 0; + u32 if_flag = 0; + s32 loopbackline = 0; + u32 loop_flag = 0; + + for (int i=0; i < cheat.num; i++) + { + type = cheat.hi[i] >> 28; + subtype = (cheat.hi[i] >> 24) & 0x0F; + + hi = cheat.hi[i] & 0x0FFFFFFF; + lo = cheat.lo[i]; + + if (if_flag > 0) + { + if ( (type == 0x0D) && (subtype == 0)) if_flag--; // ENDIF + if ( (type == 0x0D) && (subtype == 2)) // NEXT & Flush + { + if (loop_flag) + i = (loopbackline-1); + else + { + offset = 0; + datareg = 0; + loopcount = 0; + counter = 0; + if_flag = 0; + loop_flag = 0; + } + } + continue; + } + + switch (type) + { + case 0x00: + { + if (hi==0) + { + //manual hook + } + else + if ((hi==0x0000AA99) && (lo==0)) + { + //parameter bytes 9..10 for above code (padded with 00s) + } + else + { + addr = hi + offset; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20], lo); + } + } + break; + + case 0x01: + addr = hi + offset; + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20], lo & 0x0000FFFF); + break; + + case 0x02: + addr = hi + offset; + T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20], lo & 0x000000FF); + break; + + case 0x03: + val = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]); + if ( lo > val ) + { + if (if_flag > 0) if_flag--; + } + else + { + if_flag++; + } + break; + + case 0x04: + val = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]); + if ( lo < val ) + { + if (if_flag > 0) if_flag--; + } + else + { + if_flag++; + } + break; + + case 0x05: + val = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]); + if ( lo == val ) + { + if (if_flag > 0) if_flag--; + } + else + { + if_flag++; + } + break; + + case 0x06: + val = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]); + if ( lo != val ) + { + if (if_flag > 0) if_flag--; + } + else + { + if_flag++; + } + break; + + case 0x07: + val = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]) & 0x0000FFFF; + if ( (lo & 0xFFFF) > ( (~(lo >> 16)) & val) ) + { + if (if_flag > 0) if_flag--; + } + else + { + if_flag++; + } + break; + + case 0x08: + val = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]) & 0x0000FFFF; + if ( (lo & 0xFFFF) < ( (~(lo >> 16)) & val) ) + { + if (if_flag > 0) if_flag--; + } + else + { + if_flag++; + } + break; + + case 0x09: + val = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]); + if ( (lo & 0xFFFF) == ( (~(lo >> 16)) & val) ) + { + if (if_flag > 0) if_flag--; + } + else + { + if_flag++; + } + break; + + case 0x0A: + val = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][hi>>20], hi & MMU.MMU_MASK[ARMCPU_ARM9][hi>>20]) & 0x0000FFFF; + if ( (lo & 0xFFFF) != ( (~(lo >> 16)) & val) ) + { + if (if_flag > 0) if_flag--; + } + else + { + if_flag++; + } + break; + + case 0x0B: + addr = hi + offset; + offset = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20]); + break; + + case 0x0C: + switch (subtype) + { + case 0x0: + if (loopcount < (lo+1)) + loop_flag = 1; + else + loop_flag = 0; + loopcount++; + loopbackline = i; + break; + + case 0x4: + break; + + case 0x5: + counter++; + if ( (counter & (lo & 0xFFFF)) == ((lo >> 8) & 0xFFFF) ) + { + if (if_flag > 0) if_flag--; + } + else + { + if_flag++; + } + break; + + case 0x6: + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][lo>>20], lo & MMU.MMU_MASK[ARMCPU_ARM9][lo>>20], offset); + break; + } + break; + + case 0x0D: + { + switch (subtype) + { + case 0x0: + break; + + case 0x1: + if (loop_flag) + i = (loopbackline-1); + break; + + case 0x2: + if (loop_flag) + i = (loopbackline-1); + else + { + offset = 0; + datareg = 0; + loopcount = 0; + counter = 0; + if_flag = 0; + loop_flag = 0; + } + break; + + case 0x3: + offset = lo; + break; + + case 0x4: + datareg += lo; + break; + + case 0x5: + datareg = lo; + break; + + case 0x6: + addr = lo + offset; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20], datareg); + offset += 4; + break; + + case 0x7: + addr = lo + offset; + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20], datareg & 0x0000FFFF); + offset += 2; + break; + + case 0x8: + addr = lo + offset; + T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20], datareg & 0x000000FF); + offset += 1; + break; + + case 0x9: + addr = lo + offset; + datareg = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20]); + break; + + case 0xA: + addr = lo + offset; + datareg = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20]) & 0x0000FFFF; + break; + + case 0xB: + addr = lo + offset; + datareg = T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][addr>>20], addr & MMU.MMU_MASK[ARMCPU_ARM9][addr>>20]) & 0x000000FF; + break; + + case 0xC: + offset += lo; + break; + } + } + break; + + case 0xE: + for (u32 t = 0; t < lo; t++) + { + u8 tmp = T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][(hi+t)>>20], (hi+t) & MMU.MMU_MASK[ARMCPU_ARM9][(hi+t)>>20]); + T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM9][(offset+t)>>20], (offset+t) & MMU.MMU_MASK[ARMCPU_ARM9][(offset+t)>>20], tmp); + } + break; + + case 0xF: + for (u32 t = 0; t < lo; t++) + { + u8 tmp = T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][(offset+t)>>20], (offset+t) & MMU.MMU_MASK[ARMCPU_ARM9][(offset+t)>>20]); + T1WriteByte(MMU.MMU_MEM[ARMCPU_ARM9][(hi+t)>>20], (hi+t) & MMU.MMU_MASK[ARMCPU_ARM9][(hi+t)>>20], tmp); + } + break; + //default: INFO("AR: ERROR uknown command 0x%2X at %08X:%08X\n", type, hi, lo); break; + } + } +} + +static BOOL cheatsXXcodePreparser(CHEATS_LIST *cheat, char *code) +{ + u16 count = 0; + u16 t = 0; + char tmp_buf[sizeof(cheat->hi)+sizeof(cheat->lo)]; + + memset(tmp_buf, 0, sizeof(tmp_buf)); + // remove wrong chars + for (unsigned int i=0; i < strlen(code); i++) + { + switch (code[i]) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'a': + case 'B': + case 'b': + case 'C': + case 'c': + case 'D': + case 'd': + case 'E': + case 'e': + case 'F': + case 'f': + tmp_buf[t] = code[i]; + t++; + break; + } + } + + if ((strlen(tmp_buf) % 8) != 0) return FALSE; // error + if ((strlen(tmp_buf) % 16) != 0) return FALSE; // error + + // TODO: syntax check + count = (strlen(tmp_buf) / 16); + for (int i=0; i < count; i++) + { + char buf[8] = {0}; + strncpy(buf, tmp_buf+(i*16), 8); + sscanf_s(buf, "%x", &cheat->hi[i]); + strncpy(buf, tmp_buf+(i*16) + 8, 8); + sscanf_s(buf, "%x", &cheat->lo[i]); + } + + cheat->num = count; + cheat->size = 0; + return TRUE; +} + +BOOL cheatsAdd_AR(char *code, char *description, BOOL enabled) +{ + if (cheatsNum == MAX_CHEAT_LIST) return FALSE; + + if (!cheatsXXcodePreparser(&cheats[cheatsNum], code)) return FALSE; + + cheats[cheatsNum].type = 1; + + strcpy(cheats[cheatsNum].description, description); + cheats[cheatsNum].enabled = enabled; + cheatsNum++; + return TRUE; +} + +BOOL cheatsUpdate_AR(char *code, char *description, BOOL enabled, u32 pos) +{ + if (pos > cheatsNum) return FALSE; + + if (code != NULL) + { + if (!cheatsXXcodePreparser(&cheats[pos], code)) return FALSE; + strcpy(cheats[pos].description, description); + cheats[pos].type = 1; + } + + cheats[pos].enabled = enabled; + return TRUE; +} + +BOOL cheatsAdd_CB(char *code, char *description, BOOL enabled) +{ + if (cheatsNum == MAX_CHEAT_LIST) return FALSE; + + if (!cheatsXXcodePreparser(&cheats[cheatsNum], code)) return FALSE; + + cheats[cheatsNum].type = 2; + + strcpy(cheats[cheatsNum].description, description); + cheats[cheatsNum].enabled = enabled; + cheatsNum++; + return TRUE; +} + +BOOL cheatsUpdate_CB(char *code, char *description, BOOL enabled, u32 pos) +{ + if (pos > cheatsNum) return FALSE; + + if (code != NULL) + { + if (!cheatsXXcodePreparser(&cheats[pos], code)) return FALSE; + cheats[pos].type = 2; + strcpy(cheats[pos].description, description); + } + cheats[pos].enabled = enabled; + return TRUE; +} + +BOOL cheatsRemove(u32 pos) +{ + if (pos > cheatsNum) return FALSE; + if (cheatsNum == 0) return FALSE; + + for (int i = pos; i < cheatsNum; i++) + memcpy(&cheats[i], &cheats[i+1], sizeof(CHEATS_LIST)); + + memset(&cheats[cheatsNum], 0, sizeof(CHEATS_LIST)); + + cheatsNum--; + return TRUE; +} + +void cheatsGetListReset() +{ + cheatsCurrentGet = 0; + return; +} + +BOOL cheatsGetList(CHEATS_LIST *cheat) +{ + if (cheatsCurrentGet > cheatsNum) + { + cheatsCurrentGet = 0; + return FALSE; + } + memcpy(cheat, &cheats[cheatsCurrentGet++], sizeof(CHEATS_LIST)); + if (cheatsCurrentGet > cheatsNum) + { + cheatsCurrentGet = 0; + return FALSE; + } + return TRUE; +} + +BOOL cheatsGet(CHEATS_LIST *cheat, u32 pos) +{ + if (pos > cheatsNum) return FALSE; + memcpy(cheat, &cheats[pos], sizeof(CHEATS_LIST)); + return TRUE; +} + +u32 cheatsGetSize() +{ + return cheatsNum; +} + +BOOL cheatsSave() +{ + FILE *fcheat = fopen((char *)cheatFilename, "w"); + + if (fcheat) + { + fprintf(fcheat, "; DeSmuME cheat file. VERSION %i.%03i\n", CHEAT_VERSION_MAJOR, CHEAT_VERSION_MINOR); + fprintf(fcheat, "Name=%s\n", gameInfo.ROMserial); + fputs("; cheats list\n", fcheat); + for (int i = 0; i < cheatsNum; i++) + { + fprintf(fcheat, "Desc=%s\n", cheats[i].description); + fprintf(fcheat, "Info=%i,%i,%i,%i\n", cheats[i].type, cheats[i].num, cheats[i].enabled, cheats[i].size); + + if (cheats[i].num > 0) + { + fprintf(fcheat, "Data="); + for (int t = 0; t < cheats[i].num; t++) + { + fprintf(fcheat, "%08X%08X", cheats[i].hi[t], cheats[i].lo[t]); + if (t < (cheats[i].num - 1)) fputs(",", fcheat); + } + fputs("\n", fcheat); + } + fputs("\n", fcheat); + } + + fclose(fcheat); + return TRUE; + } + + return FALSE; +} + +BOOL cheatsLoad() +{ + FILE *fcheat = fopen((char *)cheatFilename, "r"); + char buf[1024]; + int last=0; + if (fcheat) + { + cheatsClear(); + memset(buf, 0, 1024); + + while (!feof(fcheat)) + { + fgets(buf, 1024, fcheat); + if (buf[0] == ';') continue; + removeCR((char *)&buf); + if (!strlen_ws(buf)) continue; + if ( (buf[0] == 'D') && + (buf[1] == 'e') && + (buf[2] == 's') && + (buf[3] == 'c') && + (buf[4] == '=') ) // new cheat block + { + strncpy((char *)cheats[last].description, (char *)buf+5, strlen(buf)-5); + fgets(buf, 1024, fcheat); + if ( (buf[0] == 'I') && + (buf[1] == 'n') && + (buf[2] == 'f') && + (buf[3] == 'o') && + (buf[4] == '=') ) // Info cheat + { + u32 dstart = 5; + u32 dsize = 0; + char bf[4] = { 0 }; + + while ( (buf[dstart+dsize] != ',') && (buf[dstart+dsize]!=0)) { dsize++; }; + if (buf[dstart+dsize]==0) continue; // error + strncpy(bf, (char*)buf+dstart, dsize); + cheats[last].type=atoi(bf); + dstart += (dsize+1); dsize=0; + while ( (buf[dstart+dsize] != ',') && (buf[dstart+dsize]!=0)) { dsize++; }; + if (buf[dstart+dsize]==0) continue; // error + strncpy(bf, (char*)buf+dstart, dsize); + dstart += (dsize+1); dsize=0; + cheats[last].num=atoi(bf); + while ( (buf[dstart+dsize] != ',') && (buf[dstart+dsize]!=0)) { dsize++; }; + if (buf[dstart+dsize]==0) continue; // error + strncpy(bf, (char*)(buf+dstart), dsize); + dstart += (dsize+1); dsize=0; + cheats[last].enabled=atoi(bf); + while ( (buf[dstart+dsize] != ',') && (buf[dstart+dsize]!=0)) { dsize++; }; + strncpy(bf, (char*)buf+dstart, dsize); + cheats[last].size=atoi(bf); + fgets(buf, 1024, fcheat); + if ( (buf[0] == 'D') && + (buf[1] == 'a') && + (buf[2] == 't') && + (buf[3] == 'a') && + (buf[4] == '=') ) // Data cheat + { + int offs = 5; + char tmp_buf[9]; + memset(tmp_buf, 0, 9); + + for (int j=0; j> 3); + u32 offs = (i % 8); + if (searchStatMem[addr] & (1<> 3); + u32 offs = (i % 8); + if (searchStatMem[addr] & (3<> 3); + u32 offs = (i % 8); + if (searchStatMem[addr] & (0x7<> 3); + u32 offs = (i % 8); + if (searchStatMem[addr] & (0xF<> 3); + u32 offs = (i % 8); + if (searchStatMem[addr] & (1< T1ReadByte(searchMem, i)); break; + case 1: res=(T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) < T1ReadByte(searchMem, i)); break; + case 2: res=(T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) == T1ReadByte(searchMem, i)); break; + case 3: res=(T1ReadByte(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) != T1ReadByte(searchMem, i)); break; + default: res = FALSE; break; + } + if ( res ) + { + searchStatMem[addr] |= (1<> 3); + u32 offs = (i % 8); + if (searchStatMem[addr] & (3< T1ReadWord(searchMem, i)); break; + case 1: res=(T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) < T1ReadWord(searchMem, i)); break; + case 2: res=(T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) == T1ReadWord(searchMem, i)); break; + case 3: res=(T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) != T1ReadWord(searchMem, i)); break; + default: res = FALSE; break; + } + if ( res ) + { + searchStatMem[addr] |= (3<> 3); + u32 offs = (i % 8); + if (searchStatMem[addr] & (7< (T1ReadLong(searchMem, i) & 0x00FFFFFF) ); break; + case 1: res=((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) & 0x00FFFFFF) < (T1ReadLong(searchMem, i) & 0x00FFFFFF) ); break; + case 2: res=((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) & 0x00FFFFFF) == (T1ReadLong(searchMem, i) & 0x00FFFFFF) ); break; + case 3: res=((T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) & 0x00FFFFFF) != (T1ReadLong(searchMem, i) & 0x00FFFFFF) ); break; + default: res = FALSE; break; + } + if ( res ) + { + searchStatMem[addr] |= (7<> 3); + u32 offs = (i % 8); + if (searchStatMem[addr] & (0xF< T1ReadLong(searchMem, i)); break; + case 1: res=(T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) < T1ReadLong(searchMem, i)); break; + case 2: res=(T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) == T1ReadLong(searchMem, i)); break; + case 3: res=(T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x20], i) != T1ReadLong(searchMem, i)); break; + default: res = FALSE; break; + } + if ( res ) + { + searchStatMem[addr] |= (0xF<> 3); + u32 offs = (i % 8); + if (searchStatMem[addr] & (stepMem< -#include -#include -#include - - -#ifndef VERSION -#define VERSION "Unknown version" -#endif - -/* - * FIXME: Not sure how to detect OpenGL in a platform portable way. - */ -#ifdef HAVE_GL_GL_H -#define INCLUDE_OPENGL_2D -#endif - -#ifdef INCLUDE_OPENGL_2D -#include -#include -#endif - -#ifndef CLI_UI -#define CLI_UI -#endif - -#include "../MMU.h" -#include "../NDSSystem.h" -#include "../debug.h" -#include "../sndsdl.h" -#include "../ctrlssdl.h" -#include "../render3D.h" -#include "../rasterize.h" -#include "../saves.h" -#include "../mic.h" -#include "../GPU_osd.h" -#ifdef GDB_STUB -#include "../gdbstub.h" -#endif - -volatile bool execute = false; - -static float nds_screen_size_ratio = 1.0f; - -#define DISPLAY_FPS - -#ifdef DISPLAY_FPS -#define NUM_FRAMES_TO_TIME 60 -#endif - - -#define FPS_LIMITER_FRAME_PERIOD 8 - -static SDL_Surface * surface; - -/* Flags to pass to SDL_SetVideoMode */ -static int sdl_videoFlags; - -SoundInterface_struct *SNDCoreList[] = { - &SNDDummy, - &SNDDummy, - &SNDSDL, - NULL -}; - -GPU3DInterface *core3DList[] = { -&gpu3DNull, -&gpu3DRasterize, -NULL -}; - -const char * save_type_names[] = { - "Autodetect", - "EEPROM 4kbit", - "EEPROM 64kbit", - "EEPROM 512kbit", - "FRAM 256kbit", - "FLASH 2mbit", - "FLASH 4mbit", - NULL -}; - - -/* Our keyboard config is different because of the directional keys */ -/* Please note that m is used for fake microphone */ -const u16 cli_kb_cfg[NB_KEYS] = - { - SDLK_x, // A - SDLK_z, // B - SDLK_RSHIFT, // select - SDLK_RETURN, // start - SDLK_RIGHT, // Right - SDLK_LEFT, // Left - SDLK_UP, // Up - SDLK_DOWN, // Down - SDLK_w, // R - SDLK_q, // L - SDLK_s, // X - SDLK_a, // Y - SDLK_p, // DEBUG - SDLK_o // BOOST - }; - -#ifdef FAKE_MIC -static BOOL enable_fake_mic; -#endif - -struct my_config { - int load_slot; - u16 arm9_gdb_port; - u16 arm7_gdb_port; - - int disable_sound; - int engine_3d; - - int savetype; - -#ifdef INCLUDE_OPENGL_2D - int opengl_2d; - int soft_colour_convert; -#endif - int auto_pause; - int disable_limiter; - int frameskip; - int fps_limiter_frame_period; - - int firmware_language; - - const char *nds_file; - const char *cflash_disk_image_file; -}; - -static void -init_config( struct my_config *config) { - config->load_slot = 0; - - config->arm9_gdb_port = 0; - config->arm7_gdb_port = 0; - - config->disable_sound = 0; - - config->auto_pause = 0; - config->disable_limiter = 0; - config->frameskip = 0; - config->fps_limiter_frame_period = FPS_LIMITER_FRAME_PERIOD; - - config->nds_file = NULL; - - config->cflash_disk_image_file = NULL; - - config->engine_3d = 1; - config->savetype = 0; - -#ifdef INCLUDE_OPENGL_2D - config->opengl_2d = 0; - config->soft_colour_convert = 0; -#endif - - /* use the default language */ - config->firmware_language = -1; -} - - -static int -fill_config( struct my_config *config, - int argc, char ** argv) { - int good_args = 1; - int print_usage = 0; - int i; - - for ( i = 1; i < argc && good_args; i++) { - if ( strcmp( argv[i], "--help") == 0) { - printf( "USAGE: %s [options] \n", argv[0]); - printf( "OPTIONS:\n"); - printf( " --load-slot=NUM Loads savegame from slot NUM\n"); - printf( " --auto-pause Pause emulation of focus is lost.\n"); - printf( " --disable-sound Disables the sound emulation\n"); - printf( " --disable-limiter Disables the 60 fps limiter\n"); - printf( " --frameskip=N Set frameskip to N\n"); - printf( " --limiter-period=N Set frame period of the fps limiter to N (default: %d)\n", FPS_LIMITER_FRAME_PERIOD); - printf( " --3d-engine=ENGINE Select 3d rendering engine, available ENGINES:\n"); - printf( " 0 = 3d disabled\n"); - printf( " 1 = internal desmume software rasterizer (default)\n"); -#ifdef INCLUDE_OPENGL_2D - printf( " --opengl-2d Enables using OpenGL for screen rendering\n"); - printf( " --soft-convert Use software colour conversion during OpenGL\n"); - printf( " screen rendering. May produce better or worse\n"); - printf( " frame rates depending on hardware.\n"); -#endif - printf( "\n"); - printf( " --save-type=TYPE Select savetype from the following:\n"); - for(int jj = 0; save_type_names[jj] != NULL; jj++){ - printf(" %d = %s\n",jj,save_type_names[jj]); - } - - printf( "\n"); - printf( " --fwlang=LANG Set the language in the firmware, LANG as follows:\n"); - printf( " 0 = Japanese\n"); - printf( " 1 = English\n"); - printf( " 2 = French\n"); - printf( " 3 = German\n"); - printf( " 4 = Italian\n"); - printf( " 5 = Spanish\n"); - printf( "\n"); -#ifdef GDB_STUB - printf( " --arm9gdb=PORT_NUM Enable the ARM9 GDB stub on the given port\n"); - printf( " --arm7gdb=PORT_NUM Enable the ARM7 GDB stub on the given port\n"); -#endif - //printf( " --sticky Enable sticky keys and stylus\n"); - printf( "\n"); - printf( " --cflash=PATH_TO_DISK_IMAGE\n"); - printf( " Enable disk image GBAMP compact flash emulation\n"); - printf( "\n"); - printf( " --help Display this message\n"); - printf( " --version Display the version\n"); - good_args = 0; - } - else if ( strcmp( argv[i], "--version") == 0) { - printf( "%s\n", VERSION); - good_args = 0; - } - else if ( strncmp( argv[i], "--load-slot=", 12) == 0) { - long slot = strtol( &argv[i][12], NULL, 10 ); - if(slot >= 0 && slot <= 10) - config->load_slot = slot; - else - printf("Invalid slot number %ld\n", slot); - } - else if ( strcmp( argv[i], "--disable-sound") == 0) { - config->disable_sound = 1; - } -#ifdef INCLUDE_OPENGL_2D - else if ( strcmp( argv[i], "--opengl-2d") == 0) { - config->opengl_2d = 1; - } - else if ( strcmp( argv[i], "--soft-convert") == 0) { - config->soft_colour_convert = 1; - } -#endif - else if ( strcmp( argv[i], "--auto-pause") == 0) { - config->auto_pause = 1; - } - else if ( strcmp( argv[i], "--disable-limiter") == 0) { - config->disable_limiter = 1; - } - else if ( strncmp( argv[i], "--frameskip=", 12) == 0) { - char *end_char; - int frameskip = strtoul(&argv[i][12], &end_char, 10); - - if ( frameskip >= 0 ) { - config->frameskip = frameskip; - } - else { - fprintf(stderr, "frameskip must be >=0\n"); - good_args = 0; - } - } - else if ( strncmp( argv[i], "--limiter-period=", 17) == 0) { - char *end_char; - int period = strtoul(&argv[i][17], &end_char, 10); - - if ( period >= 0 && period <= 30 ) { - config->fps_limiter_frame_period = period; - } - else { - fprintf(stderr, "fps lmiter period must be >=0 and <= 30!\n"); - good_args = 0; - } - } - else if ( strncmp( argv[i], "--3d-engine=", 12) == 0) { - char *end_char; - int engine = strtoul( &argv[i][12], &end_char, 10); - - if ( engine == 0 || engine == 1) { - config->engine_3d = engine; - } - else { - fprintf( stderr, "3d engine can be 0 or 1\n"); - good_args = 0; - } - } - else if ( strncmp( argv[i], "--save-type=", 12) == 0) { - char *end_char; - int savetype = strtoul( &argv[i][12], &end_char, 10); - int last = sizeof(save_type_names)/sizeof(const char * )-2; // NULL terminator, 0-based - - if ( savetype >= 0 && savetype <= last) { - config->savetype = savetype; - } - else { - fprintf( stderr, "savetype can be 0-%d\n",last); - good_args = 0; - } - } - else if ( strncmp( argv[i], "--fwlang=", 9) == 0) { - char *end_char; - int lang = strtoul( &argv[i][9], &end_char, 10); - - if ( lang >= 0 && lang <= 5) { - config->firmware_language = lang; - } - else { - fprintf( stderr, "Firmware language must be set to a value from 0 to 5.\n"); - good_args = 0; - } - } -#ifdef GDB_STUB - else if ( strncmp( argv[i], "--arm9gdb=", 10) == 0) { - char *end_char; - unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); - - if ( port_num > 0 && port_num < 65536) { - config->arm9_gdb_port = port_num; - } - else { - fprintf( stderr, "ARM9 GDB stub port must be in the range 1 to 65535\n"); - good_args = 0; - } - } - else if ( strncmp( argv[i], "--arm7gdb=", 10) == 0) { - char *end_char; - unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); - - if ( port_num > 0 && port_num < 65536) { - config->arm7_gdb_port = port_num; - } - else { - fprintf( stderr, "ARM7 GDB stub port must be in the range 1 to 65535\n"); - good_args = 0; - } - } -#endif - else if ( strncmp( argv[i], "--cflash=", 9) == 0) { - if ( config->cflash_disk_image_file == NULL) { - config->cflash_disk_image_file = &argv[i][9]; - } - else { - fprintf( stderr, "CFlash disk image file (\"%s\") already set\n", - config->cflash_disk_image_file); - good_args = 0; - } - } - else { - if ( config->nds_file == NULL) { - config->nds_file = argv[i]; - } - else { - fprintf( stderr, "NDS file (\"%s\") already set\n", config->nds_file); - good_args = 0; - } - } - } - - if ( good_args) { - if ( config->nds_file == NULL) { - print_usage = 1; - good_args = 0; - } - } - - if ( print_usage) { - fprintf( stderr, "USAGE: %s \n %s --help for more info\n", argv[0], argv[0]); - } - - return good_args; -} - -/* - * The thread handling functions needed by the GDB stub code. - */ -#ifdef GDB_STUB -void * -createThread_gdb( void (*thread_function)( void *data), - void *thread_data) { - SDL_Thread *new_thread = SDL_CreateThread( (int (*)(void *data))thread_function, - thread_data); - - return new_thread; -} - -void -joinThread_gdb( void *thread_handle) { - int ignore; - SDL_WaitThread( (SDL_Thread*)thread_handle, &ignore); -} -#endif - - - -/** - * A SDL timer callback function. Signals the supplied SDL semaphore - * if its value is small. - * - * @param interval The interval since the last call (in ms) - * @param param The pointer to the semaphore. - * - * @return The interval to the next call (required by SDL) - */ -static Uint32 -fps_limiter_fn( Uint32 interval, void *param) { - SDL_sem *sdl_semaphore = (SDL_sem *)param; - - /* signal the semaphore if it is getting low */ - if ( SDL_SemValue( sdl_semaphore) < 4) { - SDL_SemPost( sdl_semaphore); - } - - return interval; -} - - -#ifdef INCLUDE_OPENGL_2D -/* initialization openGL function */ -static int -initGL( GLuint *screen_texture) { - GLenum errCode; - u16 blank_texture[256 * 512]; - - memset(blank_texture, 0x001f, sizeof(blank_texture)); - - /* Enable Texture Mapping */ - glEnable( GL_TEXTURE_2D ); - - /* Set the background black */ - glClearColor( 0.0f, 0.0f, 0.0f, 0.5f ); - - /* Depth buffer setup */ - glClearDepth( 1.0f ); - - /* Enables Depth Testing */ - glEnable( GL_DEPTH_TEST ); - - /* The Type Of Depth Test To Do */ - glDepthFunc( GL_LEQUAL ); - - /* Create The Texture */ - glGenTextures( 1, &screen_texture[0]); - - glBindTexture( GL_TEXTURE_2D, screen_texture[0]); - - /* Generate The Texture */ - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 256, 512, - 0, GL_RGBA, - GL_UNSIGNED_SHORT_1_5_5_5_REV, - blank_texture); - - /* Linear Filtering */ - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - - if ((errCode = glGetError()) != GL_NO_ERROR) { - const GLubyte *errString; - - errString = gluErrorString(errCode); - fprintf( stderr, "Failed to init GL: %s\n", errString); - - return 0; - } - - return 1; -} - -static void -resizeWindow( u16 width, u16 height) { - int comp_width = 3 * width; - int comp_height = 2 * height; - int use_width = 1; - GLenum errCode; - - /* Height / width ration */ - GLfloat ratio; - - if ( comp_width > comp_height) { - use_width = 0; - } - - /* Protect against a divide by zero */ - if ( height == 0 ) - height = 1; - if ( width == 0) - width = 1; - - ratio = ( GLfloat )width / ( GLfloat )height; - - /* Setup our viewport. */ - glViewport( 0, 0, ( GLint )width, ( GLint )height ); - - /* - * change to the projection matrix and set - * our viewing volume. - */ - glMatrixMode( GL_PROJECTION ); - glLoadIdentity( ); - - { - double left; - double right; - double bottom; - double top; - double other_dimen; - - if ( use_width) { - left = 0.0; - right = 256.0; - - nds_screen_size_ratio = 256.0 / (double)width; - - other_dimen = (double)width * 3.0 / 2.0; - - top = 0.0; - bottom = 384.0 * ((double)height / other_dimen); - } - else { - top = 0.0; - bottom = 384.0; - - nds_screen_size_ratio = 384.0 / (double)height; - - other_dimen = (double)height * 2.0 / 3.0; - - left = 0.0; - right = 256.0 * ((double)width / other_dimen); - } - - /* get the area (0,0) to (256,384) into the middle of the viewport */ - gluOrtho2D( left, right, bottom, top); - } - - /* Make sure we're chaning the model view and not the projection */ - glMatrixMode( GL_MODELVIEW ); - - /* Reset The View */ - glLoadIdentity( ); - - if ((errCode = glGetError()) != GL_NO_ERROR) { - const GLubyte *errString; - - errString = gluErrorString(errCode); - fprintf( stderr, "GL resize failed: %s\n", errString); - } - - surface = SDL_SetVideoMode( width, height, 32, - sdl_videoFlags ); -} - - -static void -opengl_Draw( GLuint *texture, int software_convert) { - GLenum errCode; - - /* Clear The Screen And The Depth Buffer */ - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - - /* Move Into The Screen 5 Units */ - glLoadIdentity( ); - - /* Select screen Texture */ - glBindTexture( GL_TEXTURE_2D, texture[0]); - if ( software_convert) { - int i; - u8 converted[256 * 384 * 3]; - - for ( i = 0; i < (256 * 384); i++) { - converted[(i * 3) + 0] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 0) & 0x1f) << 3; - converted[(i * 3) + 1] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 5) & 0x1f) << 3; - converted[(i * 3) + 2] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 10) & 0x1f) << 3; - } - - glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384, - GL_RGB, - GL_UNSIGNED_BYTE, - converted); - } - else { - glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384, - GL_RGBA, - GL_UNSIGNED_SHORT_1_5_5_5_REV, - &GPU_screen); - } - - if ((errCode = glGetError()) != GL_NO_ERROR) { - const GLubyte *errString; - - errString = gluErrorString(errCode); - fprintf( stderr, "GL subimage failed: %s\n", errString); - } - - - /* Draw the screen as a textured quad */ - glBegin( GL_QUADS); - glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0.0f, 0.0f, 0.0f ); - glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 256.0f, 0.0f, 0.0f ); - glTexCoord2f( 1.0f, 0.75f ); glVertex3f( 256.0f, 384.0f, 0.0f ); - glTexCoord2f( 0.0f, 0.75f ); glVertex3f( 0.0f, 384.0f, 0.0f ); - glEnd( ); - - if ((errCode = glGetError()) != GL_NO_ERROR) { - const GLubyte *errString; - - errString = gluErrorString(errCode); - fprintf( stderr, "GL draw failed: %s\n", errString); - } - - /* Draw it to the screen */ - SDL_GL_SwapBuffers( ); -} -#endif - -static void -Draw( void) { - SDL_Surface *rawImage; - - rawImage = SDL_CreateRGBSurfaceFrom((void*)&GPU_screen, 256, 384, 16, 512, 0x001F, 0x03E0, 0x7C00, 0); - if(rawImage == NULL) return; - - SDL_BlitSurface(rawImage, 0, surface, 0); - - SDL_UpdateRect(surface, 0, 0, 0, 0); - - SDL_FreeSurface(rawImage); - return; -} - -static void desmume_cycle(int *sdl_quit, int *boost, struct my_config * my_config) -{ - static unsigned short keypad; - static int focused = 1; - SDL_Event event; - - /* Look for queued events and update keypad status */ - /* IMPORTANT: Reenable joystick events iif needed. */ - if(SDL_JoystickEventState(SDL_QUERY) == SDL_IGNORE) - SDL_JoystickEventState(SDL_ENABLE); - - /* There's an event waiting to be processed? */ - while ( !*sdl_quit && - (SDL_PollEvent(&event) || (!focused && SDL_WaitEvent(&event)))) - { - process_ctrls_event( event, &keypad, nds_screen_size_ratio); - - switch (event.type) - { -#ifdef INCLUDE_OPENGL_2D - case SDL_VIDEORESIZE: - resizeWindow( event.resize.w, event.resize.h); - break; -#endif - case SDL_ACTIVEEVENT: - if (my_config->auto_pause && (event.active.state & SDL_APPINPUTFOCUS )) - { - if (event.active.gain) - { - focused = 1; - SPU_Pause(0); - osd->addLine("Auto pause disabled\n"); - } - else - { - focused = 0; - SPU_Pause(1); - } - } - break; - - case SDL_KEYUP: - switch (event.key.keysym.sym) - { - case SDLK_ESCAPE: - *sdl_quit = 1; - break; -#ifdef FAKE_MIC - case SDLK_m: - enable_fake_mic = !enable_fake_mic; - Mic_DoNoise(enable_fake_mic); - if (enable_fake_mic) - osd->addLine("Fake mic enabled\n"); - else - osd->addLine("Fake mic disabled\n"); - break; -#endif - case SDLK_o: - *boost = !(*boost); - if (*boost) - osd->addLine("Boost mode enabled\n"); - else - osd->addLine("Boost mode disabled\n"); - break; - default: - break; - } - break; - - case SDL_QUIT: - *sdl_quit = 1; - break; - } - } - - /* Update mouse position and click */ - if(mouse.down) NDS_setTouchPos(mouse.x, mouse.y); - if(mouse.click) - { - NDS_releaseTouch(); - mouse.click = FALSE; - } - - update_keypad(keypad); /* Update keypad */ - NDS_exec(); - SPU_Emulate_user(); -} - -int main(int argc, char ** argv) { - struct my_config my_config; -#ifdef GDB_STUB - gdbstub_handle_t arm9_gdb_stub; - gdbstub_handle_t arm7_gdb_stub; - struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; - struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; - struct armcpu_ctrl_iface *arm9_ctrl_iface; - struct armcpu_ctrl_iface *arm7_ctrl_iface; -#endif - - int limiter_frame_counter = 0; - SDL_sem *fps_limiter_semaphore = NULL; - SDL_TimerID limiter_timer = NULL; - int sdl_quit = 0; - int boost = 0; - int error; - -#ifdef DISPLAY_FPS - u32 fps_timing = 0; - u32 fps_frame_counter = 0; - u32 fps_previous_time = 0; - u32 fps_temp_time; -#endif - -#ifdef INCLUDE_OPENGL_2D - GLuint screen_texture[1]; -#endif - /* this holds some info about our display */ - const SDL_VideoInfo *videoInfo; - - /* the firmware settings */ - struct NDS_fw_config_data fw_config; - - /* default the firmware settings, they may get changed later */ - NDS_FillDefaultFirmwareConfigData( &fw_config); - - init_config( &my_config); - - if ( !fill_config( &my_config, argc, argv)) { - exit(1); - } - - /* use any language set on the command line */ - if ( my_config.firmware_language != -1) { - fw_config.language = my_config.firmware_language; - } - -#ifdef GDB_STUB - if ( my_config.arm9_gdb_port != 0) { - arm9_gdb_stub = createStub_gdb( my_config.arm9_gdb_port, - &arm9_memio, - &arm9_direct_memory_iface); - - if ( arm9_gdb_stub == NULL) { - fprintf( stderr, "Failed to create ARM9 gdbstub on port %d\n", - my_config.arm9_gdb_port); - exit( 1); - } - } - if ( my_config.arm7_gdb_port != 0) { - arm7_gdb_stub = createStub_gdb( my_config.arm7_gdb_port, - &arm7_memio, - &arm7_base_memory_iface); - - if ( arm7_gdb_stub == NULL) { - fprintf( stderr, "Failed to create ARM7 gdbstub on port %d\n", - my_config.arm7_gdb_port); - exit( 1); - } - } -#endif - -#ifdef GDB_STUB - NDS_Init( arm9_memio, &arm9_ctrl_iface, - arm7_memio, &arm7_ctrl_iface); -#else - NDS_Init(); -#endif - - /* Create the dummy firmware */ - NDS_CreateDummyFirmware( &fw_config); - - if ( !my_config.disable_sound) { - SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); - } - - NDS_3D_ChangeCore(my_config.engine_3d); - - backup_setManualBackupType(my_config.savetype); - - error = NDS_LoadROM( my_config.nds_file ); - if (error < 0) { - fprintf(stderr, "error while loading %s\n", my_config.nds_file); - exit(-1); - } - - /* - * Activate the GDB stubs - * This has to come after the NDS_Init where the cpus are set up. - */ -#ifdef GDB_STUB - if ( my_config.arm9_gdb_port != 0) { - activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); - } - if ( my_config.arm7_gdb_port != 0) { - activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); - } -#endif - - execute = true; - - if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) - { - fprintf(stderr, "Error trying to initialize SDL: %s\n", - SDL_GetError()); - return 1; - } - SDL_WM_SetCaption("Desmume SDL", NULL); - - /* Fetch the video info */ - videoInfo = SDL_GetVideoInfo( ); - if ( !videoInfo ) { - fprintf( stderr, "Video query failed: %s\n", SDL_GetError( ) ); - exit( -1); - } - - /* This checks if hardware blits can be done */ - if ( videoInfo->blit_hw ) - sdl_videoFlags |= SDL_HWACCEL; - -#ifdef INCLUDE_OPENGL_2D - if ( my_config.opengl_2d) { - /* the flags to pass to SDL_SetVideoMode */ - sdl_videoFlags = SDL_OPENGL; /* Enable OpenGL in SDL */ - sdl_videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */ - sdl_videoFlags |= SDL_HWPALETTE; /* Store the palette in hardware */ - sdl_videoFlags |= SDL_RESIZABLE; /* Enable window resizing */ - - - /* This checks to see if surfaces can be stored in memory */ - if ( videoInfo->hw_available ) - sdl_videoFlags |= SDL_HWSURFACE; - else - sdl_videoFlags |= SDL_SWSURFACE; - - - /* Sets up OpenGL double buffering */ - SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); - - surface = SDL_SetVideoMode( 256, 192 * 2, 32, - sdl_videoFlags ); - - /* Verify there is a surface */ - if ( !surface ) { - fprintf( stderr, "Video mode set failed: %s\n", SDL_GetError( ) ); - exit( -1); - } - - - /* initialize OpenGL */ - if ( !initGL( screen_texture)) { - fprintf( stderr, "Failed to init GL, fall back to software render\n"); - - my_config.opengl_2d = 0; - } - } - - if ( !my_config.opengl_2d) { -#endif - sdl_videoFlags |= SDL_SWSURFACE; - surface = SDL_SetVideoMode(256, 384, 32, sdl_videoFlags); - - if ( !surface ) { - fprintf( stderr, "Video mode set failed: %s\n", SDL_GetError( ) ); - exit( -1); - } -#ifdef INCLUDE_OPENGL_2D - } - - /* set the initial window size */ - if ( my_config.opengl_2d) { - resizeWindow( 256, 192*2); - } -#endif - - /* Initialize joysticks */ - if(!init_joy()) return 1; - /* Load our own keyboard configuration */ - set_kb_keys(cli_kb_cfg); - - if ( !my_config.disable_limiter) { - /* create the semaphore used for fps limiting */ - fps_limiter_semaphore = SDL_CreateSemaphore( 1); - - /* start a SDL timer for every FPS_LIMITER_FRAME_PERIOD frames to keep us at 60 fps */ - if ( fps_limiter_semaphore != NULL) { - limiter_timer = SDL_AddTimer( 16 * my_config.fps_limiter_frame_period, - fps_limiter_fn, fps_limiter_semaphore); - } - - if ( limiter_timer == NULL) { - fprintf( stderr, "Error trying to start FPS limiter timer: %s\n", - SDL_GetError()); - if ( fps_limiter_semaphore != NULL) { - SDL_DestroySemaphore( fps_limiter_semaphore); - fps_limiter_semaphore = NULL; - } - return 1; - } - } - - if(my_config.load_slot){ - loadstate_slot(my_config.load_slot); - } - - Desmume_InitOnce(); - Hud.reset(); - - while(!sdl_quit) { - desmume_cycle(&sdl_quit, &boost, &my_config); - - osd->update(); - DrawHUD(); -#ifdef INCLUDE_OPENGL_2D - if ( my_config.opengl_2d) { - opengl_Draw( screen_texture, my_config.soft_colour_convert); - } - else -#endif - Draw(); - osd->clear(); - - for ( int i = 0; i < my_config.frameskip; i++ ) { - NDS_SkipNextFrame(); - desmume_cycle(&sdl_quit, &boost, &my_config); - } - - if ( !my_config.disable_limiter && !boost) { - limiter_frame_counter += 1 + my_config.frameskip; - if ( limiter_frame_counter >= my_config.fps_limiter_frame_period) { - limiter_frame_counter = 0; - - /* wait for the timer to expire */ - SDL_SemWait( fps_limiter_semaphore); - } - } - -#ifdef DISPLAY_FPS - fps_frame_counter += 1; - fps_temp_time = SDL_GetTicks(); - fps_timing += fps_temp_time - fps_previous_time; - fps_previous_time = fps_temp_time; - - if ( fps_frame_counter == NUM_FRAMES_TO_TIME) { - char win_title[20]; - float fps = (float)fps_timing; - fps /= NUM_FRAMES_TO_TIME * 1000.f; - fps = 1.0f / fps; - - fps_frame_counter = 0; - fps_timing = 0; - - snprintf( win_title, sizeof(win_title), "Desmume %f", fps); - - SDL_WM_SetCaption( win_title, NULL); - } -#endif - } - - - - /* Unload joystick */ - uninit_joy(); - - if ( !my_config.disable_limiter) { - /* tidy up the FPS limiter timer and semaphore */ - SDL_RemoveTimer( limiter_timer); - SDL_DestroySemaphore( fps_limiter_semaphore); - } - - SDL_Quit(); - NDS_DeInit(); - -#ifdef GDB_STUB - if ( my_config.arm9_gdb_port != 0) { - destroyStub_gdb( arm9_gdb_stub); - } - if ( my_config.arm7_gdb_port != 0) { - destroyStub_gdb( arm7_gdb_stub); - } -#endif - - return 0; -} +/* main.c - this file is part of DeSmuME + * + * Copyright (C) 2006,2007 DeSmuME Team + * Copyright (C) 2007 Pascal Giard (evilynux) + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#include +#include +#include +#include + + +#ifndef VERSION +#define VERSION "Unknown version" +#endif + +/* + * FIXME: Not sure how to detect OpenGL in a platform portable way. + */ +#ifdef HAVE_GL_GL_H +#define INCLUDE_OPENGL_2D +#endif + +#ifdef INCLUDE_OPENGL_2D +#include +#include +#endif + +#ifndef CLI_UI +#define CLI_UI +#endif + +#include "../MMU.h" +#include "../NDSSystem.h" +#include "../debug.h" +#include "../sndsdl.h" +#include "../ctrlssdl.h" +#include "../render3D.h" +#include "../rasterize.h" +#include "../saves.h" +#include "../mic.h" +#ifdef GDB_STUB +#include "../gdbstub.h" +#endif + +volatile BOOL execute = FALSE; + +static float nds_screen_size_ratio = 1.0f; + +#define DISPLAY_FPS + +#ifdef DISPLAY_FPS +#define NUM_FRAMES_TO_TIME 60 +#endif + + +#define FPS_LIMITER_FRAME_PERIOD 8 + +static SDL_Surface * surface; + +/* Flags to pass to SDL_SetVideoMode */ +static int sdl_videoFlags; + +SoundInterface_struct *SNDCoreList[] = { + &SNDDummy, + &SNDDummy, + &SNDSDL, + NULL +}; + +GPU3DInterface *core3DList[] = { +&gpu3DNull, +&gpu3DRasterize, +NULL +}; + +const char * save_type_names[] = { + "Autodetect", + "EEPROM 4kbit", + "EEPROM 64kbit", + "EEPROM 512kbit", + "FRAM 256kbit", + "FLASH 2mbit", + "FLASH 4mbit", + NULL +}; + + +/* Our keyboard config is different because of the directional keys */ +/* Please note that m is used for fake microphone */ +const u16 cli_kb_cfg[NB_KEYS] = + { + SDLK_x, // A + SDLK_z, // B + SDLK_RSHIFT, // select + SDLK_RETURN, // start + SDLK_RIGHT, // Right + SDLK_LEFT, // Left + SDLK_UP, // Up + SDLK_DOWN, // Down + SDLK_w, // R + SDLK_q, // L + SDLK_s, // X + SDLK_a, // Y + SDLK_p, // DEBUG + SDLK_o // BOOST + }; + +#ifdef FAKE_MIC +static BOOL enable_fake_mic; +#endif + +struct my_config { + int load_slot; + u16 arm9_gdb_port; + u16 arm7_gdb_port; + + int disable_sound; + int engine_3d; + + int savetype; + +#ifdef INCLUDE_OPENGL_2D + int opengl_2d; + int soft_colour_convert; +#endif + int auto_pause; + int disable_limiter; + int frameskip; + int fps_limiter_frame_period; + + int firmware_language; + + const char *nds_file; + const char *cflash_disk_image_file; +}; + +static void +init_config( struct my_config *config) { + config->load_slot = 0; + + config->arm9_gdb_port = 0; + config->arm7_gdb_port = 0; + + config->disable_sound = 0; + + config->auto_pause = 0; + config->disable_limiter = 0; + config->frameskip = 0; + config->fps_limiter_frame_period = FPS_LIMITER_FRAME_PERIOD; + + config->nds_file = NULL; + + config->cflash_disk_image_file = NULL; + + config->engine_3d = 1; + config->savetype = 0; + +#ifdef INCLUDE_OPENGL_2D + config->opengl_2d = 0; + config->soft_colour_convert = 0; +#endif + + /* use the default language */ + config->firmware_language = -1; +} + + +static int +fill_config( struct my_config *config, + int argc, char ** argv) { + int good_args = 1; + int print_usage = 0; + int i; + + for ( i = 1; i < argc && good_args; i++) { + if ( strcmp( argv[i], "--help") == 0) { + printf( "USAGE: %s [options] \n", argv[0]); + printf( "OPTIONS:\n"); + printf( " --load-slot=NUM Loads savegame from slot NUM\n"); + printf( " --auto-pause Pause emulation of focus is lost.\n"); + printf( " --disable-sound Disables the sound emulation\n"); + printf( " --disable-limiter Disables the 60 fps limiter\n"); + printf( " --frameskip=N Set frameskip to N\n"); + printf( " --limiter-period=N Set frame period of the fps limiter to N (default: %d)\n", FPS_LIMITER_FRAME_PERIOD); + printf( " --3d-engine=ENGINE Select 3d rendering engine, available ENGINES:\n"); + printf( " 0 = 3d disabled\n"); + printf( " 1 = internal desmume software rasterizer (default)\n"); +#ifdef INCLUDE_OPENGL_2D + printf( " --opengl-2d Enables using OpenGL for screen rendering\n"); + printf( " --soft-convert Use software colour conversion during OpenGL\n"); + printf( " screen rendering. May produce better or worse\n"); + printf( " frame rates depending on hardware.\n"); +#endif + printf( "\n"); + printf( " --save-type=TYPE Select savetype from the following:\n"); + for(int jj = 0; save_type_names[jj] != NULL; jj++){ + printf(" %d = %s\n",jj,save_type_names[jj]); + } + + printf( "\n"); + printf( " --fwlang=LANG Set the language in the firmware, LANG as follows:\n"); + printf( " 0 = Japanese\n"); + printf( " 1 = English\n"); + printf( " 2 = French\n"); + printf( " 3 = German\n"); + printf( " 4 = Italian\n"); + printf( " 5 = Spanish\n"); + printf( "\n"); +#ifdef GDB_STUB + printf( " --arm9gdb=PORT_NUM Enable the ARM9 GDB stub on the given port\n"); + printf( " --arm7gdb=PORT_NUM Enable the ARM7 GDB stub on the given port\n"); +#endif + //printf( " --sticky Enable sticky keys and stylus\n"); + printf( "\n"); + printf( " --cflash=PATH_TO_DISK_IMAGE\n"); + printf( " Enable disk image GBAMP compact flash emulation\n"); + printf( "\n"); + printf( " --help Display this message\n"); + printf( " --version Display the version\n"); + good_args = 0; + } + else if ( strcmp( argv[i], "--version") == 0) { + printf( "%s\n", VERSION); + good_args = 0; + } + else if ( strncmp( argv[i], "--load-slot=", 12) == 0) { + long slot = strtol( &argv[i][12], NULL, 10 ); + if(slot >= 0 && slot <= 10) + config->load_slot = slot; + else + printf("Invalid slot number %ld\n", slot); + } + else if ( strcmp( argv[i], "--disable-sound") == 0) { + config->disable_sound = 1; + } +#ifdef INCLUDE_OPENGL_2D + else if ( strcmp( argv[i], "--opengl-2d") == 0) { + config->opengl_2d = 1; + } + else if ( strcmp( argv[i], "--soft-convert") == 0) { + config->soft_colour_convert = 1; + } +#endif + else if ( strcmp( argv[i], "--auto-pause") == 0) { + config->auto_pause = 1; + } + else if ( strcmp( argv[i], "--disable-limiter") == 0) { + config->disable_limiter = 1; + } + else if ( strncmp( argv[i], "--frameskip=", 12) == 0) { + char *end_char; + int frameskip = strtoul(&argv[i][12], &end_char, 10); + + if ( frameskip >= 0 ) { + config->frameskip = frameskip; + } + else { + fprintf(stderr, "frameskip must be >=0\n"); + good_args = 0; + } + } + else if ( strncmp( argv[i], "--limiter-period=", 17) == 0) { + char *end_char; + int period = strtoul(&argv[i][17], &end_char, 10); + + if ( period >= 0 && period <= 30 ) { + config->fps_limiter_frame_period = period; + } + else { + fprintf(stderr, "fps lmiter period must be >=0 and <= 30!\n"); + good_args = 0; + } + } + else if ( strncmp( argv[i], "--3d-engine=", 12) == 0) { + char *end_char; + int engine = strtoul( &argv[i][12], &end_char, 10); + + if ( engine == 0 || engine == 1) { + config->engine_3d = engine; + } + else { + fprintf( stderr, "3d engine can be 0 or 1\n"); + good_args = 0; + } + } + else if ( strncmp( argv[i], "--save-type=", 12) == 0) { + char *end_char; + int savetype = strtoul( &argv[i][12], &end_char, 10); + int last = sizeof(save_type_names)/sizeof(const char * )-2; // NULL terminator, 0-based + + if ( savetype >= 0 && savetype <= last) { + config->savetype = savetype; + } + else { + fprintf( stderr, "savetype can be 0-%d\n",last); + good_args = 0; + } + } + else if ( strncmp( argv[i], "--fwlang=", 9) == 0) { + char *end_char; + int lang = strtoul( &argv[i][9], &end_char, 10); + + if ( lang >= 0 && lang <= 5) { + config->firmware_language = lang; + } + else { + fprintf( stderr, "Firmware language must be set to a value from 0 to 5.\n"); + good_args = 0; + } + } +#ifdef GDB_STUB + else if ( strncmp( argv[i], "--arm9gdb=", 10) == 0) { + char *end_char; + unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); + + if ( port_num > 0 && port_num < 65536) { + config->arm9_gdb_port = port_num; + } + else { + fprintf( stderr, "ARM9 GDB stub port must be in the range 1 to 65535\n"); + good_args = 0; + } + } + else if ( strncmp( argv[i], "--arm7gdb=", 10) == 0) { + char *end_char; + unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); + + if ( port_num > 0 && port_num < 65536) { + config->arm7_gdb_port = port_num; + } + else { + fprintf( stderr, "ARM7 GDB stub port must be in the range 1 to 65535\n"); + good_args = 0; + } + } +#endif + else if ( strncmp( argv[i], "--cflash=", 9) == 0) { + if ( config->cflash_disk_image_file == NULL) { + config->cflash_disk_image_file = &argv[i][9]; + } + else { + fprintf( stderr, "CFlash disk image file (\"%s\") already set\n", + config->cflash_disk_image_file); + good_args = 0; + } + } + else { + if ( config->nds_file == NULL) { + config->nds_file = argv[i]; + } + else { + fprintf( stderr, "NDS file (\"%s\") already set\n", config->nds_file); + good_args = 0; + } + } + } + + if ( good_args) { + if ( config->nds_file == NULL) { + print_usage = 1; + good_args = 0; + } + } + + if ( print_usage) { + fprintf( stderr, "USAGE: %s \n %s --help for more info\n", argv[0], argv[0]); + } + + return good_args; +} + +/* + * The thread handling functions needed by the GDB stub code. + */ +#ifdef GDB_STUB +void * +createThread_gdb( void (*thread_function)( void *data), + void *thread_data) { + SDL_Thread *new_thread = SDL_CreateThread( (int (*)(void *data))thread_function, + thread_data); + + return new_thread; +} + +void +joinThread_gdb( void *thread_handle) { + int ignore; + SDL_WaitThread( (SDL_Thread*)thread_handle, &ignore); +} +#endif + + + +/** + * A SDL timer callback function. Signals the supplied SDL semaphore + * if its value is small. + * + * @param interval The interval since the last call (in ms) + * @param param The pointer to the semaphore. + * + * @return The interval to the next call (required by SDL) + */ +static Uint32 +fps_limiter_fn( Uint32 interval, void *param) { + SDL_sem *sdl_semaphore = (SDL_sem *)param; + + /* signal the semaphore if it is getting low */ + if ( SDL_SemValue( sdl_semaphore) < 4) { + SDL_SemPost( sdl_semaphore); + } + + return interval; +} + + +#ifdef INCLUDE_OPENGL_2D +/* initialization openGL function */ +static int +initGL( GLuint *screen_texture) { + GLenum errCode; + u16 blank_texture[256 * 512]; + + memset(blank_texture, 0x001f, sizeof(blank_texture)); + + /* Enable Texture Mapping */ + glEnable( GL_TEXTURE_2D ); + + /* Set the background black */ + glClearColor( 0.0f, 0.0f, 0.0f, 0.5f ); + + /* Depth buffer setup */ + glClearDepth( 1.0f ); + + /* Enables Depth Testing */ + glEnable( GL_DEPTH_TEST ); + + /* The Type Of Depth Test To Do */ + glDepthFunc( GL_LEQUAL ); + + /* Create The Texture */ + glGenTextures( 1, &screen_texture[0]); + + glBindTexture( GL_TEXTURE_2D, screen_texture[0]); + + /* Generate The Texture */ + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 256, 512, + 0, GL_RGBA, + GL_UNSIGNED_SHORT_1_5_5_5_REV, + blank_texture); + + /* Linear Filtering */ + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + + if ((errCode = glGetError()) != GL_NO_ERROR) { + const GLubyte *errString; + + errString = gluErrorString(errCode); + fprintf( stderr, "Failed to init GL: %s\n", errString); + + return 0; + } + + return 1; +} + +static void +resizeWindow( u16 width, u16 height) { + int comp_width = 3 * width; + int comp_height = 2 * height; + int use_width = 1; + GLenum errCode; + + /* Height / width ration */ + GLfloat ratio; + + if ( comp_width > comp_height) { + use_width = 0; + } + + /* Protect against a divide by zero */ + if ( height == 0 ) + height = 1; + if ( width == 0) + width = 1; + + ratio = ( GLfloat )width / ( GLfloat )height; + + /* Setup our viewport. */ + glViewport( 0, 0, ( GLint )width, ( GLint )height ); + + /* + * change to the projection matrix and set + * our viewing volume. + */ + glMatrixMode( GL_PROJECTION ); + glLoadIdentity( ); + + { + double left; + double right; + double bottom; + double top; + double other_dimen; + + if ( use_width) { + left = 0.0; + right = 256.0; + + nds_screen_size_ratio = 256.0 / (double)width; + + other_dimen = (double)width * 3.0 / 2.0; + + top = 0.0; + bottom = 384.0 * ((double)height / other_dimen); + } + else { + top = 0.0; + bottom = 384.0; + + nds_screen_size_ratio = 384.0 / (double)height; + + other_dimen = (double)height * 2.0 / 3.0; + + left = 0.0; + right = 256.0 * ((double)width / other_dimen); + } + + /* get the area (0,0) to (256,384) into the middle of the viewport */ + gluOrtho2D( left, right, bottom, top); + } + + /* Make sure we're chaning the model view and not the projection */ + glMatrixMode( GL_MODELVIEW ); + + /* Reset The View */ + glLoadIdentity( ); + + if ((errCode = glGetError()) != GL_NO_ERROR) { + const GLubyte *errString; + + errString = gluErrorString(errCode); + fprintf( stderr, "GL resize failed: %s\n", errString); + } + + surface = SDL_SetVideoMode( width, height, 32, + sdl_videoFlags ); +} + + +static void +opengl_Draw( GLuint *texture, int software_convert) { + GLenum errCode; + + /* Clear The Screen And The Depth Buffer */ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + /* Move Into The Screen 5 Units */ + glLoadIdentity( ); + + /* Select screen Texture */ + glBindTexture( GL_TEXTURE_2D, texture[0]); + if ( software_convert) { + int i; + u8 converted[256 * 384 * 3]; + + for ( i = 0; i < (256 * 384); i++) { + converted[(i * 3) + 0] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 0) & 0x1f) << 3; + converted[(i * 3) + 1] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 5) & 0x1f) << 3; + converted[(i * 3) + 2] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 10) & 0x1f) << 3; + } + + glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384, + GL_RGB, + GL_UNSIGNED_BYTE, + converted); + } + else { + glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384, + GL_RGBA, + GL_UNSIGNED_SHORT_1_5_5_5_REV, + &GPU_screen); + } + + if ((errCode = glGetError()) != GL_NO_ERROR) { + const GLubyte *errString; + + errString = gluErrorString(errCode); + fprintf( stderr, "GL subimage failed: %s\n", errString); + } + + + /* Draw the screen as a textured quad */ + glBegin( GL_QUADS); + glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0.0f, 0.0f, 0.0f ); + glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 256.0f, 0.0f, 0.0f ); + glTexCoord2f( 1.0f, 0.75f ); glVertex3f( 256.0f, 384.0f, 0.0f ); + glTexCoord2f( 0.0f, 0.75f ); glVertex3f( 0.0f, 384.0f, 0.0f ); + glEnd( ); + + if ((errCode = glGetError()) != GL_NO_ERROR) { + const GLubyte *errString; + + errString = gluErrorString(errCode); + fprintf( stderr, "GL draw failed: %s\n", errString); + } + + /* Draw it to the screen */ + SDL_GL_SwapBuffers( ); +} +#endif + +static void +Draw( void) { + SDL_Surface *rawImage; + + rawImage = SDL_CreateRGBSurfaceFrom((void*)&GPU_screen, 256, 384, 16, 512, 0x001F, 0x03E0, 0x7C00, 0); + if(rawImage == NULL) return; + + SDL_BlitSurface(rawImage, 0, surface, 0); + + SDL_UpdateRect(surface, 0, 0, 0, 0); + + SDL_FreeSurface(rawImage); + return; +} + +static void desmume_cycle(int *sdl_quit, int *boost, struct my_config * my_config) +{ + static unsigned short keypad; + static int focused = 1; + SDL_Event event; + + /* Look for queued events and update keypad status */ + /* IMPORTANT: Reenable joystick events iif needed. */ + if(SDL_JoystickEventState(SDL_QUERY) == SDL_IGNORE) + SDL_JoystickEventState(SDL_ENABLE); + + /* There's an event waiting to be processed? */ + while ( !*sdl_quit && + (SDL_PollEvent(&event) || (!focused && SDL_WaitEvent(&event)))) + { + process_ctrls_event( event, &keypad, nds_screen_size_ratio); + + switch (event.type) + { +#ifdef INCLUDE_OPENGL_2D + case SDL_VIDEORESIZE: + resizeWindow( event.resize.w, event.resize.h); + break; +#endif + case SDL_ACTIVEEVENT: + if (my_config->auto_pause && (event.active.state & SDL_APPINPUTFOCUS )) + { + if (event.active.gain) + { + focused = 1; + SPU_Pause(0); + } + else + { + focused = 0; + SPU_Pause(1); + } + } + break; + + case SDL_KEYUP: + switch (event.key.keysym.sym) + { + case SDLK_ESCAPE: + *sdl_quit = 1; + break; +#ifdef FAKE_MIC + case SDLK_m: + enable_fake_mic = !enable_fake_mic; + Mic_DoNoise(enable_fake_mic); + break; +#endif + case SDLK_o: + *boost = !(*boost); + break; + default: + break; + } + break; + + case SDL_QUIT: + *sdl_quit = 1; + break; + } + } + + /* Update mouse position and click */ + if(mouse.down) NDS_setTouchPos(mouse.x, mouse.y); + if(mouse.click) + { + NDS_releaseTouch(); + mouse.click = FALSE; + } + + update_keypad(keypad); /* Update keypad */ + NDS_exec(); + SPU_Emulate_user(); +} + +int main(int argc, char ** argv) { + struct my_config my_config; +#ifdef GDB_STUB + gdbstub_handle_t arm9_gdb_stub; + gdbstub_handle_t arm7_gdb_stub; + struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; + struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; + struct armcpu_ctrl_iface *arm9_ctrl_iface; + struct armcpu_ctrl_iface *arm7_ctrl_iface; +#endif + + int limiter_frame_counter = 0; + SDL_sem *fps_limiter_semaphore = NULL; + SDL_TimerID limiter_timer = NULL; + int sdl_quit = 0; + int boost = 0; + int error; + +#ifdef DISPLAY_FPS + u32 fps_timing = 0; + u32 fps_frame_counter = 0; + u32 fps_previous_time = 0; + u32 fps_temp_time; +#endif + +#ifdef INCLUDE_OPENGL_2D + GLuint screen_texture[1]; +#endif + /* this holds some info about our display */ + const SDL_VideoInfo *videoInfo; + + /* the firmware settings */ + struct NDS_fw_config_data fw_config; + + /* default the firmware settings, they may get changed later */ + NDS_FillDefaultFirmwareConfigData( &fw_config); + + init_config( &my_config); + + if ( !fill_config( &my_config, argc, argv)) { + exit(1); + } + + /* use any language set on the command line */ + if ( my_config.firmware_language != -1) { + fw_config.language = my_config.firmware_language; + } + +#ifdef GDB_STUB + if ( my_config.arm9_gdb_port != 0) { + arm9_gdb_stub = createStub_gdb( my_config.arm9_gdb_port, + &arm9_memio, + &arm9_direct_memory_iface); + + if ( arm9_gdb_stub == NULL) { + fprintf( stderr, "Failed to create ARM9 gdbstub on port %d\n", + my_config.arm9_gdb_port); + exit( 1); + } + } + if ( my_config.arm7_gdb_port != 0) { + arm7_gdb_stub = createStub_gdb( my_config.arm7_gdb_port, + &arm7_memio, + &arm7_base_memory_iface); + + if ( arm7_gdb_stub == NULL) { + fprintf( stderr, "Failed to create ARM7 gdbstub on port %d\n", + my_config.arm7_gdb_port); + exit( 1); + } + } +#endif + +#ifdef GDB_STUB + NDS_Init( arm9_memio, &arm9_ctrl_iface, + arm7_memio, &arm7_ctrl_iface); +#else + NDS_Init(); +#endif + + /* Create the dummy firmware */ + NDS_CreateDummyFirmware( &fw_config); + + if ( !my_config.disable_sound) { + SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); + } + + NDS_3D_ChangeCore(my_config.engine_3d); + + backup_setManualBackupType(my_config.savetype); + + error = NDS_LoadROM( my_config.nds_file ); + if (error < 0) { + fprintf(stderr, "error while loading %s\n", my_config.nds_file); + exit(-1); + } + + /* + * Activate the GDB stubs + * This has to come after the NDS_Init where the cpus are set up. + */ +#ifdef GDB_STUB + if ( my_config.arm9_gdb_port != 0) { + activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); + } + if ( my_config.arm7_gdb_port != 0) { + activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); + } +#endif + + execute = TRUE; + + if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) + { + fprintf(stderr, "Error trying to initialize SDL: %s\n", + SDL_GetError()); + return 1; + } + SDL_WM_SetCaption("Desmume SDL", NULL); + + /* Fetch the video info */ + videoInfo = SDL_GetVideoInfo( ); + if ( !videoInfo ) { + fprintf( stderr, "Video query failed: %s\n", SDL_GetError( ) ); + exit( -1); + } + + /* This checks if hardware blits can be done */ + if ( videoInfo->blit_hw ) + sdl_videoFlags |= SDL_HWACCEL; + +#ifdef INCLUDE_OPENGL_2D + if ( my_config.opengl_2d) { + /* the flags to pass to SDL_SetVideoMode */ + sdl_videoFlags = SDL_OPENGL; /* Enable OpenGL in SDL */ + sdl_videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */ + sdl_videoFlags |= SDL_HWPALETTE; /* Store the palette in hardware */ + sdl_videoFlags |= SDL_RESIZABLE; /* Enable window resizing */ + + + /* This checks to see if surfaces can be stored in memory */ + if ( videoInfo->hw_available ) + sdl_videoFlags |= SDL_HWSURFACE; + else + sdl_videoFlags |= SDL_SWSURFACE; + + + /* Sets up OpenGL double buffering */ + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + + surface = SDL_SetVideoMode( 256, 192 * 2, 32, + sdl_videoFlags ); + + /* Verify there is a surface */ + if ( !surface ) { + fprintf( stderr, "Video mode set failed: %s\n", SDL_GetError( ) ); + exit( -1); + } + + + /* initialize OpenGL */ + if ( !initGL( screen_texture)) { + fprintf( stderr, "Failed to init GL, fall back to software render\n"); + + my_config.opengl_2d = 0; + } + } + + if ( !my_config.opengl_2d) { +#endif + sdl_videoFlags |= SDL_SWSURFACE; + surface = SDL_SetVideoMode(256, 384, 32, sdl_videoFlags); + + if ( !surface ) { + fprintf( stderr, "Video mode set failed: %s\n", SDL_GetError( ) ); + exit( -1); + } +#ifdef INCLUDE_OPENGL_2D + } + + /* set the initial window size */ + if ( my_config.opengl_2d) { + resizeWindow( 256, 192*2); + } +#endif + + /* Initialize joysticks */ + if(!init_joy()) return 1; + /* Load our own keyboard configuration */ + set_kb_keys(cli_kb_cfg); + + if ( !my_config.disable_limiter) { + /* create the semaphore used for fps limiting */ + fps_limiter_semaphore = SDL_CreateSemaphore( 1); + + /* start a SDL timer for every FPS_LIMITER_FRAME_PERIOD frames to keep us at 60 fps */ + if ( fps_limiter_semaphore != NULL) { + limiter_timer = SDL_AddTimer( 16 * my_config.fps_limiter_frame_period, + fps_limiter_fn, fps_limiter_semaphore); + } + + if ( limiter_timer == NULL) { + fprintf( stderr, "Error trying to start FPS limiter timer: %s\n", + SDL_GetError()); + if ( fps_limiter_semaphore != NULL) { + SDL_DestroySemaphore( fps_limiter_semaphore); + fps_limiter_semaphore = NULL; + } + return 1; + } + } + + if(my_config.load_slot){ + loadstate_slot(my_config.load_slot); + } + + while(!sdl_quit) { + desmume_cycle(&sdl_quit, &boost, &my_config); + +#ifdef INCLUDE_OPENGL_2D + if ( my_config.opengl_2d) { + opengl_Draw( screen_texture, my_config.soft_colour_convert); + } + else +#endif + Draw(); + + for ( int i = 0; i < my_config.frameskip; i++ ) { + NDS_SkipNextFrame(); + desmume_cycle(&sdl_quit, &boost, &my_config); + } + + if ( !my_config.disable_limiter && !boost) { + limiter_frame_counter += 1 + my_config.frameskip; + if ( limiter_frame_counter >= my_config.fps_limiter_frame_period) { + limiter_frame_counter = 0; + + /* wait for the timer to expire */ + SDL_SemWait( fps_limiter_semaphore); + } + } + +#ifdef DISPLAY_FPS + fps_frame_counter += 1; + fps_temp_time = SDL_GetTicks(); + fps_timing += fps_temp_time - fps_previous_time; + fps_previous_time = fps_temp_time; + + if ( fps_frame_counter == NUM_FRAMES_TO_TIME) { + char win_title[20]; + float fps = (float)fps_timing; + fps /= NUM_FRAMES_TO_TIME * 1000.f; + fps = 1.0f / fps; + + fps_frame_counter = 0; + fps_timing = 0; + + snprintf( win_title, sizeof(win_title), "Desmume %f", fps); + + SDL_WM_SetCaption( win_title, NULL); + } +#endif + } + + + + /* Unload joystick */ + uninit_joy(); + + if ( !my_config.disable_limiter) { + /* tidy up the FPS limiter timer and semaphore */ + SDL_RemoveTimer( limiter_timer); + SDL_DestroySemaphore( fps_limiter_semaphore); + } + + SDL_Quit(); + NDS_DeInit(); + +#ifdef GDB_STUB + if ( my_config.arm9_gdb_port != 0) { + destroyStub_gdb( arm9_gdb_stub); + } + if ( my_config.arm7_gdb_port != 0) { + destroyStub_gdb( arm7_gdb_stub); + } +#endif + + return 0; +} diff --git a/desmume/src/cocoa/DeSmuME.cbp b/src/cocoa/DeSmuME.cbp similarity index 100% rename from desmume/src/cocoa/DeSmuME.cbp rename to src/cocoa/DeSmuME.cbp diff --git a/desmume/src/cocoa/DeSmuME.icns b/src/cocoa/DeSmuME.icns old mode 100755 new mode 100644 similarity index 100% rename from desmume/src/cocoa/DeSmuME.icns rename to src/cocoa/DeSmuME.icns diff --git a/desmume/src/cocoa/DeSmuME.xcodeproj/project.pbxproj b/src/cocoa/DeSmuME.xcodeproj/project.pbxproj similarity index 100% rename from desmume/src/cocoa/DeSmuME.xcodeproj/project.pbxproj rename to src/cocoa/DeSmuME.xcodeproj/project.pbxproj diff --git a/desmume/src/cocoa/Info.plist b/src/cocoa/Info.plist similarity index 100% rename from desmume/src/cocoa/Info.plist rename to src/cocoa/Info.plist diff --git a/desmume/src/cocoa/InfoPlist.strings b/src/cocoa/InfoPlist.strings similarity index 100% rename from desmume/src/cocoa/InfoPlist.strings rename to src/cocoa/InfoPlist.strings diff --git a/desmume/src/cocoa/Makefile.am b/src/cocoa/Makefile.am similarity index 100% rename from desmume/src/cocoa/Makefile.am rename to src/cocoa/Makefile.am diff --git a/desmume/src/cocoa/PkgInfo b/src/cocoa/PkgInfo similarity index 100% rename from desmume/src/cocoa/PkgInfo rename to src/cocoa/PkgInfo diff --git a/desmume/src/cocoa/Rakefile b/src/cocoa/Rakefile similarity index 100% rename from desmume/src/cocoa/Rakefile rename to src/cocoa/Rakefile diff --git a/desmume/src/cocoa/about.m b/src/cocoa/about.m similarity index 100% rename from desmume/src/cocoa/about.m rename to src/cocoa/about.m diff --git a/desmume/src/cocoa/build_dmg.sh b/src/cocoa/build_dmg.sh similarity index 100% rename from desmume/src/cocoa/build_dmg.sh rename to src/cocoa/build_dmg.sh diff --git a/desmume/src/cocoa/cocoa_util.m b/src/cocoa/cocoa_util.m similarity index 100% rename from desmume/src/cocoa/cocoa_util.m rename to src/cocoa/cocoa_util.m diff --git a/desmume/src/cocoa/dialogs/rom_info.h b/src/cocoa/dialogs/rom_info.h similarity index 96% rename from desmume/src/cocoa/dialogs/rom_info.h rename to src/cocoa/dialogs/rom_info.h index e0d576d85..a0365452f 100644 --- a/desmume/src/cocoa/dialogs/rom_info.h +++ b/src/cocoa/dialogs/rom_info.h @@ -1,32 +1,32 @@ -/* Copyright (C) 2007 Jeff Bland - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#import - -@class NintendoDS; - -//there is only one ROM Info window, so we have only class functions here - -@interface ROMInfo : NSObject -{ -} -+ (void)showROMInfo:(NintendoDS*)DS; -+ (void)changeDS:(NintendoDS*)DS; -+ (void)closeROMInfo; -@end +/* Copyright (C) 2007 Jeff Bland + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#import + +@class NintendoDS; + +//there is only one ROM Info window, so we have only class functions here + +@interface ROMInfo : NSObject +{ +} ++ (void)showROMInfo:(NintendoDS*)DS; ++ (void)changeDS:(NintendoDS*)DS; ++ (void)closeROMInfo; +@end diff --git a/desmume/src/cocoa/dialogs/rom_info.m b/src/cocoa/dialogs/rom_info.m similarity index 100% rename from desmume/src/cocoa/dialogs/rom_info.m rename to src/cocoa/dialogs/rom_info.m diff --git a/desmume/src/cocoa/dialogs/speed_limit_selection_window.h b/src/cocoa/dialogs/speed_limit_selection_window.h similarity index 96% rename from desmume/src/cocoa/dialogs/speed_limit_selection_window.h rename to src/cocoa/dialogs/speed_limit_selection_window.h index b41415551..da902faec 100644 --- a/desmume/src/cocoa/dialogs/speed_limit_selection_window.h +++ b/src/cocoa/dialogs/speed_limit_selection_window.h @@ -1,33 +1,33 @@ -/* Copyright (C) 2008 Jeff Bland - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#import -#import "../nds_control.h" - -@interface SpeedLimitSelectionWindow : NSWindow -{ - BOOL modal; - NintendoDS *target; - NSTextField *value; - int initial_value; -} -- (id)initWithDS:(NintendoDS*)ds; -- (void)runModal; -- (void)dealloc; -@end +/* Copyright (C) 2008 Jeff Bland + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#import +#import "../nds_control.h" + +@interface SpeedLimitSelectionWindow : NSWindow +{ + BOOL modal; + NintendoDS *target; + NSTextField *value; + int initial_value; +} +- (id)initWithDS:(NintendoDS*)ds; +- (void)runModal; +- (void)dealloc; +@end diff --git a/desmume/src/cocoa/dialogs/speed_limit_selection_window.mm b/src/cocoa/dialogs/speed_limit_selection_window.mm similarity index 100% rename from desmume/src/cocoa/dialogs/speed_limit_selection_window.mm rename to src/cocoa/dialogs/speed_limit_selection_window.mm diff --git a/desmume/src/cocoa/globals.h b/src/cocoa/globals.h similarity index 96% rename from desmume/src/cocoa/globals.h rename to src/cocoa/globals.h index 3bffd38c3..d67ccbaa1 100644 --- a/desmume/src/cocoa/globals.h +++ b/src/cocoa/globals.h @@ -1,41 +1,41 @@ -/* Copyright (C) 2007 Jeff Bland - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#import - -#ifdef __cplusplus -extern "C" -{ -#endif - -void messageDialog(NSString *title, NSString *text); -BOOL messageDialogYN(NSString *title, NSString *text); -NSString* openDialog(NSArray *file_types); - -// -#if !defined(__LP64__) && !defined(NS_BUILD_32_LIKE_64) -typedef int NSInteger; -typedef unsigned int NSUInteger; -#endif - -typedef float CGFloat; - -#ifdef __cplusplus -} +/* Copyright (C) 2007 Jeff Bland + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#import + +#ifdef __cplusplus +extern "C" +{ +#endif + +void messageDialog(NSString *title, NSString *text); +BOOL messageDialogYN(NSString *title, NSString *text); +NSString* openDialog(NSArray *file_types); + +// +#if !defined(__LP64__) && !defined(NS_BUILD_32_LIKE_64) +typedef int NSInteger; +typedef unsigned int NSUInteger; +#endif + +typedef float CGFloat; + +#ifdef __cplusplus +} #endif \ No newline at end of file diff --git a/desmume/src/cocoa/input.h b/src/cocoa/input.h similarity index 96% rename from desmume/src/cocoa/input.h rename to src/cocoa/input.h index 968934f16..effebc906 100644 --- a/desmume/src/cocoa/input.h +++ b/src/cocoa/input.h @@ -1,50 +1,50 @@ -/* Copyright (C) 2007 Jeff Bland - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#import - -/* The main window class instanciates an input object, - and places it after the window in the responder chain, so - any events not handled by a the window get sent here. - */ - -@class VideoOutputWindow; - -@interface InputHandler : NSResponder -{ -@private - VideoOutputWindow *my_ds; -} -//preferences -+ (NSView*)createPreferencesView:(float)width; -+ (NSDictionary*)appDefaults; - -//creation/deletion -- (id)initWithWindow:(VideoOutputWindow*)nds; -- (void)dealloc; - -//keyboard input -- (void)keyDown:(NSEvent*)event; -- (void)keyUp:(NSEvent*)event; - -//mouse input -- (void)mouseDown:(NSEvent*)event; -- (void)mouseDragged:(NSEvent*)event; -- (void)mouseUp:(NSEvent*)event; -@end +/* Copyright (C) 2007 Jeff Bland + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#import + +/* The main window class instanciates an input object, + and places it after the window in the responder chain, so + any events not handled by a the window get sent here. + */ + +@class VideoOutputWindow; + +@interface InputHandler : NSResponder +{ +@private + VideoOutputWindow *my_ds; +} +//preferences ++ (NSView*)createPreferencesView:(float)width; ++ (NSDictionary*)appDefaults; + +//creation/deletion +- (id)initWithWindow:(VideoOutputWindow*)nds; +- (void)dealloc; + +//keyboard input +- (void)keyDown:(NSEvent*)event; +- (void)keyUp:(NSEvent*)event; + +//mouse input +- (void)mouseDown:(NSEvent*)event; +- (void)mouseDragged:(NSEvent*)event; +- (void)mouseUp:(NSEvent*)event; +@end diff --git a/desmume/src/cocoa/input.mm b/src/cocoa/input.mm similarity index 100% rename from desmume/src/cocoa/input.mm rename to src/cocoa/input.mm diff --git a/desmume/src/cocoa/main.mm b/src/cocoa/main.mm similarity index 100% rename from desmume/src/cocoa/main.mm rename to src/cocoa/main.mm diff --git a/desmume/src/cocoa/main_window.h b/src/cocoa/main_window.h similarity index 96% rename from desmume/src/cocoa/main_window.h rename to src/cocoa/main_window.h index 10b453e7d..d11ea1ae6 100644 --- a/desmume/src/cocoa/main_window.h +++ b/src/cocoa/main_window.h @@ -1,116 +1,116 @@ -/* Copyright (C) 2007 Jeff Bland - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#import - -#import "nds_control.h" - -@class VideoOutputView; -@class InputHandler; -//this is used internally by VideoOutputWindow - -// Backup media type array length -#define MAX_SAVE_TYPE 7 - - -//This interface is to create and manaage the window -//that displays DS video output and takes keyboard/mouse input -//do not instanciate more than one of these -@interface VideoOutputWindow : NintendoDS -{ - @private - NSWindow *window; - NSWindowController *controller; - VideoOutputView *video_output_view; - NSTextField *status_view; - NSString *status_bar_text; - InputHandler *input; - - bool no_smaller_than_ds; - bool keep_proportions; -} - -//initialization -- (id)init; -- (void)dealloc; - -//overloaded from NintendoDS class -- (BOOL)loadROM:(NSString*)filename; -- (void)execute; -- (void)pause; -- (void)reset; -- (void)setFrameSkip:(int)frameskip; -- (void)setSaveType:(int)savetype; -- (void)closeROM; - -//save features overloaded from nds class -- (BOOL)saveState:(NSString*)file; -- (BOOL)loadState:(NSString*)file; -- (BOOL)saveStateToSlot:(int)slot; //0 to MAX_SLOTS-1, anything else is ignored -- (BOOL)loadStateFromSlot:(int)slot; - -//save functions for the program menu to callback to -- (BOOL)saveStateAs; -- (BOOL)loadStateFrom; - -//toggles between allowing tiny sizes and only being as small as DS -- (void)toggleMinSize; - -//this method will contrain the size as well -//this is screen size not window size -- (void)resizeScreen:(NSSize)size; - -//like resizeScreen but does a size in relation to DS pixels -- (void)resizeScreen1x; -- (void)resizeScreen2x; -- (void)resizeScreen3x; -- (void)resizeScreen4x; - -//converts window coords to DS coords (returns -1, -1 if invalid) -- (NSPoint)windowPointToDSCoords:(NSPoint)location; - -// -- (void)toggleConstrainProportions; -- (void)toggleStatusBar; - -//rotation -- (void)setRotation:(float)rotation; -- (void)setRotation0; -- (void)setRotation90; -- (void)setRotation180; -- (void)setRotation270; -- (float)rotation; - -//layers -- (void)toggleTopBackground0; -- (void)toggleTopBackground1; -- (void)toggleTopBackground2; -- (void)toggleTopBackground3; -- (void)toggleSubBackground0; -- (void)toggleSubBackground1; -- (void)toggleSubBackground2; -- (void)toggleSubBackground3; - -//screenshots -- (void)saveScreenshot; - -//delegate -- (void)windowDidBecomeMain:(NSNotification*)notification; - -@end +/* Copyright (C) 2007 Jeff Bland + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#import + +#import "nds_control.h" + +@class VideoOutputView; +@class InputHandler; +//this is used internally by VideoOutputWindow + +// Backup media type array length +#define MAX_SAVE_TYPE 7 + + +//This interface is to create and manaage the window +//that displays DS video output and takes keyboard/mouse input +//do not instanciate more than one of these +@interface VideoOutputWindow : NintendoDS +{ + @private + NSWindow *window; + NSWindowController *controller; + VideoOutputView *video_output_view; + NSTextField *status_view; + NSString *status_bar_text; + InputHandler *input; + + bool no_smaller_than_ds; + bool keep_proportions; +} + +//initialization +- (id)init; +- (void)dealloc; + +//overloaded from NintendoDS class +- (BOOL)loadROM:(NSString*)filename; +- (void)execute; +- (void)pause; +- (void)reset; +- (void)setFrameSkip:(int)frameskip; +- (void)setSaveType:(int)savetype; +- (void)closeROM; + +//save features overloaded from nds class +- (BOOL)saveState:(NSString*)file; +- (BOOL)loadState:(NSString*)file; +- (BOOL)saveStateToSlot:(int)slot; //0 to MAX_SLOTS-1, anything else is ignored +- (BOOL)loadStateFromSlot:(int)slot; + +//save functions for the program menu to callback to +- (BOOL)saveStateAs; +- (BOOL)loadStateFrom; + +//toggles between allowing tiny sizes and only being as small as DS +- (void)toggleMinSize; + +//this method will contrain the size as well +//this is screen size not window size +- (void)resizeScreen:(NSSize)size; + +//like resizeScreen but does a size in relation to DS pixels +- (void)resizeScreen1x; +- (void)resizeScreen2x; +- (void)resizeScreen3x; +- (void)resizeScreen4x; + +//converts window coords to DS coords (returns -1, -1 if invalid) +- (NSPoint)windowPointToDSCoords:(NSPoint)location; + +// +- (void)toggleConstrainProportions; +- (void)toggleStatusBar; + +//rotation +- (void)setRotation:(float)rotation; +- (void)setRotation0; +- (void)setRotation90; +- (void)setRotation180; +- (void)setRotation270; +- (float)rotation; + +//layers +- (void)toggleTopBackground0; +- (void)toggleTopBackground1; +- (void)toggleTopBackground2; +- (void)toggleTopBackground3; +- (void)toggleSubBackground0; +- (void)toggleSubBackground1; +- (void)toggleSubBackground2; +- (void)toggleSubBackground3; + +//screenshots +- (void)saveScreenshot; + +//delegate +- (void)windowDidBecomeMain:(NSNotification*)notification; + +@end diff --git a/desmume/src/cocoa/main_window.mm b/src/cocoa/main_window.mm similarity index 100% rename from desmume/src/cocoa/main_window.mm rename to src/cocoa/main_window.mm diff --git a/desmume/src/cocoa/makeapp.sh b/src/cocoa/makeapp.sh old mode 100755 new mode 100644 similarity index 100% rename from desmume/src/cocoa/makeapp.sh rename to src/cocoa/makeapp.sh diff --git a/desmume/src/cocoa/nds_control.h b/src/cocoa/nds_control.h similarity index 96% rename from desmume/src/cocoa/nds_control.h rename to src/cocoa/nds_control.h index 59eab8ec5..ad3bd9190 100644 --- a/desmume/src/cocoa/nds_control.h +++ b/src/cocoa/nds_control.h @@ -1,195 +1,195 @@ -/* Copyright (C) 2007 Jeff Bland - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#import "globals.h" - -@class ScreenState; - -#ifdef GDB_STUB -#define OBJ_C -#include "../gdbstub.h" -#endif - -#define MAX_SLOTS 10 -#define MAX_FRAME_SKIP 10 - -//This class is a compelte objective-c wrapper for -//the core emulation features, other objective-c code inherit -//upon or instanciate this to add interfaces for these features -//Please only instanciate once. -@interface NintendoDS : NSObject -{ - @private - - NSOpenGLContext* context; //context where the 3d gets renderered to - NSOpenGLPixelFormat* pixel_format; //pixel format for opengl 3d renderer - NSThread *gui_thread; - SEL display_func; //the function id that gets called when the screen is ready to update - id display_object; //the object that the above function is called on - SEL error_func; - id error_object; - - NSLock *execution_lock; - NSLock *sound_lock; - - ScreenState * volatile current_screen; - NSLock *video_update_lock; - - volatile bool finish; //set to true to make the other thread finish - volatile bool finished; //set to true by the other thread after it finishes - volatile bool run; //set to control execution in other thread - volatile bool paused; //sey by other thread to let us know if its executing - - bool muted; - int volume; - - volatile int frame_skip; - volatile int speed_limit; - volatile int save_type; - - NSString *current_file; - NSString *flash_file; - -#ifdef GDB_STUB - NSInteger arm9_gdb_port; - NSInteger arm7_gdb_port; - gdbstub_handle_t arm9_gdb_stub; - gdbstub_handle_t arm7_gdb_stub; -#endif - - unsigned char gpu_buff[256 * 256 * 5]; //this is where the 3D rendering of the NDS is stored -} - -//Instanciating, setup, and deconstruction -- (id)init; -- (void)setVideoUpdateCallback:(SEL)callback withObject:(id)object; //this callback should take one ScreenState(below) parameter -- (void)setErrorCallback:(SEL)callback withObject:(id)object; -- (void)dealloc; - -//Firmware control -- (void)setPlayerName:(NSString*)player_name; - -//ROM control -- (BOOL)loadROM:(NSString*)filename; -- (BOOL)ROMLoaded; -- (void)closeROM; - -//ROM Info -- (NSImage*)ROMIcon; -- (NSString*)ROMFile; -- (NSString*)ROMTitle; -- (NSInteger)ROMMaker; -- (NSInteger)ROMSize; -- (NSInteger)ROMARM9Size; -- (NSInteger)ROMARM7Size; -- (NSInteger)ROMDataSize; - -//Flash memory -- (NSString*)flashFile; -- (void)setFlashFile:(NSString*)filename; - -//execution control -- (BOOL)executing; -- (void)execute; -- (BOOL)paused; -- (void)pause; -- (void)reset; -- (void)setFrameSkip:(int)frameskip; //negative is auto, 0 is off, more than 0 is the amount of frames to skip before showing a frame -- (int)frameSkip; //defaults to -1 -- (void)setSpeedLimit:(int)percent; //0 is off, 1-1000 is the pertance speed it runs at, anything else does nothing -- (int)speedLimit; -- (void)setSaveType:(int)savetype; // see save_types in src/mmu.h -- (int)saveType; // default is 0, which is autodetect - -//touch screen -- (void)touch:(NSPoint)point; -- (void)releaseTouch; - -//button input -- (void)pressStart; -- (void)liftStart; -- (BOOL)start; -- (void)pressSelect; -- (void)liftSelect; -- (BOOL)select; -- (void)pressLeft; -- (void)liftLeft; -- (BOOL)left; -- (void)pressRight; -- (void)liftRight; -- (BOOL)right; -- (void)pressUp; -- (void)liftUp; -- (BOOL)up; -- (void)pressDown; -- (void)liftDown; -- (BOOL)down; -- (void)pressA; -- (void)liftA; -- (BOOL)A; -- (void)pressB; -- (void)liftB; -- (BOOL)B; -- (void)pressX; -- (void)liftX; -- (BOOL)X; -- (void)pressY; -- (void)liftY; -- (BOOL)Y; -- (void)pressL; -- (void)liftL; -- (BOOL)L; -- (void)pressR; -- (void)liftR; -- (BOOL)R; - -//save states -- (BOOL)saveState:(NSString*)file; -- (BOOL)loadState:(NSString*)file; -- (BOOL)saveStateToSlot:(int)slot; //0 to MAX_SLOTS-1, anything else is ignored -- (BOOL)loadStateFromSlot:(int)slot; -- (BOOL)saveStateExists:(int)slot; - -//layers -- (void)toggleTopBackground0; -- (BOOL)showingTopBackground0; -- (void)toggleTopBackground1; -- (BOOL)showingTopBackground1; -- (void)toggleTopBackground2; -- (BOOL)showingTopBackground2; -- (void)toggleTopBackground3; -- (BOOL)showingTopBackground3; -- (void)toggleSubBackground0; -- (BOOL)showingSubBackground0; -- (void)toggleSubBackground1; -- (BOOL)showingSubBackground1; -- (void)toggleSubBackground2; -- (BOOL)showingSubBackground2; -- (void)toggleSubBackground3; -- (BOOL)showingSubBackground3; - -//Sound -- (BOOL)hasSound; -- (void)setVolume:(int)volume; //clamped: 0 to 100 -- (int)volume; -- (void)enableMute; -- (void)disableMute; -- (void)toggleMute; -- (BOOL)muted; -@end +/* Copyright (C) 2007 Jeff Bland + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#import "globals.h" + +@class ScreenState; + +#ifdef GDB_STUB +#define OBJ_C +#include "../gdbstub.h" +#endif + +#define MAX_SLOTS 10 +#define MAX_FRAME_SKIP 10 + +//This class is a compelte objective-c wrapper for +//the core emulation features, other objective-c code inherit +//upon or instanciate this to add interfaces for these features +//Please only instanciate once. +@interface NintendoDS : NSObject +{ + @private + + NSOpenGLContext* context; //context where the 3d gets renderered to + NSOpenGLPixelFormat* pixel_format; //pixel format for opengl 3d renderer + NSThread *gui_thread; + SEL display_func; //the function id that gets called when the screen is ready to update + id display_object; //the object that the above function is called on + SEL error_func; + id error_object; + + NSLock *execution_lock; + NSLock *sound_lock; + + ScreenState * volatile current_screen; + NSLock *video_update_lock; + + volatile bool finish; //set to true to make the other thread finish + volatile bool finished; //set to true by the other thread after it finishes + volatile bool run; //set to control execution in other thread + volatile bool paused; //sey by other thread to let us know if its executing + + bool muted; + int volume; + + volatile int frame_skip; + volatile int speed_limit; + volatile int save_type; + + NSString *current_file; + NSString *flash_file; + +#ifdef GDB_STUB + NSInteger arm9_gdb_port; + NSInteger arm7_gdb_port; + gdbstub_handle_t arm9_gdb_stub; + gdbstub_handle_t arm7_gdb_stub; +#endif + + unsigned char gpu_buff[256 * 256 * 5]; //this is where the 3D rendering of the NDS is stored +} + +//Instanciating, setup, and deconstruction +- (id)init; +- (void)setVideoUpdateCallback:(SEL)callback withObject:(id)object; //this callback should take one ScreenState(below) parameter +- (void)setErrorCallback:(SEL)callback withObject:(id)object; +- (void)dealloc; + +//Firmware control +- (void)setPlayerName:(NSString*)player_name; + +//ROM control +- (BOOL)loadROM:(NSString*)filename; +- (BOOL)ROMLoaded; +- (void)closeROM; + +//ROM Info +- (NSImage*)ROMIcon; +- (NSString*)ROMFile; +- (NSString*)ROMTitle; +- (NSInteger)ROMMaker; +- (NSInteger)ROMSize; +- (NSInteger)ROMARM9Size; +- (NSInteger)ROMARM7Size; +- (NSInteger)ROMDataSize; + +//Flash memory +- (NSString*)flashFile; +- (void)setFlashFile:(NSString*)filename; + +//execution control +- (BOOL)executing; +- (void)execute; +- (BOOL)paused; +- (void)pause; +- (void)reset; +- (void)setFrameSkip:(int)frameskip; //negative is auto, 0 is off, more than 0 is the amount of frames to skip before showing a frame +- (int)frameSkip; //defaults to -1 +- (void)setSpeedLimit:(int)percent; //0 is off, 1-1000 is the pertance speed it runs at, anything else does nothing +- (int)speedLimit; +- (void)setSaveType:(int)savetype; // see save_types in src/mmu.h +- (int)saveType; // default is 0, which is autodetect + +//touch screen +- (void)touch:(NSPoint)point; +- (void)releaseTouch; + +//button input +- (void)pressStart; +- (void)liftStart; +- (BOOL)start; +- (void)pressSelect; +- (void)liftSelect; +- (BOOL)select; +- (void)pressLeft; +- (void)liftLeft; +- (BOOL)left; +- (void)pressRight; +- (void)liftRight; +- (BOOL)right; +- (void)pressUp; +- (void)liftUp; +- (BOOL)up; +- (void)pressDown; +- (void)liftDown; +- (BOOL)down; +- (void)pressA; +- (void)liftA; +- (BOOL)A; +- (void)pressB; +- (void)liftB; +- (BOOL)B; +- (void)pressX; +- (void)liftX; +- (BOOL)X; +- (void)pressY; +- (void)liftY; +- (BOOL)Y; +- (void)pressL; +- (void)liftL; +- (BOOL)L; +- (void)pressR; +- (void)liftR; +- (BOOL)R; + +//save states +- (BOOL)saveState:(NSString*)file; +- (BOOL)loadState:(NSString*)file; +- (BOOL)saveStateToSlot:(int)slot; //0 to MAX_SLOTS-1, anything else is ignored +- (BOOL)loadStateFromSlot:(int)slot; +- (BOOL)saveStateExists:(int)slot; + +//layers +- (void)toggleTopBackground0; +- (BOOL)showingTopBackground0; +- (void)toggleTopBackground1; +- (BOOL)showingTopBackground1; +- (void)toggleTopBackground2; +- (BOOL)showingTopBackground2; +- (void)toggleTopBackground3; +- (BOOL)showingTopBackground3; +- (void)toggleSubBackground0; +- (BOOL)showingSubBackground0; +- (void)toggleSubBackground1; +- (BOOL)showingSubBackground1; +- (void)toggleSubBackground2; +- (BOOL)showingSubBackground2; +- (void)toggleSubBackground3; +- (BOOL)showingSubBackground3; + +//Sound +- (BOOL)hasSound; +- (void)setVolume:(int)volume; //clamped: 0 to 100 +- (int)volume; +- (void)enableMute; +- (void)disableMute; +- (void)toggleMute; +- (BOOL)muted; +@end diff --git a/desmume/src/cocoa/nds_control.mm b/src/cocoa/nds_control.mm similarity index 100% rename from desmume/src/cocoa/nds_control.mm rename to src/cocoa/nds_control.mm diff --git a/desmume/src/cocoa/preferences.h b/src/cocoa/preferences.h similarity index 97% rename from desmume/src/cocoa/preferences.h rename to src/cocoa/preferences.h index 56780c194..d29198349 100644 --- a/desmume/src/cocoa/preferences.h +++ b/src/cocoa/preferences.h @@ -1,50 +1,50 @@ -/* Copyright (C) 2007 Jeff Bland - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#import - -#define PREF_EXECUTE_UPON_LOAD @"Execute Upon Load" - -#define PREF_AFTER_LAUNCHED @"When Launching, Load" -#define PREF_AFTER_LAUNCHED_OPTION_NOTHING @"Load Nothing" -#define PREF_AFTER_LAUNCHED_OPTION_LAST_ROM @"Load Last ROM" - -#define PREF_FLASH_FILE @"Flash File" - -#ifdef GDB_STUB -#define PREF_ARM9_GDB_PORT @"arm9gdb" -#define PREF_ARM7_GDB_PORT @"arm7gdb" -#endif - -#define PREF_KEY_A @"A Button" -#define PREF_KEY_B @"B Button" -#define PREF_KEY_X @"X Button" -#define PREF_KEY_Y @"Y Button" -#define PREF_KEY_L @"L Button" -#define PREF_KEY_R @"R Button" -#define PREF_KEY_UP @"Up Button" -#define PREF_KEY_DOWN @"Down Button" -#define PREF_KEY_LEFT @"Left Button" -#define PREF_KEY_RIGHT @"Right Button" -#define PREF_KEY_START @"Start Button" -#define PREF_KEY_SELECT @"Select Button" - -void setAppDefaults(); //this is defined in preferences.m and should be called at app launch - -NSView *createPreferencesView(NSString *helpinfo, NSDictionary *options, id delegate); //utility func for creating a preference panel with a set of options +/* Copyright (C) 2007 Jeff Bland + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#import + +#define PREF_EXECUTE_UPON_LOAD @"Execute Upon Load" + +#define PREF_AFTER_LAUNCHED @"When Launching, Load" +#define PREF_AFTER_LAUNCHED_OPTION_NOTHING @"Load Nothing" +#define PREF_AFTER_LAUNCHED_OPTION_LAST_ROM @"Load Last ROM" + +#define PREF_FLASH_FILE @"Flash File" + +#ifdef GDB_STUB +#define PREF_ARM9_GDB_PORT @"arm9gdb" +#define PREF_ARM7_GDB_PORT @"arm7gdb" +#endif + +#define PREF_KEY_A @"A Button" +#define PREF_KEY_B @"B Button" +#define PREF_KEY_X @"X Button" +#define PREF_KEY_Y @"Y Button" +#define PREF_KEY_L @"L Button" +#define PREF_KEY_R @"R Button" +#define PREF_KEY_UP @"Up Button" +#define PREF_KEY_DOWN @"Down Button" +#define PREF_KEY_LEFT @"Left Button" +#define PREF_KEY_RIGHT @"Right Button" +#define PREF_KEY_START @"Start Button" +#define PREF_KEY_SELECT @"Select Button" + +void setAppDefaults(); //this is defined in preferences.m and should be called at app launch + +NSView *createPreferencesView(NSString *helpinfo, NSDictionary *options, id delegate); //utility func for creating a preference panel with a set of options diff --git a/desmume/src/cocoa/preferences.mm b/src/cocoa/preferences.mm similarity index 100% rename from desmume/src/cocoa/preferences.mm rename to src/cocoa/preferences.mm diff --git a/desmume/src/cocoa/screen_state.h b/src/cocoa/screen_state.h similarity index 96% rename from desmume/src/cocoa/screen_state.h rename to src/cocoa/screen_state.h index 0544f15fa..4e080d1c1 100644 --- a/desmume/src/cocoa/screen_state.h +++ b/src/cocoa/screen_state.h @@ -1,48 +1,48 @@ -/* Copyright (C) 2007 Jeff Bland - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#import "globals.h" - -#define DS_BPP 2 //bytes per pixel -#define DS_SCREEN_X_RATIO (256.0 / (192.0 * 2.0)) -#define DS_SCREEN_Y_RATIO ((192.0 * 2.0) / 256.0) -#define DS_SCREEN_WIDTH 256 -#define DS_SCREEN_HEIGHT 192 - -//This class is used to return screen data at the end of a frame -//we wrap it in a obj-c class so it can be passed to a selector -//and so we get retain/release niftyness -@interface ScreenState : NSObject -{ - @private - unsigned char color_data[DS_SCREEN_WIDTH * DS_SCREEN_HEIGHT*2 * DS_BPP]; -} -+ (NSInteger)width; -+ (NSInteger)height; -+ (NSSize)size; -+ (ScreenState*)blackScreenState; -+ (ScreenState*)whiteScreenState; -- (id)initWithBlack; -- (id)initWithWhite; -- (id)initWithScreenState:(ScreenState*)state; -- (id)initWithColorData:(const unsigned char*)data; -- (const unsigned char*)colorData; -- (NSImage*)image; -- (NSBitmapImageRep*)imageRep; +/* Copyright (C) 2007 Jeff Bland + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#import "globals.h" + +#define DS_BPP 2 //bytes per pixel +#define DS_SCREEN_X_RATIO (256.0 / (192.0 * 2.0)) +#define DS_SCREEN_Y_RATIO ((192.0 * 2.0) / 256.0) +#define DS_SCREEN_WIDTH 256 +#define DS_SCREEN_HEIGHT 192 + +//This class is used to return screen data at the end of a frame +//we wrap it in a obj-c class so it can be passed to a selector +//and so we get retain/release niftyness +@interface ScreenState : NSObject +{ + @private + unsigned char color_data[DS_SCREEN_WIDTH * DS_SCREEN_HEIGHT*2 * DS_BPP]; +} ++ (NSInteger)width; ++ (NSInteger)height; ++ (NSSize)size; ++ (ScreenState*)blackScreenState; ++ (ScreenState*)whiteScreenState; +- (id)initWithBlack; +- (id)initWithWhite; +- (id)initWithScreenState:(ScreenState*)state; +- (id)initWithColorData:(const unsigned char*)data; +- (const unsigned char*)colorData; +- (NSImage*)image; +- (NSBitmapImageRep*)imageRep; @end \ No newline at end of file diff --git a/desmume/src/cocoa/screen_state.m b/src/cocoa/screen_state.m similarity index 100% rename from desmume/src/cocoa/screen_state.m rename to src/cocoa/screen_state.m diff --git a/desmume/src/cocoa/screenshot.h b/src/cocoa/screenshot.h similarity index 97% rename from desmume/src/cocoa/screenshot.h rename to src/cocoa/screenshot.h index 5642aa314..0e235167e 100644 --- a/desmume/src/cocoa/screenshot.h +++ b/src/cocoa/screenshot.h @@ -1,26 +1,26 @@ -/* Copyright (C) 2007 Jeff Bland - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#import - -@class ScreenState; - -@interface Screenshot : NSObject {} -+ (void)saveScreenshotAs:(const ScreenState*)screen; -@end +/* Copyright (C) 2007 Jeff Bland + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#import + +@class ScreenState; + +@interface Screenshot : NSObject {} ++ (void)saveScreenshotAs:(const ScreenState*)screen; +@end diff --git a/desmume/src/cocoa/screenshot.mm b/src/cocoa/screenshot.mm similarity index 100% rename from desmume/src/cocoa/screenshot.mm rename to src/cocoa/screenshot.mm diff --git a/desmume/src/cocoa/sndOSX.h b/src/cocoa/sndOSX.h similarity index 96% rename from desmume/src/cocoa/sndOSX.h rename to src/cocoa/sndOSX.h index 432175347..a252db751 100644 --- a/desmume/src/cocoa/sndOSX.h +++ b/src/cocoa/sndOSX.h @@ -1,50 +1,50 @@ -/* Copyright 2007 Jeff Bland - - This file is part of DeSmuME. - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#define OBJ_C -#include "../SPU.h" -#undef OBJ_C - -#ifdef __cplusplus -extern "C" -{ -#endif - -#define SNDCORE_OSX 58325 //hopefully this is unique number - -//This is the sound inerface so the emulator core can send us sound info and whatnot -extern SoundInterface_struct SNDOSX; - -//Beyond this point are sound interface extensions specific to the mac port - - -int SNDOSXReset(); -void SNDOSXMuteAudio(); -void SNDOSXUnMuteAudio(); -void SNDOSXSetVolume(int volume); - -//Recording -bool SNDOSXOpenFile(void *fname); //opens a file for recording (if filename is the currently opened one, it will restart the file), fname is an NSString -void SNDOSXStartRecording(); //begins recording to the currently open file if there is an open file -void SNDOSXStopRecording(); //pauses recording (you can continue recording later) -void SNDOSXCloseFile(); //closes the file, making sure it's saved - -#ifdef __cplusplus -} +/* Copyright 2007 Jeff Bland + + This file is part of DeSmuME. + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#define OBJ_C +#include "../SPU.h" +#undef OBJ_C + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define SNDCORE_OSX 58325 //hopefully this is unique number + +//This is the sound inerface so the emulator core can send us sound info and whatnot +extern SoundInterface_struct SNDOSX; + +//Beyond this point are sound interface extensions specific to the mac port + + +int SNDOSXReset(); +void SNDOSXMuteAudio(); +void SNDOSXUnMuteAudio(); +void SNDOSXSetVolume(int volume); + +//Recording +bool SNDOSXOpenFile(void *fname); //opens a file for recording (if filename is the currently opened one, it will restart the file), fname is an NSString +void SNDOSXStartRecording(); //begins recording to the currently open file if there is an open file +void SNDOSXStopRecording(); //pauses recording (you can continue recording later) +void SNDOSXCloseFile(); //closes the file, making sure it's saved + +#ifdef __cplusplus +} #endif \ No newline at end of file diff --git a/desmume/src/cocoa/sndOSX.mm b/src/cocoa/sndOSX.mm similarity index 100% rename from desmume/src/cocoa/sndOSX.mm rename to src/cocoa/sndOSX.mm diff --git a/desmume/src/cocoa/translations/Chinese.lproj/Localizable.strings b/src/cocoa/translations/Chinese.lproj/Localizable.strings similarity index 100% rename from desmume/src/cocoa/translations/Chinese.lproj/Localizable.strings rename to src/cocoa/translations/Chinese.lproj/Localizable.strings diff --git a/desmume/src/cocoa/translations/Chinese.lproj/MainMenu.nib/classes.nib b/src/cocoa/translations/Chinese.lproj/MainMenu.nib/classes.nib similarity index 100% rename from desmume/src/cocoa/translations/Chinese.lproj/MainMenu.nib/classes.nib rename to src/cocoa/translations/Chinese.lproj/MainMenu.nib/classes.nib diff --git a/desmume/src/cocoa/translations/Chinese.lproj/MainMenu.nib/info.nib b/src/cocoa/translations/Chinese.lproj/MainMenu.nib/info.nib similarity index 100% rename from desmume/src/cocoa/translations/Chinese.lproj/MainMenu.nib/info.nib rename to src/cocoa/translations/Chinese.lproj/MainMenu.nib/info.nib diff --git a/desmume/src/cocoa/translations/Chinese.lproj/MainMenu.nib/keyedobjects.nib b/src/cocoa/translations/Chinese.lproj/MainMenu.nib/keyedobjects.nib similarity index 100% rename from desmume/src/cocoa/translations/Chinese.lproj/MainMenu.nib/keyedobjects.nib rename to src/cocoa/translations/Chinese.lproj/MainMenu.nib/keyedobjects.nib diff --git a/desmume/src/cocoa/translations/English.lproj/Localizable.strings b/src/cocoa/translations/English.lproj/Localizable.strings similarity index 100% rename from desmume/src/cocoa/translations/English.lproj/Localizable.strings rename to src/cocoa/translations/English.lproj/Localizable.strings diff --git a/desmume/src/cocoa/translations/English.lproj/MainMenu.nib/classes.nib b/src/cocoa/translations/English.lproj/MainMenu.nib/classes.nib old mode 100755 new mode 100644 similarity index 100% rename from desmume/src/cocoa/translations/English.lproj/MainMenu.nib/classes.nib rename to src/cocoa/translations/English.lproj/MainMenu.nib/classes.nib diff --git a/desmume/src/cocoa/translations/English.lproj/MainMenu.nib/info.nib b/src/cocoa/translations/English.lproj/MainMenu.nib/info.nib old mode 100755 new mode 100644 similarity index 100% rename from desmume/src/cocoa/translations/English.lproj/MainMenu.nib/info.nib rename to src/cocoa/translations/English.lproj/MainMenu.nib/info.nib diff --git a/desmume/src/cocoa/translations/English.lproj/MainMenu.nib/keyedobjects.nib b/src/cocoa/translations/English.lproj/MainMenu.nib/keyedobjects.nib old mode 100755 new mode 100644 similarity index 100% rename from desmume/src/cocoa/translations/English.lproj/MainMenu.nib/keyedobjects.nib rename to src/cocoa/translations/English.lproj/MainMenu.nib/keyedobjects.nib diff --git a/desmume/src/cocoa/translations/French.lproj/Localizable.strings b/src/cocoa/translations/French.lproj/Localizable.strings similarity index 100% rename from desmume/src/cocoa/translations/French.lproj/Localizable.strings rename to src/cocoa/translations/French.lproj/Localizable.strings diff --git a/desmume/src/cocoa/translations/French.lproj/MainMenu.nib/classes.nib b/src/cocoa/translations/French.lproj/MainMenu.nib/classes.nib similarity index 100% rename from desmume/src/cocoa/translations/French.lproj/MainMenu.nib/classes.nib rename to src/cocoa/translations/French.lproj/MainMenu.nib/classes.nib diff --git a/desmume/src/cocoa/translations/French.lproj/MainMenu.nib/info.nib b/src/cocoa/translations/French.lproj/MainMenu.nib/info.nib similarity index 100% rename from desmume/src/cocoa/translations/French.lproj/MainMenu.nib/info.nib rename to src/cocoa/translations/French.lproj/MainMenu.nib/info.nib diff --git a/desmume/src/cocoa/translations/French.lproj/MainMenu.nib/keyedobjects.nib b/src/cocoa/translations/French.lproj/MainMenu.nib/keyedobjects.nib similarity index 100% rename from desmume/src/cocoa/translations/French.lproj/MainMenu.nib/keyedobjects.nib rename to src/cocoa/translations/French.lproj/MainMenu.nib/keyedobjects.nib diff --git a/desmume/src/cocoa/translations/Italian.lproj/Localizable.strings b/src/cocoa/translations/Italian.lproj/Localizable.strings similarity index 100% rename from desmume/src/cocoa/translations/Italian.lproj/Localizable.strings rename to src/cocoa/translations/Italian.lproj/Localizable.strings diff --git a/desmume/src/cocoa/translations/Italian.lproj/MainMenu.nib/classes.nib b/src/cocoa/translations/Italian.lproj/MainMenu.nib/classes.nib similarity index 100% rename from desmume/src/cocoa/translations/Italian.lproj/MainMenu.nib/classes.nib rename to src/cocoa/translations/Italian.lproj/MainMenu.nib/classes.nib diff --git a/desmume/src/cocoa/translations/Italian.lproj/MainMenu.nib/info.nib b/src/cocoa/translations/Italian.lproj/MainMenu.nib/info.nib similarity index 100% rename from desmume/src/cocoa/translations/Italian.lproj/MainMenu.nib/info.nib rename to src/cocoa/translations/Italian.lproj/MainMenu.nib/info.nib diff --git a/desmume/src/cocoa/translations/Italian.lproj/MainMenu.nib/keyedobjects.nib b/src/cocoa/translations/Italian.lproj/MainMenu.nib/keyedobjects.nib similarity index 100% rename from desmume/src/cocoa/translations/Italian.lproj/MainMenu.nib/keyedobjects.nib rename to src/cocoa/translations/Italian.lproj/MainMenu.nib/keyedobjects.nib diff --git a/desmume/src/cocoa/translations/Japanese.lproj/Localizable.strings b/src/cocoa/translations/Japanese.lproj/Localizable.strings similarity index 100% rename from desmume/src/cocoa/translations/Japanese.lproj/Localizable.strings rename to src/cocoa/translations/Japanese.lproj/Localizable.strings diff --git a/desmume/src/cocoa/translations/Japanese.lproj/MainMenu.nib/classes.nib b/src/cocoa/translations/Japanese.lproj/MainMenu.nib/classes.nib old mode 100755 new mode 100644 similarity index 100% rename from desmume/src/cocoa/translations/Japanese.lproj/MainMenu.nib/classes.nib rename to src/cocoa/translations/Japanese.lproj/MainMenu.nib/classes.nib diff --git a/desmume/src/cocoa/translations/Japanese.lproj/MainMenu.nib/info.nib b/src/cocoa/translations/Japanese.lproj/MainMenu.nib/info.nib old mode 100755 new mode 100644 similarity index 100% rename from desmume/src/cocoa/translations/Japanese.lproj/MainMenu.nib/info.nib rename to src/cocoa/translations/Japanese.lproj/MainMenu.nib/info.nib diff --git a/desmume/src/cocoa/translations/Japanese.lproj/MainMenu.nib/keyedobjects.nib b/src/cocoa/translations/Japanese.lproj/MainMenu.nib/keyedobjects.nib old mode 100755 new mode 100644 similarity index 100% rename from desmume/src/cocoa/translations/Japanese.lproj/MainMenu.nib/keyedobjects.nib rename to src/cocoa/translations/Japanese.lproj/MainMenu.nib/keyedobjects.nib diff --git a/desmume/src/cocoa/video_output_view.h b/src/cocoa/video_output_view.h similarity index 96% rename from desmume/src/cocoa/video_output_view.h rename to src/cocoa/video_output_view.h index d8c52cace..8f28b8c70 100644 --- a/desmume/src/cocoa/video_output_view.h +++ b/src/cocoa/video_output_view.h @@ -1,50 +1,50 @@ -/* Copyright (C) 2007 Jeff Bland - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#import "nds_control.h" - -//This class uses OpenGL for drawing for speed -//if opengl is not available it uses NSImage - -@class ScreenState; - -@interface VideoOutputView : -#ifdef HAVE_OPENGL -NSView -#else -NSImageView -#endif -{ -#ifdef HAVE_OPENGL - NSOpenGLContext* context; -#endif - ScreenState *screen_buffer; -} -//init -- (id)initWithFrame:(NSRect)frame; - -//image to display -- (void)setScreenState:(ScreenState*)screen; -- (const ScreenState*)screenState; - -//size in pixels of screen display (disreguarding rotation of the view) -- (float)screenHeight; -- (float)screenWidth; -@end - +/* Copyright (C) 2007 Jeff Bland + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#import "nds_control.h" + +//This class uses OpenGL for drawing for speed +//if opengl is not available it uses NSImage + +@class ScreenState; + +@interface VideoOutputView : +#ifdef HAVE_OPENGL +NSView +#else +NSImageView +#endif +{ +#ifdef HAVE_OPENGL + NSOpenGLContext* context; +#endif + ScreenState *screen_buffer; +} +//init +- (id)initWithFrame:(NSRect)frame; + +//image to display +- (void)setScreenState:(ScreenState*)screen; +- (const ScreenState*)screenState; + +//size in pixels of screen display (disreguarding rotation of the view) +- (float)screenHeight; +- (float)screenWidth; +@end + diff --git a/desmume/src/cocoa/video_output_view.mm b/src/cocoa/video_output_view.mm similarity index 100% rename from desmume/src/cocoa/video_output_view.mm rename to src/cocoa/video_output_view.mm diff --git a/desmume/src/commandline.cpp b/src/commandline.cpp similarity index 92% rename from desmume/src/commandline.cpp rename to src/commandline.cpp index 3e4e2b351..88b3268a5 100644 --- a/desmume/src/commandline.cpp +++ b/src/commandline.cpp @@ -33,14 +33,13 @@ int scanline_filter_a = 2, scanline_filter_b = 4; CommandLine::CommandLine() -: is_cflash_configured(false) -, error(NULL) +: error(NULL) , ctx(g_option_context_new ("")) +, is_cflash_configured(false) , _play_movie_file(0) , _record_movie_file(0) , _cflash_image(0) , _cflash_path(0) -, _single_core(0) { load_slot = 0; arm9_gdb_port = arm7_gdb_port = 0; @@ -67,7 +66,6 @@ void CommandLine::loadCommonOptions() { "cflash-image", 0, 0, G_OPTION_ARG_FILENAME, &_cflash_image, "Requests cflash in gbaslot with fat image at this path", "CFLASH_IMAGE"}, { "cflash-path", 0, 0, G_OPTION_ARG_FILENAME, &_cflash_path, "Requests cflash in gbaslot with filesystem rooted at this path", "CFLASH_PATH"}, #ifdef _MSC_VER - { "single-core", 0, 0, G_OPTION_ARG_NONE, &_single_core, "Limit execution to use approximately only one core", "NUM_CORES"}, { "scanline-filter-a", 0, 0, G_OPTION_ARG_INT, &scanline_filter_a, "Intensity of fadeout for scanlines filter (edge) (default 2)", "SCANLINE_FILTER_A"}, { "scanline-filter-b", 0, 0, G_OPTION_ARG_INT, &scanline_filter_b, "Intensity of fadeout for scanlines filter (corner) (default 4)", "SCANLINE_FILTER_B"}, #endif @@ -95,7 +93,6 @@ bool CommandLine::parse(int argc,char **argv) if(_cflash_image) cflash_image = _cflash_image; if(_cflash_path) cflash_path = _cflash_path; - CommonSettings.single_core = _single_core!=0; if (argc == 2) nds_file = argv[1]; diff --git a/desmume/src/commandline.h b/src/commandline.h similarity index 95% rename from desmume/src/commandline.h rename to src/commandline.h index 689ac776d..f7097678e 100644 --- a/desmume/src/commandline.h +++ b/src/commandline.h @@ -73,7 +73,6 @@ private: char* _record_movie_file; char* _cflash_image; char* _cflash_path; - int _single_core; }; #endif diff --git a/desmume/src/common.cpp b/src/common.cpp similarity index 95% rename from desmume/src/common.cpp rename to src/common.cpp index 6df5cd606..41ffa27b1 100644 --- a/desmume/src/common.cpp +++ b/src/common.cpp @@ -1,122 +1,122 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2006-2008 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include "common.h" - -u8 gba_header_data_0x04[156] = { - 0x24,0xFF,0xAE,0x51,0x69,0x9A,0xA2,0x21,0x3D,0x84,0x82,0x0A,0x84,0xE4,0x09,0xAD, - 0x11,0x24,0x8B,0x98,0xC0,0x81,0x7F,0x21,0xA3,0x52,0xBE,0x19,0x93,0x09,0xCE,0x20, - 0x10,0x46,0x4A,0x4A,0xF8,0x27,0x31,0xEC,0x58,0xC7,0xE8,0x33,0x82,0xE3,0xCE,0xBF, - 0x85,0xF4,0xDF,0x94,0xCE,0x4B,0x09,0xC1,0x94,0x56,0x8A,0xC0,0x13,0x72,0xA7,0xFC, - 0x9F,0x84,0x4D,0x73,0xA3,0xCA,0x9A,0x61,0x58,0x97,0xA3,0x27,0xFC,0x03,0x98,0x76, - 0x23,0x1D,0xC7,0x61,0x03,0x04,0xAE,0x56,0xBF,0x38,0x84,0x00,0x40,0xA7,0x0E,0xFD, - 0xFF,0x52,0xFE,0x03,0x6F,0x95,0x30,0xF1,0x97,0xFB,0xC0,0x85,0x60,0xD6,0x80,0x25, - 0xA9,0x63,0xBE,0x03,0x01,0x4E,0x38,0xE2,0xF9,0xA2,0x34,0xFF,0xBB,0x3E,0x03,0x44, - 0x78,0x00,0x90,0xCB,0x88,0x11,0x3A,0x94,0x65,0xC0,0x7C,0x63,0x87,0xF0,0x3C,0xAF, - 0xD6,0x25,0xE4,0x8B,0x38,0x0A,0xAC,0x72,0x21,0xD4,0xF8,0x07}; - -#ifdef WIN32 -char IniName[MAX_PATH]; - -void GetINIPath() -{ - char vPath[MAX_PATH], *szPath; - /*if (*vPath) - szPath = vPath; - else - {*/ - char *p; - ZeroMemory(vPath, sizeof(vPath)); - GetModuleFileName(NULL, vPath, sizeof(vPath)); - p = vPath + lstrlen(vPath); - while (p >= vPath && *p != '\\') p--; - if (++p >= vPath) *p = 0; - szPath = vPath; - //} - if (strlen(szPath) + strlen("\\desmume.ini") < MAX_PATH) - { - sprintf(IniName, "%s\\desmume.ini",szPath); - } else if (MAX_PATH> strlen(".\\desmume.ini")) { - sprintf(IniName, ".\\desmume.ini"); - } else - { - memset(IniName,0,MAX_PATH) ; - } -} - -void WritePrivateProfileBool(char* appname, char* keyname, bool val, char* file) -{ - char temp[256] = ""; - sprintf(temp, "%d", val?1:0); - WritePrivateProfileString(appname, keyname, temp, file); -} - -bool GetPrivateProfileBool(const char* appname, const char* keyname, bool defval, const char* filename) -{ - return GetPrivateProfileInt(appname,keyname,defval?1:0,filename) != 0; -} - -void WritePrivateProfileInt(char* appname, char* keyname, int val, char* file) -{ - char temp[256] = ""; - sprintf(temp, "%d", val); - WritePrivateProfileString(appname, keyname, temp, file); -} - -#endif - -u8 reverseBitsInByte(u8 x) -{ - u8 h = 0; - u8 i = 0; - - for (i = 0; i < 8; i++) - { - h = (h << 1) + (x & 1); - x >>= 1; - } - - return h; -} - -void removeCR(char *buf) -{ - int l=strlen(buf); - for (int i=0; i < l; i++) - { - if (buf[i]==0x0A) buf[i]=0; - if (buf[i]==0x0D) buf[i]=0; - } -} - -u32 strlen_ws(char *buf) // length without last spaces -{ - if (!strlen(buf)) return 0; - for (int i=strlen(buf); i>0; i--) - { - if (buf[i]!=32) return (i-1); // space - } - return 0; +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2006-2008 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include "common.h" + +u8 gba_header_data_0x04[156] = { + 0x24,0xFF,0xAE,0x51,0x69,0x9A,0xA2,0x21,0x3D,0x84,0x82,0x0A,0x84,0xE4,0x09,0xAD, + 0x11,0x24,0x8B,0x98,0xC0,0x81,0x7F,0x21,0xA3,0x52,0xBE,0x19,0x93,0x09,0xCE,0x20, + 0x10,0x46,0x4A,0x4A,0xF8,0x27,0x31,0xEC,0x58,0xC7,0xE8,0x33,0x82,0xE3,0xCE,0xBF, + 0x85,0xF4,0xDF,0x94,0xCE,0x4B,0x09,0xC1,0x94,0x56,0x8A,0xC0,0x13,0x72,0xA7,0xFC, + 0x9F,0x84,0x4D,0x73,0xA3,0xCA,0x9A,0x61,0x58,0x97,0xA3,0x27,0xFC,0x03,0x98,0x76, + 0x23,0x1D,0xC7,0x61,0x03,0x04,0xAE,0x56,0xBF,0x38,0x84,0x00,0x40,0xA7,0x0E,0xFD, + 0xFF,0x52,0xFE,0x03,0x6F,0x95,0x30,0xF1,0x97,0xFB,0xC0,0x85,0x60,0xD6,0x80,0x25, + 0xA9,0x63,0xBE,0x03,0x01,0x4E,0x38,0xE2,0xF9,0xA2,0x34,0xFF,0xBB,0x3E,0x03,0x44, + 0x78,0x00,0x90,0xCB,0x88,0x11,0x3A,0x94,0x65,0xC0,0x7C,0x63,0x87,0xF0,0x3C,0xAF, + 0xD6,0x25,0xE4,0x8B,0x38,0x0A,0xAC,0x72,0x21,0xD4,0xF8,0x07}; + +#ifdef WIN32 +char IniName[MAX_PATH]; + +void GetINIPath() +{ + char vPath[MAX_PATH], *szPath, currDir[MAX_PATH]; + /*if (*vPath) + szPath = vPath; + else + {*/ + char *p; + ZeroMemory(vPath, sizeof(vPath)); + GetModuleFileName(NULL, vPath, sizeof(vPath)); + p = vPath + lstrlen(vPath); + while (p >= vPath && *p != '\\') p--; + if (++p >= vPath) *p = 0; + szPath = vPath; + //} + if (strlen(szPath) + strlen("\\desmume.ini") < MAX_PATH) + { + sprintf(IniName, "%s\\desmume.ini",szPath); + } else if (MAX_PATH> strlen(".\\desmume.ini")) { + sprintf(IniName, ".\\desmume.ini"); + } else + { + memset(IniName,0,MAX_PATH) ; + } +} + +void WritePrivateProfileBool(char* appname, char* keyname, bool val, char* file) +{ + char temp[256] = ""; + sprintf(temp, "%d", val?1:0); + WritePrivateProfileString(appname, keyname, temp, file); +} + +bool GetPrivateProfileBool(const char* appname, const char* keyname, bool defval, const char* filename) +{ + return GetPrivateProfileInt(appname,keyname,defval?1:0,filename) != 0; +} + +void WritePrivateProfileInt(char* appname, char* keyname, int val, char* file) +{ + char temp[256] = ""; + sprintf(temp, "%d", val); + WritePrivateProfileString(appname, keyname, temp, file); +} + +#endif + +u8 reverseBitsInByte(u8 x) +{ + u8 h = 0; + u8 i = 0; + + for (i = 0; i < 8; i++) + { + h = (h << 1) + (x & 1); + x >>= 1; + } + + return h; +} + +void removeCR(char *buf) +{ + int l=strlen(buf); + for (int i=0; i < l; i++) + { + if (buf[i]==0x0A) buf[i]=0; + if (buf[i]==0x0D) buf[i]=0; + } +} + +u32 strlen_ws(char *buf) // length without last spaces +{ + if (!strlen(buf)) return 0; + for (int i=strlen(buf); i>0; i--) + { + if (buf[i]!=32) return (i-1); // space + } + return 0; } \ No newline at end of file diff --git a/desmume/src/common.h b/src/common.h similarity index 96% rename from desmume/src/common.h rename to src/common.h index af87d4b78..bb38e22fe 100644 --- a/desmume/src/common.h +++ b/src/common.h @@ -1,89 +1,89 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2006-2008 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef _COMMON_H_ -#define _COMMON_H_ - -#include -#include "types.h" -#include - -extern u8 gba_header_data_0x04[156]; -#ifdef WIN32 - - #include - #include - - #define IDT_VIEW_DISASM7 50001 - #define IDT_VIEW_DISASM9 50002 - #define IDT_VIEW_MEM7 50003 - #define IDT_VIEW_MEM9 50004 - #define IDT_VIEW_IOREG 50005 - #define IDT_VIEW_PAL 50006 - #define IDT_VIEW_TILE 50007 - #define IDT_VIEW_MAP 50008 - #define IDT_VIEW_OAM 50009 - #define IDT_VIEW_MATRIX 50010 - #define IDT_VIEW_LIGHTS 50011 - #define IDM_EXEC 50112 - - #define IDM_RECENT_RESERVED0 65500 - #define IDM_RECENT_RESERVED1 65501 - #define IDM_RECENT_RESERVED2 65502 - #define IDM_RECENT_RESERVED3 65503 - #define IDM_RECENT_RESERVED4 65504 - #define IDM_RECENT_RESERVED5 65505 - #define IDM_RECENT_RESERVED6 65506 - #define IDM_RECENT_RESERVED7 65507 - #define IDM_RECENT_RESERVED8 65508 - #define IDM_RECENT_RESERVED9 65509 - #define IDM_RECENT_RESERVED10 65510 - #define IDM_RECENT_RESERVED11 65511 - #define IDM_RECENT_RESERVED12 65512 - #define IDM_RECENT_RESERVED13 65513 - - #define CLASSNAME "DeSmuME" - - extern HINSTANCE hAppInst; - - extern bool romloaded; - - extern char IniName[MAX_PATH]; - extern void GetINIPath(); - extern void WritePrivateProfileInt(char* appname, char* keyname, int val, char* file); - - bool GetPrivateProfileBool(const char* appname, const char* keyname, bool defval, const char* filename); - void WritePrivateProfileBool(char* appname, char* keyname, bool val, char* file); - -#else // non Windows - -#define sscanf_s sscanf - -#endif - -extern u8 reverseBitsInByte(u8 x); -extern void removeCR(char *buf); -extern u32 strlen_ws(char *buf); - -#endif - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2006-2008 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef _COMMON_H_ +#define _COMMON_H_ + +#include +#include "types.h" +#include + +extern u8 gba_header_data_0x04[156]; +#ifdef WIN32 + + #include + #include + + #define IDT_VIEW_DISASM7 50001 + #define IDT_VIEW_DISASM9 50002 + #define IDT_VIEW_MEM7 50003 + #define IDT_VIEW_MEM9 50004 + #define IDT_VIEW_IOREG 50005 + #define IDT_VIEW_PAL 50006 + #define IDT_VIEW_TILE 50007 + #define IDT_VIEW_MAP 50008 + #define IDT_VIEW_OAM 50009 + #define IDT_VIEW_MATRIX 50010 + #define IDT_VIEW_LIGHTS 50011 + #define IDM_EXEC 50112 + + #define IDM_RECENT_RESERVED0 65500 + #define IDM_RECENT_RESERVED1 65501 + #define IDM_RECENT_RESERVED2 65502 + #define IDM_RECENT_RESERVED3 65503 + #define IDM_RECENT_RESERVED4 65504 + #define IDM_RECENT_RESERVED5 65505 + #define IDM_RECENT_RESERVED6 65506 + #define IDM_RECENT_RESERVED7 65507 + #define IDM_RECENT_RESERVED8 65508 + #define IDM_RECENT_RESERVED9 65509 + #define IDM_RECENT_RESERVED10 65510 + #define IDM_RECENT_RESERVED11 65511 + #define IDM_RECENT_RESERVED12 65512 + #define IDM_RECENT_RESERVED13 65513 + + #define CLASSNAME "DeSmuME" + + extern HINSTANCE hAppInst; + + extern BOOL romloaded; + + extern char IniName[MAX_PATH]; + extern void GetINIPath(); + extern void WritePrivateProfileInt(char* appname, char* keyname, int val, char* file); + + bool GetPrivateProfileBool(const char* appname, const char* keyname, bool defval, const char* filename); + void WritePrivateProfileBool(char* appname, char* keyname, bool val, char* file); + +#else // non Windows + +#define sscanf_s sscanf + +#endif + +extern u8 reverseBitsInByte(u8 x); +extern void removeCR(char *buf); +extern u32 strlen_ws(char *buf); + +#endif + diff --git a/desmume/src/cp15.cpp b/src/cp15.cpp similarity index 96% rename from desmume/src/cp15.cpp rename to src/cp15.cpp index 2b646c5c6..7f65f49e4 100644 --- a/desmume/src/cp15.cpp +++ b/src/cp15.cpp @@ -1,595 +1,595 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include - -#include "cp15.h" -#include "debug.h" -#include "MMU.h" - -armcp15_t *armcp15_new(armcpu_t * c) -{ - int i; - armcp15_t *armcp15 = (armcp15_t*)malloc(sizeof(armcp15_t)); - if(!armcp15) return NULL; - - armcp15->cpu = c; - armcp15->IDCode = 0x41049460; - armcp15->cacheType = 0x0F0D2112; - armcp15->TCMSize = 0x00140140; - armcp15->ctrl = 0x00000000; - armcp15->DCConfig = 0x0; - armcp15->ICConfig = 0x0; - armcp15->writeBuffCtrl = 0x0; - armcp15->und = 0x0; - armcp15->DaccessPerm = 0x22222222; - armcp15->IaccessPerm = 0x22222222; - armcp15->protectBaseSize0 = 0x0; - armcp15->protectBaseSize1 = 0x0; - armcp15->protectBaseSize2 = 0x0; - armcp15->protectBaseSize3 = 0x0; - armcp15->protectBaseSize4 = 0x0; - armcp15->protectBaseSize5 = 0x0; - armcp15->protectBaseSize6 = 0x0; - armcp15->protectBaseSize7 = 0x0; - armcp15->cacheOp = 0x0; - armcp15->DcacheLock = 0x0; - armcp15->IcacheLock = 0x0; - armcp15->ITCMRegion = 0x0C; - armcp15->DTCMRegion = 0x0080000A; - armcp15->processID = 0; - - /* preset calculated regionmasks */ - for (i=0;i<8;i++) { - armcp15->regionWriteMask_USR[i] = 0 ; - armcp15->regionWriteMask_SYS[i] = 0 ; - armcp15->regionReadMask_USR[i] = 0 ; - armcp15->regionReadMask_SYS[i] = 0 ; - armcp15->regionExecuteMask_USR[i] = 0 ; - armcp15->regionExecuteMask_SYS[i] = 0 ; - armcp15->regionWriteSet_USR[i] = 0 ; - armcp15->regionWriteSet_SYS[i] = 0 ; - armcp15->regionReadSet_USR[i] = 0 ; - armcp15->regionReadSet_SYS[i] = 0 ; - armcp15->regionExecuteSet_USR[i] = 0 ; - armcp15->regionExecuteSet_SYS[i] = 0 ; - } ; - - return armcp15; -} - -#define ACCESSTYPE(val,n) (((val) >> (4*n)) & 0x0F) -#define SIZEIDENTIFIER(val) ((((val) >> 1) & 0x1F)) -#define SIZEBINARY(val) (1 << (SIZEIDENTIFIER(val)+1)) -#define MASKFROMREG(val) (~((SIZEBINARY(val)-1) | 0x3F)) -#define SETFROMREG(val) ((val) & MASKFROMREG(val)) -/* sets the precalculated regions to mask,set for the affected accesstypes */ -static void armcp15_setSingleRegionAccess(armcp15_t *armcp15,u32 dAccess,u32 iAccess,unsigned char num, u32 mask,u32 set) { - - switch (ACCESSTYPE(dAccess,num)) { - case 4: /* UNP */ - case 7: /* UNP */ - case 8: /* UNP */ - case 9: /* UNP */ - case 10: /* UNP */ - case 11: /* UNP */ - case 12: /* UNP */ - case 13: /* UNP */ - case 14: /* UNP */ - case 15: /* UNP */ - case 0: /* no access at all */ - armcp15->regionWriteMask_USR[num] = 0 ; - armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_USR[num] = 0 ; - armcp15->regionReadSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionWriteMask_SYS[num] = 0 ; - armcp15->regionWriteSet_SYS[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_SYS[num] = 0 ; - armcp15->regionReadSet_SYS[num] = 0xFFFFFFFF ; - break ; - case 1: /* no access at USR, all to sys */ - armcp15->regionWriteMask_USR[num] = 0 ; - armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_USR[num] = 0 ; - armcp15->regionReadSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionWriteMask_SYS[num] = mask ; - armcp15->regionWriteSet_SYS[num] = set ; - armcp15->regionReadMask_SYS[num] = mask ; - armcp15->regionReadSet_SYS[num] = set ; - break ; - case 2: /* read at USR, all to sys */ - armcp15->regionWriteMask_USR[num] = 0 ; - armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_USR[num] = mask ; - armcp15->regionReadSet_USR[num] = set ; - armcp15->regionWriteMask_SYS[num] = mask ; - armcp15->regionWriteSet_SYS[num] = set ; - armcp15->regionReadMask_SYS[num] = mask ; - armcp15->regionReadSet_SYS[num] = set ; - break ; - case 3: /* all to USR, all to sys */ - armcp15->regionWriteMask_USR[num] = mask ; - armcp15->regionWriteSet_USR[num] = set ; - armcp15->regionReadMask_USR[num] = mask ; - armcp15->regionReadSet_USR[num] = set ; - armcp15->regionWriteMask_SYS[num] = mask ; - armcp15->regionWriteSet_SYS[num] = set ; - armcp15->regionReadMask_SYS[num] = mask ; - armcp15->regionReadSet_SYS[num] = set ; - break ; - case 5: /* no access at USR, read to sys */ - armcp15->regionWriteMask_USR[num] = 0 ; - armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_USR[num] = 0 ; - armcp15->regionReadSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionWriteMask_SYS[num] = 0 ; - armcp15->regionWriteSet_SYS[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_SYS[num] = mask ; - armcp15->regionReadSet_SYS[num] = set ; - break ; - case 6: /* read at USR, read to sys */ - armcp15->regionWriteMask_USR[num] = 0 ; - armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_USR[num] = mask ; - armcp15->regionReadSet_USR[num] = set ; - armcp15->regionWriteMask_SYS[num] = 0 ; - armcp15->regionWriteSet_SYS[num] = 0xFFFFFFFF ; - armcp15->regionReadMask_SYS[num] = mask ; - armcp15->regionReadSet_SYS[num] = set ; - break ; - } - switch (ACCESSTYPE(iAccess,num)) { - case 4: /* UNP */ - case 7: /* UNP */ - case 8: /* UNP */ - case 9: /* UNP */ - case 10: /* UNP */ - case 11: /* UNP */ - case 12: /* UNP */ - case 13: /* UNP */ - case 14: /* UNP */ - case 15: /* UNP */ - case 0: /* no access at all */ - armcp15->regionExecuteMask_USR[num] = 0 ; - armcp15->regionExecuteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionExecuteMask_SYS[num] = 0 ; - armcp15->regionExecuteSet_SYS[num] = 0xFFFFFFFF ; - break ; - case 1: - armcp15->regionExecuteMask_USR[num] = 0 ; - armcp15->regionExecuteSet_USR[num] = 0xFFFFFFFF ; - armcp15->regionExecuteMask_SYS[num] = mask ; - armcp15->regionExecuteSet_SYS[num] = set ; - break ; - case 2: - case 3: - case 6: - armcp15->regionExecuteMask_USR[num] = mask ; - armcp15->regionExecuteSet_USR[num] = set ; - armcp15->regionExecuteMask_SYS[num] = mask ; - armcp15->regionExecuteSet_SYS[num] = set ; - break ; - } -} ; - -/* precalculate region masks/sets from cp15 register */ -static void armcp15_maskPrecalc(armcp15_t *armcp15) -{ - #define precalc(num) { \ - u32 mask = 0, set = 0xFFFFFFFF ; /* (x & 0) == 0xFF..FF is allways false (disabled) */ \ - if (BIT_N(armcp15->protectBaseSize##num,0)) /* if region is enabled */ \ - { /* reason for this define: naming includes var */ \ - mask = MASKFROMREG(armcp15->protectBaseSize##num) ; \ - set = SETFROMREG(armcp15->protectBaseSize##num) ; \ - if (SIZEIDENTIFIER(armcp15->protectBaseSize##num)==0x1F) \ - { /* for the 4GB region, u32 suffers wraparound */ \ - mask = 0 ; set = 0 ; /* (x & 0) == 0 is allways true (enabled) */ \ - } \ - } \ - armcp15_setSingleRegionAccess(armcp15,armcp15->DaccessPerm,armcp15->IaccessPerm,num,mask,set) ; \ - } - precalc(0) ; - precalc(1) ; - precalc(2) ; - precalc(3) ; - precalc(4) ; - precalc(5) ; - precalc(6) ; - precalc(7) ; -} - -INLINE BOOL armcp15_isAccessAllowed(armcp15_t *armcp15,u32 address,u32 access) -{ - int i ; - if (!(armcp15->ctrl & 1)) return TRUE ; /* protection checking is not enabled */ - for (i=0;i<8;i++) { - switch (access) { - case CP15_ACCESS_WRITEUSR: - if ((address & armcp15->regionWriteMask_USR[i]) == armcp15->regionWriteSet_USR[i]) return TRUE ; - break ; - case CP15_ACCESS_WRITESYS: - if ((address & armcp15->regionWriteMask_SYS[i]) == armcp15->regionWriteSet_SYS[i]) return TRUE ; - break ; - case CP15_ACCESS_READUSR: - if ((address & armcp15->regionReadMask_USR[i]) == armcp15->regionReadSet_USR[i]) return TRUE ; - break ; - case CP15_ACCESS_READSYS: - if ((address & armcp15->regionReadMask_SYS[i]) == armcp15->regionReadSet_SYS[i]) return TRUE ; - break ; - case CP15_ACCESS_EXECUSR: - if ((address & armcp15->regionExecuteMask_USR[i]) == armcp15->regionExecuteSet_USR[i]) return TRUE ; - break ; - case CP15_ACCESS_EXECSYS: - if ((address & armcp15->regionExecuteMask_SYS[i]) == armcp15->regionExecuteSet_SYS[i]) return TRUE ; - break ; - } - } - /* when protections are enabled, but no region allows access, deny access */ - return FALSE ; -} - -BOOL armcp15_dataProcess(armcp15_t *armcp15, u8 CRd, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2) -{ - LOG("Unsupported CP15 operation : DataProcess\n"); - return FALSE; -} - -BOOL armcp15_load(armcp15_t *armcp15, u8 CRd, u8 adr) -{ - LOG("Unsupported CP15 operation : Load\n"); - return FALSE; -} - -BOOL armcp15_store(armcp15_t *armcp15, u8 CRd, u8 adr) -{ - LOG("Unsupported CP15 operation : Store\n"); - return FALSE; -} - -BOOL armcp15_moveCP2ARM(armcp15_t *armcp15, u32 * R, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2) -{ - if(armcp15->cpu->CPSR.bits.mode == USR) return FALSE; - - switch(CRn) - { - case 0 : - if((opcode1 == 0)&&(CRm==0)) - { - switch(opcode2) - { - case 1 : - *R = armcp15->cacheType; - return TRUE; - case 2 : - *R = armcp15->TCMSize; - return TRUE; - default : - *R = armcp15->IDCode; - return TRUE; - } - } - return FALSE; - case 1 : - if((opcode1==0) && (opcode2==0) && (CRm==0)) - { - *R = armcp15->ctrl; - return TRUE; - } - return FALSE; - - case 2 : - if((opcode1==0) && (CRm==0)) - { - switch(opcode2) - { - case 0 : - *R = armcp15->DCConfig; - return TRUE; - case 1 : - *R = armcp15->ICConfig; - return TRUE; - default : - return FALSE; - } - } - return FALSE; - case 3 : - if((opcode1==0) && (opcode2==0) && (CRm==0)) - { - *R = armcp15->writeBuffCtrl; - return TRUE; - } - return FALSE; - case 5 : - if((opcode1==0) && (CRm==0)) - { - switch(opcode2) - { - case 2 : - *R = armcp15->DaccessPerm; - return TRUE; - case 3 : - *R = armcp15->IaccessPerm; - return TRUE; - default : - return FALSE; - } - } - return FALSE; - case 6 : - if((opcode1==0) && (opcode2==0)) - { - switch(CRm) - { - case 0 : - *R = armcp15->protectBaseSize0; - return TRUE; - case 1 : - *R = armcp15->protectBaseSize1; - return TRUE; - case 2 : - *R = armcp15->protectBaseSize2; - return TRUE; - case 3 : - *R = armcp15->protectBaseSize3; - return TRUE; - case 4 : - *R = armcp15->protectBaseSize4; - return TRUE; - case 5 : - *R = armcp15->protectBaseSize5; - return TRUE; - case 6 : - *R = armcp15->protectBaseSize6; - return TRUE; - case 7 : - *R = armcp15->protectBaseSize7; - return TRUE; - default : - return FALSE; - } - } - return FALSE; - case 9 : - if((opcode1==0)) - { - switch(CRm) - { - case 0 : - switch(opcode2) - { - case 0 : - *R = armcp15->DcacheLock; - return TRUE; - case 1 : - *R = armcp15->IcacheLock; - return TRUE; - default : - return FALSE; - } - case 1 : - switch(opcode2) - { - case 0 : - *R = armcp15->DTCMRegion; - return TRUE; - case 1 : - *R = armcp15->ITCMRegion; - return TRUE; - default : - return FALSE; - } - } - } - return FALSE; - default : - LOG("Unsupported CP15 operation : MRC\n"); - return FALSE; - } -} - - -static u32 CP15wait4IRQ(armcpu_t *cpu) -{ - /* on the first call, wirq is not set */ - if(cpu->wirq) - { - /* check wether an irq was issued */ - if(!cpu->waitIRQ) - { - cpu->waitIRQ = 0; - cpu->wirq = 0; - return 1; /* return execution */ - } - /* otherwise, repeat this instruction */ - cpu->R[15] = cpu->instruct_adr; - cpu->next_instruction = cpu->R[15]; - return 1; - } - /* first run, set us into waiting state */ - cpu->waitIRQ = 1; - cpu->wirq = 1; - /* and set next instruction to repeat this */ - cpu->R[15] = cpu->instruct_adr; - cpu->next_instruction = cpu->R[15]; - /* CHECKME: IME shouldn't be modified (?) */ - MMU.reg_IME[0] = 1; - return 1; -} - -BOOL armcp15_moveARM2CP(armcp15_t *armcp15, u32 val, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2) -{ - if(armcp15->cpu->CPSR.bits.mode == USR) return FALSE; - - switch(CRn) - { - case 1 : - if((opcode1==0) && (opcode2==0) && (CRm==0)) - { - armcp15->ctrl = val; - MMU.ARM9_RW_MODE = BIT7(val); - armcp15->cpu->intVector = 0x0FFF0000 * (BIT13(val)); - armcp15->cpu->LDTBit = !BIT15(val); //TBit - /*if(BIT17(val)) - { - log::ajouter("outch !!!!!!!"); - } - if(BIT19(val)) - { - log::ajouter("outch !!!!!!!"); - }*/ - return TRUE; - } - return FALSE; - case 2 : - if((opcode1==0) && (CRm==0)) - { - switch(opcode2) - { - case 0 : - armcp15->DCConfig = val; - return TRUE; - case 1 : - armcp15->ICConfig = val; - return TRUE; - default : - return FALSE; - } - } - return FALSE; - case 3 : - if((opcode1==0) && (opcode2==0) && (CRm==0)) - { - armcp15->writeBuffCtrl = val; - return TRUE; - } - return FALSE; - case 5 : - if((opcode1==0) && (CRm==0)) - { - switch(opcode2) - { - case 2 : - armcp15->DaccessPerm = val; - armcp15_maskPrecalc(armcp15); - return TRUE; - case 3 : - armcp15->IaccessPerm = val; - armcp15_maskPrecalc(armcp15); - return TRUE; - default : - return FALSE; - } - } - return FALSE; - case 6 : - if((opcode1==0) && (opcode2==0)) - { - switch(CRm) - { - case 0 : - armcp15->protectBaseSize0 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 1 : - armcp15->protectBaseSize1 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 2 : - armcp15->protectBaseSize2 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 3 : - armcp15->protectBaseSize3 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 4 : - armcp15->protectBaseSize4 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 5 : - armcp15->protectBaseSize5 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 6 : - armcp15->protectBaseSize6 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - case 7 : - armcp15->protectBaseSize7 = val; - armcp15_maskPrecalc(armcp15) ; - return TRUE; - default : - return FALSE; - } - } - return FALSE; - case 7 : - if((CRm==0)&&(opcode1==0)&&((opcode2==4))) - { - CP15wait4IRQ(armcp15->cpu); - return TRUE; - } - return FALSE; - case 9 : - if((opcode1==0)) - { - switch(CRm) - { - case 0 : - switch(opcode2) - { - case 0 : - armcp15->DcacheLock = val; - return TRUE; - case 1 : - armcp15->IcacheLock = val; - return TRUE; - default : - return FALSE; - } - case 1 : - switch(opcode2) - { - case 0 : - armcp15->DTCMRegion = val; - MMU.DTCMRegion = val & 0x0FFFFFFC0; - /*sprintf(logbuf, "%08X", val); - log::ajouter(logbuf);*/ - return TRUE; - case 1 : - armcp15->ITCMRegion = val; - /* ITCM base is not writeable! */ - MMU.ITCMRegion = 0; - return TRUE; - default : - return FALSE; - } - } - } - return FALSE; - default : - return FALSE; - } -} - - - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include + +#include "cp15.h" +#include "debug.h" +#include "MMU.h" + +armcp15_t *armcp15_new(armcpu_t * c) +{ + int i; + armcp15_t *armcp15 = (armcp15_t*)malloc(sizeof(armcp15_t)); + if(!armcp15) return NULL; + + armcp15->cpu = c; + armcp15->IDCode = 0x41049460; + armcp15->cacheType = 0x0F0D2112; + armcp15->TCMSize = 0x00140140; + armcp15->ctrl = 0x00000000; + armcp15->DCConfig = 0x0; + armcp15->ICConfig = 0x0; + armcp15->writeBuffCtrl = 0x0; + armcp15->und = 0x0; + armcp15->DaccessPerm = 0x22222222; + armcp15->IaccessPerm = 0x22222222; + armcp15->protectBaseSize0 = 0x0; + armcp15->protectBaseSize1 = 0x0; + armcp15->protectBaseSize2 = 0x0; + armcp15->protectBaseSize3 = 0x0; + armcp15->protectBaseSize4 = 0x0; + armcp15->protectBaseSize5 = 0x0; + armcp15->protectBaseSize6 = 0x0; + armcp15->protectBaseSize7 = 0x0; + armcp15->cacheOp = 0x0; + armcp15->DcacheLock = 0x0; + armcp15->IcacheLock = 0x0; + armcp15->ITCMRegion = 0x0C; + armcp15->DTCMRegion = 0x0080000A; + armcp15->processID = 0; + + /* preset calculated regionmasks */ + for (i=0;i<8;i++) { + armcp15->regionWriteMask_USR[i] = 0 ; + armcp15->regionWriteMask_SYS[i] = 0 ; + armcp15->regionReadMask_USR[i] = 0 ; + armcp15->regionReadMask_SYS[i] = 0 ; + armcp15->regionExecuteMask_USR[i] = 0 ; + armcp15->regionExecuteMask_SYS[i] = 0 ; + armcp15->regionWriteSet_USR[i] = 0 ; + armcp15->regionWriteSet_SYS[i] = 0 ; + armcp15->regionReadSet_USR[i] = 0 ; + armcp15->regionReadSet_SYS[i] = 0 ; + armcp15->regionExecuteSet_USR[i] = 0 ; + armcp15->regionExecuteSet_SYS[i] = 0 ; + } ; + + return armcp15; +} + +#define ACCESSTYPE(val,n) (((val) >> (4*n)) & 0x0F) +#define SIZEIDENTIFIER(val) ((((val) >> 1) & 0x1F)) +#define SIZEBINARY(val) (1 << (SIZEIDENTIFIER(val)+1)) +#define MASKFROMREG(val) (~((SIZEBINARY(val)-1) | 0x3F)) +#define SETFROMREG(val) ((val) & MASKFROMREG(val)) +/* sets the precalculated regions to mask,set for the affected accesstypes */ +static void armcp15_setSingleRegionAccess(armcp15_t *armcp15,u32 dAccess,u32 iAccess,unsigned char num, u32 mask,u32 set) { + + switch (ACCESSTYPE(dAccess,num)) { + case 4: /* UNP */ + case 7: /* UNP */ + case 8: /* UNP */ + case 9: /* UNP */ + case 10: /* UNP */ + case 11: /* UNP */ + case 12: /* UNP */ + case 13: /* UNP */ + case 14: /* UNP */ + case 15: /* UNP */ + case 0: /* no access at all */ + armcp15->regionWriteMask_USR[num] = 0 ; + armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; + armcp15->regionReadMask_USR[num] = 0 ; + armcp15->regionReadSet_USR[num] = 0xFFFFFFFF ; + armcp15->regionWriteMask_SYS[num] = 0 ; + armcp15->regionWriteSet_SYS[num] = 0xFFFFFFFF ; + armcp15->regionReadMask_SYS[num] = 0 ; + armcp15->regionReadSet_SYS[num] = 0xFFFFFFFF ; + break ; + case 1: /* no access at USR, all to sys */ + armcp15->regionWriteMask_USR[num] = 0 ; + armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; + armcp15->regionReadMask_USR[num] = 0 ; + armcp15->regionReadSet_USR[num] = 0xFFFFFFFF ; + armcp15->regionWriteMask_SYS[num] = mask ; + armcp15->regionWriteSet_SYS[num] = set ; + armcp15->regionReadMask_SYS[num] = mask ; + armcp15->regionReadSet_SYS[num] = set ; + break ; + case 2: /* read at USR, all to sys */ + armcp15->regionWriteMask_USR[num] = 0 ; + armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; + armcp15->regionReadMask_USR[num] = mask ; + armcp15->regionReadSet_USR[num] = set ; + armcp15->regionWriteMask_SYS[num] = mask ; + armcp15->regionWriteSet_SYS[num] = set ; + armcp15->regionReadMask_SYS[num] = mask ; + armcp15->regionReadSet_SYS[num] = set ; + break ; + case 3: /* all to USR, all to sys */ + armcp15->regionWriteMask_USR[num] = mask ; + armcp15->regionWriteSet_USR[num] = set ; + armcp15->regionReadMask_USR[num] = mask ; + armcp15->regionReadSet_USR[num] = set ; + armcp15->regionWriteMask_SYS[num] = mask ; + armcp15->regionWriteSet_SYS[num] = set ; + armcp15->regionReadMask_SYS[num] = mask ; + armcp15->regionReadSet_SYS[num] = set ; + break ; + case 5: /* no access at USR, read to sys */ + armcp15->regionWriteMask_USR[num] = 0 ; + armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; + armcp15->regionReadMask_USR[num] = 0 ; + armcp15->regionReadSet_USR[num] = 0xFFFFFFFF ; + armcp15->regionWriteMask_SYS[num] = 0 ; + armcp15->regionWriteSet_SYS[num] = 0xFFFFFFFF ; + armcp15->regionReadMask_SYS[num] = mask ; + armcp15->regionReadSet_SYS[num] = set ; + break ; + case 6: /* read at USR, read to sys */ + armcp15->regionWriteMask_USR[num] = 0 ; + armcp15->regionWriteSet_USR[num] = 0xFFFFFFFF ; + armcp15->regionReadMask_USR[num] = mask ; + armcp15->regionReadSet_USR[num] = set ; + armcp15->regionWriteMask_SYS[num] = 0 ; + armcp15->regionWriteSet_SYS[num] = 0xFFFFFFFF ; + armcp15->regionReadMask_SYS[num] = mask ; + armcp15->regionReadSet_SYS[num] = set ; + break ; + } + switch (ACCESSTYPE(iAccess,num)) { + case 4: /* UNP */ + case 7: /* UNP */ + case 8: /* UNP */ + case 9: /* UNP */ + case 10: /* UNP */ + case 11: /* UNP */ + case 12: /* UNP */ + case 13: /* UNP */ + case 14: /* UNP */ + case 15: /* UNP */ + case 0: /* no access at all */ + armcp15->regionExecuteMask_USR[num] = 0 ; + armcp15->regionExecuteSet_USR[num] = 0xFFFFFFFF ; + armcp15->regionExecuteMask_SYS[num] = 0 ; + armcp15->regionExecuteSet_SYS[num] = 0xFFFFFFFF ; + break ; + case 1: + armcp15->regionExecuteMask_USR[num] = 0 ; + armcp15->regionExecuteSet_USR[num] = 0xFFFFFFFF ; + armcp15->regionExecuteMask_SYS[num] = mask ; + armcp15->regionExecuteSet_SYS[num] = set ; + break ; + case 2: + case 3: + case 6: + armcp15->regionExecuteMask_USR[num] = mask ; + armcp15->regionExecuteSet_USR[num] = set ; + armcp15->regionExecuteMask_SYS[num] = mask ; + armcp15->regionExecuteSet_SYS[num] = set ; + break ; + } +} ; + +/* precalculate region masks/sets from cp15 register */ +static void armcp15_maskPrecalc(armcp15_t *armcp15) +{ + #define precalc(num) { \ + u32 mask = 0, set = 0xFFFFFFFF ; /* (x & 0) == 0xFF..FF is allways false (disabled) */ \ + if (BIT_N(armcp15->protectBaseSize##num,0)) /* if region is enabled */ \ + { /* reason for this define: naming includes var */ \ + mask = MASKFROMREG(armcp15->protectBaseSize##num) ; \ + set = SETFROMREG(armcp15->protectBaseSize##num) ; \ + if (SIZEIDENTIFIER(armcp15->protectBaseSize##num)==0x1F) \ + { /* for the 4GB region, u32 suffers wraparound */ \ + mask = 0 ; set = 0 ; /* (x & 0) == 0 is allways true (enabled) */ \ + } \ + } \ + armcp15_setSingleRegionAccess(armcp15,armcp15->DaccessPerm,armcp15->IaccessPerm,num,mask,set) ; \ + } + precalc(0) ; + precalc(1) ; + precalc(2) ; + precalc(3) ; + precalc(4) ; + precalc(5) ; + precalc(6) ; + precalc(7) ; +} + +INLINE BOOL armcp15_isAccessAllowed(armcp15_t *armcp15,u32 address,u32 access) +{ + int i ; + if (!(armcp15->ctrl & 1)) return TRUE ; /* protection checking is not enabled */ + for (i=0;i<8;i++) { + switch (access) { + case CP15_ACCESS_WRITEUSR: + if ((address & armcp15->regionWriteMask_USR[i]) == armcp15->regionWriteSet_USR[i]) return TRUE ; + break ; + case CP15_ACCESS_WRITESYS: + if ((address & armcp15->regionWriteMask_SYS[i]) == armcp15->regionWriteSet_SYS[i]) return TRUE ; + break ; + case CP15_ACCESS_READUSR: + if ((address & armcp15->regionReadMask_USR[i]) == armcp15->regionReadSet_USR[i]) return TRUE ; + break ; + case CP15_ACCESS_READSYS: + if ((address & armcp15->regionReadMask_SYS[i]) == armcp15->regionReadSet_SYS[i]) return TRUE ; + break ; + case CP15_ACCESS_EXECUSR: + if ((address & armcp15->regionExecuteMask_USR[i]) == armcp15->regionExecuteSet_USR[i]) return TRUE ; + break ; + case CP15_ACCESS_EXECSYS: + if ((address & armcp15->regionExecuteMask_SYS[i]) == armcp15->regionExecuteSet_SYS[i]) return TRUE ; + break ; + } + } + /* when protections are enabled, but no region allows access, deny access */ + return FALSE ; +} + +BOOL armcp15_dataProcess(armcp15_t *armcp15, u8 CRd, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2) +{ + LOG("Unsupported CP15 operation : DataProcess\n"); + return FALSE; +} + +BOOL armcp15_load(armcp15_t *armcp15, u8 CRd, u8 adr) +{ + LOG("Unsupported CP15 operation : Load\n"); + return FALSE; +} + +BOOL armcp15_store(armcp15_t *armcp15, u8 CRd, u8 adr) +{ + LOG("Unsupported CP15 operation : Store\n"); + return FALSE; +} + +BOOL armcp15_moveCP2ARM(armcp15_t *armcp15, u32 * R, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2) +{ + if(armcp15->cpu->CPSR.bits.mode == USR) return FALSE; + + switch(CRn) + { + case 0 : + if((opcode1 == 0)&&(CRm==0)) + { + switch(opcode2) + { + case 1 : + *R = armcp15->cacheType; + return TRUE; + case 2 : + *R = armcp15->TCMSize; + return TRUE; + default : + *R = armcp15->IDCode; + return TRUE; + } + } + return FALSE; + case 1 : + if((opcode1==0) && (opcode2==0) && (CRm==0)) + { + *R = armcp15->ctrl; + return TRUE; + } + return FALSE; + + case 2 : + if((opcode1==0) && (CRm==0)) + { + switch(opcode2) + { + case 0 : + *R = armcp15->DCConfig; + return TRUE; + case 1 : + *R = armcp15->ICConfig; + return TRUE; + default : + return FALSE; + } + } + return FALSE; + case 3 : + if((opcode1==0) && (opcode2==0) && (CRm==0)) + { + *R = armcp15->writeBuffCtrl; + return TRUE; + } + return FALSE; + case 5 : + if((opcode1==0) && (CRm==0)) + { + switch(opcode2) + { + case 2 : + *R = armcp15->DaccessPerm; + return TRUE; + case 3 : + *R = armcp15->IaccessPerm; + return TRUE; + default : + return FALSE; + } + } + return FALSE; + case 6 : + if((opcode1==0) && (opcode2==0)) + { + switch(CRm) + { + case 0 : + *R = armcp15->protectBaseSize0; + return TRUE; + case 1 : + *R = armcp15->protectBaseSize1; + return TRUE; + case 2 : + *R = armcp15->protectBaseSize2; + return TRUE; + case 3 : + *R = armcp15->protectBaseSize3; + return TRUE; + case 4 : + *R = armcp15->protectBaseSize4; + return TRUE; + case 5 : + *R = armcp15->protectBaseSize5; + return TRUE; + case 6 : + *R = armcp15->protectBaseSize6; + return TRUE; + case 7 : + *R = armcp15->protectBaseSize7; + return TRUE; + default : + return FALSE; + } + } + return FALSE; + case 9 : + if((opcode1==0)) + { + switch(CRm) + { + case 0 : + switch(opcode2) + { + case 0 : + *R = armcp15->DcacheLock; + return TRUE; + case 1 : + *R = armcp15->IcacheLock; + return TRUE; + default : + return FALSE; + } + case 1 : + switch(opcode2) + { + case 0 : + *R = armcp15->DTCMRegion; + return TRUE; + case 1 : + *R = armcp15->ITCMRegion; + return TRUE; + default : + return FALSE; + } + } + } + return FALSE; + default : + LOG("Unsupported CP15 operation : MRC\n"); + return FALSE; + } +} + + +static u32 CP15wait4IRQ(armcpu_t *cpu) +{ + /* on the first call, wirq is not set */ + if(cpu->wirq) + { + /* check wether an irq was issued */ + if(!cpu->waitIRQ) + { + cpu->waitIRQ = 0; + cpu->wirq = 0; + return 1; /* return execution */ + } + /* otherwise, repeat this instruction */ + cpu->R[15] = cpu->instruct_adr; + cpu->next_instruction = cpu->R[15]; + return 1; + } + /* first run, set us into waiting state */ + cpu->waitIRQ = 1; + cpu->wirq = 1; + /* and set next instruction to repeat this */ + cpu->R[15] = cpu->instruct_adr; + cpu->next_instruction = cpu->R[15]; + /* CHECKME: IME shouldn't be modified (?) */ + MMU.reg_IME[0] = 1; + return 1; +} + +BOOL armcp15_moveARM2CP(armcp15_t *armcp15, u32 val, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2) +{ + if(armcp15->cpu->CPSR.bits.mode == USR) return FALSE; + + switch(CRn) + { + case 1 : + if((opcode1==0) && (opcode2==0) && (CRm==0)) + { + armcp15->ctrl = val; + MMU.ARM9_RW_MODE = BIT7(val); + armcp15->cpu->intVector = 0x0FFF0000 * (BIT13(val)); + armcp15->cpu->LDTBit = !BIT15(val); //TBit + /*if(BIT17(val)) + { + log::ajouter("outch !!!!!!!"); + } + if(BIT19(val)) + { + log::ajouter("outch !!!!!!!"); + }*/ + return TRUE; + } + return FALSE; + case 2 : + if((opcode1==0) && (CRm==0)) + { + switch(opcode2) + { + case 0 : + armcp15->DCConfig = val; + return TRUE; + case 1 : + armcp15->ICConfig = val; + return TRUE; + default : + return FALSE; + } + } + return FALSE; + case 3 : + if((opcode1==0) && (opcode2==0) && (CRm==0)) + { + armcp15->writeBuffCtrl = val; + return TRUE; + } + return FALSE; + case 5 : + if((opcode1==0) && (CRm==0)) + { + switch(opcode2) + { + case 2 : + armcp15->DaccessPerm = val; + armcp15_maskPrecalc(armcp15); + return TRUE; + case 3 : + armcp15->IaccessPerm = val; + armcp15_maskPrecalc(armcp15); + return TRUE; + default : + return FALSE; + } + } + return FALSE; + case 6 : + if((opcode1==0) && (opcode2==0)) + { + switch(CRm) + { + case 0 : + armcp15->protectBaseSize0 = val; + armcp15_maskPrecalc(armcp15) ; + return TRUE; + case 1 : + armcp15->protectBaseSize1 = val; + armcp15_maskPrecalc(armcp15) ; + return TRUE; + case 2 : + armcp15->protectBaseSize2 = val; + armcp15_maskPrecalc(armcp15) ; + return TRUE; + case 3 : + armcp15->protectBaseSize3 = val; + armcp15_maskPrecalc(armcp15) ; + return TRUE; + case 4 : + armcp15->protectBaseSize4 = val; + armcp15_maskPrecalc(armcp15) ; + return TRUE; + case 5 : + armcp15->protectBaseSize5 = val; + armcp15_maskPrecalc(armcp15) ; + return TRUE; + case 6 : + armcp15->protectBaseSize6 = val; + armcp15_maskPrecalc(armcp15) ; + return TRUE; + case 7 : + armcp15->protectBaseSize7 = val; + armcp15_maskPrecalc(armcp15) ; + return TRUE; + default : + return FALSE; + } + } + return FALSE; + case 7 : + if((CRm==0)&&(opcode1==0)&&((opcode2==4))) + { + CP15wait4IRQ(armcp15->cpu); + return TRUE; + } + return FALSE; + case 9 : + if((opcode1==0)) + { + switch(CRm) + { + case 0 : + switch(opcode2) + { + case 0 : + armcp15->DcacheLock = val; + return TRUE; + case 1 : + armcp15->IcacheLock = val; + return TRUE; + default : + return FALSE; + } + case 1 : + switch(opcode2) + { + case 0 : + armcp15->DTCMRegion = val; + MMU.DTCMRegion = val & 0x0FFFFFFC0; + /*sprintf(logbuf, "%08X", val); + log::ajouter(logbuf);*/ + return TRUE; + case 1 : + armcp15->ITCMRegion = val; + /* ITCM base is not writeable! */ + MMU.ITCMRegion = 0; + return TRUE; + default : + return FALSE; + } + } + } + return FALSE; + default : + return FALSE; + } +} + + + diff --git a/desmume/src/cp15.h b/src/cp15.h similarity index 97% rename from desmume/src/cp15.h rename to src/cp15.h index a6499ca30..aff86ba4e 100644 --- a/desmume/src/cp15.h +++ b/src/cp15.h @@ -1,94 +1,94 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __CP15_H__ -#define __CP15_H__ - -#include "armcpu.h" - -struct armcp15_t -{ - u32 IDCode; - u32 cacheType; - u32 TCMSize; - u32 ctrl; - u32 DCConfig; - u32 ICConfig; - u32 writeBuffCtrl; - u32 und; - u32 DaccessPerm; - u32 IaccessPerm; - u32 protectBaseSize0; - u32 protectBaseSize1; - u32 protectBaseSize2; - u32 protectBaseSize3; - u32 protectBaseSize4; - u32 protectBaseSize5; - u32 protectBaseSize6; - u32 protectBaseSize7; - u32 cacheOp; - u32 DcacheLock; - u32 IcacheLock; - u32 ITCMRegion; - u32 DTCMRegion; - u32 processID; - u32 RAM_TAG; - u32 testState; - u32 cacheDbg; - /* calculated bitmasks for the regions to decide rights uppon */ - /* calculation is done in the MCR instead of on mem access for performance */ - u32 regionWriteMask_USR[8] ; - u32 regionWriteMask_SYS[8] ; - u32 regionReadMask_USR[8] ; - u32 regionReadMask_SYS[8] ; - u32 regionExecuteMask_USR[8] ; - u32 regionExecuteMask_SYS[8] ; - u32 regionWriteSet_USR[8] ; - u32 regionWriteSet_SYS[8] ; - u32 regionReadSet_USR[8] ; - u32 regionReadSet_SYS[8] ; - u32 regionExecuteSet_USR[8] ; - u32 regionExecuteSet_SYS[8] ; - - armcpu_t * cpu; - -}; - -armcp15_t *armcp15_new(armcpu_t *c); -BOOL armcp15_dataProcess(armcp15_t *armcp15, u8 CRd, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2); -BOOL armcp15_load(armcp15_t *armcp15, u8 CRd, u8 adr); -BOOL armcp15_store(armcp15_t *armcp15, u8 CRd, u8 adr); -BOOL armcp15_moveCP2ARM(armcp15_t *armcp15, u32 * R, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2); -BOOL armcp15_moveARM2CP(armcp15_t *armcp15, u32 val, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2); -INLINE BOOL armcp15_isAccessAllowed(armcp15_t *armcp15,u32 address,u32 access) ; - - -#define CP15_ACCESS_WRITE 0 -#define CP15_ACCESS_READ 2 -#define CP15_ACCESS_EXECUTE 4 -#define CP15_ACCESS_WRITEUSR CP15_ACCESS_WRITE -#define CP15_ACCESS_WRITESYS 1 -#define CP15_ACCESS_READUSR CP15_ACCESS_READ -#define CP15_ACCESS_READSYS 3 -#define CP15_ACCESS_EXECUSR CP15_ACCESS_EXECUTE -#define CP15_ACCESS_EXECSYS 5 - -#endif /* __CP15_H__*/ +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __CP15_H__ +#define __CP15_H__ + +#include "armcpu.h" + +struct armcp15_t +{ + u32 IDCode; + u32 cacheType; + u32 TCMSize; + u32 ctrl; + u32 DCConfig; + u32 ICConfig; + u32 writeBuffCtrl; + u32 und; + u32 DaccessPerm; + u32 IaccessPerm; + u32 protectBaseSize0; + u32 protectBaseSize1; + u32 protectBaseSize2; + u32 protectBaseSize3; + u32 protectBaseSize4; + u32 protectBaseSize5; + u32 protectBaseSize6; + u32 protectBaseSize7; + u32 cacheOp; + u32 DcacheLock; + u32 IcacheLock; + u32 ITCMRegion; + u32 DTCMRegion; + u32 processID; + u32 RAM_TAG; + u32 testState; + u32 cacheDbg; + /* calculated bitmasks for the regions to decide rights uppon */ + /* calculation is done in the MCR instead of on mem access for performance */ + u32 regionWriteMask_USR[8] ; + u32 regionWriteMask_SYS[8] ; + u32 regionReadMask_USR[8] ; + u32 regionReadMask_SYS[8] ; + u32 regionExecuteMask_USR[8] ; + u32 regionExecuteMask_SYS[8] ; + u32 regionWriteSet_USR[8] ; + u32 regionWriteSet_SYS[8] ; + u32 regionReadSet_USR[8] ; + u32 regionReadSet_SYS[8] ; + u32 regionExecuteSet_USR[8] ; + u32 regionExecuteSet_SYS[8] ; + + armcpu_t * cpu; + +}; + +armcp15_t *armcp15_new(armcpu_t *c); +BOOL armcp15_dataProcess(armcp15_t *armcp15, u8 CRd, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2); +BOOL armcp15_load(armcp15_t *armcp15, u8 CRd, u8 adr); +BOOL armcp15_store(armcp15_t *armcp15, u8 CRd, u8 adr); +BOOL armcp15_moveCP2ARM(armcp15_t *armcp15, u32 * R, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2); +BOOL armcp15_moveARM2CP(armcp15_t *armcp15, u32 val, u8 CRn, u8 CRm, u8 opcode1, u8 opcode2); +INLINE BOOL armcp15_isAccessAllowed(armcp15_t *armcp15,u32 address,u32 access) ; + + +#define CP15_ACCESS_WRITE 0 +#define CP15_ACCESS_READ 2 +#define CP15_ACCESS_EXECUTE 4 +#define CP15_ACCESS_WRITEUSR CP15_ACCESS_WRITE +#define CP15_ACCESS_WRITESYS 1 +#define CP15_ACCESS_READUSR CP15_ACCESS_READ +#define CP15_ACCESS_READSYS 3 +#define CP15_ACCESS_EXECUSR CP15_ACCESS_EXECUTE +#define CP15_ACCESS_EXECSYS 5 + +#endif /* __CP15_H__*/ diff --git a/desmume/src/ctrlssdl.cpp b/src/ctrlssdl.cpp similarity index 94% rename from desmume/src/ctrlssdl.cpp rename to src/ctrlssdl.cpp index 5c85f4c81..c419458ee 100644 --- a/desmume/src/ctrlssdl.cpp +++ b/src/ctrlssdl.cpp @@ -1,488 +1,488 @@ -/* joysdl.c - this file is part of DeSmuME - * - * Copyright (C) 2007 Pascal Giard - * - * Author: Pascal Giard - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "ctrlssdl.h" -#include "saves.h" -#include "SPU.h" - -u16 keyboard_cfg[NB_KEYS]; -u16 joypad_cfg[NB_KEYS]; -u16 nbr_joy; -mouse_status mouse; - -extern volatile BOOL execute; - -static SDL_Joystick **open_joysticks = NULL; - -/* Keypad key names */ -const char *key_names[NB_KEYS] = -{ - "A", "B", "Select", "Start", - "Right", "Left", "Up", "Down", - "R", "L", "X", "Y", - "Debug", "Boost" -}; - -/* Default joypad configuration */ -const u16 default_joypad_cfg[NB_KEYS] = - { 1, // A - 0, // B - 5, // select - 8, // start - 256, // Right -- Start cheating abit... - 256, // Left - 512, // Up - 512, // Down -- End of cheating. - 7, // R - 6, // L - 4, // X - 3, // Y - -1, // DEBUG - -1 // BOOST - }; - -const u16 plain_keyboard_cfg[NB_KEYS] = -{ - 'x', // A - 'z', // B - 'y', // select - 'u', // start - 'l', // Right - 'j', // Left - 'i', // Up - 'k', // Down - 'w', // R - 'q', // L - 's', // X - 'a', // Y - 'p', // DEBUG - 'o' // BOOST -}; - -/* Load default joystick and keyboard configurations */ -void load_default_config(const u16 kbCfg[]) -{ - memcpy(keyboard_cfg, kbCfg, sizeof(keyboard_cfg)); - memcpy(joypad_cfg, default_joypad_cfg, sizeof(joypad_cfg)); -} - -/* Initialize joysticks */ -BOOL init_joy( void) { - int i; - BOOL joy_init_good = TRUE; - - set_joy_keys(default_joypad_cfg); - - if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) - { - fprintf(stderr, "Error trying to initialize joystick support: %s\n", - SDL_GetError()); - return FALSE; - } - - nbr_joy = SDL_NumJoysticks(); - - if ( nbr_joy > 0) { - printf("Found %d joysticks\n", nbr_joy); - open_joysticks = - (SDL_Joystick**)calloc( sizeof ( SDL_Joystick *), nbr_joy); - - if ( open_joysticks != NULL) { - for (i = 0; i < nbr_joy; i++) - { - SDL_Joystick * joy = SDL_JoystickOpen(i); - printf("Joystick %d %s\n", i, SDL_JoystickName(i)); - printf("Axes: %d\n", SDL_JoystickNumAxes(joy)); - printf("Buttons: %d\n", SDL_JoystickNumButtons(joy)); - printf("Trackballs: %d\n", SDL_JoystickNumBalls(joy)); - printf("Hats: %d\n\n", SDL_JoystickNumHats(joy)); - } - } - else { - joy_init_good = FALSE; - } - } - - return joy_init_good; -} - -/* Set all buttons at once */ -void set_joy_keys(const u16 joyCfg[]) -{ - memcpy(joypad_cfg, joyCfg, sizeof(joypad_cfg)); -} - -/* Set all buttons at once */ -void set_kb_keys(const u16 kbCfg[]) -{ - memcpy(keyboard_cfg, kbCfg, sizeof(keyboard_cfg)); -} - -/* Unload joysticks */ -void uninit_joy( void) -{ - int i; - - if ( open_joysticks != NULL) { - for (i = 0; i < SDL_NumJoysticks(); i++) { - SDL_JoystickClose( open_joysticks[i]); - } - - free( open_joysticks); - } - - open_joysticks = NULL; - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); -} - -/* Return keypad vector with given key set to 1 */ -u16 lookup_joy_key (u16 keyval) { - int i; - u16 Key = 0; - for(i = 0; i < NB_KEYS; i++) - if(keyval == joypad_cfg[i]) break; - if(i < NB_KEYS) Key = KEYMASK_(i); - return Key; -} - -/* Return keypad vector with given key set to 1 */ -u16 lookup_key (u16 keyval) { - int i; - u16 Key = 0; - for(i = 0; i < NB_KEYS; i++) - if(keyval == keyboard_cfg[i]) break; - if(i < NB_KEYS) Key = KEYMASK_(i); - return Key; -} - -/* Empty SDL Events' queue */ -static void clear_events( void) -{ - SDL_Event event; - /* IMPORTANT: Reenable joystick events iif needed. */ - if(SDL_JoystickEventState(SDL_QUERY) == SDL_IGNORE) - SDL_JoystickEventState(SDL_ENABLE); - - /* There's an event waiting to be processed? */ - while (SDL_PollEvent(&event)) - { - } - - return; -} - -/* Get and set a new joystick key */ -u16 get_set_joy_key(int index) { - BOOL done = FALSE; - SDL_Event event; - u16 key = joypad_cfg[index]; - - /* Enable joystick events if needed */ - if( SDL_JoystickEventState(SDL_QUERY) == SDL_IGNORE ) - SDL_JoystickEventState(SDL_ENABLE); - - while(SDL_WaitEvent(&event) && !done) - { - switch(event.type) - { - case SDL_JOYBUTTONDOWN: - printf( "Got joykey: %d\n", event.jbutton.button ); - key = event.jbutton.button; - done = TRUE; - break; - } - } - - if( SDL_JoystickEventState(SDL_QUERY) == SDL_ENABLE ) - SDL_JoystickEventState(SDL_IGNORE); - joypad_cfg[index] = key; - - return key; -} - -/* Reset corresponding key and its twin axis key */ -static u16 get_joy_axis_twin(u16 key) -{ - switch(key) - { - case KEYMASK_( KEY_RIGHT-1 ): - return KEYMASK_( KEY_LEFT-1 ); - case KEYMASK_( KEY_UP-1 ): - return KEYMASK_( KEY_DOWN-1 ); - default: - return 0; - } -} - -/* Get and set a new joystick axis */ -void get_set_joy_axis(int index, int index_o) { - BOOL done = FALSE; - SDL_Event event; - u16 key = joypad_cfg[index]; - - /* Clear events */ - clear_events(); - /* Enable joystick events if needed */ - if( SDL_JoystickEventState(SDL_QUERY) == SDL_IGNORE ) - SDL_JoystickEventState(SDL_ENABLE); - - while(SDL_WaitEvent(&event) && !done) - { - switch(event.type) - { - case SDL_JOYAXISMOTION: - /* Discriminate small movements */ - if( (event.jaxis.value >> 5) != 0 ) - { - key = JOY_AXIS_(event.jaxis.axis); - done = TRUE; - } - break; - } - } - if( SDL_JoystickEventState(SDL_QUERY) == SDL_ENABLE ) - SDL_JoystickEventState(SDL_IGNORE); - /* Update configuration */ - joypad_cfg[index] = key; - joypad_cfg[index_o] = joypad_cfg[index]; -} - -static signed long -screen_to_touch_range_x( signed long scr_x, float size_ratio) { - signed long touch_x = (signed long)((float)scr_x * size_ratio); - - return touch_x; -} - -static signed long -screen_to_touch_range_y( signed long scr_y, float size_ratio) { - signed long touch_y = (signed long)((float)scr_y * size_ratio); - - return touch_y; -} - -/* Set mouse coordinates */ -void set_mouse_coord(signed long x,signed long y) -{ - if(x<0) x = 0; else if(x>255) x = 255; - if(y<0) y = 0; else if(y>192) y = 192; - mouse.x = x; - mouse.y = y; -} - -/* Update NDS keypad */ -void update_keypad(u16 keys) -{ -#ifdef WORDS_BIGENDIAN - MMU.ARM9_REG[0x130] = ~keys & 0xFF; - MMU.ARM9_REG[0x131] = (~keys >> 8) & 0x3; - MMU.ARM7_REG[0x130] = ~keys & 0xFF; - MMU.ARM7_REG[0x131] = (~keys >> 8) & 0x3; -#else - ((u16 *)MMU.ARM9_REG)[0x130>>1] = ~keys & 0x3FF; - ((u16 *)MMU.ARM7_REG)[0x130>>1] = ~keys & 0x3FF; -#endif - /* Update X and Y buttons */ - MMU.ARM7_REG[0x136] = ( ~( keys >> 10) & 0x3 ) | (MMU.ARM7_REG[0x136] & ~0x3); -} - -/* Retrieve current NDS keypad */ -u16 get_keypad( void) -{ - u16 keypad; - keypad = ~MMU.ARM7_REG[0x136]; - keypad = (keypad & 0x3) << 10; -#ifdef WORDS_BIGENDIAN - keypad |= ~(MMU.ARM9_REG[0x130] | (MMU.ARM9_REG[0x131] << 8)) & 0x3FF; -#else - keypad |= ~((u16 *)MMU.ARM9_REG)[0x130>>1] & 0x3FF; -#endif - return keypad; -} - -/* - * The internal joystick events processing function - */ -static int -do_process_joystick_events( u16 *keypad, SDL_Event *event) { - int processed = 1; - u16 key; - - switch ( event->type) - { - /* Joystick axis motion - Note: button constants have a 1bit offset. */ - case SDL_JOYAXISMOTION: - key = lookup_joy_key( JOY_AXIS_(event->jaxis.axis) ); - if( key == 0 ) break; /* Not an axis of interest? */ - - /* Axis is back to initial position */ - if( event->jaxis.value == 0 ) - RM_KEY( *keypad, key | get_joy_axis_twin(key) ); - /* Key should have been down but its currently set to up? */ - else if( (event->jaxis.value > 0) && - (key == KEYMASK_( KEY_UP-1 )) ) - key = KEYMASK_( KEY_DOWN-1 ); - /* Key should have been left but its currently set to right? */ - else if( (event->jaxis.value < 0) && - (key == KEYMASK_( KEY_RIGHT-1 )) ) - key = KEYMASK_( KEY_LEFT-1 ); - - /* Remove some sensitivity before checking if different than zero... - Fixes some badly behaving joypads [like one of mine]. */ - if( (event->jaxis.value >> 5) != 0 ) - ADD_KEY( *keypad, key ); - break; - - /* Joystick button pressed */ - /* FIXME: Add support for BOOST */ - case SDL_JOYBUTTONDOWN: - key = lookup_joy_key( event->jbutton.button ); - ADD_KEY( *keypad, key ); - break; - - /* Joystick button released */ - case SDL_JOYBUTTONUP: - key = lookup_joy_key(event->jbutton.button); - RM_KEY( *keypad, key ); - break; - - default: - processed = 0; - break; - } - - return processed; -} - -/* - * Process only the joystick events - */ -void -process_joystick_events( u16 *keypad) { - SDL_Event event; - - /* IMPORTANT: Reenable joystick events iif needed. */ - if(SDL_JoystickEventState(SDL_QUERY) == SDL_IGNORE) - SDL_JoystickEventState(SDL_ENABLE); - - /* There's an event waiting to be processed? */ - while (SDL_PollEvent(&event)) - { - do_process_joystick_events( keypad, &event); - } -} - -u16 shift_pressed; - -void -process_ctrls_event( SDL_Event& event, u16 *keypad, - float nds_screen_size_ratio) -{ - u16 key; - if ( !do_process_joystick_events( keypad, &event)) { - switch (event.type) - { - case SDL_KEYDOWN: - switch(event.key.keysym.sym){ - case SDLK_LSHIFT: - shift_pressed |= 1; - break; - case SDLK_RSHIFT: - shift_pressed |= 2; - break; - default: - key = lookup_key(event.key.keysym.sym); - ADD_KEY( *keypad, key ); - break; - } - break; - - case SDL_KEYUP: - switch(event.key.keysym.sym){ - case SDLK_LSHIFT: - shift_pressed &= ~1; - break; - case SDLK_RSHIFT: - shift_pressed &= ~2; - break; - - case SDLK_F1: - case SDLK_F2: - case SDLK_F3: - case SDLK_F4: - case SDLK_F5: - case SDLK_F6: - case SDLK_F7: - case SDLK_F8: - case SDLK_F9: - case SDLK_F10: - int prevexec; - prevexec = execute; - execute = FALSE; - SPU_Pause(1); - if(!shift_pressed){ - loadstate_slot(event.key.keysym.sym - SDLK_F1 + 1); - }else{ - savestate_slot(event.key.keysym.sym - SDLK_F1 + 1); - } - execute = prevexec; - SPU_Pause(!execute); - break; - default: - key = lookup_key(event.key.keysym.sym); - RM_KEY( *keypad, key ); - break; - } - break; - - case SDL_MOUSEBUTTONDOWN: - if(event.button.button==1) - mouse.down = TRUE; - - case SDL_MOUSEMOTION: - if(!mouse.down) - break; - else { - signed long scaled_x = - screen_to_touch_range_x( event.button.x, - nds_screen_size_ratio); - signed long scaled_y = - screen_to_touch_range_y( event.button.y, - nds_screen_size_ratio); - - if( scaled_y >= 192) - set_mouse_coord( scaled_x, scaled_y - 192); - } - break; - - case SDL_MOUSEBUTTONUP: - if(mouse.down) mouse.click = TRUE; - mouse.down = FALSE; - break; - - default: - break; - } - } -} - +/* joysdl.c - this file is part of DeSmuME + * + * Copyright (C) 2007 Pascal Giard + * + * Author: Pascal Giard + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "ctrlssdl.h" +#include "saves.h" +#include "SPU.h" + +u16 keyboard_cfg[NB_KEYS]; +u16 joypad_cfg[NB_KEYS]; +u16 nbr_joy; +mouse_status mouse; + +extern volatile BOOL execute; + +static SDL_Joystick **open_joysticks = NULL; + +/* Keypad key names */ +const char *key_names[NB_KEYS] = +{ + "A", "B", "Select", "Start", + "Right", "Left", "Up", "Down", + "R", "L", "X", "Y", + "Debug", "Boost" +}; + +/* Default joypad configuration */ +const u16 default_joypad_cfg[NB_KEYS] = + { 1, // A + 0, // B + 5, // select + 8, // start + 256, // Right -- Start cheating abit... + 256, // Left + 512, // Up + 512, // Down -- End of cheating. + 7, // R + 6, // L + 4, // X + 3, // Y + -1, // DEBUG + -1 // BOOST + }; + +const u16 plain_keyboard_cfg[NB_KEYS] = +{ + 'x', // A + 'z', // B + 'y', // select + 'u', // start + 'l', // Right + 'j', // Left + 'i', // Up + 'k', // Down + 'w', // R + 'q', // L + 's', // X + 'a', // Y + 'p', // DEBUG + 'o' // BOOST +}; + +/* Load default joystick and keyboard configurations */ +void load_default_config(const u16 kbCfg[]) +{ + memcpy(keyboard_cfg, kbCfg, sizeof(keyboard_cfg)); + memcpy(joypad_cfg, default_joypad_cfg, sizeof(joypad_cfg)); +} + +/* Initialize joysticks */ +BOOL init_joy( void) { + int i; + BOOL joy_init_good = TRUE; + + set_joy_keys(default_joypad_cfg); + + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) + { + fprintf(stderr, "Error trying to initialize joystick support: %s\n", + SDL_GetError()); + return FALSE; + } + + nbr_joy = SDL_NumJoysticks(); + + if ( nbr_joy > 0) { + printf("Found %d joysticks\n", nbr_joy); + open_joysticks = + (SDL_Joystick**)calloc( sizeof ( SDL_Joystick *), nbr_joy); + + if ( open_joysticks != NULL) { + for (i = 0; i < nbr_joy; i++) + { + SDL_Joystick * joy = SDL_JoystickOpen(i); + printf("Joystick %d %s\n", i, SDL_JoystickName(i)); + printf("Axes: %d\n", SDL_JoystickNumAxes(joy)); + printf("Buttons: %d\n", SDL_JoystickNumButtons(joy)); + printf("Trackballs: %d\n", SDL_JoystickNumBalls(joy)); + printf("Hats: %d\n\n", SDL_JoystickNumHats(joy)); + } + } + else { + joy_init_good = FALSE; + } + } + + return joy_init_good; +} + +/* Set all buttons at once */ +void set_joy_keys(const u16 joyCfg[]) +{ + memcpy(joypad_cfg, joyCfg, sizeof(joypad_cfg)); +} + +/* Set all buttons at once */ +void set_kb_keys(const u16 kbCfg[]) +{ + memcpy(keyboard_cfg, kbCfg, sizeof(keyboard_cfg)); +} + +/* Unload joysticks */ +void uninit_joy( void) +{ + int i; + + if ( open_joysticks != NULL) { + for (i = 0; i < SDL_NumJoysticks(); i++) { + SDL_JoystickClose( open_joysticks[i]); + } + + free( open_joysticks); + } + + open_joysticks = NULL; + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); +} + +/* Return keypad vector with given key set to 1 */ +u16 lookup_joy_key (u16 keyval) { + int i; + u16 Key = 0; + for(i = 0; i < NB_KEYS; i++) + if(keyval == joypad_cfg[i]) break; + if(i < NB_KEYS) Key = KEYMASK_(i); + return Key; +} + +/* Return keypad vector with given key set to 1 */ +u16 lookup_key (u16 keyval) { + int i; + u16 Key = 0; + for(i = 0; i < NB_KEYS; i++) + if(keyval == keyboard_cfg[i]) break; + if(i < NB_KEYS) Key = KEYMASK_(i); + return Key; +} + +/* Empty SDL Events' queue */ +static void clear_events( void) +{ + SDL_Event event; + /* IMPORTANT: Reenable joystick events iif needed. */ + if(SDL_JoystickEventState(SDL_QUERY) == SDL_IGNORE) + SDL_JoystickEventState(SDL_ENABLE); + + /* There's an event waiting to be processed? */ + while (SDL_PollEvent(&event)) + { + } + + return; +} + +/* Get and set a new joystick key */ +u16 get_set_joy_key(int index) { + BOOL done = FALSE; + SDL_Event event; + u16 key = joypad_cfg[index]; + + /* Enable joystick events if needed */ + if( SDL_JoystickEventState(SDL_QUERY) == SDL_IGNORE ) + SDL_JoystickEventState(SDL_ENABLE); + + while(SDL_WaitEvent(&event) && !done) + { + switch(event.type) + { + case SDL_JOYBUTTONDOWN: + printf( "Got joykey: %d\n", event.jbutton.button ); + key = event.jbutton.button; + done = TRUE; + break; + } + } + + if( SDL_JoystickEventState(SDL_QUERY) == SDL_ENABLE ) + SDL_JoystickEventState(SDL_IGNORE); + joypad_cfg[index] = key; + + return key; +} + +/* Reset corresponding key and its twin axis key */ +static u16 get_joy_axis_twin(u16 key) +{ + switch(key) + { + case KEYMASK_( KEY_RIGHT-1 ): + return KEYMASK_( KEY_LEFT-1 ); + case KEYMASK_( KEY_UP-1 ): + return KEYMASK_( KEY_DOWN-1 ); + default: + return 0; + } +} + +/* Get and set a new joystick axis */ +void get_set_joy_axis(int index, int index_o) { + BOOL done = FALSE; + SDL_Event event; + u16 key = joypad_cfg[index]; + + /* Clear events */ + clear_events(); + /* Enable joystick events if needed */ + if( SDL_JoystickEventState(SDL_QUERY) == SDL_IGNORE ) + SDL_JoystickEventState(SDL_ENABLE); + + while(SDL_WaitEvent(&event) && !done) + { + switch(event.type) + { + case SDL_JOYAXISMOTION: + /* Discriminate small movements */ + if( (event.jaxis.value >> 5) != 0 ) + { + key = JOY_AXIS_(event.jaxis.axis); + done = TRUE; + } + break; + } + } + if( SDL_JoystickEventState(SDL_QUERY) == SDL_ENABLE ) + SDL_JoystickEventState(SDL_IGNORE); + /* Update configuration */ + joypad_cfg[index] = key; + joypad_cfg[index_o] = joypad_cfg[index]; +} + +static signed long +screen_to_touch_range_x( signed long scr_x, float size_ratio) { + signed long touch_x = (signed long)((float)scr_x * size_ratio); + + return touch_x; +} + +static signed long +screen_to_touch_range_y( signed long scr_y, float size_ratio) { + signed long touch_y = (signed long)((float)scr_y * size_ratio); + + return touch_y; +} + +/* Set mouse coordinates */ +void set_mouse_coord(signed long x,signed long y) +{ + if(x<0) x = 0; else if(x>255) x = 255; + if(y<0) y = 0; else if(y>192) y = 192; + mouse.x = x; + mouse.y = y; +} + +/* Update NDS keypad */ +void update_keypad(u16 keys) +{ +#ifdef WORDS_BIGENDIAN + ARM9Mem.ARM9_REG[0x130] = ~keys & 0xFF; + ARM9Mem.ARM9_REG[0x131] = (~keys >> 8) & 0x3; + MMU.ARM7_REG[0x130] = ~keys & 0xFF; + MMU.ARM7_REG[0x131] = (~keys >> 8) & 0x3; +#else + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] = ~keys & 0x3FF; + ((u16 *)MMU.ARM7_REG)[0x130>>1] = ~keys & 0x3FF; +#endif + /* Update X and Y buttons */ + MMU.ARM7_REG[0x136] = ( ~( keys >> 10) & 0x3 ) | (MMU.ARM7_REG[0x136] & ~0x3); +} + +/* Retrieve current NDS keypad */ +u16 get_keypad( void) +{ + u16 keypad; + keypad = ~MMU.ARM7_REG[0x136]; + keypad = (keypad & 0x3) << 10; +#ifdef WORDS_BIGENDIAN + keypad |= ~(ARM9Mem.ARM9_REG[0x130] | (ARM9Mem.ARM9_REG[0x131] << 8)) & 0x3FF; +#else + keypad |= ~((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] & 0x3FF; +#endif + return keypad; +} + +/* + * The internal joystick events processing function + */ +static int +do_process_joystick_events( u16 *keypad, SDL_Event *event) { + int processed = 1; + u16 key; + + switch ( event->type) + { + /* Joystick axis motion + Note: button constants have a 1bit offset. */ + case SDL_JOYAXISMOTION: + key = lookup_joy_key( JOY_AXIS_(event->jaxis.axis) ); + if( key == 0 ) break; /* Not an axis of interest? */ + + /* Axis is back to initial position */ + if( event->jaxis.value == 0 ) + RM_KEY( *keypad, key | get_joy_axis_twin(key) ); + /* Key should have been down but its currently set to up? */ + else if( (event->jaxis.value > 0) && + (key == KEYMASK_( KEY_UP-1 )) ) + key = KEYMASK_( KEY_DOWN-1 ); + /* Key should have been left but its currently set to right? */ + else if( (event->jaxis.value < 0) && + (key == KEYMASK_( KEY_RIGHT-1 )) ) + key = KEYMASK_( KEY_LEFT-1 ); + + /* Remove some sensitivity before checking if different than zero... + Fixes some badly behaving joypads [like one of mine]. */ + if( (event->jaxis.value >> 5) != 0 ) + ADD_KEY( *keypad, key ); + break; + + /* Joystick button pressed */ + /* FIXME: Add support for BOOST */ + case SDL_JOYBUTTONDOWN: + key = lookup_joy_key( event->jbutton.button ); + ADD_KEY( *keypad, key ); + break; + + /* Joystick button released */ + case SDL_JOYBUTTONUP: + key = lookup_joy_key(event->jbutton.button); + RM_KEY( *keypad, key ); + break; + + default: + processed = 0; + break; + } + + return processed; +} + +/* + * Process only the joystick events + */ +void +process_joystick_events( u16 *keypad) { + SDL_Event event; + + /* IMPORTANT: Reenable joystick events iif needed. */ + if(SDL_JoystickEventState(SDL_QUERY) == SDL_IGNORE) + SDL_JoystickEventState(SDL_ENABLE); + + /* There's an event waiting to be processed? */ + while (SDL_PollEvent(&event)) + { + do_process_joystick_events( keypad, &event); + } +} + +u16 shift_pressed; + +void +process_ctrls_event( SDL_Event& event, u16 *keypad, + float nds_screen_size_ratio) +{ + u16 key; + if ( !do_process_joystick_events( keypad, &event)) { + switch (event.type) + { + case SDL_KEYDOWN: + switch(event.key.keysym.sym){ + case SDLK_LSHIFT: + shift_pressed |= 1; + break; + case SDLK_RSHIFT: + shift_pressed |= 2; + break; + default: + key = lookup_key(event.key.keysym.sym); + ADD_KEY( *keypad, key ); + break; + } + break; + + case SDL_KEYUP: + switch(event.key.keysym.sym){ + case SDLK_LSHIFT: + shift_pressed &= ~1; + break; + case SDLK_RSHIFT: + shift_pressed &= ~2; + break; + + case SDLK_F1: + case SDLK_F2: + case SDLK_F3: + case SDLK_F4: + case SDLK_F5: + case SDLK_F6: + case SDLK_F7: + case SDLK_F8: + case SDLK_F9: + case SDLK_F10: + int prevexec; + prevexec = execute; + execute = FALSE; + SPU_Pause(1); + if(!shift_pressed){ + loadstate_slot(event.key.keysym.sym - SDLK_F1 + 1); + }else{ + savestate_slot(event.key.keysym.sym - SDLK_F1 + 1); + } + execute = prevexec; + SPU_Pause(!execute); + break; + default: + key = lookup_key(event.key.keysym.sym); + RM_KEY( *keypad, key ); + break; + } + break; + + case SDL_MOUSEBUTTONDOWN: + if(event.button.button==1) + mouse.down = TRUE; + + case SDL_MOUSEMOTION: + if(!mouse.down) + break; + else { + signed long scaled_x = + screen_to_touch_range_x( event.button.x, + nds_screen_size_ratio); + signed long scaled_y = + screen_to_touch_range_y( event.button.y, + nds_screen_size_ratio); + + if( scaled_y >= 192) + set_mouse_coord( scaled_x, scaled_y - 192); + } + break; + + case SDL_MOUSEBUTTONUP: + if(mouse.down) mouse.click = TRUE; + mouse.down = FALSE; + break; + + default: + break; + } + } +} + diff --git a/desmume/src/ctrlssdl.h b/src/ctrlssdl.h similarity index 96% rename from desmume/src/ctrlssdl.h rename to src/ctrlssdl.h index 279e44d55..31c00d616 100644 --- a/desmume/src/ctrlssdl.h +++ b/src/ctrlssdl.h @@ -1,98 +1,98 @@ -/* joysdl.h - this file is part of DeSmuME - * - * Copyright (C) 2007 Pascal Giard - * - * Author: Pascal Giard - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef CTRLSSDL_H -#define CTRLSSDL_H - -#include -#include -#include -//#include -#include -#include "MMU.h" - -#include "types.h" - -#define ADD_KEY(keypad,key) ( (keypad) |= (key) ) -#define RM_KEY(keypad,key) ( (keypad) &= ~(key) ) -#define KEYMASK_(k) (1 << (k)) -#define JOY_AXIS_(k) (((k)+1) << 8) - -#define NB_KEYS 14 -#define KEY_NONE 0 -#define KEY_A 1 -#define KEY_B 2 -#define KEY_SELECT 3 -#define KEY_START 4 -#define KEY_RIGHT 5 -#define KEY_LEFT 6 -#define KEY_UP 7 -#define KEY_DOWN 8 -#define KEY_R 9 -#define KEY_L 10 -#define KEY_X 11 -#define KEY_Y 12 -#define KEY_DEBUG 13 -#define KEY_BOOST 14 - -/* Keypad key names */ -extern const char *key_names[NB_KEYS]; -/* Current keyboard configuration */ -extern u16 keyboard_cfg[NB_KEYS]; -/* Current joypad configuration */ -extern u16 joypad_cfg[NB_KEYS]; -/* Number of detected joypads */ -extern u16 nbr_joy; - -#ifndef GTK_UI -struct mouse_status -{ - signed long x; - signed long y; - BOOL click; - BOOL down; -}; - -extern mouse_status mouse; - -void set_mouse_coord(signed long x,signed long y); -#endif // !GTK_UI - -void load_default_config(const u16 kbCfg[]); -BOOL init_joy( void); -void uninit_joy( void); -void set_joy_keys(const u16 joyCfg[]); -void set_kb_keys(const u16 kbCfg[]); -u16 get_set_joy_key(int index); -void get_set_joy_axis(int index, int index_opp); -void update_keypad(u16 keys); -u16 get_keypad( void); -u16 lookup_key (u16 keyval); -u16 lookup_joy_key (u16 keyval); -void -process_ctrls_event( SDL_Event& event, u16 *keypad, - float nds_screen_size_ratio); - -void -process_joystick_events( u16 *keypad); - -#endif /* CTRLSSDL_H */ +/* joysdl.h - this file is part of DeSmuME + * + * Copyright (C) 2007 Pascal Giard + * + * Author: Pascal Giard + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef CTRLSSDL_H +#define CTRLSSDL_H + +#include +#include +#include +//#include +#include +#include "MMU.h" + +#include "types.h" + +#define ADD_KEY(keypad,key) ( (keypad) |= (key) ) +#define RM_KEY(keypad,key) ( (keypad) &= ~(key) ) +#define KEYMASK_(k) (1 << (k)) +#define JOY_AXIS_(k) (((k)+1) << 8) + +#define NB_KEYS 14 +#define KEY_NONE 0 +#define KEY_A 1 +#define KEY_B 2 +#define KEY_SELECT 3 +#define KEY_START 4 +#define KEY_RIGHT 5 +#define KEY_LEFT 6 +#define KEY_UP 7 +#define KEY_DOWN 8 +#define KEY_R 9 +#define KEY_L 10 +#define KEY_X 11 +#define KEY_Y 12 +#define KEY_DEBUG 13 +#define KEY_BOOST 14 + +/* Keypad key names */ +extern const char *key_names[NB_KEYS]; +/* Current keyboard configuration */ +extern u16 keyboard_cfg[NB_KEYS]; +/* Current joypad configuration */ +extern u16 joypad_cfg[NB_KEYS]; +/* Number of detected joypads */ +extern u16 nbr_joy; + +#ifndef GTK_UI +struct mouse_status +{ + signed long x; + signed long y; + BOOL click; + BOOL down; +}; + +extern mouse_status mouse; + +void set_mouse_coord(signed long x,signed long y); +#endif // !GTK_UI + +void load_default_config(const u16 kbCfg[]); +BOOL init_joy( void); +void uninit_joy( void); +void set_joy_keys(const u16 joyCfg[]); +void set_kb_keys(const u16 kbCfg[]); +u16 get_set_joy_key(int index); +void get_set_joy_axis(int index, int index_opp); +void update_keypad(u16 keys); +u16 get_keypad( void); +u16 lookup_key (u16 keyval); +u16 lookup_joy_key (u16 keyval); +void +process_ctrls_event( SDL_Event& event, u16 *keypad, + float nds_screen_size_ratio); + +void +process_joystick_events( u16 *keypad); + +#endif /* CTRLSSDL_H */ diff --git a/desmume/src/debug.cpp b/src/debug.cpp similarity index 96% rename from desmume/src/debug.cpp rename to src/debug.cpp index 36b6bc820..82fc8630d 100644 --- a/desmume/src/debug.cpp +++ b/src/debug.cpp @@ -1,117 +1,117 @@ -/* Copyright (C) 2008 Guillaume Duhamel - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "debug.h" - -#include -#include -#include "MMU.h" -#include "armcpu.h" - -std::vector Logger::channels; - -static void defaultCallback(const Logger& logger, const char * message) { - logger.getOutput() << message; -} - -Logger::Logger() { - out = &std::cout; - callback = defaultCallback; - flags = 0; -} - -Logger::~Logger() { - for(int i=0;i<(int)channels.size();i++) - delete channels[i]; -} - -void Logger::vprintf(const char * format, va_list l, const char * file, unsigned int line) { - char buffer[1024]; - char * cur = buffer; - - if (flags & Logger::FILE) cur += sprintf(cur, "%s:", file); - if (flags & Logger::LINE) cur += sprintf(cur, "%d:", line); - if (flags) cur += sprintf(cur, " "); - - ::vsnprintf(cur, 1024, format, l); - callback(*this, buffer); -} - -void Logger::setOutput(std::ostream * o) { - out = o; -} - -void Logger::setCallback(void (*cback)(const Logger& logger, const char * message)) { - callback = cback; -} - -void Logger::setFlag(unsigned int flag) { - this->flags = flag; -} - -void Logger::fixSize(unsigned int channel) { - while(channel >= channels.size()) { - channels.push_back(new Logger()); - } -} - -std::ostream& Logger::getOutput() const { - return *out; -} - -void Logger::log(unsigned int channel, const char * file, unsigned int line, const char * format, ...) { - fixSize(channel); - - va_list l; - va_start(l, format); - channels[channel]->vprintf(format, l, file, line); - va_end(l); -} - -void Logger::log(unsigned int channel, const char * file, unsigned int line, std::ostream& os) { - fixSize(channel); - - channels[channel]->setOutput(&os); -} - -void Logger::log(unsigned int channel, const char * file, unsigned int line, unsigned int flag) { - fixSize(channel); - - channels[channel]->setFlag(flag); -} - -void Logger::log(unsigned int channel, const char * file, unsigned int line, void (*callback)(const Logger& logger, const char * message)) { - fixSize(channel); - - channels[channel]->setCallback(callback); -} - -void IdeasLog(armcpu_t* cpu) -{ - u32 adr = cpu->R[0]; - printf("EMULOG%c: ",cpu->proc_ID==0?'9':'7'); - for(;;) { - u8 c = MMU_read8(cpu->proc_ID,adr); - adr++; - if(!c) break; - printf("%c",c); - } - printf("\n"); -} - +/* Copyright (C) 2008 Guillaume Duhamel + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "debug.h" + +#include +#include +#include "MMU.h" +#include "armcpu.h" + +std::vector Logger::channels; + +static void defaultCallback(const Logger& logger, const char * message) { + logger.getOutput() << message; +} + +Logger::Logger() { + out = &std::cout; + callback = defaultCallback; + flags = 0; +} + +Logger::~Logger() { + for(int i=0;i<(int)channels.size();i++) + delete channels[i]; +} + +void Logger::vprintf(const char * format, va_list l, const char * file, unsigned int line) { + char buffer[1024]; + char * cur = buffer; + + if (flags & Logger::FILE) cur += sprintf(cur, "%s:", file); + if (flags & Logger::LINE) cur += sprintf(cur, "%d:", line); + if (flags) cur += sprintf(cur, " "); + + ::vsnprintf(cur, 1024, format, l); + callback(*this, buffer); +} + +void Logger::setOutput(std::ostream * o) { + out = o; +} + +void Logger::setCallback(void (*cback)(const Logger& logger, const char * message)) { + callback = cback; +} + +void Logger::setFlag(unsigned int flag) { + this->flags = flag; +} + +void Logger::fixSize(unsigned int channel) { + while(channel >= channels.size()) { + channels.push_back(new Logger()); + } +} + +std::ostream& Logger::getOutput() const { + return *out; +} + +void Logger::log(unsigned int channel, const char * file, unsigned int line, const char * format, ...) { + fixSize(channel); + + va_list l; + va_start(l, format); + channels[channel]->vprintf(format, l, file, line); + va_end(l); +} + +void Logger::log(unsigned int channel, const char * file, unsigned int line, std::ostream& os) { + fixSize(channel); + + channels[channel]->setOutput(&os); +} + +void Logger::log(unsigned int channel, const char * file, unsigned int line, unsigned int flag) { + fixSize(channel); + + channels[channel]->setFlag(flag); +} + +void Logger::log(unsigned int channel, const char * file, unsigned int line, void (*callback)(const Logger& logger, const char * message)) { + fixSize(channel); + + channels[channel]->setCallback(callback); +} + +void IdeasLog(armcpu_t* cpu) +{ + u32 adr = cpu->R[0]; + printf("EMULOG%c: ",cpu->proc_ID==0?'9':'7'); + for(;;) { + u8 c = MMU_read8(cpu->proc_ID,adr); + adr++; + if(!c) break; + printf("%c",c); + } + printf("\n"); +} + diff --git a/desmume/src/debug.h b/src/debug.h similarity index 96% rename from desmume/src/debug.h rename to src/debug.h index 71a74d4fc..12a91dc90 100644 --- a/desmume/src/debug.h +++ b/src/debug.h @@ -1,119 +1,119 @@ -/* Copyright (C) 2008 Guillaume Duhamel - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef LOGGER_H -#define LOGGER_H - -#include -#include -#include - -struct armcpu_t; - -class Logger { -protected: - void (*callback)(const Logger& logger, const char * format); - std::ostream * out; - unsigned int flags; - - static std::vector channels; - - static void fixSize(unsigned int channel); -public: - Logger(); - ~Logger(); - - void vprintf(const char * format, va_list l, const char * filename, unsigned int line); - void setOutput(std::ostream * o); - void setCallback(void (*cback)(const Logger& logger, const char * message)); - void setFlag(unsigned int flag); - - std::ostream& getOutput() const; - - static const int LINE = 1; - static const int FILE = 2; - - static void log(unsigned int channel, const char * file, unsigned int line, const char * format, ...); - static void log(unsigned int channel, const char * file, unsigned int line, std::ostream& os); - static void log(unsigned int channel, const char * file, unsigned int line, unsigned int flag); - static void log(unsigned int channel, const char * file, unsigned int line, void (*callback)(const Logger& logger, const char * message)); -}; - -#if defined(DEBUG) || defined(GPUDEBUG) || defined(DIVDEBUG) || defined(SQRTDEBUG) || defined(DMADEBUG) || defined(DEVELOPER) -#define LOGC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__) -#else -#define LOGC(...) {} -#endif - -#ifdef DEBUG -#define LOG(...) LOGC(0, __VA_ARGS__) -#else -#define LOG(...) {} -#endif - -#ifdef GPUDEBUG -#define GPULOG(...) LOGC(1, __VA_ARGS__) -#else -#define GPULOG(...) {} -#endif - -#ifdef DIVDEBUG -#define DIVLOG(...) LOGC(2, __VA_ARGS__) -#else -#define DIVLOG(...) {} -#endif - -#ifdef SQRTDEBUG -#define SQRTLOG(...) LOGC(3, __VA_ARGS__) -#else -#define SQRTLOG(...) {} -#endif - -#ifdef DMADEBUG -#define DMALOG(...) LOGC(4, __VA_ARGS__) -#else -#define DMALOG(...) {} -#endif - -#ifdef CFLASHDEBUG -#define CFLASHLOG(...) LOGC(5, __VA_ARGS__) -#else -#define CFLASHLOG(...) {} -#endif - -#ifdef UNTESTEDOPCODELOG -#define UNTESTEDOPCODELOG(...) LOGC(6, __VA_ARGS__) -#else -#define UNTESTEDOPCODELOG(...) {} -#endif - - -#ifdef DEVELOPER -#define PROGINFO(...) LOGC(7, __VA_ARGS__) -#else -#define PROGINFO(...) {} -#endif - - -#define INFOC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__) -#define INFO(...) INFOC(10, __VA_ARGS__) - -void IdeasLog(armcpu_t* cpu); - -#endif +/* Copyright (C) 2008 Guillaume Duhamel + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef LOGGER_H +#define LOGGER_H + +#include +#include +#include + +struct armcpu_t; + +class Logger { +protected: + void (*callback)(const Logger& logger, const char * format); + std::ostream * out; + unsigned int flags; + + static std::vector channels; + + static void fixSize(unsigned int channel); +public: + Logger(); + ~Logger(); + + void vprintf(const char * format, va_list l, const char * filename, unsigned int line); + void setOutput(std::ostream * o); + void setCallback(void (*cback)(const Logger& logger, const char * message)); + void setFlag(unsigned int flag); + + std::ostream& getOutput() const; + + static const int LINE = 1; + static const int FILE = 2; + + static void log(unsigned int channel, const char * file, unsigned int line, const char * format, ...); + static void log(unsigned int channel, const char * file, unsigned int line, std::ostream& os); + static void log(unsigned int channel, const char * file, unsigned int line, unsigned int flag); + static void log(unsigned int channel, const char * file, unsigned int line, void (*callback)(const Logger& logger, const char * message)); +}; + +#if defined(DEBUG) || defined(GPUDEBUG) || defined(DIVDEBUG) || defined(SQRTDEBUG) || defined(DMADEBUG) || defined(DEVELOPER) +#define LOGC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__) +#else +#define LOGC(...) {} +#endif + +#ifdef DEBUG +#define LOG(...) LOGC(0, __VA_ARGS__) +#else +#define LOG(...) {} +#endif + +#ifdef GPUDEBUG +#define GPULOG(...) LOGC(1, __VA_ARGS__) +#else +#define GPULOG(...) {} +#endif + +#ifdef DIVDEBUG +#define DIVLOG(...) LOGC(2, __VA_ARGS__) +#else +#define DIVLOG(...) {} +#endif + +#ifdef SQRTDEBUG +#define SQRTLOG(...) LOGC(3, __VA_ARGS__) +#else +#define SQRTLOG(...) {} +#endif + +#ifdef DMADEBUG +#define DMALOG(...) LOGC(4, __VA_ARGS__) +#else +#define DMALOG(...) {} +#endif + +#ifdef CFLASHDEBUG +#define CFLASHLOG(...) LOGC(5, __VA_ARGS__) +#else +#define CFLASHLOG(...) {} +#endif + +#ifdef UNTESTEDOPCODELOG +#define UNTESTEDOPCODELOG(...) LOGC(6, __VA_ARGS__) +#else +#define UNTESTEDOPCODELOG(...) {} +#endif + + +#ifdef DEVELOPER +#define PROGINFO(...) LOGC(7, __VA_ARGS__) +#else +#define PROGINFO(...) {} +#endif + + +#define INFOC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__) +#define INFO(...) INFOC(10, __VA_ARGS__) + +void IdeasLog(armcpu_t* cpu); + +#endif diff --git a/desmume/src/desmume.mk b/src/desmume.mk similarity index 100% rename from desmume/src/desmume.mk rename to src/desmume.mk diff --git a/desmume/src/driver.h b/src/driver.h similarity index 100% rename from desmume/src/driver.h rename to src/driver.h diff --git a/src/dscard.h b/src/dscard.h new file mode 100644 index 000000000..d3a4d4132 --- /dev/null +++ b/src/dscard.h @@ -0,0 +1,34 @@ +/* Copyright (C) 2006 thoduv + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __DSCARD_H__ +#define __DSCARD_H__ + +typedef struct +{ + + u32 address; + u32 transfer_count; + +} nds_dscard; + +#endif /*__DSCARD_H__*/ + + + diff --git a/src/fat.h b/src/fat.h new file mode 100644 index 000000000..7ec251344 --- /dev/null +++ b/src/fat.h @@ -0,0 +1,85 @@ +/* + FAT.H + Mic, 2006 + Structures taken from Michael Chisholm's FAT library +*/ + +#ifndef __FAT_H__ +#define __FAT_H__ + +#include "types.h" +#include "PACKED.h" +#include "PACKED_END.h" + +#define ATTRIB_DIR 0x10 +#define ATTRIB_LFN 0x0F + +#define FILE_FREE 0xE5 +/* Name and extension maximum length */ +#define NAME_LEN 8 +#define EXT_LEN 3 + +// Boot Sector - must be packed +#if defined(_MSC_VER) || defined(__INTEL_COMPILER) +#define DIR_SEP "\\" +#else +#define DIR_SEP "/" +#endif + +#include "PACKED.h" +typedef struct +{ + u8 jmpBoot[3] __PACKED; + u8 OEMName[8] __PACKED; + // BIOS Parameter Block + u16 bytesPerSector __PACKED; + u8 sectorsPerCluster __PACKED; + u16 reservedSectors __PACKED; + u8 numFATs __PACKED; + u16 rootEntries __PACKED; + u16 numSectorsSmall __PACKED; + u8 mediaDesc __PACKED; + u16 sectorsPerFAT __PACKED; + u16 sectorsPerTrk __PACKED; + u16 numHeads __PACKED; + u32 numHiddenSectors __PACKED; + u32 numSectors __PACKED; + + struct + { + // Ext BIOS Parameter Block for FAT16 + u8 driveNumber __PACKED; + u8 reserved1 __PACKED; + u8 extBootSig __PACKED; + u32 volumeID __PACKED; + u8 volumeLabel[11] __PACKED; + u8 fileSysType[8] __PACKED; + // Bootcode + u8 bootCode[448] __PACKED; + u16 signature __PACKED; + } __PACKED fat16; + +} __PACKED BOOT_RECORD; +#include "PACKED_END.h" + +// Directory entry - must be packed +#include "PACKED.h" +typedef struct +{ + u8 name[NAME_LEN] __PACKED; + u8 ext[EXT_LEN] __PACKED; + u8 attrib __PACKED; + u8 reserved __PACKED; + u8 cTime_ms __PACKED; + u16 cTime __PACKED; + u16 cDate __PACKED; + u16 aDate __PACKED; + u16 startClusterHigh __PACKED; + u16 mTime __PACKED; + u16 mDate __PACKED; + u16 startCluster __PACKED; + u32 fileSize __PACKED; +} __PACKED DIR_ENT; +#include "PACKED_END.h" + +#endif // diff --git a/desmume/src/fs-linux.cpp b/src/fs-linux.cpp similarity index 95% rename from desmume/src/fs-linux.cpp rename to src/fs-linux.cpp index 645cda0e0..5e8193bd5 100644 --- a/desmume/src/fs-linux.cpp +++ b/src/fs-linux.cpp @@ -1,115 +1,115 @@ -/* Copyright (C) 2006 Guillaume Duhamel - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "fs.h" - -#include -#include -#include -#include -#include -#include - -typedef struct { - DIR * dir; - char * path; -} FsLinuxDir; - -const char FS_SEPARATOR = '/'; - -void * FsReadFirst(const char * path, FsEntry * entry) { - FsLinuxDir * dir; - struct dirent * e; - struct stat s; - char buffer[512+1]; /* DirSpec[256] + '/' + dirent.d_name[256] */ - DIR * tmp; - - dir = (FsLinuxDir*)malloc(sizeof(FsLinuxDir)); - if (!dir) - return NULL; - - tmp = opendir(path); - if (!tmp) - return NULL; - dir->dir = tmp; - - e = readdir(tmp); - if (!e) { - closedir(tmp); - return NULL; - } - strcpy(entry->cFileName, e->d_name); - // there's no 8.3 file names support on linux :) - strcpy(entry->cAlternateFileName, ""); - entry->flags = 0; - - dir->path = strdup(path); - sprintf(buffer, "%s/%s", dir->path, e->d_name); - - stat(buffer, &s); - if (S_ISDIR(s.st_mode)) { - entry->flags = FS_IS_DIR; - entry->fileSize = 0; - } else { - entry->fileSize = s.st_size; - } - - return dir; -} - -int FsReadNext(void * search, FsEntry * entry) { - FsLinuxDir * dir = (FsLinuxDir*)search; - struct dirent * e; - struct stat s; - char buffer[1024]; - - e = readdir(dir->dir); - if (!e) - return 0; - - strcpy(entry->cFileName, e->d_name); - // there's no 8.3 file names support on linux :) - strcpy(entry->cAlternateFileName, ""); - entry->flags = 0; - - sprintf(buffer, "%s/%s", dir->path, e->d_name); - - stat(buffer, &s); - if (S_ISDIR(s.st_mode)) { - entry->flags = FS_IS_DIR; - entry->fileSize = 0; - } else { - entry->fileSize = s.st_size; - } - - return 1; -} - -void FsClose(void * search) { - FsLinuxDir *linuxdir = (FsLinuxDir *) search; - DIR * dir = linuxdir->dir; - - closedir(dir); - free(linuxdir->path); - free(search); -} - -int FsError(void) { - return 0; -} +/* Copyright (C) 2006 Guillaume Duhamel + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "fs.h" + +#include +#include +#include +#include +#include +#include + +typedef struct { + DIR * dir; + char * path; +} FsLinuxDir; + +const char FS_SEPARATOR = '/'; + +void * FsReadFirst(const char * path, FsEntry * entry) { + FsLinuxDir * dir; + struct dirent * e; + struct stat s; + char buffer[512+1]; /* DirSpec[256] + '/' + dirent.d_name[256] */ + DIR * tmp; + + dir = (FsLinuxDir*)malloc(sizeof(FsLinuxDir)); + if (!dir) + return NULL; + + tmp = opendir(path); + if (!tmp) + return NULL; + dir->dir = tmp; + + e = readdir(tmp); + if (!e) { + closedir(tmp); + return NULL; + } + strcpy(entry->cFileName, e->d_name); + // there's no 8.3 file names support on linux :) + strcpy(entry->cAlternateFileName, ""); + entry->flags = 0; + + dir->path = strdup(path); + sprintf(buffer, "%s/%s", dir->path, e->d_name); + + stat(buffer, &s); + if (S_ISDIR(s.st_mode)) { + entry->flags = FS_IS_DIR; + entry->fileSize = 0; + } else { + entry->fileSize = s.st_size; + } + + return dir; +} + +int FsReadNext(void * search, FsEntry * entry) { + FsLinuxDir * dir = (FsLinuxDir*)search; + struct dirent * e; + struct stat s; + char buffer[1024]; + + e = readdir(dir->dir); + if (!e) + return 0; + + strcpy(entry->cFileName, e->d_name); + // there's no 8.3 file names support on linux :) + strcpy(entry->cAlternateFileName, ""); + entry->flags = 0; + + sprintf(buffer, "%s/%s", dir->path, e->d_name); + + stat(buffer, &s); + if (S_ISDIR(s.st_mode)) { + entry->flags = FS_IS_DIR; + entry->fileSize = 0; + } else { + entry->fileSize = s.st_size; + } + + return 1; +} + +void FsClose(void * search) { + FsLinuxDir *linuxdir = (FsLinuxDir *) search; + DIR * dir = linuxdir->dir; + + closedir(dir); + free(linuxdir->path); + free(search); +} + +int FsError(void) { + return 0; +} diff --git a/desmume/src/fs-windows.cpp b/src/fs-windows.cpp similarity index 96% rename from desmume/src/fs-windows.cpp rename to src/fs-windows.cpp index 5f02031db..ea354330e 100644 --- a/desmume/src/fs-windows.cpp +++ b/src/fs-windows.cpp @@ -1,90 +1,90 @@ -/* Copyright (C) 2006 Guillaume Duhamel - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "fs.h" - -#include -#include -#include -#include - -const char FS_SEPARATOR = '\\'; - -void * FsReadFirst(const char * p, FsEntry * entry) { - WIN32_FIND_DATA FindFileData; - HANDLE hFind; - HANDLE * ret; - char path[1024]; - if (strlen(p)+3 >sizeof(path)) return NULL ; - - sprintf(path, "%s\\*", p); - - hFind = FindFirstFile(path, &FindFileData); - if (hFind == INVALID_HANDLE_VALUE) - return NULL; - - strncpy(entry->cFileName, FindFileData.cFileName,256); - entry->cFileName[255] = 0 ; - strncpy(entry->cAlternateFileName, FindFileData.cAlternateFileName,14); - entry->cAlternateFileName[13] = 0 ; - entry->flags = 0; - if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - entry->flags = FS_IS_DIR; - entry->fileSize = 0; - } else { - entry->fileSize = FindFileData.nFileSizeLow; - } - - ret = (void**)malloc(sizeof(HANDLE)); - *ret = hFind; - return ret; -} - -int FsReadNext(void * search, FsEntry * entry) { - WIN32_FIND_DATA FindFileData; - HANDLE * h = (HANDLE *) search; - int ret; - - ret = FindNextFile(*h, &FindFileData); - - strncpy(entry->cFileName, FindFileData.cFileName,256); - entry->cFileName[255] = 0 ; - strncpy(entry->cAlternateFileName, FindFileData.cAlternateFileName,14); - entry->cAlternateFileName[13] = 0 ; - entry->flags = 0; - if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { - entry->flags = FS_IS_DIR; - entry->fileSize = 0; - } else { - entry->fileSize = FindFileData.nFileSizeLow; - } - - return ret; -} - -void FsClose(void * search) { - FindClose(*((HANDLE *) search)); -} - -int FsError(void) { - if (GetLastError() == ERROR_NO_MORE_FILES) - return FS_ERR_NO_MORE_FILES; - - return FS_ERR_UNKNOWN; -} +/* Copyright (C) 2006 Guillaume Duhamel + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "fs.h" + +#include +#include +#include +#include + +const char FS_SEPARATOR = '\\'; + +void * FsReadFirst(const char * p, FsEntry * entry) { + WIN32_FIND_DATA FindFileData; + HANDLE hFind; + HANDLE * ret; + char path[1024]; + if (strlen(p)+3 >sizeof(path)) return NULL ; + + sprintf(path, "%s\\*", p); + + hFind = FindFirstFile(path, &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) + return NULL; + + strncpy(entry->cFileName, FindFileData.cFileName,256); + entry->cFileName[255] = 0 ; + strncpy(entry->cAlternateFileName, FindFileData.cAlternateFileName,14); + entry->cAlternateFileName[13] = 0 ; + entry->flags = 0; + if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + entry->flags = FS_IS_DIR; + entry->fileSize = 0; + } else { + entry->fileSize = FindFileData.nFileSizeLow; + } + + ret = (void**)malloc(sizeof(HANDLE)); + *ret = hFind; + return ret; +} + +int FsReadNext(void * search, FsEntry * entry) { + WIN32_FIND_DATA FindFileData; + HANDLE * h = (HANDLE *) search; + int ret; + + ret = FindNextFile(*h, &FindFileData); + + strncpy(entry->cFileName, FindFileData.cFileName,256); + entry->cFileName[255] = 0 ; + strncpy(entry->cAlternateFileName, FindFileData.cAlternateFileName,14); + entry->cAlternateFileName[13] = 0 ; + entry->flags = 0; + if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + entry->flags = FS_IS_DIR; + entry->fileSize = 0; + } else { + entry->fileSize = FindFileData.nFileSizeLow; + } + + return ret; +} + +void FsClose(void * search) { + FindClose(*((HANDLE *) search)); +} + +int FsError(void) { + if (GetLastError() == ERROR_NO_MORE_FILES) + return FS_ERR_NO_MORE_FILES; + + return FS_ERR_UNKNOWN; +} diff --git a/desmume/src/fs.h b/src/fs.h similarity index 96% rename from desmume/src/fs.h rename to src/fs.h index c48bb0da1..1721d9a91 100644 --- a/desmume/src/fs.h +++ b/src/fs.h @@ -1,44 +1,44 @@ -/* Copyright (C) 2006 Guillaume Duhamel - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef FS_H -#define FS_H - -#include "types.h" - -#define FS_IS_DIR 1 - -#define FS_ERR_UNKNOWN -1 -#define FS_ERR_NO_MORE_FILES 1 - -extern const char FS_SEPARATOR; - -typedef struct { - char cFileName[256]; - char cAlternateFileName[14]; - u32 flags; - u32 fileSize; -} FsEntry; - -void * FsReadFirst(const char * path, FsEntry * entry); -int FsReadNext(void * search, FsEntry * entry); -void FsClose(void * search); -int FsError(void); - -#endif +/* Copyright (C) 2006 Guillaume Duhamel + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef FS_H +#define FS_H + +#include "types.h" + +#define FS_IS_DIR 1 + +#define FS_ERR_UNKNOWN -1 +#define FS_ERR_NO_MORE_FILES 1 + +extern const char FS_SEPARATOR; + +typedef struct { + char cFileName[256]; + char cAlternateFileName[14]; + u32 flags; + u32 fileSize; +} FsEntry; + +void * FsReadFirst(const char * path, FsEntry * entry); +int FsReadNext(void * search, FsEntry * entry); +void FsClose(void * search); +int FsError(void); + +#endif diff --git a/desmume/src/gdbstub.h b/src/gdbstub.h similarity index 96% rename from desmume/src/gdbstub.h rename to src/gdbstub.h index 06544d6e7..3331c0f58 100644 --- a/desmume/src/gdbstub.h +++ b/src/gdbstub.h @@ -1,58 +1,58 @@ -/* $Id: gdbstub.h,v 1.1 2007-06-07 09:43:25 masscat Exp $ - */ -/* Copyright (C) 2006 Ben Jaques - * masscat@btinternet.com - * - * This file is part of DeSmuME - * - * DeSmuME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * DeSmuME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with DeSmuME; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _GDBSTUB_H_ -#define _GDBSTUB_H_ 1 - -#include "types.h" - -typedef void *gdbstub_handle_t; - -/* - * The function interface - */ - -gdbstub_handle_t -createStub_gdb( u16 port, - struct armcpu_memory_iface **cpu_memio, - struct armcpu_memory_iface *direct_memio); - -void -destroyStub_gdb( gdbstub_handle_t stub); - -void -activateStub_gdb( gdbstub_handle_t stub, - struct armcpu_ctrl_iface *cpu_ctrl); - - /* - * An implementation of the following functions is required - * for the GDB stub to function. - */ -void * -createThread_gdb( void (WINAPI *thread_function)( void *data), - void *thread_data); - -void -joinThread_gdb( void *thread_handle); - -#endif /* End of _GDBSTUB_H_ */ - +/* $Id: gdbstub.h,v 1.1 2007-06-07 09:43:25 masscat Exp $ + */ +/* Copyright (C) 2006 Ben Jaques + * masscat@btinternet.com + * + * This file is part of DeSmuME + * + * DeSmuME is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * DeSmuME is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DeSmuME; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _GDBSTUB_H_ +#define _GDBSTUB_H_ 1 + +#include "types.h" + +typedef void *gdbstub_handle_t; + +/* + * The function interface + */ + +gdbstub_handle_t +createStub_gdb( u16 port, + struct armcpu_memory_iface **cpu_memio, + struct armcpu_memory_iface *direct_memio); + +void +destroyStub_gdb( gdbstub_handle_t stub); + +void +activateStub_gdb( gdbstub_handle_t stub, + struct armcpu_ctrl_iface *cpu_ctrl); + + /* + * An implementation of the following functions is required + * for the GDB stub to function. + */ +void * +createThread_gdb( void (WINAPI *thread_function)( void *data), + void *thread_data); + +void +joinThread_gdb( void *thread_handle); + +#endif /* End of _GDBSTUB_H_ */ + diff --git a/desmume/src/gdbstub/Makefile.am b/src/gdbstub/Makefile.am similarity index 100% rename from desmume/src/gdbstub/Makefile.am rename to src/gdbstub/Makefile.am diff --git a/desmume/src/gdbstub/gdbstub.cpp b/src/gdbstub/gdbstub.cpp similarity index 96% rename from desmume/src/gdbstub/gdbstub.cpp rename to src/gdbstub/gdbstub.cpp index 20f4c5800..b6d867460 100644 --- a/desmume/src/gdbstub/gdbstub.cpp +++ b/src/gdbstub/gdbstub.cpp @@ -1,1617 +1,1617 @@ -/* $Id: gdbstub.c,v 1.1 2007-06-07 09:43:25 masscat Exp $ - */ -/* - * THE SOFTWARE WITHIN THIS FILE IS NOT COPYRIGHTED - * - * Originally written by Ben Jaques. - * - * The software is offered for use in the public domain in the hope that - * it will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ -#include -//#include -#include -#include - -#include - -#ifdef WIN32 -#include -#else -#include -#include -#include -#include -#include -#endif - -#include "armcpu.h" - -#define uint32_t u32 -#define uint16_t u16 -#define uint8_t u8 - -#include "gdbstub.h" -#include "gdbstub_internal.h" - -#ifdef __GNUC__ -#define UNUSED_PARM( parm) parm __attribute__((unused)) -#else -#define UNUSED_PARM( parm) parm -#endif - -#if 0 -#define DEBUG_LOG( fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__) -#else -#define DEBUG_LOG( fmt, ...) -#endif - -#if 0 -#define LOG_ERROR( fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__) -#else -#define LOG_ERROR( fmt, ...) -#endif - -#define LITTLE_ENDIAN_TO_UINT32_T( v) (\ - ((v)[3] << 24) | \ - ((v)[2] << 16) | \ - ((v)[1] << 8) | \ - ((v)[0] << 0)) - -/* - * The state of the packet reader - */ -#define IDLE_READ_STATE 0 -#define MID_PACKET_READ_STATE 1 -#define FIRST_CHECKSUM_READ_STATE 2 -#define SECOND_CHECKSUM_READ_STATE 3 - -/* - * The gdb stub thread control message types. - */ -enum stub_message_type { - /** The quit message type */ - QUIT_STUB_MESSAGE = 0, - /** The emulated CPU has stopped */ - CPU_STOPPED_STUB_MESSAGE = 1 -}; - - -/* - * The GDB signal values - */ -enum target_signal - { - /* Used some places (e.g. stop_signal) to record the concept that - there is no signal. */ - TARGET_SIGNAL_0 = 0, - TARGET_SIGNAL_FIRST = 0, - TARGET_SIGNAL_HUP = 1, - TARGET_SIGNAL_INT = 2, - TARGET_SIGNAL_QUIT = 3, - TARGET_SIGNAL_ILL = 4, - TARGET_SIGNAL_TRAP = 5, - TARGET_SIGNAL_ABRT = 6, - TARGET_SIGNAL_EMT = 7, - TARGET_SIGNAL_FPE = 8, - TARGET_SIGNAL_KILL = 9, - TARGET_SIGNAL_BUS = 10, - TARGET_SIGNAL_SEGV = 11, - TARGET_SIGNAL_SYS = 12, - TARGET_SIGNAL_PIPE = 13, - TARGET_SIGNAL_ALRM = 14, - TARGET_SIGNAL_TERM = 15, - TARGET_SIGNAL_URG = 16, - TARGET_SIGNAL_STOP = 17, - TARGET_SIGNAL_TSTP = 18, - TARGET_SIGNAL_CONT = 19, - TARGET_SIGNAL_CHLD = 20, - TARGET_SIGNAL_TTIN = 21, - TARGET_SIGNAL_TTOU = 22, - TARGET_SIGNAL_IO = 23, - TARGET_SIGNAL_XCPU = 24, - TARGET_SIGNAL_XFSZ = 25, - TARGET_SIGNAL_VTALRM = 26, - TARGET_SIGNAL_PROF = 27, - TARGET_SIGNAL_WINCH = 28, - TARGET_SIGNAL_LOST = 29, - TARGET_SIGNAL_USR1 = 30, - TARGET_SIGNAL_USR2 = 31, - TARGET_SIGNAL_PWR = 32, - /* Similar to SIGIO. Perhaps they should have the same number. */ - TARGET_SIGNAL_POLL = 33, - TARGET_SIGNAL_WIND = 34, - TARGET_SIGNAL_PHONE = 35, - TARGET_SIGNAL_WAITING = 36, - TARGET_SIGNAL_LWP = 37, - TARGET_SIGNAL_DANGER = 38, - TARGET_SIGNAL_GRANT = 39, - TARGET_SIGNAL_RETRACT = 40, - TARGET_SIGNAL_MSG = 41, - TARGET_SIGNAL_SOUND = 42, - TARGET_SIGNAL_SAK = 43, - TARGET_SIGNAL_PRIO = 44, - }; - - - - - -static void -causeQuit_gdb( struct gdb_stub_state *stub) { - uint8_t command = QUIT_STUB_MESSAGE; - -#ifdef WIN32 - send( stub->ctl_pipe[1], (char*)&command, 1, 0); -#else - write( stub->ctl_pipe[1], &command, 1); -#endif -} - -static void -indicateCPUStop_gdb( struct gdb_stub_state *stub) { - uint8_t command = CPU_STOPPED_STUB_MESSAGE; - -#ifdef WIN32 - send( stub->ctl_pipe[1], (char*)&command, 1, 0); -#else - write( stub->ctl_pipe[1], &command, 1); -#endif -} - - - - -/* - * - * - * - */ -static void -break_execution( void *data, UNUSED_PARM(uint32_t addr), UNUSED_PARM(int thunmb)) { - struct gdb_stub_state *stub = (struct gdb_stub_state *)data; - - /* stall the processor */ - stub->cpu_ctrl->stall( stub->cpu_ctrl->data); - - /* remove the post execution function */ - stub->cpu_ctrl->remove_post_ex_fn( stub->cpu_ctrl->data); - - /* indicate the halt */ - stub->stop_type = STOP_HOST_BREAK; - indicateCPUStop_gdb( stub); -} - - -static void -step_instruction_watch( void *data, uint32_t addr, UNUSED_PARM(int thunmb)) { - struct gdb_stub_state *stub = (struct gdb_stub_state *)data; - - DEBUG_LOG("Step watch: waiting for %08x at %08x\n", stub->step_instr_address, - addr); - - if ( addr == stub->step_instr_address) { - DEBUG_LOG("Step hit -> %08x\n", stub->cpu_ctrl->read_reg( stub->cpu_ctrl->data, 15)); - /* stall the processor */ - stub->cpu_ctrl->stall( stub->cpu_ctrl->data); - - /* remove the post execution function */ - stub->cpu_ctrl->remove_post_ex_fn( stub->cpu_ctrl->data); - - /* indicate the halt */ - stub->stop_type = STOP_STEP_BREAK; - indicateCPUStop_gdb( stub); - } -} - - - - - -/************************************************************************/ -/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ -/* at least NUMREGBYTES*2 are needed for register packets */ -#define BUFMAX 2048 - - - -static const char hexchars[]="0123456789abcdef"; - -/* - * Convert ch from a hex digit to an int - */ -static int -hex (unsigned char ch) { - if (ch >= 'a' && ch <= 'f') - return ch-'a'+10; - if (ch >= '0' && ch <= '9') - return ch-'0'; - if (ch >= 'A' && ch <= 'F') - return ch-'A'+10; - return -1; -} - -static const unsigned char * -hex2mem ( const unsigned char *buf, uint8_t *mem, int count) { - int i; - unsigned char ch; - - for (i=0; i 0) - { - ch = memio->read8( memio->data, mem_addr++); - *buf++ = hexchars[ch >> 4]; - *buf++ = hexchars[ch & 0xf]; - } - - *buf = 0; - - return buf; -} - - - -static enum read_res_gdb -readPacket_gdb( SOCKET_TYPE sock, struct packet_reader_gdb *packet) { - uint8_t cur_byte; - enum read_res_gdb read_res = READ_NOT_FINISHED; - int sock_res; - - /* update the state */ - - while ( (sock_res = recv( sock, (char*)&cur_byte, 1, 0)) == 1) { - switch ( packet->state) { - case IDLE_READ_STATE: - /* wait for the '$' start of packet character - */ - if ( cur_byte == '$') { - //DEBUG_LOG( "Found packet\n"); - packet->state = MID_PACKET_READ_STATE; - packet->pos_index = 0; - packet->checksum = 0; - } - /* Is this the break command */ - else if ( cur_byte == 3) { - //DEBUG_LOG( "GDB has sent a break\n"); - packet->buffer[0] = cur_byte; - packet->buffer[1] = 0; - packet->pos_index = 1; - return READ_BREAK; - } - break; - - case MID_PACKET_READ_STATE: - if ( cur_byte == '#') { - //DEBUG_LOG( "\nAbout to get checksum\n"); - packet->buffer[packet->pos_index] = '\0'; - packet->state = FIRST_CHECKSUM_READ_STATE; - } - else if ( packet->pos_index >= BUFMAX - 1) { - //DEBUG_LOG( "read buffer exceeded\n"); - packet->state = IDLE_READ_STATE; - } - else { - //DEBUG_LOG( "%c", cur_byte); - packet->checksum = packet->checksum + cur_byte; - packet->buffer[packet->pos_index] = cur_byte; - packet->pos_index = packet->pos_index + 1; - } - break; - - case FIRST_CHECKSUM_READ_STATE: - packet->read_checksum = hex( cur_byte) << 4; - packet->state = SECOND_CHECKSUM_READ_STATE; - break; - - case SECOND_CHECKSUM_READ_STATE: { - packet->read_checksum += hex( cur_byte); - packet->state = IDLE_READ_STATE; - return READ_COMPLETE; - break; - } - } - } - - if ( sock_res == 0) { - read_res = READ_SOCKET_ERROR; - } - else if ( sock_res == -1) { - if ( errno != EAGAIN) { - read_res = READ_SOCKET_ERROR; - } - } - - return read_res; -} - - -struct hidden_debug_out_packet { - unsigned char *start_ptr; -}; -struct debug_out_packet { - unsigned char *const start_ptr; -}; - -static struct hidden_debug_out_packet the_out_packet; -static unsigned char hidden_buffer[BUFMAX]; - - -static struct debug_out_packet * -getOutPacket( void) { - the_out_packet.start_ptr = &hidden_buffer[1]; - return (struct debug_out_packet *)&the_out_packet; -} - -#define CHECKSUM_PART_SIZE 3 -/** - * send the packet in buffer. - */ -static int -putpacket ( SOCKET_TYPE sock, struct debug_out_packet *out_packet, uint32_t size) { - unsigned char checksum = 0; - uint32_t count; - unsigned char *ch_ptr = (unsigned char *)&out_packet->start_ptr[-1]; - uint8_t reply_ch; - - //DEBUG_LOG_START( "Putting packet size %d ", size); - /* add the '$' to the start of the packet */ - *ch_ptr++ = '$'; - - /* calculate and add the checksum to the packet */ - for ( count = 0; count < size; count += 1) { - checksum += ch_ptr[count]; - //DEBUG_LOG_PART("%c", ch_ptr[count]); - } - //DEBUG_LOG_PART("\n"); - - ch_ptr[count++] = '#'; - ch_ptr[count++] = hexchars[checksum >> 4]; - ch_ptr[count++] = hexchars[checksum & 0xf]; - ch_ptr[count] = '\0'; - //DEBUG_LOG("packet %s\n", &out_packet->start_ptr[-1]); - - /* add one for the '$' character */ - count += 1; - - do { - int reply_found = 0; - - send( sock, (char*)&out_packet->start_ptr[-1], count, 0); - - do { - int read_res = recv( sock, (char*)&reply_ch, 1, 0); - - if ( read_res == 0) { - return -1; - } - else if ( read_res == -1) { - if ( errno != EAGAIN) { - return -1; - } - } - else { - reply_found = 1; - } - } while ( !reply_found); - } while ( reply_ch != '+'); - - /* $#. */ - return count - 4; -} - - - -static uint32_t -make_stop_packet( uint8_t *ptr, enum stop_type type, uint32_t stop_address) { - uint32_t stop_size = 0; - int watch_index = 0; - const char watch_chars[] = { 'a', 'r' }; - - switch (type) { - case STOP_UNKNOWN: - case STOP_HOST_BREAK: - ptr[0] = 'S'; - ptr[1] = hexchars[TARGET_SIGNAL_INT >> 4]; - ptr[2] = hexchars[TARGET_SIGNAL_INT & 0xf]; - stop_size = 3; - break; - - case STOP_STEP_BREAK: - case STOP_BREAKPOINT: - ptr[0] = 'S'; - ptr[1] = hexchars[TARGET_SIGNAL_TRAP >> 4]; - ptr[2] = hexchars[TARGET_SIGNAL_TRAP & 0xf]; - stop_size = 3; - break; - - case STOP_WATCHPOINT: - watch_index = 1; - case STOP_RWATCHPOINT: - watch_index += 1; - case STOP_AWATCHPOINT: - { - int i; - int out_index = 0; - ptr[out_index++] = 'T'; - ptr[out_index++] = hexchars[TARGET_SIGNAL_ABRT >> 4]; - ptr[out_index++] = hexchars[TARGET_SIGNAL_ABRT & 0xf]; - - if ( watch_index < 2) { - ptr[out_index++] = watch_chars[watch_index]; - } - ptr[out_index++] = 'w'; - ptr[out_index++] = 'a'; - ptr[out_index++] = 't'; - ptr[out_index++] = 'c'; - ptr[out_index++] = 'h'; - ptr[out_index++] = ':'; - - for ( i = 0; i < 8; i++) { - ptr[out_index++] = hexchars[(stop_address >> (i * 4)) & 0xf]; - } - ptr[out_index++] = ';'; - - stop_size = out_index; - } - break; - } - - return stop_size; -} - -/** - * Returns -1 if there is a socket error. - */ -static int -processPacket_gdb( SOCKET_TYPE sock, const uint8_t *packet, - struct gdb_stub_state *stub) { - // uint8_t remcomOutBuffer[BUFMAX_GDB]; - struct debug_out_packet *out_packet = getOutPacket(); - uint8_t *out_ptr = out_packet->start_ptr; - int send_reply = 1; - uint32_t send_size = 0; - - DEBUG_LOG("Processing packet %c\n", packet[0]); - - switch( packet[0]) { - case 3: - /* The break command */ - //stub->running_state = gdb_stub_state::STOPPED_GDB_STATE; - //*ptr++ = 'S'; - //*ptr++ = hexchars[0x2 >> 4]; - //*ptr++ = hexchars[0x2 & 0xf]; - //*ptr++ = 0; - send_reply = 0; - break; - - case '?': - send_size = make_stop_packet( out_ptr, stub->stop_type, stub->stop_address); - /**ptr++ = 'S'; - *ptr++ = hexchars[stub->stop_reason >> 4]; - *ptr++ = hexchars[stub->stop_reason & 0xf]; - send_size = 3;*/ - break; - - case 'c': - stub->emu_stub_state = gdb_stub_state::RUNNING_EMU_GDB_STATE; - stub->ctl_stub_state = gdb_stub_state::START_RUN_GDB_STATE; - stub->main_stop_flag = 0; - send_reply = 0; - /* remove the cpu stall */ - stub->cpu_ctrl->unstall( stub->cpu_ctrl->data); - break; - - case 's': { - uint32_t instr_addr = stub->cpu_ctrl->read_reg( stub->cpu_ctrl->data, 15); - /* Determine where the next instruction will take the CPU. - * Execute the instruction using a copy of the CPU with a zero memory interface. - */ - DEBUG_LOG( "Stepping instruction at %08x\n", instr_addr); - - /* install the post execution function */ - stub->step_instr_address = instr_addr; - stub->cpu_ctrl->install_post_ex_fn( stub->cpu_ctrl->data, - step_instruction_watch, - stub); - - - stub->emu_stub_state = gdb_stub_state::RUNNING_EMU_GDB_STATE; - stub->ctl_stub_state = gdb_stub_state::START_RUN_GDB_STATE; - stub->main_stop_flag = 0; - send_reply = 0; - - /* remove the cpu stall */ - stub->cpu_ctrl->unstall( stub->cpu_ctrl->data); - break; - } - - /* - * Register set - */ - case 'P': { - uint32_t reg; - uint32_t value; - const uint8_t *rx_ptr = &packet[1]; - - DEBUG_LOG("Processing packet %s\n", packet); - if ( hexToInt( &rx_ptr, ®)) { - if ( *rx_ptr++ == '=') { - uint8_t tmp_mem[4]; - - rx_ptr = hex2mem( rx_ptr, tmp_mem, 4); - value = LITTLE_ENDIAN_TO_UINT32_T( tmp_mem); - DEBUG_LOG("Setting reg %d to %08x\n", reg, value); - if ( reg < 16) - stub->cpu_ctrl->set_reg( stub->cpu_ctrl->data, reg, value); - if ( reg == 25) { - stub->cpu_ctrl->set_reg( stub->cpu_ctrl->data, 16, value); - } - - strcpy( (char *)out_ptr, "OK"); - send_size = 2; - } - } - break; - } - - case 'm': { - uint32_t addr = 0; - uint32_t length = 0; - int error01 = 1; - const uint8_t *rx_ptr = &packet[1]; - - if ( hexToInt( &rx_ptr, &addr)) { - if ( *rx_ptr++ == ',') { - if ( hexToInt( &rx_ptr, &length)) { - //DEBUG_LOG("mem read from %08x (%d)\n", addr, length); - if ( !mem2hex( stub->direct_memio, addr, out_ptr, length)) { - strcpy ( (char *)out_ptr, "E03"); - send_size = 3; - } - else { - send_size = length * 2; - } - error01 = 0; - } - } - } - if ( error01) - strcpy( (char *)out_ptr,"E01"); - break; - } - - /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */ - case 'M': { - /* Try to read '%x,%x:'. */ - const uint8_t *rx_ptr = &packet[1]; - uint32_t addr = 0; - uint32_t length = 0; - int error01 = 1; - DEBUG_LOG("Memory write %s\n", rx_ptr); - if ( hexToInt(&rx_ptr, &addr)) { - if ( *rx_ptr++ == ',') { - if ( hexToInt(&rx_ptr, &length)) { - if ( *rx_ptr++ == ':') { - uint8_t write_byte; - unsigned int i; - DEBUG_LOG("Memory write of %d bytes to %08x\n", - length, addr); - - for ( i = 0; i < length; i++) { - rx_ptr = hex2mem( rx_ptr, &write_byte, 1); - - stub->direct_memio->write8( stub->direct_memio->data, - addr++, write_byte); - } - - strcpy( (char *)out_ptr, "OK"); - error01 = 0; - } - } - else { - DEBUG_LOG("Failed to find length (addr %08x)\n", addr); - } - } - else { - DEBUG_LOG("expected ',' got '%c' (addr = %08x)\n", *rx_ptr, addr); - } - } - else { - DEBUG_LOG("Failed to find addr\n"); - } - - if ( error01) { - strcpy( (char *)out_ptr, "E02"); - } - break; - } - - case 'Z': - case 'z': { - const uint8_t *rx_ptr = &packet[2]; - int remove_flag = 0; - - if ( packet[0] == 'z') - remove_flag = 1; - - DEBUG_LOG( "%c%c packet %s (remove? %d)\n", packet[0], packet[1], - rx_ptr, remove_flag); - - switch ( packet[1]) { - - /* all instruction breakpoints are treated the same */ - case '0': - case '1': - case '2': - case '3': - case '4': - { - uint32_t addr = 0; - uint32_t length = 0; - int error01 = 1; - struct breakpoint_gdb **bpoint_list; - - switch ( packet[1]) { - case '0': - case '1': - bpoint_list = &stub->instr_breakpoints; - break; - - case '2': - bpoint_list = &stub->write_breakpoints; - break; - - case '3': - bpoint_list = &stub->read_breakpoints; - break; - - case '4': - bpoint_list = &stub->access_breakpoints; - break; - } - - if ( *rx_ptr++ == ',') { - DEBUG_LOG("%s\n", rx_ptr); - - if ( hexToInt( &rx_ptr, &addr)) { - if ( *rx_ptr++ == ',') { - DEBUG_LOG("addr %08x %s\n", addr, rx_ptr); - - if ( hexToInt( &rx_ptr, &length)) { - if ( remove_flag) { - int removed = 0; - struct breakpoint_gdb *last_bpoint = NULL; - struct breakpoint_gdb *bpoint = *bpoint_list; - - while ( bpoint != NULL && !removed) { - if ( bpoint->addr == addr) { - DEBUG_LOG("Breakpoint(%c) at %08x removed\n", packet[1], addr); - removed = 1; - - if ( last_bpoint == NULL) { - *bpoint_list = bpoint->next; - } - else { - last_bpoint->next = bpoint->next; - } - bpoint->next = stub->free_breakpoints; - stub->free_breakpoints = bpoint; - } - last_bpoint = bpoint; - bpoint = bpoint->next; - } - - strcpy( (char *)out_ptr, "OK"); - send_size = 2; - error01 = 0; - } - else { - /* get a breakpoint descriptor from the free pool and add it to - * the current stub instruction breakpoint list */ - struct breakpoint_gdb *bpoint = stub->free_breakpoints; - - if ( bpoint != NULL) { - DEBUG_LOG( "Breakpoint(%c) added at %08x length %d\n", - packet[1], addr, length); - stub->free_breakpoints = bpoint->next; - - bpoint->addr = addr; - bpoint->size = length; - - bpoint->next = *bpoint_list; - *bpoint_list = bpoint; - - strcpy( (char *)out_ptr, "OK"); - send_size = 2; - error01 = 0; - } - } - } - } - } - } - - if ( error01) { - strcpy( (char *)out_ptr, "E01"); - send_size = 3; - } - } - break; - - default: - break; - } - break; - } - - /* - * Set the register values - */ - case 'G': - { - int i; - const uint8_t *rx_ptr = &packet[1]; - uint32_t reg_values[16]; - uint32_t cpsr; - uint8_t tmp_mem[4]; - DEBUG_LOG("'G' command %s\n", rx_ptr); - - /* general purpose regs 0 to 15 */ - for ( i = 0; i < 16; i++) { - rx_ptr = hex2mem( rx_ptr, tmp_mem, 4); - - reg_values[i] = LITTLE_ENDIAN_TO_UINT32_T( tmp_mem); - DEBUG_LOG("Setting reg %d to %08x\n", i, reg_values[i]); - } - - /* skip the floaing point registers and floating point status register */ - rx_ptr += 8 * (96 / 8 * 2); - rx_ptr += 8; - - /* the CPSR register is last */ - rx_ptr = hex2mem( rx_ptr, tmp_mem, 4); - cpsr = LITTLE_ENDIAN_TO_UINT32_T( tmp_mem); - DEBUG_LOG("Setting cpsr to %08x\n", cpsr); - - strcpy( (char *)out_ptr, "OK"); - send_size = 2; - break; - } - - case 'g': /* return the value of the CPU registers */ - { - int i; - int out_index = 0; - uint32_t pc_value = stub->cpu_ctrl->read_reg( stub->cpu_ctrl->data, 15); - uint32_t cpsr_value = stub->cpu_ctrl->read_reg( stub->cpu_ctrl->data, 16); - - DEBUG_LOG("'g' command PC = %08x\n", pc_value); - - /* general purpose regs 0 to 14 */ - for ( i = 0; i < 15; i++) { - uint32_t reg = stub->cpu_ctrl->read_reg( stub->cpu_ctrl->data, i); - out_ptr[out_index++] = hexchars[(reg >> 4) & 0xf]; - out_ptr[out_index++] = hexchars[(reg >> 0) & 0xf]; - out_ptr[out_index++] = hexchars[(reg >> 12) & 0xf]; - out_ptr[out_index++] = hexchars[(reg >> 8) & 0xf]; - out_ptr[out_index++] = hexchars[(reg >> 20) & 0xf]; - out_ptr[out_index++] = hexchars[(reg >> 16) & 0xf]; - out_ptr[out_index++] = hexchars[(reg >> 28) & 0xf]; - out_ptr[out_index++] = hexchars[(reg >> 24) & 0xf]; - } - - out_ptr[out_index++] = hexchars[(pc_value >> 4) & 0xf]; - out_ptr[out_index++] = hexchars[(pc_value >> 0) & 0xf]; - out_ptr[out_index++] = hexchars[(pc_value >> 12) & 0xf]; - out_ptr[out_index++] = hexchars[(pc_value >> 8) & 0xf]; - out_ptr[out_index++] = hexchars[(pc_value >> 20) & 0xf]; - out_ptr[out_index++] = hexchars[(pc_value >> 16) & 0xf]; - out_ptr[out_index++] = hexchars[(pc_value >> 28) & 0xf]; - out_ptr[out_index++] = hexchars[(pc_value >> 24) & 0xf]; - - /* floating point registers (8 96bit) */ - for ( i = 0; i < 8; i++) { - int j; - for ( j = 0; j < (96/4); j++) { - out_ptr[out_index++] = '0'; - } - } - - /* floating point status register? */ - for ( i = 0; i < 1; i++) { - int j; - for ( j = 0; j < 8; j++) { - out_ptr[out_index++] = '0'; - } - } - - /* The CPSR */ - for ( i = 0; i < 1; i++) { - out_ptr[out_index++] = hexchars[(cpsr_value >> 4) & 0xf]; - out_ptr[out_index++] = hexchars[(cpsr_value >> 0) & 0xf]; - out_ptr[out_index++] = hexchars[(cpsr_value >> 12) & 0xf]; - out_ptr[out_index++] = hexchars[(cpsr_value >> 8) & 0xf]; - out_ptr[out_index++] = hexchars[(cpsr_value >> 20) & 0xf]; - out_ptr[out_index++] = hexchars[(cpsr_value >> 16) & 0xf]; - out_ptr[out_index++] = hexchars[(cpsr_value >> 28) & 0xf]; - out_ptr[out_index++] = hexchars[(cpsr_value >> 24) & 0xf]; - } - send_size = out_index; - } - break; - } - - if ( send_reply) { - return putpacket( sock, out_packet, send_size); - } - - return 0; -} - - - -/** - * create the listening socket - */ -static SOCKET_TYPE -createSocket ( int port) { - SOCKET_TYPE sock; - struct sockaddr_in bind_addr; - - memset (&bind_addr, 0, sizeof (bind_addr)); - bind_addr.sin_family = AF_INET; - bind_addr.sin_port = htons( port); - bind_addr.sin_addr.s_addr = htonl (INADDR_ANY); - - /* create the socket, bind the address */ - - sock = socket (PF_INET, SOCK_STREAM, 0); - -#ifdef WIN32 - if ( sock != INVALID_SOCKET) -#else - if (sock != -1) -#endif - { - if (bind (sock, (struct sockaddr *) &bind_addr, - sizeof (bind_addr)) == -1) { - LOG_ERROR("Bind failed \"%s\" port %d\n", strerror( errno), port); -#ifdef WIN32 - closesocket( sock); -#else - close (sock); -#endif - sock = -1; - } - else if (listen (sock, 5) == -1) { - LOG_ERROR("Listen failed \"%s\"\n", strerror( errno)); -#ifdef WIN32 - closesocket( sock); -#else - close (sock); -#endif - sock = -1; - } - } - else { -#ifdef WIN32 - char message[30]; - int error = WSAGetLastError(); - sprintf( message, "Error creating socket %d\n", error); - LOG_ERROR("Error creating socket %d\n", error); -#endif - } - - return sock; -} - - - - -/* - * Handle GDB stub connections. - */ - - -/** - */ -INLINE static int -check_breaks_gdb( struct gdb_stub_state *gdb_state, - struct breakpoint_gdb *bpoint_list, - uint32_t addr, - UNUSED_PARM(uint32_t size), - enum stop_type stop_type) { - int found_break = 0; - - if ( gdb_state->active) { - struct breakpoint_gdb *bpoint = bpoint_list; - - while ( bpoint != NULL && !found_break) { - if ( addr == bpoint->addr) { - DEBUG_LOG("Breakpoint hit at %08x\n", addr); - - /* stall the processor */ - gdb_state->cpu_ctrl->stall( gdb_state->cpu_ctrl->data); - - /* indicate the break to the GDB stub thread */ - gdb_state->stop_type = stop_type; - gdb_state->stop_address = addr; - indicateCPUStop_gdb( gdb_state); - } - bpoint = bpoint->next; - } - } - - return found_break; -} - -static void -WINAPI listenerThread_gdb( void *data) { - struct gdb_stub_state *state = (struct gdb_stub_state *)data; - fd_set read_sock_set; - fd_set main_set; - int quit = 0; - - FD_ZERO( &main_set); - - FD_SET( state->listen_fd, &main_set); - FD_SET( state->ctl_pipe[0], &main_set); - - while (!quit) { - int sel_res; - - read_sock_set = main_set; - - //DEBUG_LOG("Waiting on sockets\n"); - - sel_res = select( FD_SETSIZE, &read_sock_set, NULL, NULL, NULL); - //DEBUG_LOG("sockets ready %d\n", sel_res); - - if ( sel_res > 0) { - - /* Is this a control message */ - if ( FD_ISSET( state->ctl_pipe[0], &read_sock_set)) { - uint8_t ctl_command; - - //DEBUG_LOG("Control message\n"); -#ifdef WIN32 - recv( state->ctl_pipe[0], (char*)&ctl_command, 1, 0); -#else - read( state->ctl_pipe[0], (char*)&ctl_command, 1); -#endif - - switch ( ctl_command) { - - case CPU_STOPPED_STUB_MESSAGE: - if ( state->active && - state->ctl_stub_state != gdb_stub_state::STOPPED_GDB_STATE) { - struct debug_out_packet *out_packet = getOutPacket(); - uint8_t *ptr = out_packet->start_ptr; - uint32_t send_size; - - /* mark the stub as stopped and send the stop packet */ - state->ctl_stub_state = gdb_stub_state::STOPPED_GDB_STATE; - state->main_stop_flag = 1; - - send_size = make_stop_packet( ptr, state->stop_type, state->stop_address); - - /*ptr[0] = 'S'; - ptr[1] = hexchars[state->stop_reason >> 4]; - ptr[2] = hexchars[state->stop_reason & 0xf];*/ - - putpacket( state->sock_fd, out_packet, send_size); - DEBUG_LOG( "\nBreak from Emulation\n"); - } - else { - LOG_ERROR( "Asked to stop and already stopped\n"); - } - break; - - default: - /* quit out */ - quit = 1; - break; - } - } - - else { - //struct armcpu_t *cpu = twin_states->cpus[i]; - SOCKET_TYPE arm_listener = state->listen_fd; - - /* check for a connection request */ - if ( FD_ISSET( arm_listener, &read_sock_set)) { - SOCKET_TYPE new_conn; - struct sockaddr_in gdb_addr; -#ifdef WIN32 - int addr_size = sizeof( gdb_addr); -#else - socklen_t addr_size = sizeof( gdb_addr); -#endif - - //DEBUG_LOG("listener\n"); - - /* accept the connection if we do not already have one */ - new_conn = accept( arm_listener, (struct sockaddr *)&gdb_addr, - &addr_size); - - if ( new_conn != -1) { - int close_sock = 1; - - //DEBUG_LOG("got new socket\n"); - if ( state->sock_fd == -1 && state->active) { -#ifdef WIN32 - BOOL nodelay_opt = 1; -#else - int nodelay_opt = 1; -#endif - int set_res; - - //DEBUG_LOG("new connection\n"); - - close_sock = 0; - /* make the socket NODELAY */ -#ifdef WIN32 - set_res = setsockopt( new_conn, IPPROTO_TCP, TCP_NODELAY, - (char*)&nodelay_opt, sizeof( nodelay_opt)); -#else - set_res = setsockopt( new_conn, IPPROTO_TCP, TCP_NODELAY, - &nodelay_opt, sizeof( nodelay_opt)); -#endif - - if ( set_res != 0) { - LOG_ERROR( "Failed to set NODELAY socket option \"%s\"\n", strerror( errno)); - } - - FD_SET( new_conn, &main_set); - state->sock_fd = new_conn; - } - - if ( close_sock) { - //DEBUG_LOG("closing new socket\n"); -#ifdef WIN32 - closesocket( new_conn); -#else - close( new_conn); -#endif - } - } - } - - /* handle the gdb connection */ - if ( state->sock_fd != -1 && state->active) { - SOCKET_TYPE gdb_sock = state->sock_fd; - if ( FD_ISSET( gdb_sock, &read_sock_set)) { - enum read_res_gdb read_res = readPacket_gdb( gdb_sock, &state->rx_packet); - - //DEBUG_LOG("socket read %d\n", read_res); - - switch ( read_res) { - case READ_NOT_FINISHED: - /* do nothing here */ - break; - - case READ_SOCKET_ERROR: - /* close the socket */ -#ifdef WIN32 - closesocket( gdb_sock); -#else - close( gdb_sock); -#endif - state->sock_fd = -1; - FD_CLR( gdb_sock, &main_set); - break; - - case READ_BREAK: { - /* break the running of the cpu */ - if ( state->ctl_stub_state != gdb_stub_state::STOPPED_GDB_STATE) { - /* this will cause the emulation to break the execution */ - DEBUG_LOG( "Breaking execution\n"); - - /* install the post execution function */ - state->cpu_ctrl->install_post_ex_fn( state->cpu_ctrl->data, - break_execution, - state); - } - break; - } - - case READ_COMPLETE: { - uint8_t reply; - int write_res; - int process_packet = 0; - int close_socket = 0; - struct packet_reader_gdb *packet = &state->rx_packet; - - if ( state->ctl_stub_state != gdb_stub_state::STOPPED_GDB_STATE) { - /* not ready to process packet yet, send a bad reply */ - reply = '-'; - } - else { - /* send a reply based on the checksum and if okay process the packet */ - if ( packet->read_checksum == packet->checksum) { - reply = '+'; - process_packet = 1; - } - else { - reply = '-'; - } - } - - write_res = send( gdb_sock, (char*)&reply, 1, 0); - - if ( write_res != 1) { - close_socket = 1; - } - else { - if ( processPacket_gdb( gdb_sock, state->rx_packet.buffer, - state) == -1) { - close_socket = 1; - } - } - - if ( close_socket) { -#ifdef WIN32 - closesocket( gdb_sock); -#else - close( gdb_sock); -#endif - state->sock_fd = -1; - FD_CLR( gdb_sock, &main_set); - } - break; - } - } - } - } - } - } - } - - - /* tidy up and leave */ - if ( state->sock_fd != -1) { -#ifdef WIN32 - closesocket( state->sock_fd); -#else - close( state->sock_fd); -#endif - } - - /* close the listenering sockets */ -#ifdef WIN32 - closesocket( state->listen_fd); -#else - close( state->listen_fd); -#endif - - return; -} - - - - -/* - * - * The memory interface - * - */ -static uint32_t FASTCALL -gdb_prefetch32( void *data, uint32_t adr) { - struct gdb_stub_state *stub = (struct gdb_stub_state *)data; - uint32_t value = 0; - int breakpoint; - - breakpoint = check_breaks_gdb( stub, stub->instr_breakpoints, adr, 4, - STOP_BREAKPOINT); - - if ( !breakpoint) { - /* pass down to the real memory interace */ - value = stub->real_cpu_memio->prefetch32( stub->real_cpu_memio->data, - adr); - } - - return value; -} -static uint16_t FASTCALL -gdb_prefetch16( void *data, uint32_t adr) { - struct gdb_stub_state *stub = (struct gdb_stub_state *)data; - uint16_t value = 0; - int breakpoint; - - breakpoint = check_breaks_gdb( stub, stub->instr_breakpoints, adr, 2, - STOP_BREAKPOINT); - - if ( !breakpoint) { - /* pass down to the real memory interace */ - value = stub->real_cpu_memio->prefetch16( stub->real_cpu_memio->data, - adr); - } - - return value; -} - -/** read 8 bit data value */ -static uint8_t FASTCALL -gdb_read8( void *data, uint32_t adr) { - struct gdb_stub_state *stub = (struct gdb_stub_state *)data; - uint8_t value = 0; - int breakpoint; - - /* pass down to the real memory interace */ - value = stub->real_cpu_memio->read8( stub->real_cpu_memio->data, - adr); - - breakpoint = check_breaks_gdb( stub, stub->read_breakpoints, adr, 1, - STOP_RWATCHPOINT); - if ( !breakpoint) - check_breaks_gdb( stub, stub->access_breakpoints, adr, 1, - STOP_AWATCHPOINT); - - return value; -} - -/** read 16 bit data value */ -static uint16_t FASTCALL -gdb_read16( void *data, uint32_t adr) { - struct gdb_stub_state *stub = (struct gdb_stub_state *)data; - uint16_t value; - int breakpoint; - - /* pass down to the real memory interace */ - value = stub->real_cpu_memio->read16( stub->real_cpu_memio->data, - adr); - - breakpoint = check_breaks_gdb( stub, stub->read_breakpoints, adr, 2, - STOP_RWATCHPOINT); - if ( !breakpoint) - check_breaks_gdb( stub, stub->access_breakpoints, adr, 2, - STOP_AWATCHPOINT); - - return value; -} -/** read 32 bit data value */ -static uint32_t FASTCALL -gdb_read32( void *data, uint32_t adr) { - struct gdb_stub_state *stub = (struct gdb_stub_state *)data; - uint32_t value; - int breakpoint; - - /* pass down to the real memory interace */ - value = stub->real_cpu_memio->read32( stub->real_cpu_memio->data, - adr); - - breakpoint = check_breaks_gdb( stub, stub->read_breakpoints, adr, 4, - STOP_RWATCHPOINT); - if ( !breakpoint) - check_breaks_gdb( stub, stub->access_breakpoints, adr, 4, - STOP_AWATCHPOINT); - - return value; -} - -/** write 8 bit data value */ -static void FASTCALL -gdb_write8( void *data, uint32_t adr, uint8_t val) { - struct gdb_stub_state *stub = (struct gdb_stub_state *)data; - int breakpoint; - - /* pass down to the real memory interace */ - stub->real_cpu_memio->write8( stub->real_cpu_memio->data, - adr, val); - - breakpoint = check_breaks_gdb( stub, stub->write_breakpoints, adr, 1, - STOP_WATCHPOINT); - if ( !breakpoint) - check_breaks_gdb( stub, stub->access_breakpoints, adr, 1, - STOP_AWATCHPOINT); -} - -/** write 16 bit data value */ -static void FASTCALL -gdb_write16( void *data, uint32_t adr, uint16_t val) { - struct gdb_stub_state *stub = (struct gdb_stub_state *)data; - int breakpoint; - - /* pass down to the real memory interace */ - stub->real_cpu_memio->write16( stub->real_cpu_memio->data, - adr, val); - - breakpoint = check_breaks_gdb( stub, stub->write_breakpoints, adr, 2, - STOP_WATCHPOINT); - if ( !breakpoint) - check_breaks_gdb( stub, stub->access_breakpoints, adr, 2, - STOP_AWATCHPOINT); -} - -/** write 32 bit data value */ -static void FASTCALL -gdb_write32( void *data, uint32_t adr, uint32_t val) { - struct gdb_stub_state *stub = (struct gdb_stub_state *)data; - int breakpoint; - - /* pass down to the real memory interace */ - stub->real_cpu_memio->write32( stub->real_cpu_memio->data, - adr, val); - - breakpoint = check_breaks_gdb( stub, stub->write_breakpoints, adr, 4, - STOP_WATCHPOINT); - if ( !breakpoint) - check_breaks_gdb( stub, stub->access_breakpoints, adr, 4, - STOP_AWATCHPOINT); -} - - - - - - - -#ifdef WIN32 -struct socket_creator_data { - SOCKET_TYPE *sock; - int port_num; -}; -/** - */ -static DWORD WINAPI -control_creator( LPVOID lpParameter) -{ - struct socket_creator_data *my_data = (struct socket_creator_data *)lpParameter; - - *my_data->sock = socket( PF_INET, SOCK_STREAM, 0); - - if ( *my_data->sock != INVALID_SOCKET) { - int connect_res; - struct sockaddr_in clientService; - - clientService.sin_family = AF_INET; - clientService.sin_addr.s_addr = inet_addr( "127.0.0.1" ); - clientService.sin_port = htons( my_data->port_num); - - connect_res = connect( *my_data->sock, (SOCKADDR*) &clientService, sizeof(clientService)); - - if ( connect_res == SOCKET_ERROR) { - LOG_ERROR( "Failed to connect to socket\n"); - } - } - - return 0; -} - -#endif - - - -/** - */ -gdbstub_handle_t -createStub_gdb( uint16_t port, - struct armcpu_memory_iface **cpu_memio, - struct armcpu_memory_iface *direct_memio) { - struct gdb_stub_state *stub; - gdbstub_handle_t handle = NULL; - int i; - int res = 0; - - stub = (gdb_stub_state*)malloc( sizeof (struct gdb_stub_state)); - if ( stub == NULL) { - return NULL; - } - - stub->active = 0; - - /* keep the memory interfaces */ - stub->real_cpu_memio = *cpu_memio; - stub->direct_memio = direct_memio; - - *cpu_memio = &stub->cpu_memio; - - /* fill in the memory interface */ - stub->cpu_memio.data = stub; - stub->cpu_memio.prefetch32 = gdb_prefetch32; - stub->cpu_memio.prefetch16 = gdb_prefetch16; - - stub->cpu_memio.read8 = gdb_read8; - stub->cpu_memio.read16 = gdb_read16; - stub->cpu_memio.read32 = gdb_read32; - - stub->cpu_memio.write8 = gdb_write8; - stub->cpu_memio.write16 = gdb_write16; - stub->cpu_memio.write32 = gdb_write32; - - - - /* put the breakpoint descriptors onto the free list */ - for ( i = 0; i < BREAKPOINT_POOL_SIZE - 1; i++) { - stub->breakpoint_pool[i].next = &stub->breakpoint_pool[i+1]; - } - stub->breakpoint_pool[i].next = NULL; - stub->free_breakpoints = &stub->breakpoint_pool[0]; - stub->instr_breakpoints = NULL; - - stub->read_breakpoints = NULL; - stub->write_breakpoints = NULL; - stub->access_breakpoints = NULL; - -#ifdef WIN32 - /* initialise the winsock library */ - { - WORD wVersionRequested; - WSADATA wsaData; - int err; - - wVersionRequested = MAKEWORD( 2, 2 ); - - err = WSAStartup( wVersionRequested, &wsaData ); - if ( err != 0 ) { - return NULL; - } - } - - { - struct socket_creator_data temp_data = { - &stub->ctl_pipe[0], - 24689 - }; - SOCKET_TYPE temp_sock = createSocket ( temp_data.port_num); - HANDLE temp_thread = INVALID_HANDLE_VALUE; - DWORD temp_threadID; - - res = -1; - - if ( temp_sock != -1) { - /* create a thread to connect to this socket */ - temp_thread = CreateThread( NULL, 0, control_creator, &temp_data, 0, &temp_threadID); - if ( temp_thread != INVALID_HANDLE_VALUE) { - struct sockaddr_in ignore_addr; - int addr_size = sizeof( ignore_addr); - - stub->ctl_pipe[1] = accept( temp_sock, (struct sockaddr *)&ignore_addr, &addr_size); - - if ( stub->ctl_pipe[1] != INVALID_SOCKET) { - BOOL nodelay_opt = 1; - int set_res; - - /* make the socket NODELAY */ - set_res = setsockopt( stub->ctl_pipe[1], IPPROTO_TCP, TCP_NODELAY, - (char*)&nodelay_opt, sizeof( nodelay_opt)); - if ( set_res == 0) { - closesocket( temp_sock); - res = 0; - } - } - } - } - } - - if ( res != 0) { - LOG_ERROR( "Failed to create control socket\n"); - } -#else - /* create the control pipe */ - res = pipe( stub->ctl_pipe); - - if ( res != 0) { - LOG_ERROR( "Failed to create control pipe \"%s\"\n", strerror( errno)); - } -#endif - else { - stub->active = 1; - stub->emu_stub_state = gdb_stub_state::RUNNING_EMU_GDB_STATE; - stub->ctl_stub_state = gdb_stub_state::STOPPED_GDB_STATE; - stub->rx_packet.state = IDLE_READ_STATE; - - stub->main_stop_flag = 1; - - stub->port_num = port; - stub->sock_fd = -1; - stub->listen_fd = createSocket( port); - - stub->stop_type = STOP_UNKNOWN; - - if ( stub->listen_fd == -1) { - LOG_ERROR( "Failed to create listening socket \"%s\"\n", strerror( errno)); - res = -1; - } - } - - if ( res != -1) { - /* create the listenering thread */ - stub->thread = createThread_gdb( listenerThread_gdb, stub); - - if ( stub->thread == NULL) { - LOG_ERROR("Failed to create listener thread\n"); - free( stub); - } - else { - handle = stub; - - DEBUG_LOG("Created stub on port %d\n", port); - } - } - else { - free( stub); - } - - return handle; -} - - -void -destroyStub_gdb( gdbstub_handle_t instance) { - struct gdb_stub_state *stub = (struct gdb_stub_state *)instance; - - causeQuit_gdb( stub); - - joinThread_gdb( stub->thread); - - //stub->cpu_ctl->unstall( stub->cpu_ctl->data); - //stub->cpu_ctl->remove_post_ex_fn( stub->cpu_ctl->data); - - free( stub); -} - -void -activateStub_gdb( gdbstub_handle_t instance, - struct armcpu_ctrl_iface *cpu_ctrl) { - struct gdb_stub_state *stub = (struct gdb_stub_state *)instance; - - stub->cpu_ctrl = cpu_ctrl; - - /* stall the cpu */ - stub->cpu_ctrl->stall( stub->cpu_ctrl->data); - - stub->active = 1; -} +/* $Id: gdbstub.c,v 1.1 2007-06-07 09:43:25 masscat Exp $ + */ +/* + * THE SOFTWARE WITHIN THIS FILE IS NOT COPYRIGHTED + * + * Originally written by Ben Jaques. + * + * The software is offered for use in the public domain in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ +#include +//#include +#include +#include + +#include + +#ifdef WIN32 +#include +#else +#include +#include +#include +#include +#include +#endif + +#include "armcpu.h" + +#define uint32_t u32 +#define uint16_t u16 +#define uint8_t u8 + +#include "gdbstub.h" +#include "gdbstub_internal.h" + +#ifdef __GNUC__ +#define UNUSED_PARM( parm) parm __attribute__((unused)) +#else +#define UNUSED_PARM( parm) parm +#endif + +#if 0 +#define DEBUG_LOG( fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__) +#else +#define DEBUG_LOG( fmt, ...) +#endif + +#if 0 +#define LOG_ERROR( fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__) +#else +#define LOG_ERROR( fmt, ...) +#endif + +#define LITTLE_ENDIAN_TO_UINT32_T( v) (\ + ((v)[3] << 24) | \ + ((v)[2] << 16) | \ + ((v)[1] << 8) | \ + ((v)[0] << 0)) + +/* + * The state of the packet reader + */ +#define IDLE_READ_STATE 0 +#define MID_PACKET_READ_STATE 1 +#define FIRST_CHECKSUM_READ_STATE 2 +#define SECOND_CHECKSUM_READ_STATE 3 + +/* + * The gdb stub thread control message types. + */ +enum stub_message_type { + /** The quit message type */ + QUIT_STUB_MESSAGE = 0, + /** The emulated CPU has stopped */ + CPU_STOPPED_STUB_MESSAGE = 1 +}; + + +/* + * The GDB signal values + */ +enum target_signal + { + /* Used some places (e.g. stop_signal) to record the concept that + there is no signal. */ + TARGET_SIGNAL_0 = 0, + TARGET_SIGNAL_FIRST = 0, + TARGET_SIGNAL_HUP = 1, + TARGET_SIGNAL_INT = 2, + TARGET_SIGNAL_QUIT = 3, + TARGET_SIGNAL_ILL = 4, + TARGET_SIGNAL_TRAP = 5, + TARGET_SIGNAL_ABRT = 6, + TARGET_SIGNAL_EMT = 7, + TARGET_SIGNAL_FPE = 8, + TARGET_SIGNAL_KILL = 9, + TARGET_SIGNAL_BUS = 10, + TARGET_SIGNAL_SEGV = 11, + TARGET_SIGNAL_SYS = 12, + TARGET_SIGNAL_PIPE = 13, + TARGET_SIGNAL_ALRM = 14, + TARGET_SIGNAL_TERM = 15, + TARGET_SIGNAL_URG = 16, + TARGET_SIGNAL_STOP = 17, + TARGET_SIGNAL_TSTP = 18, + TARGET_SIGNAL_CONT = 19, + TARGET_SIGNAL_CHLD = 20, + TARGET_SIGNAL_TTIN = 21, + TARGET_SIGNAL_TTOU = 22, + TARGET_SIGNAL_IO = 23, + TARGET_SIGNAL_XCPU = 24, + TARGET_SIGNAL_XFSZ = 25, + TARGET_SIGNAL_VTALRM = 26, + TARGET_SIGNAL_PROF = 27, + TARGET_SIGNAL_WINCH = 28, + TARGET_SIGNAL_LOST = 29, + TARGET_SIGNAL_USR1 = 30, + TARGET_SIGNAL_USR2 = 31, + TARGET_SIGNAL_PWR = 32, + /* Similar to SIGIO. Perhaps they should have the same number. */ + TARGET_SIGNAL_POLL = 33, + TARGET_SIGNAL_WIND = 34, + TARGET_SIGNAL_PHONE = 35, + TARGET_SIGNAL_WAITING = 36, + TARGET_SIGNAL_LWP = 37, + TARGET_SIGNAL_DANGER = 38, + TARGET_SIGNAL_GRANT = 39, + TARGET_SIGNAL_RETRACT = 40, + TARGET_SIGNAL_MSG = 41, + TARGET_SIGNAL_SOUND = 42, + TARGET_SIGNAL_SAK = 43, + TARGET_SIGNAL_PRIO = 44, + }; + + + + + +static void +causeQuit_gdb( struct gdb_stub_state *stub) { + uint8_t command = QUIT_STUB_MESSAGE; + +#ifdef WIN32 + send( stub->ctl_pipe[1], (char*)&command, 1, 0); +#else + write( stub->ctl_pipe[1], &command, 1); +#endif +} + +static void +indicateCPUStop_gdb( struct gdb_stub_state *stub) { + uint8_t command = CPU_STOPPED_STUB_MESSAGE; + +#ifdef WIN32 + send( stub->ctl_pipe[1], (char*)&command, 1, 0); +#else + write( stub->ctl_pipe[1], &command, 1); +#endif +} + + + + +/* + * + * + * + */ +static void +break_execution( void *data, UNUSED_PARM(uint32_t addr), UNUSED_PARM(int thunmb)) { + struct gdb_stub_state *stub = (struct gdb_stub_state *)data; + + /* stall the processor */ + stub->cpu_ctrl->stall( stub->cpu_ctrl->data); + + /* remove the post execution function */ + stub->cpu_ctrl->remove_post_ex_fn( stub->cpu_ctrl->data); + + /* indicate the halt */ + stub->stop_type = STOP_HOST_BREAK; + indicateCPUStop_gdb( stub); +} + + +static void +step_instruction_watch( void *data, uint32_t addr, UNUSED_PARM(int thunmb)) { + struct gdb_stub_state *stub = (struct gdb_stub_state *)data; + + DEBUG_LOG("Step watch: waiting for %08x at %08x\n", stub->step_instr_address, + addr); + + if ( addr == stub->step_instr_address) { + DEBUG_LOG("Step hit -> %08x\n", stub->cpu_ctrl->read_reg( stub->cpu_ctrl->data, 15)); + /* stall the processor */ + stub->cpu_ctrl->stall( stub->cpu_ctrl->data); + + /* remove the post execution function */ + stub->cpu_ctrl->remove_post_ex_fn( stub->cpu_ctrl->data); + + /* indicate the halt */ + stub->stop_type = STOP_STEP_BREAK; + indicateCPUStop_gdb( stub); + } +} + + + + + +/************************************************************************/ +/* BUFMAX defines the maximum number of characters in inbound/outbound buffers*/ +/* at least NUMREGBYTES*2 are needed for register packets */ +#define BUFMAX 2048 + + + +static const char hexchars[]="0123456789abcdef"; + +/* + * Convert ch from a hex digit to an int + */ +static int +hex (unsigned char ch) { + if (ch >= 'a' && ch <= 'f') + return ch-'a'+10; + if (ch >= '0' && ch <= '9') + return ch-'0'; + if (ch >= 'A' && ch <= 'F') + return ch-'A'+10; + return -1; +} + +static const unsigned char * +hex2mem ( const unsigned char *buf, uint8_t *mem, int count) { + int i; + unsigned char ch; + + for (i=0; i 0) + { + ch = memio->read8( memio->data, mem_addr++); + *buf++ = hexchars[ch >> 4]; + *buf++ = hexchars[ch & 0xf]; + } + + *buf = 0; + + return buf; +} + + + +static enum read_res_gdb +readPacket_gdb( SOCKET_TYPE sock, struct packet_reader_gdb *packet) { + uint8_t cur_byte; + enum read_res_gdb read_res = READ_NOT_FINISHED; + int sock_res; + + /* update the state */ + + while ( (sock_res = recv( sock, (char*)&cur_byte, 1, 0)) == 1) { + switch ( packet->state) { + case IDLE_READ_STATE: + /* wait for the '$' start of packet character + */ + if ( cur_byte == '$') { + //DEBUG_LOG( "Found packet\n"); + packet->state = MID_PACKET_READ_STATE; + packet->pos_index = 0; + packet->checksum = 0; + } + /* Is this the break command */ + else if ( cur_byte == 3) { + //DEBUG_LOG( "GDB has sent a break\n"); + packet->buffer[0] = cur_byte; + packet->buffer[1] = 0; + packet->pos_index = 1; + return READ_BREAK; + } + break; + + case MID_PACKET_READ_STATE: + if ( cur_byte == '#') { + //DEBUG_LOG( "\nAbout to get checksum\n"); + packet->buffer[packet->pos_index] = '\0'; + packet->state = FIRST_CHECKSUM_READ_STATE; + } + else if ( packet->pos_index >= BUFMAX - 1) { + //DEBUG_LOG( "read buffer exceeded\n"); + packet->state = IDLE_READ_STATE; + } + else { + //DEBUG_LOG( "%c", cur_byte); + packet->checksum = packet->checksum + cur_byte; + packet->buffer[packet->pos_index] = cur_byte; + packet->pos_index = packet->pos_index + 1; + } + break; + + case FIRST_CHECKSUM_READ_STATE: + packet->read_checksum = hex( cur_byte) << 4; + packet->state = SECOND_CHECKSUM_READ_STATE; + break; + + case SECOND_CHECKSUM_READ_STATE: { + packet->read_checksum += hex( cur_byte); + packet->state = IDLE_READ_STATE; + return READ_COMPLETE; + break; + } + } + } + + if ( sock_res == 0) { + read_res = READ_SOCKET_ERROR; + } + else if ( sock_res == -1) { + if ( errno != EAGAIN) { + read_res = READ_SOCKET_ERROR; + } + } + + return read_res; +} + + +struct hidden_debug_out_packet { + unsigned char *start_ptr; +}; +struct debug_out_packet { + unsigned char *const start_ptr; +}; + +static struct hidden_debug_out_packet the_out_packet; +static unsigned char hidden_buffer[BUFMAX]; + + +static struct debug_out_packet * +getOutPacket( void) { + the_out_packet.start_ptr = &hidden_buffer[1]; + return (struct debug_out_packet *)&the_out_packet; +} + +#define CHECKSUM_PART_SIZE 3 +/** + * send the packet in buffer. + */ +static int +putpacket ( SOCKET_TYPE sock, struct debug_out_packet *out_packet, uint32_t size) { + unsigned char checksum = 0; + uint32_t count; + unsigned char *ch_ptr = (unsigned char *)&out_packet->start_ptr[-1]; + uint8_t reply_ch; + + //DEBUG_LOG_START( "Putting packet size %d ", size); + /* add the '$' to the start of the packet */ + *ch_ptr++ = '$'; + + /* calculate and add the checksum to the packet */ + for ( count = 0; count < size; count += 1) { + checksum += ch_ptr[count]; + //DEBUG_LOG_PART("%c", ch_ptr[count]); + } + //DEBUG_LOG_PART("\n"); + + ch_ptr[count++] = '#'; + ch_ptr[count++] = hexchars[checksum >> 4]; + ch_ptr[count++] = hexchars[checksum & 0xf]; + ch_ptr[count] = '\0'; + //DEBUG_LOG("packet %s\n", &out_packet->start_ptr[-1]); + + /* add one for the '$' character */ + count += 1; + + do { + int reply_found = 0; + + send( sock, (char*)&out_packet->start_ptr[-1], count, 0); + + do { + int read_res = recv( sock, (char*)&reply_ch, 1, 0); + + if ( read_res == 0) { + return -1; + } + else if ( read_res == -1) { + if ( errno != EAGAIN) { + return -1; + } + } + else { + reply_found = 1; + } + } while ( !reply_found); + } while ( reply_ch != '+'); + + /* $#. */ + return count - 4; +} + + + +static uint32_t +make_stop_packet( uint8_t *ptr, enum stop_type type, uint32_t stop_address) { + uint32_t stop_size = 0; + int watch_index = 0; + const char watch_chars[] = { 'a', 'r' }; + + switch (type) { + case STOP_UNKNOWN: + case STOP_HOST_BREAK: + ptr[0] = 'S'; + ptr[1] = hexchars[TARGET_SIGNAL_INT >> 4]; + ptr[2] = hexchars[TARGET_SIGNAL_INT & 0xf]; + stop_size = 3; + break; + + case STOP_STEP_BREAK: + case STOP_BREAKPOINT: + ptr[0] = 'S'; + ptr[1] = hexchars[TARGET_SIGNAL_TRAP >> 4]; + ptr[2] = hexchars[TARGET_SIGNAL_TRAP & 0xf]; + stop_size = 3; + break; + + case STOP_WATCHPOINT: + watch_index = 1; + case STOP_RWATCHPOINT: + watch_index += 1; + case STOP_AWATCHPOINT: + { + int i; + int out_index = 0; + ptr[out_index++] = 'T'; + ptr[out_index++] = hexchars[TARGET_SIGNAL_ABRT >> 4]; + ptr[out_index++] = hexchars[TARGET_SIGNAL_ABRT & 0xf]; + + if ( watch_index < 2) { + ptr[out_index++] = watch_chars[watch_index]; + } + ptr[out_index++] = 'w'; + ptr[out_index++] = 'a'; + ptr[out_index++] = 't'; + ptr[out_index++] = 'c'; + ptr[out_index++] = 'h'; + ptr[out_index++] = ':'; + + for ( i = 0; i < 8; i++) { + ptr[out_index++] = hexchars[(stop_address >> (i * 4)) & 0xf]; + } + ptr[out_index++] = ';'; + + stop_size = out_index; + } + break; + } + + return stop_size; +} + +/** + * Returns -1 if there is a socket error. + */ +static int +processPacket_gdb( SOCKET_TYPE sock, const uint8_t *packet, + struct gdb_stub_state *stub) { + // uint8_t remcomOutBuffer[BUFMAX_GDB]; + struct debug_out_packet *out_packet = getOutPacket(); + uint8_t *out_ptr = out_packet->start_ptr; + int send_reply = 1; + uint32_t send_size = 0; + + DEBUG_LOG("Processing packet %c\n", packet[0]); + + switch( packet[0]) { + case 3: + /* The break command */ + //stub->running_state = gdb_stub_state::STOPPED_GDB_STATE; + //*ptr++ = 'S'; + //*ptr++ = hexchars[0x2 >> 4]; + //*ptr++ = hexchars[0x2 & 0xf]; + //*ptr++ = 0; + send_reply = 0; + break; + + case '?': + send_size = make_stop_packet( out_ptr, stub->stop_type, stub->stop_address); + /**ptr++ = 'S'; + *ptr++ = hexchars[stub->stop_reason >> 4]; + *ptr++ = hexchars[stub->stop_reason & 0xf]; + send_size = 3;*/ + break; + + case 'c': + stub->emu_stub_state = gdb_stub_state::RUNNING_EMU_GDB_STATE; + stub->ctl_stub_state = gdb_stub_state::START_RUN_GDB_STATE; + stub->main_stop_flag = 0; + send_reply = 0; + /* remove the cpu stall */ + stub->cpu_ctrl->unstall( stub->cpu_ctrl->data); + break; + + case 's': { + uint32_t instr_addr = stub->cpu_ctrl->read_reg( stub->cpu_ctrl->data, 15); + /* Determine where the next instruction will take the CPU. + * Execute the instruction using a copy of the CPU with a zero memory interface. + */ + DEBUG_LOG( "Stepping instruction at %08x\n", instr_addr); + + /* install the post execution function */ + stub->step_instr_address = instr_addr; + stub->cpu_ctrl->install_post_ex_fn( stub->cpu_ctrl->data, + step_instruction_watch, + stub); + + + stub->emu_stub_state = gdb_stub_state::RUNNING_EMU_GDB_STATE; + stub->ctl_stub_state = gdb_stub_state::START_RUN_GDB_STATE; + stub->main_stop_flag = 0; + send_reply = 0; + + /* remove the cpu stall */ + stub->cpu_ctrl->unstall( stub->cpu_ctrl->data); + break; + } + + /* + * Register set + */ + case 'P': { + uint32_t reg; + uint32_t value; + const uint8_t *rx_ptr = &packet[1]; + + DEBUG_LOG("Processing packet %s\n", packet); + if ( hexToInt( &rx_ptr, ®)) { + if ( *rx_ptr++ == '=') { + uint8_t tmp_mem[4]; + + rx_ptr = hex2mem( rx_ptr, tmp_mem, 4); + value = LITTLE_ENDIAN_TO_UINT32_T( tmp_mem); + DEBUG_LOG("Setting reg %d to %08x\n", reg, value); + if ( reg < 16) + stub->cpu_ctrl->set_reg( stub->cpu_ctrl->data, reg, value); + if ( reg == 25) { + stub->cpu_ctrl->set_reg( stub->cpu_ctrl->data, 16, value); + } + + strcpy( (char *)out_ptr, "OK"); + send_size = 2; + } + } + break; + } + + case 'm': { + uint32_t addr = 0; + uint32_t length = 0; + int error01 = 1; + const uint8_t *rx_ptr = &packet[1]; + + if ( hexToInt( &rx_ptr, &addr)) { + if ( *rx_ptr++ == ',') { + if ( hexToInt( &rx_ptr, &length)) { + //DEBUG_LOG("mem read from %08x (%d)\n", addr, length); + if ( !mem2hex( stub->direct_memio, addr, out_ptr, length)) { + strcpy ( (char *)out_ptr, "E03"); + send_size = 3; + } + else { + send_size = length * 2; + } + error01 = 0; + } + } + } + if ( error01) + strcpy( (char *)out_ptr,"E01"); + break; + } + + /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */ + case 'M': { + /* Try to read '%x,%x:'. */ + const uint8_t *rx_ptr = &packet[1]; + uint32_t addr = 0; + uint32_t length = 0; + int error01 = 1; + DEBUG_LOG("Memory write %s\n", rx_ptr); + if ( hexToInt(&rx_ptr, &addr)) { + if ( *rx_ptr++ == ',') { + if ( hexToInt(&rx_ptr, &length)) { + if ( *rx_ptr++ == ':') { + uint8_t write_byte; + unsigned int i; + DEBUG_LOG("Memory write of %d bytes to %08x\n", + length, addr); + + for ( i = 0; i < length; i++) { + rx_ptr = hex2mem( rx_ptr, &write_byte, 1); + + stub->direct_memio->write8( stub->direct_memio->data, + addr++, write_byte); + } + + strcpy( (char *)out_ptr, "OK"); + error01 = 0; + } + } + else { + DEBUG_LOG("Failed to find length (addr %08x)\n", addr); + } + } + else { + DEBUG_LOG("expected ',' got '%c' (addr = %08x)\n", *rx_ptr, addr); + } + } + else { + DEBUG_LOG("Failed to find addr\n"); + } + + if ( error01) { + strcpy( (char *)out_ptr, "E02"); + } + break; + } + + case 'Z': + case 'z': { + const uint8_t *rx_ptr = &packet[2]; + int remove_flag = 0; + + if ( packet[0] == 'z') + remove_flag = 1; + + DEBUG_LOG( "%c%c packet %s (remove? %d)\n", packet[0], packet[1], + rx_ptr, remove_flag); + + switch ( packet[1]) { + + /* all instruction breakpoints are treated the same */ + case '0': + case '1': + case '2': + case '3': + case '4': + { + uint32_t addr = 0; + uint32_t length = 0; + int error01 = 1; + struct breakpoint_gdb **bpoint_list; + + switch ( packet[1]) { + case '0': + case '1': + bpoint_list = &stub->instr_breakpoints; + break; + + case '2': + bpoint_list = &stub->write_breakpoints; + break; + + case '3': + bpoint_list = &stub->read_breakpoints; + break; + + case '4': + bpoint_list = &stub->access_breakpoints; + break; + } + + if ( *rx_ptr++ == ',') { + DEBUG_LOG("%s\n", rx_ptr); + + if ( hexToInt( &rx_ptr, &addr)) { + if ( *rx_ptr++ == ',') { + DEBUG_LOG("addr %08x %s\n", addr, rx_ptr); + + if ( hexToInt( &rx_ptr, &length)) { + if ( remove_flag) { + int removed = 0; + struct breakpoint_gdb *last_bpoint = NULL; + struct breakpoint_gdb *bpoint = *bpoint_list; + + while ( bpoint != NULL && !removed) { + if ( bpoint->addr == addr) { + DEBUG_LOG("Breakpoint(%c) at %08x removed\n", packet[1], addr); + removed = 1; + + if ( last_bpoint == NULL) { + *bpoint_list = bpoint->next; + } + else { + last_bpoint->next = bpoint->next; + } + bpoint->next = stub->free_breakpoints; + stub->free_breakpoints = bpoint; + } + last_bpoint = bpoint; + bpoint = bpoint->next; + } + + strcpy( (char *)out_ptr, "OK"); + send_size = 2; + error01 = 0; + } + else { + /* get a breakpoint descriptor from the free pool and add it to + * the current stub instruction breakpoint list */ + struct breakpoint_gdb *bpoint = stub->free_breakpoints; + + if ( bpoint != NULL) { + DEBUG_LOG( "Breakpoint(%c) added at %08x length %d\n", + packet[1], addr, length); + stub->free_breakpoints = bpoint->next; + + bpoint->addr = addr; + bpoint->size = length; + + bpoint->next = *bpoint_list; + *bpoint_list = bpoint; + + strcpy( (char *)out_ptr, "OK"); + send_size = 2; + error01 = 0; + } + } + } + } + } + } + + if ( error01) { + strcpy( (char *)out_ptr, "E01"); + send_size = 3; + } + } + break; + + default: + break; + } + break; + } + + /* + * Set the register values + */ + case 'G': + { + int i; + const uint8_t *rx_ptr = &packet[1]; + uint32_t reg_values[16]; + uint32_t cpsr; + uint8_t tmp_mem[4]; + DEBUG_LOG("'G' command %s\n", rx_ptr); + + /* general purpose regs 0 to 15 */ + for ( i = 0; i < 16; i++) { + rx_ptr = hex2mem( rx_ptr, tmp_mem, 4); + + reg_values[i] = LITTLE_ENDIAN_TO_UINT32_T( tmp_mem); + DEBUG_LOG("Setting reg %d to %08x\n", i, reg_values[i]); + } + + /* skip the floaing point registers and floating point status register */ + rx_ptr += 8 * (96 / 8 * 2); + rx_ptr += 8; + + /* the CPSR register is last */ + rx_ptr = hex2mem( rx_ptr, tmp_mem, 4); + cpsr = LITTLE_ENDIAN_TO_UINT32_T( tmp_mem); + DEBUG_LOG("Setting cpsr to %08x\n", cpsr); + + strcpy( (char *)out_ptr, "OK"); + send_size = 2; + break; + } + + case 'g': /* return the value of the CPU registers */ + { + int i; + int out_index = 0; + uint32_t pc_value = stub->cpu_ctrl->read_reg( stub->cpu_ctrl->data, 15); + uint32_t cpsr_value = stub->cpu_ctrl->read_reg( stub->cpu_ctrl->data, 16); + + DEBUG_LOG("'g' command PC = %08x\n", pc_value); + + /* general purpose regs 0 to 14 */ + for ( i = 0; i < 15; i++) { + uint32_t reg = stub->cpu_ctrl->read_reg( stub->cpu_ctrl->data, i); + out_ptr[out_index++] = hexchars[(reg >> 4) & 0xf]; + out_ptr[out_index++] = hexchars[(reg >> 0) & 0xf]; + out_ptr[out_index++] = hexchars[(reg >> 12) & 0xf]; + out_ptr[out_index++] = hexchars[(reg >> 8) & 0xf]; + out_ptr[out_index++] = hexchars[(reg >> 20) & 0xf]; + out_ptr[out_index++] = hexchars[(reg >> 16) & 0xf]; + out_ptr[out_index++] = hexchars[(reg >> 28) & 0xf]; + out_ptr[out_index++] = hexchars[(reg >> 24) & 0xf]; + } + + out_ptr[out_index++] = hexchars[(pc_value >> 4) & 0xf]; + out_ptr[out_index++] = hexchars[(pc_value >> 0) & 0xf]; + out_ptr[out_index++] = hexchars[(pc_value >> 12) & 0xf]; + out_ptr[out_index++] = hexchars[(pc_value >> 8) & 0xf]; + out_ptr[out_index++] = hexchars[(pc_value >> 20) & 0xf]; + out_ptr[out_index++] = hexchars[(pc_value >> 16) & 0xf]; + out_ptr[out_index++] = hexchars[(pc_value >> 28) & 0xf]; + out_ptr[out_index++] = hexchars[(pc_value >> 24) & 0xf]; + + /* floating point registers (8 96bit) */ + for ( i = 0; i < 8; i++) { + int j; + for ( j = 0; j < (96/4); j++) { + out_ptr[out_index++] = '0'; + } + } + + /* floating point status register? */ + for ( i = 0; i < 1; i++) { + int j; + for ( j = 0; j < 8; j++) { + out_ptr[out_index++] = '0'; + } + } + + /* The CPSR */ + for ( i = 0; i < 1; i++) { + out_ptr[out_index++] = hexchars[(cpsr_value >> 4) & 0xf]; + out_ptr[out_index++] = hexchars[(cpsr_value >> 0) & 0xf]; + out_ptr[out_index++] = hexchars[(cpsr_value >> 12) & 0xf]; + out_ptr[out_index++] = hexchars[(cpsr_value >> 8) & 0xf]; + out_ptr[out_index++] = hexchars[(cpsr_value >> 20) & 0xf]; + out_ptr[out_index++] = hexchars[(cpsr_value >> 16) & 0xf]; + out_ptr[out_index++] = hexchars[(cpsr_value >> 28) & 0xf]; + out_ptr[out_index++] = hexchars[(cpsr_value >> 24) & 0xf]; + } + send_size = out_index; + } + break; + } + + if ( send_reply) { + return putpacket( sock, out_packet, send_size); + } + + return 0; +} + + + +/** + * create the listening socket + */ +static SOCKET_TYPE +createSocket ( int port) { + SOCKET_TYPE sock; + struct sockaddr_in bind_addr; + + memset (&bind_addr, 0, sizeof (bind_addr)); + bind_addr.sin_family = AF_INET; + bind_addr.sin_port = htons( port); + bind_addr.sin_addr.s_addr = htonl (INADDR_ANY); + + /* create the socket, bind the address */ + + sock = socket (PF_INET, SOCK_STREAM, 0); + +#ifdef WIN32 + if ( sock != INVALID_SOCKET) +#else + if (sock != -1) +#endif + { + if (bind (sock, (struct sockaddr *) &bind_addr, + sizeof (bind_addr)) == -1) { + LOG_ERROR("Bind failed \"%s\" port %d\n", strerror( errno), port); +#ifdef WIN32 + closesocket( sock); +#else + close (sock); +#endif + sock = -1; + } + else if (listen (sock, 5) == -1) { + LOG_ERROR("Listen failed \"%s\"\n", strerror( errno)); +#ifdef WIN32 + closesocket( sock); +#else + close (sock); +#endif + sock = -1; + } + } + else { +#ifdef WIN32 + char message[30]; + int error = WSAGetLastError(); + sprintf( message, "Error creating socket %d\n", error); + LOG_ERROR("Error creating socket %d\n", error); +#endif + } + + return sock; +} + + + + +/* + * Handle GDB stub connections. + */ + + +/** + */ +INLINE static int +check_breaks_gdb( struct gdb_stub_state *gdb_state, + struct breakpoint_gdb *bpoint_list, + uint32_t addr, + UNUSED_PARM(uint32_t size), + enum stop_type stop_type) { + int found_break = 0; + + if ( gdb_state->active) { + struct breakpoint_gdb *bpoint = bpoint_list; + + while ( bpoint != NULL && !found_break) { + if ( addr == bpoint->addr) { + DEBUG_LOG("Breakpoint hit at %08x\n", addr); + + /* stall the processor */ + gdb_state->cpu_ctrl->stall( gdb_state->cpu_ctrl->data); + + /* indicate the break to the GDB stub thread */ + gdb_state->stop_type = stop_type; + gdb_state->stop_address = addr; + indicateCPUStop_gdb( gdb_state); + } + bpoint = bpoint->next; + } + } + + return found_break; +} + +static void +WINAPI listenerThread_gdb( void *data) { + struct gdb_stub_state *state = (struct gdb_stub_state *)data; + fd_set read_sock_set; + fd_set main_set; + int quit = 0; + + FD_ZERO( &main_set); + + FD_SET( state->listen_fd, &main_set); + FD_SET( state->ctl_pipe[0], &main_set); + + while (!quit) { + int sel_res; + + read_sock_set = main_set; + + //DEBUG_LOG("Waiting on sockets\n"); + + sel_res = select( FD_SETSIZE, &read_sock_set, NULL, NULL, NULL); + //DEBUG_LOG("sockets ready %d\n", sel_res); + + if ( sel_res > 0) { + + /* Is this a control message */ + if ( FD_ISSET( state->ctl_pipe[0], &read_sock_set)) { + uint8_t ctl_command; + + //DEBUG_LOG("Control message\n"); +#ifdef WIN32 + recv( state->ctl_pipe[0], (char*)&ctl_command, 1, 0); +#else + read( state->ctl_pipe[0], (char*)&ctl_command, 1); +#endif + + switch ( ctl_command) { + + case CPU_STOPPED_STUB_MESSAGE: + if ( state->active && + state->ctl_stub_state != gdb_stub_state::STOPPED_GDB_STATE) { + struct debug_out_packet *out_packet = getOutPacket(); + uint8_t *ptr = out_packet->start_ptr; + uint32_t send_size; + + /* mark the stub as stopped and send the stop packet */ + state->ctl_stub_state = gdb_stub_state::STOPPED_GDB_STATE; + state->main_stop_flag = 1; + + send_size = make_stop_packet( ptr, state->stop_type, state->stop_address); + + /*ptr[0] = 'S'; + ptr[1] = hexchars[state->stop_reason >> 4]; + ptr[2] = hexchars[state->stop_reason & 0xf];*/ + + putpacket( state->sock_fd, out_packet, send_size); + DEBUG_LOG( "\nBreak from Emulation\n"); + } + else { + LOG_ERROR( "Asked to stop and already stopped\n"); + } + break; + + default: + /* quit out */ + quit = 1; + break; + } + } + + else { + //struct armcpu_t *cpu = twin_states->cpus[i]; + SOCKET_TYPE arm_listener = state->listen_fd; + + /* check for a connection request */ + if ( FD_ISSET( arm_listener, &read_sock_set)) { + SOCKET_TYPE new_conn; + struct sockaddr_in gdb_addr; +#ifdef WIN32 + int addr_size = sizeof( gdb_addr); +#else + socklen_t addr_size = sizeof( gdb_addr); +#endif + + //DEBUG_LOG("listener\n"); + + /* accept the connection if we do not already have one */ + new_conn = accept( arm_listener, (struct sockaddr *)&gdb_addr, + &addr_size); + + if ( new_conn != -1) { + int close_sock = 1; + + //DEBUG_LOG("got new socket\n"); + if ( state->sock_fd == -1 && state->active) { +#ifdef WIN32 + BOOL nodelay_opt = 1; +#else + int nodelay_opt = 1; +#endif + int set_res; + + //DEBUG_LOG("new connection\n"); + + close_sock = 0; + /* make the socket NODELAY */ +#ifdef WIN32 + set_res = setsockopt( new_conn, IPPROTO_TCP, TCP_NODELAY, + (char*)&nodelay_opt, sizeof( nodelay_opt)); +#else + set_res = setsockopt( new_conn, IPPROTO_TCP, TCP_NODELAY, + &nodelay_opt, sizeof( nodelay_opt)); +#endif + + if ( set_res != 0) { + LOG_ERROR( "Failed to set NODELAY socket option \"%s\"\n", strerror( errno)); + } + + FD_SET( new_conn, &main_set); + state->sock_fd = new_conn; + } + + if ( close_sock) { + //DEBUG_LOG("closing new socket\n"); +#ifdef WIN32 + closesocket( new_conn); +#else + close( new_conn); +#endif + } + } + } + + /* handle the gdb connection */ + if ( state->sock_fd != -1 && state->active) { + SOCKET_TYPE gdb_sock = state->sock_fd; + if ( FD_ISSET( gdb_sock, &read_sock_set)) { + enum read_res_gdb read_res = readPacket_gdb( gdb_sock, &state->rx_packet); + + //DEBUG_LOG("socket read %d\n", read_res); + + switch ( read_res) { + case READ_NOT_FINISHED: + /* do nothing here */ + break; + + case READ_SOCKET_ERROR: + /* close the socket */ +#ifdef WIN32 + closesocket( gdb_sock); +#else + close( gdb_sock); +#endif + state->sock_fd = -1; + FD_CLR( gdb_sock, &main_set); + break; + + case READ_BREAK: { + /* break the running of the cpu */ + if ( state->ctl_stub_state != gdb_stub_state::STOPPED_GDB_STATE) { + /* this will cause the emulation to break the execution */ + DEBUG_LOG( "Breaking execution\n"); + + /* install the post execution function */ + state->cpu_ctrl->install_post_ex_fn( state->cpu_ctrl->data, + break_execution, + state); + } + break; + } + + case READ_COMPLETE: { + uint8_t reply; + int write_res; + int process_packet = 0; + int close_socket = 0; + struct packet_reader_gdb *packet = &state->rx_packet; + + if ( state->ctl_stub_state != gdb_stub_state::STOPPED_GDB_STATE) { + /* not ready to process packet yet, send a bad reply */ + reply = '-'; + } + else { + /* send a reply based on the checksum and if okay process the packet */ + if ( packet->read_checksum == packet->checksum) { + reply = '+'; + process_packet = 1; + } + else { + reply = '-'; + } + } + + write_res = send( gdb_sock, (char*)&reply, 1, 0); + + if ( write_res != 1) { + close_socket = 1; + } + else { + if ( processPacket_gdb( gdb_sock, state->rx_packet.buffer, + state) == -1) { + close_socket = 1; + } + } + + if ( close_socket) { +#ifdef WIN32 + closesocket( gdb_sock); +#else + close( gdb_sock); +#endif + state->sock_fd = -1; + FD_CLR( gdb_sock, &main_set); + } + break; + } + } + } + } + } + } + } + + + /* tidy up and leave */ + if ( state->sock_fd != -1) { +#ifdef WIN32 + closesocket( state->sock_fd); +#else + close( state->sock_fd); +#endif + } + + /* close the listenering sockets */ +#ifdef WIN32 + closesocket( state->listen_fd); +#else + close( state->listen_fd); +#endif + + return; +} + + + + +/* + * + * The memory interface + * + */ +static uint32_t FASTCALL +gdb_prefetch32( void *data, uint32_t adr) { + struct gdb_stub_state *stub = (struct gdb_stub_state *)data; + uint32_t value = 0; + int breakpoint; + + breakpoint = check_breaks_gdb( stub, stub->instr_breakpoints, adr, 4, + STOP_BREAKPOINT); + + if ( !breakpoint) { + /* pass down to the real memory interace */ + value = stub->real_cpu_memio->prefetch32( stub->real_cpu_memio->data, + adr); + } + + return value; +} +static uint16_t FASTCALL +gdb_prefetch16( void *data, uint32_t adr) { + struct gdb_stub_state *stub = (struct gdb_stub_state *)data; + uint16_t value = 0; + int breakpoint; + + breakpoint = check_breaks_gdb( stub, stub->instr_breakpoints, adr, 2, + STOP_BREAKPOINT); + + if ( !breakpoint) { + /* pass down to the real memory interace */ + value = stub->real_cpu_memio->prefetch16( stub->real_cpu_memio->data, + adr); + } + + return value; +} + +/** read 8 bit data value */ +static uint8_t FASTCALL +gdb_read8( void *data, uint32_t adr) { + struct gdb_stub_state *stub = (struct gdb_stub_state *)data; + uint8_t value = 0; + int breakpoint; + + /* pass down to the real memory interace */ + value = stub->real_cpu_memio->read8( stub->real_cpu_memio->data, + adr); + + breakpoint = check_breaks_gdb( stub, stub->read_breakpoints, adr, 1, + STOP_RWATCHPOINT); + if ( !breakpoint) + check_breaks_gdb( stub, stub->access_breakpoints, adr, 1, + STOP_AWATCHPOINT); + + return value; +} + +/** read 16 bit data value */ +static uint16_t FASTCALL +gdb_read16( void *data, uint32_t adr) { + struct gdb_stub_state *stub = (struct gdb_stub_state *)data; + uint16_t value; + int breakpoint; + + /* pass down to the real memory interace */ + value = stub->real_cpu_memio->read16( stub->real_cpu_memio->data, + adr); + + breakpoint = check_breaks_gdb( stub, stub->read_breakpoints, adr, 2, + STOP_RWATCHPOINT); + if ( !breakpoint) + check_breaks_gdb( stub, stub->access_breakpoints, adr, 2, + STOP_AWATCHPOINT); + + return value; +} +/** read 32 bit data value */ +static uint32_t FASTCALL +gdb_read32( void *data, uint32_t adr) { + struct gdb_stub_state *stub = (struct gdb_stub_state *)data; + uint32_t value; + int breakpoint; + + /* pass down to the real memory interace */ + value = stub->real_cpu_memio->read32( stub->real_cpu_memio->data, + adr); + + breakpoint = check_breaks_gdb( stub, stub->read_breakpoints, adr, 4, + STOP_RWATCHPOINT); + if ( !breakpoint) + check_breaks_gdb( stub, stub->access_breakpoints, adr, 4, + STOP_AWATCHPOINT); + + return value; +} + +/** write 8 bit data value */ +static void FASTCALL +gdb_write8( void *data, uint32_t adr, uint8_t val) { + struct gdb_stub_state *stub = (struct gdb_stub_state *)data; + int breakpoint; + + /* pass down to the real memory interace */ + stub->real_cpu_memio->write8( stub->real_cpu_memio->data, + adr, val); + + breakpoint = check_breaks_gdb( stub, stub->write_breakpoints, adr, 1, + STOP_WATCHPOINT); + if ( !breakpoint) + check_breaks_gdb( stub, stub->access_breakpoints, adr, 1, + STOP_AWATCHPOINT); +} + +/** write 16 bit data value */ +static void FASTCALL +gdb_write16( void *data, uint32_t adr, uint16_t val) { + struct gdb_stub_state *stub = (struct gdb_stub_state *)data; + int breakpoint; + + /* pass down to the real memory interace */ + stub->real_cpu_memio->write16( stub->real_cpu_memio->data, + adr, val); + + breakpoint = check_breaks_gdb( stub, stub->write_breakpoints, adr, 2, + STOP_WATCHPOINT); + if ( !breakpoint) + check_breaks_gdb( stub, stub->access_breakpoints, adr, 2, + STOP_AWATCHPOINT); +} + +/** write 32 bit data value */ +static void FASTCALL +gdb_write32( void *data, uint32_t adr, uint32_t val) { + struct gdb_stub_state *stub = (struct gdb_stub_state *)data; + int breakpoint; + + /* pass down to the real memory interace */ + stub->real_cpu_memio->write32( stub->real_cpu_memio->data, + adr, val); + + breakpoint = check_breaks_gdb( stub, stub->write_breakpoints, adr, 4, + STOP_WATCHPOINT); + if ( !breakpoint) + check_breaks_gdb( stub, stub->access_breakpoints, adr, 4, + STOP_AWATCHPOINT); +} + + + + + + + +#ifdef WIN32 +struct socket_creator_data { + SOCKET_TYPE *sock; + int port_num; +}; +/** + */ +static DWORD WINAPI +control_creator( LPVOID lpParameter) +{ + struct socket_creator_data *my_data = (struct socket_creator_data *)lpParameter; + + *my_data->sock = socket( PF_INET, SOCK_STREAM, 0); + + if ( *my_data->sock != INVALID_SOCKET) { + int connect_res; + struct sockaddr_in clientService; + + clientService.sin_family = AF_INET; + clientService.sin_addr.s_addr = inet_addr( "127.0.0.1" ); + clientService.sin_port = htons( my_data->port_num); + + connect_res = connect( *my_data->sock, (SOCKADDR*) &clientService, sizeof(clientService)); + + if ( connect_res == SOCKET_ERROR) { + LOG_ERROR( "Failed to connect to socket\n"); + } + } + + return 0; +} + +#endif + + + +/** + */ +gdbstub_handle_t +createStub_gdb( uint16_t port, + struct armcpu_memory_iface **cpu_memio, + struct armcpu_memory_iface *direct_memio) { + struct gdb_stub_state *stub; + gdbstub_handle_t handle = NULL; + int i; + int res = 0; + + stub = (gdb_stub_state*)malloc( sizeof (struct gdb_stub_state)); + if ( stub == NULL) { + return NULL; + } + + stub->active = 0; + + /* keep the memory interfaces */ + stub->real_cpu_memio = *cpu_memio; + stub->direct_memio = direct_memio; + + *cpu_memio = &stub->cpu_memio; + + /* fill in the memory interface */ + stub->cpu_memio.data = stub; + stub->cpu_memio.prefetch32 = gdb_prefetch32; + stub->cpu_memio.prefetch16 = gdb_prefetch16; + + stub->cpu_memio.read8 = gdb_read8; + stub->cpu_memio.read16 = gdb_read16; + stub->cpu_memio.read32 = gdb_read32; + + stub->cpu_memio.write8 = gdb_write8; + stub->cpu_memio.write16 = gdb_write16; + stub->cpu_memio.write32 = gdb_write32; + + + + /* put the breakpoint descriptors onto the free list */ + for ( i = 0; i < BREAKPOINT_POOL_SIZE - 1; i++) { + stub->breakpoint_pool[i].next = &stub->breakpoint_pool[i+1]; + } + stub->breakpoint_pool[i].next = NULL; + stub->free_breakpoints = &stub->breakpoint_pool[0]; + stub->instr_breakpoints = NULL; + + stub->read_breakpoints = NULL; + stub->write_breakpoints = NULL; + stub->access_breakpoints = NULL; + +#ifdef WIN32 + /* initialise the winsock library */ + { + WORD wVersionRequested; + WSADATA wsaData; + int err; + + wVersionRequested = MAKEWORD( 2, 2 ); + + err = WSAStartup( wVersionRequested, &wsaData ); + if ( err != 0 ) { + return NULL; + } + } + + { + struct socket_creator_data temp_data = { + &stub->ctl_pipe[0], + 24689 + }; + SOCKET_TYPE temp_sock = createSocket ( temp_data.port_num); + HANDLE temp_thread = INVALID_HANDLE_VALUE; + DWORD temp_threadID; + + res = -1; + + if ( temp_sock != -1) { + /* create a thread to connect to this socket */ + temp_thread = CreateThread( NULL, 0, control_creator, &temp_data, 0, &temp_threadID); + if ( temp_thread != INVALID_HANDLE_VALUE) { + struct sockaddr_in ignore_addr; + int addr_size = sizeof( ignore_addr); + + stub->ctl_pipe[1] = accept( temp_sock, (struct sockaddr *)&ignore_addr, &addr_size); + + if ( stub->ctl_pipe[1] != INVALID_SOCKET) { + BOOL nodelay_opt = 1; + int set_res; + + /* make the socket NODELAY */ + set_res = setsockopt( stub->ctl_pipe[1], IPPROTO_TCP, TCP_NODELAY, + (char*)&nodelay_opt, sizeof( nodelay_opt)); + if ( set_res == 0) { + closesocket( temp_sock); + res = 0; + } + } + } + } + } + + if ( res != 0) { + LOG_ERROR( "Failed to create control socket\n"); + } +#else + /* create the control pipe */ + res = pipe( stub->ctl_pipe); + + if ( res != 0) { + LOG_ERROR( "Failed to create control pipe \"%s\"\n", strerror( errno)); + } +#endif + else { + stub->active = 1; + stub->emu_stub_state = gdb_stub_state::RUNNING_EMU_GDB_STATE; + stub->ctl_stub_state = gdb_stub_state::STOPPED_GDB_STATE; + stub->rx_packet.state = IDLE_READ_STATE; + + stub->main_stop_flag = 1; + + stub->port_num = port; + stub->sock_fd = -1; + stub->listen_fd = createSocket( port); + + stub->stop_type = STOP_UNKNOWN; + + if ( stub->listen_fd == -1) { + LOG_ERROR( "Failed to create listening socket \"%s\"\n", strerror( errno)); + res = -1; + } + } + + if ( res != -1) { + /* create the listenering thread */ + stub->thread = createThread_gdb( listenerThread_gdb, stub); + + if ( stub->thread == NULL) { + LOG_ERROR("Failed to create listener thread\n"); + free( stub); + } + else { + handle = stub; + + DEBUG_LOG("Created stub on port %d\n", port); + } + } + else { + free( stub); + } + + return handle; +} + + +void +destroyStub_gdb( gdbstub_handle_t instance) { + struct gdb_stub_state *stub = (struct gdb_stub_state *)instance; + + causeQuit_gdb( stub); + + joinThread_gdb( stub->thread); + + //stub->cpu_ctl->unstall( stub->cpu_ctl->data); + //stub->cpu_ctl->remove_post_ex_fn( stub->cpu_ctl->data); + + free( stub); +} + +void +activateStub_gdb( gdbstub_handle_t instance, + struct armcpu_ctrl_iface *cpu_ctrl) { + struct gdb_stub_state *stub = (struct gdb_stub_state *)instance; + + stub->cpu_ctrl = cpu_ctrl; + + /* stall the cpu */ + stub->cpu_ctrl->stall( stub->cpu_ctrl->data); + + stub->active = 1; +} diff --git a/desmume/src/gdbstub/gdbstub_internal.h b/src/gdbstub/gdbstub_internal.h similarity index 96% rename from desmume/src/gdbstub/gdbstub_internal.h rename to src/gdbstub/gdbstub_internal.h index a9f180f3e..ceadc5720 100644 --- a/desmume/src/gdbstub/gdbstub_internal.h +++ b/src/gdbstub/gdbstub_internal.h @@ -1,160 +1,160 @@ -#ifndef _GDBSTUB_INTERNAL_H_ -#define _GDBSTUB_INTERNAL_H_ 1 -/* $Id: gdbstub_internal.h,v 1.1 2007-06-07 09:43:25 masscat Exp $ - */ -/* - * THE SOFTWARE WITHIN THIS FILE IS NOT COPYRIGHTED - * - * Originally written by Ben Jaques. - * - * The software is offered for use in the public domain in the hope that - * it will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - */ - -#ifdef WIN32 -#define SOCKET_TYPE SOCKET -#else -#define SOCKET_TYPE int -#endif - - -enum stop_type { - STOP_UNKNOWN, - STOP_HOST_BREAK, - STOP_STEP_BREAK, - STOP_BREAKPOINT, - STOP_WATCHPOINT, - STOP_RWATCHPOINT, - STOP_AWATCHPOINT -}; - - -/** - * The structure describing a breakpoint. - */ -struct breakpoint_gdb { - /** link them in a list */ - struct breakpoint_gdb *next; - - /** The address of the breakpoint */ - uint32_t addr; - - /** The size of the breakpoint */ - uint32_t size; -}; - - -/* - */ -#define BUFMAX_GDB 2048 - -struct packet_reader_gdb { - int state; - - int pos_index; - - uint8_t checksum; - - uint8_t read_checksum; - - uint8_t buffer[BUFMAX_GDB]; -}; - -/** The maximum number of breakpoints (of all types) available to the stub */ -#define BREAKPOINT_POOL_SIZE 100 - - -struct gdb_stub_state { - /** flag indicating if the stub is active */ - int active; - - int main_stop_flag; - - /** the listener thread */ - void *thread; - - /** the id of the cpu the is under control */ - //u32 cpu_id; - - /** the interface used to control the CPU */ - struct armcpu_ctrl_iface *cpu_ctrl; - - /** the memory interface passed to the CPU */ - struct armcpu_memory_iface cpu_memio; - - /** the direct interface to the memory system */ - struct armcpu_memory_iface *direct_memio; - - /** the CPU memory interface to the real memory system */ - struct armcpu_memory_iface *real_cpu_memio; - - /** the list of active instruction breakpoints */ - struct breakpoint_gdb *instr_breakpoints; - - /** the list of active read breakpoints */ - struct breakpoint_gdb *read_breakpoints; - - /** the list of active write breakpoints */ - struct breakpoint_gdb *write_breakpoints; - - /** the list of active access breakpoints */ - struct breakpoint_gdb *access_breakpoints; - - /** the pointer to the step break point (not NULL if set) */ - //struct breakpoint_gdb *step_breakpoint; - - uint32_t step_instr_address; - - /** the state of the stub as seen by the emulator, the emulator side can - * set this to STOPPING_EMU_GDB_STATE to indicate that the a breakpoint has been hit, - * and STOPPED_EMU_GDB_STATE when it has informed the gdb thread that a breakpoint has - * been hit. - * When handled the stub side will set it back to RUNNING_EMU_GDB_STATE. - * - * The emulator should only run the corresponding ARM if this is set to - * RUNNING_EMU_GDB_STATE. - */ - enum EMU_STUB_STATE { STOPPED_EMU_GDB_STATE, STOPPING_EMU_GDB_STATE, RUNNING_EMU_GDB_STATE} emu_stub_state; - - /** the state of the stub as set by the stub control thread */ - enum CTL_STUB_STATE { STOPPED_GDB_STATE, RUNNING_GDB_STATE, - STEPPING_GDB_STATE, START_RUN_GDB_STATE} ctl_stub_state; - - struct packet_reader_gdb rx_packet; - - /** the socket information */ - uint16_t port_num; - SOCKET_TYPE sock_fd; - - /** The listening socket */ - SOCKET_TYPE listen_fd; - - /** the type of event that caused the stop */ - enum stop_type stop_type; - - /** the address of the stop */ - uint32_t stop_address; - - /** The step break point decsriptor */ - struct breakpoint_gdb step_breakpoint_descr; - - /** the breakpoint descriptor pool */ - struct breakpoint_gdb breakpoint_pool[BREAKPOINT_POOL_SIZE]; - - /** the free breakpoint descriptor list */ - struct breakpoint_gdb *free_breakpoints; - - /** the control pipe (or socket) to the gdb stub */ - SOCKET_TYPE ctl_pipe[2]; -}; - - -enum read_res_gdb { - READ_NOT_FINISHED, - READ_SOCKET_ERROR, - READ_COMPLETE, - READ_BREAK -}; - -#endif /* End of _GDBSTUB_INTERNAL_H_ */ +#ifndef _GDBSTUB_INTERNAL_H_ +#define _GDBSTUB_INTERNAL_H_ 1 +/* $Id: gdbstub_internal.h,v 1.1 2007-06-07 09:43:25 masscat Exp $ + */ +/* + * THE SOFTWARE WITHIN THIS FILE IS NOT COPYRIGHTED + * + * Originally written by Ben Jaques. + * + * The software is offered for use in the public domain in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifdef WIN32 +#define SOCKET_TYPE SOCKET +#else +#define SOCKET_TYPE int +#endif + + +enum stop_type { + STOP_UNKNOWN, + STOP_HOST_BREAK, + STOP_STEP_BREAK, + STOP_BREAKPOINT, + STOP_WATCHPOINT, + STOP_RWATCHPOINT, + STOP_AWATCHPOINT +}; + + +/** + * The structure describing a breakpoint. + */ +struct breakpoint_gdb { + /** link them in a list */ + struct breakpoint_gdb *next; + + /** The address of the breakpoint */ + uint32_t addr; + + /** The size of the breakpoint */ + uint32_t size; +}; + + +/* + */ +#define BUFMAX_GDB 2048 + +struct packet_reader_gdb { + int state; + + int pos_index; + + uint8_t checksum; + + uint8_t read_checksum; + + uint8_t buffer[BUFMAX_GDB]; +}; + +/** The maximum number of breakpoints (of all types) available to the stub */ +#define BREAKPOINT_POOL_SIZE 100 + + +struct gdb_stub_state { + /** flag indicating if the stub is active */ + int active; + + int main_stop_flag; + + /** the listener thread */ + void *thread; + + /** the id of the cpu the is under control */ + //u32 cpu_id; + + /** the interface used to control the CPU */ + struct armcpu_ctrl_iface *cpu_ctrl; + + /** the memory interface passed to the CPU */ + struct armcpu_memory_iface cpu_memio; + + /** the direct interface to the memory system */ + struct armcpu_memory_iface *direct_memio; + + /** the CPU memory interface to the real memory system */ + struct armcpu_memory_iface *real_cpu_memio; + + /** the list of active instruction breakpoints */ + struct breakpoint_gdb *instr_breakpoints; + + /** the list of active read breakpoints */ + struct breakpoint_gdb *read_breakpoints; + + /** the list of active write breakpoints */ + struct breakpoint_gdb *write_breakpoints; + + /** the list of active access breakpoints */ + struct breakpoint_gdb *access_breakpoints; + + /** the pointer to the step break point (not NULL if set) */ + //struct breakpoint_gdb *step_breakpoint; + + uint32_t step_instr_address; + + /** the state of the stub as seen by the emulator, the emulator side can + * set this to STOPPING_EMU_GDB_STATE to indicate that the a breakpoint has been hit, + * and STOPPED_EMU_GDB_STATE when it has informed the gdb thread that a breakpoint has + * been hit. + * When handled the stub side will set it back to RUNNING_EMU_GDB_STATE. + * + * The emulator should only run the corresponding ARM if this is set to + * RUNNING_EMU_GDB_STATE. + */ + enum EMU_STUB_STATE { STOPPED_EMU_GDB_STATE, STOPPING_EMU_GDB_STATE, RUNNING_EMU_GDB_STATE} emu_stub_state; + + /** the state of the stub as set by the stub control thread */ + enum CTL_STUB_STATE { STOPPED_GDB_STATE, RUNNING_GDB_STATE, + STEPPING_GDB_STATE, START_RUN_GDB_STATE} ctl_stub_state; + + struct packet_reader_gdb rx_packet; + + /** the socket information */ + uint16_t port_num; + SOCKET_TYPE sock_fd; + + /** The listening socket */ + SOCKET_TYPE listen_fd; + + /** the type of event that caused the stop */ + enum stop_type stop_type; + + /** the address of the stop */ + uint32_t stop_address; + + /** The step break point decsriptor */ + struct breakpoint_gdb step_breakpoint_descr; + + /** the breakpoint descriptor pool */ + struct breakpoint_gdb breakpoint_pool[BREAKPOINT_POOL_SIZE]; + + /** the free breakpoint descriptor list */ + struct breakpoint_gdb *free_breakpoints; + + /** the control pipe (or socket) to the gdb stub */ + SOCKET_TYPE ctl_pipe[2]; +}; + + +enum read_res_gdb { + READ_NOT_FINISHED, + READ_SOCKET_ERROR, + READ_COMPLETE, + READ_BREAK +}; + +#endif /* End of _GDBSTUB_INTERNAL_H_ */ diff --git a/desmume/src/gfx3d.cpp b/src/gfx3d.cpp similarity index 84% rename from desmume/src/gfx3d.cpp rename to src/gfx3d.cpp index 8f1f9a0cc..fd5b078c4 100644 --- a/desmume/src/gfx3d.cpp +++ b/src/gfx3d.cpp @@ -1,2515 +1,2539 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2008-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -//This file implements the geometry engine hardware component. -//This handles almost all of the work of 3d rendering, leaving the renderer -//plugin responsible only for drawing primitives. - -#include -#include -#include -#include -#include "armcpu.h" -#include "debug.h" -#include "gfx3d.h" -#include "matrix.h" -#include "bits.h" -#include "MMU.h" -#include "render3D.h" -#include "mem.h" -#include "types.h" -#include "saves.h" -#include "NDSSystem.h" -#include "readwrite.h" -#include "FIFO.h" - -/* -thoughts on flush timing: -I think a flush is supposed to queue up and wait to happen during vblank sometime. -But, we have some games that continue to do work after a flush but before a vblank. -Since our timing is bad anyway, and we're not sure when the flush is really supposed to happen, -then this leaves us in a bad situation. -What makes it worse is that if flush is supposed to be deferred, then we have to queue these -errant geometry commands. That would require a better gxfifo we have now, and some mechanism to block -while the geometry engine is stalled (which doesnt exist). -Since these errant games are nevertheless using flush command to represent the end of a frame, we deem this -a good time to execute an actual flush. -I think we originally didnt do this because we found some game that it glitched, but that may have been -resolved since then by deferring actual rendering to the next vcount=0 (giving textures enough time to upload). -But since we're not sure how we'll eventually want this, I am leaving it sort of reconfigurable, doing all the work -in this function: */ -static void gfx3d_doFlush(); - -#ifdef USE_GEOMETRY_FIFO_EMULATION -#define GFX_DELAY(x) MMU.gfx3dCycles = nds_timer + (1*x); -#define GFX_DELAY_M2(x) MMU.gfx3dCycles += (1*x); -#else -#define GFX_DELAY(x) -#define GFX_DELAY_M2(x) -#endif - -using std::max; -using std::min; - -GFX3D gfx3d; - -//tables that are provided to anyone -CACHE_ALIGN u32 color_15bit_to_24bit_reverse[32768]; -CACHE_ALIGN u32 color_15bit_to_24bit[32768]; -CACHE_ALIGN u16 color_15bit_to_16bit_reverse[32768]; -CACHE_ALIGN u8 mixTable555[32][32][32]; - -//is this a crazy idea? this table spreads 5 bits evenly over 31 from exactly 0 to INT_MAX -CACHE_ALIGN const int material_5bit_to_31bit[] = { - 0x00000000, 0x04210842, 0x08421084, 0x0C6318C6, - 0x10842108, 0x14A5294A, 0x18C6318C, 0x1CE739CE, - 0x21084210, 0x25294A52, 0x294A5294, 0x2D6B5AD6, - 0x318C6318, 0x35AD6B5A, 0x39CE739C, 0x3DEF7BDE, - 0x42108421, 0x46318C63, 0x4A5294A5, 0x4E739CE7, - 0x5294A529, 0x56B5AD6B, 0x5AD6B5AD, 0x5EF7BDEF, - 0x6318C631, 0x6739CE73, 0x6B5AD6B5, 0x6F7BDEF7, - 0x739CE739, 0x77BDEF7B, 0x7BDEF7BD, 0x7FFFFFFF -}; - -CACHE_ALIGN const u8 material_5bit_to_6bit[] = { - 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, - 0x10, 0x12, 0x14, 0x16, 0x19, 0x1A, 0x1C, 0x1E, - 0x21, 0x23, 0x25, 0x27, 0x29, 0x2B, 0x2D, 0x2F, - 0x31, 0x33, 0x35, 0x37, 0x39, 0x3B, 0x3D, 0x3F -}; - -CACHE_ALIGN const u8 material_5bit_to_8bit[] = { - 0x00, 0x08, 0x10, 0x18, 0x21, 0x29, 0x31, 0x39, - 0x42, 0x4A, 0x52, 0x5A, 0x63, 0x6B, 0x73, 0x7B, - 0x84, 0x8C, 0x94, 0x9C, 0xA5, 0xAD, 0xB5, 0xBD, - 0xC6, 0xCE, 0xD6, 0xDE, 0xE7, 0xEF, 0xF7, 0xFF -}; - -CACHE_ALIGN const u8 material_3bit_to_8bit[] = { - 0x00, 0x24, 0x49, 0x6D, 0x92, 0xB6, 0xDB, 0xFF -}; - -//maybe not very precise -CACHE_ALIGN const u8 material_3bit_to_5bit[] = { - 0, 4, 8, 13, 17, 22, 26, 31 -}; - -//TODO - generate this in the static init method more accurately -CACHE_ALIGN const u8 material_3bit_to_6bit[] = { - 0, 8, 16, 26, 34, 44, 52, 63 -}; - -//private acceleration tables -static float float16table[65536]; -static float float10Table[1024]; -static float float10RelTable[1024]; -static float normalTable[1024]; - -#define fix2float(v) (((float)((s32)(v))) / (float)(1<<12)) -#define fix10_2float(v) (((float)((s32)(v))) / (float)(1<<9)) - -CACHE_ALIGN u8 gfx3d_convertedScreen[256*192*4]; - -// Matrix stack handling -static CACHE_ALIGN MatrixStack mtxStack[4] = { - MatrixStack(1), // Projection stack - MatrixStack(31), // Coordinate stack - MatrixStack(31), // Directional stack - MatrixStack(1), // Texture stack -}; - -static CACHE_ALIGN float mtxCurrent [4][16]; -static CACHE_ALIGN float mtxTemporal[16]; -static u32 mode = 0; - -// Indexes for matrix loading/multiplication -static u8 ML4x4ind = 0; -static u8 ML4x3ind = 0; -static u8 MM4x4ind = 0; -static u8 MM4x3ind = 0; -static u8 MM3x3ind = 0; - -// Data for vertex submission -static CACHE_ALIGN float coord[4] = {0.0, 0.0, 0.0, 0.0}; -static char coordind = 0; -static u32 vtxFormat; -static BOOL inBegin = FALSE; - -// Data for basic transforms -static CACHE_ALIGN float trans[4] = {0.0, 0.0, 0.0, 0.0}; -static int transind = 0; -static CACHE_ALIGN float scale[4] = {0.0, 0.0, 0.0, 0.0}; -static int scaleind = 0; -static u32 viewport; - -//various other registers -static float _t=0, _s=0; -static float last_t, last_s; -static u32 clCmd = 0; -static u32 clInd = 0; - -#ifdef USE_GEOMETRY_FIFO_EMULATION -static u32 clInd2 = 0; -static bool isSwapBuffers = false; -bool isVBlank = false; -#endif - -static u32 BTind = 0; -static u32 PTind = 0; -static CACHE_ALIGN float BTcoords[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; -static CACHE_ALIGN float PTcoords[4] = {0.0, 0.0, 0.0, 1.0}; - -//raw ds format poly attributes -static u32 polyAttr=0,textureFormat=0, texturePalette=0, polyAttrPending=0; - -//the current vertex color, 5bit values -static u8 colorRGB[4] = { 31,31,31,31 }; - -u32 control = 0; - -//light state: -static u32 lightColor[4] = {0,0,0,0}; -static u32 lightDirection[4] = {0,0,0,0}; -//material state: -static u16 dsDiffuse, dsAmbient, dsSpecular, dsEmission; -// Shininess -static float shininessTable[128] = {0}; -static int shininessInd = 0; - - -//-----------cached things: -//these dont need to go into the savestate. they can be regenerated from HW registers -//from polygonattr: -static unsigned int cullingMask=0; -static u8 colorAlpha=0; -static u32 envMode=0; -static u32 lightMask=0; -//other things: -static int texCoordinateTransform = 0; -static CACHE_ALIGN float cacheLightDirection[4][4]; -static CACHE_ALIGN float cacheHalfVector[4][4]; -//------------------ - -#define RENDER_FRONT_SURFACE 0x80 -#define RENDER_BACK_SURFACE 0X40 - - -//-------------poly and vertex lists and such things -POLYLIST* polylists = NULL; -POLYLIST* polylist = NULL; -VERTLIST* vertlists = NULL; -VERTLIST* vertlist = NULL; -int polygonListCompleted = 0; - -int listTwiddle = 1; -int triStripToggle; - -//list-building state -struct tmpVertInfo { - //the number of verts registered in this list - int count; - //indices to the main vert list - int map[4]; - //indicates that the first poly in a list has been completed - BOOL first; -} tempVertInfo; - - -static void twiddleLists() { - listTwiddle++; - listTwiddle &= 1; - polylist = &polylists[listTwiddle]; - vertlist = &vertlists[listTwiddle]; - polylist->count = 0; - vertlist->count = 0; -} - -static BOOL flushPending = FALSE; -static BOOL drawPending = FALSE; -//------------------------------------------------------------ - -static void makeTables() { - - //produce the color bits of a 24bpp color from a DS RGB15 using bit logic (internal use only) - #define RGB15TO24_BITLOGIC(col) ( (material_5bit_to_8bit[((col)>>10)&0x1F]<<16) | (material_5bit_to_8bit[((col)>>5)&0x1F]<<8) | material_5bit_to_8bit[(col)&0x1F] ) - - for(int i=0;i<32768;i++) - color_15bit_to_24bit[i] = RGB15TO24_BITLOGIC((u16)i); - - //produce the color bits of a 24bpp color from a DS RGB15 using bit logic (internal use only). RGB are reverse of usual - #define RGB15TO24_BITLOGIC_REVERSE(col) ( (material_5bit_to_8bit[(col)&0x1F]<<16) | (material_5bit_to_8bit[((col)>>5)&0x1F]<<8) | material_5bit_to_8bit[((col)>>10)&0x1F] ) - - for(int i=0;i<32768;i++) - { - color_15bit_to_24bit_reverse[i] = RGB15TO24_BITLOGIC_REVERSE((u16)i); - color_15bit_to_16bit_reverse[i] = (((i & 0x001F) << 11) | (material_5bit_to_6bit[(i & 0x03E0) >> 5] << 5) | ((i & 0x7C00) >> 10)); - } - - for (int i = 0; i < 65536; i++) - float16table[i] = fix2float((signed short)i); - - for (int i = 0; i < 1024; i++) - float10Table[i] = ((signed short)(i<<6)) / (float)(1<<12); - - for (int i = 0; i < 1024; i++) - float10RelTable[i] = ((signed short)(i<<6)) / (float)(1<<18); - - for (int i = 0; i < 1024; i++) - normalTable[i] = ((signed short)(i<<6)) / (float)(1<<15); - - for(int r=0;r<=31;r++) - for(int oldr=0;oldr<=31;oldr++) - for(int a=0;a<=31;a++) { - int temp = (r*a + oldr*(31-a)) / 31; - mixTable555[a][r][oldr] = temp; - } -} - -void gfx3d_init() -{ - //DWORD start = timeGetTime(); - //for(int i=0;i<1000000000;i++) - // MatrixMultVec4x4(mtxCurrent[0],mtxCurrent[1]); - //DWORD end = timeGetTime(); - //DWORD diff = end-start; - - //start = timeGetTime(); - //for(int i=0;i<1000000000;i++) - // MatrixMultVec4x4_b(mtxCurrent[0],mtxCurrent[1]); - //end = timeGetTime(); - //DWORD diff2 = end-start; - - //printf("SPEED TEST %d %d\n",diff,diff2); - - if(polylists == NULL) { polylists = new POLYLIST[2]; polylist = &polylists[0]; } - if(vertlists == NULL) { vertlists = new VERTLIST[2]; vertlist = &vertlists[0]; } - makeTables(); - gfx3d_reset(); -} - -void gfx3d_reset() -{ - gfx3d = GFX3D(); - - control = 0; - drawPending = FALSE; - flushPending = FALSE; - memset(polylists, 0, sizeof(polylists)); - memset(vertlists, 0, sizeof(vertlists)); - listTwiddle = 1; - twiddleLists(); - gfx3d.polylist = polylist; - gfx3d.vertlist = vertlist; - - MatrixInit (mtxCurrent[0]); - MatrixInit (mtxCurrent[1]); - MatrixInit (mtxCurrent[2]); - MatrixInit (mtxCurrent[3]); - MatrixInit (mtxTemporal); - - MatrixStackInit(&mtxStack[0]); - MatrixStackInit(&mtxStack[1]); - MatrixStackInit(&mtxStack[2]); - MatrixStackInit(&mtxStack[3]); - - clCmd = 0; - clInd = 0; - - ML4x4ind = 0; - ML4x3ind = 0; - MM4x4ind = 0; - MM4x3ind = 0; - MM3x3ind = 0; - - BTind = 0; - PTind = 0; - - _t=0; - _s=0; - last_t = 0; - last_s = 0; - viewport = 0xBFFF0000; - - memset(gfx3d_convertedScreen,0,sizeof(gfx3d_convertedScreen)); - - gfx3d.clearDepth = gfx3d_extendDepth_15_to_24(0x7FFF); - -#ifdef USE_GEOMETRY_FIFO_EMULATION - clInd2 = 0; - isSwapBuffers = false; - isVBlank = false; -#endif - - GFX_PIPEclear(); - GFX_FIFOclear(); -} - - -//================================================================================= Geometry Engine -//================================================================================= -//================================================================================= - -#define vec3dot(a, b) (((a[0]) * (b[0])) + ((a[1]) * (b[1])) + ((a[2]) * (b[2]))) -#define SUBMITVERTEX(ii, nn) polylist->list[polylist->count].vertIndexes[ii] = tempVertInfo.map[nn]; -//Submit a vertex to the GE -static void SetVertex() -{ - ALIGN(16) float coordTransformed[4] = { coord[0], coord[1], coord[2], 1.f }; - - if (texCoordinateTransform == 3) - { - last_s =((coord[0]*mtxCurrent[3][0] + - coord[1]*mtxCurrent[3][4] + - coord[2]*mtxCurrent[3][8]) + _s * 16.0f) / 16.0f; - last_t =((coord[0]*mtxCurrent[3][1] + - coord[1]*mtxCurrent[3][5] + - coord[2]*mtxCurrent[3][9]) + _t * 16.0f) / 16.0f; - } - - - //refuse to do anything if we have too many verts or polys - polygonListCompleted = 0; - if(vertlist->count >= VERTLIST_SIZE) - return; - if(polylist->count >= POLYLIST_SIZE) - return; - - //TODO - think about keeping the clip matrix concatenated, - //so that we only have to multiply one matrix here - //(we could lazy cache the concatenated clip matrix and only generate it - //when we need to) - MatrixMultVec4x4_M2(mtxCurrent[0], coordTransformed); - - //TODO - culling should be done here. - //TODO - viewport transform? - - int continuation = 0; - if(vtxFormat==2 && !tempVertInfo.first) - continuation = 2; - else if(vtxFormat==3 && !tempVertInfo.first) - continuation = 2; - - - //record the vertex - //VERT &vert = tempVertList.list[tempVertList.count]; - VERT &vert = vertlist->list[vertlist->count + tempVertInfo.count - continuation]; - - vert.texcoord[0] = last_s; - vert.texcoord[1] = last_t; - vert.coord[0] = coordTransformed[0]; - vert.coord[1] = coordTransformed[1]; - vert.coord[2] = coordTransformed[2]; - vert.coord[3] = coordTransformed[3]; - vert.color[0] = GFX3D_5TO6(colorRGB[0]); - vert.color[1] = GFX3D_5TO6(colorRGB[1]); - vert.color[2] = GFX3D_5TO6(colorRGB[2]); - tempVertInfo.map[tempVertInfo.count] = vertlist->count + tempVertInfo.count - continuation; - tempVertInfo.count++; - - //possibly complete a polygon - { - polygonListCompleted = 2; - switch(vtxFormat) { - case 0: //GL_TRIANGLES - if(tempVertInfo.count!=3) - break; - polygonListCompleted = 1; - //vertlist->list[polylist->list[polylist->count].vertIndexes[i] = vertlist->count++] = tempVertList.list[n]; - SUBMITVERTEX(0,0); - SUBMITVERTEX(1,1); - SUBMITVERTEX(2,2); - vertlist->count+=3; - polylist->list[polylist->count].type = 3; - tempVertInfo.count = 0; - break; - case 1: //GL_QUADS - if(tempVertInfo.count!=4) - break; - polygonListCompleted = 1; - SUBMITVERTEX(0,0); - SUBMITVERTEX(1,1); - SUBMITVERTEX(2,2); - SUBMITVERTEX(3,3); - vertlist->count+=4; - polylist->list[polylist->count].type = 4; - tempVertInfo.count = 0; - break; - case 2: //GL_TRIANGLE_STRIP - if(tempVertInfo.count!=3) - break; - polygonListCompleted = 1; - SUBMITVERTEX(0,0); - SUBMITVERTEX(1,1); - SUBMITVERTEX(2,2); - polylist->list[polylist->count].type = 3; - - if(triStripToggle) - tempVertInfo.map[1] = vertlist->count+2-continuation; - else - tempVertInfo.map[0] = vertlist->count+2-continuation; - - if(tempVertInfo.first) - vertlist->count+=3; - else - vertlist->count+=1; - - triStripToggle ^= 1; - tempVertInfo.first = false; - tempVertInfo.count = 2; - break; - case 3: //GL_QUAD_STRIP - if(tempVertInfo.count!=4) - break; - polygonListCompleted = 1; - SUBMITVERTEX(0,0); - SUBMITVERTEX(1,1); - SUBMITVERTEX(2,3); - SUBMITVERTEX(3,2); - polylist->list[polylist->count].type = 4; - tempVertInfo.map[0] = vertlist->count+2-continuation; - tempVertInfo.map[1] = vertlist->count+3-continuation; - if(tempVertInfo.first) - vertlist->count+=4; - else vertlist->count+=2; - tempVertInfo.first = false; - tempVertInfo.count = 2; - break; - default: - return; - } - - if(polygonListCompleted == 1) - { - POLY &poly = polylist->list[polylist->count]; - - poly.polyAttr = polyAttr; - poly.texParam = textureFormat; - poly.texPalette = texturePalette; - poly.viewport = viewport; - polylist->count++; - } - } -} - -static void gfx3d_glPolygonAttrib_cache() -{ - // Light enable/disable - lightMask = (polyAttr&0xF); - - // texture environment - envMode = (polyAttr&0x30)>>4; - - // back face culling - cullingMask = (polyAttr>>6)&3; -} - -static void gfx3d_glTexImage_cache() -{ - texCoordinateTransform = (textureFormat>>30); -} - -static void gfx3d_glLightDirection_cache(int index) -{ - u32 v = lightDirection[index]; - - // Convert format into floating point value - cacheLightDirection[index][0] = normalTable[v&1023]; - cacheLightDirection[index][1] = normalTable[(v>>10)&1023]; - cacheLightDirection[index][2] = normalTable[(v>>20)&1023]; - cacheLightDirection[index][3] = 0; - - /* Multiply the vector by the directional matrix */ - MatrixMultVec3x3(mtxCurrent[2], cacheLightDirection[index]); - - /* Calculate the half vector */ - float lineOfSight[4] = {0.0f, 0.0f, -1.0f, 0.0f}; - for(int i = 0; i < 4; i++) - { - cacheHalfVector[index][i] = ((cacheLightDirection[index][i] + lineOfSight[i]) / 2.0f); - } -} - -//=============================================================================== -void gfx3d_glMatrixMode(u32 v) -{ - mode = (v&3); - - GFX_DELAY(1); -} - -void gfx3d_glPushMatrix() -{ - u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); - //this command always works on both pos and vector when either pos or pos-vector are the current mtx mode - short mymode = (mode==1?2:mode); - - if (mtxStack[mymode].position > mtxStack[mymode].size) - { - gxstat |= (1<<15); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - return; - } - - gxstat &= 0xFFFF00FF; - - MatrixStackPushMatrix(&mtxStack[mymode], mtxCurrent[mymode]); - - GFX_DELAY(17); - - if(mymode==2) - MatrixStackPushMatrix (&mtxStack[1], mtxCurrent[1]); - - gxstat |= ((mtxStack[0].position << 13) | (mtxStack[1].position << 8)); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); -} - -void gfx3d_glPopMatrix(s32 i) -{ - u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); - - //this command always works on both pos and vector when either pos or pos-vector are the current mtx mode - short mymode = (mode==1?2:mode); - - /* - if (i > mtxStack[mymode].position) - { - gxstat |= (1<<15); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - return; - } - */ - gxstat &= 0xFFFF00FF; - - MatrixCopy(mtxCurrent[mymode], MatrixStackPopMatrix (&mtxStack[mymode], i)); - - GFX_DELAY(36); - - if (mymode == 2) - MatrixCopy(mtxCurrent[1], MatrixStackPopMatrix (&mtxStack[1], i)); - - gxstat |= ((mtxStack[0].position << 13) | (mtxStack[1].position << 8)); - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); -} - -void gfx3d_glStoreMatrix(u32 v) -{ - //this command always works on both pos and vector when either pos or pos-vector are the current mtx mode - short mymode = (mode==1?2:mode); - - //limit height of these stacks. - //without the mymode==3 namco classics galaxian will try to use pos=1 and overrun the stack, corrupting emu - if(mymode==0 || mymode==3) - v = 0; - - if (v > 31) return; - - MatrixStackLoadMatrix (&mtxStack[mymode], v, mtxCurrent[mymode]); - - GFX_DELAY(17); - - if(mymode==2) - MatrixStackLoadMatrix (&mtxStack[1], v, mtxCurrent[1]); -} - -void gfx3d_glRestoreMatrix(u32 v) -{ - //this command always works on both pos and vector when either pos or pos-vector are the current mtx mode - short mymode = (mode==1?2:mode); - - //limit height of these stacks - //without the mymode==3 namco classics galaxian will try to use pos=1 and overrun the stack, corrupting emu - if(mymode==0 || mymode==3) - v = 0; - - if (v > 31) return; - - MatrixCopy (mtxCurrent[mymode], MatrixStackGetPos(&mtxStack[mymode], v)); - - GFX_DELAY(36); - - if (mymode == 2) - MatrixCopy (mtxCurrent[1], MatrixStackGetPos(&mtxStack[1], v)); -} - -void gfx3d_glLoadIdentity() -{ - MatrixIdentity (mtxCurrent[mode]); - - GFX_DELAY(19); - - if (mode == 2) - MatrixIdentity (mtxCurrent[1]); -} - -BOOL gfx3d_glLoadMatrix4x4(s32 v) -{ - mtxCurrent[mode][ML4x4ind] = (float)v; - - ++ML4x4ind; - if(ML4x4ind<16) return FALSE; - ML4x4ind = 0; - - GFX_DELAY(19); - - vector_fix2float<4>(mtxCurrent[mode], 4096.f); - - if (mode == 2) - MatrixCopy (mtxCurrent[1], mtxCurrent[2]); - return TRUE; -} - -BOOL gfx3d_glLoadMatrix4x3(s32 v) -{ - mtxCurrent[mode][ML4x3ind] = (float)v; - - ML4x3ind++; - if((ML4x3ind & 0x03) == 3) ML4x3ind++; - if(ML4x3ind<16) return FALSE; - ML4x3ind = 0; - - vector_fix2float<4>(mtxCurrent[mode], 4096.f); - - //fill in the unusued matrix values - mtxCurrent[mode][3] = mtxCurrent[mode][7] = mtxCurrent[mode][11] = 0.f; - mtxCurrent[mode][15] = 1.f; - - GFX_DELAY(30); - - if (mode == 2) - MatrixCopy (mtxCurrent[1], mtxCurrent[2]); - return TRUE; -} - -BOOL gfx3d_glMultMatrix4x4(s32 v) -{ - mtxTemporal[MM4x4ind] = (float)v; - - MM4x4ind++; - if(MM4x4ind<16) return FALSE; - MM4x4ind = 0; - - GFX_DELAY(35); - - vector_fix2float<4>(mtxTemporal, 4096.f); - - MatrixMultiply (mtxCurrent[mode], mtxTemporal); - - if (mode == 2) - { - MatrixMultiply (mtxCurrent[1], mtxTemporal); - GFX_DELAY_M2(30); - } - - MatrixIdentity (mtxTemporal); - return TRUE; -} - -BOOL gfx3d_glMultMatrix4x3(s32 v) -{ - mtxTemporal[MM4x3ind] = (float)v; - - MM4x3ind++; - if((MM4x3ind & 0x03) == 3) MM4x3ind++; - if(MM4x3ind<16) return FALSE; - MM4x3ind = 0; - - GFX_DELAY(31); - - vector_fix2float<4>(mtxTemporal, 4096.f); - - //fill in the unusued matrix values - mtxTemporal[3] = mtxTemporal[7] = mtxTemporal[11] = 0.f; - mtxTemporal[15] = 1.f; - - MatrixMultiply (mtxCurrent[mode], mtxTemporal); - - if (mode == 2) - { - MatrixMultiply (mtxCurrent[1], mtxTemporal); - GFX_DELAY_M2(30); - } - - //does this really need to be done? - MatrixIdentity (mtxTemporal); - return TRUE; -} - -BOOL gfx3d_glMultMatrix3x3(s32 v) -{ - mtxTemporal[MM3x3ind] = (float)v; - - - MM3x3ind++; - if((MM3x3ind & 0x03) == 3) MM3x3ind++; - if(MM3x3ind<12) return FALSE; - MM3x3ind = 0; - - GFX_DELAY(28); - - vector_fix2float<3>(mtxTemporal, 4096.f); - - //fill in the unusued matrix values - mtxTemporal[3] = mtxTemporal[7] = mtxTemporal[11] = 0; - mtxTemporal[15] = 1; - mtxTemporal[12] = mtxTemporal[13] = mtxTemporal[14] = 0; - - MatrixMultiply (mtxCurrent[mode], mtxTemporal); - - if (mode == 2) - { - MatrixMultiply (mtxCurrent[1], mtxTemporal); - GFX_DELAY_M2(30); - } - - //does this really need to be done? - MatrixIdentity (mtxTemporal); - return TRUE; -} - -BOOL gfx3d_glScale(s32 v) -{ - scale[scaleind] = fix2float(v); - - ++scaleind; - - if(scaleind<3) return FALSE; - scaleind = 0; - - MatrixScale (mtxCurrent[(mode==2?1:mode)], scale); - - GFX_DELAY(22); - - //note: pos-vector mode should not cause both matrices to scale. - //the whole purpose is to keep the vector matrix orthogonal - //so, I am leaving this commented out as an example of what not to do. - //if (mode == 2) - // MatrixScale (mtxCurrent[1], scale); - return TRUE; -} - -BOOL gfx3d_glTranslate(s32 v) -{ - trans[transind] = fix2float(v); - - ++transind; - - if(transind<3) return FALSE; - transind = 0; - - MatrixTranslate (mtxCurrent[mode], trans); - - GFX_DELAY(22); - - if (mode == 2) - { - MatrixTranslate (mtxCurrent[1], trans); - GFX_DELAY_M2(30); - } - return TRUE; -} - -void gfx3d_glColor3b(u32 v) -{ - colorRGB[0] = (v&0x1F); - colorRGB[1] = ((v>>5)&0x1F); - colorRGB[2] = ((v>>10)&0x1F); - GFX_DELAY(1); -} - -void gfx3d_glNormal(u32 v) -{ - int i,c; - ALIGN(16) float normal[4] = { normalTable[v&1023], - normalTable[(v>>10)&1023], - normalTable[(v>>20)&1023], - 1}; - - if (texCoordinateTransform == 2) - { - last_s =( (normal[0] *mtxCurrent[3][0] + normal[1] *mtxCurrent[3][4] + - normal[2] *mtxCurrent[3][8]) + (_s*16.0f)) / 16.0f; - last_t =( (normal[0] *mtxCurrent[3][1] + normal[1] *mtxCurrent[3][5] + - normal[2] *mtxCurrent[3][9]) + (_t*16.0f)) / 16.0f; - } - - //use the current normal transform matrix - MatrixMultVec3x3 (mtxCurrent[2], normal); - - //apply lighting model - { - u8 diffuse[3] = { - (dsDiffuse)&0x1F, - (dsDiffuse>>5)&0x1F, - (dsDiffuse>>10)&0x1F }; - - u8 ambient[3] = { - (dsAmbient)&0x1F, - (dsAmbient>>5)&0x1F, - (dsAmbient>>10)&0x1F }; - - u8 emission[3] = { - (dsEmission)&0x1F, - (dsEmission>>5)&0x1F, - (dsEmission>>10)&0x1F }; - - u8 specular[3] = { - (dsSpecular)&0x1F, - (dsSpecular>>5)&0x1F, - (dsSpecular>>10)&0x1F }; - - int vertexColor[3] = { emission[0], emission[1], emission[2] }; - - for(i=0; i<4; i++) - { - if(!((lightMask>>i)&1)) continue; - - u8 _lightColor[3] = { - (lightColor[i])&0x1F, - (lightColor[i]>>5)&0x1F, - (lightColor[i]>>10)&0x1F }; - - /* This formula is the one used by the DS */ - /* Reference : http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters */ - - float diffuseLevel = std::max(0.0f, -vec3dot(cacheLightDirection[i], normal)); - float shininessLevel = pow(std::max(0.0f, vec3dot(-cacheHalfVector[i], normal)), 2); - - if(dsSpecular & 0x8000) - { - int shininessIndex = (int)(shininessLevel * 128); - if(shininessIndex >= (int)ARRAY_SIZE(shininessTable)) { - //we can't print this right now, because when a game triggers this it triggers it _A_LOT_ - //so wait until we have per-frame diagnostics. - //this was tested using Princess Debut (US) after proceeding through the intro and getting the tiara. - //After much research, I determined that this was caused by the game feeding in a totally jacked matrix - //to mult4x4 from 0x02129B80 (after feeding two other valid matrices) - //the game seems to internally index these as: ?, 0x37, 0x2B <-- error - //but, man... this is seriously messed up. there must be something going wrong. - //maybe it has something to do with what looks like a mirror room effect that is going on during this time? - //PROGINFO("ERROR: shininess table out of bounds.\n maybe an emulator error; maybe a non-unit normal; setting to 0\n"); - shininessIndex = 0; - } - shininessLevel = shininessTable[shininessIndex]; - } - - for(c = 0; c < 3; c++) - { - vertexColor[c] += (int)(((specular[c] * _lightColor[c] * shininessLevel) - + (diffuse[c] * _lightColor[c] * diffuseLevel) - + (ambient[c] * _lightColor[c])) / 31.0f); - } - } - - for(c=0;c<3;c++) - colorRGB[c] = std::min(31,vertexColor[c]); - } - - GFX_DELAY(9); - GFX_DELAY_M2((lightMask) & 0x01); - GFX_DELAY_M2((lightMask>>1) & 0x01); - GFX_DELAY_M2((lightMask>>2) & 0x01); - GFX_DELAY_M2((lightMask>>3) & 0x01); -} - -void gfx3d_glTexCoord(u32 val) -{ - _t = (s16)(val>>16); - _s = (s16)(val&0xFFFF); - - _s /= 16.0f; - _t /= 16.0f; - - if (texCoordinateTransform == 1) - { - last_s =_s*mtxCurrent[3][0] + _t*mtxCurrent[3][4] + - 0.0625f*mtxCurrent[3][8] + 0.0625f*mtxCurrent[3][12]; - last_t =_s*mtxCurrent[3][1] + _t*mtxCurrent[3][5] + - 0.0625f*mtxCurrent[3][9] + 0.0625f*mtxCurrent[3][13]; - } - else - { - last_s=_s; - last_t=_t; - } - GFX_DELAY(1); -} - -BOOL gfx3d_glVertex16b(unsigned int v) -{ - if(coordind==0) - { - coord[0] = float16table[v&0xFFFF]; - coord[1] = float16table[v>>16]; - - ++coordind; - return FALSE; - } - - coord[2] = float16table[v&0xFFFF]; - - coordind = 0; - SetVertex (); - - GFX_DELAY(9); - return TRUE; -} - -void gfx3d_glVertex10b(u32 v) -{ - coord[0] = float10Table[v&1023]; - coord[1] = float10Table[(v>>10)&1023]; - coord[2] = float10Table[(v>>20)&1023]; - - GFX_DELAY(8); - SetVertex (); -} - -void gfx3d_glVertex3_cord(unsigned int one, unsigned int two, unsigned int v) -{ - coord[one] = float16table[v&0xffff]; - coord[two] = float16table[v>>16]; - - SetVertex (); - - GFX_DELAY(8); -} - -void gfx3d_glVertex_rel(u32 v) -{ - coord[0] += float10RelTable[v&1023]; - coord[1] += float10RelTable[(v>>10)&1023]; - coord[2] += float10RelTable[(v>>20)&1023]; - - SetVertex (); - - GFX_DELAY(8); -} - -void gfx3d_glPolygonAttrib (u32 val) -{ - if(inBegin) { - //PROGINFO("Set polyattr in the middle of a begin/end pair.\n (This won't be activated until the next begin)\n"); - //TODO - we need some some similar checking for teximageparam etc. - } - polyAttrPending = val; - GFX_DELAY(1); -} - -void gfx3d_glTexImage(u32 val) -{ - textureFormat = val; - gfx3d_glTexImage_cache(); - GFX_DELAY(1); -} - -void gfx3d_glTexPalette(u32 val) -{ - texturePalette = val; - GFX_DELAY(1); -} - -/* - 0-4 Diffuse Reflection Red - 5-9 Diffuse Reflection Green - 10-14 Diffuse Reflection Blue - 15 Set Vertex Color (0=No, 1=Set Diffuse Reflection Color as Vertex Color) - 16-20 Ambient Reflection Red - 21-25 Ambient Reflection Green - 26-30 Ambient Reflection Blue -*/ -void gfx3d_glMaterial0(u32 val) -{ - dsDiffuse = val&0xFFFF; - dsAmbient = val>>16; - - if (BIT15(val)) - { - colorRGB[0] = (val)&0x1F; - colorRGB[1] = (val>>5)&0x1F; - colorRGB[2] = (val>>10)&0x1F; - } - GFX_DELAY(4); -} - -void gfx3d_glMaterial1(u32 val) -{ - dsSpecular = val&0xFFFF; - dsEmission = val>>16; - GFX_DELAY(4); -} - -/* - 0-9 Directional Vector's X component (1bit sign + 9bit fractional part) - 10-19 Directional Vector's Y component (1bit sign + 9bit fractional part) - 20-29 Directional Vector's Z component (1bit sign + 9bit fractional part) - 30-31 Light Number (0..3) -*/ -void gfx3d_glLightDirection (u32 v) -{ - int index = v>>30; - - lightDirection[index] = v; - gfx3d_glLightDirection_cache(index); - GFX_DELAY(6); -} - -void gfx3d_glLightColor (u32 v) -{ - int index = v>>30; - lightColor[index] = v; - GFX_DELAY(1); -} - -BOOL gfx3d_glShininess (u32 val) -{ - shininessTable[shininessInd++] = ((val & 0xFF) / 256.0f); - shininessTable[shininessInd++] = (((val >> 8) & 0xFF) / 256.0f); - shininessTable[shininessInd++] = (((val >> 16) & 0xFF) / 256.0f); - shininessTable[shininessInd++] = (((val >> 24) & 0xFF) / 256.0f); - - if (shininessInd < 128) return FALSE; - shininessInd = 0; - GFX_DELAY(32); - return TRUE; -} - -void gfx3d_glBegin(u32 v) -{ - inBegin = TRUE; - vtxFormat = v&0x03; - triStripToggle = 0; - tempVertInfo.count = 0; - tempVertInfo.first = true; - polyAttr = polyAttrPending; - gfx3d_glPolygonAttrib_cache(); - GFX_DELAY(1); -} - -void gfx3d_glEnd(void) -{ - inBegin = FALSE; - tempVertInfo.count = 0; - GFX_DELAY(1); -} - -// swap buffers - skipped - -void gfx3d_glViewPort(u32 v) -{ - viewport = v; - GFX_DELAY(1); -} - -BOOL gfx3d_glBoxTest(u32 v) -{ - u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); - gxstat &= 0xFFFFFFFD; // clear boxtest bit - gxstat |= 0x00000001; // busy - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - - BTcoords[BTind++] = float16table[v & 0xFFFF]; - BTcoords[BTind++] = float16table[v >> 16]; - - // 0 - X coordinate - // 1 - Y coordinate - // 2 - Z coordinate - // 3 - Width - // 4 - Height - // 5 - Depth - - if (BTind < 5) return FALSE; - BTind = 0; - - gxstat &= 0xFFFFFFFE; // clear busy bit - GFX_DELAY(103); - -#if 0 - INFO("BoxTEST: x %f y %f width %f height %f depth %f\n", - BTcoords[0], BTcoords[1], BTcoords[2], BTcoords[3], BTcoords[4], BTcoords[5]); - /*for (int i = 0; i < 16; i++) - { - INFO("mtx1[%i] = %f ", i, mtxCurrent[1][i]); - if ((i+1) % 4 == 0) INFO("\n"); - } - INFO("\n");*/ -#endif - -#if 0 - - // 0 - X coordinate 1 - Y coordinate 2 - Z coordinate - // 3 - Width 4 - Height 5 - Depth - ALIGN(16) float boxCoords[6][4][4] = { - // near - { {BTcoords[0], BTcoords[1], BTcoords[2], 1.0f}, - {BTcoords[0]+BTcoords[3], BTcoords[1], BTcoords[2], 1.0f}, - {BTcoords[0]+BTcoords[3], BTcoords[1]+BTcoords[4], BTcoords[2], 1.0f}, - {BTcoords[0], BTcoords[1]+BTcoords[4], BTcoords[2], 1.0f}}, - // far - { {BTcoords[0], BTcoords[1], BTcoords[2]+BTcoords[5], 1.0f}, - {BTcoords[0]+BTcoords[3], BTcoords[1], BTcoords[2]+BTcoords[5], 1.0f}, - {BTcoords[0]+BTcoords[3], BTcoords[1]+BTcoords[4], BTcoords[2]+BTcoords[5], 1.0f}, - {BTcoords[0], BTcoords[1]+BTcoords[4], BTcoords[2]+BTcoords[5], 1.0f}}, - // left - { {BTcoords[0], BTcoords[1], BTcoords[2]+BTcoords[5], 1.0f}, - {BTcoords[0], BTcoords[1], BTcoords[2], 1.0f}, - {BTcoords[0], BTcoords[1]+BTcoords[4], BTcoords[2], 1.0f}, - {BTcoords[0], BTcoords[1]+BTcoords[4], BTcoords[2]+BTcoords[5], 1.0f}}, - // right - { {BTcoords[0]+BTcoords[3], BTcoords[1], BTcoords[2], 1.0f}, - {BTcoords[0]+BTcoords[3], BTcoords[1], BTcoords[2]+BTcoords[5], 1.0f}, - {BTcoords[0]+BTcoords[3], BTcoords[1]+BTcoords[4], BTcoords[2]+BTcoords[5], 1.0f}, - {BTcoords[0]+BTcoords[3], BTcoords[1]+BTcoords[4], BTcoords[2], 1.0f}}, - // top - { {BTcoords[0], BTcoords[1], BTcoords[2]+BTcoords[5], 1.0f}, - {BTcoords[0]+BTcoords[3], BTcoords[1], BTcoords[2]+BTcoords[5], 1.0f}, - {BTcoords[0]+BTcoords[3], BTcoords[1], BTcoords[2], 1.0f}, - {BTcoords[0], BTcoords[1], BTcoords[2], 1.0f}}, - // bottom - { {BTcoords[0], BTcoords[1]+BTcoords[4], BTcoords[2]+BTcoords[5], 1.0f}, - {BTcoords[0]+BTcoords[3], BTcoords[1]+BTcoords[4], BTcoords[2]+BTcoords[5], 1.0f}, - {BTcoords[0]+BTcoords[3], BTcoords[1]+BTcoords[4], BTcoords[2], 1.0f}, - {BTcoords[0], BTcoords[1]+BTcoords[4], BTcoords[2], 1.0f}} - }; - - for(int face = 0; face < 6; face++) - { - for(int vtx = 0; vtx < 4; vtx++) - { - MatrixMultVec4x4(mtxCurrent[1], boxCoords[face][vtx]); - MatrixMultVec4x4(mtxCurrent[0], boxCoords[face][vtx]); - - boxCoords[face][vtx][0] = ((boxCoords[face][vtx][0] + boxCoords[face][vtx][3]) / (2.0f * boxCoords[face][vtx][3])); - boxCoords[face][vtx][1] = ((boxCoords[face][vtx][1] + boxCoords[face][vtx][3]) / (2.0f * boxCoords[face][vtx][3])); - boxCoords[face][vtx][2] = ((boxCoords[face][vtx][2] + boxCoords[face][vtx][3]) / (2.0f * boxCoords[face][vtx][3])); - - //if(face==0)INFO("box test: testing face %i, vtx %i: %f %f %f %f\n", face, vtx, - // boxCoords[face][vtx][0], boxCoords[face][vtx][1], boxCoords[face][vtx][2], boxCoords[face][vtx][3]); - - if ((boxCoords[face][vtx][0] >= -1.0f) && (boxCoords[face][vtx][0] <= 1.0f) && - (boxCoords[face][vtx][1] >= -1.0f) && (boxCoords[face][vtx][1] <= 1.0f) && - (boxCoords[face][vtx][2] >= -1.0f) && (boxCoords[face][vtx][2] <= 1.0f)) - { - gxstat |= 0x00000002; - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - return TRUE; - } - } - } - -#else - gxstat |= 0x00000002; // hack -#endif - - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - return TRUE; -} - -BOOL gfx3d_glPosTest(u32 v) -{ - u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); - gxstat |= 0x00000001; // busy - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - - PTcoords[PTind++] = float16table[v & 0xFFFF]; - PTcoords[PTind++] = float16table[v >> 16]; - - if (PTind < 3) return FALSE; - PTind = 0; - - PTcoords[3] = 1.0f; - - MatrixMultVec4x4(mtxCurrent[1], PTcoords); - MatrixMultVec4x4(mtxCurrent[0], PTcoords); - - gxstat &= 0xFFFFFFFE; - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - - GFX_DELAY(9); - - return TRUE; -} - -void gfx3d_glVecTest(u32 v) -{ - u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); - gxstat &= 0xFFFFFFFE; - T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); - - GFX_DELAY(5); - //INFO("NDS_glVecTest\n"); -} -//================================================================================= Geometry Engine -//================================================================================= (end) -//================================================================================= - -void VIEWPORT::decode(u32 v) -{ - x = (v&0xFF); - y = std::min(191,(int)(((v>>8)&0xFF))); - width = (((v>>16)&0xFF)+1)-(v&0xFF); - height = ((v>>24)+1)-((v>>8)&0xFF); -} - -void gfx3d_glClearColor(u32 v) -{ - gfx3d.clearColor = v; -} - -void gfx3d_glFogColor(u32 v) -{ - gfx3d.fogColor = v; -} - -void gfx3d_glFogOffset (u32 v) -{ - gfx3d.fogOffset = (v&0x7fff); -} - -void gfx3d_glClearDepth(u32 v) -{ - v &= 0x7FFF; - gfx3d.clearDepth = gfx3d_extendDepth_15_to_24(v); -} - -// Ignored for now -void gfx3d_glSwapScreen(unsigned int screen) -{ -} - -int gfx3d_GetNumPolys() -{ - //so is this in the currently-displayed or currently-built list? - return (polylists[listTwiddle].count); -} - -int gfx3d_GetNumVertex() -{ - //so is this in the currently-displayed or currently-built list? - return (vertlists[listTwiddle].count); -} - -void gfx3d_UpdateToonTable(u8 offset, u16 val) -{ - gfx3d.u16ToonTable[offset] = val; -} - -void gfx3d_UpdateToonTable(u8 offset, u32 val) -{ - gfx3d.u16ToonTable[offset] = val & 0xFFFF; - gfx3d.u16ToonTable[offset+1] = val >> 8; -} - -s32 gfx3d_GetClipMatrix (unsigned int index) -{ - float val = MatrixGetMultipliedIndex (index, mtxCurrent[0], mtxCurrent[1]); - - val *= (1<<12); - - return (s32)val; -} - -s32 gfx3d_GetDirectionalMatrix (unsigned int index) -{ - int _index = (((index / 3) * 4) + (index % 3)); - - return (s32)(mtxCurrent[2][_index]*(1<<12)); -} - -void gfx3d_ClearStack() -{ - MatrixStackSetStackPosition(&mtxStack[0], -5); - MatrixStackSetStackPosition(&mtxStack[3], -5); -} - -void gfx3d_glAlphaFunc(u32 v) -{ - gfx3d.alphaTestRef = v&31; -} - -unsigned int gfx3d_glGetPosRes(unsigned int index) -{ - return (unsigned int)(PTcoords[index] * 4096.0f); -} - -unsigned short gfx3d_glGetVecRes(unsigned int index) -{ - //INFO("NDS_glGetVecRes\n"); - return 0; -} - -#ifdef USE_GEOMETRY_FIFO_EMULATION - -//#define _3D_LOG_EXEC -void FORCEINLINE gfx3d_execute(u8 cmd, u32 param) -{ -#ifdef _3D_LOG_EXEC - u32 gxstat2 = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); - INFO("*** gxFIFO: exec 0x%02X, tail %03i, gxstat 0x%08X (timer %i)\n", cmd, gxFIFO.tail, gxstat2, nds_timer); -#endif - switch (cmd) - { - case 0x10: // MTX_MODE - Set Matrix Mode (W) - gfx3d_glMatrixMode(param); - break; - case 0x11: // MTX_PUSH - Push Current Matrix on Stack (W) - gfx3d_glPushMatrix(); - break; - case 0x12: // MTX_POP - Pop Current Matrix from Stack (W) - gfx3d_glPopMatrix(param); - break; - case 0x13: // MTX_STORE - Store Current Matrix on Stack (W) - gfx3d_glStoreMatrix(param); - break; - case 0x14: // MTX_RESTORE - Restore Current Matrix from Stack (W) - gfx3d_glRestoreMatrix(param); - break; - case 0x15: // MTX_IDENTITY - Load Unit Matrix to Current Matrix (W) - gfx3d_glLoadIdentity(); - break; - case 0x16: // MTX_LOAD_4x4 - Load 4x4 Matrix to Current Matrix (W) - gfx3d_glLoadMatrix4x4(param); - break; - case 0x17: // MTX_LOAD_4x3 - Load 4x3 Matrix to Current Matrix (W) - gfx3d_glLoadMatrix4x3(param); - break; - case 0x18: // MTX_MULT_4x4 - Multiply Current Matrix by 4x4 Matrix (W) - gfx3d_glMultMatrix4x4(param); - break; - case 0x19: // MTX_MULT_4x3 - Multiply Current Matrix by 4x3 Matrix (W) - gfx3d_glMultMatrix4x3(param); - break; - case 0x1A: // MTX_MULT_3x3 - Multiply Current Matrix by 3x3 Matrix (W) - gfx3d_glMultMatrix3x3(param); - break; - case 0x1B: // MTX_SCALE - Multiply Current Matrix by Scale Matrix (W) - gfx3d_glScale(param); - break; - case 0x1C: // MTX_TRANS - Mult. Curr. Matrix by Translation Matrix (W) - gfx3d_glTranslate(param); - break; - case 0x20: // COLOR - Directly Set Vertex Color (W) - gfx3d_glColor3b(param); - break; - case 0x21: // NORMAL - Set Normal Vector (W) - gfx3d_glNormal(param); - break; - case 0x22: // TEXCOORD - Set Texture Coordinates (W) - gfx3d_glTexCoord(param); - break; - case 0x23: // VTX_16 - Set Vertex XYZ Coordinates (W) - gfx3d_glVertex16b(param); - break; - case 0x24: // VTX_10 - Set Vertex XYZ Coordinates (W) - gfx3d_glVertex10b(param); - break; - case 0x25: // VTX_XY - Set Vertex XY Coordinates (W) - gfx3d_glVertex3_cord(0, 1, param); - break; - case 0x26: // VTX_XZ - Set Vertex XZ Coordinates (W) - gfx3d_glVertex3_cord(0, 2, param); - break; - case 0x27: // VTX_YZ - Set Vertex YZ Coordinates (W) - gfx3d_glVertex3_cord(1, 2, param); - break; - case 0x28: // VTX_DIFF - Set Relative Vertex Coordinates (W) - gfx3d_glVertex_rel(param); - break; - case 0x29: // POLYGON_ATTR - Set Polygon Attributes (W) - gfx3d_glPolygonAttrib(param); - break; - case 0x2A: // TEXIMAGE_PARAM - Set Texture Parameters (W) - gfx3d_glTexImage(param); - break; - case 0x2B: // PLTT_BASE - Set Texture Palette Base Address (W) - gfx3d_glTexPalette(param); - break; - case 0x30: // DIF_AMB - MaterialColor0 - Diffuse/Ambient Reflect. (W) - gfx3d_glMaterial0(param); - break; - case 0x31: // SPE_EMI - MaterialColor1 - Specular Ref. & Emission (W) - gfx3d_glMaterial1(param); - break; - case 0x32: // LIGHT_VECTOR - Set Light's Directional Vector (W) - gfx3d_glLightDirection(param); - break; - case 0x33: // LIGHT_COLOR - Set Light Color (W) - gfx3d_glLightColor(param); - break; - case 0x34: // SHININESS - Specular Reflection Shininess Table (W) - gfx3d_glShininess(param); - break; - case 0x40: // BEGIN_VTXS - Start of Vertex List (W) - gfx3d_glBegin(param); - break; - case 0x41: // END_VTXS - End of Vertex List (W) - gfx3d_glEnd(); - break; - case 0x50: // SWAP_BUFFERS - Swap Rendering Engine Buffer (W) - gfx3d_glFlush(param); - break; - case 0x60: // VIEWPORT - Set Viewport (W) - gfx3d_glViewPort(param); - break; - case 0x70: // BOX_TEST - Test if Cuboid Sits inside View Volume (W) - gfx3d_glBoxTest(param); - break; - case 0x71: // POS_TEST - Set Position Coordinates for Test (W) - gfx3d_glPosTest(param); - break; - case 0x72: // VEC_TEST - Set Directional Vector for Test (W) - gfx3d_glVecTest(param); - break; - default: - INFO("Unknown execute FIFO 3D command 0x%02X with param 0x%08X\n", cmd, param); - break; - } - NDS_RescheduleGXFIFO(); -} - -void gfx3d_execute3D() -{ - u8 cmd = 0; - u32 param = 0; - - if (isSwapBuffers) return; - - if (GFX_PIPErecv(&cmd, ¶m)) - { - gfx3d_execute(cmd, param); - } -} -#endif - -void gfx3d_glFlush(u32 v) -{ - -#ifdef USE_GEOMETRY_FIFO_EMULATION - gfx3d.sortmode = BIT0(v); - gfx3d.wbuffer = BIT1(v); -#if 0 - if (isSwapBuffers) - { - INFO("Error: swapBuffers already use\n"); - } -#endif - isSwapBuffers = true; -#else - if(!flushPending) - { - gfx3d.sortmode = BIT0(v); - gfx3d.wbuffer = BIT1(v); - flushPending = TRUE; - } - //see discussion at top of file - if(CommonSettings.gfx3d_flushMode == 0) - gfx3d_doFlush(); -#endif - -} - -static bool gfx3d_ysort_compare(int num1, int num2) -{ - const POLY &poly1 = polylist->list[num1]; - const POLY &poly2 = polylist->list[num2]; - - //this may be verified by checking the game create menus in harvest moon island of happiness - //also the buttons in the knights in the nightmare frontend depend on this and the perspective division - if (poly1.maxy < poly2.maxy) return true; - if (poly1.maxy > poly2.maxy) return false; - if (poly1.miny > poly2.miny) return true; - if (poly1.miny < poly2.miny) return false; - //notably, the main shop interface in harvest moon will not have a correct RTN button - //i think this is due to a math error rounding its position to one pixel too high and it popping behind - //the bar that it sits on. - //everything else in all the other menus that I could find looks right.. - - //make sure we respect the game's ordering in cases of complete ties - //this makes it a stable sort. - //this must be a stable sort or else advance wars DOR will flicker in the main map mode - if (num1 < num2) return true; - else return false; -} - -static void gfx3d_doFlush() -{ - gfx3d.frameCtr++; - -#ifndef USE_GEOMETRY_FIFO_EMULATION - GFX_PIPEclear(); - GFX_FIFOclear(); - // reset - clInd = 0; - clCmd = 0; -#endif - - //the renderer will get the lists we just built - gfx3d.polylist = polylist; - gfx3d.vertlist = vertlist; - - //and also our current render state - if(BIT1(control)) gfx3d.shading = GFX3D::HIGHLIGHT; - else gfx3d.shading = GFX3D::TOON; - gfx3d.enableTexturing = BIT0(control); - gfx3d.enableAlphaTest = BIT2(control); - gfx3d.enableAlphaBlending = BIT3(control); - gfx3d.enableAntialiasing = BIT4(control); - gfx3d.enableEdgeMarking = BIT5(control); - gfx3d.enableFogAlphaOnly = BIT6(control); - gfx3d.enableFog = BIT7(control); - gfx3d.enableClearImage = BIT14(control); - gfx3d.fogShift = (control>>8)&0xF; - - int polycount = polylist->count; - - //find the min and max y values for each poly. - //TODO - this could be a small waste of time if we are manual sorting the translucent polys - //TODO - this _MUST_ be moved later in the pipeline, after clipping. - //the w-division here is just an approximation to fix the shop in harvest moon island of happiness - //also the buttons in the knights in the nightmare frontend depend on this - for(int i=0; ilist[i]; - float verty = vertlist->list[poly.vertIndexes[0]].y; - float vertw = vertlist->list[poly.vertIndexes[0]].w; - verty = (verty+vertw)/(2*vertw); - poly.miny = poly.maxy = verty; - - for(int j=1; jlist[poly.vertIndexes[j]].y; - vertw = vertlist->list[poly.vertIndexes[j]].w; - verty = (verty+vertw)/(2*vertw); - poly.miny = min(poly.miny, verty); - poly.maxy = max(poly.maxy, verty); - } - } - - //we need to sort the poly list with alpha polys last - //first, look for opaque polys - int ctr=0; - for(int i=0;ilist[i]; - if(!poly.isTranslucent()) - gfx3d.indexlist[ctr++] = i; - } - int opaqueCount = ctr; - //then look for translucent polys - for(int i=0;ilist[i]; - if(poly.isTranslucent()) - gfx3d.indexlist[ctr++] = i; - } - - //now we have to sort the opaque polys by y-value. - //(test case: harvest moon island of happiness character cretor UI) - //should this be done after clipping?? - std::sort(gfx3d.indexlist, gfx3d.indexlist + opaqueCount, gfx3d_ysort_compare); - - if(!gfx3d.sortmode) - { - //if we are autosorting translucent polys, we need to do this also - //TODO - this is unverified behavior. need a test case - std::sort(gfx3d.indexlist + opaqueCount, gfx3d.indexlist + polycount, gfx3d_ysort_compare); - } - - //switch to the new lists - twiddleLists(); - -#ifndef USE_GEOMETRY_FIFO_EMULATION - flushPending = FALSE; - drawPending = TRUE; -#else - drawPending = TRUE; -#endif -} - -void gfx3d_VBlankSignal() -{ -#ifdef USE_GEOMETRY_FIFO_EMULATION - isVBlank = true; - if (isSwapBuffers) - { - gfx3d_doFlush(); - isSwapBuffers = false; - } -#else - //the 3d buffers are swapped when a vblank begins. - //so, if we have a redraw pending, now is a safe time to do it - if(!flushPending) - { - GFX_PIPEclear(); - GFX_FIFOclear(); - return; - } - - //see discussion at top of file - if(CommonSettings.gfx3d_flushMode == 1) - gfx3d_doFlush(); -#endif -} - -void gfx3d_VBlankEndSignal(bool skipFrame) -{ -#ifdef USE_GEOMETRY_FIFO_EMULATION - isVBlank = false; - - if (!drawPending) return; - drawPending = FALSE; - - GFX_DELAY(392); - NDS_RescheduleGXFIFO(); - - if(skipFrame) return; - //if the null 3d core is chosen, then we need to clear out the 3d buffers to keep old data from being rendered - if(gpu3D == &gpu3DNull || !CommonSettings.showGpu.main) - { - memset(gfx3d_convertedScreen,0,sizeof(gfx3d_convertedScreen)); - return; - } - - gpu3D->NDS_3D_Render(); -#else - //if we are skipping 3d frames then the 3d rendering will get held up here. - //but, as soon as we quit skipping frames, the held-up 3d frame will render - if(skipFrame) return; - if(!drawPending) return; - - drawPending = FALSE; - - if(CommonSettings.showGpu.main) - gpu3D->NDS_3D_Render(); - - //if the null 3d core is chosen, then we need to clear out the 3d buffers to keep old data from being rendered - if(gpu3D == &gpu3DNull || !CommonSettings.showGpu.main) - { - memset(gfx3d_convertedScreen,0,sizeof(gfx3d_convertedScreen)); - } -#endif -} - -#ifdef USE_GEOMETRY_FIFO_EMULATION -//#define _3D_LOG - -// http://nocash.emubase.de/gbatek.htm#ds3dvideo -// DS 3D Geometry Commands -// Sending Commands by Ports 4000440h..40005FFh -// -// If the FIFO is full, then a wait is generated until data is removed from the FIFO, -// ie. the STR opcode gets freezed, during the wait, the bus cannot be used even by DMA, -// interrupts, or by the NDS7 CPU. - -// this is a hack -#if 1 -#define CHECKFULL() if (gxFIFO.size > 255) \ - {\ - gfx3d_execute3D();\ - gfx3d_execute3D();\ - gfx3d_execute3D();\ - gfx3d_execute3D();\ - } -#else -#define CHECKFULL() ; -#endif - -static void NOPARAMS() -{ - for (;;) - { - if (clCmd == 0) return; - switch (clCmd & 0xFF) - { - case 0x00: - { - clCmd >>= 8; - continue; - } - case 0x11: - case 0x15: - case 0x41: - { - CHECKFULL(); - GFX_FIFOsend(clCmd & 0xFF, 0); - clCmd >>= 8; - continue; - } - } - break; - } -} - -void gfx3d_sendCommandToFIFO(u32 val) -{ - if (clCmd == 0) - { - clInd2 = 0; - clCmd = val; - NOPARAMS(); - return; - } -#ifdef _3D_LOG - INFO("gxFIFO: send 0x%02X: val=0x%08X, pipe %02i, fifo %03i\n", clCmd & 0xFF, val, gxPIPE.tail, gxFIFO.tail); -#endif - - CHECKFULL(); - - switch (clCmd & 0xFF) - { - case 0x34: // SHININESS - Specular Reflection Shininess Table (W) - GFX_FIFOsend(clCmd & 0xFF, val); - - clInd2++; - if (clInd2 < 32) return; - clInd2 = 0; - clCmd >>= 8; - break; - - case 0x16: // MTX_LOAD_4x4 - Load 4x4 Matrix to Current Matrix (W) - case 0x18: // MTX_MULT_4x4 - Multiply Current Matrix by 4x4 Matrix (W) - GFX_FIFOsend(clCmd & 0xFF, val); - - clInd2++; - if (clInd2 < 16) return; - clInd2 = 0; - clCmd >>= 8; - break; - - case 0x17: // MTX_LOAD_4x3 - Load 4x3 Matrix to Current Matrix (W) - case 0x19: // MTX_MULT_4x3 - Multiply Current Matrix by 4x3 Matrix (W) - GFX_FIFOsend(clCmd & 0xFF, val); - - clInd2++; - if (clInd2 < 12) return; - clInd2 = 0; - clCmd >>= 8; - break; - - case 0x1A: // MTX_MULT_3x3 - Multiply Current Matrix by 3x3 Matrix (W) - GFX_FIFOsend(clCmd & 0xFF, val); - - clInd2++; - if (clInd2 < 9) return; - clInd2 = 0; - clCmd >>= 8; - break; - - case 0x1B: // MTX_SCALE - Multiply Current Matrix by Scale Matrix (W) - case 0x1C: // MTX_TRANS - Mult. Curr. Matrix by Translation Matrix (W) - case 0x70: // BOX_TEST - Test if Cuboid Sits inside View Volume (W) - GFX_FIFOsend(clCmd & 0xFF, val); - - clInd2++; - if (clInd2 < 3) return; - clInd2 = 0; - clCmd >>= 8; - break; - - case 0x23: // VTX_16 - Set Vertex XYZ Coordinates (W) - case 0x71: // POS_TEST - Set Position Coordinates for Test (W) - GFX_FIFOsend(clCmd & 0xFF, val); - - clInd2++; - if (clInd2 < 2) return; - clInd2 = 0; - clCmd >>= 8; - break; - - case 0x10: // MTX_MODE - Set Matrix Mode (W) - case 0x12: // MTX_POP - Pop Current Matrix from Stack (W) - case 0x13: // MTX_STORE - Store Current Matrix on Stack (W) - case 0x14: // MTX_RESTORE - Restore Current Matrix from Stack (W) - case 0x20: // COLOR - Directly Set Vertex Color (W) - case 0x21: // NORMAL - Set Normal Vector (W) - case 0x22: // TEXCOORD - Set Texture Coordinates (W) - case 0x24: // VTX_10 - Set Vertex XYZ Coordinates (W) - case 0x25: // VTX_XY - Set Vertex XY Coordinates (W) - case 0x26: // VTX_XZ - Set Vertex XZ Coordinates (W) - case 0x27: // VTX_YZ - Set Vertex YZ Coordinates (W) - case 0x28: // VTX_DIFF - Set Relative Vertex Coordinates (W) - case 0x29: // POLYGON_ATTR - Set Polygon Attributes (W) - case 0x2A: // TEXIMAGE_PARAM - Set Texture Parameters (W) - case 0x2B: // PLTT_BASE - Set Texture Palette Base Address (W) - case 0x30: // DIF_AMB - MaterialColor0 - Diffuse/Ambient Reflect. (W) - case 0x31: // SPE_EMI - MaterialColor1 - Specular Ref. & Emission (W) - case 0x32: // LIGHT_VECTOR - Set Light's Directional Vector (W) - case 0x33: // LIGHT_COLOR - Set Light Color (W) - case 0x40: // BEGIN_VTXS - Start of Vertex List (W) - case 0x60: // VIEWPORT - Set Viewport (W) - case 0x72: // VEC_TEST - Set Directional Vector for Test (W) - GFX_FIFOsend(clCmd & 0xFF, val); - clCmd >>= 8; - break; - case 0x50: // SWAP_BUFFERS - Swap Rendering Engine Buffer (W) - GFX_FIFOsend(clCmd & 0xFF, val); - clCmd >>= 8; - break; - default: - INFO("Unknown FIFO 3D command 0x%02X (0x%08X)\n", clCmd&0xFF, clCmd); - clCmd >>= 8; - break; - } - NOPARAMS(); -} - -void gfx3d_sendCommand(u32 cmd, u32 param) -{ - cmd = (cmd & 0x01FF) >> 2; -#ifdef _3D_LOG - INFO("gxFIFO: send 0x%02X: val=0x%08X, pipe %02i, fifo %03i (direct)\n", cmd, param, gxPIPE.tail, gxFIFO.tail); -#endif - - CHECKFULL(); - - switch (cmd) - { - case 0x10: // MTX_MODE - Set Matrix Mode (W) - case 0x11: // MTX_PUSH - Push Current Matrix on Stack (W) - case 0x12: // MTX_POP - Pop Current Matrix from Stack (W) - case 0x13: // MTX_STORE - Store Current Matrix on Stack (W) - case 0x14: // MTX_RESTORE - Restore Current Matrix from Stack (W) - case 0x15: // MTX_IDENTITY - Load Unit Matrix to Current Matrix (W) - case 0x16: // MTX_LOAD_4x4 - Load 4x4 Matrix to Current Matrix (W) - case 0x17: // MTX_LOAD_4x3 - Load 4x3 Matrix to Current Matrix (W) - case 0x18: // MTX_MULT_4x4 - Multiply Current Matrix by 4x4 Matrix (W) - case 0x19: // MTX_MULT_4x3 - Multiply Current Matrix by 4x3 Matrix (W) - case 0x1A: // MTX_MULT_3x3 - Multiply Current Matrix by 3x3 Matrix (W) - case 0x1B: // MTX_SCALE - Multiply Current Matrix by Scale Matrix (W) - case 0x1C: // MTX_TRANS - Mult. Curr. Matrix by Translation Matrix (W) - case 0x20: // COLOR - Directly Set Vertex Color (W) - case 0x21: // NORMAL - Set Normal Vector (W) - case 0x22: // TEXCOORD - Set Texture Coordinates (W) - case 0x23: // VTX_16 - Set Vertex XYZ Coordinates (W) - case 0x24: // VTX_10 - Set Vertex XYZ Coordinates (W) - case 0x25: // VTX_XY - Set Vertex XY Coordinates (W) - case 0x26: // VTX_XZ - Set Vertex XZ Coordinates (W) - case 0x27: // VTX_YZ - Set Vertex YZ Coordinates (W) - case 0x28: // VTX_DIFF - Set Relative Vertex Coordinates (W) - case 0x29: // POLYGON_ATTR - Set Polygon Attributes (W) - case 0x2A: // TEXIMAGE_PARAM - Set Texture Parameters (W) - case 0x2B: // PLTT_BASE - Set Texture Palette Base Address (W) - case 0x30: // DIF_AMB - MaterialColor0 - Diffuse/Ambient Reflect. (W) - case 0x31: // SPE_EMI - MaterialColor1 - Specular Ref. & Emission (W) - case 0x32: // LIGHT_VECTOR - Set Light's Directional Vector (W) - case 0x33: // LIGHT_COLOR - Set Light Color (W) - case 0x34: // SHININESS - Specular Reflection Shininess Table (W) - case 0x40: // BEGIN_VTXS - Start of Vertex List (W) - case 0x41: // END_VTXS - End of Vertex List (W) - case 0x60: // VIEWPORT - Set Viewport (W) - case 0x70: // BOX_TEST - Test if Cuboid Sits inside View Volume (W) - case 0x71: // POS_TEST - Set Position Coordinates for Test (W) - case 0x72: // VEC_TEST - Set Directional Vector for Test (W) - GFX_FIFOsend(cmd, param); - break; - case 0x50: // SWAP_BUFFERS - Swap Rendering Engine Buffer (W) - GFX_FIFOsend(cmd, param); - break; - default: - INFO("Unknown 3D command %03X with param 0x%08X (directport)\n", cmd, param); - break; - } -} - -#else -//#define _3D_LOG - -static void NOPARAMS() -{ - for (;;) - { - if (clCmd == 0) return; - switch (clCmd & 0xFF) - { - case 0x00: - { - clCmd >>= 8; - continue; - } - case 0x11: - { - gfx3d_glPushMatrix(); - GFX_FIFOsend(clCmd & 0xFF, 0); - clCmd >>= 8; - continue; - } - case 0x15: - { - gfx3d_glLoadIdentity(); - GFX_FIFOsend(clCmd & 0xFF, 0); - clCmd >>= 8; - continue; - } - case 0x41: - { - gfx3d_glEnd(); - GFX_FIFOsend(clCmd & 0xFF, 0); - clCmd >>= 8; - continue; - } - } - break; - } -} - -void gfx3d_sendCommandToFIFO(u32 val) -{ - //friendly reminder: be careful to handle the case where several unpacked noparams commands get sent in a row! - - if (clCmd == 0) - { - clCmd = val; - NOPARAMS(); - return; - } -#ifdef _3D_LOG - INFO("GFX FIFO: Send GFX 3D cmd 0x%02X to FIFO (0x%08X)\n", clCmd & 0xFF, val); -#endif - - switch (clCmd & 0xFF) - { - case 0x10: // MTX_MODE - Set Matrix Mode (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glMatrixMode(val); - clCmd >>= 8; - break; - case 0x12: // MTX_POP - Pop Current Matrix from Stack (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glPopMatrix(val); - clCmd >>= 8; - break; - case 0x13: // MTX_STORE - Store Current Matrix on Stack (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glStoreMatrix(val); - clCmd >>= 8; - break; - case 0x14: // MTX_RESTORE - Restore Current Matrix from Stack (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glRestoreMatrix(val); - clCmd >>= 8; - break; - case 0x16: // MTX_LOAD_4x4 - Load 4x4 Matrix to Current Matrix (W) - GFX_FIFOsend(clCmd & 0xFF, val); - if (!gfx3d_glLoadMatrix4x4(val)) break; - clCmd >>= 8; - break; - case 0x17: // MTX_LOAD_4x3 - Load 4x3 Matrix to Current Matrix (W) - GFX_FIFOsend(clCmd & 0xFF, val); - if (!gfx3d_glLoadMatrix4x3(val)) break; - clCmd >>= 8; - break; - case 0x18: // MTX_MULT_4x4 - Multiply Current Matrix by 4x4 Matrix (W) - GFX_FIFOsend(clCmd & 0xFF, val); - if (!gfx3d_glMultMatrix4x4(val)) break; - clCmd >>= 8; - break; - case 0x19: // MTX_MULT_4x3 - Multiply Current Matrix by 4x3 Matrix (W) - GFX_FIFOsend(clCmd & 0xFF, val); - if (!gfx3d_glMultMatrix4x3(val)) break; - clCmd >>= 8; - break; - case 0x1A: // MTX_MULT_3x3 - Multiply Current Matrix by 3x3 Matrix (W) - GFX_FIFOsend(clCmd & 0xFF, val); - if (!gfx3d_glMultMatrix3x3(val)) break; - clCmd >>= 8; - break; - case 0x1B: // MTX_SCALE - Multiply Current Matrix by Scale Matrix (W) - GFX_FIFOsend(clCmd & 0xFF, val); - if (!gfx3d_glScale(val)) break; - clCmd >>= 8; - break; - case 0x1C: // MTX_TRANS - Mult. Curr. Matrix by Translation Matrix (W) - GFX_FIFOsend(clCmd & 0xFF, val); - if (!gfx3d_glTranslate(val)) break; - clCmd >>= 8; - break; - case 0x20: // COLOR - Directly Set Vertex Color (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glColor3b(val); - clCmd >>= 8; - break; - case 0x21: // NORMAL - Set Normal Vector (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glNormal(val); - clCmd >>= 8; - break; - case 0x22: // TEXCOORD - Set Texture Coordinates (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glTexCoord(val); - clCmd >>= 8; - break; - case 0x23: // VTX_16 - Set Vertex XYZ Coordinates (W) - GFX_FIFOsend(clCmd & 0xFF, val); - if (!gfx3d_glVertex16b(val)) break; - clCmd >>= 8; - break; - case 0x24: // VTX_10 - Set Vertex XYZ Coordinates (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glVertex10b(val); - clCmd >>= 8; - break; - case 0x25: // VTX_XY - Set Vertex XY Coordinates (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glVertex3_cord(0, 1, val); - clCmd >>= 8; - break; - case 0x26: // VTX_XZ - Set Vertex XZ Coordinates (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glVertex3_cord(0, 2, val); - clCmd >>= 8; - break; - case 0x27: // VTX_YZ - Set Vertex YZ Coordinates (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glVertex3_cord(1, 2, val); - clCmd >>= 8; - break; - case 0x28: // VTX_DIFF - Set Relative Vertex Coordinates (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glVertex_rel(val); - clCmd >>= 8; - break; - case 0x29: // POLYGON_ATTR - Set Polygon Attributes (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glPolygonAttrib(val); - clCmd >>= 8; - break; - case 0x2A: // TEXIMAGE_PARAM - Set Texture Parameters (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glTexImage(val); - clCmd >>= 8; - break; - case 0x2B: // PLTT_BASE - Set Texture Palette Base Address (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glTexPalette(val); - clCmd >>= 8; - break; - case 0x30: // DIF_AMB - MaterialColor0 - Diffuse/Ambient Reflect. (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glMaterial0(val); - clCmd >>= 8; - break; - case 0x31: // SPE_EMI - MaterialColor1 - Specular Ref. & Emission (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glMaterial1(val); - clCmd >>= 8; - break; - case 0x32: // LIGHT_VECTOR - Set Light's Directional Vector (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glLightDirection(val); - clCmd >>= 8; - break; - case 0x33: // LIGHT_COLOR - Set Light Color (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glLightColor(val); - clCmd >>= 8; - break; - case 0x34: // SHININESS - Specular Reflection Shininess Table (W) - GFX_FIFOsend(clCmd & 0xFF, val); - if (!gfx3d_glShininess(val)) break; - clCmd >>= 8; - break; - case 0x40: // BEGIN_VTXS - Start of Vertex List (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glBegin(val); - clCmd >>= 8; - break; - case 0x50: // SWAP_BUFFERS - Swap Rendering Engine Buffer (W) - gfx3d_glFlush(val); - break; - case 0x60: // VIEWPORT - Set Viewport (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glViewPort(val); - clCmd >>= 8; - break; - case 0x70: // BOX_TEST - Test if Cuboid Sits inside View Volume (W) - GFX_FIFOsend(clCmd & 0xFF, val); - if (!gfx3d_glBoxTest(val)) break; - clCmd >>= 8; - break; - case 0x71: // POS_TEST - Set Position Coordinates for Test (W) - GFX_FIFOsend(clCmd & 0xFF, val); - if (!gfx3d_glPosTest(val)) break; - clCmd >>= 8; - break; - case 0x72: // VEC_TEST - Set Directional Vector for Test (W) - GFX_FIFOsend(clCmd & 0xFF, val); - gfx3d_glVecTest(val); - clCmd >>= 8; - break; - default: - LOG("Unknown FIFO 3D command 0x%02X in cmd=0x%02X\n", clCmd&0xFF, val); - clCmd >>= 8; - break; - } - NOPARAMS(); -} - -void gfx3d_sendCommand(u32 cmd, u32 param) -{ - cmd &= 0x0FFF; -#ifdef _3D_LOG - INFO("GFX FIFO: Send GFX 3D cmd 0x%02X to FIFO (0x%08X) - DIRECT\n", (cmd & 0x1FF)>>2, param); -#endif - - switch (cmd) - { - case 0x340: // Alpha test reference value - Parameters:1 - gfx3d_glAlphaFunc(param); - break; - case 0x350: // Clear background color setup - Parameters:2 - gfx3d_glClearColor(param); - break; - case 0x354: // Clear background depth setup - Parameters:2 - gfx3d_glClearDepth(param); - break; - case 0x356: // Rear-plane Bitmap Scroll Offsets (W) - break; - case 0x358: // Fog Color - Parameters:4b - gfx3d_glFogColor(param); - break; - case 0x35C: - gfx3d_glFogOffset(param); - break; - case 0x440: // MTX_MODE - Set Matrix Mode (W) - gfx3d_glMatrixMode(param); - break; - case 0x444: // MTX_PUSH - Push Current Matrix on Stack (W) - gfx3d_glPushMatrix(); - break; - case 0x448: // MTX_POP - Pop Current Matrix from Stack (W) - gfx3d_glPopMatrix(param); - break; - case 0x44C: // MTX_STORE - Store Current Matrix on Stack (W) - gfx3d_glStoreMatrix(param); - break; - case 0x450: // MTX_RESTORE - Restore Current Matrix from Stack (W) - gfx3d_glRestoreMatrix(param); - break; - case 0x454: // MTX_IDENTITY - Load Unit Matrix to Current Matrix (W) - gfx3d_glLoadIdentity(); - break; - case 0x458: // MTX_LOAD_4x4 - Load 4x4 Matrix to Current Matrix (W) - gfx3d_glLoadMatrix4x4(param); - break; - case 0x45C: // MTX_LOAD_4x3 - Load 4x3 Matrix to Current Matrix (W) - gfx3d_glLoadMatrix4x3(param); - break; - case 0x460: // MTX_MULT_4x4 - Multiply Current Matrix by 4x4 Matrix (W) - gfx3d_glMultMatrix4x4(param); - break; - case 0x464: // MTX_MULT_4x3 - Multiply Current Matrix by 4x3 Matrix (W) - gfx3d_glMultMatrix4x3(param); - break; - case 0x468: // MTX_MULT_3x3 - Multiply Current Matrix by 3x3 Matrix (W) - gfx3d_glMultMatrix3x3(param); - break; - case 0x46C: // MTX_SCALE - Multiply Current Matrix by Scale Matrix (W) - gfx3d_glScale(param); - break; - case 0x470: // MTX_TRANS - Mult. Curr. Matrix by Translation Matrix (W) - gfx3d_glTranslate(param); - break; - case 0x480: // COLOR - Directly Set Vertex Color (W) - gfx3d_glColor3b(param); - break; - case 0x484: // NORMAL - Set Normal Vector (W) - gfx3d_glNormal(param); - break; - case 0x488: // TEXCOORD - Set Texture Coordinates (W) - gfx3d_glTexCoord(param); - break; - case 0x48C: // VTX_16 - Set Vertex XYZ Coordinates (W) - gfx3d_glVertex16b(param); - break; - case 0x490: // VTX_10 - Set Vertex XYZ Coordinates (W) - gfx3d_glVertex10b(param); - break; - case 0x494: // VTX_XY - Set Vertex XY Coordinates (W) - gfx3d_glVertex3_cord(0, 1, param); - break; - case 0x498: // VTX_XZ - Set Vertex XZ Coordinates (W) - gfx3d_glVertex3_cord(0, 2, param); - break; - case 0x49C: // VTX_YZ - Set Vertex YZ Coordinates (W) - gfx3d_glVertex3_cord(1, 2, param); - break; - case 0x4A0: // VTX_DIFF - Set Relative Vertex Coordinates (W) - gfx3d_glVertex_rel(param); - break; - case 0x4A4: // POLYGON_ATTR - Set Polygon Attributes (W) - gfx3d_glPolygonAttrib(param); - break; - case 0x4A8: // TEXIMAGE_PARAM - Set Texture Parameters (W) - gfx3d_glTexImage(param); - break; - case 0x4AC: // PLTT_BASE - Set Texture Palette Base Address (W) - gfx3d_glTexPalette(param); - break; - case 0x4C0: // DIF_AMB - MaterialColor0 - Diffuse/Ambient Reflect. (W) - gfx3d_glMaterial0(param); - break; - case 0x4C4: // SPE_EMI - MaterialColor1 - Specular Ref. & Emission (W) - gfx3d_glMaterial1(param); - break; - case 0x4C8: // LIGHT_VECTOR - Set Light's Directional Vector (W) - gfx3d_glLightDirection(param); - break; - case 0x4CC: // LIGHT_COLOR - Set Light Color (W) - gfx3d_glLightColor(param); - break; - case 0x4D0: // SHININESS - Specular Reflection Shininess Table (W) - gfx3d_glShininess(param); - break; - case 0x500: // BEGIN_VTXS - Start of Vertex List (W) - gfx3d_glBegin(param); - break; - case 0x504: // END_VTXS - End of Vertex List (W) - gfx3d_glEnd(); - break; - case 0x540: // SWAP_BUFFERS - Swap Rendering Engine Buffer (W) - gfx3d_glFlush(param); - break; - case 0x580: // VIEWPORT - Set Viewport (W) - gfx3d_glViewPort(param); - break; - case 0x5C0: // BOX_TEST - Test if Cuboid Sits inside View Volume (W) - gfx3d_glBoxTest(param); - break; - case 0x5C4: // POS_TEST - Set Position Coordinates for Test (W) - gfx3d_glPosTest(param); - break; - case 0x5C8: // VEC_TEST - Set Directional Vector for Test (W) - gfx3d_glVecTest(param); - break; - default: - LOG("Execute direct Port 3D command %03X in param=0x%08X\n", cmd, param); - break; - } -} -#endif - -void gfx3d_Control(u32 v) -{ - control = v; -} - -//-------------- -//other misc stuff -void gfx3d_glGetMatrix(unsigned int m_mode, int index, float* dest) -{ - if(index == -1) - { - MatrixCopy(dest, mtxCurrent[m_mode]); - return; - } - - MatrixCopy(dest, MatrixStackGetPos(&mtxStack[m_mode], index)); -} - -void gfx3d_glGetLightDirection(unsigned int index, unsigned int* dest) -{ - *dest = lightDirection[index]; -} - -void gfx3d_glGetLightColor(unsigned int index, unsigned int* dest) -{ - *dest = lightColor[index]; -} - -void gfx3d_GetLineData(int line, u8** dst) -{ - *dst = gfx3d_convertedScreen+((line)<<(8+2)); -} - -void gfx3d_GetLineData15bpp(int line, u16** dst) -{ - //TODO - this is not very thread safe!!! - static u16 buf[256]; - *dst = buf; - - u8* lineData; - gfx3d_GetLineData(line, &lineData); - for(int i=0;i<256;i++) - { - const u8 r = lineData[i*4+0]; - const u8 g = lineData[i*4+1]; - const u8 b = lineData[i*4+2]; - const u8 a = lineData[i*4+3]; - buf[i] = R6G6B6TORGB15(r,g,b) | (a==0?0:0x8000); - } -} - - -//http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node17.html -//talks about the state required to process verts in quadlists etc. helpful ideas. -//consider building a little state structure that looks exactly like this describes - -SFORMAT SF_GFX3D[]={ - { "GCTL", 4, 1, &control}, // no longer regenerated indirectly, see comment in loadstate() - { "GPAT", 4, 1, &polyAttr}, - { "GPAP", 4, 1, &polyAttrPending}, - { "GINB", 4, 1, &inBegin}, - { "GTFM", 4, 1, &textureFormat}, - { "GTPA", 4, 1, &texturePalette}, - { "GMOD", 4, 1, &mode}, - { "GMTM", 4,16, mtxTemporal}, - { "GMCU", 4,64, mtxCurrent}, - { "ML4I", 1, 1, &ML4x4ind}, - { "ML3I", 1, 1, &ML4x3ind}, - { "MM4I", 1, 1, &MM4x4ind}, - { "MM3I", 1, 1, &MM4x3ind}, - { "MMxI", 1, 1, &MM3x3ind}, - { "GCOR", 4, 1, coord}, - { "GCOI", 1, 1, &coordind}, - { "GVFM", 4, 1, &vtxFormat}, - { "GTRN", 4, 4, trans}, - { "GTRI", 1, 1, &transind}, - { "GSCA", 4, 4, scale}, - { "GSCI", 1, 1, &scaleind}, - { "G_T_", 4, 1, &_t}, - { "G_S_", 4, 1, &_s}, - { "GL_T", 4, 1, &last_t}, - { "GL_S", 4, 1, &last_s}, - { "GLCM", 4, 1, &clCmd}, - { "GLIN", 4, 1, &clInd}, -#ifdef USE_GEOMETRY_FIFO_EMULATION - { "GLI2", 4, 1, &clInd2}, - { "GLSB", 1, 1, &isSwapBuffers}, -#endif - { "GLBT", 4, 1, &BTind}, - { "GLPT", 4, 1, &PTind}, - { "GLPC", 4, 4, PTcoords}, - { "GFHE", 2, 1, &gxFIFO.head}, - { "GFTA", 2, 1, &gxFIFO.tail}, - { "GFSZ", 2, 1, &gxFIFO.size}, - { "GFCM", 1, 256, &gxFIFO.cmd[0]}, - { "GFPM", 4, 256, &gxFIFO.param[0]}, - { "GPHE", 1, 1, &gxPIPE.head}, - { "GPTA", 1, 1, &gxPIPE.tail}, - { "GPSZ", 1, 1, &gxPIPE.size}, - { "GPCM", 1, 4, &gxPIPE.cmd[0]}, - { "GPPM", 4, 4, &gxPIPE.param[0]}, - { "GCOL", 1, 4, &colorRGB[0]}, - { "GLCO", 4, 4, lightColor}, - { "GLDI", 4, 4, lightDirection}, - { "GMDI", 2, 1, &dsDiffuse}, - { "GMAM", 2, 1, &dsAmbient}, - { "GMSP", 2, 1, &dsSpecular}, - { "GMEM", 2, 1, &dsEmission}, - { "GFLP", 4, 1, &flushPending}, - { "GDRP", 4, 1, &drawPending}, - { "GSET", 4, 1, &gfx3d.enableTexturing}, - { "GSEA", 4, 1, &gfx3d.enableAlphaTest}, - { "GSEB", 4, 1, &gfx3d.enableAlphaBlending}, - { "GSEX", 4, 1, &gfx3d.enableAntialiasing}, - { "GSEE", 4, 1, &gfx3d.enableEdgeMarking}, - { "GSEC", 4, 1, &gfx3d.enableClearImage}, - { "GSEF", 4, 1, &gfx3d.enableFog}, - { "GSEO", 4, 1, &gfx3d.enableFogAlphaOnly}, - { "GFSH", 4, 1, &gfx3d.fogShift}, - { "GSSH", 4, 1, &gfx3d.shading}, - { "GSWB", 4, 1, &gfx3d.wbuffer}, - { "GSSM", 4, 1, &gfx3d.sortmode}, - { "GSAR", 1, 1, &gfx3d.alphaTestRef}, - { "GSVP", 4, 1, &viewport}, - { "GSCC", 4, 1, &gfx3d.clearColor}, - { "GSCD", 4, 1, &gfx3d.clearDepth}, - { "GSFC", 4, 4, &gfx3d.fogColor}, - { "GSFO", 4, 1, &gfx3d.fogOffset}, - { "GST2", 2, 32, gfx3d.u16ToonTable}, - { "GSST", 4, 128, shininessTable}, - { "GSSI", 4, 1, &shininessInd}, - //------------------------ - { "GTST", 4, 1, &triStripToggle}, - { "GTVC", 4, 1, &tempVertInfo.count}, - { "GTVM", 4, 4, tempVertInfo.map}, - { "GTVF", 4, 1, &tempVertInfo.first}, - { "G3CX", 1, 4*256*192, gfx3d_convertedScreen}, - { 0 } -}; - -//-------------savestate -void gfx3d_savestate(std::ostream* os) -{ - //version - write32le(2,os); - - //dump the render lists - OSWRITE(vertlist->count); - for(int i=0;icount;i++) - vertlist->list[i].save(os); - OSWRITE(polylist->count); - for(int i=0;icount;i++) - polylist->list[i].save(os); - - for(int i=0;i<4;i++) - { - OSWRITE(mtxStack[i].position); - for(int j=0;j=1) - { - OSREAD(vertlist->count); - for(int i=0;icount;i++) - vertlist->list[i].load(is); - OSREAD(polylist->count); - for(int i=0;icount;i++) - polylist->list[i].load(is); - } - - if(version>=2) - { - for(int i=0;i<4;i++) - { - OSREAD(mtxStack[i].position); - for(int j=0;jcount=0; - gfx3d.vertlist->count=0; - - return true; -} +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//This file implements the geometry engine hardware component. +//This handles almost all of the work of 3d rendering, leaving the renderer +//plugin responsible only for drawing primitives. + +#include +#include +#include +#include +#include "armcpu.h" +#include "debug.h" +#include "gfx3d.h" +#include "matrix.h" +#include "bits.h" +#include "MMU.h" +#include "render3D.h" +#include "mem.h" +#include "types.h" +#include "saves.h" +#include "NDSSystem.h" +#include "readwrite.h" +#include "FIFO.h" + +/* +thoughts on flush timing: +I think a flush is supposed to queue up and wait to happen during vblank sometime. +But, we have some games that continue to do work after a flush but before a vblank. +Since our timing is bad anyway, and we're not sure when the flush is really supposed to happen, +then this leaves us in a bad situation. +What makes it worse is that if flush is supposed to be deferred, then we have to queue these +errant geometry commands. That would require a better gxfifo we have now, and some mechanism to block +while the geometry engine is stalled (which doesnt exist). +Since these errant games are nevertheless using flush command to represent the end of a frame, we deem this +a good time to execute an actual flush. +I think we originally didnt do this because we found some game that it glitched, but that may have been +resolved since then by deferring actual rendering to the next vcount=0 (giving textures enough time to upload). +But since we're not sure how we'll eventually want this, I am leaving it sort of reconfigurable, doing all the work +in this function: */ +static void gfx3d_doFlush(); + +#ifdef USE_GEOMETRY_FIFO_EMULATION +#define GFX_DELAY(x) MMU.gfx3dCycles = nds.cycles + (2*x) +#define GFX_DELAY_M2(x) MMU.gfx3dCycles += (2*x) +#else +#define GFX_DELAY(x) +#define GFX_DELAY_M2(x) +#endif + +using std::max; +using std::min; + +GFX3D gfx3d; + +//tables that are provided to anyone +CACHE_ALIGN u32 color_15bit_to_24bit_reverse[32768]; +CACHE_ALIGN u32 color_15bit_to_24bit[32768]; +CACHE_ALIGN u16 color_15bit_to_16bit_reverse[32768]; +CACHE_ALIGN u8 mixTable555[32][32][32]; + +//is this a crazy idea? this table spreads 5 bits evenly over 31 from exactly 0 to INT_MAX +CACHE_ALIGN const int material_5bit_to_31bit[] = { + 0x00000000, 0x04210842, 0x08421084, 0x0C6318C6, + 0x10842108, 0x14A5294A, 0x18C6318C, 0x1CE739CE, + 0x21084210, 0x25294A52, 0x294A5294, 0x2D6B5AD6, + 0x318C6318, 0x35AD6B5A, 0x39CE739C, 0x3DEF7BDE, + 0x42108421, 0x46318C63, 0x4A5294A5, 0x4E739CE7, + 0x5294A529, 0x56B5AD6B, 0x5AD6B5AD, 0x5EF7BDEF, + 0x6318C631, 0x6739CE73, 0x6B5AD6B5, 0x6F7BDEF7, + 0x739CE739, 0x77BDEF7B, 0x7BDEF7BD, 0x7FFFFFFF +}; + +CACHE_ALIGN const u8 material_5bit_to_6bit[] = { + 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0E, + 0x10, 0x12, 0x14, 0x16, 0x19, 0x1A, 0x1C, 0x1E, + 0x21, 0x23, 0x25, 0x27, 0x29, 0x2B, 0x2D, 0x2F, + 0x31, 0x33, 0x35, 0x37, 0x39, 0x3B, 0x3D, 0x3F +}; + +CACHE_ALIGN const u8 material_5bit_to_8bit[] = { + 0x00, 0x08, 0x10, 0x18, 0x21, 0x29, 0x31, 0x39, + 0x42, 0x4A, 0x52, 0x5A, 0x63, 0x6B, 0x73, 0x7B, + 0x84, 0x8C, 0x94, 0x9C, 0xA5, 0xAD, 0xB5, 0xBD, + 0xC6, 0xCE, 0xD6, 0xDE, 0xE7, 0xEF, 0xF7, 0xFF +}; + +CACHE_ALIGN const u8 material_3bit_to_8bit[] = { + 0x00, 0x24, 0x49, 0x6D, 0x92, 0xB6, 0xDB, 0xFF +}; + +//maybe not very precise +CACHE_ALIGN const u8 material_3bit_to_5bit[] = { + 0, 4, 8, 13, 17, 22, 26, 31 +}; + +CACHE_ALIGN const u8 alpha_5bit_to_4bit[] = { + 0x00, 0x00, + 0x01, 0x01, + 0x02, 0x02, + 0x03, 0x03, + 0x04, 0x04, + 0x05, 0x05, + 0x06, 0x06, + 0x07, 0x07, + 0x08, 0x08, + 0x09, 0x09, + 0x0A, 0x0A, + 0x0B, 0x0B, + 0x0C, 0x0C, + 0x0D, 0x0D, + 0x0E, 0x0E, + 0x10, 0x10 +}; + +CACHE_ALIGN const u16 alpha_lookup[] = { + 0x0000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, + 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000}; + + +//private acceleration tables +static float float16table[65536]; +static float float10Table[1024]; +static float float10RelTable[1024]; +static float normalTable[1024]; + +#ifndef NOSSE2 +float ALIGN(16) _fix2float_divizor_mask[4] = { 4096.f, 4096.f, 4096.f, 4096.f }; +float ALIGN(16) _fix10_2float_divizor_mask[4] = { 512.f, 512.f, 512.f, 512.f }; +#endif + +#define fix2float(v) (((float)((s32)(v))) / (float)(1<<12)) +#define fix10_2float(v) (((float)((s32)(v))) / (float)(1<<9)) + +CACHE_ALIGN u16 gfx3d_convertedScreen[256*192]; + +//this extra *2 is a HACK to salvage some savestates. remove me when the savestate format changes. +CACHE_ALIGN u8 gfx3d_convertedAlpha[256*192*2]; + +// Matrix stack handling +static CACHE_ALIGN MatrixStack mtxStack[4] = { + MatrixStack(1), // Projection stack + MatrixStack(31), // Coordinate stack + MatrixStack(31), // Directional stack + MatrixStack(1), // Texture stack +}; + +static CACHE_ALIGN float mtxCurrent [4][16]; +static CACHE_ALIGN float mtxTemporal[16]; +static u32 mode = 0; + +// Indexes for matrix loading/multiplication +static u8 ML4x4ind = 0; +static u8 ML4x3ind = 0; +static u8 MM4x4ind = 0; +static u8 MM4x3ind = 0; +static u8 MM3x3ind = 0; + +// Data for vertex submission +static CACHE_ALIGN float coord[4] = {0.0, 0.0, 0.0, 0.0}; +static char coordind = 0; +static u32 vtxFormat; +static BOOL inBegin = FALSE; + +// Data for basic transforms +static CACHE_ALIGN float trans[4] = {0.0, 0.0, 0.0, 0.0}; +static int transind = 0; +static CACHE_ALIGN float scale[4] = {0.0, 0.0, 0.0, 0.0}; +static int scaleind = 0; +static u32 viewport; + +//various other registers +static float _t=0, _s=0; +static float last_t, last_s; +static u32 clCmd = 0; +static u32 clInd = 0; + +#ifdef USE_GEOMETRY_FIFO_EMULATION +static u32 clInd2 = 0; +static bool isSwapBuffers = false; +bool isVBlank = false; +bool bWaitForPolys = false; +#endif + +static u32 BTind = 0; +static u32 PTind = 0; +//static CACHE_ALIGN float BTcoords[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; +static CACHE_ALIGN float PTcoords[4] = {0.0, 0.0, 0.0, 1.0}; + +//raw ds format poly attributes +static u32 polyAttr=0,textureFormat=0, texturePalette=0, polyAttrPending=0; + +//the current vertex color, 5bit values +static int colorRGB[4] = { 31,31,31,31 }; + +u32 control = 0; + +//light state: +static u32 lightColor[4] = {0,0,0,0}; +static u32 lightDirection[4] = {0,0,0,0}; +//material state: +static u16 dsDiffuse, dsAmbient, dsSpecular, dsEmission; +// Shininess +static float shininessTable[128] = {0}; +static int shininessInd = 0; + + +//-----------cached things: +//these dont need to go into the savestate. they can be regenerated from HW registers +//from polygonattr: +static unsigned int cullingMask=0; +static u8 colorAlpha=0; +static u32 envMode=0; +static u32 lightMask=0; +//other things: +static int texCoordinateTransform = 0; +static CACHE_ALIGN float cacheLightDirection[4][4]; +static CACHE_ALIGN float cacheHalfVector[4][4]; +//------------------ + +#define RENDER_FRONT_SURFACE 0x80 +#define RENDER_BACK_SURFACE 0X40 + + +//-------------poly and vertex lists and such things +POLYLIST* polylists = NULL; +POLYLIST* polylist = NULL; +VERTLIST* vertlists = NULL; +VERTLIST* vertlist = NULL; +int polygonListCompleted = 0; + +int listTwiddle = 1; +int triStripToggle; + +//list-building state +struct tmpVertInfo { + //the number of verts registered in this list + int count; + //indices to the main vert list + int map[4]; + //indicates that the first poly in a list has been completed + BOOL first; +} tempVertInfo; + + +static void twiddleLists() { + listTwiddle++; + listTwiddle &= 1; + polylist = &polylists[listTwiddle]; + vertlist = &vertlists[listTwiddle]; + polylist->count = 0; + vertlist->count = 0; +} + +static BOOL flushPending = FALSE; +static BOOL drawPending = FALSE; +//------------------------------------------------------------ + +static void makeTables() { + + //produce the color bits of a 24bpp color from a DS RGB15 using bit logic (internal use only) + #define RGB15TO24_BITLOGIC(col) ( (material_5bit_to_8bit[((col)>>10)&0x1F]<<16) | (material_5bit_to_8bit[((col)>>5)&0x1F]<<8) | material_5bit_to_8bit[(col)&0x1F] ) + + for(int i=0;i<32768;i++) + color_15bit_to_24bit[i] = RGB15TO24_BITLOGIC((u16)i); + + //produce the color bits of a 24bpp color from a DS RGB15 using bit logic (internal use only). RGB are reverse of usual + #define RGB15TO24_BITLOGIC_REVERSE(col) ( (material_5bit_to_8bit[(col)&0x1F]<<16) | (material_5bit_to_8bit[((col)>>5)&0x1F]<<8) | material_5bit_to_8bit[((col)>>10)&0x1F] ) + + for(int i=0;i<32768;i++) + { + color_15bit_to_24bit_reverse[i] = RGB15TO24_BITLOGIC_REVERSE((u16)i); + color_15bit_to_16bit_reverse[i] = (((i & 0x001F) << 11) | (material_5bit_to_6bit[(i & 0x03E0) >> 5] << 5) | ((i & 0x7C00) >> 10)); + } + + for (int i = 0; i < 65536; i++) + float16table[i] = fix2float((signed short)i); + + for (int i = 0; i < 1024; i++) + float10Table[i] = ((signed short)(i<<6)) / (float)(1<<12); + + for (int i = 0; i < 1024; i++) + float10RelTable[i] = ((signed short)(i<<6)) / (float)(1<<18); + + for (int i = 0; i < 1024; i++) + normalTable[i] = ((signed short)(i<<6)) / (float)(1<<15); + + for(int r=0;r<=31;r++) + for(int oldr=0;oldr<=31;oldr++) + for(int a=0;a<=31;a++) { + int temp = (r*a + oldr*(31-a)) / 31; + mixTable555[a][r][oldr] = temp; + } +} + +void gfx3d_init() +{ + if(polylists == NULL) { polylists = new POLYLIST[2]; polylist = &polylists[0]; } + if(vertlists == NULL) { vertlists = new VERTLIST[2]; vertlist = &vertlists[0]; } + makeTables(); + gfx3d_reset(); +} + +void gfx3d_reset() +{ + gfx3d = GFX3D(); + + control = 0; + drawPending = FALSE; + flushPending = FALSE; + listTwiddle = 1; + twiddleLists(); + + MatrixInit (mtxCurrent[0]); + MatrixInit (mtxCurrent[1]); + MatrixInit (mtxCurrent[2]); + MatrixInit (mtxCurrent[3]); + MatrixInit (mtxTemporal); + + clCmd = 0; + clInd = 0; +#ifdef USE_GEOMETRY_FIFO_EMULATION + clInd2 = 0; +#endif + + ML4x4ind = 0; + ML4x3ind = 0; + MM4x4ind = 0; + MM4x3ind = 0; + MM3x3ind = 0; + + BTind = 0; + PTind = 0; + + _t=0; + _s=0; + last_t = 0; + last_s = 0; + viewport = 0xBFFF0000; + + memset(gfx3d_convertedScreen,0,sizeof(gfx3d_convertedScreen)); + memset(gfx3d_convertedAlpha,0,sizeof(gfx3d_convertedAlpha)); + + gfx3d.clearDepth = gfx3d_extendDepth_15_to_24(0x7FFF); + + GFX_FIFOclear(); + +#ifdef USE_GEOMETRY_FIFO_EMULATION + clInd2 = 0; + isSwapBuffers = false; + isVBlank = false; + bWaitForPolys = false; +#endif +} + +void gfx3d_glViewPort(u32 v) +{ + viewport = v; + GFX_DELAY(1); +} + +void VIEWPORT::decode(u32 v) +{ + x = (v&0xFF); + y = std::min(191,(int)(((v>>8)&0xFF))); + width = (((v>>16)&0xFF)+1)-(v&0xFF); + height = ((v>>24)+1)-((v>>8)&0xFF); +} + + +void gfx3d_glClearColor(u32 v) +{ + gfx3d.clearColor = v; + +} + +void gfx3d_glFogColor(u32 v) +{ + gfx3d.fogColor[0] = ((float)((v )&0x1F))/31.0f; + gfx3d.fogColor[1] = ((float)((v>> 5)&0x1F))/31.0f; + gfx3d.fogColor[2] = ((float)((v>>10)&0x1F))/31.0f; + gfx3d.fogColor[3] = ((float)((v>>16)&0x1F))/31.0f; +} + +void gfx3d_glFogOffset (u32 v) +{ + gfx3d.fogOffset = (float)(v&0xffff); +} + +void gfx3d_glClearDepth(u32 v) +{ + v &= 0x7FFF; + gfx3d.clearDepth = gfx3d_extendDepth_15_to_24(v); +} + +void gfx3d_glMatrixMode(u32 v) +{ + mode = (v&3); + + GFX_DELAY(1); +} + + +void gfx3d_glLoadIdentity() +{ + MatrixIdentity (mtxCurrent[mode]); + + GFX_DELAY(19); + + if (mode == 2) + MatrixIdentity (mtxCurrent[1]); +} + +BOOL gfx3d_glLoadMatrix4x4(s32 v) +{ +#ifdef NOSSE2 + mtxCurrent[mode][ML4x4ind] = fix2float(v); +#else + mtxCurrent[mode][ML4x4ind] = v; +#endif + + ++ML4x4ind; + if(ML4x4ind<16) return FALSE; + ML4x4ind = 0; + + GFX_DELAY(19); + +#ifndef NOSSE2 + _sse2_fix2float_16(mtxCurrent[mode], _fix2float_divizor_mask); +#endif + + if (mode == 2) + MatrixCopy (mtxCurrent[1], mtxCurrent[2]); + return TRUE; +} + +BOOL gfx3d_glLoadMatrix4x3(s32 v) +{ +#ifdef NOSSE2 + mtxCurrent[mode][ML4x3ind] = fix2float(v); +#else + mtxCurrent[mode][ML4x3ind] = v; +#endif + + ML4x3ind++; + if((ML4x3ind & 0x03) == 3) ML4x3ind++; + if(ML4x3ind<16) return FALSE; + ML4x3ind = 0; + +#ifndef NOSSE2 + _sse2_fix2float_16(mtxCurrent[mode], _fix2float_divizor_mask); +#endif + + //fill in the unusued matrix values + mtxCurrent[mode][3] = mtxCurrent[mode][7] = mtxCurrent[mode][11] = 0.f; + mtxCurrent[mode][15] = 1.f; + + GFX_DELAY(30); + + if (mode == 2) + MatrixCopy (mtxCurrent[1], mtxCurrent[2]); + return TRUE; +} + +void gfx3d_glStoreMatrix(u32 v) +{ + //this command always works on both pos and vector when either pos or pos-vector are the current mtx mode + short mymode = (mode==1?2:mode); + + //limit height of these stacks. + //without the mymode==3 namco classics galaxian will try to use pos=1 and overrun the stack, corrupting emu + if(mymode==0 || mymode==3) + v = 0; + + if(v==31) v=30; //? what should happen in this case? + + MatrixStackLoadMatrix (&mtxStack[mymode], v&31, mtxCurrent[mymode]); + + GFX_DELAY(17); + + if(mymode==2) + MatrixStackLoadMatrix (&mtxStack[1], v&31, mtxCurrent[1]); +} + +void gfx3d_glRestoreMatrix(u32 v) +{ + //this command always works on both pos and vector when either pos or pos-vector are the current mtx mode + short mymode = (mode==1?2:mode); + + //limit height of these stacks + //without the mymode==3 namco classics galaxian will try to use pos=1 and overrun the stack, corrupting emu + if(mymode==0 || mymode==3) + v = 0; + + if(v==31) v=30; //? what should happen in this case? + + MatrixCopy (mtxCurrent[mymode], MatrixStackGetPos(&mtxStack[mymode], v&31)); + + GFX_DELAY(36); + + if (mymode == 2) + MatrixCopy (mtxCurrent[1], MatrixStackGetPos(&mtxStack[1], v&31)); +} + +void gfx3d_glPushMatrix() +{ + u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); + //this command always works on both pos and vector when either pos or pos-vector are the current mtx mode + short mymode = (mode==1?2:mode); + + if (mtxStack[mymode].position > mtxStack[mymode].size) + { + gxstat |= (1<<15); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + return; + } + + gxstat &= 0xFFFF00FF; + + MatrixStackPushMatrix(&mtxStack[mymode], mtxCurrent[mymode]); + + GFX_DELAY(17); + + if(mymode==2) + MatrixStackPushMatrix (&mtxStack[1], mtxCurrent[1]); + + gxstat |= ((mtxStack[0].position << 13) | (mtxStack[1].position << 8)); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + + +} + +void gfx3d_glPopMatrix(s32 i) +{ + u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); + + //this command always works on both pos and vector when either pos or pos-vector are the current mtx mode + short mymode = (mode==1?2:mode); + + /* + if (i > mtxStack[mymode].position) + { + gxstat |= (1<<15); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + return; + } + */ + gxstat &= 0xFFFF00FF; + + MatrixCopy(mtxCurrent[mymode], MatrixStackPopMatrix (&mtxStack[mymode], i)); + + GFX_DELAY(36); + + if (mymode == 2) + MatrixCopy(mtxCurrent[1], MatrixStackPopMatrix (&mtxStack[1], i)); + + gxstat |= ((mtxStack[0].position << 13) | (mtxStack[1].position << 8)); + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + + +} + +BOOL gfx3d_glTranslate(s32 v) +{ + trans[transind] = fix2float(v); + + ++transind; + + if(transind<3) return FALSE; + transind = 0; + + MatrixTranslate (mtxCurrent[mode], trans); + + GFX_DELAY(22); + + if (mode == 2) + { + MatrixTranslate (mtxCurrent[1], trans); + GFX_DELAY_M2(30); + } + return TRUE; +} + +BOOL gfx3d_glScale(s32 v) +{ + scale[scaleind] = fix2float(v); + + ++scaleind; + + if(scaleind<3) return FALSE; + scaleind = 0; + + MatrixScale (mtxCurrent[(mode==2?1:mode)], scale); + + GFX_DELAY(22); + + //note: pos-vector mode should not cause both matrices to scale. + //the whole purpose is to keep the vector matrix orthogonal + //so, I am leaving this commented out as an example of what not to do. + //if (mode == 2) + // MatrixScale (mtxCurrent[1], scale); + return TRUE; +} + +BOOL gfx3d_glMultMatrix3x3(s32 v) +{ +#ifdef NOSSE2 + mtxTemporal[MM3x3ind] = fix2float(v); +#else + mtxTemporal[MM3x3ind] = v; +#endif + + + MM3x3ind++; + if((MM3x3ind & 0x03) == 3) MM3x3ind++; + if(MM3x3ind<12) return FALSE; + MM3x3ind = 0; + + GFX_DELAY(28); + +#ifndef NOSSE2 + _sse2_fix2float_12(mtxTemporal, _fix2float_divizor_mask); +#endif + + //fill in the unusued matrix values + mtxTemporal[3] = mtxTemporal[7] = mtxTemporal[11] = 0; + mtxTemporal[15] = 1; + mtxTemporal[12] = mtxTemporal[13] = mtxTemporal[14] = 0; + + MatrixMultiply (mtxCurrent[mode], mtxTemporal); + + if (mode == 2) + { + MatrixMultiply (mtxCurrent[1], mtxTemporal); + GFX_DELAY_M2(30); + } + + //does this really need to be done? + MatrixIdentity (mtxTemporal); + return TRUE; +} + +BOOL gfx3d_glMultMatrix4x3(s32 v) +{ +#ifdef NOSSE2 + mtxTemporal[MM4x3ind] = fix2float(v); +#else + mtxTemporal[MM4x3ind] = v; +#endif + + MM4x3ind++; + if((MM4x3ind & 0x03) == 3) MM4x3ind++; + if(MM4x3ind<16) return FALSE; + MM4x3ind = 0; + + GFX_DELAY(31); + +#ifndef NOSSE2 + _sse2_fix2float_16(mtxTemporal, _fix2float_divizor_mask); +#endif + + //fill in the unusued matrix values + mtxTemporal[3] = mtxTemporal[7] = mtxTemporal[11] = 0.f; + mtxTemporal[15] = 1.f; + + MatrixMultiply (mtxCurrent[mode], mtxTemporal); + + if (mode == 2) + { + MatrixMultiply (mtxCurrent[1], mtxTemporal); + GFX_DELAY_M2(30); + } + + //does this really need to be done? + MatrixIdentity (mtxTemporal); + return TRUE; +} + +BOOL gfx3d_glMultMatrix4x4(s32 v) +{ +#ifdef NOSSE2 + mtxTemporal[MM4x4ind] = fix2float(v); +#else + mtxTemporal[MM4x4ind] = v; +#endif + + MM4x4ind++; + if(MM4x4ind<16) return FALSE; + MM4x4ind = 0; + + GFX_DELAY(35); + +#ifndef NOSSE2 + _sse2_fix2float_16(mtxTemporal, _fix2float_divizor_mask); +#endif + + MatrixMultiply (mtxCurrent[mode], mtxTemporal); + + if (mode == 2) + { + MatrixMultiply (mtxCurrent[1], mtxTemporal); + GFX_DELAY_M2(30); + } + + MatrixIdentity (mtxTemporal); + return TRUE; +} + +static void gfx3d_glPolygonAttrib_cache() +{ + // Light enable/disable + lightMask = (polyAttr&0xF); + + // texture environment + envMode = (polyAttr&0x30)>>4; + + // back face culling + cullingMask = (polyAttr>>6)&3; + + // Alpha value, actually not well handled, 0 should be wireframe + colorRGB[3] = colorAlpha = ((polyAttr>>16)&0x1F); +} + +void gfx3d_glBegin(u32 v) +{ + inBegin = TRUE; + vtxFormat = v&0x03; + triStripToggle = 0; + tempVertInfo.count = 0; + tempVertInfo.first = true; + polyAttr = polyAttrPending; + gfx3d_glPolygonAttrib_cache(); + GFX_DELAY(1); +} + +void gfx3d_glEnd(void) +{ + inBegin = FALSE; + tempVertInfo.count = 0; + GFX_DELAY(1); +} + +void gfx3d_glColor3b(u32 v) +{ + colorRGB[0] = (v&0x1F); + colorRGB[1] = ((v>>5)&0x1F); + colorRGB[2] = ((v>>10)&0x1F); + GFX_DELAY(1); +} + +#define SUBMITVERTEX(ii, nn) polylist->list[polylist->count].vertIndexes[ii] = tempVertInfo.map[nn]; +//Submit a vertex to the GE +static void SetVertex() +{ + ALIGN(16) float coordTransformed[4] = { coord[0], coord[1], coord[2], 1.f }; + + if (texCoordinateTransform == 3) + { + last_s =((coord[0]*mtxCurrent[3][0] + + coord[1]*mtxCurrent[3][4] + + coord[2]*mtxCurrent[3][8]) + _s * 16.0f) / 16.0f; + last_t =((coord[0]*mtxCurrent[3][1] + + coord[1]*mtxCurrent[3][5] + + coord[2]*mtxCurrent[3][9]) + _t * 16.0f) / 16.0f; + } + + + //refuse to do anything if we have too many verts or polys + polygonListCompleted = 0; + if(vertlist->count >= VERTLIST_SIZE) + return; + if(polylist->count >= POLYLIST_SIZE) + return; + +#ifdef NOSSE2 + //apply modelview matrix + MatrixMultVec4x4 (mtxCurrent[1], coordTransformed); + + //apply projection matrix + MatrixMultVec4x4 (mtxCurrent[0], coordTransformed); +#else + _sse2_MatrixMultVec4x4_M2(mtxCurrent[0], coordTransformed); +#endif + + //TODO - culling should be done here. + //TODO - viewport transform? + + int continuation = 0; + if(vtxFormat==2 && !tempVertInfo.first) + continuation = 2; + else if(vtxFormat==3 && !tempVertInfo.first) + continuation = 2; + + + //record the vertex + //VERT &vert = tempVertList.list[tempVertList.count]; + VERT &vert = vertlist->list[vertlist->count + tempVertInfo.count - continuation]; + + vert.texcoord[0] = last_s; + vert.texcoord[1] = last_t; + vert.coord[0] = coordTransformed[0]; + vert.coord[1] = coordTransformed[1]; + vert.coord[2] = coordTransformed[2]; + vert.coord[3] = coordTransformed[3]; + vert.color[0] = colorRGB[0]; + vert.color[1] = colorRGB[1]; + vert.color[2] = colorRGB[2]; + tempVertInfo.map[tempVertInfo.count] = vertlist->count + tempVertInfo.count - continuation; + tempVertInfo.count++; + + //possibly complete a polygon + { + polygonListCompleted = 2; + switch(vtxFormat) { + case 0: //GL_TRIANGLES + if(tempVertInfo.count!=3) + break; + polygonListCompleted = 1; + //vertlist->list[polylist->list[polylist->count].vertIndexes[i] = vertlist->count++] = tempVertList.list[n]; + SUBMITVERTEX(0,0); + SUBMITVERTEX(1,1); + SUBMITVERTEX(2,2); + vertlist->count+=3; + polylist->list[polylist->count].type = 3; + tempVertInfo.count = 0; + break; + case 1: //GL_QUADS + if(tempVertInfo.count!=4) + break; + polygonListCompleted = 1; + SUBMITVERTEX(0,0); + SUBMITVERTEX(1,1); + SUBMITVERTEX(2,2); + SUBMITVERTEX(3,3); + vertlist->count+=4; + polylist->list[polylist->count].type = 4; + tempVertInfo.count = 0; + break; + case 2: //GL_TRIANGLE_STRIP + if(tempVertInfo.count!=3) + break; + polygonListCompleted = 1; + SUBMITVERTEX(0,0); + SUBMITVERTEX(1,1); + SUBMITVERTEX(2,2); + polylist->list[polylist->count].type = 3; + + if(triStripToggle) + tempVertInfo.map[1] = vertlist->count+2-continuation; + else + tempVertInfo.map[0] = vertlist->count+2-continuation; + + if(tempVertInfo.first) + vertlist->count+=3; + else + vertlist->count+=1; + + triStripToggle ^= 1; + tempVertInfo.first = false; + tempVertInfo.count = 2; + break; + case 3: //GL_QUAD_STRIP + if(tempVertInfo.count!=4) + break; + polygonListCompleted = 1; + SUBMITVERTEX(0,0); + SUBMITVERTEX(1,1); + SUBMITVERTEX(2,3); + SUBMITVERTEX(3,2); + polylist->list[polylist->count].type = 4; + tempVertInfo.map[0] = vertlist->count+2-continuation; + tempVertInfo.map[1] = vertlist->count+3-continuation; + if(tempVertInfo.first) + vertlist->count+=4; + else vertlist->count+=2; + tempVertInfo.first = false; + tempVertInfo.count = 2; + break; + default: + return; + } + + if(polygonListCompleted == 1) + { + POLY &poly = polylist->list[polylist->count]; + + poly.polyAttr = polyAttr; + poly.texParam = textureFormat; + poly.texPalette = texturePalette; + poly.viewport = viewport; + polylist->count++; + } + } +} + +BOOL gfx3d_glVertex16b(unsigned int v) +{ + if(coordind==0) + { + coord[0] = float16table[v&0xFFFF]; + coord[1] = float16table[v>>16]; + + ++coordind; + return FALSE; + } + + coord[2] = float16table[v&0xFFFF]; + + coordind = 0; + SetVertex (); + + GFX_DELAY(9); + return TRUE; +} + +void gfx3d_glVertex10b(u32 v) +{ + coord[0] = float10Table[v&1023]; + coord[1] = float10Table[(v>>10)&1023]; + coord[2] = float10Table[(v>>20)&1023]; + + GFX_DELAY(8); + SetVertex (); +} + +void gfx3d_glVertex3_cord(unsigned int one, unsigned int two, unsigned int v) +{ + coord[one] = float16table[v&0xffff]; + coord[two] = float16table[v>>16]; + + SetVertex (); + + GFX_DELAY(8); +} + +void gfx3d_glVertex_rel(u32 v) +{ + coord[0] += float10RelTable[v&1023]; + coord[1] += float10RelTable[(v>>10)&1023]; + coord[2] += float10RelTable[(v>>20)&1023]; + + SetVertex (); + + GFX_DELAY(8); +} + +// Ignored for now +void gfx3d_glSwapScreen(unsigned int screen) +{ +} + + +int gfx3d_GetNumPolys() +{ + //so is this in the currently-displayed or currently-built list? + return (polylists[listTwiddle].count); +} + +int gfx3d_GetNumVertex() +{ + //so is this in the currently-displayed or currently-built list? + return (vertlists[listTwiddle].count); +} + + + +void gfx3d_glPolygonAttrib (u32 val) +{ + if(inBegin) { + //PROGINFO("Set polyattr in the middle of a begin/end pair.\n (This won't be activated until the next begin)\n"); + //TODO - we need some some similar checking for teximageparam etc. + } + polyAttrPending = val; + GFX_DELAY(1); +} + +/* + 0-4 Diffuse Reflection Red + 5-9 Diffuse Reflection Green + 10-14 Diffuse Reflection Blue + 15 Set Vertex Color (0=No, 1=Set Diffuse Reflection Color as Vertex Color) + 16-20 Ambient Reflection Red + 21-25 Ambient Reflection Green + 26-30 Ambient Reflection Blue +*/ +void gfx3d_glMaterial0(u32 val) +{ + dsDiffuse = val&0xFFFF; + dsAmbient = val>>16; + + if (BIT15(val)) + { + colorRGB[0] = (val)&0x1F; + colorRGB[1] = (val>>5)&0x1F; + colorRGB[2] = (val>>10)&0x1F; + } + GFX_DELAY(4); +} + +void gfx3d_glMaterial1(u32 val) +{ + dsSpecular = val&0xFFFF; + dsEmission = val>>16; + GFX_DELAY(4); +} + +BOOL gfx3d_glShininess (u32 val) +{ + shininessTable[shininessInd++] = ((val & 0xFF) / 256.0f); + shininessTable[shininessInd++] = (((val >> 8) & 0xFF) / 256.0f); + shininessTable[shininessInd++] = (((val >> 16) & 0xFF) / 256.0f); + shininessTable[shininessInd++] = (((val >> 24) & 0xFF) / 256.0f); + + if (shininessInd < 128) return FALSE; + shininessInd = 0; + GFX_DELAY(32); + return TRUE; +} + +void gfx3d_UpdateToonTable(u8 offset, u16 val) +{ + gfx3d.u16ToonTable[offset] = val; +} + +void gfx3d_UpdateToonTable(u8 offset, u32 val) +{ + gfx3d.u16ToonTable[offset] = val & 0xFFFF; + gfx3d.u16ToonTable[offset+1] = val >> 8; +} + +static void gfx3d_glTexImage_cache() +{ + texCoordinateTransform = (textureFormat>>30); +} +void gfx3d_glTexImage(u32 val) +{ + textureFormat = val; + gfx3d_glTexImage_cache(); + GFX_DELAY(1); +} + +void gfx3d_glTexPalette(u32 val) +{ + texturePalette = val; + GFX_DELAY(1); +} + +void gfx3d_glTexCoord(u32 val) +{ + _t = (s16)(val>>16); + _s = (s16)(val&0xFFFF); + + _s /= 16.0f; + _t /= 16.0f; + + if (texCoordinateTransform == 1) + { + last_s =_s*mtxCurrent[3][0] + _t*mtxCurrent[3][4] + + 0.0625f*mtxCurrent[3][8] + 0.0625f*mtxCurrent[3][12]; + last_t =_s*mtxCurrent[3][1] + _t*mtxCurrent[3][5] + + 0.0625f*mtxCurrent[3][9] + 0.0625f*mtxCurrent[3][13]; + } + else + { + last_s=_s; + last_t=_t; + } + GFX_DELAY(1); +} + +#define vec3dot(a, b) (((a[0]) * (b[0])) + ((a[1]) * (b[1])) + ((a[2]) * (b[2]))) + +void gfx3d_glNormal(u32 v) +{ + int i,c; + ALIGN(16) float normal[4] = { normalTable[v&1023], + normalTable[(v>>10)&1023], + normalTable[(v>>20)&1023], + 1}; + + if (texCoordinateTransform == 2) + { + last_s =( (normal[0] *mtxCurrent[3][0] + normal[1] *mtxCurrent[3][4] + + normal[2] *mtxCurrent[3][8]) + (_s*16.0f)) / 16.0f; + last_t =( (normal[0] *mtxCurrent[3][1] + normal[1] *mtxCurrent[3][5] + + normal[2] *mtxCurrent[3][9]) + (_t*16.0f)) / 16.0f; + } + + //use the current normal transform matrix + MatrixMultVec3x3 (mtxCurrent[2], normal); + + //apply lighting model + { + u8 diffuse[3] = { + (dsDiffuse)&0x1F, + (dsDiffuse>>5)&0x1F, + (dsDiffuse>>10)&0x1F }; + + u8 ambient[3] = { + (dsAmbient)&0x1F, + (dsAmbient>>5)&0x1F, + (dsAmbient>>10)&0x1F }; + + u8 emission[3] = { + (dsEmission)&0x1F, + (dsEmission>>5)&0x1F, + (dsEmission>>10)&0x1F }; + + u8 specular[3] = { + (dsSpecular)&0x1F, + (dsSpecular>>5)&0x1F, + (dsSpecular>>10)&0x1F }; + + int vertexColor[3] = { emission[0], emission[1], emission[2] }; + + for(i=0; i<4; i++) + { + if(!((lightMask>>i)&1)) continue; + + u8 _lightColor[3] = { + (lightColor[i])&0x1F, + (lightColor[i]>>5)&0x1F, + (lightColor[i]>>10)&0x1F }; + + /* This formula is the one used by the DS */ + /* Reference : http://nocash.emubase.de/gbatek.htm#ds3dpolygonlightparameters */ + + float diffuseLevel = std::max(0.0f, -vec3dot(cacheLightDirection[i], normal)); + float shininessLevel = pow(std::max(0.0f, vec3dot(-cacheHalfVector[i], normal)), 2); + + if(dsSpecular & 0x8000) + { + int shininessIndex = (int)(shininessLevel * 128); + if(shininessIndex >= (int)ARRAY_SIZE(shininessTable)) { + //we can't print this right now, because when a game triggers this it triggers it _A_LOT_ + //so wait until we have per-frame diagnostics. + //this was tested using Princess Debut (US) after proceeding through the intro and getting the tiara. + //After much research, I determined that this was caused by the game feeding in a totally jacked matrix + //to mult4x4 from 0x02129B80 (after feeding two other valid matrices) + //the game seems to internally index these as: ?, 0x37, 0x2B <-- error + //but, man... this is seriously messed up. there must be something going wrong. + //maybe it has something to do with what looks like a mirror room effect that is going on during this time? + //PROGINFO("ERROR: shininess table out of bounds.\n maybe an emulator error; maybe a non-unit normal; setting to 0\n"); + shininessIndex = 0; + } + shininessLevel = shininessTable[shininessIndex]; + } + + for(c = 0; c < 3; c++) + { + vertexColor[c] += (int)(((specular[c] * _lightColor[c] * shininessLevel) + + (diffuse[c] * _lightColor[c] * diffuseLevel) + + (ambient[c] * _lightColor[c])) / 31.0f); + } + } + + for(c=0;c<3;c++) + colorRGB[c] = std::min(31,vertexColor[c]); + } + + GFX_DELAY(9); + GFX_DELAY_M2((lightMask) & 0x01); + GFX_DELAY_M2((lightMask>>1) & 0x01); + GFX_DELAY_M2((lightMask>>2) & 0x01); + GFX_DELAY_M2((lightMask>>3) & 0x01); +} + + +s32 gfx3d_GetClipMatrix (unsigned int index) +{ + float val = MatrixGetMultipliedIndex (index, mtxCurrent[0], mtxCurrent[1]); + + val *= (1<<12); + + return (s32)val; +} + +s32 gfx3d_GetDirectionalMatrix (unsigned int index) +{ + int _index = (((index / 3) * 4) + (index % 3)); + + return (s32)(mtxCurrent[2][_index]*(1<<12)); +} + +static void gfx3d_glLightDirection_cache(int index) +{ + u32 v = lightDirection[index]; + + // Convert format into floating point value + cacheLightDirection[index][0] = normalTable[v&1023]; + cacheLightDirection[index][1] = normalTable[(v>>10)&1023]; + cacheLightDirection[index][2] = normalTable[(v>>20)&1023]; + cacheLightDirection[index][3] = 0; + + /* Multiply the vector by the directional matrix */ + MatrixMultVec3x3(mtxCurrent[2], cacheLightDirection[index]); + + /* Calculate the half vector */ + float lineOfSight[4] = {0.0f, 0.0f, -1.0f, 0.0f}; + for(int i = 0; i < 4; i++) + { + cacheHalfVector[index][i] = ((cacheLightDirection[index][i] + lineOfSight[i]) / 2.0f); + } +} + +/* + 0-9 Directional Vector's X component (1bit sign + 9bit fractional part) + 10-19 Directional Vector's Y component (1bit sign + 9bit fractional part) + 20-29 Directional Vector's Z component (1bit sign + 9bit fractional part) + 30-31 Light Number (0..3) +*/ +void gfx3d_glLightDirection (u32 v) +{ + int index = v>>30; + + lightDirection[index] = v; + gfx3d_glLightDirection_cache(index); + GFX_DELAY(6); +} + +void gfx3d_glLightColor (u32 v) +{ + int index = v>>30; + lightColor[index] = v; + GFX_DELAY(1); +} + +void gfx3d_glAlphaFunc(u32 v) +{ + gfx3d.alphaTestRef = v&31; +} + +BOOL gfx3d_glBoxTest(u32 v) +{ + u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); + gxstat &= 0xFFFFFFFD; // clear boxtest bit + gxstat |= 0x00000001; // busy + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + + BTind++; + if (BTind < 3) + { + /* if(BTind == 1) + { + BTcoords[0] = float16table[v & 0xFFFF]; + BTcoords[1] = float16table[v >> 16]; + } + else if(BTind == 2) + { + BTcoords[2] = float16table[v & 0xFFFF]; + BTcoords[3] = float16table[v >> 16]; + }*/ + + return FALSE; + } + BTind = 0; + + GFX_DELAY(103); + +/* BTcoords[4] = float16table[v & 0xFFFF]; + BTcoords[5] = float16table[v >> 16]; + + ALIGN(16) float boxCoords[6][4][4] = { + // near + {{BTcoords[0], BTcoords[1], BTcoords[2], 1.0f}, + {BTcoords[0]+BTcoords[3], BTcoords[1], BTcoords[2], 1.0f}, + {BTcoords[0]+BTcoords[3], BTcoords[1]+BTcoords[4], BTcoords[2], 1.0f}, + {BTcoords[0], BTcoords[1]+BTcoords[4], BTcoords[2], 1.0f}}, + // far + {{BTcoords[0], BTcoords[1], BTcoords[2]+BTcoords[5], 1.0f}, + {BTcoords[0]+BTcoords[3], BTcoords[1], BTcoords[2]+BTcoords[5], 1.0f}, + {BTcoords[0]+BTcoords[3], BTcoords[1]+BTcoords[4], BTcoords[2]+BTcoords[5], 1.0f}, + {BTcoords[0], BTcoords[1]+BTcoords[4], BTcoords[2]+BTcoords[5], 1.0f}}, + // left + {{BTcoords[0], BTcoords[1], BTcoords[2]+BTcoords[5], 1.0f}, + {BTcoords[0], BTcoords[1], BTcoords[2], 1.0f}, + {BTcoords[0], BTcoords[1]+BTcoords[4], BTcoords[2], 1.0f}, + {BTcoords[0], BTcoords[1]+BTcoords[4], BTcoords[2]+BTcoords[5], 1.0f}}, + // right + {{BTcoords[0]+BTcoords[3], BTcoords[1], BTcoords[2], 1.0f}, + {BTcoords[0]+BTcoords[3], BTcoords[1], BTcoords[2]+BTcoords[5], 1.0f}, + {BTcoords[0]+BTcoords[3], BTcoords[1]+BTcoords[4], BTcoords[2]+BTcoords[5], 1.0f}, + {BTcoords[0]+BTcoords[3], BTcoords[1]+BTcoords[4], BTcoords[2], 1.0f}}, + // top + {{BTcoords[0], BTcoords[1], BTcoords[2]+BTcoords[5], 1.0f}, + {BTcoords[0]+BTcoords[3], BTcoords[1], BTcoords[2]+BTcoords[5], 1.0f}, + {BTcoords[0]+BTcoords[3], BTcoords[1], BTcoords[2], 1.0f}, + {BTcoords[0], BTcoords[1], BTcoords[2], 1.0f}}, + // bottom + {{BTcoords[0], BTcoords[1]+BTcoords[4], BTcoords[2]+BTcoords[5], 1.0f}, + {BTcoords[0]+BTcoords[3], BTcoords[1]+BTcoords[4], BTcoords[2]+BTcoords[5], 1.0f}, + {BTcoords[0]+BTcoords[3], BTcoords[1]+BTcoords[4], BTcoords[2], 1.0f}, + {BTcoords[0], BTcoords[1]+BTcoords[4], BTcoords[2], 1.0f}} + }; + + for(int face = 0; face < 6; face++) + { + for(int vtx = 0; vtx < 4; vtx++) + { + MatrixMultVec4x4(mtxCurrent[1], boxCoords[face][vtx]); + MatrixMultVec4x4(mtxCurrent[0], boxCoords[face][vtx]); + + boxCoords[face][vtx][0] = ((boxCoords[face][vtx][0] + boxCoords[face][vtx][3]) / (2 * boxCoords[face][vtx][3])); + boxCoords[face][vtx][1] = ((boxCoords[face][vtx][1] + boxCoords[face][vtx][3]) / (2 * boxCoords[face][vtx][3])); + boxCoords[face][vtx][2] = ((boxCoords[face][vtx][2] + boxCoords[face][vtx][3]) / (2 * boxCoords[face][vtx][3])); + + // if(face==0)INFO("box test: testing face %i, vtx %i: %f %f %f %f\n", face, vtx, + // boxCoords[face][vtx][0], boxCoords[face][vtx][1], boxCoords[face][vtx][2], boxCoords[face][vtx][3]); + + if ((boxCoords[face][vtx][0] >= 0.0f) && (boxCoords[face][vtx][0] <= 1.0f) && + (boxCoords[face][vtx][1] >= 0.0f) && (boxCoords[face][vtx][1] <= 1.0f) && + (boxCoords[face][vtx][2] >= 0.0f) && (boxCoords[face][vtx][2] <= 1.0f)) + { + // goto faceInside; + } + else + goto noFaceInside; + } + } + + goto faceInside; + +faceInside: + gxstat |= 0x2; + +noFaceInside:*/ + gxstat &= 0xFFFFFFFE; // clear busy bit + gxstat |= 0x00000002; // hack + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + return TRUE; +} + +BOOL gfx3d_glPosTest(u32 v) +{ + u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); + gxstat |= 0x00000001; // busy + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + + PTind++; + if (PTind < 2) + { + PTcoords[0] = float16table[v & 0xFFFF]; + PTcoords[1] = float16table[v >> 16]; + + return FALSE; + } + PTind = 0; + + PTcoords[2] = float16table[v & 0xFFFF]; + PTcoords[3] = 1.0f; + + MatrixMultVec4x4(mtxCurrent[1], PTcoords); + MatrixMultVec4x4(mtxCurrent[0], PTcoords); + + gxstat &= 0xFFFFFFFE; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + + GFX_DELAY(9); + + return TRUE; +} + +void gfx3d_glVecTest(u32 v) +{ + u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); + gxstat &= 0xFFFFFFFE; + T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + + GFX_DELAY(5); + //INFO("NDS_glVecTest\n"); +} + +unsigned int gfx3d_glGetPosRes(unsigned int index) +{ + return (unsigned int)(PTcoords[index] * 4096.0f); +} + +unsigned short gfx3d_glGetVecRes(unsigned int index) +{ + //INFO("NDS_glGetVecRes\n"); + return 0; +} + +#ifdef USE_GEOMETRY_FIFO_EMULATION + +//#define _3D_LOG_EXEC +void gfx3d_execute(u8 cmd, u32 param) +{ +#ifdef _3D_LOG_EXEC + u32 gxstat2 = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); + INFO("*** gxFIFO: exec 0x%02X, tail %03i, gxstat 0x%08X\n", cmd, gxFIFO.tail, gxstat2); +#endif + switch (cmd) + { + case 0x10: // MTX_MODE - Set Matrix Mode (W) + gfx3d_glMatrixMode(param); + break; + case 0x11: // MTX_PUSH - Push Current Matrix on Stack (W) + gfx3d_glPushMatrix(); + break; + case 0x12: // MTX_POP - Pop Current Matrix from Stack (W) + gfx3d_glPopMatrix(param); + break; + case 0x13: // MTX_STORE - Store Current Matrix on Stack (W) + gfx3d_glStoreMatrix(param); + break; + case 0x14: // MTX_RESTORE - Restore Current Matrix from Stack (W) + gfx3d_glRestoreMatrix(param); + break; + case 0x15: // MTX_IDENTITY - Load Unit Matrix to Current Matrix (W) + gfx3d_glLoadIdentity(); + break; + case 0x16: // MTX_LOAD_4x4 - Load 4x4 Matrix to Current Matrix (W) + gfx3d_glLoadMatrix4x4(param); + break; + case 0x17: // MTX_LOAD_4x3 - Load 4x3 Matrix to Current Matrix (W) + gfx3d_glLoadMatrix4x3(param); + break; + case 0x18: // MTX_MULT_4x4 - Multiply Current Matrix by 4x4 Matrix (W) + gfx3d_glMultMatrix4x4(param); + break; + case 0x19: // MTX_MULT_4x3 - Multiply Current Matrix by 4x3 Matrix (W) + gfx3d_glMultMatrix4x3(param); + break; + case 0x1A: // MTX_MULT_3x3 - Multiply Current Matrix by 3x3 Matrix (W) + gfx3d_glMultMatrix3x3(param); + break; + case 0x1B: // MTX_SCALE - Multiply Current Matrix by Scale Matrix (W) + gfx3d_glScale(param); + break; + case 0x1C: // MTX_TRANS - Mult. Curr. Matrix by Translation Matrix (W) + gfx3d_glTranslate(param); + break; + case 0x20: // COLOR - Directly Set Vertex Color (W) + gfx3d_glColor3b(param); + break; + case 0x21: // NORMAL - Set Normal Vector (W) + gfx3d_glNormal(param); + break; + case 0x22: // TEXCOORD - Set Texture Coordinates (W) + gfx3d_glTexCoord(param); + break; + case 0x23: // VTX_16 - Set Vertex XYZ Coordinates (W) + gfx3d_glVertex16b(param); + break; + case 0x24: // VTX_10 - Set Vertex XYZ Coordinates (W) + gfx3d_glVertex10b(param); + break; + case 0x25: // VTX_XY - Set Vertex XY Coordinates (W) + gfx3d_glVertex3_cord(0, 1, param); + break; + case 0x26: // VTX_XZ - Set Vertex XZ Coordinates (W) + gfx3d_glVertex3_cord(0, 2, param); + break; + case 0x27: // VTX_YZ - Set Vertex YZ Coordinates (W) + gfx3d_glVertex3_cord(1, 2, param); + break; + case 0x28: // VTX_DIFF - Set Relative Vertex Coordinates (W) + gfx3d_glVertex_rel(param); + break; + case 0x29: // POLYGON_ATTR - Set Polygon Attributes (W) + gfx3d_glPolygonAttrib(param); + break; + case 0x2A: // TEXIMAGE_PARAM - Set Texture Parameters (W) + gfx3d_glTexImage(param); + break; + case 0x2B: // PLTT_BASE - Set Texture Palette Base Address (W) + gfx3d_glTexPalette(param); + break; + case 0x30: // DIF_AMB - MaterialColor0 - Diffuse/Ambient Reflect. (W) + gfx3d_glMaterial0(param); + break; + case 0x31: // SPE_EMI - MaterialColor1 - Specular Ref. & Emission (W) + gfx3d_glMaterial1(param); + break; + case 0x32: // LIGHT_VECTOR - Set Light's Directional Vector (W) + gfx3d_glLightDirection(param); + break; + case 0x33: // LIGHT_COLOR - Set Light Color (W) + gfx3d_glLightColor(param); + break; + case 0x34: // SHININESS - Specular Reflection Shininess Table (W) + gfx3d_glShininess(param); + break; + case 0x40: // BEGIN_VTXS - Start of Vertex List (W) + gfx3d_glBegin(param); + break; + case 0x41: // END_VTXS - End of Vertex List (W) + gfx3d_glEnd(); + break; + case 0x50: // SWAP_BUFFERS - Swap Rendering Engine Buffer (W) + gfx3d_glFlush(param); + break; + case 0x60: // VIEWPORT - Set Viewport (W) + gfx3d_glViewPort(param); + break; + case 0x70: // BOX_TEST - Test if Cuboid Sits inside View Volume (W) + gfx3d_glBoxTest(param); + break; + case 0x71: // POS_TEST - Set Position Coordinates for Test (W) + gfx3d_glPosTest(param); + break; + case 0x72: // VEC_TEST - Set Directional Vector for Test (W) + gfx3d_glVecTest(param); + break; + default: + INFO("Unknown execute FIFO 3D command 0x%02X with param 0x%08X\n", cmd, param); + break; + } +} + +void gfx3d_execute3D() +{ + u8 cmd = 0; + u32 param = 0; + + if (isSwapBuffers) return; + + if (GFX_FIFOrecv(&cmd, ¶m)) + { + gfx3d_execute(cmd, param); +#if 0 + for ( ;;) + { + if ( (cmd == 0x11) || (cmd==0x15) || (cmd==41) ) + { + if (!GFX_FIFOrecv(&cmd, ¶m)) return; + gfx3d_execute(cmd, param); + continue; + } + break; + } +#endif +#if 0 + if (bWaitForPolys) + { + //INFO("Error: incompleted polylist\n"); + if (polygonListCompleted == 1) + { + gfx3d_doFlush(); + isSwapBuffers = true; + bWaitForPolys = false; + } + } +#endif + } +} +#endif + +void gfx3d_glFlush(u32 v) +{ + +#ifdef USE_GEOMETRY_FIFO_EMULATION + gfx3d.sortmode = BIT0(v); + gfx3d.wbuffer = BIT1(v); +#if 0 + + if (polygonListCompleted == 2) + { + //u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); + //gxstat |= 0x08000000; // set busy flag + //T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); + bWaitForPolys = true; + return; + } +#endif + + //gfx3d_doFlush(); + isSwapBuffers = true; + + //u32 gxstat = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600); + //gxstat |= 0x08000000; // set busy flag + //T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x600, gxstat); +#else + if(!flushPending) + { + gfx3d.sortmode = BIT0(v); + gfx3d.wbuffer = BIT1(v); + flushPending = TRUE; + } + //see discussion at top of file + if(CommonSettings.gfx3d_flushMode == 0) + gfx3d_doFlush(); +#endif + +} + +static bool gfx3d_ysort_compare(int num1, int num2) +{ + const POLY &poly1 = polylist->list[num1]; + const POLY &poly2 = polylist->list[num2]; + + //this may be verified by checking the game create menus in harvest moon island of happiness + if (poly1.maxy > poly2.maxy) return false; + if (poly1.maxy < poly2.maxy) return true; + if (poly1.miny < poly2.miny) return true; + if (poly1.miny > poly2.miny) return false; + + //make sure we respect the game's ordering in cases of complete ties + //this makes it a stable sort. + //this must be a stable sort or else advance wars DOR will flicker in the main map mode + if (num1 < num2) return true; + else return false; +} + +static void gfx3d_doFlush() +{ + gfx3d.frameCtr++; + +#ifndef USE_GEOMETRY_FIFO_EMULATION + GFX_FIFOclear(); + // reset + clInd = 0; + clCmd = 0; +#endif + + //the renderer will get the lists we just built + gfx3d.polylist = polylist; + gfx3d.vertlist = vertlist; + + //and also our current render state + if(BIT1(control)) gfx3d.shading = GFX3D::HIGHLIGHT; + else gfx3d.shading = GFX3D::TOON; + gfx3d.enableTexturing = BIT0(control); + gfx3d.enableAlphaTest = BIT2(control); + gfx3d.enableAlphaBlending = BIT3(control); + gfx3d.enableAntialiasing = BIT4(control); + gfx3d.enableEdgeMarking = BIT5(control); + gfx3d.enableClearImage = BIT14(control); + + int polycount = polylist->count; + + //find the min and max y values for each poly. + //TODO - this could be a small waste of time if we are manual sorting the translucent polys + for(int i=0; ilist[i]; + float verty = 0.0f; + poly.miny = poly.maxy = vertlist->list[poly.vertIndexes[0]].y; + + for(int j=1; jlist[poly.vertIndexes[j]].y; + poly.miny = min(poly.miny, verty); + poly.maxy = max(poly.maxy, verty); + } + } + + //we need to sort the poly list with alpha polys last + //first, look for opaque polys + int ctr=0; + for(int i=0;ilist[i]; + if(!poly.isTranslucent()) + gfx3d.indexlist[ctr++] = i; + } + int opaqueCount = ctr; + //then look for translucent polys + for(int i=0;ilist[i]; + if(poly.isTranslucent()) + gfx3d.indexlist[ctr++] = i; + } + + //now we have to sort the opaque polys by y-value. + //(test case: harvest moon island of happiness character cretor UI) + //should this be done after clipping?? + std::sort(gfx3d.indexlist, gfx3d.indexlist + opaqueCount, gfx3d_ysort_compare); + + if(!gfx3d.sortmode) + { + //if we are autosorting translucent polys, we need to do this also + //TODO - this is unverified behavior. need a test case + std::sort(gfx3d.indexlist + opaqueCount, gfx3d.indexlist + polycount, gfx3d_ysort_compare); + } + + //switch to the new lists + twiddleLists(); + +#ifndef USE_GEOMETRY_FIFO_EMULATION + flushPending = FALSE; + drawPending = TRUE; +#else + drawPending = TRUE; +#endif +} + +void gfx3d_VBlankSignal() +{ +#ifdef USE_GEOMETRY_FIFO_EMULATION + isVBlank = true; + if (isSwapBuffers) + { + //if (bWaitForPolys) return; + gfx3d_doFlush(); + isSwapBuffers = false; + GFX_DELAY(392); + } +#else + //the 3d buffers are swapped when a vblank begins. + //so, if we have a redraw pending, now is a safe time to do it + if(!flushPending) + { + GFX_FIFOclear(); + return; + } + + //see discussion at top of file + if(CommonSettings.gfx3d_flushMode == 1) + gfx3d_doFlush(); +#endif +} + +void gfx3d_VBlankEndSignal(bool skipFrame) +{ +#ifdef USE_GEOMETRY_FIFO_EMULATION + isVBlank = false; + + if(skipFrame) return; + if (!drawPending) return; + drawPending = FALSE; + + //if the null 3d core is chosen, then we need to clear out the 3d buffers to keep old data from being rendered + if(gpu3D == &gpu3DNull || !CommonSettings.showGpu.main) + { + memset(gfx3d_convertedScreen,0,sizeof(gfx3d_convertedScreen)); + memset(gfx3d_convertedScreen,0,sizeof(gfx3d_convertedAlpha)); + } + else + { + gpu3D->NDS_3D_Render(); + } +#else + //if we are skipping 3d frames then the 3d rendering will get held up here. + //but, as soon as we quit skipping frames, the held-up 3d frame will render + if(skipFrame) return; + if(!drawPending) return; + + drawPending = FALSE; + + if(CommonSettings.showGpu.main) + gpu3D->NDS_3D_Render(); + + //if the null 3d core is chosen, then we need to clear out the 3d buffers to keep old data from being rendered + if(gpu3D == &gpu3DNull || !CommonSettings.showGpu.main) + { + memset(gfx3d_convertedScreen,0,sizeof(gfx3d_convertedScreen)); + memset(gfx3d_convertedScreen,0,sizeof(gfx3d_convertedAlpha)); + } +#endif +} + +#ifdef USE_GEOMETRY_FIFO_EMULATION +//#define _3D_LOG + +static void NOPARAMS() +{ + for (;;) + { + if (clCmd == 0) return; + switch (clCmd & 0xFF) + { + case 0x00: + { + clCmd >>= 8; + continue; + } + case 0x11: + case 0x15: + case 0x41: + { + GFX_FIFOsend(clCmd & 0xFF, 0); + clCmd >>= 8; + continue; + } + } + break; + } +} + +void gfx3d_sendCommandToFIFO(u32 val) +{ + if (clCmd == 0) + { + clCmd = val; + return; + } +#ifdef _3D_LOG + INFO("GFX FIFO: Send GFX 3D cmd 0x%02X to FIFO (0x%08X)\n", clCmd & 0xFF, val); +#endif + + NOPARAMS(); + if (clCmd == 0) + { + if (val == 0) return; + clCmd = val; + return; + } + + switch (clCmd & 0xFF) + { + case 0x34: // SHININESS - Specular Reflection Shininess Table (W) + GFX_FIFOsend(clCmd & 0xFF, val); + + clInd2++; + if (clInd2 < 32) return; + clInd2 = 0; + clCmd >>= 8; + break; + + case 0x16: // MTX_LOAD_4x4 - Load 4x4 Matrix to Current Matrix (W) + case 0x18: // MTX_MULT_4x4 - Multiply Current Matrix by 4x4 Matrix (W) + GFX_FIFOsend(clCmd & 0xFF, val); + + clInd2++; + if (clInd2 < 16) return; + clInd2 = 0; + clCmd >>= 8; + break; + + case 0x17: // MTX_LOAD_4x3 - Load 4x3 Matrix to Current Matrix (W) + case 0x19: // MTX_MULT_4x3 - Multiply Current Matrix by 4x3 Matrix (W) + GFX_FIFOsend(clCmd & 0xFF, val); + + clInd2++; + if (clInd2 < 12) return; + clInd2 = 0; + clCmd >>= 8; + break; + + case 0x1A: // MTX_MULT_3x3 - Multiply Current Matrix by 3x3 Matrix (W) + GFX_FIFOsend(clCmd & 0xFF, val); + + clInd2++; + if (clInd2 < 9) return; + clInd2 = 0; + clCmd >>= 8; + break; + + case 0x1B: // MTX_SCALE - Multiply Current Matrix by Scale Matrix (W) + case 0x1C: // MTX_TRANS - Mult. Curr. Matrix by Translation Matrix (W) + case 0x70: // BOX_TEST - Test if Cuboid Sits inside View Volume (W) + GFX_FIFOsend(clCmd & 0xFF, val); + + clInd2++; + if (clInd2 < 3) return; + clInd2 = 0; + clCmd >>= 8; + break; + + case 0x23: // VTX_16 - Set Vertex XYZ Coordinates (W) + case 0x71: // POS_TEST - Set Position Coordinates for Test (W) + GFX_FIFOsend(clCmd & 0xFF, val); + + clInd2++; + if (clInd2 < 2) return; + clInd2 = 0; + clCmd >>= 8; + break; + + case 0x10: // MTX_MODE - Set Matrix Mode (W) + case 0x12: // MTX_POP - Pop Current Matrix from Stack (W) + case 0x13: // MTX_STORE - Store Current Matrix on Stack (W) + case 0x14: // MTX_RESTORE - Restore Current Matrix from Stack (W) + case 0x20: // COLOR - Directly Set Vertex Color (W) + case 0x21: // NORMAL - Set Normal Vector (W) + case 0x22: // TEXCOORD - Set Texture Coordinates (W) + case 0x24: // VTX_10 - Set Vertex XYZ Coordinates (W) + case 0x25: // VTX_XY - Set Vertex XY Coordinates (W) + case 0x26: // VTX_XZ - Set Vertex XZ Coordinates (W) + case 0x27: // VTX_YZ - Set Vertex YZ Coordinates (W) + case 0x28: // VTX_DIFF - Set Relative Vertex Coordinates (W) + case 0x29: // POLYGON_ATTR - Set Polygon Attributes (W) + case 0x2A: // TEXIMAGE_PARAM - Set Texture Parameters (W) + case 0x2B: // PLTT_BASE - Set Texture Palette Base Address (W) + case 0x30: // DIF_AMB - MaterialColor0 - Diffuse/Ambient Reflect. (W) + case 0x31: // SPE_EMI - MaterialColor1 - Specular Ref. & Emission (W) + case 0x32: // LIGHT_VECTOR - Set Light's Directional Vector (W) + case 0x33: // LIGHT_COLOR - Set Light Color (W) + case 0x40: // BEGIN_VTXS - Start of Vertex List (W) + case 0x60: // VIEWPORT - Set Viewport (W) + case 0x72: // VEC_TEST - Set Directional Vector for Test (W) + GFX_FIFOsend(clCmd & 0xFF, val); + clCmd >>= 8; + break; + case 0x50: // SWAP_BUFFERS - Swap Rendering Engine Buffer (W) + GFX_FIFOsend(clCmd & 0xFF, val); + clCmd >>= 8; + break; + default: + INFO("Unknown FIFO 3D command 0x%02X (0x%08X)\n", clCmd&0xFF, clCmd); + clCmd >>= 8; + return; + } + NOPARAMS(); +} + +void gfx3d_sendCommand(u32 cmd, u32 param) +{ + cmd = (cmd & 0x01FF) >> 2; +#ifdef _3D_LOG + INFO("GFX FIFO: Send GFX 3D cmd 0x%02X to FIFO (0x%08X) - DIRECT (%i)\n", cmd, param, nds.cycles); +#endif + + switch (cmd) + { + case 0x10: // MTX_MODE - Set Matrix Mode (W) + case 0x11: // MTX_PUSH - Push Current Matrix on Stack (W) + case 0x12: // MTX_POP - Pop Current Matrix from Stack (W) + case 0x13: // MTX_STORE - Store Current Matrix on Stack (W) + case 0x14: // MTX_RESTORE - Restore Current Matrix from Stack (W) + case 0x15: // MTX_IDENTITY - Load Unit Matrix to Current Matrix (W) + case 0x16: // MTX_LOAD_4x4 - Load 4x4 Matrix to Current Matrix (W) + case 0x17: // MTX_LOAD_4x3 - Load 4x3 Matrix to Current Matrix (W) + case 0x18: // MTX_MULT_4x4 - Multiply Current Matrix by 4x4 Matrix (W) + case 0x19: // MTX_MULT_4x3 - Multiply Current Matrix by 4x3 Matrix (W) + case 0x1A: // MTX_MULT_3x3 - Multiply Current Matrix by 3x3 Matrix (W) + case 0x1B: // MTX_SCALE - Multiply Current Matrix by Scale Matrix (W) + case 0x1C: // MTX_TRANS - Mult. Curr. Matrix by Translation Matrix (W) + case 0x20: // COLOR - Directly Set Vertex Color (W) + case 0x21: // NORMAL - Set Normal Vector (W) + case 0x22: // TEXCOORD - Set Texture Coordinates (W) + case 0x23: // VTX_16 - Set Vertex XYZ Coordinates (W) + case 0x24: // VTX_10 - Set Vertex XYZ Coordinates (W) + case 0x25: // VTX_XY - Set Vertex XY Coordinates (W) + case 0x26: // VTX_XZ - Set Vertex XZ Coordinates (W) + case 0x27: // VTX_YZ - Set Vertex YZ Coordinates (W) + case 0x28: // VTX_DIFF - Set Relative Vertex Coordinates (W) + case 0x29: // POLYGON_ATTR - Set Polygon Attributes (W) + case 0x2A: // TEXIMAGE_PARAM - Set Texture Parameters (W) + case 0x2B: // PLTT_BASE - Set Texture Palette Base Address (W) + case 0x30: // DIF_AMB - MaterialColor0 - Diffuse/Ambient Reflect. (W) + case 0x31: // SPE_EMI - MaterialColor1 - Specular Ref. & Emission (W) + case 0x32: // LIGHT_VECTOR - Set Light's Directional Vector (W) + case 0x33: // LIGHT_COLOR - Set Light Color (W) + case 0x34: // SHININESS - Specular Reflection Shininess Table (W) + case 0x40: // BEGIN_VTXS - Start of Vertex List (W) + case 0x41: // END_VTXS - End of Vertex List (W) + case 0x60: // VIEWPORT - Set Viewport (W) + case 0x70: // BOX_TEST - Test if Cuboid Sits inside View Volume (W) + case 0x71: // POS_TEST - Set Position Coordinates for Test (W) + case 0x72: // VEC_TEST - Set Directional Vector for Test (W) + GFX_FIFOsend(cmd, param); + break; + case 0x50: // SWAP_BUFFERS - Swap Rendering Engine Buffer (W) + GFX_FIFOsend(cmd, param); + break; + default: + INFO("Unknown 3D command %03X with param 0x%08X (directport)\n", cmd, param); + break; + } +} + +#else +//#define _3D_LOG + +static void NOPARAMS() +{ + for (;;) + { + if (clCmd == 0) return; + switch (clCmd & 0xFF) + { + case 0x00: + { + clCmd >>= 8; + continue; + } + case 0x11: + { + gfx3d_glPushMatrix(); + GFX_FIFOsend(clCmd & 0xFF, 0); + clCmd >>= 8; + continue; + } + case 0x15: + { + gfx3d_glLoadIdentity(); + GFX_FIFOsend(clCmd & 0xFF, 0); + clCmd >>= 8; + continue; + } + case 0x41: + { + gfx3d_glEnd(); + GFX_FIFOsend(clCmd & 0xFF, 0); + clCmd >>= 8; + continue; + } + } + break; + } +} + +void gfx3d_sendCommandToFIFO(u32 val) +{ + if (clCmd == 0) + { + clCmd = val; + return; + } +#ifdef _3D_LOG + INFO("GFX FIFO: Send GFX 3D cmd 0x%02X to FIFO (0x%08X)\n", clCmd & 0xFF, val); +#endif + + NOPARAMS(); + if (clCmd == 0) + { + clCmd = val; + return; + } + + switch (clCmd & 0xFF) + { + case 0x10: // MTX_MODE - Set Matrix Mode (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glMatrixMode(val); + clCmd >>= 8; + break; + case 0x12: // MTX_POP - Pop Current Matrix from Stack (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glPopMatrix(val); + clCmd >>= 8; + break; + case 0x13: // MTX_STORE - Store Current Matrix on Stack (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glStoreMatrix(val); + clCmd >>= 8; + break; + case 0x14: // MTX_RESTORE - Restore Current Matrix from Stack (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glRestoreMatrix(val); + clCmd >>= 8; + break; + case 0x16: // MTX_LOAD_4x4 - Load 4x4 Matrix to Current Matrix (W) + GFX_FIFOsend(clCmd & 0xFF, val); + if (!gfx3d_glLoadMatrix4x4(val)) break; + clCmd >>= 8; + break; + case 0x17: // MTX_LOAD_4x3 - Load 4x3 Matrix to Current Matrix (W) + GFX_FIFOsend(clCmd & 0xFF, val); + if (!gfx3d_glLoadMatrix4x3(val)) break; + clCmd >>= 8; + break; + case 0x18: // MTX_MULT_4x4 - Multiply Current Matrix by 4x4 Matrix (W) + GFX_FIFOsend(clCmd & 0xFF, val); + if (!gfx3d_glMultMatrix4x4(val)) break; + clCmd >>= 8; + break; + case 0x19: // MTX_MULT_4x3 - Multiply Current Matrix by 4x3 Matrix (W) + GFX_FIFOsend(clCmd & 0xFF, val); + if (!gfx3d_glMultMatrix4x3(val)) break; + clCmd >>= 8; + break; + case 0x1A: // MTX_MULT_3x3 - Multiply Current Matrix by 3x3 Matrix (W) + GFX_FIFOsend(clCmd & 0xFF, val); + if (!gfx3d_glMultMatrix3x3(val)) break; + clCmd >>= 8; + break; + case 0x1B: // MTX_SCALE - Multiply Current Matrix by Scale Matrix (W) + GFX_FIFOsend(clCmd & 0xFF, val); + if (!gfx3d_glScale(val)) break; + clCmd >>= 8; + break; + case 0x1C: // MTX_TRANS - Mult. Curr. Matrix by Translation Matrix (W) + GFX_FIFOsend(clCmd & 0xFF, val); + if (!gfx3d_glTranslate(val)) break; + clCmd >>= 8; + break; + case 0x20: // COLOR - Directly Set Vertex Color (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glColor3b(val); + clCmd >>= 8; + break; + case 0x21: // NORMAL - Set Normal Vector (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glNormal(val); + clCmd >>= 8; + break; + case 0x22: // TEXCOORD - Set Texture Coordinates (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glTexCoord(val); + clCmd >>= 8; + break; + case 0x23: // VTX_16 - Set Vertex XYZ Coordinates (W) + GFX_FIFOsend(clCmd & 0xFF, val); + if (!gfx3d_glVertex16b(val)) break; + clCmd >>= 8; + break; + case 0x24: // VTX_10 - Set Vertex XYZ Coordinates (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glVertex10b(val); + clCmd >>= 8; + break; + case 0x25: // VTX_XY - Set Vertex XY Coordinates (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glVertex3_cord(0, 1, val); + clCmd >>= 8; + break; + case 0x26: // VTX_XZ - Set Vertex XZ Coordinates (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glVertex3_cord(0, 2, val); + clCmd >>= 8; + break; + case 0x27: // VTX_YZ - Set Vertex YZ Coordinates (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glVertex3_cord(1, 2, val); + clCmd >>= 8; + break; + case 0x28: // VTX_DIFF - Set Relative Vertex Coordinates (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glVertex_rel(val); + clCmd >>= 8; + break; + case 0x29: // POLYGON_ATTR - Set Polygon Attributes (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glPolygonAttrib(val); + clCmd >>= 8; + break; + case 0x2A: // TEXIMAGE_PARAM - Set Texture Parameters (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glTexImage(val); + clCmd >>= 8; + break; + case 0x2B: // PLTT_BASE - Set Texture Palette Base Address (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glTexPalette(val); + clCmd >>= 8; + break; + case 0x30: // DIF_AMB - MaterialColor0 - Diffuse/Ambient Reflect. (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glMaterial0(val); + clCmd >>= 8; + break; + case 0x31: // SPE_EMI - MaterialColor1 - Specular Ref. & Emission (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glMaterial1(val); + clCmd >>= 8; + break; + case 0x32: // LIGHT_VECTOR - Set Light's Directional Vector (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glLightDirection(val); + clCmd >>= 8; + break; + case 0x33: // LIGHT_COLOR - Set Light Color (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glLightColor(val); + clCmd >>= 8; + break; + case 0x34: // SHININESS - Specular Reflection Shininess Table (W) + GFX_FIFOsend(clCmd & 0xFF, val); + if (!gfx3d_glShininess(val)) break; + clCmd >>= 8; + break; + case 0x40: // BEGIN_VTXS - Start of Vertex List (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glBegin(val); + clCmd >>= 8; + break; + case 0x50: // SWAP_BUFFERS - Swap Rendering Engine Buffer (W) + gfx3d_glFlush(val); + break; + case 0x60: // VIEWPORT - Set Viewport (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glViewPort(val); + clCmd >>= 8; + break; + case 0x70: // BOX_TEST - Test if Cuboid Sits inside View Volume (W) + GFX_FIFOsend(clCmd & 0xFF, val); + if (!gfx3d_glBoxTest(val)) break; + clCmd >>= 8; + break; + case 0x71: // POS_TEST - Set Position Coordinates for Test (W) + GFX_FIFOsend(clCmd & 0xFF, val); + if (!gfx3d_glPosTest(val)) break; + clCmd >>= 8; + break; + case 0x72: // VEC_TEST - Set Directional Vector for Test (W) + GFX_FIFOsend(clCmd & 0xFF, val); + gfx3d_glVecTest(val); + clCmd >>= 8; + break; + default: + LOG("Unknown FIFO 3D command 0x%02X in cmd=0x%02X\n", clCmd&0xFF, val); + clCmd >>= 8; + break; + } + NOPARAMS(); +} + +void gfx3d_sendCommand(u32 cmd, u32 param) +{ + cmd &= 0x0FFF; +#ifdef _3D_LOG + INFO("GFX FIFO: Send GFX 3D cmd 0x%02X to FIFO (0x%08X) - DIRECT\n", (cmd & 0x1FF)>>2, param); +#endif + + switch (cmd) + { + case 0x340: // Alpha test reference value - Parameters:1 + gfx3d_glAlphaFunc(param); + break; + case 0x350: // Clear background color setup - Parameters:2 + gfx3d_glClearColor(param); + break; + case 0x354: // Clear background depth setup - Parameters:2 + gfx3d_glClearDepth(param); + break; + case 0x356: // Rear-plane Bitmap Scroll Offsets (W) + break; + case 0x358: // Fog Color - Parameters:4b + gfx3d_glFogColor(param); + break; + case 0x35C: + gfx3d_glFogOffset(param); + break; + case 0x440: // MTX_MODE - Set Matrix Mode (W) + gfx3d_glMatrixMode(param); + break; + case 0x444: // MTX_PUSH - Push Current Matrix on Stack (W) + gfx3d_glPushMatrix(); + break; + case 0x448: // MTX_POP - Pop Current Matrix from Stack (W) + gfx3d_glPopMatrix(param); + break; + case 0x44C: // MTX_STORE - Store Current Matrix on Stack (W) + gfx3d_glStoreMatrix(param); + break; + case 0x450: // MTX_RESTORE - Restore Current Matrix from Stack (W) + gfx3d_glRestoreMatrix(param); + break; + case 0x454: // MTX_IDENTITY - Load Unit Matrix to Current Matrix (W) + gfx3d_glLoadIdentity(); + break; + case 0x458: // MTX_LOAD_4x4 - Load 4x4 Matrix to Current Matrix (W) + gfx3d_glLoadMatrix4x4(param); + break; + case 0x45C: // MTX_LOAD_4x3 - Load 4x3 Matrix to Current Matrix (W) + gfx3d_glLoadMatrix4x3(param); + break; + case 0x460: // MTX_MULT_4x4 - Multiply Current Matrix by 4x4 Matrix (W) + gfx3d_glMultMatrix4x4(param); + break; + case 0x464: // MTX_MULT_4x3 - Multiply Current Matrix by 4x3 Matrix (W) + gfx3d_glMultMatrix4x3(param); + break; + case 0x468: // MTX_MULT_3x3 - Multiply Current Matrix by 3x3 Matrix (W) + gfx3d_glMultMatrix3x3(param); + break; + case 0x46C: // MTX_SCALE - Multiply Current Matrix by Scale Matrix (W) + gfx3d_glScale(param); + break; + case 0x470: // MTX_TRANS - Mult. Curr. Matrix by Translation Matrix (W) + gfx3d_glTranslate(param); + break; + case 0x480: // COLOR - Directly Set Vertex Color (W) + gfx3d_glColor3b(param); + break; + case 0x484: // NORMAL - Set Normal Vector (W) + gfx3d_glNormal(param); + break; + case 0x488: // TEXCOORD - Set Texture Coordinates (W) + gfx3d_glTexCoord(param); + break; + case 0x48C: // VTX_16 - Set Vertex XYZ Coordinates (W) + gfx3d_glVertex16b(param); + break; + case 0x490: // VTX_10 - Set Vertex XYZ Coordinates (W) + gfx3d_glVertex10b(param); + break; + case 0x494: // VTX_XY - Set Vertex XY Coordinates (W) + gfx3d_glVertex3_cord(0, 1, param); + break; + case 0x498: // VTX_XZ - Set Vertex XZ Coordinates (W) + gfx3d_glVertex3_cord(0, 2, param); + break; + case 0x49C: // VTX_YZ - Set Vertex YZ Coordinates (W) + gfx3d_glVertex3_cord(1, 2, param); + break; + case 0x4A0: // VTX_DIFF - Set Relative Vertex Coordinates (W) + gfx3d_glVertex_rel(param); + break; + case 0x4A4: // POLYGON_ATTR - Set Polygon Attributes (W) + gfx3d_glPolygonAttrib(param); + break; + case 0x4A8: // TEXIMAGE_PARAM - Set Texture Parameters (W) + gfx3d_glTexImage(param); + break; + case 0x4AC: // PLTT_BASE - Set Texture Palette Base Address (W) + gfx3d_glTexPalette(param); + break; + case 0x4C0: // DIF_AMB - MaterialColor0 - Diffuse/Ambient Reflect. (W) + gfx3d_glMaterial0(param); + break; + case 0x4C4: // SPE_EMI - MaterialColor1 - Specular Ref. & Emission (W) + gfx3d_glMaterial1(param); + break; + case 0x4C8: // LIGHT_VECTOR - Set Light's Directional Vector (W) + gfx3d_glLightDirection(param); + break; + case 0x4CC: // LIGHT_COLOR - Set Light Color (W) + gfx3d_glLightColor(param); + break; + case 0x4D0: // SHININESS - Specular Reflection Shininess Table (W) + gfx3d_glShininess(param); + break; + case 0x500: // BEGIN_VTXS - Start of Vertex List (W) + gfx3d_glBegin(param); + break; + case 0x504: // END_VTXS - End of Vertex List (W) + gfx3d_glEnd(); + break; + case 0x540: // SWAP_BUFFERS - Swap Rendering Engine Buffer (W) + gfx3d_glFlush(param); + break; + case 0x580: // VIEWPORT - Set Viewport (W) + gfx3d_glViewPort(param); + break; + case 0x5C0: // BOX_TEST - Test if Cuboid Sits inside View Volume (W) + gfx3d_glBoxTest(param); + break; + case 0x5C4: // POS_TEST - Set Position Coordinates for Test (W) + gfx3d_glPosTest(param); + break; + case 0x5C8: // VEC_TEST - Set Directional Vector for Test (W) + gfx3d_glVecTest(param); + break; + default: + LOG("Execute direct Port 3D command %03X in param=0x%08X\n", cmd, param); + break; + } +} +#endif + +void gfx3d_Control(u32 v) +{ + control = v; +} + +//-------------- +//other misc stuff +void gfx3d_glGetMatrix(unsigned int m_mode, int index, float* dest) +{ + if(index == -1) + { + MatrixCopy(dest, mtxCurrent[m_mode]); + return; + } + + MatrixCopy(dest, MatrixStackGetPos(&mtxStack[m_mode], index)); +} + +void gfx3d_glGetLightDirection(unsigned int index, unsigned int* dest) +{ + *dest = lightDirection[index]; +} + +void gfx3d_glGetLightColor(unsigned int index, unsigned int* dest) +{ + *dest = lightColor[index]; +} + +void gfx3d_GetLineData(int line, u16** dst, u8** dstAlpha) +{ + *dst = gfx3d_convertedScreen+((line)<<8); + if(dstAlpha != NULL) + { + *dstAlpha = gfx3d_convertedAlpha+((line)<<8); + } +} + + +//http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node17.html +//talks about the state required to process verts in quadlists etc. helpful ideas. +//consider building a little state structure that looks exactly like this describes + +SFORMAT SF_GFX3D[]={ + //{ "GCTL", 4, 1, &control}, //this gets regenerated by the code i hate which regenerates gpu regs + { "GPAT", 4, 1, &polyAttr}, + { "GPAP", 4, 1, &polyAttrPending}, + { "GINB", 4, 1, &inBegin}, + { "GTFM", 4, 1, &textureFormat}, + { "GTPA", 4, 1, &texturePalette}, + { "GMOD", 4, 1, &mode}, + { "GMTM", 4,16, mtxTemporal}, + { "GMCU", 4,64, mtxCurrent}, + { "ML4I", 1, 1, &ML4x4ind}, + { "ML3I", 1, 1, &ML4x3ind}, + { "MM4I", 1, 1, &MM4x4ind}, + { "MM3I", 1, 1, &MM4x3ind}, + { "MMxI", 1, 1, &MM3x3ind}, + { "GCOR", 4, 1, coord}, + { "GCOI", 1, 1, &coordind}, + { "GVFM", 4, 1, &vtxFormat}, + { "GTRN", 4, 4, trans}, + { "GTRI", 1, 1, &transind}, + { "GSCA", 4, 4, scale}, + { "GSCI", 1, 1, &scaleind}, + { "G_T_", 4, 1, &_t}, + { "G_S_", 4, 1, &_s}, + { "GL_T", 4, 1, &last_t}, + { "GL_S", 4, 1, &last_s}, + { "GLCM", 4, 1, &clCmd}, + { "GLIN", 4, 1, &clInd}, +#ifdef USE_GEOMETRY_FIFO_EMULATION + { "GLI2", 4, 1, &clInd2}, +#endif + { "GLBT", 4, 1, &BTind}, + { "GLPT", 4, 1, &PTind}, + { "GLPC", 4, 4, PTcoords}, + { "GLF9", 4, 1, &gxFIFO.tail}, + { "GLF9", 1, 261, &gxFIFO.cmd[0]}, + { "GLF9", 4, 261, &gxFIFO.param[0]}, + { "GCOL", 1, 4, colorRGB}, + { "GLCO", 4, 4, lightColor}, + { "GLDI", 4, 4, lightDirection}, + { "GMDI", 2, 1, &dsDiffuse}, + { "GMAM", 2, 1, &dsAmbient}, + { "GMSP", 2, 1, &dsSpecular}, + { "GMEM", 2, 1, &dsEmission}, + { "GFLP", 4, 1, &flushPending}, + { "GDRP", 4, 1, &drawPending}, + { "GSET", 4, 1, &gfx3d.enableTexturing}, + { "GSEA", 4, 1, &gfx3d.enableAlphaTest}, + { "GSEB", 4, 1, &gfx3d.enableAlphaBlending}, + { "GSEX", 4, 1, &gfx3d.enableAntialiasing}, + { "GSEE", 4, 1, &gfx3d.enableEdgeMarking}, + { "GSSH", 4, 1, &gfx3d.shading}, + { "GSWB", 4, 1, &gfx3d.wbuffer}, + { "GSSM", 4, 1, &gfx3d.sortmode}, + { "GSAR", 1, 1, &gfx3d.alphaTestRef}, + { "GSVP", 4, 1, &viewport}, + { "GSCC", 4, 1, &gfx3d.clearColor}, + { "GSCD", 4, 1, &gfx3d.clearDepth}, + { "GSFC", 4, 4, gfx3d.fogColor}, + { "GSFO", 4, 1, &gfx3d.fogOffset}, + { "GST2", 2, 32, gfx3d.u16ToonTable}, + { "GSST", 4, 128, shininessTable}, + { "GSSI", 4, 1, &shininessInd}, + //------------------------ + { "GTST", 4, 1, &triStripToggle}, + { "GTVC", 4, 1, &tempVertInfo.count}, + { "GTVM", 4, 4, tempVertInfo.map}, + { "GTVF", 4, 1, &tempVertInfo.first}, + { "G3CS", 2, 256*192, gfx3d_convertedScreen}, + { "G3CA", 2, 256*192, gfx3d_convertedAlpha}, + { 0 } +}; + +//-------------savestate +void gfx3d_savestate(std::ostream* os) +{ + //version + write32le(2,os); + + //dump the render lists + OSWRITE(vertlist->count); + for(int i=0;icount;i++) + vertlist->list[i].save(os); + OSWRITE(polylist->count); + for(int i=0;icount;i++) + polylist->list[i].save(os); + + for(int i=0;i<4;i++) + { + OSWRITE(mtxStack[i].position); + for(int j=0;j=1) + { + OSREAD(vertlist->count); + for(int i=0;icount;i++) + vertlist->list[i].load(is); + OSREAD(polylist->count); + for(int i=0;icount;i++) + polylist->list[i].load(is); + } + + if(version>=2) + { + for(int i=0;i<4;i++) + { + OSREAD(mtxStack[i].position); + for(int j=0;jcount=0; + gfx3d.vertlist->count=0; + + return true; +} diff --git a/desmume/src/gfx3d.h b/src/gfx3d.h similarity index 87% rename from desmume/src/gfx3d.h rename to src/gfx3d.h index c39d5ebde..c0b223ed9 100644 --- a/desmume/src/gfx3d.h +++ b/src/gfx3d.h @@ -1,352 +1,319 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2008-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _GFX3D_H_ -#define _GFX3D_H_ - -#include "types.h" -#include -#include -#include - -//produce a 32bpp color from a DS RGB16 -#define RGB16TO32(col,alpha) (((alpha)<<24) | ((((col) & 0x7C00)>>7)<<16) | ((((col) & 0x3E0)>>2)<<8) | (((col) & 0x1F)<<3)) - -//produce a 32bpp color from a ds RGB15 plus an 8bit alpha, using a table -#define RGB15TO32(col,alpha8) ( ((alpha8)<<24) | color_15bit_to_24bit[col&0x7FFF] ) - -//produce a 5555 32bit color from a ds RGB15 plus an 5bit alpha -#define RGB15TO5555(col,alpha5) (((alpha5)<<24) | ((((col) & 0x7C00)>>10)<<16) | ((((col) & 0x3E0)>>5)<<8) | (((col) & 0x1F))) - -//produce a 6665 32bit color from a ds RGB15 plus an 5bit alpha -inline u32 RGB15TO6665(u16 col, u8 alpha5) -{ - u32 ret = alpha5<<24; - u16 r = (col&0x1F)>>0; - u16 g = (col&0x3E0)>>5; - u16 b = (col&0x7C00)>>10; - if(r) ret |= ((r<<1)+1); - if(g) ret |= ((g<<1)+1)<<8; - if(b) ret |= ((b<<1)+1)<<16; - return ret; -} - -//produce a 24bpp color from a ds RGB15, using a table -#define RGB15TO24_REVERSE(col) ( color_15bit_to_24bit_reverse[col&0x7FFF] ) - -//produce a 16bpp color from a ds RGB15, using a table -#define RGB15TO16_REVERSE(col) ( color_15bit_to_16bit_reverse[col&0x7FFF] ) - -//produce a 32bpp color from a ds RGB15 plus an 8bit alpha, not using a table (but using other tables) -#define RGB15TO32_DIRECT(col,alpha8) ( ((alpha8)<<24) | (material_5bit_to_8bit[((col)>>10)&0x1F]<<16) | (material_5bit_to_8bit[((col)>>5)&0x1F]<<8) | material_5bit_to_8bit[(col)&0x1F] ) - -//produce a 15bpp color from individual 5bit components -#define R5G5B5TORGB15(r,g,b) ((r)|((g)<<5)|((b)<<10)) - -//produce a 16bpp color from individual 5bit components -#define R6G6B6TORGB15(r,g,b) ((r>>1)|((g&0x3E)<<4)|((b&0x3E)<<9)) - -#define GFX3D_5TO6(x) ((x)?(((x)<<1)+1):0) - -inline u32 gfx3d_extendDepth_15_to_24(u32 depth) -{ - //formula from http://nocash.emubase.de/gbatek.htm#ds3drearplane - //return (depth*0x200)+((depth+1)>>15)*0x01FF; - //I think this might be slightly faster - if(depth==0x7FFF) return 0x00FFFFFF; - else return depth<<9; -} - -#define TEXMODE_NONE 0 -#define TEXMODE_A3I5 1 -#define TEXMODE_I2 2 -#define TEXMODE_I4 3 -#define TEXMODE_I8 4 -#define TEXMODE_4X4 5 -#define TEXMODE_A5I3 6 -#define TEXMODE_16BPP 7 - -void gfx3d_init(); -void gfx3d_reset(); - -#define OSWRITE(x) os->write((char*)&(x),sizeof((x))); -#define OSREAD(x) is->read((char*)&(x),sizeof((x))); - -struct POLY { - int type; //tri or quad - u16 vertIndexes[4]; //up to four verts can be referenced by this poly - u32 polyAttr, texParam, texPalette; //the hardware rendering params - u32 viewport; - float miny, maxy; - - bool isTranslucent() - { - //alpha != 31 -> translucent - //except for alpha 0 which is wireframe (unless it has a translucent tex) - if((polyAttr&0x001F0000) != 0x001F0000 && (polyAttr&0x001F0000) != 0) - return true; - int texFormat = (texParam>>26)&7; - - //a5i3 or a3i5 -> translucent - if(texFormat==1 || texFormat==6) - return true; - - return false; - } - - int getAlpha() { return (polyAttr>>16)&0x1F; } - - void save(std::ostream* os) - { - OSWRITE(type); - OSWRITE(vertIndexes[0]); OSWRITE(vertIndexes[1]); OSWRITE(vertIndexes[2]); OSWRITE(vertIndexes[3]); - OSWRITE(polyAttr); OSWRITE(texParam); OSWRITE(texPalette); - OSWRITE(viewport); - OSWRITE(miny); - OSWRITE(maxy); - } - - void load(std::istream* is) - { - OSREAD(type); - OSREAD(vertIndexes[0]); OSREAD(vertIndexes[1]); OSREAD(vertIndexes[2]); OSREAD(vertIndexes[3]); - OSREAD(polyAttr); OSREAD(texParam); OSREAD(texPalette); - OSREAD(viewport); - OSREAD(miny); - OSREAD(maxy); - } -}; - -#define POLYLIST_SIZE 100000 -//#define POLYLIST_SIZE 2048 -struct POLYLIST { - POLY list[POLYLIST_SIZE]; - int count; -}; - -struct VERT { - union { - float coord[4]; - struct { - float x,y,z,w; - }; - }; - union { - float texcoord[2]; - struct { - float u,v; - }; - }; - u8 color[3]; - float fcolor[3]; - void color_to_float() { - fcolor[0] = color[0]; - fcolor[1] = color[1]; - fcolor[2] = color[2]; - } - void save(std::ostream* os) - { - OSWRITE(x); OSWRITE(y); OSWRITE(z); OSWRITE(w); - OSWRITE(u); OSWRITE(v); - OSWRITE(color[0]); OSWRITE(color[1]); OSWRITE(color[2]); - OSWRITE(fcolor[0]); OSWRITE(fcolor[1]); OSWRITE(fcolor[2]); - } - void load(std::istream* is) - { - OSREAD(x); OSREAD(y); OSREAD(z); OSREAD(w); - OSREAD(u); OSREAD(v); - OSREAD(color[0]); OSREAD(color[1]); OSREAD(color[2]); - OSREAD(fcolor[0]); OSREAD(fcolor[1]); OSREAD(fcolor[2]); - } -}; - -#define VERTLIST_SIZE 400000 -//#define VERTLIST_SIZE 10000 -struct VERTLIST { - VERT list[VERTLIST_SIZE]; - int count; -}; - - -struct VIEWPORT { - int x, y, width, height; - void decode(u32 v); -}; - -//used to communicate state to the renderer -struct GFX3D -{ - GFX3D() - : enableTexturing(true) - , enableAlphaTest(true) - , enableAlphaBlending(true) - , enableAntialiasing(false) - , enableEdgeMarking(false) - , enableClearImage(false) - , enableFog(false) - , enableFogAlphaOnly(false) - , fogShift(0) - , shading(TOON) - , polylist(0) - , vertlist(0) - , alphaTestRef(0) - , clearDepth(1) - , clearColor(0) - , fogColor(0) - , fogOffset(0) - , frameCtr(0) - , frameCtrRaw(0) - { - } - BOOL enableTexturing, enableAlphaTest, enableAlphaBlending, - enableAntialiasing, enableEdgeMarking, enableClearImage, enableFog, enableFogAlphaOnly; - - u32 fogShift; - - static const u32 TOON = 0; - static const u32 HIGHLIGHT = 1; - u32 shading; - - POLYLIST* polylist; - VERTLIST* vertlist; - int indexlist[POLYLIST_SIZE]; - - BOOL wbuffer, sortmode; - - u8 alphaTestRef; - - u32 clearDepth; - u32 clearColor; - #include "PACKED.h" - struct { - u32 fogColor; - u32 pad[3]; //for savestate compatibility as of 26-jul-09 - }; - #include "PACKED_END.h" - u32 fogOffset; - - //ticks every time flush() is called - int frameCtr; - - //you can use this to track how many real frames passed, for comparing to frameCtr; - int frameCtrRaw; - - u16 u16ToonTable[32]; -}; -extern GFX3D gfx3d; - -//--------------------- - -extern CACHE_ALIGN u32 color_15bit_to_24bit[32768]; -extern CACHE_ALIGN u32 color_15bit_to_24bit_reverse[32768]; -extern CACHE_ALIGN u16 color_15bit_to_16bit_reverse[32768]; -extern CACHE_ALIGN u8 mixTable555[32][32][32]; -extern CACHE_ALIGN const int material_5bit_to_31bit[32]; -extern CACHE_ALIGN const u8 material_5bit_to_8bit[32]; -extern CACHE_ALIGN const u8 material_3bit_to_5bit[8]; -extern CACHE_ALIGN const u8 material_3bit_to_6bit[8]; -extern CACHE_ALIGN const u8 material_3bit_to_8bit[8]; - -//these contain the 3d framebuffer converted into the most useful format -//they are stored here instead of in the renderers in order to consolidate the buffers -extern CACHE_ALIGN u8 gfx3d_convertedScreen[256*192*4]; -extern CACHE_ALIGN u8 gfx3d_convertedAlpha[256*192*2]; //see cpp for explanation of illogical *2 - -//GE commands: -#ifndef USE_GEOMETRY_FIFO_EMULATION -void gfx3d_glMatrixMode(u32 v); -void gfx3d_glPushMatrix(void); -void gfx3d_glPopMatrix(s32 i); -void gfx3d_glStoreMatrix(u32 v); -void gfx3d_glRestoreMatrix(u32 v); -void gfx3d_glLoadIdentity(); -BOOL gfx3d_glLoadMatrix4x4(s32 v); -BOOL gfx3d_glLoadMatrix4x3(s32 v); -BOOL gfx3d_glMultMatrix4x4(s32 v); -BOOL gfx3d_glMultMatrix3x3(s32 v); -BOOL gfx3d_glMultMatrix4x3(s32 v); -BOOL gfx3d_glScale(s32 v); -BOOL gfx3d_glTranslate(s32 v); -void gfx3d_glColor3b(u32 v); -void gfx3d_glNormal(u32 v); -void gfx3d_glTexCoord(u32 val); -BOOL gfx3d_glVertex16b(u32 v); -void gfx3d_glVertex10b(u32 v); -void gfx3d_glVertex3_cord(u32 one, u32 two, u32 v); -void gfx3d_glVertex_rel(u32 v); -void gfx3d_glPolygonAttrib (u32 val); -void gfx3d_glTexImage(u32 val); -void gfx3d_glTexPalette(u32 val); -void gfx3d_glMaterial0(u32 val); -void gfx3d_glMaterial1(u32 val); -void gfx3d_glLightDirection (u32 v); -void gfx3d_glLightColor (u32 v); -BOOL gfx3d_glShininess (u32 val); -void gfx3d_glBegin(u32 v); -void gfx3d_glEnd(void); -// SwapBuffers see follow -void gfx3d_glViewPort(u32 v); -BOOL gfx3d_glBoxTest(u32 v); -BOOL gfx3d_glPosTest(u32 v); -void gfx3d_glVecTest(u32 v); -#endif -void gfx3d_glFlush(u32 v); -// end GE commands - -void gfx3d_glClearColor(u32 v); -void gfx3d_glFogColor(u32 v); -void gfx3d_glFogOffset (u32 v); -void gfx3d_glClearDepth(u32 v); -void gfx3d_glSwapScreen(u32 screen); -int gfx3d_GetNumPolys(); -int gfx3d_GetNumVertex(); -void gfx3d_UpdateToonTable(u8 offset, u16 val); -void gfx3d_UpdateToonTable(u8 offset, u32 val); -s32 gfx3d_GetClipMatrix (u32 index); -s32 gfx3d_GetDirectionalMatrix (u32 index); -void gfx3d_glAlphaFunc(u32 v); -u32 gfx3d_glGetPosRes(u32 index); -u16 gfx3d_glGetVecRes(u32 index); -void gfx3d_VBlankSignal(); -void gfx3d_VBlankEndSignal(bool skipFrame); -void gfx3d_Control(u32 v); -#ifdef USE_GEOMETRY_FIFO_EMULATION -void gfx3d_execute3D(); -#endif -void gfx3d_sendCommandToFIFO(u32 val); -void gfx3d_sendCommand(u32 cmd, u32 param); - -//other misc stuff -void gfx3d_glGetMatrix(u32 mode, int index, float* dest); -void gfx3d_glGetLightDirection(u32 index, u32* dest); -void gfx3d_glGetLightColor(u32 index, u32* dest); - -void gfx3d_GetLineData(int line, u8** dst); -void gfx3d_GetLineData15bpp(int line, u16** dst); - -struct SFORMAT; -extern SFORMAT SF_GFX3D[]; -void gfx3d_savestate(std::ostream* os); -bool gfx3d_loadstate(std::istream* is, int size); - -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _GFX3D_H_ +#define _GFX3D_H_ + +#include "types.h" +#include +#include +#include + +//produce a 32bpp color from a DS RGB16 +#define RGB16TO32(col,alpha) (((alpha)<<24) | ((((col) & 0x7C00)>>7)<<16) | ((((col) & 0x3E0)>>2)<<8) | (((col) & 0x1F)<<3)) + +//produce a 32bpp color from a ds RGB15 plus an 8bit alpha, using a table +#define RGB15TO32(col,alpha8) ( ((alpha8)<<24) | color_15bit_to_24bit[col&0x7FFF] ) + +//produce a 5555 32bit color from a ds RGB15 plus an 5bit alpha +#define RGB15TO5555(col,alpha5) (((alpha5)<<24) | ((((col) & 0x7C00)>>10)<<16) | ((((col) & 0x3E0)>>5)<<8) | (((col) & 0x1F))) + +//produce a 24bpp color from a ds RGB15, using a table +#define RGB15TO24_REVERSE(col) ( color_15bit_to_24bit_reverse[col&0x7FFF] ) + +//produce a 16bpp color from a ds RGB15, using a table +#define RGB15TO16_REVERSE(col) ( color_15bit_to_16bit_reverse[col&0x7FFF] ) + +//produce a 32bpp color from a ds RGB15 plus an 8bit alpha, not using a table (but using other tables) +#define RGB15TO32_DIRECT(col,alpha8) ( ((alpha8)<<24) | (material_5bit_to_8bit[((col)>>10)&0x1F]<<16) | (material_5bit_to_8bit[((col)>>5)&0x1F]<<8) | material_5bit_to_8bit[(col)&0x1F] ) + +//produce a 15bpp color from individual 5bit components +#define R5G5B5TORGB15(r,g,b) ((r)|((g)<<5)|((b)<<10)) + +inline u32 gfx3d_extendDepth_15_to_24(u32 depth) +{ + //formula from http://nocash.emubase.de/gbatek.htm#ds3drearplane + //return (depth*0x200)+((depth+1)>>15)*0x01FF; + //I think this might be slightly faster + if(depth==0x7FFF) return 0x00FFFFFF; + else return depth<<9; +} + +#define TEXMODE_NONE 0 +#define TEXMODE_A3I5 1 +#define TEXMODE_I2 2 +#define TEXMODE_I4 3 +#define TEXMODE_I8 4 +#define TEXMODE_4X4 5 +#define TEXMODE_A5I3 6 +#define TEXMODE_16BPP 7 + +void gfx3d_init(); +void gfx3d_reset(); + +#define OSWRITE(x) os->write((char*)&(x),sizeof((x))); +#define OSREAD(x) is->read((char*)&(x),sizeof((x))); + +struct POLY { + int type; //tri or quad + u16 vertIndexes[4]; //up to four verts can be referenced by this poly + u32 polyAttr, texParam, texPalette; //the hardware rendering params + u32 viewport; + float miny, maxy; + + bool isTranslucent() + { + //alpha != 31 -> translucent + if((polyAttr&0x001F0000) != 0x001F0000) + return true; + int texFormat = (texParam>>26)&7; + + //a5i3 or a3i5 -> translucent + if(texFormat==1 || texFormat==6) + return true; + + return false; + } + + int getAlpha() { return (polyAttr>>16)&0x1F; } + + void save(std::ostream* os) + { + OSWRITE(type); + OSWRITE(vertIndexes[0]); OSWRITE(vertIndexes[1]); OSWRITE(vertIndexes[2]); OSWRITE(vertIndexes[3]); + OSWRITE(polyAttr); OSWRITE(texParam); OSWRITE(texPalette); + OSWRITE(viewport); + OSWRITE(miny); + OSWRITE(maxy); + } + + void load(std::istream* is) + { + OSREAD(type); + OSREAD(vertIndexes[0]); OSREAD(vertIndexes[1]); OSREAD(vertIndexes[2]); OSREAD(vertIndexes[3]); + OSREAD(polyAttr); OSREAD(texParam); OSREAD(texPalette); + OSREAD(viewport); + OSREAD(miny); + OSREAD(maxy); + } +}; + +#define POLYLIST_SIZE 100000 +//#define POLYLIST_SIZE 2048 +struct POLYLIST { + POLY list[POLYLIST_SIZE]; + int count; +}; + +struct VERT { + union { + float coord[4]; + struct { + float x,y,z,w; + }; + }; + union { + float texcoord[2]; + struct { + float u,v; + }; + }; + u8 color[3]; + float fcolor[3]; + void color_to_float() { + fcolor[0] = color[0]; + fcolor[1] = color[1]; + fcolor[2] = color[2]; + } + void save(std::ostream* os) + { + OSWRITE(x); OSWRITE(y); OSWRITE(z); OSWRITE(w); + OSWRITE(u); OSWRITE(v); + OSWRITE(color[0]); OSWRITE(color[1]); OSWRITE(color[2]); + OSWRITE(fcolor[0]); OSWRITE(fcolor[1]); OSWRITE(fcolor[2]); + } + void load(std::istream* is) + { + OSREAD(x); OSREAD(y); OSREAD(z); OSREAD(w); + OSREAD(u); OSREAD(v); + OSREAD(color[0]); OSREAD(color[1]); OSREAD(color[2]); + OSREAD(fcolor[0]); OSREAD(fcolor[1]); OSREAD(fcolor[2]); + } +}; + +#define VERTLIST_SIZE 400000 +//#define VERTLIST_SIZE 10000 +struct VERTLIST { + VERT list[VERTLIST_SIZE]; + int count; +}; + + +struct VIEWPORT { + int x, y, width, height; + void decode(u32 v); +}; + +//used to communicate state to the renderer +struct GFX3D +{ + GFX3D() + : enableTexturing(true) + , enableAlphaTest(true) + , enableAlphaBlending(true) + , enableAntialiasing(false) + , enableEdgeMarking(false) + , enableClearImage(false) + , shading(TOON) + , polylist(0) + , vertlist(0) + , alphaTestRef(0) + , clearDepth(1) + , clearColor(0) + , frameCtr(0) + , frameCtrRaw(0) + { + fogColor[0] = fogColor[1] = fogColor[2] = fogColor[3] = 0; + fogOffset = 0; + } + BOOL enableTexturing, enableAlphaTest, enableAlphaBlending, + enableAntialiasing, enableEdgeMarking, enableClearImage; + + static const u32 TOON = 0; + static const u32 HIGHLIGHT = 1; + u32 shading; + + POLYLIST* polylist; + VERTLIST* vertlist; + int indexlist[POLYLIST_SIZE]; + + BOOL wbuffer, sortmode; + + u8 alphaTestRef; + + u32 clearDepth; + u32 clearColor; + float fogColor[4]; + float fogOffset; + + //ticks every time flush() is called + int frameCtr; + + //you can use this to track how many real frames passed, for comparing to frameCtr; + int frameCtrRaw; + + u16 u16ToonTable[32]; +}; +extern GFX3D gfx3d; + +//--------------------- + +extern CACHE_ALIGN const u16 alpha_lookup[32]; +extern CACHE_ALIGN u32 color_15bit_to_24bit[32768]; +extern CACHE_ALIGN u32 color_15bit_to_24bit_reverse[32768]; +extern CACHE_ALIGN u16 color_15bit_to_16bit_reverse[32768]; +extern CACHE_ALIGN u8 mixTable555[32][32][32]; +extern CACHE_ALIGN const int material_5bit_to_31bit[32]; +extern CACHE_ALIGN const u8 material_5bit_to_8bit[32]; +extern CACHE_ALIGN const u8 material_3bit_to_5bit[8]; +extern CACHE_ALIGN const u8 material_3bit_to_8bit[8]; +extern CACHE_ALIGN const u8 alpha_5bit_to_4bit[32]; + +//these contain the 3d framebuffer converted into the most useful format +//they are stored here instead of in the renderers in order to consolidate the buffers +extern CACHE_ALIGN u16 gfx3d_convertedScreen[256*192]; +extern CACHE_ALIGN u8 gfx3d_convertedAlpha[256*192*2]; //see cpp for explanation of illogical *2 + +//GE commands: +void gfx3d_glViewPort(u32 v); +void gfx3d_glClearColor(u32 v); +void gfx3d_glFogColor(u32 v); +void gfx3d_glFogOffset (u32 v); +void gfx3d_glClearDepth(u32 v); +void gfx3d_glMatrixMode(u32 v); +void gfx3d_glLoadIdentity(); +BOOL gfx3d_glLoadMatrix4x4(s32 v); +BOOL gfx3d_glLoadMatrix4x3(s32 v); +void gfx3d_glStoreMatrix(u32 v); +void gfx3d_glRestoreMatrix(u32 v); +void gfx3d_glPushMatrix(void); +void gfx3d_glPopMatrix(s32 i); +BOOL gfx3d_glTranslate(s32 v); +BOOL gfx3d_glScale(s32 v); +BOOL gfx3d_glMultMatrix3x3(s32 v); +BOOL gfx3d_glMultMatrix4x3(s32 v); +BOOL gfx3d_glMultMatrix4x4(s32 v); +void gfx3d_glBegin(u32 v); +void gfx3d_glEnd(void); +void gfx3d_glColor3b(u32 v); +BOOL gfx3d_glVertex16b(u32 v); +void gfx3d_glVertex10b(u32 v); +void gfx3d_glVertex3_cord(u32 one, u32 two, u32 v); +void gfx3d_glVertex_rel(u32 v); +void gfx3d_glSwapScreen(u32 screen); +int gfx3d_GetNumPolys(); +int gfx3d_GetNumVertex(); +void gfx3d_glPolygonAttrib (u32 val); +void gfx3d_glMaterial0(u32 val); +void gfx3d_glMaterial1(u32 val); +BOOL gfx3d_glShininess (u32 val); +void gfx3d_UpdateToonTable(u8 offset, u16 val); +void gfx3d_UpdateToonTable(u8 offset, u32 val); +void gfx3d_glTexImage(u32 val); +void gfx3d_glTexPalette(u32 val); +void gfx3d_glTexCoord(u32 val); +void gfx3d_glNormal(u32 v); +s32 gfx3d_GetClipMatrix (u32 index); +s32 gfx3d_GetDirectionalMatrix (u32 index); +void gfx3d_glLightDirection (u32 v); +void gfx3d_glLightColor (u32 v); +void gfx3d_glAlphaFunc(u32 v); +BOOL gfx3d_glBoxTest(u32 v); +BOOL gfx3d_glPosTest(u32 v); +void gfx3d_glVecTest(u32 v); +u32 gfx3d_glGetPosRes(u32 index); +u16 gfx3d_glGetVecRes(u32 index); +void gfx3d_glFlush(u32 v); +void gfx3d_VBlankSignal(); +void gfx3d_VBlankEndSignal(bool skipFrame); +void gfx3d_Control(u32 v); +u32 gfx3d_GetGXstatus(); +#ifdef USE_GEOMETRY_FIFO_EMULATION +void gfx3d_execute3D(); +#endif +void gfx3d_sendCommandToFIFO(u32 val); +void gfx3d_sendCommand(u32 cmd, u32 param); + +//other misc stuff +void gfx3d_glGetMatrix(u32 mode, int index, float* dest); +void gfx3d_glGetLightDirection(u32 index, u32* dest); +void gfx3d_glGetLightColor(u32 index, u32* dest); + +void gfx3d_GetLineData(int line, u16** dst, u8** dstAlpha); + +struct SFORMAT; +extern SFORMAT SF_GFX3D[]; +void gfx3d_savestate(std::ostream* os); +bool gfx3d_loadstate(std::istream* is, int size); + +#endif diff --git a/desmume/src/gtk-glade/Makefile.am b/src/gtk-glade/Makefile.am similarity index 100% rename from desmume/src/gtk-glade/Makefile.am rename to src/gtk-glade/Makefile.am diff --git a/desmume/src/gtk-glade/callbacks.cpp b/src/gtk-glade/callbacks.cpp old mode 100755 new mode 100644 similarity index 96% rename from desmume/src/gtk-glade/callbacks.cpp rename to src/gtk-glade/callbacks.cpp index bd5f5ee7a..43d79c19e --- a/desmume/src/gtk-glade/callbacks.cpp +++ b/src/gtk-glade/callbacks.cpp @@ -1,537 +1,537 @@ -/* callbacks.c - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Copyright (C) 2007 Pascal Giard (evilynux) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "callbacks.h" - -/* globals */ -int Frameskip = 0; -gboolean ScreenRightForce=FALSE; -gboolean ScreenRight=FALSE; -gboolean ScreenGap=FALSE; -gboolean ScreenNoGap=FALSE; -gboolean ScreenInvert=FALSE; - -/* ******** Savestate menu items handling ******** */ - -static void set_menuitem_label(GtkWidget * w, char * text ) -{ - GtkLabel * child; - - if ( GTK_BIN(w)->child ) - { - child = (GtkLabel*)GTK_BIN(w)->child; - gtk_label_set_text(child, text); - } -} - -static void clear_savestate_menu(const char * cb_name, u8 num) -{ - GtkWidget * w; - char cb[40]; - char text[40]; - - sprintf( cb, "%s%d", cb_name, num); - sprintf( text, _("State %d (empty)"), num); - w = glade_xml_get_widget(xml, cb); - set_menuitem_label( w, text ); -} - -static void update_savestate_menu(const char * cb_name, u8 num) -{ - GtkWidget * w; - char cb[40]; - - snprintf( cb, 39, "%s%d", cb_name, num); - w = glade_xml_get_widget(xml, cb); - set_menuitem_label( w, savestates[num-1].date ); -} - -static void update_savestates_menu() -{ - u8 i; - - for( i = 1; i <= NB_STATES; i++ ) - { - if( savestates[i-1].exists == TRUE ) - { - update_savestate_menu("loadstate", i); - update_savestate_menu("savestate", i); - } - else - { - clear_savestate_menu("loadstate", i); - clear_savestate_menu("savestate", i); - } - } -} - -static void update_savestate(u8 num) -{ - desmume_pause(); - savestate_slot(num); - update_savestate_menu("savestate", num); - update_savestate_menu("loadstate", num); - desmume_resume(); -} - -/* inline & protos */ - -inline void SET_SENSITIVE(const gchar *w, gboolean b) { - gtk_widget_set_sensitive( - glade_xml_get_widget(xml, w), TRUE); -} - -void enable_rom_features() { - scan_savestates(); - update_savestates_menu(); - SET_SENSITIVE("menu_exec", TRUE); - SET_SENSITIVE("menu_pause", TRUE); - SET_SENSITIVE("menu_reset", TRUE); - SET_SENSITIVE("wgt_Exec", TRUE); - SET_SENSITIVE("wgt_Reset", TRUE); -} - -static void MAINWINDOW_RESIZE() { - GtkWidget * spacer1 = glade_xml_get_widget(xml, "misc_sep3"); - GtkWidget * spacer2 = glade_xml_get_widget(xml, "misc_sep4"); - int dim1,dim2; - BOOL rotate = (ScreenRotate==90.0 || ScreenRotate==270.0 ); - - dim1 = dim2 = 66 * ScreenCoeff_Size[0]; - - /* sees whether we want a gap */ - if (!ScreenGap) dim1 = dim2 = -1; - - if (ScreenNoGap) { - gtk_widget_hide (spacer1); - gtk_widget_hide (spacer2); - } - else - { - gtk_widget_show (spacer1); - gtk_widget_show (spacer2); - } - - if (ScreenRight == rotate) { - if (ScreenRight) - dim2 = -1; - else - dim1 = -1; - } else { - dim1 = dim2 = -1; - } - gtk_widget_set_usize(spacer1, dim1, -1); - gtk_widget_set_usize(spacer2, -1, dim2); - gtk_window_resize ((GtkWindow*)pWindow,1,1); -} - -/* MENU FILE ***** ***** ***** ***** */ -void inline ADD_FILTER(GtkWidget * filech, const char * pattern, const char * name) { - GtkFileFilter *pFilter; - pFilter = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter, pattern); - gtk_file_filter_set_name(pFilter, name); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filech), pFilter); -} - -static void file_open() { - desmume_pause(); - - GtkWidget *pFileSelection; - GtkWidget *pParent; - gchar *sChemin; - - pParent = GTK_WIDGET(pWindow); - - /* Creating the selection window */ - pFileSelection = gtk_file_chooser_dialog_new(_("Open..."), - GTK_WINDOW(pParent), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_OK, - NULL); - /* On limite les actions a cette fenetre */ - gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); - - ADD_FILTER(pFileSelection, "*.nds", _("Nds binary (.nds)")); - ADD_FILTER(pFileSelection, "*.ds.gba", _("Nds binary with loader (.ds.gba)")); - ADD_FILTER(pFileSelection, "*", _("All files")); - //ADD_FILTER(pFileSelection, "*.zip", "Nds zipped binary"); - - /* Affichage fenetre*/ - switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) - { - case GTK_RESPONSE_OK: - /* Recuperation du chemin */ - sChemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); - if(desmume_open((const char*)sChemin) < 0) - { - GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Unable to load :\n%s"), sChemin); - gtk_dialog_run(GTK_DIALOG(pDialog)); - gtk_widget_destroy(pDialog); - } else { - desmume_resume(); - enable_rom_features(); - } - - g_free(sChemin); - break; - default: - break; - } - gtk_widget_destroy(pFileSelection); -} - -void on_menu_open_activate (GtkMenuItem *menuitem, gpointer user_data) { file_open();} -void on_menu_quit_activate (GtkMenuItem *menuitem, gpointer user_data) { gtk_main_quit(); } - -#define SCREENS_PIXEL_SIZE 98304 - -static void Printscreen() -{ - GdkPixbuf *screenshot; - gchar *filename; - GError *error = NULL; - u8 *rgb; - static int seq = 0; - - rgb = (u8 *) malloc(SCREENS_PIXEL_SIZE*3); - if (!rgb) - return; - for (int i = 0; i < SCREENS_PIXEL_SIZE; i++) { - rgb[(i * 3) + 0] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 0) & 0x1f) << 3; - rgb[(i * 3) + 1] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 5) & 0x1f) << 3; - rgb[(i * 3) + 2] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 10) & 0x1f) << 3; - } - - screenshot = gdk_pixbuf_new_from_data(rgb, - GDK_COLORSPACE_RGB, - FALSE, - 8, - 256, - 192*2, - 256*3, - NULL, - NULL); - - filename = g_strdup_printf("./desmume-screenshot-%d.png", seq); - gdk_pixbuf_save(screenshot, filename, "png", &error, NULL); - if (error) { - g_error_free (error); - g_printerr("Failed to save %s", filename); - } else { - seq++; - } - - free(rgb); - g_object_unref(screenshot); - g_free(filename); -} -void on_menu_pscreen_activate (GtkMenuItem *menuitem, gpointer user_data) { Printscreen(); } - - -/* MENU SAVES ***** ***** ***** ***** */ -void on_loadstateXX_activate (GtkMenuItem *m, gpointer d) { - int slot = dyn_CAST(int,d); - loadstate_slot(slot); -} -void on_savestateXX_activate (GtkMenuItem *m, gpointer d) { - int slot = dyn_CAST(int,d); - update_savestate(slot); -} -void on_savetypeXX_activate (GtkMenuItem *m, gpointer d) { - int type = dyn_CAST(int,d); - desmume_savetype(type); -} - - -/* MENU EMULATION ***** ***** ***** ***** */ -void on_menu_exec_activate (GtkMenuItem *menuitem, gpointer user_data) { desmume_resume(); } -void on_menu_pause_activate (GtkMenuItem *menuitem, gpointer user_data) { desmume_pause(); } -void on_menu_reset_activate (GtkMenuItem *menuitem, gpointer user_data) { desmume_reset(); } -void on_menu_layers_activate (GtkMenuItem *menuitem, gpointer user_data) { - /* we want to hide or show the checkbox for the layers */ - GtkWidget * w1 = glade_xml_get_widget(xml, "wvb_1_Main"); - GtkWidget * w2 = glade_xml_get_widget(xml, "wvb_2_Sub"); - if (gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem)==TRUE) { - gtk_widget_show(w1); - gtk_widget_show(w2); - } else { - gtk_widget_hide(w1); - gtk_widget_hide(w2); - } - /* pack the window */ - MAINWINDOW_RESIZE(); -} - -/* SUBMENU FRAMESKIP ***** ***** ***** ***** */ -void on_fsXX_activate (GtkMenuItem *menuitem,gpointer user_data) { - Frameskip = dyn_CAST(int,user_data); -// printf ("setting FS %d %d\n", Frameskip, user_data); -} - - -/* SUBMENU SIZE ***** ***** ***** ***** */ - -static void gtk_table_reattach(GtkTable * table, GtkWidget * w, - guint left_attach, guint right_attach, guint top_attach, guint bottom_attach, - GtkAttachOptions xoptions, GtkAttachOptions yoptions, - guint xpadding, guint ypadding) { - GList *list; - for (list = table->children; list; list = list->next) - { - GtkTableChild *table_child; - table_child = (GtkTableChild *) list->data; - if (table_child->widget == w) { - table_child->left_attach = left_attach; - table_child->right_attach = right_attach; - table_child->top_attach = top_attach; - table_child->bottom_attach = bottom_attach; - table_child->xexpand = (xoptions & GTK_EXPAND) != 0; - table_child->xshrink = (xoptions & GTK_SHRINK) != 0; - table_child->xfill = (xoptions & GTK_FILL) != 0; - table_child->xpadding = xpadding; - table_child->yexpand = (yoptions & GTK_EXPAND) != 0; - table_child->yshrink = (yoptions & GTK_SHRINK) != 0; - table_child->yfill = (yoptions & GTK_FILL) != 0; - table_child->ypadding = ypadding; - break; - } - } -} - -static void rightscreen(BOOL apply) { - GtkWidget *chk = glade_xml_get_widget(xml, "wvb_2_Sub"); - GtkTable *table = (GtkTable *)glade_xml_get_widget(xml, "table_layout"); - - ScreenRight = apply || ScreenRightForce; - if (ScreenRight) { - /* we want to change the layout, lower screen goes right */ - gtk_table_reattach(table, pDrawingArea2, - 3,4, 0,1, (GtkAttachOptions) 0, (GtkAttachOptions) 0, 0,0); - gtk_table_reattach(table, chk, - 4,5, 0,1, (GtkAttachOptions) 0, (GtkAttachOptions) 0, 0,0); - } else { - /* we want to change the layout, lower screen goes down */ - gtk_table_reattach(table, pDrawingArea2, - 1,2, 2,3, (GtkAttachOptions) 0, (GtkAttachOptions) 0, 0,0); - gtk_table_reattach(table, chk, - 0,1, 2,3, (GtkAttachOptions) 0, (GtkAttachOptions) 0, 0,0); - ScreenRight = FALSE; - } - - gtk_widget_queue_resize (GTK_WIDGET (table)); - - /* pack the window */ - MAINWINDOW_RESIZE(); -} -int H=192, W=256; -void resize (float Size1, float Size2) { - // not ready yet to handle different zoom factors - Size2 = Size1; - /* we want to scale drawing areas by a factor (1x,2x or 3x) */ - gtk_widget_set_size_request (pDrawingArea, W * Size1, H * Size1); - gtk_widget_set_size_request (pDrawingArea2, W * Size2, H * Size2); - ScreenCoeff_Size[0] = Size1; - ScreenCoeff_Size[1] = Size2; - /* remove artifacts */ - black_screen(); - /* pack the window */ - MAINWINDOW_RESIZE(); -} -void rotate(float angle) { - BOOL rotated; - if (angle >= 360.0) angle -= 360.0; - ScreenRotate = angle; - rotated = (ScreenRotate==90.0 || ScreenRotate==270.0); - ScreenInvert = (ScreenRotate >= 180.0); - if (rotated) { - H=256; W=192; - } else { - W=256; H=192; - } - rightscreen(rotated); - resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); -} - -void on_sizeXX_activate (GtkMenuItem *menuitem, gpointer user_data) { - float f = dyn_CAST(float,user_data); -// printf("setting ZOOM %f\n",f); - resize(f,f); -} - - - -/* MENU CONFIG ***** ***** ***** ***** */ - -void on_menu_controls_activate (GtkMenuItem *menuitem, gpointer user_data) { - edit_controls(); -} - -/* Show joystick controls configuration dialog - FIXME: sdl doesn't detect unplugged joysticks!! */ -void on_menu_joy_controls_activate (GtkMenuItem *menuitem, gpointer -user_data) -{ - GtkDialog * dlg; - GtkDialog * msgbox; - char * text; - - /* At least one joystick connected? - Can't configure joystick if SDL Event loop is already running. */ - if( (nbr_joy < 1) || desmume_running() ) - { - if( nbr_joy < 1 ) - text = _("You don't have any joystick!"); - else - text = _("Can't configure joystick while the game is running!"); - - dlg = (GtkDialog*)glade_xml_get_widget(xml, "wMainW"); - msgbox = (GtkDialog*) - gtk_message_dialog_new((GtkWindow*)dlg, - (GtkDialogFlags) (GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT), - GTK_MESSAGE_INFO, - GTK_BUTTONS_CLOSE, - "%s", - text); - g_signal_connect(G_OBJECT(msgbox), "response", G_CALLBACK(gtk_widget_destroy), NULL); - - gtk_dialog_run( msgbox ); - } - else - { - dlg = (GtkDialog*)glade_xml_get_widget(xml, "wJoyConfDlg"); - init_joy_labels(); - gtk_dialog_run(dlg); - } -} - -void on_menu_audio_on_activate (GtkMenuItem *menuitem, gpointer user_data) { - /* we want set audio emulation ON or OFF */ - if (gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem)) { - SPU_Pause(0); - } else { - SPU_Pause(1); - } -} - -void on_menu_gapscreen_activate (GtkMenuItem *menuitem, gpointer user_data) { - /* we want to add a gap between screens */ - ScreenGap = gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem); - - /* pack the window */ - MAINWINDOW_RESIZE(); -} - -void on_menu_nogap_activate (GtkMenuItem *menuitem, gpointer user_data) { - /* we'll make both gaps visibility false */ - ScreenNoGap = gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem); - - /* pack the window */ - MAINWINDOW_RESIZE(); -} - -void on_menu_rightscreen_activate (GtkMenuItem *menuitem, gpointer user_data) { - ScreenRightForce=gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem); - rightscreen(ScreenRightForce); -} - -void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data) { - /* we want to rotate the screen */ - float angle = dyn_CAST(float,user_data); - rotate(angle); -} - -/* MENU TOOLS ***** ***** ***** ***** */ -void on_menu_IO_regs_activate (GtkMenuItem *menuitem, gpointer user_data) { - GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_1_IOregs"); - gtk_widget_show(dlg); -} -void on_menu_memview_activate (GtkMenuItem *menuitem, gpointer user_data) { - GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_2_MemView"); - gtk_widget_show(dlg); -} -void on_menu_palview_activate (GtkMenuItem *menuitem, gpointer user_data) { - GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_3_PalView"); - gtk_widget_show(dlg); -} -#ifdef GTKGLEXT_AVAILABLE -void on_menu_tileview_activate (GtkMenuItem *menuitem, gpointer user_data) { - GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_4_TileView"); - gtk_widget_show(dlg); -} -#else -void on_menu_tileview_activate (GtkMenuItem *menuitem, gpointer user_data) { - g_printerr("You need gtkglext for the tile viewer\n"); -} -#endif -void on_menu_wtoolsXX_activate (GtkMenuItem *menuitem, gpointer user_data) { - GtkWidget * w = (GtkWidget *) user_data; - gtk_widget_show(w); -} - - -/* MENU ? ***** ***** ***** ***** */ -/* About dialog - FIXME: Add proper copyright */ -void on_menu_apropos_activate (GtkMenuItem *menuitem, gpointer user_data) { - GtkWidget * wAbout = glade_xml_get_widget(xml, "wAboutDlg"); - gtk_about_dialog_set_version((GtkAboutDialog *)wAbout, VERSION); - gtk_widget_show(wAbout); -} - - -/* TOOLBAR ***** ***** ***** ***** */ -void on_wgt_Open_clicked (GtkToolButton *toolbutton, gpointer user_data) { file_open(); } -void on_wgt_Reset_clicked (GtkToolButton *toolbutton, gpointer user_data) { desmume_reset(); } -void on_wgt_Quit_clicked (GtkToolButton *toolbutton, gpointer user_data) { gtk_main_quit(); } -void on_wgt_Exec_toggled (GtkToggleToolButton *toggletoolbutton, gpointer user_data) { - if (gtk_toggle_tool_button_get_active(toggletoolbutton)==TRUE) - desmume_resume(); - else - desmume_pause(); -} - - - -/* LAYERS ***** ***** ***** ***** */ -static void change_bgx_layer(int layer, gboolean state, NDS_Screen scr) { - //if(!desmume_running()) return; - if(state==TRUE) { - GPU_addBack(scr.gpu, layer); - } else { - GPU_remove(scr.gpu, layer); - } - //fprintf(stderr,"Changed Layer %s to %d\n",layer,state); -} -void on_wc_1_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - int layer = dyn_CAST(int,user_data); - change_bgx_layer(layer, gtk_toggle_button_get_active(togglebutton), MainScreen); -} -void on_wc_2_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - int layer = dyn_CAST(int,user_data); - change_bgx_layer(layer, gtk_toggle_button_get_active(togglebutton), SubScreen); -} +/* callbacks.c - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Copyright (C) 2007 Pascal Giard (evilynux) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "callbacks.h" + +/* globals */ +int Frameskip = 0; +gboolean ScreenRightForce=FALSE; +gboolean ScreenRight=FALSE; +gboolean ScreenGap=FALSE; +gboolean ScreenNoGap=FALSE; +gboolean ScreenInvert=FALSE; + +/* ******** Savestate menu items handling ******** */ + +static void set_menuitem_label(GtkWidget * w, char * text ) +{ + GtkLabel * child; + + if ( GTK_BIN(w)->child ) + { + child = (GtkLabel*)GTK_BIN(w)->child; + gtk_label_set_text(child, text); + } +} + +static void clear_savestate_menu(const char * cb_name, u8 num) +{ + GtkWidget * w; + char cb[40]; + char text[40]; + + sprintf( cb, "%s%d", cb_name, num); + sprintf( text, _("State %d (empty)"), num); + w = glade_xml_get_widget(xml, cb); + set_menuitem_label( w, text ); +} + +static void update_savestate_menu(const char * cb_name, u8 num) +{ + GtkWidget * w; + char cb[40]; + + snprintf( cb, 39, "%s%d", cb_name, num); + w = glade_xml_get_widget(xml, cb); + set_menuitem_label( w, savestates[num-1].date ); +} + +static void update_savestates_menu() +{ + u8 i; + + for( i = 1; i <= NB_STATES; i++ ) + { + if( savestates[i-1].exists == TRUE ) + { + update_savestate_menu("loadstate", i); + update_savestate_menu("savestate", i); + } + else + { + clear_savestate_menu("loadstate", i); + clear_savestate_menu("savestate", i); + } + } +} + +static void update_savestate(u8 num) +{ + desmume_pause(); + savestate_slot(num); + update_savestate_menu("savestate", num); + update_savestate_menu("loadstate", num); + desmume_resume(); +} + +/* inline & protos */ + +inline void SET_SENSITIVE(const gchar *w, gboolean b) { + gtk_widget_set_sensitive( + glade_xml_get_widget(xml, w), TRUE); +} + +void enable_rom_features() { + scan_savestates(); + update_savestates_menu(); + SET_SENSITIVE("menu_exec", TRUE); + SET_SENSITIVE("menu_pause", TRUE); + SET_SENSITIVE("menu_reset", TRUE); + SET_SENSITIVE("wgt_Exec", TRUE); + SET_SENSITIVE("wgt_Reset", TRUE); +} + +static void MAINWINDOW_RESIZE() { + GtkWidget * spacer1 = glade_xml_get_widget(xml, "misc_sep3"); + GtkWidget * spacer2 = glade_xml_get_widget(xml, "misc_sep4"); + int dim1,dim2; + BOOL rotate = (ScreenRotate==90.0 || ScreenRotate==270.0 ); + + dim1 = dim2 = 66 * ScreenCoeff_Size[0]; + + /* sees whether we want a gap */ + if (!ScreenGap) dim1 = dim2 = -1; + + if (ScreenNoGap) { + gtk_widget_hide (spacer1); + gtk_widget_hide (spacer2); + } + else + { + gtk_widget_show (spacer1); + gtk_widget_show (spacer2); + } + + if (ScreenRight == rotate) { + if (ScreenRight) + dim2 = -1; + else + dim1 = -1; + } else { + dim1 = dim2 = -1; + } + gtk_widget_set_usize(spacer1, dim1, -1); + gtk_widget_set_usize(spacer2, -1, dim2); + gtk_window_resize ((GtkWindow*)pWindow,1,1); +} + +/* MENU FILE ***** ***** ***** ***** */ +void inline ADD_FILTER(GtkWidget * filech, const char * pattern, const char * name) { + GtkFileFilter *pFilter; + pFilter = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter, pattern); + gtk_file_filter_set_name(pFilter, name); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filech), pFilter); +} + +static void file_open() { + desmume_pause(); + + GtkWidget *pFileSelection; + GtkWidget *pParent; + gchar *sChemin; + + pParent = GTK_WIDGET(pWindow); + + /* Creating the selection window */ + pFileSelection = gtk_file_chooser_dialog_new(_("Open..."), + GTK_WINDOW(pParent), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_OK, + NULL); + /* On limite les actions a cette fenetre */ + gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); + + ADD_FILTER(pFileSelection, "*.nds", _("Nds binary (.nds)")); + ADD_FILTER(pFileSelection, "*.ds.gba", _("Nds binary with loader (.ds.gba)")); + ADD_FILTER(pFileSelection, "*", _("All files")); + //ADD_FILTER(pFileSelection, "*.zip", "Nds zipped binary"); + + /* Affichage fenetre*/ + switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) + { + case GTK_RESPONSE_OK: + /* Recuperation du chemin */ + sChemin = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); + if(desmume_open((const char*)sChemin) < 0) + { + GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + _("Unable to load :\n%s"), sChemin); + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } else { + desmume_resume(); + enable_rom_features(); + } + + g_free(sChemin); + break; + default: + break; + } + gtk_widget_destroy(pFileSelection); +} + +void on_menu_open_activate (GtkMenuItem *menuitem, gpointer user_data) { file_open();} +void on_menu_quit_activate (GtkMenuItem *menuitem, gpointer user_data) { gtk_main_quit(); } + +#define SCREENS_PIXEL_SIZE 98304 + +static void Printscreen() +{ + GdkPixbuf *screenshot; + gchar *filename; + GError *error = NULL; + u8 *rgb; + static int seq = 0; + + rgb = (u8 *) malloc(SCREENS_PIXEL_SIZE*3); + if (!rgb) + return; + for (int i = 0; i < SCREENS_PIXEL_SIZE; i++) { + rgb[(i * 3) + 0] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 0) & 0x1f) << 3; + rgb[(i * 3) + 1] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 5) & 0x1f) << 3; + rgb[(i * 3) + 2] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 10) & 0x1f) << 3; + } + + screenshot = gdk_pixbuf_new_from_data(rgb, + GDK_COLORSPACE_RGB, + FALSE, + 8, + 256, + 192*2, + 256*3, + NULL, + NULL); + + filename = g_strdup_printf("./desmume-screenshot-%d.png", seq); + gdk_pixbuf_save(screenshot, filename, "png", &error, NULL); + if (error) { + g_error_free (error); + g_printerr("Failed to save %s", filename); + } else { + seq++; + } + + free(rgb); + g_object_unref(screenshot); + g_free(filename); +} +void on_menu_pscreen_activate (GtkMenuItem *menuitem, gpointer user_data) { Printscreen(); } + + +/* MENU SAVES ***** ***** ***** ***** */ +void on_loadstateXX_activate (GtkMenuItem *m, gpointer d) { + int slot = dyn_CAST(int,d); + loadstate_slot(slot); +} +void on_savestateXX_activate (GtkMenuItem *m, gpointer d) { + int slot = dyn_CAST(int,d); + update_savestate(slot); +} +void on_savetypeXX_activate (GtkMenuItem *m, gpointer d) { + int type = dyn_CAST(int,d); + desmume_savetype(type); +} + + +/* MENU EMULATION ***** ***** ***** ***** */ +void on_menu_exec_activate (GtkMenuItem *menuitem, gpointer user_data) { desmume_resume(); } +void on_menu_pause_activate (GtkMenuItem *menuitem, gpointer user_data) { desmume_pause(); } +void on_menu_reset_activate (GtkMenuItem *menuitem, gpointer user_data) { desmume_reset(); } +void on_menu_layers_activate (GtkMenuItem *menuitem, gpointer user_data) { + /* we want to hide or show the checkbox for the layers */ + GtkWidget * w1 = glade_xml_get_widget(xml, "wvb_1_Main"); + GtkWidget * w2 = glade_xml_get_widget(xml, "wvb_2_Sub"); + if (gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem)==TRUE) { + gtk_widget_show(w1); + gtk_widget_show(w2); + } else { + gtk_widget_hide(w1); + gtk_widget_hide(w2); + } + /* pack the window */ + MAINWINDOW_RESIZE(); +} + +/* SUBMENU FRAMESKIP ***** ***** ***** ***** */ +void on_fsXX_activate (GtkMenuItem *menuitem,gpointer user_data) { + Frameskip = dyn_CAST(int,user_data); +// printf ("setting FS %d %d\n", Frameskip, user_data); +} + + +/* SUBMENU SIZE ***** ***** ***** ***** */ + +static void gtk_table_reattach(GtkTable * table, GtkWidget * w, + guint left_attach, guint right_attach, guint top_attach, guint bottom_attach, + GtkAttachOptions xoptions, GtkAttachOptions yoptions, + guint xpadding, guint ypadding) { + GList *list; + for (list = table->children; list; list = list->next) + { + GtkTableChild *table_child; + table_child = (GtkTableChild *) list->data; + if (table_child->widget == w) { + table_child->left_attach = left_attach; + table_child->right_attach = right_attach; + table_child->top_attach = top_attach; + table_child->bottom_attach = bottom_attach; + table_child->xexpand = (xoptions & GTK_EXPAND) != 0; + table_child->xshrink = (xoptions & GTK_SHRINK) != 0; + table_child->xfill = (xoptions & GTK_FILL) != 0; + table_child->xpadding = xpadding; + table_child->yexpand = (yoptions & GTK_EXPAND) != 0; + table_child->yshrink = (yoptions & GTK_SHRINK) != 0; + table_child->yfill = (yoptions & GTK_FILL) != 0; + table_child->ypadding = ypadding; + break; + } + } +} + +static void rightscreen(BOOL apply) { + GtkWidget *chk = glade_xml_get_widget(xml, "wvb_2_Sub"); + GtkTable *table = (GtkTable *)glade_xml_get_widget(xml, "table_layout"); + + ScreenRight = apply || ScreenRightForce; + if (ScreenRight) { + /* we want to change the layout, lower screen goes right */ + gtk_table_reattach(table, pDrawingArea2, + 3,4, 0,1, (GtkAttachOptions) 0, (GtkAttachOptions) 0, 0,0); + gtk_table_reattach(table, chk, + 4,5, 0,1, (GtkAttachOptions) 0, (GtkAttachOptions) 0, 0,0); + } else { + /* we want to change the layout, lower screen goes down */ + gtk_table_reattach(table, pDrawingArea2, + 1,2, 2,3, (GtkAttachOptions) 0, (GtkAttachOptions) 0, 0,0); + gtk_table_reattach(table, chk, + 0,1, 2,3, (GtkAttachOptions) 0, (GtkAttachOptions) 0, 0,0); + ScreenRight = FALSE; + } + + gtk_widget_queue_resize (GTK_WIDGET (table)); + + /* pack the window */ + MAINWINDOW_RESIZE(); +} +int H=192, W=256; +void resize (float Size1, float Size2) { + // not ready yet to handle different zoom factors + Size2 = Size1; + /* we want to scale drawing areas by a factor (1x,2x or 3x) */ + gtk_widget_set_size_request (pDrawingArea, W * Size1, H * Size1); + gtk_widget_set_size_request (pDrawingArea2, W * Size2, H * Size2); + ScreenCoeff_Size[0] = Size1; + ScreenCoeff_Size[1] = Size2; + /* remove artifacts */ + black_screen(); + /* pack the window */ + MAINWINDOW_RESIZE(); +} +void rotate(float angle) { + BOOL rotated; + if (angle >= 360.0) angle -= 360.0; + ScreenRotate = angle; + rotated = (ScreenRotate==90.0 || ScreenRotate==270.0); + ScreenInvert = (ScreenRotate >= 180.0); + if (rotated) { + H=256; W=192; + } else { + W=256; H=192; + } + rightscreen(rotated); + resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); +} + +void on_sizeXX_activate (GtkMenuItem *menuitem, gpointer user_data) { + float f = dyn_CAST(float,user_data); +// printf("setting ZOOM %f\n",f); + resize(f,f); +} + + + +/* MENU CONFIG ***** ***** ***** ***** */ + +void on_menu_controls_activate (GtkMenuItem *menuitem, gpointer user_data) { + edit_controls(); +} + +/* Show joystick controls configuration dialog + FIXME: sdl doesn't detect unplugged joysticks!! */ +void on_menu_joy_controls_activate (GtkMenuItem *menuitem, gpointer +user_data) +{ + GtkDialog * dlg; + GtkDialog * msgbox; + char * text; + + /* At least one joystick connected? + Can't configure joystick if SDL Event loop is already running. */ + if( (nbr_joy < 1) || desmume_running() ) + { + if( nbr_joy < 1 ) + text = _("You don't have any joystick!"); + else + text = _("Can't configure joystick while the game is running!"); + + dlg = (GtkDialog*)glade_xml_get_widget(xml, "wMainW"); + msgbox = (GtkDialog*) + gtk_message_dialog_new((GtkWindow*)dlg, + (GtkDialogFlags) (GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT), + GTK_MESSAGE_INFO, + GTK_BUTTONS_CLOSE, + "%s", + text); + g_signal_connect(G_OBJECT(msgbox), "response", G_CALLBACK(gtk_widget_destroy), NULL); + + gtk_dialog_run( msgbox ); + } + else + { + dlg = (GtkDialog*)glade_xml_get_widget(xml, "wJoyConfDlg"); + init_joy_labels(); + gtk_dialog_run(dlg); + } +} + +void on_menu_audio_on_activate (GtkMenuItem *menuitem, gpointer user_data) { + /* we want set audio emulation ON or OFF */ + if (gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem)) { + SPU_Pause(0); + } else { + SPU_Pause(1); + } +} + +void on_menu_gapscreen_activate (GtkMenuItem *menuitem, gpointer user_data) { + /* we want to add a gap between screens */ + ScreenGap = gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem); + + /* pack the window */ + MAINWINDOW_RESIZE(); +} + +void on_menu_nogap_activate (GtkMenuItem *menuitem, gpointer user_data) { + /* we'll make both gaps visibility false */ + ScreenNoGap = gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem); + + /* pack the window */ + MAINWINDOW_RESIZE(); +} + +void on_menu_rightscreen_activate (GtkMenuItem *menuitem, gpointer user_data) { + ScreenRightForce=gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem); + rightscreen(ScreenRightForce); +} + +void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data) { + /* we want to rotate the screen */ + float angle = dyn_CAST(float,user_data); + rotate(angle); +} + +/* MENU TOOLS ***** ***** ***** ***** */ +void on_menu_IO_regs_activate (GtkMenuItem *menuitem, gpointer user_data) { + GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_1_IOregs"); + gtk_widget_show(dlg); +} +void on_menu_memview_activate (GtkMenuItem *menuitem, gpointer user_data) { + GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_2_MemView"); + gtk_widget_show(dlg); +} +void on_menu_palview_activate (GtkMenuItem *menuitem, gpointer user_data) { + GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_3_PalView"); + gtk_widget_show(dlg); +} +#ifdef GTKGLEXT_AVAILABLE +void on_menu_tileview_activate (GtkMenuItem *menuitem, gpointer user_data) { + GtkWidget * dlg = glade_xml_get_widget(xml_tools, "wtools_4_TileView"); + gtk_widget_show(dlg); +} +#else +void on_menu_tileview_activate (GtkMenuItem *menuitem, gpointer user_data) { + g_printerr("You need gtkglext for the tile viewer\n"); +} +#endif +void on_menu_wtoolsXX_activate (GtkMenuItem *menuitem, gpointer user_data) { + GtkWidget * w = (GtkWidget *) user_data; + gtk_widget_show(w); +} + + +/* MENU ? ***** ***** ***** ***** */ +/* About dialog + FIXME: Add proper copyright */ +void on_menu_apropos_activate (GtkMenuItem *menuitem, gpointer user_data) { + GtkWidget * wAbout = glade_xml_get_widget(xml, "wAboutDlg"); + gtk_about_dialog_set_version((GtkAboutDialog *)wAbout, VERSION); + gtk_widget_show(wAbout); +} + + +/* TOOLBAR ***** ***** ***** ***** */ +void on_wgt_Open_clicked (GtkToolButton *toolbutton, gpointer user_data) { file_open(); } +void on_wgt_Reset_clicked (GtkToolButton *toolbutton, gpointer user_data) { desmume_reset(); } +void on_wgt_Quit_clicked (GtkToolButton *toolbutton, gpointer user_data) { gtk_main_quit(); } +void on_wgt_Exec_toggled (GtkToggleToolButton *toggletoolbutton, gpointer user_data) { + if (gtk_toggle_tool_button_get_active(toggletoolbutton)==TRUE) + desmume_resume(); + else + desmume_pause(); +} + + + +/* LAYERS ***** ***** ***** ***** */ +static void change_bgx_layer(int layer, gboolean state, NDS_Screen scr) { + //if(!desmume_running()) return; + if(state==TRUE) { + GPU_addBack(scr.gpu, layer); + } else { + GPU_remove(scr.gpu, layer); + } + //fprintf(stderr,"Changed Layer %s to %d\n",layer,state); +} +void on_wc_1_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) { + int layer = dyn_CAST(int,user_data); + change_bgx_layer(layer, gtk_toggle_button_get_active(togglebutton), MainScreen); +} +void on_wc_2_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) { + int layer = dyn_CAST(int,user_data); + change_bgx_layer(layer, gtk_toggle_button_get_active(togglebutton), SubScreen); +} diff --git a/desmume/src/gtk-glade/callbacks.h b/src/gtk-glade/callbacks.h old mode 100755 new mode 100644 similarity index 98% rename from desmume/src/gtk-glade/callbacks.h rename to src/gtk-glade/callbacks.h index 7ba0a86f5..266a22c40 --- a/desmume/src/gtk-glade/callbacks.h +++ b/src/gtk-glade/callbacks.h @@ -1,75 +1,75 @@ -/* callbacks.h - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "globals.h" - -extern "C" { - -/* MENU FILE */ -G_MODULE_EXPORT void on_menu_open_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_pscreen_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_quit_activate (GtkMenuItem *menuitem, gpointer user_data); - -/* MENU SAVES */ -G_MODULE_EXPORT void on_loadstateXX_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savestateXX_activate (GtkMenuItem *, gpointer ); -G_MODULE_EXPORT void on_savetypeXX_activate (GtkMenuItem *, gpointer ); - -/* MENU EMULATION */ -G_MODULE_EXPORT void on_menu_exec_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_pause_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_reset_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_layers_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_fsXX_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_sizeXX_activate (GtkMenuItem *menuitem, gpointer user_data); - -/* MENU CONFIG */ -G_MODULE_EXPORT void on_menu_controls_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_joy_controls_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_audio_on_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_gapscreen_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_nogap_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_rightscreen_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data); - -/* MENU TOOLS */ -G_MODULE_EXPORT void on_menu_wtoolsXX_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_IO_regs_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_memview_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_palview_activate (GtkMenuItem *menuitem, gpointer user_data); -G_MODULE_EXPORT void on_menu_tileview_activate (GtkMenuItem *menuitem, gpointer user_data); - -/* MENU ? */ -G_MODULE_EXPORT void on_menu_apropos_activate (GtkMenuItem *menuitem, gpointer user_data); - - -/* TOOLBAR */ -G_MODULE_EXPORT void on_wgt_Open_clicked (GtkToolButton *toolbutton, gpointer user_data); -G_MODULE_EXPORT void on_wgt_Exec_toggled (GtkToggleToolButton *toggletoolbutton, - gpointer user_data); -G_MODULE_EXPORT void on_wgt_Reset_clicked (GtkToolButton *toolbutton, gpointer user_data); -G_MODULE_EXPORT void on_wgt_Quit_clicked (GtkToolButton *toolbutton, gpointer user_data); - -/* LAYERS TOGGLE */ -G_MODULE_EXPORT void on_wc_1_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data); -G_MODULE_EXPORT void on_wc_2_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data); - -} +/* callbacks.h - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "globals.h" + +extern "C" { + +/* MENU FILE */ +G_MODULE_EXPORT void on_menu_open_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_pscreen_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_quit_activate (GtkMenuItem *menuitem, gpointer user_data); + +/* MENU SAVES */ +G_MODULE_EXPORT void on_loadstateXX_activate (GtkMenuItem *, gpointer ); +G_MODULE_EXPORT void on_savestateXX_activate (GtkMenuItem *, gpointer ); +G_MODULE_EXPORT void on_savetypeXX_activate (GtkMenuItem *, gpointer ); + +/* MENU EMULATION */ +G_MODULE_EXPORT void on_menu_exec_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_pause_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_reset_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_layers_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_fsXX_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_sizeXX_activate (GtkMenuItem *menuitem, gpointer user_data); + +/* MENU CONFIG */ +G_MODULE_EXPORT void on_menu_controls_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_joy_controls_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_audio_on_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_gapscreen_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_nogap_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_rightscreen_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data); + +/* MENU TOOLS */ +G_MODULE_EXPORT void on_menu_wtoolsXX_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_IO_regs_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_memview_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_palview_activate (GtkMenuItem *menuitem, gpointer user_data); +G_MODULE_EXPORT void on_menu_tileview_activate (GtkMenuItem *menuitem, gpointer user_data); + +/* MENU ? */ +G_MODULE_EXPORT void on_menu_apropos_activate (GtkMenuItem *menuitem, gpointer user_data); + + +/* TOOLBAR */ +G_MODULE_EXPORT void on_wgt_Open_clicked (GtkToolButton *toolbutton, gpointer user_data); +G_MODULE_EXPORT void on_wgt_Exec_toggled (GtkToggleToolButton *toggletoolbutton, + gpointer user_data); +G_MODULE_EXPORT void on_wgt_Reset_clicked (GtkToolButton *toolbutton, gpointer user_data); +G_MODULE_EXPORT void on_wgt_Quit_clicked (GtkToolButton *toolbutton, gpointer user_data); + +/* LAYERS TOGGLE */ +G_MODULE_EXPORT void on_wc_1_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data); +G_MODULE_EXPORT void on_wc_2_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data); + +} diff --git a/desmume/src/gtk-glade/callbacks_IO.cpp b/src/gtk-glade/callbacks_IO.cpp old mode 100755 new mode 100644 similarity index 96% rename from desmume/src/gtk-glade/callbacks_IO.cpp rename to src/gtk-glade/callbacks_IO.cpp index 9449229aa..1f20b2b8a --- a/desmume/src/gtk-glade/callbacks_IO.cpp +++ b/src/gtk-glade/callbacks_IO.cpp @@ -1,439 +1,439 @@ -/* callbacks_IO.c - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Copyright (C) 2007 Pascal Giard (evilynux) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "callbacks_IO.h" -#include "keyval_names.h" - -static u16 Cur_Keypad = 0; -float ScreenCoeff_Size[2]={1.0,1.0}; -float ScreenRotate=0.0; -gboolean Boost=FALSE; -int BoostFS=20; -int saveFS; - -/* ***** ***** INPUT BUTTONS / KEYBOARD ***** ***** */ -gboolean on_wMainW_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { - u16 Key = lookup_key(event->keyval); - guint mask; - mask = GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_MOD5_MASK; // shift,ctrl, both alts - if( (event->state & mask) == 0){ - if (event->keyval == keyboard_cfg[KEY_BOOST-1]) { - Boost = !Boost; - if (Boost) { - saveFS = Frameskip; - Frameskip = BoostFS; - } else { - Frameskip = saveFS; - } - return 1; - } - if(Key){ - ADD_KEY( Cur_Keypad, Key ); - if(desmume_running()) update_keypad(Cur_Keypad); - return 1; - } - } - return 0; -} - -gboolean on_wMainW_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { - u16 Key = lookup_key(event->keyval); - RM_KEY( Cur_Keypad, Key ); - if(desmume_running()) update_keypad(Cur_Keypad); - return 1; -} - - - -/* ***** ***** SCREEN DRAWING ***** ***** */ -#define RAW_W 256 -#define RAW_H 192 -#define RAW_OFFSET 256*192*sizeof(u16) -#define MAX_SIZE 3 -u32 on_screen_image32[RAW_W*RAW_H*2*MAX_SIZE*MAX_SIZE]; - -int inline screen_size() { - int sz = ScreenCoeff_Size[0]; - return RAW_W*RAW_H*2*sz*sz*sizeof(u32); -} -int inline offset_pixels_lower_screen() { - return screen_size()/2; -} - -void black_screen () { - /* removes artifacts when resizing with scanlines */ - memset(on_screen_image32,0,screen_size()); -} - -#ifndef GTKGLEXT_AVAILABLE -// they are empty if no opengl -// else see gdk_gl.c / gdk_gl.h -BOOL my_gl_Begin (int screen) { return FALSE; } -void my_gl_End (int screen) {} -void reshape (GtkWidget * widget, int screen) {} -void init_GL_capabilities( int use_software_convert) {} - -int has_pix_col_map=0; -u32 pix_col_map[0x8000]; - -static void init_pix_col_map() { - // precalc factors - int a,b,c,A,B,C,rA,rB,rC; - if (has_pix_col_map) return; - for (a=0; a<0x20; a++) { - A=a<<10; rA=A<<9; - for (b=0; b<0x20; b++) { - B=b<<5; rB=B<<6; - for (c=0; c<0x20; c++) { - C=c; rC=C<<3; - pix_col_map[A|B|C]=rA|rB|rC; - } - } - } - has_pix_col_map=1; -} - -static void decode_screen () { - - int x,y, m, W,H,L,BL; - u32 image[RAW_H*2][RAW_W], pix; - u16 * pixel = (u16*)&GPU_screen; - u32 * rgb32 = &on_screen_image32[0]; - - /* decode colors */ - init_pix_col_map(); - for (y=0; y= 0, x--, y=0, y < RAW_H, y++) - LOOP(x=RAW_W-1, x >= 0, x--, y=RAW_H, y < RAW_H*2, y++) - } else { - H=RAW_H*2; W=RAW_W; - LOOP(y=0, y < RAW_H*2, y++, x=0, x < RAW_W, x++) - } -} - -gboolean screen (GtkWidget * widget, int off) { - int H,W,L; - if (off==0) - decode_screen(); - - if (ScreenRotate) { - W=RAW_H; H=RAW_W; - } else { - H=RAW_H; W=RAW_W; - } - L=W*ScreenCoeff_Size[0]*sizeof(u32); - off*= offset_pixels_lower_screen(); - - gdk_draw_rgb_32_image (widget->window, - widget->style->fg_gc[widget->state],0,0, - W*ScreenCoeff_Size[0], H*ScreenCoeff_Size[0], - GDK_RGB_DITHER_NONE,((guchar*)on_screen_image32)+off,L); - return TRUE; -} -#endif /* if GTKGLEXT_AVAILABLE */ - - -/* OUTPUT SCREENS */ -gboolean on_wDrawScreen_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { - int scr = dyn_CAST(int,user_data); - return screen(widget, scr); -} -gboolean on_wDrawScreen_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data) { - int scr = dyn_CAST(int,user_data); - reshape(widget, scr); return TRUE; -} - - - - - -/* ***** ***** INPUT STYLUS / MOUSE ***** ***** */ - -static void resize_incremental(int i, GdkEventScroll *event) { -#ifdef GTKGLEXT_AVAILABLE - float zoom_inc=.125, zoom_min=0.25, zoom_max=5.0; -#else - float zoom_inc=1.0, zoom_min=1.0, zoom_max=3.0; -#endif - switch (event->direction) { - case GDK_SCROLL_UP: - ScreenCoeff_Size[i]=MIN(ScreenCoeff_Size[i]+zoom_inc,zoom_max); break; - case GDK_SCROLL_DOWN: - ScreenCoeff_Size[i]=MAX(ScreenCoeff_Size[i]-zoom_inc,zoom_min); break; - case GDK_SCROLL_LEFT: - case GDK_SCROLL_RIGHT: - return; - } - resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); -} - -gboolean on_wDrawScreen_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { - int scr = dyn_CAST(int,user_data); - // separate zoom factors not supported yet - scr = 0; - resize_incremental(scr,(GdkEventScroll*)event); - - return TRUE; -} - -static void set_touch_pos (int x, int y) { - s32 EmuX, EmuY; - x /= ScreenCoeff_Size[1]; - y /= ScreenCoeff_Size[1]; - EmuX = x; EmuY = y; - if (ScreenRotate==90.0 || ScreenRotate==270.0) { EmuX = 256-y; EmuY = x; } - if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255; - if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192; - if (ScreenInvert) { - EmuX = 255-EmuX; - EmuY = 192-EmuY; - } - NDS_setTouchPos(EmuX, EmuY); -} - -gboolean on_wDrawScreen_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - int scr = dyn_CAST(int,user_data); - GdkModifierType state; - gint x,y; - - switch (event->button) { - case 1: - if (((scr==1) ^ ScreenInvert) && desmume_running()) { - click = TRUE; - gdk_window_get_pointer(widget->window, &x, &y, &state); - if (state & GDK_BUTTON1_MASK) - set_touch_pos(x,y); - } - break; - case 3: break; - case 2: - // filter out 2x / 3x clicks - if (event->type==GDK_BUTTON_PRESS) - rotate(ScreenRotate + 90.0); break; - } - return TRUE; -} - -gboolean on_wDrawScreen_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - int scr = dyn_CAST(int,user_data); - if ((scr==1) ^ ScreenInvert) { - if (click) NDS_releaseTouch(); - click = FALSE; - } - return TRUE; -} - -gboolean on_wDrawScreen_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { - int scr = dyn_CAST(int,user_data); - GdkModifierType state; - gint x,y; - - if (((scr==1) ^ ScreenInvert) && click) - { - if(event->is_hint) - gdk_window_get_pointer(widget->window, &x, &y, &state); - else - { - x= (gint)event->x; - y= (gint)event->y; - state=(GdkModifierType)event->state; - } - // fprintf(stderr,"X=%d, Y=%d, S&1=%d\n", x,y,state&GDK_BUTTON1_MASK); - if(state & GDK_BUTTON1_MASK) - set_touch_pos(x,y); - } - return TRUE; -} - - - - - -/* ***** ***** KEYBOARD CONFIG / KEY DEFINITION ***** ***** */ -u16 Keypad_Temp[NB_KEYS]; -guint temp_Key=0; - -static void init_labels() { - int i; - char text[50], bname[20]; - GtkButton *b; - for (i=0; ikeyval; - current_key_label(); - return TRUE; -} - -static void ask(GtkButton*b, int key) { - char text[50]; - GtkDialog * dlg = (GtkDialog*)glade_xml_get_widget(xml, "wKeyDlg"); - key--; /* key = bit position, start with 1 */ - temp_Key = Keypad_Temp[key]; - current_key_label(); - switch (gtk_dialog_run(dlg)) - { - case GTK_RESPONSE_OK: - Keypad_Temp[key]=temp_Key; - snprintf(text, 50, "%s : %s",key_names[key],KEYNAME(temp_Key)); - gtk_button_set_label(b,text); - break; - case GTK_RESPONSE_CANCEL: - case GTK_RESPONSE_NONE: - break; - } - gtk_widget_hide((GtkWidget*)dlg); -} - -/* Joystick configuration / Key definition */ -static void ask_joy_key(GtkButton*b, int key) -{ - char text[50]; - u16 joykey; - - GtkWidget * dlg = (GtkWidget*)glade_xml_get_widget(xml, "wJoyDlg"); - - key--; /* remove 1 to get index */ - gtk_widget_show_now(dlg); - /* Need to force event processing. Otherwise, popup won't show up. */ - while ( gtk_events_pending() ) gtk_main_iteration(); - joykey = get_set_joy_key(key); - snprintf(text, 50, "%s : %d",key_names[key],joykey); - gtk_button_set_label(b,text); - gtk_widget_hide((GtkWidget*)dlg); -} - -/* Joystick configuration / Key definition */ -static void ask_joy_axis(u8 key, u8 opposite_key) -{ - char text[50]; - char current_button[50], opposite_button[50]; - GtkWidget * dlg; - GtkButton * btn; - - key--; /* remove 1 to get index */ - opposite_key--; - - snprintf(current_button, 50, "button_joy_%s",key_names[key]); - snprintf(opposite_button, 50, "button_joy_%s",key_names[opposite_key]); - dlg = (GtkWidget*)glade_xml_get_widget(xml, "wJoyDlg"); - - gtk_widget_show(dlg); - /* Need to force event processing. Otherwise, popup won't show up. */ - while ( gtk_events_pending() ) gtk_main_iteration(); - get_set_joy_axis(key, opposite_key); - - snprintf(text, 50, "%s : %d",key_names[key],joypad_cfg[key]); - btn = (GtkButton*)glade_xml_get_widget(xml, current_button); - gtk_button_set_label(btn,text); - - snprintf(text, 50, "%s : %d",key_names[opposite_key],joypad_cfg[opposite_key]); - btn = (GtkButton*)glade_xml_get_widget(xml, opposite_button); - gtk_button_set_label(btn,text); - - gtk_widget_hide((GtkWidget*)dlg); -} - -/* Bind a keyboard key to a keypad key */ -void on_button_kb_key_clicked (GtkButton *b, gpointer user_data) -{ - int key = dyn_CAST( int, user_data ); - ask( b, key ); -} - -/* Bind a joystick axis to a keypad directionnal pad */ -void on_button_joy_axis_clicked (GtkButton *b, gpointer user_data) -{ - int key = dyn_CAST( int, user_data ); - ask_joy_axis( key, key+1 ); -} - -/* Bind a joystick button to a keypad key */ -void on_button_joy_key_clicked (GtkButton *b, gpointer user_data) -{ - int key = dyn_CAST( int, user_data ); - ask_joy_key( b, key ); -} +/* callbacks_IO.c - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Copyright (C) 2007 Pascal Giard (evilynux) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "callbacks_IO.h" +#include "keyval_names.h" + +static u16 Cur_Keypad = 0; +float ScreenCoeff_Size[2]={1.0,1.0}; +float ScreenRotate=0.0; +gboolean Boost=FALSE; +int BoostFS=20; +int saveFS; + +/* ***** ***** INPUT BUTTONS / KEYBOARD ***** ***** */ +gboolean on_wMainW_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { + u16 Key = lookup_key(event->keyval); + guint mask; + mask = GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_MOD5_MASK; // shift,ctrl, both alts + if( (event->state & mask) == 0){ + if (event->keyval == keyboard_cfg[KEY_BOOST-1]) { + Boost = !Boost; + if (Boost) { + saveFS = Frameskip; + Frameskip = BoostFS; + } else { + Frameskip = saveFS; + } + return 1; + } + if(Key){ + ADD_KEY( Cur_Keypad, Key ); + if(desmume_running()) update_keypad(Cur_Keypad); + return 1; + } + } + return 0; +} + +gboolean on_wMainW_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { + u16 Key = lookup_key(event->keyval); + RM_KEY( Cur_Keypad, Key ); + if(desmume_running()) update_keypad(Cur_Keypad); + return 1; +} + + + +/* ***** ***** SCREEN DRAWING ***** ***** */ +#define RAW_W 256 +#define RAW_H 192 +#define RAW_OFFSET 256*192*sizeof(u16) +#define MAX_SIZE 3 +u32 on_screen_image32[RAW_W*RAW_H*2*MAX_SIZE*MAX_SIZE]; + +int inline screen_size() { + int sz = ScreenCoeff_Size[0]; + return RAW_W*RAW_H*2*sz*sz*sizeof(u32); +} +int inline offset_pixels_lower_screen() { + return screen_size()/2; +} + +void black_screen () { + /* removes artifacts when resizing with scanlines */ + memset(on_screen_image32,0,screen_size()); +} + +#ifndef GTKGLEXT_AVAILABLE +// they are empty if no opengl +// else see gdk_gl.c / gdk_gl.h +BOOL my_gl_Begin (int screen) { return FALSE; } +void my_gl_End (int screen) {} +void reshape (GtkWidget * widget, int screen) {} +void init_GL_capabilities( int use_software_convert) {} + +int has_pix_col_map=0; +u32 pix_col_map[0x8000]; + +static void init_pix_col_map() { + // precalc factors + int a,b,c,A,B,C,rA,rB,rC; + if (has_pix_col_map) return; + for (a=0; a<0x20; a++) { + A=a<<10; rA=A<<9; + for (b=0; b<0x20; b++) { + B=b<<5; rB=B<<6; + for (c=0; c<0x20; c++) { + C=c; rC=C<<3; + pix_col_map[A|B|C]=rA|rB|rC; + } + } + } + has_pix_col_map=1; +} + +static void decode_screen () { + + int x,y, m, W,H,L,BL; + u32 image[RAW_H*2][RAW_W], pix; + u16 * pixel = (u16*)&GPU_screen; + u32 * rgb32 = &on_screen_image32[0]; + + /* decode colors */ + init_pix_col_map(); + for (y=0; y= 0, x--, y=0, y < RAW_H, y++) + LOOP(x=RAW_W-1, x >= 0, x--, y=RAW_H, y < RAW_H*2, y++) + } else { + H=RAW_H*2; W=RAW_W; + LOOP(y=0, y < RAW_H*2, y++, x=0, x < RAW_W, x++) + } +} + +gboolean screen (GtkWidget * widget, int off) { + int H,W,L; + if (off==0) + decode_screen(); + + if (ScreenRotate) { + W=RAW_H; H=RAW_W; + } else { + H=RAW_H; W=RAW_W; + } + L=W*ScreenCoeff_Size[0]*sizeof(u32); + off*= offset_pixels_lower_screen(); + + gdk_draw_rgb_32_image (widget->window, + widget->style->fg_gc[widget->state],0,0, + W*ScreenCoeff_Size[0], H*ScreenCoeff_Size[0], + GDK_RGB_DITHER_NONE,((guchar*)on_screen_image32)+off,L); + return TRUE; +} +#endif /* if GTKGLEXT_AVAILABLE */ + + +/* OUTPUT SCREENS */ +gboolean on_wDrawScreen_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { + int scr = dyn_CAST(int,user_data); + return screen(widget, scr); +} +gboolean on_wDrawScreen_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data) { + int scr = dyn_CAST(int,user_data); + reshape(widget, scr); return TRUE; +} + + + + + +/* ***** ***** INPUT STYLUS / MOUSE ***** ***** */ + +static void resize_incremental(int i, GdkEventScroll *event) { +#ifdef GTKGLEXT_AVAILABLE + float zoom_inc=.125, zoom_min=0.25, zoom_max=5.0; +#else + float zoom_inc=1.0, zoom_min=1.0, zoom_max=3.0; +#endif + switch (event->direction) { + case GDK_SCROLL_UP: + ScreenCoeff_Size[i]=MIN(ScreenCoeff_Size[i]+zoom_inc,zoom_max); break; + case GDK_SCROLL_DOWN: + ScreenCoeff_Size[i]=MAX(ScreenCoeff_Size[i]-zoom_inc,zoom_min); break; + case GDK_SCROLL_LEFT: + case GDK_SCROLL_RIGHT: + return; + } + resize(ScreenCoeff_Size[0],ScreenCoeff_Size[1]); +} + +gboolean on_wDrawScreen_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) { + int scr = dyn_CAST(int,user_data); + // separate zoom factors not supported yet + scr = 0; + resize_incremental(scr,(GdkEventScroll*)event); + + return TRUE; +} + +static void set_touch_pos (int x, int y) { + s32 EmuX, EmuY; + x /= ScreenCoeff_Size[1]; + y /= ScreenCoeff_Size[1]; + EmuX = x; EmuY = y; + if (ScreenRotate==90.0 || ScreenRotate==270.0) { EmuX = 256-y; EmuY = x; } + if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255; + if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192; + if (ScreenInvert) { + EmuX = 255-EmuX; + EmuY = 192-EmuY; + } + NDS_setTouchPos(EmuX, EmuY); +} + +gboolean on_wDrawScreen_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { + int scr = dyn_CAST(int,user_data); + GdkModifierType state; + gint x,y; + + switch (event->button) { + case 1: + if (((scr==1) ^ ScreenInvert) && desmume_running()) { + click = TRUE; + gdk_window_get_pointer(widget->window, &x, &y, &state); + if (state & GDK_BUTTON1_MASK) + set_touch_pos(x,y); + } + break; + case 3: break; + case 2: + // filter out 2x / 3x clicks + if (event->type==GDK_BUTTON_PRESS) + rotate(ScreenRotate + 90.0); break; + } + return TRUE; +} + +gboolean on_wDrawScreen_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { + int scr = dyn_CAST(int,user_data); + if ((scr==1) ^ ScreenInvert) { + if (click) NDS_releaseTouch(); + click = FALSE; + } + return TRUE; +} + +gboolean on_wDrawScreen_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { + int scr = dyn_CAST(int,user_data); + GdkModifierType state; + gint x,y; + + if (((scr==1) ^ ScreenInvert) && click) + { + if(event->is_hint) + gdk_window_get_pointer(widget->window, &x, &y, &state); + else + { + x= (gint)event->x; + y= (gint)event->y; + state=(GdkModifierType)event->state; + } + // fprintf(stderr,"X=%d, Y=%d, S&1=%d\n", x,y,state&GDK_BUTTON1_MASK); + if(state & GDK_BUTTON1_MASK) + set_touch_pos(x,y); + } + return TRUE; +} + + + + + +/* ***** ***** KEYBOARD CONFIG / KEY DEFINITION ***** ***** */ +u16 Keypad_Temp[NB_KEYS]; +guint temp_Key=0; + +static void init_labels() { + int i; + char text[50], bname[20]; + GtkButton *b; + for (i=0; ikeyval; + current_key_label(); + return TRUE; +} + +static void ask(GtkButton*b, int key) { + char text[50]; + GtkDialog * dlg = (GtkDialog*)glade_xml_get_widget(xml, "wKeyDlg"); + key--; /* key = bit position, start with 1 */ + temp_Key = Keypad_Temp[key]; + current_key_label(); + switch (gtk_dialog_run(dlg)) + { + case GTK_RESPONSE_OK: + Keypad_Temp[key]=temp_Key; + snprintf(text, 50, "%s : %s",key_names[key],KEYNAME(temp_Key)); + gtk_button_set_label(b,text); + break; + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_NONE: + break; + } + gtk_widget_hide((GtkWidget*)dlg); +} + +/* Joystick configuration / Key definition */ +static void ask_joy_key(GtkButton*b, int key) +{ + char text[50]; + u16 joykey; + + GtkWidget * dlg = (GtkWidget*)glade_xml_get_widget(xml, "wJoyDlg"); + + key--; /* remove 1 to get index */ + gtk_widget_show_now(dlg); + /* Need to force event processing. Otherwise, popup won't show up. */ + while ( gtk_events_pending() ) gtk_main_iteration(); + joykey = get_set_joy_key(key); + snprintf(text, 50, "%s : %d",key_names[key],joykey); + gtk_button_set_label(b,text); + gtk_widget_hide((GtkWidget*)dlg); +} + +/* Joystick configuration / Key definition */ +static void ask_joy_axis(u8 key, u8 opposite_key) +{ + char text[50]; + char current_button[50], opposite_button[50]; + GtkWidget * dlg; + GtkButton * btn; + + key--; /* remove 1 to get index */ + opposite_key--; + + snprintf(current_button, 50, "button_joy_%s",key_names[key]); + snprintf(opposite_button, 50, "button_joy_%s",key_names[opposite_key]); + dlg = (GtkWidget*)glade_xml_get_widget(xml, "wJoyDlg"); + + gtk_widget_show(dlg); + /* Need to force event processing. Otherwise, popup won't show up. */ + while ( gtk_events_pending() ) gtk_main_iteration(); + get_set_joy_axis(key, opposite_key); + + snprintf(text, 50, "%s : %d",key_names[key],joypad_cfg[key]); + btn = (GtkButton*)glade_xml_get_widget(xml, current_button); + gtk_button_set_label(btn,text); + + snprintf(text, 50, "%s : %d",key_names[opposite_key],joypad_cfg[opposite_key]); + btn = (GtkButton*)glade_xml_get_widget(xml, opposite_button); + gtk_button_set_label(btn,text); + + gtk_widget_hide((GtkWidget*)dlg); +} + +/* Bind a keyboard key to a keypad key */ +void on_button_kb_key_clicked (GtkButton *b, gpointer user_data) +{ + int key = dyn_CAST( int, user_data ); + ask( b, key ); +} + +/* Bind a joystick axis to a keypad directionnal pad */ +void on_button_joy_axis_clicked (GtkButton *b, gpointer user_data) +{ + int key = dyn_CAST( int, user_data ); + ask_joy_axis( key, key+1 ); +} + +/* Bind a joystick button to a keypad key */ +void on_button_joy_key_clicked (GtkButton *b, gpointer user_data) +{ + int key = dyn_CAST( int, user_data ); + ask_joy_key( b, key ); +} diff --git a/desmume/src/gtk-glade/callbacks_IO.h b/src/gtk-glade/callbacks_IO.h old mode 100755 new mode 100644 similarity index 98% rename from desmume/src/gtk-glade/callbacks_IO.h rename to src/gtk-glade/callbacks_IO.h index a8530ff34..fd2c8ddda --- a/desmume/src/gtk-glade/callbacks_IO.h +++ b/src/gtk-glade/callbacks_IO.h @@ -1,52 +1,52 @@ -/* callbacks_IO.h - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Copyright (C) 2007 Pascal Giard (evilynux) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "globals.h" -#include "gdk_gl.h" - -extern "C" { - -/* INPUT BUTTONS / KEYBOARD */ -G_MODULE_EXPORT gboolean on_wMainW_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wMainW_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data); - -/* OUTPUT SCREENS */ -G_MODULE_EXPORT gboolean on_wDrawScreen_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDrawScreen_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); - - -/* INPUT STYLUS / MOUSE */ -G_MODULE_EXPORT gboolean on_wDrawScreen_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDrawScreen_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDrawScreen_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDrawScreen_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data); - -/* KEYBOARD CONFIG / KEY DEFINITION */ -G_MODULE_EXPORT gboolean on_wKeyDlg_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data); -G_MODULE_EXPORT void on_wKeybConfDlg_response (GtkDialog *dialog, gint arg1, gpointer user_data); -G_MODULE_EXPORT void on_button_kb_key_clicked (GtkButton *button, gpointer user_data); - -/* Joystick configuration / Key definition */ -G_MODULE_EXPORT void on_button_joy_axis_clicked (GtkButton *button, gpointer user_data); -G_MODULE_EXPORT void on_button_joy_key_clicked (GtkButton *button, gpointer user_data); - -} +/* callbacks_IO.h - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Copyright (C) 2007 Pascal Giard (evilynux) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "globals.h" +#include "gdk_gl.h" + +extern "C" { + +/* INPUT BUTTONS / KEYBOARD */ +G_MODULE_EXPORT gboolean on_wMainW_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wMainW_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data); + +/* OUTPUT SCREENS */ +G_MODULE_EXPORT gboolean on_wDrawScreen_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDrawScreen_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data); + + +/* INPUT STYLUS / MOUSE */ +G_MODULE_EXPORT gboolean on_wDrawScreen_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDrawScreen_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDrawScreen_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDrawScreen_scroll_event (GtkWidget *widget, GdkEvent *event, gpointer user_data); + +/* KEYBOARD CONFIG / KEY DEFINITION */ +G_MODULE_EXPORT gboolean on_wKeyDlg_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data); +G_MODULE_EXPORT void on_wKeybConfDlg_response (GtkDialog *dialog, gint arg1, gpointer user_data); +G_MODULE_EXPORT void on_button_kb_key_clicked (GtkButton *button, gpointer user_data); + +/* Joystick configuration / Key definition */ +G_MODULE_EXPORT void on_button_joy_axis_clicked (GtkButton *button, gpointer user_data); +G_MODULE_EXPORT void on_button_joy_key_clicked (GtkButton *button, gpointer user_data); + +} diff --git a/desmume/src/gtk-glade/dTools/callbacks_1_ioregs.cpp b/src/gtk-glade/dTools/callbacks_1_ioregs.cpp old mode 100755 new mode 100644 similarity index 96% rename from desmume/src/gtk-glade/dTools/callbacks_1_ioregs.cpp rename to src/gtk-glade/dTools/callbacks_1_ioregs.cpp index 96915839d..9c27ffb44 --- a/desmume/src/gtk-glade/dTools/callbacks_1_ioregs.cpp +++ b/src/gtk-glade/dTools/callbacks_1_ioregs.cpp @@ -1,163 +1,163 @@ -/* callbacks_1_ioregs.cpp - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Copyright (C) 2007 Pascal Giard (evilynux) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "callbacks_dtools.h" -#include "dTools_display.h" - -/* ***** ***** IO REGISTERS ***** ***** */ -static int cpu=0; -static BOOL init=FALSE; -static int size_=0; -static dTools_dsp dsp; - -static void update_regs_fast(); -static void update_regs(); - -/* Register name list */ -#define NBR_IO_REGS 7 - -typedef struct -{ - char name[20]; - u32 addr; - BOOL trunc; -} reg_name_addr; - -const reg_name_addr Reg_Names_Addr[NBR_IO_REGS] = - { - { "REG_IPCFIFOCNT", REG_IPCFIFOCNT, TRUE }, - { "REG_SPICNT", REG_SPICNT, TRUE }, - { "REG_IME", REG_IME, TRUE }, - { "REG_IE", REG_IE, FALSE }, - { "REG_IF", REG_IF, FALSE }, - { "REG_POWCNT1", REG_POWCNT1, TRUE }, - { "REG_DISPCAPCNT", REG_DISPA_DISPCAPCNT, FALSE } - }; - -/* update */ - -static void wtools_1_update () { - update_regs_fast(); -} - - - -/* Update register display */ - -static u32 mem[NBR_IO_REGS]; - -static void update_regs_fast(){ - char text[10]; - int i; u32 w, m; - for( i = 0; i < NBR_IO_REGS; i++ ) - { - w = MMU_read32(cpu,Reg_Names_Addr[i].addr); - m = mem[i]; - if ( Reg_Names_Addr[i].trunc ) { - w &= 0xFFFF; - m &= 0xFFFF; - } - mem[i] = w; - if (w == m) continue; - - if ( Reg_Names_Addr[i].trunc ) - sprintf(text, " 0x%04X", w); - else - sprintf(text, "0x%08X", w); - - dTools_display_select_attr(&dsp, 2); - dTools_display_clear_char(&dsp, size_+3, i, 10); - dTools_display_draw_text(&dsp, size_+3, i, text); - } -} - -static void update_regs() -{ - char text[80]; - int len, i; - - if (init==FALSE) { - GtkWidget * wPaint = glade_xml_get_widget(xml_tools, "wtools_1_draw"); - - for( i = 0; i < NBR_IO_REGS; i++ ) { - len = strlen(Reg_Names_Addr[i].name); - if (size_ "); - dTools_display_add_markup(&dsp, "0x00000000"); - dTools_display_add_markup(&dsp, "0x00000000"); - init=TRUE; - } - - dTools_display_clear(&dsp); - for( i = 0; i < NBR_IO_REGS; i++ ) - { - mem[i] = MMU_read32(cpu,Reg_Names_Addr[i].addr); - if ( Reg_Names_Addr[i].trunc ) - sprintf(text, " 0x%04X", mem[i]); - else - sprintf(text, "0x%08X", mem[i]); - - dTools_display_select_attr(&dsp, 0); - dTools_display_draw_text(&dsp, 0, i, Reg_Names_Addr[i].name); - dTools_display_draw_text(&dsp, size_, i, " : "); - dTools_display_select_attr(&dsp, 1); - dTools_display_draw_text(&dsp, size_+3, i, text); - } -} - -gboolean on_wtools_1_draw_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - // clear the red marks :) - if (event->button==1) - update_regs(); - return TRUE; -} -gboolean on_wtools_1_draw_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { - update_regs(); - return TRUE; -} - - -void on_wtools_1_combo_cpu_changed (GtkComboBox *widget, gpointer user_data) { - /* c == 0 means ARM9 */ - cpu=gtk_combo_box_get_active(widget); - update_regs(); -} - -/* show, register, unregister */ -void on_wtools_1_IOregs_show (GtkWidget *widget, gpointer user_data) { - GtkWidget * combo = glade_xml_get_widget(xml_tools, "wtools_1_combo_cpu"); - - // do as if we had selected this button and ARM7 cpu - gtk_combo_box_set_active((GtkComboBox*)combo, 0); - register_Tool(wtools_1_update); -} - -gboolean on_wtools_1_IOregs_close (GtkWidget *widget, ...) { - unregister_Tool(wtools_1_update); - gtk_widget_hide(widget); - return TRUE; -} - +/* callbacks_1_ioregs.cpp - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Copyright (C) 2007 Pascal Giard (evilynux) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "callbacks_dtools.h" +#include "dTools_display.h" + +/* ***** ***** IO REGISTERS ***** ***** */ +static int cpu=0; +static BOOL init=FALSE; +static int size_=0; +static dTools_dsp dsp; + +static void update_regs_fast(); +static void update_regs(); + +/* Register name list */ +#define NBR_IO_REGS 7 + +typedef struct +{ + char name[20]; + u32 addr; + BOOL trunc; +} reg_name_addr; + +const reg_name_addr Reg_Names_Addr[NBR_IO_REGS] = + { + { "REG_IPCFIFOCNT", REG_IPCFIFOCNT, TRUE }, + { "REG_SPICNT", REG_SPICNT, TRUE }, + { "REG_IME", REG_IME, TRUE }, + { "REG_IE", REG_IE, FALSE }, + { "REG_IF", REG_IF, FALSE }, + { "REG_POWCNT1", REG_POWCNT1, TRUE }, + { "REG_DISPCAPCNT", REG_DISPA_DISPCAPCNT, FALSE } + }; + +/* update */ + +static void wtools_1_update () { + update_regs_fast(); +} + + + +/* Update register display */ + +static u32 mem[NBR_IO_REGS]; + +static void update_regs_fast(){ + char text[10]; + int i; u32 w, m; + for( i = 0; i < NBR_IO_REGS; i++ ) + { + w = MMU_read32(cpu,Reg_Names_Addr[i].addr); + m = mem[i]; + if ( Reg_Names_Addr[i].trunc ) { + w &= 0xFFFF; + m &= 0xFFFF; + } + mem[i] = w; + if (w == m) continue; + + if ( Reg_Names_Addr[i].trunc ) + sprintf(text, " 0x%04X", w); + else + sprintf(text, "0x%08X", w); + + dTools_display_select_attr(&dsp, 2); + dTools_display_clear_char(&dsp, size_+3, i, 10); + dTools_display_draw_text(&dsp, size_+3, i, text); + } +} + +static void update_regs() +{ + char text[80]; + int len, i; + + if (init==FALSE) { + GtkWidget * wPaint = glade_xml_get_widget(xml_tools, "wtools_1_draw"); + + for( i = 0; i < NBR_IO_REGS; i++ ) { + len = strlen(Reg_Names_Addr[i].name); + if (size_ "); + dTools_display_add_markup(&dsp, "0x00000000"); + dTools_display_add_markup(&dsp, "0x00000000"); + init=TRUE; + } + + dTools_display_clear(&dsp); + for( i = 0; i < NBR_IO_REGS; i++ ) + { + mem[i] = MMU_read32(cpu,Reg_Names_Addr[i].addr); + if ( Reg_Names_Addr[i].trunc ) + sprintf(text, " 0x%04X", mem[i]); + else + sprintf(text, "0x%08X", mem[i]); + + dTools_display_select_attr(&dsp, 0); + dTools_display_draw_text(&dsp, 0, i, Reg_Names_Addr[i].name); + dTools_display_draw_text(&dsp, size_, i, " : "); + dTools_display_select_attr(&dsp, 1); + dTools_display_draw_text(&dsp, size_+3, i, text); + } +} + +gboolean on_wtools_1_draw_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { + // clear the red marks :) + if (event->button==1) + update_regs(); + return TRUE; +} +gboolean on_wtools_1_draw_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { + update_regs(); + return TRUE; +} + + +void on_wtools_1_combo_cpu_changed (GtkComboBox *widget, gpointer user_data) { + /* c == 0 means ARM9 */ + cpu=gtk_combo_box_get_active(widget); + update_regs(); +} + +/* show, register, unregister */ +void on_wtools_1_IOregs_show (GtkWidget *widget, gpointer user_data) { + GtkWidget * combo = glade_xml_get_widget(xml_tools, "wtools_1_combo_cpu"); + + // do as if we had selected this button and ARM7 cpu + gtk_combo_box_set_active((GtkComboBox*)combo, 0); + register_Tool(wtools_1_update); +} + +gboolean on_wtools_1_IOregs_close (GtkWidget *widget, ...) { + unregister_Tool(wtools_1_update); + gtk_widget_hide(widget); + return TRUE; +} + diff --git a/desmume/src/gtk-glade/dTools/callbacks_2_memview.cpp b/src/gtk-glade/dTools/callbacks_2_memview.cpp old mode 100755 new mode 100644 similarity index 96% rename from desmume/src/gtk-glade/dTools/callbacks_2_memview.cpp rename to src/gtk-glade/dTools/callbacks_2_memview.cpp index 3e5a18ecf..3f7faf3e8 --- a/desmume/src/gtk-glade/dTools/callbacks_2_memview.cpp +++ b/src/gtk-glade/dTools/callbacks_2_memview.cpp @@ -1,289 +1,289 @@ -/* callbacks_2_memview.cpp - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "callbacks_dtools.h" -#include "dTools_display.h" - -/* ***** ***** MEMORY VIEWER ***** ***** */ - -enum SHOW { - Bit8, - Bit16, - Bit32 -}; - -static BOOL init=FALSE; -static enum SHOW packmode=Bit8; -static u32 address=0, tmpaddr=0; -int cpu=0; -static char patt[512]; -static u8 mem[0x100]; -static dTools_dsp dsp; - -static GtkEntry *wAddress; -static GtkRange *wRange; - -static void refresh(); -static void initialize(); - - -/* update */ - -static void wtools_2_update() { - int i,j; - u8 m8, *mem8 =mem; - u16 m16, *mem16=(u16*)mem; - u32 m32, *mem32=(u32*)mem; - u32 addr; - char txt[16]; - - // red - dTools_display_select_attr(&dsp, 3); - - addr = address; - switch (packmode) { - case Bit8: - for (i=0; i<0x10; i++) { - for (j=0; j<16; j++, addr++,mem8++) { - m8 = *mem8; *mem8 = MMU_read8(cpu, addr); - if (m8 != *mem8) { - sprintf(txt, "%02X", *mem8); - dTools_display_clear_char(&dsp, 12+3*j, i, 3); - dTools_display_draw_text(&dsp, 12+3*j, i, txt); - } - } - } - break; - case Bit16: - for (i=0; i<0x10; i++) { - for (j=0; j<16; j+=2, addr+=2,mem16++) { - m16 = *mem16; *mem16 = MMU_read16(cpu, addr); - if (m16 != *mem16) { - sprintf(txt, " %04X", *mem16); - dTools_display_clear_char(&dsp, 12+3*j, i, 6); - dTools_display_draw_text(&dsp, 12+3*j, i, txt); - } - } - } - break; - case Bit32: - for (i=0; i<0x10; i++) { - for (j=0; j<16; j+=4, addr+=4,mem32++) { - m32 = *mem32; *mem32 = MMU_read32(cpu, addr); - if (m32 != *mem32) { - sprintf(txt, " %08X", *mem32); - dTools_display_clear_char(&dsp, 12+3*j, i, 12); - dTools_display_draw_text(&dsp, 12+3*j, i, txt); - } - } - } - break; - } -} - -gboolean on_wtools_2_draw_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - // clear the red marks :) - if (event->button==1) - refresh(); - - return TRUE; -} - - - - -/* which cpu we look into */ - -void on_wtools_2_cpu_changed (GtkComboBox *widget, gpointer user_data) { - /* c == 0 means ARM9 */ - cpu=gtk_combo_box_get_active(widget); - refresh(); -} - - -/* how to pack bytes */ - -void on_wtools_2_r8_toggled (GtkToggleButton *togglebutton, gpointer user_data) { packmode=Bit8; refresh(); } -void on_wtools_2_r16_toggled (GtkToggleButton *togglebutton, gpointer user_data) { packmode=Bit16; refresh(); } -void on_wtools_2_r32_toggled (GtkToggleButton *togglebutton, gpointer user_data) { packmode=Bit32; refresh(); } - -/* which address */ -#define RANGE_MIN 0 -#define RANGE_MAX 0x10000000 -#define ADDR_MASK 0xFFFFFFF -#define STEP_ONE_LINE 0x1 -#define STEP_ONE_PAGE 0x10 -#define STEP_x10_PAGE 0x100 - -static void scroll_address(u32 addr) { - address = (addr & ADDR_MASK); - refresh(); -} -static void change_address(u32 addr) { - addr /= 0x10; - gtk_range_set_value(wRange, addr); -} -static void add_to_address(s32 inc) { - u32 addr = (address+inc) & ADDR_MASK; - gtk_range_set_value(wRange, addr); -} - -void on_wtools_2_GotoAddress_activate (GtkEntry *entry, gpointer user_data) { - change_address(strtol(gtk_entry_get_text(entry),NULL,0)); -} -void on_wtools_2_GotoAddress_changed (GtkEntry *entry, gpointer user_data) { - tmpaddr=strtol(gtk_entry_get_text(entry),NULL,0); -} -void on_wtools_2_GotoButton_clicked (GtkButton *button, gpointer user_data) { - change_address(tmpaddr); -} - - -/* show, register, unregister */ - -void on_wtools_2_MemView_show (GtkWidget *widget, gpointer user_data) { - initialize(); - register_Tool(wtools_2_update); -} -gboolean on_wtools_2_MemView_close (GtkWidget *widget, ...) { - unregister_Tool(wtools_2_update); - dTools_display_free(&dsp); - gtk_widget_hide(widget); - return TRUE; -} - - -/* scroll functions :D */ - -void on_wtools_2_scroll_value_changed (GtkRange *range, gpointer user_data) { - u32 addr=(u32)gtk_range_get_value(range); - scroll_address(addr); -} -gboolean on_wtools_2_draw_scroll_event (GtkWidget *widget, GdkEventScroll *event, gpointer user_data) { - switch (event->direction) { - case GDK_SCROLL_UP: - add_to_address(-STEP_ONE_PAGE); break; - case GDK_SCROLL_DOWN: - add_to_address(+STEP_ONE_PAGE); break; - case GDK_SCROLL_LEFT: - case GDK_SCROLL_RIGHT: - default: - break; - } - return TRUE; -} -gboolean on_wtools_2_draw_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { refresh(); return TRUE; } - - - - - -/* initialise what we have to */ - -static void initialize() { - GtkWidget * combo; - GtkWidget * wPaint; - GtkAdjustment *adj; - - if (init) return; - combo = glade_xml_get_widget(xml_tools, "wtools_2_cpu"); - adj = (GtkAdjustment *)gtk_adjustment_new (RANGE_MIN, RANGE_MIN, RANGE_MAX, - STEP_ONE_LINE, STEP_x10_PAGE, STEP_ONE_PAGE); - - // get widget reference - wAddress = (GtkEntry*)glade_xml_get_widget(xml_tools, "wtools_2_GotoAddress"); - wRange = (GtkRange*)glade_xml_get_widget(xml_tools, "wtools_2_scroll"); - wPaint = glade_xml_get_widget(xml_tools, "wtools_2_draw"); - - dTools_display_init(&dsp, wPaint, 80, 16, 5); - -#define PATT(x) x"" x "" -#define DUP(x) x x - sprintf(patt, "0000:0000 | %s| 0123456789ABCDEF", DUP(DUP(DUP(PATT("00_")))) ); - dTools_display_add_markup(&dsp, patt); - sprintf(patt, "0000:0000 | %s| 0123456789ABCDEF", DUP(DUP(PATT("_0000_"))) ); - dTools_display_add_markup(&dsp, patt); - sprintf(patt, "0000:0000 | %s| 0123456789ABCDEF", DUP(PATT("__00000000__")) ); - dTools_display_add_markup(&dsp, patt); -#undef DUP -#undef PATT - strcpy(patt, "__00000000__"); - dTools_display_add_markup(&dsp, patt); - - init = TRUE; - gtk_combo_box_set_active((GtkComboBox*)combo, 0); - gtk_range_set_adjustment(wRange, adj); - change_address(RANGE_MIN); -} - -/* PAINT memory panel */ -static void refresh() { - int i,j,addr; - u8 c; - u8 *mem8=mem; - u16 *mem16=(u16*)mem; - u32 *mem32=(u32*)mem; - - char *ptxt, txt[]="0000:0000 | 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF | 0123456789ABCDEF\0"; - - if (!init) return; - - addr=address * 0x10; - for (i=0; i<0x100; i++) - mem[i] = MMU_read8(cpu, addr+i); - - dTools_display_clear(&dsp); - switch(packmode) { - case Bit8: dTools_display_select_attr(&dsp, 0); break; - case Bit16: dTools_display_select_attr(&dsp, 1); break; - case Bit32: dTools_display_select_attr(&dsp, 2); break; - } - - -// draw memory content here - for (i=0; i<0x10; i++) { - ptxt = txt; - sprintf(ptxt, "%04X:%04X | ", (addr>>16)&0xFFFF, addr&0xFFFF); ptxt+=12; - switch(packmode) { - case Bit8: - for (j=0; j<16; j++,ptxt+=3) - sprintf(ptxt, "%02X ", mem8[j]); - break; - case Bit16: - for (j=0; j<16; j+=2,ptxt+=6, mem16++) - sprintf(ptxt, " %04X ", *mem16); - break; - case Bit32: - for (j=0; j<16; j+=4,ptxt+=12, mem32++) - sprintf(ptxt, " %08X ", *mem32); - break; - } - sprintf(ptxt, "| "); ptxt +=2; - for (j=0; j<16; j++,ptxt++) - // only ASCII printable - sprintf(ptxt, "%c", ((c=mem8[j])<0x20)?'.':((c>=0x7F)?'.':c)); - addr += 16; - mem8 +=16; - *(ptxt)=0; - - dTools_display_draw_text(&dsp, 0, i, txt); - } -} +/* callbacks_2_memview.cpp - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "callbacks_dtools.h" +#include "dTools_display.h" + +/* ***** ***** MEMORY VIEWER ***** ***** */ + +enum SHOW { + Bit8, + Bit16, + Bit32 +}; + +static BOOL init=FALSE; +static enum SHOW packmode=Bit8; +static u32 address=0, tmpaddr=0; +int cpu=0; +static char patt[512]; +static u8 mem[0x100]; +static dTools_dsp dsp; + +static GtkEntry *wAddress; +static GtkRange *wRange; + +static void refresh(); +static void initialize(); + + +/* update */ + +static void wtools_2_update() { + int i,j; + u8 m8, *mem8 =mem; + u16 m16, *mem16=(u16*)mem; + u32 m32, *mem32=(u32*)mem; + u32 addr; + char txt[16]; + + // red + dTools_display_select_attr(&dsp, 3); + + addr = address; + switch (packmode) { + case Bit8: + for (i=0; i<0x10; i++) { + for (j=0; j<16; j++, addr++,mem8++) { + m8 = *mem8; *mem8 = MMU_read8(cpu, addr); + if (m8 != *mem8) { + sprintf(txt, "%02X", *mem8); + dTools_display_clear_char(&dsp, 12+3*j, i, 3); + dTools_display_draw_text(&dsp, 12+3*j, i, txt); + } + } + } + break; + case Bit16: + for (i=0; i<0x10; i++) { + for (j=0; j<16; j+=2, addr+=2,mem16++) { + m16 = *mem16; *mem16 = MMU_read16(cpu, addr); + if (m16 != *mem16) { + sprintf(txt, " %04X", *mem16); + dTools_display_clear_char(&dsp, 12+3*j, i, 6); + dTools_display_draw_text(&dsp, 12+3*j, i, txt); + } + } + } + break; + case Bit32: + for (i=0; i<0x10; i++) { + for (j=0; j<16; j+=4, addr+=4,mem32++) { + m32 = *mem32; *mem32 = MMU_read32(cpu, addr); + if (m32 != *mem32) { + sprintf(txt, " %08X", *mem32); + dTools_display_clear_char(&dsp, 12+3*j, i, 12); + dTools_display_draw_text(&dsp, 12+3*j, i, txt); + } + } + } + break; + } +} + +gboolean on_wtools_2_draw_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { + // clear the red marks :) + if (event->button==1) + refresh(); + + return TRUE; +} + + + + +/* which cpu we look into */ + +void on_wtools_2_cpu_changed (GtkComboBox *widget, gpointer user_data) { + /* c == 0 means ARM9 */ + cpu=gtk_combo_box_get_active(widget); + refresh(); +} + + +/* how to pack bytes */ + +void on_wtools_2_r8_toggled (GtkToggleButton *togglebutton, gpointer user_data) { packmode=Bit8; refresh(); } +void on_wtools_2_r16_toggled (GtkToggleButton *togglebutton, gpointer user_data) { packmode=Bit16; refresh(); } +void on_wtools_2_r32_toggled (GtkToggleButton *togglebutton, gpointer user_data) { packmode=Bit32; refresh(); } + +/* which address */ +#define RANGE_MIN 0 +#define RANGE_MAX 0x10000000 +#define ADDR_MASK 0xFFFFFFF +#define STEP_ONE_LINE 0x1 +#define STEP_ONE_PAGE 0x10 +#define STEP_x10_PAGE 0x100 + +static void scroll_address(u32 addr) { + address = (addr & ADDR_MASK); + refresh(); +} +static void change_address(u32 addr) { + addr /= 0x10; + gtk_range_set_value(wRange, addr); +} +static void add_to_address(s32 inc) { + u32 addr = (address+inc) & ADDR_MASK; + gtk_range_set_value(wRange, addr); +} + +void on_wtools_2_GotoAddress_activate (GtkEntry *entry, gpointer user_data) { + change_address(strtol(gtk_entry_get_text(entry),NULL,0)); +} +void on_wtools_2_GotoAddress_changed (GtkEntry *entry, gpointer user_data) { + tmpaddr=strtol(gtk_entry_get_text(entry),NULL,0); +} +void on_wtools_2_GotoButton_clicked (GtkButton *button, gpointer user_data) { + change_address(tmpaddr); +} + + +/* show, register, unregister */ + +void on_wtools_2_MemView_show (GtkWidget *widget, gpointer user_data) { + initialize(); + register_Tool(wtools_2_update); +} +gboolean on_wtools_2_MemView_close (GtkWidget *widget, ...) { + unregister_Tool(wtools_2_update); + dTools_display_free(&dsp); + gtk_widget_hide(widget); + return TRUE; +} + + +/* scroll functions :D */ + +void on_wtools_2_scroll_value_changed (GtkRange *range, gpointer user_data) { + u32 addr=(u32)gtk_range_get_value(range); + scroll_address(addr); +} +gboolean on_wtools_2_draw_scroll_event (GtkWidget *widget, GdkEventScroll *event, gpointer user_data) { + switch (event->direction) { + case GDK_SCROLL_UP: + add_to_address(-STEP_ONE_PAGE); break; + case GDK_SCROLL_DOWN: + add_to_address(+STEP_ONE_PAGE); break; + case GDK_SCROLL_LEFT: + case GDK_SCROLL_RIGHT: + default: + break; + } + return TRUE; +} +gboolean on_wtools_2_draw_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { refresh(); return TRUE; } + + + + + +/* initialise what we have to */ + +static void initialize() { + GtkWidget * combo; + GtkWidget * wPaint; + GtkAdjustment *adj; + + if (init) return; + combo = glade_xml_get_widget(xml_tools, "wtools_2_cpu"); + adj = (GtkAdjustment *)gtk_adjustment_new (RANGE_MIN, RANGE_MIN, RANGE_MAX, + STEP_ONE_LINE, STEP_x10_PAGE, STEP_ONE_PAGE); + + // get widget reference + wAddress = (GtkEntry*)glade_xml_get_widget(xml_tools, "wtools_2_GotoAddress"); + wRange = (GtkRange*)glade_xml_get_widget(xml_tools, "wtools_2_scroll"); + wPaint = glade_xml_get_widget(xml_tools, "wtools_2_draw"); + + dTools_display_init(&dsp, wPaint, 80, 16, 5); + +#define PATT(x) x"" x "" +#define DUP(x) x x + sprintf(patt, "0000:0000 | %s| 0123456789ABCDEF", DUP(DUP(DUP(PATT("00_")))) ); + dTools_display_add_markup(&dsp, patt); + sprintf(patt, "0000:0000 | %s| 0123456789ABCDEF", DUP(DUP(PATT("_0000_"))) ); + dTools_display_add_markup(&dsp, patt); + sprintf(patt, "0000:0000 | %s| 0123456789ABCDEF", DUP(PATT("__00000000__")) ); + dTools_display_add_markup(&dsp, patt); +#undef DUP +#undef PATT + strcpy(patt, "__00000000__"); + dTools_display_add_markup(&dsp, patt); + + init = TRUE; + gtk_combo_box_set_active((GtkComboBox*)combo, 0); + gtk_range_set_adjustment(wRange, adj); + change_address(RANGE_MIN); +} + +/* PAINT memory panel */ +static void refresh() { + int i,j,addr; + u8 c; + u8 *mem8=mem; + u16 *mem16=(u16*)mem; + u32 *mem32=(u32*)mem; + + char *ptxt, txt[]="0000:0000 | 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF | 0123456789ABCDEF\0"; + + if (!init) return; + + addr=address * 0x10; + for (i=0; i<0x100; i++) + mem[i] = MMU_read8(cpu, addr+i); + + dTools_display_clear(&dsp); + switch(packmode) { + case Bit8: dTools_display_select_attr(&dsp, 0); break; + case Bit16: dTools_display_select_attr(&dsp, 1); break; + case Bit32: dTools_display_select_attr(&dsp, 2); break; + } + + +// draw memory content here + for (i=0; i<0x10; i++) { + ptxt = txt; + sprintf(ptxt, "%04X:%04X | ", (addr>>16)&0xFFFF, addr&0xFFFF); ptxt+=12; + switch(packmode) { + case Bit8: + for (j=0; j<16; j++,ptxt+=3) + sprintf(ptxt, "%02X ", mem8[j]); + break; + case Bit16: + for (j=0; j<16; j+=2,ptxt+=6, mem16++) + sprintf(ptxt, " %04X ", *mem16); + break; + case Bit32: + for (j=0; j<16; j+=4,ptxt+=12, mem32++) + sprintf(ptxt, " %08X ", *mem32); + break; + } + sprintf(ptxt, "| "); ptxt +=2; + for (j=0; j<16; j++,ptxt++) + // only ASCII printable + sprintf(ptxt, "%c", ((c=mem8[j])<0x20)?'.':((c>=0x7F)?'.':c)); + addr += 16; + mem8 +=16; + *(ptxt)=0; + + dTools_display_draw_text(&dsp, 0, i, txt); + } +} diff --git a/desmume/src/gtk-glade/dTools/callbacks_3_palview.cpp b/src/gtk-glade/dTools/callbacks_3_palview.cpp old mode 100755 new mode 100644 similarity index 77% rename from desmume/src/gtk-glade/dTools/callbacks_3_palview.cpp rename to src/gtk-glade/dTools/callbacks_3_palview.cpp index ca03496b4..de4872dc5 --- a/desmume/src/gtk-glade/dTools/callbacks_3_palview.cpp +++ b/src/gtk-glade/dTools/callbacks_3_palview.cpp @@ -1,167 +1,167 @@ -/* callbacks_3_palview.cpp - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "callbacks_dtools.h" - -void init_combo_palette(GtkComboBox *combo, u16 ** addresses) { - GtkTreeIter iter; - GtkListStore* model = gtk_list_store_new(1, G_TYPE_STRING); - gtk_combo_box_set_model(combo, (GtkTreeModel*)model); - - int i=0; - -#define DO(str,addr,r) \ - gtk_list_store_append (model, &iter); \ - gtk_list_store_set (model, &iter, 0, str,-1); \ - addresses[i]=((u16*)(addr) r); i++; - - DO("Main screen BG PAL", MMU.ARM9_VMEM,) - DO("Main screen SPR PAL", MMU.ARM9_VMEM,+0x100) - DO("Sub screen BG PAL", MMU.ARM9_VMEM,+0x200) - DO("Sub screen SPR PAL", MMU.ARM9_VMEM,+0x300) - DO("Main screen ExtPAL 0", MMU.ExtPal[0][0],) - DO("Main screen ExtPAL 1", MMU.ExtPal[0][1],) - DO("Main screen ExtPAL 2", MMU.ExtPal[0][2],) - DO("Main screen ExtPAL 3", MMU.ExtPal[0][3],) - DO("Sub screen ExtPAL 0", MMU.ExtPal[1][0],) - DO("Sub screen ExtPAL 1", MMU.ExtPal[1][1],) - DO("Sub screen ExtPAL 2", MMU.ExtPal[1][2],) - DO("Sub screen ExtPAL 3", MMU.ExtPal[1][3],) - DO("Main screen SPR ExtPAL 0", MMU.ObjExtPal[0][0],) - DO("Main screen SPR ExtPAL 1", MMU.ObjExtPal[0][1],) - DO("Sub screen SPR ExtPAL 0", MMU.ObjExtPal[1][0],) - DO("Sub screen SPR ExtPAL 1", MMU.ObjExtPal[1][1],) - DO("Texture PAL 0", MMU.texInfo.texPalSlot[0],) - DO("Texture PAL 1", MMU.texInfo.texPalSlot[1],) - DO("Texture PAL 2", MMU.texInfo.texPalSlot[2],) - DO("Texture PAL 3", MMU.texInfo.texPalSlot[3],) -#undef DO - gtk_combo_box_set_active(combo,0); -} - -static u16* base_addr[20]; -static BOOL init=FALSE; -static int palnum=0; -static int palindex=0; -static void refresh(); -static GtkWidget * wPaint; -static GtkSpinButton * wSpin; -static u16 mem[0x100]; - - -static COLOR c; -static COLOR32 c32; -static GdkGC * gdkGC; - -static inline void paint_col(int x, int y, u16 col) { - c.val = col; - COLOR_16_32(c,c32) - gdk_rgb_gc_set_foreground(gdkGC, c32.val); - gdk_draw_rectangle(wPaint->window, gdkGC, TRUE, x, y, 15, 15); -} -static inline void paint_cross(int x, int y) { - gdk_rgb_gc_set_foreground(gdkGC, 0x808080); - gdk_draw_rectangle(wPaint->window, gdkGC, TRUE, x, y, 15, 15); - gdk_rgb_gc_set_foreground(gdkGC, 0xFF0000); - gdk_draw_line(wPaint->window, gdkGC, x+14, y+1, x+1, y+14); - gdk_draw_line(wPaint->window, gdkGC, x+1, y+1, x+14, y+14); -} - - -static void wtools_3_update() { - int i,x,y,X,Y; - u16 * addr = base_addr[palindex], tmp; - - gdkGC = gdk_gc_new(wPaint->window); - if (addr) { - memcpy(mem, addr, 0x100*sizeof(u16)); - i=0; - for(y=Y= 0; y < 16; y++,Y+=16) - for(x=X= 0; x < 16; x++,X+=16) { - tmp=mem[i]; - if (tmp != (mem[i]=*(addr+Y+x+0x100*palnum))) - paint_col(X,Y,mem[i]); - } - } else { - for(y=Y= 0; y < 16; y++,Y+=16) - for(x=X= 0; x < 16; x++,X+=16) - paint_cross(X,Y); - } - g_object_unref(gdkGC); -} - - -static void refresh() { - int x,y,X,Y; u16 * addr = base_addr[palindex]; - - gdkGC = gdk_gc_new(wPaint->window); - if (addr) { - memcpy(mem, addr, 0x100*sizeof(u16)); - for(y=Y= 0; y < 16; y++,Y+=16) - for(x=X= 0; x < 16; x++,X+=16) - paint_col(X,Y,*(addr+Y+x+0x100*palnum)); - } else { - for(y=Y= 0; y < 16; y++,Y+=16) - for(x=X= 0; x < 16; x++,X+=16) - paint_cross(X,Y); - } - g_object_unref(gdkGC); -} - -static void initialize() { - GtkComboBox * combo; - if (init) return; - - wPaint= glade_xml_get_widget(xml_tools, "wtools_3_draw"); - wSpin = (GtkSpinButton*)glade_xml_get_widget(xml_tools, "wtools_3_palnum"); - combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_3_palette"); - - init_combo_palette(combo, base_addr); - - init=TRUE; -} - - -void on_wtools_3_PalView_show (GtkWidget *widget, gpointer data) { - initialize(); - register_Tool(wtools_3_update); -} -gboolean on_wtools_3_PalView_close (GtkWidget *widget, ...) { - unregister_Tool(wtools_3_update); - gtk_widget_hide(widget); - return TRUE; -} - - -gboolean on_wtools_3_draw_expose_event (GtkWidget * widget, GdkEventExpose *event, gpointer user_data) { - refresh(); - return TRUE; -} -void on_wtools_3_palette_changed (GtkComboBox *combo, gpointer user_data) { - palindex = gtk_combo_box_get_active(combo); - gtk_widget_set_sensitive((GtkWidget*)wSpin,(palindex >=4)); - gtk_spin_button_set_value(wSpin,0); - refresh(); -} -void on_wtools_3_palnum_value_changed (GtkSpinButton *spin, gpointer user_data) { - palnum = gtk_spin_button_get_value_as_int(spin); - refresh(); -} +/* callbacks_3_palview.cpp - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "callbacks_dtools.h" + +void init_combo_palette(GtkComboBox *combo, u16 ** addresses) { + GtkTreeIter iter; + GtkListStore* model = gtk_list_store_new(1, G_TYPE_STRING); + gtk_combo_box_set_model(combo, (GtkTreeModel*)model); + + int i=0; + +#define DO(str,addr,r) \ + gtk_list_store_append (model, &iter); \ + gtk_list_store_set (model, &iter, 0, str,-1); \ + addresses[i]=((u16*)(addr) r); i++; + + DO("Main screen BG PAL", ARM9Mem.ARM9_VMEM,) + DO("Main screen SPR PAL", ARM9Mem.ARM9_VMEM,+0x100) + DO("Sub screen BG PAL", ARM9Mem.ARM9_VMEM,+0x200) + DO("Sub screen SPR PAL", ARM9Mem.ARM9_VMEM,+0x300) + DO("Main screen ExtPAL 0", ARM9Mem.ExtPal[0][0],) + DO("Main screen ExtPAL 1", ARM9Mem.ExtPal[0][1],) + DO("Main screen ExtPAL 2", ARM9Mem.ExtPal[0][2],) + DO("Main screen ExtPAL 3", ARM9Mem.ExtPal[0][3],) + DO("Sub screen ExtPAL 0", ARM9Mem.ExtPal[1][0],) + DO("Sub screen ExtPAL 1", ARM9Mem.ExtPal[1][1],) + DO("Sub screen ExtPAL 2", ARM9Mem.ExtPal[1][2],) + DO("Sub screen ExtPAL 3", ARM9Mem.ExtPal[1][3],) + DO("Main screen SPR ExtPAL 0", ARM9Mem.ObjExtPal[0][0],) + DO("Main screen SPR ExtPAL 1", ARM9Mem.ObjExtPal[0][1],) + DO("Sub screen SPR ExtPAL 0", ARM9Mem.ObjExtPal[1][0],) + DO("Sub screen SPR ExtPAL 1", ARM9Mem.ObjExtPal[1][1],) + DO("Texture PAL 0", ARM9Mem.texInfo.texPalSlot[0],) + DO("Texture PAL 1", ARM9Mem.texInfo.texPalSlot[1],) + DO("Texture PAL 2", ARM9Mem.texInfo.texPalSlot[2],) + DO("Texture PAL 3", ARM9Mem.texInfo.texPalSlot[3],) +#undef DO + gtk_combo_box_set_active(combo,0); +} + +static u16* base_addr[20]; +static BOOL init=FALSE; +static int palnum=0; +static int palindex=0; +static void refresh(); +static GtkWidget * wPaint; +static GtkSpinButton * wSpin; +static u16 mem[0x100]; + + +static COLOR c; +static COLOR32 c32; +static GdkGC * gdkGC; + +static inline void paint_col(int x, int y, u16 col) { + c.val = col; + COLOR_16_32(c,c32) + gdk_rgb_gc_set_foreground(gdkGC, c32.val); + gdk_draw_rectangle(wPaint->window, gdkGC, TRUE, x, y, 15, 15); +} +static inline void paint_cross(int x, int y) { + gdk_rgb_gc_set_foreground(gdkGC, 0x808080); + gdk_draw_rectangle(wPaint->window, gdkGC, TRUE, x, y, 15, 15); + gdk_rgb_gc_set_foreground(gdkGC, 0xFF0000); + gdk_draw_line(wPaint->window, gdkGC, x+14, y+1, x+1, y+14); + gdk_draw_line(wPaint->window, gdkGC, x+1, y+1, x+14, y+14); +} + + +static void wtools_3_update() { + int i,x,y,X,Y; + u16 * addr = base_addr[palindex], tmp; + + gdkGC = gdk_gc_new(wPaint->window); + if (addr) { + memcpy(mem, addr, 0x100*sizeof(u16)); + i=0; + for(y=Y= 0; y < 16; y++,Y+=16) + for(x=X= 0; x < 16; x++,X+=16) { + tmp=mem[i]; + if (tmp != (mem[i]=*(addr+Y+x+0x100*palnum))) + paint_col(X,Y,mem[i]); + } + } else { + for(y=Y= 0; y < 16; y++,Y+=16) + for(x=X= 0; x < 16; x++,X+=16) + paint_cross(X,Y); + } + g_object_unref(gdkGC); +} + + +static void refresh() { + int x,y,X,Y; u16 * addr = base_addr[palindex]; + + gdkGC = gdk_gc_new(wPaint->window); + if (addr) { + memcpy(mem, addr, 0x100*sizeof(u16)); + for(y=Y= 0; y < 16; y++,Y+=16) + for(x=X= 0; x < 16; x++,X+=16) + paint_col(X,Y,*(addr+Y+x+0x100*palnum)); + } else { + for(y=Y= 0; y < 16; y++,Y+=16) + for(x=X= 0; x < 16; x++,X+=16) + paint_cross(X,Y); + } + g_object_unref(gdkGC); +} + +static void initialize() { + GtkComboBox * combo; + if (init) return; + + wPaint= glade_xml_get_widget(xml_tools, "wtools_3_draw"); + wSpin = (GtkSpinButton*)glade_xml_get_widget(xml_tools, "wtools_3_palnum"); + combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_3_palette"); + + init_combo_palette(combo, base_addr); + + init=TRUE; +} + + +void on_wtools_3_PalView_show (GtkWidget *widget, gpointer data) { + initialize(); + register_Tool(wtools_3_update); +} +gboolean on_wtools_3_PalView_close (GtkWidget *widget, ...) { + unregister_Tool(wtools_3_update); + gtk_widget_hide(widget); + return TRUE; +} + + +gboolean on_wtools_3_draw_expose_event (GtkWidget * widget, GdkEventExpose *event, gpointer user_data) { + refresh(); + return TRUE; +} +void on_wtools_3_palette_changed (GtkComboBox *combo, gpointer user_data) { + palindex = gtk_combo_box_get_active(combo); + gtk_widget_set_sensitive((GtkWidget*)wSpin,(palindex >=4)); + gtk_spin_button_set_value(wSpin,0); + refresh(); +} +void on_wtools_3_palnum_value_changed (GtkSpinButton *spin, gpointer user_data) { + palnum = gtk_spin_button_get_value_as_int(spin); + refresh(); +} diff --git a/desmume/src/gtk-glade/dTools/callbacks_4_tileview.cpp b/src/gtk-glade/dTools/callbacks_4_tileview.cpp old mode 100755 new mode 100644 similarity index 84% rename from desmume/src/gtk-glade/dTools/callbacks_4_tileview.cpp rename to src/gtk-glade/dTools/callbacks_4_tileview.cpp index dda41d575..e3fbd5988 --- a/desmume/src/gtk-glade/dTools/callbacks_4_tileview.cpp +++ b/src/gtk-glade/dTools/callbacks_4_tileview.cpp @@ -1,329 +1,329 @@ -/* callbacks_3_palview.cpp - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "callbacks_dtools.h" -#ifdef GTKGLEXT_AVAILABLE -#include "../gdk_gl.h" - -void init_combo_memory(GtkComboBox *combo, u8 ** addresses) { - GtkTreeIter iter; - GtkListStore* model = gtk_list_store_new(1, G_TYPE_STRING); - gtk_combo_box_set_model(combo, (GtkTreeModel*)model); - int i=0; - -#define DO(str,addr,r) \ - gtk_list_store_append (model, &iter); \ - gtk_list_store_set (model, &iter, 0, str,-1); \ - addresses[i]=(addr r); i++; - -// FIXME: update tileview to actually work -// DO("A-BG - 0x6000000",MMU.ARM9_ABG,) -// DO("A-BG - 0x6010000",MMU.ARM9_ABG,+0x10000) -// DO("A-BG - 0x6020000",MMU.ARM9_ABG,+0x20000) -// DO("A-BG - 0x6030000",MMU.ARM9_ABG,+0x30000) -// DO("A-BG - 0x6040000",MMU.ARM9_ABG,+0x40000) -// DO("A-BG - 0x6050000",MMU.ARM9_ABG,+0x50000) -// DO("A-BG - 0x6060000",MMU.ARM9_ABG,+0x60000) -// DO("A-BG - 0x6070000",MMU.ARM9_ABG,+0x70000) - -// DO("B-BG - 0x6200000",MMU.ARM9_BBG,) -// DO("B-BG - 0x6210000",MMU.ARM9_BBG,+0x10000) - -// DO("A-OBJ- 0x6400000",MMU.ARM9_AOBJ,) -// DO("A-OBJ- 0x6410000",MMU.ARM9_AOBJ,+0x10000) -// DO("A-OBJ- 0x6420000",MMU.ARM9_AOBJ,+0x20000) -// DO("A-OBJ- 0x6430000",MMU.ARM9_AOBJ,+0x30000) - -// DO("B-OBJ- 0x6600000",MMU.ARM9_BOBJ,) -// DO("B-OBJ- 0x6610000",MMU.ARM9_BOBJ,+0x10000) - - DO("LCD - 0x6800000",MMU.ARM9_LCD,) - DO("LCD - 0x6810000",MMU.ARM9_LCD,+0x10000) - DO("LCD - 0x6820000",MMU.ARM9_LCD,+0x20000) - DO("LCD - 0x6830000",MMU.ARM9_LCD,+0x30000) - DO("LCD - 0x6840000",MMU.ARM9_LCD,+0x40000) - DO("LCD - 0x6850000",MMU.ARM9_LCD,+0x50000) - DO("LCD - 0x6860000",MMU.ARM9_LCD,+0x60000) - DO("LCD - 0x6870000",MMU.ARM9_LCD,+0x70000) - DO("LCD - 0x6880000",MMU.ARM9_LCD,+0x80000) - DO("LCD - 0x6890000",MMU.ARM9_LCD,+0x90000) -#undef DO - gtk_combo_box_set_active(combo,0); -} - -static u16* pal_addr[20]; -static u8* mem_addr[26]; -static BOOL init=FALSE; -static int palnum=0; -static int palindex=0; -static int memnum=0; -static int colnum=0; -static void refresh(); -static GtkWidget * wPaint; -static GtkSpinButton * wSpin; -static int gl_context_num=0; - -#define TILE_NUM_MAX 1024 -#define TILE_W_SZ 8 -#define TILE_H_SZ 8 - -static void wtools_4_update() { - -} - -typedef u16 tileBMP[8*8]; - -static void refresh() { - u16 palette_16[64]; - u16 palette_256[64]; - u8 * index16, * index256, * indexBMP; - u16 * pal; - int tile_n, index; - guint Textures; - if (!init) return; - - index16 = index256 = indexBMP = mem_addr[memnum]; - - // this little thing doesnt display properly - // nothing drawn... - // seems that is the context is not shared there is a pb switching context -/* - if (!my_gl_Begin(gl_context_num)) return; - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - my_gl_DrawBeautifulQuad(); - my_gl_End(gl_context_num); - return; - -*/ - if (!my_gl_Begin(gl_context_num)) return; - - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); -#if 1 - glEnable(GL_TEXTURE_2D); - glGenTextures(1, &Textures); - - //proxy - glBindTexture(GL_TEXTURE_2D, Textures); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, - 256, 256, 0, - GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, indexBMP); - - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); glVertex2d(-1.0, 1.0); - glTexCoord2f(1.0, 0.0); glVertex2d( 1.0, 1.0); - glTexCoord2f(1.0, 1.0); glVertex2d( 1.0,-1.0); - glTexCoord2f(0.0, 1.0); glVertex2d(-1.0,-1.0); - glEnd(); - - glDeleteTextures(1, &Textures); - - my_gl_End(gl_context_num); - return; - - glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA, - 256, 256, 0, - GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL); - - - switch(colnum) { - case 0: //BMP - for (tile_n=0; tile_n> 5)<<3, - 8, 8, GL_RGBA, - GL_UNSIGNED_SHORT_1_5_5_5_REV, indexBMP); - indexBMP +=64; - } - break; - case 1: //256c - pal = pal_addr[palindex]; - if (pal) { - pal += palnum*256; - for (tile_n=0; tile_n<1024; tile_n++) { - for (index=0; index<64; index++) { - palette_256[index]=pal[*index256]; - index256++; - } - glTexSubImage2D(GL_TEXTURE_2D, 0, - (tile_n & 0x1F)<<3, (tile_n >> 5)<<3, - 8, 8, GL_RGBA, - GL_UNSIGNED_SHORT_1_5_5_5_REV, palette_256); - } - } - break; - case 2: //16c - pal = pal_addr[palindex]; - if (pal) { - pal += palnum*16; - for (tile_n=0; tile_n<1024; tile_n++) { - for (index=0; index<64; index++) { - if (index & 1) continue; - palette_16[index] =pal[*index16 & 15]; - palette_16[index+1]=pal[*index16 >> 4]; - index16++; - } - glTexSubImage2D(GL_TEXTURE_2D, 0, - (tile_n & 0x1F)<<3, (tile_n >> 5)<<3, - 8, 8, GL_RGBA, - GL_UNSIGNED_SHORT_1_5_5_5_REV, palette_16); - } - } - break; - } - - glBegin(GL_QUADS); - glTexCoord2f(0.0, 0.0); glVertex2d(-0.5, 0.5); - glTexCoord2f(0.0, 1.0); glVertex2d(-0.5,-0.5); - glTexCoord2f(1.0, 1.0); glVertex2d( 0.5,-0.5); - glTexCoord2f(1.0, 0.0); glVertex2d( 0.5, 0.5); - glEnd(); - - glDeleteTextures(1, &Textures); -#else - glDisable(GL_LIGHTING); - glDisable(GL_BLEND); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glColor4ub(255,255,255,255); - switch(colnum) { - case 0: //BMP - { - tileBMP tiles * = indexBMP; - - for (tile_n=0; tile_n<1024; tile_n++) { - i = (tile_n & 0x1F) << 4; - j = (tile_n >> 5) << 12; - memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; - memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; - memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; - memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; - memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; - memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; - memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; - memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; - } - glRasterPos2i(0,0); - glDrawPixels(256,256,GL_RGBA,GL_UNSIGNED_SHORT_1_5_5_5_REV, bmp); - } - break; - case 1: //256c - if (pal = pal_addr[palindex]) { - pal += palnum*256; - for (tile_n=0; tile_n<1024; tile_n++) { - for (index=0; index<64; index++) { - palette_256[index]=pal[*index256]; - index256++; - } - glRasterPos2i((tile_n & 0x1F)<<3, (tile_n >> 5)<<3); - glDrawPixels(8,8,GL_RGBA,GL_UNSIGNED_SHORT_1_5_5_5_REV, palette_256); - } - } - break; - case 2: //16c - if (pal = pal_addr[palindex]) { - pal += palnum*16; - for (tile_n=0; tile_n<1024; tile_n++) { - for (index=0; index<64; index++) { - if (index & 1) continue; - palette_16[index] =pal[*index16 & 15]; - palette_16[index+1]=pal[*index16 >> 4]; - index16++; - } - glRasterPos2i((tile_n & 0x1F)<<3, (tile_n >> 5)<<3); - glDrawPixels(8,8,GL_RGBA,GL_UNSIGNED_SHORT_1_5_5_5_REV, palette_16); - } - } - break; - } -#endif - my_gl_End(gl_context_num); -} - -static void initialize() { - GtkComboBox * combo; - if (init) return; - - wPaint= glade_xml_get_widget(xml_tools, "wDraw_Tile"); - wSpin = (GtkSpinButton*)glade_xml_get_widget(xml_tools, "wtools_4_palnum"); - combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_palette"); - init_combo_palette(combo, pal_addr); - combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_memory"); - init_combo_memory(combo, mem_addr); - - gl_context_num = init_GL_free_s(wPaint,0); - reshape(wPaint, gl_context_num); - gtk_widget_show(wPaint); - init=TRUE; -} - - -void on_wtools_4_TileView_show (GtkWidget *widget, gpointer data) { - initialize(); - register_Tool(wtools_4_update); -} -gboolean on_wtools_4_TileView_close (GtkWidget *widget, ...) { - unregister_Tool(wtools_4_update); - gtk_widget_hide(widget); - return TRUE; -} - -void on_wtools_4_palette_changed (GtkComboBox *combo, gpointer user_data) { - palindex = gtk_combo_box_get_active(combo); - gtk_widget_set_sensitive((GtkWidget*)wSpin,(palindex >=4)); - gtk_spin_button_set_value(wSpin,0); - gtk_widget_queue_draw(wPaint); -} -void on_wtools_4_palnum_value_changed (GtkSpinButton *spin, gpointer user_data) { - palnum = gtk_spin_button_get_value_as_int(spin); - gtk_widget_queue_draw(wPaint); -} -void on_wtools_4_memory_changed (GtkComboBox *combo, gpointer user_data) { - memnum = gtk_combo_box_get_active(combo); - gtk_widget_queue_draw(wPaint); -} -void on_wtools_4_rXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) { - colnum = dyn_CAST(int,user_data); - gtk_widget_queue_draw(wPaint); -} -gboolean on_wDraw_Tile_expose_event (GtkWidget * w, GdkEventExpose * e, gpointer user_data) { - refresh(); - return TRUE; -} -#else -void on_wtools_4_TileView_show (GtkWidget *widget, gpointer data) { -} -gboolean on_wtools_4_TileView_close (GtkWidget *widget, ...) { - return FALSE; -} -void on_wtools_4_palette_changed (GtkComboBox *combo, gpointer user_data) { -} -void on_wtools_4_palnum_value_changed (GtkSpinButton *spin, gpointer user_data) { -} -void on_wtools_4_memory_changed (GtkComboBox *combo, gpointer user_data) { -} -void on_wtools_4_rXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) { -} -gboolean on_wDraw_Tile_expose_event (GtkWidget * w, GdkEventExpose * e, gpointer user_data) { - return FALSE; -} -#endif +/* callbacks_3_palview.cpp - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "callbacks_dtools.h" +#ifdef GTKGLEXT_AVAILABLE +#include "../gdk_gl.h" + +void init_combo_memory(GtkComboBox *combo, u8 ** addresses) { + GtkTreeIter iter; + GtkListStore* model = gtk_list_store_new(1, G_TYPE_STRING); + gtk_combo_box_set_model(combo, (GtkTreeModel*)model); + int i=0; + +#define DO(str,addr,r) \ + gtk_list_store_append (model, &iter); \ + gtk_list_store_set (model, &iter, 0, str,-1); \ + addresses[i]=(addr r); i++; + +// FIXME: update tileview to actually work +// DO("A-BG - 0x6000000",ARM9Mem.ARM9_ABG,) +// DO("A-BG - 0x6010000",ARM9Mem.ARM9_ABG,+0x10000) +// DO("A-BG - 0x6020000",ARM9Mem.ARM9_ABG,+0x20000) +// DO("A-BG - 0x6030000",ARM9Mem.ARM9_ABG,+0x30000) +// DO("A-BG - 0x6040000",ARM9Mem.ARM9_ABG,+0x40000) +// DO("A-BG - 0x6050000",ARM9Mem.ARM9_ABG,+0x50000) +// DO("A-BG - 0x6060000",ARM9Mem.ARM9_ABG,+0x60000) +// DO("A-BG - 0x6070000",ARM9Mem.ARM9_ABG,+0x70000) + +// DO("B-BG - 0x6200000",ARM9Mem.ARM9_BBG,) +// DO("B-BG - 0x6210000",ARM9Mem.ARM9_BBG,+0x10000) + +// DO("A-OBJ- 0x6400000",ARM9Mem.ARM9_AOBJ,) +// DO("A-OBJ- 0x6410000",ARM9Mem.ARM9_AOBJ,+0x10000) +// DO("A-OBJ- 0x6420000",ARM9Mem.ARM9_AOBJ,+0x20000) +// DO("A-OBJ- 0x6430000",ARM9Mem.ARM9_AOBJ,+0x30000) + +// DO("B-OBJ- 0x6600000",ARM9Mem.ARM9_BOBJ,) +// DO("B-OBJ- 0x6610000",ARM9Mem.ARM9_BOBJ,+0x10000) + + DO("LCD - 0x6800000",ARM9Mem.ARM9_LCD,) + DO("LCD - 0x6810000",ARM9Mem.ARM9_LCD,+0x10000) + DO("LCD - 0x6820000",ARM9Mem.ARM9_LCD,+0x20000) + DO("LCD - 0x6830000",ARM9Mem.ARM9_LCD,+0x30000) + DO("LCD - 0x6840000",ARM9Mem.ARM9_LCD,+0x40000) + DO("LCD - 0x6850000",ARM9Mem.ARM9_LCD,+0x50000) + DO("LCD - 0x6860000",ARM9Mem.ARM9_LCD,+0x60000) + DO("LCD - 0x6870000",ARM9Mem.ARM9_LCD,+0x70000) + DO("LCD - 0x6880000",ARM9Mem.ARM9_LCD,+0x80000) + DO("LCD - 0x6890000",ARM9Mem.ARM9_LCD,+0x90000) +#undef DO + gtk_combo_box_set_active(combo,0); +} + +static u16* pal_addr[20]; +static u8* mem_addr[26]; +static BOOL init=FALSE; +static int palnum=0; +static int palindex=0; +static int memnum=0; +static int colnum=0; +static void refresh(); +static GtkWidget * wPaint; +static GtkSpinButton * wSpin; +static int gl_context_num=0; + +#define TILE_NUM_MAX 1024 +#define TILE_W_SZ 8 +#define TILE_H_SZ 8 + +static void wtools_4_update() { + +} + +typedef u16 tileBMP[8*8]; + +static void refresh() { + u16 palette_16[64]; + u16 palette_256[64]; + u8 * index16, * index256, * indexBMP; + u16 * pal; + int tile_n, index; + guint Textures; + if (!init) return; + + index16 = index256 = indexBMP = mem_addr[memnum]; + + // this little thing doesnt display properly + // nothing drawn... + // seems that is the context is not shared there is a pb switching context +/* + if (!my_gl_Begin(gl_context_num)) return; + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + my_gl_DrawBeautifulQuad(); + my_gl_End(gl_context_num); + return; + +*/ + if (!my_gl_Begin(gl_context_num)) return; + + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); +#if 1 + glEnable(GL_TEXTURE_2D); + glGenTextures(1, &Textures); + + //proxy + glBindTexture(GL_TEXTURE_2D, Textures); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, + 256, 256, 0, + GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, indexBMP); + + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex2d(-1.0, 1.0); + glTexCoord2f(1.0, 0.0); glVertex2d( 1.0, 1.0); + glTexCoord2f(1.0, 1.0); glVertex2d( 1.0,-1.0); + glTexCoord2f(0.0, 1.0); glVertex2d(-1.0,-1.0); + glEnd(); + + glDeleteTextures(1, &Textures); + + my_gl_End(gl_context_num); + return; + + glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA, + 256, 256, 0, + GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL); + + + switch(colnum) { + case 0: //BMP + for (tile_n=0; tile_n> 5)<<3, + 8, 8, GL_RGBA, + GL_UNSIGNED_SHORT_1_5_5_5_REV, indexBMP); + indexBMP +=64; + } + break; + case 1: //256c + pal = pal_addr[palindex]; + if (pal) { + pal += palnum*256; + for (tile_n=0; tile_n<1024; tile_n++) { + for (index=0; index<64; index++) { + palette_256[index]=pal[*index256]; + index256++; + } + glTexSubImage2D(GL_TEXTURE_2D, 0, + (tile_n & 0x1F)<<3, (tile_n >> 5)<<3, + 8, 8, GL_RGBA, + GL_UNSIGNED_SHORT_1_5_5_5_REV, palette_256); + } + } + break; + case 2: //16c + pal = pal_addr[palindex]; + if (pal) { + pal += palnum*16; + for (tile_n=0; tile_n<1024; tile_n++) { + for (index=0; index<64; index++) { + if (index & 1) continue; + palette_16[index] =pal[*index16 & 15]; + palette_16[index+1]=pal[*index16 >> 4]; + index16++; + } + glTexSubImage2D(GL_TEXTURE_2D, 0, + (tile_n & 0x1F)<<3, (tile_n >> 5)<<3, + 8, 8, GL_RGBA, + GL_UNSIGNED_SHORT_1_5_5_5_REV, palette_16); + } + } + break; + } + + glBegin(GL_QUADS); + glTexCoord2f(0.0, 0.0); glVertex2d(-0.5, 0.5); + glTexCoord2f(0.0, 1.0); glVertex2d(-0.5,-0.5); + glTexCoord2f(1.0, 1.0); glVertex2d( 0.5,-0.5); + glTexCoord2f(1.0, 0.0); glVertex2d( 0.5, 0.5); + glEnd(); + + glDeleteTextures(1, &Textures); +#else + glDisable(GL_LIGHTING); + glDisable(GL_BLEND); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glColor4ub(255,255,255,255); + switch(colnum) { + case 0: //BMP + { + tileBMP tiles * = indexBMP; + + for (tile_n=0; tile_n<1024; tile_n++) { + i = (tile_n & 0x1F) << 4; + j = (tile_n >> 5) << 12; + memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; + memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; + memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; + memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; + memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; + memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; + memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; j+=512; + memcpy(bmp + j + i, indexBMP, 16); indexBMP += 16; + } + glRasterPos2i(0,0); + glDrawPixels(256,256,GL_RGBA,GL_UNSIGNED_SHORT_1_5_5_5_REV, bmp); + } + break; + case 1: //256c + if (pal = pal_addr[palindex]) { + pal += palnum*256; + for (tile_n=0; tile_n<1024; tile_n++) { + for (index=0; index<64; index++) { + palette_256[index]=pal[*index256]; + index256++; + } + glRasterPos2i((tile_n & 0x1F)<<3, (tile_n >> 5)<<3); + glDrawPixels(8,8,GL_RGBA,GL_UNSIGNED_SHORT_1_5_5_5_REV, palette_256); + } + } + break; + case 2: //16c + if (pal = pal_addr[palindex]) { + pal += palnum*16; + for (tile_n=0; tile_n<1024; tile_n++) { + for (index=0; index<64; index++) { + if (index & 1) continue; + palette_16[index] =pal[*index16 & 15]; + palette_16[index+1]=pal[*index16 >> 4]; + index16++; + } + glRasterPos2i((tile_n & 0x1F)<<3, (tile_n >> 5)<<3); + glDrawPixels(8,8,GL_RGBA,GL_UNSIGNED_SHORT_1_5_5_5_REV, palette_16); + } + } + break; + } +#endif + my_gl_End(gl_context_num); +} + +static void initialize() { + GtkComboBox * combo; + if (init) return; + + wPaint= glade_xml_get_widget(xml_tools, "wDraw_Tile"); + wSpin = (GtkSpinButton*)glade_xml_get_widget(xml_tools, "wtools_4_palnum"); + combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_palette"); + init_combo_palette(combo, pal_addr); + combo = (GtkComboBox*)glade_xml_get_widget(xml_tools, "wtools_4_memory"); + init_combo_memory(combo, mem_addr); + + gl_context_num = init_GL_free_s(wPaint,0); + reshape(wPaint, gl_context_num); + gtk_widget_show(wPaint); + init=TRUE; +} + + +void on_wtools_4_TileView_show (GtkWidget *widget, gpointer data) { + initialize(); + register_Tool(wtools_4_update); +} +gboolean on_wtools_4_TileView_close (GtkWidget *widget, ...) { + unregister_Tool(wtools_4_update); + gtk_widget_hide(widget); + return TRUE; +} + +void on_wtools_4_palette_changed (GtkComboBox *combo, gpointer user_data) { + palindex = gtk_combo_box_get_active(combo); + gtk_widget_set_sensitive((GtkWidget*)wSpin,(palindex >=4)); + gtk_spin_button_set_value(wSpin,0); + gtk_widget_queue_draw(wPaint); +} +void on_wtools_4_palnum_value_changed (GtkSpinButton *spin, gpointer user_data) { + palnum = gtk_spin_button_get_value_as_int(spin); + gtk_widget_queue_draw(wPaint); +} +void on_wtools_4_memory_changed (GtkComboBox *combo, gpointer user_data) { + memnum = gtk_combo_box_get_active(combo); + gtk_widget_queue_draw(wPaint); +} +void on_wtools_4_rXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) { + colnum = dyn_CAST(int,user_data); + gtk_widget_queue_draw(wPaint); +} +gboolean on_wDraw_Tile_expose_event (GtkWidget * w, GdkEventExpose * e, gpointer user_data) { + refresh(); + return TRUE; +} +#else +void on_wtools_4_TileView_show (GtkWidget *widget, gpointer data) { +} +gboolean on_wtools_4_TileView_close (GtkWidget *widget, ...) { + return FALSE; +} +void on_wtools_4_palette_changed (GtkComboBox *combo, gpointer user_data) { +} +void on_wtools_4_palnum_value_changed (GtkSpinButton *spin, gpointer user_data) { +} +void on_wtools_4_memory_changed (GtkComboBox *combo, gpointer user_data) { +} +void on_wtools_4_rXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) { +} +gboolean on_wDraw_Tile_expose_event (GtkWidget * w, GdkEventExpose * e, gpointer user_data) { + return FALSE; +} +#endif diff --git a/desmume/src/gtk-glade/dTools/callbacks_dtools.h b/src/gtk-glade/dTools/callbacks_dtools.h old mode 100755 new mode 100644 similarity index 98% rename from desmume/src/gtk-glade/dTools/callbacks_dtools.h rename to src/gtk-glade/dTools/callbacks_dtools.h index 50a9a6257..b94dfe355 --- a/desmume/src/gtk-glade/dTools/callbacks_dtools.h +++ b/src/gtk-glade/dTools/callbacks_dtools.h @@ -1,79 +1,79 @@ -/* callbacks_dtools.h - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __CALLBACKS_DTOOLS_H__ -#define __CALLBACKS_DTOOLS_H__ - -#include "../globals.h" - -extern "C" { - -/* ***** ***** IO REGISTERS ***** ***** */ -G_MODULE_EXPORT void on_wtools_1_combo_cpu_changed (GtkComboBox *, gpointer ); -G_MODULE_EXPORT void on_wtools_1_IOregs_show (GtkWidget *, gpointer ); -G_MODULE_EXPORT gboolean on_wtools_1_IOregs_close (GtkWidget *, ...); -G_MODULE_EXPORT gboolean on_wtools_1_draw_button_release_event(GtkWidget *, GdkEventButton *, gpointer ); -G_MODULE_EXPORT gboolean on_wtools_1_draw_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data); - -/* ***** ***** MEMORY VIEWER ***** ***** */ -G_MODULE_EXPORT void on_wtools_2_MemView_show (GtkWidget *, gpointer ); -G_MODULE_EXPORT gboolean on_wtools_2_MemView_close (GtkWidget *, ...); - -G_MODULE_EXPORT void on_wtools_2_cpu_changed (GtkComboBox *, gpointer ); -G_MODULE_EXPORT void on_wtools_2_r8_toggled (GtkToggleButton *, gpointer ); -G_MODULE_EXPORT void on_wtools_2_r16_toggled (GtkToggleButton *, gpointer ); -G_MODULE_EXPORT void on_wtools_2_r32_toggled (GtkToggleButton *, gpointer ); -G_MODULE_EXPORT void on_wtools_2_GotoAddress_activate (GtkEntry *, gpointer ); -G_MODULE_EXPORT void on_wtools_2_GotoAddress_changed (GtkEntry *, gpointer ); -G_MODULE_EXPORT void on_wtools_2_GotoButton_clicked (GtkButton *, gpointer ); -G_MODULE_EXPORT void on_wtools_2_scroll_value_changed (GtkRange *, gpointer ); -G_MODULE_EXPORT gboolean on_wtools_2_draw_button_release_event(GtkWidget *, GdkEventButton *, gpointer ); -G_MODULE_EXPORT gboolean on_wtools_2_draw_expose_event (GtkWidget *, GdkEventExpose *, gpointer ); -G_MODULE_EXPORT gboolean on_wtools_2_draw_scroll_event (GtkWidget *, GdkEventScroll *, gpointer ); - -/* ***** ***** PALETTE VIEWER ***** ***** */ -// initialise combo box for all palettes -void init_combo_palette(GtkComboBox *combo, u16 ** addresses); - -G_MODULE_EXPORT void on_wtools_3_PalView_show (GtkWidget *, gpointer ); -G_MODULE_EXPORT gboolean on_wtools_3_PalView_close (GtkWidget *, ...); -G_MODULE_EXPORT gboolean on_wtools_3_PalView_delete_event (GtkWidget *, GdkEvent *, gpointer ); -G_MODULE_EXPORT gboolean on_wtools_3_draw_expose_event (GtkWidget *, GdkEventExpose *, gpointer ); -G_MODULE_EXPORT void on_wtools_3_palette_changed (GtkComboBox *, gpointer ); -G_MODULE_EXPORT void on_wtools_3_palnum_value_changed (GtkSpinButton *, gpointer ); - - -/* ***** ***** TILE VIEWER ***** ***** */ -// initialise combo box for all palettes -void init_combo_memory(GtkComboBox *combo, u8 ** addresses); - -G_MODULE_EXPORT void on_wtools_4_TileView_show (GtkWidget *, gpointer ); -G_MODULE_EXPORT gboolean on_wtools_4_TileView_close (GtkWidget *, ...); -G_MODULE_EXPORT gboolean on_wtools_4_TileView_delete_event (GtkWidget *, GdkEvent *, gpointer ); -G_MODULE_EXPORT void on_wtools_4_memory_changed (GtkComboBox *, gpointer ); -G_MODULE_EXPORT void on_wtools_4_palette_changed (GtkComboBox *, gpointer ); -G_MODULE_EXPORT void on_wtools_4_palnum_value_changed (GtkSpinButton *, gpointer ); -G_MODULE_EXPORT void on_wtools_4_rXX_toggled (GtkToggleButton *togglebutton, gpointer user_data); -G_MODULE_EXPORT gboolean on_wDraw_Tile_expose_event (GtkWidget *, GdkEventExpose *, gpointer ); - -} - -#endif +/* callbacks_dtools.h - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __CALLBACKS_DTOOLS_H__ +#define __CALLBACKS_DTOOLS_H__ + +#include "../globals.h" + +extern "C" { + +/* ***** ***** IO REGISTERS ***** ***** */ +G_MODULE_EXPORT void on_wtools_1_combo_cpu_changed (GtkComboBox *, gpointer ); +G_MODULE_EXPORT void on_wtools_1_IOregs_show (GtkWidget *, gpointer ); +G_MODULE_EXPORT gboolean on_wtools_1_IOregs_close (GtkWidget *, ...); +G_MODULE_EXPORT gboolean on_wtools_1_draw_button_release_event(GtkWidget *, GdkEventButton *, gpointer ); +G_MODULE_EXPORT gboolean on_wtools_1_draw_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data); + +/* ***** ***** MEMORY VIEWER ***** ***** */ +G_MODULE_EXPORT void on_wtools_2_MemView_show (GtkWidget *, gpointer ); +G_MODULE_EXPORT gboolean on_wtools_2_MemView_close (GtkWidget *, ...); + +G_MODULE_EXPORT void on_wtools_2_cpu_changed (GtkComboBox *, gpointer ); +G_MODULE_EXPORT void on_wtools_2_r8_toggled (GtkToggleButton *, gpointer ); +G_MODULE_EXPORT void on_wtools_2_r16_toggled (GtkToggleButton *, gpointer ); +G_MODULE_EXPORT void on_wtools_2_r32_toggled (GtkToggleButton *, gpointer ); +G_MODULE_EXPORT void on_wtools_2_GotoAddress_activate (GtkEntry *, gpointer ); +G_MODULE_EXPORT void on_wtools_2_GotoAddress_changed (GtkEntry *, gpointer ); +G_MODULE_EXPORT void on_wtools_2_GotoButton_clicked (GtkButton *, gpointer ); +G_MODULE_EXPORT void on_wtools_2_scroll_value_changed (GtkRange *, gpointer ); +G_MODULE_EXPORT gboolean on_wtools_2_draw_button_release_event(GtkWidget *, GdkEventButton *, gpointer ); +G_MODULE_EXPORT gboolean on_wtools_2_draw_expose_event (GtkWidget *, GdkEventExpose *, gpointer ); +G_MODULE_EXPORT gboolean on_wtools_2_draw_scroll_event (GtkWidget *, GdkEventScroll *, gpointer ); + +/* ***** ***** PALETTE VIEWER ***** ***** */ +// initialise combo box for all palettes +void init_combo_palette(GtkComboBox *combo, u16 ** addresses); + +G_MODULE_EXPORT void on_wtools_3_PalView_show (GtkWidget *, gpointer ); +G_MODULE_EXPORT gboolean on_wtools_3_PalView_close (GtkWidget *, ...); +G_MODULE_EXPORT gboolean on_wtools_3_PalView_delete_event (GtkWidget *, GdkEvent *, gpointer ); +G_MODULE_EXPORT gboolean on_wtools_3_draw_expose_event (GtkWidget *, GdkEventExpose *, gpointer ); +G_MODULE_EXPORT void on_wtools_3_palette_changed (GtkComboBox *, gpointer ); +G_MODULE_EXPORT void on_wtools_3_palnum_value_changed (GtkSpinButton *, gpointer ); + + +/* ***** ***** TILE VIEWER ***** ***** */ +// initialise combo box for all palettes +void init_combo_memory(GtkComboBox *combo, u8 ** addresses); + +G_MODULE_EXPORT void on_wtools_4_TileView_show (GtkWidget *, gpointer ); +G_MODULE_EXPORT gboolean on_wtools_4_TileView_close (GtkWidget *, ...); +G_MODULE_EXPORT gboolean on_wtools_4_TileView_delete_event (GtkWidget *, GdkEvent *, gpointer ); +G_MODULE_EXPORT void on_wtools_4_memory_changed (GtkComboBox *, gpointer ); +G_MODULE_EXPORT void on_wtools_4_palette_changed (GtkComboBox *, gpointer ); +G_MODULE_EXPORT void on_wtools_4_palnum_value_changed (GtkSpinButton *, gpointer ); +G_MODULE_EXPORT void on_wtools_4_rXX_toggled (GtkToggleButton *togglebutton, gpointer user_data); +G_MODULE_EXPORT gboolean on_wDraw_Tile_expose_event (GtkWidget *, GdkEventExpose *, gpointer ); + +} + +#endif diff --git a/desmume/src/gtk-glade/dTools/dTools_display.h b/src/gtk-glade/dTools/dTools_display.h old mode 100755 new mode 100644 similarity index 96% rename from desmume/src/gtk-glade/dTools/dTools_display.h rename to src/gtk-glade/dTools/dTools_display.h index 2ed554962..0da3e5e33 --- a/desmume/src/gtk-glade/dTools/dTools_display.h +++ b/src/gtk-glade/dTools/dTools_display.h @@ -1,110 +1,110 @@ -/* dTools_display.c - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _DTOOLS_DISPLAY_H_ -#define _DTOOLS_DISPLAY_H_ - -#include - -typedef struct { - GtkWidget *widget; - GdkDrawable *draw; - GdkGC *gc_fg; - GdkGC *gc_bg; - PangoLayout* playout; - int size_w, size_h; - int char_w, char_h, padding; - GList * colors_rgb; - GList * attr_list; - PangoAttrList * curr_attr; -} dTools_dsp; - -static void inline dTools_display_set_size(dTools_dsp * dsp, int w, int h, int pad) { - dsp->size_w = w; - dsp->size_h = h; - dsp->padding = pad; -// gtk_widget_set_size_request(dsp->widget, -// dsp->char_w * w + pad * 2, dsp->char_h * h + pad * 2); - gtk_widget_set_usize(dsp->widget, - dsp->char_w * w + pad * 2, dsp->char_h * h + pad * 2); -} - -static void inline dTools_display_init(dTools_dsp * dsp, GtkWidget * widget, int w, int h, int pad) { - dsp->widget = widget; - dsp->draw = widget->window; - dsp->gc_fg = widget->style->fg_gc[widget->state]; - dsp->gc_bg = widget->style->white_gc; - dsp->playout = gtk_widget_create_pango_layout(widget, NULL); - - dsp->colors_rgb = NULL; - dsp->attr_list = NULL; - dsp->curr_attr = NULL; - - pango_layout_set_markup(dsp->playout, "X",-1); - pango_layout_get_pixel_size(dsp->playout, &dsp->char_w, &dsp->char_h); - dTools_display_set_size(dsp, w, h, pad); -} - -// void unref (gpointer data, ...) { -// pango_attr_list_unref(data); -// } - -static void inline dTools_display_free(dTools_dsp * dsp) { -// g_list_foreach(dsp->attr_list, (GFunc)unref, NULL); -// g_object_unref(dsp->playout); // not alloc -} - -static void inline dTools_display_add_markup(dTools_dsp * dsp, const char * markup) { - PangoAttrList *attr; - pango_parse_markup (markup, -1, 0, &attr, NULL, NULL, NULL); - dsp->attr_list = g_list_append(dsp->attr_list, attr); - dsp->curr_attr = attr; -} - -static void inline dTools_display_clear(dTools_dsp * dsp) { - gdk_draw_rectangle(dsp->draw, dsp->gc_bg, TRUE, 0, 0, - dsp->widget->allocation.width, dsp->widget->allocation.height); -} - -static void inline dTools_display_clear_char(dTools_dsp * dsp, int x, int y, int nb) { - gdk_draw_rectangle(dsp->draw, dsp->gc_bg, TRUE, - x * dsp->char_w + dsp->padding, y * dsp->char_h + dsp->padding, - nb * dsp->char_w, dsp->char_h); -} - -static void inline dTools_display_select_attr(dTools_dsp * dsp, int index) { - PangoAttrList *attr = NULL; - attr = (PangoAttrList*) g_list_nth_data(dsp->attr_list, index); - if (attr != NULL) { - dsp->curr_attr = attr; - } - pango_layout_set_attributes(dsp->playout, dsp->curr_attr); -} - -static void inline dTools_display_draw_text(dTools_dsp * dsp, int x, int y, const char * txt) { - pango_layout_set_text(dsp->playout, txt, -1); - gdk_draw_layout(dsp->draw, dsp->gc_fg, - x * dsp->char_w + dsp->padding, - y * dsp->char_h + dsp->padding, - dsp->playout); -} - -#endif +/* dTools_display.c + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _DTOOLS_DISPLAY_H_ +#define _DTOOLS_DISPLAY_H_ + +#include + +typedef struct { + GtkWidget *widget; + GdkDrawable *draw; + GdkGC *gc_fg; + GdkGC *gc_bg; + PangoLayout* playout; + int size_w, size_h; + int char_w, char_h, padding; + GList * colors_rgb; + GList * attr_list; + PangoAttrList * curr_attr; +} dTools_dsp; + +static void inline dTools_display_set_size(dTools_dsp * dsp, int w, int h, int pad) { + dsp->size_w = w; + dsp->size_h = h; + dsp->padding = pad; +// gtk_widget_set_size_request(dsp->widget, +// dsp->char_w * w + pad * 2, dsp->char_h * h + pad * 2); + gtk_widget_set_usize(dsp->widget, + dsp->char_w * w + pad * 2, dsp->char_h * h + pad * 2); +} + +static void inline dTools_display_init(dTools_dsp * dsp, GtkWidget * widget, int w, int h, int pad) { + dsp->widget = widget; + dsp->draw = widget->window; + dsp->gc_fg = widget->style->fg_gc[widget->state]; + dsp->gc_bg = widget->style->white_gc; + dsp->playout = gtk_widget_create_pango_layout(widget, NULL); + + dsp->colors_rgb = NULL; + dsp->attr_list = NULL; + dsp->curr_attr = NULL; + + pango_layout_set_markup(dsp->playout, "X",-1); + pango_layout_get_pixel_size(dsp->playout, &dsp->char_w, &dsp->char_h); + dTools_display_set_size(dsp, w, h, pad); +} + +// void unref (gpointer data, ...) { +// pango_attr_list_unref(data); +// } + +static void inline dTools_display_free(dTools_dsp * dsp) { +// g_list_foreach(dsp->attr_list, (GFunc)unref, NULL); +// g_object_unref(dsp->playout); // not alloc +} + +static void inline dTools_display_add_markup(dTools_dsp * dsp, const char * markup) { + PangoAttrList *attr; + pango_parse_markup (markup, -1, 0, &attr, NULL, NULL, NULL); + dsp->attr_list = g_list_append(dsp->attr_list, attr); + dsp->curr_attr = attr; +} + +static void inline dTools_display_clear(dTools_dsp * dsp) { + gdk_draw_rectangle(dsp->draw, dsp->gc_bg, TRUE, 0, 0, + dsp->widget->allocation.width, dsp->widget->allocation.height); +} + +static void inline dTools_display_clear_char(dTools_dsp * dsp, int x, int y, int nb) { + gdk_draw_rectangle(dsp->draw, dsp->gc_bg, TRUE, + x * dsp->char_w + dsp->padding, y * dsp->char_h + dsp->padding, + nb * dsp->char_w, dsp->char_h); +} + +static void inline dTools_display_select_attr(dTools_dsp * dsp, int index) { + PangoAttrList *attr = NULL; + attr = (PangoAttrList*) g_list_nth_data(dsp->attr_list, index); + if (attr != NULL) { + dsp->curr_attr = attr; + } + pango_layout_set_attributes(dsp->playout, dsp->curr_attr); +} + +static void inline dTools_display_draw_text(dTools_dsp * dsp, int x, int y, const char * txt) { + pango_layout_set_text(dsp->playout, txt, -1); + gdk_draw_layout(dsp->draw, dsp->gc_fg, + x * dsp->char_w + dsp->padding, + y * dsp->char_h + dsp->padding, + dsp->playout); +} + +#endif diff --git a/desmume/src/gtk-glade/desmume-glade.desktop b/src/gtk-glade/desmume-glade.desktop similarity index 100% rename from desmume/src/gtk-glade/desmume-glade.desktop rename to src/gtk-glade/desmume-glade.desktop diff --git a/desmume/src/gtk-glade/desmume.cpp b/src/gtk-glade/desmume.cpp old mode 100755 new mode 100644 similarity index 92% rename from desmume/src/gtk-glade/desmume.cpp rename to src/gtk-glade/desmume.cpp index 90085b1b6..12f83494c --- a/desmume/src/gtk-glade/desmume.cpp +++ b/src/gtk-glade/desmume.cpp @@ -1,178 +1,178 @@ -/* desmume.c - this file is part of DeSmuME - * - * Copyright (C) 2006,2007 DeSmuME Team - * Copyright (C) 2007 Pascal Giard (evilynux) - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "desmume.h" - -#define EMULOOP_PRIO (G_PRIORITY_HIGH_IDLE + 20) -gboolean EmuLoop(gpointer data); -static BOOL regMainLoop = FALSE; - -#define TICKS_PER_FRAME 17 - - -static BOOL noticed_3D=FALSE; -volatile bool execute = false; -BOOL click = FALSE; - -void desmume_mem_init(); - -u8 *desmume_rom_data = NULL; -u32 desmume_last_cycle; - -void desmume_init( struct armcpu_memory_iface *arm9_mem_if, - struct armcpu_ctrl_iface **arm9_ctrl_iface, //ticksPrevFrame = ticksCurFrame; - struct armcpu_memory_iface *arm7_mem_if, - struct armcpu_ctrl_iface **arm7_ctrl_iface) -{ -#ifdef GDB_STUB - NDS_Init( arm9_mem_if, arm9_ctrl_iface, - arm7_mem_if, arm7_ctrl_iface); -#else - NDS_Init(); -#endif - SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); - execute = false; -} - -void desmume_free() -{ - execute = false; - NDS_DeInit(); -} - -int desmume_open(const char *filename) -{ - int i; - noticed_3D=FALSE; - clear_savestates(); - i = NDS_LoadROM(filename); - return i; -} - -void desmume_savetype(int type) { - backup_setManualBackupType(type); -} - - -void desmume_pause() -{ - execute = false; - SPU_Pause(1); -} - -void desmume_resume() -{ - SPU_Pause(0); - execute = true; - if(!regMainLoop) - g_idle_add_full(EMULOOP_PRIO, &EmuLoop, NULL, NULL); - regMainLoop = TRUE; -} - -void desmume_reset() -{ - noticed_3D=FALSE; - NDS_Reset(); - desmume_resume(); -} - -void desmume_toggle() -{ - execute ^= true; -} -/*INLINE BOOL desmume_running() -{ - return execute; -}*/ - -INLINE void desmume_cycle() -{ - u16 keypad; - /* Joystick events */ - /* Retrieve old value: can use joysticks w/ another device (from our side) */ - keypad = get_keypad(); - /* Process joystick events if any */ - process_joystick_events( &keypad); - /* Update keypad value */ - update_keypad(keypad); - - NDS_exec(); - SPU_Emulate_user(); -} - - -Uint32 fps, fps_SecStart, fps_FrameCount; -Uint32 fsFrameCount = 0; -Uint32 ticksPrevFrame = 0, ticksCurFrame = 0; -static void Draw() -{ -} - -gboolean EmuLoop(gpointer data) -{ - if(desmume_running()) /* Si on est en train d'executer le programme ... */ - { - if(Frameskip != 0 && (fsFrameCount % (Frameskip+1)) != 0) - NDS_SkipNextFrame(); - - fsFrameCount++; - - fps_FrameCount++; - if(!fps_SecStart) fps_SecStart = SDL_GetTicks(); - if(SDL_GetTicks() - fps_SecStart >= 1000) - { - fps_SecStart = SDL_GetTicks(); - fps = fps_FrameCount; - fps_FrameCount = 0; - - char Title[32]; - sprintf(Title, "Desmume - %dfps", fps); - gtk_window_set_title(GTK_WINDOW(pWindow), Title); - } - - desmume_cycle(); /* Emule ! */ - //for(i = 0; i < Frameskip; i++) desmume_cycle(); /* cycles supplĂŠmentaires pour le frameskip */ - - Draw(); - - notify_Tools(); - gtk_widget_queue_draw(pDrawingArea); - gtk_widget_queue_draw(pDrawingArea2); - - ticksCurFrame = SDL_GetTicks(); - - if(!glade_fps_limiter_disabled) - { - if((ticksCurFrame - ticksPrevFrame) < TICKS_PER_FRAME) - while((ticksCurFrame - ticksPrevFrame) < TICKS_PER_FRAME) - ticksCurFrame = SDL_GetTicks(); - } - - ticksPrevFrame = SDL_GetTicks(); - - return TRUE; - } - gtk_widget_queue_draw(pDrawingArea); - gtk_widget_queue_draw(pDrawingArea2); - regMainLoop = FALSE; - return FALSE; -} - +/* desmume.c - this file is part of DeSmuME + * + * Copyright (C) 2006,2007 DeSmuME Team + * Copyright (C) 2007 Pascal Giard (evilynux) + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "desmume.h" + +#define EMULOOP_PRIO (G_PRIORITY_HIGH_IDLE + 20) +gboolean EmuLoop(gpointer data); +static BOOL regMainLoop = FALSE; + +#define TICKS_PER_FRAME 17 + + +static BOOL noticed_3D=FALSE; +volatile BOOL execute = FALSE; +BOOL click = FALSE; + +void desmume_mem_init(); + +u8 *desmume_rom_data = NULL; +u32 desmume_last_cycle; + +void desmume_init( struct armcpu_memory_iface *arm9_mem_if, + struct armcpu_ctrl_iface **arm9_ctrl_iface, //ticksPrevFrame = ticksCurFrame; + struct armcpu_memory_iface *arm7_mem_if, + struct armcpu_ctrl_iface **arm7_ctrl_iface) +{ +#ifdef GDB_STUB + NDS_Init( arm9_mem_if, arm9_ctrl_iface, + arm7_mem_if, arm7_ctrl_iface); +#else + NDS_Init(); +#endif + SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); + execute = FALSE; +} + +void desmume_free() +{ + execute = FALSE; + NDS_DeInit(); +} + +int desmume_open(const char *filename) +{ + int i; + noticed_3D=FALSE; + clear_savestates(); + i = NDS_LoadROM(filename); + return i; +} + +void desmume_savetype(int type) { + backup_setManualBackupType(type); +} + + +void desmume_pause() +{ + execute = FALSE; + SPU_Pause(1); +} + +void desmume_resume() +{ + SPU_Pause(0); + execute = TRUE; + if(!regMainLoop) + g_idle_add_full(EMULOOP_PRIO, &EmuLoop, NULL, NULL); + regMainLoop = TRUE; +} + +void desmume_reset() +{ + noticed_3D=FALSE; + NDS_Reset(); + desmume_resume(); +} + +void desmume_toggle() +{ + execute = (execute) ? FALSE : TRUE; +} +/*INLINE BOOL desmume_running() +{ + return execute; +}*/ + +INLINE void desmume_cycle() +{ + u16 keypad; + /* Joystick events */ + /* Retrieve old value: can use joysticks w/ another device (from our side) */ + keypad = get_keypad(); + /* Process joystick events if any */ + process_joystick_events( &keypad); + /* Update keypad value */ + update_keypad(keypad); + + NDS_exec(); + SPU_Emulate_user(); +} + + +Uint32 fps, fps_SecStart, fps_FrameCount; +Uint32 fsFrameCount = 0; +Uint32 ticksPrevFrame = 0, ticksCurFrame = 0; +static void Draw() +{ +} + +gboolean EmuLoop(gpointer data) +{ + if(desmume_running()) /* Si on est en train d'executer le programme ... */ + { + if(Frameskip != 0 && (fsFrameCount % (Frameskip+1)) != 0) + NDS_SkipNextFrame(); + + fsFrameCount++; + + fps_FrameCount++; + if(!fps_SecStart) fps_SecStart = SDL_GetTicks(); + if(SDL_GetTicks() - fps_SecStart >= 1000) + { + fps_SecStart = SDL_GetTicks(); + fps = fps_FrameCount; + fps_FrameCount = 0; + + char Title[32]; + sprintf(Title, "Desmume - %dfps", fps); + gtk_window_set_title(GTK_WINDOW(pWindow), Title); + } + + desmume_cycle(); /* Emule ! */ + //for(i = 0; i < Frameskip; i++) desmume_cycle(); /* cycles supplĂŠmentaires pour le frameskip */ + + Draw(); + + notify_Tools(); + gtk_widget_queue_draw(pDrawingArea); + gtk_widget_queue_draw(pDrawingArea2); + + ticksCurFrame = SDL_GetTicks(); + + if(!glade_fps_limiter_disabled) + { + if((ticksCurFrame - ticksPrevFrame) < TICKS_PER_FRAME) + while((ticksCurFrame - ticksPrevFrame) < TICKS_PER_FRAME) + ticksCurFrame = SDL_GetTicks(); + } + + ticksPrevFrame = SDL_GetTicks(); + + return TRUE; + } + gtk_widget_queue_draw(pDrawingArea); + gtk_widget_queue_draw(pDrawingArea2); + regMainLoop = FALSE; + return FALSE; +} + diff --git a/desmume/src/gtk-glade/desmume.h b/src/gtk-glade/desmume.h old mode 100755 new mode 100644 similarity index 97% rename from desmume/src/gtk-glade/desmume.h rename to src/gtk-glade/desmume.h index 4a6dcc292..bef3116dd --- a/desmume/src/gtk-glade/desmume.h +++ b/src/gtk-glade/desmume.h @@ -1,49 +1,49 @@ -/* desmume.h - this file is part of DeSmuME - * - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __DESMUME_H__ -#define __DESMUME_H__ - -#include "globals.h" - -#define FPS_LIMITER_FRAME_PERIOD 5 -extern SDL_sem *glade_fps_limiter_semaphore; -extern int glade_fps_limiter_disabled; - -extern void desmume_init( struct armcpu_memory_iface *arm9_mem_if, - struct armcpu_ctrl_iface **arm9_ctrl_iface, - struct armcpu_memory_iface *arm7_mem_if, - struct armcpu_ctrl_iface **arm7_ctrl_iface); -extern void desmume_free( void); - -extern int desmume_open(const char *filename); -extern void desmume_savetype(int type); -extern void desmume_pause( void); -extern void desmume_resume( void); -extern void desmume_reset( void); -extern void desmume_toggle( void); -//extern BOOL desmume_running( void); -INLINE BOOL desmume_running(void) -{ - return execute; -} - -extern INLINE void desmume_cycle( void); -#endif /*__DESMUME_H__*/ - +/* desmume.h - this file is part of DeSmuME + * + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __DESMUME_H__ +#define __DESMUME_H__ + +#include "globals.h" + +#define FPS_LIMITER_FRAME_PERIOD 5 +extern SDL_sem *glade_fps_limiter_semaphore; +extern int glade_fps_limiter_disabled; + +extern void desmume_init( struct armcpu_memory_iface *arm9_mem_if, + struct armcpu_ctrl_iface **arm9_ctrl_iface, + struct armcpu_memory_iface *arm7_mem_if, + struct armcpu_ctrl_iface **arm7_ctrl_iface); +extern void desmume_free( void); + +extern int desmume_open(const char *filename); +extern void desmume_savetype(int type); +extern void desmume_pause( void); +extern void desmume_resume( void); +extern void desmume_reset( void); +extern void desmume_toggle( void); +//extern BOOL desmume_running( void); +INLINE BOOL desmume_running(void) +{ + return execute; +} + +extern INLINE void desmume_cycle( void); +#endif /*__DESMUME_H__*/ + diff --git a/desmume/src/gtk-glade/doc/Makefile.am b/src/gtk-glade/doc/Makefile.am similarity index 100% rename from desmume/src/gtk-glade/doc/Makefile.am rename to src/gtk-glade/doc/Makefile.am diff --git a/desmume/src/gtk-glade/doc/desmume-glade.1 b/src/gtk-glade/doc/desmume-glade.1 similarity index 100% rename from desmume/src/gtk-glade/doc/desmume-glade.1 rename to src/gtk-glade/doc/desmume-glade.1 diff --git a/desmume/src/gtk-glade/gdk_3Demu.cpp b/src/gtk-glade/gdk_3Demu.cpp similarity index 97% rename from desmume/src/gtk-glade/gdk_3Demu.cpp rename to src/gtk-glade/gdk_3Demu.cpp index e979965f7..681dff8d5 100644 --- a/desmume/src/gtk-glade/gdk_3Demu.cpp +++ b/src/gtk-glade/gdk_3Demu.cpp @@ -1,208 +1,208 @@ -/* $Id: gdk_3Demu.c,v 1.4 2007-07-15 21:50:30 evilynux Exp $ - */ -/* - Copyright (C) 2006-2007 Ben Jaques - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifdef GTKGLEXT_AVAILABLE - -#include -#include - -// Localization -#include -#define _(String) gettext (String) - -#include "../types.h" -#include "../render3D.h" -#include "../OGLRender.h" -#include "gdk_3Demu.h" - -/* - * The GDK 3D emulation. - * This uses the OpenGL Collector plugin, using gdkGLext for the platform - * specific helper functions. - */ - - -static GdkPixmap *target_pixmap; -static GdkGLContext *glcontext = NULL; -static GdkGLDrawable *gldrawable; - - -#if 0 /* not used */ -static void -print_gl_config_attrib (GdkGLConfig *glconfig, - const gchar *attrib_str, - int attrib, - gboolean is_boolean) -{ - int value; - - g_print ("%s = ", attrib_str); - if (gdk_gl_config_get_attrib (glconfig, attrib, &value)) - { - if (is_boolean) - g_print ("%s\n", value == TRUE ? "TRUE" : "FALSE"); - else - g_print ("%d\n", value); - } - else - g_print (_("*** Cannot get %s attribute value\n"), attrib_str); -} - - -static void -examine_gl_config_attrib (GdkGLConfig *glconfig) -{ - g_print ("\nOpenGL visual configurations :\n\n"); - - g_print ("gdk_gl_config_is_rgba (glconfig) = %s\n", - gdk_gl_config_is_rgba (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_is_double_buffered (glconfig) = %s\n", - gdk_gl_config_is_double_buffered (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_is_stereo (glconfig) = %s\n", - gdk_gl_config_is_stereo (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_has_alpha (glconfig) = %s\n", - gdk_gl_config_has_alpha (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_has_depth_buffer (glconfig) = %s\n", - gdk_gl_config_has_depth_buffer (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_has_stencil_buffer (glconfig) = %s\n", - gdk_gl_config_has_stencil_buffer (glconfig) ? "TRUE" : "FALSE"); - g_print ("gdk_gl_config_has_accum_buffer (glconfig) = %s\n", - gdk_gl_config_has_accum_buffer (glconfig) ? "TRUE" : "FALSE"); - - g_print ("\n"); - - print_gl_config_attrib (glconfig, "GDK_GL_USE_GL", - GDK_GL_USE_GL, TRUE); - print_gl_config_attrib (glconfig, "GDK_GL_BUFFER_SIZE", - GDK_GL_BUFFER_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_LEVEL", - GDK_GL_LEVEL, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_RGBA", - GDK_GL_RGBA, TRUE); - print_gl_config_attrib (glconfig, "GDK_GL_DOUBLEBUFFER", - GDK_GL_DOUBLEBUFFER, TRUE); - print_gl_config_attrib (glconfig, "GDK_GL_STEREO", - GDK_GL_STEREO, TRUE); - print_gl_config_attrib (glconfig, "GDK_GL_AUX_BUFFERS", - GDK_GL_AUX_BUFFERS, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_RED_SIZE", - GDK_GL_RED_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_GREEN_SIZE", - GDK_GL_GREEN_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_BLUE_SIZE", - GDK_GL_BLUE_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_ALPHA_SIZE", - GDK_GL_ALPHA_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_DEPTH_SIZE", - GDK_GL_DEPTH_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_STENCIL_SIZE", - GDK_GL_STENCIL_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_RED_SIZE", - GDK_GL_ACCUM_RED_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_GREEN_SIZE", - GDK_GL_ACCUM_GREEN_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_BLUE_SIZE", - GDK_GL_ACCUM_BLUE_SIZE, FALSE); - print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_ALPHA_SIZE", - GDK_GL_ACCUM_ALPHA_SIZE, FALSE); - - g_print ("\n"); -} -#endif - -static bool -begin_opengl_region_gdk_3d( void) { - bool failed = false; - - gdk_error_trap_push(); - failed = !gdk_gl_drawable_gl_begin(gldrawable, glcontext); - gdk_flush(); - failed = failed | gdk_error_trap_pop(); - - if (failed) return false; - - return true; -} - -static void -end_opengl_region_gdk_3d( void) { - gdk_gl_drawable_gl_end (gldrawable); -} - -static bool -initialise_gdk_3d( void) { - /* this does nothing */ - return true; -} - -int -init_opengl_gdk_3Demu( GdkDrawable * drawable) { - GdkGLConfig *glconfig; - - /* create the off screen pixmap */ - target_pixmap = gdk_pixmap_new ( drawable, 256, 192, -1); - - if ( target_pixmap == NULL) { - g_print (_("*** Failed to create pixmap.\n")); - return 0; - } - - glconfig = gdk_gl_config_new_by_mode ((GdkGLConfigMode) (GDK_GL_MODE_RGBA | - GDK_GL_MODE_DEPTH | - GDK_GL_MODE_STENCIL | - GDK_GL_MODE_SINGLE)); - if (glconfig == NULL) - { - g_print (_("*** No appropriate OpenGL-capable visual found.\n")); - return 0; - } - - /* - * Set OpenGL-capability to the pixmap - */ - - gldrawable = GDK_GL_DRAWABLE (gdk_pixmap_set_gl_capability (target_pixmap, - glconfig, - NULL)); - - if ( gldrawable == NULL) { - g_print (_("Failed to create the GdkGLPixmap\n")); - return 0; - } - - glcontext = gdk_gl_context_new (gldrawable, - NULL, - FALSE, - GDK_GL_RGBA_TYPE); - if (glcontext == NULL) - { - g_print (_("Connot create the OpenGL rendering context\n")); - return 0; - } - - oglrender_init = initialise_gdk_3d; - oglrender_beginOpenGL = begin_opengl_region_gdk_3d; - oglrender_endOpenGL = end_opengl_region_gdk_3d; - - return 1; -} - -#endif +/* $Id: gdk_3Demu.c,v 1.4 2007-07-15 21:50:30 evilynux Exp $ + */ +/* + Copyright (C) 2006-2007 Ben Jaques + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifdef GTKGLEXT_AVAILABLE + +#include +#include + +// Localization +#include +#define _(String) gettext (String) + +#include "../types.h" +#include "../render3D.h" +#include "../OGLRender.h" +#include "gdk_3Demu.h" + +/* + * The GDK 3D emulation. + * This uses the OpenGL Collector plugin, using gdkGLext for the platform + * specific helper functions. + */ + + +static GdkPixmap *target_pixmap; +static GdkGLContext *glcontext = NULL; +static GdkGLDrawable *gldrawable; + + +#if 0 /* not used */ +static void +print_gl_config_attrib (GdkGLConfig *glconfig, + const gchar *attrib_str, + int attrib, + gboolean is_boolean) +{ + int value; + + g_print ("%s = ", attrib_str); + if (gdk_gl_config_get_attrib (glconfig, attrib, &value)) + { + if (is_boolean) + g_print ("%s\n", value == TRUE ? "TRUE" : "FALSE"); + else + g_print ("%d\n", value); + } + else + g_print (_("*** Cannot get %s attribute value\n"), attrib_str); +} + + +static void +examine_gl_config_attrib (GdkGLConfig *glconfig) +{ + g_print ("\nOpenGL visual configurations :\n\n"); + + g_print ("gdk_gl_config_is_rgba (glconfig) = %s\n", + gdk_gl_config_is_rgba (glconfig) ? "TRUE" : "FALSE"); + g_print ("gdk_gl_config_is_double_buffered (glconfig) = %s\n", + gdk_gl_config_is_double_buffered (glconfig) ? "TRUE" : "FALSE"); + g_print ("gdk_gl_config_is_stereo (glconfig) = %s\n", + gdk_gl_config_is_stereo (glconfig) ? "TRUE" : "FALSE"); + g_print ("gdk_gl_config_has_alpha (glconfig) = %s\n", + gdk_gl_config_has_alpha (glconfig) ? "TRUE" : "FALSE"); + g_print ("gdk_gl_config_has_depth_buffer (glconfig) = %s\n", + gdk_gl_config_has_depth_buffer (glconfig) ? "TRUE" : "FALSE"); + g_print ("gdk_gl_config_has_stencil_buffer (glconfig) = %s\n", + gdk_gl_config_has_stencil_buffer (glconfig) ? "TRUE" : "FALSE"); + g_print ("gdk_gl_config_has_accum_buffer (glconfig) = %s\n", + gdk_gl_config_has_accum_buffer (glconfig) ? "TRUE" : "FALSE"); + + g_print ("\n"); + + print_gl_config_attrib (glconfig, "GDK_GL_USE_GL", + GDK_GL_USE_GL, TRUE); + print_gl_config_attrib (glconfig, "GDK_GL_BUFFER_SIZE", + GDK_GL_BUFFER_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_LEVEL", + GDK_GL_LEVEL, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_RGBA", + GDK_GL_RGBA, TRUE); + print_gl_config_attrib (glconfig, "GDK_GL_DOUBLEBUFFER", + GDK_GL_DOUBLEBUFFER, TRUE); + print_gl_config_attrib (glconfig, "GDK_GL_STEREO", + GDK_GL_STEREO, TRUE); + print_gl_config_attrib (glconfig, "GDK_GL_AUX_BUFFERS", + GDK_GL_AUX_BUFFERS, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_RED_SIZE", + GDK_GL_RED_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_GREEN_SIZE", + GDK_GL_GREEN_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_BLUE_SIZE", + GDK_GL_BLUE_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_ALPHA_SIZE", + GDK_GL_ALPHA_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_DEPTH_SIZE", + GDK_GL_DEPTH_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_STENCIL_SIZE", + GDK_GL_STENCIL_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_RED_SIZE", + GDK_GL_ACCUM_RED_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_GREEN_SIZE", + GDK_GL_ACCUM_GREEN_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_BLUE_SIZE", + GDK_GL_ACCUM_BLUE_SIZE, FALSE); + print_gl_config_attrib (glconfig, "GDK_GL_ACCUM_ALPHA_SIZE", + GDK_GL_ACCUM_ALPHA_SIZE, FALSE); + + g_print ("\n"); +} +#endif + +static bool +begin_opengl_region_gdk_3d( void) { + bool failed = false; + + gdk_error_trap_push(); + failed = !gdk_gl_drawable_gl_begin(gldrawable, glcontext); + gdk_flush(); + failed = failed | gdk_error_trap_pop(); + + if (failed) return false; + + return true; +} + +static void +end_opengl_region_gdk_3d( void) { + gdk_gl_drawable_gl_end (gldrawable); +} + +static bool +initialise_gdk_3d( void) { + /* this does nothing */ + return true; +} + +int +init_opengl_gdk_3Demu( GdkDrawable * drawable) { + GdkGLConfig *glconfig; + + /* create the off screen pixmap */ + target_pixmap = gdk_pixmap_new ( drawable, 256, 192, -1); + + if ( target_pixmap == NULL) { + g_print (_("*** Failed to create pixmap.\n")); + return 0; + } + + glconfig = gdk_gl_config_new_by_mode ((GdkGLConfigMode) (GDK_GL_MODE_RGBA | + GDK_GL_MODE_DEPTH | + GDK_GL_MODE_STENCIL | + GDK_GL_MODE_SINGLE)); + if (glconfig == NULL) + { + g_print (_("*** No appropriate OpenGL-capable visual found.\n")); + return 0; + } + + /* + * Set OpenGL-capability to the pixmap + */ + + gldrawable = GDK_GL_DRAWABLE (gdk_pixmap_set_gl_capability (target_pixmap, + glconfig, + NULL)); + + if ( gldrawable == NULL) { + g_print (_("Failed to create the GdkGLPixmap\n")); + return 0; + } + + glcontext = gdk_gl_context_new (gldrawable, + NULL, + FALSE, + GDK_GL_RGBA_TYPE); + if (glcontext == NULL) + { + g_print (_("Connot create the OpenGL rendering context\n")); + return 0; + } + + oglrender_init = initialise_gdk_3d; + oglrender_beginOpenGL = begin_opengl_region_gdk_3d; + oglrender_endOpenGL = end_opengl_region_gdk_3d; + + return 1; +} + +#endif diff --git a/desmume/src/gtk-glade/gdk_3Demu.h b/src/gtk-glade/gdk_3Demu.h similarity index 97% rename from desmume/src/gtk-glade/gdk_3Demu.h rename to src/gtk-glade/gdk_3Demu.h index 8a0a0686e..42cced988 100644 --- a/desmume/src/gtk-glade/gdk_3Demu.h +++ b/src/gtk-glade/gdk_3Demu.h @@ -1,32 +1,32 @@ -/* $Id: gdk_3Demu.h,v 1.1 2007-04-21 19:45:07 evilynux Exp $ - */ -/* - Copyright (C) 2006-2007 Ben Jaques - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifdef GTKGLEXT_AVAILABLE -/* - * The GDK 3D emulation. - * This uses the OpenGL Collector plugin, using gdkGLext for the platform - * specific helper functions. - */ - -int -init_opengl_gdk_3Demu( GdkDrawable * drawable); - -#endif +/* $Id: gdk_3Demu.h,v 1.1 2007-04-21 19:45:07 evilynux Exp $ + */ +/* + Copyright (C) 2006-2007 Ben Jaques + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifdef GTKGLEXT_AVAILABLE +/* + * The GDK 3D emulation. + * This uses the OpenGL Collector plugin, using gdkGLext for the platform + * specific helper functions. + */ + +int +init_opengl_gdk_3Demu( GdkDrawable * drawable); + +#endif diff --git a/desmume/src/gtk-glade/gdk_gl.cpp b/src/gtk-glade/gdk_gl.cpp old mode 100755 new mode 100644 similarity index 96% rename from desmume/src/gtk-glade/gdk_gl.cpp rename to src/gtk-glade/gdk_gl.cpp index 34803742e..b19b86995 --- a/desmume/src/gtk-glade/gdk_gl.cpp +++ b/src/gtk-glade/gdk_gl.cpp @@ -1,349 +1,349 @@ -/* gdk_gl.cpp - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "gdk_gl.h" - -#ifdef GTKGLEXT_AVAILABLE - -#include -#include - -#define _DUP8(a) a,a,a,a, a,a,a,a -#define _DUP4(a) a,a,a,a -#define _DUP2(a) a,a - -GLuint Textures[2]; -// free number we can use in tools 0-1 reserved for screens -static int free_gl_drawable=2; -GdkGLConfig *my_glConfig=NULL; -GdkGLContext *my_glContext[8]={_DUP8(NULL)}; -GdkGLDrawable *my_glDrawable[8]={_DUP8(NULL)}; -GtkWidget *pDrawingTexArea; - -GLuint screen_texture[1]; - -/* enable software colour format conversion */ -static int gtk_glade_use_software_colour_convert; - -#undef _DUP8 -#undef _DUP4 -#undef _DUP2 - -/* FIXME: Purpose of this code? */ -static BOOL _fun_gl_Begin (int screen) { return FALSE; } -static void _fun_gl_End (int screen) { } - -fun_gl_Begin Open_GL_beg = _fun_gl_Begin; -fun_gl_End Open_GL_end = _fun_gl_End; - -void register_gl_fun(fun_gl_Begin beg,fun_gl_End end) { - Open_GL_beg = beg; - Open_GL_end = end; -} - -/************************************************/ -/* BEGIN & END */ -/************************************************/ - -BOOL my_gl_Begin (int screen) { - return gdk_gl_drawable_gl_begin(my_glDrawable[screen], my_glContext[screen]); -} - -void my_gl_End (int screen) { - if (gdk_gl_drawable_is_double_buffered (my_glDrawable[screen])) - gdk_gl_drawable_swap_buffers (my_glDrawable[screen]); - else - glFlush(); - gdk_gl_drawable_gl_end(my_glDrawable[screen]); -} - -/************************************************/ -/* OTHER GL COMMANDS */ -/************************************************/ - -void my_gl_Identity() { - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -void my_gl_DrawBeautifulQuad( void) { - // beautiful quad - glBegin(GL_QUADS); - glColor3ub(255,0,0); glVertex2d(-0.75,-0.75); - glColor3ub(128,255,0); glVertex2d(-0.75, 0.75); - glColor3ub(0,255,128); glVertex2d( 0.75, 0.75); - glColor3ub(0,0,255); glVertex2d( 0.75,-0.75); - glEnd(); - glColor3ub(255,255,255); -} - -#if 0 /* not used */ -static void my_gl_DrawLogo() { - - -} -#endif - - -void my_gl_Clear(int screen) { - if (!my_gl_Begin(screen)) return; - - /* Set the background black */ - glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - glClearDepth(1.0); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - - my_gl_DrawBeautifulQuad(); - - my_gl_End(screen); -} - -/************************************************/ -/* INITIALIZATION */ -/************************************************/ - -void init_GL(GtkWidget * widget, int screen, int share_num) { -// for (n=gtk_events_pending(); n>0; n--) -// gtk_main_iteration(); - // init GL capability - my_glContext[screen]=NULL; - my_glDrawable[screen]=NULL; - if (!gtk_widget_set_gl_capability( - widget, my_glConfig, - my_glContext[share_num], - //NULL, - TRUE, - GDK_GL_RGBA_TYPE)) { - printf ("gtk_widget_set_gl_capability\n"); - exit(1); - } - // realize so that we get a GdkWindow - gtk_widget_realize(widget); - // make sure we realize - gdk_flush(); - - my_glDrawable[screen] = gtk_widget_get_gl_drawable(widget); - - if (screen == share_num) { - my_glContext[screen] = gtk_widget_get_gl_context(widget); - } else { - my_glContext[screen] = my_glContext[share_num]; - return; - } - - reshape(widget, screen); -} - -int init_GL_free_s(GtkWidget * widget, int share_num) { - int r = free_gl_drawable; - my_glContext[r]=NULL; - my_glDrawable[r]=NULL; - init_GL(widget, r, share_num); - free_gl_drawable++; - return r; -} - -int init_GL_free(GtkWidget * widget) { - int r = free_gl_drawable; - my_glContext[r]=NULL; - my_glDrawable[r]=NULL; - init_GL(widget, r, r); - free_gl_drawable++; - return r; -} - -void init_GL_capabilities( int use_software_convert) { - - uint16_t blank_texture[256 * 512]; - my_glConfig = gdk_gl_config_new_by_mode ( - (GdkGLConfigMode) (GDK_GL_MODE_RGBA - | GDK_GL_MODE_DEPTH - | GDK_GL_MODE_DOUBLE) - ); - - gtk_glade_use_software_colour_convert = use_software_convert; - // initialize 1st drawing area - init_GL(pDrawingArea,0,0); - my_gl_Clear(0); - - if (!my_gl_Begin(0)) return; - // generate ONE texture (display) - glEnable(GL_TEXTURE_2D); - glGenTextures(2, Textures); - - /* Generate The Texture */ - glBindTexture( GL_TEXTURE_2D, Textures[0]); - memset(blank_texture, 0x001f, sizeof(blank_texture)); - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 256, 512, - 0, GL_RGBA, - GL_UNSIGNED_SHORT_1_5_5_5_REV, - blank_texture); - my_gl_End(0); - - // initialize 2nd drawing area (sharing context) - init_GL(pDrawingArea2,1,0); - my_gl_Clear(1); -} - -/************************************************/ -/* RESHAPE */ -/************************************************/ - -void reshape (GtkWidget * widget, int screen) { - if (my_glDrawable[screen] == NULL || - !my_gl_Begin(screen)) return; - - glViewport (0, 0, widget->allocation.width, widget->allocation.height); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - my_gl_End(screen); -} - -/************************************************/ -/* TEXTURING */ -/************************************************/ - -static void my_gl_Texture2D() { - glBindTexture(GL_TEXTURE_2D, Textures[0]); -#define MyFILTER GL_LINEAR -//#define MyFILTER GL_NEAREST - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MyFILTER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MyFILTER); -#undef MyFILTER -} - -static void -my_gl_ScreenTex( int software_convert) { - if ( software_convert) { - u8 converted[256 * 384 * 3]; - int i; - - for ( i = 0; i < (256 * 384); i++) { - converted[(i * 3) + 0] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 0) & 0x1f) << 3; - converted[(i * 3) + 1] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 5) & 0x1f) << 3; - converted[(i * 3) + 2] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 10) & 0x1f) << 3; - } - - glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384, - GL_RGB, - GL_UNSIGNED_BYTE, - converted); - } - else { - glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384, - GL_RGBA, - GL_UNSIGNED_SHORT_1_5_5_5_REV, - &GPU_screen); - } -} - -static void my_gl_ScreenTexApply(int screen) { - float off = (screen)?0.375:0; - glBegin(GL_QUADS); - // texcoords 0.375 means 192, 1 means 256 - glTexCoord2f(0.0, off+0.000); glVertex2d(-1.0, 1.0); - glTexCoord2f(1.0, off+0.000); glVertex2d( 1.0, 1.0); - glTexCoord2f(1.0, off+0.375); glVertex2d( 1.0,-1.0); - glTexCoord2f(0.0, off+0.375); glVertex2d(-1.0,-1.0); - glEnd(); -} - -/************************************************/ -/* RENDERING */ -/************************************************/ - -gboolean screen (GtkWidget * widget, int viewportscreen) { - int screen; - GPU * gpu; - float bright_color = 0.0f; // blend with black - float bright_alpha = 0.0f; // don't blend - - // we take care to draw the right thing the right place - // we need to rearrange widgets not to use this trick - screen = (ScreenInvert)?1-viewportscreen:viewportscreen; -// screen = viewportscreen; - - if (!my_gl_Begin(viewportscreen)) return TRUE; - - glLoadIdentity(); - - // clear screen - glClearColor(0.0f,0.0f,0.0f,0.0f); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - - glEnable(GL_TEXTURE_2D); - - if (desmume_running()) { - - // master bright - gpu = ((screen)?SubScreen:MainScreen).gpu; - - switch (gpu->MasterBrightMode) - { - case 1: // Bright up : blend with white - bright_color = 1.0f; - // no break; - case 2: // Bright down : blend with black - bright_alpha = 1.0f; // blending max - - bright_alpha = gpu->MasterBrightFactor / 16.0; - break; - // Disabled 0, Reserved 3 - default: break; - } - // rotate - glRotatef(ScreenRotate, 0.0, 0.0, 1.0); - // create the texture for both display - my_gl_Texture2D(); - if (viewportscreen==0) { - my_gl_ScreenTex( gtk_glade_use_software_colour_convert); - } - } else { - // pause - // fake master bright up 50% - bright_color = 0.0f; - bright_alpha = 0.5f; - } - // make sure current color is ok - glColor4ub(255,255,255,255); - // apply part of the texture - my_gl_ScreenTexApply(screen); - glDisable(GL_TEXTURE_2D); - - // master bright (bis) - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - glColor4f(bright_color,bright_color,bright_color,bright_alpha); - glBegin(GL_QUADS); - glVertex2d(-1.0, 1.0); - glVertex2d( 1.0, 1.0); - glVertex2d( 1.0,-1.0); - glVertex2d(-1.0,-1.0); - glEnd(); - glDisable(GL_BLEND); - - my_gl_End(viewportscreen); - return TRUE; -} - -#endif /* if GTKGLEXT_AVAILABLE */ +/* gdk_gl.cpp - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "gdk_gl.h" + +#ifdef GTKGLEXT_AVAILABLE + +#include +#include + +#define _DUP8(a) a,a,a,a, a,a,a,a +#define _DUP4(a) a,a,a,a +#define _DUP2(a) a,a + +GLuint Textures[2]; +// free number we can use in tools 0-1 reserved for screens +static int free_gl_drawable=2; +GdkGLConfig *my_glConfig=NULL; +GdkGLContext *my_glContext[8]={_DUP8(NULL)}; +GdkGLDrawable *my_glDrawable[8]={_DUP8(NULL)}; +GtkWidget *pDrawingTexArea; + +GLuint screen_texture[1]; + +/* enable software colour format conversion */ +static int gtk_glade_use_software_colour_convert; + +#undef _DUP8 +#undef _DUP4 +#undef _DUP2 + +/* FIXME: Purpose of this code? */ +static BOOL _fun_gl_Begin (int screen) { return FALSE; } +static void _fun_gl_End (int screen) { } + +fun_gl_Begin Open_GL_beg = _fun_gl_Begin; +fun_gl_End Open_GL_end = _fun_gl_End; + +void register_gl_fun(fun_gl_Begin beg,fun_gl_End end) { + Open_GL_beg = beg; + Open_GL_end = end; +} + +/************************************************/ +/* BEGIN & END */ +/************************************************/ + +BOOL my_gl_Begin (int screen) { + return gdk_gl_drawable_gl_begin(my_glDrawable[screen], my_glContext[screen]); +} + +void my_gl_End (int screen) { + if (gdk_gl_drawable_is_double_buffered (my_glDrawable[screen])) + gdk_gl_drawable_swap_buffers (my_glDrawable[screen]); + else + glFlush(); + gdk_gl_drawable_gl_end(my_glDrawable[screen]); +} + +/************************************************/ +/* OTHER GL COMMANDS */ +/************************************************/ + +void my_gl_Identity() { + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +void my_gl_DrawBeautifulQuad( void) { + // beautiful quad + glBegin(GL_QUADS); + glColor3ub(255,0,0); glVertex2d(-0.75,-0.75); + glColor3ub(128,255,0); glVertex2d(-0.75, 0.75); + glColor3ub(0,255,128); glVertex2d( 0.75, 0.75); + glColor3ub(0,0,255); glVertex2d( 0.75,-0.75); + glEnd(); + glColor3ub(255,255,255); +} + +#if 0 /* not used */ +static void my_gl_DrawLogo() { + + +} +#endif + + +void my_gl_Clear(int screen) { + if (!my_gl_Begin(screen)) return; + + /* Set the background black */ + glClearColor(1.0f, 1.0f, 1.0f, 1.0f); + glClearDepth(1.0); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + my_gl_DrawBeautifulQuad(); + + my_gl_End(screen); +} + +/************************************************/ +/* INITIALIZATION */ +/************************************************/ + +void init_GL(GtkWidget * widget, int screen, int share_num) { +// for (n=gtk_events_pending(); n>0; n--) +// gtk_main_iteration(); + // init GL capability + my_glContext[screen]=NULL; + my_glDrawable[screen]=NULL; + if (!gtk_widget_set_gl_capability( + widget, my_glConfig, + my_glContext[share_num], + //NULL, + TRUE, + GDK_GL_RGBA_TYPE)) { + printf ("gtk_widget_set_gl_capability\n"); + exit(1); + } + // realize so that we get a GdkWindow + gtk_widget_realize(widget); + // make sure we realize + gdk_flush(); + + my_glDrawable[screen] = gtk_widget_get_gl_drawable(widget); + + if (screen == share_num) { + my_glContext[screen] = gtk_widget_get_gl_context(widget); + } else { + my_glContext[screen] = my_glContext[share_num]; + return; + } + + reshape(widget, screen); +} + +int init_GL_free_s(GtkWidget * widget, int share_num) { + int r = free_gl_drawable; + my_glContext[r]=NULL; + my_glDrawable[r]=NULL; + init_GL(widget, r, share_num); + free_gl_drawable++; + return r; +} + +int init_GL_free(GtkWidget * widget) { + int r = free_gl_drawable; + my_glContext[r]=NULL; + my_glDrawable[r]=NULL; + init_GL(widget, r, r); + free_gl_drawable++; + return r; +} + +void init_GL_capabilities( int use_software_convert) { + + uint16_t blank_texture[256 * 512]; + my_glConfig = gdk_gl_config_new_by_mode ( + (GdkGLConfigMode) (GDK_GL_MODE_RGBA + | GDK_GL_MODE_DEPTH + | GDK_GL_MODE_DOUBLE) + ); + + gtk_glade_use_software_colour_convert = use_software_convert; + // initialize 1st drawing area + init_GL(pDrawingArea,0,0); + my_gl_Clear(0); + + if (!my_gl_Begin(0)) return; + // generate ONE texture (display) + glEnable(GL_TEXTURE_2D); + glGenTextures(2, Textures); + + /* Generate The Texture */ + glBindTexture( GL_TEXTURE_2D, Textures[0]); + memset(blank_texture, 0x001f, sizeof(blank_texture)); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, 256, 512, + 0, GL_RGBA, + GL_UNSIGNED_SHORT_1_5_5_5_REV, + blank_texture); + my_gl_End(0); + + // initialize 2nd drawing area (sharing context) + init_GL(pDrawingArea2,1,0); + my_gl_Clear(1); +} + +/************************************************/ +/* RESHAPE */ +/************************************************/ + +void reshape (GtkWidget * widget, int screen) { + if (my_glDrawable[screen] == NULL || + !my_gl_Begin(screen)) return; + + glViewport (0, 0, widget->allocation.width, widget->allocation.height); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + my_gl_End(screen); +} + +/************************************************/ +/* TEXTURING */ +/************************************************/ + +static void my_gl_Texture2D() { + glBindTexture(GL_TEXTURE_2D, Textures[0]); +#define MyFILTER GL_LINEAR +//#define MyFILTER GL_NEAREST + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MyFILTER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MyFILTER); +#undef MyFILTER +} + +static void +my_gl_ScreenTex( int software_convert) { + if ( software_convert) { + u8 converted[256 * 384 * 3]; + int i; + + for ( i = 0; i < (256 * 384); i++) { + converted[(i * 3) + 0] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 0) & 0x1f) << 3; + converted[(i * 3) + 1] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 5) & 0x1f) << 3; + converted[(i * 3) + 2] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 10) & 0x1f) << 3; + } + + glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384, + GL_RGB, + GL_UNSIGNED_BYTE, + converted); + } + else { + glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384, + GL_RGBA, + GL_UNSIGNED_SHORT_1_5_5_5_REV, + &GPU_screen); + } +} + +static void my_gl_ScreenTexApply(int screen) { + float off = (screen)?0.375:0; + glBegin(GL_QUADS); + // texcoords 0.375 means 192, 1 means 256 + glTexCoord2f(0.0, off+0.000); glVertex2d(-1.0, 1.0); + glTexCoord2f(1.0, off+0.000); glVertex2d( 1.0, 1.0); + glTexCoord2f(1.0, off+0.375); glVertex2d( 1.0,-1.0); + glTexCoord2f(0.0, off+0.375); glVertex2d(-1.0,-1.0); + glEnd(); +} + +/************************************************/ +/* RENDERING */ +/************************************************/ + +gboolean screen (GtkWidget * widget, int viewportscreen) { + int screen; + GPU * gpu; + float bright_color = 0.0f; // blend with black + float bright_alpha = 0.0f; // don't blend + + // we take care to draw the right thing the right place + // we need to rearrange widgets not to use this trick + screen = (ScreenInvert)?1-viewportscreen:viewportscreen; +// screen = viewportscreen; + + if (!my_gl_Begin(viewportscreen)) return TRUE; + + glLoadIdentity(); + + // clear screen + glClearColor(0.0f,0.0f,0.0f,0.0f); + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glEnable(GL_TEXTURE_2D); + + if (desmume_running()) { + + // master bright + gpu = ((screen)?SubScreen:MainScreen).gpu; + + switch (gpu->MasterBrightMode) + { + case 1: // Bright up : blend with white + bright_color = 1.0f; + // no break; + case 2: // Bright down : blend with black + bright_alpha = 1.0f; // blending max + + bright_alpha = gpu->MasterBrightFactor / 16.0; + break; + // Disabled 0, Reserved 3 + default: break; + } + // rotate + glRotatef(ScreenRotate, 0.0, 0.0, 1.0); + // create the texture for both display + my_gl_Texture2D(); + if (viewportscreen==0) { + my_gl_ScreenTex( gtk_glade_use_software_colour_convert); + } + } else { + // pause + // fake master bright up 50% + bright_color = 0.0f; + bright_alpha = 0.5f; + } + // make sure current color is ok + glColor4ub(255,255,255,255); + // apply part of the texture + my_gl_ScreenTexApply(screen); + glDisable(GL_TEXTURE_2D); + + // master bright (bis) + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glColor4f(bright_color,bright_color,bright_color,bright_alpha); + glBegin(GL_QUADS); + glVertex2d(-1.0, 1.0); + glVertex2d( 1.0, 1.0); + glVertex2d( 1.0,-1.0); + glVertex2d(-1.0,-1.0); + glEnd(); + glDisable(GL_BLEND); + + my_gl_End(viewportscreen); + return TRUE; +} + +#endif /* if GTKGLEXT_AVAILABLE */ diff --git a/desmume/src/gtk-glade/gdk_gl.h b/src/gtk-glade/gdk_gl.h old mode 100755 new mode 100644 similarity index 96% rename from desmume/src/gtk-glade/gdk_gl.h rename to src/gtk-glade/gdk_gl.h index b88aef93c..a086af566 --- a/desmume/src/gtk-glade/gdk_gl.h +++ b/src/gtk-glade/gdk_gl.h @@ -1,48 +1,48 @@ -/* gdk_gl.h - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GDKGL_H__ -#define __GDKGL_H__ - -#include "globals.h" - -#ifdef GTKGLEXT_AVAILABLE - #include - #include - #include - #include -#endif - - -BOOL my_gl_Begin (int screen); -void my_gl_End (int screen); -void my_gl_Clear(int screen); -void my_gl_DrawBeautifulQuad( void); -void my_gl_Identity( void); - -void init_GL_capabilities( int use_software_convert); -void init_GL(GtkWidget * widget, int screen, int share_num); -int init_GL_free_s(GtkWidget * widget, int share_num); -int init_GL_free(GtkWidget * widget); -void reshape (GtkWidget * widget, int screen); -gboolean screen (GtkWidget * widget, int off); - -#endif +/* gdk_gl.h - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GDKGL_H__ +#define __GDKGL_H__ + +#include "globals.h" + +#ifdef GTKGLEXT_AVAILABLE + #include + #include + #include + #include +#endif + + +BOOL my_gl_Begin (int screen); +void my_gl_End (int screen); +void my_gl_Clear(int screen); +void my_gl_DrawBeautifulQuad( void); +void my_gl_Identity( void); + +void init_GL_capabilities( int use_software_convert); +void init_GL(GtkWidget * widget, int screen, int share_num); +int init_GL_free_s(GtkWidget * widget, int share_num); +int init_GL_free(GtkWidget * widget); +void reshape (GtkWidget * widget, int screen); +gboolean screen (GtkWidget * widget, int off); + +#endif diff --git a/desmume/src/gtk-glade/glade-xml.cpp b/src/gtk-glade/glade-xml.cpp old mode 100755 new mode 100644 similarity index 97% rename from desmume/src/gtk-glade/glade-xml.cpp rename to src/gtk-glade/glade-xml.cpp index c884fb041..b808cb944 --- a/desmume/src/gtk-glade/glade-xml.cpp +++ b/src/gtk-glade/glade-xml.cpp @@ -1,129 +1,129 @@ -/* -*- Mode: C; c-basic-offset: 4 -*- - * libglade - a library for building interfaces from XML files at runtime - * Copyright (C) 1998-2002 James Henstridge - * - * glade-xml.c: implementation of core public interface functions - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "globals.h" -#include -#include -#include -#include - -typedef struct _GladeXMLPrivate nopriv_GladeXMLPrivate; -struct _GladeXMLPrivate { - GladeInterface *tree; /* the tree for this GladeXML */ - GtkTooltips *tooltips; /* if not NULL, holds all tooltip info */ - GHashTable *name_hash; - GHashTable *signals; - GtkWindow *toplevel; - GtkAccelGroup *accel_group; - GtkWidget *focus_widget; - GtkWidget *default_widget; - GList *deferred_props; -}; - -typedef struct _GladeSignalData GladeSignalData; - -struct _GladeSignalData { - GObject *signal_object; - char *signal_name; - char *connect_object; /* or NULL if there is none */ - gboolean signal_after; -}; - -static void -autoconnect_foreach_StringObject(const char *signal_handler, - GList * signals, GModule * allsymbols) -{ - GCallback func; - - if (!g_module_symbol(allsymbols, signal_handler, (void **) &func)) - g_warning(_("could not find signal handler '%s'."), - signal_handler); - else - for (; signals != NULL; signals = signals->next) { - GladeSignalData *data = (GladeSignalData *) signals->data; - if (data->connect_object) { - GladeXML *self = - glade_get_widget_tree(GTK_WIDGET(data->signal_object)); - char format[] = "%_\0\0"; - if (sscanf(data->connect_object, "%%%c:", &format[1])) { - - // this should solve 64bit problems but now memory gets - // (it should get) deallocated when program is destroyed - gpointer argument = g_malloc(sizeof(callback_arg)); - sscanf(data->connect_object + 3, format, argument); - -// printf ("%f \n",obj); - if (data->signal_after) - g_signal_connect_after(data->signal_object, data->signal_name, func, argument); - else - g_signal_connect(data->signal_object, data->signal_name, func, argument); - } else { - - GObject *other = (GObject *) g_hash_table_lookup( - self->priv->name_hash, - data->connect_object); - g_signal_connect_object(data->signal_object, data->signal_name, func, other, - (GConnectFlags) ((data->signal_after ? G_CONNECT_AFTER : 0) | G_CONNECT_SWAPPED)); - } - - } else { - - /* the signal_data argument is just a string, but may - * be helpful for someone */ - if (data->signal_after) - g_signal_connect_after(data->signal_object, data->signal_name, func, NULL); - else - g_signal_connect(data->signal_object, data->signal_name, func, NULL); - } - } -} - -/** - * glade_xml_signal_autoconnect_StringObject: - * @self: the GladeXML object. - * - * This function is a variation of glade_xml_signal_connect. It uses - * gmodule's introspective features (by openning the module %NULL) to - * look at the application's symbol table. From here it tries to match - * the signal handler names given in the interface description with - * symbols in the application and connects the signals. - * - * Note that this function will not work correctly if gmodule is not - * supported on the platform. - */ - -void glade_xml_signal_autoconnect_StringObject(GladeXML * self) -{ - GModule *allsymbols; - nopriv_GladeXMLPrivate *priv; - - g_return_if_fail(self != NULL); - if (!g_module_supported()) - g_error("glade_xml_signal_autoconnect requires working gmodule"); - - /* get a handle on the main executable -- use this to find symbols */ - allsymbols = g_module_open(NULL, (GModuleFlags) 0); - priv = (nopriv_GladeXMLPrivate *) self->priv; - g_hash_table_foreach(priv->signals, - (GHFunc) autoconnect_foreach_StringObject, - allsymbols); -} +/* -*- Mode: C; c-basic-offset: 4 -*- + * libglade - a library for building interfaces from XML files at runtime + * Copyright (C) 1998-2002 James Henstridge + * + * glade-xml.c: implementation of core public interface functions + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "globals.h" +#include +#include +#include +#include + +typedef struct _GladeXMLPrivate nopriv_GladeXMLPrivate; +struct _GladeXMLPrivate { + GladeInterface *tree; /* the tree for this GladeXML */ + GtkTooltips *tooltips; /* if not NULL, holds all tooltip info */ + GHashTable *name_hash; + GHashTable *signals; + GtkWindow *toplevel; + GtkAccelGroup *accel_group; + GtkWidget *focus_widget; + GtkWidget *default_widget; + GList *deferred_props; +}; + +typedef struct _GladeSignalData GladeSignalData; + +struct _GladeSignalData { + GObject *signal_object; + char *signal_name; + char *connect_object; /* or NULL if there is none */ + gboolean signal_after; +}; + +static void +autoconnect_foreach_StringObject(const char *signal_handler, + GList * signals, GModule * allsymbols) +{ + GCallback func; + + if (!g_module_symbol(allsymbols, signal_handler, (void **) &func)) + g_warning(_("could not find signal handler '%s'."), + signal_handler); + else + for (; signals != NULL; signals = signals->next) { + GladeSignalData *data = (GladeSignalData *) signals->data; + if (data->connect_object) { + GladeXML *self = + glade_get_widget_tree(GTK_WIDGET(data->signal_object)); + char format[] = "%_\0\0"; + if (sscanf(data->connect_object, "%%%c:", &format[1])) { + + // this should solve 64bit problems but now memory gets + // (it should get) deallocated when program is destroyed + gpointer argument = g_malloc(sizeof(callback_arg)); + sscanf(data->connect_object + 3, format, argument); + +// printf ("%f \n",obj); + if (data->signal_after) + g_signal_connect_after(data->signal_object, data->signal_name, func, argument); + else + g_signal_connect(data->signal_object, data->signal_name, func, argument); + } else { + + GObject *other = (GObject *) g_hash_table_lookup( + self->priv->name_hash, + data->connect_object); + g_signal_connect_object(data->signal_object, data->signal_name, func, other, + (GConnectFlags) ((data->signal_after ? G_CONNECT_AFTER : 0) | G_CONNECT_SWAPPED)); + } + + } else { + + /* the signal_data argument is just a string, but may + * be helpful for someone */ + if (data->signal_after) + g_signal_connect_after(data->signal_object, data->signal_name, func, NULL); + else + g_signal_connect(data->signal_object, data->signal_name, func, NULL); + } + } +} + +/** + * glade_xml_signal_autoconnect_StringObject: + * @self: the GladeXML object. + * + * This function is a variation of glade_xml_signal_connect. It uses + * gmodule's introspective features (by openning the module %NULL) to + * look at the application's symbol table. From here it tries to match + * the signal handler names given in the interface description with + * symbols in the application and connects the signals. + * + * Note that this function will not work correctly if gmodule is not + * supported on the platform. + */ + +void glade_xml_signal_autoconnect_StringObject(GladeXML * self) +{ + GModule *allsymbols; + nopriv_GladeXMLPrivate *priv; + + g_return_if_fail(self != NULL); + if (!g_module_supported()) + g_error("glade_xml_signal_autoconnect requires working gmodule"); + + /* get a handle on the main executable -- use this to find symbols */ + allsymbols = g_module_open(NULL, (GModuleFlags) 0); + priv = (nopriv_GladeXMLPrivate *) self->priv; + g_hash_table_foreach(priv->signals, + (GHFunc) autoconnect_foreach_StringObject, + allsymbols); +} diff --git a/desmume/src/gtk-glade/glade/DeSmuME.xpm b/src/gtk-glade/glade/DeSmuME.xpm old mode 100755 new mode 100644 similarity index 100% rename from desmume/src/gtk-glade/glade/DeSmuME.xpm rename to src/gtk-glade/glade/DeSmuME.xpm diff --git a/desmume/src/gtk-glade/glade/DeSmuMe.glade b/src/gtk-glade/glade/DeSmuMe.glade old mode 100755 new mode 100644 similarity index 100% rename from desmume/src/gtk-glade/glade/DeSmuMe.glade rename to src/gtk-glade/glade/DeSmuMe.glade diff --git a/desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade b/src/gtk-glade/glade/DeSmuMe_Dtools.glade old mode 100755 new mode 100644 similarity index 100% rename from desmume/src/gtk-glade/glade/DeSmuMe_Dtools.glade rename to src/gtk-glade/glade/DeSmuMe_Dtools.glade diff --git a/desmume/src/gtk-glade/globals.h b/src/gtk-glade/globals.h old mode 100755 new mode 100644 similarity index 95% rename from desmume/src/gtk-glade/globals.h rename to src/gtk-glade/globals.h index fe6d3f7cd..087adadc7 --- a/desmume/src/gtk-glade/globals.h +++ b/src/gtk-glade/globals.h @@ -1,130 +1,130 @@ -/* globals.h - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GLOBALS_H__ -#define __GLOBALS_H__ - -#ifndef GTK_UI -#define GTK_UI -#endif - -#include -#include -#include -#include - -// Localization -#include -#define _(String) gettext (String) - -#include "SDL.h" - -// fix gtk-glade on windows with no configure -#ifndef DATADIR -#define DATADIR " " -#endif -#ifndef GLADEUI_UNINSTALLED_DIR -#define GLADEUI_UNINSTALLED_DIR "glade/" -#endif - -#include -#include -#include -#include - - -typedef union _callback_arg{ - gpointer my_pointer; - gconstpointer my_constpointer; - - gfloat my_float; - gdouble my_double; - gsize my_size; - gssize my_ssize; - - gboolean my_boolean; - - guchar my_uchar; - guint my_uint; - guint8 my_uint8; - guint16 my_uint16; - guint32 my_uint32; - guint64 my_uint64; - gushort my_ushort; - gulong my_ulong; - - gchar my_char; - gint my_int; - gint8 my_int8; - gint16 my_int16; - gint32 my_int32; - gint64 my_int64; - gshort my_short; - glong my_long; -} callback_arg; -#define dyn_CAST(gtype,var) (((callback_arg*)var)->my_##gtype) - -#include "../MMU.h" -#include "../registers.h" -#include "../armcpu.h" -#include "../NDSSystem.h" -#include "../sndsdl.h" -#include "../ctrlssdl.h" -#include "../types.h" -#include "../saves.h" -#include "../render3D.h" -#include "desmume.h" - -// autoconnect with strings as user_data - -void -glade_xml_signal_autoconnect_StringObject (GladeXML *self); - -//--- - -extern int Frameskip; - -/* main.cpp */ -extern GtkWidget * pWindow; -extern GtkWidget * pDrawingArea, * pDrawingArea2; -extern GladeXML * xml, * xml_tools; - -typedef void (*VoidFunPtr)(); -void notify_Tools(); -void register_Tool(VoidFunPtr fun); -void unregister_Tool(VoidFunPtr fun); -gchar * get_ui_file (const char *filename); - -/* callbacks.cpp */ -void enable_rom_features(); -void resize (float Size1, float Size2); -void rotate(float angle); -extern gboolean ScreenInvert; - -/* callbacks_IO.cpp */ -extern float ScreenCoeff_Size[2]; -extern float ScreenRotate; - -void black_screen (); -void edit_controls(); -void init_joy_labels(); - -#endif /* __GLOBALS_H__ */ +/* globals.h - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GLOBALS_H__ +#define __GLOBALS_H__ + +#ifndef GTK_UI +#define GTK_UI +#endif + +#include +#include +#include +#include + +// Localization +#include +#define _(String) gettext (String) + +#include "SDL.h" + +// fix gtk-glade on windows with no configure +#ifndef DATADIR +#define DATADIR " " +#endif +#ifndef GLADEUI_UNINSTALLED_DIR +#define GLADEUI_UNINSTALLED_DIR "glade/" +#endif + +#include +#include +#include +#include + + +typedef union _callback_arg{ + gpointer my_pointer; + gconstpointer my_constpointer; + + gfloat my_float; + gdouble my_double; + gsize my_size; + gssize my_ssize; + + gboolean my_boolean; + + guchar my_uchar; + guint my_uint; + guint8 my_uint8; + guint16 my_uint16; + guint32 my_uint32; + guint64 my_uint64; + gushort my_ushort; + gulong my_ulong; + + gchar my_char; + gint my_int; + gint8 my_int8; + gint16 my_int16; + gint32 my_int32; + gint64 my_int64; + gshort my_short; + glong my_long; +} callback_arg; +#define dyn_CAST(gtype,var) (((callback_arg*)var)->my_##gtype) + +#include "../MMU.h" +#include "../registers.h" +#include "../armcpu.h" +#include "../NDSSystem.h" +#include "../sndsdl.h" +#include "../ctrlssdl.h" +#include "../types.h" +#include "../saves.h" +#include "../render3D.h" +#include "desmume.h" + +// autoconnect with strings as user_data + +void +glade_xml_signal_autoconnect_StringObject (GladeXML *self); + +//--- + +extern int Frameskip; + +/* main.cpp */ +extern GtkWidget * pWindow; +extern GtkWidget * pDrawingArea, * pDrawingArea2; +extern GladeXML * xml, * xml_tools; + +typedef void (*VoidFunPtr)(); +void notify_Tools(); +void register_Tool(VoidFunPtr fun); +void unregister_Tool(VoidFunPtr fun); +gchar * get_ui_file (const char *filename); + +/* callbacks.cpp */ +void enable_rom_features(); +void resize (float Size1, float Size2); +void rotate(float angle); +extern gboolean ScreenInvert; + +/* callbacks_IO.cpp */ +extern float ScreenCoeff_Size[2]; +extern float ScreenRotate; + +void black_screen (); +void edit_controls(); +void init_joy_labels(); + +#endif /* __GLOBALS_H__ */ diff --git a/desmume/src/gtk-glade/keyval_names.cpp b/src/gtk-glade/keyval_names.cpp old mode 100755 new mode 100644 similarity index 97% rename from desmume/src/gtk-glade/keyval_names.cpp rename to src/gtk-glade/keyval_names.cpp index 65c94f12e..e15ed42e1 --- a/desmume/src/gtk-glade/keyval_names.cpp +++ b/src/gtk-glade/keyval_names.cpp @@ -1,1384 +1,1384 @@ -/* keyval_names.cpp - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "keyval_names.h" -/* see */ - -const char * unknown="(unknown)"; -const char * KEYVAL_NAMES[0x10000]; - -const char * KEYNAME(int k) { - const char * s = unknown; - s = KEYVAL_NAMES[k & 0xFFFF]; - return s; -} - -static void KEYVAL(int k, const char * name) { - if (KEYVAL_NAMES[k] == unknown) - KEYVAL_NAMES[k] = name; -} - -void init_keyvals() { - int i; - for (i=0; i<0x10000; i++) - KEYVAL_NAMES[i]=unknown; - - KEYVAL ( 0x0020 , "space" ); - KEYVAL ( 0x0021 , "exclam" ); - KEYVAL ( 0x0022 , "quotedbl" ); - KEYVAL ( 0x0023 , "numbersign" ); - KEYVAL ( 0x0024 , "dollar" ); - KEYVAL ( 0x0025 , "percent" ); - KEYVAL ( 0x0026 , "ampersand" ); - KEYVAL ( 0x0027 , "apostrophe" ); - KEYVAL ( 0x0027 , "quoteright" ); - KEYVAL ( 0x0028 , "parenleft" ); - KEYVAL ( 0x0029 , "parenright" ); - KEYVAL ( 0x002a , "asterisk" ); - KEYVAL ( 0x002b , "plus" ); - KEYVAL ( 0x002c , "comma" ); - KEYVAL ( 0x002d , "minus" ); - KEYVAL ( 0x002e , "period" ); - KEYVAL ( 0x002f , "slash" ); - KEYVAL ( 0x0030 , "0" ); - KEYVAL ( 0x0031 , "1" ); - KEYVAL ( 0x0032 , "2" ); - KEYVAL ( 0x0033 , "3" ); - KEYVAL ( 0x0034 , "4" ); - KEYVAL ( 0x0035 , "5" ); - KEYVAL ( 0x0036 , "6" ); - KEYVAL ( 0x0037 , "7" ); - KEYVAL ( 0x0038 , "8" ); - KEYVAL ( 0x0039 , "9" ); - KEYVAL ( 0x003a , "colon" ); - KEYVAL ( 0x003b , "semicolon" ); - KEYVAL ( 0x003c , "less" ); - KEYVAL ( 0x003d , "equal" ); - KEYVAL ( 0x003e , "greater" ); - KEYVAL ( 0x003f , "question" ); - KEYVAL ( 0x0040 , "at" ); - KEYVAL ( 0x0041 , "A" ); - KEYVAL ( 0x0042 , "B" ); - KEYVAL ( 0x0043 , "C" ); - KEYVAL ( 0x0044 , "D" ); - KEYVAL ( 0x0045 , "E" ); - KEYVAL ( 0x0046 , "F" ); - KEYVAL ( 0x0047 , "G" ); - KEYVAL ( 0x0048 , "H" ); - KEYVAL ( 0x0049 , "I" ); - KEYVAL ( 0x004a , "J" ); - KEYVAL ( 0x004b , "K" ); - KEYVAL ( 0x004c , "L" ); - KEYVAL ( 0x004d , "M" ); - KEYVAL ( 0x004e , "N" ); - KEYVAL ( 0x004f , "O" ); - KEYVAL ( 0x0050 , "P" ); - KEYVAL ( 0x0051 , "Q" ); - KEYVAL ( 0x0052 , "R" ); - KEYVAL ( 0x0053 , "S" ); - KEYVAL ( 0x0054 , "T" ); - KEYVAL ( 0x0055 , "U" ); - KEYVAL ( 0x0056 , "V" ); - KEYVAL ( 0x0057 , "W" ); - KEYVAL ( 0x0058 , "X" ); - KEYVAL ( 0x0059 , "Y" ); - KEYVAL ( 0x005a , "Z" ); - KEYVAL ( 0x005b , "bracketleft" ); - KEYVAL ( 0x005c , "backslash" ); - KEYVAL ( 0x005d , "bracketright" ); - KEYVAL ( 0x005e , "asciicircum" ); - KEYVAL ( 0x005f , "underscore" ); - KEYVAL ( 0x0060 , "grave" ); - KEYVAL ( 0x0060 , "quoteleft" ); - KEYVAL ( 0x0061 , "a" ); - KEYVAL ( 0x0062 , "b" ); - KEYVAL ( 0x0063 , "c" ); - KEYVAL ( 0x0064 , "d" ); - KEYVAL ( 0x0065 , "e" ); - KEYVAL ( 0x0066 , "f" ); - KEYVAL ( 0x0067 , "g" ); - KEYVAL ( 0x0068 , "h" ); - KEYVAL ( 0x0069 , "i" ); - KEYVAL ( 0x006a , "j" ); - KEYVAL ( 0x006b , "k" ); - KEYVAL ( 0x006c , "l" ); - KEYVAL ( 0x006d , "m" ); - KEYVAL ( 0x006e , "n" ); - KEYVAL ( 0x006f , "o" ); - KEYVAL ( 0x0070 , "p" ); - KEYVAL ( 0x0071 , "q" ); - KEYVAL ( 0x0072 , "r" ); - KEYVAL ( 0x0073 , "s" ); - KEYVAL ( 0x0074 , "t" ); - KEYVAL ( 0x0075 , "u" ); - KEYVAL ( 0x0076 , "v" ); - KEYVAL ( 0x0077 , "w" ); - KEYVAL ( 0x0078 , "x" ); - KEYVAL ( 0x0079 , "y" ); - KEYVAL ( 0x007a , "z" ); - KEYVAL ( 0x007b , "braceleft" ); - KEYVAL ( 0x007c , "bar" ); - KEYVAL ( 0x007d , "braceright" ); - KEYVAL ( 0x007e , "asciitilde" ); - KEYVAL ( 0x00a0 , "nobreakspace" ); - KEYVAL ( 0x00a1 , "exclamdown" ); - KEYVAL ( 0x00a2 , "cent" ); - KEYVAL ( 0x00a3 , "sterling" ); - KEYVAL ( 0x00a4 , "currency" ); - KEYVAL ( 0x00a5 , "yen" ); - KEYVAL ( 0x00a6 , "brokenbar" ); - KEYVAL ( 0x00a7 , "section" ); - KEYVAL ( 0x00a8 , "diaeresis" ); - KEYVAL ( 0x00a9 , "copyright" ); - KEYVAL ( 0x00aa , "ordfeminine" ); - KEYVAL ( 0x00ab , "guillemotleft" ); - KEYVAL ( 0x00ac , "notsign" ); - KEYVAL ( 0x00ad , "hyphen" ); - KEYVAL ( 0x00ae , "registered" ); - KEYVAL ( 0x00af , "macron" ); - KEYVAL ( 0x00b0 , "degree" ); - KEYVAL ( 0x00b1 , "plusminus" ); - KEYVAL ( 0x00b2 , "twosuperior" ); - KEYVAL ( 0x00b3 , "threesuperior" ); - KEYVAL ( 0x00b4 , "acute" ); - KEYVAL ( 0x00b5 , "mu" ); - KEYVAL ( 0x00b6 , "paragraph" ); - KEYVAL ( 0x00b7 , "periodcentered" ); - KEYVAL ( 0x00b8 , "cedilla" ); - KEYVAL ( 0x00b9 , "onesuperior" ); - KEYVAL ( 0x00ba , "masculine" ); - KEYVAL ( 0x00bb , "guillemotright" ); - KEYVAL ( 0x00bc , "onequarter" ); - KEYVAL ( 0x00bd , "onehalf" ); - KEYVAL ( 0x00be , "threequarters" ); - KEYVAL ( 0x00bf , "questiondown" ); - KEYVAL ( 0x00c0 , "Agrave" ); - KEYVAL ( 0x00c1 , "Aacute" ); - KEYVAL ( 0x00c2 , "Acircumflex" ); - KEYVAL ( 0x00c3 , "Atilde" ); - KEYVAL ( 0x00c4 , "Adiaeresis" ); - KEYVAL ( 0x00c5 , "Aring" ); - KEYVAL ( 0x00c6 , "AE" ); - KEYVAL ( 0x00c7 , "Ccedilla" ); - KEYVAL ( 0x00c8 , "Egrave" ); - KEYVAL ( 0x00c9 , "Eacute" ); - KEYVAL ( 0x00ca , "Ecircumflex" ); - KEYVAL ( 0x00cb , "Ediaeresis" ); - KEYVAL ( 0x00cc , "Igrave" ); - KEYVAL ( 0x00cd , "Iacute" ); - KEYVAL ( 0x00ce , "Icircumflex" ); - KEYVAL ( 0x00cf , "Idiaeresis" ); - KEYVAL ( 0x00d0 , "ETH" ); - KEYVAL ( 0x00d0 , "Eth" ); - KEYVAL ( 0x00d1 , "Ntilde" ); - KEYVAL ( 0x00d2 , "Ograve" ); - KEYVAL ( 0x00d3 , "Oacute" ); - KEYVAL ( 0x00d4 , "Ocircumflex" ); - KEYVAL ( 0x00d5 , "Otilde" ); - KEYVAL ( 0x00d6 , "Odiaeresis" ); - KEYVAL ( 0x00d7 , "multiply" ); - KEYVAL ( 0x00d8 , "Ooblique" ); - KEYVAL ( 0x00d9 , "Ugrave" ); - KEYVAL ( 0x00da , "Uacute" ); - KEYVAL ( 0x00db , "Ucircumflex" ); - KEYVAL ( 0x00dc , "Udiaeresis" ); - KEYVAL ( 0x00dd , "Yacute" ); - KEYVAL ( 0x00de , "THORN" ); - KEYVAL ( 0x00de , "Thorn" ); - KEYVAL ( 0x00df , "ssharp" ); - KEYVAL ( 0x00e0 , "agrave" ); - KEYVAL ( 0x00e1 , "aacute" ); - KEYVAL ( 0x00e2 , "acircumflex" ); - KEYVAL ( 0x00e3 , "atilde" ); - KEYVAL ( 0x00e4 , "adiaeresis" ); - KEYVAL ( 0x00e5 , "aring" ); - KEYVAL ( 0x00e6 , "ae" ); - KEYVAL ( 0x00e7 , "ccedilla" ); - KEYVAL ( 0x00e8 , "egrave" ); - KEYVAL ( 0x00e9 , "eacute" ); - KEYVAL ( 0x00ea , "ecircumflex" ); - KEYVAL ( 0x00eb , "ediaeresis" ); - KEYVAL ( 0x00ec , "igrave" ); - KEYVAL ( 0x00ed , "iacute" ); - KEYVAL ( 0x00ee , "icircumflex" ); - KEYVAL ( 0x00ef , "idiaeresis" ); - KEYVAL ( 0x00f0 , "eth" ); - KEYVAL ( 0x00f1 , "ntilde" ); - KEYVAL ( 0x00f2 , "ograve" ); - KEYVAL ( 0x00f3 , "oacute" ); - KEYVAL ( 0x00f4 , "ocircumflex" ); - KEYVAL ( 0x00f5 , "otilde" ); - KEYVAL ( 0x00f6 , "odiaeresis" ); - KEYVAL ( 0x00f7 , "division" ); - KEYVAL ( 0x00f8 , "oslash" ); - KEYVAL ( 0x00f9 , "ugrave" ); - KEYVAL ( 0x00fa , "uacute" ); - KEYVAL ( 0x00fb , "ucircumflex" ); - KEYVAL ( 0x00fc , "udiaeresis" ); - KEYVAL ( 0x00fd , "yacute" ); - KEYVAL ( 0x00fe , "thorn" ); - KEYVAL ( 0x00ff , "ydiaeresis" ); - KEYVAL ( 0x01a1 , "Aogonek" ); - KEYVAL ( 0x01a2 , "breve" ); - KEYVAL ( 0x01a3 , "Lstroke" ); - KEYVAL ( 0x01a5 , "Lcaron" ); - KEYVAL ( 0x01a6 , "Sacute" ); - KEYVAL ( 0x01a9 , "Scaron" ); - KEYVAL ( 0x01aa , "Scedilla" ); - KEYVAL ( 0x01ab , "Tcaron" ); - KEYVAL ( 0x01ac , "Zacute" ); - KEYVAL ( 0x01ae , "Zcaron" ); - KEYVAL ( 0x01af , "Zabovedot" ); - KEYVAL ( 0x01b1 , "aogonek" ); - KEYVAL ( 0x01b2 , "ogonek" ); - KEYVAL ( 0x01b3 , "lstroke" ); - KEYVAL ( 0x01b5 , "lcaron" ); - KEYVAL ( 0x01b6 , "sacute" ); - KEYVAL ( 0x01b7 , "caron" ); - KEYVAL ( 0x01b9 , "scaron" ); - KEYVAL ( 0x01ba , "scedilla" ); - KEYVAL ( 0x01bb , "tcaron" ); - KEYVAL ( 0x01bc , "zacute" ); - KEYVAL ( 0x01bd , "doubleacute" ); - KEYVAL ( 0x01be , "zcaron" ); - KEYVAL ( 0x01bf , "zabovedot" ); - KEYVAL ( 0x01c0 , "Racute" ); - KEYVAL ( 0x01c3 , "Abreve" ); - KEYVAL ( 0x01c5 , "Lacute" ); - KEYVAL ( 0x01c6 , "Cacute" ); - KEYVAL ( 0x01c8 , "Ccaron" ); - KEYVAL ( 0x01ca , "Eogonek" ); - KEYVAL ( 0x01cc , "Ecaron" ); - KEYVAL ( 0x01cf , "Dcaron" ); - KEYVAL ( 0x01d0 , "Dstroke" ); - KEYVAL ( 0x01d1 , "Nacute" ); - KEYVAL ( 0x01d2 , "Ncaron" ); - KEYVAL ( 0x01d5 , "Odoubleacute" ); - KEYVAL ( 0x01d8 , "Rcaron" ); - KEYVAL ( 0x01d9 , "Uring" ); - KEYVAL ( 0x01db , "Udoubleacute" ); - KEYVAL ( 0x01de , "Tcedilla" ); - KEYVAL ( 0x01e0 , "racute" ); - KEYVAL ( 0x01e3 , "abreve" ); - KEYVAL ( 0x01e5 , "lacute" ); - KEYVAL ( 0x01e6 , "cacute" ); - KEYVAL ( 0x01e8 , "ccaron" ); - KEYVAL ( 0x01ea , "eogonek" ); - KEYVAL ( 0x01ec , "ecaron" ); - KEYVAL ( 0x01ef , "dcaron" ); - KEYVAL ( 0x01f0 , "dstroke" ); - KEYVAL ( 0x01f1 , "nacute" ); - KEYVAL ( 0x01f2 , "ncaron" ); - KEYVAL ( 0x01f5 , "odoubleacute" ); - KEYVAL ( 0x01f8 , "rcaron" ); - KEYVAL ( 0x01f9 , "uring" ); - KEYVAL ( 0x01fb , "udoubleacute" ); - KEYVAL ( 0x01fe , "tcedilla" ); - KEYVAL ( 0x01ff , "abovedot" ); - KEYVAL ( 0x02a1 , "Hstroke" ); - KEYVAL ( 0x02a6 , "Hcircumflex" ); - KEYVAL ( 0x02a9 , "Iabovedot" ); - KEYVAL ( 0x02ab , "Gbreve" ); - KEYVAL ( 0x02ac , "Jcircumflex" ); - KEYVAL ( 0x02b1 , "hstroke" ); - KEYVAL ( 0x02b6 , "hcircumflex" ); - KEYVAL ( 0x02b9 , "idotless" ); - KEYVAL ( 0x02bb , "gbreve" ); - KEYVAL ( 0x02bc , "jcircumflex" ); - KEYVAL ( 0x02c5 , "Cabovedot" ); - KEYVAL ( 0x02c6 , "Ccircumflex" ); - KEYVAL ( 0x02d5 , "Gabovedot" ); - KEYVAL ( 0x02d8 , "Gcircumflex" ); - KEYVAL ( 0x02dd , "Ubreve" ); - KEYVAL ( 0x02de , "Scircumflex" ); - KEYVAL ( 0x02e5 , "cabovedot" ); - KEYVAL ( 0x02e6 , "ccircumflex" ); - KEYVAL ( 0x02f5 , "gabovedot" ); - KEYVAL ( 0x02f8 , "gcircumflex" ); - KEYVAL ( 0x02fd , "ubreve" ); - KEYVAL ( 0x02fe , "scircumflex" ); - KEYVAL ( 0x03a2 , "kappa" ); - KEYVAL ( 0x03a2 , "kra" ); - KEYVAL ( 0x03a3 , "Rcedilla" ); - KEYVAL ( 0x03a5 , "Itilde" ); - KEYVAL ( 0x03a6 , "Lcedilla" ); - KEYVAL ( 0x03aa , "Emacron" ); - KEYVAL ( 0x03ab , "Gcedilla" ); - KEYVAL ( 0x03ac , "Tslash" ); - KEYVAL ( 0x03b3 , "rcedilla" ); - KEYVAL ( 0x03b5 , "itilde" ); - KEYVAL ( 0x03b6 , "lcedilla" ); - KEYVAL ( 0x03ba , "emacron" ); - KEYVAL ( 0x03bb , "gcedilla" ); - KEYVAL ( 0x03bc , "tslash" ); - KEYVAL ( 0x03bd , "ENG" ); - KEYVAL ( 0x03bf , "eng" ); - KEYVAL ( 0x03c0 , "Amacron" ); - KEYVAL ( 0x03c7 , "Iogonek" ); - KEYVAL ( 0x03cc , "Eabovedot" ); - KEYVAL ( 0x03cf , "Imacron" ); - KEYVAL ( 0x03d1 , "Ncedilla" ); - KEYVAL ( 0x03d2 , "Omacron" ); - KEYVAL ( 0x03d3 , "Kcedilla" ); - KEYVAL ( 0x03d9 , "Uogonek" ); - KEYVAL ( 0x03dd , "Utilde" ); - KEYVAL ( 0x03de , "Umacron" ); - KEYVAL ( 0x03e0 , "amacron" ); - KEYVAL ( 0x03e7 , "iogonek" ); - KEYVAL ( 0x03ec , "eabovedot" ); - KEYVAL ( 0x03ef , "imacron" ); - KEYVAL ( 0x03f1 , "ncedilla" ); - KEYVAL ( 0x03f2 , "omacron" ); - KEYVAL ( 0x03f3 , "kcedilla" ); - KEYVAL ( 0x03f9 , "uogonek" ); - KEYVAL ( 0x03fd , "utilde" ); - KEYVAL ( 0x03fe , "umacron" ); - KEYVAL ( 0x047e , "overline" ); - KEYVAL ( 0x04a1 , "kana_fullstop" ); - KEYVAL ( 0x04a2 , "kana_openingbracket" ); - KEYVAL ( 0x04a3 , "kana_closingbracket" ); - KEYVAL ( 0x04a4 , "kana_comma" ); - KEYVAL ( 0x04a5 , "kana_conjunctive" ); - KEYVAL ( 0x04a5 , "kana_middledot" ); - KEYVAL ( 0x04a6 , "kana_WO" ); - KEYVAL ( 0x04a7 , "kana_a" ); - KEYVAL ( 0x04a8 , "kana_i" ); - KEYVAL ( 0x04a9 , "kana_u" ); - KEYVAL ( 0x04aa , "kana_e" ); - KEYVAL ( 0x04ab , "kana_o" ); - KEYVAL ( 0x04ac , "kana_ya" ); - KEYVAL ( 0x04ad , "kana_yu" ); - KEYVAL ( 0x04ae , "kana_yo" ); - KEYVAL ( 0x04af , "kana_tsu" ); - KEYVAL ( 0x04af , "kana_tu" ); - KEYVAL ( 0x04b0 , "prolongedsound" ); - KEYVAL ( 0x04b1 , "kana_A" ); - KEYVAL ( 0x04b2 , "kana_I" ); - KEYVAL ( 0x04b3 , "kana_U" ); - KEYVAL ( 0x04b4 , "kana_E" ); - KEYVAL ( 0x04b5 , "kana_O" ); - KEYVAL ( 0x04b6 , "kana_KA" ); - KEYVAL ( 0x04b7 , "kana_KI" ); - KEYVAL ( 0x04b8 , "kana_KU" ); - KEYVAL ( 0x04b9 , "kana_KE" ); - KEYVAL ( 0x04ba , "kana_KO" ); - KEYVAL ( 0x04bb , "kana_SA" ); - KEYVAL ( 0x04bc , "kana_SHI" ); - KEYVAL ( 0x04bd , "kana_SU" ); - KEYVAL ( 0x04be , "kana_SE" ); - KEYVAL ( 0x04bf , "kana_SO" ); - KEYVAL ( 0x04c0 , "kana_TA" ); - KEYVAL ( 0x04c1 , "kana_CHI" ); - KEYVAL ( 0x04c1 , "kana_TI" ); - KEYVAL ( 0x04c2 , "kana_TSU" ); - KEYVAL ( 0x04c2 , "kana_TU" ); - KEYVAL ( 0x04c3 , "kana_TE" ); - KEYVAL ( 0x04c4 , "kana_TO" ); - KEYVAL ( 0x04c5 , "kana_NA" ); - KEYVAL ( 0x04c6 , "kana_NI" ); - KEYVAL ( 0x04c7 , "kana_NU" ); - KEYVAL ( 0x04c8 , "kana_NE" ); - KEYVAL ( 0x04c9 , "kana_NO" ); - KEYVAL ( 0x04ca , "kana_HA" ); - KEYVAL ( 0x04cb , "kana_HI" ); - KEYVAL ( 0x04cc , "kana_FU" ); - KEYVAL ( 0x04cc , "kana_HU" ); - KEYVAL ( 0x04cd , "kana_HE" ); - KEYVAL ( 0x04ce , "kana_HO" ); - KEYVAL ( 0x04cf , "kana_MA" ); - KEYVAL ( 0x04d0 , "kana_MI" ); - KEYVAL ( 0x04d1 , "kana_MU" ); - KEYVAL ( 0x04d2 , "kana_ME" ); - KEYVAL ( 0x04d3 , "kana_MO" ); - KEYVAL ( 0x04d4 , "kana_YA" ); - KEYVAL ( 0x04d5 , "kana_YU" ); - KEYVAL ( 0x04d6 , "kana_YO" ); - KEYVAL ( 0x04d7 , "kana_RA" ); - KEYVAL ( 0x04d8 , "kana_RI" ); - KEYVAL ( 0x04d9 , "kana_RU" ); - KEYVAL ( 0x04da , "kana_RE" ); - KEYVAL ( 0x04db , "kana_RO" ); - KEYVAL ( 0x04dc , "kana_WA" ); - KEYVAL ( 0x04dd , "kana_N" ); - KEYVAL ( 0x04de , "voicedsound" ); - KEYVAL ( 0x04df , "semivoicedsound" ); - KEYVAL ( 0x05ac , "Arabic_comma" ); - KEYVAL ( 0x05bb , "Arabic_semicolon" ); - KEYVAL ( 0x05bf , "Arabic_question_mark" ); - KEYVAL ( 0x05c1 , "Arabic_hamza" ); - KEYVAL ( 0x05c2 , "Arabic_maddaonalef" ); - KEYVAL ( 0x05c3 , "Arabic_hamzaonalef" ); - KEYVAL ( 0x05c4 , "Arabic_hamzaonwaw" ); - KEYVAL ( 0x05c5 , "Arabic_hamzaunderalef" ); - KEYVAL ( 0x05c6 , "Arabic_hamzaonyeh" ); - KEYVAL ( 0x05c7 , "Arabic_alef" ); - KEYVAL ( 0x05c8 , "Arabic_beh" ); - KEYVAL ( 0x05c9 , "Arabic_tehmarbuta" ); - KEYVAL ( 0x05ca , "Arabic_teh" ); - KEYVAL ( 0x05cb , "Arabic_theh" ); - KEYVAL ( 0x05cc , "Arabic_jeem" ); - KEYVAL ( 0x05cd , "Arabic_hah" ); - KEYVAL ( 0x05ce , "Arabic_khah" ); - KEYVAL ( 0x05cf , "Arabic_dal" ); - KEYVAL ( 0x05d0 , "Arabic_thal" ); - KEYVAL ( 0x05d1 , "Arabic_ra" ); - KEYVAL ( 0x05d2 , "Arabic_zain" ); - KEYVAL ( 0x05d3 , "Arabic_seen" ); - KEYVAL ( 0x05d4 , "Arabic_sheen" ); - KEYVAL ( 0x05d5 , "Arabic_sad" ); - KEYVAL ( 0x05d6 , "Arabic_dad" ); - KEYVAL ( 0x05d7 , "Arabic_tah" ); - KEYVAL ( 0x05d8 , "Arabic_zah" ); - KEYVAL ( 0x05d9 , "Arabic_ain" ); - KEYVAL ( 0x05da , "Arabic_ghain" ); - KEYVAL ( 0x05e0 , "Arabic_tatweel" ); - KEYVAL ( 0x05e1 , "Arabic_feh" ); - KEYVAL ( 0x05e2 , "Arabic_qaf" ); - KEYVAL ( 0x05e3 , "Arabic_kaf" ); - KEYVAL ( 0x05e4 , "Arabic_lam" ); - KEYVAL ( 0x05e5 , "Arabic_meem" ); - KEYVAL ( 0x05e6 , "Arabic_noon" ); - KEYVAL ( 0x05e7 , "Arabic_ha" ); - KEYVAL ( 0x05e7 , "Arabic_heh" ); - KEYVAL ( 0x05e8 , "Arabic_waw" ); - KEYVAL ( 0x05e9 , "Arabic_alefmaksura" ); - KEYVAL ( 0x05ea , "Arabic_yeh" ); - KEYVAL ( 0x05eb , "Arabic_fathatan" ); - KEYVAL ( 0x05ec , "Arabic_dammatan" ); - KEYVAL ( 0x05ed , "Arabic_kasratan" ); - KEYVAL ( 0x05ee , "Arabic_fatha" ); - KEYVAL ( 0x05ef , "Arabic_damma" ); - KEYVAL ( 0x05f0 , "Arabic_kasra" ); - KEYVAL ( 0x05f1 , "Arabic_shadda" ); - KEYVAL ( 0x05f2 , "Arabic_sukun" ); - KEYVAL ( 0x06a1 , "Serbian_dje" ); - KEYVAL ( 0x06a2 , "Macedonia_gje" ); - KEYVAL ( 0x06a3 , "Cyrillic_io" ); - KEYVAL ( 0x06a4 , "Ukrainian_ie" ); - KEYVAL ( 0x06a4 , "Ukranian_je" ); - KEYVAL ( 0x06a5 , "Macedonia_dse" ); - KEYVAL ( 0x06a6 , "Ukrainian_i" ); - KEYVAL ( 0x06a6 , "Ukranian_i" ); - KEYVAL ( 0x06a7 , "Ukrainian_yi" ); - KEYVAL ( 0x06a7 , "Ukranian_yi" ); - KEYVAL ( 0x06a8 , "Cyrillic_je" ); - KEYVAL ( 0x06a8 , "Serbian_je" ); - KEYVAL ( 0x06a9 , "Cyrillic_lje" ); - KEYVAL ( 0x06a9 , "Serbian_lje" ); - KEYVAL ( 0x06aa , "Cyrillic_nje" ); - KEYVAL ( 0x06aa , "Serbian_nje" ); - KEYVAL ( 0x06ab , "Serbian_tshe" ); - KEYVAL ( 0x06ac , "Macedonia_kje" ); - KEYVAL ( 0x06ad , "Ukrainian_ghe_with_upturn" ); - KEYVAL ( 0x06ae , "Byelorussian_shortu" ); - KEYVAL ( 0x06af , "Cyrillic_dzhe" ); - KEYVAL ( 0x06af , "Serbian_dze" ); - KEYVAL ( 0x06b0 , "numerosign" ); - KEYVAL ( 0x06b1 , "Serbian_DJE" ); - KEYVAL ( 0x06b2 , "Macedonia_GJE" ); - KEYVAL ( 0x06b3 , "Cyrillic_IO" ); - KEYVAL ( 0x06b4 , "Ukrainian_IE" ); - KEYVAL ( 0x06b4 , "Ukranian_JE" ); - KEYVAL ( 0x06b5 , "Macedonia_DSE" ); - KEYVAL ( 0x06b6 , "Ukrainian_I" ); - KEYVAL ( 0x06b6 , "Ukranian_I" ); - KEYVAL ( 0x06b7 , "Ukrainian_YI" ); - KEYVAL ( 0x06b7 , "Ukranian_YI" ); - KEYVAL ( 0x06b8 , "Cyrillic_JE" ); - KEYVAL ( 0x06b8 , "Serbian_JE" ); - KEYVAL ( 0x06b9 , "Cyrillic_LJE" ); - KEYVAL ( 0x06b9 , "Serbian_LJE" ); - KEYVAL ( 0x06ba , "Cyrillic_NJE" ); - KEYVAL ( 0x06ba , "Serbian_NJE" ); - KEYVAL ( 0x06bb , "Serbian_TSHE" ); - KEYVAL ( 0x06bc , "Macedonia_KJE" ); - KEYVAL ( 0x06bd , "Ukrainian_GHE_WITH_UPTURN" ); - KEYVAL ( 0x06be , "Byelorussian_SHORTU" ); - KEYVAL ( 0x06bf , "Cyrillic_DZHE" ); - KEYVAL ( 0x06bf , "Serbian_DZE" ); - KEYVAL ( 0x06c0 , "Cyrillic_yu" ); - KEYVAL ( 0x06c1 , "Cyrillic_a" ); - KEYVAL ( 0x06c2 , "Cyrillic_be" ); - KEYVAL ( 0x06c3 , "Cyrillic_tse" ); - KEYVAL ( 0x06c4 , "Cyrillic_de" ); - KEYVAL ( 0x06c5 , "Cyrillic_ie" ); - KEYVAL ( 0x06c6 , "Cyrillic_ef" ); - KEYVAL ( 0x06c7 , "Cyrillic_ghe" ); - KEYVAL ( 0x06c8 , "Cyrillic_ha" ); - KEYVAL ( 0x06c9 , "Cyrillic_i" ); - KEYVAL ( 0x06ca , "Cyrillic_shorti" ); - KEYVAL ( 0x06cb , "Cyrillic_ka" ); - KEYVAL ( 0x06cc , "Cyrillic_el" ); - KEYVAL ( 0x06cd , "Cyrillic_em" ); - KEYVAL ( 0x06ce , "Cyrillic_en" ); - KEYVAL ( 0x06cf , "Cyrillic_o" ); - KEYVAL ( 0x06d0 , "Cyrillic_pe" ); - KEYVAL ( 0x06d1 , "Cyrillic_ya" ); - KEYVAL ( 0x06d2 , "Cyrillic_er" ); - KEYVAL ( 0x06d3 , "Cyrillic_es" ); - KEYVAL ( 0x06d4 , "Cyrillic_te" ); - KEYVAL ( 0x06d5 , "Cyrillic_u" ); - KEYVAL ( 0x06d6 , "Cyrillic_zhe" ); - KEYVAL ( 0x06d7 , "Cyrillic_ve" ); - KEYVAL ( 0x06d8 , "Cyrillic_softsign" ); - KEYVAL ( 0x06d9 , "Cyrillic_yeru" ); - KEYVAL ( 0x06da , "Cyrillic_ze" ); - KEYVAL ( 0x06db , "Cyrillic_sha" ); - KEYVAL ( 0x06dc , "Cyrillic_e" ); - KEYVAL ( 0x06dd , "Cyrillic_shcha" ); - KEYVAL ( 0x06de , "Cyrillic_che" ); - KEYVAL ( 0x06df , "Cyrillic_hardsign" ); - KEYVAL ( 0x06e0 , "Cyrillic_YU" ); - KEYVAL ( 0x06e1 , "Cyrillic_A" ); - KEYVAL ( 0x06e2 , "Cyrillic_BE" ); - KEYVAL ( 0x06e3 , "Cyrillic_TSE" ); - KEYVAL ( 0x06e4 , "Cyrillic_DE" ); - KEYVAL ( 0x06e5 , "Cyrillic_IE" ); - KEYVAL ( 0x06e6 , "Cyrillic_EF" ); - KEYVAL ( 0x06e7 , "Cyrillic_GHE" ); - KEYVAL ( 0x06e8 , "Cyrillic_HA" ); - KEYVAL ( 0x06e9 , "Cyrillic_I" ); - KEYVAL ( 0x06ea , "Cyrillic_SHORTI" ); - KEYVAL ( 0x06eb , "Cyrillic_KA" ); - KEYVAL ( 0x06ec , "Cyrillic_EL" ); - KEYVAL ( 0x06ed , "Cyrillic_EM" ); - KEYVAL ( 0x06ee , "Cyrillic_EN" ); - KEYVAL ( 0x06ef , "Cyrillic_O" ); - KEYVAL ( 0x06f0 , "Cyrillic_PE" ); - KEYVAL ( 0x06f1 , "Cyrillic_YA" ); - KEYVAL ( 0x06f2 , "Cyrillic_ER" ); - KEYVAL ( 0x06f3 , "Cyrillic_ES" ); - KEYVAL ( 0x06f4 , "Cyrillic_TE" ); - KEYVAL ( 0x06f5 , "Cyrillic_U" ); - KEYVAL ( 0x06f6 , "Cyrillic_ZHE" ); - KEYVAL ( 0x06f7 , "Cyrillic_VE" ); - KEYVAL ( 0x06f8 , "Cyrillic_SOFTSIGN" ); - KEYVAL ( 0x06f9 , "Cyrillic_YERU" ); - KEYVAL ( 0x06fa , "Cyrillic_ZE" ); - KEYVAL ( 0x06fb , "Cyrillic_SHA" ); - KEYVAL ( 0x06fc , "Cyrillic_E" ); - KEYVAL ( 0x06fd , "Cyrillic_SHCHA" ); - KEYVAL ( 0x06fe , "Cyrillic_CHE" ); - KEYVAL ( 0x06ff , "Cyrillic_HARDSIGN" ); - KEYVAL ( 0x07a1 , "Greek_ALPHAaccent" ); - KEYVAL ( 0x07a2 , "Greek_EPSILONaccent" ); - KEYVAL ( 0x07a3 , "Greek_ETAaccent" ); - KEYVAL ( 0x07a4 , "Greek_IOTAaccent" ); - KEYVAL ( 0x07a5 , "Greek_IOTAdieresis" ); - KEYVAL ( 0x07a7 , "Greek_OMICRONaccent" ); - KEYVAL ( 0x07a8 , "Greek_UPSILONaccent" ); - KEYVAL ( 0x07a9 , "Greek_UPSILONdieresis" ); - KEYVAL ( 0x07ab , "Greek_OMEGAaccent" ); - KEYVAL ( 0x07ae , "Greek_accentdieresis" ); - KEYVAL ( 0x07af , "Greek_horizbar" ); - KEYVAL ( 0x07b1 , "Greek_alphaaccent" ); - KEYVAL ( 0x07b2 , "Greek_epsilonaccent" ); - KEYVAL ( 0x07b3 , "Greek_etaaccent" ); - KEYVAL ( 0x07b4 , "Greek_iotaaccent" ); - KEYVAL ( 0x07b5 , "Greek_iotadieresis" ); - KEYVAL ( 0x07b6 , "Greek_iotaaccentdieresis" ); - KEYVAL ( 0x07b7 , "Greek_omicronaccent" ); - KEYVAL ( 0x07b8 , "Greek_upsilonaccent" ); - KEYVAL ( 0x07b9 , "Greek_upsilondieresis" ); - KEYVAL ( 0x07ba , "Greek_upsilonaccentdieresis" ); - KEYVAL ( 0x07bb , "Greek_omegaaccent" ); - KEYVAL ( 0x07c1 , "Greek_ALPHA" ); - KEYVAL ( 0x07c2 , "Greek_BETA" ); - KEYVAL ( 0x07c3 , "Greek_GAMMA" ); - KEYVAL ( 0x07c4 , "Greek_DELTA" ); - KEYVAL ( 0x07c5 , "Greek_EPSILON" ); - KEYVAL ( 0x07c6 , "Greek_ZETA" ); - KEYVAL ( 0x07c7 , "Greek_ETA" ); - KEYVAL ( 0x07c8 , "Greek_THETA" ); - KEYVAL ( 0x07c9 , "Greek_IOTA" ); - KEYVAL ( 0x07ca , "Greek_KAPPA" ); - KEYVAL ( 0x07cb , "Greek_LAMBDA" ); - KEYVAL ( 0x07cb , "Greek_LAMDA" ); - KEYVAL ( 0x07cc , "Greek_MU" ); - KEYVAL ( 0x07cd , "Greek_NU" ); - KEYVAL ( 0x07ce , "Greek_XI" ); - KEYVAL ( 0x07cf , "Greek_OMICRON" ); - KEYVAL ( 0x07d0 , "Greek_PI" ); - KEYVAL ( 0x07d1 , "Greek_RHO" ); - KEYVAL ( 0x07d2 , "Greek_SIGMA" ); - KEYVAL ( 0x07d4 , "Greek_TAU" ); - KEYVAL ( 0x07d5 , "Greek_UPSILON" ); - KEYVAL ( 0x07d6 , "Greek_PHI" ); - KEYVAL ( 0x07d7 , "Greek_CHI" ); - KEYVAL ( 0x07d8 , "Greek_PSI" ); - KEYVAL ( 0x07d9 , "Greek_OMEGA" ); - KEYVAL ( 0x07e1 , "Greek_alpha" ); - KEYVAL ( 0x07e2 , "Greek_beta" ); - KEYVAL ( 0x07e3 , "Greek_gamma" ); - KEYVAL ( 0x07e4 , "Greek_delta" ); - KEYVAL ( 0x07e5 , "Greek_epsilon" ); - KEYVAL ( 0x07e6 , "Greek_zeta" ); - KEYVAL ( 0x07e7 , "Greek_eta" ); - KEYVAL ( 0x07e8 , "Greek_theta" ); - KEYVAL ( 0x07e9 , "Greek_iota" ); - KEYVAL ( 0x07ea , "Greek_kappa" ); - KEYVAL ( 0x07eb , "Greek_lambda" ); - KEYVAL ( 0x07eb , "Greek_lamda" ); - KEYVAL ( 0x07ec , "Greek_mu" ); - KEYVAL ( 0x07ed , "Greek_nu" ); - KEYVAL ( 0x07ee , "Greek_xi" ); - KEYVAL ( 0x07ef , "Greek_omicron" ); - KEYVAL ( 0x07f0 , "Greek_pi" ); - KEYVAL ( 0x07f1 , "Greek_rho" ); - KEYVAL ( 0x07f2 , "Greek_sigma" ); - KEYVAL ( 0x07f3 , "Greek_finalsmallsigma" ); - KEYVAL ( 0x07f4 , "Greek_tau" ); - KEYVAL ( 0x07f5 , "Greek_upsilon" ); - KEYVAL ( 0x07f6 , "Greek_phi" ); - KEYVAL ( 0x07f7 , "Greek_chi" ); - KEYVAL ( 0x07f8 , "Greek_psi" ); - KEYVAL ( 0x07f9 , "Greek_omega" ); - KEYVAL ( 0x08a1 , "leftradical" ); - KEYVAL ( 0x08a2 , "topleftradical" ); - KEYVAL ( 0x08a3 , "horizconnector" ); - KEYVAL ( 0x08a4 , "topintegral" ); - KEYVAL ( 0x08a5 , "botintegral" ); - KEYVAL ( 0x08a6 , "vertconnector" ); - KEYVAL ( 0x08a7 , "topleftsqbracket" ); - KEYVAL ( 0x08a8 , "botleftsqbracket" ); - KEYVAL ( 0x08a9 , "toprightsqbracket" ); - KEYVAL ( 0x08aa , "botrightsqbracket" ); - KEYVAL ( 0x08ab , "topleftparens" ); - KEYVAL ( 0x08ac , "botleftparens" ); - KEYVAL ( 0x08ad , "toprightparens" ); - KEYVAL ( 0x08ae , "botrightparens" ); - KEYVAL ( 0x08af , "leftmiddlecurlybrace" ); - KEYVAL ( 0x08b0 , "rightmiddlecurlybrace" ); - KEYVAL ( 0x08b1 , "topleftsummation" ); - KEYVAL ( 0x08b2 , "botleftsummation" ); - KEYVAL ( 0x08b3 , "topvertsummationconnector" ); - KEYVAL ( 0x08b4 , "botvertsummationconnector" ); - KEYVAL ( 0x08b5 , "toprightsummation" ); - KEYVAL ( 0x08b6 , "botrightsummation" ); - KEYVAL ( 0x08b7 , "rightmiddlesummation" ); - KEYVAL ( 0x08bc , "lessthanequal" ); - KEYVAL ( 0x08bd , "notequal" ); - KEYVAL ( 0x08be , "greaterthanequal" ); - KEYVAL ( 0x08bf , "integral" ); - KEYVAL ( 0x08c0 , "therefore" ); - KEYVAL ( 0x08c1 , "variation" ); - KEYVAL ( 0x08c2 , "infinity" ); - KEYVAL ( 0x08c5 , "nabla" ); - KEYVAL ( 0x08c8 , "approximate" ); - KEYVAL ( 0x08c9 , "similarequal" ); - KEYVAL ( 0x08cd , "ifonlyif" ); - KEYVAL ( 0x08ce , "implies" ); - KEYVAL ( 0x08cf , "identical" ); - KEYVAL ( 0x08d6 , "radical" ); - KEYVAL ( 0x08da , "includedin" ); - KEYVAL ( 0x08db , "includes" ); - KEYVAL ( 0x08dc , "intersection" ); - KEYVAL ( 0x08dd , "union" ); - KEYVAL ( 0x08de , "logicaland" ); - KEYVAL ( 0x08df , "logicalor" ); - KEYVAL ( 0x08ef , "partialderivative" ); - KEYVAL ( 0x08f6 , "function" ); - KEYVAL ( 0x08fb , "leftarrow" ); - KEYVAL ( 0x08fc , "uparrow" ); - KEYVAL ( 0x08fd , "rightarrow" ); - KEYVAL ( 0x08fe , "downarrow" ); - KEYVAL ( 0x09df , "blank" ); - KEYVAL ( 0x09e0 , "soliddiamond" ); - KEYVAL ( 0x09e1 , "checkerboard" ); - KEYVAL ( 0x09e2 , "ht" ); - KEYVAL ( 0x09e3 , "ff" ); - KEYVAL ( 0x09e4 , "cr" ); - KEYVAL ( 0x09e5 , "lf" ); - KEYVAL ( 0x09e8 , "nl" ); - KEYVAL ( 0x09e9 , "vt" ); - KEYVAL ( 0x09ea , "lowrightcorner" ); - KEYVAL ( 0x09eb , "uprightcorner" ); - KEYVAL ( 0x09ec , "upleftcorner" ); - KEYVAL ( 0x09ed , "lowleftcorner" ); - KEYVAL ( 0x09ee , "crossinglines" ); - KEYVAL ( 0x09ef , "horizlinescan1" ); - KEYVAL ( 0x09f0 , "horizlinescan3" ); - KEYVAL ( 0x09f1 , "horizlinescan5" ); - KEYVAL ( 0x09f2 , "horizlinescan7" ); - KEYVAL ( 0x09f3 , "horizlinescan9" ); - KEYVAL ( 0x09f4 , "leftt" ); - KEYVAL ( 0x09f5 , "rightt" ); - KEYVAL ( 0x09f6 , "bott" ); - KEYVAL ( 0x09f7 , "topt" ); - KEYVAL ( 0x09f8 , "vertbar" ); - KEYVAL ( 0x0aa1 , "emspace" ); - KEYVAL ( 0x0aa2 , "enspace" ); - KEYVAL ( 0x0aa3 , "em3space" ); - KEYVAL ( 0x0aa4 , "em4space" ); - KEYVAL ( 0x0aa5 , "digitspace" ); - KEYVAL ( 0x0aa6 , "punctspace" ); - KEYVAL ( 0x0aa7 , "thinspace" ); - KEYVAL ( 0x0aa8 , "hairspace" ); - KEYVAL ( 0x0aa9 , "emdash" ); - KEYVAL ( 0x0aaa , "endash" ); - KEYVAL ( 0x0aac , "signifblank" ); - KEYVAL ( 0x0aae , "ellipsis" ); - KEYVAL ( 0x0aaf , "doubbaselinedot" ); - KEYVAL ( 0x0ab0 , "onethird" ); - KEYVAL ( 0x0ab1 , "twothirds" ); - KEYVAL ( 0x0ab2 , "onefifth" ); - KEYVAL ( 0x0ab3 , "twofifths" ); - KEYVAL ( 0x0ab4 , "threefifths" ); - KEYVAL ( 0x0ab5 , "fourfifths" ); - KEYVAL ( 0x0ab6 , "onesixth" ); - KEYVAL ( 0x0ab7 , "fivesixths" ); - KEYVAL ( 0x0ab8 , "careof" ); - KEYVAL ( 0x0abb , "figdash" ); - KEYVAL ( 0x0abc , "leftanglebracket" ); - KEYVAL ( 0x0abd , "decimalpoint" ); - KEYVAL ( 0x0abe , "rightanglebracket" ); - KEYVAL ( 0x0abf , "marker" ); - KEYVAL ( 0x0ac3 , "oneeighth" ); - KEYVAL ( 0x0ac4 , "threeeighths" ); - KEYVAL ( 0x0ac5 , "fiveeighths" ); - KEYVAL ( 0x0ac6 , "seveneighths" ); - KEYVAL ( 0x0ac9 , "trademark" ); - KEYVAL ( 0x0aca , "signaturemark" ); - KEYVAL ( 0x0acb , "trademarkincircle" ); - KEYVAL ( 0x0acc , "leftopentriangle" ); - KEYVAL ( 0x0acd , "rightopentriangle" ); - KEYVAL ( 0x0ace , "emopencircle" ); - KEYVAL ( 0x0acf , "emopenrectangle" ); - KEYVAL ( 0x0ad0 , "leftsinglequotemark" ); - KEYVAL ( 0x0ad1 , "rightsinglequotemark" ); - KEYVAL ( 0x0ad2 , "leftdoublequotemark" ); - KEYVAL ( 0x0ad3 , "rightdoublequotemark" ); - KEYVAL ( 0x0ad4 , "prescription" ); - KEYVAL ( 0x0ad6 , "minutes" ); - KEYVAL ( 0x0ad7 , "seconds" ); - KEYVAL ( 0x0ad9 , "latincross" ); - KEYVAL ( 0x0ada , "hexagram" ); - KEYVAL ( 0x0adb , "filledrectbullet" ); - KEYVAL ( 0x0adc , "filledlefttribullet" ); - KEYVAL ( 0x0add , "filledrighttribullet" ); - KEYVAL ( 0x0ade , "emfilledcircle" ); - KEYVAL ( 0x0adf , "emfilledrect" ); - KEYVAL ( 0x0ae0 , "enopencircbullet" ); - KEYVAL ( 0x0ae1 , "enopensquarebullet" ); - KEYVAL ( 0x0ae2 , "openrectbullet" ); - KEYVAL ( 0x0ae3 , "opentribulletup" ); - KEYVAL ( 0x0ae4 , "opentribulletdown" ); - KEYVAL ( 0x0ae5 , "openstar" ); - KEYVAL ( 0x0ae6 , "enfilledcircbullet" ); - KEYVAL ( 0x0ae7 , "enfilledsqbullet" ); - KEYVAL ( 0x0ae8 , "filledtribulletup" ); - KEYVAL ( 0x0ae9 , "filledtribulletdown" ); - KEYVAL ( 0x0aea , "leftpointer" ); - KEYVAL ( 0x0aeb , "rightpointer" ); - KEYVAL ( 0x0aec , "club" ); - KEYVAL ( 0x0aed , "diamond" ); - KEYVAL ( 0x0aee , "heart" ); - KEYVAL ( 0x0af0 , "maltesecross" ); - KEYVAL ( 0x0af1 , "dagger" ); - KEYVAL ( 0x0af2 , "doubledagger" ); - KEYVAL ( 0x0af3 , "checkmark" ); - KEYVAL ( 0x0af4 , "ballotcross" ); - KEYVAL ( 0x0af5 , "musicalsharp" ); - KEYVAL ( 0x0af6 , "musicalflat" ); - KEYVAL ( 0x0af7 , "malesymbol" ); - KEYVAL ( 0x0af8 , "femalesymbol" ); - KEYVAL ( 0x0af9 , "telephone" ); - KEYVAL ( 0x0afa , "telephonerecorder" ); - KEYVAL ( 0x0afb , "phonographcopyright" ); - KEYVAL ( 0x0afc , "caret" ); - KEYVAL ( 0x0afd , "singlelowquotemark" ); - KEYVAL ( 0x0afe , "doublelowquotemark" ); - KEYVAL ( 0x0aff , "cursor" ); - KEYVAL ( 0x0ba3 , "leftcaret" ); - KEYVAL ( 0x0ba6 , "rightcaret" ); - KEYVAL ( 0x0ba8 , "downcaret" ); - KEYVAL ( 0x0ba9 , "upcaret" ); - KEYVAL ( 0x0bc0 , "overbar" ); - KEYVAL ( 0x0bc2 , "downtack" ); - KEYVAL ( 0x0bc3 , "upshoe" ); - KEYVAL ( 0x0bc4 , "downstile" ); - KEYVAL ( 0x0bc6 , "underbar" ); - KEYVAL ( 0x0bca , "jot" ); - KEYVAL ( 0x0bcc , "quad" ); - KEYVAL ( 0x0bce , "uptack" ); - KEYVAL ( 0x0bcf , "circle" ); - KEYVAL ( 0x0bd3 , "upstile" ); - KEYVAL ( 0x0bd6 , "downshoe" ); - KEYVAL ( 0x0bd8 , "rightshoe" ); - KEYVAL ( 0x0bda , "leftshoe" ); - KEYVAL ( 0x0bdc , "lefttack" ); - KEYVAL ( 0x0bfc , "righttack" ); - KEYVAL ( 0x0cdf , "hebrew_doublelowline" ); - KEYVAL ( 0x0ce0 , "hebrew_aleph" ); - KEYVAL ( 0x0ce1 , "hebrew_bet" ); - KEYVAL ( 0x0ce1 , "hebrew_beth" ); - KEYVAL ( 0x0ce2 , "hebrew_gimel" ); - KEYVAL ( 0x0ce2 , "hebrew_gimmel" ); - KEYVAL ( 0x0ce3 , "hebrew_dalet" ); - KEYVAL ( 0x0ce3 , "hebrew_daleth" ); - KEYVAL ( 0x0ce4 , "hebrew_he" ); - KEYVAL ( 0x0ce5 , "hebrew_waw" ); - KEYVAL ( 0x0ce6 , "hebrew_zain" ); - KEYVAL ( 0x0ce6 , "hebrew_zayin" ); - KEYVAL ( 0x0ce7 , "hebrew_chet" ); - KEYVAL ( 0x0ce7 , "hebrew_het" ); - KEYVAL ( 0x0ce8 , "hebrew_tet" ); - KEYVAL ( 0x0ce8 , "hebrew_teth" ); - KEYVAL ( 0x0ce9 , "hebrew_yod" ); - KEYVAL ( 0x0cea , "hebrew_finalkaph" ); - KEYVAL ( 0x0ceb , "hebrew_kaph" ); - KEYVAL ( 0x0cec , "hebrew_lamed" ); - KEYVAL ( 0x0ced , "hebrew_finalmem" ); - KEYVAL ( 0x0cee , "hebrew_mem" ); - KEYVAL ( 0x0cef , "hebrew_finalnun" ); - KEYVAL ( 0x0cf0 , "hebrew_nun" ); - KEYVAL ( 0x0cf1 , "hebrew_samech" ); - KEYVAL ( 0x0cf1 , "hebrew_samekh" ); - KEYVAL ( 0x0cf2 , "hebrew_ayin" ); - KEYVAL ( 0x0cf3 , "hebrew_finalpe" ); - KEYVAL ( 0x0cf4 , "hebrew_pe" ); - KEYVAL ( 0x0cf5 , "hebrew_finalzade" ); - KEYVAL ( 0x0cf5 , "hebrew_finalzadi" ); - KEYVAL ( 0x0cf6 , "hebrew_zade" ); - KEYVAL ( 0x0cf6 , "hebrew_zadi" ); - KEYVAL ( 0x0cf7 , "hebrew_kuf" ); - KEYVAL ( 0x0cf7 , "hebrew_qoph" ); - KEYVAL ( 0x0cf8 , "hebrew_resh" ); - KEYVAL ( 0x0cf9 , "hebrew_shin" ); - KEYVAL ( 0x0cfa , "hebrew_taf" ); - KEYVAL ( 0x0cfa , "hebrew_taw" ); - KEYVAL ( 0x0da1 , "Thai_kokai" ); - KEYVAL ( 0x0da2 , "Thai_khokhai" ); - KEYVAL ( 0x0da3 , "Thai_khokhuat" ); - KEYVAL ( 0x0da4 , "Thai_khokhwai" ); - KEYVAL ( 0x0da5 , "Thai_khokhon" ); - KEYVAL ( 0x0da6 , "Thai_khorakhang" ); - KEYVAL ( 0x0da7 , "Thai_ngongu" ); - KEYVAL ( 0x0da8 , "Thai_chochan" ); - KEYVAL ( 0x0da9 , "Thai_choching" ); - KEYVAL ( 0x0daa , "Thai_chochang" ); - KEYVAL ( 0x0dab , "Thai_soso" ); - KEYVAL ( 0x0dac , "Thai_chochoe" ); - KEYVAL ( 0x0dad , "Thai_yoying" ); - KEYVAL ( 0x0dae , "Thai_dochada" ); - KEYVAL ( 0x0daf , "Thai_topatak" ); - KEYVAL ( 0x0db0 , "Thai_thothan" ); - KEYVAL ( 0x0db1 , "Thai_thonangmontho" ); - KEYVAL ( 0x0db2 , "Thai_thophuthao" ); - KEYVAL ( 0x0db3 , "Thai_nonen" ); - KEYVAL ( 0x0db4 , "Thai_dodek" ); - KEYVAL ( 0x0db5 , "Thai_totao" ); - KEYVAL ( 0x0db6 , "Thai_thothung" ); - KEYVAL ( 0x0db7 , "Thai_thothahan" ); - KEYVAL ( 0x0db8 , "Thai_thothong" ); - KEYVAL ( 0x0db9 , "Thai_nonu" ); - KEYVAL ( 0x0dba , "Thai_bobaimai" ); - KEYVAL ( 0x0dbb , "Thai_popla" ); - KEYVAL ( 0x0dbc , "Thai_phophung" ); - KEYVAL ( 0x0dbd , "Thai_fofa" ); - KEYVAL ( 0x0dbe , "Thai_phophan" ); - KEYVAL ( 0x0dbf , "Thai_fofan" ); - KEYVAL ( 0x0dc0 , "Thai_phosamphao" ); - KEYVAL ( 0x0dc1 , "Thai_moma" ); - KEYVAL ( 0x0dc2 , "Thai_yoyak" ); - KEYVAL ( 0x0dc3 , "Thai_rorua" ); - KEYVAL ( 0x0dc4 , "Thai_ru" ); - KEYVAL ( 0x0dc5 , "Thai_loling" ); - KEYVAL ( 0x0dc6 , "Thai_lu" ); - KEYVAL ( 0x0dc7 , "Thai_wowaen" ); - KEYVAL ( 0x0dc8 , "Thai_sosala" ); - KEYVAL ( 0x0dc9 , "Thai_sorusi" ); - KEYVAL ( 0x0dca , "Thai_sosua" ); - KEYVAL ( 0x0dcb , "Thai_hohip" ); - KEYVAL ( 0x0dcc , "Thai_lochula" ); - KEYVAL ( 0x0dcd , "Thai_oang" ); - KEYVAL ( 0x0dce , "Thai_honokhuk" ); - KEYVAL ( 0x0dcf , "Thai_paiyannoi" ); - KEYVAL ( 0x0dd0 , "Thai_saraa" ); - KEYVAL ( 0x0dd1 , "Thai_maihanakat" ); - KEYVAL ( 0x0dd2 , "Thai_saraaa" ); - KEYVAL ( 0x0dd3 , "Thai_saraam" ); - KEYVAL ( 0x0dd4 , "Thai_sarai" ); - KEYVAL ( 0x0dd5 , "Thai_saraii" ); - KEYVAL ( 0x0dd6 , "Thai_saraue" ); - KEYVAL ( 0x0dd7 , "Thai_sarauee" ); - KEYVAL ( 0x0dd8 , "Thai_sarau" ); - KEYVAL ( 0x0dd9 , "Thai_sarauu" ); - KEYVAL ( 0x0dda , "Thai_phinthu" ); - KEYVAL ( 0x0dde , "Thai_maihanakat_maitho" ); - KEYVAL ( 0x0ddf , "Thai_baht" ); - KEYVAL ( 0x0de0 , "Thai_sarae" ); - KEYVAL ( 0x0de1 , "Thai_saraae" ); - KEYVAL ( 0x0de2 , "Thai_sarao" ); - KEYVAL ( 0x0de3 , "Thai_saraaimaimuan" ); - KEYVAL ( 0x0de4 , "Thai_saraaimaimalai" ); - KEYVAL ( 0x0de5 , "Thai_lakkhangyao" ); - KEYVAL ( 0x0de6 , "Thai_maiyamok" ); - KEYVAL ( 0x0de7 , "Thai_maitaikhu" ); - KEYVAL ( 0x0de8 , "Thai_maiek" ); - KEYVAL ( 0x0de9 , "Thai_maitho" ); - KEYVAL ( 0x0dea , "Thai_maitri" ); - KEYVAL ( 0x0deb , "Thai_maichattawa" ); - KEYVAL ( 0x0dec , "Thai_thanthakhat" ); - KEYVAL ( 0x0ded , "Thai_nikhahit" ); - KEYVAL ( 0x0df0 , "Thai_leksun" ); - KEYVAL ( 0x0df1 , "Thai_leknung" ); - KEYVAL ( 0x0df2 , "Thai_leksong" ); - KEYVAL ( 0x0df3 , "Thai_leksam" ); - KEYVAL ( 0x0df4 , "Thai_leksi" ); - KEYVAL ( 0x0df5 , "Thai_lekha" ); - KEYVAL ( 0x0df6 , "Thai_lekhok" ); - KEYVAL ( 0x0df7 , "Thai_lekchet" ); - KEYVAL ( 0x0df8 , "Thai_lekpaet" ); - KEYVAL ( 0x0df9 , "Thai_lekkao" ); - KEYVAL ( 0x0ea1 , "Hangul_Kiyeog" ); - KEYVAL ( 0x0ea2 , "Hangul_SsangKiyeog" ); - KEYVAL ( 0x0ea3 , "Hangul_KiyeogSios" ); - KEYVAL ( 0x0ea4 , "Hangul_Nieun" ); - KEYVAL ( 0x0ea5 , "Hangul_NieunJieuj" ); - KEYVAL ( 0x0ea6 , "Hangul_NieunHieuh" ); - KEYVAL ( 0x0ea7 , "Hangul_Dikeud" ); - KEYVAL ( 0x0ea8 , "Hangul_SsangDikeud" ); - KEYVAL ( 0x0ea9 , "Hangul_Rieul" ); - KEYVAL ( 0x0eaa , "Hangul_RieulKiyeog" ); - KEYVAL ( 0x0eab , "Hangul_RieulMieum" ); - KEYVAL ( 0x0eac , "Hangul_RieulPieub" ); - KEYVAL ( 0x0ead , "Hangul_RieulSios" ); - KEYVAL ( 0x0eae , "Hangul_RieulTieut" ); - KEYVAL ( 0x0eaf , "Hangul_RieulPhieuf" ); - KEYVAL ( 0x0eb0 , "Hangul_RieulHieuh" ); - KEYVAL ( 0x0eb1 , "Hangul_Mieum" ); - KEYVAL ( 0x0eb2 , "Hangul_Pieub" ); - KEYVAL ( 0x0eb3 , "Hangul_SsangPieub" ); - KEYVAL ( 0x0eb4 , "Hangul_PieubSios" ); - KEYVAL ( 0x0eb5 , "Hangul_Sios" ); - KEYVAL ( 0x0eb6 , "Hangul_SsangSios" ); - KEYVAL ( 0x0eb7 , "Hangul_Ieung" ); - KEYVAL ( 0x0eb8 , "Hangul_Jieuj" ); - KEYVAL ( 0x0eb9 , "Hangul_SsangJieuj" ); - KEYVAL ( 0x0eba , "Hangul_Cieuc" ); - KEYVAL ( 0x0ebb , "Hangul_Khieuq" ); - KEYVAL ( 0x0ebc , "Hangul_Tieut" ); - KEYVAL ( 0x0ebd , "Hangul_Phieuf" ); - KEYVAL ( 0x0ebe , "Hangul_Hieuh" ); - KEYVAL ( 0x0ebf , "Hangul_A" ); - KEYVAL ( 0x0ec0 , "Hangul_AE" ); - KEYVAL ( 0x0ec1 , "Hangul_YA" ); - KEYVAL ( 0x0ec2 , "Hangul_YAE" ); - KEYVAL ( 0x0ec3 , "Hangul_EO" ); - KEYVAL ( 0x0ec4 , "Hangul_E" ); - KEYVAL ( 0x0ec5 , "Hangul_YEO" ); - KEYVAL ( 0x0ec6 , "Hangul_YE" ); - KEYVAL ( 0x0ec7 , "Hangul_O" ); - KEYVAL ( 0x0ec8 , "Hangul_WA" ); - KEYVAL ( 0x0ec9 , "Hangul_WAE" ); - KEYVAL ( 0x0eca , "Hangul_OE" ); - KEYVAL ( 0x0ecb , "Hangul_YO" ); - KEYVAL ( 0x0ecc , "Hangul_U" ); - KEYVAL ( 0x0ecd , "Hangul_WEO" ); - KEYVAL ( 0x0ece , "Hangul_WE" ); - KEYVAL ( 0x0ecf , "Hangul_WI" ); - KEYVAL ( 0x0ed0 , "Hangul_YU" ); - KEYVAL ( 0x0ed1 , "Hangul_EU" ); - KEYVAL ( 0x0ed2 , "Hangul_YI" ); - KEYVAL ( 0x0ed3 , "Hangul_I" ); - KEYVAL ( 0x0ed4 , "Hangul_J_Kiyeog" ); - KEYVAL ( 0x0ed5 , "Hangul_J_SsangKiyeog" ); - KEYVAL ( 0x0ed6 , "Hangul_J_KiyeogSios" ); - KEYVAL ( 0x0ed7 , "Hangul_J_Nieun" ); - KEYVAL ( 0x0ed8 , "Hangul_J_NieunJieuj" ); - KEYVAL ( 0x0ed9 , "Hangul_J_NieunHieuh" ); - KEYVAL ( 0x0eda , "Hangul_J_Dikeud" ); - KEYVAL ( 0x0edb , "Hangul_J_Rieul" ); - KEYVAL ( 0x0edc , "Hangul_J_RieulKiyeog" ); - KEYVAL ( 0x0edd , "Hangul_J_RieulMieum" ); - KEYVAL ( 0x0ede , "Hangul_J_RieulPieub" ); - KEYVAL ( 0x0edf , "Hangul_J_RieulSios" ); - KEYVAL ( 0x0ee0 , "Hangul_J_RieulTieut" ); - KEYVAL ( 0x0ee1 , "Hangul_J_RieulPhieuf" ); - KEYVAL ( 0x0ee2 , "Hangul_J_RieulHieuh" ); - KEYVAL ( 0x0ee3 , "Hangul_J_Mieum" ); - KEYVAL ( 0x0ee4 , "Hangul_J_Pieub" ); - KEYVAL ( 0x0ee5 , "Hangul_J_PieubSios" ); - KEYVAL ( 0x0ee6 , "Hangul_J_Sios" ); - KEYVAL ( 0x0ee7 , "Hangul_J_SsangSios" ); - KEYVAL ( 0x0ee8 , "Hangul_J_Ieung" ); - KEYVAL ( 0x0ee9 , "Hangul_J_Jieuj" ); - KEYVAL ( 0x0eea , "Hangul_J_Cieuc" ); - KEYVAL ( 0x0eeb , "Hangul_J_Khieuq" ); - KEYVAL ( 0x0eec , "Hangul_J_Tieut" ); - KEYVAL ( 0x0eed , "Hangul_J_Phieuf" ); - KEYVAL ( 0x0eee , "Hangul_J_Hieuh" ); - KEYVAL ( 0x0eef , "Hangul_RieulYeorinHieuh" ); - KEYVAL ( 0x0ef0 , "Hangul_SunkyeongeumMieum" ); - KEYVAL ( 0x0ef1 , "Hangul_SunkyeongeumPieub" ); - KEYVAL ( 0x0ef2 , "Hangul_PanSios" ); - KEYVAL ( 0x0ef3 , "Hangul_KkogjiDalrinIeung" ); - KEYVAL ( 0x0ef4 , "Hangul_SunkyeongeumPhieuf" ); - KEYVAL ( 0x0ef5 , "Hangul_YeorinHieuh" ); - KEYVAL ( 0x0ef6 , "Hangul_AraeA" ); - KEYVAL ( 0x0ef7 , "Hangul_AraeAE" ); - KEYVAL ( 0x0ef8 , "Hangul_J_PanSios" ); - KEYVAL ( 0x0ef9 , "Hangul_J_KkogjiDalrinIeung" ); - KEYVAL ( 0x0efa , "Hangul_J_YeorinHieuh" ); - KEYVAL ( 0x0eff , "Korean_Won" ); - KEYVAL ( 0x13bc , "OE" ); - KEYVAL ( 0x13bd , "oe" ); - KEYVAL ( 0x13be , "Ydiaeresis" ); - KEYVAL ( 0x20a0 , "EcuSign" ); - KEYVAL ( 0x20a1 , "ColonSign" ); - KEYVAL ( 0x20a2 , "CruzeiroSign" ); - KEYVAL ( 0x20a3 , "FFrancSign" ); - KEYVAL ( 0x20a4 , "LiraSign" ); - KEYVAL ( 0x20a5 , "MillSign" ); - KEYVAL ( 0x20a6 , "NairaSign" ); - KEYVAL ( 0x20a7 , "PesetaSign" ); - KEYVAL ( 0x20a8 , "RupeeSign" ); - KEYVAL ( 0x20a9 , "WonSign" ); - KEYVAL ( 0x20aa , "NewSheqelSign" ); - KEYVAL ( 0x20ab , "DongSign" ); - KEYVAL ( 0x20ac , "EuroSign" ); - KEYVAL ( 0xFD01 , "3270_Duplicate" ); - KEYVAL ( 0xFD02 , "3270_FieldMark" ); - KEYVAL ( 0xFD03 , "3270_Right2" ); - KEYVAL ( 0xFD04 , "3270_Left2" ); - KEYVAL ( 0xFD05 , "3270_BackTab" ); - KEYVAL ( 0xFD06 , "3270_EraseEOF" ); - KEYVAL ( 0xFD07 , "3270_EraseInput" ); - KEYVAL ( 0xFD08 , "3270_Reset" ); - KEYVAL ( 0xFD09 , "3270_Quit" ); - KEYVAL ( 0xFD0A , "3270_PA1" ); - KEYVAL ( 0xFD0B , "3270_PA2" ); - KEYVAL ( 0xFD0C , "3270_PA3" ); - KEYVAL ( 0xFD0D , "3270_Test" ); - KEYVAL ( 0xFD0E , "3270_Attn" ); - KEYVAL ( 0xFD0F , "3270_CursorBlink" ); - KEYVAL ( 0xFD10 , "3270_AltCursor" ); - KEYVAL ( 0xFD11 , "3270_KeyClick" ); - KEYVAL ( 0xFD12 , "3270_Jump" ); - KEYVAL ( 0xFD13 , "3270_Ident" ); - KEYVAL ( 0xFD14 , "3270_Rule" ); - KEYVAL ( 0xFD15 , "3270_Copy" ); - KEYVAL ( 0xFD16 , "3270_Play" ); - KEYVAL ( 0xFD17 , "3270_Setup" ); - KEYVAL ( 0xFD18 , "3270_Record" ); - KEYVAL ( 0xFD19 , "3270_ChangeScreen" ); - KEYVAL ( 0xFD1A , "3270_DeleteWord" ); - KEYVAL ( 0xFD1B , "3270_ExSelect" ); - KEYVAL ( 0xFD1C , "3270_CursorSelect" ); - KEYVAL ( 0xFD1D , "3270_PrintScreen" ); - KEYVAL ( 0xFD1E , "3270_Enter" ); - KEYVAL ( 0xFE01 , "ISO_Lock" ); - KEYVAL ( 0xFE02 , "ISO_Level2_Latch" ); - KEYVAL ( 0xFE03 , "ISO_Level3_Shift" ); - KEYVAL ( 0xFE04 , "ISO_Level3_Latch" ); - KEYVAL ( 0xFE05 , "ISO_Level3_Lock" ); - KEYVAL ( 0xFE06 , "ISO_Group_Latch" ); - KEYVAL ( 0xFE07 , "ISO_Group_Lock" ); - KEYVAL ( 0xFE08 , "ISO_Next_Group" ); - KEYVAL ( 0xFE09 , "ISO_Next_Group_Lock" ); - KEYVAL ( 0xFE0A , "ISO_Prev_Group" ); - KEYVAL ( 0xFE0B , "ISO_Prev_Group_Lock" ); - KEYVAL ( 0xFE0C , "ISO_First_Group" ); - KEYVAL ( 0xFE0D , "ISO_First_Group_Lock" ); - KEYVAL ( 0xFE0E , "ISO_Last_Group" ); - KEYVAL ( 0xFE0F , "ISO_Last_Group_Lock" ); - KEYVAL ( 0xFE20 , "ISO_Left_Tab" ); - KEYVAL ( 0xFE21 , "ISO_Move_Line_Up" ); - KEYVAL ( 0xFE22 , "ISO_Move_Line_Down" ); - KEYVAL ( 0xFE23 , "ISO_Partial_Line_Up" ); - KEYVAL ( 0xFE24 , "ISO_Partial_Line_Down" ); - KEYVAL ( 0xFE25 , "ISO_Partial_Space_Left" ); - KEYVAL ( 0xFE26 , "ISO_Partial_Space_Right" ); - KEYVAL ( 0xFE27 , "ISO_Set_Margin_Left" ); - KEYVAL ( 0xFE28 , "ISO_Set_Margin_Right" ); - KEYVAL ( 0xFE29 , "ISO_Release_Margin_Left" ); - KEYVAL ( 0xFE2A , "ISO_Release_Margin_Right" ); - KEYVAL ( 0xFE2B , "ISO_Release_Both_Margins" ); - KEYVAL ( 0xFE2C , "ISO_Fast_Cursor_Left" ); - KEYVAL ( 0xFE2D , "ISO_Fast_Cursor_Right" ); - KEYVAL ( 0xFE2E , "ISO_Fast_Cursor_Up" ); - KEYVAL ( 0xFE2F , "ISO_Fast_Cursor_Down" ); - KEYVAL ( 0xFE30 , "ISO_Continuous_Underline" ); - KEYVAL ( 0xFE31 , "ISO_Discontinuous_Underline" ); - KEYVAL ( 0xFE32 , "ISO_Emphasize" ); - KEYVAL ( 0xFE33 , "ISO_Center_Object" ); - KEYVAL ( 0xFE34 , "ISO_Enter" ); - KEYVAL ( 0xFE50 , "dead_grave" ); - KEYVAL ( 0xFE51 , "dead_acute" ); - KEYVAL ( 0xFE52 , "dead_circumflex" ); - KEYVAL ( 0xFE53 , "dead_tilde" ); - KEYVAL ( 0xFE54 , "dead_macron" ); - KEYVAL ( 0xFE55 , "dead_breve" ); - KEYVAL ( 0xFE56 , "dead_abovedot" ); - KEYVAL ( 0xFE57 , "dead_diaeresis" ); - KEYVAL ( 0xFE58 , "dead_abovering" ); - KEYVAL ( 0xFE59 , "dead_doubleacute" ); - KEYVAL ( 0xFE5A , "dead_caron" ); - KEYVAL ( 0xFE5B , "dead_cedilla" ); - KEYVAL ( 0xFE5C , "dead_ogonek" ); - KEYVAL ( 0xFE5D , "dead_iota" ); - KEYVAL ( 0xFE5E , "dead_voiced_sound" ); - KEYVAL ( 0xFE5F , "dead_semivoiced_sound" ); - KEYVAL ( 0xFE60 , "dead_belowdot" ); - KEYVAL ( 0xFE61 , "dead_hook" ); - KEYVAL ( 0xFE62 , "dead_horn" ); - KEYVAL ( 0xFE70 , "AccessX_Enable" ); - KEYVAL ( 0xFE71 , "AccessX_Feedback_Enable" ); - KEYVAL ( 0xFE72 , "RepeatKeys_Enable" ); - KEYVAL ( 0xFE73 , "SlowKeys_Enable" ); - KEYVAL ( 0xFE74 , "BounceKeys_Enable" ); - KEYVAL ( 0xFE75 , "StickyKeys_Enable" ); - KEYVAL ( 0xFE76 , "MouseKeys_Enable" ); - KEYVAL ( 0xFE77 , "MouseKeys_Accel_Enable" ); - KEYVAL ( 0xFE78 , "Overlay1_Enable" ); - KEYVAL ( 0xFE79 , "Overlay2_Enable" ); - KEYVAL ( 0xFE7A , "AudibleBell_Enable" ); - KEYVAL ( 0xFED0 , "First_Virtual_Screen" ); - KEYVAL ( 0xFED1 , "Prev_Virtual_Screen" ); - KEYVAL ( 0xFED2 , "Next_Virtual_Screen" ); - KEYVAL ( 0xFED4 , "Last_Virtual_Screen" ); - KEYVAL ( 0xFED5 , "Terminate_Server" ); - KEYVAL ( 0xFEE0 , "Pointer_Left" ); - KEYVAL ( 0xFEE1 , "Pointer_Right" ); - KEYVAL ( 0xFEE2 , "Pointer_Up" ); - KEYVAL ( 0xFEE3 , "Pointer_Down" ); - KEYVAL ( 0xFEE4 , "Pointer_UpLeft" ); - KEYVAL ( 0xFEE5 , "Pointer_UpRight" ); - KEYVAL ( 0xFEE6 , "Pointer_DownLeft" ); - KEYVAL ( 0xFEE7 , "Pointer_DownRight" ); - KEYVAL ( 0xFEE8 , "Pointer_Button_Dflt" ); - KEYVAL ( 0xFEE9 , "Pointer_Button1" ); - KEYVAL ( 0xFEEA , "Pointer_Button2" ); - KEYVAL ( 0xFEEB , "Pointer_Button3" ); - KEYVAL ( 0xFEEC , "Pointer_Button4" ); - KEYVAL ( 0xFEED , "Pointer_Button5" ); - KEYVAL ( 0xFEEE , "Pointer_DblClick_Dflt" ); - KEYVAL ( 0xFEEF , "Pointer_DblClick1" ); - KEYVAL ( 0xFEF0 , "Pointer_DblClick2" ); - KEYVAL ( 0xFEF1 , "Pointer_DblClick3" ); - KEYVAL ( 0xFEF2 , "Pointer_DblClick4" ); - KEYVAL ( 0xFEF3 , "Pointer_DblClick5" ); - KEYVAL ( 0xFEF4 , "Pointer_Drag_Dflt" ); - KEYVAL ( 0xFEF5 , "Pointer_Drag1" ); - KEYVAL ( 0xFEF6 , "Pointer_Drag2" ); - KEYVAL ( 0xFEF7 , "Pointer_Drag3" ); - KEYVAL ( 0xFEF8 , "Pointer_Drag4" ); - KEYVAL ( 0xFEF9 , "Pointer_EnableKeys" ); - KEYVAL ( 0xFEFA , "Pointer_Accelerate" ); - KEYVAL ( 0xFEFB , "Pointer_DfltBtnNext" ); - KEYVAL ( 0xFEFC , "Pointer_DfltBtnPrev" ); - KEYVAL ( 0xFEFD , "Pointer_Drag5" ); - KEYVAL ( 0xFF08 , "BackSpace" ); - KEYVAL ( 0xFF09 , "Tab" ); - KEYVAL ( 0xFF0A , "Linefeed" ); - KEYVAL ( 0xFF0B , "Clear" ); - KEYVAL ( 0xFF0D , "Return" ); - KEYVAL ( 0xFF13 , "Pause" ); - KEYVAL ( 0xFF14 , "Scroll_Lock" ); - KEYVAL ( 0xFF15 , "Sys_Req" ); - KEYVAL ( 0xFF1B , "Escape" ); - KEYVAL ( 0xFF20 , "Multi_key" ); - KEYVAL ( 0xFF21 , "Kanji" ); - KEYVAL ( 0xFF22 , "Muhenkan" ); - KEYVAL ( 0xFF23 , "Henkan" ); - KEYVAL ( 0xFF23 , "Henkan_Mode" ); - KEYVAL ( 0xFF24 , "Romaji" ); - KEYVAL ( 0xFF25 , "Hiragana" ); - KEYVAL ( 0xFF26 , "Katakana" ); - KEYVAL ( 0xFF27 , "Hiragana_Katakana" ); - KEYVAL ( 0xFF28 , "Zenkaku" ); - KEYVAL ( 0xFF29 , "Hankaku" ); - KEYVAL ( 0xFF2A , "Zenkaku_Hankaku" ); - KEYVAL ( 0xFF2B , "Touroku" ); - KEYVAL ( 0xFF2C , "Massyo" ); - KEYVAL ( 0xFF2D , "Kana_Lock" ); - KEYVAL ( 0xFF2E , "Kana_Shift" ); - KEYVAL ( 0xFF2F , "Eisu_Shift" ); - KEYVAL ( 0xFF30 , "Eisu_toggle" ); - KEYVAL ( 0xff31 , "Hangul" ); - KEYVAL ( 0xff32 , "Hangul_Start" ); - KEYVAL ( 0xff33 , "Hangul_End" ); - KEYVAL ( 0xff34 , "Hangul_Hanja" ); - KEYVAL ( 0xff35 , "Hangul_Jamo" ); - KEYVAL ( 0xff36 , "Hangul_Romaja" ); - KEYVAL ( 0xFF37 , "Codeinput" ); - KEYVAL ( 0xff37 , "Hangul_Codeinput" ); - KEYVAL ( 0xFF37 , "Kanji_Bangou" ); - KEYVAL ( 0xff38 , "Hangul_Jeonja" ); - KEYVAL ( 0xff39 , "Hangul_Banja" ); - KEYVAL ( 0xff3a , "Hangul_PreHanja" ); - KEYVAL ( 0xff3b , "Hangul_PostHanja" ); - KEYVAL ( 0xff3c , "Hangul_SingleCandidate" ); - KEYVAL ( 0xFF3C , "SingleCandidate" ); - KEYVAL ( 0xff3d , "Hangul_MultipleCandidate" ); - KEYVAL ( 0xFF3D , "MultipleCandidate" ); - KEYVAL ( 0xFF3D , "Zen_Koho" ); - KEYVAL ( 0xff3e , "Hangul_PreviousCandidate" ); - KEYVAL ( 0xFF3E , "Mae_Koho" ); - KEYVAL ( 0xFF3E , "PreviousCandidate" ); - KEYVAL ( 0xff3f , "Hangul_Special" ); - KEYVAL ( 0xFF50 , "Home" ); - KEYVAL ( 0xFF51 , "Left" ); - KEYVAL ( 0xFF52 , "Up" ); - KEYVAL ( 0xFF53 , "Right" ); - KEYVAL ( 0xFF54 , "Down" ); - KEYVAL ( 0xFF55 , "Page_Up" ); - KEYVAL ( 0xFF55 , "Prior" ); - KEYVAL ( 0xFF56 , "Next" ); - KEYVAL ( 0xFF56 , "Page_Down" ); - KEYVAL ( 0xFF57 , "End" ); - KEYVAL ( 0xFF58 , "Begin" ); - KEYVAL ( 0xFF60 , "Select" ); - KEYVAL ( 0xFF61 , "Print" ); - KEYVAL ( 0xFF62 , "Execute" ); - KEYVAL ( 0xFF63 , "Insert" ); - KEYVAL ( 0xFF65 , "Undo" ); - KEYVAL ( 0xFF66 , "Redo" ); - KEYVAL ( 0xFF67 , "Menu" ); - KEYVAL ( 0xFF68 , "Find" ); - KEYVAL ( 0xFF69 , "Cancel" ); - KEYVAL ( 0xFF6A , "Help" ); - KEYVAL ( 0xFF6B , "Break" ); - KEYVAL ( 0xFF7E , "Arabic_switch" ); - KEYVAL ( 0xFF7E , "Greek_switch" ); - KEYVAL ( 0xFF7E , "Hangul_switch" ); - KEYVAL ( 0xFF7E , "Hebrew_switch" ); - KEYVAL ( 0xFF7E , "ISO_Group_Shift" ); - KEYVAL ( 0xFF7E , "kana_switch" ); - KEYVAL ( 0xFF7E , "Mode_switch" ); - KEYVAL ( 0xFF7E , "script_switch" ); - KEYVAL ( 0xFF7F , "Num_Lock" ); - KEYVAL ( 0xFF80 , "KP_Space" ); - KEYVAL ( 0xFF89 , "KP_Tab" ); - KEYVAL ( 0xFF8D , "KP_Enter" ); - KEYVAL ( 0xFF91 , "KP_F1" ); - KEYVAL ( 0xFF92 , "KP_F2" ); - KEYVAL ( 0xFF93 , "KP_F3" ); - KEYVAL ( 0xFF94 , "KP_F4" ); - KEYVAL ( 0xFF95 , "KP_Home" ); - KEYVAL ( 0xFF96 , "KP_Left" ); - KEYVAL ( 0xFF97 , "KP_Up" ); - KEYVAL ( 0xFF98 , "KP_Right" ); - KEYVAL ( 0xFF99 , "KP_Down" ); - KEYVAL ( 0xFF9A , "KP_Page_Up" ); - KEYVAL ( 0xFF9A , "KP_Prior" ); - KEYVAL ( 0xFF9B , "KP_Next" ); - KEYVAL ( 0xFF9B , "KP_Page_Down" ); - KEYVAL ( 0xFF9C , "KP_End" ); - KEYVAL ( 0xFF9D , "KP_Begin" ); - KEYVAL ( 0xFF9E , "KP_Insert" ); - KEYVAL ( 0xFF9F , "KP_Delete" ); - KEYVAL ( 0xFFAA , "KP_Multiply" ); - KEYVAL ( 0xFFAB , "KP_Add" ); - KEYVAL ( 0xFFAC , "KP_Separator" ); - KEYVAL ( 0xFFAD , "KP_Subtract" ); - KEYVAL ( 0xFFAE , "KP_Decimal" ); - KEYVAL ( 0xFFAF , "KP_Divide" ); - KEYVAL ( 0xFFB0 , "KP_0" ); - KEYVAL ( 0xFFB1 , "KP_1" ); - KEYVAL ( 0xFFB2 , "KP_2" ); - KEYVAL ( 0xFFB3 , "KP_3" ); - KEYVAL ( 0xFFB4 , "KP_4" ); - KEYVAL ( 0xFFB5 , "KP_5" ); - KEYVAL ( 0xFFB6 , "KP_6" ); - KEYVAL ( 0xFFB7 , "KP_7" ); - KEYVAL ( 0xFFB8 , "KP_8" ); - KEYVAL ( 0xFFB9 , "KP_9" ); - KEYVAL ( 0xFFBD , "KP_Equal" ); - KEYVAL ( 0xFFBE , "F1" ); - KEYVAL ( 0xFFBF , "F2" ); - KEYVAL ( 0xFFC0 , "F3" ); - KEYVAL ( 0xFFC1 , "F4" ); - KEYVAL ( 0xFFC2 , "F5" ); - KEYVAL ( 0xFFC3 , "F6" ); - KEYVAL ( 0xFFC4 , "F7" ); - KEYVAL ( 0xFFC5 , "F8" ); - KEYVAL ( 0xFFC6 , "F9" ); - KEYVAL ( 0xFFC7 , "F10" ); - KEYVAL ( 0xFFC8 , "F11" ); - KEYVAL ( 0xFFC8 , "L1" ); - KEYVAL ( 0xFFC9 , "F12" ); - KEYVAL ( 0xFFC9 , "L2" ); - KEYVAL ( 0xFFCA , "F13" ); - KEYVAL ( 0xFFCA , "L3" ); - KEYVAL ( 0xFFCB , "F14" ); - KEYVAL ( 0xFFCB , "L4" ); - KEYVAL ( 0xFFCC , "F15" ); - KEYVAL ( 0xFFCC , "L5" ); - KEYVAL ( 0xFFCD , "F16" ); - KEYVAL ( 0xFFCD , "L6" ); - KEYVAL ( 0xFFCE , "F17" ); - KEYVAL ( 0xFFCE , "L7" ); - KEYVAL ( 0xFFCF , "F18" ); - KEYVAL ( 0xFFCF , "L8" ); - KEYVAL ( 0xFFD0 , "F19" ); - KEYVAL ( 0xFFD0 , "L9" ); - KEYVAL ( 0xFFD1 , "F20" ); - KEYVAL ( 0xFFD1 , "L10" ); - KEYVAL ( 0xFFD2 , "F21" ); - KEYVAL ( 0xFFD2 , "R1" ); - KEYVAL ( 0xFFD3 , "F22" ); - KEYVAL ( 0xFFD3 , "R2" ); - KEYVAL ( 0xFFD4 , "F23" ); - KEYVAL ( 0xFFD4 , "R3" ); - KEYVAL ( 0xFFD5 , "F24" ); - KEYVAL ( 0xFFD5 , "R4" ); - KEYVAL ( 0xFFD6 , "F25" ); - KEYVAL ( 0xFFD6 , "R5" ); - KEYVAL ( 0xFFD7 , "F26" ); - KEYVAL ( 0xFFD7 , "R6" ); - KEYVAL ( 0xFFD8 , "F27" ); - KEYVAL ( 0xFFD8 , "R7" ); - KEYVAL ( 0xFFD9 , "F28" ); - KEYVAL ( 0xFFD9 , "R8" ); - KEYVAL ( 0xFFDA , "F29" ); - KEYVAL ( 0xFFDA , "R9" ); - KEYVAL ( 0xFFDB , "F30" ); - KEYVAL ( 0xFFDB , "R10" ); - KEYVAL ( 0xFFDC , "F31" ); - KEYVAL ( 0xFFDC , "R11" ); - KEYVAL ( 0xFFDD , "F32" ); - KEYVAL ( 0xFFDD , "R12" ); - KEYVAL ( 0xFFDE , "F33" ); - KEYVAL ( 0xFFDE , "R13" ); - KEYVAL ( 0xFFDF , "F34" ); - KEYVAL ( 0xFFDF , "R14" ); - KEYVAL ( 0xFFE0 , "F35" ); - KEYVAL ( 0xFFE0 , "R15" ); - KEYVAL ( 0xFFE1 , "Shift_L" ); - KEYVAL ( 0xFFE2 , "Shift_R" ); - KEYVAL ( 0xFFE3 , "Control_L" ); - KEYVAL ( 0xFFE4 , "Control_R" ); - KEYVAL ( 0xFFE5 , "Caps_Lock" ); - KEYVAL ( 0xFFE6 , "Shift_Lock" ); - KEYVAL ( 0xFFE7 , "Meta_L" ); - KEYVAL ( 0xFFE8 , "Meta_R" ); - KEYVAL ( 0xFFE9 , "Alt_L" ); - KEYVAL ( 0xFFEA , "Alt_R" ); - KEYVAL ( 0xFFEB , "Super_L" ); - KEYVAL ( 0xFFEC , "Super_R" ); - KEYVAL ( 0xFFED , "Hyper_L" ); - KEYVAL ( 0xFFEE , "Hyper_R" ); - KEYVAL ( 0xFFFF , "Delete" ); - -/* 0xFFFFFF "VoidSymbol" */ -} +/* keyval_names.cpp - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "keyval_names.h" +/* see */ + +const char * unknown="(unknown)"; +const char * KEYVAL_NAMES[0x10000]; + +const char * KEYNAME(int k) { + const char * s = unknown; + s = KEYVAL_NAMES[k & 0xFFFF]; + return s; +} + +static void KEYVAL(int k, const char * name) { + if (KEYVAL_NAMES[k] == unknown) + KEYVAL_NAMES[k] = name; +} + +void init_keyvals() { + int i; + for (i=0; i<0x10000; i++) + KEYVAL_NAMES[i]=unknown; + + KEYVAL ( 0x0020 , "space" ); + KEYVAL ( 0x0021 , "exclam" ); + KEYVAL ( 0x0022 , "quotedbl" ); + KEYVAL ( 0x0023 , "numbersign" ); + KEYVAL ( 0x0024 , "dollar" ); + KEYVAL ( 0x0025 , "percent" ); + KEYVAL ( 0x0026 , "ampersand" ); + KEYVAL ( 0x0027 , "apostrophe" ); + KEYVAL ( 0x0027 , "quoteright" ); + KEYVAL ( 0x0028 , "parenleft" ); + KEYVAL ( 0x0029 , "parenright" ); + KEYVAL ( 0x002a , "asterisk" ); + KEYVAL ( 0x002b , "plus" ); + KEYVAL ( 0x002c , "comma" ); + KEYVAL ( 0x002d , "minus" ); + KEYVAL ( 0x002e , "period" ); + KEYVAL ( 0x002f , "slash" ); + KEYVAL ( 0x0030 , "0" ); + KEYVAL ( 0x0031 , "1" ); + KEYVAL ( 0x0032 , "2" ); + KEYVAL ( 0x0033 , "3" ); + KEYVAL ( 0x0034 , "4" ); + KEYVAL ( 0x0035 , "5" ); + KEYVAL ( 0x0036 , "6" ); + KEYVAL ( 0x0037 , "7" ); + KEYVAL ( 0x0038 , "8" ); + KEYVAL ( 0x0039 , "9" ); + KEYVAL ( 0x003a , "colon" ); + KEYVAL ( 0x003b , "semicolon" ); + KEYVAL ( 0x003c , "less" ); + KEYVAL ( 0x003d , "equal" ); + KEYVAL ( 0x003e , "greater" ); + KEYVAL ( 0x003f , "question" ); + KEYVAL ( 0x0040 , "at" ); + KEYVAL ( 0x0041 , "A" ); + KEYVAL ( 0x0042 , "B" ); + KEYVAL ( 0x0043 , "C" ); + KEYVAL ( 0x0044 , "D" ); + KEYVAL ( 0x0045 , "E" ); + KEYVAL ( 0x0046 , "F" ); + KEYVAL ( 0x0047 , "G" ); + KEYVAL ( 0x0048 , "H" ); + KEYVAL ( 0x0049 , "I" ); + KEYVAL ( 0x004a , "J" ); + KEYVAL ( 0x004b , "K" ); + KEYVAL ( 0x004c , "L" ); + KEYVAL ( 0x004d , "M" ); + KEYVAL ( 0x004e , "N" ); + KEYVAL ( 0x004f , "O" ); + KEYVAL ( 0x0050 , "P" ); + KEYVAL ( 0x0051 , "Q" ); + KEYVAL ( 0x0052 , "R" ); + KEYVAL ( 0x0053 , "S" ); + KEYVAL ( 0x0054 , "T" ); + KEYVAL ( 0x0055 , "U" ); + KEYVAL ( 0x0056 , "V" ); + KEYVAL ( 0x0057 , "W" ); + KEYVAL ( 0x0058 , "X" ); + KEYVAL ( 0x0059 , "Y" ); + KEYVAL ( 0x005a , "Z" ); + KEYVAL ( 0x005b , "bracketleft" ); + KEYVAL ( 0x005c , "backslash" ); + KEYVAL ( 0x005d , "bracketright" ); + KEYVAL ( 0x005e , "asciicircum" ); + KEYVAL ( 0x005f , "underscore" ); + KEYVAL ( 0x0060 , "grave" ); + KEYVAL ( 0x0060 , "quoteleft" ); + KEYVAL ( 0x0061 , "a" ); + KEYVAL ( 0x0062 , "b" ); + KEYVAL ( 0x0063 , "c" ); + KEYVAL ( 0x0064 , "d" ); + KEYVAL ( 0x0065 , "e" ); + KEYVAL ( 0x0066 , "f" ); + KEYVAL ( 0x0067 , "g" ); + KEYVAL ( 0x0068 , "h" ); + KEYVAL ( 0x0069 , "i" ); + KEYVAL ( 0x006a , "j" ); + KEYVAL ( 0x006b , "k" ); + KEYVAL ( 0x006c , "l" ); + KEYVAL ( 0x006d , "m" ); + KEYVAL ( 0x006e , "n" ); + KEYVAL ( 0x006f , "o" ); + KEYVAL ( 0x0070 , "p" ); + KEYVAL ( 0x0071 , "q" ); + KEYVAL ( 0x0072 , "r" ); + KEYVAL ( 0x0073 , "s" ); + KEYVAL ( 0x0074 , "t" ); + KEYVAL ( 0x0075 , "u" ); + KEYVAL ( 0x0076 , "v" ); + KEYVAL ( 0x0077 , "w" ); + KEYVAL ( 0x0078 , "x" ); + KEYVAL ( 0x0079 , "y" ); + KEYVAL ( 0x007a , "z" ); + KEYVAL ( 0x007b , "braceleft" ); + KEYVAL ( 0x007c , "bar" ); + KEYVAL ( 0x007d , "braceright" ); + KEYVAL ( 0x007e , "asciitilde" ); + KEYVAL ( 0x00a0 , "nobreakspace" ); + KEYVAL ( 0x00a1 , "exclamdown" ); + KEYVAL ( 0x00a2 , "cent" ); + KEYVAL ( 0x00a3 , "sterling" ); + KEYVAL ( 0x00a4 , "currency" ); + KEYVAL ( 0x00a5 , "yen" ); + KEYVAL ( 0x00a6 , "brokenbar" ); + KEYVAL ( 0x00a7 , "section" ); + KEYVAL ( 0x00a8 , "diaeresis" ); + KEYVAL ( 0x00a9 , "copyright" ); + KEYVAL ( 0x00aa , "ordfeminine" ); + KEYVAL ( 0x00ab , "guillemotleft" ); + KEYVAL ( 0x00ac , "notsign" ); + KEYVAL ( 0x00ad , "hyphen" ); + KEYVAL ( 0x00ae , "registered" ); + KEYVAL ( 0x00af , "macron" ); + KEYVAL ( 0x00b0 , "degree" ); + KEYVAL ( 0x00b1 , "plusminus" ); + KEYVAL ( 0x00b2 , "twosuperior" ); + KEYVAL ( 0x00b3 , "threesuperior" ); + KEYVAL ( 0x00b4 , "acute" ); + KEYVAL ( 0x00b5 , "mu" ); + KEYVAL ( 0x00b6 , "paragraph" ); + KEYVAL ( 0x00b7 , "periodcentered" ); + KEYVAL ( 0x00b8 , "cedilla" ); + KEYVAL ( 0x00b9 , "onesuperior" ); + KEYVAL ( 0x00ba , "masculine" ); + KEYVAL ( 0x00bb , "guillemotright" ); + KEYVAL ( 0x00bc , "onequarter" ); + KEYVAL ( 0x00bd , "onehalf" ); + KEYVAL ( 0x00be , "threequarters" ); + KEYVAL ( 0x00bf , "questiondown" ); + KEYVAL ( 0x00c0 , "Agrave" ); + KEYVAL ( 0x00c1 , "Aacute" ); + KEYVAL ( 0x00c2 , "Acircumflex" ); + KEYVAL ( 0x00c3 , "Atilde" ); + KEYVAL ( 0x00c4 , "Adiaeresis" ); + KEYVAL ( 0x00c5 , "Aring" ); + KEYVAL ( 0x00c6 , "AE" ); + KEYVAL ( 0x00c7 , "Ccedilla" ); + KEYVAL ( 0x00c8 , "Egrave" ); + KEYVAL ( 0x00c9 , "Eacute" ); + KEYVAL ( 0x00ca , "Ecircumflex" ); + KEYVAL ( 0x00cb , "Ediaeresis" ); + KEYVAL ( 0x00cc , "Igrave" ); + KEYVAL ( 0x00cd , "Iacute" ); + KEYVAL ( 0x00ce , "Icircumflex" ); + KEYVAL ( 0x00cf , "Idiaeresis" ); + KEYVAL ( 0x00d0 , "ETH" ); + KEYVAL ( 0x00d0 , "Eth" ); + KEYVAL ( 0x00d1 , "Ntilde" ); + KEYVAL ( 0x00d2 , "Ograve" ); + KEYVAL ( 0x00d3 , "Oacute" ); + KEYVAL ( 0x00d4 , "Ocircumflex" ); + KEYVAL ( 0x00d5 , "Otilde" ); + KEYVAL ( 0x00d6 , "Odiaeresis" ); + KEYVAL ( 0x00d7 , "multiply" ); + KEYVAL ( 0x00d8 , "Ooblique" ); + KEYVAL ( 0x00d9 , "Ugrave" ); + KEYVAL ( 0x00da , "Uacute" ); + KEYVAL ( 0x00db , "Ucircumflex" ); + KEYVAL ( 0x00dc , "Udiaeresis" ); + KEYVAL ( 0x00dd , "Yacute" ); + KEYVAL ( 0x00de , "THORN" ); + KEYVAL ( 0x00de , "Thorn" ); + KEYVAL ( 0x00df , "ssharp" ); + KEYVAL ( 0x00e0 , "agrave" ); + KEYVAL ( 0x00e1 , "aacute" ); + KEYVAL ( 0x00e2 , "acircumflex" ); + KEYVAL ( 0x00e3 , "atilde" ); + KEYVAL ( 0x00e4 , "adiaeresis" ); + KEYVAL ( 0x00e5 , "aring" ); + KEYVAL ( 0x00e6 , "ae" ); + KEYVAL ( 0x00e7 , "ccedilla" ); + KEYVAL ( 0x00e8 , "egrave" ); + KEYVAL ( 0x00e9 , "eacute" ); + KEYVAL ( 0x00ea , "ecircumflex" ); + KEYVAL ( 0x00eb , "ediaeresis" ); + KEYVAL ( 0x00ec , "igrave" ); + KEYVAL ( 0x00ed , "iacute" ); + KEYVAL ( 0x00ee , "icircumflex" ); + KEYVAL ( 0x00ef , "idiaeresis" ); + KEYVAL ( 0x00f0 , "eth" ); + KEYVAL ( 0x00f1 , "ntilde" ); + KEYVAL ( 0x00f2 , "ograve" ); + KEYVAL ( 0x00f3 , "oacute" ); + KEYVAL ( 0x00f4 , "ocircumflex" ); + KEYVAL ( 0x00f5 , "otilde" ); + KEYVAL ( 0x00f6 , "odiaeresis" ); + KEYVAL ( 0x00f7 , "division" ); + KEYVAL ( 0x00f8 , "oslash" ); + KEYVAL ( 0x00f9 , "ugrave" ); + KEYVAL ( 0x00fa , "uacute" ); + KEYVAL ( 0x00fb , "ucircumflex" ); + KEYVAL ( 0x00fc , "udiaeresis" ); + KEYVAL ( 0x00fd , "yacute" ); + KEYVAL ( 0x00fe , "thorn" ); + KEYVAL ( 0x00ff , "ydiaeresis" ); + KEYVAL ( 0x01a1 , "Aogonek" ); + KEYVAL ( 0x01a2 , "breve" ); + KEYVAL ( 0x01a3 , "Lstroke" ); + KEYVAL ( 0x01a5 , "Lcaron" ); + KEYVAL ( 0x01a6 , "Sacute" ); + KEYVAL ( 0x01a9 , "Scaron" ); + KEYVAL ( 0x01aa , "Scedilla" ); + KEYVAL ( 0x01ab , "Tcaron" ); + KEYVAL ( 0x01ac , "Zacute" ); + KEYVAL ( 0x01ae , "Zcaron" ); + KEYVAL ( 0x01af , "Zabovedot" ); + KEYVAL ( 0x01b1 , "aogonek" ); + KEYVAL ( 0x01b2 , "ogonek" ); + KEYVAL ( 0x01b3 , "lstroke" ); + KEYVAL ( 0x01b5 , "lcaron" ); + KEYVAL ( 0x01b6 , "sacute" ); + KEYVAL ( 0x01b7 , "caron" ); + KEYVAL ( 0x01b9 , "scaron" ); + KEYVAL ( 0x01ba , "scedilla" ); + KEYVAL ( 0x01bb , "tcaron" ); + KEYVAL ( 0x01bc , "zacute" ); + KEYVAL ( 0x01bd , "doubleacute" ); + KEYVAL ( 0x01be , "zcaron" ); + KEYVAL ( 0x01bf , "zabovedot" ); + KEYVAL ( 0x01c0 , "Racute" ); + KEYVAL ( 0x01c3 , "Abreve" ); + KEYVAL ( 0x01c5 , "Lacute" ); + KEYVAL ( 0x01c6 , "Cacute" ); + KEYVAL ( 0x01c8 , "Ccaron" ); + KEYVAL ( 0x01ca , "Eogonek" ); + KEYVAL ( 0x01cc , "Ecaron" ); + KEYVAL ( 0x01cf , "Dcaron" ); + KEYVAL ( 0x01d0 , "Dstroke" ); + KEYVAL ( 0x01d1 , "Nacute" ); + KEYVAL ( 0x01d2 , "Ncaron" ); + KEYVAL ( 0x01d5 , "Odoubleacute" ); + KEYVAL ( 0x01d8 , "Rcaron" ); + KEYVAL ( 0x01d9 , "Uring" ); + KEYVAL ( 0x01db , "Udoubleacute" ); + KEYVAL ( 0x01de , "Tcedilla" ); + KEYVAL ( 0x01e0 , "racute" ); + KEYVAL ( 0x01e3 , "abreve" ); + KEYVAL ( 0x01e5 , "lacute" ); + KEYVAL ( 0x01e6 , "cacute" ); + KEYVAL ( 0x01e8 , "ccaron" ); + KEYVAL ( 0x01ea , "eogonek" ); + KEYVAL ( 0x01ec , "ecaron" ); + KEYVAL ( 0x01ef , "dcaron" ); + KEYVAL ( 0x01f0 , "dstroke" ); + KEYVAL ( 0x01f1 , "nacute" ); + KEYVAL ( 0x01f2 , "ncaron" ); + KEYVAL ( 0x01f5 , "odoubleacute" ); + KEYVAL ( 0x01f8 , "rcaron" ); + KEYVAL ( 0x01f9 , "uring" ); + KEYVAL ( 0x01fb , "udoubleacute" ); + KEYVAL ( 0x01fe , "tcedilla" ); + KEYVAL ( 0x01ff , "abovedot" ); + KEYVAL ( 0x02a1 , "Hstroke" ); + KEYVAL ( 0x02a6 , "Hcircumflex" ); + KEYVAL ( 0x02a9 , "Iabovedot" ); + KEYVAL ( 0x02ab , "Gbreve" ); + KEYVAL ( 0x02ac , "Jcircumflex" ); + KEYVAL ( 0x02b1 , "hstroke" ); + KEYVAL ( 0x02b6 , "hcircumflex" ); + KEYVAL ( 0x02b9 , "idotless" ); + KEYVAL ( 0x02bb , "gbreve" ); + KEYVAL ( 0x02bc , "jcircumflex" ); + KEYVAL ( 0x02c5 , "Cabovedot" ); + KEYVAL ( 0x02c6 , "Ccircumflex" ); + KEYVAL ( 0x02d5 , "Gabovedot" ); + KEYVAL ( 0x02d8 , "Gcircumflex" ); + KEYVAL ( 0x02dd , "Ubreve" ); + KEYVAL ( 0x02de , "Scircumflex" ); + KEYVAL ( 0x02e5 , "cabovedot" ); + KEYVAL ( 0x02e6 , "ccircumflex" ); + KEYVAL ( 0x02f5 , "gabovedot" ); + KEYVAL ( 0x02f8 , "gcircumflex" ); + KEYVAL ( 0x02fd , "ubreve" ); + KEYVAL ( 0x02fe , "scircumflex" ); + KEYVAL ( 0x03a2 , "kappa" ); + KEYVAL ( 0x03a2 , "kra" ); + KEYVAL ( 0x03a3 , "Rcedilla" ); + KEYVAL ( 0x03a5 , "Itilde" ); + KEYVAL ( 0x03a6 , "Lcedilla" ); + KEYVAL ( 0x03aa , "Emacron" ); + KEYVAL ( 0x03ab , "Gcedilla" ); + KEYVAL ( 0x03ac , "Tslash" ); + KEYVAL ( 0x03b3 , "rcedilla" ); + KEYVAL ( 0x03b5 , "itilde" ); + KEYVAL ( 0x03b6 , "lcedilla" ); + KEYVAL ( 0x03ba , "emacron" ); + KEYVAL ( 0x03bb , "gcedilla" ); + KEYVAL ( 0x03bc , "tslash" ); + KEYVAL ( 0x03bd , "ENG" ); + KEYVAL ( 0x03bf , "eng" ); + KEYVAL ( 0x03c0 , "Amacron" ); + KEYVAL ( 0x03c7 , "Iogonek" ); + KEYVAL ( 0x03cc , "Eabovedot" ); + KEYVAL ( 0x03cf , "Imacron" ); + KEYVAL ( 0x03d1 , "Ncedilla" ); + KEYVAL ( 0x03d2 , "Omacron" ); + KEYVAL ( 0x03d3 , "Kcedilla" ); + KEYVAL ( 0x03d9 , "Uogonek" ); + KEYVAL ( 0x03dd , "Utilde" ); + KEYVAL ( 0x03de , "Umacron" ); + KEYVAL ( 0x03e0 , "amacron" ); + KEYVAL ( 0x03e7 , "iogonek" ); + KEYVAL ( 0x03ec , "eabovedot" ); + KEYVAL ( 0x03ef , "imacron" ); + KEYVAL ( 0x03f1 , "ncedilla" ); + KEYVAL ( 0x03f2 , "omacron" ); + KEYVAL ( 0x03f3 , "kcedilla" ); + KEYVAL ( 0x03f9 , "uogonek" ); + KEYVAL ( 0x03fd , "utilde" ); + KEYVAL ( 0x03fe , "umacron" ); + KEYVAL ( 0x047e , "overline" ); + KEYVAL ( 0x04a1 , "kana_fullstop" ); + KEYVAL ( 0x04a2 , "kana_openingbracket" ); + KEYVAL ( 0x04a3 , "kana_closingbracket" ); + KEYVAL ( 0x04a4 , "kana_comma" ); + KEYVAL ( 0x04a5 , "kana_conjunctive" ); + KEYVAL ( 0x04a5 , "kana_middledot" ); + KEYVAL ( 0x04a6 , "kana_WO" ); + KEYVAL ( 0x04a7 , "kana_a" ); + KEYVAL ( 0x04a8 , "kana_i" ); + KEYVAL ( 0x04a9 , "kana_u" ); + KEYVAL ( 0x04aa , "kana_e" ); + KEYVAL ( 0x04ab , "kana_o" ); + KEYVAL ( 0x04ac , "kana_ya" ); + KEYVAL ( 0x04ad , "kana_yu" ); + KEYVAL ( 0x04ae , "kana_yo" ); + KEYVAL ( 0x04af , "kana_tsu" ); + KEYVAL ( 0x04af , "kana_tu" ); + KEYVAL ( 0x04b0 , "prolongedsound" ); + KEYVAL ( 0x04b1 , "kana_A" ); + KEYVAL ( 0x04b2 , "kana_I" ); + KEYVAL ( 0x04b3 , "kana_U" ); + KEYVAL ( 0x04b4 , "kana_E" ); + KEYVAL ( 0x04b5 , "kana_O" ); + KEYVAL ( 0x04b6 , "kana_KA" ); + KEYVAL ( 0x04b7 , "kana_KI" ); + KEYVAL ( 0x04b8 , "kana_KU" ); + KEYVAL ( 0x04b9 , "kana_KE" ); + KEYVAL ( 0x04ba , "kana_KO" ); + KEYVAL ( 0x04bb , "kana_SA" ); + KEYVAL ( 0x04bc , "kana_SHI" ); + KEYVAL ( 0x04bd , "kana_SU" ); + KEYVAL ( 0x04be , "kana_SE" ); + KEYVAL ( 0x04bf , "kana_SO" ); + KEYVAL ( 0x04c0 , "kana_TA" ); + KEYVAL ( 0x04c1 , "kana_CHI" ); + KEYVAL ( 0x04c1 , "kana_TI" ); + KEYVAL ( 0x04c2 , "kana_TSU" ); + KEYVAL ( 0x04c2 , "kana_TU" ); + KEYVAL ( 0x04c3 , "kana_TE" ); + KEYVAL ( 0x04c4 , "kana_TO" ); + KEYVAL ( 0x04c5 , "kana_NA" ); + KEYVAL ( 0x04c6 , "kana_NI" ); + KEYVAL ( 0x04c7 , "kana_NU" ); + KEYVAL ( 0x04c8 , "kana_NE" ); + KEYVAL ( 0x04c9 , "kana_NO" ); + KEYVAL ( 0x04ca , "kana_HA" ); + KEYVAL ( 0x04cb , "kana_HI" ); + KEYVAL ( 0x04cc , "kana_FU" ); + KEYVAL ( 0x04cc , "kana_HU" ); + KEYVAL ( 0x04cd , "kana_HE" ); + KEYVAL ( 0x04ce , "kana_HO" ); + KEYVAL ( 0x04cf , "kana_MA" ); + KEYVAL ( 0x04d0 , "kana_MI" ); + KEYVAL ( 0x04d1 , "kana_MU" ); + KEYVAL ( 0x04d2 , "kana_ME" ); + KEYVAL ( 0x04d3 , "kana_MO" ); + KEYVAL ( 0x04d4 , "kana_YA" ); + KEYVAL ( 0x04d5 , "kana_YU" ); + KEYVAL ( 0x04d6 , "kana_YO" ); + KEYVAL ( 0x04d7 , "kana_RA" ); + KEYVAL ( 0x04d8 , "kana_RI" ); + KEYVAL ( 0x04d9 , "kana_RU" ); + KEYVAL ( 0x04da , "kana_RE" ); + KEYVAL ( 0x04db , "kana_RO" ); + KEYVAL ( 0x04dc , "kana_WA" ); + KEYVAL ( 0x04dd , "kana_N" ); + KEYVAL ( 0x04de , "voicedsound" ); + KEYVAL ( 0x04df , "semivoicedsound" ); + KEYVAL ( 0x05ac , "Arabic_comma" ); + KEYVAL ( 0x05bb , "Arabic_semicolon" ); + KEYVAL ( 0x05bf , "Arabic_question_mark" ); + KEYVAL ( 0x05c1 , "Arabic_hamza" ); + KEYVAL ( 0x05c2 , "Arabic_maddaonalef" ); + KEYVAL ( 0x05c3 , "Arabic_hamzaonalef" ); + KEYVAL ( 0x05c4 , "Arabic_hamzaonwaw" ); + KEYVAL ( 0x05c5 , "Arabic_hamzaunderalef" ); + KEYVAL ( 0x05c6 , "Arabic_hamzaonyeh" ); + KEYVAL ( 0x05c7 , "Arabic_alef" ); + KEYVAL ( 0x05c8 , "Arabic_beh" ); + KEYVAL ( 0x05c9 , "Arabic_tehmarbuta" ); + KEYVAL ( 0x05ca , "Arabic_teh" ); + KEYVAL ( 0x05cb , "Arabic_theh" ); + KEYVAL ( 0x05cc , "Arabic_jeem" ); + KEYVAL ( 0x05cd , "Arabic_hah" ); + KEYVAL ( 0x05ce , "Arabic_khah" ); + KEYVAL ( 0x05cf , "Arabic_dal" ); + KEYVAL ( 0x05d0 , "Arabic_thal" ); + KEYVAL ( 0x05d1 , "Arabic_ra" ); + KEYVAL ( 0x05d2 , "Arabic_zain" ); + KEYVAL ( 0x05d3 , "Arabic_seen" ); + KEYVAL ( 0x05d4 , "Arabic_sheen" ); + KEYVAL ( 0x05d5 , "Arabic_sad" ); + KEYVAL ( 0x05d6 , "Arabic_dad" ); + KEYVAL ( 0x05d7 , "Arabic_tah" ); + KEYVAL ( 0x05d8 , "Arabic_zah" ); + KEYVAL ( 0x05d9 , "Arabic_ain" ); + KEYVAL ( 0x05da , "Arabic_ghain" ); + KEYVAL ( 0x05e0 , "Arabic_tatweel" ); + KEYVAL ( 0x05e1 , "Arabic_feh" ); + KEYVAL ( 0x05e2 , "Arabic_qaf" ); + KEYVAL ( 0x05e3 , "Arabic_kaf" ); + KEYVAL ( 0x05e4 , "Arabic_lam" ); + KEYVAL ( 0x05e5 , "Arabic_meem" ); + KEYVAL ( 0x05e6 , "Arabic_noon" ); + KEYVAL ( 0x05e7 , "Arabic_ha" ); + KEYVAL ( 0x05e7 , "Arabic_heh" ); + KEYVAL ( 0x05e8 , "Arabic_waw" ); + KEYVAL ( 0x05e9 , "Arabic_alefmaksura" ); + KEYVAL ( 0x05ea , "Arabic_yeh" ); + KEYVAL ( 0x05eb , "Arabic_fathatan" ); + KEYVAL ( 0x05ec , "Arabic_dammatan" ); + KEYVAL ( 0x05ed , "Arabic_kasratan" ); + KEYVAL ( 0x05ee , "Arabic_fatha" ); + KEYVAL ( 0x05ef , "Arabic_damma" ); + KEYVAL ( 0x05f0 , "Arabic_kasra" ); + KEYVAL ( 0x05f1 , "Arabic_shadda" ); + KEYVAL ( 0x05f2 , "Arabic_sukun" ); + KEYVAL ( 0x06a1 , "Serbian_dje" ); + KEYVAL ( 0x06a2 , "Macedonia_gje" ); + KEYVAL ( 0x06a3 , "Cyrillic_io" ); + KEYVAL ( 0x06a4 , "Ukrainian_ie" ); + KEYVAL ( 0x06a4 , "Ukranian_je" ); + KEYVAL ( 0x06a5 , "Macedonia_dse" ); + KEYVAL ( 0x06a6 , "Ukrainian_i" ); + KEYVAL ( 0x06a6 , "Ukranian_i" ); + KEYVAL ( 0x06a7 , "Ukrainian_yi" ); + KEYVAL ( 0x06a7 , "Ukranian_yi" ); + KEYVAL ( 0x06a8 , "Cyrillic_je" ); + KEYVAL ( 0x06a8 , "Serbian_je" ); + KEYVAL ( 0x06a9 , "Cyrillic_lje" ); + KEYVAL ( 0x06a9 , "Serbian_lje" ); + KEYVAL ( 0x06aa , "Cyrillic_nje" ); + KEYVAL ( 0x06aa , "Serbian_nje" ); + KEYVAL ( 0x06ab , "Serbian_tshe" ); + KEYVAL ( 0x06ac , "Macedonia_kje" ); + KEYVAL ( 0x06ad , "Ukrainian_ghe_with_upturn" ); + KEYVAL ( 0x06ae , "Byelorussian_shortu" ); + KEYVAL ( 0x06af , "Cyrillic_dzhe" ); + KEYVAL ( 0x06af , "Serbian_dze" ); + KEYVAL ( 0x06b0 , "numerosign" ); + KEYVAL ( 0x06b1 , "Serbian_DJE" ); + KEYVAL ( 0x06b2 , "Macedonia_GJE" ); + KEYVAL ( 0x06b3 , "Cyrillic_IO" ); + KEYVAL ( 0x06b4 , "Ukrainian_IE" ); + KEYVAL ( 0x06b4 , "Ukranian_JE" ); + KEYVAL ( 0x06b5 , "Macedonia_DSE" ); + KEYVAL ( 0x06b6 , "Ukrainian_I" ); + KEYVAL ( 0x06b6 , "Ukranian_I" ); + KEYVAL ( 0x06b7 , "Ukrainian_YI" ); + KEYVAL ( 0x06b7 , "Ukranian_YI" ); + KEYVAL ( 0x06b8 , "Cyrillic_JE" ); + KEYVAL ( 0x06b8 , "Serbian_JE" ); + KEYVAL ( 0x06b9 , "Cyrillic_LJE" ); + KEYVAL ( 0x06b9 , "Serbian_LJE" ); + KEYVAL ( 0x06ba , "Cyrillic_NJE" ); + KEYVAL ( 0x06ba , "Serbian_NJE" ); + KEYVAL ( 0x06bb , "Serbian_TSHE" ); + KEYVAL ( 0x06bc , "Macedonia_KJE" ); + KEYVAL ( 0x06bd , "Ukrainian_GHE_WITH_UPTURN" ); + KEYVAL ( 0x06be , "Byelorussian_SHORTU" ); + KEYVAL ( 0x06bf , "Cyrillic_DZHE" ); + KEYVAL ( 0x06bf , "Serbian_DZE" ); + KEYVAL ( 0x06c0 , "Cyrillic_yu" ); + KEYVAL ( 0x06c1 , "Cyrillic_a" ); + KEYVAL ( 0x06c2 , "Cyrillic_be" ); + KEYVAL ( 0x06c3 , "Cyrillic_tse" ); + KEYVAL ( 0x06c4 , "Cyrillic_de" ); + KEYVAL ( 0x06c5 , "Cyrillic_ie" ); + KEYVAL ( 0x06c6 , "Cyrillic_ef" ); + KEYVAL ( 0x06c7 , "Cyrillic_ghe" ); + KEYVAL ( 0x06c8 , "Cyrillic_ha" ); + KEYVAL ( 0x06c9 , "Cyrillic_i" ); + KEYVAL ( 0x06ca , "Cyrillic_shorti" ); + KEYVAL ( 0x06cb , "Cyrillic_ka" ); + KEYVAL ( 0x06cc , "Cyrillic_el" ); + KEYVAL ( 0x06cd , "Cyrillic_em" ); + KEYVAL ( 0x06ce , "Cyrillic_en" ); + KEYVAL ( 0x06cf , "Cyrillic_o" ); + KEYVAL ( 0x06d0 , "Cyrillic_pe" ); + KEYVAL ( 0x06d1 , "Cyrillic_ya" ); + KEYVAL ( 0x06d2 , "Cyrillic_er" ); + KEYVAL ( 0x06d3 , "Cyrillic_es" ); + KEYVAL ( 0x06d4 , "Cyrillic_te" ); + KEYVAL ( 0x06d5 , "Cyrillic_u" ); + KEYVAL ( 0x06d6 , "Cyrillic_zhe" ); + KEYVAL ( 0x06d7 , "Cyrillic_ve" ); + KEYVAL ( 0x06d8 , "Cyrillic_softsign" ); + KEYVAL ( 0x06d9 , "Cyrillic_yeru" ); + KEYVAL ( 0x06da , "Cyrillic_ze" ); + KEYVAL ( 0x06db , "Cyrillic_sha" ); + KEYVAL ( 0x06dc , "Cyrillic_e" ); + KEYVAL ( 0x06dd , "Cyrillic_shcha" ); + KEYVAL ( 0x06de , "Cyrillic_che" ); + KEYVAL ( 0x06df , "Cyrillic_hardsign" ); + KEYVAL ( 0x06e0 , "Cyrillic_YU" ); + KEYVAL ( 0x06e1 , "Cyrillic_A" ); + KEYVAL ( 0x06e2 , "Cyrillic_BE" ); + KEYVAL ( 0x06e3 , "Cyrillic_TSE" ); + KEYVAL ( 0x06e4 , "Cyrillic_DE" ); + KEYVAL ( 0x06e5 , "Cyrillic_IE" ); + KEYVAL ( 0x06e6 , "Cyrillic_EF" ); + KEYVAL ( 0x06e7 , "Cyrillic_GHE" ); + KEYVAL ( 0x06e8 , "Cyrillic_HA" ); + KEYVAL ( 0x06e9 , "Cyrillic_I" ); + KEYVAL ( 0x06ea , "Cyrillic_SHORTI" ); + KEYVAL ( 0x06eb , "Cyrillic_KA" ); + KEYVAL ( 0x06ec , "Cyrillic_EL" ); + KEYVAL ( 0x06ed , "Cyrillic_EM" ); + KEYVAL ( 0x06ee , "Cyrillic_EN" ); + KEYVAL ( 0x06ef , "Cyrillic_O" ); + KEYVAL ( 0x06f0 , "Cyrillic_PE" ); + KEYVAL ( 0x06f1 , "Cyrillic_YA" ); + KEYVAL ( 0x06f2 , "Cyrillic_ER" ); + KEYVAL ( 0x06f3 , "Cyrillic_ES" ); + KEYVAL ( 0x06f4 , "Cyrillic_TE" ); + KEYVAL ( 0x06f5 , "Cyrillic_U" ); + KEYVAL ( 0x06f6 , "Cyrillic_ZHE" ); + KEYVAL ( 0x06f7 , "Cyrillic_VE" ); + KEYVAL ( 0x06f8 , "Cyrillic_SOFTSIGN" ); + KEYVAL ( 0x06f9 , "Cyrillic_YERU" ); + KEYVAL ( 0x06fa , "Cyrillic_ZE" ); + KEYVAL ( 0x06fb , "Cyrillic_SHA" ); + KEYVAL ( 0x06fc , "Cyrillic_E" ); + KEYVAL ( 0x06fd , "Cyrillic_SHCHA" ); + KEYVAL ( 0x06fe , "Cyrillic_CHE" ); + KEYVAL ( 0x06ff , "Cyrillic_HARDSIGN" ); + KEYVAL ( 0x07a1 , "Greek_ALPHAaccent" ); + KEYVAL ( 0x07a2 , "Greek_EPSILONaccent" ); + KEYVAL ( 0x07a3 , "Greek_ETAaccent" ); + KEYVAL ( 0x07a4 , "Greek_IOTAaccent" ); + KEYVAL ( 0x07a5 , "Greek_IOTAdieresis" ); + KEYVAL ( 0x07a7 , "Greek_OMICRONaccent" ); + KEYVAL ( 0x07a8 , "Greek_UPSILONaccent" ); + KEYVAL ( 0x07a9 , "Greek_UPSILONdieresis" ); + KEYVAL ( 0x07ab , "Greek_OMEGAaccent" ); + KEYVAL ( 0x07ae , "Greek_accentdieresis" ); + KEYVAL ( 0x07af , "Greek_horizbar" ); + KEYVAL ( 0x07b1 , "Greek_alphaaccent" ); + KEYVAL ( 0x07b2 , "Greek_epsilonaccent" ); + KEYVAL ( 0x07b3 , "Greek_etaaccent" ); + KEYVAL ( 0x07b4 , "Greek_iotaaccent" ); + KEYVAL ( 0x07b5 , "Greek_iotadieresis" ); + KEYVAL ( 0x07b6 , "Greek_iotaaccentdieresis" ); + KEYVAL ( 0x07b7 , "Greek_omicronaccent" ); + KEYVAL ( 0x07b8 , "Greek_upsilonaccent" ); + KEYVAL ( 0x07b9 , "Greek_upsilondieresis" ); + KEYVAL ( 0x07ba , "Greek_upsilonaccentdieresis" ); + KEYVAL ( 0x07bb , "Greek_omegaaccent" ); + KEYVAL ( 0x07c1 , "Greek_ALPHA" ); + KEYVAL ( 0x07c2 , "Greek_BETA" ); + KEYVAL ( 0x07c3 , "Greek_GAMMA" ); + KEYVAL ( 0x07c4 , "Greek_DELTA" ); + KEYVAL ( 0x07c5 , "Greek_EPSILON" ); + KEYVAL ( 0x07c6 , "Greek_ZETA" ); + KEYVAL ( 0x07c7 , "Greek_ETA" ); + KEYVAL ( 0x07c8 , "Greek_THETA" ); + KEYVAL ( 0x07c9 , "Greek_IOTA" ); + KEYVAL ( 0x07ca , "Greek_KAPPA" ); + KEYVAL ( 0x07cb , "Greek_LAMBDA" ); + KEYVAL ( 0x07cb , "Greek_LAMDA" ); + KEYVAL ( 0x07cc , "Greek_MU" ); + KEYVAL ( 0x07cd , "Greek_NU" ); + KEYVAL ( 0x07ce , "Greek_XI" ); + KEYVAL ( 0x07cf , "Greek_OMICRON" ); + KEYVAL ( 0x07d0 , "Greek_PI" ); + KEYVAL ( 0x07d1 , "Greek_RHO" ); + KEYVAL ( 0x07d2 , "Greek_SIGMA" ); + KEYVAL ( 0x07d4 , "Greek_TAU" ); + KEYVAL ( 0x07d5 , "Greek_UPSILON" ); + KEYVAL ( 0x07d6 , "Greek_PHI" ); + KEYVAL ( 0x07d7 , "Greek_CHI" ); + KEYVAL ( 0x07d8 , "Greek_PSI" ); + KEYVAL ( 0x07d9 , "Greek_OMEGA" ); + KEYVAL ( 0x07e1 , "Greek_alpha" ); + KEYVAL ( 0x07e2 , "Greek_beta" ); + KEYVAL ( 0x07e3 , "Greek_gamma" ); + KEYVAL ( 0x07e4 , "Greek_delta" ); + KEYVAL ( 0x07e5 , "Greek_epsilon" ); + KEYVAL ( 0x07e6 , "Greek_zeta" ); + KEYVAL ( 0x07e7 , "Greek_eta" ); + KEYVAL ( 0x07e8 , "Greek_theta" ); + KEYVAL ( 0x07e9 , "Greek_iota" ); + KEYVAL ( 0x07ea , "Greek_kappa" ); + KEYVAL ( 0x07eb , "Greek_lambda" ); + KEYVAL ( 0x07eb , "Greek_lamda" ); + KEYVAL ( 0x07ec , "Greek_mu" ); + KEYVAL ( 0x07ed , "Greek_nu" ); + KEYVAL ( 0x07ee , "Greek_xi" ); + KEYVAL ( 0x07ef , "Greek_omicron" ); + KEYVAL ( 0x07f0 , "Greek_pi" ); + KEYVAL ( 0x07f1 , "Greek_rho" ); + KEYVAL ( 0x07f2 , "Greek_sigma" ); + KEYVAL ( 0x07f3 , "Greek_finalsmallsigma" ); + KEYVAL ( 0x07f4 , "Greek_tau" ); + KEYVAL ( 0x07f5 , "Greek_upsilon" ); + KEYVAL ( 0x07f6 , "Greek_phi" ); + KEYVAL ( 0x07f7 , "Greek_chi" ); + KEYVAL ( 0x07f8 , "Greek_psi" ); + KEYVAL ( 0x07f9 , "Greek_omega" ); + KEYVAL ( 0x08a1 , "leftradical" ); + KEYVAL ( 0x08a2 , "topleftradical" ); + KEYVAL ( 0x08a3 , "horizconnector" ); + KEYVAL ( 0x08a4 , "topintegral" ); + KEYVAL ( 0x08a5 , "botintegral" ); + KEYVAL ( 0x08a6 , "vertconnector" ); + KEYVAL ( 0x08a7 , "topleftsqbracket" ); + KEYVAL ( 0x08a8 , "botleftsqbracket" ); + KEYVAL ( 0x08a9 , "toprightsqbracket" ); + KEYVAL ( 0x08aa , "botrightsqbracket" ); + KEYVAL ( 0x08ab , "topleftparens" ); + KEYVAL ( 0x08ac , "botleftparens" ); + KEYVAL ( 0x08ad , "toprightparens" ); + KEYVAL ( 0x08ae , "botrightparens" ); + KEYVAL ( 0x08af , "leftmiddlecurlybrace" ); + KEYVAL ( 0x08b0 , "rightmiddlecurlybrace" ); + KEYVAL ( 0x08b1 , "topleftsummation" ); + KEYVAL ( 0x08b2 , "botleftsummation" ); + KEYVAL ( 0x08b3 , "topvertsummationconnector" ); + KEYVAL ( 0x08b4 , "botvertsummationconnector" ); + KEYVAL ( 0x08b5 , "toprightsummation" ); + KEYVAL ( 0x08b6 , "botrightsummation" ); + KEYVAL ( 0x08b7 , "rightmiddlesummation" ); + KEYVAL ( 0x08bc , "lessthanequal" ); + KEYVAL ( 0x08bd , "notequal" ); + KEYVAL ( 0x08be , "greaterthanequal" ); + KEYVAL ( 0x08bf , "integral" ); + KEYVAL ( 0x08c0 , "therefore" ); + KEYVAL ( 0x08c1 , "variation" ); + KEYVAL ( 0x08c2 , "infinity" ); + KEYVAL ( 0x08c5 , "nabla" ); + KEYVAL ( 0x08c8 , "approximate" ); + KEYVAL ( 0x08c9 , "similarequal" ); + KEYVAL ( 0x08cd , "ifonlyif" ); + KEYVAL ( 0x08ce , "implies" ); + KEYVAL ( 0x08cf , "identical" ); + KEYVAL ( 0x08d6 , "radical" ); + KEYVAL ( 0x08da , "includedin" ); + KEYVAL ( 0x08db , "includes" ); + KEYVAL ( 0x08dc , "intersection" ); + KEYVAL ( 0x08dd , "union" ); + KEYVAL ( 0x08de , "logicaland" ); + KEYVAL ( 0x08df , "logicalor" ); + KEYVAL ( 0x08ef , "partialderivative" ); + KEYVAL ( 0x08f6 , "function" ); + KEYVAL ( 0x08fb , "leftarrow" ); + KEYVAL ( 0x08fc , "uparrow" ); + KEYVAL ( 0x08fd , "rightarrow" ); + KEYVAL ( 0x08fe , "downarrow" ); + KEYVAL ( 0x09df , "blank" ); + KEYVAL ( 0x09e0 , "soliddiamond" ); + KEYVAL ( 0x09e1 , "checkerboard" ); + KEYVAL ( 0x09e2 , "ht" ); + KEYVAL ( 0x09e3 , "ff" ); + KEYVAL ( 0x09e4 , "cr" ); + KEYVAL ( 0x09e5 , "lf" ); + KEYVAL ( 0x09e8 , "nl" ); + KEYVAL ( 0x09e9 , "vt" ); + KEYVAL ( 0x09ea , "lowrightcorner" ); + KEYVAL ( 0x09eb , "uprightcorner" ); + KEYVAL ( 0x09ec , "upleftcorner" ); + KEYVAL ( 0x09ed , "lowleftcorner" ); + KEYVAL ( 0x09ee , "crossinglines" ); + KEYVAL ( 0x09ef , "horizlinescan1" ); + KEYVAL ( 0x09f0 , "horizlinescan3" ); + KEYVAL ( 0x09f1 , "horizlinescan5" ); + KEYVAL ( 0x09f2 , "horizlinescan7" ); + KEYVAL ( 0x09f3 , "horizlinescan9" ); + KEYVAL ( 0x09f4 , "leftt" ); + KEYVAL ( 0x09f5 , "rightt" ); + KEYVAL ( 0x09f6 , "bott" ); + KEYVAL ( 0x09f7 , "topt" ); + KEYVAL ( 0x09f8 , "vertbar" ); + KEYVAL ( 0x0aa1 , "emspace" ); + KEYVAL ( 0x0aa2 , "enspace" ); + KEYVAL ( 0x0aa3 , "em3space" ); + KEYVAL ( 0x0aa4 , "em4space" ); + KEYVAL ( 0x0aa5 , "digitspace" ); + KEYVAL ( 0x0aa6 , "punctspace" ); + KEYVAL ( 0x0aa7 , "thinspace" ); + KEYVAL ( 0x0aa8 , "hairspace" ); + KEYVAL ( 0x0aa9 , "emdash" ); + KEYVAL ( 0x0aaa , "endash" ); + KEYVAL ( 0x0aac , "signifblank" ); + KEYVAL ( 0x0aae , "ellipsis" ); + KEYVAL ( 0x0aaf , "doubbaselinedot" ); + KEYVAL ( 0x0ab0 , "onethird" ); + KEYVAL ( 0x0ab1 , "twothirds" ); + KEYVAL ( 0x0ab2 , "onefifth" ); + KEYVAL ( 0x0ab3 , "twofifths" ); + KEYVAL ( 0x0ab4 , "threefifths" ); + KEYVAL ( 0x0ab5 , "fourfifths" ); + KEYVAL ( 0x0ab6 , "onesixth" ); + KEYVAL ( 0x0ab7 , "fivesixths" ); + KEYVAL ( 0x0ab8 , "careof" ); + KEYVAL ( 0x0abb , "figdash" ); + KEYVAL ( 0x0abc , "leftanglebracket" ); + KEYVAL ( 0x0abd , "decimalpoint" ); + KEYVAL ( 0x0abe , "rightanglebracket" ); + KEYVAL ( 0x0abf , "marker" ); + KEYVAL ( 0x0ac3 , "oneeighth" ); + KEYVAL ( 0x0ac4 , "threeeighths" ); + KEYVAL ( 0x0ac5 , "fiveeighths" ); + KEYVAL ( 0x0ac6 , "seveneighths" ); + KEYVAL ( 0x0ac9 , "trademark" ); + KEYVAL ( 0x0aca , "signaturemark" ); + KEYVAL ( 0x0acb , "trademarkincircle" ); + KEYVAL ( 0x0acc , "leftopentriangle" ); + KEYVAL ( 0x0acd , "rightopentriangle" ); + KEYVAL ( 0x0ace , "emopencircle" ); + KEYVAL ( 0x0acf , "emopenrectangle" ); + KEYVAL ( 0x0ad0 , "leftsinglequotemark" ); + KEYVAL ( 0x0ad1 , "rightsinglequotemark" ); + KEYVAL ( 0x0ad2 , "leftdoublequotemark" ); + KEYVAL ( 0x0ad3 , "rightdoublequotemark" ); + KEYVAL ( 0x0ad4 , "prescription" ); + KEYVAL ( 0x0ad6 , "minutes" ); + KEYVAL ( 0x0ad7 , "seconds" ); + KEYVAL ( 0x0ad9 , "latincross" ); + KEYVAL ( 0x0ada , "hexagram" ); + KEYVAL ( 0x0adb , "filledrectbullet" ); + KEYVAL ( 0x0adc , "filledlefttribullet" ); + KEYVAL ( 0x0add , "filledrighttribullet" ); + KEYVAL ( 0x0ade , "emfilledcircle" ); + KEYVAL ( 0x0adf , "emfilledrect" ); + KEYVAL ( 0x0ae0 , "enopencircbullet" ); + KEYVAL ( 0x0ae1 , "enopensquarebullet" ); + KEYVAL ( 0x0ae2 , "openrectbullet" ); + KEYVAL ( 0x0ae3 , "opentribulletup" ); + KEYVAL ( 0x0ae4 , "opentribulletdown" ); + KEYVAL ( 0x0ae5 , "openstar" ); + KEYVAL ( 0x0ae6 , "enfilledcircbullet" ); + KEYVAL ( 0x0ae7 , "enfilledsqbullet" ); + KEYVAL ( 0x0ae8 , "filledtribulletup" ); + KEYVAL ( 0x0ae9 , "filledtribulletdown" ); + KEYVAL ( 0x0aea , "leftpointer" ); + KEYVAL ( 0x0aeb , "rightpointer" ); + KEYVAL ( 0x0aec , "club" ); + KEYVAL ( 0x0aed , "diamond" ); + KEYVAL ( 0x0aee , "heart" ); + KEYVAL ( 0x0af0 , "maltesecross" ); + KEYVAL ( 0x0af1 , "dagger" ); + KEYVAL ( 0x0af2 , "doubledagger" ); + KEYVAL ( 0x0af3 , "checkmark" ); + KEYVAL ( 0x0af4 , "ballotcross" ); + KEYVAL ( 0x0af5 , "musicalsharp" ); + KEYVAL ( 0x0af6 , "musicalflat" ); + KEYVAL ( 0x0af7 , "malesymbol" ); + KEYVAL ( 0x0af8 , "femalesymbol" ); + KEYVAL ( 0x0af9 , "telephone" ); + KEYVAL ( 0x0afa , "telephonerecorder" ); + KEYVAL ( 0x0afb , "phonographcopyright" ); + KEYVAL ( 0x0afc , "caret" ); + KEYVAL ( 0x0afd , "singlelowquotemark" ); + KEYVAL ( 0x0afe , "doublelowquotemark" ); + KEYVAL ( 0x0aff , "cursor" ); + KEYVAL ( 0x0ba3 , "leftcaret" ); + KEYVAL ( 0x0ba6 , "rightcaret" ); + KEYVAL ( 0x0ba8 , "downcaret" ); + KEYVAL ( 0x0ba9 , "upcaret" ); + KEYVAL ( 0x0bc0 , "overbar" ); + KEYVAL ( 0x0bc2 , "downtack" ); + KEYVAL ( 0x0bc3 , "upshoe" ); + KEYVAL ( 0x0bc4 , "downstile" ); + KEYVAL ( 0x0bc6 , "underbar" ); + KEYVAL ( 0x0bca , "jot" ); + KEYVAL ( 0x0bcc , "quad" ); + KEYVAL ( 0x0bce , "uptack" ); + KEYVAL ( 0x0bcf , "circle" ); + KEYVAL ( 0x0bd3 , "upstile" ); + KEYVAL ( 0x0bd6 , "downshoe" ); + KEYVAL ( 0x0bd8 , "rightshoe" ); + KEYVAL ( 0x0bda , "leftshoe" ); + KEYVAL ( 0x0bdc , "lefttack" ); + KEYVAL ( 0x0bfc , "righttack" ); + KEYVAL ( 0x0cdf , "hebrew_doublelowline" ); + KEYVAL ( 0x0ce0 , "hebrew_aleph" ); + KEYVAL ( 0x0ce1 , "hebrew_bet" ); + KEYVAL ( 0x0ce1 , "hebrew_beth" ); + KEYVAL ( 0x0ce2 , "hebrew_gimel" ); + KEYVAL ( 0x0ce2 , "hebrew_gimmel" ); + KEYVAL ( 0x0ce3 , "hebrew_dalet" ); + KEYVAL ( 0x0ce3 , "hebrew_daleth" ); + KEYVAL ( 0x0ce4 , "hebrew_he" ); + KEYVAL ( 0x0ce5 , "hebrew_waw" ); + KEYVAL ( 0x0ce6 , "hebrew_zain" ); + KEYVAL ( 0x0ce6 , "hebrew_zayin" ); + KEYVAL ( 0x0ce7 , "hebrew_chet" ); + KEYVAL ( 0x0ce7 , "hebrew_het" ); + KEYVAL ( 0x0ce8 , "hebrew_tet" ); + KEYVAL ( 0x0ce8 , "hebrew_teth" ); + KEYVAL ( 0x0ce9 , "hebrew_yod" ); + KEYVAL ( 0x0cea , "hebrew_finalkaph" ); + KEYVAL ( 0x0ceb , "hebrew_kaph" ); + KEYVAL ( 0x0cec , "hebrew_lamed" ); + KEYVAL ( 0x0ced , "hebrew_finalmem" ); + KEYVAL ( 0x0cee , "hebrew_mem" ); + KEYVAL ( 0x0cef , "hebrew_finalnun" ); + KEYVAL ( 0x0cf0 , "hebrew_nun" ); + KEYVAL ( 0x0cf1 , "hebrew_samech" ); + KEYVAL ( 0x0cf1 , "hebrew_samekh" ); + KEYVAL ( 0x0cf2 , "hebrew_ayin" ); + KEYVAL ( 0x0cf3 , "hebrew_finalpe" ); + KEYVAL ( 0x0cf4 , "hebrew_pe" ); + KEYVAL ( 0x0cf5 , "hebrew_finalzade" ); + KEYVAL ( 0x0cf5 , "hebrew_finalzadi" ); + KEYVAL ( 0x0cf6 , "hebrew_zade" ); + KEYVAL ( 0x0cf6 , "hebrew_zadi" ); + KEYVAL ( 0x0cf7 , "hebrew_kuf" ); + KEYVAL ( 0x0cf7 , "hebrew_qoph" ); + KEYVAL ( 0x0cf8 , "hebrew_resh" ); + KEYVAL ( 0x0cf9 , "hebrew_shin" ); + KEYVAL ( 0x0cfa , "hebrew_taf" ); + KEYVAL ( 0x0cfa , "hebrew_taw" ); + KEYVAL ( 0x0da1 , "Thai_kokai" ); + KEYVAL ( 0x0da2 , "Thai_khokhai" ); + KEYVAL ( 0x0da3 , "Thai_khokhuat" ); + KEYVAL ( 0x0da4 , "Thai_khokhwai" ); + KEYVAL ( 0x0da5 , "Thai_khokhon" ); + KEYVAL ( 0x0da6 , "Thai_khorakhang" ); + KEYVAL ( 0x0da7 , "Thai_ngongu" ); + KEYVAL ( 0x0da8 , "Thai_chochan" ); + KEYVAL ( 0x0da9 , "Thai_choching" ); + KEYVAL ( 0x0daa , "Thai_chochang" ); + KEYVAL ( 0x0dab , "Thai_soso" ); + KEYVAL ( 0x0dac , "Thai_chochoe" ); + KEYVAL ( 0x0dad , "Thai_yoying" ); + KEYVAL ( 0x0dae , "Thai_dochada" ); + KEYVAL ( 0x0daf , "Thai_topatak" ); + KEYVAL ( 0x0db0 , "Thai_thothan" ); + KEYVAL ( 0x0db1 , "Thai_thonangmontho" ); + KEYVAL ( 0x0db2 , "Thai_thophuthao" ); + KEYVAL ( 0x0db3 , "Thai_nonen" ); + KEYVAL ( 0x0db4 , "Thai_dodek" ); + KEYVAL ( 0x0db5 , "Thai_totao" ); + KEYVAL ( 0x0db6 , "Thai_thothung" ); + KEYVAL ( 0x0db7 , "Thai_thothahan" ); + KEYVAL ( 0x0db8 , "Thai_thothong" ); + KEYVAL ( 0x0db9 , "Thai_nonu" ); + KEYVAL ( 0x0dba , "Thai_bobaimai" ); + KEYVAL ( 0x0dbb , "Thai_popla" ); + KEYVAL ( 0x0dbc , "Thai_phophung" ); + KEYVAL ( 0x0dbd , "Thai_fofa" ); + KEYVAL ( 0x0dbe , "Thai_phophan" ); + KEYVAL ( 0x0dbf , "Thai_fofan" ); + KEYVAL ( 0x0dc0 , "Thai_phosamphao" ); + KEYVAL ( 0x0dc1 , "Thai_moma" ); + KEYVAL ( 0x0dc2 , "Thai_yoyak" ); + KEYVAL ( 0x0dc3 , "Thai_rorua" ); + KEYVAL ( 0x0dc4 , "Thai_ru" ); + KEYVAL ( 0x0dc5 , "Thai_loling" ); + KEYVAL ( 0x0dc6 , "Thai_lu" ); + KEYVAL ( 0x0dc7 , "Thai_wowaen" ); + KEYVAL ( 0x0dc8 , "Thai_sosala" ); + KEYVAL ( 0x0dc9 , "Thai_sorusi" ); + KEYVAL ( 0x0dca , "Thai_sosua" ); + KEYVAL ( 0x0dcb , "Thai_hohip" ); + KEYVAL ( 0x0dcc , "Thai_lochula" ); + KEYVAL ( 0x0dcd , "Thai_oang" ); + KEYVAL ( 0x0dce , "Thai_honokhuk" ); + KEYVAL ( 0x0dcf , "Thai_paiyannoi" ); + KEYVAL ( 0x0dd0 , "Thai_saraa" ); + KEYVAL ( 0x0dd1 , "Thai_maihanakat" ); + KEYVAL ( 0x0dd2 , "Thai_saraaa" ); + KEYVAL ( 0x0dd3 , "Thai_saraam" ); + KEYVAL ( 0x0dd4 , "Thai_sarai" ); + KEYVAL ( 0x0dd5 , "Thai_saraii" ); + KEYVAL ( 0x0dd6 , "Thai_saraue" ); + KEYVAL ( 0x0dd7 , "Thai_sarauee" ); + KEYVAL ( 0x0dd8 , "Thai_sarau" ); + KEYVAL ( 0x0dd9 , "Thai_sarauu" ); + KEYVAL ( 0x0dda , "Thai_phinthu" ); + KEYVAL ( 0x0dde , "Thai_maihanakat_maitho" ); + KEYVAL ( 0x0ddf , "Thai_baht" ); + KEYVAL ( 0x0de0 , "Thai_sarae" ); + KEYVAL ( 0x0de1 , "Thai_saraae" ); + KEYVAL ( 0x0de2 , "Thai_sarao" ); + KEYVAL ( 0x0de3 , "Thai_saraaimaimuan" ); + KEYVAL ( 0x0de4 , "Thai_saraaimaimalai" ); + KEYVAL ( 0x0de5 , "Thai_lakkhangyao" ); + KEYVAL ( 0x0de6 , "Thai_maiyamok" ); + KEYVAL ( 0x0de7 , "Thai_maitaikhu" ); + KEYVAL ( 0x0de8 , "Thai_maiek" ); + KEYVAL ( 0x0de9 , "Thai_maitho" ); + KEYVAL ( 0x0dea , "Thai_maitri" ); + KEYVAL ( 0x0deb , "Thai_maichattawa" ); + KEYVAL ( 0x0dec , "Thai_thanthakhat" ); + KEYVAL ( 0x0ded , "Thai_nikhahit" ); + KEYVAL ( 0x0df0 , "Thai_leksun" ); + KEYVAL ( 0x0df1 , "Thai_leknung" ); + KEYVAL ( 0x0df2 , "Thai_leksong" ); + KEYVAL ( 0x0df3 , "Thai_leksam" ); + KEYVAL ( 0x0df4 , "Thai_leksi" ); + KEYVAL ( 0x0df5 , "Thai_lekha" ); + KEYVAL ( 0x0df6 , "Thai_lekhok" ); + KEYVAL ( 0x0df7 , "Thai_lekchet" ); + KEYVAL ( 0x0df8 , "Thai_lekpaet" ); + KEYVAL ( 0x0df9 , "Thai_lekkao" ); + KEYVAL ( 0x0ea1 , "Hangul_Kiyeog" ); + KEYVAL ( 0x0ea2 , "Hangul_SsangKiyeog" ); + KEYVAL ( 0x0ea3 , "Hangul_KiyeogSios" ); + KEYVAL ( 0x0ea4 , "Hangul_Nieun" ); + KEYVAL ( 0x0ea5 , "Hangul_NieunJieuj" ); + KEYVAL ( 0x0ea6 , "Hangul_NieunHieuh" ); + KEYVAL ( 0x0ea7 , "Hangul_Dikeud" ); + KEYVAL ( 0x0ea8 , "Hangul_SsangDikeud" ); + KEYVAL ( 0x0ea9 , "Hangul_Rieul" ); + KEYVAL ( 0x0eaa , "Hangul_RieulKiyeog" ); + KEYVAL ( 0x0eab , "Hangul_RieulMieum" ); + KEYVAL ( 0x0eac , "Hangul_RieulPieub" ); + KEYVAL ( 0x0ead , "Hangul_RieulSios" ); + KEYVAL ( 0x0eae , "Hangul_RieulTieut" ); + KEYVAL ( 0x0eaf , "Hangul_RieulPhieuf" ); + KEYVAL ( 0x0eb0 , "Hangul_RieulHieuh" ); + KEYVAL ( 0x0eb1 , "Hangul_Mieum" ); + KEYVAL ( 0x0eb2 , "Hangul_Pieub" ); + KEYVAL ( 0x0eb3 , "Hangul_SsangPieub" ); + KEYVAL ( 0x0eb4 , "Hangul_PieubSios" ); + KEYVAL ( 0x0eb5 , "Hangul_Sios" ); + KEYVAL ( 0x0eb6 , "Hangul_SsangSios" ); + KEYVAL ( 0x0eb7 , "Hangul_Ieung" ); + KEYVAL ( 0x0eb8 , "Hangul_Jieuj" ); + KEYVAL ( 0x0eb9 , "Hangul_SsangJieuj" ); + KEYVAL ( 0x0eba , "Hangul_Cieuc" ); + KEYVAL ( 0x0ebb , "Hangul_Khieuq" ); + KEYVAL ( 0x0ebc , "Hangul_Tieut" ); + KEYVAL ( 0x0ebd , "Hangul_Phieuf" ); + KEYVAL ( 0x0ebe , "Hangul_Hieuh" ); + KEYVAL ( 0x0ebf , "Hangul_A" ); + KEYVAL ( 0x0ec0 , "Hangul_AE" ); + KEYVAL ( 0x0ec1 , "Hangul_YA" ); + KEYVAL ( 0x0ec2 , "Hangul_YAE" ); + KEYVAL ( 0x0ec3 , "Hangul_EO" ); + KEYVAL ( 0x0ec4 , "Hangul_E" ); + KEYVAL ( 0x0ec5 , "Hangul_YEO" ); + KEYVAL ( 0x0ec6 , "Hangul_YE" ); + KEYVAL ( 0x0ec7 , "Hangul_O" ); + KEYVAL ( 0x0ec8 , "Hangul_WA" ); + KEYVAL ( 0x0ec9 , "Hangul_WAE" ); + KEYVAL ( 0x0eca , "Hangul_OE" ); + KEYVAL ( 0x0ecb , "Hangul_YO" ); + KEYVAL ( 0x0ecc , "Hangul_U" ); + KEYVAL ( 0x0ecd , "Hangul_WEO" ); + KEYVAL ( 0x0ece , "Hangul_WE" ); + KEYVAL ( 0x0ecf , "Hangul_WI" ); + KEYVAL ( 0x0ed0 , "Hangul_YU" ); + KEYVAL ( 0x0ed1 , "Hangul_EU" ); + KEYVAL ( 0x0ed2 , "Hangul_YI" ); + KEYVAL ( 0x0ed3 , "Hangul_I" ); + KEYVAL ( 0x0ed4 , "Hangul_J_Kiyeog" ); + KEYVAL ( 0x0ed5 , "Hangul_J_SsangKiyeog" ); + KEYVAL ( 0x0ed6 , "Hangul_J_KiyeogSios" ); + KEYVAL ( 0x0ed7 , "Hangul_J_Nieun" ); + KEYVAL ( 0x0ed8 , "Hangul_J_NieunJieuj" ); + KEYVAL ( 0x0ed9 , "Hangul_J_NieunHieuh" ); + KEYVAL ( 0x0eda , "Hangul_J_Dikeud" ); + KEYVAL ( 0x0edb , "Hangul_J_Rieul" ); + KEYVAL ( 0x0edc , "Hangul_J_RieulKiyeog" ); + KEYVAL ( 0x0edd , "Hangul_J_RieulMieum" ); + KEYVAL ( 0x0ede , "Hangul_J_RieulPieub" ); + KEYVAL ( 0x0edf , "Hangul_J_RieulSios" ); + KEYVAL ( 0x0ee0 , "Hangul_J_RieulTieut" ); + KEYVAL ( 0x0ee1 , "Hangul_J_RieulPhieuf" ); + KEYVAL ( 0x0ee2 , "Hangul_J_RieulHieuh" ); + KEYVAL ( 0x0ee3 , "Hangul_J_Mieum" ); + KEYVAL ( 0x0ee4 , "Hangul_J_Pieub" ); + KEYVAL ( 0x0ee5 , "Hangul_J_PieubSios" ); + KEYVAL ( 0x0ee6 , "Hangul_J_Sios" ); + KEYVAL ( 0x0ee7 , "Hangul_J_SsangSios" ); + KEYVAL ( 0x0ee8 , "Hangul_J_Ieung" ); + KEYVAL ( 0x0ee9 , "Hangul_J_Jieuj" ); + KEYVAL ( 0x0eea , "Hangul_J_Cieuc" ); + KEYVAL ( 0x0eeb , "Hangul_J_Khieuq" ); + KEYVAL ( 0x0eec , "Hangul_J_Tieut" ); + KEYVAL ( 0x0eed , "Hangul_J_Phieuf" ); + KEYVAL ( 0x0eee , "Hangul_J_Hieuh" ); + KEYVAL ( 0x0eef , "Hangul_RieulYeorinHieuh" ); + KEYVAL ( 0x0ef0 , "Hangul_SunkyeongeumMieum" ); + KEYVAL ( 0x0ef1 , "Hangul_SunkyeongeumPieub" ); + KEYVAL ( 0x0ef2 , "Hangul_PanSios" ); + KEYVAL ( 0x0ef3 , "Hangul_KkogjiDalrinIeung" ); + KEYVAL ( 0x0ef4 , "Hangul_SunkyeongeumPhieuf" ); + KEYVAL ( 0x0ef5 , "Hangul_YeorinHieuh" ); + KEYVAL ( 0x0ef6 , "Hangul_AraeA" ); + KEYVAL ( 0x0ef7 , "Hangul_AraeAE" ); + KEYVAL ( 0x0ef8 , "Hangul_J_PanSios" ); + KEYVAL ( 0x0ef9 , "Hangul_J_KkogjiDalrinIeung" ); + KEYVAL ( 0x0efa , "Hangul_J_YeorinHieuh" ); + KEYVAL ( 0x0eff , "Korean_Won" ); + KEYVAL ( 0x13bc , "OE" ); + KEYVAL ( 0x13bd , "oe" ); + KEYVAL ( 0x13be , "Ydiaeresis" ); + KEYVAL ( 0x20a0 , "EcuSign" ); + KEYVAL ( 0x20a1 , "ColonSign" ); + KEYVAL ( 0x20a2 , "CruzeiroSign" ); + KEYVAL ( 0x20a3 , "FFrancSign" ); + KEYVAL ( 0x20a4 , "LiraSign" ); + KEYVAL ( 0x20a5 , "MillSign" ); + KEYVAL ( 0x20a6 , "NairaSign" ); + KEYVAL ( 0x20a7 , "PesetaSign" ); + KEYVAL ( 0x20a8 , "RupeeSign" ); + KEYVAL ( 0x20a9 , "WonSign" ); + KEYVAL ( 0x20aa , "NewSheqelSign" ); + KEYVAL ( 0x20ab , "DongSign" ); + KEYVAL ( 0x20ac , "EuroSign" ); + KEYVAL ( 0xFD01 , "3270_Duplicate" ); + KEYVAL ( 0xFD02 , "3270_FieldMark" ); + KEYVAL ( 0xFD03 , "3270_Right2" ); + KEYVAL ( 0xFD04 , "3270_Left2" ); + KEYVAL ( 0xFD05 , "3270_BackTab" ); + KEYVAL ( 0xFD06 , "3270_EraseEOF" ); + KEYVAL ( 0xFD07 , "3270_EraseInput" ); + KEYVAL ( 0xFD08 , "3270_Reset" ); + KEYVAL ( 0xFD09 , "3270_Quit" ); + KEYVAL ( 0xFD0A , "3270_PA1" ); + KEYVAL ( 0xFD0B , "3270_PA2" ); + KEYVAL ( 0xFD0C , "3270_PA3" ); + KEYVAL ( 0xFD0D , "3270_Test" ); + KEYVAL ( 0xFD0E , "3270_Attn" ); + KEYVAL ( 0xFD0F , "3270_CursorBlink" ); + KEYVAL ( 0xFD10 , "3270_AltCursor" ); + KEYVAL ( 0xFD11 , "3270_KeyClick" ); + KEYVAL ( 0xFD12 , "3270_Jump" ); + KEYVAL ( 0xFD13 , "3270_Ident" ); + KEYVAL ( 0xFD14 , "3270_Rule" ); + KEYVAL ( 0xFD15 , "3270_Copy" ); + KEYVAL ( 0xFD16 , "3270_Play" ); + KEYVAL ( 0xFD17 , "3270_Setup" ); + KEYVAL ( 0xFD18 , "3270_Record" ); + KEYVAL ( 0xFD19 , "3270_ChangeScreen" ); + KEYVAL ( 0xFD1A , "3270_DeleteWord" ); + KEYVAL ( 0xFD1B , "3270_ExSelect" ); + KEYVAL ( 0xFD1C , "3270_CursorSelect" ); + KEYVAL ( 0xFD1D , "3270_PrintScreen" ); + KEYVAL ( 0xFD1E , "3270_Enter" ); + KEYVAL ( 0xFE01 , "ISO_Lock" ); + KEYVAL ( 0xFE02 , "ISO_Level2_Latch" ); + KEYVAL ( 0xFE03 , "ISO_Level3_Shift" ); + KEYVAL ( 0xFE04 , "ISO_Level3_Latch" ); + KEYVAL ( 0xFE05 , "ISO_Level3_Lock" ); + KEYVAL ( 0xFE06 , "ISO_Group_Latch" ); + KEYVAL ( 0xFE07 , "ISO_Group_Lock" ); + KEYVAL ( 0xFE08 , "ISO_Next_Group" ); + KEYVAL ( 0xFE09 , "ISO_Next_Group_Lock" ); + KEYVAL ( 0xFE0A , "ISO_Prev_Group" ); + KEYVAL ( 0xFE0B , "ISO_Prev_Group_Lock" ); + KEYVAL ( 0xFE0C , "ISO_First_Group" ); + KEYVAL ( 0xFE0D , "ISO_First_Group_Lock" ); + KEYVAL ( 0xFE0E , "ISO_Last_Group" ); + KEYVAL ( 0xFE0F , "ISO_Last_Group_Lock" ); + KEYVAL ( 0xFE20 , "ISO_Left_Tab" ); + KEYVAL ( 0xFE21 , "ISO_Move_Line_Up" ); + KEYVAL ( 0xFE22 , "ISO_Move_Line_Down" ); + KEYVAL ( 0xFE23 , "ISO_Partial_Line_Up" ); + KEYVAL ( 0xFE24 , "ISO_Partial_Line_Down" ); + KEYVAL ( 0xFE25 , "ISO_Partial_Space_Left" ); + KEYVAL ( 0xFE26 , "ISO_Partial_Space_Right" ); + KEYVAL ( 0xFE27 , "ISO_Set_Margin_Left" ); + KEYVAL ( 0xFE28 , "ISO_Set_Margin_Right" ); + KEYVAL ( 0xFE29 , "ISO_Release_Margin_Left" ); + KEYVAL ( 0xFE2A , "ISO_Release_Margin_Right" ); + KEYVAL ( 0xFE2B , "ISO_Release_Both_Margins" ); + KEYVAL ( 0xFE2C , "ISO_Fast_Cursor_Left" ); + KEYVAL ( 0xFE2D , "ISO_Fast_Cursor_Right" ); + KEYVAL ( 0xFE2E , "ISO_Fast_Cursor_Up" ); + KEYVAL ( 0xFE2F , "ISO_Fast_Cursor_Down" ); + KEYVAL ( 0xFE30 , "ISO_Continuous_Underline" ); + KEYVAL ( 0xFE31 , "ISO_Discontinuous_Underline" ); + KEYVAL ( 0xFE32 , "ISO_Emphasize" ); + KEYVAL ( 0xFE33 , "ISO_Center_Object" ); + KEYVAL ( 0xFE34 , "ISO_Enter" ); + KEYVAL ( 0xFE50 , "dead_grave" ); + KEYVAL ( 0xFE51 , "dead_acute" ); + KEYVAL ( 0xFE52 , "dead_circumflex" ); + KEYVAL ( 0xFE53 , "dead_tilde" ); + KEYVAL ( 0xFE54 , "dead_macron" ); + KEYVAL ( 0xFE55 , "dead_breve" ); + KEYVAL ( 0xFE56 , "dead_abovedot" ); + KEYVAL ( 0xFE57 , "dead_diaeresis" ); + KEYVAL ( 0xFE58 , "dead_abovering" ); + KEYVAL ( 0xFE59 , "dead_doubleacute" ); + KEYVAL ( 0xFE5A , "dead_caron" ); + KEYVAL ( 0xFE5B , "dead_cedilla" ); + KEYVAL ( 0xFE5C , "dead_ogonek" ); + KEYVAL ( 0xFE5D , "dead_iota" ); + KEYVAL ( 0xFE5E , "dead_voiced_sound" ); + KEYVAL ( 0xFE5F , "dead_semivoiced_sound" ); + KEYVAL ( 0xFE60 , "dead_belowdot" ); + KEYVAL ( 0xFE61 , "dead_hook" ); + KEYVAL ( 0xFE62 , "dead_horn" ); + KEYVAL ( 0xFE70 , "AccessX_Enable" ); + KEYVAL ( 0xFE71 , "AccessX_Feedback_Enable" ); + KEYVAL ( 0xFE72 , "RepeatKeys_Enable" ); + KEYVAL ( 0xFE73 , "SlowKeys_Enable" ); + KEYVAL ( 0xFE74 , "BounceKeys_Enable" ); + KEYVAL ( 0xFE75 , "StickyKeys_Enable" ); + KEYVAL ( 0xFE76 , "MouseKeys_Enable" ); + KEYVAL ( 0xFE77 , "MouseKeys_Accel_Enable" ); + KEYVAL ( 0xFE78 , "Overlay1_Enable" ); + KEYVAL ( 0xFE79 , "Overlay2_Enable" ); + KEYVAL ( 0xFE7A , "AudibleBell_Enable" ); + KEYVAL ( 0xFED0 , "First_Virtual_Screen" ); + KEYVAL ( 0xFED1 , "Prev_Virtual_Screen" ); + KEYVAL ( 0xFED2 , "Next_Virtual_Screen" ); + KEYVAL ( 0xFED4 , "Last_Virtual_Screen" ); + KEYVAL ( 0xFED5 , "Terminate_Server" ); + KEYVAL ( 0xFEE0 , "Pointer_Left" ); + KEYVAL ( 0xFEE1 , "Pointer_Right" ); + KEYVAL ( 0xFEE2 , "Pointer_Up" ); + KEYVAL ( 0xFEE3 , "Pointer_Down" ); + KEYVAL ( 0xFEE4 , "Pointer_UpLeft" ); + KEYVAL ( 0xFEE5 , "Pointer_UpRight" ); + KEYVAL ( 0xFEE6 , "Pointer_DownLeft" ); + KEYVAL ( 0xFEE7 , "Pointer_DownRight" ); + KEYVAL ( 0xFEE8 , "Pointer_Button_Dflt" ); + KEYVAL ( 0xFEE9 , "Pointer_Button1" ); + KEYVAL ( 0xFEEA , "Pointer_Button2" ); + KEYVAL ( 0xFEEB , "Pointer_Button3" ); + KEYVAL ( 0xFEEC , "Pointer_Button4" ); + KEYVAL ( 0xFEED , "Pointer_Button5" ); + KEYVAL ( 0xFEEE , "Pointer_DblClick_Dflt" ); + KEYVAL ( 0xFEEF , "Pointer_DblClick1" ); + KEYVAL ( 0xFEF0 , "Pointer_DblClick2" ); + KEYVAL ( 0xFEF1 , "Pointer_DblClick3" ); + KEYVAL ( 0xFEF2 , "Pointer_DblClick4" ); + KEYVAL ( 0xFEF3 , "Pointer_DblClick5" ); + KEYVAL ( 0xFEF4 , "Pointer_Drag_Dflt" ); + KEYVAL ( 0xFEF5 , "Pointer_Drag1" ); + KEYVAL ( 0xFEF6 , "Pointer_Drag2" ); + KEYVAL ( 0xFEF7 , "Pointer_Drag3" ); + KEYVAL ( 0xFEF8 , "Pointer_Drag4" ); + KEYVAL ( 0xFEF9 , "Pointer_EnableKeys" ); + KEYVAL ( 0xFEFA , "Pointer_Accelerate" ); + KEYVAL ( 0xFEFB , "Pointer_DfltBtnNext" ); + KEYVAL ( 0xFEFC , "Pointer_DfltBtnPrev" ); + KEYVAL ( 0xFEFD , "Pointer_Drag5" ); + KEYVAL ( 0xFF08 , "BackSpace" ); + KEYVAL ( 0xFF09 , "Tab" ); + KEYVAL ( 0xFF0A , "Linefeed" ); + KEYVAL ( 0xFF0B , "Clear" ); + KEYVAL ( 0xFF0D , "Return" ); + KEYVAL ( 0xFF13 , "Pause" ); + KEYVAL ( 0xFF14 , "Scroll_Lock" ); + KEYVAL ( 0xFF15 , "Sys_Req" ); + KEYVAL ( 0xFF1B , "Escape" ); + KEYVAL ( 0xFF20 , "Multi_key" ); + KEYVAL ( 0xFF21 , "Kanji" ); + KEYVAL ( 0xFF22 , "Muhenkan" ); + KEYVAL ( 0xFF23 , "Henkan" ); + KEYVAL ( 0xFF23 , "Henkan_Mode" ); + KEYVAL ( 0xFF24 , "Romaji" ); + KEYVAL ( 0xFF25 , "Hiragana" ); + KEYVAL ( 0xFF26 , "Katakana" ); + KEYVAL ( 0xFF27 , "Hiragana_Katakana" ); + KEYVAL ( 0xFF28 , "Zenkaku" ); + KEYVAL ( 0xFF29 , "Hankaku" ); + KEYVAL ( 0xFF2A , "Zenkaku_Hankaku" ); + KEYVAL ( 0xFF2B , "Touroku" ); + KEYVAL ( 0xFF2C , "Massyo" ); + KEYVAL ( 0xFF2D , "Kana_Lock" ); + KEYVAL ( 0xFF2E , "Kana_Shift" ); + KEYVAL ( 0xFF2F , "Eisu_Shift" ); + KEYVAL ( 0xFF30 , "Eisu_toggle" ); + KEYVAL ( 0xff31 , "Hangul" ); + KEYVAL ( 0xff32 , "Hangul_Start" ); + KEYVAL ( 0xff33 , "Hangul_End" ); + KEYVAL ( 0xff34 , "Hangul_Hanja" ); + KEYVAL ( 0xff35 , "Hangul_Jamo" ); + KEYVAL ( 0xff36 , "Hangul_Romaja" ); + KEYVAL ( 0xFF37 , "Codeinput" ); + KEYVAL ( 0xff37 , "Hangul_Codeinput" ); + KEYVAL ( 0xFF37 , "Kanji_Bangou" ); + KEYVAL ( 0xff38 , "Hangul_Jeonja" ); + KEYVAL ( 0xff39 , "Hangul_Banja" ); + KEYVAL ( 0xff3a , "Hangul_PreHanja" ); + KEYVAL ( 0xff3b , "Hangul_PostHanja" ); + KEYVAL ( 0xff3c , "Hangul_SingleCandidate" ); + KEYVAL ( 0xFF3C , "SingleCandidate" ); + KEYVAL ( 0xff3d , "Hangul_MultipleCandidate" ); + KEYVAL ( 0xFF3D , "MultipleCandidate" ); + KEYVAL ( 0xFF3D , "Zen_Koho" ); + KEYVAL ( 0xff3e , "Hangul_PreviousCandidate" ); + KEYVAL ( 0xFF3E , "Mae_Koho" ); + KEYVAL ( 0xFF3E , "PreviousCandidate" ); + KEYVAL ( 0xff3f , "Hangul_Special" ); + KEYVAL ( 0xFF50 , "Home" ); + KEYVAL ( 0xFF51 , "Left" ); + KEYVAL ( 0xFF52 , "Up" ); + KEYVAL ( 0xFF53 , "Right" ); + KEYVAL ( 0xFF54 , "Down" ); + KEYVAL ( 0xFF55 , "Page_Up" ); + KEYVAL ( 0xFF55 , "Prior" ); + KEYVAL ( 0xFF56 , "Next" ); + KEYVAL ( 0xFF56 , "Page_Down" ); + KEYVAL ( 0xFF57 , "End" ); + KEYVAL ( 0xFF58 , "Begin" ); + KEYVAL ( 0xFF60 , "Select" ); + KEYVAL ( 0xFF61 , "Print" ); + KEYVAL ( 0xFF62 , "Execute" ); + KEYVAL ( 0xFF63 , "Insert" ); + KEYVAL ( 0xFF65 , "Undo" ); + KEYVAL ( 0xFF66 , "Redo" ); + KEYVAL ( 0xFF67 , "Menu" ); + KEYVAL ( 0xFF68 , "Find" ); + KEYVAL ( 0xFF69 , "Cancel" ); + KEYVAL ( 0xFF6A , "Help" ); + KEYVAL ( 0xFF6B , "Break" ); + KEYVAL ( 0xFF7E , "Arabic_switch" ); + KEYVAL ( 0xFF7E , "Greek_switch" ); + KEYVAL ( 0xFF7E , "Hangul_switch" ); + KEYVAL ( 0xFF7E , "Hebrew_switch" ); + KEYVAL ( 0xFF7E , "ISO_Group_Shift" ); + KEYVAL ( 0xFF7E , "kana_switch" ); + KEYVAL ( 0xFF7E , "Mode_switch" ); + KEYVAL ( 0xFF7E , "script_switch" ); + KEYVAL ( 0xFF7F , "Num_Lock" ); + KEYVAL ( 0xFF80 , "KP_Space" ); + KEYVAL ( 0xFF89 , "KP_Tab" ); + KEYVAL ( 0xFF8D , "KP_Enter" ); + KEYVAL ( 0xFF91 , "KP_F1" ); + KEYVAL ( 0xFF92 , "KP_F2" ); + KEYVAL ( 0xFF93 , "KP_F3" ); + KEYVAL ( 0xFF94 , "KP_F4" ); + KEYVAL ( 0xFF95 , "KP_Home" ); + KEYVAL ( 0xFF96 , "KP_Left" ); + KEYVAL ( 0xFF97 , "KP_Up" ); + KEYVAL ( 0xFF98 , "KP_Right" ); + KEYVAL ( 0xFF99 , "KP_Down" ); + KEYVAL ( 0xFF9A , "KP_Page_Up" ); + KEYVAL ( 0xFF9A , "KP_Prior" ); + KEYVAL ( 0xFF9B , "KP_Next" ); + KEYVAL ( 0xFF9B , "KP_Page_Down" ); + KEYVAL ( 0xFF9C , "KP_End" ); + KEYVAL ( 0xFF9D , "KP_Begin" ); + KEYVAL ( 0xFF9E , "KP_Insert" ); + KEYVAL ( 0xFF9F , "KP_Delete" ); + KEYVAL ( 0xFFAA , "KP_Multiply" ); + KEYVAL ( 0xFFAB , "KP_Add" ); + KEYVAL ( 0xFFAC , "KP_Separator" ); + KEYVAL ( 0xFFAD , "KP_Subtract" ); + KEYVAL ( 0xFFAE , "KP_Decimal" ); + KEYVAL ( 0xFFAF , "KP_Divide" ); + KEYVAL ( 0xFFB0 , "KP_0" ); + KEYVAL ( 0xFFB1 , "KP_1" ); + KEYVAL ( 0xFFB2 , "KP_2" ); + KEYVAL ( 0xFFB3 , "KP_3" ); + KEYVAL ( 0xFFB4 , "KP_4" ); + KEYVAL ( 0xFFB5 , "KP_5" ); + KEYVAL ( 0xFFB6 , "KP_6" ); + KEYVAL ( 0xFFB7 , "KP_7" ); + KEYVAL ( 0xFFB8 , "KP_8" ); + KEYVAL ( 0xFFB9 , "KP_9" ); + KEYVAL ( 0xFFBD , "KP_Equal" ); + KEYVAL ( 0xFFBE , "F1" ); + KEYVAL ( 0xFFBF , "F2" ); + KEYVAL ( 0xFFC0 , "F3" ); + KEYVAL ( 0xFFC1 , "F4" ); + KEYVAL ( 0xFFC2 , "F5" ); + KEYVAL ( 0xFFC3 , "F6" ); + KEYVAL ( 0xFFC4 , "F7" ); + KEYVAL ( 0xFFC5 , "F8" ); + KEYVAL ( 0xFFC6 , "F9" ); + KEYVAL ( 0xFFC7 , "F10" ); + KEYVAL ( 0xFFC8 , "F11" ); + KEYVAL ( 0xFFC8 , "L1" ); + KEYVAL ( 0xFFC9 , "F12" ); + KEYVAL ( 0xFFC9 , "L2" ); + KEYVAL ( 0xFFCA , "F13" ); + KEYVAL ( 0xFFCA , "L3" ); + KEYVAL ( 0xFFCB , "F14" ); + KEYVAL ( 0xFFCB , "L4" ); + KEYVAL ( 0xFFCC , "F15" ); + KEYVAL ( 0xFFCC , "L5" ); + KEYVAL ( 0xFFCD , "F16" ); + KEYVAL ( 0xFFCD , "L6" ); + KEYVAL ( 0xFFCE , "F17" ); + KEYVAL ( 0xFFCE , "L7" ); + KEYVAL ( 0xFFCF , "F18" ); + KEYVAL ( 0xFFCF , "L8" ); + KEYVAL ( 0xFFD0 , "F19" ); + KEYVAL ( 0xFFD0 , "L9" ); + KEYVAL ( 0xFFD1 , "F20" ); + KEYVAL ( 0xFFD1 , "L10" ); + KEYVAL ( 0xFFD2 , "F21" ); + KEYVAL ( 0xFFD2 , "R1" ); + KEYVAL ( 0xFFD3 , "F22" ); + KEYVAL ( 0xFFD3 , "R2" ); + KEYVAL ( 0xFFD4 , "F23" ); + KEYVAL ( 0xFFD4 , "R3" ); + KEYVAL ( 0xFFD5 , "F24" ); + KEYVAL ( 0xFFD5 , "R4" ); + KEYVAL ( 0xFFD6 , "F25" ); + KEYVAL ( 0xFFD6 , "R5" ); + KEYVAL ( 0xFFD7 , "F26" ); + KEYVAL ( 0xFFD7 , "R6" ); + KEYVAL ( 0xFFD8 , "F27" ); + KEYVAL ( 0xFFD8 , "R7" ); + KEYVAL ( 0xFFD9 , "F28" ); + KEYVAL ( 0xFFD9 , "R8" ); + KEYVAL ( 0xFFDA , "F29" ); + KEYVAL ( 0xFFDA , "R9" ); + KEYVAL ( 0xFFDB , "F30" ); + KEYVAL ( 0xFFDB , "R10" ); + KEYVAL ( 0xFFDC , "F31" ); + KEYVAL ( 0xFFDC , "R11" ); + KEYVAL ( 0xFFDD , "F32" ); + KEYVAL ( 0xFFDD , "R12" ); + KEYVAL ( 0xFFDE , "F33" ); + KEYVAL ( 0xFFDE , "R13" ); + KEYVAL ( 0xFFDF , "F34" ); + KEYVAL ( 0xFFDF , "R14" ); + KEYVAL ( 0xFFE0 , "F35" ); + KEYVAL ( 0xFFE0 , "R15" ); + KEYVAL ( 0xFFE1 , "Shift_L" ); + KEYVAL ( 0xFFE2 , "Shift_R" ); + KEYVAL ( 0xFFE3 , "Control_L" ); + KEYVAL ( 0xFFE4 , "Control_R" ); + KEYVAL ( 0xFFE5 , "Caps_Lock" ); + KEYVAL ( 0xFFE6 , "Shift_Lock" ); + KEYVAL ( 0xFFE7 , "Meta_L" ); + KEYVAL ( 0xFFE8 , "Meta_R" ); + KEYVAL ( 0xFFE9 , "Alt_L" ); + KEYVAL ( 0xFFEA , "Alt_R" ); + KEYVAL ( 0xFFEB , "Super_L" ); + KEYVAL ( 0xFFEC , "Super_R" ); + KEYVAL ( 0xFFED , "Hyper_L" ); + KEYVAL ( 0xFFEE , "Hyper_R" ); + KEYVAL ( 0xFFFF , "Delete" ); + +/* 0xFFFFFF "VoidSymbol" */ +} diff --git a/desmume/src/gtk-glade/keyval_names.h b/src/gtk-glade/keyval_names.h old mode 100755 new mode 100644 similarity index 97% rename from desmume/src/gtk-glade/keyval_names.h rename to src/gtk-glade/keyval_names.h index d6bebf976..af314b3ff --- a/desmume/src/gtk-glade/keyval_names.h +++ b/src/gtk-glade/keyval_names.h @@ -1,23 +1,23 @@ -/* keyval_names.h - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -const char * KEYNAME(int k); -void init_keyvals(); +/* keyval_names.h - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +const char * KEYNAME(int k); +void init_keyvals(); diff --git a/desmume/src/gtk-glade/main.cpp b/src/gtk-glade/main.cpp old mode 100755 new mode 100644 similarity index 96% rename from desmume/src/gtk-glade/main.cpp rename to src/gtk-glade/main.cpp index 732b9feee..64da6a427 --- a/desmume/src/gtk-glade/main.cpp +++ b/src/gtk-glade/main.cpp @@ -1,638 +1,638 @@ -/* main.c - this file is part of DeSmuME - * - * Copyright (C) 2007 Damien Nozay (damdoum) - * Copyright (C) 2007 Pascal Giard (evilynux) - * Author: damdoum at users.sourceforge.net - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "callbacks.h" -#include "callbacks_IO.h" -#include "dTools/callbacks_dtools.h" -#include "globals.h" -#include "keyval_names.h" -#include "rasterize.h" -#include "desmume.h" - -#ifdef GDB_STUB -#include "../gdbstub.h" -#endif - -#ifdef GTKGLEXT_AVAILABLE -#include -#include "../OGLRender.h" -#include "gdk_3Demu.h" -#endif - -int glade_fps_limiter_disabled = 0; - -GtkWidget * pWindow; -GtkWidget * pDrawingArea, * pDrawingArea2; -GladeXML * xml, * xml_tools; - -const u16 gtk_kb_cfg[NB_KEYS] = - { - GDK_x, // A - GDK_z, // B - GDK_Shift_R, // select - GDK_Return, // start - GDK_Right, // Right - GDK_Left, // Left - GDK_Up, // Up - GDK_Down, // Down - GDK_w, // R - GDK_q, // L - GDK_s, // X - GDK_a, // Y - GDK_p, // DEBUG - GDK_o // BOOST - }; - -SoundInterface_struct *SNDCoreList[] = { -&SNDDummy, -&SNDDummy, -&SNDSDL, -NULL -}; - -GPU3DInterface *core3DList[] = { -&gpu3DNull, -&gpu3DRasterize -#ifdef GTKGLEXT_AVAILABLE - , - &gpu3Dgl -#endif -}; - -/* - * - * Command line handling - * - */ -struct configured_features { - int load_slot; - int software_colour_convert; - int opengl_2d; - int engine_3d; - int disable_limiter; - int savetype; - - u16 arm9_gdb_port; - u16 arm7_gdb_port; - - int firmware_language; - - const char *nds_file; -}; - -static void -init_configured_features( struct configured_features *config) { - config->load_slot = 0; - config->arm9_gdb_port = 0; - config->arm7_gdb_port = 0; - - config->software_colour_convert = 0; - - config->opengl_2d = 0; - config->engine_3d = 1; - - config->disable_limiter = 0; - config->savetype = 0; - - config->nds_file = NULL; - - /* use the default language */ - config->firmware_language = -1; -} - -static int -fill_configured_features( struct configured_features *config, - int argc, char ** argv) { - int good_args = 1; - int print_usage = 0; - int i; - - for ( i = 1; i < argc && good_args; i++) { - if ( strcmp( argv[i], "--help") == 0) { - g_print( _("USAGE: %s [OPTIONS] [nds-file]\n"), argv[0]); - g_print( _("OPTIONS:\n")); - g_print( _("\ - --load-slot=NUM Load game saved under NUM position.\n\n")); -#ifdef GTKGLEXT_AVAILABLE - g_print( _("\ - --soft-convert Use software colour conversion during OpenGL\n\ - screen rendering. May produce better or worse\n\ - frame rates depending on hardware.\n\n")); -#endif - g_print( _("\ - --3d-engine=ENGINE Selects 3D rendering engine\n\ - 0 = disabled\n\ - 1 = internal desmume rasterizer (default)\n")); -#ifdef GTKGLEXT_AVAILABLE - g_print( _("\ - 2 = gtkglext off-screen 3d opengl\n\n")); -#endif - g_print( _("\ - --disable-limiter Disables the 60 fps limiter\n\n")); - g_print( _("\ - --save-type=TYPE Selects savetype:\n\ - 0 = Autodetect (default)\n\ - 1 = EEPROM 4kbit\n\ - 2 = EEPROM 64kbit\n\ - 3 = EEPROM 512kbit\n\ - 4 = FRAM 256kbit\n\ - 5 = FLASH 2mbit\n\ - 6 = FLASH 4mbit\n\ - \n")); - g_print( _("\ - --fwlang=LANG Set the language in the firmware, LANG as follows:\n\ - 0 = Japanese\n\ - 1 = English\n\ - 2 = French\n\ - 3 = German\n\ - 4 = Italian\n\ - 5 = Spanish\n\n")); -#ifdef GDB_STUB - g_print( _("\ - --arm9gdb=PORT_NUM Enable the ARM9 GDB stub on the given port\n\ - --arm7gdb=PORT_NUM Enable the ARM7 GDB stub on the given port\n\n")); -#endif - g_print( _("\ - --help Display this message\n")); - //g_print(" --sticky Enable sticky keys and stylus\n"); - good_args = 0; - } - else if ( strncmp( argv[i], "--load-slot=", 12) == 0) { - char *end_char; - int slot = strtoul( &argv[i][12], &end_char, 10); - - if ( slot >= 0 && slot <= 10) { - config->load_slot = slot; - } - else { - g_printerr( _("I only know how to load from slots 1-10.\n")); - good_args = 0; - } - } -#ifdef GTKGLEXT_AVAILABLE - else if ( strcmp( argv[i], "--opengl-2d") == 0) { - // FIXME: to be implemented - config->opengl_2d = 1; - } - else if ( strcmp( argv[i], "--soft-convert") == 0) { - config->software_colour_convert = 1; - } -#define MAX3DEMU 2 -#else -#define MAX3DEMU 1 -#endif - else if ( strncmp( argv[i], "--3d-engine=", 12) == 0) { - char *end_char; - int engine = strtoul( &argv[i][12], &end_char, 10); - - if ( engine >= 0 && engine <= MAX3DEMU) { - config->engine_3d = engine; - } - else { - g_printerr( _("Supported 3d engines: 0, 1, and on some machines 2; use --help option for details\n")); - good_args = 0; - } - } - else if ( strncmp( argv[i], "--save-type=", 12) == 0) { - char *end_char; - int type = strtoul( &argv[i][12], &end_char, 10); - - if ( type >= 0 && type <= 6) { - config->savetype = type; - } - else { - g_printerr( _("select savetype from 0 to 6; use --help option for details\n")); - good_args = 0; - } - } - else if ( strncmp( argv[i], "--fwlang=", 9) == 0) { - char *end_char; - int lang = strtoul( &argv[i][9], &end_char, 10); - - if ( lang >= 0 && lang <= 5) { - config->firmware_language = lang; - } - else { - g_printerr( _("Firmware language must be set to a value from 0 to 5.\n")); - good_args = 0; - } - } -#ifdef GDB_STUB - else if ( strncmp( argv[i], "--arm9gdb=", 10) == 0) { - char *end_char; - unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); - - if ( port_num > 0 && port_num < 65536) { - config->arm9_gdb_port = port_num; - } - else { - g_print( _("ARM9 GDB stub port must be in the range 1 to 65535\n")); - good_args = 0; - } - } - else if ( strncmp( argv[i], "--arm7gdb=", 10) == 0) { - char *end_char; - unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); - - if ( port_num > 0 && port_num < 65536) { - config->arm7_gdb_port = port_num; - } - else { - g_print( _("ARM7 GDB stub port must be in the range 1 to 65535\n")); - good_args = 0; - } - } -#endif - else if ( strcmp( argv[i], "--disable-limiter") == 0) { - config->disable_limiter = 1; - } - else { - if ( config->nds_file == NULL) { - config->nds_file = argv[i]; - } - else { - g_print( _("NDS file (\"%s\") already set\n"), config->nds_file); - good_args = 0; - } - } - } - - if ( good_args) { - /* - * check if the configured features are consistant - */ - } - - if ( print_usage) { - g_print( _("USAGE: %s [options] [nds-file]\n"), argv[0]); - g_print( _("USAGE: %s --help - for help\n"), argv[0]); - } - - return good_args; -} - - - -/* ***** ***** TOOLS ***** ***** */ - -GList * tools_to_update = NULL; - -// register tool -void register_Tool(VoidFunPtr fun) { - tools_to_update = g_list_append(tools_to_update, (void *) fun); -} -void unregister_Tool(VoidFunPtr fun) { - if (tools_to_update == NULL) return; - tools_to_update = g_list_remove(tools_to_update, (void *) fun); -} - -static void notify_Tool (VoidFunPtr fun, gpointer func_data) { - fun(); -} - -void notify_Tools() { - g_list_foreach(tools_to_update, (GFunc)notify_Tool, NULL); -} - -/* Return the glade directory. - Note: See configure.ac for the value of GLADEUI_UNINSTALLED_DIR. */ -gchar * get_ui_file (const char *filename) -{ - gchar *path; - - /* looking in uninstalled (aka building) dir first */ - path = g_build_filename (GLADEUI_UNINSTALLED_DIR, filename, NULL); - if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) return path; - g_free (path); - - /* looking in installed dir */ - path = g_build_filename (DATADIR, filename, NULL); - if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) return path; - g_free (path); - - /* not found */ - return NULL; -} - - -/* ***** ***** CONFIG FILE ***** ***** */ -char * CONFIG_FILE; - -static int Read_ConfigFile() -{ - int i, tmp; - GKeyFile * keyfile = g_key_file_new(); - GError * error = NULL; - - load_default_config(gtk_kb_cfg); - - g_key_file_load_from_file(keyfile, CONFIG_FILE, G_KEY_FILE_NONE, 0); - - /* Load keypad keys */ - for(i = 0; i < NB_KEYS; i++) - { - tmp = g_key_file_get_integer(keyfile, "KEYS", key_names[i], &error); - if (error != NULL) { - g_error_free(error); - error = NULL; - } else { - keyboard_cfg[i] = tmp; - } - } - - /* Load joypad keys */ - for(i = 0; i < NB_KEYS; i++) - { - tmp = g_key_file_get_integer(keyfile, "JOYKEYS", key_names[i], &error); - if (error != NULL) { - g_error_free(error); - error = NULL; - } else { - joypad_cfg[i] = tmp; - } - } - - g_key_file_free(keyfile); - - return 0; -} - -static int Write_ConfigFile() -{ - int i; - GKeyFile * keyfile; - gchar *contents; - - keyfile = g_key_file_new(); - - for(i = 0; i < NB_KEYS; i++) - { - g_key_file_set_integer(keyfile, "KEYS", key_names[i], keyboard_cfg[i]); - g_key_file_set_integer(keyfile, "JOYKEYS", key_names[i], joypad_cfg[i]); - } - - contents = g_key_file_to_data(keyfile, 0, 0); - g_file_set_contents(CONFIG_FILE, contents, -1, 0); - g_free(contents); - - g_key_file_free(keyfile); - - return 0; -} - - -/* - * The thread handling functions needed by the GDB stub code. - */ -#ifdef GDB_STUB -void * -createThread_gdb( void (*thread_function)( void *data), - void *thread_data) { - GThread *new_thread = g_thread_create( (GThreadFunc)thread_function, - thread_data, - TRUE, - NULL); - - return new_thread; -} - -void -joinThread_gdb( void *thread_handle) { - g_thread_join((GThread *) thread_handle); -} -#endif - - -/* ***** ***** MAIN ***** ***** */ - -static int -common_gtk_glade_main( struct configured_features *my_config) { - /*SDL_TimerID limiter_timer;*/ -#ifdef GDB_STUB - gdbstub_handle_t arm9_gdb_stub; - gdbstub_handle_t arm7_gdb_stub; -#endif - struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; - struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; - struct armcpu_ctrl_iface *arm9_ctrl_iface; - struct armcpu_ctrl_iface *arm7_ctrl_iface; - /* the firmware settings */ - struct NDS_fw_config_data fw_config; - gchar *uifile; - - /* default the firmware settings, they may get changed later */ - NDS_FillDefaultFirmwareConfigData( &fw_config); - - /* use any language set on the command line */ - if ( my_config->firmware_language != -1) { - fw_config.language = my_config->firmware_language; - } - desmume_savetype(my_config->savetype); - -#ifdef GTKGLEXT_AVAILABLE -// check if you have GTHREAD when running configure script - //g_thread_init(NULL); - register_gl_fun(my_gl_Begin,my_gl_End); -#endif - init_keyvals(); - -#ifdef GDB_STUB - if ( my_config->arm9_gdb_port != 0) { - arm9_gdb_stub = createStub_gdb( my_config->arm9_gdb_port, - &arm9_memio, - &arm9_base_memory_iface); - - if ( arm9_gdb_stub == NULL) { - g_print( _("Failed to create ARM9 gdbstub on port %d\n"), - my_config->arm9_gdb_port); - return -1; - } - } - if ( my_config->arm7_gdb_port != 0) { - arm7_gdb_stub = createStub_gdb( my_config->arm7_gdb_port, - &arm7_memio, - &arm7_base_memory_iface); - - if ( arm7_gdb_stub == NULL) { - g_print( _("Failed to create ARM7 gdbstub on port %d\n"), - my_config->arm7_gdb_port); - return -1; - } - } -#endif - - if(SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO) == -1) - { - fprintf(stderr, _("Error trying to initialize SDL: %s\n"), - SDL_GetError()); - return 1; - } - - desmume_init( arm9_memio, &arm9_ctrl_iface, - arm7_memio, &arm7_ctrl_iface); - - - /* Create the dummy firmware */ - NDS_CreateDummyFirmware( &fw_config); - - /* - * Activate the GDB stubs - * This has to come after the NDS_Init (called in desmume_init) - * where the cpus are set up. - */ -#ifdef GDB_STUB - if ( my_config->arm9_gdb_port != 0) { - activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); - } - if ( my_config->arm7_gdb_port != 0) { - activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); - } -#endif - - /* Initialize joysticks */ - if(!init_joy()) return 1; - - CONFIG_FILE = g_build_filename(g_get_home_dir(), ".desmume.ini", NULL); - Read_ConfigFile(); - - /* load the interface */ - uifile = get_ui_file("DeSmuMe.glade"); - xml = glade_xml_new(uifile, NULL, NULL); - g_free (uifile); - uifile = get_ui_file("DeSmuMe_Dtools.glade"); - xml_tools = glade_xml_new(uifile, NULL, NULL); - g_free (uifile); - pWindow = glade_xml_get_widget(xml, "wMainW"); - pDrawingArea = glade_xml_get_widget(xml, "wDraw_Main"); - pDrawingArea2 = glade_xml_get_widget(xml, "wDraw_Sub"); - - { - char wdgName[40]; - snprintf(wdgName, 39, "savetype%d", my_config->savetype+1); - GtkWidget * wdgt = glade_xml_get_widget(xml, wdgName); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (wdgt), TRUE); - } - - /* connect the signals in the interface */ - glade_xml_signal_autoconnect_StringObject(xml); - glade_xml_signal_autoconnect_StringObject(xml_tools); - - init_GL_capabilities( my_config->software_colour_convert); - - /* check command line file */ - if( my_config->nds_file) { - if(desmume_open( my_config->nds_file) >= 0) { - loadstate_slot( my_config->load_slot); - desmume_resume(); - enable_rom_features(); - } else { - GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pWindow), - GTK_DIALOG_MODAL, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Unable to load :\n%s"), my_config->nds_file); - gtk_dialog_run(GTK_DIALOG(pDialog)); - gtk_widget_destroy(pDialog); - } - } - - gtk_widget_show(pDrawingArea); - gtk_widget_show(pDrawingArea2); - - { - int engine = my_config->engine_3d; - -#ifdef GTKGLEXT_AVAILABLE - if ( my_config->engine_3d==2 ) - /* setup the gdk 3D emulation */ - if(!init_opengl_gdk_3Demu(GDK_DRAWABLE(pWindow->window))){ - fprintf( stderr, _("Failed to initialise openGL 3D emulation; " - "removing 3D support\n")); - engine = 0; - } -#endif - NDS_3D_ChangeCore(engine); - if(my_config->engine_3d != 0 && gpu3D == GPU3D_NULL) - fprintf(stderr, _("Failed to setup 3D engine; removing 3D support\n")); - } - -// on_menu_tileview_activate(NULL,NULL); - - /* setup the frame limiter and indicate if it is disabled */ - glade_fps_limiter_disabled = my_config->disable_limiter; - - /* start event loop */ - gtk_main(); - desmume_free(); - - /* Unload joystick */ - uninit_joy(); - - SDL_Quit(); - Write_ConfigFile(); - return EXIT_SUCCESS; -} - -int main(int argc, char *argv[]) { - struct configured_features my_config; - - // Localization - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - init_configured_features( &my_config); - - if (!g_thread_supported()) - g_thread_init( NULL); - - gtk_init(&argc, &argv); - -#ifdef GTKGLEXT_AVAILABLE - gtk_gl_init( &argc, &argv); -#endif - - if ( !fill_configured_features( &my_config, argc, argv)) { - exit(0); - } - - return common_gtk_glade_main( &my_config); -} - - -#ifdef WIN32 -int WinMain ( HINSTANCE hThisInstance, HINSTANCE hPrevInstance, - LPSTR lpszArgument, int nFunsterStil) -{ - int argc = 0; - char *argv[] = NULL; - - /* - * FIXME: - * Emulate the argc and argv main parameters. Could do this using - * CommandLineToArgvW and then convert the wide chars to thin chars. - * Or parse the wide chars directly and call common_gtk_glade_main with a - * filled configuration structure. - */ - main( argc, argv); -} -#endif +/* main.c - this file is part of DeSmuME + * + * Copyright (C) 2007 Damien Nozay (damdoum) + * Copyright (C) 2007 Pascal Giard (evilynux) + * Author: damdoum at users.sourceforge.net + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "callbacks.h" +#include "callbacks_IO.h" +#include "dTools/callbacks_dtools.h" +#include "globals.h" +#include "keyval_names.h" +#include "rasterize.h" +#include "desmume.h" + +#ifdef GDB_STUB +#include "../gdbstub.h" +#endif + +#ifdef GTKGLEXT_AVAILABLE +#include +#include "../OGLRender.h" +#include "gdk_3Demu.h" +#endif + +int glade_fps_limiter_disabled = 0; + +GtkWidget * pWindow; +GtkWidget * pDrawingArea, * pDrawingArea2; +GladeXML * xml, * xml_tools; + +const u16 gtk_kb_cfg[NB_KEYS] = + { + GDK_x, // A + GDK_z, // B + GDK_Shift_R, // select + GDK_Return, // start + GDK_Right, // Right + GDK_Left, // Left + GDK_Up, // Up + GDK_Down, // Down + GDK_w, // R + GDK_q, // L + GDK_s, // X + GDK_a, // Y + GDK_p, // DEBUG + GDK_o // BOOST + }; + +SoundInterface_struct *SNDCoreList[] = { +&SNDDummy, +&SNDDummy, +&SNDSDL, +NULL +}; + +GPU3DInterface *core3DList[] = { +&gpu3DNull, +&gpu3DRasterize +#ifdef GTKGLEXT_AVAILABLE + , + &gpu3Dgl +#endif +}; + +/* + * + * Command line handling + * + */ +struct configured_features { + int load_slot; + int software_colour_convert; + int opengl_2d; + int engine_3d; + int disable_limiter; + int savetype; + + u16 arm9_gdb_port; + u16 arm7_gdb_port; + + int firmware_language; + + const char *nds_file; +}; + +static void +init_configured_features( struct configured_features *config) { + config->load_slot = 0; + config->arm9_gdb_port = 0; + config->arm7_gdb_port = 0; + + config->software_colour_convert = 0; + + config->opengl_2d = 0; + config->engine_3d = 1; + + config->disable_limiter = 0; + config->savetype = 0; + + config->nds_file = NULL; + + /* use the default language */ + config->firmware_language = -1; +} + +static int +fill_configured_features( struct configured_features *config, + int argc, char ** argv) { + int good_args = 1; + int print_usage = 0; + int i; + + for ( i = 1; i < argc && good_args; i++) { + if ( strcmp( argv[i], "--help") == 0) { + g_print( _("USAGE: %s [OPTIONS] [nds-file]\n"), argv[0]); + g_print( _("OPTIONS:\n")); + g_print( _("\ + --load-slot=NUM Load game saved under NUM position.\n\n")); +#ifdef GTKGLEXT_AVAILABLE + g_print( _("\ + --soft-convert Use software colour conversion during OpenGL\n\ + screen rendering. May produce better or worse\n\ + frame rates depending on hardware.\n\n")); +#endif + g_print( _("\ + --3d-engine=ENGINE Selects 3D rendering engine\n\ + 0 = disabled\n\ + 1 = internal desmume rasterizer (default)\n")); +#ifdef GTKGLEXT_AVAILABLE + g_print( _("\ + 2 = gtkglext off-screen 3d opengl\n\n")); +#endif + g_print( _("\ + --disable-limiter Disables the 60 fps limiter\n\n")); + g_print( _("\ + --save-type=TYPE Selects savetype:\n\ + 0 = Autodetect (default)\n\ + 1 = EEPROM 4kbit\n\ + 2 = EEPROM 64kbit\n\ + 3 = EEPROM 512kbit\n\ + 4 = FRAM 256kbit\n\ + 5 = FLASH 2mbit\n\ + 6 = FLASH 4mbit\n\ + \n")); + g_print( _("\ + --fwlang=LANG Set the language in the firmware, LANG as follows:\n\ + 0 = Japanese\n\ + 1 = English\n\ + 2 = French\n\ + 3 = German\n\ + 4 = Italian\n\ + 5 = Spanish\n\n")); +#ifdef GDB_STUB + g_print( _("\ + --arm9gdb=PORT_NUM Enable the ARM9 GDB stub on the given port\n\ + --arm7gdb=PORT_NUM Enable the ARM7 GDB stub on the given port\n\n")); +#endif + g_print( _("\ + --help Display this message\n")); + //g_print(" --sticky Enable sticky keys and stylus\n"); + good_args = 0; + } + else if ( strncmp( argv[i], "--load-slot=", 12) == 0) { + char *end_char; + int slot = strtoul( &argv[i][12], &end_char, 10); + + if ( slot >= 0 && slot <= 10) { + config->load_slot = slot; + } + else { + g_printerr( _("I only know how to load from slots 1-10.\n")); + good_args = 0; + } + } +#ifdef GTKGLEXT_AVAILABLE + else if ( strcmp( argv[i], "--opengl-2d") == 0) { + // FIXME: to be implemented + config->opengl_2d = 1; + } + else if ( strcmp( argv[i], "--soft-convert") == 0) { + config->software_colour_convert = 1; + } +#define MAX3DEMU 2 +#else +#define MAX3DEMU 1 +#endif + else if ( strncmp( argv[i], "--3d-engine=", 12) == 0) { + char *end_char; + int engine = strtoul( &argv[i][12], &end_char, 10); + + if ( engine >= 0 && engine <= MAX3DEMU) { + config->engine_3d = engine; + } + else { + g_printerr( _("Supported 3d engines: 0, 1, and on some machines 2; use --help option for details\n")); + good_args = 0; + } + } + else if ( strncmp( argv[i], "--save-type=", 12) == 0) { + char *end_char; + int type = strtoul( &argv[i][12], &end_char, 10); + + if ( type >= 0 && type <= 6) { + config->savetype = type; + } + else { + g_printerr( _("select savetype from 0 to 6; use --help option for details\n")); + good_args = 0; + } + } + else if ( strncmp( argv[i], "--fwlang=", 9) == 0) { + char *end_char; + int lang = strtoul( &argv[i][9], &end_char, 10); + + if ( lang >= 0 && lang <= 5) { + config->firmware_language = lang; + } + else { + g_printerr( _("Firmware language must be set to a value from 0 to 5.\n")); + good_args = 0; + } + } +#ifdef GDB_STUB + else if ( strncmp( argv[i], "--arm9gdb=", 10) == 0) { + char *end_char; + unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); + + if ( port_num > 0 && port_num < 65536) { + config->arm9_gdb_port = port_num; + } + else { + g_print( _("ARM9 GDB stub port must be in the range 1 to 65535\n")); + good_args = 0; + } + } + else if ( strncmp( argv[i], "--arm7gdb=", 10) == 0) { + char *end_char; + unsigned long port_num = strtoul( &argv[i][10], &end_char, 10); + + if ( port_num > 0 && port_num < 65536) { + config->arm7_gdb_port = port_num; + } + else { + g_print( _("ARM7 GDB stub port must be in the range 1 to 65535\n")); + good_args = 0; + } + } +#endif + else if ( strcmp( argv[i], "--disable-limiter") == 0) { + config->disable_limiter = 1; + } + else { + if ( config->nds_file == NULL) { + config->nds_file = argv[i]; + } + else { + g_print( _("NDS file (\"%s\") already set\n"), config->nds_file); + good_args = 0; + } + } + } + + if ( good_args) { + /* + * check if the configured features are consistant + */ + } + + if ( print_usage) { + g_print( _("USAGE: %s [options] [nds-file]\n"), argv[0]); + g_print( _("USAGE: %s --help - for help\n"), argv[0]); + } + + return good_args; +} + + + +/* ***** ***** TOOLS ***** ***** */ + +GList * tools_to_update = NULL; + +// register tool +void register_Tool(VoidFunPtr fun) { + tools_to_update = g_list_append(tools_to_update, (void *) fun); +} +void unregister_Tool(VoidFunPtr fun) { + if (tools_to_update == NULL) return; + tools_to_update = g_list_remove(tools_to_update, (void *) fun); +} + +static void notify_Tool (VoidFunPtr fun, gpointer func_data) { + fun(); +} + +void notify_Tools() { + g_list_foreach(tools_to_update, (GFunc)notify_Tool, NULL); +} + +/* Return the glade directory. + Note: See configure.ac for the value of GLADEUI_UNINSTALLED_DIR. */ +gchar * get_ui_file (const char *filename) +{ + gchar *path; + + /* looking in uninstalled (aka building) dir first */ + path = g_build_filename (GLADEUI_UNINSTALLED_DIR, filename, NULL); + if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) return path; + g_free (path); + + /* looking in installed dir */ + path = g_build_filename (DATADIR, filename, NULL); + if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) return path; + g_free (path); + + /* not found */ + return NULL; +} + + +/* ***** ***** CONFIG FILE ***** ***** */ +char * CONFIG_FILE; + +static int Read_ConfigFile() +{ + int i, tmp; + GKeyFile * keyfile = g_key_file_new(); + GError * error = NULL; + + load_default_config(gtk_kb_cfg); + + g_key_file_load_from_file(keyfile, CONFIG_FILE, G_KEY_FILE_NONE, 0); + + /* Load keypad keys */ + for(i = 0; i < NB_KEYS; i++) + { + tmp = g_key_file_get_integer(keyfile, "KEYS", key_names[i], &error); + if (error != NULL) { + g_error_free(error); + error = NULL; + } else { + keyboard_cfg[i] = tmp; + } + } + + /* Load joypad keys */ + for(i = 0; i < NB_KEYS; i++) + { + tmp = g_key_file_get_integer(keyfile, "JOYKEYS", key_names[i], &error); + if (error != NULL) { + g_error_free(error); + error = NULL; + } else { + joypad_cfg[i] = tmp; + } + } + + g_key_file_free(keyfile); + + return 0; +} + +static int Write_ConfigFile() +{ + int i; + GKeyFile * keyfile; + gchar *contents; + + keyfile = g_key_file_new(); + + for(i = 0; i < NB_KEYS; i++) + { + g_key_file_set_integer(keyfile, "KEYS", key_names[i], keyboard_cfg[i]); + g_key_file_set_integer(keyfile, "JOYKEYS", key_names[i], joypad_cfg[i]); + } + + contents = g_key_file_to_data(keyfile, 0, 0); + g_file_set_contents(CONFIG_FILE, contents, -1, 0); + g_free(contents); + + g_key_file_free(keyfile); + + return 0; +} + + +/* + * The thread handling functions needed by the GDB stub code. + */ +#ifdef GDB_STUB +void * +createThread_gdb( void (*thread_function)( void *data), + void *thread_data) { + GThread *new_thread = g_thread_create( (GThreadFunc)thread_function, + thread_data, + TRUE, + NULL); + + return new_thread; +} + +void +joinThread_gdb( void *thread_handle) { + g_thread_join((GThread *) thread_handle); +} +#endif + + +/* ***** ***** MAIN ***** ***** */ + +static int +common_gtk_glade_main( struct configured_features *my_config) { + /*SDL_TimerID limiter_timer;*/ +#ifdef GDB_STUB + gdbstub_handle_t arm9_gdb_stub; + gdbstub_handle_t arm7_gdb_stub; +#endif + struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; + struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; + struct armcpu_ctrl_iface *arm9_ctrl_iface; + struct armcpu_ctrl_iface *arm7_ctrl_iface; + /* the firmware settings */ + struct NDS_fw_config_data fw_config; + gchar *uifile; + + /* default the firmware settings, they may get changed later */ + NDS_FillDefaultFirmwareConfigData( &fw_config); + + /* use any language set on the command line */ + if ( my_config->firmware_language != -1) { + fw_config.language = my_config->firmware_language; + } + desmume_savetype(my_config->savetype); + +#ifdef GTKGLEXT_AVAILABLE +// check if you have GTHREAD when running configure script + //g_thread_init(NULL); + register_gl_fun(my_gl_Begin,my_gl_End); +#endif + init_keyvals(); + +#ifdef GDB_STUB + if ( my_config->arm9_gdb_port != 0) { + arm9_gdb_stub = createStub_gdb( my_config->arm9_gdb_port, + &arm9_memio, + &arm9_base_memory_iface); + + if ( arm9_gdb_stub == NULL) { + g_print( _("Failed to create ARM9 gdbstub on port %d\n"), + my_config->arm9_gdb_port); + return -1; + } + } + if ( my_config->arm7_gdb_port != 0) { + arm7_gdb_stub = createStub_gdb( my_config->arm7_gdb_port, + &arm7_memio, + &arm7_base_memory_iface); + + if ( arm7_gdb_stub == NULL) { + g_print( _("Failed to create ARM7 gdbstub on port %d\n"), + my_config->arm7_gdb_port); + return -1; + } + } +#endif + + if(SDL_Init( SDL_INIT_TIMER | SDL_INIT_VIDEO) == -1) + { + fprintf(stderr, _("Error trying to initialize SDL: %s\n"), + SDL_GetError()); + return 1; + } + + desmume_init( arm9_memio, &arm9_ctrl_iface, + arm7_memio, &arm7_ctrl_iface); + + + /* Create the dummy firmware */ + NDS_CreateDummyFirmware( &fw_config); + + /* + * Activate the GDB stubs + * This has to come after the NDS_Init (called in desmume_init) + * where the cpus are set up. + */ +#ifdef GDB_STUB + if ( my_config->arm9_gdb_port != 0) { + activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); + } + if ( my_config->arm7_gdb_port != 0) { + activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); + } +#endif + + /* Initialize joysticks */ + if(!init_joy()) return 1; + + CONFIG_FILE = g_build_filename(g_get_home_dir(), ".desmume.ini", NULL); + Read_ConfigFile(); + + /* load the interface */ + uifile = get_ui_file("DeSmuMe.glade"); + xml = glade_xml_new(uifile, NULL, NULL); + g_free (uifile); + uifile = get_ui_file("DeSmuMe_Dtools.glade"); + xml_tools = glade_xml_new(uifile, NULL, NULL); + g_free (uifile); + pWindow = glade_xml_get_widget(xml, "wMainW"); + pDrawingArea = glade_xml_get_widget(xml, "wDraw_Main"); + pDrawingArea2 = glade_xml_get_widget(xml, "wDraw_Sub"); + + { + char wdgName[40]; + snprintf(wdgName, 39, "savetype%d", my_config->savetype+1); + GtkWidget * wdgt = glade_xml_get_widget(xml, wdgName); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (wdgt), TRUE); + } + + /* connect the signals in the interface */ + glade_xml_signal_autoconnect_StringObject(xml); + glade_xml_signal_autoconnect_StringObject(xml_tools); + + init_GL_capabilities( my_config->software_colour_convert); + + /* check command line file */ + if( my_config->nds_file) { + if(desmume_open( my_config->nds_file) >= 0) { + loadstate_slot( my_config->load_slot); + desmume_resume(); + enable_rom_features(); + } else { + GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pWindow), + GTK_DIALOG_MODAL, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + _("Unable to load :\n%s"), my_config->nds_file); + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } + } + + gtk_widget_show(pDrawingArea); + gtk_widget_show(pDrawingArea2); + + { + int engine = my_config->engine_3d; + +#ifdef GTKGLEXT_AVAILABLE + if ( my_config->engine_3d==2 ) + /* setup the gdk 3D emulation */ + if(!init_opengl_gdk_3Demu(GDK_DRAWABLE(pWindow->window))){ + fprintf( stderr, _("Failed to initialise openGL 3D emulation; " + "removing 3D support\n")); + engine = 0; + } +#endif + NDS_3D_ChangeCore(engine); + if(my_config->engine_3d != 0 && gpu3D == GPU3D_NULL) + fprintf(stderr, _("Failed to setup 3D engine; removing 3D support\n")); + } + +// on_menu_tileview_activate(NULL,NULL); + + /* setup the frame limiter and indicate if it is disabled */ + glade_fps_limiter_disabled = my_config->disable_limiter; + + /* start event loop */ + gtk_main(); + desmume_free(); + + /* Unload joystick */ + uninit_joy(); + + SDL_Quit(); + Write_ConfigFile(); + return EXIT_SUCCESS; +} + +int main(int argc, char *argv[]) { + struct configured_features my_config; + + // Localization + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + + init_configured_features( &my_config); + + if (!g_thread_supported()) + g_thread_init( NULL); + + gtk_init(&argc, &argv); + +#ifdef GTKGLEXT_AVAILABLE + gtk_gl_init( &argc, &argv); +#endif + + if ( !fill_configured_features( &my_config, argc, argv)) { + exit(0); + } + + return common_gtk_glade_main( &my_config); +} + + +#ifdef WIN32 +int WinMain ( HINSTANCE hThisInstance, HINSTANCE hPrevInstance, + LPSTR lpszArgument, int nFunsterStil) +{ + int argc = 0; + char *argv[] = NULL; + + /* + * FIXME: + * Emulate the argc and argv main parameters. Could do this using + * CommandLineToArgvW and then convert the wide chars to thin chars. + * Or parse the wide chars directly and call common_gtk_glade_main with a + * filled configuration structure. + */ + main( argc, argv); +} +#endif diff --git a/desmume/src/gtk/DeSmuME.xpm b/src/gtk/DeSmuME.xpm similarity index 100% rename from desmume/src/gtk/DeSmuME.xpm rename to src/gtk/DeSmuME.xpm diff --git a/desmume/src/gtk/Makefile.am b/src/gtk/Makefile.am similarity index 100% rename from desmume/src/gtk/Makefile.am rename to src/gtk/Makefile.am diff --git a/desmume/src/gtk/cheatsGTK.cpp b/src/gtk/cheatsGTK.cpp similarity index 96% rename from desmume/src/gtk/cheatsGTK.cpp rename to src/gtk/cheatsGTK.cpp index 3ab4838c7..c2a80ffee 100644 --- a/desmume/src/gtk/cheatsGTK.cpp +++ b/src/gtk/cheatsGTK.cpp @@ -1,437 +1,437 @@ -/* cheats.cpp - this file is part of DeSmuME - * - * Copyright (C) 2006-2009 DeSmuME Team - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#include -#include -#include -#include "cheatsGTK.h" -#include "cheatSystem.h" -#include "main.h" -#include "desmume.h" - -enum { - COLUMN_ENABLED, - COLUMN_SIZE, - COLUMN_HI, - COLUMN_LO, - COLUMN_DESC, - NUM_COL -}; - -enum -{ - COLUMN_SIZE_TEXT, - NUM_SIZE_COLUMNS -}; - -enum { - TYPE_TOGGLE, - TYPE_COMBO, - TYPE_STRING -}; - -static struct { - const gchar *caption; - gint type; - gint column; -} columnTable[]={ - { "Enabled", TYPE_TOGGLE, COLUMN_ENABLED}, - { "Size", TYPE_COMBO, COLUMN_SIZE}, - { "Offset", TYPE_STRING, COLUMN_HI}, - { "Value", TYPE_STRING, COLUMN_LO}, - { "Description", TYPE_STRING, COLUMN_DESC} -}; - -static GtkWidget *win = NULL; -static BOOL shouldBeRunning = FALSE; - -// --------------------------------------------------------------------------------- -// SEARCH -// --------------------------------------------------------------------------------- - -static void -enabled_toggled(GtkCellRendererToggle * cell, - gchar * path_str, gpointer data) -{ - GtkTreeModel *model = (GtkTreeModel *) data; - GtkTreeIter iter; - GtkTreePath *path = gtk_tree_path_new_from_string(path_str); - gboolean enabled; - - gtk_tree_model_get_iter(model, &iter, path); - gtk_tree_model_get(model, &iter, COLUMN_ENABLED, &enabled, -1); - - enabled ^= 1; - CHEATS_LIST cheat; - u32 ii; - GtkTreePath *path1; - - path1 = gtk_tree_model_get_path (model, &iter); - ii = gtk_tree_path_get_indices (path)[0]; - - cheatsGet(&cheat, ii); - - cheatsUpdate(cheat.size, cheat.hi[0], cheat.lo[0], cheat.description, - enabled, ii); - - gtk_list_store_set(GTK_LIST_STORE(model), &iter, COLUMN_ENABLED, enabled, -1); - - gtk_tree_path_free(path); -} - -static void cheat_list_modify_cheat(GtkCellRendererText * cell, - const gchar * path_string, - const gchar * new_text, gpointer data) -{ - GtkTreeModel *model = (GtkTreeModel *) data; - GtkTreePath *path = gtk_tree_path_new_from_string(path_string); - GtkTreeIter iter; - - gint column = - GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "column")); - - gtk_tree_model_get_iter(model, &iter, path); - - { - u32 ii; - GtkTreePath *path1; - CHEATS_LIST cheat; - - path1 = gtk_tree_model_get_path (model, &iter); - ii = gtk_tree_path_get_indices (path)[0]; - - cheatsGet(&cheat, ii); - - gtk_tree_path_free (path1); - - if (column == COLUMN_LO || column == COLUMN_HI - || column == COLUMN_SIZE) { - u32 v = atoi(new_text); - switch (column) { - case COLUMN_SIZE: - cheatsUpdate(v-1, cheat.hi[0], cheat.lo[0], - cheat.description, cheat.enabled, ii); - break; - case COLUMN_HI: - cheatsUpdate(cheat.size, v, cheat.lo[0], cheat.description, - cheat.enabled, ii); - break; - case COLUMN_LO: - cheatsUpdate(cheat.size, cheat.hi[0], v, cheat.description, - cheat.enabled, ii); - break; - } - gtk_list_store_set(GTK_LIST_STORE(model), &iter, column, - atoi(new_text), -1); - } else if (column == COLUMN_DESC){ - cheatsUpdate(cheat.size, cheat.hi[0], cheat.lo[0], - g_strdup(new_text), cheat.enabled, ii); - gtk_list_store_set(GTK_LIST_STORE(model), &iter, column, - g_strdup(new_text), -1); - } - - } -} - -static void cheat_list_remove_cheat(GtkWidget * widget, gpointer data) -{ - GtkTreeView *tree = (GtkTreeView *) data; - GtkTreeSelection *selection = gtk_tree_view_get_selection (tree); - GtkTreeModel *model = gtk_tree_view_get_model (tree); - GtkTreeIter iter; - - if (gtk_tree_selection_get_selected (selection, NULL, &iter)){ - u32 ii; - GtkTreePath *path; - - path = gtk_tree_model_get_path (model, &iter); - ii = gtk_tree_path_get_indices (path)[0]; - - gtk_list_store_remove(GTK_LIST_STORE(model), &iter); - cheatsRemove(ii); - - gtk_tree_path_free (path); - } -} - -static void cheat_list_add_cheat(GtkWidget * widget, gpointer data) -{ -#define NEW_DESC "New cheat" - GtkListStore *store = (GtkListStore *) data; - GtkTreeIter iter; - cheatsAdd(1, 0, 0, g_strdup(NEW_DESC), FALSE); - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - COLUMN_ENABLED, FALSE, - COLUMN_SIZE, 1, - COLUMN_HI, 0, - COLUMN_LO, 0, COLUMN_DESC, NEW_DESC, -1); - -#undef NEW_DESC -} - -static GtkTreeModel * create_numbers_model (void) -{ -#define N_NUMBERS 4 - gint i = 0; - GtkListStore *model; - GtkTreeIter iter; - - /* create list store */ - model = gtk_list_store_new (NUM_SIZE_COLUMNS, G_TYPE_STRING, G_TYPE_INT); - - /* add numbers */ - for (i = 1; i < N_NUMBERS+1; i++) - { - char str[2]; - - str[0] = '0' + i; - str[1] = '\0'; - - gtk_list_store_append (model, &iter); - - gtk_list_store_set (model, &iter, - COLUMN_SIZE_TEXT, str, - -1); - } - - return GTK_TREE_MODEL (model); - -#undef N_NUMBERS -} - -static void cheat_list_add_columns(GtkTreeView * tree, GtkListStore * store) -{ - - GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree)); - static GtkTreeModel * size_model; - - for (u32 ii = 0; ii < sizeof(columnTable) / sizeof(columnTable[0]); ii++) { - GtkCellRenderer *renderer = NULL; - GtkTreeViewColumn *column; - const gchar *attrib = NULL; - switch (columnTable[ii].type) { - case TYPE_TOGGLE: - renderer = gtk_cell_renderer_toggle_new(); - g_signal_connect(renderer, "toggled", - G_CALLBACK(enabled_toggled), model); - attrib = "active"; - break; - case TYPE_STRING: - renderer = gtk_cell_renderer_text_new(); - g_object_set(renderer, "editable", TRUE, NULL); - g_signal_connect(renderer, "edited", - G_CALLBACK(cheat_list_modify_cheat), store); - attrib = "text"; - break; - case TYPE_COMBO: - renderer = gtk_cell_renderer_combo_new(); - size_model = create_numbers_model(); - g_object_set(renderer, - "model", size_model, - "text-column", COLUMN_SIZE_TEXT, - "editable", TRUE, - "has-entry", FALSE, - NULL); - g_object_unref(size_model); - g_signal_connect(renderer, "edited", - G_CALLBACK(cheat_list_modify_cheat), store); - attrib = "text"; - break; - } - column = - gtk_tree_view_column_new_with_attributes(columnTable[ii]. - caption, renderer, - attrib, columnTable[ii].column, - NULL); - g_object_set_data(G_OBJECT(renderer), "column", - GINT_TO_POINTER(columnTable[ii].column)); - gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); - } - -} - -static void cheatListEnd() -{ - cheatsSave(); - if(shouldBeRunning) - Launch(); -} - -static GtkListStore *cheat_list_populate() -{ - GtkListStore *store = gtk_list_store_new (5, G_TYPE_BOOLEAN, - G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING); - - CHEATS_LIST cheat; - u32 chsize = cheatsGetSize(); - for(u32 ii = 0; ii < chsize; ii++){ - GtkTreeIter iter; - cheatsGet(&cheat, ii); - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - COLUMN_ENABLED, cheat.enabled, - COLUMN_SIZE, cheat.size+1, - COLUMN_HI, cheat.hi[0], - COLUMN_LO, cheat.lo[0], - COLUMN_DESC, cheat.description, - -1); - } - return store; -} - -static GtkWidget *cheat_list_create_ui() -{ - GtkListStore *store = cheat_list_populate(); - GtkWidget *tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); - GtkWidget *vbox = gtk_vbox_new(FALSE, 1); - GtkWidget *hbbox = gtk_hbutton_box_new(); - GtkWidget *button; - - gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(tree)); - gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(hbbox)); - gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox)); - - button = gtk_button_new_with_label("add cheat"); - g_signal_connect (button, "clicked", G_CALLBACK (cheat_list_add_cheat), store); - gtk_container_add(GTK_CONTAINER(hbbox),button); - - button = gtk_button_new_with_label("Remove cheat"); - g_signal_connect (button, "clicked", G_CALLBACK (cheat_list_remove_cheat), tree); - gtk_container_add(GTK_CONTAINER(hbbox),button); - - cheat_list_add_columns(GTK_TREE_VIEW(tree), store); - - /* Setup the selection handler */ - GtkTreeSelection *select; - select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree)); - gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE); - - return tree; -} - -void CheatList () -{ - shouldBeRunning = desmume_running(); - Pause(); - win = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(win),"Cheat List"); - gtk_window_set_modal(GTK_WINDOW(win), TRUE); - g_signal_connect(G_OBJECT(win), "destroy", cheatListEnd, NULL); - - cheat_list_create_ui(); - - gtk_widget_show_all(win); -} - -// --------------------------------------------------------------------------------- -// SEARCH -// --------------------------------------------------------------------------------- - -static void cheat_search_create_ui() -{ - GtkWidget *button; - GtkWidget *vbox = gtk_vbox_new(FALSE, 1); - GtkWidget *hbbox = gtk_hbutton_box_new(); - GtkWidget *b; - - gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox)); - - { - b = gtk_hbox_new(FALSE, 1); - gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(b)); - - { - GtkTreeModel * size_model; - GtkWidget *w; - w = gtk_label_new("size"); - gtk_container_add(GTK_CONTAINER(b), w); - - size_model = create_numbers_model(); - - w = gtk_combo_box_new_with_model(size_model); - g_object_unref(size_model); - GtkCellRenderer * renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (w), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (w), renderer, - "text", COLUMN_SIZE_TEXT, - NULL); - gtk_combo_box_set_active (GTK_COMBO_BOX (w), 0); - gtk_container_add(GTK_CONTAINER(b), w); - } - - b = gtk_hbox_new(FALSE, 1); - gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(b)); - - { - GtkWidget *w; - w = gtk_label_new("signedness"); - gtk_container_add(GTK_CONTAINER(b), w); - -// m = create_sign_model(); - - w = gtk_combo_box_new(); -// w = gtk_combo_box_new_with_model(size_model); -// g_object_unref(size_model); -// size_model = NULL; - GtkCellRenderer * renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (w), renderer, TRUE); -// gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (w), renderer, -// "text", COLUMN_SIZE_TEXT, -// NULL); - gtk_combo_box_set_active (GTK_COMBO_BOX (w), 0); - gtk_container_add(GTK_CONTAINER(b), w); - } - } - - // BUTTONS: - - gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(hbbox)); - - button = gtk_button_new_with_label("add cheats"); -// g_signal_connect (button, "clicked", g_callback (cheat_list_add_cheat), store); - gtk_container_add(GTK_CONTAINER(hbbox),button); - - button = gtk_button_new_with_label("search"); -// g_signal_connect (button, "clicked", g_callback (cheat_list_add_cheat), store); - gtk_container_add(GTK_CONTAINER(hbbox),button); - -// GtkWidget *vbox = gtk_vbox_new(FALSE, 1); -// gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox)); -} - -static void cheatSearchEnd() -{ -} - -void CheatSearch () -{ - shouldBeRunning = desmume_running(); - Pause(); - win = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(win),"Cheat Search"); - gtk_window_set_modal(GTK_WINDOW(win), TRUE); - g_signal_connect(G_OBJECT(win), "destroy", cheatSearchEnd, NULL); - - cheat_search_create_ui(); - - gtk_widget_show_all(win); -} +/* cheats.cpp - this file is part of DeSmuME + * + * Copyright (C) 2006-2009 DeSmuME Team + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + + +#include +#include +#include +#include "cheatsGTK.h" +#include "cheatSystem.h" +#include "main.h" +#include "desmume.h" + +enum { + COLUMN_ENABLED, + COLUMN_SIZE, + COLUMN_HI, + COLUMN_LO, + COLUMN_DESC, + NUM_COL +}; + +enum +{ + COLUMN_SIZE_TEXT, + NUM_SIZE_COLUMNS +}; + +enum { + TYPE_TOGGLE, + TYPE_COMBO, + TYPE_STRING +}; + +static struct { + const gchar *caption; + gint type; + gint column; +} columnTable[]={ + { "Enabled", TYPE_TOGGLE, COLUMN_ENABLED}, + { "Size", TYPE_COMBO, COLUMN_SIZE}, + { "Offset", TYPE_STRING, COLUMN_HI}, + { "Value", TYPE_STRING, COLUMN_LO}, + { "Description", TYPE_STRING, COLUMN_DESC} +}; + +static GtkWidget *win = NULL; +static BOOL shouldBeRunning = FALSE; + +// --------------------------------------------------------------------------------- +// SEARCH +// --------------------------------------------------------------------------------- + +static void +enabled_toggled(GtkCellRendererToggle * cell, + gchar * path_str, gpointer data) +{ + GtkTreeModel *model = (GtkTreeModel *) data; + GtkTreeIter iter; + GtkTreePath *path = gtk_tree_path_new_from_string(path_str); + gboolean enabled; + + gtk_tree_model_get_iter(model, &iter, path); + gtk_tree_model_get(model, &iter, COLUMN_ENABLED, &enabled, -1); + + enabled ^= 1; + CHEATS_LIST cheat; + u32 ii; + GtkTreePath *path1; + + path1 = gtk_tree_model_get_path (model, &iter); + ii = gtk_tree_path_get_indices (path)[0]; + + cheatsGet(&cheat, ii); + + cheatsUpdate(cheat.size, cheat.hi[0], cheat.lo[0], cheat.description, + enabled, ii); + + gtk_list_store_set(GTK_LIST_STORE(model), &iter, COLUMN_ENABLED, enabled, -1); + + gtk_tree_path_free(path); +} + +static void cheat_list_modify_cheat(GtkCellRendererText * cell, + const gchar * path_string, + const gchar * new_text, gpointer data) +{ + GtkTreeModel *model = (GtkTreeModel *) data; + GtkTreePath *path = gtk_tree_path_new_from_string(path_string); + GtkTreeIter iter; + + gint column = + GPOINTER_TO_INT(g_object_get_data(G_OBJECT(cell), "column")); + + gtk_tree_model_get_iter(model, &iter, path); + + { + u32 ii; + GtkTreePath *path1; + CHEATS_LIST cheat; + + path1 = gtk_tree_model_get_path (model, &iter); + ii = gtk_tree_path_get_indices (path)[0]; + + cheatsGet(&cheat, ii); + + gtk_tree_path_free (path1); + + if (column == COLUMN_LO || column == COLUMN_HI + || column == COLUMN_SIZE) { + u32 v = atoi(new_text); + switch (column) { + case COLUMN_SIZE: + cheatsUpdate(v-1, cheat.hi[0], cheat.lo[0], + cheat.description, cheat.enabled, ii); + break; + case COLUMN_HI: + cheatsUpdate(cheat.size, v, cheat.lo[0], cheat.description, + cheat.enabled, ii); + break; + case COLUMN_LO: + cheatsUpdate(cheat.size, cheat.hi[0], v, cheat.description, + cheat.enabled, ii); + break; + } + gtk_list_store_set(GTK_LIST_STORE(model), &iter, column, + atoi(new_text), -1); + } else if (column == COLUMN_DESC){ + cheatsUpdate(cheat.size, cheat.hi[0], cheat.lo[0], + g_strdup(new_text), cheat.enabled, ii); + gtk_list_store_set(GTK_LIST_STORE(model), &iter, column, + g_strdup(new_text), -1); + } + + } +} + +static void cheat_list_remove_cheat(GtkWidget * widget, gpointer data) +{ + GtkTreeView *tree = (GtkTreeView *) data; + GtkTreeSelection *selection = gtk_tree_view_get_selection (tree); + GtkTreeModel *model = gtk_tree_view_get_model (tree); + GtkTreeIter iter; + + if (gtk_tree_selection_get_selected (selection, NULL, &iter)){ + u32 ii; + GtkTreePath *path; + + path = gtk_tree_model_get_path (model, &iter); + ii = gtk_tree_path_get_indices (path)[0]; + + gtk_list_store_remove(GTK_LIST_STORE(model), &iter); + cheatsRemove(ii); + + gtk_tree_path_free (path); + } +} + +static void cheat_list_add_cheat(GtkWidget * widget, gpointer data) +{ +#define NEW_DESC "New cheat" + GtkListStore *store = (GtkListStore *) data; + GtkTreeIter iter; + cheatsAdd(1, 0, 0, g_strdup(NEW_DESC), FALSE); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, + COLUMN_ENABLED, FALSE, + COLUMN_SIZE, 1, + COLUMN_HI, 0, + COLUMN_LO, 0, COLUMN_DESC, NEW_DESC, -1); + +#undef NEW_DESC +} + +static GtkTreeModel * create_numbers_model (void) +{ +#define N_NUMBERS 4 + gint i = 0; + GtkListStore *model; + GtkTreeIter iter; + + /* create list store */ + model = gtk_list_store_new (NUM_SIZE_COLUMNS, G_TYPE_STRING, G_TYPE_INT); + + /* add numbers */ + for (i = 1; i < N_NUMBERS+1; i++) + { + char str[2]; + + str[0] = '0' + i; + str[1] = '\0'; + + gtk_list_store_append (model, &iter); + + gtk_list_store_set (model, &iter, + COLUMN_SIZE_TEXT, str, + -1); + } + + return GTK_TREE_MODEL (model); + +#undef N_NUMBERS +} + +static void cheat_list_add_columns(GtkTreeView * tree, GtkListStore * store) +{ + + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree)); + static GtkTreeModel * size_model; + + for (u32 ii = 0; ii < sizeof(columnTable) / sizeof(columnTable[0]); ii++) { + GtkCellRenderer *renderer = NULL; + GtkTreeViewColumn *column; + const gchar *attrib = NULL; + switch (columnTable[ii].type) { + case TYPE_TOGGLE: + renderer = gtk_cell_renderer_toggle_new(); + g_signal_connect(renderer, "toggled", + G_CALLBACK(enabled_toggled), model); + attrib = "active"; + break; + case TYPE_STRING: + renderer = gtk_cell_renderer_text_new(); + g_object_set(renderer, "editable", TRUE, NULL); + g_signal_connect(renderer, "edited", + G_CALLBACK(cheat_list_modify_cheat), store); + attrib = "text"; + break; + case TYPE_COMBO: + renderer = gtk_cell_renderer_combo_new(); + size_model = create_numbers_model(); + g_object_set(renderer, + "model", size_model, + "text-column", COLUMN_SIZE_TEXT, + "editable", TRUE, + "has-entry", FALSE, + NULL); + g_object_unref(size_model); + g_signal_connect(renderer, "edited", + G_CALLBACK(cheat_list_modify_cheat), store); + attrib = "text"; + break; + } + column = + gtk_tree_view_column_new_with_attributes(columnTable[ii]. + caption, renderer, + attrib, columnTable[ii].column, + NULL); + g_object_set_data(G_OBJECT(renderer), "column", + GINT_TO_POINTER(columnTable[ii].column)); + gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); + } + +} + +static void cheatListEnd() +{ + cheatsSave(); + if(shouldBeRunning) + Launch(); +} + +static GtkListStore *cheat_list_populate() +{ + GtkListStore *store = gtk_list_store_new (5, G_TYPE_BOOLEAN, + G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING); + + CHEATS_LIST cheat; + u32 chsize = cheatsGetSize(); + for(u32 ii = 0; ii < chsize; ii++){ + GtkTreeIter iter; + cheatsGet(&cheat, ii); + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, + COLUMN_ENABLED, cheat.enabled, + COLUMN_SIZE, cheat.size+1, + COLUMN_HI, cheat.hi[0], + COLUMN_LO, cheat.lo[0], + COLUMN_DESC, cheat.description, + -1); + } + return store; +} + +static GtkWidget *cheat_list_create_ui() +{ + GtkListStore *store = cheat_list_populate(); + GtkWidget *tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); + GtkWidget *vbox = gtk_vbox_new(FALSE, 1); + GtkWidget *hbbox = gtk_hbutton_box_new(); + GtkWidget *button; + + gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(tree)); + gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(hbbox)); + gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox)); + + button = gtk_button_new_with_label("add cheat"); + g_signal_connect (button, "clicked", G_CALLBACK (cheat_list_add_cheat), store); + gtk_container_add(GTK_CONTAINER(hbbox),button); + + button = gtk_button_new_with_label("Remove cheat"); + g_signal_connect (button, "clicked", G_CALLBACK (cheat_list_remove_cheat), tree); + gtk_container_add(GTK_CONTAINER(hbbox),button); + + cheat_list_add_columns(GTK_TREE_VIEW(tree), store); + + /* Setup the selection handler */ + GtkTreeSelection *select; + select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree)); + gtk_tree_selection_set_mode (select, GTK_SELECTION_SINGLE); + + return tree; +} + +void CheatList () +{ + shouldBeRunning = desmume_running(); + Pause(); + win = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(win),"Cheat List"); + gtk_window_set_modal(GTK_WINDOW(win), TRUE); + g_signal_connect(G_OBJECT(win), "destroy", cheatListEnd, NULL); + + cheat_list_create_ui(); + + gtk_widget_show_all(win); +} + +// --------------------------------------------------------------------------------- +// SEARCH +// --------------------------------------------------------------------------------- + +static void cheat_search_create_ui() +{ + GtkWidget *button; + GtkWidget *vbox = gtk_vbox_new(FALSE, 1); + GtkWidget *hbbox = gtk_hbutton_box_new(); + GtkWidget *b; + + gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox)); + + { + b = gtk_hbox_new(FALSE, 1); + gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(b)); + + { + GtkTreeModel * size_model; + GtkWidget *w; + w = gtk_label_new("size"); + gtk_container_add(GTK_CONTAINER(b), w); + + size_model = create_numbers_model(); + + w = gtk_combo_box_new_with_model(size_model); + g_object_unref(size_model); + GtkCellRenderer * renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (w), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (w), renderer, + "text", COLUMN_SIZE_TEXT, + NULL); + gtk_combo_box_set_active (GTK_COMBO_BOX (w), 0); + gtk_container_add(GTK_CONTAINER(b), w); + } + + b = gtk_hbox_new(FALSE, 1); + gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(b)); + + { + GtkWidget *w; + w = gtk_label_new("signedness"); + gtk_container_add(GTK_CONTAINER(b), w); + +// m = create_sign_model(); + + w = gtk_combo_box_new(); +// w = gtk_combo_box_new_with_model(size_model); +// g_object_unref(size_model); +// size_model = NULL; + GtkCellRenderer * renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (w), renderer, TRUE); +// gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (w), renderer, +// "text", COLUMN_SIZE_TEXT, +// NULL); + gtk_combo_box_set_active (GTK_COMBO_BOX (w), 0); + gtk_container_add(GTK_CONTAINER(b), w); + } + } + + // BUTTONS: + + gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(hbbox)); + + button = gtk_button_new_with_label("add cheats"); +// g_signal_connect (button, "clicked", g_callback (cheat_list_add_cheat), store); + gtk_container_add(GTK_CONTAINER(hbbox),button); + + button = gtk_button_new_with_label("search"); +// g_signal_connect (button, "clicked", g_callback (cheat_list_add_cheat), store); + gtk_container_add(GTK_CONTAINER(hbbox),button); + +// GtkWidget *vbox = gtk_vbox_new(FALSE, 1); +// gtk_container_add(GTK_CONTAINER(win), GTK_WIDGET(vbox)); +} + +static void cheatSearchEnd() +{ +} + +void CheatSearch () +{ + shouldBeRunning = desmume_running(); + Pause(); + win = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(win),"Cheat Search"); + gtk_window_set_modal(GTK_WINDOW(win), TRUE); + g_signal_connect(G_OBJECT(win), "destroy", cheatSearchEnd, NULL); + + cheat_search_create_ui(); + + gtk_widget_show_all(win); +} diff --git a/desmume/src/gtk/cheatsGTK.h b/src/gtk/cheatsGTK.h similarity index 97% rename from desmume/src/gtk/cheatsGTK.h rename to src/gtk/cheatsGTK.h index 141111348..193e47e73 100644 --- a/desmume/src/gtk/cheatsGTK.h +++ b/src/gtk/cheatsGTK.h @@ -1,29 +1,29 @@ -/* desmume.h - this file is part of DeSmuME - * - * Copyright (C) 2006,2007 DeSmuME Team - * Copyright (C) 2007 Pascal Giard (evilynux) - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __CHEATS_H__ -#define __CHEATS_H__ - -void CheatSearch (); -void CheatList (); - -#endif /*__CHEATS_H__*/ - +/* desmume.h - this file is part of DeSmuME + * + * Copyright (C) 2006,2007 DeSmuME Team + * Copyright (C) 2007 Pascal Giard (evilynux) + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __CHEATS_H__ +#define __CHEATS_H__ + +void CheatSearch (); +void CheatList (); + +#endif /*__CHEATS_H__*/ + diff --git a/desmume/src/gtk/dTool.h b/src/gtk/dTool.h similarity index 95% rename from desmume/src/gtk/dTool.h rename to src/gtk/dTool.h index 82685b3f7..647982ede 100644 --- a/desmume/src/gtk/dTool.h +++ b/src/gtk/dTool.h @@ -1,23 +1,23 @@ -#ifndef __DTOOL_H__ -#define __DTOOL_H__ - -#include "../types.h" -#include "../registers.h" - -typedef void (*dTool_openFn)(int id); -typedef void (*dTool_updateFn)(); -typedef void (*dTool_closeFn)(); - -typedef struct -{ - /* this should be the same name of the action in the gui xml */ - const char shortname[16]; - const char name[32]; - dTool_openFn open; - dTool_updateFn update; - dTool_closeFn close; -} dTool_t; - -extern void dTool_CloseCallback(int id); - -#endif /*__DTOOL_H__*/ +#ifndef __DTOOL_H__ +#define __DTOOL_H__ + +#include "../types.h" +#include "../registers.h" + +typedef void (*dTool_openFn)(int id); +typedef void (*dTool_updateFn)(); +typedef void (*dTool_closeFn)(); + +typedef struct +{ + /* this should be the same name of the action in the gui xml */ + const char shortname[16]; + const char name[32]; + dTool_openFn open; + dTool_updateFn update; + dTool_closeFn close; +} dTool_t; + +extern void dTool_CloseCallback(int id); + +#endif /*__DTOOL_H__*/ diff --git a/desmume/src/gtk/dToolsList.cpp b/src/gtk/dToolsList.cpp similarity index 96% rename from desmume/src/gtk/dToolsList.cpp rename to src/gtk/dToolsList.cpp index 1b7e24d16..2a31df992 100644 --- a/desmume/src/gtk/dToolsList.cpp +++ b/src/gtk/dToolsList.cpp @@ -1,31 +1,31 @@ -/* dToolsList.cpp - * - * Copyright (C) 2006 Thoduv - * - * This file is part of DeSmuME - * - * DeSmuME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * DeSmuME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with DeSmuME; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "dTool.h" -#include "tools/ioregsView.h" - -dTool_t *dTools_list[] = -{ - &dTool_ioregsView -}; - -int dTools_list_size = ARRAY_SIZE(dTools_list); - +/* dToolsList.cpp + * + * Copyright (C) 2006 Thoduv + * + * This file is part of DeSmuME + * + * DeSmuME is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * DeSmuME is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DeSmuME; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "dTool.h" +#include "tools/ioregsView.h" + +dTool_t *dTools_list[] = +{ + &dTool_ioregsView +}; + +int dTools_list_size = ARRAY_SIZE(dTools_list); + diff --git a/desmume/src/gtk/desmume.cpp b/src/gtk/desmume.cpp similarity index 89% rename from desmume/src/gtk/desmume.cpp rename to src/gtk/desmume.cpp index aa35b689a..a8abd83ad 100644 --- a/desmume/src/gtk/desmume.cpp +++ b/src/gtk/desmume.cpp @@ -1,92 +1,92 @@ -/* desmume.c - this file is part of DeSmuME - * - * Copyright (C) 2006,2007 DeSmuME Team - * Copyright (C) 2007 Pascal Giard (evilynux) - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "types.h" -#include "NDSSystem.h" -#include "SPU.h" -#include "sndsdl.h" -#include "ctrlssdl.h" -#include "desmume.h" -#include "movie.h" - -volatile bool execute = false; -BOOL click = FALSE; - -void desmume_init( struct armcpu_memory_iface *arm9_mem_if, - struct armcpu_ctrl_iface **arm9_ctrl_iface, - struct armcpu_memory_iface *arm7_mem_if, - struct armcpu_ctrl_iface **arm7_ctrl_iface, - int disable_sound) -{ -#ifdef GDB_STUB - NDS_Init( arm9_mem_if, arm9_ctrl_iface, - arm7_mem_if, arm7_ctrl_iface); -#else - NDS_Init(); -#endif - if ( !disable_sound) { - SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); - } - execute = false; -} - -void desmume_free( void) -{ - execute = false; - NDS_DeInit(); -} - -void desmume_pause( void) -{ - execute = false; - SPU_Pause(1); -} -void desmume_resume( void) -{ - execute = true; - SPU_Pause(0); -} -void desmume_toggle( void) -{ - execute ^= true; -} -bool desmume_running( void) -{ - return execute; -} - -void desmume_cycle( void) -{ - u16 keypad; - - /* Joystick events */ - /* Retrieve old value: can use joysticks w/ another device (from our side) */ - keypad = get_keypad(); - /* Look for queued events */ - process_joystick_events( &keypad); - /* Update keypad value */ - update_keypad(keypad); - - FCEUMOV_AddInputState(); - NDS_exec(); - SPU_Emulate_user(); -} - +/* desmume.c - this file is part of DeSmuME + * + * Copyright (C) 2006,2007 DeSmuME Team + * Copyright (C) 2007 Pascal Giard (evilynux) + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "types.h" +#include "NDSSystem.h" +#include "SPU.h" +#include "sndsdl.h" +#include "ctrlssdl.h" +#include "desmume.h" +#include "movie.h" + +volatile BOOL execute = FALSE; +BOOL click = FALSE; + +void desmume_init( struct armcpu_memory_iface *arm9_mem_if, + struct armcpu_ctrl_iface **arm9_ctrl_iface, + struct armcpu_memory_iface *arm7_mem_if, + struct armcpu_ctrl_iface **arm7_ctrl_iface, + int disable_sound) +{ +#ifdef GDB_STUB + NDS_Init( arm9_mem_if, arm9_ctrl_iface, + arm7_mem_if, arm7_ctrl_iface); +#else + NDS_Init(); +#endif + if ( !disable_sound) { + SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); + } + execute = FALSE; +} + +void desmume_free( void) +{ + execute = FALSE; + NDS_DeInit(); +} + +void desmume_pause( void) +{ + execute = FALSE; + SPU_Pause(1); +} +void desmume_resume( void) +{ + execute = TRUE; + SPU_Pause(0); +} +void desmume_toggle( void) +{ + execute = (execute) ? FALSE : TRUE; +} +BOOL desmume_running( void) +{ + return execute; +} + +void desmume_cycle( void) +{ + u16 keypad; + + /* Joystick events */ + /* Retrieve old value: can use joysticks w/ another device (from our side) */ + keypad = get_keypad(); + /* Look for queued events */ + process_joystick_events( &keypad); + /* Update keypad value */ + update_keypad(keypad); + + FCEUMOV_AddInputState(); + NDS_exec(); + SPU_Emulate_user(); +} + diff --git a/desmume/src/gtk/desmume.desktop b/src/gtk/desmume.desktop similarity index 100% rename from desmume/src/gtk/desmume.desktop rename to src/gtk/desmume.desktop diff --git a/desmume/src/gtk/desmume.h b/src/gtk/desmume.h similarity index 94% rename from desmume/src/gtk/desmume.h rename to src/gtk/desmume.h index d91f41c63..5695521e2 100644 --- a/desmume/src/gtk/desmume.h +++ b/src/gtk/desmume.h @@ -1,40 +1,40 @@ -/* desmume.h - this file is part of DeSmuME - * - * Copyright (C) 2006,2007 DeSmuME Team - * Copyright (C) 2007 Pascal Giard (evilynux) - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __DESMUME_H__ -#define __DESMUME_H__ - -extern void desmume_init( struct armcpu_memory_iface *arm9_mem_if, - struct armcpu_ctrl_iface **arm9_ctrl_iface, - struct armcpu_memory_iface *arm7_mem_if, - struct armcpu_ctrl_iface **arm7_ctrl_iface, - int disable_sound); -extern void desmume_free( void); - -extern void desmume_pause( void); -extern void desmume_resume( void); -extern void desmume_toggle( void); -extern bool desmume_running( void); - -extern void desmume_cycle( void); - -#endif /*__DESMUME_H__*/ - +/* desmume.h - this file is part of DeSmuME + * + * Copyright (C) 2006,2007 DeSmuME Team + * Copyright (C) 2007 Pascal Giard (evilynux) + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __DESMUME_H__ +#define __DESMUME_H__ + +extern void desmume_init( struct armcpu_memory_iface *arm9_mem_if, + struct armcpu_ctrl_iface **arm9_ctrl_iface, + struct armcpu_memory_iface *arm7_mem_if, + struct armcpu_ctrl_iface **arm7_ctrl_iface, + int disable_sound); +extern void desmume_free( void); + +extern void desmume_pause( void); +extern void desmume_resume( void); +extern void desmume_toggle( void); +extern BOOL desmume_running( void); + +extern void desmume_cycle( void); + +#endif /*__DESMUME_H__*/ + diff --git a/desmume/src/gtk/desmume_config.cpp b/src/gtk/desmume_config.cpp similarity index 96% rename from desmume/src/gtk/desmume_config.cpp rename to src/gtk/desmume_config.cpp index bb5406c0b..4403ce285 100644 --- a/desmume/src/gtk/desmume_config.cpp +++ b/src/gtk/desmume_config.cpp @@ -1,147 +1,147 @@ -/* main.c - this file is part of DeSmuME - * - * Copyright (C) 2009 DeSmuME Team - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include - -#include "ctrlssdl.h" -#include "desmume_config.h" - -static const gchar *desmume_config_file = ".desmume.ini"; -static const u16 gtk_kb_cfg[NB_KEYS] = { - GDK_x, // A - GDK_z, // B - GDK_Shift_R, // select - GDK_Return, // start - GDK_Right, // Right - GDK_Left, // Left - GDK_Up, // Up - GDK_Down, // Down - GDK_w, // R - GDK_q, // L - GDK_s, // X - GDK_a, // Y - GDK_p, // DEBUG - GDK_o // BOOST -}; - - -GKeyFile *desmume_config_read_file() -{ - gchar *config_file; - GKeyFile *keyfile; - GError *error = NULL; - gboolean ret; - - config_file = g_build_filename(g_get_home_dir(), desmume_config_file, NULL); - keyfile = g_key_file_new(); - ret = g_key_file_load_from_file(keyfile, config_file, G_KEY_FILE_NONE, &error); - if (!ret) { - g_error_free(error); - } - - g_free(config_file); - - load_default_config(gtk_kb_cfg); - desmume_config_read_keys(keyfile); - desmume_config_read_joykeys(keyfile); - - return keyfile; -} - -void desmume_config_dispose(GKeyFile *keyfile) -{ - g_key_file_free(keyfile); -} - -static gboolean desmume_config_write_file(GKeyFile *keyfile) -{ - gchar *config_file; - gchar *data; - GError *error = NULL; - gsize length; - gboolean ret = TRUE; - - config_file = g_build_filename(g_get_home_dir(), desmume_config_file, NULL); - data = g_key_file_to_data(keyfile, &length, NULL); - ret = g_file_set_contents(config_file, data, length, &error); - if (!ret) { - g_error_free(error); - } - - g_free(config_file); - g_free(data); - - return ret; -} - -gboolean desmume_config_update_keys(GKeyFile *keyfile) -{ - for(int i = 0; i < NB_KEYS; i++) { - g_key_file_set_integer(keyfile, "KEYS", key_names[i], keyboard_cfg[i]); - } - - return desmume_config_write_file(keyfile); -} - -gboolean desmume_config_update_joykeys(GKeyFile *keyfile) -{ - for(int i = 0; i < NB_KEYS; i++) { - g_key_file_set_integer(keyfile, "JOYKEYS", key_names[i], joypad_cfg[i]); - } - - return desmume_config_write_file(keyfile); -} - -gboolean desmume_config_read_keys(GKeyFile *keyfile) -{ - GError *error = NULL; - - if (!g_key_file_has_group(keyfile, "KEYS")) - return TRUE; - - for (int i = 0; i < NB_KEYS; i++) { - keyboard_cfg[i] = g_key_file_get_integer(keyfile, "KEYS", key_names[i], &error); - if (error != NULL) { - g_error_free(error); - return FALSE; - } - } - - return TRUE; -} - -gboolean desmume_config_read_joykeys(GKeyFile *keyfile) -{ - GError *error = NULL; - - if (!g_key_file_has_group(keyfile, "JOYKEYS")) - return TRUE; - - for (int i = 0; i < NB_KEYS; i++) { - joypad_cfg[i] = g_key_file_get_integer(keyfile, "JOYKEYS", key_names[i], &error); - if (error != NULL) { - g_error_free(error); - return FALSE; - } - } - - return TRUE; -} +/* main.c - this file is part of DeSmuME + * + * Copyright (C) 2009 DeSmuME Team + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include + +#include "ctrlssdl.h" +#include "desmume_config.h" + +static const gchar *desmume_config_file = ".desmume.ini"; +static const u16 gtk_kb_cfg[NB_KEYS] = { + GDK_x, // A + GDK_z, // B + GDK_Shift_R, // select + GDK_Return, // start + GDK_Right, // Right + GDK_Left, // Left + GDK_Up, // Up + GDK_Down, // Down + GDK_w, // R + GDK_q, // L + GDK_s, // X + GDK_a, // Y + GDK_p, // DEBUG + GDK_o // BOOST +}; + + +GKeyFile *desmume_config_read_file() +{ + gchar *config_file; + GKeyFile *keyfile; + GError *error = NULL; + gboolean ret; + + config_file = g_build_filename(g_get_home_dir(), desmume_config_file, NULL); + keyfile = g_key_file_new(); + ret = g_key_file_load_from_file(keyfile, config_file, G_KEY_FILE_NONE, &error); + if (!ret) { + g_error_free(error); + } + + g_free(config_file); + + load_default_config(gtk_kb_cfg); + desmume_config_read_keys(keyfile); + desmume_config_read_joykeys(keyfile); + + return keyfile; +} + +void desmume_config_dispose(GKeyFile *keyfile) +{ + g_key_file_free(keyfile); +} + +static gboolean desmume_config_write_file(GKeyFile *keyfile) +{ + gchar *config_file; + gchar *data; + GError *error = NULL; + gsize length; + gboolean ret = TRUE; + + config_file = g_build_filename(g_get_home_dir(), desmume_config_file, NULL); + data = g_key_file_to_data(keyfile, &length, NULL); + ret = g_file_set_contents(config_file, data, length, &error); + if (!ret) { + g_error_free(error); + } + + g_free(config_file); + g_free(data); + + return ret; +} + +gboolean desmume_config_update_keys(GKeyFile *keyfile) +{ + for(int i = 0; i < NB_KEYS; i++) { + g_key_file_set_integer(keyfile, "KEYS", key_names[i], keyboard_cfg[i]); + } + + return desmume_config_write_file(keyfile); +} + +gboolean desmume_config_update_joykeys(GKeyFile *keyfile) +{ + for(int i = 0; i < NB_KEYS; i++) { + g_key_file_set_integer(keyfile, "JOYKEYS", key_names[i], joypad_cfg[i]); + } + + return desmume_config_write_file(keyfile); +} + +gboolean desmume_config_read_keys(GKeyFile *keyfile) +{ + GError *error = NULL; + + if (!g_key_file_has_group(keyfile, "KEYS")) + return TRUE; + + for (int i = 0; i < NB_KEYS; i++) { + keyboard_cfg[i] = g_key_file_get_integer(keyfile, "KEYS", key_names[i], &error); + if (error != NULL) { + g_error_free(error); + return FALSE; + } + } + + return TRUE; +} + +gboolean desmume_config_read_joykeys(GKeyFile *keyfile) +{ + GError *error = NULL; + + if (!g_key_file_has_group(keyfile, "JOYKEYS")) + return TRUE; + + for (int i = 0; i < NB_KEYS; i++) { + joypad_cfg[i] = g_key_file_get_integer(keyfile, "JOYKEYS", key_names[i], &error); + if (error != NULL) { + g_error_free(error); + return FALSE; + } + } + + return TRUE; +} diff --git a/desmume/src/gtk/desmume_config.h b/src/gtk/desmume_config.h similarity index 97% rename from desmume/src/gtk/desmume_config.h rename to src/gtk/desmume_config.h index 2fab74a48..e3e8b7247 100644 --- a/desmume/src/gtk/desmume_config.h +++ b/src/gtk/desmume_config.h @@ -1,32 +1,32 @@ -/* main.c - this file is part of DeSmuME - * - * Copyright (C) 2009 DeSmuME Team - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _DESMUME_GTK_CONFIG -#define _DESMUME_GTK_CONFIG - -GKeyFile *desmume_config_read_file(); -void desmume_config_dispose(GKeyFile *); - -gboolean desmume_config_update_keys(GKeyFile*); -gboolean desmume_config_update_joykeys(GKeyFile*); -gboolean desmume_config_read_keys(GKeyFile*); -gboolean desmume_config_read_joykeys(GKeyFile*); - -#endif +/* main.c - this file is part of DeSmuME + * + * Copyright (C) 2009 DeSmuME Team + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _DESMUME_GTK_CONFIG +#define _DESMUME_GTK_CONFIG + +GKeyFile *desmume_config_read_file(); +void desmume_config_dispose(GKeyFile *); + +gboolean desmume_config_update_keys(GKeyFile*); +gboolean desmume_config_update_joykeys(GKeyFile*); +gboolean desmume_config_read_keys(GKeyFile*); +gboolean desmume_config_read_joykeys(GKeyFile*); + +#endif diff --git a/desmume/src/gtk/doc/Makefile.am b/src/gtk/doc/Makefile.am similarity index 100% rename from desmume/src/gtk/doc/Makefile.am rename to src/gtk/doc/Makefile.am diff --git a/desmume/src/gtk/doc/desmume.1 b/src/gtk/doc/desmume.1 similarity index 100% rename from desmume/src/gtk/doc/desmume.1 rename to src/gtk/doc/desmume.1 diff --git a/desmume/src/gtk/main.cpp b/src/gtk/main.cpp similarity index 96% rename from desmume/src/gtk/main.cpp rename to src/gtk/main.cpp index 6ed3beca7..0f41bb941 100644 --- a/desmume/src/gtk/main.cpp +++ b/src/gtk/main.cpp @@ -1,2093 +1,2080 @@ -/* main.cpp - this file is part of DeSmuME - * - * Copyright (C) 2006-2009 DeSmuME Team - * Copyright (C) 2007 Pascal Giard (evilynux) - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef GTK_UI -#define GTK_UI -#endif - -#include -#include -#include -#include -#include -#include - -#include "types.h" -#include "armcpu.h" -#include "NDSSystem.h" -#include "sndsdl.h" -#include "ctrlssdl.h" -#include "MMU.h" -#include "render3D.h" -#include "desmume.h" -#include "debug.h" -#include "rasterize.h" -#include "saves.h" -#include "mic.h" -#include "movie.h" -#include "dTool.h" -#include "desmume_config.h" -#include "cheatsGTK.h" -#include "GPU_osd.h" - -#include "commandline.h" - -#include "addons.h" - -#ifdef GDB_STUB -#include "gdbstub.h" -#endif - -#ifdef HAVE_LIBOSMESA -#include -#include -#include "OGLRender.h" -#include "osmesa_3Demu.h" -#endif - -#include "DeSmuME.xpm" - -#define EMULOOP_PRIO (G_PRIORITY_HIGH_IDLE + 20) - -#if GTK_CHECK_VERSION(2,10,0) -#define HAVE_RECENT_FILES 1 -#endif - -#if GTK_CHECK_VERSION(2,14,0) -#define HAVE_TIMEOUT 1 -#endif - -#define SCREENS_PIXEL_SIZE (256*192*2) -#define SCREEN_BYTES_PER_PIXEL 3 -#define GAP_SIZE 50 - -#define FPS_LIMITER_FRAME_PERIOD 8 -static SDL_sem *fps_limiter_semaphore; -static int gtk_fps_limiter_disabled; - -enum { - MAIN_BG_0 = 0, - MAIN_BG_1, - MAIN_BG_2, - MAIN_BG_3, - MAIN_OBJ, - SUB_BG_0, - SUB_BG_1, - SUB_BG_2, - SUB_BG_3, - SUB_OBJ -}; - -gboolean EmuLoop(gpointer data); - -static void RecordMovieDialog(); -static void PlayMovieDialog(); -static void StopMovie(); -static void OpenNdsDialog(); -static void SaveStateDialog(); -static void LoadStateDialog(); -void Launch(); -void Pause(); -static void Printscreen(); -static void Reset(); -static void Edit_Controls(); -static void MenuSave(GtkMenuItem *item, gpointer slot); -static void MenuLoad(GtkMenuItem *item, gpointer slot); -static void About(); -static void ToggleMenuVisible(GtkToggleAction *action); -static void ToggleStatusbarVisible(GtkToggleAction *action); -static void ToggleToolbarVisible(GtkToggleAction *action); -static void ToggleAudio (GtkToggleAction *action); -#ifdef FAKE_MIC -static void ToggleMicNoise (GtkToggleAction *action); -#endif -static void ToggleGap (GtkToggleAction *action); -static void SetRotation (GtkAction *action); -static void ToggleLayerVisibility(GtkToggleAction* action, gpointer data); -#ifdef DESMUME_GTK_FIRMWARE_BROKEN -static void SelectFirmwareFile(); -#endif - -static const char *ui_description = -"" -" " -" " -" " -#ifdef HAVE_RECENT_FILES -" " -#endif -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -#ifdef GTK_DESMUME_FIRMWARE_BROKEN -" " -#endif -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -#ifdef FAKE_MIC -" " -#endif -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -""; - -static const GtkActionEntry action_entries[] = { - { "FileMenu", NULL, "_File" }, - { "open", "gtk-open", "_Open", "o", NULL, OpenNdsDialog }, -#ifdef HAVE_RECENT_FILES - { "RecentMenu", NULL, "Open _recent" }, -#endif - { "savestateto", NULL, "Save state _to ...", NULL, NULL, SaveStateDialog }, - { "loadstatefrom", NULL, "Load state _from ...", NULL, NULL, LoadStateDialog }, - { "recordmovie", NULL, "Record movie _to ...", NULL, NULL, RecordMovieDialog }, - { "playmovie", NULL, "Play movie _from ...", NULL, NULL, PlayMovieDialog }, - { "stopmovie", NULL, "Stop movie", NULL, NULL, StopMovie }, - { "SavestateMenu", NULL, "_Save state" }, - { "LoadstateMenu", NULL, "_Load state" }, -#ifdef DESMUME_GTK_FIRMWARE_BROKEN - { "loadfirmware","gtk-open", "Load Firm_ware file", "l", NULL, SelectFirmwareFile }, -#endif - { "printscreen","gtk-media-record", "Take a _screenshot", "s", NULL, Printscreen }, - { "quit", "gtk-quit", "_Quit", "q", NULL, gtk_main_quit }, - - { "EmulationMenu", NULL, "_Emulation" }, - { "run", "gtk-media-play", "_Run", "r", NULL, Launch }, - { "pause", "gtk-media-pause", "_Pause", "p", NULL, Pause }, - { "reset", "gtk-refresh", "Re_set", NULL, NULL, Reset }, - { "FrameskipMenu", NULL, "_Frameskip" }, - { "LayersMenu", NULL, "_Layers" }, - { "CheatMenu", NULL, "_Cheat" }, - { "cheatsearch", NULL, "_Search", NULL, NULL, CheatSearch }, - { "cheatlist", NULL, "_List", NULL, NULL, CheatList }, - - { "ConfigMenu", NULL, "_Config" }, - { "ConfigSaveMenu", NULL, "_Saves" }, - { "editctrls", NULL, "_Edit controls",NULL, NULL, Edit_Controls }, - { "RotationMenu", NULL, "_Rotation" }, - { "rotate_0", "gtk-orientation-portrait", "_0", NULL, NULL, G_CALLBACK(SetRotation) }, - { "rotate_90", "gtk-orientation-landscape", "_90", NULL, NULL, G_CALLBACK(SetRotation) }, - { "rotate_180", "gtk-orientation-reverse-portrait", "_180",NULL, NULL, G_CALLBACK(SetRotation) }, - { "rotate_270", "gtk-orientation-reverse-landscape", "_270",NULL, NULL, G_CALLBACK(SetRotation) }, - { "InterpolationMenu", NULL, "_Interpolation" }, - { "ViewMenu", NULL, "_View" }, - - { "ToolsMenu", NULL, "_Tools" }, - - { "HelpMenu", NULL, "_Help" }, - { "about", "gtk-about", "_About", NULL, NULL, About } -}; - -static const GtkToggleActionEntry toggle_entries[] = { - { "enableaudio", NULL, "_Enable audio", NULL, NULL, G_CALLBACK(ToggleAudio), TRUE}, -#ifdef FAKE_MIC - { "micnoise", NULL, "Fake mic _noise", NULL, NULL, G_CALLBACK(ToggleMicNoise), FALSE}, -#endif - { "gap", NULL, "_Gap", NULL, NULL, G_CALLBACK(ToggleGap), FALSE}, - { "view_menu", NULL, "View _menu", NULL, NULL, G_CALLBACK(ToggleMenuVisible), TRUE}, - { "view_toolbar", NULL, "View _toolbar", NULL, NULL, G_CALLBACK(ToggleToolbarVisible), TRUE}, - { "view_statusbar", NULL, "View _statusbar", NULL, NULL, G_CALLBACK(ToggleStatusbarVisible), TRUE} -}; - -static const GtkRadioActionEntry interpolation_entries[] = { - { "interp_nearest", NULL, "_Nearest", NULL, NULL, 0}, - { "interp_bilinear", NULL, "_Bilinear", NULL, NULL, 1}, -}; - -static const GtkRadioActionEntry frameskip_entries[] = { - { "frameskip0", NULL, "_0", NULL, NULL, 0}, - { "frameskip1", NULL, "_1", NULL, NULL, 1}, - { "frameskip2", NULL, "_2", NULL, NULL, 2}, - { "frameskip3", NULL, "_3", NULL, NULL, 3}, - { "frameskip4", NULL, "_4", NULL, NULL, 4}, - { "frameskip5", NULL, "_5", NULL, NULL, 5}, - { "frameskip6", NULL, "_6", NULL, NULL, 6}, - { "frameskip7", NULL, "_7", NULL, NULL, 7}, - { "frameskip8", NULL, "_8", NULL, NULL, 8}, - { "frameskip9", NULL, "_9", NULL, NULL, 9}, -}; - -static const GtkRadioActionEntry savet_entries[] = { - { "save_t0", NULL, "_0 Autodetect", NULL, NULL, 0}, - { "save_t1", NULL, "_1 EEPROM 4kbit", NULL, NULL, 1}, - { "save_t2", NULL, "_2 EEPROM 64kbit", NULL, NULL, 2}, - { "save_t3", NULL, "_3 EEPROM 512kbit", NULL, NULL, 3}, - { "save_t4", NULL, "_4 FRAM 256kbit", NULL, NULL, 4}, - { "save_t5", NULL, "_5 FLASH 2mbit", NULL, NULL, 5}, - { "save_t6", NULL, "_6 FLASH 4mbit", NULL, NULL, 6} -}; - -SoundInterface_struct *SNDCoreList[] = { -&SNDDummy, -&SNDSDL, -NULL -}; - -GPU3DInterface *core3DList[] = { - &gpu3DNull, - &gpu3DRasterize -#if defined(HAVE_LIBOSMESA) - , - &gpu3Dgl -#endif -}; - -GKeyFile *keyfile; - -struct modify_key_ctx { - gint mk_key_chosen; - GtkWidget *label; -}; - -static u16 Cur_Keypad = 0; -static u16 gdk_shift_pressed = 0; -u16 Keypad_Temp[NB_KEYS]; - -class configured_features : public CommandLine -{ -public: - int disable_sound; - int engine_3d; - int disable_limiter; - int savetype; - - int arm9_gdb_port; - int arm7_gdb_port; - - int firmware_language; - - const char *cflash_disk_image_file; -#ifdef HAVE_TIMEOUT - int timeout; -#endif -}; - -static void -init_configured_features( struct configured_features *config) -{ - config->arm9_gdb_port = 0; - config->arm7_gdb_port = 0; - - config->disable_sound = 0; - - config->engine_3d = 1; - - config->disable_limiter = 0; - - config->savetype = 0; - - config->cflash_disk_image_file = NULL; - -#ifdef HAVE_TIMEOUT - config->timeout = 0; -#endif - - /* use the default language */ - config->firmware_language = -1; -} - -static int -fill_configured_features( struct configured_features *config, - int argc, char ** argv) -{ - GOptionEntry options[] = { - { "disable-sound", 0, 0, G_OPTION_ARG_NONE, &config->disable_sound, "Disables the sound emulation", NULL}, - { "disable-limiter", 0, 0, G_OPTION_ARG_NONE, &config->disable_limiter, "Disables the 60fps limiter", NULL}, - { "3d-engine", 0, 0, G_OPTION_ARG_INT, &config->engine_3d, "Select 3d rendering engine. Available engines:\n" - "\t\t\t\t 0 = 3d disabled\n" - "\t\t\t\t 1 = internal rasterizer (default)\n" -#ifdef HAVE_LIBOSMESA - "\t\t\t\t 2 = osmesa opengl\n" -#endif - ,"ENGINE"}, - { "save-type", 0, 0, G_OPTION_ARG_INT, &config->savetype, "Select savetype from the following:\n" - "\t\t\t\t 0 = Autodetect (default)\n" - "\t\t\t\t 1 = EEPROM 4kbit\n" - "\t\t\t\t 2 = EEPROM 64kbit\n" - "\t\t\t\t 3 = EEPROM 512kbit\n" - "\t\t\t\t 4 = FRAM 256kbit\n" - "\t\t\t\t 5 = FLASH 2mbit\n" - "\t\t\t\t 6 = FLASH 4mbit\n", - "SAVETYPE"}, - { "fwlang", 0, 0, G_OPTION_ARG_INT, &config->firmware_language, "Set the language in the firmware, LANG as follows:\n" - "\t\t\t\t 0 = Japanese\n" - "\t\t\t\t 1 = English\n" - "\t\t\t\t 2 = French\n" - "\t\t\t\t 3 = German\n" - "\t\t\t\t 4 = Italian\n" - "\t\t\t\t 5 = Spanish\n", - "LANG"}, -#ifdef HAVE_TIMEOUT - { "timeout", 0, 0, G_OPTION_ARG_INT, &config->timeout, "Quit desmume after the specified seconds for testing purpose.", "SECONDS"}, -#endif - { NULL } - }; - - config->loadCommonOptions(); - g_option_context_add_main_entries (config->ctx, options, "options"); - g_option_context_add_group (config->ctx, gtk_get_option_group (TRUE)); - config->parse(argc,argv); - - if(!config->validate()) - goto error; - - if (config->savetype < 0 || config->savetype > 6) { - g_printerr("Accepted savetypes are from 0 to 6.\n"); - return false; - } - - if (config->firmware_language < -1 || config->firmware_language > 5) { - g_printerr("Firmware language must be set to a value from 0 to 5.\n"); - goto error; - } - - - if (config->engine_3d != 0 && config->engine_3d != 1 -#if defined(HAVE_LIBOSMESA) - && config->engine_3d != 2 -#endif - ) { - g_printerr("Currently available ENGINES: 0, 1" -#if defined(HAVE_LIBOSMESA) - ", 2" -#endif - "\n"); - goto error; - } - -#ifdef GDB_STUB - if (config->arm9_gdb_port != 0 && (config->arm9_gdb_port < 1 || config->arm9_gdb_port > 65535)) { - g_printerr("ARM9 GDB stub port must be in the range 1 to 65535\n"); - goto error; - } - - if (config->arm7_gdb_port != 0 && (config->arm7_gdb_port < 1 || config->arm7_gdb_port > 65535)) { - g_printerr("ARM7 GDB stub port must be in the range 1 to 65535\n"); - goto error; - } -#endif - - return 1; - -error: - config->errorHelp(argv[0]); - - return 0; -} - - -/* - * The thread handling functions needed by the GDB stub code. - */ -#ifdef GDB_STUB -void * -createThread_gdb( void (*thread_function)( void *data), - void *thread_data) -{ - GThread *new_thread = g_thread_create( (GThreadFunc)thread_function, - thread_data, - TRUE, - NULL); - - return new_thread; -} - -void -joinThread_gdb( void *thread_handle) { - g_thread_join( (GThread *)thread_handle); -} -#endif - -/************************ GTK *******************************/ - -uint Frameskip = 0; -GdkInterpType Interpolation = GDK_INTERP_BILINEAR; - -static GtkWidget *pWindow; -static GtkWidget *pStatusBar; -static GtkWidget *pDrawingArea; -GtkActionGroup * action_group; -GtkUIManager *ui_manager; - -guint nds_gap_size = 0; -float nds_screen_size_ratio = 1.0f; -int nds_screen_rotation_angle = 0; - -static BOOL regMainLoop = FALSE; - -static inline void UpdateStatusBar (const char *message) -{ - gint pStatusBar_Ctx; - - pStatusBar_Ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(pStatusBar), "Global"); - gtk_statusbar_pop(GTK_STATUSBAR(pStatusBar), pStatusBar_Ctx); - gtk_statusbar_push(GTK_STATUSBAR(pStatusBar), pStatusBar_Ctx, message); -} - -static void About() -{ - GdkPixbuf * pixbuf = gdk_pixbuf_new_from_xpm_data(DeSmuME_xpm); - - gtk_show_about_dialog(GTK_WINDOW(pWindow), - "name", "DeSmuME", - "version", VERSION, - "website", "http://desmume.org", - "logo", pixbuf, - "comments", "Nintendo DS emulator based on work by Yopyop", - NULL); - - g_object_unref(pixbuf); -} - -static void ToggleMenuVisible(GtkToggleAction *action) -{ - GtkWidget *pMenuBar = gtk_ui_manager_get_widget (ui_manager, "/MainMenu"); - - if (gtk_toggle_action_get_active(action) == TRUE) - gtk_widget_show(pMenuBar); - else - gtk_widget_hide(pMenuBar); -} - -static void ToggleToolbarVisible(GtkToggleAction *action) -{ - GtkWidget *pToolBar = gtk_ui_manager_get_widget (ui_manager, "/ToolBar"); - - if (gtk_toggle_action_get_active(action) == TRUE) - gtk_widget_show(pToolBar); - else - gtk_widget_hide(pToolBar); -} - -static void ToggleStatusbarVisible(GtkToggleAction *action) -{ - if (gtk_toggle_action_get_active(action) == TRUE) - gtk_widget_show(pStatusBar); - else - gtk_widget_hide(pStatusBar); -} - - - -static int Open(const char *filename) -{ - int res; - res = NDS_LoadROM( filename ); - if(res > 0) - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "cheatlist"), TRUE); - return res; -} - -void Launch() -{ - GtkWidget *pause; - desmume_resume(); - - if(!regMainLoop) { - g_idle_add_full(EMULOOP_PRIO, &EmuLoop, pWindow, NULL); - regMainLoop = TRUE; - } - - UpdateStatusBar("Running ..."); - - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "pause"), TRUE); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "reset"), TRUE); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "printscreen"), TRUE); - - pause = gtk_bin_get_child(GTK_BIN(gtk_ui_manager_get_widget(ui_manager, "/ToolBar/pause"))); - gtk_widget_grab_focus(pause); -} - -void Pause() -{ - GtkWidget *run; - desmume_pause(); - UpdateStatusBar("Paused"); - - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "pause"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); - - run = gtk_bin_get_child(GTK_BIN(gtk_ui_manager_get_widget(ui_manager, "/ToolBar/run"))); - gtk_widget_grab_focus(run); -} - -static void LoadStateDialog() -{ - GtkFileFilter *pFilter_ds, *pFilter_any; - GtkWidget *pFileSelection; - GtkWidget *pParent; - gchar *sPath; - - if (desmume_running()) - Pause(); - - pParent = GTK_WIDGET(pWindow); - - pFilter_ds = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_ds, "*.ds*"); - gtk_file_filter_set_name(pFilter_ds, "DeSmuME binary (.ds*)"); - - pFilter_any = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_any, "*"); - gtk_file_filter_set_name(pFilter_any, "All files"); - - /* Creating the selection window */ - pFileSelection = gtk_file_chooser_dialog_new("Load State From ...", - GTK_WINDOW(pParent), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_OK, - NULL); - - /* Only the dialog window is accepting events: */ - gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); - - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_ds); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); - - /* Showing the window */ - switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { - case GTK_RESPONSE_OK: - sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); - - if(savestate_load(sPath) == false ) { - GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - "Unable to load :\n%s", sPath); - gtk_dialog_run(GTK_DIALOG(pDialog)); - gtk_widget_destroy(pDialog); - } else { - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); - } - - g_free(sPath); - break; - default: - break; - } - gtk_widget_destroy(pFileSelection); -} - -static void RecordMovieDialog() -{ - GtkFileFilter *pFilter_dsm, *pFilter_any; - GtkWidget *pFileSelection; - GtkWidget *pParent; - gchar *sPath; - - if (desmume_running()) - Pause(); - - pParent = GTK_WIDGET(pWindow); - - pFilter_dsm = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_dsm, "*.dsm*"); - gtk_file_filter_set_name(pFilter_dsm, "DeSmuME movie file (.dsm*)"); - - pFilter_any = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_any, "*"); - gtk_file_filter_set_name(pFilter_any, "All files"); - - /* Creating the selection window */ - pFileSelection = gtk_file_chooser_dialog_new("Save Movie To ...", - GTK_WINDOW(pParent), - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_OK, - NULL); - gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (pFileSelection), TRUE); - - /* Only the dialog window is accepting events: */ - gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); - - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_dsm); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); - - /* Showing the window */ - switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { - case GTK_RESPONSE_OK: - sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); - FCEUI_SaveMovie(sPath,L"",0,NULL); - g_free(sPath); - break; - default: - break; - } - gtk_widget_destroy(pFileSelection); -} - -static void StopMovie() -{ - FCEUI_StopMovie(); -} - -static void PlayMovieDialog() -{ - GtkFileFilter *pFilter_dsm, *pFilter_any; - GtkWidget *pFileSelection; - GtkWidget *pParent; - gchar *sPath; - - if (desmume_running()) - Pause(); - - pParent = GTK_WIDGET(pWindow); - - pFilter_dsm = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_dsm, "*.dsm*"); - gtk_file_filter_set_name(pFilter_dsm, "DeSmuME movie file (.dsm*)"); - - pFilter_any = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_any, "*"); - gtk_file_filter_set_name(pFilter_any, "All files"); - - /* Creating the selection window */ - pFileSelection = gtk_file_chooser_dialog_new("Play movie from...", - GTK_WINDOW(pParent), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_OK, - NULL); - gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (pFileSelection), TRUE); - - /* Only the dialog window is accepting events: */ - gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); - - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_dsm); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); - - /* Showing the window */ - switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { - case GTK_RESPONSE_OK: - sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); - - FCEUI_LoadMovie(sPath,true,false,-1); - - g_free(sPath); - break; - default: - break; - } - gtk_widget_destroy(pFileSelection); -} - -static void SaveStateDialog() -{ - GtkFileFilter *pFilter_ds, *pFilter_any; - GtkWidget *pFileSelection; - GtkWidget *pParent; - gchar *sPath; - - if (desmume_running()) - Pause(); - - pParent = GTK_WIDGET(pWindow); - - pFilter_ds = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_ds, "*.ds*"); - gtk_file_filter_set_name(pFilter_ds, "DeSmuME binary (.ds*)"); - - pFilter_any = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_any, "*"); - gtk_file_filter_set_name(pFilter_any, "All files"); - - /* Creating the selection window */ - pFileSelection = gtk_file_chooser_dialog_new("Save State To ...", - GTK_WINDOW(pParent), - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_OK, - NULL); - gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (pFileSelection), TRUE); - - /* Only the dialog window is accepting events: */ - gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); - - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_ds); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); - - /* Showing the window */ - switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { - case GTK_RESPONSE_OK: - sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); - - if(savestate_save(sPath) == false ) { - GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - "Unable to save :\n%s", sPath); - gtk_dialog_run(GTK_DIALOG(pDialog)); - gtk_widget_destroy(pDialog); - } else { - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); - } - - g_free(sPath); - break; - default: - break; - } - gtk_widget_destroy(pFileSelection); -} - -static void OpenNdsDialog() -{ - GtkFileFilter *pFilter_nds, *pFilter_dsgba, *pFilter_any; - GtkWidget *pFileSelection; - GtkWidget *pParent; - gchar *sPath; - - if (desmume_running()) - Pause(); - - pParent = GTK_WIDGET(pWindow); - - pFilter_nds = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_nds, "*.[nN][dD][sS]"); -#ifdef HAVE_LIBZ - gtk_file_filter_add_pattern(pFilter_nds, "*.[nN][dD][sS].gz"); -#endif -#ifdef HAVE_LIBZZIP - gtk_file_filter_add_pattern(pFilter_nds, "*.[nN][dD][sS].zip"); -#endif - gtk_file_filter_set_name(pFilter_nds, "Nds binary (.nds)"); - - pFilter_dsgba = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_dsgba, "*.ds.gba"); - gtk_file_filter_set_name(pFilter_dsgba, "Nds binary with loader (.ds.gba)"); - - pFilter_any = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_any, "*"); - gtk_file_filter_set_name(pFilter_any, "All files"); - - /* Creating the selection window */ - pFileSelection = gtk_file_chooser_dialog_new("Open...", - GTK_WINDOW(pParent), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_OK, - NULL); - /* Only the dialog window is accepting events: */ - gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); - - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_dsgba); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); - - gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(pFileSelection), g_get_home_dir()); - - /* Showing the window */ - switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { - case GTK_RESPONSE_OK: - sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); - if(Open((const char*)sPath) < 0) { - GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - "Unable to load :\n%s", sPath); - gtk_dialog_run(GTK_DIALOG(pDialog)); - gtk_widget_destroy(pDialog); - } else { -#ifdef HAVE_RECENT_FILES - GtkRecentData recentData; - gchar *uri; - memset(&recentData, 0, sizeof(GtkRecentData)); - recentData.mime_type = g_strdup("application/x-nintendo-ds-rom"); - recentData.app_name = (gchar *) g_get_application_name (); - recentData.app_exec = g_strjoin (" ", g_get_prgname (), "%f", NULL); - - GtkRecentManager *manager; - manager = gtk_recent_manager_get_default (); - uri = g_filename_to_uri (sPath, NULL, NULL); - gtk_recent_manager_add_full (manager, uri, &recentData); - - g_free(uri); - g_free(recentData.app_name); - g_free(recentData.app_exec); -#endif - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); - } - - //Launch(NULL, pWindow); - - g_free(sPath); - break; - default: - break; - } - gtk_widget_destroy(pFileSelection); -} - -#ifdef HAVE_RECENT_FILES -static void OpenRecent(GtkRecentChooser *chooser, gpointer user_data) -{ - Open(g_filename_from_uri(gtk_recent_chooser_get_current_uri(chooser), NULL, NULL)); - - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); -} -#endif - -static void Reset() -{ - NDS_Reset(); - desmume_resume(); - - UpdateStatusBar("Running ..."); -} - - -/////////////////////////////// DRAWING SCREEN ////////////////////////////////// -static void UpdateDrawingAreaAspect() -{ - gint H, W; - switch (nds_screen_rotation_angle) { - case 0: - case 180: - W = 256; - H = 384 + nds_gap_size; - break; - case 90: - case 270: - W = 384 + nds_gap_size; - H = 256; - break; - default: - g_printerr("Congratulations, you've managed to set unsupported screen rotation angle (%d), resetting angle to 0\n", - nds_screen_rotation_angle); - nds_screen_rotation_angle = 0; - W = 256; - H = 384 + nds_gap_size; - break; - } - - gtk_widget_set_size_request(GTK_WIDGET(pDrawingArea), W, H); -} - -static void ToggleGap(GtkToggleAction* action) -{ - nds_gap_size = gtk_toggle_action_get_active(action) ? GAP_SIZE : 0; - UpdateDrawingAreaAspect(); -} - -static void SetRotation(GtkAction* action) -{ - const gchar *angle; - - angle = gtk_action_get_name(GTK_ACTION(action)) + strlen("rotate_"); - nds_screen_rotation_angle = atoi(angle); - UpdateDrawingAreaAspect(); -} - -static int ConfigureDrawingArea(GtkWidget *widget, GdkEventConfigure *event, gpointer data) -{ - return TRUE; -} - -static inline void gpu_screen_to_rgb(guchar * rgb, int size) -{ - u16 gpu_pixel; - int rot = nds_screen_rotation_angle; - - memset(rgb, 0, size); - for (int i = 0; i < 256; i++) { - for (int j = 0; j < 384; j++) { - - gpu_pixel = *((u16 *) & GPU_screen[(i + j * 256) << 1]); - u32 offset; - if(rot == 0 || rot == 180) - offset = i * 3 + j * 3 * 256; - else - offset = j * 3 + (255 - i) * 3 * 384; - switch (rot) { - case 0: - case 270: - *(rgb + offset + 0) = ((gpu_pixel >> 0) & 0x1f) << 3; - *(rgb + offset + 1) = ((gpu_pixel >> 5) & 0x1f) << 3; - *(rgb + offset + 2) = ((gpu_pixel >> 10) & 0x1f) << 3; - break; - case 180: - case 90: - *(rgb + size - offset - 3) = - ((gpu_pixel >> 0) & 0x1f) << 3; - *(rgb + size - offset - 2) = - ((gpu_pixel >> 5) & 0x1f) << 3; - *(rgb + size - offset - 1) = - ((gpu_pixel >> 10) & 0x1f) << 3; - break; - } - } - } -} - -/* Drawing callback */ -static int ExposeDrawingArea (GtkWidget *widget, GdkEventExpose *event, gpointer data) -{ - GdkPixbuf *origPixbuf, *resizedPixbuf = NULL, *drawPixbuf; - guchar rgb[SCREENS_PIXEL_SIZE*SCREEN_BYTES_PER_PIXEL]; - - float ssize, vratio, hratio; - gint daW, daH, imgH, imgW, xoff, yoff, xsize, ysize, xs, ys, xd, yd; - int rot = (nds_screen_rotation_angle % 180 == 90); - -#if GTK_CHECK_VERSION(2,14,0) - gdk_drawable_get_size( - gtk_widget_get_window(GTK_WIDGET(pDrawingArea)), &daW, &daH); -#else - gdk_drawable_get_size( - (GTK_WIDGET(pDrawingArea))->window, &daW, &daH); -#endif - - if(!rot){ - imgW = 256; imgH = 384; - daH -= nds_gap_size; - }else{ - imgH = 256; imgW = 384; - daW -= nds_gap_size; - } - - hratio = (float)daW / (float)imgW; - vratio = (float)daH / (float)imgH; - ssize = MIN(hratio, vratio); - nds_screen_size_ratio = 1 / (float)ssize; - xoff = (daW-ssize*imgW)/2; - yoff = (daH-ssize*imgH)/2; - if(!rot){ - xsize = ssize*imgW; - ysize = ssize*imgH/2; - xs = 0; - ys = ysize; - xd = xoff; - yd = yoff+ysize+nds_gap_size; - } else { - xsize = ssize*imgW/2; - ysize = ssize*imgH; - xs = xsize; - ys = 0; - xd = xoff+xsize+nds_gap_size; - yd = yoff; - } - - osd->update(); - DrawHUD(); - gpu_screen_to_rgb(rgb, SCREENS_PIXEL_SIZE*SCREEN_BYTES_PER_PIXEL); - origPixbuf = gdk_pixbuf_new_from_data(rgb, GDK_COLORSPACE_RGB, - 0, 8, imgW, imgH, imgW*SCREEN_BYTES_PER_PIXEL, NULL, NULL); - drawPixbuf = origPixbuf; - - if(nds_screen_size_ratio != 1.0) { - resizedPixbuf = gdk_pixbuf_scale_simple (origPixbuf, ssize*imgW, ssize*imgH, - Interpolation); - drawPixbuf = resizedPixbuf; - } - - gdk_draw_pixbuf(widget->window, NULL, drawPixbuf, 0,0, xoff, yoff, xsize, ysize, - GDK_RGB_DITHER_NONE, 0,0); - - gdk_draw_pixbuf(widget->window, NULL, drawPixbuf, xs, ys, xd, yd, xsize,ysize, - GDK_RGB_DITHER_NONE, 0,0); - - drawPixbuf = NULL; - if(nds_screen_size_ratio != 1.0) { - g_object_unref(resizedPixbuf); - } - g_object_unref(origPixbuf); - - return TRUE; -} - -/////////////////////////////// KEYS AND STYLUS UPDATE /////////////////////////////////////// - -static inline void rotoscaled_touchpos(gint x, gint y) -{ - int X, Y, rot, inv, dah, daw, gap_corr; - u16 EmuX, EmuY; - - rot = ( nds_screen_rotation_angle == 90 || nds_screen_rotation_angle == 270); - inv = ( nds_screen_rotation_angle == 180 || nds_screen_rotation_angle == 90); - gap_corr = inv ? 0 : nds_gap_size; - dah = GTK_WIDGET(pDrawingArea)->allocation.height; - daw = GTK_WIDGET(pDrawingArea)->allocation.width; - if(!rot){ - X = x - (daw-256/nds_screen_size_ratio)/2; - Y = y - (dah-nds_gap_size-384/nds_screen_size_ratio)/2-gap_corr; - } else { - X = y - (dah-256/nds_screen_size_ratio)/2; - Y = x - (daw-nds_gap_size-384/nds_screen_size_ratio)/2-gap_corr; - } - X = int (X * nds_screen_size_ratio); - Y = int (Y * nds_screen_size_ratio)-192; - - if(inv){ - Y = -Y; - } - - if((inv && !rot) || (!inv && rot)){ - X = 255 - X; - } - - LOG("X=%d, Y=%d\n", x,y); - - // FIXME: should ignore events only when STARTING touched-position - // was outside touchscreen - desmume window does not have physical band - // to limit movement of stylus - if ( Y >= 0 ) { - EmuX = CLAMP(X, 0, 255); - EmuY = CLAMP(Y, 0, 191); - NDS_setTouchPos(EmuX, EmuY); - } -} - -static gboolean Stylus_Move(GtkWidget *w, GdkEventMotion *e, gpointer data) -{ - GdkModifierType state; - gint x,y; - - if(click) { - if(e->is_hint) - gdk_window_get_pointer(w->window, &x, &y, &state); - else { - x= (gint)e->x; - y= (gint)e->y; - state=(GdkModifierType)e->state; - } - - if(state & GDK_BUTTON1_MASK) - rotoscaled_touchpos(x,y); - } - - return TRUE; -} - -static gboolean Stylus_Press(GtkWidget * w, GdkEventButton * e, - gpointer data) -{ - GdkModifierType state; - gint x, y; - - if (e->button == 3) { - GtkWidget * pMenu = gtk_menu_item_get_submenu ( GTK_MENU_ITEM( - gtk_ui_manager_get_widget (ui_manager, "/MainMenu/ConfigMenu/ViewMenu"))); - gtk_menu_popup(GTK_MENU(pMenu), NULL, NULL, NULL, NULL, 3, e->time); - } - - if( !desmume_running()) - return TRUE; - - if (e->button == 1) { - click = TRUE; - - gdk_window_get_pointer(w->window, &x, &y, &state); - - if(state & GDK_BUTTON1_MASK) - rotoscaled_touchpos(x, y); - } - - return TRUE; -} -static gboolean Stylus_Release(GtkWidget *w, GdkEventButton *e, gpointer data) -{ - if(click) NDS_releaseTouch(); - click = FALSE; - return TRUE; -} - -static void loadgame(int num){ - if (desmume_running()) - { - Pause(); - loadstate_slot(num); - Launch(); - } - else - loadstate_slot(num); -} - -static void savegame(int num){ - if (desmume_running()) - { - Pause(); - savestate_slot(num); - Launch(); - } - else - savestate_slot(num); -} - -static void MenuLoad(GtkMenuItem *item, gpointer slot) -{ - loadgame(GPOINTER_TO_INT(slot)); -} - -static void MenuSave(GtkMenuItem *item, gpointer slot) -{ - savegame(GPOINTER_TO_INT(slot)); -} - -static gint Key_Press(GtkWidget *w, GdkEventKey *e, gpointer data) -{ - if (e->keyval == GDK_Shift_L){ - gdk_shift_pressed |= 1; - return 1; - } - if (e->keyval == GDK_Shift_R){ - gdk_shift_pressed |= 2; - return 1; - } - if( e->keyval >= GDK_F1 && e->keyval <= GDK_F10 ){ - if(!gdk_shift_pressed) - loadgame(e->keyval - GDK_F1 + 1); - else - savegame(e->keyval - GDK_F1 + 1); - return 1; - } - guint mask; - mask = gtk_accelerator_get_default_mod_mask (); - if( (e->state & mask) == 0){ - u16 Key = lookup_key(e->keyval); - if(Key){ - ADD_KEY( Cur_Keypad, Key ); - if(desmume_running()) update_keypad(Cur_Keypad); - return 1; - } - } - -#ifdef PROFILE_MEMORY_ACCESS - if ( e->keyval == GDK_Tab) { - print_memory_profiling(); - return 1; - } -#endif - return 0; -} - -static gint Key_Release(GtkWidget *w, GdkEventKey *e, gpointer data) -{ - if (e->keyval == GDK_Shift_L){ - gdk_shift_pressed &= ~1; - return 1; - } - if (e->keyval == GDK_Shift_R){ - gdk_shift_pressed &= ~2; - return 1; - } - u16 Key = lookup_key(e->keyval); - RM_KEY( Cur_Keypad, Key ); - if(desmume_running()) update_keypad(Cur_Keypad); - return 1; - -} - -/////////////////////////////// CONTROLS EDIT ////////////////////////////////////// - -static void AcceptNewInputKey(GtkWidget *w, GdkEventKey *e, struct modify_key_ctx *ctx) -{ - gchar *YouPressed; - - ctx->mk_key_chosen = e->keyval; - YouPressed = g_strdup_printf("You pressed : %s\nClick OK to keep this key.", gdk_keyval_name(e->keyval)); - gtk_label_set(GTK_LABEL(ctx->label), YouPressed); - g_free(YouPressed); -} - -static void Modify_Key(GtkWidget* widget, gpointer data) -{ - struct modify_key_ctx ctx; - GtkWidget *mkDialog; - gchar *Key_Label; - gchar *Title; - gint Key; - - Key = GPOINTER_TO_INT(data); - ctx.mk_key_chosen = 0; - Title = g_strdup_printf("Press \"%s\" key ...\n", key_names[Key]); - mkDialog = gtk_dialog_new_with_buttons(Title, - GTK_WINDOW(pWindow), - GTK_DIALOG_MODAL, - GTK_STOCK_OK,GTK_RESPONSE_OK, - GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, - NULL); - - ctx.label = gtk_label_new(Title); - g_free(Title); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mkDialog)->vbox), ctx.label, TRUE, FALSE, 0); - - g_signal_connect(G_OBJECT(mkDialog), "key_press_event", G_CALLBACK(AcceptNewInputKey), &ctx); - - gtk_widget_show_all(GTK_DIALOG(mkDialog)->vbox); - - switch(gtk_dialog_run(GTK_DIALOG(mkDialog))) { - case GTK_RESPONSE_OK: - Keypad_Temp[Key] = ctx.mk_key_chosen; - Key_Label = g_strdup_printf("%s (%s)", key_names[Key], gdk_keyval_name(Keypad_Temp[Key])); - gtk_button_set_label(GTK_BUTTON(widget), Key_Label); - g_free(Key_Label); - break; - case GTK_RESPONSE_CANCEL: - case GTK_RESPONSE_NONE: - ctx.mk_key_chosen = 0; - break; - } - - gtk_widget_destroy(mkDialog); - -} - -static void Edit_Controls() -{ - GtkWidget *ecDialog; - GtkWidget *ecKey; - gchar *Key_Label; - int i; - - memcpy(&Keypad_Temp, &keyboard_cfg, sizeof(keyboard_cfg)); - - ecDialog = gtk_dialog_new_with_buttons("Edit controls", - GTK_WINDOW(pWindow), - GTK_DIALOG_MODAL, - GTK_STOCK_OK,GTK_RESPONSE_OK, - GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, - NULL); - - for(i = 0; i < NB_KEYS; i++) { - Key_Label = g_strdup_printf("%s (%s)", key_names[i], gdk_keyval_name(Keypad_Temp[i])); - ecKey = gtk_button_new_with_label(Key_Label); - g_free(Key_Label); - g_signal_connect(G_OBJECT(ecKey), "clicked", G_CALLBACK(Modify_Key), GINT_TO_POINTER(i)); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(ecDialog)->vbox), ecKey,TRUE, FALSE, 0); - } - - gtk_widget_show_all(GTK_DIALOG(ecDialog)->vbox); - - switch (gtk_dialog_run(GTK_DIALOG(ecDialog))) { - case GTK_RESPONSE_OK: - memcpy(&keyboard_cfg, &Keypad_Temp, sizeof(keyboard_cfg)); - desmume_config_update_keys(keyfile); - case GTK_RESPONSE_CANCEL: - case GTK_RESPONSE_NONE: - break; - } - gtk_widget_destroy(ecDialog); - -} - -static void ToggleLayerVisibility(GtkToggleAction* action, gpointer data) -{ - guint Layer = GPOINTER_TO_UINT(data); - gboolean active; - - // FIXME: make it work after resume - if (!desmume_running()) - return; - - active = gtk_toggle_action_get_active(action); - - switch (Layer) { - case MAIN_BG_0: - case MAIN_BG_1: - case MAIN_BG_2: - case MAIN_BG_3: - case MAIN_OBJ: - if(active == TRUE) { - GPU_addBack(MainScreen.gpu, Layer); - } else { - GPU_remove(MainScreen.gpu, Layer); - } - break; - case SUB_BG_0: - case SUB_BG_1: - case SUB_BG_2: - case SUB_BG_3: - case SUB_OBJ: - if(active == TRUE) { - GPU_addBack(SubScreen.gpu, Layer-SUB_BG_0); - } else { - GPU_remove(SubScreen.gpu, Layer-SUB_BG_0); - } - break; - default: - break; - } -} - -static void Printscreen() -{ - GdkPixbuf *screenshot; - gchar *filename; - GError *error = NULL; - u8 *rgb; - static int seq = 0; - - rgb = (u8 *) malloc(SCREENS_PIXEL_SIZE*3); - if (!rgb) - return; - - gpu_screen_to_rgb(rgb, SCREENS_PIXEL_SIZE); - screenshot = gdk_pixbuf_new_from_data(rgb, - GDK_COLORSPACE_RGB, - FALSE, - 8, - 256, - 192*2, - 256*3, - NULL, - NULL); - - filename = g_strdup_printf("./desmume-screenshot-%d.png", seq); - gdk_pixbuf_save(screenshot, filename, "png", &error, NULL); - if (error) { - g_error_free (error); - g_printerr("Failed to save %s", filename); - } else { - seq++; - } - - free(rgb); - g_object_unref(screenshot); - g_free(filename); -} - -#ifdef DESMUME_GTK_FIRMWARE_BROKEN -static void SelectFirmwareFile() -{ - GtkFileFilter *pFilter_nds, *pFilter_bin, *pFilter_any; - GtkWidget *pFileSelection; - GtkWidget *pParent; - gchar *sPath; - - BOOL oldState = desmume_running(); - Pause(); - - pParent = GTK_WIDGET(pWindow); - - pFilter_nds = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_nds, "*.nds"); - gtk_file_filter_set_name(pFilter_nds, "Nds binary (.nds)"); - - pFilter_bin = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_bin, "*.bin"); - gtk_file_filter_set_name(pFilter_bin, "Binary file (.bin)"); - - pFilter_any = gtk_file_filter_new(); - gtk_file_filter_add_pattern(pFilter_any, "*"); - gtk_file_filter_set_name(pFilter_any, "All files"); - - pFileSelection = gtk_file_chooser_dialog_new("Load firmware...", - GTK_WINDOW(pParent), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_OK, - NULL); - gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); - - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_bin); - gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); - - switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { - case GTK_RESPONSE_OK: - sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); - CommonSettings.UseExtFirmware = true; - strncpy(CommonSettings.Firmware, (const char*)sPath, g_utf8_strlen(sPath, -1)); - g_free(sPath); - break; - default: - break; - } - gtk_widget_destroy(pFileSelection); - - if(oldState) Launch(); -} -#endif - -static void Modify_Interpolation(GtkAction *action, GtkRadioAction *current) -{ - uint i = gtk_radio_action_get_current_value(current) ; - Interpolation = (i == 0 ? GDK_INTERP_NEAREST : GDK_INTERP_BILINEAR); -} - -static void Modify_Frameskip(GtkAction *action, GtkRadioAction *current) -{ - Frameskip = gtk_radio_action_get_current_value(current) ; -} - -/////////////////////////////// TOOLS MANAGEMENT /////////////////////////////// - -extern const dTool_t *dTools_list[]; -extern const int dTools_list_size; - -BOOL *dTools_running; - -static void Start_dTool(GtkWidget *widget, gpointer data) -{ - int tool = GPOINTER_TO_INT(data); - - if(dTools_running == NULL || dTools_running[tool]) - return; - - dTools_list[tool]->open(tool); - dTools_running[tool] = TRUE; -} - -void dTool_CloseCallback(int tool) -{ - if (dTools_running == NULL) - return; - - dTools_running[tool] = FALSE; -} - - -static inline void _updateDTools() -{ - if (dTools_running == NULL) - return; - - for(int i = 0; i < dTools_list_size; i++) { - if(dTools_running[i]) { dTools_list[i]->update(); } - } -} - -/////////////////////////////// MAIN EMULATOR LOOP /////////////////////////////// - -gboolean EmuLoop(gpointer data) -{ - static Uint32 fps_SecStart, fps_FrameCount; - static int limiter_frame_counter; - unsigned int i; - gchar Title[20]; - - if (!desmume_running()) { - regMainLoop = FALSE; - return FALSE; - } - - /* If desmume is currently running */ - fps_FrameCount += Frameskip + 1; - if (!fps_SecStart) - fps_SecStart = SDL_GetTicks(); - - if (SDL_GetTicks() - fps_SecStart >= 1000) { - fps_SecStart = SDL_GetTicks(); - - snprintf(Title, sizeof(Title), "Desmume - %dfps", fps_FrameCount); - gtk_window_set_title(GTK_WINDOW(pWindow), Title); - fps_FrameCount = 0; - } - - desmume_cycle(); /* Emule ! */ - for (i = 0; i < Frameskip; i++) { - NDS_SkipNextFrame(); - desmume_cycle(); - } - - _updateDTools(); - gtk_widget_queue_draw( pDrawingArea ); - osd->clear(); - - if (!gtk_fps_limiter_disabled) { - limiter_frame_counter += 1; - if (limiter_frame_counter >= FPS_LIMITER_FRAME_PERIOD) { - limiter_frame_counter = 0; - /* wait for the timer to expire */ - SDL_SemWait( fps_limiter_semaphore); - } - } - - return TRUE; -} - - -/** - * A SDL timer callback function. Signals the supplied SDL semaphore - * if its value is small. - * - * @param interval The interval since the last call (in ms) - * @param param The pointer to the semaphore. - * - * @return The interval to the next call (required by SDL) - */ -static Uint32 fps_limiter_fn(Uint32 interval, void *param) -{ - SDL_sem *sdl_semaphore = (SDL_sem *)param; - - /* signal the semaphore if it is getting low */ - if ( SDL_SemValue( sdl_semaphore) < 4) { - SDL_SemPost( sdl_semaphore); - } - - return interval; -} - -static void desmume_try_adding_ui(GtkUIManager *self, const char *ui_descr){ - GError *error; - error = NULL; - if (!gtk_ui_manager_add_ui_from_string (self, ui_descr, -1, &error)) - { - g_message ("building menus failed: %s", error->message); - g_error_free (error); - exit (EXIT_FAILURE); - } -} - -static void dui_set_accel_group(gpointer action, gpointer group) { - gtk_action_set_accel_group((GtkAction *)action, (GtkAccelGroup *)group); -} - -static void desmume_gtk_menu_file_saveload_slot (GtkActionGroup *ag) -{ - for(guint i = 1; i <= 10; i++){ - GtkAction *act; - char label[64], name[64]; - - snprintf(label, 60, "_%d", i); - - snprintf(name, 60, "savestate%d", i); - act = gtk_action_new(name, label, NULL, NULL); - g_signal_connect(G_OBJECT(act), "activate", G_CALLBACK(MenuSave), GUINT_TO_POINTER(i)); - gtk_action_group_add_action_with_accel(ag, GTK_ACTION(act), NULL); - - snprintf(name, 60, "loadstate%d", i); - act = gtk_action_new(name, label, NULL, NULL); - g_signal_connect(G_OBJECT(act), "activate", G_CALLBACK(MenuLoad), GUINT_TO_POINTER(i)); - gtk_action_group_add_action_with_accel(ag, GTK_ACTION(act), NULL); - } -} - -static void changesavetype(GtkAction *action, GtkRadioAction *current) -{ - backup_setManualBackupType( gtk_radio_action_get_current_value(current)); -} - -static void desmume_gtk_menu_emulation_layers (GtkActionGroup *ag) -{ - const char *Layers_Menu[10][2] = { - {"layermainbg0","_0 Main BG 0"}, - {"layermainbg1","_1 Main BG 1"}, - {"layermainbg2","_2 Main BG 2"}, - {"layermainbg3","_3 Main BG 3"}, - {"layermainobj","_4 Main OBJ"}, - {"layersubbg0", "_5 SUB BG 0"}, - {"layersubbg1", "_6 SUB BG 1"}, - {"layersubbg2", "_7 SUB BG 2"}, - {"layersubbg3", "_8 SUB BG 3"}, - {"layersubobj", "_9 SUB OBJ"} - }; - guint i; - - GtkToggleAction *act; - for(i = 0; i< 10; i++){ - act = gtk_toggle_action_new(Layers_Menu[i][0],Layers_Menu[i][1],NULL,NULL); - gtk_toggle_action_set_active(act, TRUE); - g_signal_connect(G_OBJECT(act), "activate", G_CALLBACK(ToggleLayerVisibility), GUINT_TO_POINTER(i)); - gtk_action_group_add_action_with_accel(ag, GTK_ACTION(act), NULL); - } -} - -static void ToggleAudio (GtkToggleAction *action) -{ - if (gtk_toggle_action_get_active(action) == TRUE) { - SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); - osd->addLine("Audio enabled\n"); - } else { - SPU_ChangeSoundCore(0, 0); - osd->addLine("Audio disabled\n"); - } -} - -#ifdef FAKE_MIC -static void ToggleMicNoise (GtkToggleAction *action) -{ - BOOL doNoise = (BOOL)gtk_toggle_action_get_active(action); - - Mic_DoNoise(doNoise); - if (doNoise) - osd->addLine("Fake mic enabled\n"); - else - osd->addLine("Fake mic disabled\n"); -} -#endif - -static void desmume_gtk_menu_tools (GtkActionGroup *ag) -{ - gint i; - for(i = 0; i < dTools_list_size; i++) { - GtkAction *act; - act = gtk_action_new(dTools_list[i]->shortname, dTools_list[i]->name, NULL, NULL); - g_signal_connect(G_OBJECT(act), "activate", G_CALLBACK(Start_dTool), GINT_TO_POINTER(i)); - gtk_action_group_add_action(ag, GTK_ACTION(act)); - } -} - -#ifdef HAVE_TIMEOUT -static gboolean timeout_exit_cb(gpointer data) -{ - gtk_main_quit(); - INFO("Quit after %d seconds timeout\n", GPOINTER_TO_INT(data)); - - return FALSE; -} -#endif - - -static int -common_gtk_main( struct configured_features *my_config) -{ - SDL_TimerID limiter_timer = NULL; - - GtkAccelGroup * accel_group; - GtkWidget *pVBox; - GtkWidget *pMenuBar; - GtkWidget *pToolBar; - gint pStatusBar_Ctx; - -#ifdef GDB_STUB - gdbstub_handle_t arm9_gdb_stub; - gdbstub_handle_t arm7_gdb_stub; -#endif - struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; - struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; - struct armcpu_ctrl_iface *arm9_ctrl_iface; - struct armcpu_ctrl_iface *arm7_ctrl_iface; - - /* the firmware settings */ - struct NDS_fw_config_data fw_config; - - /* default the firmware settings, they may get changed later */ - NDS_FillDefaultFirmwareConfigData( &fw_config); - - /* use any language set on the command line */ - if ( my_config->firmware_language != -1) { - fw_config.language = my_config->firmware_language; - } - - //------------------addons---------- - my_config->process_addonCommands(); - addon_type = NDS_ADDON_NONE; - if (my_config->is_cflash_configured) - addon_type = NDS_ADDON_CFLASH; - - switch (addon_type) { - case NDS_ADDON_CFLASH: - case NDS_ADDON_RUMBLEPAK: - case NDS_ADDON_NONE: - case NDS_ADDON_GBAGAME: - break; - default: - addon_type = NDS_ADDON_NONE; - break; - } - addonsChangePak (addon_type); - -#ifdef GDB_STUB - if ( my_config->arm9_gdb_port != 0) { - arm9_gdb_stub = createStub_gdb( my_config->arm9_gdb_port, - &arm9_memio, - &arm9_base_memory_iface); - - if ( arm9_gdb_stub == NULL) { - g_printerr("Failed to create ARM9 gdbstub on port %d\n", - my_config->arm9_gdb_port); - exit( -1); - } - } - if ( my_config->arm7_gdb_port != 0) { - arm7_gdb_stub = createStub_gdb( my_config->arm7_gdb_port, - &arm7_memio, - &arm7_base_memory_iface); - - if ( arm7_gdb_stub == NULL) { - g_printerr("Failed to create ARM7 gdbstub on port %d\n", - my_config->arm7_gdb_port); - exit( -1); - } - } -#endif - - /* FIXME: SDL_INIT_VIDEO is needed for joystick support to work!? - Perhaps it needs a "window" to catch events...? */ - if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO) == -1) { - g_printerr("Error trying to initialize SDL: %s\n", - SDL_GetError()); - return 1; - } - desmume_init( arm9_memio, &arm9_ctrl_iface, - arm7_memio, &arm7_ctrl_iface, - my_config->disable_sound); - - /* Init the hud / osd stuff */ - Desmume_InitOnce(); - Hud.reset(); - - /* - * Activate the GDB stubs - * This has to come after the NDS_Init (called in desmume_init) - * where the cpus are set up. - */ -#ifdef GDB_STUB - if ( my_config->arm9_gdb_port != 0) { - activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); - } - if ( my_config->arm7_gdb_port != 0) { - activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); - } -#endif - - /* Create the dummy firmware */ - NDS_CreateDummyFirmware( &fw_config); - - /* Initialize joysticks */ - if(!init_joy()) return 1; - - dTools_running = (BOOL*)malloc(sizeof(BOOL) * dTools_list_size); - if (dTools_running != NULL) - memset(dTools_running, FALSE, sizeof(BOOL) * dTools_list_size); - - keyfile = desmume_config_read_file(); - - /* Create the window */ - pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(pWindow), "Desmume"); - gtk_window_set_resizable(GTK_WINDOW (pWindow), TRUE); - gtk_window_set_icon(GTK_WINDOW (pWindow), gdk_pixbuf_new_from_xpm_data(DeSmuME_xpm)); - - g_signal_connect(G_OBJECT(pWindow), "destroy", G_CALLBACK(gtk_main_quit), NULL); - g_signal_connect(G_OBJECT(pWindow), "key_press_event", G_CALLBACK(Key_Press), NULL); - g_signal_connect(G_OBJECT(pWindow), "key_release_event", G_CALLBACK(Key_Release), NULL); - - /* Create the GtkVBox */ - pVBox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(pWindow), pVBox); - - ui_manager = gtk_ui_manager_new (); - accel_group = gtk_accel_group_new(); - action_group = gtk_action_group_new("dui"); - - gtk_action_group_add_actions(action_group, action_entries, G_N_ELEMENTS(action_entries), NULL); - gtk_action_group_add_toggle_actions(action_group, toggle_entries, G_N_ELEMENTS(toggle_entries), NULL); - desmume_gtk_menu_emulation_layers(action_group); - desmume_gtk_menu_file_saveload_slot(action_group); - desmume_gtk_menu_tools(action_group); - gtk_action_group_add_radio_actions(action_group, savet_entries, G_N_ELEMENTS(savet_entries), - my_config->savetype, G_CALLBACK(changesavetype), NULL); - gtk_action_group_add_radio_actions(action_group, interpolation_entries, G_N_ELEMENTS(interpolation_entries), - 1, G_CALLBACK(Modify_Interpolation), NULL); - gtk_action_group_add_radio_actions(action_group, frameskip_entries, G_N_ELEMENTS(frameskip_entries), - 0, G_CALLBACK(Modify_Frameskip), NULL); - { - GList * list = gtk_action_group_list_actions(action_group); - g_list_foreach(list, dui_set_accel_group, accel_group); - } - gtk_window_add_accel_group(GTK_WINDOW(pWindow), accel_group); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "pause"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "reset"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "printscreen"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "cheatlist"), FALSE); - gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "cheatsearch"), FALSE); - - gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); - - accel_group = gtk_ui_manager_get_accel_group (ui_manager); - gtk_window_add_accel_group (GTK_WINDOW (pWindow), accel_group); - - desmume_try_adding_ui(ui_manager, ui_description); - - pMenuBar = gtk_ui_manager_get_widget (ui_manager, "/MainMenu"); - gtk_box_pack_start (GTK_BOX (pVBox), pMenuBar, FALSE, FALSE, 0); - pToolBar = gtk_ui_manager_get_widget (ui_manager, "/ToolBar"); - gtk_box_pack_start (GTK_BOX(pVBox), pToolBar, FALSE, FALSE, 0); - -#ifdef HAVE_RECENT_FILES - { - GtkWidget * recentMenu = gtk_ui_manager_get_widget (ui_manager, "/MainMenu/FileMenu/RecentMenu"); - GtkWidget * recentFiles = gtk_recent_chooser_menu_new(); - GtkRecentFilter * recentFilter = gtk_recent_filter_new(); - gtk_recent_filter_add_mime_type(recentFilter, "application/x-nintendo-ds-rom"); - gtk_recent_chooser_set_filter(GTK_RECENT_CHOOSER(recentFiles), recentFilter); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(recentMenu), recentFiles); - g_signal_connect(G_OBJECT(recentFiles), "item-activated", G_CALLBACK(OpenRecent), NULL); - } -#endif - - /* Creating the place for showing DS screens */ - pDrawingArea = gtk_drawing_area_new(); - gtk_container_add (GTK_CONTAINER (pVBox), pDrawingArea); - - gtk_widget_set_size_request(GTK_WIDGET(pDrawingArea), 256, 384); - - gtk_widget_set_events(pDrawingArea, - GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK ); - - g_signal_connect(G_OBJECT(pDrawingArea), "button_press_event", - G_CALLBACK(Stylus_Press), NULL); - g_signal_connect(G_OBJECT(pDrawingArea), "button_release_event", - G_CALLBACK(Stylus_Release), NULL); - g_signal_connect(G_OBJECT(pDrawingArea), "motion_notify_event", - G_CALLBACK(Stylus_Move), NULL); - g_signal_connect(G_OBJECT(pDrawingArea), "expose_event", - G_CALLBACK(ExposeDrawingArea), NULL ) ; - g_signal_connect(G_OBJECT(pDrawingArea), "configure_event", - G_CALLBACK(ConfigureDrawingArea), NULL ) ; - - /* Status bar */ - pStatusBar = gtk_statusbar_new(); - pStatusBar_Ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(pStatusBar), "Global"); - UpdateStatusBar("Desmume"); - gtk_box_pack_end(GTK_BOX(pVBox), pStatusBar, FALSE, FALSE, 0); - - gtk_widget_show_all(pWindow); - - gtk_fps_limiter_disabled = my_config->disable_limiter; - if ( !gtk_fps_limiter_disabled) { - /* create the semaphore used for fps limiting */ - fps_limiter_semaphore = SDL_CreateSemaphore( 1); - - /* start a SDL timer for every FPS_LIMITER_FRAME_PERIOD frames to keep us at 60 fps */ - limiter_timer = SDL_AddTimer( 16 * FPS_LIMITER_FRAME_PERIOD, fps_limiter_fn, fps_limiter_semaphore); - if ( limiter_timer == NULL) { - g_printerr("Error trying to start FPS limiter timer: %s\n", - SDL_GetError()); - return 1; - } - } - - //Set the 3D emulation to use - unsigned core = my_config->engine_3d; - // setup the gdk 3D emulation; -#if defined(HAVE_LIBOSMESA) - if(my_config->engine_3d == 2){ - core = init_osmesa_3Demu() ? 2 : GPU3D_NULL; - } -#endif - NDS_3D_ChangeCore(core); - if(my_config->engine_3d != 0 && gpu3D == &gpu3DNull) { - g_printerr("Failed to initialise openGL 3D emulation; " - "removing 3D support\n"); - } - - backup_setManualBackupType(my_config->savetype); - - // Command line arg - if( my_config->nds_file != "") { - if(Open( my_config->nds_file.c_str()) >= 0) { - my_config->process_movieCommands(); - - if(my_config->load_slot){ - loadstate_slot(my_config->load_slot); - } - - Launch(); - } else { - GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pWindow), - GTK_DIALOG_MODAL, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - "Unable to load :\n%s", my_config->nds_file.c_str()); - gtk_dialog_run(GTK_DIALOG(pDialog)); - gtk_widget_destroy(pDialog); - } - } - -#ifdef HAVE_TIMEOUT - if (my_config->timeout > 0) { - g_timeout_add_seconds(my_config->timeout, timeout_exit_cb, GINT_TO_POINTER(my_config->timeout)); - } -#endif - - /* Main loop */ - -// gtk_idle_add(&EmuLoop, pWindow); -// g_idle_add(&EmuLoop, pWindow); - - gtk_main(); - - desmume_free(); - - if ( !gtk_fps_limiter_disabled) { - /* tidy up the FPS limiter timer and semaphore */ - SDL_RemoveTimer( limiter_timer); - SDL_DestroySemaphore( fps_limiter_semaphore); - } - - /* Unload joystick */ - uninit_joy(); - - SDL_Quit(); - - desmume_config_dispose(keyfile); - -#ifdef GDB_STUB - if ( my_config->arm9_gdb_port != 0) { - destroyStub_gdb( arm9_gdb_stub); - } - if ( my_config->arm7_gdb_port != 0) { - destroyStub_gdb( arm7_gdb_stub); - } -#endif - - return EXIT_SUCCESS; -} - - -int main (int argc, char *argv[]) -{ - configured_features my_config; - - init_configured_features( &my_config); - - if (!g_thread_supported()) - g_thread_init( NULL); - - gtk_init(&argc, &argv); - - if ( !fill_configured_features( &my_config, argc, argv)) { - exit(0); - } - - return common_gtk_main( &my_config); -} - -#ifdef WIN32 -int WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) -{ - int argc = 0; - char *argv[] = NULL; - - /* - * FIXME: - * Emulate the argc and argv main parameters. Could do this using - * CommandLineToArgvW and then convert the wide chars to thin chars. - * Or parse the wide chars directly and call common_gtk_main with a - * filled configuration structure. - */ - main( argc, argv); -} -#endif - +/* main.cpp - this file is part of DeSmuME + * + * Copyright (C) 2006-2009 DeSmuME Team + * Copyright (C) 2007 Pascal Giard (evilynux) + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef GTK_UI +#define GTK_UI +#endif + +#include +#include +#include +#include +#include +#include + +#include "types.h" +#include "armcpu.h" +#include "NDSSystem.h" +#include "sndsdl.h" +#include "ctrlssdl.h" +#include "MMU.h" +#include "render3D.h" +#include "desmume.h" +#include "debug.h" +#include "rasterize.h" +#include "saves.h" +#include "mic.h" +#include "movie.h" +#include "dTool.h" +#include "desmume_config.h" +#include "cheatsGTK.h" +#include "GPU_osd.h" + +#include "commandline.h" + +#include "addons.h" + +#ifdef GDB_STUB +#include "gdbstub.h" +#endif + +#ifdef HAVE_LIBOSMESA +#include +#include +#include "OGLRender.h" +#include "osmesa_3Demu.h" +#endif + +#include "DeSmuME.xpm" + +#define EMULOOP_PRIO (G_PRIORITY_HIGH_IDLE + 20) + +#if GTK_CHECK_VERSION(2,10,0) +#define HAVE_RECENT_FILES 1 +#endif + +#if GTK_CHECK_VERSION(2,14,0) +#define HAVE_TIMEOUT 1 +#endif + +#define SCREENS_PIXEL_SIZE (256*192*2) +#define SCREEN_BYTES_PER_PIXEL 3 +#define GAP_SIZE 50 + +#define FPS_LIMITER_FRAME_PERIOD 8 +static SDL_sem *fps_limiter_semaphore; +static int gtk_fps_limiter_disabled; + +enum { + MAIN_BG_0 = 0, + MAIN_BG_1, + MAIN_BG_2, + MAIN_BG_3, + MAIN_OBJ, + SUB_BG_0, + SUB_BG_1, + SUB_BG_2, + SUB_BG_3, + SUB_OBJ +}; + +gboolean EmuLoop(gpointer data); + +static void RecordMovieDialog(); +static void PlayMovieDialog(); +static void StopMovie(); +static void OpenNdsDialog(); +static void SaveStateDialog(); +static void LoadStateDialog(); +void Launch(); +void Pause(); +static void Printscreen(); +static void Reset(); +static void Edit_Controls(); +static void MenuSave(GtkMenuItem *item, gpointer slot); +static void MenuLoad(GtkMenuItem *item, gpointer slot); +static void About(); +static void ToggleMenuVisible(GtkToggleAction *action); +static void ToggleStatusbarVisible(GtkToggleAction *action); +static void ToggleToolbarVisible(GtkToggleAction *action); +static void ToggleAudio (GtkToggleAction *action); +#ifdef FAKE_MIC +static void ToggleMicNoise (GtkToggleAction *action); +#endif +static void ToggleGap (GtkToggleAction *action); +static void SetRotation (GtkAction *action); +static void ToggleLayerVisibility(GtkToggleAction* action, gpointer data); +#ifdef DESMUME_GTK_FIRMWARE_BROKEN +static void SelectFirmwareFile(); +#endif + +static const char *ui_description = +"" +" " +" " +" " +#ifdef HAVE_RECENT_FILES +" " +#endif +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +#ifdef GTK_DESMUME_FIRMWARE_BROKEN +" " +#endif +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +#ifdef FAKE_MIC +" " +#endif +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +""; + +static const GtkActionEntry action_entries[] = { + { "FileMenu", NULL, "_File" }, + { "open", "gtk-open", "_Open", "o", NULL, OpenNdsDialog }, +#ifdef HAVE_RECENT_FILES + { "RecentMenu", NULL, "Open _recent" }, +#endif + { "savestateto", NULL, "Save state _to ...", NULL, NULL, SaveStateDialog }, + { "loadstatefrom", NULL, "Load state _from ...", NULL, NULL, LoadStateDialog }, + { "recordmovie", NULL, "Record movie _to ...", NULL, NULL, RecordMovieDialog }, + { "playmovie", NULL, "Play movie _from ...", NULL, NULL, PlayMovieDialog }, + { "stopmovie", NULL, "Stop movie", NULL, NULL, StopMovie }, + { "SavestateMenu", NULL, "_Save state" }, + { "LoadstateMenu", NULL, "_Load state" }, +#ifdef DESMUME_GTK_FIRMWARE_BROKEN + { "loadfirmware","gtk-open", "Load Firm_ware file", "l", NULL, SelectFirmwareFile }, +#endif + { "printscreen","gtk-media-record", "Take a _screenshot", "s", NULL, Printscreen }, + { "quit", "gtk-quit", "_Quit", "q", NULL, gtk_main_quit }, + + { "EmulationMenu", NULL, "_Emulation" }, + { "run", "gtk-media-play", "_Run", "r", NULL, Launch }, + { "pause", "gtk-media-pause", "_Pause", "p", NULL, Pause }, + { "reset", "gtk-refresh", "Re_set", NULL, NULL, Reset }, + { "FrameskipMenu", NULL, "_Frameskip" }, + { "LayersMenu", NULL, "_Layers" }, + { "CheatMenu", NULL, "_Cheat" }, + { "cheatsearch", NULL, "_Search", NULL, NULL, CheatSearch }, + { "cheatlist", NULL, "_List", NULL, NULL, CheatList }, + + { "ConfigMenu", NULL, "_Config" }, + { "ConfigSaveMenu", NULL, "_Saves" }, + { "editctrls", NULL, "_Edit controls",NULL, NULL, Edit_Controls }, + { "RotationMenu", NULL, "_Rotation" }, + { "rotate_0", "gtk-orientation-portrait", "_0", NULL, NULL, G_CALLBACK(SetRotation) }, + { "rotate_90", "gtk-orientation-landscape", "_90", NULL, NULL, G_CALLBACK(SetRotation) }, + { "rotate_180", "gtk-orientation-reverse-portrait", "_180",NULL, NULL, G_CALLBACK(SetRotation) }, + { "rotate_270", "gtk-orientation-reverse-landscape", "_270",NULL, NULL, G_CALLBACK(SetRotation) }, + { "InterpolationMenu", NULL, "_Interpolation" }, + { "ViewMenu", NULL, "_View" }, + + { "ToolsMenu", NULL, "_Tools" }, + + { "HelpMenu", NULL, "_Help" }, + { "about", "gtk-about", "_About", NULL, NULL, About } +}; + +static const GtkToggleActionEntry toggle_entries[] = { + { "enableaudio", NULL, "_Enable audio", NULL, NULL, G_CALLBACK(ToggleAudio), TRUE}, +#ifdef FAKE_MIC + { "micnoise", NULL, "Fake mic _noise", NULL, NULL, G_CALLBACK(ToggleMicNoise), FALSE}, +#endif + { "gap", NULL, "_Gap", NULL, NULL, G_CALLBACK(ToggleGap), FALSE}, + { "view_menu", NULL, "View _menu", NULL, NULL, G_CALLBACK(ToggleMenuVisible), TRUE}, + { "view_toolbar", NULL, "View _toolbar", NULL, NULL, G_CALLBACK(ToggleToolbarVisible), TRUE}, + { "view_statusbar", NULL, "View _statusbar", NULL, NULL, G_CALLBACK(ToggleStatusbarVisible), TRUE} +}; + +static const GtkRadioActionEntry interpolation_entries[] = { + { "interp_nearest", NULL, "_Nearest", NULL, NULL, 0}, + { "interp_bilinear", NULL, "_Bilinear", NULL, NULL, 1}, +}; + +static const GtkRadioActionEntry frameskip_entries[] = { + { "frameskip0", NULL, "_0", NULL, NULL, 0}, + { "frameskip1", NULL, "_1", NULL, NULL, 1}, + { "frameskip2", NULL, "_2", NULL, NULL, 2}, + { "frameskip3", NULL, "_3", NULL, NULL, 3}, + { "frameskip4", NULL, "_4", NULL, NULL, 4}, + { "frameskip5", NULL, "_5", NULL, NULL, 5}, + { "frameskip6", NULL, "_6", NULL, NULL, 6}, + { "frameskip7", NULL, "_7", NULL, NULL, 7}, + { "frameskip8", NULL, "_8", NULL, NULL, 8}, + { "frameskip9", NULL, "_9", NULL, NULL, 9}, +}; + +static const GtkRadioActionEntry savet_entries[] = { + { "save_t0", NULL, "_0 Autodetect", NULL, NULL, 0}, + { "save_t1", NULL, "_1 EEPROM 4kbit", NULL, NULL, 1}, + { "save_t2", NULL, "_2 EEPROM 64kbit", NULL, NULL, 2}, + { "save_t3", NULL, "_3 EEPROM 512kbit", NULL, NULL, 3}, + { "save_t4", NULL, "_4 FRAM 256kbit", NULL, NULL, 4}, + { "save_t5", NULL, "_5 FLASH 2mbit", NULL, NULL, 5}, + { "save_t6", NULL, "_6 FLASH 4mbit", NULL, NULL, 6} +}; + +SoundInterface_struct *SNDCoreList[] = { +&SNDDummy, +&SNDDummy, +&SNDSDL, +NULL +}; + +GPU3DInterface *core3DList[] = { + &gpu3DNull, + &gpu3DRasterize +#if defined(HAVE_LIBOSMESA) + , + &gpu3Dgl +#endif +}; + +GKeyFile *keyfile; + +struct modify_key_ctx { + gint mk_key_chosen; + GtkWidget *label; +}; + +static u16 Cur_Keypad = 0; +static u16 gdk_shift_pressed = 0; +u16 Keypad_Temp[NB_KEYS]; + +class configured_features : public CommandLine +{ +public: + int disable_sound; + int engine_3d; + int disable_limiter; + int savetype; + + int arm9_gdb_port; + int arm7_gdb_port; + + int firmware_language; + + const char *cflash_disk_image_file; +#ifdef HAVE_TIMEOUT + int timeout; +#endif +}; + +static void +init_configured_features( struct configured_features *config) +{ + config->arm9_gdb_port = 0; + config->arm7_gdb_port = 0; + + config->disable_sound = 0; + + config->engine_3d = 1; + + config->disable_limiter = 0; + + config->savetype = 0; + + config->cflash_disk_image_file = NULL; + +#ifdef HAVE_TIMEOUT + config->timeout = 0; +#endif + + /* use the default language */ + config->firmware_language = -1; +} + +static int +fill_configured_features( struct configured_features *config, + int argc, char ** argv) +{ + GOptionEntry options[] = { + { "disable-sound", 0, 0, G_OPTION_ARG_NONE, &config->disable_sound, "Disables the sound emulation", NULL}, + { "disable-limiter", 0, 0, G_OPTION_ARG_NONE, &config->disable_limiter, "Disables the 60fps limiter", NULL}, + { "3d-engine", 0, 0, G_OPTION_ARG_INT, &config->engine_3d, "Select 3d rendering engine. Available engines:\n" + "\t\t\t\t 0 = 3d disabled\n" + "\t\t\t\t 1 = internal rasterizer (default)\n" +#ifdef HAVE_LIBOSMESA + "\t\t\t\t 2 = osmesa opengl\n" +#endif + ,"ENGINE"}, + { "save-type", 0, 0, G_OPTION_ARG_INT, &config->savetype, "Select savetype from the following:\n" + "\t\t\t\t 0 = Autodetect (default)\n" + "\t\t\t\t 1 = EEPROM 4kbit\n" + "\t\t\t\t 2 = EEPROM 64kbit\n" + "\t\t\t\t 3 = EEPROM 512kbit\n" + "\t\t\t\t 4 = FRAM 256kbit\n" + "\t\t\t\t 5 = FLASH 2mbit\n" + "\t\t\t\t 6 = FLASH 4mbit\n", + "SAVETYPE"}, + { "fwlang", 0, 0, G_OPTION_ARG_INT, &config->firmware_language, "Set the language in the firmware, LANG as follows:\n" + "\t\t\t\t 0 = Japanese\n" + "\t\t\t\t 1 = English\n" + "\t\t\t\t 2 = French\n" + "\t\t\t\t 3 = German\n" + "\t\t\t\t 4 = Italian\n" + "\t\t\t\t 5 = Spanish\n", + "LANG"}, +#ifdef HAVE_TIMEOUT + { "timeout", 0, 0, G_OPTION_ARG_INT, &config->timeout, "Quit desmume after the specified seconds for testing purpose.", "SECONDS"}, +#endif + { NULL } + }; + + config->loadCommonOptions(); + g_option_context_add_main_entries (config->ctx, options, "options"); + g_option_context_add_group (config->ctx, gtk_get_option_group (TRUE)); + config->parse(argc,argv); + + if(!config->validate()) + goto error; + + if (config->savetype < 0 || config->savetype > 6) { + g_printerr("Accepted savetypes are from 0 to 6.\n"); + return false; + } + + if (config->firmware_language < -1 || config->firmware_language > 5) { + g_printerr("Firmware language must be set to a value from 0 to 5.\n"); + goto error; + } + + + if (config->engine_3d != 0 && config->engine_3d != 1 +#if defined(HAVE_LIBOSMESA) + && config->engine_3d != 2 +#endif + ) { + g_printerr("Currently available ENGINES: 0, 1" +#if defined(HAVE_LIBOSMESA) + ", 2" +#endif + "\n"); + goto error; + } + +#ifdef GDB_STUB + if (config->arm9_gdb_port != 0 && (config->arm9_gdb_port < 1 || config->arm9_gdb_port > 65535)) { + g_printerr("ARM9 GDB stub port must be in the range 1 to 65535\n"); + goto error; + } + + if (config->arm7_gdb_port != 0 && (config->arm7_gdb_port < 1 || config->arm7_gdb_port > 65535)) { + g_printerr("ARM7 GDB stub port must be in the range 1 to 65535\n"); + goto error; + } +#endif + + return 1; + +error: + config->errorHelp(argv[0]); + + return 0; +} + + +/* + * The thread handling functions needed by the GDB stub code. + */ +#ifdef GDB_STUB +void * +createThread_gdb( void (*thread_function)( void *data), + void *thread_data) +{ + GThread *new_thread = g_thread_create( (GThreadFunc)thread_function, + thread_data, + TRUE, + NULL); + + return new_thread; +} + +void +joinThread_gdb( void *thread_handle) { + g_thread_join( (GThread *)thread_handle); +} +#endif + +/************************ GTK *******************************/ + +uint Frameskip = 0; +GdkInterpType Interpolation = GDK_INTERP_BILINEAR; + +static GtkWidget *pWindow; +static GtkWidget *pStatusBar; +static GtkWidget *pDrawingArea; +GtkActionGroup * action_group; +GtkUIManager *ui_manager; + +guint nds_gap_size = 0; +float nds_screen_size_ratio = 1.0f; +int nds_screen_rotation_angle = 0; + +static BOOL regMainLoop = FALSE; + +static inline void UpdateStatusBar (const char *message) +{ + gint pStatusBar_Ctx; + + pStatusBar_Ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(pStatusBar), "Global"); + gtk_statusbar_pop(GTK_STATUSBAR(pStatusBar), pStatusBar_Ctx); + gtk_statusbar_push(GTK_STATUSBAR(pStatusBar), pStatusBar_Ctx, message); +} + +static void About() +{ + GdkPixbuf * pixbuf = gdk_pixbuf_new_from_xpm_data(DeSmuME_xpm); + + gtk_show_about_dialog(GTK_WINDOW(pWindow), + "name", "DeSmuME", + "version", VERSION, + "website", "http://desmume.org", + "logo", pixbuf, + "comments", "Nintendo DS emulator based on work by Yopyop", + NULL); + + g_object_unref(pixbuf); +} + +static void ToggleMenuVisible(GtkToggleAction *action) +{ + GtkWidget *pMenuBar = gtk_ui_manager_get_widget (ui_manager, "/MainMenu"); + + if (gtk_toggle_action_get_active(action) == TRUE) + gtk_widget_show(pMenuBar); + else + gtk_widget_hide(pMenuBar); +} + +static void ToggleToolbarVisible(GtkToggleAction *action) +{ + GtkWidget *pToolBar = gtk_ui_manager_get_widget (ui_manager, "/ToolBar"); + + if (gtk_toggle_action_get_active(action) == TRUE) + gtk_widget_show(pToolBar); + else + gtk_widget_hide(pToolBar); +} + +static void ToggleStatusbarVisible(GtkToggleAction *action) +{ + if (gtk_toggle_action_get_active(action) == TRUE) + gtk_widget_show(pStatusBar); + else + gtk_widget_hide(pStatusBar); +} + + + +static int Open(const char *filename) +{ + int res; + res = NDS_LoadROM( filename ); + if(res > 0) + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "cheatlist"), TRUE); + return res; +} + +void Launch() +{ + GtkWidget *pause; + desmume_resume(); + + if(!regMainLoop) { + g_idle_add_full(EMULOOP_PRIO, &EmuLoop, pWindow, NULL); + regMainLoop = TRUE; + } + + UpdateStatusBar("Running ..."); + + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "pause"), TRUE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "reset"), TRUE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "printscreen"), TRUE); + + pause = gtk_bin_get_child(GTK_BIN(gtk_ui_manager_get_widget(ui_manager, "/ToolBar/pause"))); + gtk_widget_grab_focus(pause); +} + +void Pause() +{ + GtkWidget *run; + desmume_pause(); + UpdateStatusBar("Paused"); + + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "pause"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); + + run = gtk_bin_get_child(GTK_BIN(gtk_ui_manager_get_widget(ui_manager, "/ToolBar/run"))); + gtk_widget_grab_focus(run); +} + +static void LoadStateDialog() +{ + GtkFileFilter *pFilter_ds, *pFilter_any; + GtkWidget *pFileSelection; + GtkWidget *pParent; + gchar *sPath; + + if (desmume_running()) + Pause(); + + pParent = GTK_WIDGET(pWindow); + + pFilter_ds = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_ds, "*.ds*"); + gtk_file_filter_set_name(pFilter_ds, "DeSmuME binary (.ds*)"); + + pFilter_any = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_any, "*"); + gtk_file_filter_set_name(pFilter_any, "All files"); + + /* Creating the selection window */ + pFileSelection = gtk_file_chooser_dialog_new("Load State From ...", + GTK_WINDOW(pParent), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_OK, + NULL); + + /* Only the dialog window is accepting events: */ + gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); + + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_ds); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); + + /* Showing the window */ + switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { + case GTK_RESPONSE_OK: + sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); + + if(savestate_load(sPath) == false ) { + GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + "Unable to load :\n%s", sPath); + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } else { + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); + } + + g_free(sPath); + break; + default: + break; + } + gtk_widget_destroy(pFileSelection); +} + +static void RecordMovieDialog() +{ + GtkFileFilter *pFilter_dsm, *pFilter_any; + GtkWidget *pFileSelection; + GtkWidget *pParent; + gchar *sPath; + + if (desmume_running()) + Pause(); + + pParent = GTK_WIDGET(pWindow); + + pFilter_dsm = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_dsm, "*.dsm*"); + gtk_file_filter_set_name(pFilter_dsm, "DeSmuME movie file (.dsm*)"); + + pFilter_any = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_any, "*"); + gtk_file_filter_set_name(pFilter_any, "All files"); + + /* Creating the selection window */ + pFileSelection = gtk_file_chooser_dialog_new("Save Movie To ...", + GTK_WINDOW(pParent), + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, GTK_RESPONSE_OK, + NULL); + gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (pFileSelection), TRUE); + + /* Only the dialog window is accepting events: */ + gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); + + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_dsm); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); + + /* Showing the window */ + switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { + case GTK_RESPONSE_OK: + sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); + FCEUI_SaveMovie(sPath,L"",0,NULL); + g_free(sPath); + break; + default: + break; + } + gtk_widget_destroy(pFileSelection); +} + +static void StopMovie() +{ + FCEUI_StopMovie(); +} + +static void PlayMovieDialog() +{ + GtkFileFilter *pFilter_dsm, *pFilter_any; + GtkWidget *pFileSelection; + GtkWidget *pParent; + gchar *sPath; + + if (desmume_running()) + Pause(); + + pParent = GTK_WIDGET(pWindow); + + pFilter_dsm = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_dsm, "*.dsm*"); + gtk_file_filter_set_name(pFilter_dsm, "DeSmuME movie file (.dsm*)"); + + pFilter_any = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_any, "*"); + gtk_file_filter_set_name(pFilter_any, "All files"); + + /* Creating the selection window */ + pFileSelection = gtk_file_chooser_dialog_new("Play movie from...", + GTK_WINDOW(pParent), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_OK, + NULL); + gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (pFileSelection), TRUE); + + /* Only the dialog window is accepting events: */ + gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); + + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_dsm); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); + + /* Showing the window */ + switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { + case GTK_RESPONSE_OK: + sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); + + FCEUI_LoadMovie(sPath,true,false,-1); + + g_free(sPath); + break; + default: + break; + } + gtk_widget_destroy(pFileSelection); +} + +static void SaveStateDialog() +{ + GtkFileFilter *pFilter_ds, *pFilter_any; + GtkWidget *pFileSelection; + GtkWidget *pParent; + gchar *sPath; + + if (desmume_running()) + Pause(); + + pParent = GTK_WIDGET(pWindow); + + pFilter_ds = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_ds, "*.ds*"); + gtk_file_filter_set_name(pFilter_ds, "DeSmuME binary (.ds*)"); + + pFilter_any = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_any, "*"); + gtk_file_filter_set_name(pFilter_any, "All files"); + + /* Creating the selection window */ + pFileSelection = gtk_file_chooser_dialog_new("Save State To ...", + GTK_WINDOW(pParent), + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, GTK_RESPONSE_OK, + NULL); + gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (pFileSelection), TRUE); + + /* Only the dialog window is accepting events: */ + gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); + + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_ds); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); + + /* Showing the window */ + switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { + case GTK_RESPONSE_OK: + sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); + + if(savestate_save(sPath) == false ) { + GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + "Unable to save :\n%s", sPath); + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } else { + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); + } + + g_free(sPath); + break; + default: + break; + } + gtk_widget_destroy(pFileSelection); +} + +static void OpenNdsDialog() +{ + GtkFileFilter *pFilter_nds, *pFilter_dsgba, *pFilter_any; + GtkWidget *pFileSelection; + GtkWidget *pParent; + gchar *sPath; + + if (desmume_running()) + Pause(); + + pParent = GTK_WIDGET(pWindow); + + pFilter_nds = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_nds, "*.[nN][dD][sS]"); +#ifdef HAVE_LIBZ + gtk_file_filter_add_pattern(pFilter_nds, "*.[nN][dD][sS].gz"); +#endif +#ifdef HAVE_LIBZZIP + gtk_file_filter_add_pattern(pFilter_nds, "*.[nN][dD][sS].zip"); +#endif + gtk_file_filter_set_name(pFilter_nds, "Nds binary (.nds)"); + + pFilter_dsgba = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_dsgba, "*.ds.gba"); + gtk_file_filter_set_name(pFilter_dsgba, "Nds binary with loader (.ds.gba)"); + + pFilter_any = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_any, "*"); + gtk_file_filter_set_name(pFilter_any, "All files"); + + /* Creating the selection window */ + pFileSelection = gtk_file_chooser_dialog_new("Open...", + GTK_WINDOW(pParent), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_OK, + NULL); + /* Only the dialog window is accepting events: */ + gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); + + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_dsgba); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); + + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(pFileSelection), g_get_home_dir()); + + /* Showing the window */ + switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { + case GTK_RESPONSE_OK: + sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); + if(Open((const char*)sPath) < 0) { + GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection), + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + "Unable to load :\n%s", sPath); + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } else { +#ifdef HAVE_RECENT_FILES + GtkRecentData recentData; + gchar *uri; + memset(&recentData, 0, sizeof(GtkRecentData)); + recentData.mime_type = "application/x-nintendo-ds-rom"; + recentData.app_name = (gchar *) g_get_application_name (); + recentData.app_exec = g_strjoin (" ", g_get_prgname (), "%f", NULL); + + GtkRecentManager *manager; + manager = gtk_recent_manager_get_default (); + uri = g_filename_to_uri (sPath, NULL, NULL); + gtk_recent_manager_add_full (manager, uri, &recentData); + + g_free(uri); + g_free(recentData.app_exec); +#endif + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); + } + + //Launch(NULL, pWindow); + + g_free(sPath); + break; + default: + break; + } + gtk_widget_destroy(pFileSelection); +} + +#ifdef HAVE_RECENT_FILES +static void OpenRecent(GtkRecentChooser *chooser, gpointer user_data) +{ + Open(g_filename_from_uri(gtk_recent_chooser_get_current_uri(chooser), NULL, NULL)); + + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE); +} +#endif + +static void Reset() +{ + NDS_Reset(); + desmume_resume(); + + UpdateStatusBar("Running ..."); +} + + +/////////////////////////////// DRAWING SCREEN ////////////////////////////////// +static void UpdateDrawingAreaAspect() +{ + gint H, W; + switch (nds_screen_rotation_angle) { + case 0: + case 180: + W = 256; + H = 384 + nds_gap_size; + break; + case 90: + case 270: + W = 384 + nds_gap_size; + H = 256; + break; + default: + g_printerr("Congratulations, you've managed to set unsupported screen rotation angle (%d), resetting angle to 0\n", + nds_screen_rotation_angle); + nds_screen_rotation_angle = 0; + W = 256; + H = 384 + nds_gap_size; + break; + } + + gtk_widget_set_size_request(GTK_WIDGET(pDrawingArea), W, H); +} + +static void ToggleGap(GtkToggleAction* action) +{ + nds_gap_size = gtk_toggle_action_get_active(action) ? GAP_SIZE : 0; + UpdateDrawingAreaAspect(); +} + +static void SetRotation(GtkAction* action) +{ + const gchar *angle; + + angle = gtk_action_get_name(GTK_ACTION(action)) + strlen("rotate_"); + nds_screen_rotation_angle = atoi(angle); + UpdateDrawingAreaAspect(); +} + +static int ConfigureDrawingArea(GtkWidget *widget, GdkEventConfigure *event, gpointer data) +{ + return TRUE; +} + +static inline void gpu_screen_to_rgb(guchar * rgb, int size) +{ + u16 gpu_pixel; + int rot = nds_screen_rotation_angle; + + memset(rgb, 0, size); + for (int i = 0; i < 256; i++) { + for (int j = 0; j < 384; j++) { + + gpu_pixel = *((u16 *) & GPU_screen[(i + j * 256) << 1]); + u32 offset; + if(rot == 0 || rot == 180) + offset = i * 3 + j * 3 * 256; + else + offset = j * 3 + (255 - i) * 3 * 384; + switch (rot) { + case 0: + case 270: + *(rgb + offset + 0) = ((gpu_pixel >> 0) & 0x1f) << 3; + *(rgb + offset + 1) = ((gpu_pixel >> 5) & 0x1f) << 3; + *(rgb + offset + 2) = ((gpu_pixel >> 10) & 0x1f) << 3; + break; + case 180: + case 90: + *(rgb + size - offset - 3) = + ((gpu_pixel >> 0) & 0x1f) << 3; + *(rgb + size - offset - 2) = + ((gpu_pixel >> 5) & 0x1f) << 3; + *(rgb + size - offset - 1) = + ((gpu_pixel >> 10) & 0x1f) << 3; + break; + } + } + } +} + +/* Drawing callback */ +static int ExposeDrawingArea (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + GdkPixbuf *origPixbuf, *resizedPixbuf = NULL, *drawPixbuf; + guchar rgb[SCREENS_PIXEL_SIZE*SCREEN_BYTES_PER_PIXEL]; + + float ssize, vratio, hratio; + gint daW, daH, imgH, imgW, xoff, yoff, xsize, ysize, xs, ys, xd, yd; + int rot = (nds_screen_rotation_angle % 180 == 90); + +#if GTK_CHECK_VERSION(2,14,0) + gdk_drawable_get_size( + gtk_widget_get_window(GTK_WIDGET(pDrawingArea)), &daW, &daH); +#else + gdk_drawable_get_size( + (GTK_WIDGET(pDrawingArea))->window, &daW, &daH); +#endif + + if(!rot){ + imgW = 256; imgH = 384; + daH -= nds_gap_size; + }else{ + imgH = 256; imgW = 384; + daW -= nds_gap_size; + } + + hratio = (float)daW / (float)imgW; + vratio = (float)daH / (float)imgH; + ssize = MIN(hratio, vratio); + nds_screen_size_ratio = 1 / (float)ssize; + xoff = (daW-ssize*imgW)/2; + yoff = (daH-ssize*imgH)/2; + if(!rot){ + xsize = ssize*imgW; + ysize = ssize*imgH/2; + xs = 0; + ys = ysize; + xd = xoff; + yd = yoff+ysize+nds_gap_size; + } else { + xsize = ssize*imgW/2; + ysize = ssize*imgH; + xs = xsize; + ys = 0; + xd = xoff+xsize+nds_gap_size; + yd = yoff; + } + + DrawHUD(); + gpu_screen_to_rgb(rgb, SCREENS_PIXEL_SIZE*SCREEN_BYTES_PER_PIXEL); + origPixbuf = gdk_pixbuf_new_from_data(rgb, GDK_COLORSPACE_RGB, + 0, 8, imgW, imgH, imgW*SCREEN_BYTES_PER_PIXEL, NULL, NULL); + drawPixbuf = origPixbuf; + + if(nds_screen_size_ratio != 1.0) { + resizedPixbuf = gdk_pixbuf_scale_simple (origPixbuf, ssize*imgW, ssize*imgH, + Interpolation); + drawPixbuf = resizedPixbuf; + } + + gdk_draw_pixbuf(widget->window, NULL, drawPixbuf, 0,0, xoff, yoff, xsize, ysize, + GDK_RGB_DITHER_NONE, 0,0); + + gdk_draw_pixbuf(widget->window, NULL, drawPixbuf, xs, ys, xd, yd, xsize,ysize, + GDK_RGB_DITHER_NONE, 0,0); + + drawPixbuf = NULL; + if(nds_screen_size_ratio != 1.0) { + g_object_unref(resizedPixbuf); + } + g_object_unref(origPixbuf); + + return TRUE; +} + +/////////////////////////////// KEYS AND STYLUS UPDATE /////////////////////////////////////// + +static inline void rotoscaled_touchpos(gint x, gint y) +{ + int X, Y, rot, inv, dah, daw, gap_corr; + u16 EmuX, EmuY; + + rot = ( nds_screen_rotation_angle == 90 || nds_screen_rotation_angle == 270); + inv = ( nds_screen_rotation_angle == 180 || nds_screen_rotation_angle == 90); + gap_corr = inv ? 0 : nds_gap_size; + dah = GTK_WIDGET(pDrawingArea)->allocation.height; + daw = GTK_WIDGET(pDrawingArea)->allocation.width; + if(!rot){ + X = x - (daw-256/nds_screen_size_ratio)/2; + Y = y - (dah-nds_gap_size-384/nds_screen_size_ratio)/2-gap_corr; + } else { + X = y - (dah-256/nds_screen_size_ratio)/2; + Y = x - (daw-nds_gap_size-384/nds_screen_size_ratio)/2-gap_corr; + } + X = int (X * nds_screen_size_ratio); + Y = int (Y * nds_screen_size_ratio)-192; + + if(inv){ + Y = -Y; + } + + if((inv && !rot) || (!inv && rot)){ + X = 255 - X; + } + + LOG("X=%d, Y=%d\n", x,y); + + // FIXME: should ignore events only when STARTING touched-position + // was outside touchscreen - desmume window does not have physical band + // to limit movement of stylus + if ( Y >= 0 ) { + EmuX = CLAMP(X, 0, 255); + EmuY = CLAMP(Y, 0, 191); + NDS_setTouchPos(EmuX, EmuY); + } +} + +static gboolean Stylus_Move(GtkWidget *w, GdkEventMotion *e, gpointer data) +{ + GdkModifierType state; + gint x,y; + + if(click) { + if(e->is_hint) + gdk_window_get_pointer(w->window, &x, &y, &state); + else { + x= (gint)e->x; + y= (gint)e->y; + state=(GdkModifierType)e->state; + } + + if(state & GDK_BUTTON1_MASK) + rotoscaled_touchpos(x,y); + } + + return TRUE; +} + +static gboolean Stylus_Press(GtkWidget * w, GdkEventButton * e, + gpointer data) +{ + GdkModifierType state; + gint x, y; + + if (e->button == 3) { + GtkWidget * pMenu = gtk_menu_item_get_submenu ( GTK_MENU_ITEM( + gtk_ui_manager_get_widget (ui_manager, "/MainMenu/ConfigMenu/ViewMenu"))); + gtk_menu_popup(GTK_MENU(pMenu), NULL, NULL, NULL, NULL, 3, e->time); + } + + if( !desmume_running()) + return TRUE; + + if (e->button == 1) { + click = TRUE; + + gdk_window_get_pointer(w->window, &x, &y, &state); + + if(state & GDK_BUTTON1_MASK) + rotoscaled_touchpos(x, y); + } + + return TRUE; +} +static gboolean Stylus_Release(GtkWidget *w, GdkEventButton *e, gpointer data) +{ + if(click) NDS_releaseTouch(); + click = FALSE; + return TRUE; +} + +static void loadgame(int num){ + if (desmume_running()) + { + Pause(); + loadstate_slot(num); + Launch(); + } + else + loadstate_slot(num); +} + +static void savegame(int num){ + if (desmume_running()) + { + Pause(); + savestate_slot(num); + Launch(); + } + else + savestate_slot(num); +} + +static void MenuLoad(GtkMenuItem *item, gpointer slot) +{ + loadgame(GPOINTER_TO_INT(slot)); +} + +static void MenuSave(GtkMenuItem *item, gpointer slot) +{ + savegame(GPOINTER_TO_INT(slot)); +} + +static gint Key_Press(GtkWidget *w, GdkEventKey *e, gpointer data) +{ + if (e->keyval == GDK_Shift_L){ + gdk_shift_pressed |= 1; + return 1; + } + if (e->keyval == GDK_Shift_R){ + gdk_shift_pressed |= 2; + return 1; + } + if( e->keyval >= GDK_F1 && e->keyval <= GDK_F10 ){ + if(!gdk_shift_pressed) + loadgame(e->keyval - GDK_F1 + 1); + else + savegame(e->keyval - GDK_F1 + 1); + return 1; + } + guint mask; + mask = gtk_accelerator_get_default_mod_mask (); + if( (e->state & mask) == 0){ + u16 Key = lookup_key(e->keyval); + if(Key){ + ADD_KEY( Cur_Keypad, Key ); + if(desmume_running()) update_keypad(Cur_Keypad); + return 1; + } + } + +#ifdef PROFILE_MEMORY_ACCESS + if ( e->keyval == GDK_Tab) { + print_memory_profiling(); + return 1; + } +#endif + return 0; +} + +static gint Key_Release(GtkWidget *w, GdkEventKey *e, gpointer data) +{ + if (e->keyval == GDK_Shift_L){ + gdk_shift_pressed &= ~1; + return 1; + } + if (e->keyval == GDK_Shift_R){ + gdk_shift_pressed &= ~2; + return 1; + } + u16 Key = lookup_key(e->keyval); + RM_KEY( Cur_Keypad, Key ); + if(desmume_running()) update_keypad(Cur_Keypad); + return 1; + +} + +/////////////////////////////// CONTROLS EDIT ////////////////////////////////////// + +static void AcceptNewInputKey(GtkWidget *w, GdkEventKey *e, struct modify_key_ctx *ctx) +{ + gchar *YouPressed; + + ctx->mk_key_chosen = e->keyval; + YouPressed = g_strdup_printf("You pressed : %s\nClick OK to keep this key.", gdk_keyval_name(e->keyval)); + gtk_label_set(GTK_LABEL(ctx->label), YouPressed); + g_free(YouPressed); +} + +static void Modify_Key(GtkWidget* widget, gpointer data) +{ + struct modify_key_ctx ctx; + GtkWidget *mkDialog; + gchar *Key_Label; + gchar *Title; + gint Key; + + Key = GPOINTER_TO_INT(data); + ctx.mk_key_chosen = 0; + Title = g_strdup_printf("Press \"%s\" key ...\n", key_names[Key]); + mkDialog = gtk_dialog_new_with_buttons(Title, + GTK_WINDOW(pWindow), + GTK_DIALOG_MODAL, + GTK_STOCK_OK,GTK_RESPONSE_OK, + GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, + NULL); + + ctx.label = gtk_label_new(Title); + g_free(Title); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mkDialog)->vbox), ctx.label, TRUE, FALSE, 0); + + g_signal_connect(G_OBJECT(mkDialog), "key_press_event", G_CALLBACK(AcceptNewInputKey), &ctx); + + gtk_widget_show_all(GTK_DIALOG(mkDialog)->vbox); + + switch(gtk_dialog_run(GTK_DIALOG(mkDialog))) { + case GTK_RESPONSE_OK: + Keypad_Temp[Key] = ctx.mk_key_chosen; + Key_Label = g_strdup_printf("%s (%s)", key_names[Key], gdk_keyval_name(Keypad_Temp[Key])); + gtk_button_set_label(GTK_BUTTON(widget), Key_Label); + g_free(Key_Label); + break; + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_NONE: + ctx.mk_key_chosen = 0; + break; + } + + gtk_widget_destroy(mkDialog); + +} + +static void Edit_Controls() +{ + GtkWidget *ecDialog; + GtkWidget *ecKey; + gchar *Key_Label; + int i; + + memcpy(&Keypad_Temp, &keyboard_cfg, sizeof(keyboard_cfg)); + + ecDialog = gtk_dialog_new_with_buttons("Edit controls", + GTK_WINDOW(pWindow), + GTK_DIALOG_MODAL, + GTK_STOCK_OK,GTK_RESPONSE_OK, + GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL, + NULL); + + for(i = 0; i < NB_KEYS; i++) { + Key_Label = g_strdup_printf("%s (%s)", key_names[i], gdk_keyval_name(Keypad_Temp[i])); + ecKey = gtk_button_new_with_label(Key_Label); + g_free(Key_Label); + g_signal_connect(G_OBJECT(ecKey), "clicked", G_CALLBACK(Modify_Key), GINT_TO_POINTER(i)); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(ecDialog)->vbox), ecKey,TRUE, FALSE, 0); + } + + gtk_widget_show_all(GTK_DIALOG(ecDialog)->vbox); + + switch (gtk_dialog_run(GTK_DIALOG(ecDialog))) { + case GTK_RESPONSE_OK: + memcpy(&keyboard_cfg, &Keypad_Temp, sizeof(keyboard_cfg)); + desmume_config_update_keys(keyfile); + case GTK_RESPONSE_CANCEL: + case GTK_RESPONSE_NONE: + break; + } + gtk_widget_destroy(ecDialog); + +} + +static void ToggleLayerVisibility(GtkToggleAction* action, gpointer data) +{ + guint Layer = GPOINTER_TO_UINT(data); + gboolean active; + + // FIXME: make it work after resume + if (!desmume_running()) + return; + + active = gtk_toggle_action_get_active(action); + + switch (Layer) { + case MAIN_BG_0: + case MAIN_BG_1: + case MAIN_BG_2: + case MAIN_BG_3: + case MAIN_OBJ: + if(active == TRUE) { + GPU_addBack(MainScreen.gpu, Layer); + } else { + GPU_remove(MainScreen.gpu, Layer); + } + break; + case SUB_BG_0: + case SUB_BG_1: + case SUB_BG_2: + case SUB_BG_3: + case SUB_OBJ: + if(active == TRUE) { + GPU_addBack(SubScreen.gpu, Layer-SUB_BG_0); + } else { + GPU_remove(SubScreen.gpu, Layer-SUB_BG_0); + } + break; + default: + break; + } +} + +static void Printscreen() +{ + GdkPixbuf *screenshot; + gchar *filename; + GError *error = NULL; + u8 *rgb; + static int seq = 0; + + rgb = (u8 *) malloc(SCREENS_PIXEL_SIZE*3); + if (!rgb) + return; + + gpu_screen_to_rgb(rgb, SCREENS_PIXEL_SIZE); + screenshot = gdk_pixbuf_new_from_data(rgb, + GDK_COLORSPACE_RGB, + FALSE, + 8, + 256, + 192*2, + 256*3, + NULL, + NULL); + + filename = g_strdup_printf("./desmume-screenshot-%d.png", seq); + gdk_pixbuf_save(screenshot, filename, "png", &error, NULL); + if (error) { + g_error_free (error); + g_printerr("Failed to save %s", filename); + } else { + seq++; + } + + free(rgb); + g_object_unref(screenshot); + g_free(filename); +} + +#ifdef DESMUME_GTK_FIRMWARE_BROKEN +static void SelectFirmwareFile() +{ + GtkFileFilter *pFilter_nds, *pFilter_bin, *pFilter_any; + GtkWidget *pFileSelection; + GtkWidget *pParent; + gchar *sPath; + + BOOL oldState = desmume_running(); + Pause(); + + pParent = GTK_WIDGET(pWindow); + + pFilter_nds = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_nds, "*.nds"); + gtk_file_filter_set_name(pFilter_nds, "Nds binary (.nds)"); + + pFilter_bin = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_bin, "*.bin"); + gtk_file_filter_set_name(pFilter_bin, "Binary file (.bin)"); + + pFilter_any = gtk_file_filter_new(); + gtk_file_filter_add_pattern(pFilter_any, "*"); + gtk_file_filter_set_name(pFilter_any, "All files"); + + pFileSelection = gtk_file_chooser_dialog_new("Load firmware...", + GTK_WINDOW(pParent), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_OK, + NULL); + gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE); + + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_nds); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_bin); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any); + + switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) { + case GTK_RESPONSE_OK: + sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection)); + CommonSettings.UseExtFirmware = true; + strncpy(CommonSettings.Firmware, (const char*)sPath, g_utf8_strlen(sPath, -1)); + g_free(sPath); + break; + default: + break; + } + gtk_widget_destroy(pFileSelection); + + if(oldState) Launch(); +} +#endif + +static void Modify_Interpolation(GtkAction *action, GtkRadioAction *current) +{ + uint i = gtk_radio_action_get_current_value(current) ; + Interpolation = (i == 0 ? GDK_INTERP_NEAREST : GDK_INTERP_BILINEAR); +} + +static void Modify_Frameskip(GtkAction *action, GtkRadioAction *current) +{ + Frameskip = gtk_radio_action_get_current_value(current) ; +} + +/////////////////////////////// TOOLS MANAGEMENT /////////////////////////////// + +extern const dTool_t *dTools_list[]; +extern const int dTools_list_size; + +BOOL *dTools_running; + +static void Start_dTool(GtkWidget *widget, gpointer data) +{ + int tool = GPOINTER_TO_INT(data); + + if(dTools_running == NULL || dTools_running[tool]) + return; + + dTools_list[tool]->open(tool); + dTools_running[tool] = TRUE; +} + +void dTool_CloseCallback(int tool) +{ + if (dTools_running == NULL) + return; + + dTools_running[tool] = FALSE; +} + + +static inline void _updateDTools() +{ + if (dTools_running == NULL) + return; + + for(int i = 0; i < dTools_list_size; i++) { + if(dTools_running[i]) { dTools_list[i]->update(); } + } +} + +/////////////////////////////// MAIN EMULATOR LOOP /////////////////////////////// + +gboolean EmuLoop(gpointer data) +{ + static Uint32 fps_SecStart, fps_FrameCount; + static int limiter_frame_counter; + unsigned int i; + gchar Title[20]; + + if (!desmume_running()) { + regMainLoop = FALSE; + return FALSE; + } + + /* If desmume is currently running */ + fps_FrameCount += Frameskip + 1; + if (!fps_SecStart) + fps_SecStart = SDL_GetTicks(); + + if (SDL_GetTicks() - fps_SecStart >= 1000) { + fps_SecStart = SDL_GetTicks(); + + snprintf(Title, sizeof(Title), "Desmume - %dfps", fps_FrameCount); + gtk_window_set_title(GTK_WINDOW(pWindow), Title); + fps_FrameCount = 0; + } + + desmume_cycle(); /* Emule ! */ + for (i = 0; i < Frameskip; i++) { + NDS_SkipNextFrame(); + desmume_cycle(); + } + + _updateDTools(); + gtk_widget_queue_draw( pDrawingArea ); + + if (!gtk_fps_limiter_disabled) { + limiter_frame_counter += 1; + if (limiter_frame_counter >= FPS_LIMITER_FRAME_PERIOD) { + limiter_frame_counter = 0; + /* wait for the timer to expire */ + SDL_SemWait( fps_limiter_semaphore); + } + } + + return TRUE; +} + + +/** + * A SDL timer callback function. Signals the supplied SDL semaphore + * if its value is small. + * + * @param interval The interval since the last call (in ms) + * @param param The pointer to the semaphore. + * + * @return The interval to the next call (required by SDL) + */ +static Uint32 fps_limiter_fn(Uint32 interval, void *param) +{ + SDL_sem *sdl_semaphore = (SDL_sem *)param; + + /* signal the semaphore if it is getting low */ + if ( SDL_SemValue( sdl_semaphore) < 4) { + SDL_SemPost( sdl_semaphore); + } + + return interval; +} + +static void desmume_try_adding_ui(GtkUIManager *self, const char *ui_descr){ + GError *error; + error = NULL; + if (!gtk_ui_manager_add_ui_from_string (self, ui_descr, -1, &error)) + { + g_message ("building menus failed: %s", error->message); + g_error_free (error); + exit (EXIT_FAILURE); + } +} + +static void dui_set_accel_group(gpointer action, gpointer group) { + gtk_action_set_accel_group((GtkAction *)action, (GtkAccelGroup *)group); +} + +static void desmume_gtk_menu_file_saveload_slot (GtkActionGroup *ag) +{ + for(guint i = 1; i <= 10; i++){ + GtkAction *act; + char label[64], name[64]; + + snprintf(label, 60, "_%d", i); + + snprintf(name, 60, "savestate%d", i); + act = gtk_action_new(name, label, NULL, NULL); + g_signal_connect(G_OBJECT(act), "activate", G_CALLBACK(MenuSave), GUINT_TO_POINTER(i)); + gtk_action_group_add_action_with_accel(ag, GTK_ACTION(act), NULL); + + snprintf(name, 60, "loadstate%d", i); + act = gtk_action_new(name, label, NULL, NULL); + g_signal_connect(G_OBJECT(act), "activate", G_CALLBACK(MenuLoad), GUINT_TO_POINTER(i)); + gtk_action_group_add_action_with_accel(ag, GTK_ACTION(act), NULL); + } +} + +static void changesavetype(GtkAction *action, GtkRadioAction *current) +{ + backup_setManualBackupType( gtk_radio_action_get_current_value(current)); +} + +static void desmume_gtk_menu_emulation_layers (GtkActionGroup *ag) +{ + const char *Layers_Menu[10][2] = { + {"layermainbg0","_0 Main BG 0"}, + {"layermainbg1","_1 Main BG 1"}, + {"layermainbg2","_2 Main BG 2"}, + {"layermainbg3","_3 Main BG 3"}, + {"layermainobj","_4 Main OBJ"}, + {"layersubbg0", "_5 SUB BG 0"}, + {"layersubbg1", "_6 SUB BG 1"}, + {"layersubbg2", "_7 SUB BG 2"}, + {"layersubbg3", "_8 SUB BG 3"}, + {"layersubobj", "_9 SUB OBJ"} + }; + guint i; + + GtkToggleAction *act; + for(i = 0; i< 10; i++){ + act = gtk_toggle_action_new(Layers_Menu[i][0],Layers_Menu[i][1],NULL,NULL); + gtk_toggle_action_set_active(act, TRUE); + g_signal_connect(G_OBJECT(act), "activate", G_CALLBACK(ToggleLayerVisibility), GUINT_TO_POINTER(i)); + gtk_action_group_add_action_with_accel(ag, GTK_ACTION(act), NULL); + } +} + +static void ToggleAudio (GtkToggleAction *action) +{ + if (gtk_toggle_action_get_active(action) == TRUE) { + SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); + } else { + SPU_ChangeSoundCore(0, 0); + } +} + +#ifdef FAKE_MIC +static void ToggleMicNoise (GtkToggleAction *action) +{ + Mic_DoNoise((BOOL)gtk_toggle_action_get_active(action)); +} +#endif + +static void desmume_gtk_menu_tools (GtkActionGroup *ag) +{ + gint i; + for(i = 0; i < dTools_list_size; i++) { + GtkAction *act; + act = gtk_action_new(dTools_list[i]->shortname, dTools_list[i]->name, NULL, NULL); + g_signal_connect(G_OBJECT(act), "activate", G_CALLBACK(Start_dTool), GINT_TO_POINTER(i)); + gtk_action_group_add_action(ag, GTK_ACTION(act)); + } +} + +#ifdef HAVE_TIMEOUT +static gboolean timeout_exit_cb(gpointer data) +{ + gtk_main_quit(); + INFO("Quit after %d seconds timeout\n", GPOINTER_TO_INT(data)); + + return FALSE; +} +#endif + + +static int +common_gtk_main( struct configured_features *my_config) +{ + Desmume_InitOnce(); + SDL_TimerID limiter_timer = NULL; + + GtkAccelGroup * accel_group; + GtkWidget *pVBox; + GtkWidget *pMenuBar; + GtkWidget *pToolBar; + gint pStatusBar_Ctx; + +#ifdef GDB_STUB + gdbstub_handle_t arm9_gdb_stub; + gdbstub_handle_t arm7_gdb_stub; +#endif + struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; + struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; + struct armcpu_ctrl_iface *arm9_ctrl_iface; + struct armcpu_ctrl_iface *arm7_ctrl_iface; + + /* the firmware settings */ + struct NDS_fw_config_data fw_config; + + /* default the firmware settings, they may get changed later */ + NDS_FillDefaultFirmwareConfigData( &fw_config); + + /* use any language set on the command line */ + if ( my_config->firmware_language != -1) { + fw_config.language = my_config->firmware_language; + } + + //------------------addons---------- + my_config->process_addonCommands(); + addon_type = NDS_ADDON_NONE; + if (my_config->is_cflash_configured) + addon_type = NDS_ADDON_CFLASH; + + switch (addon_type) { + case NDS_ADDON_CFLASH: + case NDS_ADDON_RUMBLEPAK: + case NDS_ADDON_NONE: + case NDS_ADDON_GBAGAME: + break; + default: + addon_type = NDS_ADDON_NONE; + break; + } + addonsChangePak (addon_type); + +#ifdef GDB_STUB + if ( my_config->arm9_gdb_port != 0) { + arm9_gdb_stub = createStub_gdb( my_config->arm9_gdb_port, + &arm9_memio, + &arm9_base_memory_iface); + + if ( arm9_gdb_stub == NULL) { + g_printerr("Failed to create ARM9 gdbstub on port %d\n", + my_config->arm9_gdb_port); + exit( -1); + } + } + if ( my_config->arm7_gdb_port != 0) { + arm7_gdb_stub = createStub_gdb( my_config->arm7_gdb_port, + &arm7_memio, + &arm7_base_memory_iface); + + if ( arm7_gdb_stub == NULL) { + g_printerr("Failed to create ARM7 gdbstub on port %d\n", + my_config->arm7_gdb_port); + exit( -1); + } + } +#endif + + /* FIXME: SDL_INIT_VIDEO is needed for joystick support to work!? + Perhaps it needs a "window" to catch events...? */ + if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO) == -1) { + g_printerr("Error trying to initialize SDL: %s\n", + SDL_GetError()); + return 1; + } + desmume_init( arm9_memio, &arm9_ctrl_iface, + arm7_memio, &arm7_ctrl_iface, + my_config->disable_sound); + + /* + * Activate the GDB stubs + * This has to come after the NDS_Init (called in desmume_init) + * where the cpus are set up. + */ +#ifdef GDB_STUB + if ( my_config->arm9_gdb_port != 0) { + activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); + } + if ( my_config->arm7_gdb_port != 0) { + activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); + } +#endif + + /* Create the dummy firmware */ + NDS_CreateDummyFirmware( &fw_config); + + /* Initialize joysticks */ + if(!init_joy()) return 1; + + dTools_running = (BOOL*)malloc(sizeof(BOOL) * dTools_list_size); + if (dTools_running != NULL) + memset(dTools_running, FALSE, sizeof(BOOL) * dTools_list_size); + + keyfile = desmume_config_read_file(); + + /* Create the window */ + pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_title(GTK_WINDOW(pWindow), "Desmume"); + gtk_window_set_resizable(GTK_WINDOW (pWindow), TRUE); + gtk_window_set_icon(GTK_WINDOW (pWindow), gdk_pixbuf_new_from_xpm_data(DeSmuME_xpm)); + + g_signal_connect(G_OBJECT(pWindow), "destroy", G_CALLBACK(gtk_main_quit), NULL); + g_signal_connect(G_OBJECT(pWindow), "key_press_event", G_CALLBACK(Key_Press), NULL); + g_signal_connect(G_OBJECT(pWindow), "key_release_event", G_CALLBACK(Key_Release), NULL); + + /* Create the GtkVBox */ + pVBox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(pWindow), pVBox); + + ui_manager = gtk_ui_manager_new (); + accel_group = gtk_accel_group_new(); + action_group = gtk_action_group_new("dui"); + + gtk_action_group_add_actions(action_group, action_entries, G_N_ELEMENTS(action_entries), NULL); + gtk_action_group_add_toggle_actions(action_group, toggle_entries, G_N_ELEMENTS(toggle_entries), NULL); + desmume_gtk_menu_emulation_layers(action_group); + desmume_gtk_menu_file_saveload_slot(action_group); + desmume_gtk_menu_tools(action_group); + gtk_action_group_add_radio_actions(action_group, savet_entries, G_N_ELEMENTS(savet_entries), + my_config->savetype, G_CALLBACK(changesavetype), NULL); + gtk_action_group_add_radio_actions(action_group, interpolation_entries, G_N_ELEMENTS(interpolation_entries), + 1, G_CALLBACK(Modify_Interpolation), NULL); + gtk_action_group_add_radio_actions(action_group, frameskip_entries, G_N_ELEMENTS(frameskip_entries), + 0, G_CALLBACK(Modify_Frameskip), NULL); + { + GList * list = gtk_action_group_list_actions(action_group); + g_list_foreach(list, dui_set_accel_group, accel_group); + } + gtk_window_add_accel_group(GTK_WINDOW(pWindow), accel_group); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "pause"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "reset"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "printscreen"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "cheatlist"), FALSE); + gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "cheatsearch"), FALSE); + + gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); + + accel_group = gtk_ui_manager_get_accel_group (ui_manager); + gtk_window_add_accel_group (GTK_WINDOW (pWindow), accel_group); + + desmume_try_adding_ui(ui_manager, ui_description); + + pMenuBar = gtk_ui_manager_get_widget (ui_manager, "/MainMenu"); + gtk_box_pack_start (GTK_BOX (pVBox), pMenuBar, FALSE, FALSE, 0); + pToolBar = gtk_ui_manager_get_widget (ui_manager, "/ToolBar"); + gtk_box_pack_start (GTK_BOX(pVBox), pToolBar, FALSE, FALSE, 0); + +#ifdef HAVE_RECENT_FILES + { + GtkWidget * recentMenu = gtk_ui_manager_get_widget (ui_manager, "/MainMenu/FileMenu/RecentMenu"); + GtkWidget * recentFiles = gtk_recent_chooser_menu_new(); + GtkRecentFilter * recentFilter = gtk_recent_filter_new(); + gtk_recent_filter_add_mime_type(recentFilter, "application/x-nintendo-ds-rom"); + gtk_recent_chooser_set_filter(GTK_RECENT_CHOOSER(recentFiles), recentFilter); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(recentMenu), recentFiles); + g_signal_connect(G_OBJECT(recentFiles), "item-activated", G_CALLBACK(OpenRecent), NULL); + } +#endif + + /* Creating the place for showing DS screens */ + pDrawingArea = gtk_drawing_area_new(); + gtk_container_add (GTK_CONTAINER (pVBox), pDrawingArea); + + gtk_widget_set_size_request(GTK_WIDGET(pDrawingArea), 256, 384); + + gtk_widget_set_events(pDrawingArea, + GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | + GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK ); + + g_signal_connect(G_OBJECT(pDrawingArea), "button_press_event", + G_CALLBACK(Stylus_Press), NULL); + g_signal_connect(G_OBJECT(pDrawingArea), "button_release_event", + G_CALLBACK(Stylus_Release), NULL); + g_signal_connect(G_OBJECT(pDrawingArea), "motion_notify_event", + G_CALLBACK(Stylus_Move), NULL); + g_signal_connect(G_OBJECT(pDrawingArea), "expose_event", + G_CALLBACK(ExposeDrawingArea), NULL ) ; + g_signal_connect(G_OBJECT(pDrawingArea), "configure_event", + G_CALLBACK(ConfigureDrawingArea), NULL ) ; + + /* Status bar */ + pStatusBar = gtk_statusbar_new(); + pStatusBar_Ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(pStatusBar), "Global"); + UpdateStatusBar("Desmume"); + gtk_box_pack_end(GTK_BOX(pVBox), pStatusBar, FALSE, FALSE, 0); + + gtk_widget_show_all(pWindow); + + gtk_fps_limiter_disabled = my_config->disable_limiter; + if ( !gtk_fps_limiter_disabled) { + /* create the semaphore used for fps limiting */ + fps_limiter_semaphore = SDL_CreateSemaphore( 1); + + /* start a SDL timer for every FPS_LIMITER_FRAME_PERIOD frames to keep us at 60 fps */ + limiter_timer = SDL_AddTimer( 16 * FPS_LIMITER_FRAME_PERIOD, fps_limiter_fn, fps_limiter_semaphore); + if ( limiter_timer == NULL) { + g_printerr("Error trying to start FPS limiter timer: %s\n", + SDL_GetError()); + return 1; + } + } + + //Set the 3D emulation to use + unsigned core = my_config->engine_3d; + // setup the gdk 3D emulation; +#if defined(HAVE_LIBOSMESA) + if(my_config->engine_3d == 2){ + core = init_osmesa_3Demu() ? 2 : GPU3D_NULL; + } +#endif + NDS_3D_ChangeCore(core); + if(my_config->engine_3d != 0 && gpu3D == &gpu3DNull) { + g_printerr("Failed to initialise openGL 3D emulation; " + "removing 3D support\n"); + } + + backup_setManualBackupType(my_config->savetype); + + // Command line arg + if( my_config->nds_file != "") { + if(Open( my_config->nds_file.c_str()) >= 0) { + my_config->process_movieCommands(); + + if(my_config->load_slot){ + loadstate_slot(my_config->load_slot); + } + + Launch(); + } else { + GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pWindow), + GTK_DIALOG_MODAL, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + "Unable to load :\n%s", my_config->nds_file.c_str()); + gtk_dialog_run(GTK_DIALOG(pDialog)); + gtk_widget_destroy(pDialog); + } + } + +#ifdef HAVE_TIMEOUT + if (my_config->timeout > 0) { + g_timeout_add_seconds(my_config->timeout, timeout_exit_cb, GINT_TO_POINTER(my_config->timeout)); + } +#endif + + /* Main loop */ + +// gtk_idle_add(&EmuLoop, pWindow); +// g_idle_add(&EmuLoop, pWindow); + + gtk_main(); + + desmume_free(); + + if ( !gtk_fps_limiter_disabled) { + /* tidy up the FPS limiter timer and semaphore */ + SDL_RemoveTimer( limiter_timer); + SDL_DestroySemaphore( fps_limiter_semaphore); + } + + /* Unload joystick */ + uninit_joy(); + + SDL_Quit(); + + desmume_config_dispose(keyfile); + +#ifdef GDB_STUB + if ( my_config->arm9_gdb_port != 0) { + destroyStub_gdb( arm9_gdb_stub); + } + if ( my_config->arm7_gdb_port != 0) { + destroyStub_gdb( arm7_gdb_stub); + } +#endif + + return EXIT_SUCCESS; +} + + +int main (int argc, char *argv[]) +{ + configured_features my_config; + + init_configured_features( &my_config); + + if (!g_thread_supported()) + g_thread_init( NULL); + + gtk_init(&argc, &argv); + + if ( !fill_configured_features( &my_config, argc, argv)) { + exit(0); + } + + return common_gtk_main( &my_config); +} + +#ifdef WIN32 +int WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) +{ + int argc = 0; + char *argv[] = NULL; + + /* + * FIXME: + * Emulate the argc and argv main parameters. Could do this using + * CommandLineToArgvW and then convert the wide chars to thin chars. + * Or parse the wide chars directly and call common_gtk_main with a + * filled configuration structure. + */ + main( argc, argv); +} +#endif + diff --git a/desmume/src/gtk/main.h b/src/gtk/main.h similarity index 93% rename from desmume/src/gtk/main.h rename to src/gtk/main.h index a12669fcf..b64706d67 100644 --- a/desmume/src/gtk/main.h +++ b/src/gtk/main.h @@ -1,7 +1,7 @@ -#ifndef __DESMUME_GTK_MAIN_H__ -#define __DESMUME_GTK_MAIN_H__ - -void Pause(); -void Launch(); - -#endif +#ifndef __DESMUME_GTK_MAIN_H__ +#define __DESMUME_GTK_MAIN_H__ + +void Pause(); +void Launch(); + +#endif diff --git a/desmume/src/gtk/osmesa_3Demu.cpp b/src/gtk/osmesa_3Demu.cpp similarity index 96% rename from desmume/src/gtk/osmesa_3Demu.cpp rename to src/gtk/osmesa_3Demu.cpp index 302ba95a0..293b8b272 100644 --- a/desmume/src/gtk/osmesa_3Demu.cpp +++ b/src/gtk/osmesa_3Demu.cpp @@ -1,53 +1,53 @@ -/* - Copyright (C) 2009 Guillaume Duhamel - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifdef HAVE_LIBOSMESA -#include -#include -#include "../OGLRender.h" -#include "osmesa_3Demu.h" - -static bool osmesa_beginOpenGL(void) { - return 1; -} - -static void osmesa_endOpenGL(void) { -} - -static bool osmesa_init(void) { - - return true; -} - -int init_osmesa_3Demu(void) { - void * buffer; - OSMesaContext ctx; - - ctx = OSMesaCreateContext(OSMESA_RGBA, NULL); - buffer = malloc(256 * 192 * 4); - OSMesaMakeCurrent(ctx, buffer, GL_UNSIGNED_BYTE, 256, 192); - - oglrender_init = osmesa_init; - oglrender_beginOpenGL = osmesa_beginOpenGL; - oglrender_endOpenGL = osmesa_endOpenGL; - - return 1; -} -#endif +/* + Copyright (C) 2009 Guillaume Duhamel + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifdef HAVE_LIBOSMESA +#include +#include +#include "../OGLRender.h" +#include "osmesa_3Demu.h" + +static bool osmesa_beginOpenGL(void) { + return 1; +} + +static void osmesa_endOpenGL(void) { +} + +static bool osmesa_init(void) { + + return true; +} + +int init_osmesa_3Demu(void) { + void * buffer; + OSMesaContext ctx; + + ctx = OSMesaCreateContext(OSMESA_RGBA, NULL); + buffer = malloc(256 * 192 * 4); + OSMesaMakeCurrent(ctx, buffer, GL_UNSIGNED_BYTE, 256, 192); + + oglrender_init = osmesa_init; + oglrender_beginOpenGL = osmesa_beginOpenGL; + oglrender_endOpenGL = osmesa_endOpenGL; + + return 1; +} +#endif diff --git a/desmume/src/gtk/osmesa_3Demu.h b/src/gtk/osmesa_3Demu.h similarity index 97% rename from desmume/src/gtk/osmesa_3Demu.h rename to src/gtk/osmesa_3Demu.h index d9f04eb8e..abd7cd175 100644 --- a/desmume/src/gtk/osmesa_3Demu.h +++ b/src/gtk/osmesa_3Demu.h @@ -1,23 +1,23 @@ -/* - Copyright (C) 2009 Guillaume Duhamel - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifdef HAVE_LIBOSMESA -int init_osmesa_3Demu( void); -#endif +/* + Copyright (C) 2009 Guillaume Duhamel + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifdef HAVE_LIBOSMESA +int init_osmesa_3Demu( void); +#endif diff --git a/desmume/src/gtk/tools/ioregsView.cpp b/src/gtk/tools/ioregsView.cpp similarity index 96% rename from desmume/src/gtk/tools/ioregsView.cpp rename to src/gtk/tools/ioregsView.cpp index cf75b1530..2ef6b183d 100644 --- a/desmume/src/gtk/tools/ioregsView.cpp +++ b/src/gtk/tools/ioregsView.cpp @@ -1,482 +1,482 @@ -/* ioregsView.cpp - this file is part of DeSmuME - * - * Copyright (C) 2006 Thoduv - * Copyright (C) 2006,2007 DeSmuME Team - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include "../dTool.h" - -#include "../MMU.h" - -#define SHORTNAME "ioregs" -#define TOOL_NAME "IO regs view" - -BOOL CPUS [2] = {TRUE, TRUE}; - -static GtkWidget *mWin[2]; -static GtkWidget *mVbox0[2]; -static GtkWidget *mIoRegCombo[2]; -static GtkWidget *mRegInfos[2]; - -typedef void (*reg_dispFn)(int c); -typedef u32 (*reg_valFn)(int c); - -typedef struct -{ - char name[64]; - u32 adress; - int size; - reg_dispFn create; - reg_dispFn update; - reg_dispFn destroy; - reg_valFn value; -} reg_t; - -static reg_t *current_reg[2] = {NULL, NULL}; - -#define REGFN_BEGIN(reg) \ - GtkWidget **_wl_ = Widgets_##reg [c]; - -#define BIT_CHECK(w, n, s) { \ - char _bit_check_buf[64]; \ - snprintf(_bit_check_buf, ARRAY_SIZE(_bit_check_buf), "Bit %d: %s", n,s); \ - _wl_[w] = gtk_check_button_new_with_label(_bit_check_buf ); \ - gtk_box_pack_start(GTK_BOX(mVbox0[c]), _wl_[w], FALSE, FALSE, 0); } - -#define BIT_COMBO(w,n,s) { \ - _wl_[w] = gtk_hbox_new(FALSE, 0); \ - gtk_box_pack_start(GTK_BOX(mVbox0[c]), _wl_[w], FALSE, FALSE, 0); } \ - char _bit_combo_buf[64]; \ - snprintf(_bit_combo_buf, ARRAY_SIZE(_bit_combo_buf), "Bits %s: %s", n,s); \ - GtkWidget *__combo_lbl_tmp = gtk_label_new(_bit_combo_buf); \ - GtkWidget *__combo_tmp = gtk_combo_box_new_text(); \ - -#define BIT_COMBO_ADD(w, s) { \ - gtk_combo_box_append_text(GTK_COMBO_BOX(__combo_tmp), s); } - -#define BIT_COMBO_GET(w) (GTK_WIDGET(g_list_first(gtk_container_get_children(GTK_CONTAINER(_wl_[w])))->data)) - -#define BIT_COMBO_END(w) \ - gtk_box_pack_start(GTK_BOX(_wl_[w]), __combo_tmp, FALSE, FALSE, 0); \ - gtk_box_pack_start(GTK_BOX(_wl_[w]), __combo_lbl_tmp, FALSE, FALSE, 0); - -#define CREA_END() \ - gtk_widget_show_all(mWin[c]); - -/////////////////////////////// REG_IME /////////////////////////////// -static GtkWidget *Widgets_REG_IME[2][1]; -static void crea_REG_IME(int c) -{ - REGFN_BEGIN(REG_IME); - BIT_CHECK(0, 0, "Master interrupt enable"); - CREA_END(); -} -static void updt_REG_IME(int c) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_IME[c][0]), MMU.reg_IME[c] ? 1 : 0); } -static void dest_REG_IME(int c) { gtk_widget_destroy(Widgets_REG_IME[c][0]); } -static u32 val_REG_IME(int c) { return MMU.reg_IME[c]; } - -/////////////////////////////// REG_IE /////////////////////////////// - -static const char *interrupt_strings[25] = -{ - "LCD VBlank", // 0 - "LCD HBlank", // 1 - "LCD VCount", // 2 - "Timer0 overflow", // 3 - "Timer1 overflow", - "Timer2 overflow", - "Timer3 overflow", - "Serial communication (RTC)", // 7 - "DMA0", // 8 - "DMA1", - "DMA2", - "DMA3", - "Keypad", // 12 - "Game Pak (GBA slot)", // 13 - "", // 14 - "", // 15 - "IPC Sync", // 16 - "IPC Send FIFO empty", // 17 - "IPC Recv FIFO not empty", // 18 - "Card Data Transfer Completion (DS-card slot)", // 19 - "Card IREQ_MC (DS-card slot)", // 20 - "Geometry (3D) command FIFO", // 21 - "Screens unfolding", // 22 - "SPI bus", // 23 - "Wifi" // 24 -}; -#define INTERRUPT_SKIP(c) if(i == 14 || i == 15 || (c == 0 && (i == 7 || i == 22 || i == 23 || i == 24)) || (c == 1 && i == 21))continue; - -static GtkWidget *Widgets_REG_IE[2][32]; -static void crea_REG_IE(int c) -{ - REGFN_BEGIN(REG_IE); - int i; - for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); BIT_CHECK(i, i, interrupt_strings[i]); } - CREA_END(); -} -static void updt_REG_IE(int c) -{ - int i; - for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_IE[c][i]), (MMU.reg_IE[c] & (1<>1]&(1<>1]; } - -/////////////////////////////// POWER_CR /////////////////////////////// -static const char *powercr9_strings[] = -{ - "Enable LCD", - "2D A engine", - "3D render engine", - "3D geometry engine (matrix)", - "", "", "", "", "", - "2D B engine", - "", "", "", "", "", - "Swap LCD" -}; -static const char *powercr7_strings[] = -{ - "Sound speakers", - "Wifi system" -}; -#define POWER_CR_SKIP(c) if(i==4||i==5||i==6||i==7||i==8||i==10||i==11||i==12||i==13||i==14)continue; -#define POWER_CR_SIZE(c) ((c==0)?16:2) - -static GtkWidget *Widgets_POWER_CR[2][16]; -static void crea_POWER_CR(int c) -{ - REGFN_BEGIN(POWER_CR); - int i; - for(i = 0; i < POWER_CR_SIZE(c); i++) { POWER_CR_SKIP(c); BIT_CHECK(i, i, (c==0?powercr9_strings:powercr7_strings)[i]); } - CREA_END(); -} -static void updt_POWER_CR(int c) -{ - int i; - for(i = 0; i < POWER_CR_SIZE(c); i++) { POWER_CR_SKIP(c); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_POWER_CR[c][i]), (((u16 *)(MMU.MMU_MEM[c][0x40]))[0x304>>1]&(1<>1]; } - -/////////////////////////////// REG_SPICNT /////////////////////////////// -static const char *spicnt_strings[16] = -{ - "Baudrate", - "","","","","","", - "Busy flag", - "Device", - "", - "Transfer size", - "Chipselect Hold", - "Unknown", - "Unknown", - "Interrupt request", - "Enable SPI bus", -}; - -// 0-1 Baudrate (0=4MHz/Firmware, 1=2MHz/Touchscr, 2=1MHz/Powerman., 3=512KHz) -// 2-6 Not used (Zero) -// 7 Busy Flag (0=Ready, 1=Busy) (presumably Read-only) -// 8-9 Device Select (0=Powerman., 1=Firmware, 2=Touchscr, 3=Reserved) -// 10 Transfer Size (0=8bit, 1=16bit) -// 11 Chipselect Hold (0=Deselect after transfer, 1=Keep selected) -// 12 Unknown (usually 0) (set equal to Bit11 when BIOS accesses firmware) -// 13 Unknown (usually 0) (set to 1 when BIOS accesses firmware) -// 14 Interrupt Request (0=Disable, 1=Enable) -// 15 SPI Bus Enable (0=Disable, 1=Enable) - - -#define REG_SPICNT_SKIP(c) if(i==1||i==2||i==3||i==4||i==5||i==6||i==9)continue; -#define REG_SPICNT_ISCHECK(c) (i==7||i==11||i==14||i==15||i==12||i==13) - -static GtkWidget *Widgets_REG_SPICNT[2][16]; -static void crea_REG_SPICNT(int c) -{ - REGFN_BEGIN(REG_SPICNT); - int i; - for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c); - if(REG_SPICNT_ISCHECK(c)) { BIT_CHECK(i, i, spicnt_strings[i]); } - else if(i == 0) { BIT_COMBO(i, "0-1", spicnt_strings[0]); - BIT_COMBO_ADD(i, "0= 4Mhz"); - BIT_COMBO_ADD(i, "1= 2Mhz"); - BIT_COMBO_ADD(i, "2= 1Mhz"); - BIT_COMBO_ADD(i, "3= 512Khz"); - BIT_COMBO_END(i); } - else if(i == 8) { BIT_COMBO(i, "8-9", spicnt_strings[8]); - BIT_COMBO_ADD(i, "0= Power management device"); - BIT_COMBO_ADD(i, "1= Firmware"); - BIT_COMBO_ADD(i, "2= Touchscreen/Microphone"); - BIT_COMBO_ADD(i, "3= Reserved/Prohibited"); - BIT_COMBO_END(i); } - else if(i == 10) { BIT_COMBO(i, "10", spicnt_strings[10]); - BIT_COMBO_ADD(i, "0= 8 bits"); - BIT_COMBO_ADD(i, "1= 16 bits"); - BIT_COMBO_END(i); } - } - CREA_END(); -} -static u32 val_REG_SPICNT(int c) { return ((u16 *)(MMU.MMU_MEM[c][0x40]))[0x1C0>>1]; } -static void updt_REG_SPICNT(int c) -{ - REGFN_BEGIN(REG_SPICNT); - u16 val = val_REG_SPICNT(c); - int i; - for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c); - if(REG_SPICNT_ISCHECK(c)) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_SPICNT[c][i]), (((u16 *)(MMU.MMU_MEM[c][0x40]))[0x1C0>>1]&(1<>8)&3); } - else if(i == 10) { gtk_combo_box_set_active(GTK_COMBO_BOX(BIT_COMBO_GET(i)) , (val>>10)&1); } - } -} -static void dest_REG_SPICNT(int c) -{ - int i; - for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c); gtk_widget_destroy(Widgets_REG_SPICNT[c][i]); } -} - -/////////////////////////////// LIST /////////////////////////////// -#define BITS_8 1 -#define BITS_16 2 -#define BITS_32 4 -static const char *bits_strings[5] = {"0", "8", "16", "24", "32"}; - -#define REG_STR(r, s) {#r, r, s, &crea_##r, &updt_##r, &dest_##r, &val_##r} -#define REG_FNS(r) &crea_##r, &updt_##r, &dest_##r, &val_##r -//////// ARM9 //////// -#define REG_LIST_SIZE_ARM9 5 -static const reg_t regs_list_9[] = -{ - {"REG_IME", REG_IME, BITS_16, REG_FNS(REG_IME)}, - {"REG_IE", REG_IE, BITS_32, REG_FNS(REG_IE)}, - {"REG_IF", REG_IF, BITS_32, REG_FNS(REG_IF)}, - {"REG_IPCFIFOCNT", 0x04000184, BITS_16, REG_FNS(REG_IPCFIFOCNT)}, - {"POWER_CR", REG_POWCNT1, BITS_16, REG_FNS(POWER_CR)} -}; - -//////// ARM7 //////// -#define REG_LIST_SIZE_ARM7 6 -static const reg_t regs_list_7[] = -{ - {"REG_IME", REG_IME, BITS_16, REG_FNS(REG_IME)}, - {"REG_IE", REG_IE, BITS_32, REG_FNS(REG_IE)}, - {"REG_IF", REG_IF, BITS_32, REG_FNS(REG_IF)}, - {"REG_IPCFIFOCNT", 0x04000184, BITS_16, REG_FNS(REG_IPCFIFOCNT)}, - {"POWER_CR", REG_POWCNT1, BITS_16, REG_FNS(POWER_CR)}, - {"REG_SPICNT", REG_SPICNT, BITS_16, REG_FNS(REG_SPICNT)} -}; - -#define GET_REG_LIST_SIZE(i) ((i==0)?REG_LIST_SIZE_ARM9:REG_LIST_SIZE_ARM7) -#define GET_REG_LIST(i) ((i==0)?regs_list_9:regs_list_7) - -static void _clearContainer(GtkWidget *widget, gpointer data) -{ - if(widget == mRegInfos[0] || widget == mRegInfos[1]) return; - if(widget == mIoRegCombo[0] || widget == mIoRegCombo[1]) return; - - gtk_container_remove(GTK_CONTAINER((GtkWidget*)data), widget); -// gtk_widget_destroy(widget); -// gtk_object_destroy(GTK_OBJECT(widget)); -} - -static void selected_reg(GtkWidget* widget, gpointer data) -{ - int c = GPOINTER_TO_INT(data); - gchar *regInfosBuffer; - - guint active = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); - - if(current_reg[c]) current_reg[c]->destroy(c); - gtk_container_foreach(GTK_CONTAINER(mVbox0[c]), _clearContainer, (gpointer)mVbox0[c]); - - current_reg[c] = (reg_t*)&(GET_REG_LIST(c)[active]); - -// gtk_box_pack_start(GTK_BOX(mVbox0[c]), mIoRegCombo[c], FALSE, FALSE, 0); - - switch (current_reg[c]->size) { - case BITS_8: - regInfosBuffer = g_strdup_printf("0x%02X", current_reg[c]->value(c)); - break; - case BITS_16: - regInfosBuffer = g_strdup_printf("0x%04X", current_reg[c]->value(c)); - break; - default: - regInfosBuffer = g_strdup_printf("0x%08X", current_reg[c]->value(c)); - } -// gtk_box_pack_start(GTK_BOX(mVbox0[c]), mRegInfos[c], FALSE, FALSE, 0); - gtk_label_set_label(GTK_LABEL(mRegInfos[c]), regInfosBuffer); - g_free(regInfosBuffer); - - current_reg[c]->create(c); - current_reg[c]->update(c); -} - -/////////////////////////////// TOOL /////////////////////////////// - -static int DTOOL_ID; - -static void close() -{ - memset(current_reg, 0, sizeof(current_reg)); - dTool_CloseCallback(DTOOL_ID); -} - -static void _closeOne(GtkWidget *widget, gpointer data) -{ - int c = GPOINTER_TO_INT(data); - - CPUS[c] = FALSE; - if(c == 0 && !CPUS[1]) close(); - if(c == 1 && !CPUS[0]) close(); - - gtk_widget_destroy(mRegInfos[c]); - gtk_widget_destroy(mIoRegCombo[c]); - gtk_widget_destroy(mVbox0[c]); -// gtk_widget_destroy(mWin[c]); -} - -static void update() -{ - int c; - - for(c = 0; c < 2; c++) - { - if(!CPUS[c]) continue; - current_reg[c]->update(c); - } -} - -static void open(int ID) -{ - int c, i; - - DTOOL_ID = ID; - - for(c = 0; c < 2; c++) - { - CPUS[c] = TRUE; - - mWin[c]= gtk_window_new(GTK_WINDOW_TOPLEVEL); - if(c == 0) gtk_window_set_title(GTK_WINDOW(mWin[c]), TOOL_NAME " : ARM9"); - else gtk_window_set_title(GTK_WINDOW(mWin[c]), TOOL_NAME " : ARM7"); - g_signal_connect(G_OBJECT(mWin[c]), "destroy", G_CALLBACK(&_closeOne), GINT_TO_POINTER(c)); - - mVbox0[c] = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(mWin[c]), mVbox0[c]); - - mIoRegCombo[c] = gtk_combo_box_new_text(); - mRegInfos[c] = gtk_label_new(""); - - for(i = 0; i < GET_REG_LIST_SIZE(c); i++) - { - gchar *reg_name_buffer; - reg_name_buffer = g_strdup_printf("0x%08X : %s (%s)", GET_REG_LIST(c)[i].adress, GET_REG_LIST(c)[i].name, bits_strings[GET_REG_LIST(c)[i].size]); - gtk_combo_box_append_text(GTK_COMBO_BOX(mIoRegCombo[c]), reg_name_buffer); - g_free(reg_name_buffer); - } - - gtk_combo_box_set_active(GTK_COMBO_BOX(mIoRegCombo[c]), 0); - g_signal_connect(G_OBJECT(mIoRegCombo[c]), "changed", G_CALLBACK(selected_reg), GINT_TO_POINTER(c)); - - gtk_box_pack_start(GTK_BOX(mVbox0[c]), mIoRegCombo[c], FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(mVbox0[c]), mRegInfos[c], FALSE, FALSE, 0); - selected_reg(mIoRegCombo[c], GINT_TO_POINTER(c)); - - gtk_widget_show_all(mWin[c]); - } -} - -/////////////////////////////// TOOL DEFINITION /////////////////////////////// - -dTool_t dTool_ioregsView = -{ - SHORTNAME, - TOOL_NAME, - &open, - &update, - &close -}; - +/* ioregsView.cpp - this file is part of DeSmuME + * + * Copyright (C) 2006 Thoduv + * Copyright (C) 2006,2007 DeSmuME Team + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include "../dTool.h" + +#include "../MMU.h" + +#define SHORTNAME "ioregs" +#define TOOL_NAME "IO regs view" + +BOOL CPUS [2] = {TRUE, TRUE}; + +static GtkWidget *mWin[2]; +static GtkWidget *mVbox0[2]; +static GtkWidget *mIoRegCombo[2]; +static GtkWidget *mRegInfos[2]; + +typedef void (*reg_dispFn)(int c); +typedef u32 (*reg_valFn)(int c); + +typedef struct +{ + char name[64]; + u32 adress; + int size; + reg_dispFn create; + reg_dispFn update; + reg_dispFn destroy; + reg_valFn value; +} reg_t; + +static reg_t *current_reg[2] = {NULL, NULL}; + +#define REGFN_BEGIN(reg) \ + GtkWidget **_wl_ = Widgets_##reg [c]; + +#define BIT_CHECK(w, n, s) { \ + char _bit_check_buf[64]; \ + snprintf(_bit_check_buf, ARRAY_SIZE(_bit_check_buf), "Bit %d: %s", n,s); \ + _wl_[w] = gtk_check_button_new_with_label(_bit_check_buf ); \ + gtk_box_pack_start(GTK_BOX(mVbox0[c]), _wl_[w], FALSE, FALSE, 0); } + +#define BIT_COMBO(w,n,s) { \ + _wl_[w] = gtk_hbox_new(FALSE, 0); \ + gtk_box_pack_start(GTK_BOX(mVbox0[c]), _wl_[w], FALSE, FALSE, 0); } \ + char _bit_combo_buf[64]; \ + snprintf(_bit_combo_buf, ARRAY_SIZE(_bit_combo_buf), "Bits %s: %s", n,s); \ + GtkWidget *__combo_lbl_tmp = gtk_label_new(_bit_combo_buf); \ + GtkWidget *__combo_tmp = gtk_combo_box_new_text(); \ + +#define BIT_COMBO_ADD(w, s) { \ + gtk_combo_box_append_text(GTK_COMBO_BOX(__combo_tmp), s); } + +#define BIT_COMBO_GET(w) (GTK_WIDGET(g_list_first(gtk_container_get_children(GTK_CONTAINER(_wl_[w])))->data)) + +#define BIT_COMBO_END(w) \ + gtk_box_pack_start(GTK_BOX(_wl_[w]), __combo_tmp, FALSE, FALSE, 0); \ + gtk_box_pack_start(GTK_BOX(_wl_[w]), __combo_lbl_tmp, FALSE, FALSE, 0); + +#define CREA_END() \ + gtk_widget_show_all(mWin[c]); + +/////////////////////////////// REG_IME /////////////////////////////// +static GtkWidget *Widgets_REG_IME[2][1]; +static void crea_REG_IME(int c) +{ + REGFN_BEGIN(REG_IME); + BIT_CHECK(0, 0, "Master interrupt enable"); + CREA_END(); +} +static void updt_REG_IME(int c) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_IME[c][0]), MMU.reg_IME[c] ? 1 : 0); } +static void dest_REG_IME(int c) { gtk_widget_destroy(Widgets_REG_IME[c][0]); } +static u32 val_REG_IME(int c) { return MMU.reg_IME[c]; } + +/////////////////////////////// REG_IE /////////////////////////////// + +static const char *interrupt_strings[25] = +{ + "LCD VBlank", // 0 + "LCD HBlank", // 1 + "LCD VCount", // 2 + "Timer0 overflow", // 3 + "Timer1 overflow", + "Timer2 overflow", + "Timer3 overflow", + "Serial communication (RTC)", // 7 + "DMA0", // 8 + "DMA1", + "DMA2", + "DMA3", + "Keypad", // 12 + "Game Pak (GBA slot)", // 13 + "", // 14 + "", // 15 + "IPC Sync", // 16 + "IPC Send FIFO empty", // 17 + "IPC Recv FIFO not empty", // 18 + "Card Data Transfer Completion (DS-card slot)", // 19 + "Card IREQ_MC (DS-card slot)", // 20 + "Geometry (3D) command FIFO", // 21 + "Screens unfolding", // 22 + "SPI bus", // 23 + "Wifi" // 24 +}; +#define INTERRUPT_SKIP(c) if(i == 14 || i == 15 || (c == 0 && (i == 7 || i == 22 || i == 23 || i == 24)) || (c == 1 && i == 21))continue; + +static GtkWidget *Widgets_REG_IE[2][32]; +static void crea_REG_IE(int c) +{ + REGFN_BEGIN(REG_IE); + int i; + for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); BIT_CHECK(i, i, interrupt_strings[i]); } + CREA_END(); +} +static void updt_REG_IE(int c) +{ + int i; + for(i = 0; i < 24; i++) { INTERRUPT_SKIP(c); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_IE[c][i]), (MMU.reg_IE[c] & (1<>1]&(1<>1]; } + +/////////////////////////////// POWER_CR /////////////////////////////// +static const char *powercr9_strings[] = +{ + "Enable LCD", + "2D A engine", + "3D render engine", + "3D geometry engine (matrix)", + "", "", "", "", "", + "2D B engine", + "", "", "", "", "", + "Swap LCD" +}; +static const char *powercr7_strings[] = +{ + "Sound speakers", + "Wifi system" +}; +#define POWER_CR_SKIP(c) if(i==4||i==5||i==6||i==7||i==8||i==10||i==11||i==12||i==13||i==14)continue; +#define POWER_CR_SIZE(c) ((c==0)?16:2) + +static GtkWidget *Widgets_POWER_CR[2][16]; +static void crea_POWER_CR(int c) +{ + REGFN_BEGIN(POWER_CR); + int i; + for(i = 0; i < POWER_CR_SIZE(c); i++) { POWER_CR_SKIP(c); BIT_CHECK(i, i, (c==0?powercr9_strings:powercr7_strings)[i]); } + CREA_END(); +} +static void updt_POWER_CR(int c) +{ + int i; + for(i = 0; i < POWER_CR_SIZE(c); i++) { POWER_CR_SKIP(c); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_POWER_CR[c][i]), (((u16 *)(MMU.MMU_MEM[c][0x40]))[0x304>>1]&(1<>1]; } + +/////////////////////////////// REG_SPICNT /////////////////////////////// +static const char *spicnt_strings[16] = +{ + "Baudrate", + "","","","","","", + "Busy flag", + "Device", + "", + "Transfer size", + "Chipselect Hold", + "Unknown", + "Unknown", + "Interrupt request", + "Enable SPI bus", +}; + +// 0-1 Baudrate (0=4MHz/Firmware, 1=2MHz/Touchscr, 2=1MHz/Powerman., 3=512KHz) +// 2-6 Not used (Zero) +// 7 Busy Flag (0=Ready, 1=Busy) (presumably Read-only) +// 8-9 Device Select (0=Powerman., 1=Firmware, 2=Touchscr, 3=Reserved) +// 10 Transfer Size (0=8bit, 1=16bit) +// 11 Chipselect Hold (0=Deselect after transfer, 1=Keep selected) +// 12 Unknown (usually 0) (set equal to Bit11 when BIOS accesses firmware) +// 13 Unknown (usually 0) (set to 1 when BIOS accesses firmware) +// 14 Interrupt Request (0=Disable, 1=Enable) +// 15 SPI Bus Enable (0=Disable, 1=Enable) + + +#define REG_SPICNT_SKIP(c) if(i==1||i==2||i==3||i==4||i==5||i==6||i==9)continue; +#define REG_SPICNT_ISCHECK(c) (i==7||i==11||i==14||i==15||i==12||i==13) + +static GtkWidget *Widgets_REG_SPICNT[2][16]; +static void crea_REG_SPICNT(int c) +{ + REGFN_BEGIN(REG_SPICNT); + int i; + for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c); + if(REG_SPICNT_ISCHECK(c)) { BIT_CHECK(i, i, spicnt_strings[i]); } + else if(i == 0) { BIT_COMBO(i, "0-1", spicnt_strings[0]); + BIT_COMBO_ADD(i, "0= 4Mhz"); + BIT_COMBO_ADD(i, "1= 2Mhz"); + BIT_COMBO_ADD(i, "2= 1Mhz"); + BIT_COMBO_ADD(i, "3= 512Khz"); + BIT_COMBO_END(i); } + else if(i == 8) { BIT_COMBO(i, "8-9", spicnt_strings[8]); + BIT_COMBO_ADD(i, "0= Power management device"); + BIT_COMBO_ADD(i, "1= Firmware"); + BIT_COMBO_ADD(i, "2= Touchscreen/Microphone"); + BIT_COMBO_ADD(i, "3= Reserved/Prohibited"); + BIT_COMBO_END(i); } + else if(i == 10) { BIT_COMBO(i, "10", spicnt_strings[10]); + BIT_COMBO_ADD(i, "0= 8 bits"); + BIT_COMBO_ADD(i, "1= 16 bits"); + BIT_COMBO_END(i); } + } + CREA_END(); +} +static u32 val_REG_SPICNT(int c) { return ((u16 *)(MMU.MMU_MEM[c][0x40]))[0x1C0>>1]; } +static void updt_REG_SPICNT(int c) +{ + REGFN_BEGIN(REG_SPICNT); + u16 val = val_REG_SPICNT(c); + int i; + for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c); + if(REG_SPICNT_ISCHECK(c)) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Widgets_REG_SPICNT[c][i]), (((u16 *)(MMU.MMU_MEM[c][0x40]))[0x1C0>>1]&(1<>8)&3); } + else if(i == 10) { gtk_combo_box_set_active(GTK_COMBO_BOX(BIT_COMBO_GET(i)) , (val>>10)&1); } + } +} +static void dest_REG_SPICNT(int c) +{ + int i; + for(i = 0; i < 16; i++) { REG_SPICNT_SKIP(c); gtk_widget_destroy(Widgets_REG_SPICNT[c][i]); } +} + +/////////////////////////////// LIST /////////////////////////////// +#define BITS_8 1 +#define BITS_16 2 +#define BITS_32 4 +static const char *bits_strings[5] = {"0", "8", "16", "24", "32"}; + +#define REG_STR(r, s) {#r, r, s, &crea_##r, &updt_##r, &dest_##r, &val_##r} +#define REG_FNS(r) &crea_##r, &updt_##r, &dest_##r, &val_##r +//////// ARM9 //////// +#define REG_LIST_SIZE_ARM9 5 +static const reg_t regs_list_9[] = +{ + {"REG_IME", REG_IME, BITS_16, REG_FNS(REG_IME)}, + {"REG_IE", REG_IE, BITS_32, REG_FNS(REG_IE)}, + {"REG_IF", REG_IF, BITS_32, REG_FNS(REG_IF)}, + {"REG_IPCFIFOCNT", 0x04000184, BITS_16, REG_FNS(REG_IPCFIFOCNT)}, + {"POWER_CR", REG_POWCNT1, BITS_16, REG_FNS(POWER_CR)} +}; + +//////// ARM7 //////// +#define REG_LIST_SIZE_ARM7 6 +static const reg_t regs_list_7[] = +{ + {"REG_IME", REG_IME, BITS_16, REG_FNS(REG_IME)}, + {"REG_IE", REG_IE, BITS_32, REG_FNS(REG_IE)}, + {"REG_IF", REG_IF, BITS_32, REG_FNS(REG_IF)}, + {"REG_IPCFIFOCNT", 0x04000184, BITS_16, REG_FNS(REG_IPCFIFOCNT)}, + {"POWER_CR", REG_POWCNT1, BITS_16, REG_FNS(POWER_CR)}, + {"REG_SPICNT", REG_SPICNT, BITS_16, REG_FNS(REG_SPICNT)} +}; + +#define GET_REG_LIST_SIZE(i) ((i==0)?REG_LIST_SIZE_ARM9:REG_LIST_SIZE_ARM7) +#define GET_REG_LIST(i) ((i==0)?regs_list_9:regs_list_7) + +static void _clearContainer(GtkWidget *widget, gpointer data) +{ + if(widget == mRegInfos[0] || widget == mRegInfos[1]) return; + if(widget == mIoRegCombo[0] || widget == mIoRegCombo[1]) return; + + gtk_container_remove(GTK_CONTAINER((GtkWidget*)data), widget); +// gtk_widget_destroy(widget); +// gtk_object_destroy(GTK_OBJECT(widget)); +} + +static void selected_reg(GtkWidget* widget, gpointer data) +{ + int c = GPOINTER_TO_INT(data); + gchar *regInfosBuffer; + + guint active = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); + + if(current_reg[c]) current_reg[c]->destroy(c); + gtk_container_foreach(GTK_CONTAINER(mVbox0[c]), _clearContainer, (gpointer)mVbox0[c]); + + current_reg[c] = (reg_t*)&(GET_REG_LIST(c)[active]); + +// gtk_box_pack_start(GTK_BOX(mVbox0[c]), mIoRegCombo[c], FALSE, FALSE, 0); + + switch (current_reg[c]->size) { + case BITS_8: + regInfosBuffer = g_strdup_printf("0x%02X", current_reg[c]->value(c)); + break; + case BITS_16: + regInfosBuffer = g_strdup_printf("0x%04X", current_reg[c]->value(c)); + break; + default: + regInfosBuffer = g_strdup_printf("0x%08X", current_reg[c]->value(c)); + } +// gtk_box_pack_start(GTK_BOX(mVbox0[c]), mRegInfos[c], FALSE, FALSE, 0); + gtk_label_set_label(GTK_LABEL(mRegInfos[c]), regInfosBuffer); + g_free(regInfosBuffer); + + current_reg[c]->create(c); + current_reg[c]->update(c); +} + +/////////////////////////////// TOOL /////////////////////////////// + +static int DTOOL_ID; + +static void close() +{ + memset(current_reg, 0, sizeof(current_reg)); + dTool_CloseCallback(DTOOL_ID); +} + +static void _closeOne(GtkWidget *widget, gpointer data) +{ + int c = GPOINTER_TO_INT(data); + + CPUS[c] = FALSE; + if(c == 0 && !CPUS[1]) close(); + if(c == 1 && !CPUS[0]) close(); + + gtk_widget_destroy(mRegInfos[c]); + gtk_widget_destroy(mIoRegCombo[c]); + gtk_widget_destroy(mVbox0[c]); +// gtk_widget_destroy(mWin[c]); +} + +static void update() +{ + int c; + + for(c = 0; c < 2; c++) + { + if(!CPUS[c]) continue; + current_reg[c]->update(c); + } +} + +static void open(int ID) +{ + int c, i; + + DTOOL_ID = ID; + + for(c = 0; c < 2; c++) + { + CPUS[c] = TRUE; + + mWin[c]= gtk_window_new(GTK_WINDOW_TOPLEVEL); + if(c == 0) gtk_window_set_title(GTK_WINDOW(mWin[c]), TOOL_NAME " : ARM9"); + else gtk_window_set_title(GTK_WINDOW(mWin[c]), TOOL_NAME " : ARM7"); + g_signal_connect(G_OBJECT(mWin[c]), "destroy", G_CALLBACK(&_closeOne), GINT_TO_POINTER(c)); + + mVbox0[c] = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(mWin[c]), mVbox0[c]); + + mIoRegCombo[c] = gtk_combo_box_new_text(); + mRegInfos[c] = gtk_label_new(""); + + for(i = 0; i < GET_REG_LIST_SIZE(c); i++) + { + gchar *reg_name_buffer; + reg_name_buffer = g_strdup_printf("0x%08X : %s (%s)", GET_REG_LIST(c)[i].adress, GET_REG_LIST(c)[i].name, bits_strings[GET_REG_LIST(c)[i].size]); + gtk_combo_box_append_text(GTK_COMBO_BOX(mIoRegCombo[c]), reg_name_buffer); + g_free(reg_name_buffer); + } + + gtk_combo_box_set_active(GTK_COMBO_BOX(mIoRegCombo[c]), 0); + g_signal_connect(G_OBJECT(mIoRegCombo[c]), "changed", G_CALLBACK(selected_reg), GINT_TO_POINTER(c)); + + gtk_box_pack_start(GTK_BOX(mVbox0[c]), mIoRegCombo[c], FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(mVbox0[c]), mRegInfos[c], FALSE, FALSE, 0); + selected_reg(mIoRegCombo[c], GINT_TO_POINTER(c)); + + gtk_widget_show_all(mWin[c]); + } +} + +/////////////////////////////// TOOL DEFINITION /////////////////////////////// + +dTool_t dTool_ioregsView = +{ + SHORTNAME, + TOOL_NAME, + &open, + &update, + &close +}; + diff --git a/desmume/src/gtk/tools/ioregsView.h b/src/gtk/tools/ioregsView.h similarity index 97% rename from desmume/src/gtk/tools/ioregsView.h rename to src/gtk/tools/ioregsView.h index 2c814451a..4ee8949f8 100644 --- a/desmume/src/gtk/tools/ioregsView.h +++ b/src/gtk/tools/ioregsView.h @@ -1,29 +1,29 @@ -/* ioregsview.h - this file is part of DeSmuME - * - * Copyright (C) 2006,2007 DeSmuME Team - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __IOREGSVIEW_H__ -#define __IOREGSVIEW_H__ - -#include "../dTool.h" - -extern dTool_t dTool_ioregsView; - -#endif /*__IOREGSVIEW_H__*/ - +/* ioregsview.h - this file is part of DeSmuME + * + * Copyright (C) 2006,2007 DeSmuME Team + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __IOREGSVIEW_H__ +#define __IOREGSVIEW_H__ + +#include "../dTool.h" + +extern dTool_t dTool_ioregsView; + +#endif /*__IOREGSVIEW_H__*/ + diff --git a/desmume/src/instruction_tabdef.inc b/src/instruction_tabdef.inc similarity index 100% rename from desmume/src/instruction_tabdef.inc rename to src/instruction_tabdef.inc diff --git a/desmume/src/lua-engine.cpp b/src/lua-engine.cpp similarity index 100% rename from desmume/src/lua-engine.cpp rename to src/lua-engine.cpp diff --git a/desmume/src/lua-engine.h b/src/lua-engine.h similarity index 100% rename from desmume/src/lua-engine.h rename to src/lua-engine.h diff --git a/desmume/src/matrix.cpp b/src/matrix.cpp similarity index 88% rename from desmume/src/matrix.cpp rename to src/matrix.cpp index d2eff5a43..947100169 100644 --- a/desmume/src/matrix.cpp +++ b/src/matrix.cpp @@ -1,344 +1,335 @@ -/* - Copyright (C) 2006-2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include -#include -#include -#include "matrix.h" - -//------------------------- -//switched SSE functions: implementations for no SSE -#ifndef ENABLE_SSE -void MatrixMultVec4x4 (const float *matrix, float *vecPtr) -{ - float x = vecPtr[0]; - float y = vecPtr[1]; - float z = vecPtr[2]; - float w = vecPtr[3]; - - vecPtr[0] = x * matrix[0] + y * matrix[4] + z * matrix[ 8] + w * matrix[12]; - vecPtr[1] = x * matrix[1] + y * matrix[5] + z * matrix[ 9] + w * matrix[13]; - vecPtr[2] = x * matrix[2] + y * matrix[6] + z * matrix[10] + w * matrix[14]; - vecPtr[3] = x * matrix[3] + y * matrix[7] + z * matrix[11] + w * matrix[15]; -} - - -void MatrixMultVec3x3 (const float *matrix, float *vecPtr) -{ - float x = vecPtr[0]; - float y = vecPtr[1]; - float z = vecPtr[2]; - - vecPtr[0] = x * matrix[0] + y * matrix[4] + z * matrix[ 8]; - vecPtr[1] = x * matrix[1] + y * matrix[5] + z * matrix[ 9]; - vecPtr[2] = x * matrix[2] + y * matrix[6] + z * matrix[10]; -} - -void MatrixMultiply (float *matrix, const float *rightMatrix) -{ - float tmpMatrix[16]; - - tmpMatrix[0] = (matrix[0]*rightMatrix[0])+(matrix[4]*rightMatrix[1])+(matrix[8]*rightMatrix[2])+(matrix[12]*rightMatrix[3]); - tmpMatrix[1] = (matrix[1]*rightMatrix[0])+(matrix[5]*rightMatrix[1])+(matrix[9]*rightMatrix[2])+(matrix[13]*rightMatrix[3]); - tmpMatrix[2] = (matrix[2]*rightMatrix[0])+(matrix[6]*rightMatrix[1])+(matrix[10]*rightMatrix[2])+(matrix[14]*rightMatrix[3]); - tmpMatrix[3] = (matrix[3]*rightMatrix[0])+(matrix[7]*rightMatrix[1])+(matrix[11]*rightMatrix[2])+(matrix[15]*rightMatrix[3]); - - tmpMatrix[4] = (matrix[0]*rightMatrix[4])+(matrix[4]*rightMatrix[5])+(matrix[8]*rightMatrix[6])+(matrix[12]*rightMatrix[7]); - tmpMatrix[5] = (matrix[1]*rightMatrix[4])+(matrix[5]*rightMatrix[5])+(matrix[9]*rightMatrix[6])+(matrix[13]*rightMatrix[7]); - tmpMatrix[6] = (matrix[2]*rightMatrix[4])+(matrix[6]*rightMatrix[5])+(matrix[10]*rightMatrix[6])+(matrix[14]*rightMatrix[7]); - tmpMatrix[7] = (matrix[3]*rightMatrix[4])+(matrix[7]*rightMatrix[5])+(matrix[11]*rightMatrix[6])+(matrix[15]*rightMatrix[7]); - - tmpMatrix[8] = (matrix[0]*rightMatrix[8])+(matrix[4]*rightMatrix[9])+(matrix[8]*rightMatrix[10])+(matrix[12]*rightMatrix[11]); - tmpMatrix[9] = (matrix[1]*rightMatrix[8])+(matrix[5]*rightMatrix[9])+(matrix[9]*rightMatrix[10])+(matrix[13]*rightMatrix[11]); - tmpMatrix[10] = (matrix[2]*rightMatrix[8])+(matrix[6]*rightMatrix[9])+(matrix[10]*rightMatrix[10])+(matrix[14]*rightMatrix[11]); - tmpMatrix[11] = (matrix[3]*rightMatrix[8])+(matrix[7]*rightMatrix[9])+(matrix[11]*rightMatrix[10])+(matrix[15]*rightMatrix[11]); - - tmpMatrix[12] = (matrix[0]*rightMatrix[12])+(matrix[4]*rightMatrix[13])+(matrix[8]*rightMatrix[14])+(matrix[12]*rightMatrix[15]); - tmpMatrix[13] = (matrix[1]*rightMatrix[12])+(matrix[5]*rightMatrix[13])+(matrix[9]*rightMatrix[14])+(matrix[13]*rightMatrix[15]); - tmpMatrix[14] = (matrix[2]*rightMatrix[12])+(matrix[6]*rightMatrix[13])+(matrix[10]*rightMatrix[14])+(matrix[14]*rightMatrix[15]); - tmpMatrix[15] = (matrix[3]*rightMatrix[12])+(matrix[7]*rightMatrix[13])+(matrix[11]*rightMatrix[14])+(matrix[15]*rightMatrix[15]); - - memcpy (matrix, tmpMatrix, sizeof(float)*16); -} - -void MatrixTranslate (float *matrix, const float *ptr) -{ - matrix[12] += (matrix[0]*ptr[0])+(matrix[4]*ptr[1])+(matrix[ 8]*ptr[2]); - matrix[13] += (matrix[1]*ptr[0])+(matrix[5]*ptr[1])+(matrix[ 9]*ptr[2]); - matrix[14] += (matrix[2]*ptr[0])+(matrix[6]*ptr[1])+(matrix[10]*ptr[2]); - matrix[15] += (matrix[3]*ptr[0])+(matrix[7]*ptr[1])+(matrix[11]*ptr[2]); -} - -void MatrixScale (float *matrix, const float *ptr) -{ - matrix[0] *= ptr[0]; - matrix[1] *= ptr[0]; - matrix[2] *= ptr[0]; - matrix[3] *= ptr[0]; - - matrix[4] *= ptr[1]; - matrix[5] *= ptr[1]; - matrix[6] *= ptr[1]; - matrix[7] *= ptr[1]; - - matrix[8] *= ptr[2]; - matrix[9] *= ptr[2]; - matrix[10] *= ptr[2]; - matrix[11] *= ptr[2]; -} - -#endif //switched c/asm functions -//----------------------------------------- - -void MatrixInit (float *matrix) -{ - memset (matrix, 0, sizeof(float)*16); - matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.f; -} - -void MatrixTranspose(float *matrix) -{ - float temp; -#define swap(A,B) temp = matrix[A];matrix[A] = matrix[B]; matrix[B] = temp; - swap(1,4); - swap(2,8); - swap(3,0xC); - swap(6,9); - swap(7,0xD); - swap(0xB,0xE); -#undef swap -} - -void MatrixIdentity (float *matrix) -{ - matrix[1] = matrix[2] = matrix[3] = matrix[4] = 0.0f; - matrix[6] = matrix[7] = matrix[8] = matrix[9] = 0.0f; - matrix[11] = matrix[12] = matrix[13] = matrix[14] = 0.0f; - matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.f; -} - -float MatrixGetMultipliedIndex (int index, float *matrix, float *rightMatrix) -{ - int iMod = index%4, iDiv = (index>>2)<<2; - - return (matrix[iMod ]*rightMatrix[iDiv ])+(matrix[iMod+ 4]*rightMatrix[iDiv+1])+ - (matrix[iMod+8]*rightMatrix[iDiv+2])+(matrix[iMod+12]*rightMatrix[iDiv+3]); -} - -void MatrixSet (float *matrix, int x, int y, float value) // TODO -{ - matrix [x+(y<<2)] = value; -} - -void MatrixCopy (float* matrixDST, const float* matrixSRC) -{ - matrixDST[0] = matrixSRC[0]; - matrixDST[1] = matrixSRC[1]; - matrixDST[2] = matrixSRC[2]; - matrixDST[3] = matrixSRC[3]; - matrixDST[4] = matrixSRC[4]; - matrixDST[5] = matrixSRC[5]; - matrixDST[6] = matrixSRC[6]; - matrixDST[7] = matrixSRC[7]; - matrixDST[8] = matrixSRC[8]; - matrixDST[9] = matrixSRC[9]; - matrixDST[10] = matrixSRC[10]; - matrixDST[11] = matrixSRC[11]; - matrixDST[12] = matrixSRC[12]; - matrixDST[13] = matrixSRC[13]; - matrixDST[14] = matrixSRC[14]; - matrixDST[15] = matrixSRC[15]; - -} - -int MatrixCompare (const float* matrixDST, const float* matrixSRC) -{ - return memcmp((void*)matrixDST, matrixSRC, sizeof(float)*16); -} - -void MatrixStackInit(MatrixStack *stack) -{ - for (int i = 0; i < stack->size; i++) - { - MatrixInit(&stack->matrix[i]); - } - stack->position = 0; -} - -void MatrixStackSetMaxSize (MatrixStack *stack, int size) -{ - int i; - - stack->size = (size + 1); - - if (stack->matrix != NULL) { - free (stack->matrix); - } - stack->matrix = (float*) malloc (stack->size*16*sizeof(float)); - - for (i = 0; i < stack->size; i++) - { - MatrixInit (&stack->matrix[i*16]); - } - - stack->size--; -} - - -MatrixStack::MatrixStack(int size) -{ - MatrixStackSetMaxSize(this,size); -} - -void MatrixStackSetStackPosition (MatrixStack *stack, int pos) -{ - stack->position += pos; - - if (stack->position < 0) - stack->position = 0; - else if (stack->position > stack->size) - stack->position = stack->size+1; -} - -void MatrixStackPushMatrix (MatrixStack *stack, const float *ptr) -{ - MatrixCopy (&stack->matrix[stack->position*16], ptr); - - MatrixStackSetStackPosition (stack, 1); -} - -float * MatrixStackPopMatrix (MatrixStack *stack, int size) -{ - MatrixStackSetStackPosition(stack, -size); - - return &stack->matrix[stack->position*16]; -} - -float * MatrixStackGetPos (MatrixStack *stack, int pos) -{ - assert(pos<31); - return &stack->matrix[pos*16]; -} - -float * MatrixStackGet (MatrixStack *stack) -{ - return &stack->matrix[stack->position*16]; -} - -void MatrixStackLoadMatrix (MatrixStack *stack, int pos, const float *ptr) -{ - assert(pos<31); - MatrixCopy (&stack->matrix[pos*16], ptr); -} - -void Vector2Copy(float *dst, const float *src) -{ - dst[0] = src[0]; - dst[1] = src[1]; -} - -void Vector2Add(float *dst, const float *src) -{ - dst[0] += src[0]; - dst[1] += src[1]; -} - -void Vector2Subtract(float *dst, const float *src) -{ - dst[0] -= src[0]; - dst[1] -= src[1]; -} - -float Vector2Dot(const float *a, const float *b) -{ - return (a[0]*b[0]) + (a[1]*b[1]); -} - -/* http://www.gamedev.net/community/forums/topic.asp?topic_id=289972 */ -float Vector2Cross(const float *a, const float *b) -{ - return (a[0]*b[1]) - (a[1]*b[0]); -} - -float Vector3Dot(const float *a, const float *b) -{ - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; -} - -void Vector3Cross(float* dst, const float *a, const float *b) -{ - dst[0] = a[1]*b[2] - a[2]*b[1]; - dst[1] = a[2]*b[0] - a[0]*b[2]; - dst[2] = a[0]*b[1] - a[1]*b[0]; -} - - -float Vector3Length(const float *a) -{ - float lengthSquared = Vector3Dot(a,a); - float length = sqrt(lengthSquared); - return length; -} - -void Vector3Add(float *dst, const float *src) -{ - dst[0] += src[0]; - dst[1] += src[1]; - dst[2] += src[2]; -} - -void Vector3Subtract(float *dst, const float *src) -{ - dst[0] -= src[0]; - dst[1] -= src[1]; - dst[2] -= src[2]; -} - -void Vector3Scale(float *dst, const float scale) -{ - dst[0] *= scale; - dst[1] *= scale; - dst[2] *= scale; -} - -void Vector3Copy(float *dst, const float *src) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; -} - -void Vector3Normalize(float *dst) -{ - float length = Vector3Length(dst); - Vector3Scale(dst,1.0f/length); -} - -void Vector4Copy(float *dst, const float *src) -{ - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; -} - - +/* + Copyright (C) 2006-2007 shash + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include +#include +#include +#include "matrix.h" + +extern "C" { + + +void MatrixInit (float *matrix) +{ + memset (matrix, 0, sizeof(float)*16); + matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.f; +} + +#ifdef NOSSE2 +void MATRIXFASTCALL MatrixMultVec4x4 (const float *matrix, float *vecPtr) +{ + float x = vecPtr[0]; + float y = vecPtr[1]; + float z = vecPtr[2]; + float w = vecPtr[3]; + + vecPtr[0] = x * matrix[0] + y * matrix[4] + z * matrix[ 8] + w * matrix[12]; + vecPtr[1] = x * matrix[1] + y * matrix[5] + z * matrix[ 9] + w * matrix[13]; + vecPtr[2] = x * matrix[2] + y * matrix[6] + z * matrix[10] + w * matrix[14]; + vecPtr[3] = x * matrix[3] + y * matrix[7] + z * matrix[11] + w * matrix[15]; +} + +void MATRIXFASTCALL MatrixMultVec3x3 (const float *matrix, float *vecPtr) +{ + float x = vecPtr[0]; + float y = vecPtr[1]; + float z = vecPtr[2]; + + vecPtr[0] = x * matrix[0] + y * matrix[4] + z * matrix[ 8]; + vecPtr[1] = x * matrix[1] + y * matrix[5] + z * matrix[ 9]; + vecPtr[2] = x * matrix[2] + y * matrix[6] + z * matrix[10]; +} + +void MATRIXFASTCALL MatrixMultiply (float *matrix, const float *rightMatrix) +{ + float tmpMatrix[16]; + + tmpMatrix[0] = (matrix[0]*rightMatrix[0])+(matrix[4]*rightMatrix[1])+(matrix[8]*rightMatrix[2])+(matrix[12]*rightMatrix[3]); + tmpMatrix[1] = (matrix[1]*rightMatrix[0])+(matrix[5]*rightMatrix[1])+(matrix[9]*rightMatrix[2])+(matrix[13]*rightMatrix[3]); + tmpMatrix[2] = (matrix[2]*rightMatrix[0])+(matrix[6]*rightMatrix[1])+(matrix[10]*rightMatrix[2])+(matrix[14]*rightMatrix[3]); + tmpMatrix[3] = (matrix[3]*rightMatrix[0])+(matrix[7]*rightMatrix[1])+(matrix[11]*rightMatrix[2])+(matrix[15]*rightMatrix[3]); + + tmpMatrix[4] = (matrix[0]*rightMatrix[4])+(matrix[4]*rightMatrix[5])+(matrix[8]*rightMatrix[6])+(matrix[12]*rightMatrix[7]); + tmpMatrix[5] = (matrix[1]*rightMatrix[4])+(matrix[5]*rightMatrix[5])+(matrix[9]*rightMatrix[6])+(matrix[13]*rightMatrix[7]); + tmpMatrix[6] = (matrix[2]*rightMatrix[4])+(matrix[6]*rightMatrix[5])+(matrix[10]*rightMatrix[6])+(matrix[14]*rightMatrix[7]); + tmpMatrix[7] = (matrix[3]*rightMatrix[4])+(matrix[7]*rightMatrix[5])+(matrix[11]*rightMatrix[6])+(matrix[15]*rightMatrix[7]); + + tmpMatrix[8] = (matrix[0]*rightMatrix[8])+(matrix[4]*rightMatrix[9])+(matrix[8]*rightMatrix[10])+(matrix[12]*rightMatrix[11]); + tmpMatrix[9] = (matrix[1]*rightMatrix[8])+(matrix[5]*rightMatrix[9])+(matrix[9]*rightMatrix[10])+(matrix[13]*rightMatrix[11]); + tmpMatrix[10] = (matrix[2]*rightMatrix[8])+(matrix[6]*rightMatrix[9])+(matrix[10]*rightMatrix[10])+(matrix[14]*rightMatrix[11]); + tmpMatrix[11] = (matrix[3]*rightMatrix[8])+(matrix[7]*rightMatrix[9])+(matrix[11]*rightMatrix[10])+(matrix[15]*rightMatrix[11]); + + tmpMatrix[12] = (matrix[0]*rightMatrix[12])+(matrix[4]*rightMatrix[13])+(matrix[8]*rightMatrix[14])+(matrix[12]*rightMatrix[15]); + tmpMatrix[13] = (matrix[1]*rightMatrix[12])+(matrix[5]*rightMatrix[13])+(matrix[9]*rightMatrix[14])+(matrix[13]*rightMatrix[15]); + tmpMatrix[14] = (matrix[2]*rightMatrix[12])+(matrix[6]*rightMatrix[13])+(matrix[10]*rightMatrix[14])+(matrix[14]*rightMatrix[15]); + tmpMatrix[15] = (matrix[3]*rightMatrix[12])+(matrix[7]*rightMatrix[13])+(matrix[11]*rightMatrix[14])+(matrix[15]*rightMatrix[15]); + + memcpy (matrix, tmpMatrix, sizeof(float)*16); +} + +void MATRIXFASTCALL MatrixTranslate (float *matrix, const float *ptr) +{ + matrix[12] += (matrix[0]*ptr[0])+(matrix[4]*ptr[1])+(matrix[ 8]*ptr[2]); + matrix[13] += (matrix[1]*ptr[0])+(matrix[5]*ptr[1])+(matrix[ 9]*ptr[2]); + matrix[14] += (matrix[2]*ptr[0])+(matrix[6]*ptr[1])+(matrix[10]*ptr[2]); + matrix[15] += (matrix[3]*ptr[0])+(matrix[7]*ptr[1])+(matrix[11]*ptr[2]); +} + +void MATRIXFASTCALL MatrixScale (float *matrix, const float *ptr) +{ + matrix[0] *= ptr[0]; + matrix[1] *= ptr[0]; + matrix[2] *= ptr[0]; + matrix[3] *= ptr[0]; + + matrix[4] *= ptr[1]; + matrix[5] *= ptr[1]; + matrix[6] *= ptr[1]; + matrix[7] *= ptr[1]; + + matrix[8] *= ptr[2]; + matrix[9] *= ptr[2]; + matrix[10] *= ptr[2]; + matrix[11] *= ptr[2]; +} +#endif //switched c/asm functions +//----------------------------------------- + +void MatrixTranspose(float *matrix) +{ + float temp; +#define swap(A,B) temp = matrix[A];matrix[A] = matrix[B]; matrix[B] = temp; + swap(1,4); + swap(2,8); + swap(3,0xC); + swap(6,9); + swap(7,0xD); + swap(0xB,0xE); +#undef swap +} + +void MATRIXFASTCALL MatrixIdentity (float *matrix) +{ + matrix[1] = matrix[2] = matrix[3] = matrix[4] = 0.0f; + matrix[6] = matrix[7] = matrix[8] = matrix[9] = 0.0f; + matrix[11] = matrix[12] = matrix[13] = matrix[14] = 0.0f; + matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.f; +} + +float MATRIXFASTCALL MatrixGetMultipliedIndex (int index, float *matrix, float *rightMatrix) +{ + int iMod = index%4, iDiv = (index>>2)<<2; + + return (matrix[iMod ]*rightMatrix[iDiv ])+(matrix[iMod+ 4]*rightMatrix[iDiv+1])+ + (matrix[iMod+8]*rightMatrix[iDiv+2])+(matrix[iMod+12]*rightMatrix[iDiv+3]); +} + +void MATRIXFASTCALL MatrixSet (float *matrix, int x, int y, float value) // TODO +{ + matrix [x+(y<<2)] = value; +} + +void MATRIXFASTCALL MatrixCopy (float* matrixDST, const float* matrixSRC) +{ + matrixDST[0] = matrixSRC[0]; + matrixDST[1] = matrixSRC[1]; + matrixDST[2] = matrixSRC[2]; + matrixDST[3] = matrixSRC[3]; + matrixDST[4] = matrixSRC[4]; + matrixDST[5] = matrixSRC[5]; + matrixDST[6] = matrixSRC[6]; + matrixDST[7] = matrixSRC[7]; + matrixDST[8] = matrixSRC[8]; + matrixDST[9] = matrixSRC[9]; + matrixDST[10] = matrixSRC[10]; + matrixDST[11] = matrixSRC[11]; + matrixDST[12] = matrixSRC[12]; + matrixDST[13] = matrixSRC[13]; + matrixDST[14] = matrixSRC[14]; + matrixDST[15] = matrixSRC[15]; + +} + +int MATRIXFASTCALL MatrixCompare (const float* matrixDST, const float* matrixSRC) +{ + return memcmp((void*)matrixDST, matrixSRC, sizeof(float)*16); +} + +void MatrixStackSetMaxSize (MatrixStack *stack, int size) +{ + int i; + + stack->size = size; + + if (stack->matrix != NULL) { + free (stack->matrix); + } + stack->matrix = (float*) malloc (stack->size*16*sizeof(float)); + + for (i = 0; i < stack->size; i++) + { + MatrixInit (&stack->matrix[i*16]); + } + + stack->size--; +} + + +MatrixStack::MatrixStack(int size) +{ + MatrixStackSetMaxSize(this,size); +} + +void MatrixStackSetStackPosition (MatrixStack *stack, int pos) +{ + stack->position += pos; + + if (stack->position < 0) + stack->position = 0; + else if (stack->position > stack->size) + stack->position = stack->size+1; +} + +void MatrixStackPushMatrix (MatrixStack *stack, const float *ptr) +{ + MatrixCopy (&stack->matrix[stack->position*16], ptr); + + MatrixStackSetStackPosition (stack, 1); +} + +float * MatrixStackPopMatrix (MatrixStack *stack, int size) +{ + MatrixStackSetStackPosition(stack, -size); + + return &stack->matrix[stack->position*16]; +} + +float * MatrixStackGetPos (MatrixStack *stack, int pos) +{ + assert(pos<31); + return &stack->matrix[pos*16]; +} + +float * MatrixStackGet (MatrixStack *stack) +{ + return &stack->matrix[stack->position*16]; +} + +void MatrixStackLoadMatrix (MatrixStack *stack, int pos, const float *ptr) +{ + assert(pos<31); + MatrixCopy (&stack->matrix[pos*16], ptr); +} + +void Vector2Copy(float *dst, const float *src) +{ + dst[0] = src[0]; + dst[1] = src[1]; +} + +void Vector2Add(float *dst, const float *src) +{ + dst[0] += src[0]; + dst[1] += src[1]; +} + +void Vector2Subtract(float *dst, const float *src) +{ + dst[0] -= src[0]; + dst[1] -= src[1]; +} + +float Vector2Dot(const float *a, const float *b) +{ + return (a[0]*b[0]) + (a[1]*b[1]); +} + +/* http://www.gamedev.net/community/forums/topic.asp?topic_id=289972 */ +float Vector2Cross(const float *a, const float *b) +{ + return (a[0]*b[1]) - (a[1]*b[0]); +} + +float Vector3Dot(const float *a, const float *b) +{ + return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; +} + +void Vector3Cross(float* dst, const float *a, const float *b) +{ + dst[0] = a[1]*b[2] - a[2]*b[1]; + dst[1] = a[2]*b[0] - a[0]*b[2]; + dst[2] = a[0]*b[1] - a[1]*b[0]; +} + + +float Vector3Length(const float *a) +{ + float lengthSquared = Vector3Dot(a,a); + float length = sqrt(lengthSquared); + return length; +} + +void Vector3Add(float *dst, const float *src) +{ + dst[0] += src[0]; + dst[1] += src[1]; + dst[2] += src[2]; +} + +void Vector3Subtract(float *dst, const float *src) +{ + dst[0] -= src[0]; + dst[1] -= src[1]; + dst[2] -= src[2]; +} + +void Vector3Scale(float *dst, const float scale) +{ + dst[0] *= scale; + dst[1] *= scale; + dst[2] *= scale; +} + +void Vector3Copy(float *dst, const float *src) +{ + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; +} + +void Vector3Normalize(float *dst) +{ + float length = Vector3Length(dst); + Vector3Scale(dst,1.0f/length); +} + +void Vector4Copy(float *dst, const float *src) +{ + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = src[2]; + dst[3] = src[3]; +} + +} //extern "C" + diff --git a/src/matrix.h b/src/matrix.h new file mode 100644 index 000000000..f4e00baa9 --- /dev/null +++ b/src/matrix.h @@ -0,0 +1,146 @@ +/* + Copyright (C) 2006-2007 shash + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef MATRIX_H +#define MATRIX_H + +#include + +#include "types.h" + +extern "C" { + +struct MatrixStack +{ + MatrixStack(int size); + float *matrix; + int position; + int size; +}; + +void MatrixInit (float *matrix); + +#if defined(_MSC_VER) || defined(__INTEL_COMPILER) +#define MATRIXFASTCALL __fastcall +#else +#define MATRIXFASTCALL +#endif + +//In order to conditionally use these asm optimized functions in visual studio +//without having to make new build types to exclude the assembly files. +//a bit sloppy, but there aint much to it +#ifndef NOSSE2 +#define SSE2_FUNC(X) _sse2_##X +#define MatrixMultVec4x4 _sse2_MatrixMultVec4x4 +#define MatrixMultVec3x3 _sse2_MatrixMultVec3x3 +#define MatrixMultiply _sse2_MatrixMultiply +#define MatrixTranslate _sse2_MatrixTranslate +#define MatrixScale _sse2_MatrixScale +void MATRIXFASTCALL _sse2_fix2float_16 (float* matrix, float* divizor_mask); +void MATRIXFASTCALL _sse2_fix2float_12 (float* matrix, float* divizor_mask); +void MATRIXFASTCALL _sse2_MatrixMultVec4x4_M2 (const float * matrix, float * vecPtr); // mode 2 +#else +#define SSE2_FUNC(X) X +#endif + +void MATRIXFASTCALL SSE2_FUNC(MatrixMultVec3x3) (const float * matrix, float * vecPtr); +void MATRIXFASTCALL SSE2_FUNC(MatrixMultVec4x4) (const float * matrix, float * vecPtr); +void MATRIXFASTCALL SSE2_FUNC(MatrixMultiply) (float * matrix, const float * rightMatrix); +void MATRIXFASTCALL SSE2_FUNC(MatrixTranslate) (float *matrix, const float *ptr); +void MATRIXFASTCALL SSE2_FUNC(MatrixScale) (float * matrix, const float * ptr); + + + +float MATRIXFASTCALL MatrixGetMultipliedIndex (int index, float *matrix, float *rightMatrix); +void MATRIXFASTCALL MatrixSet (float *matrix, int x, int y, float value); +void MATRIXFASTCALL MatrixCopy (float * matrixDST, const float * matrixSRC); +int MATRIXFASTCALL MatrixCompare (const float * matrixDST, const float * matrixSRC); +void MATRIXFASTCALL MatrixIdentity (float *matrix); + +void MatrixTranspose (float *matrix); +void MatrixStackInit (MatrixStack *stack); +void MatrixStackSetMaxSize (MatrixStack *stack, int size); +void MatrixStackSetStackPosition (MatrixStack *stack, int pos); +void MatrixStackPushMatrix (MatrixStack *stack, const float *ptr); +float* MatrixStackPopMatrix (MatrixStack *stack, int size); +float* MatrixStackGetPos (MatrixStack *stack, int pos); +float* MatrixStackGet (MatrixStack *stack); +void MatrixStackLoadMatrix (MatrixStack *stack, int pos, const float *ptr); + +void Vector2Copy(float *dst, const float *src); +void Vector2Add(float *dst, const float *src); +void Vector2Subtract(float *dst, const float *src); +float Vector2Dot(const float *a, const float *b); +float Vector2Cross(const float *a, const float *b); + +float Vector3Dot(const float *a, const float *b); +void Vector3Cross(float* dst, const float *a, const float *b); +float Vector3Length(const float *a); +void Vector3Add(float *dst, const float *src); +void Vector3Subtract(float *dst, const float *src); +void Vector3Scale(float *dst, const float scale); +void Vector3Copy(float *dst, const float *src); +void Vector3Normalize(float *dst); + +void Vector4Copy(float *dst, const float *src); + +} //extern "C" + +//these functions are an unreliable, inaccurate floor. +//it should only be used for positive numbers +//this isnt as fast as it could be if we used a visual c++ intrinsic, but those appear not to be universally available +FORCEINLINE u32 u32floor(float f) +{ +#ifndef NOSSE2 + __asm cvttss2si eax, f; +#else + return (u32)f; +#endif +} +FORCEINLINE u32 u32floor(double d) +{ +#ifndef NOSSE2 + __asm cvttsd2si eax, d; +#else + return (u32)d; +#endif +} + +//same as above but works for negative values too. +//be sure that the results are the same thing as floorf! +FORCEINLINE s32 s32floor(float f) +{ +#ifndef NOSSE2 + static const float c = -0.5f; + __asm + { + movss xmm0, f; + addss xmm0, xmm0; + addss xmm0, c; + cvtss2si eax, xmm0 + sar eax, 1 + } +#else + return (s32)floorf(f); +#endif +} + + +#endif diff --git a/src/matrix_sse2-x64.asm b/src/matrix_sse2-x64.asm new file mode 100644 index 000000000..ffbeb7a2f --- /dev/null +++ b/src/matrix_sse2-x64.asm @@ -0,0 +1,182 @@ +; +; Copyright (C) 2006 yopyop +; Copyright (C) 2008 CrazyMax +; +; This file is part of DeSmuME +; +; DeSmuME is free software; you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation; either version 2 of the License, or +; (at your option) any later version. +; +; DeSmuME is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with DeSmuME; if not, write to the Free Software +; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + TITLE matrix_sse2-x64.asm + .code + +_sse2_MatrixMultVec4x4 PROC PUBLIC + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rcx+16] + movaps xmm2, XMMWORD PTR [rcx+32] + movaps xmm3, XMMWORD PTR [rcx+48] + movaps xmm4, XMMWORD PTR [rdx] + movaps xmm5, xmm4 + movaps xmm6, xmm4 + movaps xmm7, xmm4 + shufps xmm4, xmm4, 00000000b + shufps xmm5, xmm5, 01010101b + shufps xmm6, xmm6, 10101010b + shufps xmm7, xmm7, 11111111b + mulps xmm4, xmm0 + mulps xmm5, xmm1 + mulps xmm6, xmm2 + mulps xmm7, xmm3 + addps xmm4, xmm5 + addps xmm4, xmm6 + addps xmm4, xmm7 + movaps XMMWORD PTR [rdx], xmm4 + ret 0 +_sse2_MatrixMultVec4x4 ENDP + +_sse2_MatrixMultVec3x3 PROC PUBLIC + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rcx+16] + movaps xmm2, XMMWORD PTR [rcx+32] + movaps xmm4, XMMWORD PTR [rdx] + movaps xmm5, xmm4 + movaps xmm6, xmm4 + movaps xmm7, xmm4 + shufps xmm4, xmm4, 00000000b + shufps xmm5, xmm5, 01010101b + shufps xmm6, xmm6, 10101010b + mulps xmm4, xmm0 + mulps xmm5, xmm1 + mulps xmm6, xmm2 + addps xmm4, xmm5 + addps xmm4, xmm6 + movaps XMMWORD PTR [rdx], xmm4 + ret 0 +_sse2_MatrixMultVec3x3 ENDP + +_sse2_MatrixMultiply PROC PUBLIC + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rcx+16] + movaps xmm2, XMMWORD PTR [rcx+32] + movaps xmm3, XMMWORD PTR [rcx+48] + movaps xmm4, XMMWORD PTR [rdx] ; r00, r01, r02, r03 + movaps xmm8, XMMWORD PTR [rdx+16] ; r04, r05, r06, r07 + movaps xmm5,xmm4 + movaps xmm6,xmm4 + movaps xmm7,xmm4 + movaps xmm9,xmm8 ; + movaps xmm10,xmm8 + movaps xmm11,xmm8 + shufps xmm4,xmm4,00000000b + shufps xmm5,xmm5,01010101b + shufps xmm6,xmm6,10101010b + shufps xmm7,xmm7,11111111b + shufps xmm8, xmm8, 00000000b ; + shufps xmm9, xmm9, 01010101b + shufps xmm10,xmm10,10101010b + shufps xmm11,xmm11,11111111b + mulps xmm4,xmm0 + mulps xmm5,xmm1 + mulps xmm6,xmm2 + mulps xmm7,xmm3 + mulps xmm8, xmm0 ; + mulps xmm9, xmm1 + mulps xmm10,xmm2 + mulps xmm11,xmm3 + addps xmm4,xmm5 + addps xmm4,xmm6 + addps xmm4,xmm7 + addps xmm8,xmm9 ; + addps xmm8,xmm10 + addps xmm8,xmm11 + movaps XMMWORD PTR [rcx],xmm4 + movaps XMMWORD PTR [rcx+16],xmm8 + + movaps xmm4, XMMWORD PTR [rdx+32] ; r00, r01, r02, r03 + movaps xmm8, XMMWORD PTR [rdx+48] ; r04, r05, r06, r07 + movaps xmm5,xmm4 + movaps xmm6,xmm4 + movaps xmm7,xmm4 + movaps xmm9,xmm8 ; + movaps xmm10,xmm8 + movaps xmm11,xmm8 + shufps xmm4,xmm4,00000000b + shufps xmm5,xmm5,01010101b + shufps xmm6,xmm6,10101010b + shufps xmm7,xmm7,11111111b + shufps xmm8, xmm8, 00000000b ; + shufps xmm9, xmm9, 01010101b + shufps xmm10,xmm10,10101010b + shufps xmm11,xmm11,11111111b + mulps xmm4,xmm0 + mulps xmm5,xmm1 + mulps xmm6,xmm2 + mulps xmm7,xmm3 + mulps xmm8, xmm0 ; + mulps xmm9, xmm1 + mulps xmm10,xmm2 + mulps xmm11,xmm3 + addps xmm4,xmm5 + addps xmm4,xmm6 + addps xmm4,xmm7 + addps xmm8,xmm9 ; + addps xmm8,xmm10 + addps xmm8,xmm11 + movaps XMMWORD PTR [rcx+32],xmm4 + movaps XMMWORD PTR [rcx+48],xmm8 + ret 0 +_sse2_MatrixMultiply ENDP + +_sse2_MatrixTranslate PROC PUBLIC + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rcx+16] + movaps xmm2, XMMWORD PTR [rcx+32] + movaps xmm3, XMMWORD PTR [rcx+48] + movaps xmm4, XMMWORD PTR [rdx] + movaps xmm5, xmm4 + movaps xmm6, xmm4 + movaps xmm7, xmm4 + shufps xmm4, xmm4, 00000000b + shufps xmm5, xmm5, 01010101b + shufps xmm6, xmm6, 10101010b + mulps xmm4, xmm0 + mulps xmm5, xmm1 + mulps xmm6, xmm2 + addps xmm4, xmm5 + addps xmm4, xmm6 + addps xmm4, xmm3 + movaps XMMWORD PTR [rcx+48], xmm4 + ret 0 +_sse2_MatrixTranslate ENDP + +_sse2_MatrixScale PROC PUBLIC + movaps xmm0, XMMWORD PTR [rcx] + movaps xmm1, XMMWORD PTR [rcx+16] + movaps xmm2, XMMWORD PTR [rcx+32] + movaps xmm4, XMMWORD PTR [rdx] + movaps xmm5, xmm4 + movaps xmm6, xmm4 + shufps xmm4, xmm4, 00000000b + shufps xmm5, xmm5, 01010101b + shufps xmm6, xmm6, 10101010b + mulps xmm4, xmm0 + mulps xmm5, xmm1 + mulps xmm6, xmm2 + movaps XMMWORD PTR [rcx],xmm4 + movaps XMMWORD PTR [rcx+16],xmm5 + movaps XMMWORD PTR [rcx+32],xmm6 + ret 0 +_sse2_MatrixScale ENDP + +end diff --git a/src/matrix_sse2-x86.asm b/src/matrix_sse2-x86.asm new file mode 100644 index 000000000..4f2ddf30e --- /dev/null +++ b/src/matrix_sse2-x86.asm @@ -0,0 +1,214 @@ +; +; Copyright (C) 2006 yopyop +; Copyright (C) 2008 CrazyMax +; +; This file is part of DeSmuME +; +; DeSmuME is free software; you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation; either version 2 of the License, or +; (at your option) any later version. +; +; DeSmuME is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with DeSmuME; if not, write to the Free Software +; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + TITLE matrix_sse2-x86.asm + .686P + .XMM + .model flat + .code + +@_sse2_MatrixMultVec4x4@8 PROC PUBLIC + movaps xmm4, XMMWORD PTR [edx] + pshufd xmm5, xmm4, 01010101b + pshufd xmm6, xmm4, 10101010b + pshufd xmm7, xmm4, 11111111b + shufps xmm4, xmm4, 00000000b + mulps xmm4, XMMWORD PTR [ecx] + mulps xmm5, XMMWORD PTR [ecx+16] + mulps xmm6, XMMWORD PTR [ecx+32] + mulps xmm7, XMMWORD PTR [ecx+48] + addps xmm4, xmm5 + addps xmm4, xmm6 + addps xmm4, xmm7 + movaps XMMWORD PTR [edx], xmm4 + ret 0 +@_sse2_MatrixMultVec4x4@8 ENDP + +@_sse2_MatrixMultVec4x4_M2@8 PROC PUBLIC + movaps xmm4, XMMWORD PTR [edx] + pshufd xmm5, xmm4, 01010101b + pshufd xmm6, xmm4, 10101010b + pshufd xmm7, xmm4, 11111111b + shufps xmm4, xmm4, 00000000b + mulps xmm4, XMMWORD PTR [ecx+64] + mulps xmm5, XMMWORD PTR [ecx+80] + mulps xmm6, XMMWORD PTR [ecx+96] + mulps xmm7, XMMWORD PTR [ecx+112] + addps xmm4, xmm5 + addps xmm4, xmm6 + addps xmm4, xmm7 + pshufd xmm5, xmm4, 01010101b + pshufd xmm6, xmm4, 10101010b + pshufd xmm7, xmm4, 11111111b + shufps xmm4, xmm4, 00000000b + mulps xmm4, XMMWORD PTR [ecx] + mulps xmm5, XMMWORD PTR [ecx+16] + mulps xmm6, XMMWORD PTR [ecx+32] + mulps xmm7, XMMWORD PTR [ecx+48] + addps xmm4, xmm5 + addps xmm4, xmm6 + addps xmm4, xmm7 + movaps XMMWORD PTR [edx], xmm4 + ret 0 +@_sse2_MatrixMultVec4x4_M2@8 ENDP + + +@_sse2_MatrixMultVec3x3@8 PROC PUBLIC + movaps xmm4, XMMWORD PTR [edx] + pshufd xmm5, xmm4, 01010101b + pshufd xmm6, xmm4, 10101010b + shufps xmm4, xmm4, 00000000b + mulps xmm4, XMMWORD PTR [ecx] + mulps xmm5, XMMWORD PTR [ecx+16] + mulps xmm6, XMMWORD PTR [ecx+32] + addps xmm4, xmm5 + addps xmm4, xmm6 + movaps XMMWORD PTR [edx], xmm4 + ret 0 +@_sse2_MatrixMultVec3x3@8 ENDP + +@_sse2_MatrixMultiply@8 PROC PUBLIC + movaps xmm0, XMMWORD PTR [ecx] + movaps xmm1, XMMWORD PTR [ecx+16] + movaps xmm2, XMMWORD PTR [ecx+32] + movaps xmm3, XMMWORD PTR [ecx+48] + movaps xmm4, XMMWORD PTR [edx] ; r00, r01, r02, r03 + pshufd xmm5, xmm4, 01010101b + pshufd xmm6, xmm4, 10101010b + pshufd xmm7, xmm4, 11111111b + shufps xmm4, xmm4, 00000000b + mulps xmm4,xmm0 + mulps xmm5,xmm1 + mulps xmm6,xmm2 + mulps xmm7,xmm3 + addps xmm4,xmm5 + addps xmm4,xmm6 + addps xmm4,xmm7 + movaps XMMWORD PTR [ecx],xmm4 + + movaps xmm4, XMMWORD PTR [edx+16] ; r04, r05, r06, r07 + pshufd xmm5, xmm4, 01010101b + pshufd xmm6, xmm4, 10101010b + pshufd xmm7, xmm4, 11111111b + shufps xmm4, xmm4, 00000000b + mulps xmm4,xmm0 + mulps xmm5,xmm1 + mulps xmm6,xmm2 + mulps xmm7,xmm3 + addps xmm4,xmm5 + addps xmm4,xmm6 + addps xmm4,xmm7 + movaps XMMWORD PTR [ecx+16],xmm4 + + movaps xmm4, XMMWORD PTR [edx+32] ; r08, r09, r10, r11 + pshufd xmm5, xmm4, 01010101b + pshufd xmm6, xmm4, 10101010b + pshufd xmm7, xmm4, 11111111b + shufps xmm4, xmm4, 00000000b + mulps xmm4,xmm0 + mulps xmm5,xmm1 + mulps xmm6,xmm2 + mulps xmm7,xmm3 + addps xmm4,xmm5 + addps xmm4,xmm6 + addps xmm4,xmm7 + movaps XMMWORD PTR [ecx+32],xmm4 + + movaps xmm4, XMMWORD PTR [edx+48] ; r12, r13, r14, r15 + pshufd xmm5, xmm4, 01010101b + pshufd xmm6, xmm4, 10101010b + pshufd xmm7, xmm4, 11111111b + shufps xmm4, xmm4, 00000000b + mulps xmm4,xmm0 + mulps xmm5,xmm1 + mulps xmm6,xmm2 + mulps xmm7,xmm3 + addps xmm4,xmm5 + addps xmm4,xmm6 + addps xmm4,xmm7 + movaps XMMWORD PTR [ecx+48],xmm4 + + ret 0 +@_sse2_MatrixMultiply@8 ENDP + +@_sse2_MatrixTranslate@8 PROC PUBLIC + movaps xmm4, XMMWORD PTR [edx] + pshufd xmm5, xmm4, 01010101b + pshufd xmm6, xmm4, 10101010b + shufps xmm4, xmm4, 00000000b + mulps xmm4, XMMWORD PTR [ecx] + mulps xmm5, XMMWORD PTR [ecx+16] + mulps xmm6, XMMWORD PTR [ecx+32] + addps xmm4, xmm5 + addps xmm4, xmm6 + addps xmm4, XMMWORD PTR [ecx+48] + movaps XMMWORD PTR [ecx+48], xmm4 + ret 0 +@_sse2_MatrixTranslate@8 ENDP + +@_sse2_MatrixScale@8 PROC PUBLIC + movaps xmm4, XMMWORD PTR [edx] + pshufd xmm5, xmm4, 01010101b + pshufd xmm6, xmm4, 10101010b + shufps xmm4, xmm4, 00000000b + mulps xmm4, XMMWORD PTR [ecx] + mulps xmm5, XMMWORD PTR [ecx+16] + mulps xmm6, XMMWORD PTR [ecx+32] + movaps XMMWORD PTR [ecx], xmm4 + movaps XMMWORD PTR [ecx+16], xmm5 + movaps XMMWORD PTR [ecx+32], xmm6 + ret 0 +@_sse2_MatrixScale@8 ENDP + +@_sse2_fix2float_12@8 PROC PUBLIC + movaps xmm0, XMMWORD PTR[ecx] + movaps xmm1, XMMWORD PTR[ecx+16] + movaps xmm2, XMMWORD PTR[ecx+32] + movaps xmm4, XMMWORD PTR [edx] + ;prefetchnta [ecx+64] + divps xmm0, xmm4 + divps xmm1, xmm4 + divps xmm2, xmm4 + movaps XMMWORD PTR[ecx], xmm0 + movaps XMMWORD PTR[ecx+16],xmm1 + movaps XMMWORD PTR[ecx+32],xmm2 + ret 0 +@_sse2_fix2float_12@8 ENDP + +@_sse2_fix2float_16@8 PROC PUBLIC + movaps xmm0, XMMWORD PTR[ecx] + movaps xmm1, XMMWORD PTR[ecx+16] + movaps xmm2, XMMWORD PTR[ecx+32] + movaps xmm3, XMMWORD PTR[ecx+48] + movaps xmm4, XMMWORD PTR [edx] + ;prefetchnta [ecx+64] + divps xmm0, xmm4 + divps xmm1, xmm4 + divps xmm2, xmm4 + divps xmm3, xmm4 + movaps XMMWORD PTR[ecx], xmm0 + movaps XMMWORD PTR[ecx+16],xmm1 + movaps XMMWORD PTR[ecx+32],xmm2 + movaps XMMWORD PTR[ecx+48],xmm3 + ret 0 +@_sse2_fix2float_16@8 ENDP + +end + diff --git a/desmume/src/mc.cpp b/src/mc.cpp similarity index 82% rename from desmume/src/mc.cpp rename to src/mc.cpp index 7f37d7a44..f6912c793 100644 --- a/desmume/src/mc.cpp +++ b/src/mc.cpp @@ -1,998 +1,820 @@ -/* Copyright (C) 2006 thoduv - Copyright (C) 2006-2007 Theo Berkau - Copyright (C) 2008-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include "debug.h" -#include "types.h" -#include "mc.h" -#include "movie.h" -#include "readwrite.h" -#include "NDSSystem.h" - -//temporary hack until we have better error reporting facilities -#ifdef _MSC_VER -#include -#endif - -#define FW_CMD_READ 0x3 -#define FW_CMD_WRITEDISABLE 0x4 -#define FW_CMD_READSTATUS 0x5 -#define FW_CMD_WRITEENABLE 0x6 -#define FW_CMD_PAGEWRITE 0xA - -#define BM_CMD_AUTODETECT 0xFF -#define BM_CMD_WRITESTATUS 0x1 -#define BM_CMD_WRITELOW 0x2 -#define BM_CMD_READLOW 0x3 -#define BM_CMD_WRITEDISABLE 0x4 -#define BM_CMD_READSTATUS 0x5 -#define BM_CMD_WRITEENABLE 0x6 -#define BM_CMD_WRITEHIGH 0xA -#define BM_CMD_READHIGH 0xB - -/* FLASH*/ -#define COMM_PAGE_WRITE 0x0A -#define COMM_PAGE_ERASE 0xDB -#define COMM_SECTOR_ERASE 0xD8 -#define COMM_CHIP_ERASE 0xC7 -#define CARDFLASH_READ_BYTES_FAST 0x0B /* Not used*/ -#define CARDFLASH_DEEP_POWDOWN 0xB9 /* Not used*/ -#define CARDFLASH_WAKEUP 0xAB /* Not used*/ - -//this should probably be 0xFF but we're using 0x00 until we find out otherwise -//(no$ appears definitely to initialized to 0xFF) -static const u8 kUninitializedSaveDataValue = 0x00; - -static const char* kDesmumeSaveCookie = "|-DESMUME SAVE-|"; - -static const u32 saveSizes[] = {512,8*1024,32*1024,64*1024,256*1024,512*1024,0xFFFFFFFF}; -static const u32 saveSizes_count = ARRAY_SIZE(saveSizes); - -//the lookup table from user save types to save parameters -static const int save_types[7][2] = { - {MC_TYPE_AUTODETECT,1}, - {MC_TYPE_EEPROM1,MC_SIZE_4KBITS}, - {MC_TYPE_EEPROM2,MC_SIZE_64KBITS}, - {MC_TYPE_EEPROM2,MC_SIZE_512KBITS}, - {MC_TYPE_FRAM,MC_SIZE_256KBITS}, - {MC_TYPE_FLASH,MC_SIZE_2MBITS}, - {MC_TYPE_FLASH,MC_SIZE_4MBITS} -}; - -void backup_setManualBackupType(int type) -{ - CommonSettings.manualBackupType = type; -} - -void mc_init(memory_chip_t *mc, int type) -{ - mc->com = 0; - mc->addr = 0; - mc->addr_shift = 0; - mc->data = NULL; - mc->size = 0; - mc->write_enable = FALSE; - mc->writeable_buffer = FALSE; - mc->type = type; - mc->autodetectsize = 0; - - switch(mc->type) - { - case MC_TYPE_EEPROM1: - mc->addr_size = 1; - break; - case MC_TYPE_EEPROM2: - case MC_TYPE_FRAM: - mc->addr_size = 2; - break; - case MC_TYPE_FLASH: - mc->addr_size = 3; - break; - default: break; - } -} - -u8 *mc_alloc(memory_chip_t *mc, u32 size) -{ - u8 *buffer; - buffer = new u8[size]; - memset(buffer,0,size); - - mc->data = buffer; - if(!buffer) { return NULL; } - mc->size = size; - mc->writeable_buffer = TRUE; - - return buffer; -} - -void mc_free(memory_chip_t *mc) -{ - if(mc->data) delete[] mc->data; - mc_init(mc, 0); -} - -void fw_reset_com(memory_chip_t *mc) -{ - if(mc->com == FW_CMD_PAGEWRITE) - { - if (mc->fp) - { - fseek(mc->fp, 0, SEEK_SET); - fwrite(mc->data, mc->size, 1, mc->fp); - } - - mc->write_enable = FALSE; - } - - mc->com = 0; -} - -u8 fw_transfer(memory_chip_t *mc, u8 data) -{ - if(mc->com == FW_CMD_READ || mc->com == FW_CMD_PAGEWRITE) /* check if we are in a command that needs 3 bytes address */ - { - if(mc->addr_shift > 0) /* if we got a complete address */ - { - mc->addr_shift--; - mc->addr |= data << (mc->addr_shift * 8); /* argument is a byte of address */ - } - else /* if we have received 3 bytes of address, proceed command */ - { - switch(mc->com) - { - case FW_CMD_READ: - if(mc->addr < mc->size) /* check if we can read */ - { - data = mc->data[mc->addr]; /* return byte */ - mc->addr++; /* then increment address */ - } - break; - - case FW_CMD_PAGEWRITE: - if(mc->addr < mc->size) - { - mc->data[mc->addr] = data; /* write byte */ - mc->addr++; - } - break; - } - - } - } - else if(mc->com == FW_CMD_READSTATUS) - { - return (mc->write_enable ? 0x02 : 0x00); - } - else /* finally, check if it's a new command */ - { - switch(data) - { - case 0: break; /* nothing */ - - case FW_CMD_READ: /* read command */ - mc->addr = 0; - mc->addr_shift = 3; - mc->com = FW_CMD_READ; - break; - - case FW_CMD_WRITEENABLE: /* enable writing */ - if(mc->writeable_buffer) { mc->write_enable = TRUE; } - break; - - case FW_CMD_WRITEDISABLE: /* disable writing */ - mc->write_enable = FALSE; - break; - - case FW_CMD_PAGEWRITE: /* write command */ - if(mc->write_enable) - { - mc->addr = 0; - mc->addr_shift = 3; - mc->com = FW_CMD_PAGEWRITE; - } - else { data = 0; } - break; - - case FW_CMD_READSTATUS: /* status register command */ - mc->com = FW_CMD_READSTATUS; - break; - - default: - printf("Unhandled FW command: %02X\n", data); - break; - } - } - - return data; -} - -bool BackupDevice::save_state(std::ostream* os) -{ - int version = 1; - write32le(version,os); - write32le(write_enable,os); - write32le(com,os); - write32le(addr_size,os); - write32le(addr_counter,os); - write32le((u32)state,os); - writebuffer(data,os); - writebuffer(data_autodetect,os); - write32le(addr,os); - return true; -} - -bool BackupDevice::load_state(std::istream* is) -{ - int version; - if(read32le(&version,is)!=1) return false; - if(version==0 || version==1) { - read32le(&write_enable,is); - read32le(&com,is); - read32le(&addr_size,is); - read32le(&addr_counter,is); - u32 temp; - read32le(&temp,is); - state = (STATE)temp; - readbuffer(data,is); - readbuffer(data_autodetect,is); - if(version==1) - read32le(&addr,is); - } - return true; -} - -BackupDevice::BackupDevice() -{ -} - -//due to unfortunate shortcomings in the emulator architecture, -//at reset-time, we won't have a filename to the .dsv file. -//so the only difference between load_rom (init) and reset is that -//one of them saves the filename -void BackupDevice::load_rom(const char* filename) -{ - isMovieMode = false; - this->filename = filename; - reset(); -} - -void BackupDevice::movie_mode() -{ - isMovieMode = true; - reset(); -} - -void BackupDevice::reset() -{ - com = 0; - addr = addr_counter = 0; - flushPending = false; - lazyFlushPending = false; - data.resize(0); - write_enable = FALSE; - data_autodetect.resize(0); - - state = DETECTING; - addr_size = 0; - loadfile(); - - //if the user has requested a manual choice for backup type, and we havent imported a raw save file, then apply it now - if(state == DETECTING && CommonSettings.manualBackupType != MC_TYPE_AUTODETECT) - { - state = RUNNING; - int savetype = save_types[CommonSettings.manualBackupType][0]; - int savesize = save_types[CommonSettings.manualBackupType][1]; - ensure((u32)savesize); //expand properly if necessary - data.resize(savesize); //truncate if necessary - addr_size = addr_size_for_old_save_type(savetype); - flush(); - } -} - -void BackupDevice::close_rom() -{ - flush(); -} - -void BackupDevice::reset_command() -{ - //for a performance hack, save files are only flushed after each reset command - //(hopefully, after each page) - if(flushPending) - { - flush(); - flushPending = false; - lazyFlushPending = false; - } - - if(state == DETECTING && data_autodetect.size()>0) - { - //we can now safely detect the save address size - u32 autodetect_size = data_autodetect.size(); - - printf("Autodetecting with autodetect_size=%d\n",autodetect_size); - - const u8 sm64_sig[] = {0x01,0x80,0x00,0x00}; - if(autodetect_size == 4 && !memcmp(&data_autodetect[0],sm64_sig,4)) - { - addr_size = 2; - } - else //detect based on rules - switch(autodetect_size) - { - case 0: - case 1: - printf("Catastrophic error while autodetecting save type.\nIt will need to be specified manually\n"); - #ifdef _MSC_VER - MessageBox(0,"Catastrophic Error Code: Camel;\nyour save type has not been autodetected correctly;\nplease report to developers",0,0); - #endif - addr_size = 1; //choose 1 just to keep the busted savefile from growing too big - break; - case 2: - //the modern typical case for small eeproms - addr_size = 1; - break; - case 3: - //another modern typical case.. - //but unfortunately we select this case for spider-man 3, when what it meant to do was - //present the archaic 1+2 case - addr_size = 2; - break; - case 4: - //a modern typical case - addr_size = 3; - break; - default: - //the archaic case: write the address and then some modulo-4 number of bytes - //why modulo 4? who knows. - addr_size = autodetect_size & 3; - break; - } - - state = RUNNING; - data_autodetect.resize(0); - flush(); - } - - com = 0; -} -u8 BackupDevice::data_command(u8 val) -{ - if(com == BM_CMD_READLOW || com == BM_CMD_WRITELOW) - { - //handle data or address - if(state == DETECTING) - { - if(com == BM_CMD_WRITELOW) - { - printf("Unexpected backup device initialization sequence using writes!\n"); - } - - //just buffer the data until we're no longer detecting - data_autodetect.push_back(val); - val = 0; - } - else - { - if(addr_counterwrite_enable << 1); - return (write_enable << 1); - } - else - { - //there is no current command. receive one - switch(val) - { - case 0: break; //?? - - case BM_CMD_WRITEDISABLE: - write_enable = FALSE; - break; - - case BM_CMD_READSTATUS: - com = BM_CMD_READSTATUS; - break; - - case BM_CMD_WRITEENABLE: - write_enable = TRUE; - break; - - case BM_CMD_WRITELOW: - case BM_CMD_READLOW: - //printf("XLO: %08X\n",addr); - com = val; - addr_counter = 0; - addr = 0; - break; - - case BM_CMD_WRITEHIGH: - case BM_CMD_READHIGH: - //printf("XHI: %08X\n",addr); - if(val == BM_CMD_WRITEHIGH) val = BM_CMD_WRITELOW; - if(val == BM_CMD_READHIGH) val = BM_CMD_READLOW; - com = val; - addr_counter = 0; - addr = 0; - if(addr_size==1) { - //"write command that's only available on ST M95040-W that I know of" - //this makes sense, since this device would only have a 256 bytes address space with writelow - //and writehigh would allow access to the upper 256 bytes - //but it was detected in pokemon diamond also during the main save process - addr = 0x1; - } - break; - - default: - printf("COMMAND: Unhandled Backup Memory command: %02X\n", val); - break; - } - } - return val; -} - -//guarantees that the data buffer has room enough for the specified number of bytes -void BackupDevice::ensure(u32 addr) -{ - u32 size = data.size(); - if(sizeaddr_size = addr_size; - this->data.resize(datasize); - memcpy(&this->data[0],data,datasize); - - //dump back out as a dsv, just to keep things sane - flush(); -} - -//======================================================================= no$GBA -//======================================================================= -//======================================================================= - -static int no_gba_unpackSAV(void *in_buf, u32 fsize, void *out_buf, u32 &size) -{ - const char no_GBA_HEADER_ID[] = "NocashGbaBackupMediaSavDataFile"; - const char no_GBA_HEADER_SRAM_ID[] = "SRAM"; - u8 *src = (u8 *)in_buf; - u8 *dst = (u8 *)out_buf; - u32 src_pos = 0; - u32 dst_pos = 0; - u8 cc = 0; - u32 size_unpacked = 0; - u32 size_packed = 0; - u32 compressMethod = 0; - - if (fsize < 0x50) return (1); - - for (int i = 0; i < 0x1F; i++) - { - if (src[i] != no_GBA_HEADER_ID[i]) return (2); - } - if (src[0x1F] != 0x1A) return (2); - for (int i = 0; i < 0x4; i++) - { - if (src[i+0x40] != no_GBA_HEADER_SRAM_ID[i]) return (2); - } - - compressMethod = *((u32*)(src+0x44)); - - if (compressMethod == 0) // unpacked - { - size_unpacked = *((u32*)(src+0x48)); - src_pos = 0x4C; - for (u32 i = 0; i < size_unpacked; i++) - { - dst[dst_pos++] = src[src_pos++]; - } - size = dst_pos; - return (0); - } - - if (compressMethod == 1) // packed (method 1) - { - size_packed = *((u32*)(src+0x48)); - size_unpacked = *((u32*)(src+0x4C)); - - src_pos = 0x50; - while (true) - { - cc = src[src_pos++]; - - if (cc == 0) - { - size = dst_pos; - return (0); - } - - if (cc == 0x80) - { - u16 tsize = *((u16*)(src+src_pos+1)); - for (int t = 0; t < tsize; t++) - dst[dst_pos++] = src[src_pos]; - src_pos += 3; - continue; - } - - if (cc > 0x80) // repeat - { - cc -= 0x80; - for (int t = 0; t < cc; t++) - dst[dst_pos++] = src[src_pos]; - src_pos++; - continue; - } - // copy - for (int t = 0; t < cc; t++) - dst[dst_pos++] = src[src_pos++]; - } - size = dst_pos; - return (0); - } - return (200); -} - -static u32 no_gba_savTrim(void *buf, u32 size) -{ - u32 rows = size / 16; - u32 pos = (size - 16); - u8 *src = (u8*)buf; - - for (unsigned int i = 0; i < rows; i++, pos -= 16) - { - if (src[pos] == 0xFF) - { - for (int t = 0; t < 16; t++) - { - if (src[pos+t] != 0xFF) return (pos+16); - } - } - else - { - return (pos+16); - } - } - return (size); -} - -static u32 no_gba_fillLeft(u32 size) -{ - for (u32 i = 1; i < ARRAY_SIZE(save_types); i++) - { - if (size <= (u32)save_types[i][1]) - return (size + (save_types[i][1] - size)); - } - return size; -} - -bool BackupDevice::load_no_gba(const char *fname) -{ - FILE *fsrc = fopen(fname, "rb"); - u8 *in_buf = NULL; - u8 *out_buf = NULL; - - if (fsrc) - { - u32 fsize = 0; - fseek(fsrc, 0, SEEK_END); - fsize = ftell(fsrc); - fseek(fsrc, 0, SEEK_SET); - //printf("Open %s file (size %i bytes)\n", fname, fsize); - - in_buf = new u8 [fsize]; - - if (fread(in_buf, 1, fsize, fsrc) == fsize) - { - out_buf = new u8 [8 * 1024 * 1024 / 8]; - for (int jj = 0; jj < 8 * 1024 * 1024 / 8; jj++) - { - out_buf[jj] = 0xFF; - } - - u32 size = 0; - - if (no_gba_unpackSAV(in_buf, fsize, out_buf, size) == 0) - { - //printf("New size %i byte(s)\n", size); - size = no_gba_savTrim(out_buf, size); - //printf("--- new size after trim %i byte(s)\n", size); - size = no_gba_fillLeft(size); - //printf("--- new size after fill %i byte(s)\n", size); - raw_applyUserSettings(size); - data.resize(size); - for (u32 tt = 0; tt < size; tt++) - data[tt] = out_buf[tt]; - - //dump back out as a dsv, just to keep things sane - flush(); - printf("---- Loaded no$GBA save\n"); - - if (in_buf) delete [] in_buf; - if (out_buf) delete [] out_buf; - return true; - } - if (out_buf) delete [] out_buf; - } - if (in_buf) delete [] in_buf; - } - - return false; -} -//======================================================================= end -//======================================================================= -//======================================================================= no$GBA - - -void BackupDevice::loadfile() -{ - //never use save files if we are in movie mode - if(isMovieMode) return; - if(filename.length() ==0) return; //No sense crashing if no filename supplied - - FILE* inf = fopen(filename.c_str(),"rb"); - if(!inf) - { - //no dsv found; we need to try auto-importing a file with .sav extension - printf("DeSmuME .dsv save file not found. Trying to load an old raw .sav file.\n"); - - //change extension to sav - char tmp[MAX_PATH]; - strcpy(tmp,filename.c_str()); - tmp[strlen(tmp)-3] = 0; - strcat(tmp,"sav"); - - inf = fopen(tmp,"rb"); - if(!inf) - { - printf("Missing save file %s\n",filename.c_str()); - return; - } - fclose(inf); - - if (!load_no_gba(tmp)) - load_raw(tmp); - } - else - { - //scan for desmume save footer - const s32 cookieLen = (s32)strlen(kDesmumeSaveCookie); - char *sigbuf = new char[cookieLen]; - fseek(inf, -cookieLen, SEEK_END); - fread(sigbuf,1,cookieLen,inf); - int cmp = memcmp(sigbuf,kDesmumeSaveCookie,cookieLen); - delete[] sigbuf; - if(cmp) - { - //maybe it is a misnamed raw save file. try loading it that way - printf("Not a DeSmuME .dsv save file. Trying to load as raw.\n"); - fclose(inf); - if (!load_no_gba(filename.c_str())) - load_raw(filename.c_str()); - return; - } - //desmume format - fseek(inf, -cookieLen, SEEK_END); - fseek(inf, -4, SEEK_CUR); - u32 version = 0xFFFFFFFF; - read32le(&version,inf); - if(version!=0) { - printf("Unknown save file format\n"); - return; - } - fseek(inf, -24, SEEK_CUR); - struct { - u32 size,padSize,type,addr_size,mem_size; - } info; - read32le(&info.size,inf); - read32le(&info.padSize,inf); - read32le(&info.type,inf); - read32le(&info.addr_size,inf); - read32le(&info.mem_size,inf); - - //establish the save data - data.resize(info.size); - fseek(inf, 0, SEEK_SET); - if(info.size>0) - fread(&data[0],1,info.size,inf); //read all the raw data we have - state = RUNNING; - addr_size = info.addr_size; - //none of the other fields are used right now - - fclose(inf); - } -} - -bool BackupDevice::save_raw(const char* filename) -{ - FILE* outf = fopen(filename,"wb"); - if(!outf) return false; - u32 size = data.size(); - u32 padSize = pad_up_size(size); - if(data.size()>0) - fwrite(&data[0],1,size,outf); - for(u32 i=size;i saveSizes[ctr]) ctr++; - u32 padSize = saveSizes[ctr]; - if(padSize == 0xFFFFFFFF) - { - printf("PANIC! Couldn't pad up save size. Refusing to pad.\n"); - padSize = startSize; - } - return padSize; -} - -void BackupDevice::lazy_flush() -{ - if(flushPending || lazyFlushPending) - { - lazyFlushPending = flushPending = false; - flush(); - } -} - -void BackupDevice::flush() -{ - //never use save files if we are in movie mode - if(isMovieMode) return; - - FILE* outf = fopen(filename.c_str(),"wb"); - if(outf) - { - if(data.size()>0) - fwrite(&data[0],1,data.size(),outf); - - //write the footer. we use a footer so that we can maximize the chance of the - //save file being recognized as a raw save file by other emulators etc. - - //first, pad up to the next largest known save size. - u32 size = data.size(); - u32 padSize = pad_up_size(size); - - for(u32 i=size;iseekg(-cookieLen, std::ios::end); - is->seekg(-4, std::ios::cur); - - u32 version = 0xFFFFFFFF; - is->read((char*)&version,4); - if(version!=0) { - printf("Unknown save file format\n"); - return false; - } - is->seekg(-24, std::ios::cur); - - struct{ - u32 size,padSize,type,addr_size,mem_size; - }info; - - is->read((char*)&info.size,4); - is->read((char*)&info.padSize,4); - is->read((char*)&info.type,4); - is->read((char*)&info.addr_size,4); - is->read((char*)&info.mem_size,4); - - //establish the save data - data.resize(info.size); - is->seekg(0, std::ios::beg); - if(info.size>0) - is->read((char*)&data[0],info.size); - - state = RUNNING; - addr_size = info.addr_size; - //none of the other fields are used right now - - return true; -} +/* Copyright (C) 2006 thoduv + Copyright (C) 2006-2007 Theo Berkau + Copyright (C) 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include "debug.h" +#include "types.h" +#include "mc.h" +#include "movie.h" +#include "readwrite.h" +#include "NDSSystem.h" + +//temporary hack until we have better error reporting facilities +#ifdef _MSC_VER +#include +#endif + +#define FW_CMD_READ 0x3 +#define FW_CMD_WRITEDISABLE 0x4 +#define FW_CMD_READSTATUS 0x5 +#define FW_CMD_WRITEENABLE 0x6 +#define FW_CMD_PAGEWRITE 0xA + +#define BM_CMD_AUTODETECT 0xFF +#define BM_CMD_WRITESTATUS 0x1 +#define BM_CMD_WRITELOW 0x2 +#define BM_CMD_READLOW 0x3 +#define BM_CMD_WRITEDISABLE 0x4 +#define BM_CMD_READSTATUS 0x5 +#define BM_CMD_WRITEENABLE 0x6 +#define BM_CMD_WRITEHIGH 0xA +#define BM_CMD_READHIGH 0xB + +/* FLASH*/ +#define COMM_PAGE_WRITE 0x0A +#define COMM_PAGE_ERASE 0xDB +#define COMM_SECTOR_ERASE 0xD8 +#define COMM_CHIP_ERASE 0xC7 +#define CARDFLASH_READ_BYTES_FAST 0x0B /* Not used*/ +#define CARDFLASH_DEEP_POWDOWN 0xB9 /* Not used*/ +#define CARDFLASH_WAKEUP 0xAB /* Not used*/ + +//this should probably be 0xFF but we're using 0x00 until we find out otherwise +//(no$ appears definitely to initialized to 0xFF) +static const u8 kUninitializedSaveDataValue = 0x00; + +static const char* kDesmumeSaveCookie = "|-DESMUME SAVE-|"; + +static const u32 saveSizes[] = {512,8*1024,32*1024,64*1024,256*1024,512*1024,0xFFFFFFFF}; +static const u32 saveSizes_count = ARRAY_SIZE(saveSizes); + +//the lookup table from user save types to save parameters +static const int save_types[7][2] = { + {MC_TYPE_AUTODETECT,1}, + {MC_TYPE_EEPROM1,MC_SIZE_4KBITS}, + {MC_TYPE_EEPROM2,MC_SIZE_64KBITS}, + {MC_TYPE_EEPROM2,MC_SIZE_512KBITS}, + {MC_TYPE_FRAM,MC_SIZE_256KBITS}, + {MC_TYPE_FLASH,MC_SIZE_2MBITS}, + {MC_TYPE_FLASH,MC_SIZE_4MBITS} +}; + +void backup_setManualBackupType(int type) +{ + CommonSettings.manualBackupType = type; +} + +void mc_init(memory_chip_t *mc, int type) +{ + mc->com = 0; + mc->addr = 0; + mc->addr_shift = 0; + mc->data = NULL; + mc->size = 0; + mc->write_enable = FALSE; + mc->writeable_buffer = FALSE; + mc->type = type; + mc->autodetectsize = 0; + + switch(mc->type) + { + case MC_TYPE_EEPROM1: + mc->addr_size = 1; + break; + case MC_TYPE_EEPROM2: + case MC_TYPE_FRAM: + mc->addr_size = 2; + break; + case MC_TYPE_FLASH: + mc->addr_size = 3; + break; + default: break; + } +} + +u8 *mc_alloc(memory_chip_t *mc, u32 size) +{ + u8 *buffer; + buffer = new u8[size]; + memset(buffer,0,size); + + mc->data = buffer; + if(!buffer) { return NULL; } + mc->size = size; + mc->writeable_buffer = TRUE; + + return buffer; +} + +void mc_free(memory_chip_t *mc) +{ + if(mc->data) delete[] mc->data; + mc_init(mc, 0); +} + +void fw_reset_com(memory_chip_t *mc) +{ + if(mc->com == FW_CMD_PAGEWRITE) + { + if (mc->fp) + { + fseek(mc->fp, 0, SEEK_SET); + fwrite(mc->data, mc->size, 1, mc->fp); + } + + mc->write_enable = FALSE; + } + + mc->com = 0; +} + +u8 fw_transfer(memory_chip_t *mc, u8 data) +{ + if(mc->com == FW_CMD_READ || mc->com == FW_CMD_PAGEWRITE) /* check if we are in a command that needs 3 bytes address */ + { + if(mc->addr_shift > 0) /* if we got a complete address */ + { + mc->addr_shift--; + mc->addr |= data << (mc->addr_shift * 8); /* argument is a byte of address */ + } + else /* if we have received 3 bytes of address, proceed command */ + { + switch(mc->com) + { + case FW_CMD_READ: + if(mc->addr < mc->size) /* check if we can read */ + { + data = mc->data[mc->addr]; /* return byte */ + mc->addr++; /* then increment address */ + } + break; + + case FW_CMD_PAGEWRITE: + if(mc->addr < mc->size) + { + mc->data[mc->addr] = data; /* write byte */ + mc->addr++; + } + break; + } + + } + } + else if(mc->com == FW_CMD_READSTATUS) + { + return (mc->write_enable ? 0x02 : 0x00); + } + else /* finally, check if it's a new command */ + { + switch(data) + { + case 0: break; /* nothing */ + + case FW_CMD_READ: /* read command */ + mc->addr = 0; + mc->addr_shift = 3; + mc->com = FW_CMD_READ; + break; + + case FW_CMD_WRITEENABLE: /* enable writing */ + if(mc->writeable_buffer) { mc->write_enable = TRUE; } + break; + + case FW_CMD_WRITEDISABLE: /* disable writing */ + mc->write_enable = FALSE; + break; + + case FW_CMD_PAGEWRITE: /* write command */ + if(mc->write_enable) + { + mc->addr = 0; + mc->addr_shift = 3; + mc->com = FW_CMD_PAGEWRITE; + } + else { data = 0; } + break; + + case FW_CMD_READSTATUS: /* status register command */ + mc->com = FW_CMD_READSTATUS; + break; + + default: + printf("Unhandled FW command: %02X\n", data); + break; + } + } + + return data; +} + +bool BackupDevice::save_state(std::ostream* os) +{ + int version = 1; + write32le(version,os); + write32le(write_enable,os); + write32le(com,os); + write32le(addr_size,os); + write32le(addr_counter,os); + write32le((u32)state,os); + writebuffer(data,os); + writebuffer(data_autodetect,os); + write32le(addr,os); + return true; +} + +bool BackupDevice::load_state(std::istream* is) +{ + int version; + if(read32le(&version,is)!=1) return false; + if(version==0 || version==1) { + read32le(&write_enable,is); + read32le(&com,is); + read32le(&addr_size,is); + read32le(&addr_counter,is); + u32 temp; + read32le(&temp,is); + state = (STATE)temp; + readbuffer(data,is); + readbuffer(data_autodetect,is); + if(version==1) + read32le(&addr,is); + } + return true; +} + +BackupDevice::BackupDevice() +{ +} + +//due to unfortunate shortcomings in the emulator architecture, +//at reset-time, we won't have a filename to the .dsv file. +//so the only difference between load_rom (init) and reset is that +//one of them saves the filename +void BackupDevice::load_rom(const char* filename) +{ + isMovieMode = false; + this->filename = filename; + reset(); +} + +void BackupDevice::movie_mode() +{ + isMovieMode = true; + reset(); +} + +void BackupDevice::reset() +{ + com = 0; + addr = addr_counter = 0; + flushPending = false; + lazyFlushPending = false; + data.resize(0); + write_enable = FALSE; + data_autodetect.resize(0); + + state = DETECTING; + addr_size = 0; + loadfile(); + + //if the user has requested a manual choice for backup type, and we havent imported a raw save file, then apply it now + if(state == DETECTING && CommonSettings.manualBackupType != MC_TYPE_AUTODETECT) + { + state = RUNNING; + int savetype = save_types[CommonSettings.manualBackupType][0]; + int savesize = save_types[CommonSettings.manualBackupType][1]; + ensure((u32)savesize); //expand properly if necessary + data.resize(savesize); //truncate if necessary + addr_size = addr_size_for_old_save_type(savetype); + flush(); + } +} + +void BackupDevice::close_rom() +{ + flush(); +} + +void BackupDevice::reset_command() +{ + //for a performance hack, save files are only flushed after each reset command + //(hopefully, after each page) + if(flushPending) + { + flush(); + flushPending = false; + lazyFlushPending = false; + } + + if(state == DETECTING && data_autodetect.size()>0) + { + //we can now safely detect the save address size + u32 autodetect_size = data_autodetect.size(); + + printf("Autodetecting with autodetect_size=%d\n",autodetect_size); + + const u8 sm64_sig[] = {0x01,0x80,0x00,0x00}; + if(autodetect_size == 4 && !memcmp(&data_autodetect[0],sm64_sig,4)) + { + addr_size = 2; + } + else //detect based on rules + switch(autodetect_size) + { + case 0: + case 1: + printf("Catastrophic error while autodetecting save type.\nIt will need to be specified manually\n"); + #ifdef _MSC_VER + MessageBox(0,"Catastrophic Error Code: Camel;\nyour save type has not been autodetected correctly;\nplease report to developers",0,0); + #endif + addr_size = 1; //choose 1 just to keep the busted savefile from growing too big + break; + case 2: + //the modern typical case for small eeproms + addr_size = 1; + break; + case 3: + //another modern typical case.. + //but unfortunately we select this case for spider-man 3, when what it meant to do was + //present the archaic 1+2 case + addr_size = 2; + break; + case 4: + //a modern typical case + addr_size = 3; + break; + default: + //the archaic case: write the address and then some modulo-4 number of bytes + //why modulo 4? who knows. + addr_size = autodetect_size & 3; + break; + } + + state = RUNNING; + data_autodetect.resize(0); + flush(); + } + + com = 0; +} +u8 BackupDevice::data_command(u8 val) +{ + if(com == BM_CMD_READLOW || com == BM_CMD_WRITELOW) + { + //handle data or address + if(state == DETECTING) + { + if(com == BM_CMD_WRITELOW) + { + printf("Unexpected backup device initialization sequence using writes!\n"); + } + + //just buffer the data until we're no longer detecting + data_autodetect.push_back(val); + val = 0; + } + else + { + if(addr_counterwrite_enable << 1); + return (write_enable << 1); + } + else + { + //there is no current command. receive one + switch(val) + { + case 0: break; //?? + + case BM_CMD_WRITEDISABLE: + write_enable = FALSE; + break; + + case BM_CMD_READSTATUS: + com = BM_CMD_READSTATUS; + break; + + case BM_CMD_WRITEENABLE: + write_enable = TRUE; + break; + + case BM_CMD_WRITELOW: + case BM_CMD_READLOW: + //printf("XLO: %08X\n",addr); + com = val; + addr_counter = 0; + addr = 0; + break; + + case BM_CMD_WRITEHIGH: + case BM_CMD_READHIGH: + //printf("XHI: %08X\n",addr); + if(val == BM_CMD_WRITEHIGH) val = BM_CMD_WRITELOW; + if(val == BM_CMD_READHIGH) val = BM_CMD_READLOW; + com = val; + addr_counter = 0; + addr = 0; + if(addr_size==1) { + //"write command that's only available on ST M95040-W that I know of" + //this makes sense, since this device would only have a 256 bytes address space with writelow + //and writehigh would allow access to the upper 256 bytes + //but it was detected in pokemon diamond also during the main save process + addr = 0x1; + } + break; + + default: + printf("COMMAND: Unhandled Backup Memory command: %02X\n", val); + break; + } + } + return val; +} + +//guarantees that the data buffer has room enough for the specified number of bytes +void BackupDevice::ensure(u32 addr) +{ + u32 size = data.size(); + if(sizeaddr_size = addr_size; + this->data.resize(datasize); + memcpy(&this->data[0],data,datasize); + + //dump back out as a dsv, just to keep things sane + flush(); +} + + +void BackupDevice::loadfile() +{ + //never use save files if we are in movie mode + if(isMovieMode) return; + if(filename.length() ==0) return; //No sense crashing if no filename supplied + + FILE* inf = fopen(filename.c_str(),"rb"); + if(!inf) + { + //no dsv found; we need to try auto-importing a file with .sav extension + printf("DeSmuME .dsv save file not found. Trying to load an old raw .sav file.\n"); + + //change extension to sav + char tmp[MAX_PATH]; + strcpy(tmp,filename.c_str()); + tmp[strlen(tmp)-3] = 0; + strcat(tmp,"sav"); + + inf = fopen(tmp,"rb"); + if(!inf) + { + printf("Missing save file %s\n",filename.c_str()); + return; + } + fclose(inf); + + load_raw(tmp); + } + else + { + //scan for desmume save footer + const u32 cookieLen = strlen(kDesmumeSaveCookie); + char *sigbuf = new char[cookieLen]; + fseek(inf, -cookieLen, SEEK_END); + fread(sigbuf,1,cookieLen,inf); + int cmp = memcmp(sigbuf,kDesmumeSaveCookie,cookieLen); + delete[] sigbuf; + if(cmp) + { + //maybe it is a misnamed raw save file. try loading it that way + printf("Not a DeSmuME .dsv save file. Trying to load as raw.\n"); + fclose(inf); + load_raw(filename.c_str()); + return; + } + //desmume format + fseek(inf, -cookieLen, SEEK_END); + fseek(inf, -4, SEEK_CUR); + u32 version = 0xFFFFFFFF; + read32le(&version,inf); + if(version!=0) { + printf("Unknown save file format\n"); + return; + } + fseek(inf, -24, SEEK_CUR); + struct { + u32 size,padSize,type,addr_size,mem_size; + } info; + read32le(&info.size,inf); + read32le(&info.padSize,inf); + read32le(&info.type,inf); + read32le(&info.addr_size,inf); + read32le(&info.mem_size,inf); + + //establish the save data + data.resize(info.size); + fseek(inf, 0, SEEK_SET); + if(info.size>0) + fread(&data[0],1,info.size,inf); //read all the raw data we have + state = RUNNING; + addr_size = info.addr_size; + //none of the other fields are used right now + + fclose(inf); + } +} + +bool BackupDevice::save_raw(const char* filename) +{ + FILE* outf = fopen(filename,"wb"); + if(!outf) return false; + u32 size = data.size(); + u32 padSize = pad_up_size(size); + if(data.size()>0) + fwrite(&data[0],1,size,outf); + for(u32 i=size;i saveSizes[ctr]) ctr++; + u32 padSize = saveSizes[ctr]; + if(padSize == 0xFFFFFFFF) + { + printf("PANIC! Couldn't pad up save size. Refusing to pad.\n"); + padSize = startSize; + } + return padSize; +} + +void BackupDevice::lazy_flush() +{ + if(flushPending || lazyFlushPending) + { + lazyFlushPending = flushPending = false; + flush(); + } +} + +void BackupDevice::flush() +{ + //never use save files if we are in movie mode + if(isMovieMode) return; + + FILE* outf = fopen(filename.c_str(),"wb"); + if(outf) + { + if(data.size()>0) + fwrite(&data[0],1,data.size(),outf); + + //write the footer. we use a footer so that we can maximize the chance of the + //save file being recognized as a raw save file by other emulators etc. + + //first, pad up to the next largest known save size. + u32 size = data.size(); + u32 padSize = pad_up_size(size); + + for(u32 i=size;iseekg(-cookieLen, std::ios::end); + is->seekg(-4, std::ios::cur); + + u32 version = 0xFFFFFFFF; + is->read((char*)&version,4); + if(version!=0) { + printf("Unknown save file format\n"); + return false; + } + is->seekg(-24, std::ios::cur); + + struct{ + u32 size,padSize,type,addr_size,mem_size; + }info; + + is->read((char*)&info.size,4); + is->read((char*)&info.padSize,4); + is->read((char*)&info.type,4); + is->read((char*)&info.addr_size,4); + is->read((char*)&info.mem_size,4); + + //establish the save data + data.resize(info.size); + is->seekg(0, std::ios::beg); + if(info.size>0) + is->read((char*)&data[0],info.size); + + state = RUNNING; + addr_size = info.addr_size; + //none of the other fields are used right now + + return true; +} diff --git a/desmume/src/mc.h b/src/mc.h similarity index 97% rename from desmume/src/mc.h rename to src/mc.h index 66598121e..4c4dc6d44 100644 --- a/desmume/src/mc.h +++ b/src/mc.h @@ -1,148 +1,147 @@ -/* Copyright (C) 2006 thoduv - Copyright (C) 2006 Theo Berkau - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __FW_H__ -#define __FW_H__ - -#include -#include -#include -#include "types.h" - -#define MC_TYPE_AUTODETECT 0x0 -#define MC_TYPE_EEPROM1 0x1 -#define MC_TYPE_EEPROM2 0x2 -#define MC_TYPE_FLASH 0x3 -#define MC_TYPE_FRAM 0x4 - -#define MC_SIZE_4KBITS 0x000200 -#define MC_SIZE_64KBITS 0x002000 -#define MC_SIZE_256KBITS 0x008000 -#define MC_SIZE_512KBITS 0x010000 -#define MC_SIZE_1MBITS 0x020000 -#define MC_SIZE_2MBITS 0x040000 -#define MC_SIZE_4MBITS 0x080000 -#define MC_SIZE_8MBITS 0x100000 -#define MC_SIZE_16MBITS 0x200000 -#define MC_SIZE_64MBITS 0x800000 - -typedef struct -{ - u8 com; /* persistent command actually handled */ - u32 addr; /* current address for reading/writing */ - u8 addr_shift; /* shift for address (since addresses are transfered by 3 bytes units) */ - u8 addr_size; /* size of addr when writing/reading */ - - BOOL write_enable; /* is write enabled ? */ - - u8 *data; /* memory data */ - u32 size; /* memory size */ - BOOL writeable_buffer; /* is "data" writeable ? */ - int type; /* type of Memory */ - char *filename; - FILE *fp; - u8 autodetectbuf[32768]; - int autodetectsize; -} memory_chip_t; - -//the new backup system by zeromus -class BackupDevice -{ -public: - BackupDevice(); - - //signals the save system that we are in our regular mode, loading up a rom. initializes for that case. - void load_rom(const char* filename); - //signals the save system that we are in MOVIE mode. doesnt load up a rom, and never saves it. initializes for that case. - void movie_mode(); - - void reset(); - void close_rom(); - - bool save_state(std::ostream* os); - bool load_state(std::istream* is); - - //commands from mmu - void reset_command(); - u8 data_command(u8); - - //this info was saved before the last reset (used for savestate compatibility) - struct SavedInfo - { - u32 addr_size; - } savedInfo; - - //and these are used by old savestates - void load_old_state(u32 addr_size, u8* data, u32 datasize); - static u32 addr_size_for_old_save_size(int bupmem_size); - static u32 addr_size_for_old_save_type(int bupmem_type); - - static u32 pad_up_size(u32 startSize); - void raw_applyUserSettings(u32& size); - - bool load_duc(const char* filename); - bool load_no_gba(const char *fname); - bool load_raw(const char* filename); - bool save_raw(const char* filename); - bool load_movie(std::istream* is); - - //call me once a second or so to lazy flush the save data - //here's the reason for this system: we want to dump save files when theyre READ - //so that we have a better idea earlier on how large they are. but it slows things down - //way too much if we flush whenever we read. - void lazy_flush(); - -private: - BOOL write_enable; //is write enabled? - u32 com; //persistent command actually handled - u32 addr_size, addr_counter; - u32 addr; - bool isMovieMode; - - std::string filename; - std::vector data; - std::vector data_autodetect; - enum STATE { - DETECTING = 0, RUNNING = 1 - } state; - - void loadfile(); - bool _loadfile(const char *fname); - void ensure(u32 addr); - void flush(); - - bool flushPending, lazyFlushPending; -}; - -#define NDS_FW_SIZE_V1 (256 * 1024) /* size of fw memory on nds v1 */ -#define NDS_FW_SIZE_V2 (512 * 1024) /* size of fw memory on nds v2 */ - -void mc_init(memory_chip_t *mc, int type); /* reset and init values for memory struct */ -u8 *mc_alloc(memory_chip_t *mc, u32 size); /* alloc mc memory */ -void mc_realloc(memory_chip_t *mc, int type, u32 size); /* realloc mc memory */ -void mc_load_file(memory_chip_t *mc, const char* filename); /* load save file and setup fp */ -void mc_free(memory_chip_t *mc); /* delete mc memory */ -void fw_reset_com(memory_chip_t *mc); /* reset communication with mc */ -u8 fw_transfer(memory_chip_t *mc, u8 data); - -void backup_setManualBackupType(int type); - -#endif /*__FW_H__*/ - +/* Copyright (C) 2006 thoduv + Copyright (C) 2006 Theo Berkau + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __FW_H__ +#define __FW_H__ + +#include +#include +#include +#include "types.h" + +#define MC_TYPE_AUTODETECT 0x0 +#define MC_TYPE_EEPROM1 0x1 +#define MC_TYPE_EEPROM2 0x2 +#define MC_TYPE_FLASH 0x3 +#define MC_TYPE_FRAM 0x4 + +#define MC_SIZE_4KBITS 0x000200 +#define MC_SIZE_64KBITS 0x002000 +#define MC_SIZE_256KBITS 0x008000 +#define MC_SIZE_512KBITS 0x010000 +#define MC_SIZE_1MBITS 0x020000 +#define MC_SIZE_2MBITS 0x040000 +#define MC_SIZE_4MBITS 0x080000 +#define MC_SIZE_8MBITS 0x100000 +#define MC_SIZE_16MBITS 0x200000 +#define MC_SIZE_64MBITS 0x800000 + +typedef struct +{ + u8 com; /* persistent command actually handled */ + u32 addr; /* current address for reading/writing */ + u8 addr_shift; /* shift for address (since addresses are transfered by 3 bytes units) */ + u8 addr_size; /* size of addr when writing/reading */ + + BOOL write_enable; /* is write enabled ? */ + + u8 *data; /* memory data */ + u32 size; /* memory size */ + BOOL writeable_buffer; /* is "data" writeable ? */ + int type; /* type of Memory */ + char *filename; + FILE *fp; + u8 autodetectbuf[32768]; + int autodetectsize; +} memory_chip_t; + +//the new backup system by zeromus +class BackupDevice +{ +public: + BackupDevice(); + + //signals the save system that we are in our regular mode, loading up a rom. initializes for that case. + void load_rom(const char* filename); + //signals the save system that we are in MOVIE mode. doesnt load up a rom, and never saves it. initializes for that case. + void movie_mode(); + + void reset(); + void close_rom(); + + bool save_state(std::ostream* os); + bool load_state(std::istream* is); + + //commands from mmu + void reset_command(); + u8 data_command(u8); + + //this info was saved before the last reset (used for savestate compatibility) + struct SavedInfo + { + u32 addr_size; + } savedInfo; + + //and these are used by old savestates + void load_old_state(u32 addr_size, u8* data, u32 datasize); + static u32 addr_size_for_old_save_size(int bupmem_size); + static u32 addr_size_for_old_save_type(int bupmem_type); + + static u32 pad_up_size(u32 startSize); + void raw_applyUserSettings(u32& size); + + bool load_duc(const char* filename); + bool load_raw(const char* filename); + bool save_raw(const char* filename); + bool load_movie(std::istream* is); + + //call me once a second or so to lazy flush the save data + //here's the reason for this system: we want to dump save files when theyre READ + //so that we have a better idea earlier on how large they are. but it slows things down + //way too much if we flush whenever we read. + void lazy_flush(); + +private: + BOOL write_enable; //is write enabled? + u32 com; //persistent command actually handled + u32 addr_size, addr_counter; + u32 addr; + bool isMovieMode; + + std::string filename; + std::vector data; + std::vector data_autodetect; + enum STATE { + DETECTING = 0, RUNNING = 1 + } state; + + void loadfile(); + bool _loadfile(const char *fname); + void ensure(u32 addr); + void flush(); + + bool flushPending, lazyFlushPending; +}; + +#define NDS_FW_SIZE_V1 (256 * 1024) /* size of fw memory on nds v1 */ +#define NDS_FW_SIZE_V2 (512 * 1024) /* size of fw memory on nds v2 */ + +void mc_init(memory_chip_t *mc, int type); /* reset and init values for memory struct */ +u8 *mc_alloc(memory_chip_t *mc, u32 size); /* alloc mc memory */ +void mc_realloc(memory_chip_t *mc, int type, u32 size); /* realloc mc memory */ +void mc_load_file(memory_chip_t *mc, const char* filename); /* load save file and setup fp */ +void mc_free(memory_chip_t *mc); /* delete mc memory */ +void fw_reset_com(memory_chip_t *mc); /* reset communication with mc */ +u8 fw_transfer(memory_chip_t *mc, u8 data); + +void backup_setManualBackupType(int type); + +#endif /*__FW_H__*/ + diff --git a/desmume/src/mem.h b/src/mem.h similarity index 96% rename from desmume/src/mem.h rename to src/mem.h index 261f7c138..4b0d4cd7c 100644 --- a/desmume/src/mem.h +++ b/src/mem.h @@ -1,164 +1,164 @@ -/* Copyright 2005-2006 Guillaume Duhamel - Copyright 2005 Theo Berkau - - This file is part of Yabause. - - Yabause is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - Yabause is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Yabause; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef MEM_H -#define MEM_H - -#include -#include -#include "types.h" - -/* Type 1 Memory, faster for byte (8 bits) accesses */ - -static INLINE u8 T1ReadByte(u8* const mem, const u32 addr) -{ - return mem[addr]; -} - -static INLINE u16 T1ReadWord_guaranteedAligned(void* const mem, const u32 addr) -{ - assert((addr&1)==0); -#ifdef WORDS_BIGENDIAN - return (((u8*)mem)[addr + 1] << 8) | ((u8*)mem)[addr]; -#else - return *(u16*)((u8*)mem + addr); -#endif -} - -static INLINE u16 T1ReadWord(void* const mem, const u32 addr) -{ -#ifdef WORDS_BIGENDIAN - return (((u8*)mem)[addr + 1] << 8) | ((u8*)mem)[addr]; -#else - return *((u16 *) ((u8*)mem + addr)); -#endif -} - -static INLINE u32 T1ReadLong_guaranteedAligned(u8* const mem, const u32 addr) -{ - assert((addr&3)==0); -#ifdef WORDS_BIGENDIAN - return (mem[addr + 3] << 24 | mem[addr + 2] << 16 | - mem[addr + 1] << 8 | mem[addr]); -#else - return *(u32*)(mem + addr); -#endif -} - - -static INLINE u32 T1ReadLong(u8* const mem, const u32 addr) -{ -#ifdef WORDS_BIGENDIAN - return (mem[addr + 3] << 24 | mem[addr + 2] << 16 | - mem[addr + 1] << 8 | mem[addr]); -#else - return *((u32 *)mem + (addr>>2)); -#endif -} - -static INLINE u64 T1ReadQuad(u8* const mem, const u32 addr) -{ -#ifdef WORDS_BIGENDIAN - return (u64(mem[addr + 7]) << 56 | u64(mem[addr + 6]) << 48 | - u64(mem[addr + 5]) << 40 | u64(mem[addr + 4]) << 32 | - u64(mem[addr + 3]) << 24 | u64(mem[addr + 2]) << 16 | - u64(mem[addr + 1]) << 8 | u64(mem[addr ])); -#else - return *((u64 *) (mem + addr)); -#endif -} - -static INLINE void T1WriteByte(u8* const mem, const u32 addr, const u8 val) -{ - mem[addr] = val; -} - -static INLINE void T1WriteWord(u8* const mem, const u32 addr, const u16 val) -{ -#ifdef WORDS_BIGENDIAN - mem[addr + 1] = val >> 8; - mem[addr] = val & 0xFF; -#else - *((u16 *) (mem + addr)) = val; -#endif -} - -static INLINE void T1WriteLong(u8* const mem, const u32 addr, const u32 val) -{ -#ifdef WORDS_BIGENDIAN - mem[addr + 3] = val >> 24; - mem[addr + 2] = (val >> 16) & 0xFF; - mem[addr + 1] = (val >> 8) & 0xFF; - mem[addr] = val & 0xFF; -#else - *((u32 *) (mem + addr)) = val; -#endif -} - -/* Type 2 Memory, faster for word (16 bits) accesses */ - -static INLINE u8 T2ReadByte(u8* const mem, const u32 addr) -{ -#ifdef WORDS_BIGENDIAN - return mem[addr ^ 1]; -#else - return mem[addr]; -#endif -} - -static INLINE u16 T2ReadWord(u8* const mem, const u32 addr) -{ - return *((u16 *) (mem + addr)); -} - -static INLINE u32 T2ReadLong(u8* const mem, const u32 addr) -{ -#ifdef WORDS_BIGENDIAN - return *((u16 *) (mem + addr + 2)) << 16 | *((u16 *) (mem + addr)); -#else - return *((u32 *) (mem + addr)); -#endif -} - -static INLINE void T2WriteByte(u8* const mem, const u32 addr, const u8 val) -{ -#ifdef WORDS_BIGENDIAN - mem[addr ^ 1] = val; -#else - mem[addr] = val; -#endif -} - -static INLINE void T2WriteWord(u8* const mem, const u32 addr, const u16 val) -{ - *((u16 *) (mem + addr)) = val; -} - -static INLINE void T2WriteLong(u8* const mem, const u32 addr, const u32 val) -{ -#ifdef WORDS_BIGENDIAN - *((u16 *) (mem + addr + 2)) = val >> 16; - *((u16 *) (mem + addr)) = val & 0xFFFF; -#else - *((u32 *) (mem + addr)) = val; -#endif -} - -#endif +/* Copyright 2005-2006 Guillaume Duhamel + Copyright 2005 Theo Berkau + + This file is part of Yabause. + + Yabause is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + Yabause is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Yabause; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef MEM_H +#define MEM_H + +#include +#include +#include "types.h" + +/* Type 1 Memory, faster for byte (8 bits) accesses */ + +static INLINE u8 T1ReadByte(u8* const mem, const u32 addr) +{ + return mem[addr]; +} + +static INLINE u16 T1ReadWord_guaranteedAligned(void* const mem, const u32 addr) +{ + assert((addr&1)==0); +#ifdef WORDS_BIGENDIAN + return (((u8*)mem)[addr + 1] << 8) | ((u8*)mem)[addr]; +#else + return *(u16*)((u8*)mem + addr); +#endif +} + +static INLINE u16 T1ReadWord(void* const mem, const u32 addr) +{ +#ifdef WORDS_BIGENDIAN + return (((u8*)mem)[addr + 1] << 8) | ((u8*)mem)[addr]; +#else + return *((u16 *) ((u8*)mem + addr)); +#endif +} + +static INLINE u32 T1ReadLong_guaranteedAligned(u8* const mem, const u32 addr) +{ + assert((addr&3)==0); +#ifdef WORDS_BIGENDIAN + return (mem[addr + 3] << 24 | mem[addr + 2] << 16 | + mem[addr + 1] << 8 | mem[addr]); +#else + return *(u32*)(mem + addr); +#endif +} + + +static INLINE u32 T1ReadLong(u8* const mem, const u32 addr) +{ +#ifdef WORDS_BIGENDIAN + return (mem[addr + 3] << 24 | mem[addr + 2] << 16 | + mem[addr + 1] << 8 | mem[addr]); +#else + return *((u32 *)mem + (addr>>2)); +#endif +} + +static INLINE u64 T1ReadQuad(u8* const mem, const u32 addr) +{ +#ifdef WORDS_BIGENDIAN + return (u64(mem[addr + 7]) << 56 | u64(mem[addr + 6]) << 48 | + u64(mem[addr + 5]) << 40 | u64(mem[addr + 4]) << 32 | + u64(mem[addr + 3]) << 24 | u64(mem[addr + 2]) << 16 | + u64(mem[addr + 1]) << 8 | u64(mem[addr ])); +#else + return *((u64 *) (mem + addr)); +#endif +} + +static INLINE void T1WriteByte(u8* const mem, const u32 addr, const u8 val) +{ + mem[addr] = val; +} + +static INLINE void T1WriteWord(u8* const mem, const u32 addr, const u16 val) +{ +#ifdef WORDS_BIGENDIAN + mem[addr + 1] = val >> 8; + mem[addr] = val & 0xFF; +#else + *((u16 *) (mem + addr)) = val; +#endif +} + +static INLINE void T1WriteLong(u8* const mem, const u32 addr, const u32 val) +{ +#ifdef WORDS_BIGENDIAN + mem[addr + 3] = val >> 24; + mem[addr + 2] = (val >> 16) & 0xFF; + mem[addr + 1] = (val >> 8) & 0xFF; + mem[addr] = val & 0xFF; +#else + *((u32 *) (mem + addr)) = val; +#endif +} + +/* Type 2 Memory, faster for word (16 bits) accesses */ + +static INLINE u8 T2ReadByte(u8* const mem, const u32 addr) +{ +#ifdef WORDS_BIGENDIAN + return mem[addr ^ 1]; +#else + return mem[addr]; +#endif +} + +static INLINE u16 T2ReadWord(u8* const mem, const u32 addr) +{ + return *((u16 *) (mem + addr)); +} + +static INLINE u32 T2ReadLong(u8* const mem, const u32 addr) +{ +#ifdef WORDS_BIGENDIAN + return *((u16 *) (mem + addr + 2)) << 16 | *((u16 *) (mem + addr)); +#else + return *((u32 *) (mem + addr)); +#endif +} + +static INLINE void T2WriteByte(u8* const mem, const u32 addr, const u8 val) +{ +#ifdef WORDS_BIGENDIAN + mem[addr ^ 1] = val; +#else + mem[addr] = val; +#endif +} + +static INLINE void T2WriteWord(u8* const mem, const u32 addr, const u16 val) +{ + *((u16 *) (mem + addr)) = val; +} + +static INLINE void T2WriteLong(u8* const mem, const u32 addr, const u32 val) +{ +#ifdef WORDS_BIGENDIAN + *((u16 *) (mem + addr + 2)) = val >> 16; + *((u16 *) (mem + addr)) = val & 0xFFFF; +#else + *((u32 *) (mem + addr)) = val; +#endif +} + +#endif diff --git a/desmume/src/memorystream.h b/src/memorystream.h similarity index 95% rename from desmume/src/memorystream.h rename to src/memorystream.h index c796f7cf1..3005ba453 100644 --- a/desmume/src/memorystream.h +++ b/src/memorystream.h @@ -1,305 +1,305 @@ -#ifndef _memorystream_h_ -#define _memorystream_h_ - -#include -#include -#include -#include -#include -#include - -template -class memory_streambuf: public std::streambuf { -private: - - friend class memorystream; - - //the current buffer - T* buf; - - //the current allocated capacity of the buffer - size_t capacity; - - //whether the sequence is owned by the stringbuf - bool myBuf; - - //the logical length of the buffer - size_t length; - - //the current 'write window' starting position within the buffer for writing. - size_t ww; - - //a vector that we have been told to use - std::vector* usevec; - - -public: - - memory_streambuf(int _capacity) - : buf(new T[capacity=_capacity]) - , myBuf(true) - , length(_capacity) - , ww(0) - , usevec(0) - { - sync(); - } - - - memory_streambuf() - : buf(new T[capacity = 128]) - , myBuf(true) - , length(0) - , ww(0) - , usevec(0) - { - sync(); - } - - //constructs a non-expandable streambuf around the provided buffer - memory_streambuf(T* usebuf, int buflength) - : buf(usebuf) - , myBuf(false) - , length(buflength) - , ww(0) - , usevec(0) - { - sync(); - } - - //constructs an expandable streambuf around the provided buffer - memory_streambuf(std::vector* _usevec) - : capacity(_usevec->size()) - , myBuf(false) - , length(_usevec->size()) - , ww(0) - , usevec(_usevec) - { - if(length>0) - buf = &(*_usevec)[0]; - else buf = 0; - - sync(); - } - - ~memory_streambuf() - { - //only cleanup if we own the seq - if(myBuf) delete[] buf; - } - - //the logical length of the buffer - size_t size() - { - sync(); - return length; - } - - //to avoid copying, rebuilds the provided vector and copies the streambuf contents into it - void toVector(std::vector& out) - { - out.resize(length); - memcpy(&out[0],buf,length); - } - - //maybe the compiler can avoid copying, but maybe not: returns a vector representing the current streambuf - std::vector toVector() - { - return std::vector(buf,buf+length); - } - - //if the memorystream wraps a vector, the vector will be trimmed to the correct size,. - //you probably need to use this if you are using the vector wrapper - void trim() - { - if(!usevec) return; - usevec->resize(size()); - } - - //tells the current read or write position - std::streampos tell(std::ios::openmode which) - { - if(which == std::ios::in) - return tellRead(); - else if(which == std::ios::out) - return tellWrite(); - else return -1; - } - - //tells the current read position - std::streampos tellRead() - { - return gptr()-eback(); - } - - //tells the current write position - std::streampos tellWrite() - { - return pptr()-pbase() + ww; - } - - int sync() - { - dosync(-1); - return 0; - } - - T* getbuf() - { - sync(); - return buf; - } - - //if we were provided a buffer, then calling this gives us ownership of it - void giveBuf() { - myBuf = true; - } - - void expand(size_t upto) - { - if(!myBuf && !usevec) - throw new std::runtime_error("memory_streambuf is not expandable"); - - size_t newcapacity; - if(upto == (size_t)-1) - newcapacity = capacity + capacity/2 + 2; - else - newcapacity = std::max(upto,capacity); - - if(newcapacity == capacity) return; - - //if we are supposed to use the vector, then do it now - if(usevec) - { - usevec->resize(newcapacity); - capacity = usevec->size(); - buf = &(*usevec)[0]; - } - else - { - //otherwise, manage our own buffer - T* newbuf = new T[newcapacity]; - memcpy(newbuf,buf,capacity); - delete[] buf; - capacity = newcapacity; - buf = newbuf; - } - } - -private: - - void dosync(int c) - { - size_t wp = tellWrite(); - size_t rp = tellRead(); - - //if we are supposed to insert a character.. - if(c != -1) - { - buf[wp] = c; - wp++; - } - - //the length is determined by the highest character that was ever inserted - length = std::max(length,wp); - - //the write window advances to begin at the current write insertion point - ww = wp; - - //set the new write and read windows - setp(buf+ww, buf + capacity); - setg(buf, buf+rp, buf + length); - } - -protected: - - int overflow(int c) - { - expand((size_t)-1); - dosync(c); - return 1; - } - - std::streambuf::pos_type seekpos(pos_type pos, std::ios::openmode which) - { - //extend if we are seeking the write cursor - if(which & std::ios_base::out) - expand(pos); - - sync(); - - if(which & std::ios_base::in) - setg(buf, buf+pos, buf + length); - if(which & std::ios_base::out) - { - ww = pos; - setp(buf+pos, buf + capacity); - } - - return pos; - } - - pos_type seekoff(off_type off, std::ios::seekdir way, std::ios::openmode which) - { - switch(way) { - case std::ios::beg: - return seekpos(off, which); - case std::ios::cur: - return seekpos(tell(which)+off, which); - case std::ios::end: - return seekpos(length+off, which); - default: - return -1; - } - } - -}; - -//an iostream that uses the memory_streambuf to effectively act much like a c# memorystream -//please call sync() after writing data if you want to read it back -class memorystream : public std::basic_iostream > -{ -public: - memorystream() - : std::basic_iostream >(&streambuf) - {} - - memorystream(int sz) - : std::basic_iostream >(&streambuf) - , streambuf(sz) - {} - - memorystream(char* usebuf, int buflength) - : std::basic_iostream >(&streambuf) - , streambuf(usebuf, buflength) - {} - - memorystream(std::vector* usevec) - : std::basic_iostream >(&streambuf) - , streambuf(usevec) - {} - - //the underlying memory_streambuf - memory_streambuf streambuf; - - -public: - - size_t size() { return streambuf.size(); } - char* buf() { return streambuf.getbuf(); } - //flushes all the writing state and ensures the stream is ready for reading - void sync() { streambuf.sync(); } - //rewinds the cursors to offset 0 - void rewind() { streambuf.seekpos(0,std::ios::in | std::ios::out); } - - //if the memorystream wraps a vector, the vector will be trimmed to the correct size,. - //you probably need to use this if you are using the vector wrapper - void trim() { streambuf.trim(); } - - void giveBuf() { streambuf.giveBuf(); } - - memory_streambuf& getStreambuf() { return streambuf; } -}; - - -#endif +#ifndef _memorystream_h_ +#define _memorystream_h_ + +#include +#include +#include +#include +#include +#include + +template +class memory_streambuf: public std::streambuf { +private: + + friend class memorystream; + + //the current buffer + T* buf; + + //the current allocated capacity of the buffer + size_t capacity; + + //whether the sequence is owned by the stringbuf + bool myBuf; + + //the logical length of the buffer + size_t length; + + //the current 'write window' starting position within the buffer for writing. + size_t ww; + + //a vector that we have been told to use + std::vector* usevec; + + +public: + + memory_streambuf(int _capacity) + : buf(new T[capacity=_capacity]) + , myBuf(true) + , length(_capacity) + , ww(0) + , usevec(0) + { + sync(); + } + + + memory_streambuf() + : buf(new T[capacity = 128]) + , myBuf(true) + , length(0) + , ww(0) + , usevec(0) + { + sync(); + } + + //constructs a non-expandable streambuf around the provided buffer + memory_streambuf(T* usebuf, int buflength) + : buf(usebuf) + , myBuf(false) + , length(buflength) + , ww(0) + , usevec(0) + { + sync(); + } + + //constructs an expandable streambuf around the provided buffer + memory_streambuf(std::vector* _usevec) + : capacity(_usevec->size()) + , myBuf(false) + , length(_usevec->size()) + , ww(0) + , usevec(_usevec) + { + if(length>0) + buf = &(*_usevec)[0]; + else buf = 0; + + sync(); + } + + ~memory_streambuf() + { + //only cleanup if we own the seq + if(myBuf) delete[] buf; + } + + //the logical length of the buffer + size_t size() + { + sync(); + return length; + } + + //to avoid copying, rebuilds the provided vector and copies the streambuf contents into it + void toVector(std::vector& out) + { + out.resize(length); + memcpy(&out[0],buf,length); + } + + //maybe the compiler can avoid copying, but maybe not: returns a vector representing the current streambuf + std::vector toVector() + { + return std::vector(buf,buf+length); + } + + //if the memorystream wraps a vector, the vector will be trimmed to the correct size,. + //you probably need to use this if you are using the vector wrapper + void trim() + { + if(!usevec) return; + usevec->resize(size()); + } + + //tells the current read or write position + std::streampos tell(std::ios::openmode which) + { + if(which == std::ios::in) + return tellRead(); + else if(which == std::ios::out) + return tellWrite(); + else return -1; + } + + //tells the current read position + std::streampos tellRead() + { + return gptr()-eback(); + } + + //tells the current write position + std::streampos tellWrite() + { + return pptr()-pbase() + ww; + } + + int sync() + { + dosync(-1); + return 0; + } + + T* getbuf() + { + sync(); + return buf; + } + + //if we were provided a buffer, then calling this gives us ownership of it + void giveBuf() { + myBuf = true; + } + + void expand(size_t upto) + { + if(!myBuf && !usevec) + throw new std::runtime_error("memory_streambuf is not expandable"); + + size_t newcapacity; + if(upto == (size_t)-1) + newcapacity = capacity + capacity/2 + 2; + else + newcapacity = std::max(upto,capacity); + + if(newcapacity == capacity) return; + + //if we are supposed to use the vector, then do it now + if(usevec) + { + usevec->resize(newcapacity); + capacity = usevec->size(); + buf = &(*usevec)[0]; + } + else + { + //otherwise, manage our own buffer + T* newbuf = new T[newcapacity]; + memcpy(newbuf,buf,capacity); + delete[] buf; + capacity = newcapacity; + buf = newbuf; + } + } + +private: + + void dosync(int c) + { + size_t wp = tellWrite(); + size_t rp = tellRead(); + + //if we are supposed to insert a character.. + if(c != -1) + { + buf[wp] = c; + wp++; + } + + //the length is determined by the highest character that was ever inserted + length = std::max(length,wp); + + //the write window advances to begin at the current write insertion point + ww = wp; + + //set the new write and read windows + setp(buf+ww, buf + capacity); + setg(buf, buf+rp, buf + length); + } + +protected: + + int overflow(int c) + { + expand((size_t)-1); + dosync(c); + return 1; + } + + std::streambuf::pos_type seekpos(pos_type pos, std::ios::openmode which) + { + //extend if we are seeking the write cursor + if(which & std::ios_base::out) + expand(pos); + + sync(); + + if(which & std::ios_base::in) + setg(buf, buf+pos, buf + length); + if(which & std::ios_base::out) + { + ww = pos; + setp(buf+pos, buf + capacity); + } + + return pos; + } + + pos_type seekoff(off_type off, std::ios::seekdir way, std::ios::openmode which) + { + switch(way) { + case std::ios::beg: + return seekpos(off, which); + case std::ios::cur: + return seekpos(tell(which)+off, which); + case std::ios::end: + return seekpos(length+off, which); + default: + return -1; + } + } + +}; + +//an iostream that uses the memory_streambuf to effectively act much like a c# memorystream +//please call sync() after writing data if you want to read it back +class memorystream : public std::basic_iostream > +{ +public: + memorystream() + : std::basic_iostream >(&streambuf) + {} + + memorystream(int sz) + : std::basic_iostream >(&streambuf) + , streambuf(sz) + {} + + memorystream(char* usebuf, int buflength) + : std::basic_iostream >(&streambuf) + , streambuf(usebuf, buflength) + {} + + memorystream(std::vector* usevec) + : std::basic_iostream >(&streambuf) + , streambuf(usevec) + {} + + //the underlying memory_streambuf + memory_streambuf streambuf; + + +public: + + size_t size() { return streambuf.size(); } + char* buf() { return streambuf.getbuf(); } + //flushes all the writing state and ensures the stream is ready for reading + void sync() { streambuf.sync(); } + //rewinds the cursors to offset 0 + void rewind() { streambuf.seekpos(0,std::ios::in | std::ios::out); } + + //if the memorystream wraps a vector, the vector will be trimmed to the correct size,. + //you probably need to use this if you are using the vector wrapper + void trim() { streambuf.trim(); } + + void giveBuf() { streambuf.giveBuf(); } + + memory_streambuf& getStreambuf() { return streambuf; } +}; + + +#endif diff --git a/desmume/src/mic.cpp b/src/mic.cpp similarity index 95% rename from desmume/src/mic.cpp rename to src/mic.cpp index c4a468d9a..37c3e374b 100644 --- a/desmume/src/mic.cpp +++ b/src/mic.cpp @@ -1,55 +1,55 @@ -/* mic.cpp - this file is part of DeSmuME - * - * Copyright (C) 2009 DeSmuME Team - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef WIN32 - -#include "types.h" -#include "mic.h" - -static BOOL silence = TRUE; -int MicButtonPressed; - -BOOL Mic_Init() -{ - return TRUE; -} - -void Mic_Reset() -{ -} - -void Mic_DeInit() -{ -} - -u8 Mic_ReadSample() -{ - if (silence) - return 0; - - return 150; -} - -void Mic_DoNoise(BOOL noise) -{ - silence = !noise; -} - -#endif +/* mic.cpp - this file is part of DeSmuME + * + * Copyright (C) 2009 DeSmuME Team + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef WIN32 + +#include "types.h" +#include "mic.h" + +static BOOL silence = TRUE; +int MicButtonPressed; + +BOOL Mic_Init() +{ + return TRUE; +} + +void Mic_Reset() +{ +} + +void Mic_DeInit() +{ +} + +u8 Mic_ReadSample() +{ + if (silence) + return 0; + + return 150; +} + +void Mic_DoNoise(BOOL noise) +{ + silence = !noise; +} + +#endif diff --git a/desmume/src/mic.h b/src/mic.h similarity index 96% rename from desmume/src/mic.h rename to src/mic.h index 4bbdea231..dfe3a309a 100644 --- a/desmume/src/mic.h +++ b/src/mic.h @@ -1,42 +1,42 @@ -/* mic.h - this file is part of DeSmuME - * - * Copyright (C) 2009 DeSmuME Team - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef MIC_H -#define MIC_H - -extern int MicButtonPressed; - -#ifdef WIN32 -static char MicSampleName[256]; -bool LoadSample(const char *name); -#endif - -extern int MicDisplay; - -#ifdef FAKE_MIC -void Mic_DoNoise(BOOL); -#endif - -BOOL Mic_Init(); -void Mic_Reset(); -void Mic_DeInit(); -u8 Mic_ReadSample(); - -#endif +/* mic.h - this file is part of DeSmuME + * + * Copyright (C) 2009 DeSmuME Team + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef MIC_H +#define MIC_H + +extern int MicButtonPressed; + +#ifdef WIN32 +static char MicSampleName[256]; +bool LoadSample(const char *name); +#endif + +extern int MicDisplay; + +#ifdef FAKE_MIC +void Mic_DoNoise(BOOL); +#endif + +BOOL Mic_Init(); +void Mic_Reset(); +void Mic_DeInit(); +u8 Mic_ReadSample(); + +#endif diff --git a/desmume/src/mic_alsa.cpp b/src/mic_alsa.cpp similarity index 100% rename from desmume/src/mic_alsa.cpp rename to src/mic_alsa.cpp diff --git a/desmume/src/movie.cpp b/src/movie.cpp similarity index 96% rename from desmume/src/movie.cpp rename to src/movie.cpp index c728a04ea..8f1b467c3 100644 --- a/desmume/src/movie.cpp +++ b/src/movie.cpp @@ -1,1046 +1,1047 @@ -/* movie.cpp - * - * Copyright (C) 2006-2009 DeSmuME team - * - * This file is part of DeSmuME - * - * DeSmuME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * DeSmuME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with DeSmuME; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include -#include -#include -#include "utils/guid.h" -#include "utils/xstring.h" -#include "movie.h" -#include "NDSSystem.h" -#include "readwrite.h" -#include "debug.h" -#include "rtc.h" -#include "common.h" -#include "mic.h" -#include "version.h" -#include "GPU_osd.h" -#include "memorystream.h" -#include "path.h" - -using namespace std; -bool freshMovie = false; //True when a movie loads, false when movie is altered. Used to determine if a movie has been altered since opening -bool autoMovieBackup = true; - -#define FCEU_PrintError LOG - -#define MOVIE_VERSION 1 - -//----movie engine main state - -EMOVIEMODE movieMode = MOVIEMODE_INACTIVE; - -//this should not be set unless we are in MOVIEMODE_RECORD! -fstream* osRecordingMovie = 0; - -int currFrameCounter; -uint32 cur_input_display = 0; -int pauseframe = -1; -bool movie_readonly = true; - -char curMovieFilename[512] = {0}; -MovieData currMovieData; -int currRerecordCount; -bool movie_reset_command = false; -bool movie_lid = false; -//-------------- - - -void MovieData::clearRecordRange(int start, int len) -{ - for(int i=0;iput(mnemonic); - else //otherwise write an unset bit - os->put('.'); - } -} - - -void MovieRecord::parsePad(std::istream* is, u16& pad) -{ - char buf[13]; - is->read(buf,13); - pad = 0; - for(int i=0;i<13;i++) - { - pad <<= 1; - pad |= ((buf[i]=='.'||buf[i]==' ')?0:1); - } -} - - -void MovieRecord::parse(MovieData* md, std::istream* is) -{ - //by the time we get in here, the initial pipe has already been extracted - - //extract the commands - commands = u32DecFromIstream(is); - - is->get(); //eat the pipe - - parsePad(is, pad); - touch.x = u32DecFromIstream(is); - touch.y = u32DecFromIstream(is); - touch.touch = u32DecFromIstream(is); - - is->get(); //eat the pipe - - //should be left at a newline -} - - -void MovieRecord::dump(MovieData* md, std::ostream* os, int index) -{ - //dump the misc commands - //*os << '|' << setw(1) << (int)commands; - os->put('|'); - putdec(os,commands); - - os->put('|'); - dumpPad(os, pad); - putdec(os,touch.x); os->put(' '); - putdec(os,touch.y); os->put(' '); - putdec(os,touch.touch); - os->put('|'); - - //each frame is on a new line - os->put('\n'); -} - -MovieData::MovieData() - : version(MOVIE_VERSION) - , emuVersion(DESMUME_VERSION_NUMERIC) - , romChecksum(0) - , rerecordCount(1) - , binaryFlag(false) -{ -} - -void MovieData::truncateAt(int frame) -{ - records.resize(frame); -} - - -void MovieData::installValue(std::string& key, std::string& val) -{ - //todo - use another config system, or drive this from a little data structure. because this is gross - if(key == "version") - installInt(val,version); - else if(key == "emuVersion") - installInt(val,emuVersion); - else if(key == "rerecordCount") - installInt(val,rerecordCount); - else if(key == "romFilename") - romFilename = val; - else if(key == "romChecksum") - StringToBytes(val,&romChecksum,MD5DATA::size); - else if(key == "romSerial") - romSerial = val; - else if(key == "guid") - guid = Desmume_Guid::fromString(val); - else if(key == "comment") - comments.push_back(mbstowcs(val)); - else if(key == "binary") - installBool(val,binaryFlag); - else if(key == "savestate") - { - int len = Base64StringToBytesLength(val); - if(len == -1) len = HexStringToBytesLength(val); // wasn't base64, try hex - if(len >= 1) - { - savestate.resize(len); - StringToBytes(val,&savestate[0],len); // decodes either base64 or hex - } - } - else if(key == "sram") - { - int len = Base64StringToBytesLength(val); - if(len == -1) len = HexStringToBytesLength(val); // wasn't base64, try hex - if(len >= 1) - { - sram.resize(len); - StringToBytes(val,&sram[0],len); // decodes either base64 or hex - } - } -} - - -int MovieData::dump(std::ostream *os, bool binary) -{ - int start = os->tellp(); - *os << "version " << version << endl; - *os << "emuVersion " << emuVersion << endl; - *os << "rerecordCount " << rerecordCount << endl; - *os << "romFilename " << romFilename << endl; - *os << "romChecksum " << u32ToHexString(gameInfo.crc) << endl; - *os << "romSerial " << romSerial << endl; - *os << "guid " << guid.toString() << endl; - *os << "useExtBios " << CommonSettings.UseExtBIOS << endl; - - if(CommonSettings.UseExtBIOS) - *os << "swiFromBios " << CommonSettings.SWIFromBIOS << endl; - - for(uint32 i=0;iput('|'); - for(int i=0;i<(int)records.size();i++) - records[i].dumpBinary(this,os,i); - } - else - for(int i=0;i<(int)records.size();i++) - records[i].dump(this,os,i); - - int end = os->tellp(); - return end-start; -} - -//yuck... another custom text parser. -bool LoadFM2(MovieData& movieData, std::istream* fp, int size, bool stopAfterHeader) -{ - //TODO - start with something different. like 'desmume movie version 1" - std::ios::pos_type curr = fp->tellg(); - - //movie must start with "version 1" - char buf[9]; - curr = fp->tellg(); - fp->read(buf,9); - fp->seekg(curr); - if(fp->fail()) return false; - if(memcmp(buf,"version 1",9)) - return false; - - std::string key,value; - enum { - NEWLINE, KEY, SEPARATOR, VALUE, RECORD, COMMENT - } state = NEWLINE; - bool bail = false; - for(;;) - { - bool iswhitespace, isrecchar, isnewline; - int c; - if(size--<=0) goto bail; - c = fp->get(); - if(c == -1) - goto bail; - iswhitespace = (c==' '||c=='\t'); - isrecchar = (c=='|'); - isnewline = (c==10||c==13); - if(isrecchar && movieData.binaryFlag && !stopAfterHeader) - { - LoadFM2_binarychunk(movieData, fp, size); - return true; - } - switch(state) - { - case NEWLINE: - if(isnewline) goto done; - if(iswhitespace) goto done; - if(isrecchar) - goto dorecord; - //must be a key - key = ""; - value = ""; - goto dokey; - break; - case RECORD: - { - dorecord: - if (stopAfterHeader) return true; - int currcount = movieData.records.size(); - movieData.records.resize(currcount+1); - int preparse = fp->tellg(); - movieData.records[currcount].parse(&movieData, fp); - int postparse = fp->tellg(); - size -= (postparse-preparse); - state = NEWLINE; - break; - } - - case KEY: - dokey: //dookie - state = KEY; - if(iswhitespace) goto doseparator; - if(isnewline) goto commit; - key += c; - break; - case SEPARATOR: - doseparator: - state = SEPARATOR; - if(isnewline) goto commit; - if(!iswhitespace) goto dovalue; - break; - case VALUE: - dovalue: - state = VALUE; - if(isnewline) goto commit; - value += c; - break; - case COMMENT: - default: - break; - } - goto done; - - bail: - bail = true; - if(state == VALUE) goto commit; - goto done; - commit: - movieData.installValue(key,value); - state = NEWLINE; - done: ; - if(bail) break; - } - - return true; -} - - -static void closeRecordingMovie() -{ - if(osRecordingMovie) - { - delete osRecordingMovie; - osRecordingMovie = 0; - } -} - -/// Stop movie playback. -static void StopPlayback() -{ - driver->USR_InfoMessage("Movie playback stopped."); - movieMode = MOVIEMODE_INACTIVE; -} - - -/// Stop movie recording -static void StopRecording() -{ - driver->USR_InfoMessage("Movie recording stopped."); - movieMode = MOVIEMODE_INACTIVE; - - closeRecordingMovie(); -} - - - -void FCEUI_StopMovie() -{ - if(movieMode == MOVIEMODE_PLAY) - StopPlayback(); - else if(movieMode == MOVIEMODE_RECORD) - StopRecording(); - - curMovieFilename[0] = 0; - freshMovie = false; -} - - -//begin playing an existing movie -void _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe) -{ - //if(!tasedit && !FCEU_IsValidUI(FCEUI_PLAYMOVIE)) - // return; - - assert(fname); - - //mbg 6/10/08 - we used to call StopMovie here, but that cleared curMovieFilename and gave us crashes... - if(movieMode == MOVIEMODE_PLAY) - StopPlayback(); - else if(movieMode == MOVIEMODE_RECORD) - StopRecording(); - //-------------- - - currMovieData = MovieData(); - - strcpy(curMovieFilename, fname); - //FCEUFILE *fp = FCEU_fopen(fname,0,"rb",0); - //if (!fp) return; - //if(fp->isArchive() && !_read_only) { - // FCEU_PrintError("Cannot open a movie in read+write from an archive."); - // return; - //} - - //LoadFM2(currMovieData, fp->stream, INT_MAX, false); - - - fstream fs (fname); - LoadFM2(currMovieData, &fs, INT_MAX, false); - fs.close(); - - //TODO - //fully reload the game to reinitialize everything before playing any movie - //poweron(true); - - NDS_Reset(); - - ////WE NEED TO LOAD A SAVESTATE - //if(currMovieData.savestate.size() != 0) - //{ - // bool success = MovieData::loadSavestateFrom(&currMovieData.savestate); - // if(!success) return; - //} - lagframecounter=0; - LagFrameFlag=0; - lastLag=0; - TotalLagFrames=0; - - currFrameCounter = 0; - pauseframe = _pauseframe; - movie_readonly = _read_only; - movieMode = MOVIEMODE_PLAY; - currRerecordCount = currMovieData.rerecordCount; - InitMovieTime(); - MMU_new.backupDevice.movie_mode(); - if(currMovieData.sram.size() != 0) - { - bool success = MovieData::loadSramFrom(&currMovieData.sram); - if(!success) return; - } - freshMovie = true; - ClearAutoHold(); - - if(movie_readonly) - driver->USR_InfoMessage("Replay started Read-Only."); - else - driver->USR_InfoMessage("Replay started Read+Write."); -} - -static void openRecordingMovie(const char* fname) -{ - //osRecordingMovie = FCEUD_UTF8_fstream(fname, "wb"); - osRecordingMovie = new fstream(fname,std::ios_base::out); - /*if(!osRecordingMovie) - FCEU_PrintError("Error opening movie output file: %s",fname);*/ - strcpy(curMovieFilename, fname); -} - -bool MovieData::loadSramFrom(std::vector* buf) -{ - memorystream ms(buf); - MMU_new.backupDevice.load_movie(&ms); - return true; -} - -static bool FCEUSS_SaveSRAM(std::ostream* outstream, std:: string fname) -{ - //a temp memory stream. we'll dump some data here and then compress - //TODO - support dumping directly without compressing to save a buffer copy - - memorystream ms; - - //size it - FILE * fp = fopen( fname.c_str(), "r" ); - if(!fp) - return 0; - - fseek( fp, 0, SEEK_END ); - int size = ftell(fp); - fclose(fp); - - filebuf fb; - fb.open (fname.c_str(), ios::in | ios::binary);//ios::in - istream is(&fb); - - char *buffer = new char[size]; - - is.read(buffer, size); - - outstream->write((char*)buffer,size); - - fb.close(); - - return true; -} - -void MovieData::dumpSramTo(std::vector* buf, std::string sramfname) { - - memorystream ms(buf); - FCEUSS_SaveSRAM(&ms, sramfname); - ms.trim(); -} - -//begin recording a new movie -//TODO - BUG - the record-from-another-savestate doesnt work. -void _CDECL_ FCEUI_SaveMovie(const char *fname, std::wstring author, int flag, std::string sramfname) -{ - //if(!FCEU_IsValidUI(FCEUI_RECORDMOVIE)) - // return; - - assert(fname); - - FCEUI_StopMovie(); - - openRecordingMovie(fname); - - currFrameCounter = 0; - //LagCounterReset(); - - currMovieData = MovieData(); - currMovieData.guid.newGuid(); - - if(author != L"") currMovieData.comments.push_back(L"author " + author); - currMovieData.romChecksum = gameInfo.crc; - currMovieData.romSerial = gameInfo.ROMserial; - currMovieData.romFilename = path.GetRomName(); - - NDS_Reset(); - - //todo ? - //poweron(true); - //else - // MovieData::dumpSavestateTo(&currMovieData.savestate,Z_BEST_COMPRESSION); - - if(flag == 1) - MovieData::dumpSramTo(&currMovieData.sram, sramfname); - - //we are going to go ahead and dump the header. from now on we will only be appending frames - currMovieData.dump(osRecordingMovie, false); - - currFrameCounter=0; - lagframecounter=0; - LagFrameFlag=0; - lastLag=0; - TotalLagFrames=0; - - movieMode = MOVIEMODE_RECORD; - movie_readonly = false; - currRerecordCount = 0; - InitMovieTime(); - MMU_new.backupDevice.movie_mode(); - - if(currMovieData.sram.size() != 0) - { - bool success = MovieData::loadSramFrom(&currMovieData.sram); - if(!success) return; - } - - driver->USR_InfoMessage("Movie recording started."); -} - - void NDS_setTouchFromMovie(void) { - - if(movieMode == MOVIEMODE_PLAY) - { - - MovieRecord* mr = &currMovieData.records[currFrameCounter]; - nds.touchX=mr->touch.x << 4; - nds.touchY=mr->touch.y << 4; - - if(mr->touch.touch) { - nds.isTouch=mr->touch.touch; - MMU.ARM7_REG[0x136] &= 0xBF; - } - else { - nds.touchX=0; - nds.touchY=0; - nds.isTouch=0; - - MMU.ARM7_REG[0x136] |= 0x40; - } - //osd->addFixed(mr->touch.x, mr->touch.y, "%s", "X"); - } - } - - //the main interaction point between the emulator and the movie system. - //either dumps the current joystick state or loads one state from the movie - void FCEUMOV_AddInputState() - { - if(movieMode == MOVIEMODE_PLAY) - { - //stop when we run out of frames - if(currFrameCounter == (int)currMovieData.records.size()) - { - StopPlayback(); - } - else - { - MovieRecord* mr = &currMovieData.records[currFrameCounter]; - - if(mr->command_microphone()) MicButtonPressed=1; - else MicButtonPressed=0; - - if(mr->command_reset()) NDS_Reset(); - - if(mr->command_lid()) movie_lid = true; - else movie_lid = false; - - NDS_setPadFromMovie(mr->pad); - NDS_setTouchFromMovie(); - } - - //if we are on the last frame, then pause the emulator if the player requested it - if(currFrameCounter == (int)currMovieData.records.size()-1) - { - /*if(FCEUD_PauseAfterPlayback()) - { - FCEUI_ToggleEmulationPause(); - }*/ - } - - //pause the movie at a specified frame - //if(FCEUMOV_ShouldPause() && FCEUI_EmulationPaused()==0) - //{ - // FCEUI_ToggleEmulationPause(); - // FCEU_DispMessage("Paused at specified movie frame"); - //} - osd->addFixed(180, 176, "%s", "Playback"); - - } - else if(movieMode == MOVIEMODE_RECORD) - { - MovieRecord mr; - - mr.commands = 0; - - if(MicButtonPressed == 1) - mr.commands=1; - - mr.pad = nds.pad; - - if(movie_lid) { - mr.commands=4; - movie_lid = false; - } - - if(movie_reset_command) { - mr.commands=2; - movie_reset_command = false; - } - - if(nds.isTouch) { - mr.touch.x = nds.touchX >> 4; - mr.touch.y = nds.touchY >> 4; - mr.touch.touch = 1; - } else { - mr.touch.x = 0; - mr.touch.y = 0; - mr.touch.touch = 0; - } - - mr.dump(&currMovieData, osRecordingMovie,currMovieData.records.size()); - currMovieData.records.push_back(mr); - osd->addFixed(180, 176, "%s", "Recording"); - } - - /*extern uint8 joy[4]; - memcpy(&cur_input_display,joy,4);*/ - } - - -//TODO -static void FCEUMOV_AddCommand(int cmd) -{ - // do nothing if not recording a movie - if(movieMode != MOVIEMODE_RECORD) - return; - - //printf("%d\n",cmd); - - //MBG TODO BIG TODO TODO TODO - //DoEncode((cmd>>3)&0x3,cmd&0x7,1); -} - -//little endian 4-byte cookies -static const int kMOVI = 0x49564F4D; -static const int kNOMO = 0x4F4D4F4E; - -void mov_savestate(std::ostream* os) -{ - //we are supposed to dump the movie data into the savestate - //if(movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_PLAY) - // return currMovieData.dump(os, true); - //else return 0; - if(movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_PLAY) - { - write32le(kMOVI,os); - currMovieData.dump(os, true); - } - else - { - write32le(kNOMO,os); - } -} - - - -static bool load_successful; - -bool mov_loadstate(std::istream* is, int size) -{ - load_successful = false; - - int cookie; - if(read32le(&cookie,is) != 1) return false; - if(cookie == kNOMO) - return true; - else if(cookie != kMOVI) - return false; - - size -= 4; - - if (!movie_readonly && autoMovieBackup && freshMovie) //If auto-backup is on, movie has not been altered this session and the movie is in read+write mode - { - FCEUI_MakeBackupMovie(false); //Backup the movie before the contents get altered, but do not display messages - } - - //a little rule: cant load states in read+write mode with a movie from an archive. - //so we are going to switch it to readonly mode in that case -// if(!movie_readonly -// //*&& FCEU_isFileInArchive(curMovieFilename)*/ -// ) { -// FCEU_PrintError("Cannot loadstate in Read+Write with movie from archive. Movie is now Read-Only."); -// movie_readonly = true; -// } - - MovieData tempMovieData = MovieData(); - std::ios::pos_type curr = is->tellg(); - if(!LoadFM2(tempMovieData, is, size, false)) { - - // is->seekg((uint32)curr+size); - /* extern bool FCEU_state_loading_old_format; - if(FCEU_state_loading_old_format) { - if(movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_RECORD) { - FCEUI_StopMovie(); - FCEU_PrintError("You have tried to use an old savestate while playing a movie. This is unsupported (since the old savestate has old-format movie data in it which can't be converted on the fly)"); - } - }*/ - return false; - } - - //complex TAS logic for when a savestate is loaded: - //---------------- - //if we are playing or recording and toggled read-only: - // then, the movie we are playing must match the guid of the one stored in the savestate or else error. - // the savestate is assumed to be in the same timeline as the current movie. - // if the current movie is not long enough to get to the savestate's frame#, then it is an error. - // the movie contained in the savestate will be discarded. - // the emulator will be put into play mode. - //if we are playing or recording and toggled read+write - // then, the movie we are playing must match the guid of the one stored in the savestate or else error. - // the movie contained in the savestate will be loaded into memory - // the frames in the movie after the savestate frame will be discarded - // the in-memory movie will have its rerecord count incremented - // the in-memory movie will be dumped to disk as fcm. - // the emulator will be put into record mode. - //if we are doing neither: - // then, we must discard this movie and just load the savestate - - - if(movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_RECORD) - { - //handle moviefile mismatch - if(tempMovieData.guid != currMovieData.guid) - { - //mbg 8/18/08 - this code can be used to turn the error message into an OK/CANCEL - #ifdef WIN32 - //std::string msg = "There is a mismatch between savestate's movie and current movie.\ncurrent: " + currMovieData.guid.toString() + "\nsavestate: " + tempMovieData.guid.toString() + "\n\nThis means that you have loaded a savestate belonging to a different movie than the one you are playing now.\n\nContinue loading this savestate anyway?"; - //extern HWND pwindow; - //int result = MessageBox(pwindow,msg.c_str(),"Error loading savestate",MB_OKCANCEL); - //if(result == IDCANCEL) - // return false; - #else - FCEU_PrintError("Mismatch between savestate's movie and current movie.\ncurrent: %s\nsavestate: %s\n",currMovieData.guid.toString().c_str(),tempMovieData.guid.toString().c_str()); - return false; - #endif - } - - closeRecordingMovie(); - - if(movie_readonly) - { - //------------------------------------------------------------- - //this code would reload the movie from disk. allegedly it is helpful to hexers, but - //it is way too slow with dsm format. so it is only here as a reminder, and in case someone - //wants to play with it - //------------------------------------------------------------- - //{ - // fstream fs (curMovieFilename); - // if(!LoadFM2(tempMovieData, &fs, INT_MAX, false)) - // { - // FCEU_PrintError("Failed to reload DSM after loading savestate"); - // } - // fs.close(); - // currMovieData = tempMovieData; - //} - //------------------------------------------------------------- - - //if the frame counter is longer than our current movie, then error - if(currFrameCounter > (int)currMovieData.records.size()) - { - FCEU_PrintError("Savestate is from a frame (%d) after the final frame in the movie (%d). This is not permitted.", currFrameCounter, currMovieData.records.size()-1); - return false; - } - - movieMode = MOVIEMODE_PLAY; - } - else - { - //truncate before we copy, just to save some time - tempMovieData.truncateAt(currFrameCounter); - currMovieData = tempMovieData; - - // #ifdef _S9XLUA_H - // if(!FCEU_LuaRerecordCountSkip()) - currRerecordCount++; - // #endif - - currMovieData.rerecordCount = currRerecordCount; - - openRecordingMovie(curMovieFilename); - //printf("DUMPING MOVIE: %d FRAMES\n",currMovieData.records.size()); - currMovieData.dump(osRecordingMovie, false); - movieMode = MOVIEMODE_RECORD; - } - } - - load_successful = true; - freshMovie = false; - - //// Maximus: Show the last input combination entered from the - //// movie within the state - //if(current!=0) // <- mz: only if playing or recording a movie - // memcpy(&cur_input_display, joop, 4); - - return true; -} - -static void FCEUMOV_PreLoad(void) -{ - load_successful=0; -} - -static bool FCEUMOV_PostLoad(void) -{ - if(movieMode == MOVIEMODE_INACTIVE) - return true; - else - return load_successful; -} - - -bool FCEUI_MovieGetInfo(std::istream* fp, MOVIE_INFO& info, bool skipFrameCount) -{ - //MovieData md; - //if(!LoadFM2(md, fp, INT_MAX, skipFrameCount)) - // return false; - // - //info.movie_version = md.version; - //info.poweron = md.savestate.size()==0; - //info.pal = md.palFlag; - //info.nosynchack = true; - //info.num_frames = md.records.size(); - //info.md5_of_rom_used = md.romChecksum; - //info.emu_version_used = md.emuVersion; - //info.name_of_rom_used = md.romFilename; - //info.rerecord_count = md.rerecordCount; - //info.comments = md.comments; - - return true; -} - -bool MovieRecord::parseBinary(MovieData* md, std::istream* is) -{ - commands=is->get(); - is->read((char *) &pad, sizeof pad); - is->read((char *) &touch.x, sizeof touch.x); - is->read((char *) &touch.y, sizeof touch.y); - is->read((char *) &touch.touch, sizeof touch.touch); - return true; -} - - -void MovieRecord::dumpBinary(MovieData* md, std::ostream* os, int index) -{ - os->put(md->records[index].commands); - os->write((char *) &md->records[index].pad, sizeof md->records[index].pad); - os->write((char *) &md->records[index].touch.x, sizeof md->records[index].touch.x); - os->write((char *) &md->records[index].touch.y, sizeof md->records[index].touch.y); - os->write((char *) &md->records[index].touch.touch, sizeof md->records[index].touch.touch); -} - -void LoadFM2_binarychunk(MovieData& movieData, std::istream* fp, int size) -{ - int recordsize = 1; //1 for the command - - recordsize = 6; - - assert(size%6==0); - - //find out how much remains in the file - int curr = fp->tellg(); - fp->seekg(0,std::ios::end); - int end = fp->tellg(); - int flen = end-curr; - fp->seekg(curr,std::ios::beg); - - //the amount todo is the min of the limiting size we received and the remaining contents of the file - int todo = std::min(size, flen); - - int numRecords = todo/recordsize; - //printf("LOADED MOVIE: %d records; currFrameCounter: %d\n",numRecords,currFrameCounter); - movieData.records.resize(numRecords); - for(int i=0;i - -static bool CheckFileExists(const char* filename) -{ - //This function simply checks to see if the given filename exists - string checkFilename; - - if (filename) - checkFilename = filename; - - //Check if this filename exists - fstream test; - test.open(checkFilename.c_str(),fstream::in); - - if (test.fail()) - { - test.close(); - return false; - } - else - { - test.close(); - return true; - } -} - -void FCEUI_MakeBackupMovie(bool dispMessage) -{ - //This function generates backup movie files - string currentFn; //Current movie fillename - string backupFn; //Target backup filename - string tempFn; //temp used in back filename creation - stringstream stream; - int x; //Temp variable for string manip - bool exist = false; //Used to test if filename exists - bool overflow = false; //Used for special situation when backup numbering exceeds limit - - currentFn = curMovieFilename; //Get current moviefilename - backupFn = curMovieFilename; //Make backup filename the same as current moviefilename - x = backupFn.find_last_of("."); //Find file extension - backupFn = backupFn.substr(0,x); //Remove extension - tempFn = backupFn; //Store the filename at this point - for (unsigned int backNum=0;backNum<999;backNum++) //999 = arbituary limit to backup files - { - stream.str(""); //Clear stream - if (backNum > 99) - stream << "-" << backNum; //assign backNum to stream - else if (backNum <= 99 && backNum >= 10) - stream << "-0" << backNum; //Make it 010, etc if two digits - else - stream << "-00" << backNum; //Make it 001, etc if single digit - backupFn.append(stream.str()); //add number to bak filename - backupFn.append(".bak"); //add extension - - exist = CheckFileExists(backupFn.c_str()); //Check if file exists - - if (!exist) - break; //Yeah yeah, I should use a do loop or something - else - { - backupFn = tempFn; //Before we loop again, reset the filename - - if (backNum == 999) //If 999 exists, we have overflowed, let's handle that - { - backupFn.append("-001.bak"); //We are going to simply overwrite 001.bak - overflow = true; //Flag that we have exceeded limit - break; //Just in case - } - } - } - - MovieData md = currMovieData; //Get current movie data - std::fstream* outf = new fstream(backupFn.c_str(),std::ios_base::out); //FCEUD_UTF8_fstream(backupFn, "wb"); //open/create file - md.dump(outf,false); //dump movie data - delete outf; //clean up, delete file object - - //TODO, decide if fstream successfully opened the file and print error message if it doesn't - - if (dispMessage) //If we should inform the user - { -// if (overflow) -// FCEUI_DispMessage("Backup overflow, overwriting %s",backupFn.c_str()); //Inform user of overflow -// else -// FCEUI_DispMessage("%s created",backupFn.c_str()); //Inform user of backup filename - } -} - +/* movie.cpp + * + * Copyright (C) 2006-2009 DeSmuME team + * + * This file is part of DeSmuME + * + * DeSmuME is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * DeSmuME is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with DeSmuME; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include +#include +#include "utils/guid.h" +#include "utils/xstring.h" +#include "movie.h" +#include "NDSSystem.h" +#include "readwrite.h" +#include "debug.h" +#include "rtc.h" +#include "common.h" +#include "mic.h" +#include "version.h" +#include "GPU_osd.h" +#include "memorystream.h" +#include "path.h" + +using namespace std; +bool freshMovie = false; //True when a movie loads, false when movie is altered. Used to determine if a movie has been altered since opening +bool autoMovieBackup = true; + +#define FCEU_PrintError LOG + +#define MOVIE_VERSION 1 + +//----movie engine main state + +EMOVIEMODE movieMode = MOVIEMODE_INACTIVE; + +//this should not be set unless we are in MOVIEMODE_RECORD! +fstream* osRecordingMovie = 0; + +int currFrameCounter; +uint32 cur_input_display = 0; +int pauseframe = -1; +bool movie_readonly = true; + +char curMovieFilename[512] = {0}; +MovieData currMovieData; +int currRerecordCount; +bool movie_reset_command = false; +bool movie_lid = false; +//-------------- + + +void MovieData::clearRecordRange(int start, int len) +{ + for(int i=0;iput(mnemonic); + else //otherwise write an unset bit + os->put('.'); + } +} + + +void MovieRecord::parsePad(std::istream* is, u16& pad) +{ + char buf[13]; + is->read(buf,13); + pad = 0; + for(int i=0;i<13;i++) + { + pad <<= 1; + pad |= ((buf[i]=='.'||buf[i]==' ')?0:1); + } +} + + +void MovieRecord::parse(MovieData* md, std::istream* is) +{ + //by the time we get in here, the initial pipe has already been extracted + + //extract the commands + commands = u32DecFromIstream(is); + + is->get(); //eat the pipe + + parsePad(is, pad); + touch.x = u32DecFromIstream(is); + touch.y = u32DecFromIstream(is); + touch.touch = u32DecFromIstream(is); + + is->get(); //eat the pipe + + //should be left at a newline +} + + +void MovieRecord::dump(MovieData* md, std::ostream* os, int index) +{ + //dump the misc commands + //*os << '|' << setw(1) << (int)commands; + os->put('|'); + putdec(os,commands); + + os->put('|'); + dumpPad(os, pad); + putdec(os,touch.x); os->put(' '); + putdec(os,touch.y); os->put(' '); + putdec(os,touch.touch); + os->put('|'); + + //each frame is on a new line + os->put('\n'); +} + +MovieData::MovieData() + : version(MOVIE_VERSION) + , emuVersion(DESMUME_VERSION_NUMERIC) + , romChecksum(0) + , rerecordCount(1) + , binaryFlag(false) +{ +} + +void MovieData::truncateAt(int frame) +{ + records.resize(frame); +} + + +void MovieData::installValue(std::string& key, std::string& val) +{ + //todo - use another config system, or drive this from a little data structure. because this is gross + if(key == "version") + installInt(val,version); + else if(key == "emuVersion") + installInt(val,emuVersion); + else if(key == "rerecordCount") + installInt(val,rerecordCount); + else if(key == "romFilename") + romFilename = val; + else if(key == "romChecksum") + StringToBytes(val,&romChecksum,MD5DATA::size); + else if(key == "romSerial") + romSerial = val; + else if(key == "guid") + guid = Desmume_Guid::fromString(val); + else if(key == "comment") + comments.push_back(mbstowcs(val)); + else if(key == "binary") + installBool(val,binaryFlag); + else if(key == "savestate") + { + int len = Base64StringToBytesLength(val); + if(len == -1) len = HexStringToBytesLength(val); // wasn't base64, try hex + if(len >= 1) + { + savestate.resize(len); + StringToBytes(val,&savestate[0],len); // decodes either base64 or hex + } + } + else if(key == "sram") + { + int len = Base64StringToBytesLength(val); + if(len == -1) len = HexStringToBytesLength(val); // wasn't base64, try hex + if(len >= 1) + { + sram.resize(len); + StringToBytes(val,&sram[0],len); // decodes either base64 or hex + } + } +} + + +int MovieData::dump(std::ostream *os, bool binary) +{ + int start = os->tellp(); + *os << "version " << version << endl; + *os << "emuVersion " << emuVersion << endl; + *os << "rerecordCount " << rerecordCount << endl; + *os << "romFilename " << romFilename << endl; + *os << "romChecksum " << u32ToHexString(gameInfo.crc) << endl; + *os << "romSerial " << romSerial << endl; + *os << "guid " << guid.toString() << endl; + *os << "useExtBios " << CommonSettings.UseExtBIOS << endl; + + if(CommonSettings.UseExtBIOS) + *os << "swiFromBios " << CommonSettings.SWIFromBIOS << endl; + + for(uint32 i=0;iput('|'); + for(int i=0;i<(int)records.size();i++) + records[i].dumpBinary(this,os,i); + } + else + for(int i=0;i<(int)records.size();i++) + records[i].dump(this,os,i); + + int end = os->tellp(); + return end-start; +} + +//yuck... another custom text parser. +bool LoadFM2(MovieData& movieData, std::istream* fp, int size, bool stopAfterHeader) +{ + //TODO - start with something different. like 'desmume movie version 1" + std::ios::pos_type curr = fp->tellg(); + + //movie must start with "version 1" + char buf[9]; + curr = fp->tellg(); + fp->read(buf,9); + fp->seekg(curr); + if(fp->fail()) return false; + if(memcmp(buf,"version 1",9)) + return false; + + std::string key,value; + enum { + NEWLINE, KEY, SEPARATOR, VALUE, RECORD, COMMENT + } state = NEWLINE; + bool bail = false; + for(;;) + { + bool iswhitespace, isrecchar, isnewline; + int c; + if(size--<=0) goto bail; + c = fp->get(); + if(c == -1) + goto bail; + iswhitespace = (c==' '||c=='\t'); + isrecchar = (c=='|'); + isnewline = (c==10||c==13); + if(isrecchar && movieData.binaryFlag && !stopAfterHeader) + { + LoadFM2_binarychunk(movieData, fp, size); + return true; + } + switch(state) + { + case NEWLINE: + if(isnewline) goto done; + if(iswhitespace) goto done; + if(isrecchar) + goto dorecord; + //must be a key + key = ""; + value = ""; + goto dokey; + break; + case RECORD: + { + dorecord: + if (stopAfterHeader) return true; + int currcount = movieData.records.size(); + movieData.records.resize(currcount+1); + int preparse = fp->tellg(); + movieData.records[currcount].parse(&movieData, fp); + int postparse = fp->tellg(); + size -= (postparse-preparse); + state = NEWLINE; + break; + } + + case KEY: + dokey: //dookie + state = KEY; + if(iswhitespace) goto doseparator; + if(isnewline) goto commit; + key += c; + break; + case SEPARATOR: + doseparator: + state = SEPARATOR; + if(isnewline) goto commit; + if(!iswhitespace) goto dovalue; + break; + case VALUE: + dovalue: + state = VALUE; + if(isnewline) goto commit; + value += c; + break; + case COMMENT: + default: + break; + } + goto done; + + bail: + bail = true; + if(state == VALUE) goto commit; + goto done; + commit: + movieData.installValue(key,value); + state = NEWLINE; + done: ; + if(bail) break; + } + + return true; +} + + +static void closeRecordingMovie() +{ + if(osRecordingMovie) + { + delete osRecordingMovie; + osRecordingMovie = 0; + } +} + +/// Stop movie playback. +static void StopPlayback() +{ + driver->USR_InfoMessage("Movie playback stopped."); + movieMode = MOVIEMODE_INACTIVE; +} + + +/// Stop movie recording +static void StopRecording() +{ + driver->USR_InfoMessage("Movie recording stopped."); + movieMode = MOVIEMODE_INACTIVE; + + closeRecordingMovie(); +} + + + +void FCEUI_StopMovie() +{ + if(movieMode == MOVIEMODE_PLAY) + StopPlayback(); + else if(movieMode == MOVIEMODE_RECORD) + StopRecording(); + + curMovieFilename[0] = 0; + freshMovie = false; +} + + +//begin playing an existing movie +void _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe) +{ + //if(!tasedit && !FCEU_IsValidUI(FCEUI_PLAYMOVIE)) + // return; + + assert(fname); + + //mbg 6/10/08 - we used to call StopMovie here, but that cleared curMovieFilename and gave us crashes... + if(movieMode == MOVIEMODE_PLAY) + StopPlayback(); + else if(movieMode == MOVIEMODE_RECORD) + StopRecording(); + //-------------- + + currMovieData = MovieData(); + + strcpy(curMovieFilename, fname); + //FCEUFILE *fp = FCEU_fopen(fname,0,"rb",0); + //if (!fp) return; + //if(fp->isArchive() && !_read_only) { + // FCEU_PrintError("Cannot open a movie in read+write from an archive."); + // return; + //} + + //LoadFM2(currMovieData, fp->stream, INT_MAX, false); + + + fstream fs (fname); + LoadFM2(currMovieData, &fs, INT_MAX, false); + fs.close(); + + //TODO + //fully reload the game to reinitialize everything before playing any movie + //poweron(true); + + NDS_Reset(); + + ////WE NEED TO LOAD A SAVESTATE + //if(currMovieData.savestate.size() != 0) + //{ + // bool success = MovieData::loadSavestateFrom(&currMovieData.savestate); + // if(!success) return; + //} + lagframecounter=0; + LagFrameFlag=0; + lastLag=0; + TotalLagFrames=0; + + currFrameCounter = 0; + pauseframe = _pauseframe; + movie_readonly = _read_only; + movieMode = MOVIEMODE_PLAY; + currRerecordCount = currMovieData.rerecordCount; + InitMovieTime(); + MMU_new.backupDevice.movie_mode(); + if(currMovieData.sram.size() != 0) + { + bool success = MovieData::loadSramFrom(&currMovieData.sram); + if(!success) return; + } + freshMovie = true; + ClearAutoHold(); + + if(movie_readonly) + driver->USR_InfoMessage("Replay started Read-Only."); + else + driver->USR_InfoMessage("Replay started Read+Write."); +} + +static void openRecordingMovie(const char* fname) +{ + //osRecordingMovie = FCEUD_UTF8_fstream(fname, "wb"); + osRecordingMovie = new fstream(fname,std::ios_base::out); + /*if(!osRecordingMovie) + FCEU_PrintError("Error opening movie output file: %s",fname);*/ + strcpy(curMovieFilename, fname); +} + +bool MovieData::loadSramFrom(std::vector* buf) +{ + memorystream ms(buf); + MMU_new.backupDevice.load_movie(&ms); + return true; +} + +static bool FCEUSS_SaveSRAM(std::ostream* outstream, std:: string fname) +{ + //a temp memory stream. we'll dump some data here and then compress + //TODO - support dumping directly without compressing to save a buffer copy + + memorystream ms; + std::ostream* os = (std::ostream*)&ms; + + //size it + FILE * fp = fopen( fname.c_str(), "r" ); + if(!fp) + return 0; + + fseek( fp, 0, SEEK_END ); + int size = ftell(fp); + fclose(fp); + + filebuf fb; + fb.open (fname.c_str(), ios::in | ios::binary);//ios::in + istream is(&fb); + + char *buffer = new char[size]; + + is.read(buffer, size); + + outstream->write((char*)buffer,size); + + fb.close(); + + return true; +} + +void MovieData::dumpSramTo(std::vector* buf, std::string sramfname) { + + memorystream ms(buf); + FCEUSS_SaveSRAM(&ms, sramfname); + ms.trim(); +} + +//begin recording a new movie +//TODO - BUG - the record-from-another-savestate doesnt work. +void _CDECL_ FCEUI_SaveMovie(const char *fname, std::wstring author, int flag, std::string sramfname) +{ + //if(!FCEU_IsValidUI(FCEUI_RECORDMOVIE)) + // return; + + assert(fname); + + FCEUI_StopMovie(); + + openRecordingMovie(fname); + + currFrameCounter = 0; + //LagCounterReset(); + + currMovieData = MovieData(); + currMovieData.guid.newGuid(); + + if(author != L"") currMovieData.comments.push_back(L"author " + author); + currMovieData.romChecksum = gameInfo.crc; + currMovieData.romSerial = gameInfo.ROMserial; + currMovieData.romFilename = path.GetRomName(); + + NDS_Reset(); + + //todo ? + //poweron(true); + //else + // MovieData::dumpSavestateTo(&currMovieData.savestate,Z_BEST_COMPRESSION); + + if(flag == 1) + MovieData::dumpSramTo(&currMovieData.sram, sramfname); + + //we are going to go ahead and dump the header. from now on we will only be appending frames + currMovieData.dump(osRecordingMovie, false); + + currFrameCounter=0; + lagframecounter=0; + LagFrameFlag=0; + lastLag=0; + TotalLagFrames=0; + + movieMode = MOVIEMODE_RECORD; + movie_readonly = false; + currRerecordCount = 0; + InitMovieTime(); + MMU_new.backupDevice.movie_mode(); + + if(currMovieData.sram.size() != 0) + { + bool success = MovieData::loadSramFrom(&currMovieData.sram); + if(!success) return; + } + + driver->USR_InfoMessage("Movie recording started."); +} + + void NDS_setTouchFromMovie(void) { + + if(movieMode == MOVIEMODE_PLAY) + { + + MovieRecord* mr = &currMovieData.records[currFrameCounter]; + nds.touchX=mr->touch.x << 4; + nds.touchY=mr->touch.y << 4; + + if(mr->touch.touch) { + nds.isTouch=mr->touch.touch; + MMU.ARM7_REG[0x136] &= 0xBF; + } + else { + nds.touchX=0; + nds.touchY=0; + nds.isTouch=0; + + MMU.ARM7_REG[0x136] |= 0x40; + } + //osd->addFixed(mr->touch.x, mr->touch.y, "%s", "X"); + } + } + + //the main interaction point between the emulator and the movie system. + //either dumps the current joystick state or loads one state from the movie + void FCEUMOV_AddInputState() + { + if(movieMode == MOVIEMODE_PLAY) + { + //stop when we run out of frames + if(currFrameCounter == (int)currMovieData.records.size()) + { + StopPlayback(); + } + else + { + MovieRecord* mr = &currMovieData.records[currFrameCounter]; + + if(mr->command_microphone()) MicButtonPressed=1; + else MicButtonPressed=0; + + if(mr->command_reset()) NDS_Reset(); + + if(mr->command_lid()) movie_lid = true; + else movie_lid = false; + + NDS_setPadFromMovie(mr->pad); + NDS_setTouchFromMovie(); + } + + //if we are on the last frame, then pause the emulator if the player requested it + if(currFrameCounter == (int)currMovieData.records.size()-1) + { + /*if(FCEUD_PauseAfterPlayback()) + { + FCEUI_ToggleEmulationPause(); + }*/ + } + + //pause the movie at a specified frame + //if(FCEUMOV_ShouldPause() && FCEUI_EmulationPaused()==0) + //{ + // FCEUI_ToggleEmulationPause(); + // FCEU_DispMessage("Paused at specified movie frame"); + //} + osd->addFixed(180, 176, "%s", "Playback"); + + } + else if(movieMode == MOVIEMODE_RECORD) + { + MovieRecord mr; + + mr.commands = 0; + + if(MicButtonPressed == 1) + mr.commands=1; + + mr.pad = nds.pad; + + if(movie_lid) { + mr.commands=4; + movie_lid = false; + } + + if(movie_reset_command) { + mr.commands=2; + movie_reset_command = false; + } + + if(nds.isTouch) { + mr.touch.x = nds.touchX >> 4; + mr.touch.y = nds.touchY >> 4; + mr.touch.touch = 1; + } else { + mr.touch.x = 0; + mr.touch.y = 0; + mr.touch.touch = 0; + } + + mr.dump(&currMovieData, osRecordingMovie,currMovieData.records.size()); + currMovieData.records.push_back(mr); + osd->addFixed(180, 176, "%s", "Recording"); + } + + /*extern uint8 joy[4]; + memcpy(&cur_input_display,joy,4);*/ + } + + +//TODO +static void FCEUMOV_AddCommand(int cmd) +{ + // do nothing if not recording a movie + if(movieMode != MOVIEMODE_RECORD) + return; + + //printf("%d\n",cmd); + + //MBG TODO BIG TODO TODO TODO + //DoEncode((cmd>>3)&0x3,cmd&0x7,1); +} + +//little endian 4-byte cookies +static const int kMOVI = 0x49564F4D; +static const int kNOMO = 0x4F4D4F4E; + +void mov_savestate(std::ostream* os) +{ + //we are supposed to dump the movie data into the savestate + //if(movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_PLAY) + // return currMovieData.dump(os, true); + //else return 0; + if(movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_PLAY) + { + write32le(kMOVI,os); + currMovieData.dump(os, true); + } + else + { + write32le(kNOMO,os); + } +} + + + +static bool load_successful; + +bool mov_loadstate(std::istream* is, int size) +{ + load_successful = false; + + int cookie; + if(read32le(&cookie,is) != 1) return false; + if(cookie == kNOMO) + return true; + else if(cookie != kMOVI) + return false; + + size -= 4; + + if (!movie_readonly && autoMovieBackup && freshMovie) //If auto-backup is on, movie has not been altered this session and the movie is in read+write mode + { + FCEUI_MakeBackupMovie(false); //Backup the movie before the contents get altered, but do not display messages + } + + //a little rule: cant load states in read+write mode with a movie from an archive. + //so we are going to switch it to readonly mode in that case +// if(!movie_readonly +// //*&& FCEU_isFileInArchive(curMovieFilename)*/ +// ) { +// FCEU_PrintError("Cannot loadstate in Read+Write with movie from archive. Movie is now Read-Only."); +// movie_readonly = true; +// } + + MovieData tempMovieData = MovieData(); + std::ios::pos_type curr = is->tellg(); + if(!LoadFM2(tempMovieData, is, size, false)) { + + // is->seekg((uint32)curr+size); + /* extern bool FCEU_state_loading_old_format; + if(FCEU_state_loading_old_format) { + if(movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_RECORD) { + FCEUI_StopMovie(); + FCEU_PrintError("You have tried to use an old savestate while playing a movie. This is unsupported (since the old savestate has old-format movie data in it which can't be converted on the fly)"); + } + }*/ + return false; + } + + //complex TAS logic for when a savestate is loaded: + //---------------- + //if we are playing or recording and toggled read-only: + // then, the movie we are playing must match the guid of the one stored in the savestate or else error. + // the savestate is assumed to be in the same timeline as the current movie. + // if the current movie is not long enough to get to the savestate's frame#, then it is an error. + // the movie contained in the savestate will be discarded. + // the emulator will be put into play mode. + //if we are playing or recording and toggled read+write + // then, the movie we are playing must match the guid of the one stored in the savestate or else error. + // the movie contained in the savestate will be loaded into memory + // the frames in the movie after the savestate frame will be discarded + // the in-memory movie will have its rerecord count incremented + // the in-memory movie will be dumped to disk as fcm. + // the emulator will be put into record mode. + //if we are doing neither: + // then, we must discard this movie and just load the savestate + + + if(movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_RECORD) + { + //handle moviefile mismatch + if(tempMovieData.guid != currMovieData.guid) + { + //mbg 8/18/08 - this code can be used to turn the error message into an OK/CANCEL + #ifdef WIN32 + //std::string msg = "There is a mismatch between savestate's movie and current movie.\ncurrent: " + currMovieData.guid.toString() + "\nsavestate: " + tempMovieData.guid.toString() + "\n\nThis means that you have loaded a savestate belonging to a different movie than the one you are playing now.\n\nContinue loading this savestate anyway?"; + //extern HWND pwindow; + //int result = MessageBox(pwindow,msg.c_str(),"Error loading savestate",MB_OKCANCEL); + //if(result == IDCANCEL) + // return false; + #else + FCEU_PrintError("Mismatch between savestate's movie and current movie.\ncurrent: %s\nsavestate: %s\n",currMovieData.guid.toString().c_str(),tempMovieData.guid.toString().c_str()); + return false; + #endif + } + + closeRecordingMovie(); + + if(movie_readonly) + { + //------------------------------------------------------------- + //this code would reload the movie from disk. allegedly it is helpful to hexers, but + //it is way too slow with dsm format. so it is only here as a reminder, and in case someone + //wants to play with it + //------------------------------------------------------------- + //{ + // fstream fs (curMovieFilename); + // if(!LoadFM2(tempMovieData, &fs, INT_MAX, false)) + // { + // FCEU_PrintError("Failed to reload DSM after loading savestate"); + // } + // fs.close(); + // currMovieData = tempMovieData; + //} + //------------------------------------------------------------- + + //if the frame counter is longer than our current movie, then error + if(currFrameCounter > (int)currMovieData.records.size()) + { + FCEU_PrintError("Savestate is from a frame (%d) after the final frame in the movie (%d). This is not permitted.", currFrameCounter, currMovieData.records.size()-1); + return false; + } + + movieMode = MOVIEMODE_PLAY; + } + else + { + //truncate before we copy, just to save some time + tempMovieData.truncateAt(currFrameCounter); + currMovieData = tempMovieData; + + // #ifdef _S9XLUA_H + // if(!FCEU_LuaRerecordCountSkip()) + currRerecordCount++; + // #endif + + currMovieData.rerecordCount = currRerecordCount; + + openRecordingMovie(curMovieFilename); + //printf("DUMPING MOVIE: %d FRAMES\n",currMovieData.records.size()); + currMovieData.dump(osRecordingMovie, false); + movieMode = MOVIEMODE_RECORD; + } + } + + load_successful = true; + freshMovie = false; + + //// Maximus: Show the last input combination entered from the + //// movie within the state + //if(current!=0) // <- mz: only if playing or recording a movie + // memcpy(&cur_input_display, joop, 4); + + return true; +} + +static void FCEUMOV_PreLoad(void) +{ + load_successful=0; +} + +static bool FCEUMOV_PostLoad(void) +{ + if(movieMode == MOVIEMODE_INACTIVE) + return true; + else + return load_successful; +} + + +bool FCEUI_MovieGetInfo(std::istream* fp, MOVIE_INFO& info, bool skipFrameCount) +{ + //MovieData md; + //if(!LoadFM2(md, fp, INT_MAX, skipFrameCount)) + // return false; + // + //info.movie_version = md.version; + //info.poweron = md.savestate.size()==0; + //info.pal = md.palFlag; + //info.nosynchack = true; + //info.num_frames = md.records.size(); + //info.md5_of_rom_used = md.romChecksum; + //info.emu_version_used = md.emuVersion; + //info.name_of_rom_used = md.romFilename; + //info.rerecord_count = md.rerecordCount; + //info.comments = md.comments; + + return true; +} + +bool MovieRecord::parseBinary(MovieData* md, std::istream* is) +{ + commands=is->get(); + is->read((char *) &pad, sizeof pad); + is->read((char *) &touch.x, sizeof touch.x); + is->read((char *) &touch.y, sizeof touch.y); + is->read((char *) &touch.touch, sizeof touch.touch); + return true; +} + + +void MovieRecord::dumpBinary(MovieData* md, std::ostream* os, int index) +{ + os->put(md->records[index].commands); + os->write((char *) &md->records[index].pad, sizeof md->records[index].pad); + os->write((char *) &md->records[index].touch.x, sizeof md->records[index].touch.x); + os->write((char *) &md->records[index].touch.y, sizeof md->records[index].touch.y); + os->write((char *) &md->records[index].touch.touch, sizeof md->records[index].touch.touch); +} + +void LoadFM2_binarychunk(MovieData& movieData, std::istream* fp, int size) +{ + int recordsize = 1; //1 for the command + + recordsize = 6; + + assert(size%6==0); + + //find out how much remains in the file + int curr = fp->tellg(); + fp->seekg(0,std::ios::end); + int end = fp->tellg(); + int flen = end-curr; + fp->seekg(curr,std::ios::beg); + + //the amount todo is the min of the limiting size we received and the remaining contents of the file + int todo = std::min(size, flen); + + int numRecords = todo/recordsize; + //printf("LOADED MOVIE: %d records; currFrameCounter: %d\n",numRecords,currFrameCounter); + movieData.records.resize(numRecords); + for(int i=0;i + +static bool CheckFileExists(const char* filename) +{ + //This function simply checks to see if the given filename exists + string checkFilename; + + if (filename) + checkFilename = filename; + + //Check if this filename exists + fstream test; + test.open(checkFilename.c_str(),fstream::in); + + if (test.fail()) + { + test.close(); + return false; + } + else + { + test.close(); + return true; + } +} + +void FCEUI_MakeBackupMovie(bool dispMessage) +{ + //This function generates backup movie files + string currentFn; //Current movie fillename + string backupFn; //Target backup filename + string tempFn; //temp used in back filename creation + stringstream stream; + int x; //Temp variable for string manip + bool exist = false; //Used to test if filename exists + bool overflow = false; //Used for special situation when backup numbering exceeds limit + + currentFn = curMovieFilename; //Get current moviefilename + backupFn = curMovieFilename; //Make backup filename the same as current moviefilename + x = backupFn.find_last_of("."); //Find file extension + backupFn = backupFn.substr(0,x); //Remove extension + tempFn = backupFn; //Store the filename at this point + for (unsigned int backNum=0;backNum<999;backNum++) //999 = arbituary limit to backup files + { + stream.str(""); //Clear stream + if (backNum > 99) + stream << "-" << backNum; //assign backNum to stream + else if (backNum <= 99 && backNum >= 10) + stream << "-0" << backNum; //Make it 010, etc if two digits + else + stream << "-00" << backNum; //Make it 001, etc if single digit + backupFn.append(stream.str()); //add number to bak filename + backupFn.append(".bak"); //add extension + + exist = CheckFileExists(backupFn.c_str()); //Check if file exists + + if (!exist) + break; //Yeah yeah, I should use a do loop or something + else + { + backupFn = tempFn; //Before we loop again, reset the filename + + if (backNum == 999) //If 999 exists, we have overflowed, let's handle that + { + backupFn.append("-001.bak"); //We are going to simply overwrite 001.bak + overflow = true; //Flag that we have exceeded limit + break; //Just in case + } + } + } + + MovieData md = currMovieData; //Get current movie data + std::fstream* outf = new fstream(backupFn.c_str(),std::ios_base::out); //FCEUD_UTF8_fstream(backupFn, "wb"); //open/create file + md.dump(outf,false); //dump movie data + delete outf; //clean up, delete file object + + //TODO, decide if fstream successfully opened the file and print error message if it doesn't + + if (dispMessage) //If we should inform the user + { +// if (overflow) +// FCEUI_DispMessage("Backup overflow, overwriting %s",backupFn.c_str()); //Inform user of overflow +// else +// FCEUI_DispMessage("%s created",backupFn.c_str()); //Inform user of backup filename + } +} + diff --git a/desmume/src/movie.h b/src/movie.h similarity index 95% rename from desmume/src/movie.h rename to src/movie.h index 432a6226b..928c5ca43 100644 --- a/desmume/src/movie.h +++ b/src/movie.h @@ -1,208 +1,208 @@ -#ifndef __MOVIE_H_ -#define __MOVIE_H_ - -#include -#include -#include -#include -#include -#include - -#include "utils/guid.h" -#include "utils/md5.h" - -typedef struct -{ - int movie_version; // version of the movie format in the file - u32 num_frames; - u32 rerecord_count; - bool poweron; - u32 emu_version_used; - MD5DATA md5_of_rom_used; - std::string name_of_rom_used; - - std::vector comments; - std::vector subtitles; -} MOVIE_INFO; - -enum EMOVIEMODE -{ - MOVIEMODE_INACTIVE = 1, - MOVIEMODE_RECORD = 2, - MOVIEMODE_PLAY = 4, -}; - -enum EMOVIECMD -{ - MOVIECMD_RESET = 2, -}; - -//RLDUTSBAYXWEG - -class MovieData; -class MovieRecord -{ - -public: - u16 pad; - - union { - struct { - u8 x, y; - u8 touch; - }; - - u32 padding; - } touch; - - //misc commands like reset, etc. - //small now to save space; we might need to support more commands later. - //the disk format will support up to 64bit if necessary - uint8 commands; - bool command_reset() { return (commands&MOVIECMD_RESET)!=0; } - bool command_microphone() { return (commands&1)!=0; } - bool command_lid() { return (commands&4)!=0; } - - void toggleBit(int bit) - { - pad ^= mask(bit); - } - - void setBit(int bit) - { - pad |= mask(bit); - } - - void clearBit(int bit) - { - pad &= ~mask(bit); - } - - void setBitValue(int bit, bool val) - { - if(val) setBit(bit); - else clearBit(bit); - } - - bool checkBit(int bit) - { - return (pad & mask(bit))!=0; - } - - void clear(); - - void parse(MovieData* md, std::istream* is); - bool parseBinary(MovieData* md, std::istream* is); - void dump(MovieData* md, std::ostream* os, int index); - void dumpBinary(MovieData* md, std::ostream* os, int index); - void parsePad(std::istream* is, u16& pad); - void dumpPad(std::ostream* os, u16 pad); - - static const char mnemonics[13]; - -private: - int mask(int bit) { return 1< savestate; - std::vector sram; - std::vector records; - std::vector comments; - - int rerecordCount; - Desmume_Guid guid; - - //was the frame data stored in binary? - bool binaryFlag; - - int getNumRecords() { return records.size(); } - - class TDictionary : public std::map - { - public: - bool containsKey(std::string key) - { - return find(key) != end(); - } - - void tryInstallBool(std::string key, bool& val) - { - if(containsKey(key)) - val = atoi(operator [](key).c_str())!=0; - } - - void tryInstallString(std::string key, std::string& val) - { - if(containsKey(key)) - val = operator [](key); - } - - void tryInstallInt(std::string key, int& val) - { - if(containsKey(key)) - val = atoi(operator [](key).c_str()); - } - - }; - - void truncateAt(int frame); - void installValue(std::string& key, std::string& val); - int dump(std::ostream* os, bool binary); - void clearRecordRange(int start, int len); - void insertEmpty(int at, int frames); - - static bool loadSavestateFrom(std::vector* buf); - static void dumpSavestateTo(std::vector* buf, int compressionLevel); - - static bool loadSramFrom(std::vector* buf); - static void dumpSramTo(std::vector* buf, std::string sramfname); - //void TryDumpIncremental(); - -private: - void installInt(std::string& val, int& var) - { - var = atoi(val.c_str()); - } - - void installBool(std::string& val, bool& var) - { - var = atoi(val.c_str())!=0; - } -}; - -extern int currFrameCounter; -extern EMOVIEMODE movieMode; //adelikat: main needs this for frame counter display -extern MovieData currMovieData; //adelikat: main needs this for frame counter display - -extern bool movie_reset_command; -extern bool movie_lid; - -bool FCEUI_MovieGetInfo(std::istream* fp, MOVIE_INFO& info, bool skipFrameCount); -void _CDECL_ FCEUI_SaveMovie(const char *fname, std::wstring author, int flag, std::string sramfname); -void _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe); -void FCEUI_StopMovie(); -void FCEUMOV_AddInputState(); -void NDS_setTouchFromMovie(void); -void mov_savestate(std::ostream* os); -bool mov_loadstate(std::istream* is, int size); -void LoadFM2_binarychunk(MovieData& movieData, std::istream* fp, int size); -bool LoadFM2(MovieData& movieData, std::istream* fp, int size, bool stopAfterHeader); -extern bool movie_readonly; -extern bool ShowInputDisplay; -extern int MicButtonPressed; -void FCEUI_MakeBackupMovie(bool dispMessage); -#endif +#ifndef __MOVIE_H_ +#define __MOVIE_H_ + +#include +#include +#include +#include +#include +#include + +#include "utils/guid.h" +#include "utils/md5.h" + +typedef struct +{ + int movie_version; // version of the movie format in the file + u32 num_frames; + u32 rerecord_count; + bool poweron; + u32 emu_version_used; + MD5DATA md5_of_rom_used; + std::string name_of_rom_used; + + std::vector comments; + std::vector subtitles; +} MOVIE_INFO; + +enum EMOVIEMODE +{ + MOVIEMODE_INACTIVE = 1, + MOVIEMODE_RECORD = 2, + MOVIEMODE_PLAY = 4, +}; + +enum EMOVIECMD +{ + MOVIECMD_RESET = 2, +}; + +//RLDUTSBAYXWEG + +class MovieData; +class MovieRecord +{ + +public: + u16 pad; + + union { + struct { + u8 x, y; + u8 touch; + }; + + u32 padding; + } touch; + + //misc commands like reset, etc. + //small now to save space; we might need to support more commands later. + //the disk format will support up to 64bit if necessary + uint8 commands; + bool command_reset() { return (commands&MOVIECMD_RESET)!=0; } + bool command_microphone() { return (commands&1)!=0; } + bool command_lid() { return (commands&4)!=0; } + + void toggleBit(int bit) + { + pad ^= mask(bit); + } + + void setBit(int bit) + { + pad |= mask(bit); + } + + void clearBit(int bit) + { + pad &= ~mask(bit); + } + + void setBitValue(int bit, bool val) + { + if(val) setBit(bit); + else clearBit(bit); + } + + bool checkBit(int bit) + { + return (pad & mask(bit))!=0; + } + + void clear(); + + void parse(MovieData* md, std::istream* is); + bool parseBinary(MovieData* md, std::istream* is); + void dump(MovieData* md, std::ostream* os, int index); + void dumpBinary(MovieData* md, std::ostream* os, int index); + void parsePad(std::istream* is, u16& pad); + void dumpPad(std::ostream* os, u16 pad); + + static const char mnemonics[13]; + +private: + int mask(int bit) { return 1< savestate; + std::vector sram; + std::vector records; + std::vector comments; + + int rerecordCount; + Desmume_Guid guid; + + //was the frame data stored in binary? + bool binaryFlag; + + int getNumRecords() { return records.size(); } + + class TDictionary : public std::map + { + public: + bool containsKey(std::string key) + { + return find(key) != end(); + } + + void tryInstallBool(std::string key, bool& val) + { + if(containsKey(key)) + val = atoi(operator [](key).c_str())!=0; + } + + void tryInstallString(std::string key, std::string& val) + { + if(containsKey(key)) + val = operator [](key); + } + + void tryInstallInt(std::string key, int& val) + { + if(containsKey(key)) + val = atoi(operator [](key).c_str()); + } + + }; + + void truncateAt(int frame); + void installValue(std::string& key, std::string& val); + int dump(std::ostream* os, bool binary); + void clearRecordRange(int start, int len); + void insertEmpty(int at, int frames); + + static bool loadSavestateFrom(std::vector* buf); + static void dumpSavestateTo(std::vector* buf, int compressionLevel); + + static bool loadSramFrom(std::vector* buf); + static void dumpSramTo(std::vector* buf, std::string sramfname); + //void TryDumpIncremental(); + +private: + void installInt(std::string& val, int& var) + { + var = atoi(val.c_str()); + } + + void installBool(std::string& val, bool& var) + { + var = atoi(val.c_str())!=0; + } +}; + +extern int currFrameCounter; +extern EMOVIEMODE movieMode; //adelikat: main needs this for frame counter display +extern MovieData currMovieData; //adelikat: main needs this for frame counter display + +extern bool movie_reset_command; +extern bool movie_lid; + +bool FCEUI_MovieGetInfo(std::istream* fp, MOVIE_INFO& info, bool skipFrameCount); +void _CDECL_ FCEUI_SaveMovie(const char *fname, std::wstring author, int flag, std::string sramfname); +void _CDECL_ FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe); +void FCEUI_StopMovie(); +void FCEUMOV_AddInputState(); +void NDS_setTouchFromMovie(void); +void mov_savestate(std::ostream* os); +bool mov_loadstate(std::istream* is, int size); +void LoadFM2_binarychunk(MovieData& movieData, std::istream* fp, int size); +bool LoadFM2(MovieData& movieData, std::istream* fp, int size, bool stopAfterHeader); +extern bool movie_readonly; +extern bool ShowInputDisplay; +extern int MicButtonPressed; +void FCEUI_MakeBackupMovie(bool dispMessage); +#endif diff --git a/desmume/src/path.h b/src/path.h similarity index 93% rename from desmume/src/path.h rename to src/path.h index bebba0447..6671842f0 100644 --- a/desmume/src/path.h +++ b/src/path.h @@ -128,7 +128,7 @@ public: ReadKey(pathToLua, LUAKEY); #ifdef WIN32 GetPrivateProfileString(SECTION, FORMATKEY, "%f_%s_%r", screenshotFormat, MAX_FORMAT, IniName); - savelastromvisit = GetPrivateProfileBool(SECTION, LASTVISITKEY, true, IniName); + savelastromvisit = GetPrivateProfileInt(SECTION, LASTVISITKEY, TRUE, IniName); currentimageformat = (ImageFormat)GetPrivateProfileInt(SECTION, DEFAULTFORMATKEY, PNG, IniName); #endif /* @@ -252,7 +252,7 @@ public: std::string file; time_t now = time(NULL); tm *time_struct = localtime(&now); - srand((unsigned int)now); + srand(now); for(int i = 0; i < MAX_FORMAT;i++) { diff --git a/desmume/src/rasterize.cpp b/src/rasterize.cpp similarity index 79% rename from desmume/src/rasterize.cpp rename to src/rasterize.cpp index 2fda13f04..ab5054192 100644 --- a/desmume/src/rasterize.cpp +++ b/src/rasterize.cpp @@ -1,1477 +1,1425 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -//nothing in this file should be assumed to be accurate -// -//the shape rasterizers contained herein are based on code supplied by Chris Hecker from -//http://chrishecker.com/Miscellaneous_Technical_Articles - -//The worst case we've managed to think of so far would be a viewport zoomed in a little bit -//on a diamond, with cut-out bits in all four corners -#define MAX_CLIPPED_VERTS 8 - -//TODO - due to a late change of a y-coord flipping, our winding order is wrong -//this causes us to have to flip the verts for every front-facing poly. -//a performance improvement would be to change the winding order logic -//so that this is done less frequently - -#include "rasterize.h" - -#include -#include -#include -#include - -#include "bits.h" -#include "common.h" -#include "matrix.h" -#include "render3D.h" -#include "gfx3d.h" -#include "texcache.h" -#include "NDSSystem.h" - -//#undef FORCEINLINE -//#define FORCEINLINE -//#undef INLINE -//#define INLINE - -using std::min; -using std::max; -using std::swap; - -template T _min(T a, T b, T c) { return min(min(a,b),c); } -template T _max(T a, T b, T c) { return max(max(a,b),c); } -template T _min(T a, T b, T c, T d) { return min(_min(a,b,d),c); } -template T _max(T a, T b, T c, T d) { return max(_max(a,b,d),c); } - -static const int kUnsetTranslucentPolyID = 255; - -static int polynum; - -static u8 modulate_table[64][64]; -static u8 decal_table[32][64][64]; -static u8 index_lookup_table[65]; -static u8 index_start_table[8]; - -static struct TClippedPoly -{ - int type; - POLY* poly; - VERT clipVerts[MAX_CLIPPED_VERTS]; -} *clippedPolys = NULL; -static int clippedPolyCounter; - -TClippedPoly tempClippedPoly; -TClippedPoly outClippedPoly; - -////optimized float floor useful in limited cases -////from http://www.stereopsis.com/FPU.html#convert -////(unfortunately, it relies on certain FPU register settings) -//int Real2Int(double val) -//{ -// const double _double2fixmagic = 68719476736.0*1.5; //2^36 * 1.5, (52-_shiftamt=36) uses limited precisicion to floor -// const int _shiftamt = 16; //16.16 fixed point representation, -// -// #ifdef WORDS_BIGENDIAN -// #define iman_ 1 -// #else -// #define iman_ 0 -// #endif -// -// val = val + _double2fixmagic; -// return ((int*)&val)[iman_] >> _shiftamt; -//} - -//// this probably relies on rounding settings.. -//int Real2Int(float val) -//{ -// //val -= 0.5f; -// //int temp; -// //__asm { -// // fld val; -// // fistp temp; -// //} -// //return temp; -// return 0; -//} - - -//doesnt work yet -static FORCEINLINE int fastFloor(float f) -{ - float temp = f + 1.f; - int ret = (*((u32*)&temp))&0x7FFFFF; - return ret; -} - - - -//----texture cache--- - -//TODO - the texcache could ask for a buffer to generate into -//that would avoid us ever having to buffercopy.. -struct TextureBuffers -{ - static const int numTextures = MAX_TEXTURE+1; - u8* buffers[numTextures]; - - void clear() { memset(buffers,0,sizeof(buffers)); } - - TextureBuffers() - { - clear(); - } - - void free() - { - for(int i=0;i>4)&0x3; - if(mode==3 && polyid !=0) return !backfacing; - //another reasonable possibility is that we should be forcing back faces to draw (mariokart doesnt use them) - //and then only using a single bit buffer (but a cursory test of this doesnt actually work) - - switch((val>>6)&3) { - case 0: return false; - case 1: return backfacing; - case 2: return !backfacing; - case 3: return true; - default: assert(false); return false; - } - } - - void setup(u32 polyAttr) - { - val = polyAttr; - decalMode = BIT14(val); - translucentDepthWrite = BIT11(val); - polyid = (polyAttr>>24)&0x3F; - alpha = (polyAttr>>16)&0x1F; - drawBackPlaneIntersectingPolys = BIT12(val); - fogged = BIT15(val); - } - -} polyAttr; - -union FragmentColor { - u32 color; - struct { - u8 r,g,b,a; - }; -}; - -struct Fragment -{ - u32 depth; - - struct { - u8 opaque, translucent; - } polyid; - - u8 stencil; - - struct { - u8 isTranslucentPoly:1; - u8 fogged:1; - }; -}; - -static VERT* verts[MAX_CLIPPED_VERTS]; - -INLINE static void SubmitVertex(int vert_index, VERT& rawvert) -{ - verts[vert_index] = &rawvert; -} - -static Fragment screen[256*192]; -static FragmentColor screenColor[256*192]; -static FragmentColor toonTable[32]; -static u8 fogTable[32768]; - -FORCEINLINE int iround(float f) { - return (int)f; //lol -} - - -static struct Sampler -{ - int width, height; - int wmask, hmask; - int wrap; - int wshift; - int texFormat; - void setup(u32 texParam) - { - texFormat = (texParam>>26)&7; - wshift = ((texParam>>20)&0x07) + 3; - width=(1 << wshift); - height=(8 << ((texParam>>23)&0x07)); - wmask = width-1; - hmask = height-1; - wrap = (texParam>>16)&0xF; - } - - FORCEINLINE void clamp(int &val, const int size, const int sizemask){ - if(val<0) val = 0; - if(val>sizemask) val = sizemask; - } - FORCEINLINE void hclamp(int &val) { clamp(val,width,wmask); } - FORCEINLINE void vclamp(int &val) { clamp(val,height,hmask); } - - FORCEINLINE void repeat(int &val, const int size, const int sizemask) { - val &= sizemask; - } - FORCEINLINE void hrepeat(int &val) { repeat(val,width,wmask); } - FORCEINLINE void vrepeat(int &val) { repeat(val,height,hmask); } - - FORCEINLINE void flip(int &val, const int size, const int sizemask) { - val &= ((size<<1)-1); - if(val>=size) val = (size<<1)-val-1; - } - FORCEINLINE void hflip(int &val) { flip(val,width,wmask); } - FORCEINLINE void vflip(int &val) { flip(val,height,hmask); } - - FORCEINLINE void dowrap(int& iu, int& iv) - { - switch(wrap) { - //flip none - case 0x0: hclamp(iu); vclamp(iv); break; - case 0x1: hrepeat(iu); vclamp(iv); break; - case 0x2: hclamp(iu); vrepeat(iv); break; - case 0x3: hrepeat(iu); vrepeat(iv); break; - //flip S - case 0x4: hclamp(iu); vclamp(iv); break; - case 0x5: hflip(iu); vclamp(iv); break; - case 0x6: hclamp(iu); vrepeat(iv); break; - case 0x7: hflip(iu); vrepeat(iv); break; - //flip T - case 0x8: hclamp(iu); vclamp(iv); break; - case 0x9: hrepeat(iu); vclamp(iv); break; - case 0xA: hclamp(iu); vflip(iv); break; - case 0xB: hrepeat(iu); vflip(iv); break; - //flip both - case 0xC: hclamp(iu); vclamp(iv); break; - case 0xD: hflip(iu); vclamp(iv); break; - case 0xE: hclamp(iu); vflip(iv); break; - case 0xF: hflip(iu); vflip(iv); break; - } - } - - FORCEINLINE FragmentColor sample(float u, float v) - { - //finally, we can use floor here. but, it is slower than we want. - //the best solution is probably to wait until the pipeline is full of fixed point - s32 iu = s32floor(u); - s32 iv = s32floor(v); - dowrap(iu,iv); - - FragmentColor color; - color.color = ((u32*)textures.currentData)[(iv<>4)&0x3; - //if there is no texture set, then set to the mode which doesnt even use a texture - //(no texture makes sense for toon/highlight mode) - if(sampler.texFormat == 0 && (mode == 0 || mode == 1)) - mode = 4; - } - - float invu, invv, w; - FragmentColor materialColor; - - FORCEINLINE void shade(FragmentColor& dst) - { - FragmentColor texColor; - float u,v; - - switch(mode) - { - case 0: //modulate - u = invu*w; - v = invv*w; - texColor = sampler.sample(u,v); - dst.r = modulate_table[texColor.r][materialColor.r]; - dst.g = modulate_table[texColor.g][materialColor.g]; - dst.b = modulate_table[texColor.b][materialColor.b]; - dst.a = modulate_table[GFX3D_5TO6(texColor.a)][GFX3D_5TO6(materialColor.a)]>>1; - //dst.color.components.a = 31; - //#ifdef _MSC_VER - //if(GetAsyncKeyState(VK_SHIFT)) { - // //debugging tricks - // dst = materialColor; - // if(GetAsyncKeyState(VK_TAB)) { - // u8 alpha = dst.a; - // dst.color = polynum*8+8; - // dst.a = alpha; - // } - //} - //#endif - break; - case 1: //decal - u = invu*w; - v = invv*w; - texColor = sampler.sample(u,v); - dst.r = decal_table[texColor.a][texColor.r][materialColor.r]; - dst.g = decal_table[texColor.a][texColor.g][materialColor.g]; - dst.b = decal_table[texColor.a][texColor.b][materialColor.b]; - dst.a = materialColor.a; - break; - case 2: //toon/highlight shading - { - u = invu*w; - v = invv*w; - texColor = sampler.sample(u,v); - FragmentColor toonColor = toonTable[materialColor.r>>1]; - if(sampler.texFormat == 0) - { - //if no texture is set then we dont need to modulate texture with toon - //but rather just use toon directly - dst = toonColor; - dst.a = materialColor.a; - } - else - { - if(gfx3d.shading == GFX3D::HIGHLIGHT) - { - dst.r = modulate_table[texColor.r][materialColor.r]; - dst.g = modulate_table[texColor.g][materialColor.r]; - dst.b = modulate_table[texColor.b][materialColor.r]; - dst.a = modulate_table[GFX3D_5TO6(texColor.a)][GFX3D_5TO6(materialColor.a)]>>1; - - dst.r = min(63, (dst.r + toonColor.r)); - dst.g = min(63, (dst.g + toonColor.g)); - dst.b = min(63, (dst.b + toonColor.b)); - } - else - { - dst.r = modulate_table[texColor.r][toonColor.r]; - dst.g = modulate_table[texColor.g][toonColor.g]; - dst.b = modulate_table[texColor.b][toonColor.b]; - dst.a = modulate_table[GFX3D_5TO6(texColor.a)][GFX3D_5TO6(materialColor.a)]>>1; - } - } - - } - break; - case 3: //shadows - //is this right? only with the material color? - dst = materialColor; - break; - case 4: //our own special mode which only uses the material color (for when texturing is disabled) - dst = materialColor; - break; - - } - } - -} shader; - -static FORCEINLINE void alphaBlend(FragmentColor & dst, const FragmentColor & src) -{ - if(gfx3d.enableAlphaBlending) - { - if(src.a == 0 || dst.a == 0) - { - dst = src; - } - else - { - u8 alpha = src.a+1; - u8 invAlpha = 32 - alpha; - dst.r = (alpha*src.r + invAlpha*dst.r)>>5; - dst.g = (alpha*src.g + invAlpha*dst.g)>>5; - dst.b = (alpha*src.b + invAlpha*dst.b)>>5; - } - - dst.a = max(src.a,dst.a); - } - else - { - if(src.a == 0) - { - //do nothing; the fragment is totally transparent - } - else - { - dst = src; - } - } -} - -static FORCEINLINE void pixel(int adr,float r, float g, float b, float invu, float invv, float w, float z) { - Fragment &destFragment = screen[adr]; - FragmentColor &destFragmentColor = screenColor[adr]; - - u32 depth; - if(gfx3d.wbuffer) - { - //not sure about this - //this value was chosen to make the skybox, castle window decals, and water level render correctly in SM64 - depth = u32floor(4096*w); - } - else - { - depth = u32floor(z*0x7FFF); - depth <<= 9; - } - - if(polyAttr.decalMode) - { - if(depth != destFragment.depth) - { - goto depth_fail; - } - } - else - { - if(depth>=destFragment.depth) - { - goto depth_fail; - } - } - - //handle shadow polys - if(shader.mode == 3) - { - if(polyAttr.polyid == 0) - { - //that's right! stencil buffers, despite reports to the contrary, must be more than 1 bit - //this is necessary to make these cases work all at once. - //1. sm64 (standing near signs and blocks) - //2. mariokart (no glitches in shadow shape in kart selector) - //3. mariokart (no junk beneath platform in kart selector / no shadow beneath grate floor in bowser stage) - //(specifically, the shadows in mario kart are complicated concave shapes) - destFragment.stencil++; - goto rejected_fragment; - } - else - { - if(destFragment.stencil) - { - destFragment.stencil--; - goto rejected_fragment; - } - - //shadow polys have a special check here to keep from self-shadowing when user - //has tried to prevent it from happening - //if this isnt here, then the vehicle select in mariokart will look terrible - if(destFragment.polyid.opaque == polyAttr.polyid) - goto rejected_fragment; - } - } - - shader.w = w; - shader.invu = invu; - shader.invv = invv; - - //perspective-correct the colors - r = (r * w) + 0.5f; - g = (g * w) + 0.5f; - b = (b * w) + 0.5f; - - //this is a HACK: - //we are being very sloppy with our interpolation precision right now - //and rather than fix it, i just want to clamp it - shader.materialColor.r = max(0U,min(63U,u32floor(r))); - shader.materialColor.g = max(0U,min(63U,u32floor(g))); - shader.materialColor.b = max(0U,min(63U,u32floor(b))); - - shader.materialColor.a = polyAttr.alpha; - - //pixel shader - FragmentColor shaderOutput; - shader.shade(shaderOutput); - - //alpha test (don't have any test cases for this...? is it in the right place...?) - if(gfx3d.enableAlphaTest) - { - if(shaderOutput.a < gfx3d.alphaTestRef) - goto rejected_fragment; - } - - //we shouldnt do any of this if we generated a totally transparent pixel - if(shaderOutput.a != 0) - { - //handle polyids - bool isOpaquePixel = shaderOutput.a == 31; - if(isOpaquePixel) - { - destFragment.polyid.opaque = polyAttr.polyid; - destFragment.isTranslucentPoly = polyAttr.translucent?1:0; - destFragment.fogged = polyAttr.fogged; - destFragmentColor = shaderOutput; - } - else - { - //dont overwrite pixels on translucent polys with the same polyids - if(destFragment.polyid.translucent == polyAttr.polyid) - goto rejected_fragment; - - //originally we were using a test case of shadows-behind-trees in sm64ds - //but, it looks bad in that game. this is actually correct - //if this isnt correct, then complex shape cart shadows in mario kart don't work right - destFragment.polyid.translucent = polyAttr.polyid; - - //alpha blending and write color - alphaBlend(destFragmentColor, shaderOutput); - - destFragment.fogged &= polyAttr.fogged; - } - - //depth writing - if(isOpaquePixel || polyAttr.translucentDepthWrite) - destFragment.depth = depth; - - } - - depth_fail: - rejected_fragment: - ; -} - - -typedef int fixed28_4; - -static bool failure; - -// handle floor divides and mods correctly -FORCEINLINE void FloorDivMod(long Numerator, long Denominator, long &Floor, long &Mod) -{ - //These must be caused by invalid or degenerate shapes.. not sure yet. - //check it out in the mario face intro of SM64 - //so, we have to take out the assert. - //I do know that we handle SOME invalid shapes without crashing, - //since I see them acting poppy in a way that doesnt happen in the HW.. so alas it is also incorrect. - //This particular incorrectness is not likely ever to get fixed! - - //assert(Denominator > 0); - - //but we have to bail out since our handling for these cases currently steps scanlines - //the wrong way and goes totally nuts (freezes) - if(Denominator<=0) - failure = true; - - if(Numerator >= 0) { - // positive case, C is okay - Floor = Numerator / Denominator; - Mod = Numerator % Denominator; - } else { - // Numerator is negative, do the right thing - Floor = -((-Numerator) / Denominator); - Mod = (-Numerator) % Denominator; - if(Mod) { - // there is a remainder - Floor--; Mod = Denominator - Mod; - } - } -} - -FORCEINLINE fixed28_4 FloatToFixed28_4( float Value ) { - return (fixed28_4)(Value * 16); -} -FORCEINLINE float Fixed28_4ToFloat( fixed28_4 Value ) { - return Value / 16.0f; -} -//inline fixed16_16 FloatToFixed16_16( float Value ) { -// return (fixed16_6)(Value * 65536); -//} -//inline float Fixed16_16ToFloat( fixed16_16 Value ) { -// return Value / 65536.0; -//} -FORCEINLINE fixed28_4 Fixed28_4Mul( fixed28_4 A, fixed28_4 B ) { - // could make this asm to prevent overflow - return (A * B) / 16; // 28.4 * 28.4 = 24.8 / 16 = 28.4 -} -FORCEINLINE int Ceil28_4( fixed28_4 Value ) { - int ReturnValue; - int Numerator = Value - 1 + 16; - if(Numerator >= 0) { - ReturnValue = Numerator/16; - } else { - // deal with negative numerators correctly - ReturnValue = -((-Numerator)/16); - ReturnValue -= ((-Numerator) % 16) ? 1 : 0; - } - return ReturnValue; -} - -struct edge_fx_fl { - edge_fx_fl() {} - edge_fx_fl(int Top, int Bottom); - FORCEINLINE int Step(); - - long X, XStep, Numerator, Denominator; // DDA info for x - long ErrorTerm; - int Y, Height; // current y and vertical count - - struct Interpolant { - float curr, step, stepExtra; - FORCEINLINE void doStep() { curr += step; } - FORCEINLINE void doStepExtra() { curr += stepExtra; } - FORCEINLINE void initialize(float top, float bottom, float dx, float dy, long XStep, float XPrestep, float YPrestep) { - dx = 0; - dy *= (bottom-top); - curr = top + YPrestep * dy + XPrestep * dx; - step = XStep * dx + dy; - stepExtra = dx; - } - }; - - static const int NUM_INTERPOLANTS = 7; - union { - struct { - Interpolant invw,z,u,v,color[3]; - }; - Interpolant interpolants[NUM_INTERPOLANTS]; - }; - void FORCEINLINE doStepInterpolants() { for(int i=0;iy); - int YEnd = Ceil28_4((fixed28_4)verts[Bottom]->y); - Height = YEnd - Y; - - if(Height) - { - long dN = long(verts[Bottom]->y - verts[Top]->y); - long dM = long(verts[Bottom]->x - verts[Top]->x); - - long InitialNumerator = (long)(dM*16*Y - dM*verts[Top]->y + dN*verts[Top]->x - 1 + dN*16); - FloorDivMod(InitialNumerator,dN*16,X,ErrorTerm); - FloorDivMod(dM*16,dN*16,XStep,Numerator); - Denominator = dN*16; - - float YPrestep = Fixed28_4ToFloat((fixed28_4)(Y*16 - verts[Top]->y)); - float XPrestep = Fixed28_4ToFloat((fixed28_4)(X*16 - verts[Top]->x)); - - float dy = 1/Fixed28_4ToFloat(dN); - float dx = 1/Fixed28_4ToFloat(dM); - - invw.initialize(1/verts[Top]->w,1/verts[Bottom]->w,dx,dy,XStep,XPrestep,YPrestep); - u.initialize(verts[Top]->u,verts[Bottom]->u,dx,dy,XStep,XPrestep,YPrestep); - v.initialize(verts[Top]->v,verts[Bottom]->v,dx,dy,XStep,XPrestep,YPrestep); - z.initialize(verts[Top]->z,verts[Bottom]->z,dx,dy,XStep,XPrestep,YPrestep); - for(int i=0;i<3;i++) - color[i].initialize(verts[Top]->fcolor[i],verts[Bottom]->fcolor[i],dx,dy,XStep,XPrestep,YPrestep); - } -} - -FORCEINLINE int edge_fx_fl::Step() { - X += XStep; Y++; Height--; - doStepInterpolants(); - - ErrorTerm += Numerator; - if(ErrorTerm >= Denominator) { - X++; - ErrorTerm -= Denominator; - doStepExtraInterpolants(); - } - return Height; -} - -//draws a single scanline -FORCEINLINE static void drawscanline(edge_fx_fl *pLeft, edge_fx_fl *pRight) -{ - int XStart = pLeft->X; - int width = pRight->X - XStart; - - //these are the starting values, taken from the left edge - float invw = pLeft->invw.curr; - float u = pLeft->u.curr; - float v = pLeft->v.curr; - float z = pLeft->z.curr; - float color[3] = { - pLeft->color[0].curr, - pLeft->color[1].curr, - pLeft->color[2].curr }; - - //our dx values are taken from the steps up until the right edge - float invWidth = 1.0f / width; - float dinvw_dx = (pRight->invw.curr - invw) * invWidth; - float du_dx = (pRight->u.curr - u) * invWidth; - float dv_dx = (pRight->v.curr - v) * invWidth; - float dz_dx = (pRight->z.curr - z) * invWidth; - float dc_dx[3] = { - (pRight->color[0].curr - color[0]) * invWidth, - (pRight->color[1].curr - color[1]) * invWidth, - (pRight->color[2].curr - color[2]) * invWidth }; - - int adr = (pLeft->Y<<8)+XStart; - - //CONSIDER: in case some other math is wrong (shouldve been clipped OK), we might go out of bounds here. - //better check the Y value. - if(pLeft->Y<0 || pLeft->Y>191) { - printf("rasterizer rendering at y=%d! oops!\n",pLeft->Y); - return; - } - - int x = XStart; - - while(width-- > 0) - { - if(x<0 || x>255) { - printf("rasterizer rendering at x=%d! oops!\n",x); - return; - } - pixel(adr,color[0],color[1],color[2],u,v,1.0f/invw,z); - adr++; - x++; - - invw += dinvw_dx; - u += du_dx; - v += dv_dx; - z += dz_dx; - color[0] += dc_dx[0]; - color[1] += dc_dx[1]; - color[2] += dc_dx[2]; - } -} - -//runs several scanlines, until an edge is finished -static void runscanlines(edge_fx_fl *left, edge_fx_fl *right) -{ - //do not overstep either of the edges - int Height = min(left->Height,right->Height); - while(Height--) { - drawscanline(left,right); - left->Step(); - right->Step(); - } -} - -//rotates verts counterclockwise -template -INLINE static void rot_verts() { - #define ROTSWAP(X) if(type>X) swap(verts[X-1],verts[X]); - ROTSWAP(1); ROTSWAP(2); ROTSWAP(3); ROTSWAP(4); - ROTSWAP(5); ROTSWAP(6); ROTSWAP(7); -} - -//rotate verts until vert0.y is minimum, and then vert0.x is minimum in case of ties -//this is a necessary precondition for our shape engine -template -static void sort_verts(bool backwards) { - //if the verts are backwards, reorder them first - if(backwards) - for(int i=0;iX) if(verts[0]->y > verts[X]->y) goto doswap; - CHECKY(1); CHECKY(2); CHECKY(3); CHECKY(4); - CHECKY(5); CHECKY(6); CHECKY(7); - break; - - doswap: - rot_verts(); - } - - while(verts[0]->y == verts[1]->y && verts[0]->x > verts[1]->x) - rot_verts(); - -} - -//This function can handle any convex N-gon up to octagons -//verts must be clockwise. -//I didnt reference anything for this algorithm but it seems like I've seen it somewhere before. -static void shape_engine(int type, bool backwards) -{ - failure = false; - - switch(type) { - case 3: sort_verts<3>(backwards); break; - case 4: sort_verts<4>(backwards); break; - case 5: sort_verts<5>(backwards); break; - case 6: sort_verts<6>(backwards); break; - case 7: sort_verts<7>(backwards); break; - case 8: sort_verts<8>(backwards); break; - default: printf("skipping type %d\n",type); return; - } - - //we are going to step around the polygon in both directions starting from vert 0. - //right edges will be stepped over clockwise and left edges stepped over counterclockwise. - //these variables track that stepping, but in order to facilitate wrapping we start extra high - //for the counter we're decrementing. - int lv = type, rv = 0; - - edge_fx_fl left, right; - bool step_left = true, step_right = true; - for(;;) { - //generate new edges if necessary. we must avoid regenerating edges when they are incomplete - //so that they can be continued on down the shape - assert(rv != type); - int _lv = lv==type?0:lv; //make sure that we ask for vert 0 when the variable contains the starting value - if(step_left) left = edge_fx_fl(_lv,lv-1); - if(step_right) right = edge_fx_fl(rv,rv+1); - step_left = step_right = false; - - //handle a failure in the edge setup due to nutty polys - if(failure) - return; - - - - runscanlines(&left,&right); - - //if we ran out of an edge, step to the next one - if(right.Height == 0) { - step_right = true; - rv++; - } - if(left.Height == 0) { - step_left = true; - lv--; - } - - //this is our completion condition: when our stepped edges meet in the middle - if(lv<=rv+1) break; - } - -} - -static char SoftRastInit(void) -{ - static bool tables_generated = false; - if(!tables_generated) - { - tables_generated = true; - - clippedPolys = new TClippedPoly[POLYLIST_SIZE*2]; - - for(int i=0;i<64;i++) - { - for(int j=0;j<64;j++) - { - modulate_table[i][j] = ((i+1) * (j+1) - 1) >> 6; - for(int a=0;a<32;a++) - decal_table[a][i][j] = ((i*a) + (j*(31-a))) >> 5; - } - } - - //these tables are used to increment through vert lists without having to do wrapping logic/math - int idx=0; - for(int i=3;i<=8;i++) - { - index_start_table[i-3] = idx; - for(int j=0;j>3]) continue; - if(destFragment.isTranslucentPoly) continue; - - // > is used instead of != to prevent double edges - // between overlapping polys of different IDs. - // also note that the edge generally goes on the outside, not the inside, - // and that polys with the same edge color can make edges against each other. - - FragmentColor edgeColor = edgeMarkColors[self>>3]; - -#define PIXOFFSET(dx,dy) ((dx)+(256*(dy))) -#define ISEDGE(dx,dy) ((x+(dx)!=256) && (x+(dx)!=-1) && (y+(dy)!=192) && (y+(dy)!=-1) && self > screen[i+PIXOFFSET(dx,dy)].polyid.opaque) -#define DRAWEDGE(dx,dy) alphaBlend(screenColor[i+PIXOFFSET(dx,dy)], edgeColor) - - bool upleft = ISEDGE(-1,-1); - bool up = ISEDGE( 0,-1); - bool upright = ISEDGE( 1,-1); - bool left = ISEDGE(-1, 0); - bool right = ISEDGE( 1, 0); - bool downleft = ISEDGE(-1, 1); - bool down = ISEDGE( 0, 1); - bool downright = ISEDGE( 1, 1); - - if(upleft && upright && downleft && !downright) - DRAWEDGE(-1,-1); - if(up && !down) - DRAWEDGE(0,-1); - if(upleft && upright && !downleft && downright) - DRAWEDGE(1,-1); - if(left && !right) - DRAWEDGE(-1,0); - if(right && !left) - DRAWEDGE(1,0); - if(upleft && !upright && downleft && downright) - DRAWEDGE(-1,1); - if(down && !up) - DRAWEDGE(0,1); - if(!upleft && upright && downleft && downright) - DRAWEDGE(1,1); - -#undef PIXOFFSET -#undef ISEDGE -#undef DRAWEDGE - - } - } - } - - if(gfx3d.enableFog) - { - u32 r = GFX3D_5TO6((gfx3d.fogColor)&0x1F); - u32 g = GFX3D_5TO6((gfx3d.fogColor>>5)&0x1F); - u32 b = GFX3D_5TO6((gfx3d.fogColor>>10)&0x1F); - u32 a = (gfx3d.fogColor>>16)&0x1F; - for(int i=0;i<256*192;i++) - { - Fragment &destFragment = screen[i]; - if(!destFragment.fogged) continue; - FragmentColor &destFragmentColor = screenColor[i]; - u32 fogIndex = destFragment.depth>>9; - assert(fogIndex<32768); - u8 fog = fogTable[fogIndex]; - if(fog==127) fog=128; - if(!gfx3d.enableFogAlphaOnly) - { - destFragmentColor.r = ((128-fog)*destFragmentColor.r + r*fog)>>7; - destFragmentColor.g = ((128-fog)*destFragmentColor.g + g*fog)>>7; - destFragmentColor.b = ((128-fog)*destFragmentColor.b + b*fog)>>7; - } - destFragmentColor.a = ((128-fog)*destFragmentColor.a + a*fog)>>7; - } - } -} - -static void SoftRastConvertFramebuffer() -{ - memcpy(gfx3d_convertedScreen,screenColor,256*192*4); -} - - -template -static T interpolate(const float ratio, const T& x0, const T& x1) { - return (T)(x0 + (float)(x1-x0) * (ratio)); -} - - -//http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/as6/discussion.shtml -static FORCEINLINE VERT clipPoint(VERT* inside, VERT* outside, int coord, int which) -{ - VERT ret; - - float coord_inside = inside->coord[coord]; - float coord_outside = outside->coord[coord]; - float w_inside = inside->coord[3]; - float w_outside = outside->coord[3]; - - float t; - - if(which==-1) { - w_outside = -w_outside; - w_inside = -w_inside; - } - - t = (coord_inside - w_inside)/ ((w_outside-w_inside) - (coord_outside-coord_inside)); - - -#define INTERP(X) ret . X = interpolate(t, inside-> X ,outside-> X ) - - INTERP(coord[0]); INTERP(coord[1]); INTERP(coord[2]); INTERP(coord[3]); - INTERP(texcoord[0]); INTERP(texcoord[1]); - - if(CommonSettings.HighResolutionInterpolateColor) - { - INTERP(fcolor[0]); INTERP(fcolor[1]); INTERP(fcolor[2]); - } - else - { - INTERP(color[0]); INTERP(color[1]); INTERP(color[2]); - ret.color_to_float(); - } - - //this seems like a prudent measure to make sure that math doesnt make a point pop back out - //of the clip volume through interpolation - if(which==-1) - ret.coord[coord] = -ret.coord[3]; - else - ret.coord[coord] = ret.coord[3]; - - return ret; -} - -//#define CLIPLOG(X) printf(X); -//#define CLIPLOG2(X,Y,Z) printf(X,Y,Z); -#define CLIPLOG(X) -#define CLIPLOG2(X,Y,Z) - -static FORCEINLINE void clipSegmentVsPlane(VERT** verts, const int coord, int which) -{ - bool out0, out1; - if(which==-1) - out0 = verts[0]->coord[coord] < -verts[0]->coord[3]; - else - out0 = verts[0]->coord[coord] > verts[0]->coord[3]; - if(which==-1) - out1 = verts[1]->coord[coord] < -verts[1]->coord[3]; - else - out1 = verts[1]->coord[coord] > verts[1]->coord[3]; - - //CONSIDER: should we try and clip things behind the eye? does this code even successfully do it? not sure. - //if(coord==2 && which==1) { - // out0 = verts[0]->coord[2] < 0; - // out1 = verts[1]->coord[2] < 0; - //} - - //both outside: insert no points - if(out0 && out1) { - CLIPLOG(" both outside\n"); - } - - //both inside: insert the first point - if(!out0 && !out1) - { - CLIPLOG(" both inside\n"); - outClippedPoly.clipVerts[outClippedPoly.type++] = *verts[1]; - } - - //exiting volume: insert the clipped point and the first (interior) point - if(!out0 && out1) - { - CLIPLOG(" exiting\n"); - outClippedPoly.clipVerts[outClippedPoly.type++] = clipPoint(verts[0],verts[1], coord, which); - } - - //entering volume: insert clipped point - if(out0 && !out1) { - CLIPLOG(" entering\n"); - outClippedPoly.clipVerts[outClippedPoly.type++] = clipPoint(verts[1],verts[0], coord, which); - outClippedPoly.clipVerts[outClippedPoly.type++] = *verts[1]; - - } -} - -static FORCEINLINE void clipPolyVsPlane(const int coord, int which) -{ - outClippedPoly.type = 0; - CLIPLOG2("Clipping coord %d against %f\n",coord,x); - for(int i=0;itype; - - CLIPLOG("==Begin poly==\n"); - - tempClippedPoly.clipVerts[0] = gfx3d.vertlist->list[poly->vertIndexes[0]]; - tempClippedPoly.clipVerts[1] = gfx3d.vertlist->list[poly->vertIndexes[1]]; - tempClippedPoly.clipVerts[2] = gfx3d.vertlist->list[poly->vertIndexes[2]]; - if(type==4) - tempClippedPoly.clipVerts[3] = gfx3d.vertlist->list[poly->vertIndexes[3]]; - - - tempClippedPoly.type = type; - - clipPolyVsPlane(0, -1); - clipPolyVsPlane(0, 1); - clipPolyVsPlane(1, -1); - clipPolyVsPlane(1, 1); - clipPolyVsPlane(2, -1); - clipPolyVsPlane(2, 1); - //TODO - we need to parameterize back plane clipping - - - if(tempClippedPoly.type < 3) - { - //a totally clipped poly. discard it. - //or, a degenerate poly. we're not handling these right now - } - else - { - //TODO - build right in this list instead of copying - clippedPolys[clippedPolyCounter] = tempClippedPoly; - clippedPolys[clippedPolyCounter].poly = poly; - clippedPolyCounter++; - } - -} - -static void SoftRastRender() -{ - Fragment clearFragment; - FragmentColor clearFragmentColor; - clearFragment.isTranslucentPoly = 0; - clearFragmentColor.r = GFX3D_5TO6(gfx3d.clearColor&0x1F); - clearFragmentColor.g = GFX3D_5TO6((gfx3d.clearColor>>5)&0x1F); - clearFragmentColor.b = GFX3D_5TO6((gfx3d.clearColor>>10)&0x1F); - clearFragmentColor.a = ((gfx3d.clearColor>>16)&0x1F); - clearFragment.polyid.opaque = (gfx3d.clearColor>>24)&0x3F; - //special value for uninitialized translucent polyid. without this, fires in spiderman2 dont display - //I am not sure whether it is right, though. previously this was cleared to 0, as a guess, - //but in spiderman2 some fires with polyid 0 try to render on top of the background - clearFragment.polyid.translucent = kUnsetTranslucentPolyID; - clearFragment.depth = gfx3d.clearDepth; - clearFragment.stencil = 0; - clearFragment.isTranslucentPoly = 0; - clearFragment.fogged = BIT15(gfx3d.clearColor); - for(int i=0;i<256*192;i++) - screen[i] = clearFragment; - - if(gfx3d.enableClearImage) - { - u16* clearImage = (u16*)MMU.texInfo.textureSlotAddr[2]; - u16* clearDepth = (u16*)MMU.texInfo.textureSlotAddr[3]; - - //the lion, the witch, and the wardrobe (thats book 1, suck it you new-school numberers) - //uses the scroll registers in the main game engine - u16 scroll = T1ReadWord(MMU.ARM9_REG,0x356); //CLRIMAGE_OFFSET - u16 xscroll = scroll&0xFF; - u16 yscroll = (scroll>>8)&0xFF; - - FragmentColor *dstColor = screenColor; - Fragment *dst = screen; - - for(int iy=0;iy<192;iy++) { - int y = ((iy + yscroll)&255)<<8; - for(int ix=0;ix<256;ix++) { - int x = (ix + xscroll)&255; - int adr = y + x; - - //this is tested by harry potter and the order of the phoenix. - //TODO (optimization) dont do this if we are mapped to blank memory (such as in sonic chronicles) - //(or use a special zero fill in the bulk clearing above) - u16 col = clearImage[adr]; - dstColor->color = RGB15TO6665(col,31*(col>>15)); - - //this is tested quite well in the sonic chronicles main map mode - //where depth values are used for trees etc you can walk behind - u32 depth = clearDepth[adr]; - dst->fogged = BIT15(depth); - //TODO - might consider a lookup table for this - dst->depth = gfx3d_extendDepth_15_to_24(depth&0x7FFF); - - dstColor++; - dst++; - } - } - } - else - for(int i=0;i<256*192;i++) - screenColor[i] = clearFragmentColor; - - //convert the toon colors - //TODO for a slight speedup this could be cached in gfx3d (oglrenderer could benefit as well) - for(int i=0;i<32;i++) { - toonTable[i].r = GFX3D_5TO6((gfx3d.u16ToonTable[i])&0x1F); - toonTable[i].g = GFX3D_5TO6((gfx3d.u16ToonTable[i]>>5)&0x1F); - toonTable[i].b = GFX3D_5TO6((gfx3d.u16ToonTable[i]>>10)&0x1F); - } - - //setup fog variables (but only if fog is enabled) - if(gfx3d.enableFog) - { - u8* fogDensity = MMU.MMU_MEM[ARMCPU_ARM9][0x40] + 0x360; - //TODO - this might be a little slow; - //we might need to hash all the variables and only recompute this when something changes - const int increment = (0x400 >> gfx3d.fogShift); - for(u32 i=0;i<32768;i++) { - if(icount;i++) - gfx3d.vertlist->list[i].color_to_float(); - - //submit all polys to clipper - clippedPolyCounter = 0; - for(int i=0;icount;i++) - { - clipPoly(&gfx3d.polylist->list[gfx3d.indexlist[i]]); - } - - //printf("%d %d %d %d\n",gfx3d.viewport.x,gfx3d.viewport.y,gfx3d.viewport.width,gfx3d.viewport.height); - - //viewport transforms - for(int i=0;iviewport); - vert.coord[0] *= viewport.width; - vert.coord[0] += viewport.x; - vert.coord[1] *= viewport.height; - vert.coord[1] += viewport.y; - vert.coord[1] = 192 - vert.coord[1]; - - //well, i guess we need to do this to keep Princess Debut from rendering huge polys. - //there must be something strange going on - vert.coord[0] = max(0.0f,min(256.0f,vert.coord[0])); - vert.coord[1] = max(0.0f,min(192.0f,vert.coord[1])); - } - } - - //a counter for how many polys got culled - int culled = 0; - - u32 lastTextureFormat = 0, lastTexturePalette = 0, lastPolyAttr = 0; - - //iterate over polys - bool needInitTexture = true; - for(int i=0;ipolyAttr) - { - polyAttr.setup(poly->polyAttr); - polyAttr.translucent = poly->isTranslucent(); - lastPolyAttr = poly->polyAttr; - } - - //HACK: backface culling - //this should be moved to gfx3d, but first we need to redo the way the lists are built - //because it is too convoluted right now. - //(must we throw out verts if a poly gets backface culled? if not, then it might be easier) - //TODO - is this good enough for quads and other shapes? we think so. - float ab[2], ac[2]; - Vector2Copy(ab, verts[1].coord); - Vector2Copy(ac, verts[2].coord); - Vector2Subtract(ab, verts[0].coord); - Vector2Subtract(ac, verts[0].coord); - float cross = Vector2Cross(ab, ac); - polyAttr.backfacing = (cross>0); - - if(!polyAttr.isVisible(polyAttr.backfacing)) { - culled++; - continue; - } - - if(needInitTexture || lastTextureFormat != poly->texParam || lastTexturePalette != poly->texPalette) - { - TexCache_SetTexture(poly->texParam,poly->texPalette); - sampler.setup(poly->texParam); - lastTextureFormat = poly->texParam; - lastTexturePalette = poly->texPalette; - needInitTexture = false; - } - - //here is a hack which needs to be removed. - //at some point our shape engine needs these to be converted to "fixed point" - //which is currently just a float - for(int j=0;jpolyAttr); - - for(int j=0;jcount-culled,gfx3d.polylist->count); - SoftRastConvertFramebuffer(); -} - -GPU3DInterface gpu3DRasterize = { - "SoftRasterizer", - SoftRastInit, - SoftRastReset, - SoftRastClose, - SoftRastRender, - SoftRastVramReconfigureSignal, -}; +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright 2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +//nothing in this file should be assumed to be accurate +// +//the shape rasterizers contained herein are based on code supplied by Chris Hecker from +//http://chrishecker.com/Miscellaneous_Technical_Articles + +//The worst case we've managed to think of so far would be a viewport zoomed in a little bit +//on a diamond, with cut-out bits in all four corners +#define MAX_CLIPPED_VERTS 8 + +//TODO - due to a late change of a y-coord flipping, our winding order is wrong +//this causes us to have to flip the verts for every front-facing poly. +//a performance improvement would be to change the winding order logic +//so that this is done less frequently + +#include "rasterize.h" + +#include +#include +#include +#include + +#include "bits.h" +#include "common.h" +#include "matrix.h" +#include "render3D.h" +#include "gfx3d.h" +#include "texcache.h" +#include "NDSSystem.h" + +//#undef FORCEINLINE +//#define FORCEINLINE +//#undef INLINE +//#define INLINE + +using std::min; +using std::max; +using std::swap; + +template T _min(T a, T b, T c) { return min(min(a,b),c); } +template T _max(T a, T b, T c) { return max(max(a,b),c); } +template T _min(T a, T b, T c, T d) { return min(_min(a,b,d),c); } +template T _max(T a, T b, T c, T d) { return max(_max(a,b,d),c); } + +static const int kUnsetTranslucentPolyID = 255; + +static int polynum; + +static u8 modulate_table[32][32]; +static u8 decal_table[32][32][32]; +static u8 index_lookup_table[65]; +static u8 index_start_table[8]; + +static struct TClippedPoly +{ + int type; + POLY* poly; + VERT clipVerts[MAX_CLIPPED_VERTS]; +} *clippedPolys = NULL; +static int clippedPolyCounter; + +TClippedPoly tempClippedPoly; +TClippedPoly outClippedPoly; + +////optimized float floor useful in limited cases +////from http://www.stereopsis.com/FPU.html#convert +////(unfortunately, it relies on certain FPU register settings) +//int Real2Int(double val) +//{ +// const double _double2fixmagic = 68719476736.0*1.5; //2^36 * 1.5, (52-_shiftamt=36) uses limited precisicion to floor +// const int _shiftamt = 16; //16.16 fixed point representation, +// +// #ifdef WORDS_BIGENDIAN +// #define iman_ 1 +// #else +// #define iman_ 0 +// #endif +// +// val = val + _double2fixmagic; +// return ((int*)&val)[iman_] >> _shiftamt; +//} + +//// this probably relies on rounding settings.. +//int Real2Int(float val) +//{ +// //val -= 0.5f; +// //int temp; +// //__asm { +// // fld val; +// // fistp temp; +// //} +// //return temp; +// return 0; +//} + + +//doesnt work yet +static FORCEINLINE int fastFloor(float f) +{ + float temp = f + 1.f; + int ret = (*((u32*)&temp))&0x7FFFFF; + return ret; +} + + + +//----texture cache--- + +//TODO - the texcache could ask for a buffer to generate into +//that would avoid us ever having to buffercopy.. +struct TextureBuffers +{ + static const int numTextures = MAX_TEXTURE+1; + u8* buffers[numTextures]; + + void clear() { memset(buffers,0,sizeof(buffers)); } + + TextureBuffers() + { + clear(); + } + + void free() + { + for(int i=0;i>6)&3) { + case 0: return false; + case 1: return backfacing; + case 2: return !backfacing; + case 3: return true; + default: assert(false); return false; + } + } + + void setup(u32 polyAttr) + { + val = polyAttr; + decalMode = BIT14(val); + translucentDepthWrite = BIT11(val); + polyid = (polyAttr>>24)&0x3F; + alpha = (polyAttr>>16)&0x1F; + drawBackPlaneIntersectingPolys = BIT12(val); + } + +} polyAttr; + +union FragmentColor { + u32 color; + struct { +#ifdef WORDS_BIGENDIAN + u8 a,b,g,r; +#else + u8 r,g,b,a; +#endif + }; +}; + +struct Fragment +{ + u32 depth; + + struct { + u8 opaque, translucent; + } polyid; + + u8 stencil; + + u8 isTranslucentPoly; +}; + +static VERT* verts[MAX_CLIPPED_VERTS]; + +INLINE static void SubmitVertex(int vert_index, VERT& rawvert) +{ + verts[vert_index] = &rawvert; +} + +static Fragment screen[256*192]; +static FragmentColor screenColor[256*192]; +static FragmentColor toonTable[32]; + + +FORCEINLINE int iround(float f) { + return (int)f; //lol +} + + +static struct Sampler +{ + int width, height; + int wmask, hmask; + int wrap; + int wshift; + int texFormat; + void setup(u32 texParam) + { + texFormat = (texParam>>26)&7; + wshift = ((texParam>>20)&0x07) + 3; + width=(1 << wshift); + height=(8 << ((texParam>>23)&0x07)); + wmask = width-1; + hmask = height-1; + wrap = (texParam>>16)&0xF; + } + + FORCEINLINE void clamp(int &val, const int size, const int sizemask){ + if(val<0) val = 0; + if(val>sizemask) val = sizemask; + } + FORCEINLINE void hclamp(int &val) { clamp(val,width,wmask); } + FORCEINLINE void vclamp(int &val) { clamp(val,height,hmask); } + + FORCEINLINE void repeat(int &val, const int size, const int sizemask) { + val &= sizemask; + } + FORCEINLINE void hrepeat(int &val) { repeat(val,width,wmask); } + FORCEINLINE void vrepeat(int &val) { repeat(val,height,hmask); } + + FORCEINLINE void flip(int &val, const int size, const int sizemask) { + val &= ((size<<1)-1); + if(val>=size) val = (size<<1)-val-1; + } + FORCEINLINE void hflip(int &val) { flip(val,width,wmask); } + FORCEINLINE void vflip(int &val) { flip(val,height,hmask); } + + FORCEINLINE void dowrap(int& iu, int& iv) + { + switch(wrap) { + //flip none + case 0x0: hclamp(iu); vclamp(iv); break; + case 0x1: hrepeat(iu); vclamp(iv); break; + case 0x2: hclamp(iu); vrepeat(iv); break; + case 0x3: hrepeat(iu); vrepeat(iv); break; + //flip S + case 0x4: hclamp(iu); vclamp(iv); break; + case 0x5: hflip(iu); vclamp(iv); break; + case 0x6: hclamp(iu); vrepeat(iv); break; + case 0x7: hflip(iu); vrepeat(iv); break; + //flip T + case 0x8: hclamp(iu); vclamp(iv); break; + case 0x9: hrepeat(iu); vclamp(iv); break; + case 0xA: hclamp(iu); vflip(iv); break; + case 0xB: hrepeat(iu); vflip(iv); break; + //flip both + case 0xC: hclamp(iu); vclamp(iv); break; + case 0xD: hflip(iu); vclamp(iv); break; + case 0xE: hclamp(iu); vflip(iv); break; + case 0xF: hflip(iu); vflip(iv); break; + } + } + + FORCEINLINE FragmentColor sample(float u, float v) + { + //finally, we can use floor here. but, it is slower than we want. + //the best solution is probably to wait until the pipeline is full of fixed point + s32 iu = s32floor(u); + s32 iv = s32floor(v); + dowrap(iu,iv); + + FragmentColor color; + color.color = ((u32*)textures.currentData)[(iv<>4)&0x3; + //if there is no texture set, then set to the mode which doesnt even use a texture + if(sampler.texFormat == 0 && mode == 0) + mode = 4; + } + + float invu, invv, w; + FragmentColor materialColor; + + FORCEINLINE void shade(FragmentColor& dst) + { + FragmentColor texColor; + float u,v; + + switch(mode) + { + case 0: //modulate + u = invu*w; + v = invv*w; + texColor = sampler.sample(u,v); + dst.r = modulate_table[texColor.r][materialColor.r]; + dst.g = modulate_table[texColor.g][materialColor.g]; + dst.b = modulate_table[texColor.b][materialColor.b]; + dst.a = modulate_table[texColor.a][materialColor.a]; + //dst.color.components.a = 31; + //#ifdef _MSC_VER + //if(GetAsyncKeyState(VK_SHIFT)) { + // //debugging tricks + // dst = materialColor; + // if(GetAsyncKeyState(VK_TAB)) { + // u8 alpha = dst.a; + // dst.color = polynum*8+8; + // dst.a = alpha; + // } + //} + //#endif + break; + case 1: //decal + u = invu*w; + v = invv*w; + texColor = sampler.sample(u,v); + dst.r = decal_table[texColor.a][texColor.r][materialColor.r]; + dst.g = decal_table[texColor.a][texColor.g][materialColor.g]; + dst.b = decal_table[texColor.a][texColor.b][materialColor.b]; + dst.a = materialColor.a; + break; + case 2: //toon/highlight shading + { + u = invu*w; + v = invv*w; + texColor = sampler.sample(u,v); + FragmentColor toonColor = toonTable[materialColor.r]; + if(sampler.texFormat == 0) + { + //if no texture is set then we dont need to modulate texture with toon + //but rather just use toon directly + dst = toonColor; + dst.a = materialColor.a; + } + else + { + if(gfx3d.shading == GFX3D::HIGHLIGHT) + { + dst.r = modulate_table[texColor.r][materialColor.r]; + dst.g = modulate_table[texColor.g][materialColor.r]; + dst.b = modulate_table[texColor.b][materialColor.r]; + dst.a = modulate_table[texColor.a][materialColor.a]; + + dst.r = min(31, (dst.r + toonColor.r)); + dst.g = min(31, (dst.g + toonColor.g)); + dst.b = min(31, (dst.b + toonColor.b)); + } + else + { + dst.r = modulate_table[texColor.r][toonColor.r]; + dst.g = modulate_table[texColor.g][toonColor.g]; + dst.b = modulate_table[texColor.b][toonColor.b]; + dst.a = modulate_table[texColor.a][materialColor.a]; + } + } + } + break; + case 3: //shadows + //is this right? only with the material color? + dst = materialColor; + break; + case 4: //our own special mode which only uses the material color (for when texturing is disabled) + dst = materialColor; + break; + + } + } + +} shader; + +static FORCEINLINE void alphaBlend(FragmentColor & dst, const FragmentColor & src) +{ + u8 dstAlpha = dst.a; + if(gfx3d.enableAlphaBlending) + { + if(src.a == 0 || dst.a == 0) + { + dst = src; + } + else + { + u8 alpha = src.a+1; + u8 invAlpha = 32 - alpha; + dst.r = (alpha*src.r + invAlpha*dst.r)>>5; + dst.g = (alpha*src.g + invAlpha*dst.g)>>5; + dst.b = (alpha*src.b + invAlpha*dst.b)>>5; + } + + dst.a = max(src.a,dst.a); + } + else + { + if(src.a == 0) + { + //do nothing; the fragment is totally transparent + } + else + { + dst = src; + } + } +} + +static FORCEINLINE void pixel(int adr,float r, float g, float b, float invu, float invv, float w, float z) { + Fragment &destFragment = screen[adr]; + FragmentColor &destFragmentColor = screenColor[adr]; + + //depth test + u32 depth; + if(gfx3d.wbuffer) { + //not sure about this + //this value was chosen to make the skybox, castle window decals, and water level render correctly in SM64 + depth = u32floor(4096*w); + } + else + { + depth = u32floor(z*0x7FFF); + depth <<= 9; + } + if(polyAttr.decalMode) + { + if(depth != destFragment.depth) + { + goto depth_fail; + } + } + else + { + if(depth>=destFragment.depth) + { + goto depth_fail; + } + } + + shader.w = w; + shader.invu = invu; + shader.invv = invv; + + //perspective-correct the colors + r = (r * w) + 0.5f; + g = (g * w) + 0.5f; + b = (b * w) + 0.5f; + + //this is a HACK: + //we are being very sloppy with our interpolation precision right now + //and rather than fix it, i just want to clamp it + shader.materialColor.r = max(0U,min(31U,u32floor(r))); + shader.materialColor.g = max(0U,min(31U,u32floor(g))); + shader.materialColor.b = max(0U,min(31U,u32floor(b))); + + shader.materialColor.a = polyAttr.alpha; + + //pixel shader + FragmentColor shaderOutput; + shader.shade(shaderOutput); + + //alpha test + if(gfx3d.enableAlphaTest) + { + if(shaderOutput.a < gfx3d.alphaTestRef) + goto rejected_fragment; + } + + //we shouldnt do any of this if we generated a totally transparent pixel + if(shaderOutput.a != 0) + { + //handle shadow polys + if(shader.mode == 3) + { + if(polyAttr.polyid == 0) + { + destFragment.stencil = 1; + goto rejected_fragment; + } + else + { + //some shadow volumes are rendering two-sided + //and this is the only way to fix them. + //rendering two-sided makes no sense, since the back side + //will clear the stencil bit and cause the shadow to get drawn in + //empty space. + //but yet, it is done, and gbatek even suggests that we should do it + if(polyAttr.backfacing) + goto rejected_fragment; + + //now, if we arent supposed to draw shadow here, then bail out + if(destFragment.stencil == 1) + { + destFragment.stencil = 0; + goto rejected_fragment; + } + + destFragment.stencil = 0; + } + + //reset the shadow flag to keep the shadow from getting drawn more than once + //if(polyAttr.polyid == 0) + // destFragment.stencil = 1; + } + + //handle polyids + bool isOpaquePixel = shaderOutput.a == 31; + if(isOpaquePixel) + { + destFragment.polyid.opaque = polyAttr.polyid; + destFragment.isTranslucentPoly = polyAttr.translucent?1:0; + destFragmentColor = shaderOutput; + } + else + { + + //shadow polys have a special check here to keep from self-shadowing when user + //has tried to prevent it from happening + //if this isnt here, then the vehicle select in mariokart will look terrible + if(shader.mode == 3) + { + if(destFragment.polyid.opaque == polyAttr.polyid) + goto rejected_fragment; + } + + //dont overwrite pixels on translucent polys with the same polyids + if(destFragment.polyid.translucent == polyAttr.polyid) + goto rejected_fragment; + + //originally we were using a test case of shadows-behind-trees in sm64ds + //but, it looks bad in that game. this is actually correct + //if this isnt correct, then complex shape cart shadows in mario kart don't work right + destFragment.polyid.translucent = polyAttr.polyid; + + //alpha blending and write color + alphaBlend(destFragmentColor, shaderOutput); + } + + //depth writing + if(isOpaquePixel || polyAttr.translucentDepthWrite) + destFragment.depth = depth; + + } + + goto done_with_pixel; + + depth_fail: + //handle stencil-writing in shadow mode +/* if((shader.mode == 3) && (polyAttr.polyid == 0)) + { + destFragment.stencil = 1; + }*/ + + rejected_fragment: + done_with_pixel: + ; +} + + +typedef int fixed28_4; + +static bool failure; + +// handle floor divides and mods correctly +INLINE void FloorDivMod(long Numerator, long Denominator, long &Floor, long &Mod) +{ + //These must be caused by invalid or degenerate shapes.. not sure yet. + //check it out in the mario face intro of SM64 + //so, we have to take out the assert. + //I do know that we handle SOME invalid shapes without crashing, + //since I see them acting poppy in a way that doesnt happen in the HW.. so alas it is also incorrect. + //This particular incorrectness is not likely ever to get fixed! + + //assert(Denominator > 0); + + //but we have to bail out since our handling for these cases currently steps scanlines + //the wrong way and goes totally nuts (freezes) + if(Denominator<=0) + failure = true; + + if(Numerator >= 0) { + // positive case, C is okay + Floor = Numerator / Denominator; + Mod = Numerator % Denominator; + } else { + // Numerator is negative, do the right thing + Floor = -((-Numerator) / Denominator); + Mod = (-Numerator) % Denominator; + if(Mod) { + // there is a remainder + Floor--; Mod = Denominator - Mod; + } + } +} + +INLINE fixed28_4 FloatToFixed28_4( float Value ) { + return (fixed28_4)(Value * 16); +} +INLINE float Fixed28_4ToFloat( fixed28_4 Value ) { + return Value / 16.0; +} +//inline fixed16_16 FloatToFixed16_16( float Value ) { +// return (fixed16_6)(Value * 65536); +//} +//inline float Fixed16_16ToFloat( fixed16_16 Value ) { +// return Value / 65536.0; +//} +INLINE fixed28_4 Fixed28_4Mul( fixed28_4 A, fixed28_4 B ) { + // could make this asm to prevent overflow + return (A * B) / 16; // 28.4 * 28.4 = 24.8 / 16 = 28.4 +} +INLINE int Ceil28_4( fixed28_4 Value ) { + int ReturnValue; + int Numerator = Value - 1 + 16; + if(Numerator >= 0) { + ReturnValue = Numerator/16; + } else { + // deal with negative numerators correctly + ReturnValue = -((-Numerator)/16); + ReturnValue -= ((-Numerator) % 16) ? 1 : 0; + } + return ReturnValue; +} + +struct edge_fx_fl { + edge_fx_fl() {} + edge_fx_fl(int Top, int Bottom); + FORCEINLINE int Step(); + + long X, XStep, Numerator, Denominator; // DDA info for x + long ErrorTerm; + int Y, Height; // current y and vertical count + + struct Interpolant { + float curr, step, stepExtra; + FORCEINLINE void doStep() { curr += step; } + FORCEINLINE void doStepExtra() { curr += stepExtra; } + void initialize(float top, float bottom, float dx, float dy, long XStep, float XPrestep, float YPrestep) { + dx = 0; + dy *= (bottom-top); + curr = top + YPrestep * dy + XPrestep * dx; + step = XStep * dx + dy; + stepExtra = dx; + } + }; + + static const int NUM_INTERPOLANTS = 7; + union { + struct { + Interpolant invw,z,u,v,color[3]; + }; + Interpolant interpolants[NUM_INTERPOLANTS]; + }; + void FORCEINLINE doStepInterpolants() { for(int i=0;iy); + int YEnd = Ceil28_4(verts[Bottom]->y); + Height = YEnd - Y; + + if(Height) + { + long dN = long(verts[Bottom]->y - verts[Top]->y); + long dM = long(verts[Bottom]->x - verts[Top]->x); + + long InitialNumerator = dM*16*Y - dM*verts[Top]->y + dN*verts[Top]->x - 1 + dN*16; + FloorDivMod(InitialNumerator,dN*16,X,ErrorTerm); + FloorDivMod(dM*16,dN*16,XStep,Numerator); + Denominator = dN*16; + + float YPrestep = Fixed28_4ToFloat(Y*16 - verts[Top]->y); + float XPrestep = Fixed28_4ToFloat(X*16 - verts[Top]->x); + + float dy = 1/Fixed28_4ToFloat(dN); + float dx = 1/Fixed28_4ToFloat(dM); + + invw.initialize(1/verts[Top]->w,1/verts[Bottom]->w,dx,dy,XStep,XPrestep,YPrestep); + u.initialize(verts[Top]->u,verts[Bottom]->u,dx,dy,XStep,XPrestep,YPrestep); + v.initialize(verts[Top]->v,verts[Bottom]->v,dx,dy,XStep,XPrestep,YPrestep); + z.initialize(verts[Top]->z,verts[Bottom]->z,dx,dy,XStep,XPrestep,YPrestep); + for(int i=0;i<3;i++) + color[i].initialize(verts[Top]->fcolor[i],verts[Bottom]->fcolor[i],dx,dy,XStep,XPrestep,YPrestep); + } +} + +FORCEINLINE int edge_fx_fl::Step() { + X += XStep; Y++; Height--; + doStepInterpolants(); + + ErrorTerm += Numerator; + if(ErrorTerm >= Denominator) { + X++; + ErrorTerm -= Denominator; + doStepExtraInterpolants(); + } + return Height; +} + +//draws a single scanline +static void drawscanline(edge_fx_fl *pLeft, edge_fx_fl *pRight) +{ + int XStart = pLeft->X; + int width = pRight->X - XStart; + + //these are the starting values, taken from the left edge + float invw = pLeft->invw.curr; + float u = pLeft->u.curr; + float v = pLeft->v.curr; + float z = pLeft->z.curr; + float color[3] = { + pLeft->color[0].curr, + pLeft->color[1].curr, + pLeft->color[2].curr }; + + //our dx values are taken from the steps up until the right edge + float invWidth = 1.0f / width; + float dinvw_dx = (pRight->invw.curr - invw) * invWidth; + float du_dx = (pRight->u.curr - u) * invWidth; + float dv_dx = (pRight->v.curr - v) * invWidth; + float dz_dx = (pRight->z.curr - z) * invWidth; + float dc_dx[3] = { + (pRight->color[0].curr - color[0]) * invWidth, + (pRight->color[1].curr - color[1]) * invWidth, + (pRight->color[2].curr - color[2]) * invWidth }; + + int adr = (pLeft->Y<<8)+XStart; + + //CONSIDER: in case some other math is wrong (shouldve been clipped OK), we might go out of bounds here. + //better check the Y value. + if(pLeft->Y<0 || pLeft->Y>191) { + printf("rasterizer rendering at y=%d! oops!\n",pLeft->Y); + return; + } + + int x = XStart; + + while(width-- > 0) + { + if(x<0 || x>255) { + printf("rasterizer rendering at x=%d! oops!\n",x); + return; + } + pixel(adr,color[0],color[1],color[2],u,v,1.0f/invw,z); + adr++; + x++; + + invw += dinvw_dx; + u += du_dx; + v += dv_dx; + z += dz_dx; + color[0] += dc_dx[0]; + color[1] += dc_dx[1]; + color[2] += dc_dx[2]; + } +} + +//runs several scanlines, until an edge is finished +static void runscanlines(edge_fx_fl *left, edge_fx_fl *right) +{ + //do not overstep either of the edges + int Height = min(left->Height,right->Height); + while(Height--) { + drawscanline(left,right); + left->Step(); + right->Step(); + } +} + +//rotates verts counterclockwise +template +INLINE static void rot_verts() { + #define ROTSWAP(X) if(type>X) swap(verts[X-1],verts[X]); + ROTSWAP(1); ROTSWAP(2); ROTSWAP(3); ROTSWAP(4); + ROTSWAP(5); ROTSWAP(6); ROTSWAP(7); +} + +//rotate verts until vert0.y is minimum, and then vert0.x is minimum in case of ties +//this is a necessary precondition for our shape engine +template +static void sort_verts(bool backwards) { + //if the verts are backwards, reorder them first + if(backwards) + for(int i=0;iX) if(verts[0]->y > verts[X]->y) goto doswap; + CHECKY(1); CHECKY(2); CHECKY(3); CHECKY(4); + CHECKY(5); CHECKY(6); CHECKY(7); + break; + + doswap: + rot_verts(); + } + + while(verts[0]->y == verts[1]->y && verts[0]->x > verts[1]->x) + rot_verts(); + +} + +//This function can handle any convex N-gon up to octagons +//verts must be clockwise. +//I didnt reference anything for this algorithm but it seems like I've seen it somewhere before. +static void shape_engine(int type, bool backwards) +{ + failure = false; + + switch(type) { + case 3: sort_verts<3>(backwards); break; + case 4: sort_verts<4>(backwards); break; + case 5: sort_verts<5>(backwards); break; + case 6: sort_verts<6>(backwards); break; + case 7: sort_verts<7>(backwards); break; + case 8: sort_verts<8>(backwards); break; + default: printf("skipping type %d\n",type); return; + } + + //we are going to step around the polygon in both directions starting from vert 0. + //right edges will be stepped over clockwise and left edges stepped over counterclockwise. + //these variables track that stepping, but in order to facilitate wrapping we start extra high + //for the counter we're decrementing. + int lv = type, rv = 0; + + edge_fx_fl left, right; + bool step_left = true, step_right = true; + for(;;) { + //generate new edges if necessary. we must avoid regenerating edges when they are incomplete + //so that they can be continued on down the shape + assert(rv != type); + int _lv = lv==type?0:lv; //make sure that we ask for vert 0 when the variable contains the starting value + if(step_left) left = edge_fx_fl(_lv,lv-1); + if(step_right) right = edge_fx_fl(rv,rv+1); + step_left = step_right = false; + + //handle a failure in the edge setup due to nutty polys + if(failure) + return; + + + + runscanlines(&left,&right); + + //if we ran out of an edge, step to the next one + if(right.Height == 0) { + step_right = true; + rv++; + } + if(left.Height == 0) { + step_left = true; + lv--; + } + + //this is our completion condition: when our stepped edges meet in the middle + if(lv<=rv+1) break; + } + +} + +static char SoftRastInit(void) +{ + static bool tables_generated = false; + if(!tables_generated) + { + tables_generated = true; + + clippedPolys = new TClippedPoly[POLYLIST_SIZE*2]; + + for(int i=0;i<32;i++) + { + for(int j=0;j<32;j++) + { + modulate_table[i][j] = ((i+1) * (j+1) - 1) >> 5; + for(int a=0;a<32;a++) + decal_table[a][i][j] = ((i*a) + (j*(31-a))) >> 5; + } + } + + //these tables are used to increment through vert lists without having to do wrapping logic/math + int idx=0; + for(int i=3;i<=8;i++) + { + index_start_table[i-3] = idx; + for(int j=0;j>24)&0x3F)>>3; + + //TODO - need to test and find out whether these get grabbed at flush time, or at render time + //we can do this by rendering a 3d frame and then freezing the system, but only changing the edge mark colors + + //now, I am not entirely sure about this. I can't find any documentation about the high bit here but + //it doesnt seem plausible to me that its all or nothing. I think that only polyid groups with a color + //with the high bit set get edge marked. + u16 edgeMarkColors[8]; + bool edgeMarkEnables[8]; + for(int i=0;i<8;i++) + { + edgeMarkColors[i] = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x330+i*2); + edgeMarkEnables[i] = (edgeMarkColors[i]&0x8000)!=0; + } + + for(int i=0,y=0;y<192;y++) + { + for(int x=0;x<256;x++,i++) + { + Fragment &destFragment = screen[i]; + FragmentColor &destFragmentColor = screenColor[i]; + u8 self = destFragment.polyid.opaque>>3; + if(!edgeMarkEnables[self]) continue; + if(destFragment.isTranslucentPoly) continue; + + u8 left = x==0?clearPolyid:(screen[i-1].polyid.opaque>>3); + u8 right = x==255?clearPolyid:(screen[i+1].polyid.opaque>>3); + u8 top = y==0?clearPolyid:(screen[i-256].polyid.opaque>>3); + u8 bottom = y==191?clearPolyid:(screen[i+256].polyid.opaque>>3); + + if(left != self || right != self || top != self || bottom != self) + { + destFragmentColor.color = edgeMarkColors[self]; + } + + + } + } + + } + +} + +static void SoftRastConvertFramebuffer() +{ + FragmentColor* src = screenColor; + u16* dst = gfx3d_convertedScreen; + u8* dstAlpha = gfx3d_convertedAlpha; + + //in an effort to speed this up, the misc pixel buffers and the color buffer were separated. + + for(int i=0,y=0;y<192;y++) + { + #ifndef NOSSE2 + u8* wanx = (u8*)&src[i]; + #define ASS(X,Y) __asm { prefetchnta [wanx+32*0x##X##Y] } + #define PUNK(X) ASS(X,0) ASS(X,1) ASS(X,2) ASS(X,3) ASS(X,4) ASS(X,5) ASS(X,6) ASS(X,7) ASS(X,8) ASS(X,9) ASS(X,A) ASS(X,B) ASS(X,C) ASS(X,D) ASS(X,E) ASS(X,F) + PUNK(0); PUNK(1); + #endif + + for(int x=0;x<256;x++,i++) + { + const u8 r = src[i].r; + const u8 g = src[i].g; + const u8 b = src[i].b; + const u8 a = src[i].a; + dst[i] = R5G5B5TORGB15(r,g,b) | alpha_lookup[a]; + dstAlpha[i] = alpha_5bit_to_4bit[a]; + } + } +} + + +template +static T interpolate(const float ratio, const T& x0, const T& x1) { + return x0 + (float)(x1-x0) * (ratio); +} + + +//http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/as6/discussion.shtml +static FORCEINLINE VERT clipPoint(VERT* inside, VERT* outside, int coord, int which) +{ + VERT ret; + + float coord_inside = inside->coord[coord]; + float coord_outside = outside->coord[coord]; + float w_inside = inside->coord[3]; + float w_outside = outside->coord[3]; + + float t; + + if(which==-1) { + w_outside = -w_outside; + w_inside = -w_inside; + } + + t = (coord_inside - w_inside)/ ((w_outside-w_inside) - (coord_outside-coord_inside)); + + +#define INTERP(X) ret . X = interpolate(t, inside-> X ,outside-> X ) + + INTERP(coord[0]); INTERP(coord[1]); INTERP(coord[2]); INTERP(coord[3]); + INTERP(texcoord[0]); INTERP(texcoord[1]); + + if(CommonSettings.HighResolutionInterpolateColor) + { + INTERP(fcolor[0]); INTERP(fcolor[1]); INTERP(fcolor[2]); + } + else + { + INTERP(color[0]); INTERP(color[1]); INTERP(color[2]); + ret.color_to_float(); + } + + //this seems like a prudent measure to make sure that math doesnt make a point pop back out + //of the clip volume through interpolation + if(which==-1) + ret.coord[coord] = -ret.coord[3]; + else + ret.coord[coord] = ret.coord[3]; + + return ret; +} + +//#define CLIPLOG(X) printf(X); +//#define CLIPLOG2(X,Y,Z) printf(X,Y,Z); +#define CLIPLOG(X) +#define CLIPLOG2(X,Y,Z) + +static FORCEINLINE void clipSegmentVsPlane(VERT** verts, const int coord, int which) +{ + bool out0, out1; + if(which==-1) + out0 = verts[0]->coord[coord] < -verts[0]->coord[3]; + else + out0 = verts[0]->coord[coord] > verts[0]->coord[3]; + if(which==-1) + out1 = verts[1]->coord[coord] < -verts[1]->coord[3]; + else + out1 = verts[1]->coord[coord] > verts[1]->coord[3]; + + //CONSIDER: should we try and clip things behind the eye? does this code even successfully do it? not sure. + //if(coord==2 && which==1) { + // out0 = verts[0]->coord[2] < 0; + // out1 = verts[1]->coord[2] < 0; + //} + + //both outside: insert no points + if(out0 && out1) { + CLIPLOG(" both outside\n"); + } + + //both inside: insert the first point + if(!out0 && !out1) + { + CLIPLOG(" both inside\n"); + outClippedPoly.clipVerts[outClippedPoly.type++] = *verts[1]; + } + + //exiting volume: insert the clipped point and the first (interior) point + if(!out0 && out1) + { + CLIPLOG(" exiting\n"); + outClippedPoly.clipVerts[outClippedPoly.type++] = clipPoint(verts[0],verts[1], coord, which); + } + + //entering volume: insert clipped point + if(out0 && !out1) { + CLIPLOG(" entering\n"); + outClippedPoly.clipVerts[outClippedPoly.type++] = clipPoint(verts[1],verts[0], coord, which); + outClippedPoly.clipVerts[outClippedPoly.type++] = *verts[1]; + + } +} + +static FORCEINLINE void clipPolyVsPlane(const int coord, int which) +{ + outClippedPoly.type = 0; + CLIPLOG2("Clipping coord %d against %f\n",coord,x); + for(int i=0;itype; + + CLIPLOG("==Begin poly==\n"); + + tempClippedPoly.clipVerts[0] = gfx3d.vertlist->list[poly->vertIndexes[0]]; + tempClippedPoly.clipVerts[1] = gfx3d.vertlist->list[poly->vertIndexes[1]]; + tempClippedPoly.clipVerts[2] = gfx3d.vertlist->list[poly->vertIndexes[2]]; + if(type==4) + tempClippedPoly.clipVerts[3] = gfx3d.vertlist->list[poly->vertIndexes[3]]; + + + tempClippedPoly.type = type; + + clipPolyVsPlane(0, -1); + clipPolyVsPlane(0, 1); + clipPolyVsPlane(1, -1); + clipPolyVsPlane(1, 1); + clipPolyVsPlane(2, -1); + clipPolyVsPlane(2, 1); + //TODO - we need to parameterize back plane clipping + + + if(tempClippedPoly.type < 3) + { + //a totally clipped poly. discard it. + //or, a degenerate poly. we're not handling these right now + } + else + { + //TODO - build right in this list instead of copying + clippedPolys[clippedPolyCounter] = tempClippedPoly; + clippedPolys[clippedPolyCounter].poly = poly; + clippedPolyCounter++; + } + +} + +static void SoftRastRender() +{ + Fragment clearFragment; + FragmentColor clearFragmentColor; + clearFragment.isTranslucentPoly = 0; + clearFragmentColor.r = gfx3d.clearColor&0x1F; + clearFragmentColor.g = (gfx3d.clearColor>>5)&0x1F; + clearFragmentColor.b = (gfx3d.clearColor>>10)&0x1F; + clearFragmentColor.a = (gfx3d.clearColor>>16)&0x1F; + clearFragment.polyid.opaque = (gfx3d.clearColor>>24)&0x3F; + //special value for uninitialized translucent polyid. without this, fires in spiderman2 dont display + //I am not sure whether it is right, though. previously this was cleared to 0, as a guess, + //but in spiderman2 some fires with polyid 0 try to render on top of the background + clearFragment.polyid.translucent = kUnsetTranslucentPolyID; + clearFragment.depth = gfx3d.clearDepth; + clearFragment.stencil = 0; + for(int i=0;i<256*192;i++) + screen[i] = clearFragment; + + if(gfx3d.enableClearImage) + { + u16* clearImage = (u16*)ARM9Mem.texInfo.textureSlotAddr[2]; + u16* clearDepth = (u16*)ARM9Mem.texInfo.textureSlotAddr[3]; + + //not emulated until we actually have a test case + //(since in the meantime it would just slow us down) + //(and when we find a case, it will be obvious that it isnt scrolling, instead of possibly obscured by a bug) + u16 scroll = T1ReadWord(ARM9Mem.ARM9_REG,0x356); //CLRIMAGE_OFFSET + u16 xscroll = scroll&0xFF; + u16 yscroll = (scroll>>8)&0xFF; + + FragmentColor *dstColor = screenColor; + Fragment *dst = screen; + + for(int y=0;y<192;y++) + for(int x=0;x<256;x++) { + + //this is tested by harry potter and the order of the phoenix. + //TODO (optimization) dont do this if we are mapped to blank memory (such as in sonic chronicles) + //(or use a special zero fill in the bulk clearing above) + u16 col = *clearImage; + dstColor->color = RGB15TO5555(col,31*(col>>15)); + + //this is tested quite well in the sonic chronicles main map mode + //where depth values are used for trees etc you can walk behind + u32 depth = *clearDepth; + //masking off fog for now + depth &= 0x7FFF; + //TODO - might consider a lookup table for this + dst->depth = gfx3d_extendDepth_15_to_24(depth); + + clearDepth++; + clearImage++; + dstColor++; + dst++; + } + } + else + for(int i=0;i<256*192;i++) + screenColor[i] = clearFragmentColor; + + //convert the toon colors + //TODO for a slight speedup this could be cached in gfx3d (oglrenderer could benefit as well) + for(int i=0;i<32;i++) { + toonTable[i].r = gfx3d.u16ToonTable[i]&0x1F; + toonTable[i].g = (gfx3d.u16ToonTable[i]>>5)&0x1F; + toonTable[i].b = (gfx3d.u16ToonTable[i]>>10)&0x1F; + } + + //convert colors to float to get more precision in case we need it + for(int i=0;icount;i++) + gfx3d.vertlist->list[i].color_to_float(); + + //submit all polys to clipper + clippedPolyCounter = 0; + for(int i=0;icount;i++) + { + clipPoly(&gfx3d.polylist->list[gfx3d.indexlist[i]]); + } + + //printf("%d %d %d %d\n",gfx3d.viewport.x,gfx3d.viewport.y,gfx3d.viewport.width,gfx3d.viewport.height); + + //viewport transforms + for(int i=0;iviewport); + vert.coord[0] *= viewport.width; + vert.coord[0] += viewport.x; + vert.coord[1] *= viewport.height; + vert.coord[1] += viewport.y; + vert.coord[1] = 192 - vert.coord[1]; + + //well, i guess we need to do this to keep Princess Debut from rendering huge polys. + //there must be something strange going on + vert.coord[0] = max(0.0f,min(256.0f,vert.coord[0])); + vert.coord[1] = max(0.0f,min(192.0f,vert.coord[1])); + } + } + + //a counter for how many polys got culled + int culled = 0; + + u32 lastTextureFormat = 0, lastTexturePalette = 0, lastPolyAttr = 0; + + //iterate over polys + bool needInitTexture = true; + for(int i=0;ipolyAttr) + { + polyAttr.setup(poly->polyAttr); + polyAttr.translucent = poly->isTranslucent(); + lastPolyAttr = poly->polyAttr; + } + + //HACK: backface culling + //this should be moved to gfx3d, but first we need to redo the way the lists are built + //because it is too convoluted right now. + //(must we throw out verts if a poly gets backface culled? if not, then it might be easier) + //TODO - is this good enough for quads and other shapes? we think so. + float ab[2], ac[2]; + Vector2Copy(ab, verts[1].coord); + Vector2Copy(ac, verts[2].coord); + Vector2Subtract(ab, verts[0].coord); + Vector2Subtract(ac, verts[0].coord); + float cross = Vector2Cross(ab, ac); + polyAttr.backfacing = (cross>0); + + if(!polyAttr.isVisible(polyAttr.backfacing)) { + culled++; + continue; + } + + if(needInitTexture || lastTextureFormat != poly->texParam || lastTexturePalette != poly->texPalette) + { + TexCache_SetTexture(poly->texParam,poly->texPalette); + sampler.setup(poly->texParam); + lastTextureFormat = poly->texParam; + lastTexturePalette = poly->texPalette; + needInitTexture = false; + } + + //here is a hack which needs to be removed. + //at some point our shape engine needs these to be converted to "fixed point" + //which is currently just a float + for(int j=0;jpolyAttr); + + for(int j=0;jcount-culled,gfx3d.polylist->count); + SoftRastConvertFramebuffer(); +} + +GPU3DInterface gpu3DRasterize = { + "SoftRasterizer", + SoftRastInit, + SoftRastReset, + SoftRastClose, + SoftRastRender, + SoftRastVramReconfigureSignal, +}; diff --git a/desmume/src/rasterize.h b/src/rasterize.h similarity index 96% rename from desmume/src/rasterize.h rename to src/rasterize.h index 9f24e2c04..ca7a515e9 100644 --- a/desmume/src/rasterize.h +++ b/src/rasterize.h @@ -1,31 +1,31 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _RASTERIZE_H_ -#define _RASTERIZE_H_ - -#include "render3D.h" - -extern GPU3DInterface gpu3DRasterize; - -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright 2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _RASTERIZE_H_ +#define _RASTERIZE_H_ + +#include "render3D.h" + +extern GPU3DInterface gpu3DRasterize; + +#endif diff --git a/desmume/src/readwrite.cpp b/src/readwrite.cpp similarity index 85% rename from desmume/src/readwrite.cpp rename to src/readwrite.cpp index 5c2e98ecc..10363b17b 100644 --- a/desmume/src/readwrite.cpp +++ b/src/readwrite.cpp @@ -1,183 +1,173 @@ -/* readwrite.cpp - - Copyright (C) 2006-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "readwrite.h" -#include "types.h" - -//well. just for the sake of consistency -int write8le(u8 b, FILE *fp) -{ - return((fwrite(&b,1,1,fp)<1)?0:1); -} - -//well. just for the sake of consistency -int write8le(u8 b, std::ostream *os) -{ - os->write((char*)&b,1); - return 1; -} - -//well. just for the sake of consistency -int read8le(u8 *Bufo, std::istream *is) -{ - if(is->read((char*)Bufo,1).gcount() != 1) - return 0; - return 1; -} - -///writes a little endian 16bit value to the specified file -int write16le(u16 b, FILE *fp) -{ - u8 s[2]; - s[0]=(u8)b; - s[1]=(u8)(b>>8); - return((fwrite(s,1,2,fp)<2)?0:2); -} - - -///writes a little endian 16bit value to the specified file -int write16le(u16 b, std::ostream *os) -{ - u8 s[2]; - s[0]=(u8)b; - s[1]=(u8)(b>>8); - os->write((char*)&s,2); - return 2; -} - -///writes a little endian 32bit value to the specified file -int write32le(u32 b, FILE *fp) -{ - u8 s[4]; - s[0]=(u8)b; - s[1]=(u8)(b>>8); - s[2]=(u8)(b>>16); - s[3]=(u8)(b>>24); - return((fwrite(s,1,4,fp)<4)?0:4); -} - -int write32le(u32 b, std::ostream* os) -{ - u8 s[4]; - s[0]=(u8)b; - s[1]=(u8)(b>>8); - s[2]=(u8)(b>>16); - s[3]=(u8)(b>>24); - os->write((char*)&s,4); - return 4; -} - -void writebool(bool b, std::ostream* os) { write32le(b?1:0,os); } - -int write64le(u64 b, std::ostream* os) -{ - u8 s[8]; - s[0]=(u8)b; - s[1]=(u8)(b>>8); - s[2]=(u8)(b>>16); - s[3]=(u8)(b>>24); - s[4]=(u8)(b>>32); - s[5]=(u8)(b>>40); - s[6]=(u8)(b>>48); - s[7]=(u8)(b>>56); - os->write((char*)&s,8); - return 8; -} - - -///reads a little endian 32bit value from the specified file -int read32le(u32 *Bufo, FILE *fp) -{ - u32 buf; - if(fread(&buf,1,4,fp)<4) - return 0; -#ifdef LOCAL_LE - *(u32*)Bufo=buf; -#else - *(u32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24); -#endif - return 1; -} - -int read16le(u16 *Bufo, std::istream *is) -{ - u16 buf; - if(is->read((char*)&buf,2).gcount() != 2) - return 0; -#ifdef LOCAL_LE - *Bufo=buf; -#else - *Bufo = LE_TO_LOCAL_16(buf); -#endif - return 1; -} - -///reads a little endian 64bit value from the specified file -int read64le(u64 *Bufo, std::istream *is) -{ - u64 buf; - if(is->read((char*)&buf,8).gcount() != 8) - return 0; -#ifdef LOCAL_LE - *Bufo=buf; -#else - *Bufo = LE_TO_LOCAL_64(buf); -#endif - return 1; -} - -int read32le(u32 *Bufo, std::istream *is) -{ - u32 buf; - if(is->read((char*)&buf,4).gcount() != 4) - return 0; -#ifdef LOCAL_LE - *(u32*)Bufo=buf; -#else - *(u32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24); -#endif - return 1; -} - -int readbool(bool *b, std::istream* is) -{ - u32 temp; - int ret = read32le(&temp,is); - *b = temp!=0; - return ret; -} - -int readbuffer(std::vector &vec, std::istream* is) -{ - u32 size; - if(read32le(&size,is) != 1) return 0; - vec.resize(size); - if(size>0) is->read((char*)&vec[0],size); - return 1; -} - -int writebuffer(std::vector& vec, std::ostream* os) -{ - u32 size = vec.size(); - write32le(size,os); - if(size>0) os->write((char*)&vec[0],size); - return 1; -} +/* readwrite.cpp + + Copyright (C) 2006-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "readwrite.h" +#include "types.h" + +//well. just for the sake of consistency +int write8le(u8 b, FILE *fp) +{ + return((fwrite(&b,1,1,fp)<1)?0:1); +} + +//well. just for the sake of consistency +int write8le(u8 b, std::ostream *os) +{ + os->write((char*)&b,1); + return 1; +} + +//well. just for the sake of consistency +int read8le(u8 *Bufo, std::istream *is) +{ + if(is->read((char*)Bufo,1).gcount() != 1) + return 0; + return 1; +} + +///writes a little endian 16bit value to the specified file +int write16le(u16 b, FILE *fp) +{ + u8 s[2]; + s[0]=b; + s[1]=b>>8; + return((fwrite(s,1,2,fp)<2)?0:2); +} + + +///writes a little endian 16bit value to the specified file +int write16le(u16 b, std::ostream *os) +{ + u8 s[2]; + s[0]=b; + s[1]=b>>8; + os->write((char*)&s,2); + return 2; +} + +///writes a little endian 32bit value to the specified file +int write32le(u32 b, FILE *fp) +{ + u8 s[4]; + s[0]=b; + s[1]=b>>8; + s[2]=b>>16; + s[3]=b>>24; + return((fwrite(s,1,4,fp)<4)?0:4); +} + +int write32le(u32 b, std::ostream* os) +{ + u8 s[4]; + s[0]=b; + s[1]=b>>8; + s[2]=b>>16; + s[3]=b>>24; + os->write((char*)&s,4); + return 4; +} + +int write64le(u64 b, std::ostream* os) +{ + u8 s[8]; + s[0]=b; + s[1]=b>>8; + s[2]=b>>16; + s[3]=b>>24; + s[4]=b>>32; + s[5]=b>>40; + s[6]=b>>48; + s[7]=b>>56; + os->write((char*)&s,8); + return 8; +} + + +///reads a little endian 32bit value from the specified file +int read32le(u32 *Bufo, FILE *fp) +{ + u32 buf; + if(fread(&buf,1,4,fp)<4) + return 0; +#ifdef LOCAL_LE + *(u32*)Bufo=buf; +#else + *(u32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24); +#endif + return 1; +} + +int read16le(u16 *Bufo, std::istream *is) +{ + u16 buf; + if(is->read((char*)&buf,2).gcount() != 2) + return 0; +#ifdef LOCAL_LE + *Bufo=buf; +#else + *Bufo = LE_TO_LOCAL_16(buf); +#endif + return 1; +} + +///reads a little endian 64bit value from the specified file +int read64le(u64 *Bufo, std::istream *is) +{ + u64 buf; + if(is->read((char*)&buf,8).gcount() != 8) + return 0; +#ifdef LOCAL_LE + *Bufo=buf; +#else + *Bufo = LE_TO_LOCAL_64(buf); +#endif + return 1; +} + +int read32le(u32 *Bufo, std::istream *is) +{ + u32 buf; + if(is->read((char*)&buf,4).gcount() != 4) + return 0; +#ifdef LOCAL_LE + *(u32*)Bufo=buf; +#else + *(u32*)Bufo=((buf&0xFF)<<24)|((buf&0xFF00)<<8)|((buf&0xFF0000)>>8)|((buf&0xFF000000)>>24); +#endif + return 1; +} + +int readbuffer(std::vector &vec, std::istream* is) +{ + u32 size; + if(read32le(&size,is) != 1) return 0; + vec.resize(size); + if(size>0) is->read((char*)&vec[0],size); + return 1; +} + +int writebuffer(std::vector& vec, std::ostream* os) +{ + u32 size = vec.size(); + write32le(size,os); + if(size>0) os->write((char*)&vec[0],size); + return 1; +} diff --git a/desmume/src/readwrite.h b/src/readwrite.h similarity index 91% rename from desmume/src/readwrite.h rename to src/readwrite.h index 6ee2f6225..d3c236aec 100644 --- a/desmume/src/readwrite.h +++ b/src/readwrite.h @@ -1,30 +1,28 @@ -#ifndef _READWRITE_H_ -#define _READWRITE_H_ - -#include "types.h" -#include -#include -#include - -//well. just for the sake of consistency -int write8le(u8 b, FILE *fp); -int write8le(u8 b, std::ostream *os); -int write16le(u16 b, FILE *fp); -int write16le(u16 b, std::ostream* os); -int write32le(u32 b, FILE *fp); -int write32le(u32 b, std::ostream* os); -int write64le(u64 b, std::ostream* os); -int read64le(u64 *Bufo, std::istream *is); -int read32le(u32 *Bufo, std::istream *is); -inline int read32le(int *Bufo, std::istream *is) { return read32le((u32*)Bufo,is); } -int read32le(u32 *Bufo, FILE *fp); -int read16le(u16 *Bufo, std::istream *is); -inline int read16le(s16 *Bufo, std::istream* is) { return read16le((u16*)Bufo,is); } -int read8le(u8 *Bufo, std::istream *is); -int readbool(bool *b, std::istream* is); -void writebool(bool b, std::ostream* os); - -int readbuffer(std::vector &vec, std::istream* is); -int writebuffer(std::vector& vec, std::ostream* os); - -#endif +#ifndef _READWRITE_H_ +#define _READWRITE_H_ + +#include "types.h" +#include +#include +#include + +//well. just for the sake of consistency +int write8le(u8 b, FILE *fp); +int write8le(u8 b, std::ostream *os); +int write16le(u16 b, FILE *fp); +int write16le(u16 b, std::ostream* os); +int write32le(u32 b, FILE *fp); +int write32le(u32 b, std::ostream* os); +int write64le(u64 b, std::ostream* os); +int read64le(u64 *Bufo, std::istream *is); +int read32le(u32 *Bufo, std::istream *is); +inline int read32le(int *Bufo, std::istream *is) { return read32le((u32*)Bufo,is); } +int read32le(u32 *Bufo, FILE *fp); +int read16le(u16 *Bufo, std::istream *is); +inline int read16le(s16 *Bufo, std::istream* is) { return read16le((u16*)Bufo,is); } +int read8le(u8 *Bufo, std::istream *is); + +int readbuffer(std::vector &vec, std::istream* is); +int writebuffer(std::vector& vec, std::ostream* os); + +#endif diff --git a/desmume/src/registers.h b/src/registers.h similarity index 97% rename from desmume/src/registers.h rename to src/registers.h index f9060214d..d679e9643 100644 --- a/desmume/src/registers.h +++ b/src/registers.h @@ -1,333 +1,333 @@ -/* Copyright (C) 2006 Theo Berkau - - Ideas borrowed from Stephane Dallongeville's SCSP core - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef REGISTERS_H -#define REGISTERS_H - -#define REG_REGION_MASK 0x0FFFEF80 -#define REG_BASE_DISPx 0x04000000 -#define REG_BASE_DISPA 0x04000000 -#define REG_BASE_DISPB 0x04001000 -#define REG_BASE_DMA 0x04000080 -#define REG_BASE_SIORTCTIMERS 0x04000100 -#define REG_BASE_ROMIPC 0x04000180 -#define REG_BASE_MEMIRQ 0x04000200 -#define REG_BASE_MATH 0x04000280 -#define REG_BASE_OTHER 0x04000300 -#define REG_BASE_RCVPORTS 0x04100000 - -// Display Engine A -#define REG_DISPA_DISPCNT 0x04000000 -#define REG_DISPA_VCOUNT 0x04000006 -#define REG_DISPA_BG0CNT 0x04000008 -#define REG_DISPA_BG1CNT 0x0400000A -#define REG_DISPA_BG2CNT 0x0400000C -#define REG_DISPA_BG3CNT 0x0400000E -#define REG_DISPA_BG0HOFS 0x04000010 -#define REG_DISPA_BG0VOFS 0x04000012 -#define REG_DISPA_BG1HOFS 0x04000014 -#define REG_DISPA_BG1VOFS 0x04000016 -#define REG_DISPA_BG2HOFS 0x04000018 -#define REG_DISPA_BG2VOFS 0x0400001A -#define REG_DISPA_BG3HOFS 0x0400001C -#define REG_DISPA_BG3VOFS 0x0400001E -#define REG_DISPA_BG2PA 0x04000020 -#define REG_DISPA_BG2PB 0x04000022 -#define REG_DISPA_BG2PC 0x04000024 -#define REG_DISPA_BG2PD 0x04000026 -#define REG_DISPA_BG2XL 0x04000028 -#define REG_DISPA_BG2XH 0x0400002A -#define REG_DISPA_BG2YL 0x0400002C -#define REG_DISPA_BG2YH 0x0400002E -#define REG_DISPA_BG3PA 0x04000030 -#define REG_DISPA_BG3PB 0x04000032 -#define REG_DISPA_BG3PC 0x04000034 -#define REG_DISPA_BG3PD 0x04000036 -#define REG_DISPA_BG3XL 0x04000038 -#define REG_DISPA_BG3XH 0x0400003A -#define REG_DISPA_BG3YL 0x0400003C -#define REG_DISPA_BG3YH 0x0400003E -#define REG_DISPA_WIN0H 0x04000040 -#define REG_DISPA_WIN1H 0x04000042 -#define REG_DISPA_WIN0V 0x04000044 -#define REG_DISPA_WIN1V 0x04000046 -#define REG_DISPA_WININ 0x04000048 -#define REG_DISPA_WINOUT 0x0400004A -#define REG_DISPA_MOSAIC 0x0400004C -#define REG_DISPA_BLDCNT 0x04000050 -#define REG_DISPA_BLDALPHA 0x04000052 -#define REG_DISPA_BLDY 0x04000054 -#define REG_DISPA_MASTERBRIGHT 0x0400006C - -// DMA -#define REG_DMA0SAD 0x040000B0 -#define REG_DMA0DAD 0x040000B4 -#define REG_DMA0CNTL 0x040000B8 -#define REG_DMA0CNTH 0x040000BA -#define REG_DMA1SAD 0x040000BC -#define REG_DMA1DAD 0x040000C0 -#define REG_DMA1CNTL 0x040000C4 -#define REG_DMA1CNTH 0x040000C6 -#define REG_DMA2SAD 0x040000C8 -#define REG_DMA2DAD 0x040000CC -#define REG_DMA2CNTL 0x040000D0 -#define REG_DMA2CNTH 0x040000D2 -#define REG_DMA3SAD 0x040000D4 -#define REG_DMA3DAD 0x040000D8 -#define REG_DMA3CNTL 0x040000DC -#define REG_DMA3CNTH 0x040000DE -#define REG_DMA0FILL 0x040000E0 -#define REG_DMA1FILL 0x040000E4 -#define REG_DMA2FILL 0x040000E8 -#define REG_DMA3FILL 0x040000EC - -// Timers -#define REG_TM0CNTL 0x04000100 -#define REG_TM0CNTH 0x04000102 -#define REG_TM1CNTL 0x04000104 -#define REG_TM1CNTH 0x04000106 -#define REG_TM2CNTL 0x04000108 -#define REG_TM2CNTH 0x0400010A -#define REG_TM3CNTL 0x0400010C -#define REG_TM3CNTH 0x0400010E - -// SIO/Keypad Input/RTC -#define REG_SIODATA32 0x04000120 -#define REG_SIOCNT 0x04000128 -#define REG_KEYINPUT 0x04000130 -#define REG_KEYCNT 0x04000132 -#define REG_RCNT 0x04000134 -#define REG_EXTKEYIN 0x04000136 -#define REG_RTC 0x04000138 - -// IPC -#define REG_IPCSYNC 0x04000180 -#define REG_IPCFIFOCNT 0x04000184 -#define REG_IPCFIFOSEND 0x04000188 - -// ROM -#define REG_AUXSPICNT 0x040001A0 -#define REG_AUXSPIDATA 0x040001A2 -#define REG_GCROMCTRL 0x040001A4 -#define REG_GCCMDOUT 0x040001A8 -#define REG_ENCSEED0L 0x040001B0 -#define REG_ENCSEED1L 0x040001B4 -#define REG_ENCSEED0H 0x040001B8 -#define REG_ENCSEED1H 0x040001BC -#define REG_SPICNT 0x040001C0 -#define REG_SPIDATA 0x040001C2 - -// Memory/IRQ -#define REG_EXMEMCNT 0x04000204 -#define REG_WIFIWAITCNT 0x04000206 -#define REG_IME 0x04000208 -#define REG_IE 0x04000210 -#define REG_IF 0x04000214 -#define REG_VRAMCNTA 0x04000240 -#define REG_VRAMSTAT 0x04000240 -#define REG_VRAMCNTB 0x04000241 -#define REG_WRAMSTAT 0x04000241 -#define REG_VRAMCNTC 0x04000242 -#define REG_VRAMCNTD 0x04000243 -#define REG_VRAMCNTE 0x04000244 -#define REG_VRAMCNTF 0x04000245 -#define REG_VRAMCNTG 0x04000246 -#define REG_WRAMCNT 0x04000247 -#define REG_VRAMCNTH 0x04000248 -#define REG_VRAMCNTI 0x04000249 - -// Math -#define REG_DIVCNT 0x04000280 -#define REG_DIVNUMER 0x04000290 -#define REG_DIVDENOM 0x04000298 -#define REG_DIVRESULT 0x040002A0 -#define REG_DIVREMRESULT 0x040002A8 -#define REG_SQRTCNT 0x040002B0 -#define REG_SQRTRESULT 0x040002B4 -#define REG_SQRTPARAM 0x040002B8 - -// Other -#define REG_POSTFLG 0x04000300 -#define REG_HALTCNT 0x04000301 -#define REG_POWCNT1 0x04000304 -#define REG_POWCNT2 0x04000304 -#define REG_BIOSPROT 0x04000308 - -#define REG_DISPB_DISPCNT 0x04001000 -#define REG_DISPB_BG0CNT 0x04001008 -#define REG_DISPB_BG1CNT 0x0400100A -#define REG_DISPB_BG2CNT 0x0400100C -#define REG_DISPB_BG3CNT 0x0400100E -#define REG_DISPB_BG0HOFS 0x04001010 -#define REG_DISPB_BG0VOFS 0x04001012 -#define REG_DISPB_BG1HOFS 0x04001014 -#define REG_DISPB_BG1VOFS 0x04001016 -#define REG_DISPB_BG2HOFS 0x04001018 -#define REG_DISPB_BG2VOFS 0x0400101A -#define REG_DISPB_BG3HOFS 0x0400101C -#define REG_DISPB_BG3VOFS 0x0400101E -#define REG_DISPB_BG2PA 0x04001020 -#define REG_DISPB_BG2PB 0x04001022 -#define REG_DISPB_BG2PC 0x04001024 -#define REG_DISPB_BG2PD 0x04001026 -#define REG_DISPB_BG2XL 0x04001028 -#define REG_DISPB_BG2XH 0x0400102A -#define REG_DISPB_BG2YL 0x0400102C -#define REG_DISPB_BG2YH 0x0400102E -#define REG_DISPB_BG3PA 0x04001030 -#define REG_DISPB_BG3PB 0x04001032 -#define REG_DISPB_BG3PC 0x04001034 -#define REG_DISPB_BG3PD 0x04001036 -#define REG_DISPB_BG3XL 0x04001038 -#define REG_DISPB_BG3XH 0x0400103A -#define REG_DISPB_BG3YL 0x0400103C -#define REG_DISPB_BG3YH 0x0400103E -#define REG_DISPB_WIN0H 0x04001040 -#define REG_DISPB_WIN1H 0x04001042 -#define REG_DISPB_WIN0V 0x04001044 -#define REG_DISPB_WIN1V 0x04001046 -#define REG_DISPB_WININ 0x04001048 -#define REG_DISPB_WINOUT 0x0400104A -#define REG_DISPB_MOSAIC 0x0400104C -#define REG_DISPB_BLDCNT 0x04001050 -#define REG_DISPB_BLDALPHA 0x04001052 -#define REG_DISPB_BLDY 0x04001054 -#define REG_DISPB_MASTERBRIGHT 0x0400106C - -// Receive ports -#define REG_IPCFIFORECV 0x04100000 -#define REG_GCDATAIN 0x04100010 - - - - - -#define REG_DISPB 0x00001000 -// core A and B specific -#define REG_DISPx_DISPCNT 0x04000000 -#define REG_DISPx_VCOUNT 0x04000006 -#define REG_DISPx_BG0CNT 0x04000008 -#define REG_DISPx_BG1CNT 0x0400000A -#define REG_DISPx_BG2CNT 0x0400000C -#define REG_DISPx_BG3CNT 0x0400000E -#define REG_DISPx_BG0HOFS 0x04000010 -#define REG_DISPx_BG0VOFS 0x04000012 -#define REG_DISPx_BG1HOFS 0x04000014 -#define REG_DISPx_BG1VOFS 0x04000016 -#define REG_DISPx_BG2HOFS 0x04000018 -#define REG_DISPx_BG2VOFS 0x0400001A -#define REG_DISPx_BG3HOFS 0x0400001C -#define REG_DISPx_BG3VOFS 0x0400001E -#define REG_DISPx_BG2PA 0x04000020 -#define REG_DISPx_BG2PB 0x04000022 -#define REG_DISPx_BG2PC 0x04000024 -#define REG_DISPx_BG2PD 0x04000026 -#define REG_DISPx_BG2XL 0x04000028 -#define REG_DISPx_BG2XH 0x0400002A -#define REG_DISPx_BG2YL 0x0400002C -#define REG_DISPx_BG2YH 0x0400002E -#define REG_DISPx_BG3PA 0x04000030 -#define REG_DISPx_BG3PB 0x04000032 -#define REG_DISPx_BG3PC 0x04000034 -#define REG_DISPx_BG3PD 0x04000036 -#define REG_DISPx_BG3XL 0x04000038 -#define REG_DISPx_BG3XH 0x0400003A -#define REG_DISPx_BG3YL 0x0400003C -#define REG_DISPx_BG3YH 0x0400003E -#define REG_DISPx_WIN0H 0x04000040 -#define REG_DISPx_WIN1H 0x04000042 -#define REG_DISPx_WIN0V 0x04000044 -#define REG_DISPx_WIN1V 0x04000046 -#define REG_DISPx_WININ 0x04000048 -#define REG_DISPx_WINOUT 0x0400004A -#define REG_DISPx_MOSAIC 0x0400004C -#define REG_DISPx_BLDCNT 0x04000050 -#define REG_DISPx_BLDALPHA 0x04000052 -#define REG_DISPx_BLDY 0x04000054 -#define REG_DISPx_MASTERBRIGHT 0x0400006C -// core A specific -#define REG_DISPA_DISPSTAT 0x04000004 -#define REG_DISPA_DISP3DCNT 0x04000060 -#define REG_DISPA_DISPCAPCNT 0x04000064 -#define REG_DISPA_DISPMMEMFIFO 0x04000068 - - -#define eng_3D_RDLINES_COUNT 0x04000320 -#define eng_3D_EDGE_COLOR 0x04000330 -#define eng_3D_ALPHA_TEST_REF 0x04000340 -#define eng_3D_CLEAR_COLOR 0x04000350 -#define eng_3D_CLEAR_DEPTH 0x04000354 -#define eng_3D_CLRIMAGE_OFFSET 0x04000356 -#define eng_3D_FOG_COLOR 0x04000358 -#define eng_3D_FOG_OFFSET 0x0400035C -#define eng_3D_FOG_TABLE 0x04000360 -#define eng_3D_TOON_TABLE 0x04000380 -#define eng_3D_GXFIFO 0x04000400 - -// 3d commands -#define cmd_3D_MTX_MODE 0x04000440 -#define cmd_3D_MTX_PUSH 0x04000444 -#define cmd_3D_MTX_POP 0x04000448 -#define cmd_3D_MTX_STORE 0x0400044C -#define cmd_3D_MTX_RESTORE 0x04000450 -#define cmd_3D_MTX_IDENTITY 0x04000454 -#define cmd_3D_MTX_LOAD_4x4 0x04000458 -#define cmd_3D_MTX_LOAD_4x3 0x0400045C -#define cmd_3D_MTX_MULT_4x4 0x04000460 -#define cmd_3D_MTX_MULT_4x3 0x04000464 -#define cmd_3D_MTX_MULT_3x3 0x04000468 -#define cmd_3D_MTX_SCALE 0x0400046C -#define cmd_3D_MTX_TRANS 0x04000470 -#define cmd_3D_COLOR 0x04000480 -#define cmd_3D_NORMA 0x04000484 -#define cmd_3D_TEXCOORD 0x04000488 -#define cmd_3D_VTX_16 0x0400048C -#define cmd_3D_VTX_10 0x04000490 -#define cmd_3D_VTX_XY 0x04000494 -#define cmd_3D_VTX_XZ 0x04000498 -#define cmd_3D_VTX_YZ 0x0400049C -#define cmd_3D_VTX_DIFF 0x040004A0 -#define cmd_3D_POLYGON_ATTR 0x040004A4 -#define cmd_3D_TEXIMAGE_PARAM 0x040004A8 -#define cmd_3D_PLTT_BASE 0x040004AC -#define cmd_3D_DIF_AMB 0x040004C0 -#define cmd_3D_SPE_EMI 0x040004C4 -#define cmd_3D_LIGHT_VECTOR 0x040004C8 -#define cmd_3D_LIGHT_COLOR 0x040004CC -#define cmd_3D_SHININESS 0x040004D0 -#define cmd_3D_BEGIN_VTXS 0x04000500 -#define cmd_3D_END_VTXS 0x04000504 -#define cmd_3D_SWAP_BUFFERS 0x04000540 -#define cmd_3D_VIEWPORT 0x04000580 -#define cmd_3D_BOX_TEST 0x040005C0 -#define cmd_3D_POS_TEST 0x040005C4 -#define cmd_3D_VEC_TEST 0x040005C8 - -#define eng_3D_GXSTAT 0x04000600 -#define eng_3D_RAM_COUNT 0x04000604 -#define eng_3D_DISP_1DOT_DEPTH 0x04000610 -#define eng_3D_POS_RESULT 0x04000620 -#define eng_3D_VEC_RESULT 0x04000630 -#define eng_3D_CLIPMTX_RESULT 0x04000640 -#define eng_3D_VECMTX_RESULT 0x04000680 - - -#endif +/* Copyright (C) 2006 Theo Berkau + + Ideas borrowed from Stephane Dallongeville's SCSP core + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef REGISTERS_H +#define REGISTERS_H + +#define REG_REGION_MASK 0x0FFFEF80 +#define REG_BASE_DISPx 0x04000000 +#define REG_BASE_DISPA 0x04000000 +#define REG_BASE_DISPB 0x04001000 +#define REG_BASE_DMA 0x04000080 +#define REG_BASE_SIORTCTIMERS 0x04000100 +#define REG_BASE_ROMIPC 0x04000180 +#define REG_BASE_MEMIRQ 0x04000200 +#define REG_BASE_MATH 0x04000280 +#define REG_BASE_OTHER 0x04000300 +#define REG_BASE_RCVPORTS 0x04100000 + +// Display Engine A +#define REG_DISPA_DISPCNT 0x04000000 +#define REG_DISPA_VCOUNT 0x04000006 +#define REG_DISPA_BG0CNT 0x04000008 +#define REG_DISPA_BG1CNT 0x0400000A +#define REG_DISPA_BG2CNT 0x0400000C +#define REG_DISPA_BG3CNT 0x0400000E +#define REG_DISPA_BG0HOFS 0x04000010 +#define REG_DISPA_BG0VOFS 0x04000012 +#define REG_DISPA_BG1HOFS 0x04000014 +#define REG_DISPA_BG1VOFS 0x04000016 +#define REG_DISPA_BG2HOFS 0x04000018 +#define REG_DISPA_BG2VOFS 0x0400001A +#define REG_DISPA_BG3HOFS 0x0400001C +#define REG_DISPA_BG3VOFS 0x0400001E +#define REG_DISPA_BG2PA 0x04000020 +#define REG_DISPA_BG2PB 0x04000022 +#define REG_DISPA_BG2PC 0x04000024 +#define REG_DISPA_BG2PD 0x04000026 +#define REG_DISPA_BG2XL 0x04000028 +#define REG_DISPA_BG2XH 0x0400002A +#define REG_DISPA_BG2YL 0x0400002C +#define REG_DISPA_BG2YH 0x0400002E +#define REG_DISPA_BG3PA 0x04000030 +#define REG_DISPA_BG3PB 0x04000032 +#define REG_DISPA_BG3PC 0x04000034 +#define REG_DISPA_BG3PD 0x04000036 +#define REG_DISPA_BG3XL 0x04000038 +#define REG_DISPA_BG3XH 0x0400003A +#define REG_DISPA_BG3YL 0x0400003C +#define REG_DISPA_BG3YH 0x0400003E +#define REG_DISPA_WIN0H 0x04000040 +#define REG_DISPA_WIN1H 0x04000042 +#define REG_DISPA_WIN0V 0x04000044 +#define REG_DISPA_WIN1V 0x04000046 +#define REG_DISPA_WININ 0x04000048 +#define REG_DISPA_WINOUT 0x0400004A +#define REG_DISPA_MOSAIC 0x0400004C +#define REG_DISPA_BLDCNT 0x04000050 +#define REG_DISPA_BLDALPHA 0x04000052 +#define REG_DISPA_BLDY 0x04000054 +#define REG_DISPA_MASTERBRIGHT 0x0400006C + +// DMA +#define REG_DMA0SAD 0x040000B0 +#define REG_DMA0DAD 0x040000B4 +#define REG_DMA0CNTL 0x040000B8 +#define REG_DMA0CNTH 0x040000BA +#define REG_DMA1SAD 0x040000BC +#define REG_DMA1DAD 0x040000C0 +#define REG_DMA1CNTL 0x040000C4 +#define REG_DMA1CNTH 0x040000C6 +#define REG_DMA2SAD 0x040000C8 +#define REG_DMA2DAD 0x040000CC +#define REG_DMA2CNTL 0x040000D0 +#define REG_DMA2CNTH 0x040000D2 +#define REG_DMA3SAD 0x040000D4 +#define REG_DMA3DAD 0x040000D8 +#define REG_DMA3CNTL 0x040000DC +#define REG_DMA3CNTH 0x040000DE +#define REG_DMA0FILL 0x040000E0 +#define REG_DMA1FILL 0x040000E4 +#define REG_DMA2FILL 0x040000E8 +#define REG_DMA3FILL 0x040000EC + +// Timers +#define REG_TM0CNTL 0x04000100 +#define REG_TM0CNTH 0x04000102 +#define REG_TM1CNTL 0x04000104 +#define REG_TM1CNTH 0x04000106 +#define REG_TM2CNTL 0x04000108 +#define REG_TM2CNTH 0x0400010A +#define REG_TM3CNTL 0x0400010C +#define REG_TM3CNTH 0x0400010E + +// SIO/Keypad Input/RTC +#define REG_SIODATA32 0x04000120 +#define REG_SIOCNT 0x04000128 +#define REG_KEYINPUT 0x04000130 +#define REG_KEYCNT 0x04000132 +#define REG_RCNT 0x04000134 +#define REG_EXTKEYIN 0x04000136 +#define REG_RTC 0x04000138 + +// IPC +#define REG_IPCSYNC 0x04000180 +#define REG_IPCFIFOCNT 0x04000184 +#define REG_IPCFIFOSEND 0x04000188 + +// ROM +#define REG_AUXSPICNT 0x040001A0 +#define REG_AUXSPIDATA 0x040001A2 +#define REG_GCROMCTRL 0x040001A4 +#define REG_GCCMDOUT 0x040001A8 +#define REG_ENCSEED0L 0x040001B0 +#define REG_ENCSEED1L 0x040001B4 +#define REG_ENCSEED0H 0x040001B8 +#define REG_ENCSEED1H 0x040001BC +#define REG_SPICNT 0x040001C0 +#define REG_SPIDATA 0x040001C2 + +// Memory/IRQ +#define REG_EXMEMCNT 0x04000204 +#define REG_WIFIWAITCNT 0x04000206 +#define REG_IME 0x04000208 +#define REG_IE 0x04000210 +#define REG_IF 0x04000214 +#define REG_VRAMCNTA 0x04000240 +#define REG_VRAMSTAT 0x04000240 +#define REG_VRAMCNTB 0x04000241 +#define REG_WRAMSTAT 0x04000241 +#define REG_VRAMCNTC 0x04000242 +#define REG_VRAMCNTD 0x04000243 +#define REG_VRAMCNTE 0x04000244 +#define REG_VRAMCNTF 0x04000245 +#define REG_VRAMCNTG 0x04000246 +#define REG_WRAMCNT 0x04000247 +#define REG_VRAMCNTH 0x04000248 +#define REG_VRAMCNTI 0x04000249 + +// Math +#define REG_DIVCNT 0x04000280 +#define REG_DIVNUMER 0x04000290 +#define REG_DIVDENOM 0x04000298 +#define REG_DIVRESULT 0x040002A0 +#define REG_DIVREMRESULT 0x040002A8 +#define REG_SQRTCNT 0x040002B0 +#define REG_SQRTRESULT 0x040002B4 +#define REG_SQRTPARAM 0x040002B8 + +// Other +#define REG_POSTFLG 0x04000300 +#define REG_HALTCNT 0x04000301 +#define REG_POWCNT1 0x04000304 +#define REG_POWCNT2 0x04000304 +#define REG_BIOSPROT 0x04000308 + +#define REG_DISPB_DISPCNT 0x04001000 +#define REG_DISPB_BG0CNT 0x04001008 +#define REG_DISPB_BG1CNT 0x0400100A +#define REG_DISPB_BG2CNT 0x0400100C +#define REG_DISPB_BG3CNT 0x0400100E +#define REG_DISPB_BG0HOFS 0x04001010 +#define REG_DISPB_BG0VOFS 0x04001012 +#define REG_DISPB_BG1HOFS 0x04001014 +#define REG_DISPB_BG1VOFS 0x04001016 +#define REG_DISPB_BG2HOFS 0x04001018 +#define REG_DISPB_BG2VOFS 0x0400101A +#define REG_DISPB_BG3HOFS 0x0400101C +#define REG_DISPB_BG3VOFS 0x0400101E +#define REG_DISPB_BG2PA 0x04001020 +#define REG_DISPB_BG2PB 0x04001022 +#define REG_DISPB_BG2PC 0x04001024 +#define REG_DISPB_BG2PD 0x04001026 +#define REG_DISPB_BG2XL 0x04001028 +#define REG_DISPB_BG2XH 0x0400102A +#define REG_DISPB_BG2YL 0x0400102C +#define REG_DISPB_BG2YH 0x0400102E +#define REG_DISPB_BG3PA 0x04001030 +#define REG_DISPB_BG3PB 0x04001032 +#define REG_DISPB_BG3PC 0x04001034 +#define REG_DISPB_BG3PD 0x04001036 +#define REG_DISPB_BG3XL 0x04001038 +#define REG_DISPB_BG3XH 0x0400103A +#define REG_DISPB_BG3YL 0x0400103C +#define REG_DISPB_BG3YH 0x0400103E +#define REG_DISPB_WIN0H 0x04001040 +#define REG_DISPB_WIN1H 0x04001042 +#define REG_DISPB_WIN0V 0x04001044 +#define REG_DISPB_WIN1V 0x04001046 +#define REG_DISPB_WININ 0x04001048 +#define REG_DISPB_WINOUT 0x0400104A +#define REG_DISPB_MOSAIC 0x0400104C +#define REG_DISPB_BLDCNT 0x04001050 +#define REG_DISPB_BLDALPHA 0x04001052 +#define REG_DISPB_BLDY 0x04001054 +#define REG_DISPB_MASTERBRIGHT 0x0400106C + +// Receive ports +#define REG_IPCFIFORECV 0x04100000 +#define REG_GCDATAIN 0x04100010 + + + + + +#define REG_DISPB 0x00001000 +// core A and B specific +#define REG_DISPx_DISPCNT 0x04000000 +#define REG_DISPx_VCOUNT 0x04000006 +#define REG_DISPx_BG0CNT 0x04000008 +#define REG_DISPx_BG1CNT 0x0400000A +#define REG_DISPx_BG2CNT 0x0400000C +#define REG_DISPx_BG3CNT 0x0400000E +#define REG_DISPx_BG0HOFS 0x04000010 +#define REG_DISPx_BG0VOFS 0x04000012 +#define REG_DISPx_BG1HOFS 0x04000014 +#define REG_DISPx_BG1VOFS 0x04000016 +#define REG_DISPx_BG2HOFS 0x04000018 +#define REG_DISPx_BG2VOFS 0x0400001A +#define REG_DISPx_BG3HOFS 0x0400001C +#define REG_DISPx_BG3VOFS 0x0400001E +#define REG_DISPx_BG2PA 0x04000020 +#define REG_DISPx_BG2PB 0x04000022 +#define REG_DISPx_BG2PC 0x04000024 +#define REG_DISPx_BG2PD 0x04000026 +#define REG_DISPx_BG2XL 0x04000028 +#define REG_DISPx_BG2XH 0x0400002A +#define REG_DISPx_BG2YL 0x0400002C +#define REG_DISPx_BG2YH 0x0400002E +#define REG_DISPx_BG3PA 0x04000030 +#define REG_DISPx_BG3PB 0x04000032 +#define REG_DISPx_BG3PC 0x04000034 +#define REG_DISPx_BG3PD 0x04000036 +#define REG_DISPx_BG3XL 0x04000038 +#define REG_DISPx_BG3XH 0x0400003A +#define REG_DISPx_BG3YL 0x0400003C +#define REG_DISPx_BG3YH 0x0400003E +#define REG_DISPx_WIN0H 0x04000040 +#define REG_DISPx_WIN1H 0x04000042 +#define REG_DISPx_WIN0V 0x04000044 +#define REG_DISPx_WIN1V 0x04000046 +#define REG_DISPx_WININ 0x04000048 +#define REG_DISPx_WINOUT 0x0400004A +#define REG_DISPx_MOSAIC 0x0400004C +#define REG_DISPx_BLDCNT 0x04000050 +#define REG_DISPx_BLDALPHA 0x04000052 +#define REG_DISPx_BLDY 0x04000054 +#define REG_DISPx_MASTERBRIGHT 0x0400006C +// core A specific +#define REG_DISPA_DISPSTAT 0x04000004 +#define REG_DISPA_DISP3DCNT 0x04000060 +#define REG_DISPA_DISPCAPCNT 0x04000064 +#define REG_DISPA_DISPMMEMFIFO 0x04000068 + + +#define eng_3D_RDLINES_COUNT 0x04000320 +#define eng_3D_EDGE_COLOR 0x04000330 +#define eng_3D_ALPHA_TEST_REF 0x04000340 +#define eng_3D_CLEAR_COLOR 0x04000350 +#define eng_3D_CLEAR_DEPTH 0x04000354 +#define eng_3D_CLRIMAGE_OFFSET 0x04000356 +#define eng_3D_FOG_COLOR 0x04000358 +#define eng_3D_FOG_OFFSET 0x0400035C +#define eng_3D_FOG_TABLE 0x04000360 +#define eng_3D_TOON_TABLE 0x04000380 +#define eng_3D_GXFIFO 0x04000400 + +// 3d commands +#define cmd_3D_MTX_MODE 0x04000440 +#define cmd_3D_MTX_PUSH 0x04000444 +#define cmd_3D_MTX_POP 0x04000448 +#define cmd_3D_MTX_STORE 0x0400044C +#define cmd_3D_MTX_RESTORE 0x04000450 +#define cmd_3D_MTX_IDENTITY 0x04000454 +#define cmd_3D_MTX_LOAD_4x4 0x04000458 +#define cmd_3D_MTX_LOAD_4x3 0x0400045C +#define cmd_3D_MTX_MULT_4x4 0x04000460 +#define cmd_3D_MTX_MULT_4x3 0x04000464 +#define cmd_3D_MTX_MULT_3x3 0x04000468 +#define cmd_3D_MTX_SCALE 0x0400046C +#define cmd_3D_MTX_TRANS 0x04000470 +#define cmd_3D_COLOR 0x04000480 +#define cmd_3D_NORMA 0x04000484 +#define cmd_3D_TEXCOORD 0x04000488 +#define cmd_3D_VTX_16 0x0400048C +#define cmd_3D_VTX_10 0x04000490 +#define cmd_3D_VTX_XY 0x04000494 +#define cmd_3D_VTX_XZ 0x04000498 +#define cmd_3D_VTX_YZ 0x0400049C +#define cmd_3D_VTX_DIFF 0x040004A0 +#define cmd_3D_POLYGON_ATTR 0x040004A4 +#define cmd_3D_TEXIMAGE_PARAM 0x040004A8 +#define cmd_3D_PLTT_BASE 0x040004AC +#define cmd_3D_DIF_AMB 0x040004C0 +#define cmd_3D_SPE_EMI 0x040004C4 +#define cmd_3D_LIGHT_VECTOR 0x040004C8 +#define cmd_3D_LIGHT_COLOR 0x040004CC +#define cmd_3D_SHININESS 0x040004D0 +#define cmd_3D_BEGIN_VTXS 0x04000500 +#define cmd_3D_END_VTXS 0x04000504 +#define cmd_3D_SWAP_BUFFERS 0x04000540 +#define cmd_3D_VIEWPORT 0x04000580 +#define cmd_3D_BOX_TEST 0x040005C0 +#define cmd_3D_POS_TEST 0x040005C4 +#define cmd_3D_VEC_TEST 0x040005C8 + +#define eng_3D_GXSTAT 0x04000600 +#define eng_3D_RAM_COUNT 0x04000604 +#define eng_3D_DISP_1DOT_DEPTH 0x04000610 +#define eng_3D_POS_RESULT 0x04000620 +#define eng_3D_VEC_RESULT 0x04000630 +#define eng_3D_CLIPMTX_RESULT 0x04000640 +#define eng_3D_VECMTX_RESULT 0x04000680 + + +#endif diff --git a/desmume/src/render3D.cpp b/src/render3D.cpp similarity index 96% rename from desmume/src/render3D.cpp rename to src/render3D.cpp index 03650a2f0..bf853fe8f 100644 --- a/desmume/src/render3D.cpp +++ b/src/render3D.cpp @@ -1,54 +1,54 @@ -/* - Copyright (C) 2006-2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "render3D.h" - -int cur3DCore = GPU3D_NULL; - -static void NDS_nullFunc1 (void){} -static char NDS_nullFunc2 (void){ return 1; } - -GPU3DInterface gpu3DNull = { - "None", - NDS_nullFunc2, //NDS_3D_Init - NDS_nullFunc1, //NDS_3D_Reset - NDS_nullFunc1, //NDS_3D_Close - NDS_nullFunc1, //NDS_3D_Render - NDS_nullFunc1, //NDS_3D_VramReconfigureSignal -}; - -GPU3DInterface *gpu3D = &gpu3DNull; - -void NDS_3D_SetDriver (int core3DIndex) -{ - cur3DCore = core3DIndex; - gpu3D = core3DList[cur3DCore]; -} - -void NDS_3D_ChangeCore(int newCore) -{ - gpu3D->NDS_3D_Close(); - NDS_3D_SetDriver(newCore); - if(gpu3D->NDS_3D_Init() == 0) - { - NDS_3D_SetDriver(GPU3D_NULL); - gpu3D->NDS_3D_Init(); - } -} +/* + Copyright (C) 2006-2007 shash + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "render3D.h" + +int cur3DCore = GPU3D_NULL; + +static void NDS_nullFunc1 (void){} +static char NDS_nullFunc2 (void){ return 1; } + +GPU3DInterface gpu3DNull = { + "None", + NDS_nullFunc2, //NDS_3D_Init + NDS_nullFunc1, //NDS_3D_Reset + NDS_nullFunc1, //NDS_3D_Close + NDS_nullFunc1, //NDS_3D_Render + NDS_nullFunc1, //NDS_3D_VramReconfigureSignal +}; + +GPU3DInterface *gpu3D = &gpu3DNull; + +void NDS_3D_SetDriver (int core3DIndex) +{ + cur3DCore = core3DIndex; + gpu3D = core3DList[cur3DCore]; +} + +void NDS_3D_ChangeCore(int newCore) +{ + gpu3D->NDS_3D_Close(); + NDS_3D_SetDriver(newCore); + if(gpu3D->NDS_3D_Init() == 0) + { + NDS_3D_SetDriver(GPU3D_NULL); + gpu3D->NDS_3D_Init(); + } +} diff --git a/desmume/src/render3D.h b/src/render3D.h similarity index 96% rename from desmume/src/render3D.h rename to src/render3D.h index 877afa4d8..428b806de 100644 --- a/desmume/src/render3D.h +++ b/src/render3D.h @@ -1,67 +1,67 @@ -/* - Copyright (C) 2006-2007 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef RENDER3D_H -#define RENDER3D_H - -#include "types.h" - -//not using this right now -#define CALL_CONVENTION - -typedef struct Render3DInterface -{ - // The name of the plugin, this name will appear in the plugins list - const char * name; - - //called once when the plugin starts up - char (CALL_CONVENTION* NDS_3D_Init) (void); - - //called when the emulator resets (is this necessary?) - void (CALL_CONVENTION* NDS_3D_Reset) (void); - - //called when the plugin shuts down - void (CALL_CONVENTION* NDS_3D_Close) (void); - - //called when the renderer should do its job and render the current display lists - void (CALL_CONVENTION* NDS_3D_Render) (void); - - //called when the emulator reconfigures its vram. you may need to invalidate your texture cache. - void (CALL_CONVENTION* NDS_3D_VramReconfigureSignal) (); - -} GPU3DInterface; - -extern int cur3DCore; - -// gpu 3D core list, per port -extern GPU3DInterface *core3DList[]; - -// Default null plugin -#define GPU3D_NULL 0 -extern GPU3DInterface gpu3DNull; - -// Extern pointer -extern GPU3DInterface *gpu3D; - -void NDS_3D_SetDriver (int core3DIndex); -void NDS_3D_ChangeCore(int newCore); - -#endif - +/* + Copyright (C) 2006-2007 shash + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef RENDER3D_H +#define RENDER3D_H + +#include "types.h" + +//not using this right now +#define CALL_CONVENTION + +typedef struct Render3DInterface +{ + // The name of the plugin, this name will appear in the plugins list + const char * name; + + //called once when the plugin starts up + char (CALL_CONVENTION* NDS_3D_Init) (void); + + //called when the emulator resets (is this necessary?) + void (CALL_CONVENTION* NDS_3D_Reset) (void); + + //called when the plugin shuts down + void (CALL_CONVENTION* NDS_3D_Close) (void); + + //called when the renderer should do its job and render the current display lists + void (CALL_CONVENTION* NDS_3D_Render) (void); + + //called when the emulator reconfigures its vram. you may need to invalidate your texture cache. + void (CALL_CONVENTION* NDS_3D_VramReconfigureSignal) (); + +} GPU3DInterface; + +extern int cur3DCore; + +// gpu 3D core list, per port +extern GPU3DInterface *core3DList[]; + +// Default null plugin +#define GPU3D_NULL 0 +extern GPU3DInterface gpu3DNull; + +// Extern pointer +extern GPU3DInterface *gpu3D; + +void NDS_3D_SetDriver (int core3DIndex); +void NDS_3D_ChangeCore(int newCore); + +#endif + diff --git a/desmume/src/rtc.cpp b/src/rtc.cpp similarity index 94% rename from desmume/src/rtc.cpp rename to src/rtc.cpp index 3dfd91907..e5a74b4f1 100644 --- a/desmume/src/rtc.cpp +++ b/src/rtc.cpp @@ -1,399 +1,405 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright 2008 CrazyMax - Copyright 2008-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -// TODO: interrupt handler - -#include "rtc.h" -#include "common.h" -#include "debug.h" -#include "armcpu.h" -#include -#include -#include "saves.h" -#ifdef WIN32 -#include "windows/main.h" -#endif -#include "movie.h" - -typedef struct -{ - // RTC registers - u8 regStatus1; - u8 regStatus2; - u8 regAdjustment; - u8 regFree; - - // BUS - u8 _prevSCK; - u8 _prevCS; - u8 _prevSIO; - u8 _SCK; - u8 _CS; - u8 _SIO; - u8 _DD; - u16 _REG; - - // command & data - u8 cmd; - u8 cmdStat; - u8 bitsCount; - u8 data[8]; - - u8 cmdBitsSize[8]; -} _RTC; - -_RTC rtc; - -SFORMAT SF_RTC[]={ - { "R000", 1, 1, &rtc.regStatus1}, - { "R010", 1, 1, &rtc.regStatus2}, - { "R020", 1, 1, &rtc.regAdjustment}, - { "R030", 1, 1, &rtc.regFree}, - - { "R040", 1, 1, &rtc._prevSCK}, - { "R050", 1, 1, &rtc._prevCS}, - { "R060", 1, 1, &rtc._prevSIO}, - { "R070", 1, 1, &rtc._SCK}, - { "R080", 1, 1, &rtc._CS}, - { "R090", 1, 1, &rtc._SIO}, - { "R100", 1, 1, &rtc._DD}, - { "R110", 2, 1, &rtc._REG}, - - { "R120", 1, 1, &rtc.cmd}, - { "R130", 1, 1, &rtc.cmdStat}, - { "R140", 1, 1, &rtc.bitsCount}, - { "R150", 1, 8, &rtc.data[0]}, - - { "R160", 1, 8, &rtc.cmdBitsSize[0]}, - - { 0 } -}; - -static const u8 kDefaultCmdBitsSize[8] = {8, 8, 56, 24, 0, 24, 8, 8}; - -#define toBCD(x) ((x / 10) << 4) | (x % 10); - -struct movietime { - - int sec; - int minute; - int hour; - int monthday; - int month; - int year; - int weekday; -}; - -struct movietime movie; - -bool moviemode=false; - -void InitMovieTime(void) -{ - movie.year=9; - movie.month=1; - movie.monthday=1; - movie.weekday=4; -} - -static void MovieTime(void) { - - //now, you might think it is silly to go through all these conniptions - //when we could just assume that there are 60fps and base the seconds on frameCounter/60 - //but, we were imagining that one day we might need more precision - - const u32 arm9rate_unitsperframe = 560190<<1; - const u32 arm9rate_unitspersecond = (u32)(arm9rate_unitsperframe * 59.8261); - const u64 noon = (u64)arm9rate_unitspersecond * 60 * 60 * 12; - - u64 frameCycles = (u64)arm9rate_unitsperframe * currFrameCounter; - u64 totalcycles = frameCycles + noon; - u64 totalseconds=totalcycles/arm9rate_unitspersecond; - - movie.sec=(int)(totalseconds % 60); - movie.minute=(int)(totalseconds/60); - movie.hour=movie.minute/60; - - //convert to sane numbers - movie.minute=movie.minute % 60; - movie.hour=movie.hour % 24; -} - -static void rtcRecv() -{ - //INFO("RTC Read command 0x%02X\n", (rtc.cmd >> 1)); - memset(rtc.data, 0, sizeof(rtc.data)); - switch (rtc.cmd >> 1) - { - case 0: // status register 1 - //INFO("RTC: read regstatus1 (0x%02X)\n", rtc.regStatus1); - rtc.regStatus1 &= 0x0F; - rtc.data[0] = rtc.regStatus1; - //rtc.regStatus1 &= 0x7F; - break; - case 1: // status register 2 - //INFO("RTC: read regstatus2 (0x%02X)\n", rtc.regStatus1); - rtc.data[0] = rtc.regStatus2; - break; - case 2: // date & time - { - //INFO("RTC: read date & time\n"); - time_t tm; - time(&tm); - struct tm *tm_local= localtime(&tm); - tm_local->tm_year %= 100; - tm_local->tm_mon++; - - if(movieMode != MOVIEMODE_INACTIVE) { - - MovieTime(); - - rtc.data[0]=toBCD(movie.year); - rtc.data[1]=toBCD(movie.month); - rtc.data[2]=toBCD(movie.monthday); - rtc.data[3]=(movie.weekday + 6) & 7; - if (!(rtc.regStatus1 & 0x02)) movie.hour %= 12; - rtc.data[4] = ((movie.hour < 12) ? 0x00 : 0x40) | toBCD(movie.hour); - rtc.data[5]=toBCD(movie.minute); - rtc.data[6]=toBCD(movie.sec); - break; - } - else { - - rtc.data[0] = toBCD(tm_local->tm_year); - rtc.data[1] = toBCD(tm_local->tm_mon); - rtc.data[2] = toBCD(tm_local->tm_mday); - rtc.data[3] = (tm_local->tm_wday + 6) & 7; - if (!(rtc.regStatus1 & 0x02)) tm_local->tm_hour %= 12; - rtc.data[4] = ((tm_local->tm_hour < 12) ? 0x00 : 0x40) | toBCD(tm_local->tm_hour); - rtc.data[5] = toBCD(tm_local->tm_min); - rtc.data[6] = toBCD(tm_local->tm_sec); - break; - } - } - case 3: // time - { - //INFO("RTC: read time\n"); - time_t tm; - time(&tm); - struct tm *tm_local= localtime(&tm); - - if(movieMode != MOVIEMODE_INACTIVE) { - - MovieTime(); - - if (!(rtc.regStatus1 & 0x02)) movie.hour %= 12; - rtc.data[0] = ((movie.hour < 12) ? 0x00 : 0x40) | toBCD(movie.hour); - rtc.data[1] = toBCD(movie.minute); - rtc.data[2] = toBCD(movie.sec); - } - else { - - if (!(rtc.regStatus1 & 0x02)) tm_local->tm_hour %= 12; - rtc.data[0] = ((tm_local->tm_hour < 12) ? 0x00 : 0x40) | toBCD(tm_local->tm_hour); - rtc.data[1] = toBCD(tm_local->tm_min); - rtc.data[2] = toBCD(tm_local->tm_sec); - break; - } - } - case 4: // freq/alarm 1 - /*if (cmdBitsSize[0x04] == 8) - INFO("RTC: read INT1 freq\n"); - else - INFO("RTC: read INT1 alarm1\n");*/ - //NDS_makeARM7Int(7); - break; - case 5: // alarm 2 - //INFO("RTC: read alarm 2\n"); - break; - case 6: // clock adjust - //INFO("RTC: read clock adjust\n"); - rtc.data[0] = rtc.regAdjustment; - break; - case 7: // free register - //INFO("RTC: read free register\n"); - rtc.data[0] = rtc.regFree; - break; - } -} - -static void rtcSend() -{ - //INFO("RTC write 0x%02X\n", (rtc.cmd >> 1)); - switch (rtc.cmd >> 1) - { - case 0: // status register 1 - //INFO("RTC: write regstatus1 0x%02X\n", rtc.data[0]); - // rtc.regStatus1 &= 0xF1; - // rtc.regStatus1 |= (rtc.data[0] | 0x0E); - rtc.regStatus1 = rtc.data[0]; - break; - case 1: // status register 2 - //INFO("RTC: write regstatus2 0x%02X\n", rtc.data[0]); - rtc.regStatus2 = rtc.data[0]; - break; - case 2: // date & time - //INFO("RTC: write date & time : %02X %02X %02X %02X %02X %02X %02X\n", rtc.data[0], rtc.data[1], rtc.data[2], rtc.data[3], rtc.data[4], rtc.data[5], rtc.data[6]); - break; - case 3: // time - //INFO("RTC: write time : %02X %02X %02X\n", rtc.data[0], rtc.data[1], rtc.data[2]); - break; - case 4: // freq/alarm 1 - /*if (cmdBitsSize[0x04] == 8) - INFO("RTC: write INT1 freq 0x%02X\n", rtc.data[0]); - else - INFO("RTC: write INT1 alarm1 0x%02X\n", rtc.data[0]);*/ - break; - case 5: // alarm 2 - //INFO("RTC: write alarm 2\n"); - break; - case 6: // clock adjust - //INFO("RTC: write clock adjust\n"); - rtc.regAdjustment = rtc.data[0]; - break; - case 7: // free register - //INFO("RTC: write free register\n"); - rtc.regFree = rtc.data[0]; - break; - } -} - -void rtcInit() -{ - memset(&rtc, 0, sizeof(_RTC)); - memcpy(rtc.cmdBitsSize,kDefaultCmdBitsSize,8); - rtc.regStatus1 |= 0x02; -} - -u16 rtcRead() -{ - //INFO("MMU Read RTC 0x%02X (%03i)\n", rtc._REG, rtc.bitsCount); - return (rtc._REG); -} - -void rtcWrite(u16 val) -{ - //INFO("MMU Write RTC 0x%02X (%03i)\n", val, rtc.bitsCount); - rtc._DD = (val & 0x10) >> 4; - rtc._SIO = rtc._DD?(val & 0x01):rtc._prevSIO; - rtc._SCK = (val & 0x20)?((val & 0x02) >> 1):rtc._prevSCK; - rtc._CS = (val & 0x40)?((val & 0x04) >> 2):rtc._prevCS; - - switch (rtc.cmdStat) - { - case 0: - if ( (!rtc._prevCS) && (rtc._prevSCK) && (rtc._CS) && (rtc._SCK) ) - { - rtc.cmdStat = 1; - rtc.bitsCount = 0; - rtc.cmd = 0; - } - break; - - case 1: - if (!rtc._CS) - { - rtc.cmdStat = 0; - break; - } - - if (rtc._SCK && rtc._DD) break; - if (!rtc._SCK && !rtc._DD) break; - - rtc.cmd |= (rtc._SIO << rtc.bitsCount ); - rtc.bitsCount ++; - if (rtc.bitsCount == 8) - { - //INFO("RTC command 0x%02X\n", rtc.cmd); - - // Little-endian command - if((rtc.cmd & 0x0F) == 0x06) - { - u8 tmp = rtc.cmd; - rtc.cmd = ((tmp & 0x80) >> 7) | ((tmp & 0x40) >> 5) | ((tmp & 0x20) >> 3) | ((tmp & 0x10) >> 1); - } - // Big-endian command - else - { - rtc.cmd &= 0x0F; - } - - if((rtc._prevSCK) && (!rtc._SCK)) - { - rtc.bitsCount = 0; - if ((rtc.cmd >> 1) == 0x04) - { - if ((rtc.regStatus2 & 0x0F) == 0x04) - rtc.cmdBitsSize[rtc.cmd >> 1] = 24; - else - rtc.cmdBitsSize[rtc.cmd >> 1] = 8; - } - if (rtc.cmd & 0x01) - { - rtc.cmdStat = 4; - rtcRecv(); - } - else - { - rtc.cmdStat = 3; - } - } - } - - break; - - case 3: // write: - if( (rtc._prevSCK) && (!rtc._SCK) ) - { - if(rtc._SIO) rtc.data[rtc.bitsCount >> 3] |= (1 << (rtc.bitsCount & 0x07)); - rtc.bitsCount++; - if (rtc.bitsCount == rtc.cmdBitsSize[rtc.cmd >> 1]) - { - rtcSend(); - rtc.cmdStat = 0; - } - } - break; - - case 4: // read: - if( (rtc._prevSCK) && (!rtc._SCK) ) - { - rtc._REG = val; - if(rtc.data[rtc.bitsCount >> 3] >> (rtc.bitsCount & 0x07) & 0x01) - rtc._REG |= 0x01; - else - rtc._REG &= ~0x01; - - rtc.bitsCount++; - if (rtc.bitsCount == rtc.cmdBitsSize[rtc.cmd >> 1]) - rtc.cmdStat = 0; - } - break; - - } - - rtc._prevSIO = rtc._SIO; - rtc._prevSCK = rtc._SCK; - rtc._prevCS = rtc._CS; -} +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright 2008 CrazyMax + Copyright 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +// TODO: interrupt handler + +#include "rtc.h" +#include "common.h" +#include "debug.h" +#include "armcpu.h" +#include +#include +#include "saves.h" +#ifdef WIN32 +#include "windows/main.h" +#endif +#include "movie.h" + +typedef struct +{ + // RTC registers + u8 regStatus1; + u8 regStatus2; + u8 regAdjustment; + u8 regFree; + + // BUS + u8 _prevSCK; + u8 _prevCS; + u8 _prevSIO; + u8 _SCK; + u8 _CS; + u8 _SIO; + u8 _DD; + u16 _REG; + + // command & data + u8 cmd; + u8 cmdStat; + u8 bitsCount; + u8 data[8]; + + u8 cmdBitsSize[8]; +} _RTC; + +_RTC rtc; + +SFORMAT SF_RTC[]={ + { "R000", 1, 1, &rtc.regStatus1}, + { "R010", 1, 1, &rtc.regStatus2}, + { "R020", 1, 1, &rtc.regAdjustment}, + { "R030", 1, 1, &rtc.regFree}, + + { "R040", 1, 1, &rtc._prevSCK}, + { "R050", 1, 1, &rtc._prevCS}, + { "R060", 1, 1, &rtc._prevSIO}, + { "R070", 1, 1, &rtc._SCK}, + { "R080", 1, 1, &rtc._CS}, + { "R090", 1, 1, &rtc._SIO}, + { "R100", 1, 1, &rtc._DD}, + { "R110", 2, 1, &rtc._REG}, + + { "R120", 1, 1, &rtc.cmd}, + { "R130", 1, 1, &rtc.cmdStat}, + { "R140", 1, 1, &rtc.bitsCount}, + { "R150", 1, 8, &rtc.data[0]}, + + { "R160", 1, 8, &rtc.cmdBitsSize[0]}, + + { 0 } +}; + +static const u8 kDefaultCmdBitsSize[8] = {8, 8, 56, 24, 0, 24, 8, 8}; + +#define toBCD(x) ((x / 10) << 4) | (x % 10); + +struct movietime { + + int sec; + int minute; + int hour; + int monthday; + int month; + int year; + int weekday; +}; + +struct movietime movie; + +bool moviemode=false; + +void InitMovieTime(void) +{ + movie.year=9; + movie.month=1; + movie.monthday=1; + movie.weekday=4; +} + +#ifdef WIN32 +static void MovieTime(void) { + + //now, you might think it is silly to go through all these conniptions + //when we could just assume that there are 60fps and base the seconds on frameCounter/60 + //but, we were imagining that one day we might need more precision + + const u32 arm9rate_unitsperframe = 560190<<1; + const u32 arm9rate_unitspersecond = (u32)(arm9rate_unitsperframe * 59.8261); + const u64 noon = (u64)arm9rate_unitspersecond * 60 * 60 * 12; + + u64 frameCycles = (u64)arm9rate_unitsperframe * currFrameCounter; + u64 totalcycles = frameCycles + noon; + u32 totalseconds=totalcycles/arm9rate_unitspersecond; + + movie.sec=totalseconds % 60; + movie.minute=totalseconds/60; + movie.hour=movie.minute/60; + + //convert to sane numbers + movie.minute=movie.minute % 60; + movie.hour=movie.hour % 24; +} +#else +static void MovieTime(void) +{ +} +#endif + +static void rtcRecv() +{ + //INFO("RTC Read command 0x%02X\n", (rtc.cmd >> 1)); + memset(rtc.data, 0, sizeof(rtc.data)); + switch (rtc.cmd >> 1) + { + case 0: // status register 1 + //INFO("RTC: read regstatus1 (0x%02X)\n", rtc.regStatus1); + rtc.regStatus1 &= 0x0F; + rtc.data[0] = rtc.regStatus1; + //rtc.regStatus1 &= 0x7F; + break; + case 1: // status register 2 + //INFO("RTC: read regstatus2 (0x%02X)\n", rtc.regStatus1); + rtc.data[0] = rtc.regStatus2; + break; + case 2: // date & time + { + //INFO("RTC: read date & time\n"); + time_t tm; + time(&tm); + struct tm *tm_local= localtime(&tm); + tm_local->tm_year %= 100; + tm_local->tm_mon++; + + if(movieMode != MOVIEMODE_INACTIVE) { + + MovieTime(); + + rtc.data[0]=toBCD(movie.year); + rtc.data[1]=toBCD(movie.month); + rtc.data[2]=toBCD(movie.monthday); + rtc.data[3]=(movie.weekday + 6) & 7; + if (!(rtc.regStatus1 & 0x02)) movie.hour %= 12; + rtc.data[4] = ((movie.hour < 12) ? 0x00 : 0x40) | toBCD(movie.hour); + rtc.data[5]=toBCD(movie.minute); + rtc.data[6]=toBCD(movie.sec); + break; + } + else { + + rtc.data[0] = toBCD(tm_local->tm_year); + rtc.data[1] = toBCD(tm_local->tm_mon); + rtc.data[2] = toBCD(tm_local->tm_mday); + rtc.data[3] = (tm_local->tm_wday + 6) & 7; + if (!(rtc.regStatus1 & 0x02)) tm_local->tm_hour %= 12; + rtc.data[4] = ((tm_local->tm_hour < 12) ? 0x00 : 0x40) | toBCD(tm_local->tm_hour); + rtc.data[5] = toBCD(tm_local->tm_min); + rtc.data[6] = toBCD(tm_local->tm_sec); + break; + } + } + case 3: // time + { + //INFO("RTC: read time\n"); + time_t tm; + time(&tm); + struct tm *tm_local= localtime(&tm); + + if(movieMode != MOVIEMODE_INACTIVE) { + + MovieTime(); + + if (!(rtc.regStatus1 & 0x02)) movie.hour %= 12; + rtc.data[0] = ((movie.hour < 12) ? 0x00 : 0x40) | toBCD(movie.hour); + rtc.data[1] = toBCD(movie.minute); + rtc.data[2] = toBCD(movie.sec); + } + else { + + if (!(rtc.regStatus1 & 0x02)) tm_local->tm_hour %= 12; + rtc.data[0] = ((tm_local->tm_hour < 12) ? 0x00 : 0x40) | toBCD(tm_local->tm_hour); + rtc.data[1] = toBCD(tm_local->tm_min); + rtc.data[2] = toBCD(tm_local->tm_sec); + break; + } + } + case 4: // freq/alarm 1 + /*if (cmdBitsSize[0x04] == 8) + INFO("RTC: read INT1 freq\n"); + else + INFO("RTC: read INT1 alarm1\n");*/ + //NDS_makeARM7Int(7); + break; + case 5: // alarm 2 + //INFO("RTC: read alarm 2\n"); + break; + case 6: // clock adjust + //INFO("RTC: read clock adjust\n"); + rtc.data[0] = rtc.regAdjustment; + break; + case 7: // free register + //INFO("RTC: read free register\n"); + rtc.data[0] = rtc.regFree; + break; + } +} + +static void rtcSend() +{ + //INFO("RTC write 0x%02X\n", (rtc.cmd >> 1)); + switch (rtc.cmd >> 1) + { + case 0: // status register 1 + //INFO("RTC: write regstatus1 0x%02X\n", rtc.data[0]); + // rtc.regStatus1 &= 0xF1; + // rtc.regStatus1 |= (rtc.data[0] | 0x0E); + rtc.regStatus1 = rtc.data[0]; + break; + case 1: // status register 2 + //INFO("RTC: write regstatus2 0x%02X\n", rtc.data[0]); + rtc.regStatus2 = rtc.data[0]; + break; + case 2: // date & time + //INFO("RTC: write date & time : %02X %02X %02X %02X %02X %02X %02X\n", rtc.data[0], rtc.data[1], rtc.data[2], rtc.data[3], rtc.data[4], rtc.data[5], rtc.data[6]); + break; + case 3: // time + //INFO("RTC: write time : %02X %02X %02X\n", rtc.data[0], rtc.data[1], rtc.data[2]); + break; + case 4: // freq/alarm 1 + /*if (cmdBitsSize[0x04] == 8) + INFO("RTC: write INT1 freq 0x%02X\n", rtc.data[0]); + else + INFO("RTC: write INT1 alarm1 0x%02X\n", rtc.data[0]);*/ + break; + case 5: // alarm 2 + //INFO("RTC: write alarm 2\n"); + break; + case 6: // clock adjust + //INFO("RTC: write clock adjust\n"); + rtc.regAdjustment = rtc.data[0]; + break; + case 7: // free register + //INFO("RTC: write free register\n"); + rtc.regFree = rtc.data[0]; + break; + } +} + +void rtcInit() +{ + memset(&rtc, 0, sizeof(_RTC)); + memcpy(rtc.cmdBitsSize,kDefaultCmdBitsSize,8); + rtc.regStatus1 |= 0x02; +} + +u16 rtcRead() +{ + //INFO("MMU Read RTC 0x%02X (%03i)\n", rtc._REG, rtc.bitsCount); + return (rtc._REG); +} + +void rtcWrite(u16 val) +{ + //INFO("MMU Write RTC 0x%02X (%03i)\n", val, rtc.bitsCount); + rtc._DD = (val & 0x10) >> 4; + rtc._SIO = rtc._DD?(val & 0x01):rtc._prevSIO; + rtc._SCK = (val & 0x20)?((val & 0x02) >> 1):rtc._prevSCK; + rtc._CS = (val & 0x40)?((val & 0x04) >> 2):rtc._prevCS; + + switch (rtc.cmdStat) + { + case 0: + if ( (!rtc._prevCS) && (rtc._prevSCK) && (rtc._CS) && (rtc._SCK) ) + { + rtc.cmdStat = 1; + rtc.bitsCount = 0; + rtc.cmd = 0; + } + break; + + case 1: + if (!rtc._CS) + { + rtc.cmdStat = 0; + break; + } + + if (rtc._SCK && rtc._DD) break; + if (!rtc._SCK && !rtc._DD) break; + + rtc.cmd |= (rtc._SIO << rtc.bitsCount ); + rtc.bitsCount ++; + if (rtc.bitsCount == 8) + { + //INFO("RTC command 0x%02X\n", rtc.cmd); + + // Little-endian command + if((rtc.cmd & 0x0F) == 0x06) + { + u8 tmp = rtc.cmd; + rtc.cmd = ((tmp & 0x80) >> 7) | ((tmp & 0x40) >> 5) | ((tmp & 0x20) >> 3) | ((tmp & 0x10) >> 1); + } + // Big-endian command + else + { + rtc.cmd &= 0x0F; + } + + if((rtc._prevSCK) && (!rtc._SCK)) + { + rtc.bitsCount = 0; + if ((rtc.cmd >> 1) == 0x04) + { + if ((rtc.regStatus2 & 0x0F) == 0x04) + rtc.cmdBitsSize[rtc.cmd >> 1] = 24; + else + rtc.cmdBitsSize[rtc.cmd >> 1] = 8; + } + if (rtc.cmd & 0x01) + { + rtc.cmdStat = 4; + rtcRecv(); + } + else + { + rtc.cmdStat = 3; + } + } + } + + break; + + case 3: // write: + if( (rtc._prevSCK) && (!rtc._SCK) ) + { + if(rtc._SIO) rtc.data[rtc.bitsCount >> 3] |= (1 << (rtc.bitsCount & 0x07)); + rtc.bitsCount++; + if (rtc.bitsCount == rtc.cmdBitsSize[rtc.cmd >> 1]) + { + rtcSend(); + rtc.cmdStat = 0; + } + } + break; + + case 4: // read: + if( (rtc._prevSCK) && (!rtc._SCK) ) + { + rtc._REG = val; + if(rtc.data[rtc.bitsCount >> 3] >> (rtc.bitsCount & 0x07) & 0x01) + rtc._REG |= 0x01; + else + rtc._REG &= ~0x01; + + rtc.bitsCount++; + if (rtc.bitsCount == rtc.cmdBitsSize[rtc.cmd >> 1]) + rtc.cmdStat = 0; + } + break; + + } + + rtc._prevSIO = rtc._SIO; + rtc._prevSCK = rtc._SCK; + rtc._prevCS = rtc._CS; +} diff --git a/desmume/src/rtc.h b/src/rtc.h similarity index 96% rename from desmume/src/rtc.h rename to src/rtc.h index f1b6765ae..e57653082 100644 --- a/desmume/src/rtc.h +++ b/src/rtc.h @@ -1,35 +1,35 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright 2008 CrazyMax - Copyright 2008-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _RTC_H_ -#define _RTC_H_ -#include -#include "types.h" - -extern void rtcInit(); -extern u16 rtcRead(); -extern void rtcWrite(u16 val); - -void InitMovieTime(void); -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright 2008 CrazyMax + Copyright 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _RTC_H_ +#define _RTC_H_ +#include +#include "types.h" + +extern void rtcInit(); +extern u16 rtcRead(); +extern void rtcWrite(u16 val); + +void InitMovieTime(void); +#endif diff --git a/desmume/src/saves.cpp b/src/saves.cpp similarity index 87% rename from desmume/src/saves.cpp rename to src/saves.cpp index 52d47926d..b9f3b79eb 100644 --- a/desmume/src/saves.cpp +++ b/src/saves.cpp @@ -1,1232 +1,1175 @@ -/* Copyright (C) 2006 Normmatt - Copyright (C) 2006 Theo Berkau - Copyright (C) 2007 Pascal Giard - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifdef HAVE_LIBZ -#include -#endif -#include -#include -#include -#include -#include -#include -#include "saves.h" -#include "MMU.h" -#include "NDSSystem.h" -#include "render3D.h" -#include "cp15.h" -#include "GPU_osd.h" -#include "version.h" - -#include "memorystream.h" -#include "readwrite.h" -#include "gfx3d.h" -#include "movie.h" - -#include "path.h" - -#ifdef _MSC_VER -#include "windows/main.h" -#endif - -int lastSaveState = 0; //Keeps track of last savestate used for quick save/load functions - -//void*v is actually a void** which will be indirected before reading -//since this isnt supported right now, it is declared in here to make things compile -#define SS_INDIRECT 0x80000000 - -savestates_t savestates[NB_STATES]; - -#define SAVESTATE_VERSION 12 -static const char* magic = "DeSmuME SState\0"; - -//a savestate chunk loader can set this if it wants to permit a silent failure (for compatibility) -static bool SAV_silent_fail_flag; - -#ifndef MAX_PATH -#define MAX_PATH 256 -#endif - - -SFORMAT SF_ARM7[]={ - { "7INS", 4, 1, &NDS_ARM7.instruction }, - { "7INA", 4, 1, &NDS_ARM7.instruct_adr }, - { "7INN", 4, 1, &NDS_ARM7.next_instruction }, - { "7REG", 4,16, NDS_ARM7.R }, - { "7CPS", 4, 1, &NDS_ARM7.CPSR }, - { "7SPS", 4, 1, &NDS_ARM7.SPSR }, - { "7DUS", 4, 1, &NDS_ARM7.R13_usr }, - { "7EUS", 4, 1, &NDS_ARM7.R14_usr }, - { "7DSV", 4, 1, &NDS_ARM7.R13_svc }, - { "7ESV", 4, 1, &NDS_ARM7.R14_svc }, - { "7DAB", 4, 1, &NDS_ARM7.R13_abt }, - { "7EAB", 4, 1, &NDS_ARM7.R14_abt }, - { "7DUN", 4, 1, &NDS_ARM7.R13_und }, - { "7EUN", 4, 1, &NDS_ARM7.R14_und }, - { "7DIR", 4, 1, &NDS_ARM7.R13_irq }, - { "7EIR", 4, 1, &NDS_ARM7.R14_irq }, - { "78FI", 4, 1, &NDS_ARM7.R8_fiq }, - { "79FI", 4, 1, &NDS_ARM7.R9_fiq }, - { "7AFI", 4, 1, &NDS_ARM7.R10_fiq }, - { "7BFI", 4, 1, &NDS_ARM7.R11_fiq }, - { "7CFI", 4, 1, &NDS_ARM7.R12_fiq }, - { "7DFI", 4, 1, &NDS_ARM7.R13_fiq }, - { "7EFI", 4, 1, &NDS_ARM7.R14_fiq }, - { "7SVC", 4, 1, &NDS_ARM7.SPSR_svc }, - { "7ABT", 4, 1, &NDS_ARM7.SPSR_abt }, - { "7UND", 4, 1, &NDS_ARM7.SPSR_und }, - { "7IRQ", 4, 1, &NDS_ARM7.SPSR_irq }, - { "7FIQ", 4, 1, &NDS_ARM7.SPSR_fiq }, - { "7int", 4, 1, &NDS_ARM7.intVector }, - { "7LDT", 1, 1, &NDS_ARM7.LDTBit }, - { "7Wai", 4, 1, &NDS_ARM7.waitIRQ }, - { "7wIR", 4, 1, &NDS_ARM7.wIRQ, }, - { "7wir", 4, 1, &NDS_ARM7.wirq, }, - { "7NIF", 4, 1, &NDS_ARM7.newIrqFlags}, - { 0 } -}; - -SFORMAT SF_ARM9[]={ - { "9INS", 4, 1, &NDS_ARM9.instruction}, - { "9INA", 4, 1, &NDS_ARM9.instruct_adr}, - { "9INN", 4, 1, &NDS_ARM9.next_instruction}, - { "9REG", 4,16, NDS_ARM9.R}, - { "9CPS", 4, 1, &NDS_ARM9.CPSR}, - { "9SPS", 4, 1, &NDS_ARM9.SPSR}, - { "9DUS", 4, 1, &NDS_ARM9.R13_usr}, - { "9EUS", 4, 1, &NDS_ARM9.R14_usr}, - { "9DSV", 4, 1, &NDS_ARM9.R13_svc}, - { "9ESV", 4, 1, &NDS_ARM9.R14_svc}, - { "9DAB", 4, 1, &NDS_ARM9.R13_abt}, - { "9EAB", 4, 1, &NDS_ARM9.R14_abt}, - { "9DUN", 4, 1, &NDS_ARM9.R13_und}, - { "9EUN", 4, 1, &NDS_ARM9.R14_und}, - { "9DIR", 4, 1, &NDS_ARM9.R13_irq}, - { "9EIR", 4, 1, &NDS_ARM9.R14_irq}, - { "98FI", 4, 1, &NDS_ARM9.R8_fiq}, - { "99FI", 4, 1, &NDS_ARM9.R9_fiq}, - { "9AFI", 4, 1, &NDS_ARM9.R10_fiq}, - { "9BFI", 4, 1, &NDS_ARM9.R11_fiq}, - { "9CFI", 4, 1, &NDS_ARM9.R12_fiq}, - { "9DFI", 4, 1, &NDS_ARM9.R13_fiq}, - { "9EFI", 4, 1, &NDS_ARM9.R14_fiq}, - { "9SVC", 4, 1, &NDS_ARM9.SPSR_svc}, - { "9ABT", 4, 1, &NDS_ARM9.SPSR_abt}, - { "9UND", 4, 1, &NDS_ARM9.SPSR_und}, - { "9IRQ", 4, 1, &NDS_ARM9.SPSR_irq}, - { "9FIQ", 4, 1, &NDS_ARM9.SPSR_fiq}, - { "9int", 4, 1, &NDS_ARM9.intVector}, - { "9LDT", 1, 1, &NDS_ARM9.LDTBit}, - { "9Wai", 4, 1, &NDS_ARM9.waitIRQ}, - { "9wIR", 4, 1, &NDS_ARM9.wIRQ}, - { "9wir", 4, 1, &NDS_ARM9.wirq}, - { "9NIF", 4, 1, &NDS_ARM9.newIrqFlags}, - { 0 } -}; - -SFORMAT SF_MEM[]={ - { "ITCM", 1, sizeof(MMU.ARM9_ITCM), MMU.ARM9_ITCM}, - { "DTCM", 1, sizeof(MMU.ARM9_DTCM), MMU.ARM9_DTCM}, - - //for legacy purposes, WRAX is a separate variable. shouldnt be a problem. - { "WRAM", 1, 0x400000, MMU.MAIN_MEM}, - { "WRAX", 1, 0x400000, MMU.MAIN_MEM+0x400000}, - - //NOTE - this is not as large as the allocated memory. - //the memory is overlarge due to the way our memory map system is setup - //but there are actually no more registers than this - { "9REG", 1, 0x2000, MMU.ARM9_REG}, - - { "VMEM", 1, sizeof(MMU.ARM9_VMEM), MMU.ARM9_VMEM}, - { "OAMS", 1, sizeof(MMU.ARM9_OAM), MMU.ARM9_OAM}, - - //this size is specially chosen to avoid saving the blank space at the end - { "LCDM", 1, 0xA4000, MMU.ARM9_LCD}, - { 0 } -}; - -SFORMAT SF_NDS[]={ - { "_WCY", 4, 1, &nds.wifiCycle}, - { "_TCY", 8, 8, nds.timerCycle}, - { "_VCT", 4, 1, &nds.VCount}, - { "_OLD", 4, 1, &nds.old}, - { "_TPX", 2, 1, &nds.touchX}, - { "_TPY", 2, 1, &nds.touchY}, - { "_TPB", 4, 1, &nds.isTouch}, - { "_DBG", 4, 1, &nds.debugConsole}, - { 0 } -}; - -extern u32 DMASrc[2][4]; -extern u32 DMADst[2][4]; - -SFORMAT SF_MMU[]={ - { "M7BI", 1, sizeof(MMU.ARM7_BIOS), MMU.ARM7_BIOS}, - { "M7ER", 1, sizeof(MMU.ARM7_ERAM), MMU.ARM7_ERAM}, - { "M7RG", 1, sizeof(MMU.ARM7_REG), MMU.ARM7_REG}, - { "M7WI", 1, sizeof(MMU.ARM7_WIRAM), MMU.ARM7_WIRAM}, - { "MSWI", 1, sizeof(MMU.SWIRAM), MMU.SWIRAM}, - { "MCRA", 1, sizeof(MMU.CART_RAM), MMU.CART_RAM}, - { "M9RW", 1, 1, &MMU.ARM9_RW_MODE}, - { "MDTC", 4, 1, &MMU.DTCMRegion}, - { "MITC", 4, 1, &MMU.ITCMRegion}, - { "MTIM", 2, 8, MMU.timer}, - { "MTMO", 4, 8, MMU.timerMODE}, - { "MTON", 4, 8, MMU.timerON}, - { "MTRN", 4, 8, MMU.timerRUN}, - { "MTRL", 2, 8, MMU.timerReload}, - { "MIME", 4, 2, MMU.reg_IME}, - { "MIE_", 4, 2, MMU.reg_IE}, - { "MIF_", 4, 2, MMU.reg_IF}, - - { "MGXC", 8, 1, &MMU.gfx3dCycles}, - - { "M_SX", 1, 2, &MMU.SPI_CNT}, - { "M_SC", 1, 2, &MMU.SPI_CMD}, - { "MASX", 1, 2, &MMU.AUX_SPI_CNT}, - { "MASC", 1, 2, &MMU.AUX_SPI_CMD}, - - { "MDST", 4, 8, MMU.DMAStartTime}, - { "MDCY", 8, 8, MMU.DMACycle}, - { "MDCR", 4, 8, MMU.DMACrt}, - { "MDMA", 4, 8, MMU.DMAing}, - { "MDMC", 4, 8, MMU.DMACompleted}, - { "MDSR", 4, 8, DMASrc}, - { "MDDS", 4, 8, DMADst}, - - { "MDV1", 4, 1, &MMU.divRunning}, - { "MDV2", 8, 1, &MMU.divResult}, - { "MDV3", 8, 1, &MMU.divMod}, - { "MDV4", 4, 1, &MMU.divCnt}, - { "MDV5", 8, 1, &MMU.divCycles}, - - { "MSQ1", 4, 1, &MMU.sqrtRunning}, - { "MSQ2", 4, 1, &MMU.sqrtResult}, - { "MSQ3", 4, 1, &MMU.sqrtCnt}, - { "MSQ4", 8, 1, &MMU.sqrtCycles}, - - //begin memory chips - { "BUCO", 1, 1, &MMU.fw.com}, - { "BUAD", 4, 1, &MMU.fw.addr}, - { "BUAS", 1, 1, &MMU.fw.addr_shift}, - { "BUAZ", 1, 1, &MMU.fw.addr_size}, - { "BUWE", 4, 1, &MMU.fw.write_enable}, - { "BUWR", 4, 1, &MMU.fw.writeable_buffer}, - //end memory chips - - { "MC0A", 4, 1, &MMU.dscard[0].address}, - { "MC0T", 4, 1, &MMU.dscard[0].transfer_count}, - { "MC1A", 4, 1, &MMU.dscard[1].address}, - { "MC1T", 4, 1, &MMU.dscard[1].transfer_count}, - { "MCHT", 4, 1, &MMU.CheckTimers}, - { "MCHD", 4, 1, &MMU.CheckDMAs}, - - //fifos - { "F0TH", 1, 1, &ipc_fifo[0].head}, - { "F0TL", 1, 1, &ipc_fifo[0].tail}, - { "F0SZ", 1, 1, &ipc_fifo[0].size}, - { "F0BF", 4, 16, ipc_fifo[0].buf}, - { "F1TH", 1, 1, &ipc_fifo[1].head}, - { "F1TL", 1, 1, &ipc_fifo[1].tail}, - { "F1SZ", 1, 1, &ipc_fifo[1].size}, - { "F1BF", 4, 16, ipc_fifo[1].buf}, - - { "FDHD", 4, 1, &disp_fifo.head}, - { "FDTL", 4, 1, &disp_fifo.tail}, - { "FDBF", 4, 0x6000, disp_fifo.buf}, - - { 0 } -}; - -SFORMAT SF_MOVIE[]={ - { "FRAC", 4, 1, &currFrameCounter}, - { "LAGC", 4, 1, &TotalLagFrames}, - { 0 } -}; - -static void mmu_savestate(std::ostream* os) -{ - //version - write32le(2,os); - - //newer savefile system: - MMU_new.backupDevice.save_state(os); -} - -SFORMAT SF_WIFI[]={ - { "W000", 4, 1, &wifiMac.powerOn}, - { "W010", 4, 1, &wifiMac.powerOnPending}, - - { "W020", 2, 1, &wifiMac.rfStatus}, - { "W030", 2, 1, &wifiMac.rfPins}, - - { "W040", 2, 1, &wifiMac.IE.val}, - { "W050", 2, 1, &wifiMac.IF.val}, - - { "W060", 2, 1, &wifiMac.macMode}, - { "W070", 2, 1, &wifiMac.wepMode}, - { "W080", 4, 1, &wifiMac.WEP_enable}, - - { "W090", 2, 3, &wifiMac.TXSlot[0]}, - { "W100", 2, 1, &wifiMac.TXCnt}, - { "W110", 2, 1, &wifiMac.TXOpt}, - { "W120", 2, 1, &wifiMac.TXStat}, - { "W130", 2, 1, &wifiMac.BEACONSlot}, - { "W140", 4, 1, &wifiMac.BEACON_enable}, - { "W150", 1, 1, &wifiMac.txCurSlot}, - { "W160", 1, 3, &wifiMac.txSlotBusy[0]}, - { "W170", 4, 3, &wifiMac.txSlotAddr[0]}, - { "W180", 4, 3, &wifiMac.txSlotLen[0]}, - { "W190", 4, 3, &wifiMac.txSlotRemainingBytes[0]}, - - { "W200", 2, 1, &wifiMac.RXCnt}, - { "W210", 2, 1, &wifiMac.RXCheckCounter}, - - { "W220", 1, 6, &wifiMac.mac.bytes}, - { "W230", 1, 6, &wifiMac.bss.bytes}, - - { "W240", 2, 1, &wifiMac.aid}, - { "W250", 2, 1, &wifiMac.pid}, - { "W260", 2, 1, &wifiMac.retryLimit}, - - { "W270", 4, 1, &wifiMac.crystalEnabled}, - { "W280", 8, 1, &wifiMac.usec}, - { "W290", 4, 1, &wifiMac.usecEnable}, - { "W300", 8, 1, &wifiMac.ucmp}, - { "W310", 4, 1, &wifiMac.ucmpEnable}, - { "W320", 2, 1, &wifiMac.eCount}, - { "W330", 4, 1, &wifiMac.eCountEnable}, - - { "WR00", 4, 1, &wifiMac.RF.CFG1.val}, - { "WR01", 4, 1, &wifiMac.RF.IFPLL1.val}, - { "WR02", 4, 1, &wifiMac.RF.IFPLL2.val}, - { "WR03", 4, 1, &wifiMac.RF.IFPLL3.val}, - { "WR04", 4, 1, &wifiMac.RF.RFPLL1.val}, - { "WR05", 4, 1, &wifiMac.RF.RFPLL2.val}, - { "WR06", 4, 1, &wifiMac.RF.RFPLL3.val}, - { "WR07", 4, 1, &wifiMac.RF.RFPLL4.val}, - { "WR08", 4, 1, &wifiMac.RF.CAL1.val}, - { "WR09", 4, 1, &wifiMac.RF.TXRX1.val}, - { "WR10", 4, 1, &wifiMac.RF.PCNT1.val}, - { "WR11", 4, 1, &wifiMac.RF.PCNT2.val}, - { "WR12", 4, 1, &wifiMac.RF.VCOT1.val}, - - { "W340", 1, 105, &wifiMac.BB.data[0]}, - - { "W350", 2, 1, &wifiMac.rfIOCnt.val}, - { "W360", 2, 1, &wifiMac.rfIOStatus.val}, - { "W370", 4, 1, &wifiMac.rfIOData.val}, - { "W380", 2, 1, &wifiMac.bbIOCnt.val}, - - { "W390", 1, 1, &wifiMac.bbDataToWrite}, - - { "W400", 2, 0x1000, &wifiMac.circularBuffer[0]}, - { "W410", 2, 1, &wifiMac.RXRangeBegin}, - { "W420", 2, 1, &wifiMac.RXRangeEnd}, - { "W430", 2, 1, &wifiMac.RXHWWriteCursor}, - { "W440", 2, 1, &wifiMac.RXHWWriteCursorReg}, - { "W450", 2, 1, &wifiMac.RXHWWriteCursorLatched}, - { "W460", 2, 1, &wifiMac.RXReadCursor}, - { "W470", 2, 1, &wifiMac.RXUnits}, - { "W480", 2, 1, &wifiMac.RXBufCount}, - { "W490", 2, 1, &wifiMac.CircBufReadAddress}, - { "W500", 2, 1, &wifiMac.CircBufWriteAddress}, - { "W510", 2, 1, &wifiMac.CircBufRdEnd}, - { "W520", 2, 1, &wifiMac.CircBufRdSkip}, - { "W530", 2, 1, &wifiMac.CircBufWrEnd}, - { "W540", 2, 1, &wifiMac.CircBufWrSkip}, - - { "W550", 4, 1, &wifiMac.curPacketSize[0]}, - { "W560", 4, 1, &wifiMac.curPacketPos[0]}, - { "W570", 4, 1, &wifiMac.curPacketSending[0]}, - - { "W580", 2, 0x800, &wifiMac.ioMem[0]}, - { "W590", 2, 1, &wifiMac.randomSeed}, - - { "WX00", 8, 1, &wifiMac.SoftAP.usecCounter}, - { "WX10", 1, 4096, &wifiMac.SoftAP.curPacket[0]}, - { "WX20", 4, 1, &wifiMac.SoftAP.curPacketSize}, - { "WX30", 4, 1, &wifiMac.SoftAP.curPacketPos}, - { "WX40", 4, 1, &wifiMac.SoftAP.curPacketSending}, - - { 0 } -}; - -static bool mmu_loadstate(std::istream* is, int size) -{ - //read version - int version; - if(read32le(&version,is) != 1) return false; - - if(version == 0 || version == 1) - { - u32 bupmem_size; - u32 addr_size; - - if(version == 0) - { - //version 0 was buggy and didnt save the type. - //it would silently fail if there was a size mismatch - SAV_silent_fail_flag = true; - if(read32le(&bupmem_size,is) != 1) return false; - //if(bupmem_size != MMU.bupmem.size) return false; //mismatch between current initialized and saved size - addr_size = BackupDevice::addr_size_for_old_save_size(bupmem_size); - } - else if(version == 1) - { - //version 1 reinitializes the save system with the type that was saved - int bupmem_type; - if(read32le(&bupmem_type,is) != 1) return false; - if(read32le(&bupmem_size,is) != 1) return false; - addr_size = BackupDevice::addr_size_for_old_save_type(bupmem_type); - if(addr_size == 0xFFFFFFFF) - addr_size = BackupDevice::addr_size_for_old_save_size(bupmem_size); - } - - if(addr_size == 0xFFFFFFFF) - return false; - - u8* temp = new u8[bupmem_size]; - is->read((char*)temp,bupmem_size); - MMU_new.backupDevice.load_old_state(addr_size,temp,bupmem_size); - delete[] temp; - if(is->fail()) return false; - } - else if(version == 2) - { - //newer savefile system: - MMU_new.backupDevice.load_state(is); - } - - return true; -} - -static void cp15_saveone(armcp15_t *cp15, std::ostream* os) -{ - write32le(cp15->IDCode,os); - write32le(cp15->cacheType,os); - write32le(cp15->TCMSize,os); - write32le(cp15->ctrl,os); - write32le(cp15->DCConfig,os); - write32le(cp15->ICConfig,os); - write32le(cp15->writeBuffCtrl,os); - write32le(cp15->und,os); - write32le(cp15->DaccessPerm,os); - write32le(cp15->IaccessPerm,os); - write32le(cp15->protectBaseSize0,os); - write32le(cp15->protectBaseSize1,os); - write32le(cp15->protectBaseSize2,os); - write32le(cp15->protectBaseSize3,os); - write32le(cp15->protectBaseSize4,os); - write32le(cp15->protectBaseSize5,os); - write32le(cp15->protectBaseSize6,os); - write32le(cp15->protectBaseSize7,os); - write32le(cp15->cacheOp,os); - write32le(cp15->DcacheLock,os); - write32le(cp15->IcacheLock,os); - write32le(cp15->ITCMRegion,os); - write32le(cp15->DTCMRegion,os); - write32le(cp15->processID,os); - write32le(cp15->RAM_TAG,os); - write32le(cp15->testState,os); - write32le(cp15->cacheDbg,os); - for(int i=0;i<8;i++) write32le(cp15->regionWriteMask_USR[i],os); - for(int i=0;i<8;i++) write32le(cp15->regionWriteMask_SYS[i],os); - for(int i=0;i<8;i++) write32le(cp15->regionReadMask_USR[i],os); - for(int i=0;i<8;i++) write32le(cp15->regionReadMask_SYS[i],os); - for(int i=0;i<8;i++) write32le(cp15->regionExecuteMask_USR[i],os); - for(int i=0;i<8;i++) write32le(cp15->regionExecuteMask_SYS[i],os); - for(int i=0;i<8;i++) write32le(cp15->regionWriteSet_USR[i],os); - for(int i=0;i<8;i++) write32le(cp15->regionWriteSet_SYS[i],os); - for(int i=0;i<8;i++) write32le(cp15->regionReadSet_USR[i],os); - for(int i=0;i<8;i++) write32le(cp15->regionReadSet_SYS[i],os); - for(int i=0;i<8;i++) write32le(cp15->regionExecuteSet_USR[i],os); - for(int i=0;i<8;i++) write32le(cp15->regionExecuteSet_SYS[i],os); -} - -static void cp15_savestate(std::ostream* os) -{ - //version - write32le(0,os); - - cp15_saveone((armcp15_t *)NDS_ARM9.coproc[15],os); - cp15_saveone((armcp15_t *)NDS_ARM7.coproc[15],os); -} - -static bool cp15_loadone(armcp15_t *cp15, std::istream* is) -{ - if(!read32le(&cp15->IDCode,is)) return false; - if(!read32le(&cp15->cacheType,is)) return false; - if(!read32le(&cp15->TCMSize,is)) return false; - if(!read32le(&cp15->ctrl,is)) return false; - if(!read32le(&cp15->DCConfig,is)) return false; - if(!read32le(&cp15->ICConfig,is)) return false; - if(!read32le(&cp15->writeBuffCtrl,is)) return false; - if(!read32le(&cp15->und,is)) return false; - if(!read32le(&cp15->DaccessPerm,is)) return false; - if(!read32le(&cp15->IaccessPerm,is)) return false; - if(!read32le(&cp15->protectBaseSize0,is)) return false; - if(!read32le(&cp15->protectBaseSize1,is)) return false; - if(!read32le(&cp15->protectBaseSize2,is)) return false; - if(!read32le(&cp15->protectBaseSize3,is)) return false; - if(!read32le(&cp15->protectBaseSize4,is)) return false; - if(!read32le(&cp15->protectBaseSize5,is)) return false; - if(!read32le(&cp15->protectBaseSize6,is)) return false; - if(!read32le(&cp15->protectBaseSize7,is)) return false; - if(!read32le(&cp15->cacheOp,is)) return false; - if(!read32le(&cp15->DcacheLock,is)) return false; - if(!read32le(&cp15->IcacheLock,is)) return false; - if(!read32le(&cp15->ITCMRegion,is)) return false; - if(!read32le(&cp15->DTCMRegion,is)) return false; - if(!read32le(&cp15->processID,is)) return false; - if(!read32le(&cp15->RAM_TAG,is)) return false; - if(!read32le(&cp15->testState,is)) return false; - if(!read32le(&cp15->cacheDbg,is)) return false; - for(int i=0;i<8;i++) if(!read32le(&cp15->regionWriteMask_USR[i],is)) return false; - for(int i=0;i<8;i++) if(!read32le(&cp15->regionWriteMask_SYS[i],is)) return false; - for(int i=0;i<8;i++) if(!read32le(&cp15->regionReadMask_USR[i],is)) return false; - for(int i=0;i<8;i++) if(!read32le(&cp15->regionReadMask_SYS[i],is)) return false; - for(int i=0;i<8;i++) if(!read32le(&cp15->regionExecuteMask_USR[i],is)) return false; - for(int i=0;i<8;i++) if(!read32le(&cp15->regionExecuteMask_SYS[i],is)) return false; - for(int i=0;i<8;i++) if(!read32le(&cp15->regionWriteSet_USR[i],is)) return false; - for(int i=0;i<8;i++) if(!read32le(&cp15->regionWriteSet_SYS[i],is)) return false; - for(int i=0;i<8;i++) if(!read32le(&cp15->regionReadSet_USR[i],is)) return false; - for(int i=0;i<8;i++) if(!read32le(&cp15->regionReadSet_SYS[i],is)) return false; - for(int i=0;i<8;i++) if(!read32le(&cp15->regionExecuteSet_USR[i],is)) return false; - for(int i=0;i<8;i++) if(!read32le(&cp15->regionExecuteSet_SYS[i],is)) return false; - - return true; -} - -static bool cp15_loadstate(std::istream* is, int size) -{ - //read version - int version; - if(read32le(&version,is) != 1) return false; - if(version != 0) return false; - - if(!cp15_loadone((armcp15_t *)NDS_ARM9.coproc[15],is)) return false; - if(!cp15_loadone((armcp15_t *)NDS_ARM7.coproc[15],is)) return false; - - return true; -} - - - -/* Format time and convert to string */ -static char * format_time(time_t cal_time) -{ - struct tm *time_struct; - static char str[64]; - - time_struct=localtime(&cal_time); - strftime(str, sizeof str, "%d-%b-%Y %H:%M:%S", time_struct); - - return(str); -} - -void clear_savestates() -{ - u8 i; - for( i = 0; i < NB_STATES; i++ ) - savestates[i].exists = FALSE; -} - -/* Scan for existing savestates and update struct */ -void scan_savestates() -{ - struct stat sbuf; - char filename[MAX_PATH+1]; - u8 i; - - clear_savestates(); - - for( i = 1; i <= NB_STATES; i++ ) - { - path.getpathnoext(path.STATES, filename); - - if (strlen(filename) + strlen(".dst") + strlen("-2147483648") /* = biggest string for i */ >MAX_PATH) return ; - sprintf(filename+strlen(filename), ".ds%d", i); - if( stat(filename,&sbuf) == -1 ) continue; - savestates[i-1].exists = TRUE; - strncpy(savestates[i-1].date, format_time(sbuf.st_mtime),40); - savestates[i-1].date[40-1] = '\0'; - } - - return ; -} - -void savestate_slot(int num) -{ - struct stat sbuf; - char filename[MAX_PATH+1]; - - lastSaveState = num; //Set last savestate used - - path.getpathnoext(path.STATES, filename); - - if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ >MAX_PATH) return ; - sprintf(filename+strlen(filename), ".ds%d", num); - - if (savestate_save(filename)) - { - osd->setLineColor(255, 255, 255); - osd->addLine("Saved to %i slot", num); - } - else - { - osd->setLineColor(255, 0, 0); - osd->addLine("Error save to %i slot", num); - return; - } - - if (num >= 0 && num < NB_STATES) - { - if (stat(filename,&sbuf) != -1) - { - savestates[num].exists = TRUE; - strncpy(savestates[num].date, format_time(sbuf.st_mtime),40); - savestates[num].date[40-1] = '\0'; - } - } -} - -void loadstate_slot(int num) -{ - char filename[MAX_PATH]; - - lastSaveState = num; //Set last savestate used - - path.getpathnoext(path.STATES, filename); - - if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ >MAX_PATH) return ; - sprintf(filename+strlen(filename), ".ds%d", num); - if (savestate_load(filename)) - { - osd->setLineColor(255, 255, 255); - osd->addLine("Loaded from %i slot", num); - } - else - { - osd->setLineColor(255, 0, 0); - osd->addLine("Error from load %i slot", num); - } -} - -u8 sram_read (u32 address) { - address = address - SRAM_ADDRESS; - - if ( address > SRAM_SIZE ) - return 0; - - return MMU.CART_RAM[address]; - -} - -void sram_write (u32 address, u8 value) { - - address = address - SRAM_ADDRESS; - - if ( address < SRAM_SIZE ) - MMU.CART_RAM[address] = value; - -} - -int sram_load (const char *file_name) { - - FILE *file; - size_t elems_read; - - file = fopen ( file_name, "rb" ); - if( file == NULL ) - return 0; - - elems_read = fread ( MMU.CART_RAM, SRAM_SIZE, 1, file ); - - fclose ( file ); - - osd->setLineColor(255, 255, 255); - osd->addLine("Loaded SRAM"); - - return 1; - -} - -int sram_save (const char *file_name) { - - FILE *file; - size_t elems_written; - - file = fopen ( file_name, "wb" ); - if( file == NULL ) - return 0; - - elems_written = fwrite ( MMU.CART_RAM, SRAM_SIZE, 1, file ); - - fclose ( file ); - - osd->setLineColor(255, 255, 255); - osd->addLine("Saved SRAM"); - - return 1; - -} - -// note: guessSF is so we don't have to do a linear search through the SFORMAT array every time -// in the (most common) case that we already know where the next entry is. -static const SFORMAT *CheckS(const SFORMAT *guessSF, const SFORMAT *firstSF, u32 size, u32 count, char *desc) -{ - const SFORMAT *sf = guessSF ? guessSF : firstSF; - while(sf->v) - { - //NOT SUPPORTED RIGHT NOW - //if(sf->size==~0) // Link to another SFORMAT structure. - //{ - // SFORMAT *tmp; - // if((tmp= CheckS((SFORMAT *)sf->v, tsize, desc) )) - // return(tmp); - // sf++; - // continue; - //} - if(!memcmp(desc,sf->desc,4)) - { - if(sf->size != size || sf->count != count) - return 0; - return sf; - } - - // failed to find it, have to keep iterating - if(guessSF) - { - sf = firstSF; - guessSF = NULL; - } - else - { - sf++; - } - } - return 0; -} - - -static bool ReadStateChunk(std::istream* is, const SFORMAT *sf, int size) -{ - const SFORMAT *tmp = NULL; - const SFORMAT *guessSF = NULL; - int temp = is->tellg(); - - while(is->tellg()read(toa,4); - if(is->fail()) - return false; - - if(!read32le(&sz,is)) return false; - if(!read32le(&count,is)) return false; - - if((tmp=CheckS(guessSF,sf,sz,count,toa))) - { - #ifdef LOCAL_LE - // no need to ever loop one at a time if not flipping byte order - is->read((char *)tmp->v,sz*count); - #else - if(sz == 1) { - //special case: read a huge byte array - is->read((char *)tmp->v,count); - } else { - for(unsigned int i=0;iread((char *)tmp->v + i*sz,sz); - FlipByteOrder((u8*)tmp->v + i*sz,sz); - } - } - #endif - guessSF = tmp + 1; - } - else - { - is->seekg(sz*count,std::ios::cur); - guessSF = NULL; - } - } // while(...) - return true; -} - - - -static int SubWrite(std::ostream* os, const SFORMAT *sf) -{ - uint32 acc=0; - - const SFORMAT* temp = sf; - while(temp->v) { - const SFORMAT* seek = sf; - while(seek->v && seek != temp) { - if(!strcmp(seek->desc,temp->desc)) { - printf("ERROR! duplicated chunk name: %s\n", temp->desc); - } - seek++; - } - temp++; - } - - while(sf->v) - { - //not supported right now - //if(sf->size==~0) //Link to another struct - //{ - // uint32 tmp; - - // if(!(tmp=SubWrite(os,(SFORMAT *)sf->v))) - // return(0); - // acc+=tmp; - // sf++; - // continue; - //} - - int count = sf->count; - int size = sf->size; - - //add size of current node to the accumulator - acc += 4 + sizeof(sf->size) + sizeof(sf->count); - acc += count * size; - - if(os) //Are we writing or calculating the size of this block? - { - os->write(sf->desc,4); - write32le(sf->size,os); - write32le(sf->count,os); - - #ifdef LOCAL_LE - // no need to ever loop one at a time if not flipping byte order - os->write((char *)sf->v,size*count); - #else - if(sz == 1) { - //special case: write a huge byte array - os->write((char *)sf->v,count); - } else { - for(int i=0;iv + i*size, size); - os->write((char*)sf->v + i*size,size); - //Now restore the original byte order. - FlipByteOrder((u8*)sf->v + i*size, size); - } - } - #endif - } - sf++; - } - - return(acc); -} - -static int savestate_WriteChunk(std::ostream* os, int type, const SFORMAT *sf) -{ - write32le(type,os); - if(!sf) return 4; - int bsize = SubWrite((std::ostream*)0,sf); - write32le(bsize,os); - - if(!SubWrite(os,sf)) - { - return 8; - } - return (bsize+8); -} - -static void savestate_WriteChunk(std::ostream* os, int type, void (*saveproc)(std::ostream* os)) -{ - u32 pos1 = os->tellp(); - - //write the type, size(placeholder), and data - write32le(type,os); - write32le(0,os); // <-- temporary write, re-written later - saveproc(os); - - //get the size - u32 pos2 = os->tellp(); - assert(pos2 != (u32)-1); // if this assert fails, saveproc did something bad - u32 size = (pos2 - pos1) - (2 * sizeof(u32)); - - //fill in the actual size - os->seekp(pos1 + sizeof(u32)); - write32le(size,os); - os->seekp(pos2); - -/* -// old version of this function, -// for reference in case the new one above starts misbehaving somehow: - - // - this is retarded. why not write placeholders for size and then write directly to the stream - //and then go back and fill them in - - //get the size - memorystream mstemp; - saveproc(&mstemp); - mstemp.flush(); - u32 size = mstemp.size(); - - //write the type, size, and data - write32le(type,os); - write32le(size,os); - os->write(mstemp.buf(),size); -*/ -} - -static void writechunks(std::ostream* os); - -static bool savestate_save(std::ostream* outstream, int compressionLevel) -{ - #ifndef HAVE_LIBZ - compressionLevel = Z_NO_COMPRESSION; - #endif - - memorystream ms; - std::ostream* os; - - if(compressionLevel != Z_NO_COMPRESSION) - { - //generate the savestate in memory first - os = (std::ostream*)&ms; - writechunks(os); - ms.flush(); - } - else - { - os = outstream; - os->seekp(32); //skip the header - writechunks(os); - } - - os->flush(); - - //save the length of the file - u32 len = os->tellp(); - - u32 comprlen = 0xFFFFFFFF; - u8* cbuf; - - //compress the data - int error = Z_OK; - if(compressionLevel != Z_NO_COMPRESSION) - { - cbuf = (u8*)ms.buf(); - uLongf comprlen2; - //worst case compression. - //zlib says "0.1% larger than sourceLen plus 12 bytes" - comprlen = (len>>9)+12 + len; - cbuf = new u8[comprlen]; - /* Workaround to make it compile under linux 64bit */ - comprlen2 = comprlen; - error = compress2(cbuf,&comprlen2,(u8*)ms.buf(),len,compressionLevel); - comprlen = (u32)comprlen2; - } - - //dump the header - outstream->seekp(0); - outstream->write(magic,16); - write32le(SAVESTATE_VERSION,outstream); - write32le(DESMUME_VERSION_NUMERIC,outstream); //desmume version - write32le(len,outstream); //uncompressed length - write32le(comprlen,outstream); //compressed length (-1 if it is not compressed) - outstream->flush(); - - if(compressionLevel != Z_NO_COMPRESSION) - { - outstream->write((char*)cbuf,comprlen==(u32)-1?len:comprlen); - delete[] cbuf; - } - - return error == Z_OK; -} - -bool savestate_save (const char *file_name) -{ - memorystream ms; - size_t elems_written; -#ifdef HAVE_LIBZ - if(!savestate_save(&ms, Z_DEFAULT_COMPRESSION)) -#else - if(!savestate_save(&ms, 0)) -#endif - return false; - ms.flush(); - FILE* file = fopen(file_name,"wb"); - if(file) - { - elems_written = fwrite(ms.buf(),1,ms.size(),file); - fclose(file); - return (elems_written == ms.size()); - } else return false; -} - -extern SFORMAT SF_RTC[]; - -static void writechunks(std::ostream* os) { - savestate_WriteChunk(os,1,SF_ARM9); - savestate_WriteChunk(os,2,SF_ARM7); - savestate_WriteChunk(os,3,cp15_savestate); - savestate_WriteChunk(os,4,SF_MEM); - savestate_WriteChunk(os,5,SF_NDS); - savestate_WriteChunk(os,51,nds_savestate); - savestate_WriteChunk(os,60,SF_MMU); - savestate_WriteChunk(os,61,mmu_savestate); - savestate_WriteChunk(os,7,gpu_savestate); - savestate_WriteChunk(os,8,spu_savestate); - savestate_WriteChunk(os,90,SF_GFX3D); - savestate_WriteChunk(os,91,gfx3d_savestate); - savestate_WriteChunk(os,100,SF_MOVIE); - savestate_WriteChunk(os,101,mov_savestate); - savestate_WriteChunk(os,110,SF_WIFI); - savestate_WriteChunk(os,120,SF_RTC); - savestate_WriteChunk(os,0xFFFFFFFF,(SFORMAT*)0); -} - -static bool ReadStateChunks(std::istream* is, s32 totalsize) -{ - bool ret = true; - while(totalsize > 0) - { - uint32 size; - u32 t; - if(!read32le(&t,is)) { ret=false; break; } - if(t == 0xFFFFFFFF) goto done; - if(!read32le(&size,is)) { ret=false; break; } - switch(t) - { - case 1: if(!ReadStateChunk(is,SF_ARM9,size)) ret=false; break; - case 2: if(!ReadStateChunk(is,SF_ARM7,size)) ret=false; break; - case 3: if(!cp15_loadstate(is,size)) ret=false; break; - case 4: if(!ReadStateChunk(is,SF_MEM,size)) ret=false; break; - case 5: if(!ReadStateChunk(is,SF_NDS,size)) ret=false; break; - case 51: if(!nds_loadstate(is,size)) ret=false; break; - case 60: if(!ReadStateChunk(is,SF_MMU,size)) ret=false; break; - case 61: if(!mmu_loadstate(is,size)) ret=false; break; - case 7: if(!gpu_loadstate(is,size)) ret=false; break; - case 8: if(!spu_loadstate(is,size)) ret=false; break; - case 90: if(!ReadStateChunk(is,SF_GFX3D,size)) ret=false; break; - case 91: if(!gfx3d_loadstate(is,size)) ret=false; break; - case 100: if(!ReadStateChunk(is,SF_MOVIE, size)) ret=false; break; - case 101: if(!mov_loadstate(is, size)) ret=false; break; - case 110: if(!ReadStateChunk(is,SF_WIFI,size)) ret=false; break; - case 120: if(!ReadStateChunk(is,SF_RTC,size)) ret=false; break; - default: - ret=false; - break; - } - if(!ret) - return false; - } -done: - - return ret; -} - -static void loadstate() -{ - // This should regenerate the vram banks - for (int i = 0; i < 0xA; i++) - _MMU_write08(0x04000240+i, _MMU_read08(0x04000240+i)); - - // This should regenerate the graphics power control register - _MMU_write16(0x04000304, _MMU_read16(0x04000304)); - - // This should regenerate the graphics configuration - //zero 27-jul-09 : was formerly up to 7F but that wrote to dispfifo which is dumb (one of nitsuja's desynch bugs [that he found, not caused]) - //so then i brought it down to 66 but this resulted in a conceptual bug with affine start registers, which shouldnt get regenerated - //so then i just made this exhaustive list - // for (int i = REG_BASE_DISPA; i<=REG_BASE_DISPA + 0x66; i+=2) - //_MMU_write16(i, _MMU_read16(i)); - // for (int i = REG_BASE_DISPB; i<=REG_BASE_DISPB + 0x7F; i+=2) - //_MMU_write16(i, _MMU_read16(i)); - static const u8 mainRegenAddr[] = {0x00,0x02,0x08,0x0a,0x0c,0x0e,0x40,0x42,0x44,0x46,0x48,0x4a,0x4c,0x50,0x52,0x54,0x64,0x66,0x6c}; - static const u8 subRegenAddr[] = {0x00,0x02,0x08,0x0a,0x0c,0x0e,0x40,0x42,0x44,0x46,0x48,0x4a,0x4c,0x50,0x52,0x54,0x6c}; - for(u32 i=0;i(REG_BASE_DISPA+mainRegenAddr[i], _MMU_read16(REG_BASE_DISPA+mainRegenAddr[i])); - for(u32 i=0;i(REG_BASE_DISPB+subRegenAddr[i], _MMU_read16(REG_BASE_DISPB+subRegenAddr[i])); - // no need to restore 0x60 since control and MMU.ARM9_REG are both in the savestates, and restoring it could mess up the ack bits anyway - - SetupMMU(nds.debugConsole); -} - -static bool savestate_load(std::istream* is) -{ - SAV_silent_fail_flag = false; - char header[16]; - is->read(header,16); - if(is->fail() || memcmp(header,magic,16)) - return false; - - u32 ssversion,dversion,len,comprlen; - if(!read32le(&ssversion,is)) return false; - if(!read32le(&dversion,is)) return false; - if(!read32le(&len,is)) return false; - if(!read32le(&comprlen,is)) return false; - - if(ssversion != SAVESTATE_VERSION) return false; - - std::vector buf(len); - - if(comprlen != 0xFFFFFFFF) { -#ifndef HAVE_LIBZ - //without libz, we can't decompress this savestate - return false; -#endif - std::vector cbuf(comprlen); - is->read(&cbuf[0],comprlen); - if(is->fail()) return false; - -#ifdef HAVE_LIBZ - uLongf uncomprlen = len; - int error = uncompress((uint8*)&buf[0],&uncomprlen,(uint8*)&cbuf[0],comprlen); - if(error != Z_OK || uncomprlen != len) - return false; -#endif - } else { - is->read((char*)&buf[0],len); - } - - //GO!! READ THE SAVESTATE - //THERE IS NO GOING BACK NOW - //reset the emulator first to clean out the host's state - - //while the series of resets below should work, - //we are testing the robustness of the savestate system with this full reset. - //the full reset wipes more things, so we can make sure that they are being restored correctly - extern bool _HACK_DONT_STOPMOVIE; - _HACK_DONT_STOPMOVIE = true; - NDS_Reset(); - _HACK_DONT_STOPMOVIE = false; - - //reset some options to their old defaults which werent saved - nds.debugConsole = FALSE; - - //GPU_Reset(MainScreen.gpu, 0); - //GPU_Reset(SubScreen.gpu, 1); - //gfx3d_reset(); - //gpu3D->NDS_3D_Reset(); - //SPU_Reset(); - - memorystream mstemp(&buf); - bool x = ReadStateChunks(&mstemp,(s32)len); - - if(!x && !SAV_silent_fail_flag) - { - printf("Error loading savestate. It failed halfway through;\nSince there is no savestate backup system, your current game session is wrecked"); -#ifdef _MSC_VER - //HACK! we really need a better way to handle this kind of feedback - MessageBox(0,"Error loading savestate. It failed halfway through;\nSince there is no savestate backup system, your current game session is wrecked",0,0); -#endif - return false; - } - - loadstate(); - - if((nds.debugConsole!=0) != CommonSettings.DebugConsole) { - printf("WARNING: forcing console debug mode to: debugmode=%s\n",nds.debugConsole?"TRUE":"FALSE"); - } - - return true; -} - -bool savestate_load(const char *file_name) -{ - std::ifstream f; - f.open(file_name,std::ios_base::binary|std::ios_base::in); - if(!f) return false; - - return savestate_load(&f); -} - -static std::stack rewindFreeList; -static std::vector rewindbuffer; - -int rewindstates = 16; -int rewindinterval = 4; - -void rewindsave () { - - if(currFrameCounter % rewindinterval) - return; - - //printf("rewindsave"); printf("%d%s", currFrameCounter, "\n"); - - - memorystream *ms; - if(!rewindFreeList.empty()) { - ms = rewindFreeList.top(); - rewindFreeList.pop(); - } else { - ms = new memorystream(); - } - - ms->getStreambuf().expand(1024*1024*12); - - if(!savestate_save(ms, Z_NO_COMPRESSION)) - return; - - ms->sync(); - - rewindbuffer.push_back(ms); - - if((int)rewindbuffer.size() > rewindstates) { - delete *rewindbuffer.begin(); - rewindbuffer.erase(rewindbuffer.begin()); - } -} - -void dorewind() -{ - - if(currFrameCounter % rewindinterval) - return; - - //printf("rewind\n"); - - nds.debugConsole = FALSE; - - int size = rewindbuffer.size(); - - if(size < 1) { - printf("rewind buffer empty\n"); - return; - } - - printf("%d", size); - - memorystream* loadms = rewindbuffer[size-1]; - loadms->seekg(32, std::ios::beg); - - ReadStateChunks(loadms,loadms->size()-32); - loadstate(); - - if(rewindbuffer.size()>1) - { - rewindFreeList.push(loadms); - rewindbuffer.pop_back(); - } - -} +/* Copyright (C) 2006 Normmatt + Copyright (C) 2006 Theo Berkau + Copyright (C) 2007 Pascal Giard + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifdef HAVE_LIBZ +#include +#endif +#include +#include +#include +#include +#include +#include +#include "saves.h" +#include "MMU.h" +#include "NDSSystem.h" +#include "render3D.h" +#include "cp15.h" +#include "GPU_osd.h" +#include "version.h" + +#include "memorystream.h" +#include "readwrite.h" +#include "gfx3d.h" +#include "movie.h" + +#include "path.h" + +#ifdef _MSC_VER +#include "windows/main.h" +#endif + +int lastSaveState = 0; //Keeps track of last savestate used for quick save/load functions + +//void*v is actually a void** which will be indirected before reading +//since this isnt supported right now, it is declared in here to make things compile +#define SS_INDIRECT 0x80000000 + +savestates_t savestates[NB_STATES]; + +#define SAVESTATE_VERSION 11 +static const char* magic = "DeSmuME SState\0"; + +//a savestate chunk loader can set this if it wants to permit a silent failure (for compatibility) +static bool SAV_silent_fail_flag; + +#ifndef MAX_PATH +#define MAX_PATH 256 +#endif + + +SFORMAT SF_ARM7[]={ + { "7INS", 4, 1, &NDS_ARM7.instruction }, + { "7INA", 4, 1, &NDS_ARM7.instruct_adr }, + { "7INN", 4, 1, &NDS_ARM7.next_instruction }, + { "7REG", 4,16, NDS_ARM7.R }, + { "7CPS", 4, 1, &NDS_ARM7.CPSR }, + { "7SPS", 4, 1, &NDS_ARM7.SPSR }, + { "7DUS", 4, 1, &NDS_ARM7.R13_usr }, + { "7EUS", 4, 1, &NDS_ARM7.R14_usr }, + { "7DSV", 4, 1, &NDS_ARM7.R13_svc }, + { "7ESV", 4, 1, &NDS_ARM7.R14_svc }, + { "7DAB", 4, 1, &NDS_ARM7.R13_abt }, + { "7EAB", 4, 1, &NDS_ARM7.R14_abt }, + { "7DUN", 4, 1, &NDS_ARM7.R13_und }, + { "7EUN", 4, 1, &NDS_ARM7.R14_und }, + { "7DIR", 4, 1, &NDS_ARM7.R13_irq }, + { "7EIR", 4, 1, &NDS_ARM7.R14_irq }, + { "78FI", 4, 1, &NDS_ARM7.R8_fiq }, + { "79FI", 4, 1, &NDS_ARM7.R9_fiq }, + { "7AFI", 4, 1, &NDS_ARM7.R10_fiq }, + { "7BFI", 4, 1, &NDS_ARM7.R11_fiq }, + { "7CFI", 4, 1, &NDS_ARM7.R12_fiq }, + { "7DFI", 4, 1, &NDS_ARM7.R13_fiq }, + { "7EFI", 4, 1, &NDS_ARM7.R14_fiq }, + { "7SVC", 4, 1, &NDS_ARM7.SPSR_svc }, + { "7ABT", 4, 1, &NDS_ARM7.SPSR_abt }, + { "7UND", 4, 1, &NDS_ARM7.SPSR_und }, + { "7IRQ", 4, 1, &NDS_ARM7.SPSR_irq }, + { "7FIQ", 4, 1, &NDS_ARM7.SPSR_fiq }, + { "7int", 4, 1, &NDS_ARM7.intVector }, + { "7LDT", 1, 1, &NDS_ARM7.LDTBit }, + { "7Wai", 4, 1, &NDS_ARM7.waitIRQ }, + { "7wIR", 4, 1, &NDS_ARM7.wIRQ, }, + { "7wir", 4, 1, &NDS_ARM7.wirq, }, + { "7NIF", 4, 1, &NDS_ARM7.newIrqFlags}, + { 0 } +}; + +SFORMAT SF_ARM9[]={ + { "9INS", 4, 1, &NDS_ARM9.instruction}, + { "9INA", 4, 1, &NDS_ARM9.instruct_adr}, + { "9INN", 4, 1, &NDS_ARM9.next_instruction}, + { "9REG", 4,16, NDS_ARM9.R}, + { "9CPS", 4, 1, &NDS_ARM9.CPSR}, + { "9SPS", 4, 1, &NDS_ARM9.SPSR}, + { "9DUS", 4, 1, &NDS_ARM9.R13_usr}, + { "9EUS", 4, 1, &NDS_ARM9.R14_usr}, + { "9DSV", 4, 1, &NDS_ARM9.R13_svc}, + { "9ESV", 4, 1, &NDS_ARM9.R14_svc}, + { "9DAB", 4, 1, &NDS_ARM9.R13_abt}, + { "9EAB", 4, 1, &NDS_ARM9.R14_abt}, + { "9DUN", 4, 1, &NDS_ARM9.R13_und}, + { "9EUN", 4, 1, &NDS_ARM9.R14_und}, + { "9DIR", 4, 1, &NDS_ARM9.R13_irq}, + { "9EIR", 4, 1, &NDS_ARM9.R14_irq}, + { "98FI", 4, 1, &NDS_ARM9.R8_fiq}, + { "99FI", 4, 1, &NDS_ARM9.R9_fiq}, + { "9AFI", 4, 1, &NDS_ARM9.R10_fiq}, + { "9BFI", 4, 1, &NDS_ARM9.R11_fiq}, + { "9CFI", 4, 1, &NDS_ARM9.R12_fiq}, + { "9DFI", 4, 1, &NDS_ARM9.R13_fiq}, + { "9EFI", 4, 1, &NDS_ARM9.R14_fiq}, + { "9SVC", 4, 1, &NDS_ARM9.SPSR_svc}, + { "9ABT", 4, 1, &NDS_ARM9.SPSR_abt}, + { "9UND", 4, 1, &NDS_ARM9.SPSR_und}, + { "9IRQ", 4, 1, &NDS_ARM9.SPSR_irq}, + { "9FIQ", 4, 1, &NDS_ARM9.SPSR_fiq}, + { "9int", 4, 1, &NDS_ARM9.intVector}, + { "9LDT", 1, 1, &NDS_ARM9.LDTBit}, + { "9Wai", 4, 1, &NDS_ARM9.waitIRQ}, + { "9wIR", 4, 1, &NDS_ARM9.wIRQ}, + { "9wir", 4, 1, &NDS_ARM9.wirq}, + { "9NIF", 4, 1, &NDS_ARM9.newIrqFlags}, + { 0 } +}; + +SFORMAT SF_MEM[]={ + { "ITCM", 1, sizeof(ARM9Mem.ARM9_ITCM), ARM9Mem.ARM9_ITCM}, + { "DTCM", 1, sizeof(ARM9Mem.ARM9_DTCM), ARM9Mem.ARM9_DTCM}, + + //for legacy purposes, WRAX is a separate variable. shouldnt be a problem. + { "WRAM", 1, 0x400000, ARM9Mem.MAIN_MEM}, + { "WRAX", 1, 0x400000, ARM9Mem.MAIN_MEM+0x400000}, + + //NOTE - this is not as large as the allocated memory. + //the memory is overlarge due to the way our memory map system is setup + //but there are actually no more registers than this + { "9REG", 1, 0x2000, ARM9Mem.ARM9_REG}, + + { "VMEM", 1, sizeof(ARM9Mem.ARM9_VMEM), ARM9Mem.ARM9_VMEM}, + { "OAMS", 1, sizeof(ARM9Mem.ARM9_OAM), ARM9Mem.ARM9_OAM}, + + //this size is specially chosen to avoid saving the blank space at the end + { "LCDM", 1, 0xA4000, ARM9Mem.ARM9_LCD}, + { 0 } +}; + +SFORMAT SF_NDS[]={ + { "_9CY", 4, 1, &nds.ARM9Cycle}, + { "_7CY", 4, 1, &nds.ARM7Cycle}, + { "_CYC", 4, 1, &nds.cycles}, + { "_WCY", 4, 1, &nds.wifiCycle}, + { "_TCY", 4, 8, nds.timerCycle}, + { "_TOV", 4, 8, nds.timerOver}, + { "_NHB", 4, 1, &nds.nextHBlank}, + { "_VCT", 4, 1, &nds.VCount}, + { "_OLD", 4, 1, &nds.old}, + { "_DIF", 4, 1, &nds.diff}, + { "_LIG", 4, 1, &nds.lignerendu}, + { "_TPX", 2, 1, &nds.touchX}, + { "_TPY", 2, 1, &nds.touchY}, + { "_TPB", 4, 1, &nds.isTouch}, + { "_DBG", 4, 1, &nds.debugConsole}, + { 0 } +}; + +extern u32 DMASrc[2][4]; +extern u32 DMADst[2][4]; + +SFORMAT SF_MMU[]={ + { "M7BI", 1, sizeof(MMU.ARM7_BIOS), MMU.ARM7_BIOS}, + { "M7ER", 1, sizeof(MMU.ARM7_ERAM), MMU.ARM7_ERAM}, + { "M7RG", 1, sizeof(MMU.ARM7_REG), MMU.ARM7_REG}, + { "M7WI", 1, sizeof(MMU.ARM7_WIRAM), MMU.ARM7_WIRAM}, + { "MSWI", 1, sizeof(MMU.SWIRAM), MMU.SWIRAM}, + { "MCRA", 1, sizeof(MMU.CART_RAM), MMU.CART_RAM}, + { "M9RW", 1, 1, &MMU.ARM9_RW_MODE}, + { "MDTC", 4, 1, &MMU.DTCMRegion}, + { "MITC", 4, 1, &MMU.ITCMRegion}, + { "MTIM", 2, 8, MMU.timer}, + { "MTMO", 4, 8, MMU.timerMODE}, + { "MTON", 4, 8, MMU.timerON}, + { "MTRN", 4, 8, MMU.timerRUN}, + { "MTRL", 2, 8, MMU.timerReload}, + { "MIME", 4, 2, MMU.reg_IME}, + { "MIE_", 4, 2, MMU.reg_IE}, + { "MIF_", 4, 2, MMU.reg_IF}, + + { "M_SX", 1, 2, &MMU.SPI_CNT}, + { "M_SC", 1, 2, &MMU.SPI_CMD}, + { "MASX", 1, 2, &MMU.AUX_SPI_CNT}, + { "MASC", 1, 2, &MMU.AUX_SPI_CMD}, + + { "MPAR", 4, 1, &partie}, + + { "MDST", 4, 8, MMU.DMAStartTime}, + { "MDCY", 4, 8, MMU.DMACycle}, + { "MDCR", 4, 8, MMU.DMACrt}, + { "MDMA", 4, 8, MMU.DMAing}, + { "MDSR", 4, 8, DMASrc}, + { "MDDS", 4, 8, DMADst}, + + { "MDV1", 4, 1, &MMU.divRunning}, + { "MDV2", 8, 1, &MMU.divResult}, + { "MDV3", 8, 1, &MMU.divMod}, + { "MDV4", 4, 1, &MMU.divCnt}, + { "MDV5", 4, 1, &MMU.divCycles}, + + { "MSQ1", 4, 1, &MMU.sqrtRunning}, + { "MSQ2", 4, 1, &MMU.sqrtResult}, + { "MSQ3", 4, 1, &MMU.sqrtCnt}, + { "MSQ4", 4, 1, &MMU.sqrtCycles}, + + //begin memory chips + { "BUCO", 1, 1, &MMU.fw.com}, + { "BUAD", 4, 1, &MMU.fw.addr}, + { "BUAS", 1, 1, &MMU.fw.addr_shift}, + { "BUAZ", 1, 1, &MMU.fw.addr_size}, + { "BUWE", 4, 1, &MMU.fw.write_enable}, + { "BUWR", 4, 1, &MMU.fw.writeable_buffer}, + //end memory chips + + { "MC0A", 4, 1, &MMU.dscard[0].address}, + { "MC0T", 4, 1, &MMU.dscard[0].transfer_count}, + { "MC1A", 4, 1, &MMU.dscard[1].address}, + { "MC1T", 4, 1, &MMU.dscard[1].transfer_count}, + { "MCHT", 4, 1, &MMU.CheckTimers}, + { "MCHD", 4, 1, &MMU.CheckDMAs}, + + //fifos + { "F0TL", 1, 1, &ipc_fifo[0].tail}, + { "F0BF", 4, 16, ipc_fifo[0].buf}, + { "F1TL", 1, 1, &ipc_fifo[1].tail}, + { "F1BF", 4, 16, ipc_fifo[1].buf}, + + { "FDHD", 4, 1, &disp_fifo.head}, + { "FDTL", 4, 1, &disp_fifo.tail}, + { "FDBF", 4, 0x6000, disp_fifo.buf}, + + { 0 } +}; + +SFORMAT SF_MOVIE[]={ + { "FRAC", 4, 1, &currFrameCounter}, + { "LAGC", 4, 1, &TotalLagFrames}, + { 0 } +}; + +static void mmu_savestate(std::ostream* os) +{ + //version + write32le(2,os); + + //newer savefile system: + MMU_new.backupDevice.save_state(os); +} + +SFORMAT SF_WIFI[]={ + { "W000", 4, 1, &wifiMac.powerOn}, + { "W010", 4, 1, &wifiMac.powerOnPending}, + + { "W020", 2, 1, &wifiMac.rfStatus}, + { "W030", 2, 1, &wifiMac.rfPins}, + + { "W040", 2, 1, &wifiMac.IE.val}, + { "W050", 2, 1, &wifiMac.IF.val}, + + { "W060", 2, 1, &wifiMac.macMode}, + { "W070", 2, 1, &wifiMac.wepMode}, + { "W080", 4, 1, &wifiMac.WEP_enable}, + + { "W090", 2, 3, &wifiMac.TXSlot[0]}, + { "W100", 2, 1, &wifiMac.TXCnt}, + { "W110", 2, 1, &wifiMac.TXOpt}, + { "W120", 2, 1, &wifiMac.TXStat}, + { "W130", 2, 1, &wifiMac.BEACONSlot}, + { "W140", 4, 1, &wifiMac.BEACON_enable}, + { "W150", 1, 1, &wifiMac.txCurSlot}, + { "W160", 1, 3, &wifiMac.txSlotBusy[0]}, + { "W170", 4, 3, &wifiMac.txSlotAddr[0]}, + { "W180", 4, 3, &wifiMac.txSlotLen[0]}, + { "W190", 4, 3, &wifiMac.txSlotRemainingBytes[0]}, + + { "W200", 2, 1, &wifiMac.RXCnt}, + { "W210", 2, 1, &wifiMac.RXCheckCounter}, + + { "W220", 1, 6, &wifiMac.mac.bytes}, + { "W230", 1, 6, &wifiMac.bss.bytes}, + + { "W240", 2, 1, &wifiMac.aid}, + { "W250", 2, 1, &wifiMac.pid}, + { "W260", 2, 1, &wifiMac.retryLimit}, + + { "W270", 4, 1, &wifiMac.crystalEnabled}, + { "W280", 8, 1, &wifiMac.usec}, + { "W290", 4, 1, &wifiMac.usecEnable}, + { "W300", 8, 1, &wifiMac.ucmp}, + { "W310", 4, 1, &wifiMac.ucmpEnable}, + { "W320", 2, 1, &wifiMac.eCount}, + { "W330", 4, 1, &wifiMac.eCountEnable}, + + { "WR00", 4, 1, &wifiMac.RF.CFG1.val}, + { "WR01", 4, 1, &wifiMac.RF.IFPLL1.val}, + { "WR02", 4, 1, &wifiMac.RF.IFPLL2.val}, + { "WR03", 4, 1, &wifiMac.RF.IFPLL3.val}, + { "WR04", 4, 1, &wifiMac.RF.RFPLL1.val}, + { "WR05", 4, 1, &wifiMac.RF.RFPLL2.val}, + { "WR06", 4, 1, &wifiMac.RF.RFPLL3.val}, + { "WR07", 4, 1, &wifiMac.RF.RFPLL4.val}, + { "WR08", 4, 1, &wifiMac.RF.CAL1.val}, + { "WR09", 4, 1, &wifiMac.RF.TXRX1.val}, + { "WR10", 4, 1, &wifiMac.RF.PCNT1.val}, + { "WR11", 4, 1, &wifiMac.RF.PCNT2.val}, + { "WR12", 4, 1, &wifiMac.RF.VCOT1.val}, + + { "W340", 1, 105, &wifiMac.BB.data[0]}, + + { "W350", 2, 1, &wifiMac.rfIOCnt.val}, + { "W360", 2, 1, &wifiMac.rfIOStatus.val}, + { "W370", 4, 1, &wifiMac.rfIOData.val}, + { "W380", 2, 1, &wifiMac.bbIOCnt.val}, + + { "W390", 1, 1, &wifiMac.bbDataToWrite}, + + { "W400", 2, 0x1000, &wifiMac.circularBuffer[0]}, + { "W410", 2, 1, &wifiMac.RXRangeBegin}, + { "W420", 2, 1, &wifiMac.RXRangeEnd}, + { "W430", 2, 1, &wifiMac.RXHWWriteCursor}, + { "W440", 2, 1, &wifiMac.RXHWWriteCursorReg}, + { "W450", 2, 1, &wifiMac.RXHWWriteCursorLatched}, + { "W460", 2, 1, &wifiMac.RXReadCursor}, + { "W470", 2, 1, &wifiMac.RXUnits}, + { "W480", 2, 1, &wifiMac.RXBufCount}, + { "W490", 2, 1, &wifiMac.CircBufReadAddress}, + { "W500", 2, 1, &wifiMac.CircBufWriteAddress}, + { "W510", 2, 1, &wifiMac.CircBufRdEnd}, + { "W520", 2, 1, &wifiMac.CircBufRdSkip}, + { "W530", 2, 1, &wifiMac.CircBufWrEnd}, + { "W540", 2, 1, &wifiMac.CircBufWrSkip}, + + { "W540", 4, 1, &wifiMac.curPacketSize[0]}, + { "W550", 4, 1, &wifiMac.curPacketPos[0]}, + { "W560", 4, 1, &wifiMac.curPacketSending[0]}, + + { "W570", 2, 0x800, &wifiMac.ioMem[0]}, + { "W580", 2, 1, &wifiMac.randomSeed}, + + { "WX00", 8, 1, &wifiMac.SoftAP.usecCounter}, + { "WX10", 1, 4096, &wifiMac.SoftAP.curPacket[0]}, + { "WX20", 4, 1, &wifiMac.SoftAP.curPacketSize}, + { "WX30", 4, 1, &wifiMac.SoftAP.curPacketPos}, + { "WX40", 4, 1, &wifiMac.SoftAP.curPacketSending}, + + { 0 } +}; + +static bool mmu_loadstate(std::istream* is, int size) +{ + //read version + int version; + if(read32le(&version,is) != 1) return false; + + if(version == 0 || version == 1) + { + u32 bupmem_size; + u32 addr_size; + + if(version == 0) + { + //version 0 was buggy and didnt save the type. + //it would silently fail if there was a size mismatch + SAV_silent_fail_flag = true; + if(read32le(&bupmem_size,is) != 1) return false; + //if(bupmem_size != MMU.bupmem.size) return false; //mismatch between current initialized and saved size + addr_size = BackupDevice::addr_size_for_old_save_size(bupmem_size); + } + else if(version == 1) + { + //version 1 reinitializes the save system with the type that was saved + int bupmem_type; + if(read32le(&bupmem_type,is) != 1) return false; + if(read32le(&bupmem_size,is) != 1) return false; + addr_size = BackupDevice::addr_size_for_old_save_type(bupmem_type); + if(addr_size == 0xFFFFFFFF) + addr_size = BackupDevice::addr_size_for_old_save_size(bupmem_size); + } + + if(addr_size == 0xFFFFFFFF) + return false; + + u8* temp = new u8[bupmem_size]; + is->read((char*)temp,bupmem_size); + MMU_new.backupDevice.load_old_state(addr_size,temp,bupmem_size); + delete[] temp; + if(is->fail()) return false; + } + else if(version == 2) + { + //newer savefile system: + MMU_new.backupDevice.load_state(is); + } + + return true; +} + +static void cp15_saveone(armcp15_t *cp15, std::ostream* os) +{ + write32le(cp15->IDCode,os); + write32le(cp15->cacheType,os); + write32le(cp15->TCMSize,os); + write32le(cp15->ctrl,os); + write32le(cp15->DCConfig,os); + write32le(cp15->ICConfig,os); + write32le(cp15->writeBuffCtrl,os); + write32le(cp15->und,os); + write32le(cp15->DaccessPerm,os); + write32le(cp15->IaccessPerm,os); + write32le(cp15->protectBaseSize0,os); + write32le(cp15->protectBaseSize1,os); + write32le(cp15->protectBaseSize2,os); + write32le(cp15->protectBaseSize3,os); + write32le(cp15->protectBaseSize4,os); + write32le(cp15->protectBaseSize5,os); + write32le(cp15->protectBaseSize6,os); + write32le(cp15->protectBaseSize7,os); + write32le(cp15->cacheOp,os); + write32le(cp15->DcacheLock,os); + write32le(cp15->IcacheLock,os); + write32le(cp15->ITCMRegion,os); + write32le(cp15->DTCMRegion,os); + write32le(cp15->processID,os); + write32le(cp15->RAM_TAG,os); + write32le(cp15->testState,os); + write32le(cp15->cacheDbg,os); + for(int i=0;i<8;i++) write32le(cp15->regionWriteMask_USR[i],os); + for(int i=0;i<8;i++) write32le(cp15->regionWriteMask_SYS[i],os); + for(int i=0;i<8;i++) write32le(cp15->regionReadMask_USR[i],os); + for(int i=0;i<8;i++) write32le(cp15->regionReadMask_SYS[i],os); + for(int i=0;i<8;i++) write32le(cp15->regionExecuteMask_USR[i],os); + for(int i=0;i<8;i++) write32le(cp15->regionExecuteMask_SYS[i],os); + for(int i=0;i<8;i++) write32le(cp15->regionWriteSet_USR[i],os); + for(int i=0;i<8;i++) write32le(cp15->regionWriteSet_SYS[i],os); + for(int i=0;i<8;i++) write32le(cp15->regionReadSet_USR[i],os); + for(int i=0;i<8;i++) write32le(cp15->regionReadSet_SYS[i],os); + for(int i=0;i<8;i++) write32le(cp15->regionExecuteSet_USR[i],os); + for(int i=0;i<8;i++) write32le(cp15->regionExecuteSet_SYS[i],os); +} + +static void cp15_savestate(std::ostream* os) +{ + //version + write32le(0,os); + + cp15_saveone((armcp15_t *)NDS_ARM9.coproc[15],os); + cp15_saveone((armcp15_t *)NDS_ARM7.coproc[15],os); +} + +static bool cp15_loadone(armcp15_t *cp15, std::istream* is) +{ + if(!read32le(&cp15->IDCode,is)) return false; + if(!read32le(&cp15->cacheType,is)) return false; + if(!read32le(&cp15->TCMSize,is)) return false; + if(!read32le(&cp15->ctrl,is)) return false; + if(!read32le(&cp15->DCConfig,is)) return false; + if(!read32le(&cp15->ICConfig,is)) return false; + if(!read32le(&cp15->writeBuffCtrl,is)) return false; + if(!read32le(&cp15->und,is)) return false; + if(!read32le(&cp15->DaccessPerm,is)) return false; + if(!read32le(&cp15->IaccessPerm,is)) return false; + if(!read32le(&cp15->protectBaseSize0,is)) return false; + if(!read32le(&cp15->protectBaseSize1,is)) return false; + if(!read32le(&cp15->protectBaseSize2,is)) return false; + if(!read32le(&cp15->protectBaseSize3,is)) return false; + if(!read32le(&cp15->protectBaseSize4,is)) return false; + if(!read32le(&cp15->protectBaseSize5,is)) return false; + if(!read32le(&cp15->protectBaseSize6,is)) return false; + if(!read32le(&cp15->protectBaseSize7,is)) return false; + if(!read32le(&cp15->cacheOp,is)) return false; + if(!read32le(&cp15->DcacheLock,is)) return false; + if(!read32le(&cp15->IcacheLock,is)) return false; + if(!read32le(&cp15->ITCMRegion,is)) return false; + if(!read32le(&cp15->DTCMRegion,is)) return false; + if(!read32le(&cp15->processID,is)) return false; + if(!read32le(&cp15->RAM_TAG,is)) return false; + if(!read32le(&cp15->testState,is)) return false; + if(!read32le(&cp15->cacheDbg,is)) return false; + for(int i=0;i<8;i++) if(!read32le(&cp15->regionWriteMask_USR[i],is)) return false; + for(int i=0;i<8;i++) if(!read32le(&cp15->regionWriteMask_SYS[i],is)) return false; + for(int i=0;i<8;i++) if(!read32le(&cp15->regionReadMask_USR[i],is)) return false; + for(int i=0;i<8;i++) if(!read32le(&cp15->regionReadMask_SYS[i],is)) return false; + for(int i=0;i<8;i++) if(!read32le(&cp15->regionExecuteMask_USR[i],is)) return false; + for(int i=0;i<8;i++) if(!read32le(&cp15->regionExecuteMask_SYS[i],is)) return false; + for(int i=0;i<8;i++) if(!read32le(&cp15->regionWriteSet_USR[i],is)) return false; + for(int i=0;i<8;i++) if(!read32le(&cp15->regionWriteSet_SYS[i],is)) return false; + for(int i=0;i<8;i++) if(!read32le(&cp15->regionReadSet_USR[i],is)) return false; + for(int i=0;i<8;i++) if(!read32le(&cp15->regionReadSet_SYS[i],is)) return false; + for(int i=0;i<8;i++) if(!read32le(&cp15->regionExecuteSet_USR[i],is)) return false; + for(int i=0;i<8;i++) if(!read32le(&cp15->regionExecuteSet_SYS[i],is)) return false; + + return true; +} + +static bool cp15_loadstate(std::istream* is, int size) +{ + //read version + int version; + if(read32le(&version,is) != 1) return false; + if(version != 0) return false; + + if(!cp15_loadone((armcp15_t *)NDS_ARM9.coproc[15],is)) return false; + if(!cp15_loadone((armcp15_t *)NDS_ARM7.coproc[15],is)) return false; + + return true; +} + + + +/* Format time and convert to string */ +static char * format_time(time_t cal_time) +{ + struct tm *time_struct; + static char str[64]; + + time_struct=localtime(&cal_time); + strftime(str, sizeof str, "%d-%b-%Y %H:%M:%S", time_struct); + + return(str); +} + +void clear_savestates() +{ + u8 i; + for( i = 0; i < NB_STATES; i++ ) + savestates[i].exists = FALSE; +} + +/* Scan for existing savestates and update struct */ +void scan_savestates() +{ + struct stat sbuf; + char filename[MAX_PATH+1]; + u8 i; + + clear_savestates(); + + for( i = 1; i <= NB_STATES; i++ ) + { + path.getpathnoext(path.STATES, filename); + + if (strlen(filename) + strlen(".dst") + strlen("-2147483648") /* = biggest string for i */ >MAX_PATH) return ; + sprintf(filename+strlen(filename), ".ds%d", i); + if( stat(filename,&sbuf) == -1 ) continue; + savestates[i-1].exists = TRUE; + strncpy(savestates[i-1].date, format_time(sbuf.st_mtime),40); + savestates[i-1].date[40-1] = '\0'; + } + + return ; +} + +void savestate_slot(int num) +{ + struct stat sbuf; + char filename[MAX_PATH+1]; + + if(num<0 || num>=NB_STATES) { + assert(false); + printf("wtf?? why would you do that.\n"); + } + + lastSaveState = num; //Set last savestate used + + path.getpathnoext(path.STATES, filename); + + if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ >MAX_PATH) return ; + sprintf(filename+strlen(filename), ".ds%d", num); + + if (savestate_save(filename)) + { + osd->setLineColor(255, 255, 255); + osd->addLine("Saved to %i slot", num); + } + else + { + osd->setLineColor(255, 0, 0); + osd->addLine("Error save to %i slot", num); + return; + } + + if (num >= 0 && num < NB_STATES) + { + if (stat(filename,&sbuf) != -1) + { + savestates[num].exists = TRUE; + strncpy(savestates[num].date, format_time(sbuf.st_mtime),40); + savestates[num].date[40-1] = '\0'; + } + } +} + +void loadstate_slot(int num) +{ + char filename[MAX_PATH]; + + lastSaveState = num; //Set last savestate used + + path.getpathnoext(path.STATES, filename); + + if (strlen(filename) + strlen(".dsx") + strlen("-2147483648") /* = biggest string for num */ >MAX_PATH) return ; + sprintf(filename+strlen(filename), ".ds%d", num); + if (savestate_load(filename)) + { + osd->setLineColor(255, 255, 255); + osd->addLine("Loaded from %i slot", num); + } + else + { + osd->setLineColor(255, 0, 0); + osd->addLine("Error from load %i slot", num); + } +} + +u8 sram_read (u32 address) { + address = address - SRAM_ADDRESS; + + if ( address > SRAM_SIZE ) + return 0; + + return MMU.CART_RAM[address]; + +} + +void sram_write (u32 address, u8 value) { + + address = address - SRAM_ADDRESS; + + if ( address < SRAM_SIZE ) + MMU.CART_RAM[address] = value; + +} + +int sram_load (const char *file_name) { + + FILE *file; + size_t elems_read; + + file = fopen ( file_name, "rb" ); + if( file == NULL ) + return 0; + + elems_read = fread ( MMU.CART_RAM, SRAM_SIZE, 1, file ); + + fclose ( file ); + + osd->setLineColor(255, 255, 255); + osd->addLine("Loaded SRAM"); + + return 1; + +} + +int sram_save (const char *file_name) { + + FILE *file; + size_t elems_written; + + file = fopen ( file_name, "wb" ); + if( file == NULL ) + return 0; + + elems_written = fwrite ( MMU.CART_RAM, SRAM_SIZE, 1, file ); + + fclose ( file ); + + osd->setLineColor(255, 255, 255); + osd->addLine("Saved SRAM"); + + return 1; + +} + +static const SFORMAT *CheckS(const SFORMAT *sf, u32 size, u32 count, char *desc) +{ + while(sf->v) + { + //NOT SUPPORTED RIGHT NOW + //if(sf->size==~0) // Link to another SFORMAT structure. + //{ + // SFORMAT *tmp; + // if((tmp= CheckS((SFORMAT *)sf->v, tsize, desc) )) + // return(tmp); + // sf++; + // continue; + //} + if(!memcmp(desc,sf->desc,4)) + { + if(sf->size != size || sf->count != count) + return 0; + return sf; + } + sf++; + } + return 0; +} + + +static bool ReadStateChunk(std::istream* is, const SFORMAT *sf, int size) +{ + const SFORMAT *tmp; + int temp = is->tellg(); + + while(is->tellg()read(toa,4); + if(is->fail()) + return false; + + if(!read32le(&sz,is)) return false; + if(!read32le(&count,is)) return false; + + if((tmp=CheckS(sf,sz,count,toa))) + { + if(sz == 1) { + //special case: read a huge byte array + is->read((char *)tmp->v,count); + } else { + for(unsigned int i=0;iread((char *)tmp->v + i*sz,sz); + + #ifndef LOCAL_LE + FlipByteOrder((u8*)tmp->v + i*sz,sz); + #endif + } + } + } + else + is->seekg(sz*count,std::ios::cur); + } // while(...) + return true; +} + + + +static int SubWrite(std::ostream* os, const SFORMAT *sf) +{ + uint32 acc=0; + + while(sf->v) + { + //not supported right now + //if(sf->size==~0) //Link to another struct + //{ + // uint32 tmp; + + // if(!(tmp=SubWrite(os,(SFORMAT *)sf->v))) + // return(0); + // acc+=tmp; + // sf++; + // continue; + //} + + int count = sf->count; + int size = sf->size; + + //add size of current node to the accumulator + acc += 4 + sizeof(sf->size) + sizeof(sf->count); + acc += count * size; + + if(os) //Are we writing or calculating the size of this block? + { + os->write(sf->desc,4); + write32le(sf->size,os); + write32le(sf->count,os); + + if(size == 1) { + //special case: write a huge byte array + os->write((char *)sf->v,count); + } else { + for(int i=0;iv + i*size, size); + #endif + + os->write((char*)sf->v + i*size,size); + + //Now restore the original byte order. + #ifndef LOCAL_LE + FlipByteOrder((u8*)sf->v + i*size, size); + #endif + } + } + } + sf++; + } + + return(acc); +} + +static int savestate_WriteChunk(std::ostream* os, int type, const SFORMAT *sf) +{ + write32le(type,os); + if(!sf) return 4; + int bsize = SubWrite((std::ostream*)0,sf); + write32le(bsize,os); + + if(!SubWrite(os,sf)) + { + return 8; + } + return (bsize+8); +} + +//TODO TODO TODO TODO TODO TODO TODO +// - this is retarded. why not write placeholders for size and then write directly to the stream +//and then go back and fill them in +static void savestate_WriteChunk(std::ostream* os, int type, void (*saveproc)(std::ostream* os)) +{ + //get the size + memorystream mstemp; + saveproc(&mstemp); + mstemp.flush(); + u32 size = mstemp.size(); + + //write the type, size, and data + write32le(type,os); + write32le(size,os); + os->write(mstemp.buf(),size); +} + +static void writechunks(std::ostream* os); + +static bool savestate_save(std::ostream* outstream, int compressionLevel) +{ + #ifndef HAVE_LIBZ + compressionLevel = Z_NO_COMPRESSION; + #endif + + memorystream ms; + std::ostream* os; + + if(compressionLevel != Z_NO_COMPRESSION) + { + //generate the savestate in memory first + os = (std::ostream*)&ms; + writechunks(os); + ms.flush(); + } + else + { + os = outstream; + os->seekp(32); //skip the header + writechunks(os); + } + + os->flush(); + + //save the length of the file + u32 len = os->tellp(); + + u32 comprlen = 0xFFFFFFFF; + u8* cbuf; + + //compress the data + int error = Z_OK; + if(compressionLevel != Z_NO_COMPRESSION) + { + cbuf = (u8*)ms.buf(); + uLongf comprlen2; + //worst case compression. + //zlib says "0.1% larger than sourceLen plus 12 bytes" + comprlen = (len>>9)+12 + len; + cbuf = new u8[comprlen]; + /* Workaround to make it compile under linux 64bit */ + comprlen2 = comprlen; + error = compress2(cbuf,&comprlen2,(u8*)ms.buf(),len,compressionLevel); + comprlen = (u32)comprlen2; + } + + //dump the header + outstream->seekp(0); + outstream->write(magic,16); + write32le(SAVESTATE_VERSION,outstream); + write32le(DESMUME_VERSION_NUMERIC,outstream); //desmume version + write32le(len,outstream); //uncompressed length + write32le(comprlen,outstream); //compressed length (-1 if it is not compressed) + outstream->flush(); + + if(compressionLevel != Z_NO_COMPRESSION) + { + outstream->write((char*)cbuf,comprlen==(u32)-1?len:comprlen); + delete[] cbuf; + } + + return error == Z_OK; +} + +bool savestate_save (const char *file_name) +{ + memorystream ms; + size_t elems_written; +#ifdef HAVE_LIBZ + if(!savestate_save(&ms, Z_DEFAULT_COMPRESSION)) +#else + if(!savestate_save(&ms, 0)) +#endif + return false; + ms.flush(); + FILE* file = fopen(file_name,"wb"); + if(file) + { + elems_written = fwrite(ms.buf(),1,ms.size(),file); + fclose(file); + return (elems_written == ms.size()); + } else return false; +} + +extern SFORMAT SF_RTC[]; + +static void writechunks(std::ostream* os) { + savestate_WriteChunk(os,1,SF_ARM9); + savestate_WriteChunk(os,2,SF_ARM7); + savestate_WriteChunk(os,3,cp15_savestate); + savestate_WriteChunk(os,4,SF_MEM); + savestate_WriteChunk(os,5,SF_NDS); + savestate_WriteChunk(os,60,SF_MMU); + savestate_WriteChunk(os,61,mmu_savestate); + savestate_WriteChunk(os,7,gpu_savestate); + savestate_WriteChunk(os,8,spu_savestate); + savestate_WriteChunk(os,90,SF_GFX3D); + savestate_WriteChunk(os,91,gfx3d_savestate); + savestate_WriteChunk(os,100,SF_MOVIE); + savestate_WriteChunk(os,101,mov_savestate); + savestate_WriteChunk(os,110,SF_WIFI); + savestate_WriteChunk(os,120,SF_RTC); + savestate_WriteChunk(os,0xFFFFFFFF,(SFORMAT*)0); +} + +static bool ReadStateChunks(std::istream* is, s32 totalsize) +{ + bool ret = true; + while(totalsize > 0) + { + uint32 size; + u32 t; + if(!read32le(&t,is)) { ret=false; break; } + if(t == 0xFFFFFFFF) goto done; + if(!read32le(&size,is)) { ret=false; break; } + switch(t) + { + case 1: if(!ReadStateChunk(is,SF_ARM9,size)) ret=false; break; + case 2: if(!ReadStateChunk(is,SF_ARM7,size)) ret=false; break; + case 3: if(!cp15_loadstate(is,size)) ret=false; break; + case 4: if(!ReadStateChunk(is,SF_MEM,size)) ret=false; break; + case 5: if(!ReadStateChunk(is,SF_NDS,size)) ret=false; break; + case 60: if(!ReadStateChunk(is,SF_MMU,size)) ret=false; break; + case 61: if(!mmu_loadstate(is,size)) ret=false; break; + case 7: if(!gpu_loadstate(is,size)) ret=false; break; + case 8: if(!spu_loadstate(is,size)) ret=false; break; + case 90: if(!ReadStateChunk(is,SF_GFX3D,size)) ret=false; break; + case 91: if(!gfx3d_loadstate(is,size)) ret=false; break; + case 100: if(!ReadStateChunk(is,SF_MOVIE, size)) ret=false; break; + case 101: if(!mov_loadstate(is, size)) ret=false; break; + case 110: if(!ReadStateChunk(is,SF_WIFI,size)) ret=false; break; + case 120: if(!ReadStateChunk(is,SF_RTC,size)) ret=false; break; + default: + ret=false; + break; + } + if(!ret) return false; + } +done: + + return ret; +} + +static void loadstate() +{ + // This should regenerate the vram banks + for (int i = 0; i < 0xA; i++) + _MMU_write08(0x04000240+i, _MMU_read08(0x04000240+i)); + + // This should regenerate the graphics power control register + _MMU_write16(0x04000304, _MMU_read16(0x04000304)); + + // This should regenerate the graphics configuration + //zero 27-jul-09 : was formerly up to 7F but that wrote to dispfifo which is dumb (one of nitsuja's desynch bugs [that he found, not caused]) + for (int i = REG_BASE_DISPA; i<=REG_BASE_DISPA + 0x66; i+=2) + _MMU_write16(i, _MMU_read16(i)); + for (int i = REG_BASE_DISPB; i<=REG_BASE_DISPB + 0x7F; i+=2) + _MMU_write16(i, _MMU_read16(i)); + + SetupMMU(nds.debugConsole); +} + +static bool savestate_load(std::istream* is) +{ + SAV_silent_fail_flag = false; + char header[16]; + is->read(header,16); + if(is->fail() || memcmp(header,magic,16)) + return false; + + u32 ssversion,dversion,len,comprlen; + if(!read32le(&ssversion,is)) return false; + if(!read32le(&dversion,is)) return false; + if(!read32le(&len,is)) return false; + if(!read32le(&comprlen,is)) return false; + + if(ssversion != SAVESTATE_VERSION) return false; + + std::vector buf(len); + + if(comprlen != 0xFFFFFFFF) { +#ifndef HAVE_LIBZ + //without libz, we can't decompress this savestate + return false; +#endif + std::vector cbuf(comprlen); + is->read(&cbuf[0],comprlen); + if(is->fail()) return false; + +#ifdef HAVE_LIBZ + uLongf uncomprlen = len; + int error = uncompress((uint8*)&buf[0],&uncomprlen,(uint8*)&cbuf[0],comprlen); + if(error != Z_OK || uncomprlen != len) + return false; +#endif + } else { + is->read((char*)&buf[0],len); + } + + //GO!! READ THE SAVESTATE + //THERE IS NO GOING BACK NOW + //reset the emulator first to clean out the host's state + + //while the series of resets below should work, + //we are testing the robustness of the savestate system with this full reset. + //the full reset wipes more things, so we can make sure that they are being restored correctly + extern bool _HACK_DONT_STOPMOVIE; + _HACK_DONT_STOPMOVIE = true; + NDS_Reset(); + _HACK_DONT_STOPMOVIE = false; + + //reset some options to their old defaults which werent saved + nds.debugConsole = FALSE; + + //GPU_Reset(MainScreen.gpu, 0); + //GPU_Reset(SubScreen.gpu, 1); + //gfx3d_reset(); + //gpu3D->NDS_3D_Reset(); + //SPU_Reset(); + + memorystream mstemp(&buf); + bool x = ReadStateChunks(&mstemp,(s32)len); + + if(!x && !SAV_silent_fail_flag) + { + printf("Error loading savestate. It failed halfway through;\nSince there is no savestate backup system, your current game session is wrecked"); +#ifdef _MSC_VER + //HACK! we really need a better way to handle this kind of feedback + MessageBox(0,"Error loading savestate. It failed halfway through;\nSince there is no savestate backup system, your current game session is wrecked",0,0); +#endif + return false; + } + + loadstate(); + + if((nds.debugConsole!=0) != CommonSettings.DebugConsole) { + printf("WARNING: forcing console debug mode to: debugmode=%s\n",nds.debugConsole?"TRUE":"FALSE"); + } + + return true; +} + +bool savestate_load(const char *file_name) +{ + std::ifstream f; + f.open(file_name,std::ios_base::binary|std::ios_base::in); + if(!f) return false; + + return savestate_load(&f); +} + +static std::stack rewindFreeList; +static std::vector rewindbuffer; + +int rewindstates = 16; +int rewindinterval = 4; + +void rewindsave () { + + if(currFrameCounter % rewindinterval) + return; + + //printf("rewindsave"); printf("%d%s", currFrameCounter, "\n"); + + + memorystream *ms; + if(!rewindFreeList.empty()) { + ms = rewindFreeList.top(); + rewindFreeList.pop(); + } else { + ms = new memorystream(); + } + + ms->getStreambuf().expand(1024*1024*12); + + if(!savestate_save(ms, Z_NO_COMPRESSION)) + return; + + ms->sync(); + + rewindbuffer.push_back(ms); + + if(rewindbuffer.size() > rewindstates) { + delete *rewindbuffer.begin(); + rewindbuffer.erase(rewindbuffer.begin()); + } +} + +void dorewind() +{ + + if(currFrameCounter % rewindinterval) + return; + + //printf("rewind\n"); + + nds.debugConsole = FALSE; + + int size = rewindbuffer.size(); + + if(size < 1) { + printf("rewind buffer empty\n"); + return; + } + + printf("%d", size); + + memorystream* loadms = rewindbuffer[size-1]; + loadms->seekg(32, std::ios::beg); + + ReadStateChunks(loadms,loadms->size()-32); + loadstate(); + + if(rewindbuffer.size()>1) + { + rewindFreeList.push(loadms); + rewindbuffer.pop_back(); + } + +} \ No newline at end of file diff --git a/desmume/src/saves.h b/src/saves.h similarity index 96% rename from desmume/src/saves.h rename to src/saves.h index d9ae9d12d..4d5baed13 100644 --- a/desmume/src/saves.h +++ b/src/saves.h @@ -1,72 +1,69 @@ -/* Copyright (C) 2006 Normmatt - Copyright (C) 2007 Pascal Giard - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef _SRAM_H -#define _SRAM_H - -#include "types.h" - -#define SRAM_ADDRESS 0x0A000000 -#define SRAM_SIZE 0x10000 -#define NB_STATES 10 - -extern int lastSaveState; - -typedef struct -{ - BOOL exists; - char date[40]; -} savestates_t; - - -struct SFORMAT -{ - //a string description of the element - const char *desc; - - //the size of each element - u32 size; - - //the number of each element - u32 count; - - //a void* to the data or a void** to the data - void *v; -}; - -extern savestates_t savestates[NB_STATES]; - -void clear_savestates(); -void scan_savestates(); -u8 sram_read (u32 address); -void sram_write (u32 address, u8 value); -int sram_load (const char *file_name); -int sram_save (const char *file_name); - -bool savestate_load (const char *file_name); -bool savestate_save (const char *file_name); - -void savestate_slot(int num); -void loadstate_slot(int num); - -void dorewind(); -void rewindsave(); - -#endif +/* Copyright (C) 2006 Normmatt + Copyright (C) 2007 Pascal Giard + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef _SRAM_H +#define _SRAM_H + +#include "types.h" + +#define SRAM_ADDRESS 0x0A000000 +#define SRAM_SIZE 0x10000 +#define NB_STATES 10 + +extern int lastSaveState; + +typedef struct +{ + BOOL exists; + char date[40]; +} savestates_t; + + +struct SFORMAT +{ + //a string description of the element + const char *desc; + + //the size of each element + u32 size; + + //the number of each element + u32 count; + + //a void* to the data or a void** to the data + void *v; +}; + +extern savestates_t savestates[NB_STATES]; + +void clear_savestates(); +void scan_savestates(); +u8 sram_read (u32 address); +void sram_write (u32 address, u8 value); +int sram_load (const char *file_name); +int sram_save (const char *file_name); + +bool savestate_load (const char *file_name); +bool savestate_save (const char *file_name); + +void savestate_slot(int num); +void loadstate_slot(int num); + +#endif diff --git a/desmume/src/shaders.h b/src/shaders.h similarity index 96% rename from desmume/src/shaders.h rename to src/shaders.h index 4cd2cbf6e..89386fd99 100644 --- a/desmume/src/shaders.h +++ b/src/shaders.h @@ -1,78 +1,78 @@ -/* Predefined OpenGL shaders */ - -/* Vertex shader */ -const char *vertexShader = {"\ - void main() \n\ - { \n\ - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \n\ - gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; \n\ - gl_FrontColor = gl_Color; \n\ - } \n\ -"}; - -/* Fragment shader */ -const char *fragmentShader = {"\ - uniform sampler1D toonTable; \n\ - uniform sampler2D tex2d; \n\ - uniform int hasTexture; \n\ - uniform int texBlending; \n\ - \n\ - vec4 float_to_6bit(in vec4 color) \n\ - { \n\ - vec4 ret = color * vec4(31.0,31.0,31.0,31.0);\n\ - \n\ - if(ret.r > 0.0) ret.r = (ret.r * 2.0) + 1.0; \n\ - if(ret.g > 0.0) ret.g = (ret.g * 2.0) + 1.0; \n\ - if(ret.b > 0.0) ret.b = (ret.b * 2.0) + 1.0; \n\ - if(ret.a > 0.0) ret.a = (ret.a * 2.0) + 1.0; \n\ - \n\ - return ret; \n\ - } \n\ - \n\ - void main() \n\ - { \n\ - vec4 vtxColor = float_to_6bit(gl_Color); \n\ - vec4 texColor = float_to_6bit(texture2D(tex2d, gl_TexCoord[0].st)); \n\ - vec3 toonColor = vec3(float_to_6bit(vec4(texture1D(toonTable, gl_Color.r).rgb, 0.0))); \n\ - vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \n\ - \n\ - if(hasTexture == 0) \n\ - { \n\ - texColor = vec4(63.0, 63.0, 63.0, 63.0); \n\ - } \n\ - \n\ - if(texBlending == 0) \n\ - { \n\ - fragColor = ((texColor + 1.0) * (vtxColor + 1.0) - 1.0) / 64.0; \n\ - } \n\ - else if(texBlending == 1) \n\ - { \n\ - if(texColor.a == 0.0 || hasTexture == 0) \n\ - { \n\ - fragColor.rgb = vtxColor.rgb; \n\ - } \n\ - else if(texColor.a == 63.0) \n\ - { \n\ - fragColor.rgb = texColor.rgb; \n\ - } \n\ - else \n\ - { \n\ - fragColor.rgb = ((texColor.rgb * texColor.a) + (vtxColor.rgb * (63.0 - texColor.a))) / 64.0; \n\ - } \n\ - \n\ - fragColor.a = vtxColor.a; \n\ - } \n\ - else if(texBlending == 2) \n\ - { \n\ - fragColor.rgb = ((texColor.rgb + 1.0) * (toonColor + 1.0) - 1.0) / 64.0; \n\ - fragColor.a = ((texColor.a + 1.0) * (vtxColor.a + 1.0) - 1.0) / 64.0; \n\ - } \n\ - else if(texBlending == 3) \n\ - { \n\ - fragColor.rgb = min((((texColor.rgb + 1.0) * (toonColor + 1.0) - 1.0) / 64.0) + toonColor, 63.0); \n\ - fragColor.a = ((texColor.a + 1.0) * (vtxColor.a + 1.0) - 1.0) / 64.0; \n\ - } \n\ - \n\ - gl_FragColor = ((fragColor - 1.0) / 2.0) / 31.0; \n\ - } \n\ -"}; +/* Predefined OpenGL shaders */ + +/* Vertex shader */ +const char *vertexShader = {"\ + void main() \n\ + { \n\ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \n\ + gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; \n\ + gl_FrontColor = gl_Color; \n\ + } \n\ +"}; + +/* Fragment shader */ +const char *fragmentShader = {"\ + uniform sampler1D toonTable; \n\ + uniform sampler2D tex2d; \n\ + uniform int hasTexture; \n\ + uniform int texBlending; \n\ + \n\ + vec4 float_to_6bit(in vec4 color) \n\ + { \n\ + vec4 ret = color * vec4(31.0,31.0,31.0,31.0);\n\ + \n\ + if(ret.r > 0.0) ret.r = (ret.r * 2.0) + 1.0; \n\ + if(ret.g > 0.0) ret.g = (ret.g * 2.0) + 1.0; \n\ + if(ret.b > 0.0) ret.b = (ret.b * 2.0) + 1.0; \n\ + if(ret.a > 0.0) ret.a = (ret.a * 2.0) + 1.0; \n\ + \n\ + return ret; \n\ + } \n\ + \n\ + void main() \n\ + { \n\ + vec4 vtxColor = float_to_6bit(gl_Color); \n\ + vec4 texColor = float_to_6bit(texture2D(tex2d, gl_TexCoord[0].st)); \n\ + vec3 toonColor = vec3(float_to_6bit(vec4(texture1D(toonTable, gl_Color.r).rgb, 0.0))); \n\ + vec4 fragColor = vec4(0.0, 0.0, 0.0, 0.0); \n\ + \n\ + if(hasTexture == 0) \n\ + { \n\ + texColor = vec4(63.0, 63.0, 63.0, 63.0); \n\ + } \n\ + \n\ + if(texBlending == 0) \n\ + { \n\ + fragColor = ((texColor + 1.0) * (vtxColor + 1.0) - 1.0) / 64.0; \n\ + } \n\ + else if(texBlending == 1) \n\ + { \n\ + if(texColor.a == 0.0 || hasTexture == 0) \n\ + { \n\ + fragColor.rgb = vtxColor.rgb; \n\ + } \n\ + else if(texColor.a == 63.0) \n\ + { \n\ + fragColor.rgb = texColor.rgb; \n\ + } \n\ + else \n\ + { \n\ + fragColor.rgb = ((texColor.rgb * texColor.a) + (vtxColor.rgb * (63.0 - texColor.a))) / 64.0; \n\ + } \n\ + \n\ + fragColor.a = vtxColor.a; \n\ + } \n\ + else if(texBlending == 2) \n\ + { \n\ + fragColor.rgb = ((texColor.rgb + 1.0) * (toonColor + 1.0) - 1.0) / 64.0; \n\ + fragColor.a = ((texColor.a + 1.0) * (vtxColor.a + 1.0) - 1.0) / 64.0; \n\ + } \n\ + else if(texBlending == 3) \n\ + { \n\ + fragColor.rgb = min((((texColor.rgb + 1.0) * (toonColor + 1.0) - 1.0) / 64.0) + toonColor, 63.0); \n\ + fragColor.a = ((texColor.a + 1.0) * (vtxColor.a + 1.0) - 1.0) / 64.0; \n\ + } \n\ + \n\ + gl_FragColor = ((fragColor - 1.0) / 2.0) / 31.0; \n\ + } \n\ +"}; diff --git a/desmume/src/sndsdl.cpp b/src/sndsdl.cpp similarity index 96% rename from desmume/src/sndsdl.cpp rename to src/sndsdl.cpp index 4f2c8bd34..16ea300c5 100644 --- a/desmume/src/sndsdl.cpp +++ b/src/sndsdl.cpp @@ -1,189 +1,189 @@ -/* Copyright 2005-2006 Theo Berkau - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - Yabause is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Yabause; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include - -#include -#include "types.h" -#include "SPU.h" -#include "sndsdl.h" -#include "debug.h" - -int SNDSDLInit(int buffersize); -void SNDSDLDeInit(); -void SNDSDLUpdateAudio(s16 *buffer, u32 num_samples); -u32 SNDSDLGetAudioSpace(); -void SNDSDLMuteAudio(); -void SNDSDLUnMuteAudio(); -void SNDSDLSetVolume(int volume); - -SoundInterface_struct SNDSDL = { -SNDCORE_SDL, -"SDL Sound Interface", -SNDSDLInit, -SNDSDLDeInit, -SNDSDLUpdateAudio, -SNDSDLGetAudioSpace, -SNDSDLMuteAudio, -SNDSDLUnMuteAudio, -SNDSDLSetVolume -}; - -static u16 *stereodata16; -static u32 soundoffset; -static volatile u32 soundpos; -static u32 soundlen; -static u32 soundbufsize; -static SDL_AudioSpec audiofmt; - -////////////////////////////////////////////////////////////////////////////// - -static void MixAudio(void *userdata, Uint8 *stream, int len) { - int i; - Uint8 *soundbuf=(Uint8 *)stereodata16; - - for (i = 0; i < len; i++) - { - if (soundpos >= soundbufsize) - soundpos = 0; - - stream[i] = soundbuf[soundpos]; - soundpos++; - } -} - -////////////////////////////////////////////////////////////////////////////// - -int SNDSDLInit(int buffersize) -{ - if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) - return -1; - - audiofmt.freq = 44100; - audiofmt.format = AUDIO_S16SYS; - audiofmt.channels = 2; - audiofmt.samples = (audiofmt.freq / 60) * 2; - audiofmt.callback = MixAudio; - audiofmt.userdata = NULL; - - //samples should be a power of 2 according to SDL-doc - //so normalize it to the nearest power of 2 here - u32 normSamples = 512; - while (normSamples < audiofmt.samples) - normSamples <<= 1; - - audiofmt.samples = normSamples; - - soundlen = audiofmt.freq / 60; // 60 for NTSC - soundbufsize = buffersize * sizeof(s16) * 2; - - if (SDL_OpenAudio(&audiofmt, NULL) != 0) - { - return -1; - } - - if ((stereodata16 = (u16 *)malloc(soundbufsize)) == NULL) - return -1; - - memset(stereodata16, 0, soundbufsize); - - soundpos = 0; - - SDL_PauseAudio(0); - - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDSDLDeInit() -{ - SDL_CloseAudio(); - - if (stereodata16) - free(stereodata16); -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDSDLUpdateAudio(s16 *buffer, u32 num_samples) -{ - u32 copy1size=0, copy2size=0; - SDL_LockAudio(); - - if ((soundbufsize - soundoffset) < (num_samples * sizeof(s16) * 2)) - { - copy1size = (soundbufsize - soundoffset); - copy2size = (num_samples * sizeof(s16) * 2) - copy1size; - } - else - { - copy1size = (num_samples * sizeof(s16) * 2); - copy2size = 0; - } - - memcpy((((u8 *)stereodata16)+soundoffset), buffer, copy1size); -// ScspConvert32uto16s((s32 *)leftchanbuffer, (s32 *)rightchanbuffer, (s16 *)(((u8 *)stereodata16)+soundoffset), copy1size / sizeof(s16) / 2); - - if (copy2size) - memcpy(stereodata16, ((u8 *)buffer)+copy1size, copy2size); -// ScspConvert32uto16s((s32 *)leftchanbuffer, (s32 *)rightchanbuffer, (s16 *)stereodata16, copy2size / sizeof(s16) / 2); - - soundoffset += copy1size + copy2size; - soundoffset %= soundbufsize; - - SDL_UnlockAudio(); -} - -////////////////////////////////////////////////////////////////////////////// - -u32 SNDSDLGetAudioSpace() -{ - u32 freespace=0; - - if (soundoffset > soundpos) - freespace = soundbufsize - soundoffset + soundpos; - else - freespace = soundpos - soundoffset; - - return (freespace / sizeof(s16) / 2); -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDSDLMuteAudio() -{ - SDL_PauseAudio(1); -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDSDLUnMuteAudio() -{ - SDL_PauseAudio(0); -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDSDLSetVolume(int volume) -{ -} - -////////////////////////////////////////////////////////////////////////////// +/* Copyright 2005-2006 Theo Berkau + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + Yabause is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Yabause; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include + +#include +#include "types.h" +#include "SPU.h" +#include "sndsdl.h" +#include "debug.h" + +int SNDSDLInit(int buffersize); +void SNDSDLDeInit(); +void SNDSDLUpdateAudio(s16 *buffer, u32 num_samples); +u32 SNDSDLGetAudioSpace(); +void SNDSDLMuteAudio(); +void SNDSDLUnMuteAudio(); +void SNDSDLSetVolume(int volume); + +SoundInterface_struct SNDSDL = { +SNDCORE_SDL, +"SDL Sound Interface", +SNDSDLInit, +SNDSDLDeInit, +SNDSDLUpdateAudio, +SNDSDLGetAudioSpace, +SNDSDLMuteAudio, +SNDSDLUnMuteAudio, +SNDSDLSetVolume +}; + +static u16 *stereodata16; +static u32 soundoffset; +static volatile u32 soundpos; +static u32 soundlen; +static u32 soundbufsize; +static SDL_AudioSpec audiofmt; + +////////////////////////////////////////////////////////////////////////////// + +static void MixAudio(void *userdata, Uint8 *stream, int len) { + int i; + Uint8 *soundbuf=(Uint8 *)stereodata16; + + for (i = 0; i < len; i++) + { + if (soundpos >= soundbufsize) + soundpos = 0; + + stream[i] = soundbuf[soundpos]; + soundpos++; + } +} + +////////////////////////////////////////////////////////////////////////////// + +int SNDSDLInit(int buffersize) +{ + if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) + return -1; + + audiofmt.freq = 44100; + audiofmt.format = AUDIO_S16SYS; + audiofmt.channels = 2; + audiofmt.samples = (audiofmt.freq / 60) * 2; + audiofmt.callback = MixAudio; + audiofmt.userdata = NULL; + + //samples should be a power of 2 according to SDL-doc + //so normalize it to the nearest power of 2 here + u32 normSamples = 512; + while (normSamples < audiofmt.samples) + normSamples <<= 1; + + audiofmt.samples = normSamples; + + soundlen = audiofmt.freq / 60; // 60 for NTSC + soundbufsize = buffersize * sizeof(s16) * 2; + + if (SDL_OpenAudio(&audiofmt, NULL) != 0) + { + return -1; + } + + if ((stereodata16 = (u16 *)malloc(soundbufsize)) == NULL) + return -1; + + memset(stereodata16, 0, soundbufsize); + + soundpos = 0; + + SDL_PauseAudio(0); + + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDSDLDeInit() +{ + SDL_CloseAudio(); + + if (stereodata16) + free(stereodata16); +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDSDLUpdateAudio(s16 *buffer, u32 num_samples) +{ + u32 copy1size=0, copy2size=0; + SDL_LockAudio(); + + if ((soundbufsize - soundoffset) < (num_samples * sizeof(s16) * 2)) + { + copy1size = (soundbufsize - soundoffset); + copy2size = (num_samples * sizeof(s16) * 2) - copy1size; + } + else + { + copy1size = (num_samples * sizeof(s16) * 2); + copy2size = 0; + } + + memcpy((((u8 *)stereodata16)+soundoffset), buffer, copy1size); +// ScspConvert32uto16s((s32 *)leftchanbuffer, (s32 *)rightchanbuffer, (s16 *)(((u8 *)stereodata16)+soundoffset), copy1size / sizeof(s16) / 2); + + if (copy2size) + memcpy(stereodata16, ((u8 *)buffer)+copy1size, copy2size); +// ScspConvert32uto16s((s32 *)leftchanbuffer, (s32 *)rightchanbuffer, (s16 *)stereodata16, copy2size / sizeof(s16) / 2); + + soundoffset += copy1size + copy2size; + soundoffset %= soundbufsize; + + SDL_UnlockAudio(); +} + +////////////////////////////////////////////////////////////////////////////// + +u32 SNDSDLGetAudioSpace() +{ + u32 freespace=0; + + if (soundoffset > soundpos) + freespace = soundbufsize - soundoffset + soundpos; + else + freespace = soundpos - soundoffset; + + return (freespace / sizeof(s16) / 2); +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDSDLMuteAudio() +{ + SDL_PauseAudio(1); +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDSDLUnMuteAudio() +{ + SDL_PauseAudio(0); +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDSDLSetVolume(int volume) +{ +} + +////////////////////////////////////////////////////////////////////////////// diff --git a/desmume/src/sndsdl.h b/src/sndsdl.h similarity index 97% rename from desmume/src/sndsdl.h rename to src/sndsdl.h index 2561455b5..71288d9c3 100644 --- a/desmume/src/sndsdl.h +++ b/src/sndsdl.h @@ -1,26 +1,26 @@ -/* Copyright 2005-2006 Theo Berkau - - This file is part of DeSmuME. - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - Yabause is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Yabause; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef SNDSDL_H -#define SNDSDL_H - -#define SNDCORE_SDL 2 - -extern SoundInterface_struct SNDSDL; -#endif +/* Copyright 2005-2006 Theo Berkau + + This file is part of DeSmuME. + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + Yabause is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Yabause; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef SNDSDL_H +#define SNDSDL_H + +#define SNDCORE_SDL 2 + +extern SoundInterface_struct SNDSDL; +#endif diff --git a/desmume/src/texcache.cpp b/src/texcache.cpp similarity index 92% rename from desmume/src/texcache.cpp rename to src/texcache.cpp index 18af01ed2..ece81b4a0 100644 --- a/desmume/src/texcache.cpp +++ b/src/texcache.cpp @@ -1,653 +1,650 @@ -#include "texcache.h" - -#include -#include - -#include "bits.h" -#include "common.h" -#include "debug.h" -#include "gfx3d.h" -#include "NDSSystem.h" - -using std::min; -using std::max; - -//only dump this from ogl renderer. for now, softrasterizer creates things in an incompatible pixel format -//#define DEBUG_DUMP_TEXTURE - -//This class represents a number of regions of memory which should be viewed as contiguous -class MemSpan -{ -public: - static const int MAXSIZE = 8; - - MemSpan() - : numItems(0) - {} - - int numItems; - - struct Item { - u32 start; - u32 len; - u8* ptr; - u32 ofs; //offset within the memspan - } items[MAXSIZE]; - - int size; - - //this MemSpan shall be considered the first argument to a standard memcmp - //the length shall be as specified in this MemSpan, unless you specify otherwise - int memcmp(void* buf2, int size=-1) - { - if(size==-1) size = this->size; - size = min(this->size,size); - for(int i=0;isize; - size = min(this->size,size); - u8* bufptr = (u8*)buf; - int done = 0; - for(int i=0;isize; - size = min(this->size,size); - u16* bufptr = (u16*)buf; - int done = 0; - for(int i=0;i>17)&3; //slots will wrap around - curr.len = min(len,0x20000-curr.start); - curr.ofs = currofs; - len -= curr.len; - ofs += curr.len; - currofs += curr.len; - u8* ptr = MMU.texInfo.textureSlotAddr[slot]; - - if(ptr == MMU.blank_memory) { - PROGINFO("Tried to reference unmapped texture memory: slot %d\n",slot); - } - curr.ptr = ptr + curr.start; - } - return ret; -} - -//creates a MemSpan in texture palette memory -static MemSpan MemSpan_TexPalette(u32 ofs, u32 len) -{ - MemSpan ret; - ret.size = len; - u32 currofs = 0; - while(len) { - MemSpan::Item &curr = ret.items[ret.numItems++]; - curr.start = ofs&0x3FFF; - u32 slot = (ofs>>14)&7; //this masks to 8 slots, but there are really only 6 - if(slot>5) { - PROGINFO("Texture palette overruns texture memory. Wrapping at palette slot 0.\n"); - slot -= 5; - } - curr.len = min(len,0x4000-curr.start); - curr.ofs = currofs; - len -= curr.len; - ofs += curr.len; - //if(len != 0) - //here is an actual test case of bank spanning - currofs += curr.len; - u8* ptr = MMU.texInfo.texPalSlot[slot]; - - if(ptr == MMU.blank_memory) { - PROGINFO("Tried to reference unmapped texture palette memory: 16k slot #%d\n",slot); - } - curr.ptr = ptr + curr.start; - } - return ret; -} - -TextureCache *texcache; -u32 texcache_start; -u32 texcache_stop; -u8 *TexCache_texMAP = NULL; - - -#if defined (DEBUG_DUMP_TEXTURE) && defined (WIN32) -#define DO_DEBUG_DUMP_TEXTURE -static void DebugDumpTexture(int which) -{ - char fname[100]; - sprintf(fname,"c:\\dump\\%d.bmp", which); - - NDS_WriteBMP_32bppBuffer(texcache[which].sizeX,texcache[which].sizeY,TexCache_texMAP,fname); -} -#endif - - -static int lastTexture = -1; - -#define CONVERT(color,alpha) ((TEXFORMAT == TexFormat_32bpp)?(RGB15TO32(color,alpha)):RGB15TO6665(color,alpha)) - -template -void TexCache_SetTexture(u32 format, u32 texpal) -{ - //for each texformat, number of palette entries - const int palSizes[] = {0, 32, 4, 16, 256, 0, 8, 0}; - - //for each texformat, multiplier from numtexels to numbytes (fixed point 30.2) - const int texSizes[] = {0, 4, 1, 2, 4, 1, 4, 8}; - - //used to hold a copy of the palette specified for this texture - u16 pal[256]; - - u32 *dwdst = (u32*)TexCache_texMAP; - - u32 textureMode = (unsigned short)((format>>26)&0x07); - unsigned int sizeX=(8 << ((format>>20)&0x07)); - unsigned int sizeY=(8 << ((format>>23)&0x07)); - unsigned int imageSize = sizeX*sizeY; - - u8 *adr; - - u32 paletteAddress; - - switch (textureMode) - { - case TEXMODE_I2: - paletteAddress = texpal<<3; - break; - case TEXMODE_A3I5: //a3i5 - case TEXMODE_I4: //i4 - case TEXMODE_I8: //i8 - case TEXMODE_A5I3: //a5i3 - case TEXMODE_16BPP: //16bpp - case TEXMODE_4X4: //4x4 - default: - paletteAddress = texpal<<4; - break; - } - - //analyze the texture memory mapping and the specifications of this texture - int palSize = palSizes[textureMode]; - int texSize = (imageSize*texSizes[textureMode])>>2; //shifted because the texSizes multiplier is fixed point - MemSpan ms = MemSpan_TexMem((format&0xFFFF)<<3,texSize); - MemSpan mspal = MemSpan_TexPalette(paletteAddress,palSize*2); - - //determine the location for 4x4 index data - u32 indexBase; - if((format & 0xc000) == 0x8000) indexBase = 0x30000; - else indexBase = 0x20000; - - u32 indexOffset = (format&0x3FFF)<<2; - - int indexSize = 0; - MemSpan msIndex; - if(textureMode == TEXMODE_4X4) - { - indexSize = imageSize>>3; - msIndex = MemSpan_TexMem(indexOffset+indexBase,indexSize); - } - - - //dump the palette to a temp buffer, so that we don't have to worry about memory mapping. - //this isnt such a problem with texture memory, because we read sequentially from it. - //however, we read randomly from palette memory, so the mapping is more costly. -#ifdef WORDS_BIGENDIAN - mspal.dump16(pal); -#else - mspal.dump(pal); -#endif - - - u32 tx=texcache_start; - - //if(false) - while (TRUE) - { - //conditions where we give up and regenerate the texture: - if (texcache_stop == tx) break; - if (texcache[tx].frm == 0) break; - - //conditions where we reject matches: - //when the teximage or texpal params dont match - //(this is our key for identifying palettes in the cache) - if (texcache[tx].frm != format) goto REJECT; - if (texcache[tx].pal != texpal) goto REJECT; - - //the texture matches params, but isnt suspected invalid. accept it. - if (!texcache[tx].suspectedInvalid) goto ACCEPT; - - //if we couldnt cache this entire texture due to it being too large, then reject it - if (texSize+indexSize > (int)sizeof(texcache[tx].dump.texture)) goto REJECT; - - //when the palettes dont match: - //note that we are considering 4x4 textures to have a palette size of 0. - //they really have a potentially HUGE palette, too big for us to handle like a normal palette, - //so they go through a different system - if (mspal.size != 0 && memcmp(texcache[tx].dump.palette,pal,mspal.size)) goto REJECT; - - //when the texture data doesn't match - if(ms.memcmp(texcache[tx].dump.texture,sizeof(texcache[tx].dump.texture))) goto REJECT; - - //if the texture is 4x4 then the index data must match - if(textureMode == TEXMODE_4X4) - { - if(msIndex.memcmp(texcache[tx].dump.texture + texcache[tx].dump.textureSize,texcache[tx].dump.indexSize)) goto REJECT; - } - - -ACCEPT: - texcache[tx].suspectedInvalid = false; - if(lastTexture == -1 || (int)tx != lastTexture) - { - lastTexture = tx; - if(TexCache_BindTexture) - TexCache_BindTexture(tx); - } - return; - -REJECT: - tx++; - if ( tx > MAX_TEXTURE ) - { - texcache_stop=texcache_start; - texcache[texcache_stop].frm=0; - texcache_start++; - if (texcache_start>MAX_TEXTURE) - { - texcache_start=0; - texcache_stop=MAX_TEXTURE<<1; - } - tx=0; - } - } - - lastTexture = tx; - //glBindTexture(GL_TEXTURE_2D, texcache[tx].id); - - texcache[tx].suspectedInvalid = false; - texcache[tx].frm=format; - texcache[tx].mode=textureMode; - texcache[tx].pal=texpal; - texcache[tx].sizeX=sizeX; - texcache[tx].sizeY=sizeY; - texcache[tx].invSizeX=1.0f/((float)(sizeX)); - texcache[tx].invSizeY=1.0f/((float)(sizeY)); - texcache[tx].dump.textureSize = ms.dump(texcache[tx].dump.texture,sizeof(texcache[tx].dump.texture)); - - //dump palette data for cache keying - if ( palSize ) - { - memcpy(texcache[tx].dump.palette, pal, palSize*2); - } - //dump 4x4 index data for cache keying - texcache[tx].dump.indexSize = 0; - if(textureMode == TEXMODE_4X4) - { - texcache[tx].dump.indexSize = min(msIndex.size,(int)sizeof(texcache[tx].dump.texture) - texcache[tx].dump.textureSize); - msIndex.dump(texcache[tx].dump.texture+texcache[tx].dump.textureSize,texcache[tx].dump.indexSize); - } - - - //INFO("Texture %03i - format=%08X; pal=%04X (mode %X, width %04i, height %04i)\n",i, texcache[i].frm, texcache[i].pal, texcache[i].mode, sizeX, sizeY); - - //============================================================================ Texture conversion - const u32 opaqueColor = TEXFORMAT==TexFormat_32bpp?255:31; - u32 palZeroTransparent = (1-((format>>29)&1))*opaqueColor; - - switch (texcache[tx].mode) - { - case TEXMODE_A3I5: - { - for(int j=0;j>5; - if(TEXFORMAT == TexFormat_15bpp) - *dwdst++ = RGB15TO6665(c,material_3bit_to_5bit[alpha]); - else - *dwdst++ = RGB15TO32(c,material_3bit_to_8bit[alpha]); - adr++; - } - } - - break; - } - case TEXMODE_I2: - { - for(int j=0;j>2)&0x3; - c = pal[bits]; - *dwdst++ = CONVERT(c,(bits == 0) ? palZeroTransparent : opaqueColor); - - bits = ((*adr)>>4)&0x3; - c = pal[bits]; - *dwdst++ = CONVERT(c,(bits == 0) ? palZeroTransparent : opaqueColor); - - bits = ((*adr)>>6)&0x3; - c = pal[bits]; - *dwdst++ = CONVERT(c,(bits == 0) ? palZeroTransparent : opaqueColor); - - adr++; - } - } - break; - } - case TEXMODE_I4: - { - for(int j=0;j>4); - c = pal[bits]; - *dwdst++ = CONVERT(c,(bits == 0) ? palZeroTransparent : opaqueColor); - adr++; - } - } - break; - } - case TEXMODE_I8: - { - for(int j=0;j>14)] + ((paletteAddress + (offset)*2)&0x3FFF) ) ) - - u16* slot1; - u32* map = (u32*)ms.items[0].ptr; - u32 limit = ms.items[0].len<<2; - u32 d = 0; - if ( (texcache[tx].frm & 0xc000) == 0x8000) - // texel are in slot 2 - slot1=(u16*)&MMU.texInfo.textureSlotAddr[1][((texcache[tx].frm & 0x3FFF)<<2)+0x010000]; - else - slot1=(u16*)&MMU.texInfo.textureSlotAddr[1][(texcache[tx].frm & 0x3FFF)<<2]; - - u16 yTmpSize = (texcache[tx].sizeY>>2); - u16 xTmpSize = (texcache[tx].sizeX>>2); - - //this is flagged whenever a 4x4 overruns its slot. - //i am guessing we just generate black in that case - bool dead = false; - - for (int y = 0; y < yTmpSize; y ++) - { - u32 tmpPos[4]={(y<<2)*texcache[tx].sizeX,((y<<2)+1)*texcache[tx].sizeX, - ((y<<2)+2)*texcache[tx].sizeX,((y<<2)+3)*texcache[tx].sizeX}; - for (int x = 0; x < xTmpSize; x ++, d++) - { - if(d >= limit) - dead = true; - - if(dead) { - for (int sy = 0; sy < 4; sy++) - { - u32 currentPos = (x<<2) + tmpPos[sy]; - dwdst[currentPos] = dwdst[currentPos+1] = dwdst[currentPos+2] = dwdst[currentPos+3] = 0; - } - continue; - } - - u32 currBlock = map[d]; - u16 pal1 = slot1[d]; - u16 pal1offset = (pal1 & 0x3FFF)<<1; - u8 mode = pal1>>14; - u32 tmp_col[4]; - - tmp_col[0]=RGB16TO32(PAL4X4(pal1offset),255); - tmp_col[1]=RGB16TO32(PAL4X4(pal1offset+1),255); - - switch (mode) - { - case 0: - tmp_col[2]=RGB16TO32(PAL4X4(pal1offset+2),255); - tmp_col[3]=RGB16TO32(0x7FFF,0); - break; - case 1: - tmp_col[2]=(((tmp_col[0]&0xFF)+(tmp_col[1]&0xff))>>1)| - (((tmp_col[0]&(0xFF<<8))+(tmp_col[1]&(0xFF<<8)))>>1)| - (((tmp_col[0]&(0xFF<<16))+(tmp_col[1]&(0xFF<<16)))>>1)| - (0xff<<24); - tmp_col[3]=RGB16TO32(0x7FFF,0); - break; - case 2: - tmp_col[2]=RGB16TO32(PAL4X4(pal1offset+2),255); - tmp_col[3]=RGB16TO32(PAL4X4(pal1offset+3),255); - break; - case 3: - { - u32 red1, red2; - u32 green1, green2; - u32 blue1, blue2; - u16 tmp1, tmp2; - - red1=tmp_col[0]&0xff; - green1=(tmp_col[0]>>8)&0xff; - blue1=(tmp_col[0]>>16)&0xff; - red2=tmp_col[1]&0xff; - green2=(tmp_col[1]>>8)&0xff; - blue2=(tmp_col[1]>>16)&0xff; - - tmp1=((red1*5+red2*3)>>6)| - (((green1*5+green2*3)>>6)<<5)| - (((blue1*5+blue2*3)>>6)<<10); - tmp2=((red2*5+red1*3)>>6)| - (((green2*5+green1*3)>>6)<<5)| - (((blue2*5+blue1*3)>>6)<<10); - - tmp_col[2]=RGB16TO32(tmp1,255); - tmp_col[3]=RGB16TO32(tmp2,255); - break; - } - } - - if(TEXFORMAT==TexFormat_15bpp) - { - for(int i=0;i<4;i++) - { - tmp_col[i] >>= 2; - tmp_col[i] &= 0x3F3F3F3F; - u32 a = tmp_col[i]>>24; - tmp_col[i] &= 0x00FFFFFF; - tmp_col[i] |= (a>>1)<<24; - } - } - - //TODO - this could be more precise for 32bpp mode (run it through the color separation table) - - //set all 16 texels - for (int sy = 0; sy < 4; sy++) - { - // Texture offset - u32 currentPos = (x<<2) + tmpPos[sy]; - u8 currRow = (u8)((currBlock>>(sy<<3))&0xFF); - - dwdst[currentPos] = tmp_col[currRow&3]; - dwdst[currentPos+1] = tmp_col[(currRow>>2)&3]; - dwdst[currentPos+2] = tmp_col[(currRow>>4)&3]; - dwdst[currentPos+3] = tmp_col[(currRow>>6)&3]; - } - - - } - } - - - break; - } - case TEXMODE_A5I3: - { - for(int j=0;j>3); - if(TEXFORMAT == TexFormat_15bpp) - *dwdst++ = RGB15TO6665(c,alpha); - else - *dwdst++ = RGB15TO32(c,material_5bit_to_8bit[alpha]); - adr++; - } - } - break; - } - case TEXMODE_16BPP: - { - for(int j=0;j>1; - for(int x = 0; x < len; ++x) - { - u16 c = map[x]; - int alpha = ((c&0x8000)?opaqueColor:0); - *dwdst++ = CONVERT(c&0x7FFF,alpha); - } - } - break; - } - } - - if(TexCache_BindTextureData != 0) - TexCache_BindTextureData(tx,TexCache_texMAP); - -#ifdef DO_DEBUG_DUMP_TEXTURE - DebugDumpTexture(tx); -#endif - -} - -void TexCache_Reset() -{ - if(TexCache_texMAP == NULL) TexCache_texMAP = new u8[1024*2048*4]; - if(texcache == NULL) texcache = new TextureCache[MAX_TEXTURE+1]; - - memset(texcache,0,sizeof(TextureCache[MAX_TEXTURE+1])); - - texcache_start=0; - texcache_stop=MAX_TEXTURE<<1; -} - -TextureCache* TexCache_Curr() -{ - if(lastTexture == -1) - return NULL; - else return &texcache[lastTexture]; -} - -void TexCache_Invalidate() -{ - //well, this is a very blunt instrument. - //lets just flag all the textures as invalid. - for(int i=0;i(u32 format, u32 texpal); -template void TexCache_SetTexture(u32 format, u32 texpal); +#include "texcache.h" + +#include +#include + +#include "bits.h" +#include "common.h" +#include "debug.h" +#include "gfx3d.h" +#include "NDSSystem.h" + +using std::min; +using std::max; + +//only dump this from ogl renderer. for now, softrasterizer creates things in an incompatible pixel format +//#define DEBUG_DUMP_TEXTURE + +//This class represents a number of regions of memory which should be viewed as contiguous +class MemSpan +{ +public: + static const int MAXSIZE = 8; + + MemSpan() + : numItems(0) + {} + + int numItems; + + struct Item { + u32 start; + u32 len; + u8* ptr; + u32 ofs; //offset within the memspan + } items[MAXSIZE]; + + int size; + + //this MemSpan shall be considered the first argument to a standard memcmp + //the length shall be as specified in this MemSpan, unless you specify otherwise + int memcmp(void* buf2, int size=-1) + { + if(size==-1) size = this->size; + size = min(this->size,size); + for(int i=0;isize; + size = min(this->size,size); + u8* bufptr = (u8*)buf; + int done = 0; + for(int i=0;isize; + size = min(this->size,size); + u16* bufptr = (u16*)buf; + int done = 0; + for(int i=0;i>17)&3; //slots will wrap around + curr.len = min(len,0x20000-curr.start); + curr.ofs = currofs; + len -= curr.len; + ofs += curr.len; + currofs += curr.len; + u8* ptr = ARM9Mem.texInfo.textureSlotAddr[slot]; + + if(ptr == ARM9Mem.blank_memory) { + PROGINFO("Tried to reference unmapped texture memory: slot %d\n",slot); + } + curr.ptr = ptr + curr.start; + } + return ret; +} + +//creates a MemSpan in texture palette memory +static MemSpan MemSpan_TexPalette(u32 ofs, u32 len) +{ + MemSpan ret; + ret.size = len; + u32 currofs = 0; + while(len) { + MemSpan::Item &curr = ret.items[ret.numItems++]; + curr.start = ofs&0x3FFF; + u32 slot = (ofs>>14)&7; //this masks to 8 slots, but there are really only 6 + if(slot>5) { + PROGINFO("Texture palette overruns texture memory. Wrapping at palette slot 0.\n"); + slot -= 5; + } + curr.len = min(len,0x4000-curr.start); + curr.ofs = currofs; + len -= curr.len; + ofs += curr.len; + //if(len != 0) + //here is an actual test case of bank spanning + currofs += curr.len; + u8* ptr = ARM9Mem.texInfo.texPalSlot[slot]; + + if(ptr == ARM9Mem.blank_memory) { + PROGINFO("Tried to reference unmapped texture palette memory: 16k slot #%d\n",slot); + } + curr.ptr = ptr + curr.start; + } + return ret; +} + +TextureCache *texcache; +u32 texcache_start; +u32 texcache_stop; +u8 *TexCache_texMAP = NULL; + + +#if defined (DEBUG_DUMP_TEXTURE) && defined (WIN32) +#define DO_DEBUG_DUMP_TEXTURE +static void DebugDumpTexture(int which) +{ + char fname[100]; + sprintf(fname,"c:\\dump\\%d.bmp", which); + + NDS_WriteBMP_32bppBuffer(texcache[which].sizeX,texcache[which].sizeY,TexCache_texMAP,fname); +} +#endif + + +static int lastTexture = -1; + +#define CONVERT(color,alpha) ((TEXFORMAT == TexFormat_32bpp)?(RGB15TO32(color,alpha)):RGB15TO5555(color,alpha)) + +template +void TexCache_SetTexture(u32 format, u32 texpal) +{ + //for each texformat, number of palette entries + const int palSizes[] = {0, 32, 4, 16, 256, 0, 8, 0}; + + //for each texformat, multiplier from numtexels to numbytes (fixed point 30.2) + const int texSizes[] = {0, 4, 1, 2, 4, 1, 4, 8}; + + //used to hold a copy of the palette specified for this texture + u16 pal[256]; + + u32 *dwdst = (u32*)TexCache_texMAP; + + u32 textureMode = (unsigned short)((format>>26)&0x07); + unsigned int sizeX=(8 << ((format>>20)&0x07)); + unsigned int sizeY=(8 << ((format>>23)&0x07)); + unsigned int imageSize = sizeX*sizeY; + + u8 *adr; + + u32 paletteAddress; + + switch (textureMode) + { + case TEXMODE_I2: + paletteAddress = texpal<<3; + break; + case TEXMODE_A3I5: //a3i5 + case TEXMODE_I4: //i4 + case TEXMODE_I8: //i8 + case TEXMODE_A5I3: //a5i3 + case TEXMODE_16BPP: //16bpp + case TEXMODE_4X4: //4x4 + default: + paletteAddress = texpal<<4; + break; + } + + //analyze the texture memory mapping and the specifications of this texture + int palSize = palSizes[textureMode]; + int texSize = (imageSize*texSizes[textureMode])>>2; //shifted because the texSizes multiplier is fixed point + MemSpan ms = MemSpan_TexMem((format&0xFFFF)<<3,texSize); + MemSpan mspal = MemSpan_TexPalette(paletteAddress,palSize*2); + + //determine the location for 4x4 index data + u32 indexBase; + if((format & 0xc000) == 0x8000) indexBase = 0x30000; + else indexBase = 0x20000; + + u32 indexOffset = (format&0x3FFF)<<2; + + int indexSize = 0; + MemSpan msIndex; + if(textureMode == TEXMODE_4X4) + { + indexSize = imageSize>>3; + msIndex = MemSpan_TexMem(indexOffset+indexBase,indexSize); + } + + + //dump the palette to a temp buffer, so that we don't have to worry about memory mapping. + //this isnt such a problem with texture memory, because we read sequentially from it. + //however, we read randomly from palette memory, so the mapping is more costly. +#ifdef WORDS_BIGENDIAN + mspal.dump16(pal); +#else + mspal.dump(pal); +#endif + + + u32 tx=texcache_start; + + //if(false) + while (TRUE) + { + //conditions where we give up and regenerate the texture: + if (texcache_stop == tx) break; + if (texcache[tx].frm == 0) break; + + //conditions where we reject matches: + //when the teximage or texpal params dont match + //(this is our key for identifying palettes in the cache) + if (texcache[tx].frm != format) goto REJECT; + if (texcache[tx].pal != texpal) goto REJECT; + + //the texture matches params, but isnt suspected invalid. accept it. + if (!texcache[tx].suspectedInvalid) goto ACCEPT; + + //if we couldnt cache this entire texture due to it being too large, then reject it + if (texSize+indexSize > (int)sizeof(texcache[tx].dump.texture)) goto REJECT; + + //when the palettes dont match: + //note that we are considering 4x4 textures to have a palette size of 0. + //they really have a potentially HUGE palette, too big for us to handle like a normal palette, + //so they go through a different system + if (mspal.size != 0 && memcmp(texcache[tx].dump.palette,pal,mspal.size)) goto REJECT; + + //when the texture data doesn't match + if(ms.memcmp(texcache[tx].dump.texture,sizeof(texcache[tx].dump.texture))) goto REJECT; + + //if the texture is 4x4 then the index data must match + if(textureMode == TEXMODE_4X4) + { + if(msIndex.memcmp(texcache[tx].dump.texture + texcache[tx].dump.textureSize,texcache[tx].dump.indexSize)) goto REJECT; + } + + +ACCEPT: + texcache[tx].suspectedInvalid = false; + if(lastTexture == -1 || (int)tx != lastTexture) + { + lastTexture = tx; + if(TexCache_BindTexture) + TexCache_BindTexture(tx); + } + return; + +REJECT: + tx++; + if ( tx > MAX_TEXTURE ) + { + texcache_stop=texcache_start; + texcache[texcache_stop].frm=0; + texcache_start++; + if (texcache_start>MAX_TEXTURE) + { + texcache_start=0; + texcache_stop=MAX_TEXTURE<<1; + } + tx=0; + } + } + + lastTexture = tx; + //glBindTexture(GL_TEXTURE_2D, texcache[tx].id); + + texcache[tx].suspectedInvalid = false; + texcache[tx].frm=format; + texcache[tx].mode=textureMode; + texcache[tx].pal=texpal; + texcache[tx].sizeX=sizeX; + texcache[tx].sizeY=sizeY; + texcache[tx].invSizeX=1.0f/((float)(sizeX)); + texcache[tx].invSizeY=1.0f/((float)(sizeY)); + texcache[tx].dump.textureSize = ms.dump(texcache[tx].dump.texture,sizeof(texcache[tx].dump.texture)); + + //dump palette data for cache keying + if ( palSize ) + { + memcpy(texcache[tx].dump.palette, pal, palSize*2); + } + //dump 4x4 index data for cache keying + texcache[tx].dump.indexSize = 0; + if(textureMode == TEXMODE_4X4) + { + texcache[tx].dump.indexSize = min(msIndex.size,(int)sizeof(texcache[tx].dump.texture) - texcache[tx].dump.textureSize); + msIndex.dump(texcache[tx].dump.texture+texcache[tx].dump.textureSize,texcache[tx].dump.indexSize); + } + + + //INFO("Texture %03i - format=%08X; pal=%04X (mode %X, width %04i, height %04i)\n",i, texcache[i].frm, texcache[i].pal, texcache[i].mode, sizeX, sizeY); + + //============================================================================ Texture conversion + const u32 opaqueColor = TEXFORMAT==TexFormat_32bpp?255:31; + u32 palZeroTransparent = (1-((format>>29)&1))*opaqueColor; + + switch (texcache[tx].mode) + { + case TEXMODE_A3I5: + { + for(int j=0;j>5; + if(TEXFORMAT == TexFormat_15bpp) + *dwdst++ = RGB15TO5555(c,material_3bit_to_5bit[alpha]); + else + *dwdst++ = RGB15TO32(c,material_3bit_to_8bit[alpha]); + adr++; + } + } + + break; + } + case TEXMODE_I2: + { + for(int j=0;j>2)&0x3; + c = pal[bits]; + *dwdst++ = CONVERT(c,(bits == 0) ? palZeroTransparent : opaqueColor); + + bits = ((*adr)>>4)&0x3; + c = pal[bits]; + *dwdst++ = CONVERT(c,(bits == 0) ? palZeroTransparent : opaqueColor); + + bits = ((*adr)>>6)&0x3; + c = pal[bits]; + *dwdst++ = CONVERT(c,(bits == 0) ? palZeroTransparent : opaqueColor); + + adr++; + } + } + break; + } + case TEXMODE_I4: + { + for(int j=0;j>4); + c = pal[bits]; + *dwdst++ = CONVERT(c,(bits == 0) ? palZeroTransparent : opaqueColor); + adr++; + } + } + break; + } + case TEXMODE_I8: + { + for(int j=0;j>14)] + ((paletteAddress + (offset)*2)&0x3FFF) ) ) + + u16* slot1; + u32* map = (u32*)ms.items[0].ptr; + u32 limit = ms.items[0].len<<2; + u32 d = 0; + if ( (texcache[tx].frm & 0xc000) == 0x8000) + // texel are in slot 2 + slot1=(u16*)&ARM9Mem.texInfo.textureSlotAddr[1][((texcache[tx].frm & 0x3FFF)<<2)+0x010000]; + else + slot1=(u16*)&ARM9Mem.texInfo.textureSlotAddr[1][(texcache[tx].frm & 0x3FFF)<<2]; + + u16 yTmpSize = (texcache[tx].sizeY>>2); + u16 xTmpSize = (texcache[tx].sizeX>>2); + + //this is flagged whenever a 4x4 overruns its slot. + //i am guessing we just generate black in that case + bool dead = false; + + for (int y = 0; y < yTmpSize; y ++) + { + u32 tmpPos[4]={(y<<2)*texcache[tx].sizeX,((y<<2)+1)*texcache[tx].sizeX, + ((y<<2)+2)*texcache[tx].sizeX,((y<<2)+3)*texcache[tx].sizeX}; + for (int x = 0; x < xTmpSize; x ++, d++) + { + if(d >= limit) + dead = true; + + if(dead) { + for (int sy = 0; sy < 4; sy++) + { + u32 currentPos = (x<<2) + tmpPos[sy]; + dwdst[currentPos] = dwdst[currentPos+1] = dwdst[currentPos+2] = dwdst[currentPos+3] = 0; + } + continue; + } + + u32 currBlock = map[d]; + u16 pal1 = slot1[d]; + u16 pal1offset = (pal1 & 0x3FFF)<<1; + u8 mode = pal1>>14; + u32 tmp_col[4]; + + tmp_col[0]=RGB16TO32(PAL4X4(pal1offset),255); + tmp_col[1]=RGB16TO32(PAL4X4(pal1offset+1),255); + + switch (mode) + { + case 0: + tmp_col[2]=RGB16TO32(PAL4X4(pal1offset+2),255); + tmp_col[3]=RGB16TO32(0x7FFF,0); + break; + case 1: + tmp_col[2]=(((tmp_col[0]&0xFF)+(tmp_col[1]&0xff))>>1)| + (((tmp_col[0]&(0xFF<<8))+(tmp_col[1]&(0xFF<<8)))>>1)| + (((tmp_col[0]&(0xFF<<16))+(tmp_col[1]&(0xFF<<16)))>>1)| + (0xff<<24); + tmp_col[3]=RGB16TO32(0x7FFF,0); + break; + case 2: + tmp_col[2]=RGB16TO32(PAL4X4(pal1offset+2),255); + tmp_col[3]=RGB16TO32(PAL4X4(pal1offset+3),255); + break; + case 3: + { + u32 red1, red2; + u32 green1, green2; + u32 blue1, blue2; + u16 tmp1, tmp2; + + red1=tmp_col[0]&0xff; + green1=(tmp_col[0]>>8)&0xff; + blue1=(tmp_col[0]>>16)&0xff; + red2=tmp_col[1]&0xff; + green2=(tmp_col[1]>>8)&0xff; + blue2=(tmp_col[1]>>16)&0xff; + + tmp1=((red1*5+red2*3)>>6)| + (((green1*5+green2*3)>>6)<<5)| + (((blue1*5+blue2*3)>>6)<<10); + tmp2=((red2*5+red1*3)>>6)| + (((green2*5+green1*3)>>6)<<5)| + (((blue2*5+blue1*3)>>6)<<10); + + tmp_col[2]=RGB16TO32(tmp1,255); + tmp_col[3]=RGB16TO32(tmp2,255); + break; + } + } + + if(TEXFORMAT==TexFormat_15bpp) + { + for(int i=0;i<4;i++) + { + tmp_col[i] >>= 3; + tmp_col[i] &= 0x1F1F1F1F; + } + } + + //TODO - this could be more precise for 32bpp mode (run it through the color separation table) + + //set all 16 texels + for (int sy = 0; sy < 4; sy++) + { + // Texture offset + u32 currentPos = (x<<2) + tmpPos[sy]; + u8 currRow = (u8)((currBlock>>(sy<<3))&0xFF); + + dwdst[currentPos] = tmp_col[currRow&3]; + dwdst[currentPos+1] = tmp_col[(currRow>>2)&3]; + dwdst[currentPos+2] = tmp_col[(currRow>>4)&3]; + dwdst[currentPos+3] = tmp_col[(currRow>>6)&3]; + } + + + } + } + + + break; + } + case TEXMODE_A5I3: + { + for(int j=0;j>3); + if(TEXFORMAT == TexFormat_15bpp) + *dwdst++ = RGB15TO5555(c,alpha); + else + *dwdst++ = RGB15TO32(c,material_5bit_to_8bit[alpha]); + adr++; + } + } + break; + } + case TEXMODE_16BPP: + { + for(int j=0;j>1; + for(u32 x = 0; x < len; ++x) + { + u16 c = map[x]; + int alpha = ((c&0x8000)?opaqueColor:0); + *dwdst++ = CONVERT(c&0x7FFF,alpha); + } + } + break; + } + } + + if(TexCache_BindTextureData != 0) + TexCache_BindTextureData(tx,TexCache_texMAP); + +#ifdef DO_DEBUG_DUMP_TEXTURE + DebugDumpTexture(tx); +#endif + +} + +void TexCache_Reset() +{ + if(TexCache_texMAP == NULL) TexCache_texMAP = new u8[1024*2048*4]; + if(texcache == NULL) texcache = new TextureCache[MAX_TEXTURE+1]; + + memset(texcache,0,sizeof(TextureCache[MAX_TEXTURE+1])); + + texcache_start=0; + texcache_stop=MAX_TEXTURE<<1; +} + +TextureCache* TexCache_Curr() +{ + if(lastTexture == -1) + return NULL; + else return &texcache[lastTexture]; +} + +void TexCache_Invalidate() +{ + //well, this is a very blunt instrument. + //lets just flag all the textures as invalid. + for(int i=0;i(u32 format, u32 texpal); +template void TexCache_SetTexture(u32 format, u32 texpal); diff --git a/desmume/src/texcache.h b/src/texcache.h similarity index 85% rename from desmume/src/texcache.h rename to src/texcache.h index d51de2f0f..648b8eb48 100644 --- a/desmume/src/texcache.h +++ b/src/texcache.h @@ -1,51 +1,54 @@ -#ifndef _TEXCACHE_H_ -#define _TEXCACHE_H_ - -#include "common.h" - -enum TexCache_TexFormat -{ - TexFormat_32bpp, - TexFormat_15bpp -}; - -#define MAX_TEXTURE 500 - - -struct CACHE_ALIGN TextureCache -{ - u32 id; - u32 frm; - u32 mode; - u32 pal; - u32 sizeX; - u32 sizeY; - float invSizeX; - float invSizeY; - - struct { - int textureSize, indexSize; - u8 texture[128*1024]; // 128Kb texture slot - u8 palette[256*2]; - } dump; - - //set if this texture is suspected be invalid due to a vram reconfigure - bool suspectedInvalid; -}; - -extern TextureCache *texcache; - -extern void (*TexCache_BindTexture)(u32 texnum); -extern void (*TexCache_BindTextureData)(u32 texnum, u8* data); - -void TexCache_Reset(); - -template -void TexCache_SetTexture(u32 format, u32 texpal); - -void TexCache_Invalidate(); - -extern u8 *TexCache_texMAP; -TextureCache* TexCache_Curr(); - -#endif +#ifndef _TEXCACHE_H_ +#define _TEXCACHE_H_ + +#include "common.h" + +enum TexCache_TexFormat +{ + TexFormat_32bpp, + TexFormat_15bpp +}; + +#define MAX_TEXTURE 500 +#ifndef NOSSE2 +struct ALIGN(16) TextureCache +#else +struct ALIGN(8) TextureCache +#endif +{ + u32 id; + u32 frm; + u32 mode; + u32 pal; + u32 sizeX; + u32 sizeY; + float invSizeX; + float invSizeY; + + struct { + int textureSize, indexSize; + u8 texture[128*1024]; // 128Kb texture slot + u8 palette[256*2]; + } dump; + + //set if this texture is suspected be invalid due to a vram reconfigure + bool suspectedInvalid; + +}; + +extern TextureCache *texcache; + +extern void (*TexCache_BindTexture)(u32 texnum); +extern void (*TexCache_BindTextureData)(u32 texnum, u8* data); + +void TexCache_Reset(); + +template +void TexCache_SetTexture(u32 format, u32 texpal); + +void TexCache_Invalidate(); + +extern u8 *TexCache_texMAP; +TextureCache* TexCache_Curr(); + +#endif diff --git a/desmume/src/thumb_instructions.cpp b/src/thumb_instructions.cpp similarity index 95% rename from desmume/src/thumb_instructions.cpp rename to src/thumb_instructions.cpp index 3fcb9990e..09ee55242 100644 --- a/desmume/src/thumb_instructions.cpp +++ b/src/thumb_instructions.cpp @@ -1,994 +1,983 @@ -/* - Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Code added on 18/08/2006 by shash - - Missing missaligned addresses correction - (reference in http://nocash.emubase.de/gbatek.htm#cpumemoryalignments) - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "bios.h" -#include "debug.h" -#include "MMU.h" -#include "NDSSystem.h" -#include - -#define cpu (&ARMPROC) -#define TEMPLATE template - -#define REG_NUM(i, n) (((i)>>n)&0x7) - -extern volatile bool execute; - -TEMPLATE static u32 FASTCALL OP_UND_THUMB() -{ - emu_halt(); - return 1; -} - -TEMPLATE static u32 FASTCALL OP_LSL_0() -{ - const u32 &i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] = cpu->R[REG_NUM(i, 3)]; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_LSL() -{ - const u32 &i = cpu->instruction; - u32 v = (i>>6) & 0x1F; - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 3)], 32-v); - cpu->R[REG_NUM(i, 0)] = (cpu->R[REG_NUM(i, 3)] << v); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_LSR_0() -{ - const u32 &i = cpu->instruction; - // cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 3)]); - cpu->R[REG_NUM(i, 0)] = 0; - cpu->CPSR.bits.N = 0; - cpu->CPSR.bits.Z = 1; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_LSR() -{ - const u32 &i = cpu->instruction; - u32 v = (i>>6) & 0x1F; - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 3)], v-1); - cpu->R[REG_NUM(i, 0)] = (cpu->R[REG_NUM(i, 3)] >> v); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_ASR_0() -{ - const u32 &i = cpu->instruction; - cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 3)]); - cpu->R[REG_NUM(i, 0)] = BIT31(cpu->R[REG_NUM(i, 3)])*0xFFFFFFFF; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_ASR() -{ - const u32 &i = cpu->instruction; - u32 v = (i>>6) & 0x1F; - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 3)], v-1); - cpu->R[REG_NUM(i, 0)] = (((s32)cpu->R[REG_NUM(i, 3)]) >> v); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_ADD_REG() -{ - const u32 &i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 3)]; - u32 b = cpu->R[REG_NUM(i, 6)]; - cpu->R[REG_NUM(i, 0)] = a + b; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(a, b, cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.V = SIGNED_OVERFLOW(a, b, cpu->R[REG_NUM(i, 0)]); - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_SUB_REG() -{ - const u32 &i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 3)]; - u32 b = cpu->R[REG_NUM(i, 6)]; - cpu->R[REG_NUM(i, 0)] = a - b; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(a, b, cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(a, b, cpu->R[REG_NUM(i, 0)]); - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_ADD_IMM3() -{ - const u32 &i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 3)]; - cpu->R[REG_NUM(i, 0)] = a + REG_NUM(i, 6); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.V = SIGNED_OVERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]); - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SUB_IMM3() -{ - const u32 &i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 3)]; - cpu->R[REG_NUM(i, 0)] = a - REG_NUM(i, 6); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]); - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_MOV_IMM8() -{ - const u32 &i = cpu->instruction; - cpu->R[REG_NUM(i, 8)] = i & 0xFF; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 8)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 8)] == 0; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_CMP_IMM8() -{ - const u32 &i = cpu->instruction; - u32 tmp = cpu->R[REG_NUM(i, 8)] - (i & 0xFF); - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_ADD_IMM8() -{ - const u32 &i = cpu->instruction; - u32 tmp = cpu->R[REG_NUM(i, 8)] + (i & 0xFF); - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); - cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); - cpu->R[REG_NUM(i, 8)] = tmp; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_SUB_IMM8() -{ - const u32 &i = cpu->instruction; - u32 tmp = cpu->R[REG_NUM(i, 8)] - (i & 0xFF); - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); - cpu->R[REG_NUM(i, 8)] = tmp; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_AND() -{ - const u32 &i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] &= cpu->R[REG_NUM(i, 3)]; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_EOR() -{ - const u32 &i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] ^= cpu->R[REG_NUM(i, 3)]; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_LSL_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_NUM(i, 3)]&0xFF; - - if(!v) - { - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - if(v<32) - { - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], 32-v); - cpu->R[REG_NUM(i, 0)] <<= v; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - if(v==32) - cpu->CPSR.bits.C = BIT0(cpu->R[REG_NUM(i, 0)]); - else - cpu->CPSR.bits.C = 0; - cpu->R[REG_NUM(i, 0)] = 0; - cpu->CPSR.bits.N = 0; - cpu->CPSR.bits.Z = 1; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_LSR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_NUM(i, 3)]&0xFF; - - if(!v) - { - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - if(v<32) - { - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1); - cpu->R[REG_NUM(i, 0)] >>= v; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - if(v==32) - cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]); - else - cpu->CPSR.bits.C = 0; - cpu->R[REG_NUM(i, 0)] = 0; - cpu->CPSR.bits.N = 0; - cpu->CPSR.bits.Z = 1; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_ASR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_NUM(i, 3)]&0xFF; - - if(!v) - { - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - if(v<32) - { - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1); - cpu->R[REG_NUM(i, 0)] = (u32)(((s32)cpu->R[REG_NUM(i, 0)]) >> v); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - - cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->R[REG_NUM(i, 0)] = BIT31(cpu->R[REG_NUM(i, 0)])*0xFFFFFFFF; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_ADC_REG() -{ - const u32 &i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 0)]; - u32 b = cpu->R[REG_NUM(i, 3)]; - u32 tmp = b + cpu->CPSR.bits.C; - u32 res = a + tmp; - - cpu->R[REG_NUM(i, 0)] = res; - - cpu->CPSR.bits.N = BIT31(res); - cpu->CPSR.bits.Z = res == 0; - - //the below UNSIGNED_OVERFLOW calculation is the clever way of doing it - //but just to keep from making a mistake, lets assert that it matches the precise definition of unsigned overflow - static long passcount = 0; - assert(++passcount); - assert( - ((((u64)a+(u64)b+cpu->CPSR.bits.C)>>32)&1) - == (UNSIGNED_OVERFLOW(b, (u32) cpu->CPSR.bits.C, tmp) | UNSIGNED_OVERFLOW(tmp, a, res)) - ); - - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(b, (u32) cpu->CPSR.bits.C, tmp) | UNSIGNED_OVERFLOW(tmp, a, res); - cpu->CPSR.bits.V = SIGNED_OVERFLOW(b, (u32) cpu->CPSR.bits.C, tmp) | SIGNED_OVERFLOW(tmp, a, res); - - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_SBC_REG() -{ - const u32 &i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 0)]; - u32 b = cpu->R[REG_NUM(i, 3)]; - u32 tmp = a - (!cpu->CPSR.bits.C); - u32 res = tmp - b; - cpu->R[REG_NUM(i, 0)] = res; - - cpu->CPSR.bits.N = BIT31(res); - cpu->CPSR.bits.Z = res == 0; - - //the below UNSIGNED_UNDERFLOW calculation is the clever way of doing it - //but just to keep from making a mistake, lets assert that it matches the precise definition of unsigned overflow - static long passcount = 0; - assert(++passcount); - assert( - ((((u64)a-(u64)b-(!cpu->CPSR.bits.C))>>32)&1) - == UNSIGNED_UNDERFLOW(a, b, res) - ); - - //zero 31-dec-2008 - apply normatt's fixed logic from the arm SBC instruction - //although it seemed a bit odd to me and to whomever wrote this for SBC not to work similar to ADC.. - //but thats how it is. - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(a, b, res); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(a, b, res); - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_ROR_REG() -{ - const u32 &i = cpu->instruction; - u32 v = cpu->R[REG_NUM(i, 3)]&0xFF; - - if(v == 0) - { - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - v &= 0x1F; - if(v == 0) - { - cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - return 3; - } - cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1); - cpu->R[REG_NUM(i, 0)] = ROR(cpu->R[REG_NUM(i, 0)], v); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_TST() -{ - const u32 &i = cpu->instruction; - u32 tmp = cpu->R[REG_NUM(i, 0)] & cpu->R[REG_NUM(i, 3)]; - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_NEG() -{ - const u32 &i = cpu->instruction; - u32 a = cpu->R[REG_NUM(i, 3)]; - cpu->R[REG_NUM(i, 0)] = -((signed int)a); - - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW((u32)0, a, cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW((u32)0, a, cpu->R[REG_NUM(i, 0)]); - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_CMP() -{ - const u32 &i = cpu->instruction; - u32 tmp = cpu->R[REG_NUM(i, 0)] -cpu->R[REG_NUM(i, 3)]; - - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_CMN() -{ - const u32 &i = cpu->instruction; - u32 tmp = cpu->R[REG_NUM(i, 0)] + cpu->R[REG_NUM(i, 3)]; - - //emu_halt(); - //log::ajouter("OP_CMN THUMB"); - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); - cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_ORR() -{ - const u32 &i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] |= cpu->R[REG_NUM(i, 3)]; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_MUL_REG() -{ - const u32 &i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] *= cpu->R[REG_NUM(i, 3)]; - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_BIC() -{ - const u32 &i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] &= (~cpu->R[REG_NUM(i, 3)]); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_MVN() -{ - const u32 &i = cpu->instruction; - cpu->R[REG_NUM(i, 0)] = (~cpu->R[REG_NUM(i, 3)]); - cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); - cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_ADD_SPE() -{ - const u32 &i = cpu->instruction; - u32 Rd = (i&7) | ((i>>4)&8); - cpu->R[Rd] += cpu->R[REG_POS(i, 3)]; - - if(Rd==15) - cpu->next_instruction = cpu->R[15]; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_CMP_SPE() -{ - const u32 &i = cpu->instruction; - u32 Rn = (i&7) | ((i>>4)&8); - u32 tmp = cpu->R[Rn] -cpu->R[REG_POS(i, 3)]; - - cpu->CPSR.bits.N = BIT31(tmp); - cpu->CPSR.bits.Z = tmp == 0; - cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[Rn], cpu->R[REG_POS(i, 3)], tmp); - cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[Rn], cpu->R[REG_POS(i, 3)], tmp); - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_MOV_SPE() -{ - const u32 &i = cpu->instruction; - u32 Rd = (i&7) | ((i>>4)&8); - cpu->R[Rd] = cpu->R[REG_POS(i, 3)]; - - if(Rd==15) - cpu->next_instruction = cpu->R[15]; - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_BX_THUMB() -{ - // When using PC as operand with BX opcode, switch to ARM state and jump to (instruct_adr+4) - // Reference: http://nocash.emubase.de/gbatek.htm#thumb5hiregisteroperationsbranchexchange - if (REG_POS(cpu->instruction, 3) == 15) - { - cpu->CPSR.bits.T = 0; - cpu->R[15] &= 0xFFFFFFFC; - cpu->next_instruction = cpu->R[15]; - } - else - { - u32 Rm = cpu->R[REG_POS(cpu->instruction, 3)]; - - cpu->CPSR.bits.T = BIT0(Rm); - cpu->R[15] = (Rm & 0xFFFFFFFE); - cpu->next_instruction = cpu->R[15]; - } - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_BLX_THUMB() -{ - u32 Rm = cpu->R[REG_POS(cpu->instruction, 3)]; - - cpu->CPSR.bits.T = BIT0(Rm); - cpu->R[14] = cpu->next_instruction | 1; - cpu->R[15] = (Rm & 0xFFFFFFFE); - cpu->next_instruction = cpu->R[15]; - - return 3; -} - -TEMPLATE static u32 FASTCALL OP_LDR_PCREL() -{ - u32 adr = (cpu->R[15]&0xFFFFFFFC) + ((cpu->instruction&0xFF)<<2); - - cpu->R[REG_NUM(cpu->instruction, 8)] = READ32(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 6)] + cpu->R[REG_NUM(i, 3)]; - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_NUM(i, 0)]); - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; - WRITE16(cpu->mem_if->data, adr, ((u16)cpu->R[REG_NUM(i, 0)])); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; - WRITE8(cpu->mem_if->data, adr, ((u8)cpu->R[REG_NUM(i, 0)])); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSB_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; - cpu->R[REG_NUM(i, 0)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = (cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]); - u32 tempValue = READ32(cpu->mem_if->data, adr&0xFFFFFFFC); - - adr = (adr&3)*8; - tempValue = (tempValue>>adr) | (tempValue<<(32-adr)); - cpu->R[REG_NUM(i, 0)] = tempValue; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; - cpu->R[REG_NUM(i, 0)] = (u32)READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; - cpu->R[REG_NUM(i, 0)] = (u32)READ8(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRSH_REG_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; - cpu->R[REG_NUM(i, 0)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>4)&0x7C); - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_NUM(i, 0)]); - - return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>4)&0x7C); - u32 tempValue = READ32(cpu->mem_if->data, adr&0xFFFFFFFC); - adr = (adr&3)*8; - tempValue = (tempValue>>adr) | (tempValue<<(32-adr)); - cpu->R[REG_NUM(i, 0)] = tempValue; - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRB_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>6)&0x1F); - WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_NUM(i, 0)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRB_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>6)&0x1F); - cpu->R[REG_NUM(i, 0)] = READ8(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STRH_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>5)&0x3E); - WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_NUM(i, 0)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDRH_IMM_OFF() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>5)&0x3E); - cpu->R[REG_NUM(i, 0)] = READ16(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_STR_SPREL() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[13] + ((i&0xFF)<<2); - WRITE32(cpu->mem_if->data, adr, cpu->R[REG_NUM(i, 8)]); - - return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_LDR_SPREL() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[13] + ((i&0xFF)<<2); - cpu->R[REG_NUM(i, 8)] = READ32(cpu->mem_if->data, adr); - - return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; -} - -TEMPLATE static u32 FASTCALL OP_ADD_2PC() -{ - const u32 &i = cpu->instruction; - cpu->R[REG_NUM(i, 8)] = (cpu->R[15]&0xFFFFFFFC) + ((i&0xFF)<<2); - - return 5; -} - -TEMPLATE static u32 FASTCALL OP_ADD_2SP() -{ - const u32 &i = cpu->instruction; - cpu->R[REG_NUM(i, 8)] = cpu->R[13] + ((i&0xFF)<<2); - - return 2; -} - -TEMPLATE static u32 FASTCALL OP_ADJUST_P_SP() -{ - cpu->R[13] += ((cpu->instruction&0x7F)<<2); - - return 1; -} - -TEMPLATE static u32 FASTCALL OP_ADJUST_M_SP() -{ - cpu->R[13] -= ((cpu->instruction&0x7F)<<2); - - return 1; -} - -TEMPLATE static u32 FASTCALL OP_PUSH() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[13] - 4; - u32 c = 0, j; - - for(j = 0; j<8; ++j) - if(BIT_N(i, 7-j)) - { - WRITE32(cpu->mem_if->data, adr, cpu->R[7-j]); - c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - adr -= 4; - } - cpu->R[13] = adr + 4; - - return c + 3; -} - -TEMPLATE static u32 FASTCALL OP_PUSH_LR() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[13] - 4; - u32 c = 0, j; - - WRITE32(cpu->mem_if->data, adr, cpu->R[14]); - c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - adr -= 4; - - for(j = 0; j<8; ++j) - if(BIT_N(i, 7-j)) - { - WRITE32(cpu->mem_if->data, adr, cpu->R[7-j]); - c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - adr -= 4; - } - cpu->R[13] = adr + 4; - - return c + 4; -} - -TEMPLATE static u32 FASTCALL OP_POP() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[13]; - u32 c = 0, j; - - for(j = 0; j<8; ++j) - if(BIT_N(i, j)) - { - cpu->R[j] = READ32(cpu->mem_if->data, adr); - c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - adr += 4; - } - cpu->R[13] = adr; - - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_POP_PC() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[13]; - u32 c = 0, j; - u32 v; - - for(j = 0; j<8; ++j) - if(BIT_N(i, j)) - { - cpu->R[j] = READ32(cpu->mem_if->data, adr); - c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - adr += 4; - } - - v = READ32(cpu->mem_if->data, adr); - c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - cpu->R[15] = v & 0xFFFFFFFE; - cpu->next_instruction = v & 0xFFFFFFFE; - if(PROCNUM==0) - cpu->CPSR.bits.T = BIT0(v); - adr += 4; - - cpu->R[13] = adr; - return c + 5; -} - -TEMPLATE static u32 FASTCALL OP_BKPT_THUMB() -{ - return 1; -} - -TEMPLATE static u32 FASTCALL OP_STMIA_THUMB() -{ - const u32 &i = cpu->instruction; - u32 adr = cpu->R[REG_NUM(i, 8)]; - u32 c = 0, j; - - for(j = 0; j<8; ++j) - if(BIT_N(i, j)) - { - WRITE32(cpu->mem_if->data, adr, cpu->R[j]); - c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - adr += 4; - } - cpu->R[REG_NUM(i, 8)] = adr; - return c + 2; -} - -TEMPLATE static u32 FASTCALL OP_LDMIA_THUMB() -{ - const u32 &i = cpu->instruction; - u32 regIndex = REG_NUM(i, 8); - u32 adr = cpu->R[regIndex]; - u32 c = 0, j; - - for(j = 0; j<8; ++j) - if(BIT_N(i, j)) - { - cpu->R[j] = READ32(cpu->mem_if->data, adr); - c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; - adr += 4; - } - - // Only over-write if not on the read list - if(!BIT_N(i, regIndex)) - cpu->R[regIndex] = adr; - - return c + 3; -} - -TEMPLATE static u32 FASTCALL OP_B_COND() -{ - const u32 &i = cpu->instruction; - if(!TEST_COND((i>>8)&0xF, 0, cpu->CPSR)) - return 1; - - cpu->R[15] += ((s32)((s8)(i&0xFF)))<<1; - cpu->next_instruction = cpu->R[15]; - return 3; -} - -TEMPLATE static u32 FASTCALL OP_SWI_THUMB() -{ - u32 swinum = cpu->instruction & 0xFF; - - //ideas-style debug prints - if(swinum==0xFC) { - IdeasLog(cpu); - return 0; - } - - if(cpu->swi_tab) { - //zero 25-dec-2008 - in arm, we were masking to 0x1F. - //this is probably safer since an invalid opcode could crash the emu - //zero 30-jun-2009 - but they say that the ideas 0xFF should crash the device... - //u32 swinum = cpu->instruction & 0xFF; - swinum &= 0x1F; - return cpu->swi_tab[swinum]() + 3; - } - else { - /* we use an irq thats not in the irq tab, as - it was replaced duie to a changed intVector */ - Status_Reg tmp = cpu->CPSR; - armcpu_switchMode(cpu, SVC); /* enter svc mode */ - cpu->R[14] = cpu->next_instruction; /* jump to swi Vector */ - cpu->SPSR = tmp; /* save old CPSR as new SPSR */ - cpu->CPSR.bits.T = 0; /* handle as ARM32 code */ - cpu->CPSR.bits.I = 1; - cpu->R[15] = cpu->intVector + 0x08; - cpu->next_instruction = cpu->R[15]; - return 3; - } -} - -#define SIGNEEXT_IMM11(i) (((i)&0x7FF) | (BIT10(i) * 0xFFFFF800)) - -TEMPLATE static u32 FASTCALL OP_B_UNCOND() -{ - const u32 &i = cpu->instruction; - cpu->R[15] += (SIGNEEXT_IMM11(i)<<1); - cpu->next_instruction = cpu->R[15]; - return 3; -} - -TEMPLATE static u32 FASTCALL OP_BLX() -{ - const u32 &i = cpu->instruction; - cpu->R[15] = (cpu->R[14] + ((i&0x7FF)<<1))&0xFFFFFFFC; - cpu->R[14] = cpu->next_instruction | 1; - cpu->next_instruction = cpu->R[15]; - cpu->CPSR.bits.T = 0; - return 3; -} - -TEMPLATE static u32 FASTCALL OP_BL_10() -{ - const u32 &i = cpu->instruction; - cpu->R[14] = cpu->R[15] + (SIGNEEXT_IMM11(i)<<12); - return 1; -} - -TEMPLATE static u32 FASTCALL OP_BL_THUMB() -{ - const u32 &i = cpu->instruction; - cpu->R[15] = (cpu->R[14] + ((i&0x7FF)<<1)); - cpu->R[14] = cpu->next_instruction | 1; - cpu->next_instruction = cpu->R[15]; - return 3; -} - -#define TYPE_RETOUR u32 -#define CALLTYPE FASTCALL -#define PARAMETRES -#define NOM_THUMB_TAB thumb_instructions_set_0 -#define TABDECL(x) x<0> - -#include "thumb_tabdef.inc" - -#undef TYPE_RETOUR -#undef PARAMETRES -#undef CALLTYPE -#undef NOM_THUMB_TAB -#undef TABDECL - -#define TYPE_RETOUR u32 -#define PARAMETRES -#define CALLTYPE FASTCALL -#define NOM_THUMB_TAB thumb_instructions_set_1 -#define TABDECL(x) x<1> - -#include "thumb_tabdef.inc" +/* + Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Code added on 18/08/2006 by shash + - Missing missaligned addresses correction + (reference in http://nocash.emubase.de/gbatek.htm#cpumemoryalignments) + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "bios.h" +#include "debug.h" +#include "MMU.h" +#include "NDSSystem.h" +#include + +#define cpu (&ARMPROC) +#define TEMPLATE template + +#define REG_NUM(i, n) (((i)>>n)&0x7) + +extern volatile BOOL execute; + +TEMPLATE static u32 FASTCALL OP_UND_THUMB() +{ + emu_halt(); + return 1; +} + +TEMPLATE static u32 FASTCALL OP_LSL_0() +{ + const u32 &i = cpu->instruction; + cpu->R[REG_NUM(i, 0)] = cpu->R[REG_NUM(i, 3)]; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_LSL() +{ + const u32 &i = cpu->instruction; + u32 v = (i>>6) & 0x1F; + cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 3)], 32-v); + cpu->R[REG_NUM(i, 0)] = (cpu->R[REG_NUM(i, 3)] << v); + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_LSR_0() +{ + const u32 &i = cpu->instruction; + // cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 3)]); + cpu->R[REG_NUM(i, 0)] = 0; + cpu->CPSR.bits.N = 0; + cpu->CPSR.bits.Z = 1; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_LSR() +{ + const u32 &i = cpu->instruction; + u32 v = (i>>6) & 0x1F; + cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1); + cpu->R[REG_NUM(i, 0)] = (cpu->R[REG_NUM(i, 3)] >> v); + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_ASR_0() +{ + const u32 &i = cpu->instruction; + cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 3)]); + cpu->R[REG_NUM(i, 0)] = BIT31(cpu->R[REG_NUM(i, 3)])*0xFFFFFFFF; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_ASR() +{ + const u32 &i = cpu->instruction; + u32 v = (i>>6) & 0x1F; + cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 3)], v-1); + cpu->R[REG_NUM(i, 0)] = (((s32)cpu->R[REG_NUM(i, 3)]) >> v); + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_ADD_REG() +{ + const u32 &i = cpu->instruction; + u32 a = cpu->R[REG_NUM(i, 3)]; + u32 b = cpu->R[REG_NUM(i, 6)]; + cpu->R[REG_NUM(i, 0)] = a + b; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(a, b, cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.V = SIGNED_OVERFLOW(a, b, cpu->R[REG_NUM(i, 0)]); + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_SUB_REG() +{ + const u32 &i = cpu->instruction; + u32 a = cpu->R[REG_NUM(i, 3)]; + u32 b = cpu->R[REG_NUM(i, 6)]; + cpu->R[REG_NUM(i, 0)] = a - b; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(a, b, cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(a, b, cpu->R[REG_NUM(i, 0)]); + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_ADD_IMM3() +{ + const u32 &i = cpu->instruction; + u32 a = cpu->R[REG_NUM(i, 3)]; + cpu->R[REG_NUM(i, 0)] = a + REG_NUM(i, 6); + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.V = SIGNED_OVERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]); + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SUB_IMM3() +{ + const u32 &i = cpu->instruction; + u32 a = cpu->R[REG_NUM(i, 3)]; + cpu->R[REG_NUM(i, 0)] = a - REG_NUM(i, 6); + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(a, REG_NUM(i, 6), cpu->R[REG_NUM(i, 0)]); + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_MOV_IMM8() +{ + const u32 &i = cpu->instruction; + cpu->R[REG_NUM(i, 8)] = i & 0xFF; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 8)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 8)] == 0; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_CMP_IMM8() +{ + const u32 &i = cpu->instruction; + u32 tmp = cpu->R[REG_NUM(i, 8)] - (i & 0xFF); + cpu->CPSR.bits.N = BIT31(tmp); + cpu->CPSR.bits.Z = tmp == 0; + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_ADD_IMM8() +{ + const u32 &i = cpu->instruction; + u32 tmp = cpu->R[REG_NUM(i, 8)] + (i & 0xFF); + cpu->CPSR.bits.N = BIT31(tmp); + cpu->CPSR.bits.Z = tmp == 0; + cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); + cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); + cpu->R[REG_NUM(i, 8)] = tmp; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_SUB_IMM8() +{ + const u32 &i = cpu->instruction; + u32 tmp = cpu->R[REG_NUM(i, 8)] - (i & 0xFF); + cpu->CPSR.bits.N = BIT31(tmp); + cpu->CPSR.bits.Z = tmp == 0; + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 8)], (i & 0xFF), tmp); + cpu->R[REG_NUM(i, 8)] = tmp; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_AND() +{ + const u32 &i = cpu->instruction; + cpu->R[REG_NUM(i, 0)] &= cpu->R[REG_NUM(i, 3)]; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_EOR() +{ + const u32 &i = cpu->instruction; + cpu->R[REG_NUM(i, 0)] ^= cpu->R[REG_NUM(i, 3)]; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_LSL_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_NUM(i, 3)]&0xFF; + + if(!v) + { + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + return 3; + } + if(v<32) + { + cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], 32-v); + cpu->R[REG_NUM(i, 0)] <<= v; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + return 3; + } + if(v==32) + cpu->CPSR.bits.C = BIT0(cpu->R[REG_NUM(i, 0)]); + else + cpu->CPSR.bits.C = 0; + cpu->R[REG_NUM(i, 0)] = 0; + cpu->CPSR.bits.N = 0; + cpu->CPSR.bits.Z = 1; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_LSR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_NUM(i, 3)]&0xFF; + + if(!v) + { + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + return 3; + } + if(v<32) + { + cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1); + cpu->R[REG_NUM(i, 0)] >>= v; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + return 3; + } + if(v==32) + cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]); + else + cpu->CPSR.bits.C = 0; + cpu->R[REG_NUM(i, 0)] = 0; + cpu->CPSR.bits.N = 0; + cpu->CPSR.bits.Z = 1; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_ASR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_NUM(i, 3)]&0xFF; + + if(!v) + { + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + return 3; + } + if(v<32) + { + cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1); + cpu->R[REG_NUM(i, 0)] = (u32)(((s32)cpu->R[REG_NUM(i, 0)]) >> v); + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + return 3; + } + + cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->R[REG_NUM(i, 0)] = BIT31(cpu->R[REG_NUM(i, 0)])*0xFFFFFFFF; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_ADC_REG() +{ + const u32 &i = cpu->instruction; + u32 a = cpu->R[REG_NUM(i, 0)]; + u32 b = cpu->R[REG_NUM(i, 3)]; + u32 tmp = b + cpu->CPSR.bits.C; + u32 res = a + tmp; + + cpu->R[REG_NUM(i, 0)] = res; + + cpu->CPSR.bits.N = BIT31(res); + cpu->CPSR.bits.Z = res == 0; + + //the below UNSIGNED_OVERFLOW calculation is the clever way of doing it + //but just to keep from making a mistake, lets assert that it matches the precise definition of unsigned overflow + static long passcount = 0; + assert(++passcount); + assert( + ((((u64)a+(u64)b+cpu->CPSR.bits.C)>>32)&1) + == (UNSIGNED_OVERFLOW(b, (u32) cpu->CPSR.bits.C, tmp) | UNSIGNED_OVERFLOW(tmp, a, res)) + ); + + cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(b, (u32) cpu->CPSR.bits.C, tmp) | UNSIGNED_OVERFLOW(tmp, a, res); + cpu->CPSR.bits.V = SIGNED_OVERFLOW(b, (u32) cpu->CPSR.bits.C, tmp) | SIGNED_OVERFLOW(tmp, a, res); + + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_SBC_REG() +{ + const u32 &i = cpu->instruction; + u32 a = cpu->R[REG_NUM(i, 0)]; + u32 b = cpu->R[REG_NUM(i, 3)]; + u32 tmp = a - (!cpu->CPSR.bits.C); + u32 res = tmp - b; + cpu->R[REG_NUM(i, 0)] = res; + + cpu->CPSR.bits.N = BIT31(res); + cpu->CPSR.bits.Z = res == 0; + + //the below UNSIGNED_UNDERFLOW calculation is the clever way of doing it + //but just to keep from making a mistake, lets assert that it matches the precise definition of unsigned overflow + static long passcount = 0; + assert(++passcount); + assert( + ((((u64)a-(u64)b-(!cpu->CPSR.bits.C))>>32)&1) + == UNSIGNED_UNDERFLOW(a, b, res) + ); + + //zero 31-dec-2008 - apply normatt's fixed logic from the arm SBC instruction + //although it seemed a bit odd to me and to whomever wrote this for SBC not to work similar to ADC.. + //but thats how it is. + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(a, b, res); + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(a, b, res); + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_ROR_REG() +{ + const u32 &i = cpu->instruction; + u32 v = cpu->R[REG_NUM(i, 3)]&0xFF; + + if(v == 0) + { + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + return 3; + } + v &= 0x1F; + if(v == 0) + { + cpu->CPSR.bits.C = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + return 3; + } + cpu->CPSR.bits.C = BIT_N(cpu->R[REG_NUM(i, 0)], v-1); + cpu->R[REG_NUM(i, 0)] = ROR(cpu->R[REG_NUM(i, 0)], v); + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_TST() +{ + const u32 &i = cpu->instruction; + u32 tmp = cpu->R[REG_NUM(i, 0)] & cpu->R[REG_NUM(i, 3)]; + cpu->CPSR.bits.N = BIT31(tmp); + cpu->CPSR.bits.Z = tmp == 0; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_NEG() +{ + const u32 &i = cpu->instruction; + u32 a = cpu->R[REG_NUM(i, 3)]; + cpu->R[REG_NUM(i, 0)] = -((signed int)a); + + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW((u32)0, a, cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.V = SIGNED_UNDERFLOW((u32)0, a, cpu->R[REG_NUM(i, 0)]); + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_CMP() +{ + const u32 &i = cpu->instruction; + u32 tmp = cpu->R[REG_NUM(i, 0)] -cpu->R[REG_NUM(i, 3)]; + + cpu->CPSR.bits.N = BIT31(tmp); + cpu->CPSR.bits.Z = tmp == 0; + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_CMN() +{ + const u32 &i = cpu->instruction; + u32 tmp = cpu->R[REG_NUM(i, 0)] + cpu->R[REG_NUM(i, 3)]; + + //emu_halt(); + //log::ajouter("OP_CMN THUMB"); + cpu->CPSR.bits.N = BIT31(tmp); + cpu->CPSR.bits.Z = tmp == 0; + cpu->CPSR.bits.C = UNSIGNED_OVERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); + cpu->CPSR.bits.V = SIGNED_OVERFLOW(cpu->R[REG_NUM(i, 0)], cpu->R[REG_NUM(i, 3)], tmp); + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_ORR() +{ + const u32 &i = cpu->instruction; + cpu->R[REG_NUM(i, 0)] |= cpu->R[REG_NUM(i, 3)]; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_MUL_REG() +{ + const u32 &i = cpu->instruction; + cpu->R[REG_NUM(i, 0)] *= cpu->R[REG_NUM(i, 3)]; + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_BIC() +{ + const u32 &i = cpu->instruction; + cpu->R[REG_NUM(i, 0)] &= (~cpu->R[REG_NUM(i, 3)]); + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_MVN() +{ + const u32 &i = cpu->instruction; + cpu->R[REG_NUM(i, 0)] = (~cpu->R[REG_NUM(i, 3)]); + cpu->CPSR.bits.N = BIT31(cpu->R[REG_NUM(i, 0)]); + cpu->CPSR.bits.Z = cpu->R[REG_NUM(i, 0)] == 0; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_ADD_SPE() +{ + const u32 &i = cpu->instruction; + u32 Rd = (i&7) | ((i>>4)&8); + cpu->R[Rd] += cpu->R[REG_POS(i, 3)]; + + if(Rd==15) + cpu->next_instruction = cpu->R[15]; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_CMP_SPE() +{ + const u32 &i = cpu->instruction; + u32 Rn = (i&7) | ((i>>4)&8); + u32 tmp = cpu->R[Rn] -cpu->R[REG_POS(i, 3)]; + + cpu->CPSR.bits.N = BIT31(tmp); + cpu->CPSR.bits.Z = tmp == 0; + cpu->CPSR.bits.C = !UNSIGNED_UNDERFLOW(cpu->R[Rn], cpu->R[REG_POS(i, 3)], tmp); + cpu->CPSR.bits.V = SIGNED_UNDERFLOW(cpu->R[Rn], cpu->R[REG_POS(i, 3)], tmp); + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_MOV_SPE() +{ + const u32 &i = cpu->instruction; + u32 Rd = (i&7) | ((i>>4)&8); + cpu->R[Rd] = cpu->R[REG_POS(i, 3)]; + + if(Rd==15) + cpu->next_instruction = cpu->R[15]; + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_BX_THUMB() +{ + u32 Rm = cpu->R[REG_POS(cpu->instruction, 3)]; + + cpu->CPSR.bits.T = BIT0(Rm); + cpu->R[15] = (Rm & 0xFFFFFFFE); + cpu->next_instruction = cpu->R[15]; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_BLX_THUMB() +{ + u32 Rm = cpu->R[REG_POS(cpu->instruction, 3)]; + + cpu->CPSR.bits.T = BIT0(Rm); + cpu->R[14] = cpu->next_instruction | 1; + cpu->R[15] = (Rm & 0xFFFFFFFE); + cpu->next_instruction = cpu->R[15]; + + return 3; +} + +TEMPLATE static u32 FASTCALL OP_LDR_PCREL() +{ + u32 adr = (cpu->R[15]&0xFFFFFFFC) + ((cpu->instruction&0xFF)<<2); + + cpu->R[REG_NUM(cpu->instruction, 8)] = READ32(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 6)] + cpu->R[REG_NUM(i, 3)]; + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_NUM(i, 0)]); + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; + WRITE16(cpu->mem_if->data, adr, ((u16)cpu->R[REG_NUM(i, 0)])); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; + WRITE8(cpu->mem_if->data, adr, ((u8)cpu->R[REG_NUM(i, 0)])); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSB_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; + cpu->R[REG_NUM(i, 0)] = (s32)((s8)READ8(cpu->mem_if->data, adr)); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = (cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]); + u32 tempValue = READ32(cpu->mem_if->data, adr&0xFFFFFFFC); + + adr = (adr&3)*8; + tempValue = (tempValue>>adr) | (tempValue<<(32-adr)); + cpu->R[REG_NUM(i, 0)] = tempValue; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; + cpu->R[REG_NUM(i, 0)] = (u32)READ16(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; + cpu->R[REG_NUM(i, 0)] = (u32)READ8(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRSH_REG_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 3)] + cpu->R[REG_NUM(i, 6)]; + cpu->R[REG_NUM(i, 0)] = (s32)((s16)READ16(cpu->mem_if->data, adr)); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>4)&0x7C); + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_NUM(i, 0)]); + + return 2 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>4)&0x7C); + u32 tempValue = READ32(cpu->mem_if->data, adr&0xFFFFFFFC); + adr = (adr&3)*8; + tempValue = (tempValue>>adr) | (tempValue<<(32-adr)); + cpu->R[REG_NUM(i, 0)] = tempValue; + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRB_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>6)&0x1F); + WRITE8(cpu->mem_if->data, adr, (u8)cpu->R[REG_NUM(i, 0)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRB_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>6)&0x1F); + cpu->R[REG_NUM(i, 0)] = READ8(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STRH_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>5)&0x3E); + WRITE16(cpu->mem_if->data, adr, (u16)cpu->R[REG_NUM(i, 0)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDRH_IMM_OFF() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 3)] + ((i>>5)&0x3E); + cpu->R[REG_NUM(i, 0)] = READ16(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_STR_SPREL() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[13] + ((i&0xFF)<<2); + WRITE32(cpu->mem_if->data, adr, cpu->R[REG_NUM(i, 8)]); + + return 2 + MMU.MMU_WAIT16[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_LDR_SPREL() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[13] + ((i&0xFF)<<2); + cpu->R[REG_NUM(i, 8)] = READ32(cpu->mem_if->data, adr); + + return 3 + MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; +} + +TEMPLATE static u32 FASTCALL OP_ADD_2PC() +{ + const u32 &i = cpu->instruction; + cpu->R[REG_NUM(i, 8)] = (cpu->R[15]&0xFFFFFFFC) + ((i&0xFF)<<2); + + return 5; +} + +TEMPLATE static u32 FASTCALL OP_ADD_2SP() +{ + const u32 &i = cpu->instruction; + cpu->R[REG_NUM(i, 8)] = cpu->R[13] + ((i&0xFF)<<2); + + return 2; +} + +TEMPLATE static u32 FASTCALL OP_ADJUST_P_SP() +{ + cpu->R[13] += ((cpu->instruction&0x7F)<<2); + + return 1; +} + +TEMPLATE static u32 FASTCALL OP_ADJUST_M_SP() +{ + cpu->R[13] -= ((cpu->instruction&0x7F)<<2); + + return 1; +} + +TEMPLATE static u32 FASTCALL OP_PUSH() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[13] - 4; + u32 c = 0, j; + + for(j = 0; j<8; ++j) + if(BIT_N(i, 7-j)) + { + WRITE32(cpu->mem_if->data, adr, cpu->R[7-j]); + c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + adr -= 4; + } + cpu->R[13] = adr + 4; + + return c + 3; +} + +TEMPLATE static u32 FASTCALL OP_PUSH_LR() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[13] - 4; + u32 c = 0, j; + + WRITE32(cpu->mem_if->data, adr, cpu->R[14]); + c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + adr -= 4; + + for(j = 0; j<8; ++j) + if(BIT_N(i, 7-j)) + { + WRITE32(cpu->mem_if->data, adr, cpu->R[7-j]); + c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + adr -= 4; + } + cpu->R[13] = adr + 4; + + return c + 4; +} + +TEMPLATE static u32 FASTCALL OP_POP() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[13]; + u32 c = 0, j; + + for(j = 0; j<8; ++j) + if(BIT_N(i, j)) + { + cpu->R[j] = READ32(cpu->mem_if->data, adr); + c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + adr += 4; + } + cpu->R[13] = adr; + + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_POP_PC() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[13]; + u32 c = 0, j; + u32 v; + + for(j = 0; j<8; ++j) + if(BIT_N(i, j)) + { + cpu->R[j] = READ32(cpu->mem_if->data, adr); + c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + adr += 4; + } + + v = READ32(cpu->mem_if->data, adr); + c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + cpu->R[15] = v & 0xFFFFFFFE; + cpu->next_instruction = v & 0xFFFFFFFE; + if(PROCNUM==0) + cpu->CPSR.bits.T = BIT0(v); + adr += 4; + + cpu->R[13] = adr; + return c + 5; +} + +TEMPLATE static u32 FASTCALL OP_BKPT_THUMB() +{ + return 1; +} + +TEMPLATE static u32 FASTCALL OP_STMIA_THUMB() +{ + const u32 &i = cpu->instruction; + u32 adr = cpu->R[REG_NUM(i, 8)]; + u32 c = 0, j; + + for(j = 0; j<8; ++j) + if(BIT_N(i, j)) + { + WRITE32(cpu->mem_if->data, adr, cpu->R[j]); + c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + adr += 4; + } + cpu->R[REG_NUM(i, 8)] = adr; + return c + 2; +} + +TEMPLATE static u32 FASTCALL OP_LDMIA_THUMB() +{ + const u32 &i = cpu->instruction; + u32 regIndex = REG_NUM(i, 8); + u32 adr = cpu->R[regIndex]; + u32 c = 0, j; + + for(j = 0; j<8; ++j) + if(BIT_N(i, j)) + { + cpu->R[j] = READ32(cpu->mem_if->data, adr); + c += MMU.MMU_WAIT32[PROCNUM][(adr>>24)&0xF]; + adr += 4; + } + + // Only over-write if not on the read list + if(!BIT_N(i, regIndex)) + cpu->R[regIndex] = adr; + + return c + 3; +} + +TEMPLATE static u32 FASTCALL OP_B_COND() +{ + const u32 &i = cpu->instruction; + if(!TEST_COND((i>>8)&0xF, 0, cpu->CPSR)) + return 1; + + cpu->R[15] += ((s32)((s8)(i&0xFF)))<<1; + cpu->next_instruction = cpu->R[15]; + return 3; +} + +TEMPLATE static u32 FASTCALL OP_SWI_THUMB() +{ + u32 swinum = cpu->instruction & 0xFF; + + //ideas-style debug prints + if(swinum==0xFC) { + IdeasLog(cpu); + return 0; + } + + if(cpu->swi_tab) { + //zero 25-dec-2008 - in arm, we were masking to 0x1F. + //this is probably safer since an invalid opcode could crash the emu + //zero 30-jun-2009 - but they say that the ideas 0xFF should crash the device... + //u32 swinum = cpu->instruction & 0xFF; + swinum &= 0x1F; + return cpu->swi_tab[swinum]() + 3; + } + else { + /* we use an irq thats not in the irq tab, as + it was replaced duie to a changed intVector */ + Status_Reg tmp = cpu->CPSR; + armcpu_switchMode(cpu, SVC); /* enter svc mode */ + cpu->R[14] = cpu->next_instruction; /* jump to swi Vector */ + cpu->SPSR = tmp; /* save old CPSR as new SPSR */ + cpu->CPSR.bits.T = 0; /* handle as ARM32 code */ + cpu->CPSR.bits.I = 1; + cpu->R[15] = cpu->intVector + 0x08; + cpu->next_instruction = cpu->R[15]; + return 3; + } +} + +#define SIGNEEXT_IMM11(i) (((i)&0x7FF) | (BIT10(i) * 0xFFFFF800)) + +TEMPLATE static u32 FASTCALL OP_B_UNCOND() +{ + const u32 &i = cpu->instruction; + cpu->R[15] += (SIGNEEXT_IMM11(i)<<1); + cpu->next_instruction = cpu->R[15]; + return 3; +} + +TEMPLATE static u32 FASTCALL OP_BLX() +{ + const u32 &i = cpu->instruction; + cpu->R[15] = (cpu->R[14] + ((i&0x7FF)<<1))&0xFFFFFFFC; + cpu->R[14] = cpu->next_instruction | 1; + cpu->next_instruction = cpu->R[15]; + cpu->CPSR.bits.T = 0; + return 3; +} + +TEMPLATE static u32 FASTCALL OP_BL_10() +{ + const u32 &i = cpu->instruction; + cpu->R[14] = cpu->R[15] + (SIGNEEXT_IMM11(i)<<12); + return 1; +} + +TEMPLATE static u32 FASTCALL OP_BL_THUMB() +{ + const u32 &i = cpu->instruction; + cpu->R[15] = (cpu->R[14] + ((i&0x7FF)<<1)); + cpu->R[14] = cpu->next_instruction | 1; + cpu->next_instruction = cpu->R[15]; + return 3; +} + +#define TYPE_RETOUR u32 +#define CALLTYPE FASTCALL +#define PARAMETRES +#define NOM_THUMB_TAB thumb_instructions_set_0 +#define TABDECL(x) x<0> + +#include "thumb_tabdef.inc" + +#undef TYPE_RETOUR +#undef PARAMETRES +#undef CALLTYPE +#undef NOM_THUMB_TAB +#undef TABDECL + +#define TYPE_RETOUR u32 +#define PARAMETRES +#define CALLTYPE FASTCALL +#define NOM_THUMB_TAB thumb_instructions_set_1 +#define TABDECL(x) x<1> + +#include "thumb_tabdef.inc" diff --git a/desmume/src/thumb_instructions.h b/src/thumb_instructions.h similarity index 97% rename from desmume/src/thumb_instructions.h rename to src/thumb_instructions.h index 08db2521c..1aa89fb76 100644 --- a/desmume/src/thumb_instructions.h +++ b/src/thumb_instructions.h @@ -1,31 +1,31 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef THUMB_INSTRUCTIONS_H -#define THUMB_INSTRUCTIONS_H - -#include "armcpu.h" - -extern u32 (FASTCALL* thumb_instructions_set_0[1024])(); -extern u32 (FASTCALL* thumb_instructions_set_1[1024])(); - -#endif - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef THUMB_INSTRUCTIONS_H +#define THUMB_INSTRUCTIONS_H + +#include "armcpu.h" + +extern u32 (FASTCALL* thumb_instructions_set_0[1024])(); +extern u32 (FASTCALL* thumb_instructions_set_1[1024])(); + +#endif + diff --git a/desmume/src/thumb_tabdef.inc b/src/thumb_tabdef.inc similarity index 100% rename from desmume/src/thumb_tabdef.inc rename to src/thumb_tabdef.inc diff --git a/desmume/src/types.h b/src/types.h similarity index 71% rename from desmume/src/types.h rename to src/types.h index 8c5c49324..fb7c8a4bf 100644 --- a/desmume/src/types.h +++ b/src/types.h @@ -1,399 +1,336 @@ -/* Copyright (C) 2005 Guillaume Duhamel - Copyright (C) 2008-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef TYPES_HPP -#define TYPES_HPP - -//todo - everyone will want to support this eventually, i suppose -#ifdef _MSC_VER -#include "config.h" -#endif - -#ifdef _MSC_VER -#define ENABLE_SSE -#define ENABLE_SSE2 -#endif - -#ifdef NOSSE -#undef ENABLE_SSE -#endif - -#ifdef NOSSE2 -#undef ENABLE_SSE2 -#endif - -#ifdef _WIN32 -#define strcasecmp(x,y) _stricmp(x,y) -#define snprintf _snprintf -#else -#define WINAPI -#endif - -#ifdef __GNUC__ -#include -#ifndef PATH_MAX -#define MAX_PATH 1024 -#else -#define MAX_PATH PATH_MAX -#endif -#endif - -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) -#define ALIGN(X) __declspec(align(X)) -#elif __GNUC__ -#define ALIGN(X) __attribute__ ((aligned (X))) -#else -#define ALIGN(X) -#endif - -#define CACHE_ALIGN ALIGN(32) - -#ifndef FASTCALL -#ifdef __MINGW32__ -#define FASTCALL __attribute__((fastcall)) -#elif defined (__i386__) -#define FASTCALL __attribute__((regparm(3))) -#elif defined(_MSC_VER) || defined(__INTEL_COMPILER) -#define FASTCALL -#else -#define FASTCALL -#endif -#endif - -#ifdef _MSC_VER -#define _CDECL_ __cdecl -#else -#define _CDECL_ -#endif - -#ifndef INLINE -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) -#define INLINE _inline -#else -#define INLINE inline -#endif -#endif - -#ifndef FORCEINLINE -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) -#define FORCEINLINE __forceinline -#define MSC_FORCEINLINE __forceinline -#else -#define FORCEINLINE INLINE -#define MSC_FORCEINLINE -#endif -#endif - -#if defined(__LP64__) -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef unsigned long long u64; - -typedef signed char s8; -typedef signed short s16; -typedef signed int s32; -typedef signed long long s64; -#else -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) -typedef unsigned __int64 u64; -#else -typedef unsigned long long u64; -#endif - -typedef signed char s8; -typedef signed short s16; -typedef signed int s32; -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) -typedef __int64 s64; -#else -typedef signed long long s64; -#endif -#endif - -typedef u8 uint8; -typedef u16 uint16; - -#ifndef OBJ_C -typedef u32 uint32; -#else -#define uint32 u32 //uint32 is defined in Leopard somewhere, avoid conflicts -#endif - -/*---------- GPU3D fixed-points types -----------*/ - -typedef s32 f32; -#define inttof32(n) ((n) << 12) -#define f32toint(n) ((n) >> 12) -#define floattof32(n) ((int32)((n) * (1 << 12))) -#define f32tofloat(n) (((float)(n)) / (float)(1<<12)) - -typedef s16 t16; -#define f32tot16(n) ((t16)(n >> 8)) -#define inttot16(n) ((n) << 4) -#define t16toint(n) ((n) >> 4) -#define floattot16(n) ((t16)((n) * (1 << 4))) -#define t16ofloat(n) (((float)(n)) / (float)(1<<4)) - -typedef s16 v16; -#define inttov16(n) ((n) << 12) -#define f32tov16(n) (n) -#define floattov16(n) ((v16)((n) * (1 << 12))) -#define v16toint(n) ((n) >> 12) -#define v16tofloat(n) (((float)(n)) / (float)(1<<12)) - -typedef s16 v10; -#define inttov10(n) ((n) << 9) -#define f32tov10(n) ((v10)(n >> 3)) -#define v10toint(n) ((n) >> 9) -#define floattov10(n) ((v10)((n) * (1 << 9))) -#define v10tofloat(n) (((float)(n)) / (float)(1<<9)) - -/*----------------------*/ - -#ifndef OBJ_C -typedef int BOOL; -#else -//apple also defines BOOL -typedef int desmume_BOOL; -#define BOOL desmume_BOOL -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifdef __BIG_ENDIAN__ -#ifndef WORDS_BIGENDIAN -#define WORDS_BIGENDIAN -#endif -#endif - -#ifdef WORDS_BIGENDIAN -# define LOCAL_BE -#else -# define LOCAL_LE -#endif - -/* little endian (ds' endianess) to local endianess convert macros */ -#ifdef LOCAL_BE /* local arch is big endian */ -# define LE_TO_LOCAL_16(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff)) -# define LE_TO_LOCAL_32(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff)) -# define LE_TO_LOCAL_64(x) ((((x)&0xff)<<56)|(((x)&0xff00)<<40)|(((x)&0xff0000)<<24)|(((x)&0xff000000)<<8)|(((x)>>8)&0xff000000)|(((x)>>24)&0xff00)|(((x)>>40)&0xff00)|(((x)>>56)&0xff)) -# define LOCAL_TO_LE_16(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff)) -# define LOCAL_TO_LE_32(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff)) -# define LOCAL_TO_LE_64(x) ((((x)&0xff)<<56)|(((x)&0xff00)<<40)|(((x)&0xff0000)<<24)|(((x)&0xff000000)<<8)|(((x)>>8)&0xff000000)|(((x)>>24)&0xff00)|(((x)>>40)&0xff00)|(((x)>>56)&0xff)) -#else /* local arch is little endian */ -# define LE_TO_LOCAL_16(x) (x) -# define LE_TO_LOCAL_32(x) (x) -# define LE_TO_LOCAL_64(x) (x) -# define LOCAL_TO_LE_16(x) (x) -# define LOCAL_TO_LE_32(x) (x) -# define LOCAL_TO_LE_64(x) (x) -#endif - -// kilobytes and megabytes macro -#define MB(x) ((x)*1024*1024) -#define KB(x) ((x)*1024) - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - -#define CPU_STR(c) ((c==ARM9)?"ARM9":"ARM7") -typedef enum -{ - ARM9 = 0, - ARM7 = 1 -} cpu_id_t; - -///endian-flips count bytes. count should be even and nonzero. -inline void FlipByteOrder(u8 *src, u32 count) -{ - u8 *start=src; - u8 *end=src+count-1; - - if((count&1) || !count) return; /* This shouldn't happen. */ - - while(count--) - { - u8 tmp; - - tmp=*end; - *end=*start; - *start=tmp; - end--; - start++; - } -} - - - -inline u64 double_to_u64(double d) { - union { - u64 a; - double b; - } fuxor; - fuxor.b = d; - return fuxor.a; -} - -inline double u64_to_double(u64 u) { - union { - u64 a; - double b; - } fuxor; - fuxor.a = u; - return fuxor.b; -} - -inline u32 float_to_u32(float f) { - union { - u32 a; - float b; - } fuxor; - fuxor.b = f; - return fuxor.a; -} - -inline float u32_to_float(u32 u) { - union { - u32 a; - float b; - } fuxor; - fuxor.a = u; - return fuxor.b; -} - - -///stores a 32bit value into the provided byte array in guaranteed little endian form -inline void en32lsb(u8 *buf, u32 morp) -{ - buf[0]=(u8)(morp); - buf[1]=(u8)(morp>>8); - buf[2]=(u8)(morp>>16); - buf[3]=(u8)(morp>>24); -} - -inline void en16lsb(u8* buf, u16 morp) -{ - buf[0]=(u8)morp; - buf[1]=(u8)(morp>>8); -} - -///unpacks a 64bit little endian value from the provided byte array into host byte order -inline u64 de64lsb(u8 *morp) -{ - return morp[0]|(morp[1]<<8)|(morp[2]<<16)|(morp[3]<<24)|((u64)morp[4]<<32)|((u64)morp[5]<<40)|((u64)morp[6]<<48)|((u64)morp[7]<<56); -} - -///unpacks a 32bit little endian value from the provided byte array into host byte order -inline u32 de32lsb(u8 *morp) -{ - return morp[0]|(morp[1]<<8)|(morp[2]<<16)|(morp[3]<<24); -} - -///unpacks a 16bit little endian value from the provided byte array into host byte order -inline u16 de16lsb(u8 *morp) -{ - return morp[0]|(morp[1]<<8); -} - -#ifndef ARRAY_SIZE -//taken from winnt.h -extern "C++" // templates cannot be declared to have 'C' linkage -template -char (*BLAHBLAHBLAH( UNALIGNED T (&)[N] ))[N]; - -#define ARRAY_SIZE(A) (sizeof(*BLAHBLAHBLAH(A))) -#endif - - -//fairly standard for loop macros -#define MACRODO1(TRICK,TODO) { const int X = TRICK; TODO; } -#define MACRODO2(X,TODO) { MACRODO1((X),TODO) MACRODO1(((X)+1),TODO) } -#define MACRODO4(X,TODO) { MACRODO2((X),TODO) MACRODO2(((X)+2),TODO) } -#define MACRODO8(X,TODO) { MACRODO4((X),TODO) MACRODO4(((X)+4),TODO) } -#define MACRODO16(X,TODO) { MACRODO8((X),TODO) MACRODO8(((X)+8),TODO) } -#define MACRODO32(X,TODO) { MACRODO16((X),TODO) MACRODO16(((X)+16),TODO) } -#define MACRODO64(X,TODO) { MACRODO32((X),TODO) MACRODO32(((X)+32),TODO) } -#define MACRODO128(X,TODO) { MACRODO64((X),TODO) MACRODO64(((X)+64),TODO) } -#define MACRODO256(X,TODO) { MACRODO128((X),TODO) MACRODO128(((X)+128),TODO) } - -//this one lets you loop any number of times (as long as N<256) -#define MACRODO_N(N,TODO) {\ - if((N)&0x100) MACRODO256(0,TODO); \ - if((N)&0x080) MACRODO128((N)&(0x100),TODO); \ - if((N)&0x040) MACRODO64((N)&(0x100|0x080),TODO); \ - if((N)&0x020) MACRODO32((N)&(0x100|0x080|0x040),TODO); \ - if((N)&0x010) MACRODO16((N)&(0x100|0x080|0x040|0x020),TODO); \ - if((N)&0x008) MACRODO8((N)&(0x100|0x080|0x040|0x020|0x010),TODO); \ - if((N)&0x004) MACRODO4((N)&(0x100|0x080|0x040|0x020|0x010|0x008),TODO); \ - if((N)&0x002) MACRODO2((N)&(0x100|0x080|0x040|0x020|0x010|0x008|0x004),TODO); \ - if((N)&0x001) MACRODO1((N)&(0x100|0x080|0x040|0x020|0x010|0x008|0x004|0x002),TODO); \ -} - -//--------------------------- -//Binary constant generator macro By Tom Torfs - donated to the public domain - -//turn a numeric literal into a hex constant -//(avoids problems with leading zeroes) -//8-bit constants max value 0x11111111, always fits in unsigned long -#define HEX__(n) 0x##n##LU - -//8-bit conversion function -#define B8__(x) ((x&0x0000000FLU)?1:0) \ -+((x&0x000000F0LU)?2:0) \ -+((x&0x00000F00LU)?4:0) \ -+((x&0x0000F000LU)?8:0) \ -+((x&0x000F0000LU)?16:0) \ -+((x&0x00F00000LU)?32:0) \ -+((x&0x0F000000LU)?64:0) \ -+((x&0xF0000000LU)?128:0) - -//for upto 8-bit binary constants -#define B8(d) ((unsigned char)B8__(HEX__(d))) - -// for upto 16-bit binary constants, MSB first -#define B16(dmsb,dlsb) (((unsigned short)B8(dmsb)<<8) \ -+ B8(dlsb)) - -// for upto 32-bit binary constants, MSB first */ -#define B32(dmsb,db2,db3,dlsb) (((unsigned long)B8(dmsb)<<24) \ -+ ((unsigned long)B8(db2)<<16) \ -+ ((unsigned long)B8(db3)<<8) \ -+ B8(dlsb)) - -//Sample usage: -//B8(01010101) = 85 -//B16(10101010,01010101) = 43605 -//B32(10000000,11111111,10101010,01010101) = 2164238933 -//--------------------------- - -#ifndef CTASSERT -#define CTASSERT(x) typedef char __assert ## y[(x) ? 1 : -1] -#endif - -#endif +/* Copyright (C) 2005 Guillaume Duhamel + Copyright (C) 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef TYPES_HPP +#define TYPES_HPP + +//todo - everyone will want to support this eventually, i suppose +#ifdef _MSC_VER +#include "config.h" +#endif + +#ifndef _MSC_VER +#define NOSSE2 +#endif + +#ifdef _WIN32 +#define strcasecmp(x,y) _stricmp(x,y) +#define snprintf _snprintf +#else +#define WINAPI +#endif + +#ifdef __GNUC__ +#include +#define MAX_PATH PATH_MAX +#endif + +#if defined(_MSC_VER) || defined(__INTEL_COMPILER) +#define ALIGN(X) __declspec(align(X)) +#elif __GNUC__ +#define ALIGN(X) __attribute__ ((aligned (X))) +#else +#define ALIGN(X) +#endif + +#define CACHE_ALIGN ALIGN(32) + +#ifndef FASTCALL +#ifdef __MINGW32__ +#define FASTCALL __attribute__((fastcall)) +#elif defined (__i386__) +#define FASTCALL __attribute__((regparm(3))) +#elif defined(_MSC_VER) || defined(__INTEL_COMPILER) +#define FASTCALL +#else +#define FASTCALL +#endif +#endif + +#ifdef _MSC_VER +#define _CDECL_ __cdecl +#else +#define _CDECL_ +#endif + +#ifndef INLINE +#if defined(_MSC_VER) || defined(__INTEL_COMPILER) +#define INLINE _inline +#else +#define INLINE inline +#endif +#endif + +#ifndef FORCEINLINE +#if defined(_MSC_VER) || defined(__INTEL_COMPILER) +#define FORCEINLINE __forceinline +#define MSC_FORCEINLINE __forceinline +#else +#define FORCEINLINE INLINE +#define MSC_FORCEINLINE +#endif +#endif + +//#ifndef _PREFETCH +//#if (defined(_MSC_VER) || defined(__INTEL_COMPILER)) && !defined(NOSSE2) +//#include +//#include +//#define _PREFETCH(X) _mm_prefetch((char*)(X),_MM_HINT_T0); +//#define _PREFETCHNTA(X) _mm_prefetch((char*)(X),_MM_HINT_NTA); +//#else +#define _PREFETCH(X) {} +#define _PREFETCHNTA(X) {} +//#endif +//#endif + + + +#if defined(__LP64__) +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long u64; + +typedef signed char s8; +typedef signed short s16; +typedef signed int s32; +typedef signed long long s64; +#else +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +#if defined(_MSC_VER) || defined(__INTEL_COMPILER) +typedef unsigned __int64 u64; +#else +typedef unsigned long long u64; +#endif + +typedef signed char s8; +typedef signed short s16; +typedef signed int s32; +#if defined(_MSC_VER) || defined(__INTEL_COMPILER) +typedef __int64 s64; +#else +typedef signed long long s64; +#endif +#endif + +typedef u8 uint8; +typedef u16 uint16; + +#ifndef OBJ_C +typedef u32 uint32; +#else +#define uint32 u32 //uint32 is defined in Leopard somewhere, avoid conflicts +#endif + +/*---------- GPU3D fixed-points types -----------*/ + +typedef s32 f32; +#define inttof32(n) ((n) << 12) +#define f32toint(n) ((n) >> 12) +#define floattof32(n) ((int32)((n) * (1 << 12))) +#define f32tofloat(n) (((float)(n)) / (float)(1<<12)) + +typedef s16 t16; +#define f32tot16(n) ((t16)(n >> 8)) +#define inttot16(n) ((n) << 4) +#define t16toint(n) ((n) >> 4) +#define floattot16(n) ((t16)((n) * (1 << 4))) +#define t16ofloat(n) (((float)(n)) / (float)(1<<4)) + +typedef s16 v16; +#define inttov16(n) ((n) << 12) +#define f32tov16(n) (n) +#define floattov16(n) ((v16)((n) * (1 << 12))) +#define v16toint(n) ((n) >> 12) +#define v16tofloat(n) (((float)(n)) / (float)(1<<12)) + +typedef s16 v10; +#define inttov10(n) ((n) << 9) +#define f32tov10(n) ((v10)(n >> 3)) +#define v10toint(n) ((n) >> 9) +#define floattov10(n) ((v10)((n) * (1 << 9))) +#define v10tofloat(n) (((float)(n)) / (float)(1<<9)) + +/*----------------------*/ + +#ifndef OBJ_C +typedef int BOOL; +#else +//apple also defines BOOL +typedef int desmume_BOOL; +#define BOOL desmume_BOOL +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifdef __BIG_ENDIAN__ +#ifndef WORDS_BIGENDIAN +#define WORDS_BIGENDIAN +#endif +#endif + +#ifdef WORDS_BIGENDIAN +# define LOCAL_BE +#else +# define LOCAL_LE +#endif + +/* little endian (ds' endianess) to local endianess convert macros */ +#ifdef LOCAL_BE /* local arch is big endian */ +# define LE_TO_LOCAL_16(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff)) +# define LE_TO_LOCAL_32(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff)) +# define LE_TO_LOCAL_64(x) ((((x)&0xff)<<56)|(((x)&0xff00)<<40)|(((x)&0xff0000)<<24)|(((x)&0xff000000)<<8)|(((x)>>8)&0xff000000)|(((x)>>24)&0xff00)|(((x)>>40)&0xff00)|(((x)>>56)&0xff)) +# define LOCAL_TO_LE_16(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff)) +# define LOCAL_TO_LE_32(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff)) +# define LOCAL_TO_LE_64(x) ((((x)&0xff)<<56)|(((x)&0xff00)<<40)|(((x)&0xff0000)<<24)|(((x)&0xff000000)<<8)|(((x)>>8)&0xff000000)|(((x)>>24)&0xff00)|(((x)>>40)&0xff00)|(((x)>>56)&0xff)) +#else /* local arch is little endian */ +# define LE_TO_LOCAL_16(x) (x) +# define LE_TO_LOCAL_32(x) (x) +# define LE_TO_LOCAL_64(x) (x) +# define LOCAL_TO_LE_16(x) (x) +# define LOCAL_TO_LE_32(x) (x) +# define LOCAL_TO_LE_64(x) (x) +#endif + +// kilobytes and megabytes macro +#define MB(x) ((x)*1024*1024) +#define KB(x) ((x)*1024) + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) + +#define CPU_STR(c) ((c==ARM9)?"ARM9":"ARM7") +typedef enum +{ + ARM9 = 0, + ARM7 = 1 +} cpu_id_t; + +///endian-flips count bytes. count should be even and nonzero. +inline void FlipByteOrder(u8 *src, u32 count) +{ + u8 *start=src; + u8 *end=src+count-1; + + if((count&1) || !count) return; /* This shouldn't happen. */ + + while(count--) + { + u8 tmp; + + tmp=*end; + *end=*start; + *start=tmp; + end--; + start++; + } +} + + + +inline u64 double_to_u64(double d) { + union { + u64 a; + double b; + } fuxor; + fuxor.b = d; + return fuxor.a; +} + +inline double u64_to_double(u64 u) { + union { + u64 a; + double b; + } fuxor; + fuxor.a = u; + return fuxor.b; +} + +inline u32 float_to_u32(float f) { + union { + u32 a; + float b; + } fuxor; + fuxor.b = f; + return fuxor.a; +} + +inline float u32_to_float(u32 u) { + union { + u32 a; + float b; + } fuxor; + fuxor.a = u; + return fuxor.b; +} + + +///stores a 32bit value into the provided byte array in guaranteed little endian form +inline void en32lsb(u8 *buf, u32 morp) +{ + buf[0]=morp; + buf[1]=morp>>8; + buf[2]=morp>>16; + buf[3]=morp>>24; +} + +inline void en16lsb(u8* buf, u16 morp) +{ + buf[0]=morp; + buf[1]=morp>>8; +} + +///unpacks a 64bit little endian value from the provided byte array into host byte order +inline u64 de64lsb(u8 *morp) +{ + return morp[0]|(morp[1]<<8)|(morp[2]<<16)|(morp[3]<<24)|((u64)morp[4]<<32)|((u64)morp[5]<<40)|((u64)morp[6]<<48)|((u64)morp[7]<<56); +} + +///unpacks a 32bit little endian value from the provided byte array into host byte order +inline u32 de32lsb(u8 *morp) +{ + return morp[0]|(morp[1]<<8)|(morp[2]<<16)|(morp[3]<<24); +} + +///unpacks a 16bit little endian value from the provided byte array into host byte order +inline u16 de16lsb(u8 *morp) +{ + return morp[0]|(morp[1]<<8); +} + +#ifndef ARRAY_SIZE +//taken from winnt.h +extern "C++" // templates cannot be declared to have 'C' linkage +template +char (*BLAHBLAHBLAH( UNALIGNED T (&)[N] ))[N]; + +#define ARRAY_SIZE(A) (sizeof(*BLAHBLAHBLAH(A))) +#endif + + + +#endif diff --git a/desmume/src/utils/ConvertUTF.c b/src/utils/ConvertUTF.c similarity index 100% rename from desmume/src/utils/ConvertUTF.c rename to src/utils/ConvertUTF.c diff --git a/desmume/src/utils/ConvertUTF.h b/src/utils/ConvertUTF.h similarity index 97% rename from desmume/src/utils/ConvertUTF.h rename to src/utils/ConvertUTF.h index e26491536..bff37f5bc 100644 --- a/desmume/src/utils/ConvertUTF.h +++ b/src/utils/ConvertUTF.h @@ -1,149 +1,149 @@ -/* - * Copyright 2001-2004 Unicode, Inc. - * - * Disclaimer - * - * This source code is provided as is by Unicode, Inc. No claims are - * made as to fitness for any particular purpose. No warranties of any - * kind are expressed or implied. The recipient agrees to determine - * applicability of information provided. If this file has been - * purchased on magnetic or optical media from Unicode, Inc., the - * sole remedy for any claim will be exchange of defective media - * within 90 days of receipt. - * - * Limitations on Rights to Redistribute This Code - * - * Unicode, Inc. hereby grants the right to freely use the information - * supplied in this file in the creation of products supporting the - * Unicode Standard, and to make copies of this file in any form - * for internal or external distribution as long as this notice - * remains attached. - */ - -/* --------------------------------------------------------------------- - - Conversions between UTF32, UTF-16, and UTF-8. Header file. - - Several funtions are included here, forming a complete set of - conversions between the three formats. UTF-7 is not included - here, but is handled in a separate source file. - - Each of these routines takes pointers to input buffers and output - buffers. The input buffers are const. - - Each routine converts the text between *sourceStart and sourceEnd, - putting the result into the buffer between *targetStart and - targetEnd. Note: the end pointers are *after* the last item: e.g. - *(sourceEnd - 1) is the last item. - - The return result indicates whether the conversion was successful, - and if not, whether the problem was in the source or target buffers. - (Only the first encountered problem is indicated.) - - After the conversion, *sourceStart and *targetStart are both - updated to point to the end of last text successfully converted in - the respective buffers. - - Input parameters: - sourceStart - pointer to a pointer to the source buffer. - The contents of this are modified on return so that - it points at the next thing to be converted. - targetStart - similarly, pointer to pointer to the target buffer. - sourceEnd, targetEnd - respectively pointers to the ends of the - two buffers, for overflow checking only. - - These conversion functions take a ConversionFlags argument. When this - flag is set to strict, both irregular sequences and isolated surrogates - will cause an error. When the flag is set to lenient, both irregular - sequences and isolated surrogates are converted. - - Whether the flag is strict or lenient, all illegal sequences will cause - an error return. This includes sequences such as: , , - or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code - must check for illegal sequences. - - When the flag is set to lenient, characters over 0x10FFFF are converted - to the replacement character; otherwise (when the flag is set to strict) - they constitute an error. - - Output parameters: - The value "sourceIllegal" is returned from some routines if the input - sequence is malformed. When "sourceIllegal" is returned, the source - value will point to the illegal value that caused the problem. E.g., - in UTF-8 when a sequence is malformed, it points to the start of the - malformed sequence. - - Author: Mark E. Davis, 1994. - Rev History: Rick McGowan, fixes & updates May 2001. - Fixes & updates, Sept 2001. - ------------------------------------------------------------------------- */ - -/* --------------------------------------------------------------------- - The following 4 definitions are compiler-specific. - The C standard does not guarantee that wchar_t has at least - 16 bits, so wchar_t is no less portable than unsigned short! - All should be unsigned values to avoid sign extension during - bit mask & shift operations. ------------------------------------------------------------------------- */ - -typedef unsigned long UTF32; /* at least 32 bits */ -typedef unsigned short UTF16; /* at least 16 bits */ -typedef unsigned char UTF8; /* typically 8 bits */ -typedef unsigned char Boolean; /* 0 or 1 */ - -/* Some fundamental constants */ -#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD -#define UNI_MAX_BMP (UTF32)0x0000FFFF -#define UNI_MAX_UTF16 (UTF32)0x0010FFFF -#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF -#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF - -typedef enum { - conversionOK, /* conversion successful */ - sourceExhausted, /* partial character in source, but hit end */ - targetExhausted, /* insuff. room in target for conversion */ - sourceIllegal /* source sequence is illegal/malformed */ -} ConversionResult; - -typedef enum { - strictConversion = 0, - lenientConversion -} ConversionFlags; - -/* This is for C++ and does no harm in C */ -#ifdef __cplusplus -extern "C" { -#endif - -ConversionResult ConvertUTF8toUTF16 ( - const UTF8** sourceStart, const UTF8* sourceEnd, - UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); - -ConversionResult ConvertUTF16toUTF8 ( - const UTF16** sourceStart, const UTF16* sourceEnd, - UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); - -ConversionResult ConvertUTF8toUTF32 ( - const UTF8** sourceStart, const UTF8* sourceEnd, - UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); - -ConversionResult ConvertUTF32toUTF8 ( - const UTF32** sourceStart, const UTF32* sourceEnd, - UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); - -ConversionResult ConvertUTF16toUTF32 ( - const UTF16** sourceStart, const UTF16* sourceEnd, - UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); - -ConversionResult ConvertUTF32toUTF16 ( - const UTF32** sourceStart, const UTF32* sourceEnd, - UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); - -Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); - -#ifdef __cplusplus -} -#endif - -/* --------------------------------------------------------------------- */ +/* + * Copyright 2001-2004 Unicode, Inc. + * + * Disclaimer + * + * This source code is provided as is by Unicode, Inc. No claims are + * made as to fitness for any particular purpose. No warranties of any + * kind are expressed or implied. The recipient agrees to determine + * applicability of information provided. If this file has been + * purchased on magnetic or optical media from Unicode, Inc., the + * sole remedy for any claim will be exchange of defective media + * within 90 days of receipt. + * + * Limitations on Rights to Redistribute This Code + * + * Unicode, Inc. hereby grants the right to freely use the information + * supplied in this file in the creation of products supporting the + * Unicode Standard, and to make copies of this file in any form + * for internal or external distribution as long as this notice + * remains attached. + */ + +/* --------------------------------------------------------------------- + + Conversions between UTF32, UTF-16, and UTF-8. Header file. + + Several funtions are included here, forming a complete set of + conversions between the three formats. UTF-7 is not included + here, but is handled in a separate source file. + + Each of these routines takes pointers to input buffers and output + buffers. The input buffers are const. + + Each routine converts the text between *sourceStart and sourceEnd, + putting the result into the buffer between *targetStart and + targetEnd. Note: the end pointers are *after* the last item: e.g. + *(sourceEnd - 1) is the last item. + + The return result indicates whether the conversion was successful, + and if not, whether the problem was in the source or target buffers. + (Only the first encountered problem is indicated.) + + After the conversion, *sourceStart and *targetStart are both + updated to point to the end of last text successfully converted in + the respective buffers. + + Input parameters: + sourceStart - pointer to a pointer to the source buffer. + The contents of this are modified on return so that + it points at the next thing to be converted. + targetStart - similarly, pointer to pointer to the target buffer. + sourceEnd, targetEnd - respectively pointers to the ends of the + two buffers, for overflow checking only. + + These conversion functions take a ConversionFlags argument. When this + flag is set to strict, both irregular sequences and isolated surrogates + will cause an error. When the flag is set to lenient, both irregular + sequences and isolated surrogates are converted. + + Whether the flag is strict or lenient, all illegal sequences will cause + an error return. This includes sequences such as: , , + or in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code + must check for illegal sequences. + + When the flag is set to lenient, characters over 0x10FFFF are converted + to the replacement character; otherwise (when the flag is set to strict) + they constitute an error. + + Output parameters: + The value "sourceIllegal" is returned from some routines if the input + sequence is malformed. When "sourceIllegal" is returned, the source + value will point to the illegal value that caused the problem. E.g., + in UTF-8 when a sequence is malformed, it points to the start of the + malformed sequence. + + Author: Mark E. Davis, 1994. + Rev History: Rick McGowan, fixes & updates May 2001. + Fixes & updates, Sept 2001. + +------------------------------------------------------------------------ */ + +/* --------------------------------------------------------------------- + The following 4 definitions are compiler-specific. + The C standard does not guarantee that wchar_t has at least + 16 bits, so wchar_t is no less portable than unsigned short! + All should be unsigned values to avoid sign extension during + bit mask & shift operations. +------------------------------------------------------------------------ */ + +typedef unsigned long UTF32; /* at least 32 bits */ +typedef unsigned short UTF16; /* at least 16 bits */ +typedef unsigned char UTF8; /* typically 8 bits */ +typedef unsigned char Boolean; /* 0 or 1 */ + +/* Some fundamental constants */ +#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD +#define UNI_MAX_BMP (UTF32)0x0000FFFF +#define UNI_MAX_UTF16 (UTF32)0x0010FFFF +#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF +#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF + +typedef enum { + conversionOK, /* conversion successful */ + sourceExhausted, /* partial character in source, but hit end */ + targetExhausted, /* insuff. room in target for conversion */ + sourceIllegal /* source sequence is illegal/malformed */ +} ConversionResult; + +typedef enum { + strictConversion = 0, + lenientConversion +} ConversionFlags; + +/* This is for C++ and does no harm in C */ +#ifdef __cplusplus +extern "C" { +#endif + +ConversionResult ConvertUTF8toUTF16 ( + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF16toUTF8 ( + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF8toUTF32 ( + const UTF8** sourceStart, const UTF8* sourceEnd, + UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF32toUTF8 ( + const UTF32** sourceStart, const UTF32* sourceEnd, + UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF16toUTF32 ( + const UTF16** sourceStart, const UTF16* sourceEnd, + UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); + +ConversionResult ConvertUTF32toUTF16 ( + const UTF32** sourceStart, const UTF32* sourceEnd, + UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); + +Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); + +#ifdef __cplusplus +} +#endif + +/* --------------------------------------------------------------------- */ diff --git a/desmume/src/utils/decrypt/crc.cpp b/src/utils/decrypt/crc.cpp similarity index 98% rename from desmume/src/utils/decrypt/crc.cpp rename to src/utils/decrypt/crc.cpp index 30f62cf9e..e079ab28a 100644 --- a/desmume/src/utils/decrypt/crc.cpp +++ b/src/utils/decrypt/crc.cpp @@ -1,167 +1,167 @@ -//taken from ndstool -//http://devkitpro.cvs.sourceforge.net/viewvc/devkitpro/tools/nds/ndstool/source/crc.cpp?revision=1.2 - -/* crc.cpp - this file is part of DeSmuME - * - * Copyright (C) 2005-2006 Rafael Vuijk - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - Cyclic Redundancy Code (CRC) functions - by Rafael Vuijk (aka DarkFader) -*/ - -unsigned short ccitt16tab[] = -{ - 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, - 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, - 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, - 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, - 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, - 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, - 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, - 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, - 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, - 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, - 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, - 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, - 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, - 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, - 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, - 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, - 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, - 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, - 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, - 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, - 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, - 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, - 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, - 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, - 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, - 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, - 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, - 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, - 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, - 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, - 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, - 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 -}; - -unsigned short crc16tab[] = -{ - 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, - 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, - 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, - 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, - 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, - 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, - 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, - 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, - 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, - 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, - 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, - 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, - 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, - 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, - 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, - 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041, - 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, - 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441, - 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, - 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, - 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, - 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, - 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, - 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, - 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, - 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440, - 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, - 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, - 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, - 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, - 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, - 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 -}; - -unsigned long crc32tab[] = -{ - 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, - 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L, - 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L, - 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L, - 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL, - 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L, - 0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL, - 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L, - 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L, - 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL, - 0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L, - 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L, - 0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L, - 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL, - 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L, - 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL, - 0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL, - 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L, - 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L, - 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L, - 0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL, - 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L, - 0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL, - 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L, - 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L, - 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL, - 0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L, - 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L, - 0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L, - 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL, - 0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L, - 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL, - 0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL, - 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L, - 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L, - 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L, - 0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL, - 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L, - 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL, - 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L, - 0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L, - 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL, - 0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L, - 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L, - 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L, - 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL, - 0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L, - 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL, - 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL, - 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L, - 0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L, - 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L, - 0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL, - 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L, - 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL, - 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L, - 0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L, - 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL, - 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L, - 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L, - 0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L, - 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL, - 0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L, - 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL -}; +//taken from ndstool +//http://devkitpro.cvs.sourceforge.net/viewvc/devkitpro/tools/nds/ndstool/source/crc.cpp?revision=1.2 + +/* crc.cpp - this file is part of DeSmuME + * + * Copyright (C) 2005-2006 Rafael Vuijk + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + Cyclic Redundancy Code (CRC) functions + by Rafael Vuijk (aka DarkFader) +*/ + +unsigned short ccitt16tab[] = +{ + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, + 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, + 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, + 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, + 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, + 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, + 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, + 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, + 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, + 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, + 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, + 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, + 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, + 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, + 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, + 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, + 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, + 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, + 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, + 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, + 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, + 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, + 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 +}; + +unsigned short crc16tab[] = +{ + 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, + 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, + 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, + 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, + 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, + 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, + 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, + 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, + 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, + 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, + 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, + 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, + 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, + 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, + 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, + 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041, + 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, + 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441, + 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, + 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, + 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, + 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, + 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, + 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, + 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, + 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440, + 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, + 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, + 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, + 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, + 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, + 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040 +}; + +unsigned long crc32tab[] = +{ + 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, + 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L, + 0x0EDB8832L, 0x79DCB8A4L, 0xE0D5E91EL, 0x97D2D988L, + 0x09B64C2BL, 0x7EB17CBDL, 0xE7B82D07L, 0x90BF1D91L, + 0x1DB71064L, 0x6AB020F2L, 0xF3B97148L, 0x84BE41DEL, + 0x1ADAD47DL, 0x6DDDE4EBL, 0xF4D4B551L, 0x83D385C7L, + 0x136C9856L, 0x646BA8C0L, 0xFD62F97AL, 0x8A65C9ECL, + 0x14015C4FL, 0x63066CD9L, 0xFA0F3D63L, 0x8D080DF5L, + 0x3B6E20C8L, 0x4C69105EL, 0xD56041E4L, 0xA2677172L, + 0x3C03E4D1L, 0x4B04D447L, 0xD20D85FDL, 0xA50AB56BL, + 0x35B5A8FAL, 0x42B2986CL, 0xDBBBC9D6L, 0xACBCF940L, + 0x32D86CE3L, 0x45DF5C75L, 0xDCD60DCFL, 0xABD13D59L, + 0x26D930ACL, 0x51DE003AL, 0xC8D75180L, 0xBFD06116L, + 0x21B4F4B5L, 0x56B3C423L, 0xCFBA9599L, 0xB8BDA50FL, + 0x2802B89EL, 0x5F058808L, 0xC60CD9B2L, 0xB10BE924L, + 0x2F6F7C87L, 0x58684C11L, 0xC1611DABL, 0xB6662D3DL, + 0x76DC4190L, 0x01DB7106L, 0x98D220BCL, 0xEFD5102AL, + 0x71B18589L, 0x06B6B51FL, 0x9FBFE4A5L, 0xE8B8D433L, + 0x7807C9A2L, 0x0F00F934L, 0x9609A88EL, 0xE10E9818L, + 0x7F6A0DBBL, 0x086D3D2DL, 0x91646C97L, 0xE6635C01L, + 0x6B6B51F4L, 0x1C6C6162L, 0x856530D8L, 0xF262004EL, + 0x6C0695EDL, 0x1B01A57BL, 0x8208F4C1L, 0xF50FC457L, + 0x65B0D9C6L, 0x12B7E950L, 0x8BBEB8EAL, 0xFCB9887CL, + 0x62DD1DDFL, 0x15DA2D49L, 0x8CD37CF3L, 0xFBD44C65L, + 0x4DB26158L, 0x3AB551CEL, 0xA3BC0074L, 0xD4BB30E2L, + 0x4ADFA541L, 0x3DD895D7L, 0xA4D1C46DL, 0xD3D6F4FBL, + 0x4369E96AL, 0x346ED9FCL, 0xAD678846L, 0xDA60B8D0L, + 0x44042D73L, 0x33031DE5L, 0xAA0A4C5FL, 0xDD0D7CC9L, + 0x5005713CL, 0x270241AAL, 0xBE0B1010L, 0xC90C2086L, + 0x5768B525L, 0x206F85B3L, 0xB966D409L, 0xCE61E49FL, + 0x5EDEF90EL, 0x29D9C998L, 0xB0D09822L, 0xC7D7A8B4L, + 0x59B33D17L, 0x2EB40D81L, 0xB7BD5C3BL, 0xC0BA6CADL, + 0xEDB88320L, 0x9ABFB3B6L, 0x03B6E20CL, 0x74B1D29AL, + 0xEAD54739L, 0x9DD277AFL, 0x04DB2615L, 0x73DC1683L, + 0xE3630B12L, 0x94643B84L, 0x0D6D6A3EL, 0x7A6A5AA8L, + 0xE40ECF0BL, 0x9309FF9DL, 0x0A00AE27L, 0x7D079EB1L, + 0xF00F9344L, 0x8708A3D2L, 0x1E01F268L, 0x6906C2FEL, + 0xF762575DL, 0x806567CBL, 0x196C3671L, 0x6E6B06E7L, + 0xFED41B76L, 0x89D32BE0L, 0x10DA7A5AL, 0x67DD4ACCL, + 0xF9B9DF6FL, 0x8EBEEFF9L, 0x17B7BE43L, 0x60B08ED5L, + 0xD6D6A3E8L, 0xA1D1937EL, 0x38D8C2C4L, 0x4FDFF252L, + 0xD1BB67F1L, 0xA6BC5767L, 0x3FB506DDL, 0x48B2364BL, + 0xD80D2BDAL, 0xAF0A1B4CL, 0x36034AF6L, 0x41047A60L, + 0xDF60EFC3L, 0xA867DF55L, 0x316E8EEFL, 0x4669BE79L, + 0xCB61B38CL, 0xBC66831AL, 0x256FD2A0L, 0x5268E236L, + 0xCC0C7795L, 0xBB0B4703L, 0x220216B9L, 0x5505262FL, + 0xC5BA3BBEL, 0xB2BD0B28L, 0x2BB45A92L, 0x5CB36A04L, + 0xC2D7FFA7L, 0xB5D0CF31L, 0x2CD99E8BL, 0x5BDEAE1DL, + 0x9B64C2B0L, 0xEC63F226L, 0x756AA39CL, 0x026D930AL, + 0x9C0906A9L, 0xEB0E363FL, 0x72076785L, 0x05005713L, + 0x95BF4A82L, 0xE2B87A14L, 0x7BB12BAEL, 0x0CB61B38L, + 0x92D28E9BL, 0xE5D5BE0DL, 0x7CDCEFB7L, 0x0BDBDF21L, + 0x86D3D2D4L, 0xF1D4E242L, 0x68DDB3F8L, 0x1FDA836EL, + 0x81BE16CDL, 0xF6B9265BL, 0x6FB077E1L, 0x18B74777L, + 0x88085AE6L, 0xFF0F6A70L, 0x66063BCAL, 0x11010B5CL, + 0x8F659EFFL, 0xF862AE69L, 0x616BFFD3L, 0x166CCF45L, + 0xA00AE278L, 0xD70DD2EEL, 0x4E048354L, 0x3903B3C2L, + 0xA7672661L, 0xD06016F7L, 0x4969474DL, 0x3E6E77DBL, + 0xAED16A4AL, 0xD9D65ADCL, 0x40DF0B66L, 0x37D83BF0L, + 0xA9BCAE53L, 0xDEBB9EC5L, 0x47B2CF7FL, 0x30B5FFE9L, + 0xBDBDF21CL, 0xCABAC28AL, 0x53B39330L, 0x24B4A3A6L, + 0xBAD03605L, 0xCDD70693L, 0x54DE5729L, 0x23D967BFL, + 0xB3667A2EL, 0xC4614AB8L, 0x5D681B02L, 0x2A6F2B94L, + 0xB40BBE37L, 0xC30C8EA1L, 0x5A05DF1BL, 0x2D02EF8DL +}; diff --git a/desmume/src/utils/decrypt/crc.h b/src/utils/decrypt/crc.h similarity index 96% rename from desmume/src/utils/decrypt/crc.h rename to src/utils/decrypt/crc.h index 38da26d76..9d77f1574 100644 --- a/desmume/src/utils/decrypt/crc.h +++ b/src/utils/decrypt/crc.h @@ -1,198 +1,198 @@ -//taken from ndstool -//http://devkitpro.cvs.sourceforge.net/viewvc/devkitpro/tools/nds/ndstool/include/crc.h?revision=1.3 - -/* crc.h - this file is part of DeSmuME - * - * Copyright (C) 2005-2006 Rafael Vuijk - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - Cyclic Redundancy Code (CRC) functions - by Rafael Vuijk (aka DarkFader) -*/ - -#ifndef __CRC_H -#define __CRC_H - -//#include "little.h" // FixCrc is not yet big endian compatible - -/* - * Data - */ -extern unsigned short ccitt16tab[]; -extern unsigned short crc16tab[]; -extern unsigned long crc32tab[]; - -/* - * Defines - */ -#define CRC_TEMPLATE template - -/* - * CalcCcitt - * Does not perform final inversion. - */ -#define CalcCcitt_ CalcCcitt -#define CalcCcitt16 CalcCcitt -CRC_TEMPLATE inline CrcType CalcCcitt(unsigned char *data, unsigned int length, CrcType crc = (CrcType)0) -{ - for (unsigned int i=0; i> 8) ^ data[i]]; - } - return crc; -} - -/* - * CalcCrc - * Does not perform final inversion. - */ -#define CalcCrc_ CalcCrc -#define CalcCrc16 CalcCrc -#define CalcCrc32 CalcCrc -CRC_TEMPLATE inline CrcType CalcCrc(unsigned char *data, unsigned int length, CrcType crc = (CrcType)~0) -{ - for (unsigned int i=0; i> 8) ^ crcTable[(crc ^ data[i]) & 0xFF]; - } - return crc; -} - -/* - * FCalcCrc - * Does not perform final inversion. - */ -#define FCalcCrc_ FCalcCrc -#define FCalcCrc16 FCalcCrc -#define FCalcCrc32 FCalcCrc -CRC_TEMPLATE inline CrcType FCalcCrc(FILE *f, unsigned int offset, unsigned int length, CrcType crc = (CrcType)~0) -{ - fseek(f, offset, SEEK_SET); - for (unsigned int i=0; i> 8) ^ crcTable[(crc ^ fgetc(f)) & 0xFF]; - } - return crc; -} - -/* - * RevCrc - * Reverse table lookup. - */ -#define RevCrc_ RevCrc -CRC_TEMPLATE inline unsigned char RevCrc(unsigned char x, CrcType *value = 0) -{ - for (int y=0; y<256; y++) - { - if ((crcTable[y] >> (8*sizeof(CrcType)-8)) == x) - { - if (value) *value = crcTable[y]; - return y; - } - } - return 0; -} - -/* - * FixCrc - */ -#define FixCrc_ FixCrc -#define FixCrc16 FixCrc -#define FixCrc32 FixCrc -CRC_TEMPLATE void FixCrc -( - unsigned char *data, // data to be patched - unsigned int patch_offset, unsigned char *patch_data, unsigned int patch_length, // patch data - unsigned int fix_offset = 0, // position to write the fix. by default, it is immediately after the patched data - CrcType initial_crc = (CrcType)~0 // useful when manually calculating leading data -) -{ - if (!fix_offset) fix_offset = patch_offset + patch_length; - - // calculate CRC after leading data - initial_crc = CalcCrc_(data, patch_offset, initial_crc); - - // calculate CRC before fix - unsigned char buf[2*sizeof(CrcType)]; - CrcType crc_before_fix = CalcCrc_(data + patch_offset, fix_offset - patch_offset); - *(CrcType *)(buf + 0) = crc_before_fix; - - // patch - memcpy(data + patch_offset, patch_data, patch_length); - - // calculate CRC after unfixed - CrcType crc_after_unfix = CalcCrc_(data + patch_offset, fix_offset - patch_offset + sizeof(CrcType)); - *(CrcType *)(buf + sizeof(CrcType)) = crc_after_unfix; - - // fix it - for (int i=sizeof(CrcType); i>=1; i--) - { - CrcType value; - unsigned char index = RevCrc_(buf[i + sizeof(CrcType) - 1], &value); - *(CrcType *)(buf + i) ^= value; - buf[i - 1] ^= index; - } - memcpy(data + fix_offset, buf, sizeof(CrcType)); -} - -/* - * FFixCrc - */ -#define FFixCrc_ FFixCrc -#define FFixCrc16 FFixCrc -#define FFixCrc32 FFixCrc -CRC_TEMPLATE void FFixCrc -( - FILE *f, // file to be patched - unsigned int patch_offset, unsigned char *patch_data, unsigned int patch_length, // patch data - unsigned int fix_offset = 0, // position to write the fix. by default, it is immediately after the patched data - CrcType initial_crc = (CrcType)~0 // useful when manually calculating leading data -) -{ - if (!fix_offset) fix_offset = patch_offset + patch_length; - - // calculate CRC after leading data - initial_crc = FCalcCrc_(f, 0, patch_offset, initial_crc); - - // calculate CRC before fix - unsigned char buf[2*sizeof(CrcType)]; - CrcType crc_before_fix = FCalcCrc_(f, patch_offset, fix_offset - patch_offset); - *(CrcType *)(buf + 0) = crc_before_fix; - - // patch - fseek(f, patch_offset, SEEK_SET); - fwrite(patch_data, 1, patch_length, f); - - // calculate CRC after unfixed - CrcType crc_after_unfix = FCalcCrc_(f, patch_offset, fix_offset - patch_offset + sizeof(CrcType)); - *(CrcType *)(buf + sizeof(CrcType)) = crc_after_unfix; - - // fix it - for (int i=sizeof(CrcType); i>=1; i--) - { - CrcType value=0; - unsigned char index = RevCrc_(buf[i + sizeof(CrcType) - 1], &value); - *(CrcType *)(buf + i) ^= value; - buf[i - 1] ^= index; - } - fseek(f, fix_offset, SEEK_SET); - fwrite(buf, sizeof(CrcType), 1, f); -} - -#endif // __CRC_H +//taken from ndstool +//http://devkitpro.cvs.sourceforge.net/viewvc/devkitpro/tools/nds/ndstool/include/crc.h?revision=1.3 + +/* crc.h - this file is part of DeSmuME + * + * Copyright (C) 2005-2006 Rafael Vuijk + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + Cyclic Redundancy Code (CRC) functions + by Rafael Vuijk (aka DarkFader) +*/ + +#ifndef __CRC_H +#define __CRC_H + +//#include "little.h" // FixCrc is not yet big endian compatible + +/* + * Data + */ +extern unsigned short ccitt16tab[]; +extern unsigned short crc16tab[]; +extern unsigned long crc32tab[]; + +/* + * Defines + */ +#define CRC_TEMPLATE template + +/* + * CalcCcitt + * Does not perform final inversion. + */ +#define CalcCcitt_ CalcCcitt +#define CalcCcitt16 CalcCcitt +CRC_TEMPLATE inline CrcType CalcCcitt(unsigned char *data, unsigned int length, CrcType crc = (CrcType)0) +{ + for (unsigned int i=0; i> 8) ^ data[i]]; + } + return crc; +} + +/* + * CalcCrc + * Does not perform final inversion. + */ +#define CalcCrc_ CalcCrc +#define CalcCrc16 CalcCrc +#define CalcCrc32 CalcCrc +CRC_TEMPLATE inline CrcType CalcCrc(unsigned char *data, unsigned int length, CrcType crc = (CrcType)~0) +{ + for (unsigned int i=0; i> 8) ^ crcTable[(crc ^ data[i]) & 0xFF]; + } + return crc; +} + +/* + * FCalcCrc + * Does not perform final inversion. + */ +#define FCalcCrc_ FCalcCrc +#define FCalcCrc16 FCalcCrc +#define FCalcCrc32 FCalcCrc +CRC_TEMPLATE inline CrcType FCalcCrc(FILE *f, unsigned int offset, unsigned int length, CrcType crc = (CrcType)~0) +{ + fseek(f, offset, SEEK_SET); + for (unsigned int i=0; i> 8) ^ crcTable[(crc ^ fgetc(f)) & 0xFF]; + } + return crc; +} + +/* + * RevCrc + * Reverse table lookup. + */ +#define RevCrc_ RevCrc +CRC_TEMPLATE inline unsigned char RevCrc(unsigned char x, CrcType *value = 0) +{ + for (int y=0; y<256; y++) + { + if ((crcTable[y] >> (8*sizeof(CrcType)-8)) == x) + { + if (value) *value = crcTable[y]; + return y; + } + } + return 0; +} + +/* + * FixCrc + */ +#define FixCrc_ FixCrc +#define FixCrc16 FixCrc +#define FixCrc32 FixCrc +CRC_TEMPLATE void FixCrc +( + unsigned char *data, // data to be patched + unsigned int patch_offset, unsigned char *patch_data, unsigned int patch_length, // patch data + unsigned int fix_offset = 0, // position to write the fix. by default, it is immediately after the patched data + CrcType initial_crc = (CrcType)~0 // useful when manually calculating leading data +) +{ + if (!fix_offset) fix_offset = patch_offset + patch_length; + + // calculate CRC after leading data + initial_crc = CalcCrc_(data, patch_offset, initial_crc); + + // calculate CRC before fix + unsigned char buf[2*sizeof(CrcType)]; + CrcType crc_before_fix = CalcCrc_(data + patch_offset, fix_offset - patch_offset); + *(CrcType *)(buf + 0) = crc_before_fix; + + // patch + memcpy(data + patch_offset, patch_data, patch_length); + + // calculate CRC after unfixed + CrcType crc_after_unfix = CalcCrc_(data + patch_offset, fix_offset - patch_offset + sizeof(CrcType)); + *(CrcType *)(buf + sizeof(CrcType)) = crc_after_unfix; + + // fix it + for (int i=sizeof(CrcType); i>=1; i--) + { + CrcType value; + unsigned char index = RevCrc_(buf[i + sizeof(CrcType) - 1], &value); + *(CrcType *)(buf + i) ^= value; + buf[i - 1] ^= index; + } + memcpy(data + fix_offset, buf, sizeof(CrcType)); +} + +/* + * FFixCrc + */ +#define FFixCrc_ FFixCrc +#define FFixCrc16 FFixCrc +#define FFixCrc32 FFixCrc +CRC_TEMPLATE void FFixCrc +( + FILE *f, // file to be patched + unsigned int patch_offset, unsigned char *patch_data, unsigned int patch_length, // patch data + unsigned int fix_offset = 0, // position to write the fix. by default, it is immediately after the patched data + CrcType initial_crc = (CrcType)~0 // useful when manually calculating leading data +) +{ + if (!fix_offset) fix_offset = patch_offset + patch_length; + + // calculate CRC after leading data + initial_crc = FCalcCrc_(f, 0, patch_offset, initial_crc); + + // calculate CRC before fix + unsigned char buf[2*sizeof(CrcType)]; + CrcType crc_before_fix = FCalcCrc_(f, patch_offset, fix_offset - patch_offset); + *(CrcType *)(buf + 0) = crc_before_fix; + + // patch + fseek(f, patch_offset, SEEK_SET); + fwrite(patch_data, 1, patch_length, f); + + // calculate CRC after unfixed + CrcType crc_after_unfix = FCalcCrc_(f, patch_offset, fix_offset - patch_offset + sizeof(CrcType)); + *(CrcType *)(buf + sizeof(CrcType)) = crc_after_unfix; + + // fix it + for (int i=sizeof(CrcType); i>=1; i--) + { + CrcType value=0; + unsigned char index = RevCrc_(buf[i + sizeof(CrcType) - 1], &value); + *(CrcType *)(buf + i) ^= value; + buf[i - 1] ^= index; + } + fseek(f, fix_offset, SEEK_SET); + fwrite(buf, sizeof(CrcType), 1, f); +} + +#endif // __CRC_H diff --git a/desmume/src/utils/decrypt/decrypt.cpp b/src/utils/decrypt/decrypt.cpp similarity index 98% rename from desmume/src/utils/decrypt/decrypt.cpp rename to src/utils/decrypt/decrypt.cpp index 9a0de58e1..9fbe7ac88 100644 --- a/desmume/src/utils/decrypt/decrypt.cpp +++ b/src/utils/decrypt/decrypt.cpp @@ -1,506 +1,506 @@ -//taken from ndstool -//http://devkitpro.cvs.sourceforge.net/viewvc/devkitpro/tools/nds/ndstool/source/encryption.cpp?revision=1.2 - -/* decrypt.cpp - this file is part of DeSmuME - * - * Copyright (C) 2006 Rafael Vuijk - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include - -#include "../../types.h" -#include "crc.h" -#include "header.h" -#include "decrypt.h" - -const unsigned char encr_data[] = -{ - 0x99,0xD5,0x20,0x5F,0x57,0x44,0xF5,0xB9,0x6E,0x19,0xA4,0xD9,0x9E,0x6A,0x5A,0x94, - 0xD8,0xAE,0xF1,0xEB,0x41,0x75,0xE2,0x3A,0x93,0x82,0xD0,0x32,0x33,0xEE,0x31,0xD5, - 0xCC,0x57,0x61,0x9A,0x37,0x06,0xA2,0x1B,0x79,0x39,0x72,0xF5,0x55,0xAE,0xF6,0xBE, - 0x5F,0x1B,0x69,0xFB,0xE5,0x9D,0xF1,0xE9,0xCE,0x2C,0xD9,0xA1,0x5E,0x32,0x05,0xE6, - 0xFE,0xD3,0xFE,0xCF,0xD4,0x62,0x04,0x0D,0x8B,0xF5,0xEC,0xB7,0x2B,0x60,0x79,0xBB, - 0x12,0x95,0x31,0x0D,0x6E,0x3F,0xDA,0x2B,0x88,0x84,0xF0,0xF1,0x3D,0x12,0x7E,0x25, - 0x45,0x22,0xF1,0xBB,0x24,0x06,0x1A,0x06,0x11,0xAD,0xDF,0x28,0x8B,0x64,0x81,0x34, - 0x2B,0xEB,0x33,0x29,0x99,0xAA,0xF2,0xBD,0x9C,0x14,0x95,0x9D,0x9F,0xF7,0xF5,0x8C, - 0x72,0x97,0xA1,0x29,0x9D,0xD1,0x5F,0xCF,0x66,0x4D,0x07,0x1A,0xDE,0xD3,0x4A,0x4B, - 0x85,0xC9,0xA7,0xA3,0x17,0x95,0x05,0x3A,0x3D,0x49,0x0A,0xBF,0x0A,0x89,0x8B,0xA2, - 0x4A,0x82,0x49,0xDD,0x27,0x90,0xF1,0x0B,0xE9,0xEB,0x1C,0x6A,0x83,0x76,0x45,0x05, - 0xBA,0x81,0x70,0x61,0x17,0x3F,0x4B,0xDE,0xAE,0xCF,0xAB,0x39,0x57,0xF2,0x3A,0x56, - 0x48,0x11,0xAD,0x8A,0x40,0xE1,0x45,0x3F,0xFA,0x9B,0x02,0x54,0xCA,0xA6,0x93,0xFB, - 0xEF,0x4D,0xFE,0x6F,0xA3,0xD8,0x87,0x9C,0x08,0xBA,0xD5,0x48,0x6A,0x8D,0x2D,0xFD, - 0x6E,0x15,0xF8,0x74,0xBD,0xBE,0x52,0x8B,0x18,0x22,0x8A,0x9E,0xFB,0x74,0x37,0x07, - 0x1B,0x36,0x6C,0x4A,0x19,0xBA,0x42,0x62,0xB9,0x79,0x91,0x10,0x7B,0x67,0x65,0x96, - 0xFE,0x02,0x23,0xE8,0xEE,0x99,0x8C,0x77,0x3E,0x5C,0x86,0x64,0x4D,0x6D,0x78,0x86, - 0xA5,0x4F,0x65,0xE2,0x1E,0xB2,0xDF,0x5A,0x0A,0xD0,0x7E,0x08,0x14,0xB0,0x71,0xAC, - 0xBD,0xDB,0x83,0x1C,0xB9,0xD7,0xA1,0x62,0xCD,0xC6,0x63,0x7C,0x52,0x69,0xC3,0xE6, - 0xBF,0x75,0xCE,0x12,0x44,0x5D,0x21,0x04,0xFA,0xFB,0xD3,0x3C,0x38,0x11,0x63,0xD4, - 0x95,0x85,0x41,0x49,0x46,0x09,0xF2,0x08,0x43,0x11,0xDC,0x1F,0x76,0xC0,0x15,0x6D, - 0x1F,0x3C,0x63,0x70,0xEA,0x87,0x80,0x6C,0xC3,0xBD,0x63,0x8B,0xC2,0x37,0x21,0x37, - 0xDC,0xEE,0x09,0x23,0x2E,0x37,0x6A,0x4D,0x73,0x90,0xF7,0x50,0x30,0xAC,0x1C,0x92, - 0x04,0x10,0x23,0x91,0x4F,0xD2,0x07,0xAA,0x68,0x3E,0x4F,0x9A,0xC9,0x64,0x60,0x6A, - 0xC8,0x14,0x21,0xF3,0xD6,0x22,0x41,0x12,0x44,0x24,0xCF,0xE6,0x8A,0x56,0xDD,0x0D, - 0x53,0x4D,0xE1,0x85,0x1E,0x8C,0x52,0x5A,0x9C,0x19,0x84,0xC2,0x03,0x57,0xF1,0x6F, - 0xE3,0x00,0xBE,0x58,0xF6,0x4C,0xED,0xD5,0x21,0x64,0x9C,0x1F,0xBE,0x55,0x03,0x3C, - 0x4A,0xDC,0xFF,0xAA,0xC9,0xDA,0xE0,0x5D,0x5E,0xBF,0xE6,0xDE,0xF5,0xD8,0xB1,0xF8, - 0xFF,0x36,0xB3,0xB9,0x62,0x67,0x95,0xDB,0x31,0x5F,0x37,0xED,0x4C,0x70,0x67,0x99, - 0x90,0xB5,0x18,0x31,0x6C,0x3D,0x99,0x99,0xE4,0x42,0xDA,0xD3,0x25,0x42,0x13,0xA0, - 0xAE,0xD7,0x70,0x6C,0xB1,0x55,0xCF,0xC7,0xD7,0x46,0xD5,0x43,0x61,0x17,0x3D,0x44, - 0x28,0xE9,0x33,0x85,0xD5,0xD0,0xA2,0x93,0xAA,0x25,0x12,0x1F,0xFB,0xC5,0x0B,0x46, - 0xF5,0x97,0x76,0x56,0x45,0xA6,0xBE,0x87,0xB1,0x94,0x6B,0xE8,0xB1,0xFE,0x33,0x99, - 0xAE,0x1F,0x3E,0x6C,0x39,0x71,0x1D,0x09,0x00,0x90,0x37,0xE4,0x10,0x3E,0x75,0x74, - 0xFF,0x8C,0x83,0x3B,0xB0,0xF1,0xB0,0xF9,0x01,0x05,0x47,0x42,0x95,0xF1,0xD6,0xAC, - 0x7E,0x38,0xE6,0x9E,0x95,0x74,0x26,0x3F,0xB4,0x68,0x50,0x18,0xD0,0x43,0x30,0xB4, - 0x4C,0x4B,0xE3,0x68,0xBF,0xE5,0x4D,0xB6,0x95,0x8B,0x0A,0xA0,0x74,0x25,0x32,0x77, - 0xCF,0xA1,0xF7,0x2C,0xD8,0x71,0x13,0x5A,0xAB,0xEA,0xC9,0x51,0xE8,0x0D,0xEE,0xEF, - 0xE9,0x93,0x7E,0x19,0xA7,0x1E,0x43,0x38,0x81,0x16,0x2C,0xA1,0x48,0xE3,0x73,0xCC, - 0x29,0x21,0x6C,0xD3,0x5D,0xCE,0xA0,0xD9,0x61,0x71,0x43,0xA0,0x15,0x13,0xB5,0x64, - 0x92,0xCF,0x2A,0x19,0xDC,0xAD,0xB7,0xA5,0x9F,0x86,0x65,0xF8,0x1A,0x9F,0xE7,0xFB, - 0xF7,0xFD,0xB8,0x13,0x6C,0x27,0xDB,0x6F,0xDF,0x35,0x1C,0xF7,0x8D,0x2C,0x5B,0x9B, - 0x12,0xAB,0x38,0x64,0x06,0xCC,0xDE,0x31,0xE8,0x4E,0x75,0x11,0x64,0xE3,0xFA,0xEA, - 0xEB,0x34,0x54,0xC2,0xAD,0x3F,0x34,0xEB,0x93,0x2C,0x7D,0x26,0x36,0x9D,0x56,0xF3, - 0x5A,0xE1,0xF6,0xB3,0x98,0x63,0x4A,0x9E,0x32,0x83,0xE4,0x9A,0x84,0x60,0x7D,0x90, - 0x2E,0x13,0x0E,0xEE,0x93,0x4B,0x36,0xA2,0x85,0xEC,0x16,0x38,0xE8,0x88,0x06,0x02, - 0xBF,0xF0,0xA0,0x3A,0xED,0xD7,0x6A,0x9A,0x73,0xE1,0x57,0xCF,0xF8,0x44,0xB8,0xDC, - 0x2E,0x23,0x59,0xD1,0xDF,0x95,0x52,0x71,0x99,0x61,0xA0,0x4B,0xD5,0x7F,0x6E,0x78, - 0xBA,0xA9,0xC5,0x30,0xD3,0x40,0x86,0x32,0x9D,0x32,0x0C,0x9C,0x37,0xB7,0x02,0x2F, - 0xBA,0x54,0x98,0xA9,0xC4,0x13,0x04,0xC9,0x8D,0xBE,0xC8,0xE7,0x5D,0x97,0x50,0x2E, - 0x93,0xD6,0x22,0x59,0x0C,0x27,0xBC,0x22,0x92,0xE0,0xA7,0x20,0x0F,0x93,0x6F,0x7F, - 0x4C,0x9F,0xD3,0xB5,0xA6,0x2A,0x0B,0x74,0x67,0x49,0x7D,0x10,0x26,0xCB,0xD1,0xC5, - 0x86,0x71,0xE7,0x8C,0xA0,0x9C,0xE9,0x5B,0xB2,0x1A,0xF6,0x01,0xEE,0x8C,0x9E,0x5E, - 0x83,0xF2,0x1A,0xDB,0xE6,0xE5,0xEA,0x84,0x59,0x76,0xD2,0x7C,0xF6,0x8D,0xA5,0x49, - 0x36,0x48,0xC2,0x16,0x52,0xBB,0x83,0xA3,0x74,0xB9,0x07,0x0C,0x3B,0xFF,0x61,0x28, - 0xE1,0x61,0xE9,0xE4,0xEF,0x6E,0x15,0xAA,0x4E,0xBA,0xE8,0x5D,0x05,0x96,0xBB,0x32, - 0x56,0xB0,0xFB,0x72,0x52,0x0F,0x0E,0xC8,0x42,0x25,0x65,0x76,0x89,0xAF,0xF2,0xDE, - 0x10,0x27,0xF0,0x01,0x4B,0x74,0xA7,0x97,0x07,0xD5,0x26,0x54,0x54,0x09,0x1F,0x82, - 0x0A,0x86,0x7D,0x30,0x39,0x0E,0xB3,0x26,0x9B,0x0B,0x57,0xBB,0x36,0x06,0x31,0xAF, - 0xFD,0x79,0xFC,0xD9,0x30,0x10,0x2B,0x0C,0xB3,0xE1,0x9B,0xD7,0x7B,0xDC,0x5F,0xEF, - 0xD2,0xF8,0x13,0x45,0x4D,0x47,0x75,0xBD,0x46,0x96,0x3C,0x7E,0x75,0xF3,0x3E,0xB5, - 0x67,0xC5,0x9A,0x3B,0xB0,0x5B,0x29,0x6B,0xDE,0x80,0x5B,0xC8,0x15,0x05,0xB1,0x31, - 0xB6,0xCE,0x49,0xDD,0xAD,0x84,0xB5,0xAE,0x60,0xDC,0x67,0x31,0x34,0x30,0xFE,0x4E, - 0xBD,0x80,0x2F,0xA6,0xBF,0x63,0x39,0x21,0x86,0xD9,0x35,0x7F,0x16,0x68,0x22,0x05, - 0x54,0xE9,0x90,0x26,0x8C,0x07,0x6C,0x51,0xA4,0x31,0x55,0xD7,0x09,0x07,0xA8,0x3E, - 0x2E,0x53,0x66,0xC1,0xF8,0xF2,0x7B,0xC4,0xF2,0x58,0xCF,0xF1,0x87,0xC5,0xA2,0xE7, - 0x27,0x8F,0x30,0x87,0x58,0xA0,0x64,0x62,0x23,0x18,0xB9,0x88,0x7C,0xFA,0xCE,0xC4, - 0x98,0xAE,0xAD,0x17,0xCC,0x4A,0x5B,0xF3,0xE9,0x48,0xD5,0x56,0xD3,0x0D,0xF2,0xC8, - 0x92,0x73,0x8C,0xDB,0xD7,0x2F,0x56,0xAC,0x81,0xF9,0x92,0x69,0x4D,0xC6,0x32,0xF6, - 0xE6,0xC0,0x8D,0x21,0xE2,0x76,0x80,0x61,0x11,0xBC,0xDC,0x6C,0x93,0xAF,0x19,0x69, - 0x9B,0xD0,0xBF,0xB9,0x31,0x9F,0x02,0x67,0xA3,0x51,0xEE,0x83,0x06,0x22,0x7B,0x0C, - 0xAB,0x49,0x42,0x40,0xB8,0xD5,0x01,0x7D,0xCE,0x5E,0xF7,0x55,0x53,0x39,0xC5,0x99, - 0x46,0xD8,0x87,0x9F,0xBA,0xF7,0x64,0xB4,0xE3,0x9A,0xFA,0xA1,0x6D,0x90,0x68,0x10, - 0x30,0xCA,0x8A,0x54,0xA7,0x9F,0x60,0xC3,0x19,0xF5,0x6B,0x0D,0x7A,0x51,0x98,0xE6, - 0x98,0x43,0x51,0xB4,0xD6,0x35,0xE9,0x4F,0xC3,0xDF,0x0F,0x7B,0xD6,0x2F,0x5C,0xBD, - 0x3A,0x15,0x61,0x19,0xF1,0x4B,0xCB,0xAA,0xDC,0x6D,0x64,0xC9,0xD3,0xC6,0x1E,0x56, - 0xEF,0x38,0x4C,0x50,0x71,0x86,0x75,0xCC,0x0D,0x0D,0x4E,0xE9,0x28,0xF6,0x06,0x5D, - 0x70,0x1B,0xAA,0xD3,0x45,0xCF,0xA8,0x39,0xAC,0x95,0xA6,0x2E,0xB4,0xE4,0x22,0xD4, - 0x74,0xA8,0x37,0x5F,0x48,0x7A,0x04,0xCC,0xA5,0x4C,0x40,0xD8,0x28,0xB4,0x28,0x08, - 0x0D,0x1C,0x72,0x52,0x41,0xF0,0x7D,0x47,0x19,0x3A,0x53,0x4E,0x58,0x84,0x62,0x6B, - 0x93,0xB5,0x8A,0x81,0x21,0x4E,0x0D,0xDC,0xB4,0x3F,0xA2,0xC6,0xFC,0xC9,0x2B,0x40, - 0xDA,0x38,0x04,0xE9,0x5E,0x5A,0x86,0x6B,0x0C,0x22,0x25,0x85,0x68,0x11,0x8D,0x7C, - 0x92,0x1D,0x95,0x55,0x4D,0xAB,0x8E,0xBB,0xDA,0xA6,0xE6,0xB7,0x51,0xB6,0x32,0x5A, - 0x05,0x41,0xDD,0x05,0x2A,0x0A,0x56,0x50,0x91,0x17,0x47,0xCC,0xC9,0xE6,0x7E,0xB5, - 0x61,0x4A,0xDB,0x73,0x67,0x51,0xC8,0x33,0xF5,0xDA,0x6E,0x74,0x2E,0x54,0xC3,0x37, - 0x0D,0x6D,0xAF,0x08,0xE8,0x15,0x8A,0x5F,0xE2,0x59,0x21,0xCD,0xA8,0xDE,0x0C,0x06, - 0x5A,0x77,0x6B,0x5F,0xDB,0x18,0x65,0x3E,0xC8,0x50,0xDE,0x78,0xE0,0xB8,0x82,0xB3, - 0x5D,0x4E,0x72,0x32,0x07,0x4F,0xC1,0x34,0x23,0xBA,0x96,0xB7,0x67,0x4E,0xA4,0x28, - 0x1E,0x34,0x62,0xEB,0x2D,0x6A,0x70,0xE9,0x2F,0x42,0xC4,0x70,0x4E,0x5A,0x31,0x9C, - 0xF9,0x5B,0x47,0x28,0xAA,0xDA,0x71,0x6F,0x38,0x1F,0xB3,0x78,0xC4,0x92,0x6B,0x1C, - 0x9E,0xF6,0x35,0x9A,0xB7,0x4D,0x0E,0xBF,0xCC,0x18,0x29,0x41,0x03,0x48,0x35,0x5D, - 0x55,0xD0,0x2B,0xC6,0x29,0xAF,0x5C,0x60,0x74,0x69,0x8E,0x5E,0x9B,0x7C,0xD4,0xBD, - 0x7B,0x44,0x64,0x7D,0x3F,0x92,0x5D,0x69,0xB6,0x1F,0x00,0x4B,0xD4,0x83,0x35,0xCF, - 0x7E,0x64,0x4E,0x17,0xAE,0x8D,0xD5,0x2E,0x9A,0x28,0x12,0x4E,0x2E,0x2B,0x49,0x08, - 0x5C,0xAE,0xC6,0x46,0x85,0xAE,0x41,0x61,0x1E,0x6F,0x82,0xD2,0x51,0x37,0x16,0x1F, - 0x0B,0xF6,0x59,0xA4,0x9A,0xCA,0x5A,0xAF,0x0D,0xD4,0x33,0x8B,0x20,0x63,0xF1,0x84, - 0x80,0x5C,0xCB,0xCF,0x08,0xB4,0xB9,0xD3,0x16,0x05,0xBD,0x62,0x83,0x31,0x9B,0x56, - 0x51,0x98,0x9F,0xBA,0xB2,0x5B,0xAA,0xB2,0x22,0x6B,0x2C,0xB5,0xD4,0x48,0xFA,0x63, - 0x2B,0x5F,0x58,0xFA,0x61,0xFA,0x64,0x09,0xBB,0x38,0xE0,0xB8,0x9D,0x92,0x60,0xA8, - 0x0D,0x67,0x6F,0x0E,0x37,0xF5,0x0D,0x01,0x9F,0xC2,0x77,0xD4,0xFE,0xEC,0xF1,0x73, - 0x30,0x39,0xE0,0x7D,0xF5,0x61,0x98,0xE4,0x2C,0x28,0x55,0x04,0x56,0x55,0xDB,0x2F, - 0x6B,0xEC,0xE5,0x58,0x06,0xB6,0x64,0x80,0x6A,0x2A,0x1A,0x4E,0x5B,0x0F,0xD8,0xC4, - 0x0A,0x2E,0x52,0x19,0xD9,0x62,0xF5,0x30,0x48,0xBE,0x8C,0x7B,0x4F,0x38,0x9B,0xA2, - 0xC3,0xAF,0xC9,0xD3,0xC7,0xC1,0x62,0x41,0x86,0xB9,0x61,0x21,0x57,0x6F,0x99,0x4F, - 0xC1,0xBA,0xCE,0x7B,0xB5,0x3B,0x4D,0x5E,0x8A,0x8B,0x44,0x57,0x5F,0x13,0x5F,0x70, - 0x6D,0x5B,0x29,0x47,0xDC,0x38,0xE2,0xEC,0x04,0x55,0x65,0x12,0x2A,0xE8,0x17,0x43, - 0xE1,0x8E,0xDD,0x2A,0xB3,0xE2,0x94,0xF7,0x09,0x6E,0x5C,0xE6,0xEB,0x8A,0xF8,0x6D, - 0x89,0x49,0x54,0x48,0xF5,0x2F,0xAD,0xBF,0xEA,0x94,0x4B,0xCA,0xFC,0x39,0x87,0x82, - 0x5F,0x8A,0x01,0xF2,0x75,0xF2,0xE6,0x71,0xD6,0xD8,0x42,0xDE,0xF1,0x2D,0x1D,0x28, - 0xA6,0x88,0x7E,0xA3,0xA0,0x47,0x1D,0x30,0xD9,0xA3,0x71,0xDF,0x49,0x1C,0xCB,0x01, - 0xF8,0x36,0xB1,0xF2,0xF0,0x22,0x58,0x5D,0x45,0x6B,0xBD,0xA0,0xBB,0xB2,0x88,0x42, - 0xC7,0x8C,0x28,0xCE,0x93,0xE8,0x90,0x63,0x08,0x90,0x7C,0x89,0x3C,0xF5,0x7D,0xB7, - 0x04,0x2D,0x4F,0x55,0x51,0x16,0xFD,0x7E,0x79,0xE8,0xBE,0xC1,0xF2,0x12,0xD4,0xF8, - 0xB4,0x84,0x05,0x23,0xA0,0xCC,0xD2,0x2B,0xFD,0xE1,0xAB,0xAD,0x0D,0xD1,0x55,0x6C, - 0x23,0x41,0x94,0x4D,0x77,0x37,0x4F,0x05,0x28,0x0C,0xBF,0x17,0xB3,0x12,0x67,0x6C, - 0x8C,0xC3,0x5A,0xF7,0x41,0x84,0x2A,0x6D,0xD0,0x94,0x12,0x27,0x2C,0xB4,0xED,0x9C, - 0x4D,0xEC,0x47,0x82,0x97,0xD5,0x67,0xB9,0x1B,0x9D,0xC0,0x55,0x07,0x7E,0xE5,0x8E, - 0xE2,0xA8,0xE7,0x3E,0x12,0xE4,0x0E,0x3A,0x2A,0x45,0x55,0x34,0xA2,0xF9,0x2D,0x5A, - 0x1B,0xAB,0x52,0x7C,0x83,0x10,0x5F,0x55,0xD2,0xF1,0x5A,0x43,0x2B,0xC6,0xA7,0xA4, - 0x89,0x15,0x95,0xE8,0xB4,0x4B,0x9D,0xF8,0x75,0xE3,0x9F,0x60,0x78,0x5B,0xD6,0xE6, - 0x0D,0x44,0xE6,0x21,0x06,0xBD,0x47,0x22,0x53,0xA4,0x00,0xAD,0x8D,0x43,0x13,0x85, - 0x39,0xF7,0xAA,0xFC,0x38,0xAF,0x7B,0xED,0xFC,0xE4,0x2B,0x54,0x50,0x98,0x4C,0xFC, - 0x85,0x80,0xF7,0xDF,0x3C,0x80,0x22,0xE1,0x94,0xDA,0xDE,0x24,0xC6,0xB0,0x7A,0x39, - 0x38,0xDC,0x0F,0xA1,0xA7,0xF4,0xF9,0x6F,0x63,0x18,0x57,0x8B,0x84,0x41,0x2A,0x2E, - 0xD4,0x53,0xF2,0xD9,0x00,0x0F,0xD0,0xDD,0x99,0x6E,0x19,0xA6,0x0A,0xD0,0xEC,0x5B, - 0x58,0x24,0xAB,0xC0,0xCB,0x06,0x65,0xEC,0x1A,0x13,0x38,0x94,0x0A,0x67,0x03,0x2F, - 0x3F,0xF7,0xE3,0x77,0x44,0x77,0x33,0xC6,0x14,0x39,0xD0,0xE3,0xC0,0xA2,0x08,0x79, - 0xBB,0x40,0x99,0x57,0x41,0x0B,0x01,0x90,0xCD,0xE1,0xCC,0x48,0x67,0xDB,0xB3,0xAF, - 0x88,0x74,0xF3,0x4C,0x82,0x8F,0x72,0xB1,0xB5,0x23,0x29,0xC4,0x12,0x6C,0x19,0xFC, - 0x8E,0x46,0xA4,0x9C,0xC4,0x25,0x65,0x87,0xD3,0x6D,0xBE,0x8A,0x93,0x11,0x03,0x38, - 0xED,0x83,0x2B,0xF3,0x46,0xA4,0x93,0xEA,0x3B,0x53,0x85,0x1D,0xCE,0xD4,0xF1,0x08, - 0x83,0x27,0xED,0xFC,0x9B,0x1A,0x18,0xBC,0xF9,0x8B,0xAE,0xDC,0x24,0xAB,0x50,0x38, - 0xE9,0x72,0x4B,0x10,0x22,0x17,0x7B,0x46,0x5D,0xAB,0x59,0x64,0xF3,0x40,0xAE,0xF8, - 0xBB,0xE5,0xC8,0xF9,0x26,0x03,0x4E,0x55,0x7D,0xEB,0xEB,0xFE,0xF7,0x39,0xE6,0xE0, - 0x0A,0x11,0xBE,0x2E,0x28,0xFF,0x98,0xED,0xC0,0xC9,0x42,0x56,0x42,0xC3,0xFD,0x00, - 0xF6,0xAF,0x87,0xA2,0x5B,0x01,0x3F,0x32,0x92,0x47,0x95,0x9A,0x72,0xA5,0x32,0x3D, - 0xAE,0x6B,0xD0,0x9B,0x07,0xD2,0x49,0x92,0xE3,0x78,0x4A,0xFA,0xA1,0x06,0x7D,0xF2, - 0x41,0xCF,0x77,0x74,0x04,0x14,0xB2,0x0C,0x86,0x84,0x64,0x16,0xD5,0xBB,0x51,0xA1, - 0xE5,0x6F,0xF1,0xD1,0xF2,0xE2,0xF7,0x5F,0x58,0x20,0x4D,0xB8,0x57,0xC7,0xCF,0xDD, - 0xC5,0xD8,0xBE,0x76,0x3D,0xF6,0x5F,0x7E,0xE7,0x2A,0x8B,0x88,0x24,0x1B,0x38,0x3F, - 0x0E,0x41,0x23,0x77,0xF5,0xF0,0x4B,0xD4,0x0C,0x1F,0xFA,0xA4,0x0B,0x80,0x5F,0xCF, - 0x45,0xF6,0xE0,0xDA,0x2F,0x34,0x59,0x53,0xFB,0x20,0x3C,0x52,0x62,0x5E,0x35,0xB5, - 0x62,0xFE,0x8B,0x60,0x63,0xE3,0x86,0x5A,0x15,0x1A,0x6E,0xD1,0x47,0x45,0xBC,0x32, - 0xB4,0xEB,0x67,0x38,0xAB,0xE4,0x6E,0x33,0x3A,0xB5,0xED,0xA3,0xAD,0x67,0xE0,0x4E, - 0x41,0x95,0xEE,0x62,0x62,0x71,0x26,0x1D,0x31,0xEF,0x62,0x30,0xAF,0xD7,0x82,0xAC, - 0xC2,0xDC,0x05,0x04,0xF5,0x97,0x07,0xBF,0x11,0x59,0x23,0x07,0xC0,0x64,0x02,0xE8, - 0x97,0xE5,0x3E,0xAF,0x18,0xAC,0x59,0xA6,0x8B,0x4A,0x33,0x90,0x1C,0x6E,0x7C,0x9C, - 0x20,0x7E,0x4C,0x3C,0x3E,0x61,0x64,0xBB,0xC5,0x6B,0x7C,0x7E,0x3E,0x9F,0xC5,0x4C, - 0x9F,0xEA,0x73,0xF5,0xD7,0x89,0xC0,0x4C,0xF4,0xFB,0xF4,0x2D,0xEC,0x14,0x1B,0x51, - 0xD5,0xC1,0x12,0xC8,0x10,0xDF,0x0B,0x4A,0x8B,0x9C,0xBC,0x93,0x45,0x6A,0x3E,0x3E, - 0x7D,0xC1,0xA9,0xBA,0xCD,0xC1,0xB4,0x07,0xE4,0xE1,0x68,0x86,0x43,0xB2,0x6D,0x38, - 0xF3,0xFB,0x0C,0x5C,0x66,0x37,0x71,0xDE,0x56,0xEF,0x6E,0xA0,0x10,0x40,0x65,0xA7, - 0x98,0xF7,0xD0,0xBE,0x0E,0xC8,0x37,0x36,0xEC,0x10,0xCA,0x7C,0x9C,0xAB,0x84,0x1E, - 0x05,0x17,0x76,0x02,0x1C,0x4F,0x52,0xAA,0x5F,0xC1,0xC6,0xA0,0x56,0xB9,0xD8,0x04, - 0x84,0x44,0x4D,0xA7,0x59,0xD8,0xDE,0x60,0xE6,0x38,0x0E,0x05,0x8F,0x03,0xE1,0x3B, - 0x6D,0x81,0x04,0x33,0x6F,0x30,0x0B,0xCE,0x69,0x05,0x21,0x33,0xFB,0x26,0xBB,0x89, - 0x7D,0xB6,0xAE,0x87,0x7E,0x51,0x07,0xE0,0xAC,0xF7,0x96,0x0A,0x6B,0xF9,0xC4,0x5C, - 0x1D,0xE4,0x44,0x47,0xB8,0x5E,0xFA,0xE3,0x78,0x84,0x55,0x42,0x4B,0x48,0x5E,0xF7, - 0x7D,0x47,0x35,0x86,0x1D,0x2B,0x43,0x05,0x03,0xEC,0x8A,0xB8,0x1E,0x06,0x3C,0x76, - 0x0C,0x48,0x1A,0x43,0xA7,0xB7,0x8A,0xED,0x1E,0x13,0xC6,0x43,0xEE,0x10,0xEF,0xDB, - 0xEC,0xFB,0x3C,0x83,0xB2,0x95,0x44,0xEF,0xD8,0x54,0x51,0x4E,0x2D,0x11,0x44,0x1D, - 0xFB,0x36,0x59,0x1E,0x7A,0x34,0xC1,0xC3,0xCA,0x57,0x00,0x61,0xEA,0x67,0xA5,0x16, - 0x9B,0x55,0xD0,0x55,0xE1,0x7F,0xD9,0x36,0xD2,0x40,0x76,0xAE,0xDC,0x01,0xCE,0xB0, - 0x7A,0x83,0xD5,0xCB,0x20,0x98,0xEC,0x6B,0xC1,0x72,0x92,0x34,0xF3,0x82,0x57,0x37, - 0x62,0x8A,0x32,0x36,0x0C,0x90,0x43,0xAE,0xAE,0x5C,0x9B,0x78,0x8E,0x13,0x65,0x02, - 0xFD,0x68,0x71,0xC1,0xFE,0xB0,0x31,0xA0,0x24,0x82,0xB0,0xC3,0xB1,0x79,0x69,0xA7, - 0xF5,0xD2,0xEB,0xD0,0x82,0xC0,0x32,0xDC,0x9E,0xC7,0x26,0x3C,0x6D,0x8D,0x98,0xC1, - 0xBB,0x22,0xD4,0xD0,0x0F,0x33,0xEC,0x3E,0xB9,0xCC,0xE1,0xDC,0x6A,0x4C,0x77,0x36, - 0x14,0x1C,0xF9,0xBF,0x81,0x9F,0x28,0x5F,0x71,0x85,0x32,0x29,0x90,0x75,0x48,0xC4, - 0xB3,0x4A,0xCE,0xD8,0x44,0x8F,0x14,0x2F,0xFD,0x40,0x57,0xEF,0xAA,0x08,0x75,0xD9, - 0x46,0xD1,0xD6,0x6E,0x32,0x55,0x1F,0xC3,0x18,0xFE,0x84,0x1F,0xFC,0x84,0xD5,0xFF, - 0x71,0x5E,0x1B,0x48,0xC3,0x86,0x95,0x0E,0x28,0x08,0x27,0xD3,0x38,0x83,0x71,0x7B, - 0x4C,0x80,0x63,0x54,0x9A,0x56,0xB0,0xAC,0xCF,0x80,0xCA,0x31,0x09,0xEF,0xFE,0xF3, - 0xBE,0xAF,0x24,0x7E,0xA6,0xFE,0x53,0x3F,0xC2,0x8D,0x4A,0x33,0x68,0xD1,0x22,0xA6, - 0x66,0xAD,0x7B,0xEA,0xDE,0xB6,0x43,0xB0,0xA1,0x25,0x95,0x00,0xA3,0x3F,0x75,0x46, - 0x14,0x11,0x44,0xEC,0xD7,0x95,0xBC,0x92,0xF0,0x4F,0xA9,0x16,0x53,0x62,0x97,0x60, - 0x2A,0x0F,0x41,0xF1,0x71,0x24,0xBE,0xEE,0x94,0x7F,0x08,0xCD,0x60,0x93,0xB3,0x85, - 0x5B,0x07,0x00,0x3F,0xD8,0x0F,0x28,0x83,0x9A,0xD1,0x69,0x9F,0xD1,0xDA,0x2E,0xC3, - 0x90,0x01,0xA2,0xB9,0x6B,0x4E,0x2A,0x66,0x9D,0xDA,0xAE,0xA6,0xEA,0x2A,0xD3,0x68, - 0x2F,0x0C,0x0C,0x9C,0xD2,0x8C,0x4A,0xED,0xE2,0x9E,0x57,0x65,0x9D,0x09,0x87,0xA3, - 0xB4,0xC4,0x32,0x5D,0xC9,0xD4,0x32,0x2B,0xB1,0xE0,0x71,0x1E,0x64,0x4D,0xE6,0x90, - 0x71,0xE3,0x1E,0x40,0xED,0x7D,0xF3,0x84,0x0E,0xED,0xC8,0x78,0x76,0xAE,0xC0,0x71, - 0x27,0x72,0xBB,0x05,0xEA,0x02,0x64,0xFB,0xF3,0x48,0x6B,0xB5,0x42,0x93,0x3F,0xED, - 0x9F,0x13,0x53,0xD2,0xF7,0xFE,0x2A,0xEC,0x1D,0x47,0x25,0xDB,0x3C,0x91,0x86,0xC6, - 0x8E,0xF0,0x11,0xFD,0x23,0x74,0x36,0xF7,0xA4,0xF5,0x9E,0x7A,0x7E,0x53,0x50,0x44, - 0xD4,0x47,0xCA,0xD3,0xEB,0x38,0x6D,0xE6,0xD9,0x71,0x94,0x7F,0x4A,0xC6,0x69,0x4B, - 0x11,0xF4,0x52,0xEA,0x22,0xFE,0x8A,0xB0,0x36,0x67,0x8B,0x59,0xE8,0xE6,0x80,0x2A, - 0xEB,0x65,0x04,0x13,0xEE,0xEC,0xDC,0x9E,0x5F,0xB1,0xEC,0x05,0x6A,0x59,0xE6,0x9F, - 0x5E,0x59,0x6B,0x89,0xBF,0xF7,0x1A,0xCA,0x44,0xF9,0x5B,0x6A,0x71,0x85,0x03,0xE4, - 0x29,0x62,0xE0,0x70,0x6F,0x41,0xC4,0xCF,0xB2,0xB1,0xCC,0xE3,0x7E,0xA6,0x07,0xA8, - 0x87,0xE7,0x7F,0x84,0x93,0xDB,0x52,0x4B,0x6C,0xEC,0x7E,0xDD,0xD4,0x24,0x48,0x10, - 0x69,0x9F,0x04,0x60,0x74,0xE6,0x48,0x18,0xF3,0xE4,0x2C,0xB9,0x4F,0x2E,0x50,0x7A, - 0xDF,0xD4,0x54,0x69,0x2B,0x8B,0xA7,0xF3,0xCE,0xFF,0x1F,0xF3,0x3E,0x26,0x01,0x39, - 0x17,0x95,0x84,0x89,0xB0,0xF0,0x4C,0x4B,0x82,0x91,0x9F,0xC4,0x4B,0xAC,0x9D,0xA5, - 0x74,0xAF,0x17,0x25,0xC9,0xCA,0x32,0xD3,0xBC,0x89,0x8A,0x84,0x89,0xCC,0x0D,0xAE, - 0x7C,0xA2,0xDB,0x9C,0x6A,0x78,0x91,0xEE,0xEA,0x76,0x5D,0x4E,0x87,0x60,0xF5,0x69, - 0x15,0x67,0xD4,0x02,0xCF,0xAF,0x48,0x36,0x07,0xEA,0xBF,0x6F,0x66,0x2D,0x06,0x8F, - 0xC4,0x9A,0xFE,0xF9,0xF6,0x90,0x87,0x75,0xB8,0xF7,0xAD,0x0F,0x76,0x10,0x5A,0x3D, - 0x59,0xB0,0x2E,0xB3,0xC7,0x35,0x2C,0xCC,0x70,0x56,0x2B,0xCB,0xE3,0x37,0x96,0xC5, - 0x2F,0x46,0x1B,0x8A,0x22,0x46,0xC7,0x88,0xA7,0x26,0x32,0x98,0x61,0xDF,0x86,0x22, - 0x8A,0xF4,0x1C,0x2F,0x87,0xA1,0x09,0xAA,0xCC,0xA9,0xAE,0xD3,0xBD,0x00,0x45,0x1C, - 0x9A,0x54,0x87,0x86,0x52,0x87,0xEF,0xFF,0x1E,0x8F,0xA1,0x8F,0xC1,0x89,0x5C,0x35, - 0x1B,0xDA,0x2D,0x3A,0x2C,0x16,0xB2,0xC2,0xF1,0x56,0xE2,0x78,0xC1,0x6B,0x63,0x97, - 0xC5,0x56,0x8F,0xC9,0x32,0x7F,0x2C,0xAA,0xAF,0xA6,0xA8,0xAC,0x20,0x91,0x22,0x88, - 0xDE,0xE4,0x60,0x8B,0xF9,0x4B,0x42,0x25,0x1A,0xE3,0x7F,0x9C,0x2C,0x19,0x89,0x3A, - 0x7E,0x05,0xD4,0x36,0xCC,0x69,0x58,0xC2,0xC1,0x32,0x8B,0x2F,0x90,0x85,0xEB,0x7A, - 0x39,0x50,0xA5,0xA1,0x27,0x92,0xC5,0x66,0xB0,0x20,0x4F,0x58,0x7E,0x55,0x83,0x43, - 0x2B,0x45,0xE2,0x9C,0xE4,0xD8,0x12,0x90,0x2C,0x16,0x83,0x56,0x16,0x79,0x03,0xB3, - 0xAD,0x2D,0x61,0x18,0x1A,0x13,0x1F,0x37,0xE2,0xE1,0x9C,0x73,0x7B,0x80,0xD5,0xFD, - 0x2D,0x51,0x87,0xFC,0x7B,0xAA,0xD7,0x1F,0x2C,0x7A,0x8E,0xAF,0xF4,0x8D,0xBB,0xCD, - 0x95,0x11,0x7C,0x72,0x0B,0xEE,0x6F,0xE2,0xB9,0xAF,0xDE,0x37,0x83,0xDE,0x8C,0x8D, - 0x62,0x05,0x67,0xB7,0x96,0xC6,0x8D,0x56,0xB6,0x0D,0xD7,0x62,0xBA,0xD6,0x46,0x36, - 0xBD,0x8E,0xC8,0xE6,0xEA,0x2A,0x6C,0x10,0x14,0xFF,0x6B,0x5B,0xFA,0x82,0x3C,0x46, - 0xB1,0x30,0x43,0x46,0x51,0x8A,0x7D,0x9B,0x92,0x3E,0x83,0x79,0x5B,0x55,0x5D,0xB2, - 0x6C,0x5E,0xCE,0x90,0x62,0x8E,0x53,0x98,0xC9,0x0D,0x6D,0xE5,0x2D,0x57,0xCD,0xC5, - 0x81,0x57,0xBA,0xE1,0xE8,0xB8,0x8F,0x72,0xE5,0x4F,0x13,0xDC,0xEA,0x9D,0x71,0x15, - 0x10,0xB2,0x11,0x88,0xD5,0x09,0xD4,0x7F,0x5B,0x65,0x7F,0x2C,0x3B,0x38,0x4C,0x11, - 0x68,0x50,0x8D,0xFB,0x9E,0xB0,0x59,0xBF,0x94,0x80,0x89,0x4A,0xC5,0x1A,0x18,0x12, - 0x89,0x53,0xD1,0x4A,0x10,0x29,0xE8,0x8C,0x1C,0xEC,0xB6,0xEA,0x46,0xC7,0x17,0x8B, - 0x25,0x15,0x31,0xA8,0xA2,0x6B,0x43,0xB1,0x9D,0xE2,0xDB,0x0B,0x87,0x9B,0xB0,0x11, - 0x04,0x0E,0x71,0xD2,0x29,0x77,0x89,0x82,0x0A,0x66,0x41,0x7F,0x1D,0x0B,0x48,0xFF, - 0x72,0xBB,0x24,0xFD,0xC2,0x48,0xA1,0x9B,0xFE,0x7B,0x7F,0xCE,0x88,0xDB,0x86,0xD9, - 0x85,0x3B,0x1C,0xB0,0xDC,0xA8,0x33,0x07,0xBF,0x51,0x2E,0xE3,0x0E,0x9A,0x00,0x97, - 0x1E,0x06,0xC0,0x97,0x43,0x9D,0xD8,0xB6,0x45,0xC4,0x86,0x67,0x5F,0x00,0xF8,0x88, - 0x9A,0xA4,0x52,0x9E,0xC7,0xAA,0x8A,0x83,0x75,0xEC,0xC5,0x18,0xAE,0xCE,0xC3,0x2F, - 0x1A,0x2B,0xF9,0x18,0xFF,0xAE,0x1A,0xF5,0x53,0x0B,0xB5,0x33,0x51,0xA7,0xFD,0xE8, - 0xA8,0xE1,0xA2,0x64,0xB6,0x22,0x17,0x43,0x80,0xCC,0x0A,0xD8,0xAE,0x3B,0xBA,0x40, - 0xD7,0xD9,0x92,0x4A,0x89,0xDF,0x04,0x10,0xEE,0x9B,0x18,0x2B,0x6A,0x77,0x69,0x8A, - 0x68,0xF4,0xF9,0xB9,0xA2,0x21,0x15,0x6E,0xE6,0x1E,0x3B,0x03,0x62,0x30,0x9B,0x60, - 0x41,0x7E,0x25,0x9B,0x9E,0x8F,0xC5,0x52,0x10,0x08,0xF8,0xC2,0x69,0xA1,0x21,0x11, - 0x88,0x37,0x5E,0x79,0x35,0x66,0xFF,0x10,0x42,0x18,0x6E,0xED,0x97,0xB6,0x6B,0x1C, - 0x4E,0x36,0xE5,0x6D,0x7D,0xB4,0xE4,0xBF,0x20,0xB9,0xE0,0x05,0x3A,0x69,0xD5,0xB8, - 0xE3,0xD5,0xDC,0xE0,0xB9,0xAC,0x53,0x3E,0x07,0xA4,0x57,0xAD,0x77,0xFF,0x48,0x18, - 0x76,0x2A,0xAC,0x49,0x2A,0x8E,0x47,0x75,0x6D,0x9F,0x67,0x63,0x30,0x35,0x8C,0x39, - 0x05,0x39,0xD5,0x6F,0x64,0x3A,0x5B,0xAD,0xCA,0x0B,0xBB,0x82,0x52,0x99,0x45,0xB1, - 0x93,0x36,0x36,0x99,0xAF,0x13,0x20,0x44,0x36,0xD8,0x02,0x44,0x09,0x39,0x92,0x85, - 0xFF,0x4A,0x4A,0x97,0x87,0xA6,0x63,0xD7,0xC7,0xB5,0xB5,0x24,0xED,0x0F,0xB4,0x6F, - 0x0C,0x58,0x52,0x14,0xD9,0xA6,0x7B,0xD3,0x79,0xBC,0x38,0x58,0xA1,0xBD,0x3B,0x84, - 0x06,0xD8,0x1A,0x06,0xFD,0x6B,0xA8,0xEA,0x4B,0x69,0x28,0x04,0x37,0xAD,0x82,0x99, - 0xFB,0x0E,0x1B,0x85,0xBD,0xA8,0x5D,0x73,0xCD,0xDC,0x58,0x75,0x0A,0xBE,0x63,0x6C, - 0x48,0xE7,0x4C,0xE4,0x30,0x2B,0x04,0x60,0xB9,0x15,0xD8,0xDA,0x86,0x81,0x75,0x8F, - 0x96,0xD4,0x8D,0x1C,0x5D,0x70,0x85,0x7C,0x1C,0x67,0x7B,0xD5,0x08,0x67,0xA6,0xCE, - 0x4B,0x0A,0x66,0x70,0xB7,0xE5,0x63,0xD4,0x5B,0x8A,0x82,0xEA,0x10,0x67,0xCA,0xE2, - 0xF4,0xEF,0x17,0x85,0x2F,0x2A,0x5F,0x8A,0x97,0x82,0xF8,0x6A,0xD6,0x34,0x10,0xEA, - 0xEB,0xC9,0x5C,0x3C,0xE1,0x49,0xF8,0x46,0xEB,0xDE,0xBD,0xF6,0xA9,0x92,0xF1,0xAA, - 0xA6,0xA0,0x18,0xB0,0x3A,0xD3,0x0F,0x1F,0xF3,0x6F,0xFF,0x31,0x45,0x43,0x44,0xD3, - 0x50,0x9A,0xF7,0x88,0x09,0x96,0xC1,0xCE,0x76,0xCC,0xF2,0x2C,0x2C,0xBA,0xAD,0x82, - 0x77,0x8F,0x18,0x84,0xC0,0xD2,0x07,0x9C,0x36,0x90,0x83,0x4E,0x0B,0xA5,0x4F,0x43, - 0x3E,0x04,0xAB,0x78,0x4F,0xD6,0xFB,0x09,0x01,0x24,0x90,0xDA,0x6F,0x3C,0x3A,0x61, - 0x0D,0x7F,0x69,0x4A,0xEB,0x2B,0x30,0x02,0xB4,0xDB,0xE0,0x84,0xA9,0xEC,0xD7,0x35, - 0xBF,0x37,0x7D,0x85,0x58,0xCE,0xA9,0x4E,0xE4,0x80,0xC7,0xA8,0xD3,0x30,0x67,0x48, - 0xEB,0x29,0xAF,0x2F,0x74,0x6A,0xB4,0xA7,0x3F,0x0F,0x3F,0x92,0xAF,0xF3,0xCA,0xAC, - 0xAF,0x4B,0xD9,0x94,0xC0,0x43,0xCA,0x81,0x0D,0x2F,0x48,0xA1,0xB0,0x27,0xD5,0xD2, - 0xEF,0x4B,0x05,0x85,0xA3,0xDE,0x4D,0x93,0x30,0x3C,0xF0,0xBB,0x4A,0x8F,0x30,0x27, - 0x4C,0xEB,0xE3,0x3E,0x64,0xED,0x9A,0x2F,0x3B,0xF1,0x82,0xF0,0xBA,0xF4,0xCF,0x7F, - 0x40,0xCB,0xB0,0xE1,0x7F,0xBC,0xAA,0x57,0xD3,0xC9,0x74,0xF2,0xFA,0x43,0x0D,0x22, - 0xD0,0xF4,0x77,0x4E,0x93,0xD7,0x85,0x70,0x1F,0x99,0xBF,0xB6,0xDE,0x35,0xF1,0x30, - 0xA7,0x5E,0x71,0xF0,0x6B,0x01,0x2D,0x7B,0x64,0xF0,0x33,0x53,0x0A,0x39,0x88,0xF3, - 0x6B,0x3A,0xA6,0x6B,0x35,0xD2,0x2F,0x43,0xCD,0x02,0xFD,0xB5,0xE9,0xBC,0x5B,0xAA, - 0xD8,0xA4,0x19,0x7E,0x0E,0x5D,0x94,0x81,0x9E,0x6F,0x77,0xAD,0xD6,0x0E,0x74,0x93, - 0x96,0xE7,0xC4,0x18,0x5F,0xAD,0xF5,0x19, -}; - -u32 card_hash[0x412]; -int cardheader_devicetype = 0; -u32 global3_x00, global3_x04; // RTC value -u32 global3_rand1; -u32 global3_rand3; - -static u32 lookup(u32 *magic, u32 v) -{ - u32 a = (v >> 24) & 0xFF; - u32 b = (v >> 16) & 0xFF; - u32 c = (v >> 8) & 0xFF; - u32 d = (v >> 0) & 0xFF; - - a = magic[a+18+0]; - b = magic[b+18+256]; - c = magic[c+18+512]; - d = magic[d+18+768]; - - return d + (c ^ (b + a)); -} - -static void encrypt(u32 *magic, u32 *arg1, u32 *arg2) -{ - u32 a,b,c; - a = *arg1; - b = *arg2; - for (int i=0; i<16; i++) - { - c = magic[i] ^ a; - a = b ^ lookup(magic, c); - b = c; - } - *arg2 = a ^ magic[16]; - *arg1 = b ^ magic[17]; -} - -static void decrypt(u32 *magic, u32 *arg1, u32 *arg2) -{ - u32 a,b,c; - a = *arg1; - b = *arg2; - for (int i=17; i>1; i--) - { - c = magic[i] ^ a; - a = b ^ lookup(magic, c); - b = c; - } - *arg1 = b ^ magic[0]; - *arg2 = a ^ magic[1]; -} - -static void encrypt(u32 *magic, u64 &cmd) -{ - encrypt(magic, (u32 *)&cmd + 1, (u32 *)&cmd + 0); -} - -static void decrypt(u32 *magic, u64 &cmd) -{ - decrypt(magic, (u32 *)&cmd + 1, (u32 *)&cmd + 0); -} - -static void update_hashtable(u32* magic, u8 arg1[8]) -{ - for (int j=0;j<18;j++) - { - u32 r3=0; - for (int i=0;i<4;i++) - { - r3 <<= 8; - r3 |= arg1[(j*4 + i) & 7]; - } - magic[j] ^= r3; - } - - u32 tmp1 = 0; - u32 tmp2 = 0; - for (int i=0; i<18; i+=2) - { - encrypt(magic,&tmp1,&tmp2); - magic[i+0] = tmp1; - magic[i+1] = tmp2; - } - for (int i=0; i<0x400; i+=2) - { - encrypt(magic,&tmp1,&tmp2); - magic[i+18+0] = tmp1; - magic[i+18+1] = tmp2; - } -} - -u32 arg2[3]; - -static void init2(u32 *magic, u32 a[3]) -{ - encrypt(magic, a+2, a+1); - encrypt(magic, a+1, a+0); - update_hashtable(magic, (u8*)a); -} - -static void init1(u32 cardheader_gamecode) -{ - memcpy(card_hash, &encr_data, 4*(1024 + 18)); - arg2[0] = *(u32 *)&cardheader_gamecode; - arg2[1] = (*(u32 *)&cardheader_gamecode) >> 1; - arg2[2] = (*(u32 *)&cardheader_gamecode) << 1; - init2(card_hash, arg2); - init2(card_hash, arg2); -} - -static void init0(u32 cardheader_gamecode) -{ - init1(cardheader_gamecode); - encrypt(card_hash, (u32*)&global3_x04, (u32*)&global3_x00); - global3_rand1 = global3_x00 ^ global3_x04; // more RTC - global3_rand3 = global3_x04 ^ 0x0380FEB2; - encrypt(card_hash, (u32*)&global3_rand3, (u32*)&global3_rand1); -} - -// ARM9 decryption check values -#define MAGIC30 0x72636E65 -#define MAGIC34 0x6A624F79 - -/* - * decrypt_arm9 - */ -static void decrypt_arm9(u32 cardheader_gamecode, unsigned char *data) -{ - u32 *p = (u32*)data; - - init1(cardheader_gamecode); - decrypt(card_hash, p+1, p); - arg2[1] <<= 1; - arg2[2] >>= 1; - init2(card_hash, arg2); - decrypt(card_hash, p+1, p); - - if (p[0] != MAGIC30 || p[1] != MAGIC34) - { - fprintf(stderr, "Decryption failed!\n"); - exit(1); - } - - *p++ = 0xE7FFDEFF; - *p++ = 0xE7FFDEFF; - u32 size = 0x800 - 8; - while (size > 0) - { - decrypt(card_hash, p+1, p); - p += 2; - size -= 8; - } -} - - -bool DecryptSecureArea(u8 *romdata, long romlen) -{ - //this looks like it will only work on little endian hosts - Header* header = (Header*)romdata; - - int romType = DetectRomType(*header,(char*)romdata); - - /*bool do_decrypt = (endecrypt_option == 'd'); - bool do_encrypt = (endecrypt_option == 'e') || (endecrypt_option == 'E'); - unsigned int rounds_offsets = (endecrypt_option == 'E') ? 0x2000 : 0x1600; - unsigned int sbox_offsets = (endecrypt_option == 'E') ? 0x2400 : 0x2800;*/ -#if 0 - unsigned int rounds_offsets = 0x1600; - unsigned int sbox_offsets = 0x2800; -#endif - - if(romType == ROMTYPE_INVALID) - return false; - - // check if ROM is already encrypted - if (romType == ROMTYPE_NDSDUMPED) - { - printf("Already decrypted.\n"); - } - else if (romType >= ROMTYPE_ENCRSECURE) // includes ROMTYPE_MASKROM - { - unsigned char data[0x4000]; - memcpy(data,romdata+0x4000,0x4000); - - decrypt_arm9(*(u32 *)header->gamecode, data); - - // clear data after header - //fseek(fNDS, 0x200, SEEK_SET); - //for (unsigned int i=0x200; i<0x4000; i++) fputc(0, fNDS); - memset(romdata+0x200,0,(0x4000-0x200)); - - // write secure 0x800 - //fseek(fNDS, 0x4000, SEEK_SET); - //fwrite(data, 1, 0x800, fNDS); - memcpy(romdata+0x4000,data,0x800); - - // write header - //(already poked directly) - //fseek(fNDS, 0, SEEK_SET); - //fwrite(&header, 512, 1, fNDS); - - printf("Decrypted.\n"); - } - else - { - printf("File doesn't appear to have a secure area.\n"); - } - - return true; -} +//taken from ndstool +//http://devkitpro.cvs.sourceforge.net/viewvc/devkitpro/tools/nds/ndstool/source/encryption.cpp?revision=1.2 + +/* decrypt.cpp - this file is part of DeSmuME + * + * Copyright (C) 2006 Rafael Vuijk + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include + +#include "../../types.h" +#include "crc.h" +#include "header.h" +#include "decrypt.h" + +const unsigned char encr_data[] = +{ + 0x99,0xD5,0x20,0x5F,0x57,0x44,0xF5,0xB9,0x6E,0x19,0xA4,0xD9,0x9E,0x6A,0x5A,0x94, + 0xD8,0xAE,0xF1,0xEB,0x41,0x75,0xE2,0x3A,0x93,0x82,0xD0,0x32,0x33,0xEE,0x31,0xD5, + 0xCC,0x57,0x61,0x9A,0x37,0x06,0xA2,0x1B,0x79,0x39,0x72,0xF5,0x55,0xAE,0xF6,0xBE, + 0x5F,0x1B,0x69,0xFB,0xE5,0x9D,0xF1,0xE9,0xCE,0x2C,0xD9,0xA1,0x5E,0x32,0x05,0xE6, + 0xFE,0xD3,0xFE,0xCF,0xD4,0x62,0x04,0x0D,0x8B,0xF5,0xEC,0xB7,0x2B,0x60,0x79,0xBB, + 0x12,0x95,0x31,0x0D,0x6E,0x3F,0xDA,0x2B,0x88,0x84,0xF0,0xF1,0x3D,0x12,0x7E,0x25, + 0x45,0x22,0xF1,0xBB,0x24,0x06,0x1A,0x06,0x11,0xAD,0xDF,0x28,0x8B,0x64,0x81,0x34, + 0x2B,0xEB,0x33,0x29,0x99,0xAA,0xF2,0xBD,0x9C,0x14,0x95,0x9D,0x9F,0xF7,0xF5,0x8C, + 0x72,0x97,0xA1,0x29,0x9D,0xD1,0x5F,0xCF,0x66,0x4D,0x07,0x1A,0xDE,0xD3,0x4A,0x4B, + 0x85,0xC9,0xA7,0xA3,0x17,0x95,0x05,0x3A,0x3D,0x49,0x0A,0xBF,0x0A,0x89,0x8B,0xA2, + 0x4A,0x82,0x49,0xDD,0x27,0x90,0xF1,0x0B,0xE9,0xEB,0x1C,0x6A,0x83,0x76,0x45,0x05, + 0xBA,0x81,0x70,0x61,0x17,0x3F,0x4B,0xDE,0xAE,0xCF,0xAB,0x39,0x57,0xF2,0x3A,0x56, + 0x48,0x11,0xAD,0x8A,0x40,0xE1,0x45,0x3F,0xFA,0x9B,0x02,0x54,0xCA,0xA6,0x93,0xFB, + 0xEF,0x4D,0xFE,0x6F,0xA3,0xD8,0x87,0x9C,0x08,0xBA,0xD5,0x48,0x6A,0x8D,0x2D,0xFD, + 0x6E,0x15,0xF8,0x74,0xBD,0xBE,0x52,0x8B,0x18,0x22,0x8A,0x9E,0xFB,0x74,0x37,0x07, + 0x1B,0x36,0x6C,0x4A,0x19,0xBA,0x42,0x62,0xB9,0x79,0x91,0x10,0x7B,0x67,0x65,0x96, + 0xFE,0x02,0x23,0xE8,0xEE,0x99,0x8C,0x77,0x3E,0x5C,0x86,0x64,0x4D,0x6D,0x78,0x86, + 0xA5,0x4F,0x65,0xE2,0x1E,0xB2,0xDF,0x5A,0x0A,0xD0,0x7E,0x08,0x14,0xB0,0x71,0xAC, + 0xBD,0xDB,0x83,0x1C,0xB9,0xD7,0xA1,0x62,0xCD,0xC6,0x63,0x7C,0x52,0x69,0xC3,0xE6, + 0xBF,0x75,0xCE,0x12,0x44,0x5D,0x21,0x04,0xFA,0xFB,0xD3,0x3C,0x38,0x11,0x63,0xD4, + 0x95,0x85,0x41,0x49,0x46,0x09,0xF2,0x08,0x43,0x11,0xDC,0x1F,0x76,0xC0,0x15,0x6D, + 0x1F,0x3C,0x63,0x70,0xEA,0x87,0x80,0x6C,0xC3,0xBD,0x63,0x8B,0xC2,0x37,0x21,0x37, + 0xDC,0xEE,0x09,0x23,0x2E,0x37,0x6A,0x4D,0x73,0x90,0xF7,0x50,0x30,0xAC,0x1C,0x92, + 0x04,0x10,0x23,0x91,0x4F,0xD2,0x07,0xAA,0x68,0x3E,0x4F,0x9A,0xC9,0x64,0x60,0x6A, + 0xC8,0x14,0x21,0xF3,0xD6,0x22,0x41,0x12,0x44,0x24,0xCF,0xE6,0x8A,0x56,0xDD,0x0D, + 0x53,0x4D,0xE1,0x85,0x1E,0x8C,0x52,0x5A,0x9C,0x19,0x84,0xC2,0x03,0x57,0xF1,0x6F, + 0xE3,0x00,0xBE,0x58,0xF6,0x4C,0xED,0xD5,0x21,0x64,0x9C,0x1F,0xBE,0x55,0x03,0x3C, + 0x4A,0xDC,0xFF,0xAA,0xC9,0xDA,0xE0,0x5D,0x5E,0xBF,0xE6,0xDE,0xF5,0xD8,0xB1,0xF8, + 0xFF,0x36,0xB3,0xB9,0x62,0x67,0x95,0xDB,0x31,0x5F,0x37,0xED,0x4C,0x70,0x67,0x99, + 0x90,0xB5,0x18,0x31,0x6C,0x3D,0x99,0x99,0xE4,0x42,0xDA,0xD3,0x25,0x42,0x13,0xA0, + 0xAE,0xD7,0x70,0x6C,0xB1,0x55,0xCF,0xC7,0xD7,0x46,0xD5,0x43,0x61,0x17,0x3D,0x44, + 0x28,0xE9,0x33,0x85,0xD5,0xD0,0xA2,0x93,0xAA,0x25,0x12,0x1F,0xFB,0xC5,0x0B,0x46, + 0xF5,0x97,0x76,0x56,0x45,0xA6,0xBE,0x87,0xB1,0x94,0x6B,0xE8,0xB1,0xFE,0x33,0x99, + 0xAE,0x1F,0x3E,0x6C,0x39,0x71,0x1D,0x09,0x00,0x90,0x37,0xE4,0x10,0x3E,0x75,0x74, + 0xFF,0x8C,0x83,0x3B,0xB0,0xF1,0xB0,0xF9,0x01,0x05,0x47,0x42,0x95,0xF1,0xD6,0xAC, + 0x7E,0x38,0xE6,0x9E,0x95,0x74,0x26,0x3F,0xB4,0x68,0x50,0x18,0xD0,0x43,0x30,0xB4, + 0x4C,0x4B,0xE3,0x68,0xBF,0xE5,0x4D,0xB6,0x95,0x8B,0x0A,0xA0,0x74,0x25,0x32,0x77, + 0xCF,0xA1,0xF7,0x2C,0xD8,0x71,0x13,0x5A,0xAB,0xEA,0xC9,0x51,0xE8,0x0D,0xEE,0xEF, + 0xE9,0x93,0x7E,0x19,0xA7,0x1E,0x43,0x38,0x81,0x16,0x2C,0xA1,0x48,0xE3,0x73,0xCC, + 0x29,0x21,0x6C,0xD3,0x5D,0xCE,0xA0,0xD9,0x61,0x71,0x43,0xA0,0x15,0x13,0xB5,0x64, + 0x92,0xCF,0x2A,0x19,0xDC,0xAD,0xB7,0xA5,0x9F,0x86,0x65,0xF8,0x1A,0x9F,0xE7,0xFB, + 0xF7,0xFD,0xB8,0x13,0x6C,0x27,0xDB,0x6F,0xDF,0x35,0x1C,0xF7,0x8D,0x2C,0x5B,0x9B, + 0x12,0xAB,0x38,0x64,0x06,0xCC,0xDE,0x31,0xE8,0x4E,0x75,0x11,0x64,0xE3,0xFA,0xEA, + 0xEB,0x34,0x54,0xC2,0xAD,0x3F,0x34,0xEB,0x93,0x2C,0x7D,0x26,0x36,0x9D,0x56,0xF3, + 0x5A,0xE1,0xF6,0xB3,0x98,0x63,0x4A,0x9E,0x32,0x83,0xE4,0x9A,0x84,0x60,0x7D,0x90, + 0x2E,0x13,0x0E,0xEE,0x93,0x4B,0x36,0xA2,0x85,0xEC,0x16,0x38,0xE8,0x88,0x06,0x02, + 0xBF,0xF0,0xA0,0x3A,0xED,0xD7,0x6A,0x9A,0x73,0xE1,0x57,0xCF,0xF8,0x44,0xB8,0xDC, + 0x2E,0x23,0x59,0xD1,0xDF,0x95,0x52,0x71,0x99,0x61,0xA0,0x4B,0xD5,0x7F,0x6E,0x78, + 0xBA,0xA9,0xC5,0x30,0xD3,0x40,0x86,0x32,0x9D,0x32,0x0C,0x9C,0x37,0xB7,0x02,0x2F, + 0xBA,0x54,0x98,0xA9,0xC4,0x13,0x04,0xC9,0x8D,0xBE,0xC8,0xE7,0x5D,0x97,0x50,0x2E, + 0x93,0xD6,0x22,0x59,0x0C,0x27,0xBC,0x22,0x92,0xE0,0xA7,0x20,0x0F,0x93,0x6F,0x7F, + 0x4C,0x9F,0xD3,0xB5,0xA6,0x2A,0x0B,0x74,0x67,0x49,0x7D,0x10,0x26,0xCB,0xD1,0xC5, + 0x86,0x71,0xE7,0x8C,0xA0,0x9C,0xE9,0x5B,0xB2,0x1A,0xF6,0x01,0xEE,0x8C,0x9E,0x5E, + 0x83,0xF2,0x1A,0xDB,0xE6,0xE5,0xEA,0x84,0x59,0x76,0xD2,0x7C,0xF6,0x8D,0xA5,0x49, + 0x36,0x48,0xC2,0x16,0x52,0xBB,0x83,0xA3,0x74,0xB9,0x07,0x0C,0x3B,0xFF,0x61,0x28, + 0xE1,0x61,0xE9,0xE4,0xEF,0x6E,0x15,0xAA,0x4E,0xBA,0xE8,0x5D,0x05,0x96,0xBB,0x32, + 0x56,0xB0,0xFB,0x72,0x52,0x0F,0x0E,0xC8,0x42,0x25,0x65,0x76,0x89,0xAF,0xF2,0xDE, + 0x10,0x27,0xF0,0x01,0x4B,0x74,0xA7,0x97,0x07,0xD5,0x26,0x54,0x54,0x09,0x1F,0x82, + 0x0A,0x86,0x7D,0x30,0x39,0x0E,0xB3,0x26,0x9B,0x0B,0x57,0xBB,0x36,0x06,0x31,0xAF, + 0xFD,0x79,0xFC,0xD9,0x30,0x10,0x2B,0x0C,0xB3,0xE1,0x9B,0xD7,0x7B,0xDC,0x5F,0xEF, + 0xD2,0xF8,0x13,0x45,0x4D,0x47,0x75,0xBD,0x46,0x96,0x3C,0x7E,0x75,0xF3,0x3E,0xB5, + 0x67,0xC5,0x9A,0x3B,0xB0,0x5B,0x29,0x6B,0xDE,0x80,0x5B,0xC8,0x15,0x05,0xB1,0x31, + 0xB6,0xCE,0x49,0xDD,0xAD,0x84,0xB5,0xAE,0x60,0xDC,0x67,0x31,0x34,0x30,0xFE,0x4E, + 0xBD,0x80,0x2F,0xA6,0xBF,0x63,0x39,0x21,0x86,0xD9,0x35,0x7F,0x16,0x68,0x22,0x05, + 0x54,0xE9,0x90,0x26,0x8C,0x07,0x6C,0x51,0xA4,0x31,0x55,0xD7,0x09,0x07,0xA8,0x3E, + 0x2E,0x53,0x66,0xC1,0xF8,0xF2,0x7B,0xC4,0xF2,0x58,0xCF,0xF1,0x87,0xC5,0xA2,0xE7, + 0x27,0x8F,0x30,0x87,0x58,0xA0,0x64,0x62,0x23,0x18,0xB9,0x88,0x7C,0xFA,0xCE,0xC4, + 0x98,0xAE,0xAD,0x17,0xCC,0x4A,0x5B,0xF3,0xE9,0x48,0xD5,0x56,0xD3,0x0D,0xF2,0xC8, + 0x92,0x73,0x8C,0xDB,0xD7,0x2F,0x56,0xAC,0x81,0xF9,0x92,0x69,0x4D,0xC6,0x32,0xF6, + 0xE6,0xC0,0x8D,0x21,0xE2,0x76,0x80,0x61,0x11,0xBC,0xDC,0x6C,0x93,0xAF,0x19,0x69, + 0x9B,0xD0,0xBF,0xB9,0x31,0x9F,0x02,0x67,0xA3,0x51,0xEE,0x83,0x06,0x22,0x7B,0x0C, + 0xAB,0x49,0x42,0x40,0xB8,0xD5,0x01,0x7D,0xCE,0x5E,0xF7,0x55,0x53,0x39,0xC5,0x99, + 0x46,0xD8,0x87,0x9F,0xBA,0xF7,0x64,0xB4,0xE3,0x9A,0xFA,0xA1,0x6D,0x90,0x68,0x10, + 0x30,0xCA,0x8A,0x54,0xA7,0x9F,0x60,0xC3,0x19,0xF5,0x6B,0x0D,0x7A,0x51,0x98,0xE6, + 0x98,0x43,0x51,0xB4,0xD6,0x35,0xE9,0x4F,0xC3,0xDF,0x0F,0x7B,0xD6,0x2F,0x5C,0xBD, + 0x3A,0x15,0x61,0x19,0xF1,0x4B,0xCB,0xAA,0xDC,0x6D,0x64,0xC9,0xD3,0xC6,0x1E,0x56, + 0xEF,0x38,0x4C,0x50,0x71,0x86,0x75,0xCC,0x0D,0x0D,0x4E,0xE9,0x28,0xF6,0x06,0x5D, + 0x70,0x1B,0xAA,0xD3,0x45,0xCF,0xA8,0x39,0xAC,0x95,0xA6,0x2E,0xB4,0xE4,0x22,0xD4, + 0x74,0xA8,0x37,0x5F,0x48,0x7A,0x04,0xCC,0xA5,0x4C,0x40,0xD8,0x28,0xB4,0x28,0x08, + 0x0D,0x1C,0x72,0x52,0x41,0xF0,0x7D,0x47,0x19,0x3A,0x53,0x4E,0x58,0x84,0x62,0x6B, + 0x93,0xB5,0x8A,0x81,0x21,0x4E,0x0D,0xDC,0xB4,0x3F,0xA2,0xC6,0xFC,0xC9,0x2B,0x40, + 0xDA,0x38,0x04,0xE9,0x5E,0x5A,0x86,0x6B,0x0C,0x22,0x25,0x85,0x68,0x11,0x8D,0x7C, + 0x92,0x1D,0x95,0x55,0x4D,0xAB,0x8E,0xBB,0xDA,0xA6,0xE6,0xB7,0x51,0xB6,0x32,0x5A, + 0x05,0x41,0xDD,0x05,0x2A,0x0A,0x56,0x50,0x91,0x17,0x47,0xCC,0xC9,0xE6,0x7E,0xB5, + 0x61,0x4A,0xDB,0x73,0x67,0x51,0xC8,0x33,0xF5,0xDA,0x6E,0x74,0x2E,0x54,0xC3,0x37, + 0x0D,0x6D,0xAF,0x08,0xE8,0x15,0x8A,0x5F,0xE2,0x59,0x21,0xCD,0xA8,0xDE,0x0C,0x06, + 0x5A,0x77,0x6B,0x5F,0xDB,0x18,0x65,0x3E,0xC8,0x50,0xDE,0x78,0xE0,0xB8,0x82,0xB3, + 0x5D,0x4E,0x72,0x32,0x07,0x4F,0xC1,0x34,0x23,0xBA,0x96,0xB7,0x67,0x4E,0xA4,0x28, + 0x1E,0x34,0x62,0xEB,0x2D,0x6A,0x70,0xE9,0x2F,0x42,0xC4,0x70,0x4E,0x5A,0x31,0x9C, + 0xF9,0x5B,0x47,0x28,0xAA,0xDA,0x71,0x6F,0x38,0x1F,0xB3,0x78,0xC4,0x92,0x6B,0x1C, + 0x9E,0xF6,0x35,0x9A,0xB7,0x4D,0x0E,0xBF,0xCC,0x18,0x29,0x41,0x03,0x48,0x35,0x5D, + 0x55,0xD0,0x2B,0xC6,0x29,0xAF,0x5C,0x60,0x74,0x69,0x8E,0x5E,0x9B,0x7C,0xD4,0xBD, + 0x7B,0x44,0x64,0x7D,0x3F,0x92,0x5D,0x69,0xB6,0x1F,0x00,0x4B,0xD4,0x83,0x35,0xCF, + 0x7E,0x64,0x4E,0x17,0xAE,0x8D,0xD5,0x2E,0x9A,0x28,0x12,0x4E,0x2E,0x2B,0x49,0x08, + 0x5C,0xAE,0xC6,0x46,0x85,0xAE,0x41,0x61,0x1E,0x6F,0x82,0xD2,0x51,0x37,0x16,0x1F, + 0x0B,0xF6,0x59,0xA4,0x9A,0xCA,0x5A,0xAF,0x0D,0xD4,0x33,0x8B,0x20,0x63,0xF1,0x84, + 0x80,0x5C,0xCB,0xCF,0x08,0xB4,0xB9,0xD3,0x16,0x05,0xBD,0x62,0x83,0x31,0x9B,0x56, + 0x51,0x98,0x9F,0xBA,0xB2,0x5B,0xAA,0xB2,0x22,0x6B,0x2C,0xB5,0xD4,0x48,0xFA,0x63, + 0x2B,0x5F,0x58,0xFA,0x61,0xFA,0x64,0x09,0xBB,0x38,0xE0,0xB8,0x9D,0x92,0x60,0xA8, + 0x0D,0x67,0x6F,0x0E,0x37,0xF5,0x0D,0x01,0x9F,0xC2,0x77,0xD4,0xFE,0xEC,0xF1,0x73, + 0x30,0x39,0xE0,0x7D,0xF5,0x61,0x98,0xE4,0x2C,0x28,0x55,0x04,0x56,0x55,0xDB,0x2F, + 0x6B,0xEC,0xE5,0x58,0x06,0xB6,0x64,0x80,0x6A,0x2A,0x1A,0x4E,0x5B,0x0F,0xD8,0xC4, + 0x0A,0x2E,0x52,0x19,0xD9,0x62,0xF5,0x30,0x48,0xBE,0x8C,0x7B,0x4F,0x38,0x9B,0xA2, + 0xC3,0xAF,0xC9,0xD3,0xC7,0xC1,0x62,0x41,0x86,0xB9,0x61,0x21,0x57,0x6F,0x99,0x4F, + 0xC1,0xBA,0xCE,0x7B,0xB5,0x3B,0x4D,0x5E,0x8A,0x8B,0x44,0x57,0x5F,0x13,0x5F,0x70, + 0x6D,0x5B,0x29,0x47,0xDC,0x38,0xE2,0xEC,0x04,0x55,0x65,0x12,0x2A,0xE8,0x17,0x43, + 0xE1,0x8E,0xDD,0x2A,0xB3,0xE2,0x94,0xF7,0x09,0x6E,0x5C,0xE6,0xEB,0x8A,0xF8,0x6D, + 0x89,0x49,0x54,0x48,0xF5,0x2F,0xAD,0xBF,0xEA,0x94,0x4B,0xCA,0xFC,0x39,0x87,0x82, + 0x5F,0x8A,0x01,0xF2,0x75,0xF2,0xE6,0x71,0xD6,0xD8,0x42,0xDE,0xF1,0x2D,0x1D,0x28, + 0xA6,0x88,0x7E,0xA3,0xA0,0x47,0x1D,0x30,0xD9,0xA3,0x71,0xDF,0x49,0x1C,0xCB,0x01, + 0xF8,0x36,0xB1,0xF2,0xF0,0x22,0x58,0x5D,0x45,0x6B,0xBD,0xA0,0xBB,0xB2,0x88,0x42, + 0xC7,0x8C,0x28,0xCE,0x93,0xE8,0x90,0x63,0x08,0x90,0x7C,0x89,0x3C,0xF5,0x7D,0xB7, + 0x04,0x2D,0x4F,0x55,0x51,0x16,0xFD,0x7E,0x79,0xE8,0xBE,0xC1,0xF2,0x12,0xD4,0xF8, + 0xB4,0x84,0x05,0x23,0xA0,0xCC,0xD2,0x2B,0xFD,0xE1,0xAB,0xAD,0x0D,0xD1,0x55,0x6C, + 0x23,0x41,0x94,0x4D,0x77,0x37,0x4F,0x05,0x28,0x0C,0xBF,0x17,0xB3,0x12,0x67,0x6C, + 0x8C,0xC3,0x5A,0xF7,0x41,0x84,0x2A,0x6D,0xD0,0x94,0x12,0x27,0x2C,0xB4,0xED,0x9C, + 0x4D,0xEC,0x47,0x82,0x97,0xD5,0x67,0xB9,0x1B,0x9D,0xC0,0x55,0x07,0x7E,0xE5,0x8E, + 0xE2,0xA8,0xE7,0x3E,0x12,0xE4,0x0E,0x3A,0x2A,0x45,0x55,0x34,0xA2,0xF9,0x2D,0x5A, + 0x1B,0xAB,0x52,0x7C,0x83,0x10,0x5F,0x55,0xD2,0xF1,0x5A,0x43,0x2B,0xC6,0xA7,0xA4, + 0x89,0x15,0x95,0xE8,0xB4,0x4B,0x9D,0xF8,0x75,0xE3,0x9F,0x60,0x78,0x5B,0xD6,0xE6, + 0x0D,0x44,0xE6,0x21,0x06,0xBD,0x47,0x22,0x53,0xA4,0x00,0xAD,0x8D,0x43,0x13,0x85, + 0x39,0xF7,0xAA,0xFC,0x38,0xAF,0x7B,0xED,0xFC,0xE4,0x2B,0x54,0x50,0x98,0x4C,0xFC, + 0x85,0x80,0xF7,0xDF,0x3C,0x80,0x22,0xE1,0x94,0xDA,0xDE,0x24,0xC6,0xB0,0x7A,0x39, + 0x38,0xDC,0x0F,0xA1,0xA7,0xF4,0xF9,0x6F,0x63,0x18,0x57,0x8B,0x84,0x41,0x2A,0x2E, + 0xD4,0x53,0xF2,0xD9,0x00,0x0F,0xD0,0xDD,0x99,0x6E,0x19,0xA6,0x0A,0xD0,0xEC,0x5B, + 0x58,0x24,0xAB,0xC0,0xCB,0x06,0x65,0xEC,0x1A,0x13,0x38,0x94,0x0A,0x67,0x03,0x2F, + 0x3F,0xF7,0xE3,0x77,0x44,0x77,0x33,0xC6,0x14,0x39,0xD0,0xE3,0xC0,0xA2,0x08,0x79, + 0xBB,0x40,0x99,0x57,0x41,0x0B,0x01,0x90,0xCD,0xE1,0xCC,0x48,0x67,0xDB,0xB3,0xAF, + 0x88,0x74,0xF3,0x4C,0x82,0x8F,0x72,0xB1,0xB5,0x23,0x29,0xC4,0x12,0x6C,0x19,0xFC, + 0x8E,0x46,0xA4,0x9C,0xC4,0x25,0x65,0x87,0xD3,0x6D,0xBE,0x8A,0x93,0x11,0x03,0x38, + 0xED,0x83,0x2B,0xF3,0x46,0xA4,0x93,0xEA,0x3B,0x53,0x85,0x1D,0xCE,0xD4,0xF1,0x08, + 0x83,0x27,0xED,0xFC,0x9B,0x1A,0x18,0xBC,0xF9,0x8B,0xAE,0xDC,0x24,0xAB,0x50,0x38, + 0xE9,0x72,0x4B,0x10,0x22,0x17,0x7B,0x46,0x5D,0xAB,0x59,0x64,0xF3,0x40,0xAE,0xF8, + 0xBB,0xE5,0xC8,0xF9,0x26,0x03,0x4E,0x55,0x7D,0xEB,0xEB,0xFE,0xF7,0x39,0xE6,0xE0, + 0x0A,0x11,0xBE,0x2E,0x28,0xFF,0x98,0xED,0xC0,0xC9,0x42,0x56,0x42,0xC3,0xFD,0x00, + 0xF6,0xAF,0x87,0xA2,0x5B,0x01,0x3F,0x32,0x92,0x47,0x95,0x9A,0x72,0xA5,0x32,0x3D, + 0xAE,0x6B,0xD0,0x9B,0x07,0xD2,0x49,0x92,0xE3,0x78,0x4A,0xFA,0xA1,0x06,0x7D,0xF2, + 0x41,0xCF,0x77,0x74,0x04,0x14,0xB2,0x0C,0x86,0x84,0x64,0x16,0xD5,0xBB,0x51,0xA1, + 0xE5,0x6F,0xF1,0xD1,0xF2,0xE2,0xF7,0x5F,0x58,0x20,0x4D,0xB8,0x57,0xC7,0xCF,0xDD, + 0xC5,0xD8,0xBE,0x76,0x3D,0xF6,0x5F,0x7E,0xE7,0x2A,0x8B,0x88,0x24,0x1B,0x38,0x3F, + 0x0E,0x41,0x23,0x77,0xF5,0xF0,0x4B,0xD4,0x0C,0x1F,0xFA,0xA4,0x0B,0x80,0x5F,0xCF, + 0x45,0xF6,0xE0,0xDA,0x2F,0x34,0x59,0x53,0xFB,0x20,0x3C,0x52,0x62,0x5E,0x35,0xB5, + 0x62,0xFE,0x8B,0x60,0x63,0xE3,0x86,0x5A,0x15,0x1A,0x6E,0xD1,0x47,0x45,0xBC,0x32, + 0xB4,0xEB,0x67,0x38,0xAB,0xE4,0x6E,0x33,0x3A,0xB5,0xED,0xA3,0xAD,0x67,0xE0,0x4E, + 0x41,0x95,0xEE,0x62,0x62,0x71,0x26,0x1D,0x31,0xEF,0x62,0x30,0xAF,0xD7,0x82,0xAC, + 0xC2,0xDC,0x05,0x04,0xF5,0x97,0x07,0xBF,0x11,0x59,0x23,0x07,0xC0,0x64,0x02,0xE8, + 0x97,0xE5,0x3E,0xAF,0x18,0xAC,0x59,0xA6,0x8B,0x4A,0x33,0x90,0x1C,0x6E,0x7C,0x9C, + 0x20,0x7E,0x4C,0x3C,0x3E,0x61,0x64,0xBB,0xC5,0x6B,0x7C,0x7E,0x3E,0x9F,0xC5,0x4C, + 0x9F,0xEA,0x73,0xF5,0xD7,0x89,0xC0,0x4C,0xF4,0xFB,0xF4,0x2D,0xEC,0x14,0x1B,0x51, + 0xD5,0xC1,0x12,0xC8,0x10,0xDF,0x0B,0x4A,0x8B,0x9C,0xBC,0x93,0x45,0x6A,0x3E,0x3E, + 0x7D,0xC1,0xA9,0xBA,0xCD,0xC1,0xB4,0x07,0xE4,0xE1,0x68,0x86,0x43,0xB2,0x6D,0x38, + 0xF3,0xFB,0x0C,0x5C,0x66,0x37,0x71,0xDE,0x56,0xEF,0x6E,0xA0,0x10,0x40,0x65,0xA7, + 0x98,0xF7,0xD0,0xBE,0x0E,0xC8,0x37,0x36,0xEC,0x10,0xCA,0x7C,0x9C,0xAB,0x84,0x1E, + 0x05,0x17,0x76,0x02,0x1C,0x4F,0x52,0xAA,0x5F,0xC1,0xC6,0xA0,0x56,0xB9,0xD8,0x04, + 0x84,0x44,0x4D,0xA7,0x59,0xD8,0xDE,0x60,0xE6,0x38,0x0E,0x05,0x8F,0x03,0xE1,0x3B, + 0x6D,0x81,0x04,0x33,0x6F,0x30,0x0B,0xCE,0x69,0x05,0x21,0x33,0xFB,0x26,0xBB,0x89, + 0x7D,0xB6,0xAE,0x87,0x7E,0x51,0x07,0xE0,0xAC,0xF7,0x96,0x0A,0x6B,0xF9,0xC4,0x5C, + 0x1D,0xE4,0x44,0x47,0xB8,0x5E,0xFA,0xE3,0x78,0x84,0x55,0x42,0x4B,0x48,0x5E,0xF7, + 0x7D,0x47,0x35,0x86,0x1D,0x2B,0x43,0x05,0x03,0xEC,0x8A,0xB8,0x1E,0x06,0x3C,0x76, + 0x0C,0x48,0x1A,0x43,0xA7,0xB7,0x8A,0xED,0x1E,0x13,0xC6,0x43,0xEE,0x10,0xEF,0xDB, + 0xEC,0xFB,0x3C,0x83,0xB2,0x95,0x44,0xEF,0xD8,0x54,0x51,0x4E,0x2D,0x11,0x44,0x1D, + 0xFB,0x36,0x59,0x1E,0x7A,0x34,0xC1,0xC3,0xCA,0x57,0x00,0x61,0xEA,0x67,0xA5,0x16, + 0x9B,0x55,0xD0,0x55,0xE1,0x7F,0xD9,0x36,0xD2,0x40,0x76,0xAE,0xDC,0x01,0xCE,0xB0, + 0x7A,0x83,0xD5,0xCB,0x20,0x98,0xEC,0x6B,0xC1,0x72,0x92,0x34,0xF3,0x82,0x57,0x37, + 0x62,0x8A,0x32,0x36,0x0C,0x90,0x43,0xAE,0xAE,0x5C,0x9B,0x78,0x8E,0x13,0x65,0x02, + 0xFD,0x68,0x71,0xC1,0xFE,0xB0,0x31,0xA0,0x24,0x82,0xB0,0xC3,0xB1,0x79,0x69,0xA7, + 0xF5,0xD2,0xEB,0xD0,0x82,0xC0,0x32,0xDC,0x9E,0xC7,0x26,0x3C,0x6D,0x8D,0x98,0xC1, + 0xBB,0x22,0xD4,0xD0,0x0F,0x33,0xEC,0x3E,0xB9,0xCC,0xE1,0xDC,0x6A,0x4C,0x77,0x36, + 0x14,0x1C,0xF9,0xBF,0x81,0x9F,0x28,0x5F,0x71,0x85,0x32,0x29,0x90,0x75,0x48,0xC4, + 0xB3,0x4A,0xCE,0xD8,0x44,0x8F,0x14,0x2F,0xFD,0x40,0x57,0xEF,0xAA,0x08,0x75,0xD9, + 0x46,0xD1,0xD6,0x6E,0x32,0x55,0x1F,0xC3,0x18,0xFE,0x84,0x1F,0xFC,0x84,0xD5,0xFF, + 0x71,0x5E,0x1B,0x48,0xC3,0x86,0x95,0x0E,0x28,0x08,0x27,0xD3,0x38,0x83,0x71,0x7B, + 0x4C,0x80,0x63,0x54,0x9A,0x56,0xB0,0xAC,0xCF,0x80,0xCA,0x31,0x09,0xEF,0xFE,0xF3, + 0xBE,0xAF,0x24,0x7E,0xA6,0xFE,0x53,0x3F,0xC2,0x8D,0x4A,0x33,0x68,0xD1,0x22,0xA6, + 0x66,0xAD,0x7B,0xEA,0xDE,0xB6,0x43,0xB0,0xA1,0x25,0x95,0x00,0xA3,0x3F,0x75,0x46, + 0x14,0x11,0x44,0xEC,0xD7,0x95,0xBC,0x92,0xF0,0x4F,0xA9,0x16,0x53,0x62,0x97,0x60, + 0x2A,0x0F,0x41,0xF1,0x71,0x24,0xBE,0xEE,0x94,0x7F,0x08,0xCD,0x60,0x93,0xB3,0x85, + 0x5B,0x07,0x00,0x3F,0xD8,0x0F,0x28,0x83,0x9A,0xD1,0x69,0x9F,0xD1,0xDA,0x2E,0xC3, + 0x90,0x01,0xA2,0xB9,0x6B,0x4E,0x2A,0x66,0x9D,0xDA,0xAE,0xA6,0xEA,0x2A,0xD3,0x68, + 0x2F,0x0C,0x0C,0x9C,0xD2,0x8C,0x4A,0xED,0xE2,0x9E,0x57,0x65,0x9D,0x09,0x87,0xA3, + 0xB4,0xC4,0x32,0x5D,0xC9,0xD4,0x32,0x2B,0xB1,0xE0,0x71,0x1E,0x64,0x4D,0xE6,0x90, + 0x71,0xE3,0x1E,0x40,0xED,0x7D,0xF3,0x84,0x0E,0xED,0xC8,0x78,0x76,0xAE,0xC0,0x71, + 0x27,0x72,0xBB,0x05,0xEA,0x02,0x64,0xFB,0xF3,0x48,0x6B,0xB5,0x42,0x93,0x3F,0xED, + 0x9F,0x13,0x53,0xD2,0xF7,0xFE,0x2A,0xEC,0x1D,0x47,0x25,0xDB,0x3C,0x91,0x86,0xC6, + 0x8E,0xF0,0x11,0xFD,0x23,0x74,0x36,0xF7,0xA4,0xF5,0x9E,0x7A,0x7E,0x53,0x50,0x44, + 0xD4,0x47,0xCA,0xD3,0xEB,0x38,0x6D,0xE6,0xD9,0x71,0x94,0x7F,0x4A,0xC6,0x69,0x4B, + 0x11,0xF4,0x52,0xEA,0x22,0xFE,0x8A,0xB0,0x36,0x67,0x8B,0x59,0xE8,0xE6,0x80,0x2A, + 0xEB,0x65,0x04,0x13,0xEE,0xEC,0xDC,0x9E,0x5F,0xB1,0xEC,0x05,0x6A,0x59,0xE6,0x9F, + 0x5E,0x59,0x6B,0x89,0xBF,0xF7,0x1A,0xCA,0x44,0xF9,0x5B,0x6A,0x71,0x85,0x03,0xE4, + 0x29,0x62,0xE0,0x70,0x6F,0x41,0xC4,0xCF,0xB2,0xB1,0xCC,0xE3,0x7E,0xA6,0x07,0xA8, + 0x87,0xE7,0x7F,0x84,0x93,0xDB,0x52,0x4B,0x6C,0xEC,0x7E,0xDD,0xD4,0x24,0x48,0x10, + 0x69,0x9F,0x04,0x60,0x74,0xE6,0x48,0x18,0xF3,0xE4,0x2C,0xB9,0x4F,0x2E,0x50,0x7A, + 0xDF,0xD4,0x54,0x69,0x2B,0x8B,0xA7,0xF3,0xCE,0xFF,0x1F,0xF3,0x3E,0x26,0x01,0x39, + 0x17,0x95,0x84,0x89,0xB0,0xF0,0x4C,0x4B,0x82,0x91,0x9F,0xC4,0x4B,0xAC,0x9D,0xA5, + 0x74,0xAF,0x17,0x25,0xC9,0xCA,0x32,0xD3,0xBC,0x89,0x8A,0x84,0x89,0xCC,0x0D,0xAE, + 0x7C,0xA2,0xDB,0x9C,0x6A,0x78,0x91,0xEE,0xEA,0x76,0x5D,0x4E,0x87,0x60,0xF5,0x69, + 0x15,0x67,0xD4,0x02,0xCF,0xAF,0x48,0x36,0x07,0xEA,0xBF,0x6F,0x66,0x2D,0x06,0x8F, + 0xC4,0x9A,0xFE,0xF9,0xF6,0x90,0x87,0x75,0xB8,0xF7,0xAD,0x0F,0x76,0x10,0x5A,0x3D, + 0x59,0xB0,0x2E,0xB3,0xC7,0x35,0x2C,0xCC,0x70,0x56,0x2B,0xCB,0xE3,0x37,0x96,0xC5, + 0x2F,0x46,0x1B,0x8A,0x22,0x46,0xC7,0x88,0xA7,0x26,0x32,0x98,0x61,0xDF,0x86,0x22, + 0x8A,0xF4,0x1C,0x2F,0x87,0xA1,0x09,0xAA,0xCC,0xA9,0xAE,0xD3,0xBD,0x00,0x45,0x1C, + 0x9A,0x54,0x87,0x86,0x52,0x87,0xEF,0xFF,0x1E,0x8F,0xA1,0x8F,0xC1,0x89,0x5C,0x35, + 0x1B,0xDA,0x2D,0x3A,0x2C,0x16,0xB2,0xC2,0xF1,0x56,0xE2,0x78,0xC1,0x6B,0x63,0x97, + 0xC5,0x56,0x8F,0xC9,0x32,0x7F,0x2C,0xAA,0xAF,0xA6,0xA8,0xAC,0x20,0x91,0x22,0x88, + 0xDE,0xE4,0x60,0x8B,0xF9,0x4B,0x42,0x25,0x1A,0xE3,0x7F,0x9C,0x2C,0x19,0x89,0x3A, + 0x7E,0x05,0xD4,0x36,0xCC,0x69,0x58,0xC2,0xC1,0x32,0x8B,0x2F,0x90,0x85,0xEB,0x7A, + 0x39,0x50,0xA5,0xA1,0x27,0x92,0xC5,0x66,0xB0,0x20,0x4F,0x58,0x7E,0x55,0x83,0x43, + 0x2B,0x45,0xE2,0x9C,0xE4,0xD8,0x12,0x90,0x2C,0x16,0x83,0x56,0x16,0x79,0x03,0xB3, + 0xAD,0x2D,0x61,0x18,0x1A,0x13,0x1F,0x37,0xE2,0xE1,0x9C,0x73,0x7B,0x80,0xD5,0xFD, + 0x2D,0x51,0x87,0xFC,0x7B,0xAA,0xD7,0x1F,0x2C,0x7A,0x8E,0xAF,0xF4,0x8D,0xBB,0xCD, + 0x95,0x11,0x7C,0x72,0x0B,0xEE,0x6F,0xE2,0xB9,0xAF,0xDE,0x37,0x83,0xDE,0x8C,0x8D, + 0x62,0x05,0x67,0xB7,0x96,0xC6,0x8D,0x56,0xB6,0x0D,0xD7,0x62,0xBA,0xD6,0x46,0x36, + 0xBD,0x8E,0xC8,0xE6,0xEA,0x2A,0x6C,0x10,0x14,0xFF,0x6B,0x5B,0xFA,0x82,0x3C,0x46, + 0xB1,0x30,0x43,0x46,0x51,0x8A,0x7D,0x9B,0x92,0x3E,0x83,0x79,0x5B,0x55,0x5D,0xB2, + 0x6C,0x5E,0xCE,0x90,0x62,0x8E,0x53,0x98,0xC9,0x0D,0x6D,0xE5,0x2D,0x57,0xCD,0xC5, + 0x81,0x57,0xBA,0xE1,0xE8,0xB8,0x8F,0x72,0xE5,0x4F,0x13,0xDC,0xEA,0x9D,0x71,0x15, + 0x10,0xB2,0x11,0x88,0xD5,0x09,0xD4,0x7F,0x5B,0x65,0x7F,0x2C,0x3B,0x38,0x4C,0x11, + 0x68,0x50,0x8D,0xFB,0x9E,0xB0,0x59,0xBF,0x94,0x80,0x89,0x4A,0xC5,0x1A,0x18,0x12, + 0x89,0x53,0xD1,0x4A,0x10,0x29,0xE8,0x8C,0x1C,0xEC,0xB6,0xEA,0x46,0xC7,0x17,0x8B, + 0x25,0x15,0x31,0xA8,0xA2,0x6B,0x43,0xB1,0x9D,0xE2,0xDB,0x0B,0x87,0x9B,0xB0,0x11, + 0x04,0x0E,0x71,0xD2,0x29,0x77,0x89,0x82,0x0A,0x66,0x41,0x7F,0x1D,0x0B,0x48,0xFF, + 0x72,0xBB,0x24,0xFD,0xC2,0x48,0xA1,0x9B,0xFE,0x7B,0x7F,0xCE,0x88,0xDB,0x86,0xD9, + 0x85,0x3B,0x1C,0xB0,0xDC,0xA8,0x33,0x07,0xBF,0x51,0x2E,0xE3,0x0E,0x9A,0x00,0x97, + 0x1E,0x06,0xC0,0x97,0x43,0x9D,0xD8,0xB6,0x45,0xC4,0x86,0x67,0x5F,0x00,0xF8,0x88, + 0x9A,0xA4,0x52,0x9E,0xC7,0xAA,0x8A,0x83,0x75,0xEC,0xC5,0x18,0xAE,0xCE,0xC3,0x2F, + 0x1A,0x2B,0xF9,0x18,0xFF,0xAE,0x1A,0xF5,0x53,0x0B,0xB5,0x33,0x51,0xA7,0xFD,0xE8, + 0xA8,0xE1,0xA2,0x64,0xB6,0x22,0x17,0x43,0x80,0xCC,0x0A,0xD8,0xAE,0x3B,0xBA,0x40, + 0xD7,0xD9,0x92,0x4A,0x89,0xDF,0x04,0x10,0xEE,0x9B,0x18,0x2B,0x6A,0x77,0x69,0x8A, + 0x68,0xF4,0xF9,0xB9,0xA2,0x21,0x15,0x6E,0xE6,0x1E,0x3B,0x03,0x62,0x30,0x9B,0x60, + 0x41,0x7E,0x25,0x9B,0x9E,0x8F,0xC5,0x52,0x10,0x08,0xF8,0xC2,0x69,0xA1,0x21,0x11, + 0x88,0x37,0x5E,0x79,0x35,0x66,0xFF,0x10,0x42,0x18,0x6E,0xED,0x97,0xB6,0x6B,0x1C, + 0x4E,0x36,0xE5,0x6D,0x7D,0xB4,0xE4,0xBF,0x20,0xB9,0xE0,0x05,0x3A,0x69,0xD5,0xB8, + 0xE3,0xD5,0xDC,0xE0,0xB9,0xAC,0x53,0x3E,0x07,0xA4,0x57,0xAD,0x77,0xFF,0x48,0x18, + 0x76,0x2A,0xAC,0x49,0x2A,0x8E,0x47,0x75,0x6D,0x9F,0x67,0x63,0x30,0x35,0x8C,0x39, + 0x05,0x39,0xD5,0x6F,0x64,0x3A,0x5B,0xAD,0xCA,0x0B,0xBB,0x82,0x52,0x99,0x45,0xB1, + 0x93,0x36,0x36,0x99,0xAF,0x13,0x20,0x44,0x36,0xD8,0x02,0x44,0x09,0x39,0x92,0x85, + 0xFF,0x4A,0x4A,0x97,0x87,0xA6,0x63,0xD7,0xC7,0xB5,0xB5,0x24,0xED,0x0F,0xB4,0x6F, + 0x0C,0x58,0x52,0x14,0xD9,0xA6,0x7B,0xD3,0x79,0xBC,0x38,0x58,0xA1,0xBD,0x3B,0x84, + 0x06,0xD8,0x1A,0x06,0xFD,0x6B,0xA8,0xEA,0x4B,0x69,0x28,0x04,0x37,0xAD,0x82,0x99, + 0xFB,0x0E,0x1B,0x85,0xBD,0xA8,0x5D,0x73,0xCD,0xDC,0x58,0x75,0x0A,0xBE,0x63,0x6C, + 0x48,0xE7,0x4C,0xE4,0x30,0x2B,0x04,0x60,0xB9,0x15,0xD8,0xDA,0x86,0x81,0x75,0x8F, + 0x96,0xD4,0x8D,0x1C,0x5D,0x70,0x85,0x7C,0x1C,0x67,0x7B,0xD5,0x08,0x67,0xA6,0xCE, + 0x4B,0x0A,0x66,0x70,0xB7,0xE5,0x63,0xD4,0x5B,0x8A,0x82,0xEA,0x10,0x67,0xCA,0xE2, + 0xF4,0xEF,0x17,0x85,0x2F,0x2A,0x5F,0x8A,0x97,0x82,0xF8,0x6A,0xD6,0x34,0x10,0xEA, + 0xEB,0xC9,0x5C,0x3C,0xE1,0x49,0xF8,0x46,0xEB,0xDE,0xBD,0xF6,0xA9,0x92,0xF1,0xAA, + 0xA6,0xA0,0x18,0xB0,0x3A,0xD3,0x0F,0x1F,0xF3,0x6F,0xFF,0x31,0x45,0x43,0x44,0xD3, + 0x50,0x9A,0xF7,0x88,0x09,0x96,0xC1,0xCE,0x76,0xCC,0xF2,0x2C,0x2C,0xBA,0xAD,0x82, + 0x77,0x8F,0x18,0x84,0xC0,0xD2,0x07,0x9C,0x36,0x90,0x83,0x4E,0x0B,0xA5,0x4F,0x43, + 0x3E,0x04,0xAB,0x78,0x4F,0xD6,0xFB,0x09,0x01,0x24,0x90,0xDA,0x6F,0x3C,0x3A,0x61, + 0x0D,0x7F,0x69,0x4A,0xEB,0x2B,0x30,0x02,0xB4,0xDB,0xE0,0x84,0xA9,0xEC,0xD7,0x35, + 0xBF,0x37,0x7D,0x85,0x58,0xCE,0xA9,0x4E,0xE4,0x80,0xC7,0xA8,0xD3,0x30,0x67,0x48, + 0xEB,0x29,0xAF,0x2F,0x74,0x6A,0xB4,0xA7,0x3F,0x0F,0x3F,0x92,0xAF,0xF3,0xCA,0xAC, + 0xAF,0x4B,0xD9,0x94,0xC0,0x43,0xCA,0x81,0x0D,0x2F,0x48,0xA1,0xB0,0x27,0xD5,0xD2, + 0xEF,0x4B,0x05,0x85,0xA3,0xDE,0x4D,0x93,0x30,0x3C,0xF0,0xBB,0x4A,0x8F,0x30,0x27, + 0x4C,0xEB,0xE3,0x3E,0x64,0xED,0x9A,0x2F,0x3B,0xF1,0x82,0xF0,0xBA,0xF4,0xCF,0x7F, + 0x40,0xCB,0xB0,0xE1,0x7F,0xBC,0xAA,0x57,0xD3,0xC9,0x74,0xF2,0xFA,0x43,0x0D,0x22, + 0xD0,0xF4,0x77,0x4E,0x93,0xD7,0x85,0x70,0x1F,0x99,0xBF,0xB6,0xDE,0x35,0xF1,0x30, + 0xA7,0x5E,0x71,0xF0,0x6B,0x01,0x2D,0x7B,0x64,0xF0,0x33,0x53,0x0A,0x39,0x88,0xF3, + 0x6B,0x3A,0xA6,0x6B,0x35,0xD2,0x2F,0x43,0xCD,0x02,0xFD,0xB5,0xE9,0xBC,0x5B,0xAA, + 0xD8,0xA4,0x19,0x7E,0x0E,0x5D,0x94,0x81,0x9E,0x6F,0x77,0xAD,0xD6,0x0E,0x74,0x93, + 0x96,0xE7,0xC4,0x18,0x5F,0xAD,0xF5,0x19, +}; + +u32 card_hash[0x412]; +int cardheader_devicetype = 0; +u32 global3_x00, global3_x04; // RTC value +u32 global3_rand1; +u32 global3_rand3; + +static u32 lookup(u32 *magic, u32 v) +{ + u32 a = (v >> 24) & 0xFF; + u32 b = (v >> 16) & 0xFF; + u32 c = (v >> 8) & 0xFF; + u32 d = (v >> 0) & 0xFF; + + a = magic[a+18+0]; + b = magic[b+18+256]; + c = magic[c+18+512]; + d = magic[d+18+768]; + + return d + (c ^ (b + a)); +} + +static void encrypt(u32 *magic, u32 *arg1, u32 *arg2) +{ + u32 a,b,c; + a = *arg1; + b = *arg2; + for (int i=0; i<16; i++) + { + c = magic[i] ^ a; + a = b ^ lookup(magic, c); + b = c; + } + *arg2 = a ^ magic[16]; + *arg1 = b ^ magic[17]; +} + +static void decrypt(u32 *magic, u32 *arg1, u32 *arg2) +{ + u32 a,b,c; + a = *arg1; + b = *arg2; + for (int i=17; i>1; i--) + { + c = magic[i] ^ a; + a = b ^ lookup(magic, c); + b = c; + } + *arg1 = b ^ magic[0]; + *arg2 = a ^ magic[1]; +} + +static void encrypt(u32 *magic, u64 &cmd) +{ + encrypt(magic, (u32 *)&cmd + 1, (u32 *)&cmd + 0); +} + +static void decrypt(u32 *magic, u64 &cmd) +{ + decrypt(magic, (u32 *)&cmd + 1, (u32 *)&cmd + 0); +} + +static void update_hashtable(u32* magic, u8 arg1[8]) +{ + for (int j=0;j<18;j++) + { + u32 r3=0; + for (int i=0;i<4;i++) + { + r3 <<= 8; + r3 |= arg1[(j*4 + i) & 7]; + } + magic[j] ^= r3; + } + + u32 tmp1 = 0; + u32 tmp2 = 0; + for (int i=0; i<18; i+=2) + { + encrypt(magic,&tmp1,&tmp2); + magic[i+0] = tmp1; + magic[i+1] = tmp2; + } + for (int i=0; i<0x400; i+=2) + { + encrypt(magic,&tmp1,&tmp2); + magic[i+18+0] = tmp1; + magic[i+18+1] = tmp2; + } +} + +u32 arg2[3]; + +static void init2(u32 *magic, u32 a[3]) +{ + encrypt(magic, a+2, a+1); + encrypt(magic, a+1, a+0); + update_hashtable(magic, (u8*)a); +} + +static void init1(u32 cardheader_gamecode) +{ + memcpy(card_hash, &encr_data, 4*(1024 + 18)); + arg2[0] = *(u32 *)&cardheader_gamecode; + arg2[1] = (*(u32 *)&cardheader_gamecode) >> 1; + arg2[2] = (*(u32 *)&cardheader_gamecode) << 1; + init2(card_hash, arg2); + init2(card_hash, arg2); +} + +static void init0(u32 cardheader_gamecode) +{ + init1(cardheader_gamecode); + encrypt(card_hash, (u32*)&global3_x04, (u32*)&global3_x00); + global3_rand1 = global3_x00 ^ global3_x04; // more RTC + global3_rand3 = global3_x04 ^ 0x0380FEB2; + encrypt(card_hash, (u32*)&global3_rand3, (u32*)&global3_rand1); +} + +// ARM9 decryption check values +#define MAGIC30 0x72636E65 +#define MAGIC34 0x6A624F79 + +/* + * decrypt_arm9 + */ +static void decrypt_arm9(u32 cardheader_gamecode, unsigned char *data) +{ + u32 *p = (u32*)data; + + init1(cardheader_gamecode); + decrypt(card_hash, p+1, p); + arg2[1] <<= 1; + arg2[2] >>= 1; + init2(card_hash, arg2); + decrypt(card_hash, p+1, p); + + if (p[0] != MAGIC30 || p[1] != MAGIC34) + { + fprintf(stderr, "Decryption failed!\n"); + exit(1); + } + + *p++ = 0xE7FFDEFF; + *p++ = 0xE7FFDEFF; + u32 size = 0x800 - 8; + while (size > 0) + { + decrypt(card_hash, p+1, p); + p += 2; + size -= 8; + } +} + + +bool DecryptSecureArea(u8 *romdata, long romlen) +{ + //this looks like it will only work on little endian hosts + Header* header = (Header*)romdata; + + int romType = DetectRomType(*header,(char*)romdata); + + /*bool do_decrypt = (endecrypt_option == 'd'); + bool do_encrypt = (endecrypt_option == 'e') || (endecrypt_option == 'E'); + unsigned int rounds_offsets = (endecrypt_option == 'E') ? 0x2000 : 0x1600; + unsigned int sbox_offsets = (endecrypt_option == 'E') ? 0x2400 : 0x2800;*/ +#if 0 + unsigned int rounds_offsets = 0x1600; + unsigned int sbox_offsets = 0x2800; +#endif + + if(romType == ROMTYPE_INVALID) + return false; + + // check if ROM is already encrypted + if (romType == ROMTYPE_NDSDUMPED) + { + printf("Already decrypted.\n"); + } + else if (romType >= ROMTYPE_ENCRSECURE) // includes ROMTYPE_MASKROM + { + unsigned char data[0x4000]; + memcpy(data,romdata+0x4000,0x4000); + + decrypt_arm9(*(u32 *)header->gamecode, data); + + // clear data after header + //fseek(fNDS, 0x200, SEEK_SET); + //for (unsigned int i=0x200; i<0x4000; i++) fputc(0, fNDS); + memset(romdata+0x200,0,(0x4000-0x200)); + + // write secure 0x800 + //fseek(fNDS, 0x4000, SEEK_SET); + //fwrite(data, 1, 0x800, fNDS); + memcpy(romdata+0x4000,data,0x800); + + // write header + //(already poked directly) + //fseek(fNDS, 0, SEEK_SET); + //fwrite(&header, 512, 1, fNDS); + + printf("Decrypted.\n"); + } + else + { + printf("File doesn't appear to have a secure area.\n"); + } + + return true; +} diff --git a/desmume/src/utils/decrypt/decrypt.h b/src/utils/decrypt/decrypt.h similarity index 97% rename from desmume/src/utils/decrypt/decrypt.h rename to src/utils/decrypt/decrypt.h index d279d560d..ad12d0032 100644 --- a/desmume/src/utils/decrypt/decrypt.h +++ b/src/utils/decrypt/decrypt.h @@ -1,26 +1,26 @@ -/* decrypt.h - this file is part of DeSmuME - * - * Copyright (C) 2006 Rafael Vuijk - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _DECRYPT_H_ -#define _DECRYPT_H_ - -bool DecryptSecureArea(u8 *romdata, long romlen); - -#endif +/* decrypt.h - this file is part of DeSmuME + * + * Copyright (C) 2006 Rafael Vuijk + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _DECRYPT_H_ +#define _DECRYPT_H_ + +bool DecryptSecureArea(u8 *romdata, long romlen); + +#endif diff --git a/desmume/src/utils/decrypt/header.cpp b/src/utils/decrypt/header.cpp similarity index 97% rename from desmume/src/utils/decrypt/header.cpp rename to src/utils/decrypt/header.cpp index 484e7e0e8..b6932c6c0 100644 --- a/desmume/src/utils/decrypt/header.cpp +++ b/src/utils/decrypt/header.cpp @@ -1,657 +1,657 @@ -//taken from ndstool -//http://devkitpro.cvs.sourceforge.net/viewvc/devkitpro/tools/nds/ndstool/source/header.cpp?revision=1.23 - -/* header.cpp - this file is part of DeSmuME - * - * Copyright (C) 2005-2006 Rafael Vuijk - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "header.h" - -//#include "ndstool.h" -//#include "banner.h" -//#include "sha1.h" -//#include "crc.h" -//#include "bigint.h" -//#include "arm7_sha1_homebrew.h" -//#include "arm7_sha1_nintendo.h" -//#include "encryption.h" -// -///* -// * Data -// */ -//unsigned char publicKeyNintendo[] = -//{ -// 0x9E, 0xC1, 0xCC, 0xC0, 0x4A, 0x6B, 0xD0, 0xA0, 0x6D, 0x62, 0xED, 0x5F, 0x15, 0x67, 0x87, 0x12, -// 0xE6, 0xF4, 0x77, 0x1F, 0xD8, 0x5C, 0x81, 0xCE, 0x0C, 0xD0, 0x22, 0x31, 0xF5, 0x89, 0x08, 0xF5, -// 0xBE, 0x04, 0xCB, 0xC1, 0x4F, 0x63, 0xD9, 0x5A, 0x98, 0xFF, 0xEB, 0x36, 0x0F, 0x9C, 0x5D, 0xAD, -// 0x15, 0xB9, 0x99, 0xFB, 0xC6, 0x86, 0x2C, 0x0A, 0x0C, 0xFC, 0xE6, 0x86, 0x03, 0x60, 0xD4, 0x87, -// 0x28, 0xD5, 0x66, 0x42, 0x9C, 0xF7, 0x04, 0x14, 0x4E, 0x6F, 0x73, 0x20, 0xC3, 0x3E, 0x3F, 0xF5, -// 0x82, 0x2E, 0x78, 0x18, 0xD6, 0xCD, 0xD5, 0xC2, 0xDC, 0xAA, 0x1D, 0x34, 0x91, 0xEC, 0x99, 0xC9, -// 0xF7, 0xBF, 0xBF, 0xA0, 0x0E, 0x1E, 0xF0, 0x25, 0xF8, 0x66, 0x17, 0x54, 0x34, 0x28, 0x2D, 0x28, -// 0xA3, 0xAE, 0xF0, 0xA9, 0xFA, 0x3A, 0x70, 0x56, 0xD2, 0x34, 0xA9, 0xC5, 0x9E, 0x5D, 0xF5, 0xE1, -//}; -// -///* -// * CalcHeaderCRC -// */ -//unsigned short CalcHeaderCRC(Header &header) -//{ -// return CalcCrc16((unsigned char *)&header, 0x15E); -//} -// -///* -// * CalcLogoCRC -// */ -//unsigned short CalcLogoCRC(Header &header) -//{ -// return CalcCrc16((unsigned char *)&header + 0xC0, 156); -//} -// -/* - * DetectRomType - */ -int DetectRomType(const Header& header, char* romdata) -{ - unsigned int * data = (unsigned int*)(romdata + 0x4000); - - //this is attempting to check for an utterly invalid nds header - if(header.unitcode != 0 && header.unitcode != 2) return ROMTYPE_INVALID; - - if (header.arm9_rom_offset < 0x4000) return ROMTYPE_HOMEBREW; - if (data[0] == 0x00000000 && data[1] == 0x00000000) return ROMTYPE_MULTIBOOT; - if (data[0] == 0xE7FFDEFF && data[1] == 0xE7FFDEFF) return ROMTYPE_NDSDUMPED; - romdata += 0x200; - for (int i=0x200; i<0x4000; i++) - if (*romdata) return ROMTYPE_MASKROM; // found something odd ;) - return ROMTYPE_ENCRSECURE; -} - -///* -// * CalcSecureAreaCRC -// */ -//unsigned short CalcSecureAreaCRC(bool encrypt) -//{ -// fseek(fNDS, 0x4000, SEEK_SET); -// unsigned char data[0x4000]; -// fread(data, 1, 0x4000, fNDS); -// if (encrypt) encrypt_arm9(*(u32 *)header.gamecode, data); -// return CalcCrc16(data, 0x4000); -//} -// -///* -// * CalcSecurityDataCRC -// */ -//unsigned short CalcSecurityDataCRC() -//{ -// fseek(fNDS, 0x1000, SEEK_SET); -// unsigned char data[0x2000]; -// fread(data, 1, 0x2000, fNDS); -// return CalcCrc16(data, 0x2000); -//} -// -///* -// * CalcSegment3CRC -// */ -//unsigned short CalcSegment3CRC() -//{ -// fseek(fNDS, 0x3000, SEEK_SET); -// unsigned char data[0x1000]; -// fread(data, 1, 0x1000, fNDS); -// for (int i=0; i<0x1000; i+=2) // swap bytes -// { -// unsigned char t = data[i+1]; data[i+1] = data[i]; data[i] = t; -// } -// return CalcCcitt16(data, 0x1000); // why would they use CRC16-CCITT ? -//} -// -///* -// * FixHeaderCRC -// */ -//void FixHeaderCRC(char *ndsfilename) -//{ -// fNDS = fopen(ndsfilename, "r+b"); -// if (!fNDS) { fprintf(stderr, "Cannot open file '%s'.\n", ndsfilename); exit(1); } -// fread(&header, 512, 1, fNDS); -// header.header_crc = CalcHeaderCRC(header); -// fseek(fNDS, 0, SEEK_SET); -// fwrite(&header, 512, 1, fNDS); -// fclose(fNDS); -//} -// -///* -// * ShowHeaderInfo -// */ -//void ShowHeaderInfo(Header &header, int romType, unsigned int length = 0x200) -//{ -// printf("0x00\t%-25s\t", "Game title"); -// -// for (unsigned int i=0; i= 2) -// { -// printf("{ DS Download Play(TM) / Wireless MultiBoot header information:\n"); -// ShowHeaderInfo(*(Header *)(buf + 0x20), romType, 0x160); -// printf("}\n"); -// } -// } -// else -// { -// fseek(fNDS, 0, SEEK_SET); -// fread(buf, 1, sizeof(buf), fNDS); -// sha1_hash(buf, 0x160, &m_sha1); -// } -// sha1_end(header_sha1, &m_sha1); -//} -// -///* -// * Arm9Sha1Multiboot -// */ -//void Arm9Sha1Multiboot(FILE *fNDS, unsigned char *arm9_sha1) -//{ -// sha1_ctx m_sha1; -// sha1_begin(&m_sha1); -// fseek(fNDS, header.arm9_rom_offset, SEEK_SET); -// unsigned int len = header.arm9_size; -// unsigned char *buf = new unsigned char [len]; -// fread(buf, 1, len, fNDS); -// //printf("%u\n", len); -// sha1_hash(buf, len, &m_sha1); -// delete [] buf; -// sha1_end(arm9_sha1, &m_sha1); -//} -// -///* -// * Arm9Sha1ClearedOutArea -// */ -//void Arm9Sha1ClearedOutArea(FILE *fNDS, unsigned char *arm9_sha1) -//{ -// sha1_ctx m_sha1; -// sha1_begin(&m_sha1); -// fseek(fNDS, header.arm9_rom_offset, SEEK_SET); -// unsigned int len = header.arm9_size; -// unsigned char *buf = new unsigned char [len]; -// -// int len1 = (0x5000 - header.arm9_rom_offset); // e.g. 0x5000 - 0x4000 = 0x1000 -// int len3 = header.arm9_size - (0x7000 - header.arm9_rom_offset); // e.g. 0x10000 - (0x7000 - 0x4000) = 0xD000 -// int len2 = header.arm9_size - len1 - len3; // e.g. 0x10000 - 0x1000 - 0xD000 = 0x2000 -// if (len1 > 0) fread(buf, 1, len1, fNDS); -// if (len2 > 0) { memset(buf + len1, 0, len2); fseek(fNDS, len2, SEEK_CUR); } // gets cleared for security? -// if (len3 > 0) fread(buf + len1 + len2, 1, len3, fNDS); -//// printf("%X %X %X\n", len1, len2, len3); -// -//// memset(buf, 0, 0x800); // clear "secure area" too -// -// sha1_hash(buf, len, &m_sha1); -// delete [] buf; -// sha1_end(arm9_sha1, &m_sha1); -//} -// -///* -// * Arm7Sha1 -// */ -//void Arm7Sha1(FILE *fNDS, unsigned char *arm7_sha1) -//{ -// sha1_ctx m_sha1; -// sha1_begin(&m_sha1); -// fseek(fNDS, header.arm7_rom_offset, SEEK_SET); -// unsigned int len = header.arm7_size; -// unsigned char *buf = new unsigned char [len]; -// fread(buf, 1, len, fNDS); -// //printf("%u\n", len); -// sha1_hash(buf, len, &m_sha1); -// delete [] buf; -// sha1_end(arm7_sha1, &m_sha1); -//} -// -///* -// * CompareSha1WithList -// */ -//int CompareSha1WithList(unsigned char *arm7_sha1, const unsigned char *text, unsigned int textSize) -//{ -// while (1) -// { -// //printf("\n"); -// for (int i=0; i '9') ? ((*text - 'A') & 7) + 10 : *text - '0'); -// text++; -// } -// //printf("%02X", b); -// if (b != arm7_sha1[i]) break; else if (i == 19) return 0; -// } -// while (*text && (*text >= ' ')) text++; // line end -// while (*text && (*text < ' ')) text++; // new line -// } -//} -// -///* -// * HashAndCompareWithList -// * -1=error, 0=match, 1=no match -// */ -//int HashAndCompareWithList(char *filename, unsigned char sha1[]) -//{ -// FILE *f = fopen(filename, "rb"); -// if (!f) return -1; -// sha1_ctx m_sha1; -// sha1_begin(&m_sha1); -// unsigned char buf[1024]; -// unsigned int r; -// do -// { -// r = fread(buf, 1, 1024, f); -// sha1_hash(buf, r, &m_sha1); -// } while (r > 0); -// fclose(f); -// sha1_end(sha1, &m_sha1); -// if (CompareSha1WithList(sha1, arm7_sha1_homebrew, arm7_sha1_homebrew_size)) return 1; // not yet in list -// return 0; -//} -// -///* -// * strsepc -// */ -//char *strsepc(char **s, char d) -//{ -// char *r = *s; -// for (char *p = *s; ; p++) -// { -// if (*p == 0) { *s = p; break; } -// if (*p == d) { *s = p+1; *p = 0; break; } -// } -// return r; -//} -// -///* -// * RomListInfo -// */ -//void RomListInfo(unsigned int crc32_match) -//{ -// if (!romlistfilename) return; -// FILE *fRomList = fopen(romlistfilename, "rt"); -// if (!fRomList) { fprintf(stderr, "Cannot open file '%s'.\n", romlistfilename); exit(1); } -// char s[1024]; -// while (fgets(s, 1024, fRomList)) // empty, title, title, title, title, filename, CRC32 -// { -// char *p = s; -// if (strlen(strsepc(&p, '\xAC')) == 0) -// { -// char *title = strsepc(&p, '\xAC'); -// unsigned int index = strtoul(title, 0, 10); -// title += 7; -// char *b1 = strchr(title, '('); -// char *b2 = b1 ? strchr(b1+1, ')') : 0; -// char *b3 = b2 ? strchr(b2+1, '(') : 0; -// char *b4 = b3 ? strchr(b3+1, ')') : 0; -// char *group = 0; -// if (b1 + 2 == b2) if (b3 && b4) { *b3 = 0; *b4 = 0; group = b3+1; } // remove release group name -// strsepc(&p, '\xAC'); strsepc(&p, '\xAC'); -// strsepc(&p, '\xAC'); strsepc(&p, '\xAC'); -// unsigned long crc32 = strtoul(strsepc(&p, '\xAC'), 0, 16); -// if (crc32 == crc32_match) -// { -// printf("Release index: \t%u\n", index); -// printf("Release title: \t%s\n", title); -// printf("Release group: \t%s\n", group ? group : ""); -// } -// //for (int i=0; i<10; i++) printf("%d %s\n", i, strsepc(&p, '\xAC')); -// } -// } -//} -// -///* -// * ShowVerboseInfo -// */ -//void ShowVerboseInfo(FILE *fNDS, Header &header, int romType) -//{ -// // calculate SHA1 of ARM7 binary -// unsigned char arm7_sha1[SHA1_DIGEST_SIZE]; -// Arm7Sha1(fNDS, arm7_sha1); -// -// // find signature data -// unsigned_int signature_id = 0; -// fseek(fNDS, header.application_end_offset, SEEK_SET); -// fread(&signature_id, sizeof(signature_id), 1, fNDS); -// if (signature_id != 0x00016361) -// { -// fseek(fNDS, header.application_end_offset - 136, SEEK_SET); // try again -// fread(&signature_id, sizeof(signature_id), 1, fNDS); -// } -// if (signature_id == 0x00016361) -// { -// printf("\n"); -// -// unsigned char signature[128]; -// fread(signature, 1, sizeof(signature), fNDS); -// -// unsigned char sha_parts[3*SHA1_DIGEST_SIZE + 4]; -// fread(sha_parts + 3*SHA1_DIGEST_SIZE, 4, 1, fNDS); // some number -// -// //printf("%08X\n", *(unsigned int *)(sha_parts + 3*SHA1_DIGEST_SIZE)); -// -// unsigned char header_sha1[SHA1_DIGEST_SIZE]; -// HeaderSha1(fNDS, header_sha1, romType); -// memcpy(sha_parts + 0*SHA1_DIGEST_SIZE, header_sha1, SHA1_DIGEST_SIZE); -// -// unsigned char arm9_sha1[SHA1_DIGEST_SIZE]; -// if (romType == ROMTYPE_MULTIBOOT) -// { -// Arm9Sha1Multiboot(fNDS, arm9_sha1); -// } -// else -// { -// Arm9Sha1ClearedOutArea(fNDS, arm9_sha1); -// } -// memcpy(sha_parts + 1*SHA1_DIGEST_SIZE, arm9_sha1, SHA1_DIGEST_SIZE); -// -// memcpy(sha_parts + 2*SHA1_DIGEST_SIZE, arm7_sha1, SHA1_DIGEST_SIZE); -// -// unsigned char sha_final[SHA1_DIGEST_SIZE]; -// { -// sha1_ctx m_sha1; -// sha1_begin(&m_sha1); -// unsigned int len = sizeof(sha_parts); -// unsigned char *buf = sha_parts; -// sha1_hash(buf, len, &m_sha1); -// sha1_end(sha_final, &m_sha1); -// } -// -// // calculate SHA1 from signature -// unsigned char sha1_from_sig[SHA1_DIGEST_SIZE]; -// { -// BigInt _signature; -// _signature.Set(signature, sizeof(signature)); -// //printf("signature: "); _signature.print(); -// -// BigInt _publicKey; -// _publicKey.Set(publicKeyNintendo, sizeof(publicKeyNintendo)); -// //printf("public key: "); _publicKey.print(); -// -// BigInt big_sha1; -// big_sha1.PowMod(_signature, _publicKey); -// //printf("big_sha1: "); big_sha1.print(); -// big_sha1.Get(sha1_from_sig, sizeof(sha1_from_sig)); -// } -// -// bool ok = (memcmp(sha_final, sha1_from_sig, SHA1_DIGEST_SIZE) == 0); -// printf("DS Download Play(TM) / Wireless MultiBoot signature: %s\n", ok ? "OK" : "INVALID"); -// if (!ok) -// { -// printf("header hash: \t"); for (int i=0; i 0) -// { -// crc32 = CalcCrc32(buf, r, crc32); -// } -// crc32 = ~crc32; -// delete [] buf; -// -// printf("\nFile CRC32: \t%08X\n", (unsigned int)crc32); -// RomListInfo(crc32); -// } -// -// // ROM dumper 1.0 bad data -// { -// unsigned char buf[0x200]; -// fseek(fNDS, 0x7E00, SEEK_SET); -// fread(buf, 1, 0x200, fNDS); -// unsigned long crc32 = ~CalcCrc32(buf, 0x200); -// printf("\nSMT dumper v1.0 corruption check: \t%s\n", (crc32 == 0x7E8B456F) ? "CORRUPTED" : "OK"); -// } -// -// // Verify ARM7 SHA1 hash against known default binaries -// int bKnownArm7 = 0; -// { -// printf("\nARM7 binary hash : \t"); for (int i=0; i= 0x04000000)) -// { -// printf("\nWARNING! ARM7 RAM address does not point to shared memory!\n"); -// } -// -// // check ARM7 entry address -// if ((header.arm7_entry_address < header.arm7_ram_address) || -// (header.arm7_entry_address > header.arm7_ram_address + header.arm7_size)) -// { -// printf("\nWARNING! ARM7 entry address points outside of ARM7 binary!\n"); -// } -//} -// -///* -// * ShowInfo -// */ -//void ShowInfo(char *ndsfilename) -//{ -// fNDS = fopen(ndsfilename, "rb"); -// if (!fNDS) { fprintf(stderr, "Cannot open file '%s'.\n", ndsfilename); exit(1); } -// fread(&header, 512, 1, fNDS); -// -// int romType = DetectRomType(); -// -// printf("Header information:\n"); -// ShowHeaderInfo(header, romType); -// -// // banner info -// if (header.banner_offset) -// { -// Banner banner; -// fseek(fNDS, header.banner_offset, SEEK_SET); -// if (fread(&banner, 1, sizeof(banner), fNDS)) -// { -// unsigned short banner_crc = CalcBannerCRC(banner); -// printf("\n"); -// printf("Banner CRC: \t0x%04X (%s)\n", (int)banner.crc, (banner_crc == banner.crc) ? "OK" : "INVALID"); -// -// for (int language=1; language<=1; language++) -// { -// int line = 1; -// bool nextline = true; -// for (int i=0; i<128; i++) -// { -// unsigned short c = banner.title[language][i]; -// if (c >= 128) c = '_'; -// if (c == 0x00) { printf("\n"); break; } -// if (c == 0x0A) -// { -// nextline = true; -// } -// else -// { -// if (nextline) -// { -// if (line != 1) printf("\n"); -// printf("%s banner text, line %d:", bannerLanguages[language], line); -// for (unsigned int i=0; i<11 - strlen(bannerLanguages[language]); i++) putchar(' '); -// printf("\t"); -// nextline = false; -// line++; -// } -// putchar(c); -// } -// } -// } -// } -// } -// -// // ARM9 footer -// fseek(fNDS, header.arm9_rom_offset + header.arm9_size, SEEK_SET); -// unsigned_int nitrocode; -// if (fread(&nitrocode, sizeof(nitrocode), 1, fNDS) && (nitrocode == 0xDEC00621)) -// { -// printf("\n"); -// printf("ARM9 footer found.\n"); -// unsigned_int x; -// fread(&x, sizeof(x), 1, fNDS); -// fread(&x, sizeof(x), 1, fNDS); -// } -// -// // show security CRCs -// if (romType >= ROMTYPE_NDSDUMPED) -// { -// printf("\n"); -// unsigned short securitydata_crc = CalcSecurityDataCRC(); -// printf("Security data CRC (0x1000-0x2FFF) 0x%04X\n", (int)securitydata_crc); -// unsigned short segment3_crc = CalcSegment3CRC(); -// printf("Segment3 CRC (0x3000-0x3FFF) 0x%04X (%s)\n", (int)segment3_crc, (segment3_crc == 0x0254) ? "OK" : "INVALID"); -// } -// -// // more information -// if (verbose >= 1) -// { -// ShowVerboseInfo(fNDS, header, romType); -// } -// -// fclose(fNDS); -//} +//taken from ndstool +//http://devkitpro.cvs.sourceforge.net/viewvc/devkitpro/tools/nds/ndstool/source/header.cpp?revision=1.23 + +/* header.cpp - this file is part of DeSmuME + * + * Copyright (C) 2005-2006 Rafael Vuijk + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "header.h" + +//#include "ndstool.h" +//#include "banner.h" +//#include "sha1.h" +//#include "crc.h" +//#include "bigint.h" +//#include "arm7_sha1_homebrew.h" +//#include "arm7_sha1_nintendo.h" +//#include "encryption.h" +// +///* +// * Data +// */ +//unsigned char publicKeyNintendo[] = +//{ +// 0x9E, 0xC1, 0xCC, 0xC0, 0x4A, 0x6B, 0xD0, 0xA0, 0x6D, 0x62, 0xED, 0x5F, 0x15, 0x67, 0x87, 0x12, +// 0xE6, 0xF4, 0x77, 0x1F, 0xD8, 0x5C, 0x81, 0xCE, 0x0C, 0xD0, 0x22, 0x31, 0xF5, 0x89, 0x08, 0xF5, +// 0xBE, 0x04, 0xCB, 0xC1, 0x4F, 0x63, 0xD9, 0x5A, 0x98, 0xFF, 0xEB, 0x36, 0x0F, 0x9C, 0x5D, 0xAD, +// 0x15, 0xB9, 0x99, 0xFB, 0xC6, 0x86, 0x2C, 0x0A, 0x0C, 0xFC, 0xE6, 0x86, 0x03, 0x60, 0xD4, 0x87, +// 0x28, 0xD5, 0x66, 0x42, 0x9C, 0xF7, 0x04, 0x14, 0x4E, 0x6F, 0x73, 0x20, 0xC3, 0x3E, 0x3F, 0xF5, +// 0x82, 0x2E, 0x78, 0x18, 0xD6, 0xCD, 0xD5, 0xC2, 0xDC, 0xAA, 0x1D, 0x34, 0x91, 0xEC, 0x99, 0xC9, +// 0xF7, 0xBF, 0xBF, 0xA0, 0x0E, 0x1E, 0xF0, 0x25, 0xF8, 0x66, 0x17, 0x54, 0x34, 0x28, 0x2D, 0x28, +// 0xA3, 0xAE, 0xF0, 0xA9, 0xFA, 0x3A, 0x70, 0x56, 0xD2, 0x34, 0xA9, 0xC5, 0x9E, 0x5D, 0xF5, 0xE1, +//}; +// +///* +// * CalcHeaderCRC +// */ +//unsigned short CalcHeaderCRC(Header &header) +//{ +// return CalcCrc16((unsigned char *)&header, 0x15E); +//} +// +///* +// * CalcLogoCRC +// */ +//unsigned short CalcLogoCRC(Header &header) +//{ +// return CalcCrc16((unsigned char *)&header + 0xC0, 156); +//} +// +/* + * DetectRomType + */ +int DetectRomType(const Header& header, char* romdata) +{ + unsigned int * data = (unsigned int*)(romdata + 0x4000); + + //this is attempting to check for an utterly invalid nds header + if(header.unitcode != 0 && header.unitcode != 2) return ROMTYPE_INVALID; + + if (header.arm9_rom_offset < 0x4000) return ROMTYPE_HOMEBREW; + if (data[0] == 0x00000000 && data[1] == 0x00000000) return ROMTYPE_MULTIBOOT; + if (data[0] == 0xE7FFDEFF && data[1] == 0xE7FFDEFF) return ROMTYPE_NDSDUMPED; + romdata += 0x200; + for (int i=0x200; i<0x4000; i++) + if (*romdata) return ROMTYPE_MASKROM; // found something odd ;) + return ROMTYPE_ENCRSECURE; +} + +///* +// * CalcSecureAreaCRC +// */ +//unsigned short CalcSecureAreaCRC(bool encrypt) +//{ +// fseek(fNDS, 0x4000, SEEK_SET); +// unsigned char data[0x4000]; +// fread(data, 1, 0x4000, fNDS); +// if (encrypt) encrypt_arm9(*(u32 *)header.gamecode, data); +// return CalcCrc16(data, 0x4000); +//} +// +///* +// * CalcSecurityDataCRC +// */ +//unsigned short CalcSecurityDataCRC() +//{ +// fseek(fNDS, 0x1000, SEEK_SET); +// unsigned char data[0x2000]; +// fread(data, 1, 0x2000, fNDS); +// return CalcCrc16(data, 0x2000); +//} +// +///* +// * CalcSegment3CRC +// */ +//unsigned short CalcSegment3CRC() +//{ +// fseek(fNDS, 0x3000, SEEK_SET); +// unsigned char data[0x1000]; +// fread(data, 1, 0x1000, fNDS); +// for (int i=0; i<0x1000; i+=2) // swap bytes +// { +// unsigned char t = data[i+1]; data[i+1] = data[i]; data[i] = t; +// } +// return CalcCcitt16(data, 0x1000); // why would they use CRC16-CCITT ? +//} +// +///* +// * FixHeaderCRC +// */ +//void FixHeaderCRC(char *ndsfilename) +//{ +// fNDS = fopen(ndsfilename, "r+b"); +// if (!fNDS) { fprintf(stderr, "Cannot open file '%s'.\n", ndsfilename); exit(1); } +// fread(&header, 512, 1, fNDS); +// header.header_crc = CalcHeaderCRC(header); +// fseek(fNDS, 0, SEEK_SET); +// fwrite(&header, 512, 1, fNDS); +// fclose(fNDS); +//} +// +///* +// * ShowHeaderInfo +// */ +//void ShowHeaderInfo(Header &header, int romType, unsigned int length = 0x200) +//{ +// printf("0x00\t%-25s\t", "Game title"); +// +// for (unsigned int i=0; i= 2) +// { +// printf("{ DS Download Play(TM) / Wireless MultiBoot header information:\n"); +// ShowHeaderInfo(*(Header *)(buf + 0x20), romType, 0x160); +// printf("}\n"); +// } +// } +// else +// { +// fseek(fNDS, 0, SEEK_SET); +// fread(buf, 1, sizeof(buf), fNDS); +// sha1_hash(buf, 0x160, &m_sha1); +// } +// sha1_end(header_sha1, &m_sha1); +//} +// +///* +// * Arm9Sha1Multiboot +// */ +//void Arm9Sha1Multiboot(FILE *fNDS, unsigned char *arm9_sha1) +//{ +// sha1_ctx m_sha1; +// sha1_begin(&m_sha1); +// fseek(fNDS, header.arm9_rom_offset, SEEK_SET); +// unsigned int len = header.arm9_size; +// unsigned char *buf = new unsigned char [len]; +// fread(buf, 1, len, fNDS); +// //printf("%u\n", len); +// sha1_hash(buf, len, &m_sha1); +// delete [] buf; +// sha1_end(arm9_sha1, &m_sha1); +//} +// +///* +// * Arm9Sha1ClearedOutArea +// */ +//void Arm9Sha1ClearedOutArea(FILE *fNDS, unsigned char *arm9_sha1) +//{ +// sha1_ctx m_sha1; +// sha1_begin(&m_sha1); +// fseek(fNDS, header.arm9_rom_offset, SEEK_SET); +// unsigned int len = header.arm9_size; +// unsigned char *buf = new unsigned char [len]; +// +// int len1 = (0x5000 - header.arm9_rom_offset); // e.g. 0x5000 - 0x4000 = 0x1000 +// int len3 = header.arm9_size - (0x7000 - header.arm9_rom_offset); // e.g. 0x10000 - (0x7000 - 0x4000) = 0xD000 +// int len2 = header.arm9_size - len1 - len3; // e.g. 0x10000 - 0x1000 - 0xD000 = 0x2000 +// if (len1 > 0) fread(buf, 1, len1, fNDS); +// if (len2 > 0) { memset(buf + len1, 0, len2); fseek(fNDS, len2, SEEK_CUR); } // gets cleared for security? +// if (len3 > 0) fread(buf + len1 + len2, 1, len3, fNDS); +//// printf("%X %X %X\n", len1, len2, len3); +// +//// memset(buf, 0, 0x800); // clear "secure area" too +// +// sha1_hash(buf, len, &m_sha1); +// delete [] buf; +// sha1_end(arm9_sha1, &m_sha1); +//} +// +///* +// * Arm7Sha1 +// */ +//void Arm7Sha1(FILE *fNDS, unsigned char *arm7_sha1) +//{ +// sha1_ctx m_sha1; +// sha1_begin(&m_sha1); +// fseek(fNDS, header.arm7_rom_offset, SEEK_SET); +// unsigned int len = header.arm7_size; +// unsigned char *buf = new unsigned char [len]; +// fread(buf, 1, len, fNDS); +// //printf("%u\n", len); +// sha1_hash(buf, len, &m_sha1); +// delete [] buf; +// sha1_end(arm7_sha1, &m_sha1); +//} +// +///* +// * CompareSha1WithList +// */ +//int CompareSha1WithList(unsigned char *arm7_sha1, const unsigned char *text, unsigned int textSize) +//{ +// while (1) +// { +// //printf("\n"); +// for (int i=0; i '9') ? ((*text - 'A') & 7) + 10 : *text - '0'); +// text++; +// } +// //printf("%02X", b); +// if (b != arm7_sha1[i]) break; else if (i == 19) return 0; +// } +// while (*text && (*text >= ' ')) text++; // line end +// while (*text && (*text < ' ')) text++; // new line +// } +//} +// +///* +// * HashAndCompareWithList +// * -1=error, 0=match, 1=no match +// */ +//int HashAndCompareWithList(char *filename, unsigned char sha1[]) +//{ +// FILE *f = fopen(filename, "rb"); +// if (!f) return -1; +// sha1_ctx m_sha1; +// sha1_begin(&m_sha1); +// unsigned char buf[1024]; +// unsigned int r; +// do +// { +// r = fread(buf, 1, 1024, f); +// sha1_hash(buf, r, &m_sha1); +// } while (r > 0); +// fclose(f); +// sha1_end(sha1, &m_sha1); +// if (CompareSha1WithList(sha1, arm7_sha1_homebrew, arm7_sha1_homebrew_size)) return 1; // not yet in list +// return 0; +//} +// +///* +// * strsepc +// */ +//char *strsepc(char **s, char d) +//{ +// char *r = *s; +// for (char *p = *s; ; p++) +// { +// if (*p == 0) { *s = p; break; } +// if (*p == d) { *s = p+1; *p = 0; break; } +// } +// return r; +//} +// +///* +// * RomListInfo +// */ +//void RomListInfo(unsigned int crc32_match) +//{ +// if (!romlistfilename) return; +// FILE *fRomList = fopen(romlistfilename, "rt"); +// if (!fRomList) { fprintf(stderr, "Cannot open file '%s'.\n", romlistfilename); exit(1); } +// char s[1024]; +// while (fgets(s, 1024, fRomList)) // empty, title, title, title, title, filename, CRC32 +// { +// char *p = s; +// if (strlen(strsepc(&p, '\xAC')) == 0) +// { +// char *title = strsepc(&p, '\xAC'); +// unsigned int index = strtoul(title, 0, 10); +// title += 7; +// char *b1 = strchr(title, '('); +// char *b2 = b1 ? strchr(b1+1, ')') : 0; +// char *b3 = b2 ? strchr(b2+1, '(') : 0; +// char *b4 = b3 ? strchr(b3+1, ')') : 0; +// char *group = 0; +// if (b1 + 2 == b2) if (b3 && b4) { *b3 = 0; *b4 = 0; group = b3+1; } // remove release group name +// strsepc(&p, '\xAC'); strsepc(&p, '\xAC'); +// strsepc(&p, '\xAC'); strsepc(&p, '\xAC'); +// unsigned long crc32 = strtoul(strsepc(&p, '\xAC'), 0, 16); +// if (crc32 == crc32_match) +// { +// printf("Release index: \t%u\n", index); +// printf("Release title: \t%s\n", title); +// printf("Release group: \t%s\n", group ? group : ""); +// } +// //for (int i=0; i<10; i++) printf("%d %s\n", i, strsepc(&p, '\xAC')); +// } +// } +//} +// +///* +// * ShowVerboseInfo +// */ +//void ShowVerboseInfo(FILE *fNDS, Header &header, int romType) +//{ +// // calculate SHA1 of ARM7 binary +// unsigned char arm7_sha1[SHA1_DIGEST_SIZE]; +// Arm7Sha1(fNDS, arm7_sha1); +// +// // find signature data +// unsigned_int signature_id = 0; +// fseek(fNDS, header.application_end_offset, SEEK_SET); +// fread(&signature_id, sizeof(signature_id), 1, fNDS); +// if (signature_id != 0x00016361) +// { +// fseek(fNDS, header.application_end_offset - 136, SEEK_SET); // try again +// fread(&signature_id, sizeof(signature_id), 1, fNDS); +// } +// if (signature_id == 0x00016361) +// { +// printf("\n"); +// +// unsigned char signature[128]; +// fread(signature, 1, sizeof(signature), fNDS); +// +// unsigned char sha_parts[3*SHA1_DIGEST_SIZE + 4]; +// fread(sha_parts + 3*SHA1_DIGEST_SIZE, 4, 1, fNDS); // some number +// +// //printf("%08X\n", *(unsigned int *)(sha_parts + 3*SHA1_DIGEST_SIZE)); +// +// unsigned char header_sha1[SHA1_DIGEST_SIZE]; +// HeaderSha1(fNDS, header_sha1, romType); +// memcpy(sha_parts + 0*SHA1_DIGEST_SIZE, header_sha1, SHA1_DIGEST_SIZE); +// +// unsigned char arm9_sha1[SHA1_DIGEST_SIZE]; +// if (romType == ROMTYPE_MULTIBOOT) +// { +// Arm9Sha1Multiboot(fNDS, arm9_sha1); +// } +// else +// { +// Arm9Sha1ClearedOutArea(fNDS, arm9_sha1); +// } +// memcpy(sha_parts + 1*SHA1_DIGEST_SIZE, arm9_sha1, SHA1_DIGEST_SIZE); +// +// memcpy(sha_parts + 2*SHA1_DIGEST_SIZE, arm7_sha1, SHA1_DIGEST_SIZE); +// +// unsigned char sha_final[SHA1_DIGEST_SIZE]; +// { +// sha1_ctx m_sha1; +// sha1_begin(&m_sha1); +// unsigned int len = sizeof(sha_parts); +// unsigned char *buf = sha_parts; +// sha1_hash(buf, len, &m_sha1); +// sha1_end(sha_final, &m_sha1); +// } +// +// // calculate SHA1 from signature +// unsigned char sha1_from_sig[SHA1_DIGEST_SIZE]; +// { +// BigInt _signature; +// _signature.Set(signature, sizeof(signature)); +// //printf("signature: "); _signature.print(); +// +// BigInt _publicKey; +// _publicKey.Set(publicKeyNintendo, sizeof(publicKeyNintendo)); +// //printf("public key: "); _publicKey.print(); +// +// BigInt big_sha1; +// big_sha1.PowMod(_signature, _publicKey); +// //printf("big_sha1: "); big_sha1.print(); +// big_sha1.Get(sha1_from_sig, sizeof(sha1_from_sig)); +// } +// +// bool ok = (memcmp(sha_final, sha1_from_sig, SHA1_DIGEST_SIZE) == 0); +// printf("DS Download Play(TM) / Wireless MultiBoot signature: %s\n", ok ? "OK" : "INVALID"); +// if (!ok) +// { +// printf("header hash: \t"); for (int i=0; i 0) +// { +// crc32 = CalcCrc32(buf, r, crc32); +// } +// crc32 = ~crc32; +// delete [] buf; +// +// printf("\nFile CRC32: \t%08X\n", (unsigned int)crc32); +// RomListInfo(crc32); +// } +// +// // ROM dumper 1.0 bad data +// { +// unsigned char buf[0x200]; +// fseek(fNDS, 0x7E00, SEEK_SET); +// fread(buf, 1, 0x200, fNDS); +// unsigned long crc32 = ~CalcCrc32(buf, 0x200); +// printf("\nSMT dumper v1.0 corruption check: \t%s\n", (crc32 == 0x7E8B456F) ? "CORRUPTED" : "OK"); +// } +// +// // Verify ARM7 SHA1 hash against known default binaries +// int bKnownArm7 = 0; +// { +// printf("\nARM7 binary hash : \t"); for (int i=0; i= 0x04000000)) +// { +// printf("\nWARNING! ARM7 RAM address does not point to shared memory!\n"); +// } +// +// // check ARM7 entry address +// if ((header.arm7_entry_address < header.arm7_ram_address) || +// (header.arm7_entry_address > header.arm7_ram_address + header.arm7_size)) +// { +// printf("\nWARNING! ARM7 entry address points outside of ARM7 binary!\n"); +// } +//} +// +///* +// * ShowInfo +// */ +//void ShowInfo(char *ndsfilename) +//{ +// fNDS = fopen(ndsfilename, "rb"); +// if (!fNDS) { fprintf(stderr, "Cannot open file '%s'.\n", ndsfilename); exit(1); } +// fread(&header, 512, 1, fNDS); +// +// int romType = DetectRomType(); +// +// printf("Header information:\n"); +// ShowHeaderInfo(header, romType); +// +// // banner info +// if (header.banner_offset) +// { +// Banner banner; +// fseek(fNDS, header.banner_offset, SEEK_SET); +// if (fread(&banner, 1, sizeof(banner), fNDS)) +// { +// unsigned short banner_crc = CalcBannerCRC(banner); +// printf("\n"); +// printf("Banner CRC: \t0x%04X (%s)\n", (int)banner.crc, (banner_crc == banner.crc) ? "OK" : "INVALID"); +// +// for (int language=1; language<=1; language++) +// { +// int line = 1; +// bool nextline = true; +// for (int i=0; i<128; i++) +// { +// unsigned short c = banner.title[language][i]; +// if (c >= 128) c = '_'; +// if (c == 0x00) { printf("\n"); break; } +// if (c == 0x0A) +// { +// nextline = true; +// } +// else +// { +// if (nextline) +// { +// if (line != 1) printf("\n"); +// printf("%s banner text, line %d:", bannerLanguages[language], line); +// for (unsigned int i=0; i<11 - strlen(bannerLanguages[language]); i++) putchar(' '); +// printf("\t"); +// nextline = false; +// line++; +// } +// putchar(c); +// } +// } +// } +// } +// } +// +// // ARM9 footer +// fseek(fNDS, header.arm9_rom_offset + header.arm9_size, SEEK_SET); +// unsigned_int nitrocode; +// if (fread(&nitrocode, sizeof(nitrocode), 1, fNDS) && (nitrocode == 0xDEC00621)) +// { +// printf("\n"); +// printf("ARM9 footer found.\n"); +// unsigned_int x; +// fread(&x, sizeof(x), 1, fNDS); +// fread(&x, sizeof(x), 1, fNDS); +// } +// +// // show security CRCs +// if (romType >= ROMTYPE_NDSDUMPED) +// { +// printf("\n"); +// unsigned short securitydata_crc = CalcSecurityDataCRC(); +// printf("Security data CRC (0x1000-0x2FFF) 0x%04X\n", (int)securitydata_crc); +// unsigned short segment3_crc = CalcSegment3CRC(); +// printf("Segment3 CRC (0x3000-0x3FFF) 0x%04X (%s)\n", (int)segment3_crc, (segment3_crc == 0x0254) ? "OK" : "INVALID"); +// } +// +// // more information +// if (verbose >= 1) +// { +// ShowVerboseInfo(fNDS, header, romType); +// } +// +// fclose(fNDS); +//} diff --git a/desmume/src/utils/decrypt/header.h b/src/utils/decrypt/header.h similarity index 96% rename from desmume/src/utils/decrypt/header.h rename to src/utils/decrypt/header.h index a8eb9c380..0bf960039 100644 --- a/desmume/src/utils/decrypt/header.h +++ b/src/utils/decrypt/header.h @@ -1,134 +1,134 @@ -//taken from ndstool -//http://devkitpro.cvs.sourceforge.net/viewvc/devkitpro/tools/nds/ndstool/include/header.h?revision=1.14 - -/* header.h - this file is part of DeSmuME - * - * Copyright (C) 2005-2006 Rafael Vuijk - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _HEADER_H_ -#define _HEADER_H_ - - -#include "../../types.h" - -#include "../../PACKED.h" -struct __PACKED Header -{ - char title[0xC]; - char gamecode[0x4]; - char makercode[2]; - unsigned char unitcode; // product code. 0 = Nintendo DS - unsigned char devicetype; // device code. 0 = normal - unsigned char devicecap; // device size. (1< -#include "guid.h" -#include "../types.h" - -void Desmume_Guid::newGuid() -{ - for(int i=0;i='A') a=a-'A'+10; - else a-='0'; - if(b>='A') b=b-'A'+10; - else b-='0'; - return ((unsigned char)a<<4)|(unsigned char)b; -} - -void Desmume_Guid::scan(std::string& str) -{ - char* endptr = (char*)str.c_str(); - en32lsb(data,strtoul(endptr,&endptr,16)); - en16lsb(data+4,(u16)strtoul(endptr+1,&endptr,16)); - en16lsb(data+6,(u16)strtoul(endptr+1,&endptr,16)); - en16lsb(data+8,(u16)strtoul(endptr+1,&endptr,16)); - endptr++; - for(int i=0;i<6;i++) - data[10+i] = hexToByte(&endptr); -} +/* guid.cpp + + Copyright (C) 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include "guid.h" +#include "../types.h" + +void Desmume_Guid::newGuid() +{ + for(int i=0;i='A') a=a-'A'+10; + else a-='0'; + if(b>='A') b=b-'A'+10; + else b-='0'; + return ((unsigned char)a<<4)|(unsigned char)b; +} + +void Desmume_Guid::scan(std::string& str) +{ + char* endptr = (char*)str.c_str(); + en32lsb(data,strtoul(endptr,&endptr,16)); + en16lsb(data+4,strtoul(endptr+1,&endptr,16)); + en16lsb(data+6,strtoul(endptr+1,&endptr,16)); + en16lsb(data+8,strtoul(endptr+1,&endptr,16)); + endptr++; + for(int i=0;i<6;i++) + data[10+i] = hexToByte(&endptr); +} diff --git a/desmume/src/utils/guid.h b/src/utils/guid.h similarity index 94% rename from desmume/src/utils/guid.h rename to src/utils/guid.h index df5e57e43..b1a1ae787 100644 --- a/desmume/src/utils/guid.h +++ b/src/utils/guid.h @@ -1,19 +1,19 @@ -#ifndef _guid_h_ -#define _guid_h_ - -#include -#include -#include "../types.h" -#include "valuearray.h" - -struct Desmume_Guid : public ValueArray -{ - void newGuid(); - std::string toString(); - static Desmume_Guid fromString(std::string str); - static uint8 hexToByte(char** ptrptr); - void scan(std::string& str); -}; - - -#endif +#ifndef _guid_h_ +#define _guid_h_ + +#include +#include +#include "../types.h" +#include "valuearray.h" + +struct Desmume_Guid : public ValueArray +{ + void newGuid(); + std::string toString(); + static Desmume_Guid fromString(std::string str); + static uint8 hexToByte(char** ptrptr); + void scan(std::string& str); +}; + + +#endif diff --git a/desmume/src/utils/md5.cpp b/src/utils/md5.cpp similarity index 96% rename from desmume/src/utils/md5.cpp rename to src/utils/md5.cpp index 3ba6e3709..912d36329 100644 --- a/desmume/src/utils/md5.cpp +++ b/src/utils/md5.cpp @@ -1,248 +1,248 @@ -/// \file -/// \brief RFC 1321 compliant MD5 implementation, -/// RFC 1321 compliant MD5 implementation, -/// by Christophe Devine ; -/// this program is licensed under the GPL. - -//Modified October 3, 2003, to remove testing code, and add include of "types.h". -//Added simple MD5 to ASCII string conversion function. -// -Xodnizel - -#include -#include "../types.h" -#include "md5.h" - -typedef u8 uint8; -typedef u16 uint16; -typedef u32 uint32; - -#define GET_UINT32(n,b,i) \ -{ \ - (n) = ( (uint32) (b)[(i) + 3] << 24 ) \ - | ( (uint32) (b)[(i) + 2] << 16 ) \ - | ( (uint32) (b)[(i) + 1] << 8 ) \ - | ( (uint32) (b)[(i) ] ); \ -} - -#define PUT_UINT32(n,b,i) \ -{ \ - (b)[(i) ] = (uint8) ( (n) ); \ - (b)[(i) + 1] = (uint8) ( (n) >> 8 ); \ - (b)[(i) + 2] = (uint8) ( (n) >> 16 ); \ - (b)[(i) + 3] = (uint8) ( (n) >> 24 ); \ -} - -void md5_starts( struct md5_context *ctx ) -{ - ctx->total[0] = 0; - ctx->total[1] = 0; - ctx->state[0] = 0x67452301; - ctx->state[1] = 0xEFCDAB89; - ctx->state[2] = 0x98BADCFE; - ctx->state[3] = 0x10325476; -} - -static void md5_process( struct md5_context *ctx, uint8 data[64] ) -{ - uint32 A, B, C, D, X[16]; - - GET_UINT32( X[0], data, 0 ); - GET_UINT32( X[1], data, 4 ); - GET_UINT32( X[2], data, 8 ); - GET_UINT32( X[3], data, 12 ); - GET_UINT32( X[4], data, 16 ); - GET_UINT32( X[5], data, 20 ); - GET_UINT32( X[6], data, 24 ); - GET_UINT32( X[7], data, 28 ); - GET_UINT32( X[8], data, 32 ); - GET_UINT32( X[9], data, 36 ); - GET_UINT32( X[10], data, 40 ); - GET_UINT32( X[11], data, 44 ); - GET_UINT32( X[12], data, 48 ); - GET_UINT32( X[13], data, 52 ); - GET_UINT32( X[14], data, 56 ); - GET_UINT32( X[15], data, 60 ); - -#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) - -#define P(a,b,c,d,k,s,t) \ -{ \ - a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \ -} - - A = ctx->state[0]; - B = ctx->state[1]; - C = ctx->state[2]; - D = ctx->state[3]; - -#define F(x,y,z) (z ^ (x & (y ^ z))) - - P( A, B, C, D, 0, 7, 0xD76AA478 ); - P( D, A, B, C, 1, 12, 0xE8C7B756 ); - P( C, D, A, B, 2, 17, 0x242070DB ); - P( B, C, D, A, 3, 22, 0xC1BDCEEE ); - P( A, B, C, D, 4, 7, 0xF57C0FAF ); - P( D, A, B, C, 5, 12, 0x4787C62A ); - P( C, D, A, B, 6, 17, 0xA8304613 ); - P( B, C, D, A, 7, 22, 0xFD469501 ); - P( A, B, C, D, 8, 7, 0x698098D8 ); - P( D, A, B, C, 9, 12, 0x8B44F7AF ); - P( C, D, A, B, 10, 17, 0xFFFF5BB1 ); - P( B, C, D, A, 11, 22, 0x895CD7BE ); - P( A, B, C, D, 12, 7, 0x6B901122 ); - P( D, A, B, C, 13, 12, 0xFD987193 ); - P( C, D, A, B, 14, 17, 0xA679438E ); - P( B, C, D, A, 15, 22, 0x49B40821 ); - -#undef F - -#define F(x,y,z) (y ^ (z & (x ^ y))) - - P( A, B, C, D, 1, 5, 0xF61E2562 ); - P( D, A, B, C, 6, 9, 0xC040B340 ); - P( C, D, A, B, 11, 14, 0x265E5A51 ); - P( B, C, D, A, 0, 20, 0xE9B6C7AA ); - P( A, B, C, D, 5, 5, 0xD62F105D ); - P( D, A, B, C, 10, 9, 0x02441453 ); - P( C, D, A, B, 15, 14, 0xD8A1E681 ); - P( B, C, D, A, 4, 20, 0xE7D3FBC8 ); - P( A, B, C, D, 9, 5, 0x21E1CDE6 ); - P( D, A, B, C, 14, 9, 0xC33707D6 ); - P( C, D, A, B, 3, 14, 0xF4D50D87 ); - P( B, C, D, A, 8, 20, 0x455A14ED ); - P( A, B, C, D, 13, 5, 0xA9E3E905 ); - P( D, A, B, C, 2, 9, 0xFCEFA3F8 ); - P( C, D, A, B, 7, 14, 0x676F02D9 ); - P( B, C, D, A, 12, 20, 0x8D2A4C8A ); - -#undef F - -#define F(x,y,z) (x ^ y ^ z) - - P( A, B, C, D, 5, 4, 0xFFFA3942 ); - P( D, A, B, C, 8, 11, 0x8771F681 ); - P( C, D, A, B, 11, 16, 0x6D9D6122 ); - P( B, C, D, A, 14, 23, 0xFDE5380C ); - P( A, B, C, D, 1, 4, 0xA4BEEA44 ); - P( D, A, B, C, 4, 11, 0x4BDECFA9 ); - P( C, D, A, B, 7, 16, 0xF6BB4B60 ); - P( B, C, D, A, 10, 23, 0xBEBFBC70 ); - P( A, B, C, D, 13, 4, 0x289B7EC6 ); - P( D, A, B, C, 0, 11, 0xEAA127FA ); - P( C, D, A, B, 3, 16, 0xD4EF3085 ); - P( B, C, D, A, 6, 23, 0x04881D05 ); - P( A, B, C, D, 9, 4, 0xD9D4D039 ); - P( D, A, B, C, 12, 11, 0xE6DB99E5 ); - P( C, D, A, B, 15, 16, 0x1FA27CF8 ); - P( B, C, D, A, 2, 23, 0xC4AC5665 ); - -#undef F - -#define F(x,y,z) (y ^ (x | ~z)) - - P( A, B, C, D, 0, 6, 0xF4292244 ); - P( D, A, B, C, 7, 10, 0x432AFF97 ); - P( C, D, A, B, 14, 15, 0xAB9423A7 ); - P( B, C, D, A, 5, 21, 0xFC93A039 ); - P( A, B, C, D, 12, 6, 0x655B59C3 ); - P( D, A, B, C, 3, 10, 0x8F0CCC92 ); - P( C, D, A, B, 10, 15, 0xFFEFF47D ); - P( B, C, D, A, 1, 21, 0x85845DD1 ); - P( A, B, C, D, 8, 6, 0x6FA87E4F ); - P( D, A, B, C, 15, 10, 0xFE2CE6E0 ); - P( C, D, A, B, 6, 15, 0xA3014314 ); - P( B, C, D, A, 13, 21, 0x4E0811A1 ); - P( A, B, C, D, 4, 6, 0xF7537E82 ); - P( D, A, B, C, 11, 10, 0xBD3AF235 ); - P( C, D, A, B, 2, 15, 0x2AD7D2BB ); - P( B, C, D, A, 9, 21, 0xEB86D391 ); - -#undef F - - ctx->state[0] += A; - ctx->state[1] += B; - ctx->state[2] += C; - ctx->state[3] += D; -} - -void md5_update( struct md5_context *ctx, uint8 *input, uint32 length ) -{ - uint32 left, fill; - - if( ! length ) return; - - left = ( ctx->total[0] >> 3 ) & 0x3F; - fill = 64 - left; - - ctx->total[0] += length << 3; - ctx->total[1] += length >> 29; - - ctx->total[0] &= 0xFFFFFFFF; - ctx->total[1] += ctx->total[0] < ( length << 3 ); - - if( left && length >= fill ) - { - memcpy( (void *) (ctx->buffer + left), (void *) input, fill ); - md5_process( ctx, ctx->buffer ); - length -= fill; - input += fill; - left = 0; - } - - while( length >= 64 ) - { - md5_process( ctx, input ); - length -= 64; - input += 64; - } - - if( length ) - { - memcpy( (void *) (ctx->buffer + left), (void *) input, length ); - } -} - -static uint8 md5_padding[64] = -{ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -void md5_finish( struct md5_context *ctx, uint8 digest[16] ) -{ - uint32 last, padn; - uint8 msglen[8]; - - PUT_UINT32( ctx->total[0], msglen, 0 ); - PUT_UINT32( ctx->total[1], msglen, 4 ); - - last = ( ctx->total[0] >> 3 ) & 0x3F; - padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); - - md5_update( ctx, md5_padding, padn ); - md5_update( ctx, msglen, 8 ); - - PUT_UINT32( ctx->state[0], digest, 0 ); - PUT_UINT32( ctx->state[1], digest, 4 ); - PUT_UINT32( ctx->state[2], digest, 8 ); - PUT_UINT32( ctx->state[3], digest, 12 ); -} - - -/* Uses a static buffer, so beware of how it's used. */ -char *md5_asciistr(MD5DATA& md5) -{ - uint8* digest = md5.data; - static char str[33]; - static char trans[16]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; - int x; - - for(x=0;x<16;x++) - { - str[x*2]=trans[digest[x]>>4]; - str[x*2+1]=trans[digest[x]&0x0F]; - } - return(str); -} +/// \file +/// \brief RFC 1321 compliant MD5 implementation, +/// RFC 1321 compliant MD5 implementation, +/// by Christophe Devine ; +/// this program is licensed under the GPL. + +//Modified October 3, 2003, to remove testing code, and add include of "types.h". +//Added simple MD5 to ASCII string conversion function. +// -Xodnizel + +#include +#include "../types.h" +#include "md5.h" + +typedef u8 uint8; +typedef u16 uint16; +typedef u32 uint32; + +#define GET_UINT32(n,b,i) \ +{ \ + (n) = ( (uint32) (b)[(i) + 3] << 24 ) \ + | ( (uint32) (b)[(i) + 2] << 16 ) \ + | ( (uint32) (b)[(i) + 1] << 8 ) \ + | ( (uint32) (b)[(i) ] ); \ +} + +#define PUT_UINT32(n,b,i) \ +{ \ + (b)[(i) ] = (uint8) ( (n) ); \ + (b)[(i) + 1] = (uint8) ( (n) >> 8 ); \ + (b)[(i) + 2] = (uint8) ( (n) >> 16 ); \ + (b)[(i) + 3] = (uint8) ( (n) >> 24 ); \ +} + +void md5_starts( struct md5_context *ctx ) +{ + ctx->total[0] = 0; + ctx->total[1] = 0; + ctx->state[0] = 0x67452301; + ctx->state[1] = 0xEFCDAB89; + ctx->state[2] = 0x98BADCFE; + ctx->state[3] = 0x10325476; +} + +static void md5_process( struct md5_context *ctx, uint8 data[64] ) +{ + uint32 A, B, C, D, X[16]; + + GET_UINT32( X[0], data, 0 ); + GET_UINT32( X[1], data, 4 ); + GET_UINT32( X[2], data, 8 ); + GET_UINT32( X[3], data, 12 ); + GET_UINT32( X[4], data, 16 ); + GET_UINT32( X[5], data, 20 ); + GET_UINT32( X[6], data, 24 ); + GET_UINT32( X[7], data, 28 ); + GET_UINT32( X[8], data, 32 ); + GET_UINT32( X[9], data, 36 ); + GET_UINT32( X[10], data, 40 ); + GET_UINT32( X[11], data, 44 ); + GET_UINT32( X[12], data, 48 ); + GET_UINT32( X[13], data, 52 ); + GET_UINT32( X[14], data, 56 ); + GET_UINT32( X[15], data, 60 ); + +#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) + +#define P(a,b,c,d,k,s,t) \ +{ \ + a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \ +} + + A = ctx->state[0]; + B = ctx->state[1]; + C = ctx->state[2]; + D = ctx->state[3]; + +#define F(x,y,z) (z ^ (x & (y ^ z))) + + P( A, B, C, D, 0, 7, 0xD76AA478 ); + P( D, A, B, C, 1, 12, 0xE8C7B756 ); + P( C, D, A, B, 2, 17, 0x242070DB ); + P( B, C, D, A, 3, 22, 0xC1BDCEEE ); + P( A, B, C, D, 4, 7, 0xF57C0FAF ); + P( D, A, B, C, 5, 12, 0x4787C62A ); + P( C, D, A, B, 6, 17, 0xA8304613 ); + P( B, C, D, A, 7, 22, 0xFD469501 ); + P( A, B, C, D, 8, 7, 0x698098D8 ); + P( D, A, B, C, 9, 12, 0x8B44F7AF ); + P( C, D, A, B, 10, 17, 0xFFFF5BB1 ); + P( B, C, D, A, 11, 22, 0x895CD7BE ); + P( A, B, C, D, 12, 7, 0x6B901122 ); + P( D, A, B, C, 13, 12, 0xFD987193 ); + P( C, D, A, B, 14, 17, 0xA679438E ); + P( B, C, D, A, 15, 22, 0x49B40821 ); + +#undef F + +#define F(x,y,z) (y ^ (z & (x ^ y))) + + P( A, B, C, D, 1, 5, 0xF61E2562 ); + P( D, A, B, C, 6, 9, 0xC040B340 ); + P( C, D, A, B, 11, 14, 0x265E5A51 ); + P( B, C, D, A, 0, 20, 0xE9B6C7AA ); + P( A, B, C, D, 5, 5, 0xD62F105D ); + P( D, A, B, C, 10, 9, 0x02441453 ); + P( C, D, A, B, 15, 14, 0xD8A1E681 ); + P( B, C, D, A, 4, 20, 0xE7D3FBC8 ); + P( A, B, C, D, 9, 5, 0x21E1CDE6 ); + P( D, A, B, C, 14, 9, 0xC33707D6 ); + P( C, D, A, B, 3, 14, 0xF4D50D87 ); + P( B, C, D, A, 8, 20, 0x455A14ED ); + P( A, B, C, D, 13, 5, 0xA9E3E905 ); + P( D, A, B, C, 2, 9, 0xFCEFA3F8 ); + P( C, D, A, B, 7, 14, 0x676F02D9 ); + P( B, C, D, A, 12, 20, 0x8D2A4C8A ); + +#undef F + +#define F(x,y,z) (x ^ y ^ z) + + P( A, B, C, D, 5, 4, 0xFFFA3942 ); + P( D, A, B, C, 8, 11, 0x8771F681 ); + P( C, D, A, B, 11, 16, 0x6D9D6122 ); + P( B, C, D, A, 14, 23, 0xFDE5380C ); + P( A, B, C, D, 1, 4, 0xA4BEEA44 ); + P( D, A, B, C, 4, 11, 0x4BDECFA9 ); + P( C, D, A, B, 7, 16, 0xF6BB4B60 ); + P( B, C, D, A, 10, 23, 0xBEBFBC70 ); + P( A, B, C, D, 13, 4, 0x289B7EC6 ); + P( D, A, B, C, 0, 11, 0xEAA127FA ); + P( C, D, A, B, 3, 16, 0xD4EF3085 ); + P( B, C, D, A, 6, 23, 0x04881D05 ); + P( A, B, C, D, 9, 4, 0xD9D4D039 ); + P( D, A, B, C, 12, 11, 0xE6DB99E5 ); + P( C, D, A, B, 15, 16, 0x1FA27CF8 ); + P( B, C, D, A, 2, 23, 0xC4AC5665 ); + +#undef F + +#define F(x,y,z) (y ^ (x | ~z)) + + P( A, B, C, D, 0, 6, 0xF4292244 ); + P( D, A, B, C, 7, 10, 0x432AFF97 ); + P( C, D, A, B, 14, 15, 0xAB9423A7 ); + P( B, C, D, A, 5, 21, 0xFC93A039 ); + P( A, B, C, D, 12, 6, 0x655B59C3 ); + P( D, A, B, C, 3, 10, 0x8F0CCC92 ); + P( C, D, A, B, 10, 15, 0xFFEFF47D ); + P( B, C, D, A, 1, 21, 0x85845DD1 ); + P( A, B, C, D, 8, 6, 0x6FA87E4F ); + P( D, A, B, C, 15, 10, 0xFE2CE6E0 ); + P( C, D, A, B, 6, 15, 0xA3014314 ); + P( B, C, D, A, 13, 21, 0x4E0811A1 ); + P( A, B, C, D, 4, 6, 0xF7537E82 ); + P( D, A, B, C, 11, 10, 0xBD3AF235 ); + P( C, D, A, B, 2, 15, 0x2AD7D2BB ); + P( B, C, D, A, 9, 21, 0xEB86D391 ); + +#undef F + + ctx->state[0] += A; + ctx->state[1] += B; + ctx->state[2] += C; + ctx->state[3] += D; +} + +void md5_update( struct md5_context *ctx, uint8 *input, uint32 length ) +{ + uint32 left, fill; + + if( ! length ) return; + + left = ( ctx->total[0] >> 3 ) & 0x3F; + fill = 64 - left; + + ctx->total[0] += length << 3; + ctx->total[1] += length >> 29; + + ctx->total[0] &= 0xFFFFFFFF; + ctx->total[1] += ctx->total[0] < ( length << 3 ); + + if( left && length >= fill ) + { + memcpy( (void *) (ctx->buffer + left), (void *) input, fill ); + md5_process( ctx, ctx->buffer ); + length -= fill; + input += fill; + left = 0; + } + + while( length >= 64 ) + { + md5_process( ctx, input ); + length -= 64; + input += 64; + } + + if( length ) + { + memcpy( (void *) (ctx->buffer + left), (void *) input, length ); + } +} + +static uint8 md5_padding[64] = +{ + 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +void md5_finish( struct md5_context *ctx, uint8 digest[16] ) +{ + uint32 last, padn; + uint8 msglen[8]; + + PUT_UINT32( ctx->total[0], msglen, 0 ); + PUT_UINT32( ctx->total[1], msglen, 4 ); + + last = ( ctx->total[0] >> 3 ) & 0x3F; + padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last ); + + md5_update( ctx, md5_padding, padn ); + md5_update( ctx, msglen, 8 ); + + PUT_UINT32( ctx->state[0], digest, 0 ); + PUT_UINT32( ctx->state[1], digest, 4 ); + PUT_UINT32( ctx->state[2], digest, 8 ); + PUT_UINT32( ctx->state[3], digest, 12 ); +} + + +/* Uses a static buffer, so beware of how it's used. */ +char *md5_asciistr(MD5DATA& md5) +{ + uint8* digest = md5.data; + static char str[33]; + static char trans[16]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; + int x; + + for(x=0;x<16;x++) + { + str[x*2]=trans[digest[x]>>4]; + str[x*2+1]=trans[digest[x]&0x0F]; + } + return(str); +} diff --git a/desmume/src/utils/md5.h b/src/utils/md5.h similarity index 95% rename from desmume/src/utils/md5.h rename to src/utils/md5.h index bbd2593b1..f197aac19 100644 --- a/desmume/src/utils/md5.h +++ b/src/utils/md5.h @@ -1,23 +1,23 @@ -#ifndef _MD5_H -#define _MD5_H - -#include "../types.h" -#include "valuearray.h" - -struct md5_context -{ - u32 total[2]; - u32 state[4]; - u8 buffer[64]; -}; - -typedef ValueArray MD5DATA; - -void md5_starts( struct md5_context *ctx ); -void md5_update( struct md5_context *ctx, u8 *input, u32 length ); -void md5_finish( struct md5_context *ctx, u8 digest[16] ); - -/* Uses a static buffer, so beware of how it's used. */ -char *md5_asciistr(MD5DATA& md5); - -#endif /* md5.h */ +#ifndef _MD5_H +#define _MD5_H + +#include "../types.h" +#include "valuearray.h" + +struct md5_context +{ + u32 total[2]; + u32 state[4]; + u8 buffer[64]; +}; + +typedef ValueArray MD5DATA; + +void md5_starts( struct md5_context *ctx ); +void md5_update( struct md5_context *ctx, u8 *input, u32 length ); +void md5_finish( struct md5_context *ctx, u8 digest[16] ); + +/* Uses a static buffer, so beware of how it's used. */ +char *md5_asciistr(MD5DATA& md5); + +#endif /* md5.h */ diff --git a/desmume/src/utils/valuearray.h b/src/utils/valuearray.h similarity index 95% rename from desmume/src/utils/valuearray.h rename to src/utils/valuearray.h index 697014d56..8606ff829 100644 --- a/desmume/src/utils/valuearray.h +++ b/src/utils/valuearray.h @@ -1,21 +1,21 @@ -#ifndef _VALUEARRAY_H_ -#define _VALUEARRAY_H_ - -template -struct ValueArray -{ - T data[N]; - T &operator[](int index) { return data[index]; } - static const int size = N; - bool operator!=(ValueArray &other) { return !operator==(other); } - bool operator==(ValueArray &other) - { - for(int i=0;i +struct ValueArray +{ + T data[N]; + T &operator[](int index) { return data[index]; } + static const int size = N; + bool operator!=(ValueArray &other) { return !operator==(other); } + bool operator==(ValueArray &other) + { + for(int i=0;i - -//a vc-style substring operation (very kind and lenient) -std::string strsub(const std::string& str, int pos, int len) { - int strlen = str.size(); - - if(strlen==0) return str; //empty strings always return empty strings - if(pos>=strlen) return str; //if you start past the end of the string, return the entire string. this is unusual, but there you have it - - //clipping - if(pos<0) { - len += pos; - pos = 0; - } - - if (pos+len>=strlen) - len=strlen-pos+1; - - //return str.str().substr(pos,len); - return str.substr(pos,len); -} - -std::string strmid(const std::string& str, int pos, int len) { return strsub(str,pos,len); } -std::string strleft(const std::string& str, int len) { return strsub(str,0,len); } -std::string strright(const std::string& str, int len) { return len ? strsub(str,str.size()-len,len) : ""; } -std::string toupper(const std::string& str) -{ - std::string ret = str; - for(u32 i=0;i= 'a') && (str[i] <= 'z')) { - str[i] &= ~0x20; - j++; - } - i++; - } - return j; -} - - -///Lower case routine. Returns number of characters modified -int str_lcase(char *str) { - u32 i=0,j=0; - - while (i < strlen(str)) { - if ((str[i] >= 'A') && (str[i] <= 'Z')) { - str[i] |= 0x20; - j++; - } - i++; - } - return j; -} - - -///White space-trimming routine - -///Removes whitespace from left side of string, depending on the flags set (See STRIP_x definitions in xstring.h) -///Returns number of characters removed -int str_ltrim(char *str, int flags) { - u32 i=0; - - while (str[0]) { - if ((str[0] != ' ') || (str[0] != '\t') || (str[0] != '\r') || (str[0] != '\n')) break; - - if ((flags & STRIP_SP) && (str[0] == ' ')) { - i++; - strcpy(str,str+1); - } - if ((flags & STRIP_TAB) && (str[0] == '\t')) { - i++; - strcpy(str,str+1); - } - if ((flags & STRIP_CR) && (str[0] == '\r')) { - i++; - strcpy(str,str+1); - } - if ((flags & STRIP_LF) && (str[0] == '\n')) { - i++; - strcpy(str,str+1); - } - } - return i; -} - - -///White space-trimming routine - -///Removes whitespace from right side of string, depending on the flags set (See STRIP_x definitions in xstring.h) -///Returns number of characters removed -int str_rtrim(char *str, int flags) { - u32 i=0; - - while (strlen(str)) { - if ((str[strlen(str)-1] != ' ') || - (str[strlen(str)-1] != '\t') || - (str[strlen(str)-1] != '\r') || - (str[strlen(str)-1] != '\n')) break; - - if ((flags & STRIP_SP) && (str[0] == ' ')) { - i++; - str[strlen(str)-1] = 0; - } - if ((flags & STRIP_TAB) && (str[0] == '\t')) { - i++; - str[strlen(str)-1] = 0; - } - if ((flags & STRIP_CR) && (str[0] == '\r')) { - i++; - str[strlen(str)-1] = 0; - } - if ((flags & STRIP_LF) && (str[0] == '\n')) { - i++; - str[strlen(str)-1] = 0; - } - } - return i; -} - - -///White space-stripping routine - -///Removes whitespace depending on the flags set (See STRIP_x definitions in xstring.h) -///Returns number of characters removed, or -1 on error -int str_strip(char *str, int flags) { - u32 i=0,j=0; - char *astr,chr; - - if (!strlen(str)) return -1; - if (!(flags & (STRIP_SP|STRIP_TAB|STRIP_CR|STRIP_LF))) return -1; - if (!(astr = (char*)malloc(strlen(str)+1))) return -1; - while (i < strlen(str)) { - chr = str[i++]; - if ((flags & STRIP_SP) && (chr == ' ')) chr = 0; - if ((flags & STRIP_TAB) && (chr == '\t')) chr = 0; - if ((flags & STRIP_CR) && (chr == '\r')) chr = 0; - if ((flags & STRIP_LF) && (chr == '\n')) chr = 0; - - if (chr) astr[j++] = chr; - } - astr[j] = 0; - strcpy(str,astr); - free(astr); - return j; -} - - -///Character replacement routine - -///Replaces all instances of 'search' with 'replace' -///Returns number of characters modified -int chr_replace(char *str, char search, char replace) { - u32 i=0,j=0; - - while (i < strlen(str)) { - if (str[i] == search) { - str[i] = replace; - j++; - } - i++; - } - return j; -} - - -///Sub-String replacement routine - -///Replaces all instances of 'search' with 'replace' -///Returns number of sub-strings modified, or -1 on error -int str_replace(char *str, char *search, char *replace) { - u32 i=0,j=0; - int searchlen,replacelen; - char *astr; - - searchlen = strlen(search); - replacelen = strlen(replace); - if ((!strlen(str)) || (!searchlen)) return -1; //note: allow *replace to have a length of zero! - if (!(astr = (char*)malloc(strlen(str)+1))) return -1; - while (i < strlen(str)) { - if (!strncmp(str+i,search,searchlen)) { - if (replacelen) memcpy(astr+j,replace,replacelen); - i += searchlen; - j += replacelen; - } - else astr[j++] = str[i++]; - } - astr[j] = 0; - strcpy(str,astr); - free(astr); - return j; -} - -static const struct Base64Table -{ - Base64Table() - { - size_t a=0; - for(a=0; a<256; ++a) data[a] = 0xFF; // mark everything as invalid by default - // create value->ascii mapping - a=0; - for(unsigned char c='A'; c<='Z'; ++c) data[a++] = c; // 0..25 - for(unsigned char c='a'; c<='z'; ++c) data[a++] = c; // 26..51 - for(unsigned char c='0'; c<='9'; ++c) data[a++] = c; // 52..61 - data[62] = '+'; // 62 - data[63] = '/'; // 63 - // create ascii->value mapping (but due to overlap, write it to highbit region) - for(a=0; a<64; ++a) data[data[a]^0x80] = a; // - data[((unsigned char)'=') ^ 0x80] = 0; - } - unsigned char operator[] (size_t pos) const { return data[pos]; } -private: - unsigned char data[256]; -} Base64Table; - -std::string u32ToHexString(u32 val) -{ - char temp[16]; - sprintf(temp,"%08X",val); - return temp; -} - -///Converts the provided data to a string in a standard, user-friendly, round-trippable format -std::string BytesToString(const void* data, int len) -{ - char temp[16]; - if(len==1) { - sprintf(temp,"%d",*(const unsigned char*)data); - return temp; - } else if(len==2) { - sprintf(temp,"%d",*(const unsigned short*)data); - return temp; - } else if(len==4) { - sprintf(temp,"%d",*(const unsigned int*)data); - return temp; - } - - std::string ret; - if(1) // use base64 - { - const unsigned char* src = (const unsigned char*)data; - ret = "base64:"; - for(int n; len > 0; len -= n) - { - unsigned char input[3] = {0,0,0}; - for(n=0; n<3 && n> 2 ], - Base64Table[ ((input[0] & 0x03) << 4) | (input[1] >> 4) ], - n<2 ? '=' : Base64Table[ ((input[1] & 0x0F) << 2) | (input[2] >> 6) ], - n<3 ? '=' : Base64Table[ input[2] & 0x3F ] - }; - ret.append(output, output+4); - } - } - else // use hex - { - ret.resize(len*2+2); - ret[0] = '0'; - ret[1] = 'x'; - for(int i=0;i>4); - int b = (((const unsigned char*)data)[i])&15; - if(a>9) a += 'A'-10; - else a += '0'; - if(b>9) b += 'A'-10; - else b += '0'; - ret[2+i*2] = a; - ret[2+i*2+1] = b; - } - } - return ret; -} - -///returns -1 if this is not a hex string -int HexStringToBytesLength(const std::string& str) -{ - if(str.size()>2 && str[0] == '0' && toupper(str[1]) == 'X') - return str.size()/2-1; - else return -1; -} - -int Base64StringToBytesLength(const std::string& str) -{ - if(str.size() < 7 || (str.size()-7) % 4 || str.substr(0,7) != "base64:") return -1; - - size_t c = ((str.size() - 7) / 4) * 3; - if(str[str.size()-1] == '=') { --c; - if(str[str.size()-2] == '=') --c; } - return c; -} - -///parses a string in the same format as BytesToString -///returns true if success. -bool StringToBytes(const std::string& str, void* data, int len) -{ - if(str.substr(0,7) == "base64:") - { - // base64 - unsigned char* tgt = (unsigned char*)data; - for(size_t pos = 7; pos < str.size() && len > 0; ) - { - unsigned char input[4], converted[4]; - for(int i=0; i<4; ++i) - { - if(pos >= str.size() && i > 0) return false; // invalid data - input[i] = str[pos++]; - if(input[i] & 0x80) return false; // illegal character - converted[i] = Base64Table[input[i]^0x80]; - if(converted[i] & 0x80) return false; // illegal character - } - unsigned char outpacket[3] = - { - (converted[0] << 2) | (converted[1] >> 4), - (converted[1] << 4) | (converted[2] >> 2), - (converted[2] << 6) | (converted[3]) - }; - int outlen = (input[2] == '=') ? 1 : (input[3] == '=' ? 2 : 3); - if(outlen > len) outlen = len; - memcpy(tgt, outpacket, outlen); - tgt += outlen; - len -= outlen; - } - return true; - } - if(str.size()>2 && str[0] == '0' && toupper(str[1]) == 'X') - { - // hex - int amt = len; - int bytesAvailable = str.size()/2; - if(bytesAvailable < amt) - amt = bytesAvailable; - const char* cstr = str.c_str()+2; - for(int i=0;i='A') a=a-'A'+10; - else a-='0'; - if(b>='A') b=b-'A'+10; - else b-='0'; - unsigned char val = ((unsigned char)a<<4)|(unsigned char)b; - ((unsigned char*)data)[i] = val; - } - return true; - } - - if(len==1) { - int x = atoi(str.c_str()); - *(unsigned char*)data = x; - return true; - } else if(len==2) { - int x = atoi(str.c_str()); - *(unsigned short*)data = x; - return true; - } else if(len==4) { - int x = atoi(str.c_str()); - *(unsigned int*)data = x; - return true; - } - //we can't handle it - return false; -} - -#include -#include -/// \brief convert input string into vector of string tokens -/// -/// \note consecutive delimiters will be treated as single delimiter -/// \note delimiters are _not_ included in return data -/// -/// \param input string to be parsed -/// \param delims list of delimiters. - -std::vector tokenize_str(const std::string & str, - const std::string & delims=", \t") -{ - using namespace std; - // Skip delims at beginning, find start of first token - string::size_type lastPos = str.find_first_not_of(delims, 0); - // Find next delimiter @ end of token - string::size_type pos = str.find_first_of(delims, lastPos); - - // output vector - vector tokens; - - while (string::npos != pos || string::npos != lastPos) - { - // Found a token, add it to the vector. - tokens.push_back(str.substr(lastPos, pos - lastPos)); - // Skip delims. Note the "not_of". this is beginning of token - lastPos = str.find_first_not_of(delims, pos); - // Find next delimiter at end of token. - pos = str.find_first_of(delims, lastPos); - } - - return tokens; -} - -//this code was taken from WINE (LGPL) -//http://google.com/codesearch?hl=en&q=+lang:c+splitpath+show:CPvw9Z-euls:_RSotQzmLeU:KGzljMEYFbY&sa=N&cd=9&ct=rc&cs_p=http://gentoo.osuosl.org/distfiles/Wine-20050524.tar.gz&cs_f=wine-20050524/programs/winefile/splitpath.c -void splitpath(const char* path, char* drv, char* dir, char* name, char* ext) -{ - const char* end; /* end of processed string */ - const char* p; /* search pointer */ - const char* s; /* copy pointer */ - - /* extract drive name */ - if (path[0] && path[1]==':') { - if (drv) { - *drv++ = *path++; - *drv++ = *path++; - *drv = '\0'; - } else path+=2; - } else if (drv) - *drv = '\0'; - - /* search for end of string or stream separator */ - for(end=path; *end && *end!=':'; ) - end++; - - /* search for begin of file extension */ - for(p=end; p>path && *--p!='\\' && *p!='/'; ) - if (*p == '.') { - end = p; - break; - } - - if (ext) - for(s=end; (*ext=*s++); ) - ext++; - else - for(s=end; *s++; ) {} - - /* search for end of directory name */ - for(p=end; p>path; ) - if (*--p=='\\' || *p=='/') { - p++; - break; - } - - if (name) { - for(s=p; s= '0' && s[i] <= '9') - { - v+=s[i]-'0'; - } - else if(s[i] >= 'a' && s[i] <= 'f') - { - v+=s[i]-'a'+10; - } - else if(s[i] >= 'A' && s[i] <= 'F') - { - v+=s[i]-'A'+10; - } - else - { - valid = false; - return 0xFFFF; - } - } - valid = true; - return v; -} - -char *U8ToDecStr(uint8 a) -{ - TempArray[0] = '0' + a/100; - TempArray[1] = '0' + (a%100)/10; - TempArray[2] = '0' + (a%10); - TempArray[3] = 0; - return TempArray; -} - -char *U16ToDecStr(uint16 a) -{ - TempArray[0] = '0' + a/10000; - TempArray[1] = '0' + (a%10000)/1000; - TempArray[2] = '0' + (a%1000)/100; - TempArray[3] = '0' + (a%100)/10; - TempArray[4] = '0' + (a%10); - TempArray[5] = 0; - return TempArray; -} - -char *U32ToDecStr(char* buf, uint32 a) -{ - buf[0] = '0' + a/1000000000; - buf[1] = '0' + (a%1000000000)/100000000; - buf[2] = '0' + (a%100000000)/10000000; - buf[3] = '0' + (a%10000000)/1000000; - buf[4] = '0' + (a%1000000)/100000; - buf[5] = '0' + (a%100000)/10000; - buf[6] = '0' + (a%10000)/1000; - buf[7] = '0' + (a%1000)/100; - buf[8] = '0' + (a%100)/10; - buf[9] = '0' + (a%10); - buf[10] = 0; - return buf; -} -char *U32ToDecStr(uint32 a) -{ - return U32ToDecStr(TempArray,a); -} - -char *U16ToHexStr(uint16 a) -{ - TempArray[0] = a/4096 > 9?'A'+a/4096-10:'0' + a/4096; - TempArray[1] = (a%4096)/256 > 9?'A'+(a%4096)/256 - 10:'0' + (a%4096)/256; - TempArray[2] = (a%256)/16 > 9?'A'+(a%256)/16 - 10:'0' + (a%256)/16; - TempArray[3] = a%16 > 9?'A'+(a%16) - 10:'0' + (a%16); - TempArray[4] = 0; - return TempArray; -} - -char *U8ToHexStr(uint8 a) -{ - TempArray[0] = a/16 > 9?'A'+a/16 - 10:'0' + a/16; - TempArray[1] = a%16 > 9?'A'+(a%16) - 10:'0' + (a%16); - TempArray[2] = 0; - return TempArray; -} - -std::string stditoa(int n) -{ - char tempbuf[16]; - sprintf(tempbuf, "%d", n); - return tempbuf; -} - - -std::string readNullTerminatedAscii(std::istream* is) -{ - std::string ret; - ret.reserve(50); - for(;;) - { - int c = is->get(); - if(c == 0) break; - else ret += (char)c; - } - return ret; -} - -// replace all instances of victim with replacement -std::string mass_replace(const std::string &source, const std::string &victim, const std::string &replacement) -{ - std::string answer = source; - std::string::size_type j = 0; - while ((j = answer.find(victim, j)) != std::string::npos ) - answer.replace(j, victim.length(), replacement); - return answer; -} - -//http://www.codeproject.com/KB/string/UtfConverter.aspx -#include "ConvertUTF.h" -namespace UtfConverter -{ - static std::wstring FromUtf8(const std::string& utf8string) - { - size_t widesize = utf8string.length(); - if (sizeof(wchar_t) == 2) - { - wchar_t* widestringnative = new wchar_t[widesize+1]; - const UTF8* sourcestart = reinterpret_cast(utf8string.c_str()); - const UTF8* sourceend = sourcestart + widesize; - UTF16* targetstart = reinterpret_cast(widestringnative); - UTF16* targetend = targetstart + widesize+1; - ConversionResult res = ConvertUTF8toUTF16(&sourcestart, sourceend, &targetstart, targetend, strictConversion); - if (res != conversionOK) - { - delete [] widestringnative; - throw std::exception(); - } - *targetstart = 0; - std::wstring resultstring(widestringnative); - delete [] widestringnative; - return resultstring; - } - else if (sizeof(wchar_t) == 4) - { - wchar_t* widestringnative = new wchar_t[widesize+1]; - const UTF8* sourcestart = reinterpret_cast(utf8string.c_str()); - const UTF8* sourceend = sourcestart + widesize; - UTF32* targetstart = reinterpret_cast(widestringnative); - UTF32* targetend = targetstart + widesize; - ConversionResult res = ConvertUTF8toUTF32(&sourcestart, sourceend, &targetstart, targetend, strictConversion); - if (res != conversionOK) - { - delete [] widestringnative; - throw std::exception(); - } - *targetstart = 0; - std::wstring resultstring(widestringnative); - delete [] widestringnative; - return resultstring; - } - else - { - throw std::exception(); - } - return L""; - } - - static std::string ToUtf8(const std::wstring& widestring) - { - size_t widesize = widestring.length(); - - if (sizeof(wchar_t) == 2) - { - size_t utf8size = 3 * widesize + 1; - char* utf8stringnative = new char[utf8size]; - const UTF16* sourcestart = reinterpret_cast(widestring.c_str()); - const UTF16* sourceend = sourcestart + widesize; - UTF8* targetstart = reinterpret_cast(utf8stringnative); - UTF8* targetend = targetstart + utf8size; - ConversionResult res = ConvertUTF16toUTF8(&sourcestart, sourceend, &targetstart, targetend, strictConversion); - if (res != conversionOK) - { - delete [] utf8stringnative; - throw std::exception(); - } - *targetstart = 0; - std::string resultstring(utf8stringnative); - delete [] utf8stringnative; - return resultstring; - } - else if (sizeof(wchar_t) == 4) - { - size_t utf8size = 4 * widesize + 1; - char* utf8stringnative = new char[utf8size]; - const UTF32* sourcestart = reinterpret_cast(widestring.c_str()); - const UTF32* sourceend = sourcestart + widesize; - UTF8* targetstart = reinterpret_cast(utf8stringnative); - UTF8* targetend = targetstart + utf8size; - ConversionResult res = ConvertUTF32toUTF8(&sourcestart, sourceend, &targetstart, targetend, strictConversion); - if (res != conversionOK) - { - delete [] utf8stringnative; - throw std::exception(); - } - *targetstart = 0; - std::string resultstring(utf8stringnative); - delete [] utf8stringnative; - return resultstring; - } - else - { - throw std::exception(); - } - return ""; - } -} - -//convert a std::string to std::wstring -std::wstring mbstowcs(std::string str) -{ - try { - return UtfConverter::FromUtf8(str); - } catch(std::exception) { - return L"(failed UTF-8 conversion)"; - } -} - -std::string wcstombs(std::wstring str) -{ - return UtfConverter::ToUtf8(str); -} - - -//TODO - dont we already have another function that can do this -std::string getExtension(const char* input) { - char buf[1024]; - strcpy(buf,input); - char* dot=strrchr(buf,'.'); - if(!dot) - return ""; - char ext [512]; - strcpy(ext, dot+1); - int k, extlen=strlen(ext); - for(k=0;k + +//a vc-style substring operation (very kind and lenient) +std::string strsub(const std::string& str, int pos, int len) { + int strlen = str.size(); + + if(strlen==0) return str; //empty strings always return empty strings + if(pos>=strlen) return str; //if you start past the end of the string, return the entire string. this is unusual, but there you have it + + //clipping + if(pos<0) { + len += pos; + pos = 0; + } + + if (pos+len>=strlen) + len=strlen-pos+1; + + //return str.str().substr(pos,len); + return str.substr(pos,len); +} + +std::string strmid(const std::string& str, int pos, int len) { return strsub(str,pos,len); } +std::string strleft(const std::string& str, int len) { return strsub(str,0,len); } +std::string strright(const std::string& str, int len) { return len ? strsub(str,str.size()-len,len) : ""; } +std::string toupper(const std::string& str) +{ + std::string ret = str; + for(u32 i=0;i= 'a') && (str[i] <= 'z')) { + str[i] &= ~0x20; + j++; + } + i++; + } + return j; +} + + +///Lower case routine. Returns number of characters modified +int str_lcase(char *str) { + u32 i=0,j=0; + + while (i < strlen(str)) { + if ((str[i] >= 'A') && (str[i] <= 'Z')) { + str[i] |= 0x20; + j++; + } + i++; + } + return j; +} + + +///White space-trimming routine + +///Removes whitespace from left side of string, depending on the flags set (See STRIP_x definitions in xstring.h) +///Returns number of characters removed +int str_ltrim(char *str, int flags) { + u32 i=0; + + while (str[0]) { + if ((str[0] != ' ') || (str[0] != '\t') || (str[0] != '\r') || (str[0] != '\n')) break; + + if ((flags & STRIP_SP) && (str[0] == ' ')) { + i++; + strcpy(str,str+1); + } + if ((flags & STRIP_TAB) && (str[0] == '\t')) { + i++; + strcpy(str,str+1); + } + if ((flags & STRIP_CR) && (str[0] == '\r')) { + i++; + strcpy(str,str+1); + } + if ((flags & STRIP_LF) && (str[0] == '\n')) { + i++; + strcpy(str,str+1); + } + } + return i; +} + + +///White space-trimming routine + +///Removes whitespace from right side of string, depending on the flags set (See STRIP_x definitions in xstring.h) +///Returns number of characters removed +int str_rtrim(char *str, int flags) { + u32 i=0; + + while (strlen(str)) { + if ((str[strlen(str)-1] != ' ') || + (str[strlen(str)-1] != '\t') || + (str[strlen(str)-1] != '\r') || + (str[strlen(str)-1] != '\n')) break; + + if ((flags & STRIP_SP) && (str[0] == ' ')) { + i++; + str[strlen(str)-1] = 0; + } + if ((flags & STRIP_TAB) && (str[0] == '\t')) { + i++; + str[strlen(str)-1] = 0; + } + if ((flags & STRIP_CR) && (str[0] == '\r')) { + i++; + str[strlen(str)-1] = 0; + } + if ((flags & STRIP_LF) && (str[0] == '\n')) { + i++; + str[strlen(str)-1] = 0; + } + } + return i; +} + + +///White space-stripping routine + +///Removes whitespace depending on the flags set (See STRIP_x definitions in xstring.h) +///Returns number of characters removed, or -1 on error +int str_strip(char *str, int flags) { + u32 i=0,j=0; + char *astr,chr; + + if (!strlen(str)) return -1; + if (!(flags & (STRIP_SP|STRIP_TAB|STRIP_CR|STRIP_LF))) return -1; + if (!(astr = (char*)malloc(strlen(str)+1))) return -1; + while (i < strlen(str)) { + chr = str[i++]; + if ((flags & STRIP_SP) && (chr == ' ')) chr = 0; + if ((flags & STRIP_TAB) && (chr == '\t')) chr = 0; + if ((flags & STRIP_CR) && (chr == '\r')) chr = 0; + if ((flags & STRIP_LF) && (chr == '\n')) chr = 0; + + if (chr) astr[j++] = chr; + } + astr[j] = 0; + strcpy(str,astr); + free(astr); + return j; +} + + +///Character replacement routine + +///Replaces all instances of 'search' with 'replace' +///Returns number of characters modified +int chr_replace(char *str, char search, char replace) { + u32 i=0,j=0; + + while (i < strlen(str)) { + if (str[i] == search) { + str[i] = replace; + j++; + } + i++; + } + return j; +} + + +///Sub-String replacement routine + +///Replaces all instances of 'search' with 'replace' +///Returns number of sub-strings modified, or -1 on error +int str_replace(char *str, char *search, char *replace) { + u32 i=0,j=0; + int searchlen,replacelen; + char *astr; + + searchlen = strlen(search); + replacelen = strlen(replace); + if ((!strlen(str)) || (!searchlen)) return -1; //note: allow *replace to have a length of zero! + if (!(astr = (char*)malloc(strlen(str)+1))) return -1; + while (i < strlen(str)) { + if (!strncmp(str+i,search,searchlen)) { + if (replacelen) memcpy(astr+j,replace,replacelen); + i += searchlen; + j += replacelen; + } + else astr[j++] = str[i++]; + } + astr[j] = 0; + strcpy(str,astr); + free(astr); + return j; +} + +static const struct Base64Table +{ + Base64Table() + { + size_t a=0; + for(a=0; a<256; ++a) data[a] = 0xFF; // mark everything as invalid by default + // create value->ascii mapping + a=0; + for(unsigned char c='A'; c<='Z'; ++c) data[a++] = c; // 0..25 + for(unsigned char c='a'; c<='z'; ++c) data[a++] = c; // 26..51 + for(unsigned char c='0'; c<='9'; ++c) data[a++] = c; // 52..61 + data[62] = '+'; // 62 + data[63] = '/'; // 63 + // create ascii->value mapping (but due to overlap, write it to highbit region) + for(a=0; a<64; ++a) data[data[a]^0x80] = a; // + data[((unsigned char)'=') ^ 0x80] = 0; + } + unsigned char operator[] (size_t pos) const { return data[pos]; } +private: + unsigned char data[256]; +} Base64Table; + +std::string u32ToHexString(u32 val) +{ + char temp[16]; + sprintf(temp,"%08X",val); + return temp; +} + +///Converts the provided data to a string in a standard, user-friendly, round-trippable format +std::string BytesToString(const void* data, int len) +{ + char temp[16]; + if(len==1) { + sprintf(temp,"%d",*(const unsigned char*)data); + return temp; + } else if(len==2) { + sprintf(temp,"%d",*(const unsigned short*)data); + return temp; + } else if(len==4) { + sprintf(temp,"%d",*(const unsigned int*)data); + return temp; + } + + std::string ret; + if(1) // use base64 + { + const unsigned char* src = (const unsigned char*)data; + ret = "base64:"; + for(int n; len > 0; len -= n) + { + unsigned char input[3] = {0,0,0}; + for(n=0; n<3 && n> 2 ], + Base64Table[ ((input[0] & 0x03) << 4) | (input[1] >> 4) ], + n<2 ? '=' : Base64Table[ ((input[1] & 0x0F) << 2) | (input[2] >> 6) ], + n<3 ? '=' : Base64Table[ input[2] & 0x3F ] + }; + ret.append(output, output+4); + } + } + else // use hex + { + ret.resize(len*2+2); + ret[0] = '0'; + ret[1] = 'x'; + for(int i=0;i>4); + int b = (((const unsigned char*)data)[i])&15; + if(a>9) a += 'A'-10; + else a += '0'; + if(b>9) b += 'A'-10; + else b += '0'; + ret[2+i*2] = a; + ret[2+i*2+1] = b; + } + } + return ret; +} + +///returns -1 if this is not a hex string +int HexStringToBytesLength(const std::string& str) +{ + if(str.size()>2 && str[0] == '0' && toupper(str[1]) == 'X') + return str.size()/2-1; + else return -1; +} + +int Base64StringToBytesLength(const std::string& str) +{ + if(str.size() < 7 || (str.size()-7) % 4 || str.substr(0,7) != "base64:") return -1; + + size_t c = ((str.size() - 7) / 4) * 3; + if(str[str.size()-1] == '=') { --c; + if(str[str.size()-2] == '=') --c; } + return c; +} + +///parses a string in the same format as BytesToString +///returns true if success. +bool StringToBytes(const std::string& str, void* data, int len) +{ + if(str.substr(0,7) == "base64:") + { + // base64 + unsigned char* tgt = (unsigned char*)data; + for(size_t pos = 7; pos < str.size() && len > 0; ) + { + unsigned char input[4], converted[4]; + for(int i=0; i<4; ++i) + { + if(pos >= str.size() && i > 0) return false; // invalid data + input[i] = str[pos++]; + if(input[i] & 0x80) return false; // illegal character + converted[i] = Base64Table[input[i]^0x80]; + if(converted[i] & 0x80) return false; // illegal character + } + unsigned char outpacket[3] = + { + (converted[0] << 2) | (converted[1] >> 4), + (converted[1] << 4) | (converted[2] >> 2), + (converted[2] << 6) | (converted[3]) + }; + int outlen = (input[2] == '=') ? 1 : (input[3] == '=' ? 2 : 3); + if(outlen > len) outlen = len; + memcpy(tgt, outpacket, outlen); + tgt += outlen; + len -= outlen; + } + return true; + } + if(str.size()>2 && str[0] == '0' && toupper(str[1]) == 'X') + { + // hex + int amt = len; + int bytesAvailable = str.size()/2; + if(bytesAvailable < amt) + amt = bytesAvailable; + const char* cstr = str.c_str()+2; + for(int i=0;i='A') a=a-'A'+10; + else a-='0'; + if(b>='A') b=b-'A'+10; + else b-='0'; + unsigned char val = ((unsigned char)a<<4)|(unsigned char)b; + ((unsigned char*)data)[i] = val; + } + return true; + } + + if(len==1) { + int x = atoi(str.c_str()); + *(unsigned char*)data = x; + return true; + } else if(len==2) { + int x = atoi(str.c_str()); + *(unsigned short*)data = x; + return true; + } else if(len==4) { + int x = atoi(str.c_str()); + *(unsigned int*)data = x; + return true; + } + //we can't handle it + return false; +} + +#include +#include +/// \brief convert input string into vector of string tokens +/// +/// \note consecutive delimiters will be treated as single delimiter +/// \note delimiters are _not_ included in return data +/// +/// \param input string to be parsed +/// \param delims list of delimiters. + +std::vector tokenize_str(const std::string & str, + const std::string & delims=", \t") +{ + using namespace std; + // Skip delims at beginning, find start of first token + string::size_type lastPos = str.find_first_not_of(delims, 0); + // Find next delimiter @ end of token + string::size_type pos = str.find_first_of(delims, lastPos); + + // output vector + vector tokens; + + while (string::npos != pos || string::npos != lastPos) + { + // Found a token, add it to the vector. + tokens.push_back(str.substr(lastPos, pos - lastPos)); + // Skip delims. Note the "not_of". this is beginning of token + lastPos = str.find_first_not_of(delims, pos); + // Find next delimiter at end of token. + pos = str.find_first_of(delims, lastPos); + } + + return tokens; +} + +//this code was taken from WINE (LGPL) +//http://google.com/codesearch?hl=en&q=+lang:c+splitpath+show:CPvw9Z-euls:_RSotQzmLeU:KGzljMEYFbY&sa=N&cd=9&ct=rc&cs_p=http://gentoo.osuosl.org/distfiles/Wine-20050524.tar.gz&cs_f=wine-20050524/programs/winefile/splitpath.c +void splitpath(const char* path, char* drv, char* dir, char* name, char* ext) +{ + const char* end; /* end of processed string */ + const char* p; /* search pointer */ + const char* s; /* copy pointer */ + + /* extract drive name */ + if (path[0] && path[1]==':') { + if (drv) { + *drv++ = *path++; + *drv++ = *path++; + *drv = '\0'; + } else path+=2; + } else if (drv) + *drv = '\0'; + + /* search for end of string or stream separator */ + for(end=path; *end && *end!=':'; ) + end++; + + /* search for begin of file extension */ + for(p=end; p>path && *--p!='\\' && *p!='/'; ) + if (*p == '.') { + end = p; + break; + } + + if (ext) + for(s=end; (*ext=*s++); ) + ext++; + else + for(s=end; *s++; ) {} + + /* search for end of directory name */ + for(p=end; p>path; ) + if (*--p=='\\' || *p=='/') { + p++; + break; + } + + if (name) { + for(s=p; s= '0' && s[i] <= '9') + { + v+=s[i]-'0'; + } + else if(s[i] >= 'a' && s[i] <= 'f') + { + v+=s[i]-'a'+10; + } + else if(s[i] >= 'A' && s[i] <= 'F') + { + v+=s[i]-'A'+10; + } + else + { + valid = false; + return 0xFFFF; + } + } + valid = true; + return v; +} + +char *U8ToDecStr(uint8 a) +{ + TempArray[0] = '0' + a/100; + TempArray[1] = '0' + (a%100)/10; + TempArray[2] = '0' + (a%10); + TempArray[3] = 0; + return TempArray; +} + +char *U16ToDecStr(uint16 a) +{ + TempArray[0] = '0' + a/10000; + TempArray[1] = '0' + (a%10000)/1000; + TempArray[2] = '0' + (a%1000)/100; + TempArray[3] = '0' + (a%100)/10; + TempArray[4] = '0' + (a%10); + TempArray[5] = 0; + return TempArray; +} + +char *U32ToDecStr(char* buf, uint32 a) +{ + buf[0] = '0' + a/1000000000; + buf[1] = '0' + (a%1000000000)/100000000; + buf[2] = '0' + (a%100000000)/10000000; + buf[3] = '0' + (a%10000000)/1000000; + buf[4] = '0' + (a%1000000)/100000; + buf[5] = '0' + (a%100000)/10000; + buf[6] = '0' + (a%10000)/1000; + buf[7] = '0' + (a%1000)/100; + buf[8] = '0' + (a%100)/10; + buf[9] = '0' + (a%10); + buf[10] = 0; + return buf; +} +char *U32ToDecStr(uint32 a) +{ + return U32ToDecStr(TempArray,a); +} + +char *U16ToHexStr(uint16 a) +{ + TempArray[0] = a/4096 > 9?'A'+a/4096-10:'0' + a/4096; + TempArray[1] = (a%4096)/256 > 9?'A'+(a%4096)/256 - 10:'0' + (a%4096)/256; + TempArray[2] = (a%256)/16 > 9?'A'+(a%256)/16 - 10:'0' + (a%256)/16; + TempArray[3] = a%16 > 9?'A'+(a%16) - 10:'0' + (a%16); + TempArray[4] = 0; + return TempArray; +} + +char *U8ToHexStr(uint8 a) +{ + TempArray[0] = a/16 > 9?'A'+a/16 - 10:'0' + a/16; + TempArray[1] = a%16 > 9?'A'+(a%16) - 10:'0' + (a%16); + TempArray[2] = 0; + return TempArray; +} + +std::string stditoa(int n) +{ + char tempbuf[16]; + sprintf(tempbuf, "%d", n); + return tempbuf; +} + + +std::string readNullTerminatedAscii(std::istream* is) +{ + std::string ret; + ret.reserve(50); + for(;;) + { + int c = is->get(); + if(c == 0) break; + else ret += (char)c; + } + return ret; +} + +// replace all instances of victim with replacement +std::string mass_replace(const std::string &source, const std::string &victim, const std::string &replacement) +{ + std::string answer = source; + std::string::size_type j = 0; + while ((j = answer.find(victim, j)) != std::string::npos ) + answer.replace(j, victim.length(), replacement); + return answer; +} + +//http://www.codeproject.com/KB/string/UtfConverter.aspx +#include "ConvertUTF.h" +namespace UtfConverter +{ + static std::wstring FromUtf8(const std::string& utf8string) + { + size_t widesize = utf8string.length(); + if (sizeof(wchar_t) == 2) + { + wchar_t* widestringnative = new wchar_t[widesize+1]; + const UTF8* sourcestart = reinterpret_cast(utf8string.c_str()); + const UTF8* sourceend = sourcestart + widesize; + UTF16* targetstart = reinterpret_cast(widestringnative); + UTF16* targetend = targetstart + widesize+1; + ConversionResult res = ConvertUTF8toUTF16(&sourcestart, sourceend, &targetstart, targetend, strictConversion); + if (res != conversionOK) + { + delete [] widestringnative; + throw std::exception(); + } + *targetstart = 0; + std::wstring resultstring(widestringnative); + delete [] widestringnative; + return resultstring; + } + else if (sizeof(wchar_t) == 4) + { + wchar_t* widestringnative = new wchar_t[widesize+1]; + const UTF8* sourcestart = reinterpret_cast(utf8string.c_str()); + const UTF8* sourceend = sourcestart + widesize; + UTF32* targetstart = reinterpret_cast(widestringnative); + UTF32* targetend = targetstart + widesize; + ConversionResult res = ConvertUTF8toUTF32(&sourcestart, sourceend, &targetstart, targetend, strictConversion); + if (res != conversionOK) + { + delete [] widestringnative; + throw std::exception(); + } + *targetstart = 0; + std::wstring resultstring(widestringnative); + delete [] widestringnative; + return resultstring; + } + else + { + throw std::exception(); + } + return L""; + } + + static std::string ToUtf8(const std::wstring& widestring) + { + size_t widesize = widestring.length(); + + if (sizeof(wchar_t) == 2) + { + size_t utf8size = 3 * widesize + 1; + char* utf8stringnative = new char[utf8size]; + const UTF16* sourcestart = reinterpret_cast(widestring.c_str()); + const UTF16* sourceend = sourcestart + widesize; + UTF8* targetstart = reinterpret_cast(utf8stringnative); + UTF8* targetend = targetstart + utf8size; + ConversionResult res = ConvertUTF16toUTF8(&sourcestart, sourceend, &targetstart, targetend, strictConversion); + if (res != conversionOK) + { + delete [] utf8stringnative; + throw std::exception(); + } + *targetstart = 0; + std::string resultstring(utf8stringnative); + delete [] utf8stringnative; + return resultstring; + } + else if (sizeof(wchar_t) == 4) + { + size_t utf8size = 4 * widesize + 1; + char* utf8stringnative = new char[utf8size]; + const UTF32* sourcestart = reinterpret_cast(widestring.c_str()); + const UTF32* sourceend = sourcestart + widesize; + UTF8* targetstart = reinterpret_cast(utf8stringnative); + UTF8* targetend = targetstart + utf8size; + ConversionResult res = ConvertUTF32toUTF8(&sourcestart, sourceend, &targetstart, targetend, strictConversion); + if (res != conversionOK) + { + delete [] utf8stringnative; + throw std::exception(); + } + *targetstart = 0; + std::string resultstring(utf8stringnative); + delete [] utf8stringnative; + return resultstring; + } + else + { + throw std::exception(); + } + return ""; + } +} + +//convert a std::string to std::wstring +std::wstring mbstowcs(std::string str) +{ + try { + return UtfConverter::FromUtf8(str); + } catch(std::exception) { + return L"(failed UTF-8 conversion)"; + } +} + +std::string wcstombs(std::wstring str) +{ + return UtfConverter::ToUtf8(str); +} + + +//TODO - dont we already have another function that can do this +std::string getExtension(const char* input) { + char buf[1024]; + strcpy(buf,input); + char* dot=strrchr(buf,'.'); + if(!dot) + return ""; + char ext [512]; + strcpy(ext, dot+1); + int k, extlen=strlen(ext); + for(k=0;k -#include -#include -#include -#include -#include - -#include "../types.h" - - -//definitions for str_strip() flags -#define STRIP_SP 0x01 // space -#define STRIP_TAB 0x02 // tab -#define STRIP_CR 0x04 // carriage return -#define STRIP_LF 0x08 // line feed - - -int str_ucase(char *str); -int str_lcase(char *str); -int str_ltrim(char *str, int flags); -int str_rtrim(char *str, int flags); -int str_strip(char *str, int flags); -int chr_replace(char *str, char search, char replace); -int str_replace(char *str, char *search, char *replace); - -std::string strsub(const std::string& str, int pos, int len); -std::string strmid(const std::string& str, int pos, int len); -std::string strleft(const std::string& str, int len); -std::string strright(const std::string& str, int len); -std::string toupper(const std::string& str); - -int HexStringToBytesLength(const std::string& str); -int Base64StringToBytesLength(const std::string& str); -std::string u32ToHexString(u32 val); -std::string BytesToString(const void* data, int len); -bool StringToBytes(const std::string& str, void* data, int len); - -std::vector tokenize_str(const std::string & str,const std::string & delims); -void splitpath(const char* path, char* drv, char* dir, char* name, char* ext); - -uint16 FastStrToU16(char* s, bool& valid); -char *U16ToDecStr(uint16 a); -char *U32ToDecStr(uint32 a); -char *U32ToDecStr(char* buf, uint32 a); -char *U8ToDecStr(uint8 a); -char *U8ToHexStr(uint8 a); -char *U16ToHexStr(uint16 a); - -std::string stditoa(int n); - -std::string readNullTerminatedAscii(std::istream* is); - -//extracts a decimal uint from an istream -template T templateIntegerDecFromIstream(std::istream* is) -{ - unsigned int ret = 0; - bool pre = true; - - for(;;) - { - int c = is->get(); - if(c == -1) return ret; - int d = c - '0'; - if((d<0 || d>9)) - { - if(!pre) - break; - } - else - { - pre = false; - ret *= 10; - ret += d; - } - } - is->unget(); - return ret; -} - -inline u32 u32DecFromIstream(std::istream* is) { return templateIntegerDecFromIstream(is); } -inline u64 u64DecFromIstream(std::istream* is) { return templateIntegerDecFromIstream(is); } - -//puts an optionally 0-padded decimal integer of type T into the ostream (0-padding is quicker) -template void putdec(std::ostream* os, T dec) -{ - char temp[DIGITS]; - int ctr = 0; - for(int i=0;iwrite(temp+DIGITS-ctr-1,ctr+1); - else - os->write(temp,DIGITS); -} - -std::string mass_replace(const std::string &source, const std::string &victim, const std::string &replacement); - -std::wstring mbstowcs(std::string str); -std::string wcstombs(std::wstring str); - - - -//TODO - dont we already have another function that can do this -std::string getExtension(const char* input); - - -#endif +//taken from fceux on 10/27/08 + +#ifndef _STRINGUTIL_H_ +#define _STRINGUTIL_H_ + +#include +#include +#include +#include +#include +#include + +#include "../types.h" + + +//definitions for str_strip() flags +#define STRIP_SP 0x01 // space +#define STRIP_TAB 0x02 // tab +#define STRIP_CR 0x04 // carriage return +#define STRIP_LF 0x08 // line feed + + +int str_ucase(char *str); +int str_lcase(char *str); +int str_ltrim(char *str, int flags); +int str_rtrim(char *str, int flags); +int str_strip(char *str, int flags); +int chr_replace(char *str, char search, char replace); +int str_replace(char *str, char *search, char *replace); + +std::string strsub(const std::string& str, int pos, int len); +std::string strmid(const std::string& str, int pos, int len); +std::string strleft(const std::string& str, int len); +std::string strright(const std::string& str, int len); +std::string toupper(const std::string& str); + +int HexStringToBytesLength(const std::string& str); +int Base64StringToBytesLength(const std::string& str); +std::string u32ToHexString(u32 val); +std::string BytesToString(const void* data, int len); +bool StringToBytes(const std::string& str, void* data, int len); + +std::vector tokenize_str(const std::string & str,const std::string & delims); +void splitpath(const char* path, char* drv, char* dir, char* name, char* ext); + +uint16 FastStrToU16(char* s, bool& valid); +char *U16ToDecStr(uint16 a); +char *U32ToDecStr(uint32 a); +char *U32ToDecStr(char* buf, uint32 a); +char *U8ToDecStr(uint8 a); +char *U8ToHexStr(uint8 a); +char *U16ToHexStr(uint16 a); + +std::string stditoa(int n); + +std::string readNullTerminatedAscii(std::istream* is); + +//extracts a decimal uint from an istream +template T templateIntegerDecFromIstream(std::istream* is) +{ + unsigned int ret = 0; + bool pre = true; + + for(;;) + { + int c = is->get(); + if(c == -1) return ret; + int d = c - '0'; + if((d<0 || d>9)) + { + if(!pre) + break; + } + else + { + pre = false; + ret *= 10; + ret += d; + } + } + is->unget(); + return ret; +} + +inline u32 u32DecFromIstream(std::istream* is) { return templateIntegerDecFromIstream(is); } +inline u64 u64DecFromIstream(std::istream* is) { return templateIntegerDecFromIstream(is); } + +//puts an optionally 0-padded decimal integer of type T into the ostream (0-padding is quicker) +template void putdec(std::ostream* os, T dec) +{ + char temp[DIGITS]; + int ctr = 0; + for(int i=0;iwrite(temp+DIGITS-ctr-1,ctr+1); + else + os->write(temp,DIGITS); +} + +std::string mass_replace(const std::string &source, const std::string &victim, const std::string &replacement); + +std::wstring mbstowcs(std::string str); +std::string wcstombs(std::wstring str); + + + +//TODO - dont we already have another function that can do this +std::string getExtension(const char* input); + + +#endif diff --git a/desmume/src/version.h b/src/version.h similarity index 84% rename from desmume/src/version.h rename to src/version.h index 7ceb38dee..6be8fca07 100644 --- a/desmume/src/version.h +++ b/src/version.h @@ -41,12 +41,8 @@ #endif #endif -#ifndef ENABLE_SSE2 - #ifndef ENABLE_SSE - #define DESMUME_CPUEXT_STRING " NOSSE" - #else - #define DESMUME_CPUEXT_STRING " NOSSE2" - #endif +#ifdef NOSSE2 +#define DESMUME_CPUEXT_STRING " NOSSE2" #else #define DESMUME_CPUEXT_STRING "" #endif @@ -81,6 +77,6 @@ #define DESMUME_COMPILER_DETAIL "" #endif -#define DESMUME_VERSION_NUMERIC 90500 -#define DESMUME_VERSION_STRING " " "0.9.5" DESMUME_SUBVERSION_STRING DESMUME_FEATURE_STRING DESMUME_PLATFORM_STRING DESMUME_CPUEXT_STRING DESMUME_COMPILER +#define DESMUME_VERSION_NUMERIC 90400 +#define DESMUME_VERSION_STRING " " "0.9.4+" DESMUME_SUBVERSION_STRING DESMUME_FEATURE_STRING DESMUME_PLATFORM_STRING DESMUME_CPUEXT_STRING DESMUME_COMPILER #define DESMUME_NAME_AND_VERSION " " DESMUME_NAME DESMUME_VERSION_STRING diff --git a/desmume/src/wifi.cpp b/src/wifi.cpp similarity index 60% rename from desmume/src/wifi.cpp rename to src/wifi.cpp index 4402bcdc5..ec198f31b 100644 --- a/desmume/src/wifi.cpp +++ b/src/wifi.cpp @@ -1,1683 +1,1555 @@ -/* Copyright (C) 2007 Tim Seidel - Copyright (C) 2008-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include "wifi.h" -#include "armcpu.h" -#include "NDSSystem.h" -#include "debug.h" - -#ifdef EXPERIMENTAL_WIFI - -#ifdef WIN32 -#include "windriver.h" -#else -#include "pcap/pcap.h" -#endif - -bool wifi_netEnabled = false; -pcap_t *wifi_bridge = NULL; - -#endif - -wifimac_t wifiMac; - -/******************************************************************************* - - Firmware info needed for if no firmware image is available - see: http://www.akkit.org/info/dswifi.htm#WifiInit - - written in bytes, to avoid endianess issues - - *******************************************************************************/ - -u8 FW_Mac[6] = { 0x00, 0x09, 0xBF, 0x12, 0x34, 0x56 } ; -const u8 FW_WIFIInit[32] = { 0x02,0x00, 0x17,0x00, 0x26,0x00, 0x18,0x18, - 0x48,0x00, 0x40,0x48, 0x58,0x00, 0x42,0x00, - 0x40,0x01, 0x64,0x80, 0xE0,0xE0, 0x43,0x24, - 0x0E,0x00, 0x32,0x00, 0xF4,0x01, 0x01,0x01 } ; -const u8 FW_BBInit[105] = { 0x6D, 0x9E, 0x40, 0x05, - 0x1B, 0x6C, 0x48, 0x80, - 0x38, 0x00, 0x35, 0x07, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0xb0, 0x00, 0x04, 0x01, - 0xd8, 0xff, 0xff, 0xc7, - 0xbb, 0x01, 0xb6, 0x7f, - 0x5a, 0x01, 0x3f, 0x01, - 0x3f, 0x36, 0x36, 0x00, - 0x78, 0x28, 0x55, 0x08, - 0x28, 0x16, 0x00, 0x01, - 0x0e, 0x20, 0x02, 0x98, - 0x98, 0x1f, 0x0a, 0x08, - 0x04, 0x01, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xfe, - 0xfe, 0xfe, 0xfe, 0xfc, - 0xfa, 0xfa, 0xf8, 0xf8, - 0xf6, 0xa5, 0x12, 0x14, - 0x12, 0x41, 0x23, 0x03, - 0x04, 0x70, 0x35, 0x0E, - 0x16, 0x16, 0x00, 0x00, - 0x06, 0x01, 0xff, 0xfe, - 0xff, 0xff, 0x00, 0x0e, - 0x13, 0x00, 0x00, 0x28, - 0x1c - } ; -const u8 FW_RFInit[36] = { 0x07, 0xC0, 0x00, - 0x03, 0x9C, 0x12, - 0x28, 0x17, 0x14, - 0xba, 0xe8, 0x1a, - 0x6f, 0x45, 0x1d, - 0xfa, 0xff, 0x23, - 0x30, 0x1d, 0x24, - 0x01, 0x00, 0x28, - 0x00, 0x00, 0x2c, - 0x03, 0x9c, 0x06, - 0x22, 0x00, 0x08, - 0x6f, 0xff, 0x0d - } ; -const u8 FW_RFChannel[6*14] = { 0x28, 0x17, 0x14, /* Channel 1 */ - 0xba, 0xe8, 0x1a, - 0x37, 0x17, 0x14, /* Channel 2 */ - 0x46, 0x17, 0x19, - 0x45, 0x17, 0x14, /* Channel 3 */ - 0xd1, 0x45, 0x1b, - 0x54, 0x17, 0x14, /* Channel 4 */ - 0x5d, 0x74, 0x19, - 0x62, 0x17, 0x14, /* Channel 5 */ - 0xe9, 0xa2, 0x1b, - 0x71, 0x17, 0x14, /* Channel 6 */ - 0x74, 0xd1, 0x19, - 0x80, 0x17, 0x14, /* Channel 7 */ - 0x00, 0x00, 0x18, - 0x8e, 0x17, 0x14, /* Channel 8 */ - 0x8c, 0x2e, 0x1a, - 0x9d, 0x17, 0x14, /* Channel 9 */ - 0x17, 0x5d, 0x18, - 0xab, 0x17, 0x14, /* Channel 10 */ - 0xa3, 0x8b, 0x1a, - 0xba, 0x17, 0x14, /* Channel 11 */ - 0x2f, 0xba, 0x18, - 0xc8, 0x17, 0x14, /* Channel 12 */ - 0xba, 0xe8, 0x1a, - 0xd7, 0x17, 0x14, /* Channel 13 */ - 0x46, 0x17, 0x19, - 0xfa, 0x17, 0x14, /* Channel 14 */ - 0x2f, 0xba, 0x18 - } ; -const u8 FW_BBChannel[14] = { 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, /* channel 1- 6 */ - 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, /* channel 7-10 */ - 0xb5, 0xb5, /* channel 11-12 */ - 0xb6, 0xb6 /* channel 13-14 */ - } ; - -/* Note : the values are inspired from what I found in a firmware image from my DS */ - -FW_WFCProfile FW_WFCProfile1 = {"SoftAP", - "", - "", - "", - "", - "", - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - 0, - "", - 0, - 0, - 0, - {0, 0, 0, 0, 0, 0, 0}, - 0, - {0xBA, 0xA0, 0x35, 0xE7, 0x01, 0xD0, 0x05, 0xAD, 0x39, 0x0F, 0x40, 0x1C, 0x2B, 0x2C}, - {0, 0} - } ; - -FW_WFCProfile FW_WFCProfile2 = {"", - "", - "", - "", - "", - "", - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - 0, - "", - 0, - 0, - 0xFF, - {0, 0, 0, 0, 0, 0, 0}, - 0, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0} - } ; - -FW_WFCProfile FW_WFCProfile3 = {"", - "", - "", - "", - "", - "", - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - {0, 0, 0, 0}, - 0, - "", - 0, - 0, - 0xFF, - {0, 0, 0, 0, 0, 0, 0}, - 0, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0} - } ; - -#ifdef EXPERIMENTAL_WIFI - -/******************************************************************************* - - Communication interface - - *******************************************************************************/ - -struct WifiComInterface -{ - bool (*Init)(); - void (*DeInit)(); - void (*Reset)(); - void (*SendPacket)(u8* packet, u32 len); - void (*usTrigger)(); -}; - -WifiComInterface* wifiComs[]; -WifiComInterface* wifiCom; - -/******************************************************************************* - - Logging - - *******************************************************************************/ - -// 0: disable logging -// 1: lowest logging, shows most important messages such as errors -// 2: low logging, shows things such as warnings -// 3: medium logging, for debugging, shows lots of stuff -// 4: high logging, for debugging, shows almost everything, may slow down -// 5: highest logging, for debugging, shows everything, may slow down a lot -#define WIFI_LOGGING_LEVEL 0 - -#define WIFI_LOG_USE_LOGC 0 - -#if (WIFI_LOGGING_LEVEL >= 1) - #if WIFI_LOG_USE_LOGC - #define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) LOGC(8, "WIFI: "__VA_ARGS__); - #else - #define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) printf("WIFI: "__VA_ARGS__); - #endif -#else -#define WIFI_LOG(level, ...) {} -#endif - -/******************************************************************************* - - Helpers - - *******************************************************************************/ - -INLINE u32 WIFI_alignedLen(u32 len) -{ - return ((len + 3) & ~3); -} - -#ifdef WIN32 -static pcap_t *desmume_pcap_open(const char *source, int snaplen, int flags, - int read_timeout, char *errbuf) -{ - return PCAP::pcap_open(source, snaplen, flags, read_timeout, NULL, errbuf); -} - -static int desmume_pcap_findalldevs(pcap_if_t **alldevs, char *errbuf) -{ - return PCAP::pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, alldevs, errbuf); -} - -static void desmume_pcap_freealldevs(pcap_if_t *alldevs) -{ - return PCAP::pcap_freealldevs(alldevs); -} - -static void desmume_pcap_close(pcap_t *p) -{ - return PCAP::pcap_close(p); -} - -static int desmume_pcap_sendpacket(pcap_t *p, u_char *buf, int size) -{ - return PCAP::pcap_sendpacket(p, buf, size); -} - -#else -static pcap_t *desmume_pcap_open(const char *device, int snaplen, int promisc, - int to_ms, char *errbuf) -{ - return pcap_open_live(device, snaplen, promisc, to_ms, errbuf); -} - -static int desmume_pcap_findalldevs(pcap_if_t **alldevs, char *errbuf) -{ - return pcap_findalldevs(alldevs, errbuf); -} - -static void desmume_pcap_freealldevs(pcap_if_t *alldevs) -{ - return pcap_freealldevs(alldevs); -} - -static void desmume_pcap_close(pcap_t *p) -{ - return pcap_close(p); -} - -static int desmume_pcap_sendpacket(pcap_t *p, u_char *buf, int size) -{ - return pcap_sendpacket(p, buf, size); -} -#endif - -/******************************************************************************* - - CRC32 (http://www.codeproject.com/KB/recipes/crc32_large.aspx) - - *******************************************************************************/ - -u32 WIFI_CRC32Table[256]; - -static u32 reflect(u32 ref, char ch) -{ - u32 value = 0; - - for(int i = 1; i < (ch + 1); i++) - { - if (ref & 1) - value |= 1 << (ch - i); - ref >>= 1; - } - - return value; -} - -static u32 WIFI_getCRC32(u8 *data, int len) -{ - u32 crc = 0xFFFFFFFF; - - while(len--) - crc = (crc >> 8) ^ WIFI_CRC32Table[(crc & 0xFF) ^ *data++]; - - return (crc ^ 0xFFFFFFFF); -} - -static void WIFI_initCRC32Table() -{ - static bool initialized = false; - if(initialized) return; - initialized = true; - - u32 polynomial = 0x04C11DB7; - - for(int i = 0; i < 0x100; i++) - { - WIFI_CRC32Table[i] = reflect(i, 8) << 24; - for(int j = 0; j < 8; j++) - WIFI_CRC32Table[i] = (WIFI_CRC32Table[i] << 1) ^ (WIFI_CRC32Table[i] & (1 << 31) ? polynomial : 0); - WIFI_CRC32Table[i] = reflect(WIFI_CRC32Table[i], 32); - } -} - -/******************************************************************************* - - RF-Chip - - *******************************************************************************/ - -static void WIFI_resetRF(rffilter_t *rf) { - /* reinitialize RF chip with the default values refer RF2958 docs */ - /* CFG1 */ - rf->CFG1.bits.IF_VGA_REG_EN = 1 ; - rf->CFG1.bits.IF_VCO_REG_EN = 1 ; - rf->CFG1.bits.RF_VCO_REG_EN = 1 ; - rf->CFG1.bits.HYBERNATE = 0 ; - rf->CFG1.bits.REF_SEL = 0 ; - /* IFPLL1 */ - rf->IFPLL1.bits.DAC = 3 ; - rf->IFPLL1.bits.P1 = 0 ; - rf->IFPLL1.bits.LD_EN1 = 0 ; - rf->IFPLL1.bits.AUTOCAL_EN1 = 0 ; - rf->IFPLL1.bits.PDP1 = 1 ; - rf->IFPLL1.bits.CPL1 = 0 ; - rf->IFPLL1.bits.LPF1 = 0 ; - rf->IFPLL1.bits.VTC_EN1 = 1 ; - rf->IFPLL1.bits.KV_EN1 = 0 ; - rf->IFPLL1.bits.PLL_EN1 = 0 ; - /* IFPLL2 */ - rf->IFPLL2.bits.IF_N = 0x22 ; - /* IFPLL3 */ - rf->IFPLL3.bits.KV_DEF1 = 8 ; - rf->IFPLL3.bits.CT_DEF1 = 7 ; - rf->IFPLL3.bits.DN1 = 0x1FF ; - /* RFPLL1 */ - rf->RFPLL1.bits.DAC = 3 ; - rf->RFPLL1.bits.P = 0 ; - rf->RFPLL1.bits.LD_EN = 0 ; - rf->RFPLL1.bits.AUTOCAL_EN = 0 ; - rf->RFPLL1.bits.PDP = 1 ; - rf->RFPLL1.bits.CPL = 0 ; - rf->RFPLL1.bits.LPF = 0 ; - rf->RFPLL1.bits.VTC_EN = 0 ; - rf->RFPLL1.bits.KV_EN = 0 ; - rf->RFPLL1.bits.PLL_EN = 0 ; - /* RFPLL2 */ - rf->RFPLL2.bits.NUM2 = 0 ; - rf->RFPLL2.bits.N2 = 0x5E ; - /* RFPLL3 */ - rf->RFPLL3.bits.NUM2 = 0 ; - /* RFPLL4 */ - rf->RFPLL4.bits.KV_DEF = 8 ; - rf->RFPLL4.bits.CT_DEF = 7 ; - rf->RFPLL4.bits.DN = 0x145 ; - /* CAL1 */ - rf->CAL1.bits.LD_WINDOW = 2 ; - rf->CAL1.bits.M_CT_VALUE = 8 ; - rf->CAL1.bits.TLOCK = 7 ; - rf->CAL1.bits.TVCO = 0x0F ; - /* TXRX1 */ - rf->TXRX1.bits.TXBYPASS = 0 ; - rf->TXRX1.bits.INTBIASEN = 0 ; - rf->TXRX1.bits.TXENMODE = 0 ; - rf->TXRX1.bits.TXDIFFMODE = 0 ; - rf->TXRX1.bits.TXLPFBW = 2 ; - rf->TXRX1.bits.RXLPFBW = 2 ; - rf->TXRX1.bits.TXVGC = 0 ; - rf->TXRX1.bits.PCONTROL = 0 ; - rf->TXRX1.bits.RXDCFBBYPS = 0 ; - /* PCNT1 */ - rf->PCNT1.bits.TX_DELAY = 0 ; - rf->PCNT1.bits.PC_OFFSET = 0 ; - rf->PCNT1.bits.P_DESIRED = 0 ; - rf->PCNT1.bits.MID_BIAS = 0 ; - /* PCNT2 */ - rf->PCNT2.bits.MIN_POWER = 0 ; - rf->PCNT2.bits.MID_POWER = 0 ; - rf->PCNT2.bits.MAX_POWER = 0 ; - /* VCOT1 */ - rf->VCOT1.bits.AUX1 = 0 ; - rf->VCOT1.bits.AUX = 0 ; -} ; - - -void WIFI_setRF_CNT(u16 val) -{ -// printf("write rf cnt %04X\n", val); - if (!wifiMac.rfIOStatus.bits.busy) - wifiMac.rfIOCnt.val = val ; -} - -void WIFI_setRF_DATA(u16 val, u8 part) -{ -// printf("write rf data %04X %s part\n", val, (part?"high":"low")); - if (!wifiMac.rfIOStatus.bits.busy) - { - rfIOData_t *rfreg = (rfIOData_t *)&wifiMac.RF; - switch (wifiMac.rfIOCnt.bits.readOperation) - { - case 1: /* read from RF chip */ - /* low part of data is ignored on reads */ - /* on high part, the address is read, and the data at this is written back */ - if (part==1) - { - wifiMac.rfIOData.array16[part] = val ; - if (wifiMac.rfIOData.bits.address > (sizeof(wifiMac.RF) / 4)) return ; /* out of bound */ - /* get content of the addressed register */ - wifiMac.rfIOData.bits.content = rfreg[wifiMac.rfIOData.bits.address].bits.content ; - } - break ; - case 0: /* write to RF chip */ - wifiMac.rfIOData.array16[part] = val ; - if (wifiMac.rfIOData.bits.address > (sizeof(wifiMac.RF) / 4)) return ; /* out of bound */ - /* the actual transfer is done on high part write */ - if (part==1) - { - switch (wifiMac.rfIOData.bits.address) - { - case 5: /* write to upper part of the frequency filter */ - case 6: /* write to lower part of the frequency filter */ - { - u32 channelFreqN ; - rfreg[wifiMac.rfIOData.bits.address].bits.content = wifiMac.rfIOData.bits.content ; - /* get the complete rfpll.n */ - channelFreqN = (u32)wifiMac.RF.RFPLL3.bits.NUM2 + ((u32)wifiMac.RF.RFPLL2.bits.NUM2 << 18) + ((u32)wifiMac.RF.RFPLL2.bits.N2 << 24) ; - /* frequency setting is out of range */ - if (channelFreqN<0x00A2E8BA) return ; - /* substract base frequency (channel 1) */ - channelFreqN -= 0x00A2E8BA ; - } - return ; - case 13: - /* special purpose register: TEST1, on write, the RF chip resets */ - WIFI_resetRF(&wifiMac.RF) ; - return ; - } - /* set content of the addressed register */ - rfreg[wifiMac.rfIOData.bits.address].bits.content = wifiMac.rfIOData.bits.content ; - } - break ; - } - } -} - -u16 WIFI_getRF_DATA(u8 part) -{ -// printf("read rf data %s part\n", (part?"high":"low")); - if (!wifiMac.rfIOStatus.bits.busy) - { - return wifiMac.rfIOData.array16[part] ; - } else - { /* data is not (yet) available */ - return 0 ; - } - } - -u16 WIFI_getRF_STATUS() -{ -// printf("read rf status\n"); - return wifiMac.rfIOStatus.val ; -} - -/******************************************************************************* - - BB-Chip - - *******************************************************************************/ - -void WIFI_setBB_CNT(u16 val) -{ - wifiMac.bbIOCnt.val = val; - - if(wifiMac.bbIOCnt.bits.mode == 1) - wifiMac.BB.data[wifiMac.bbIOCnt.bits.address] = wifiMac.bbDataToWrite; -} - -u8 WIFI_getBB_DATA() -{ - if((!wifiMac.bbIOCnt.bits.enable) || (wifiMac.bbIOCnt.bits.mode != 2)) - return 0; - - return wifiMac.BB.data[wifiMac.bbIOCnt.bits.address]; -// if ((wifiMac.bbIOCnt.bits.mode != 2) || !(wifiMac.bbIOCnt.bits.enable)) return 0 ; /* not for read or disabled */ -// return wifiMac.BB.data[wifiMac.bbIOCnt.bits.address] ; -} - -void WIFI_setBB_DATA(u8 val) -{ - wifiMac.bbDataToWrite = (val); -// if ((wifiMac.bbIOCnt.bits.mode != 1) || !(wifiMac.bbIOCnt.bits.enable)) return ; /* not for write or disabled */ -// wifiMac.BB.data[wifiMac.bbIOCnt.bits.address] = val ; -} - -/******************************************************************************* - - wifimac IO: a lot of the wifi regs are action registers, that are mirrored - without action, so the default IO via MMU.c does not seem to - be very suitable - - all registers are 16 bit - - *******************************************************************************/ - -static void WIFI_triggerIRQMask(u16 mask) -{ - u16 oResult,nResult ; - oResult = wifiMac.IE.val & wifiMac.IF.val ; - wifiMac.IF.val = wifiMac.IF.val | (mask & ~0x0400) ; - nResult = wifiMac.IE.val & wifiMac.IF.val ; - //printf("wifi: trigger irq: ie=%04X, if=%04X, mask=%08X, oldresult=%04X, newresult=%04X\n", - // wifiMac.IE.val, wifiMac.IF.val, mask, oResult, nResult); - if (!oResult && nResult) - { - NDS_makeARM7Int(24) ; /* cascade it via arm7 wifi irq */ - } -} - -static void WIFI_triggerIRQ(u8 irq) -{ - WIFI_triggerIRQMask(1<WIFI_Host_InitSystem()) - { - wifi_netEnabled = true; - } - wifiMac.powerOn = FALSE; - wifiMac.powerOnPending = FALSE; - - wifiMac.rfStatus = 0x0000; - wifiMac.rfPins = 0x0004; - - wifiCom = wifiComs[CommonSettings.wifi.mode]; - wifiCom->Init(); - - return true; -} - -void WIFI_DeInit() -{ - wifiCom->DeInit(); -} - -void WIFI_Reset() -{ - memset(&wifiMac, 0, sizeof(wifimac_t)); - - WIFI_resetRF(&wifiMac.RF) ; - wifi_netEnabled = false; - if(driver->WIFI_Host_InitSystem()) - { - wifi_netEnabled = true; - } - wifiMac.powerOn = FALSE; - wifiMac.powerOnPending = FALSE; - - wifiMac.rfStatus = 0x0000; - wifiMac.rfPins = 0x0004; - - wifiCom = wifiComs[CommonSettings.wifi.mode]; - wifiCom->Reset(); -} - -static void WIFI_RXPutWord(u16 val) -{ -// printf("wifi: rx circbuf write attempt: rxcnt=%04X, rxread=%04X, rxwrite=%04X\n", -// wifiMac.RXCnt, wifiMac.RXReadCursor, wifiMac.RXHWWriteCursor); - /* abort when RX data queuing is not enabled */ - if (!(wifiMac.RXCnt & 0x8000)) return ; - /* abort when ringbuffer is full */ - //if (wifiMac.RXReadCursor == wifiMac.RXHWWriteCursor) return ; - /*if(wifiMac.RXHWWriteCursor >= wifiMac.RXReadCursor) - { - printf("WIFI: write cursor (%04X) above READCSR (%04X). Cannot write received packet.\n", - wifiMac.RXHWWriteCursor, wifiMac.RXReadCursor); - return; - }*/ - /* write the data to cursor position */ - wifiMac.circularBuffer[wifiMac.RXHWWriteCursor & 0xFFF] = val; -// printf("wifi: written word %04X to circbuf addr %04X\n", val, (wifiMac.RXHWWriteCursor << 1)); - /* move cursor by one */ - //printf("written one word to %04X (start %04X, end %04X), ", wifiMac.RXHWWriteCursor, wifiMac.RXRangeBegin, wifiMac.RXRangeEnd); - wifiMac.RXHWWriteCursor++ ; - /* wrap around */ -// wifiMac.RXHWWriteCursor %= (wifiMac.RXRangeEnd - wifiMac.RXRangeBegin) >> 1 ; -// printf("new addr=%04X\n", wifiMac.RXHWWriteCursor); - if(wifiMac.RXHWWriteCursor >= ((wifiMac.RXRangeEnd & 0x1FFE) >> 1)) - wifiMac.RXHWWriteCursor = ((wifiMac.RXRangeBegin & 0x1FFE) >> 1); -} - -static void WIFI_TXStart(u8 slot) -{ - WIFI_LOG(3, "TX slot %i trying to send a packet: TXCnt = %04X, TXBufLoc = %04X\n", - slot, wifiMac.TXCnt, wifiMac.TXSlot[slot]); - - if (wifiMac.TXSlot[slot] & 0x8000) /* is slot enabled? */ - { - u16 txLen; - /* the address has to be somewhere in the circular buffer, so drop the other bits */ - u16 address = (wifiMac.TXSlot[slot] & 0x0FFF); - /* is there even enough space for the header (6 hwords) in the tx buffer? */ - if (address > 0x1000-6) - { - WIFI_LOG(1, "TX slot %i trying to send a packet overflowing from the TX buffer (address %04X). Attempt ignored.\n", - slot, (address << 1)); - return; - } - - /* 12 byte header TX Header: http://www.akkit.org/info/dswifi.htm#FmtTx */ - txLen = wifiMac.circularBuffer[address+5]; - /* zero length */ - if (txLen == 0) - { - WIFI_LOG(1, "TX slot %i trying to send a packet with length field set to zero. Attempt ignored.\n", - slot); - return; - } - /* unsupported txRate */ - switch (wifiMac.circularBuffer[address+4] & 0xFF) - { - case 10: /* 1 mbit */ - case 20: /* 2 mbit */ - break; - default: /* other rates */ - WIFI_LOG(1, "TX slot %i trying to send a packet with transfer rate field set to an invalid value of %i. Attempt ignored.\n", - slot, wifiMac.circularBuffer[address+4] & 0xFF); - return; - } - - /* FIXME: calculate FCS */ - - WIFI_triggerIRQ(WIFI_IRQ_SENDSTART) ; - - if(slot > wifiMac.txCurSlot) - wifiMac.txCurSlot = slot; - - wifiMac.txSlotBusy[slot] = 1; - wifiMac.txSlotAddr[slot] = address; - wifiMac.txSlotLen[slot] = txLen; - wifiMac.txSlotRemainingBytes[slot] = (txLen + 12); - - wifiMac.rfStatus = 0x0003; - wifiMac.rfPins = 0x0046; - -#if 0 - WIFI_SoftAP_RecvPacketFromDS((u8*)&wifiMac.circularBuffer[address+6], txLen); - WIFI_triggerIRQ(WIFI_IRQ_SENDCOMPLETE) ; - - wifiMac.circularBuffer[address] = 0x0001; - wifiMac.circularBuffer[address+4] &= 0x00FF; -#endif - } -} - -void WIFI_write16(u32 address, u16 val) -{ - BOOL action = FALSE ; - if (!(MMU_read32(ARMCPU_ARM7,REG_PWRCNT) & 0x0002)) return ; /* access to wifi hardware was disabled */ - if ((address & 0xFF800000) != 0x04800000) return ; /* error: the address does not describe a wifi register */ - - WIFI_LOG(5, "Write at address %08X, %04X\n", address, val); - - /* the first 0x1000 bytes are mirrored at +0x1000,+0x2000,+0x3000,+06000,+0x7000 */ - /* only the first mirror causes an special action */ - /* the gap at +0x4000 is filled with the circular bufferspace */ - /* the so created 0x8000 byte block is then mirrored till 0x04FFFFFF */ - /* see: http://www.akkit.org/info/dswifi.htm#Wifihwcap */ - if (((address & 0x00007000) >= 0x00004000) && ((address & 0x00007000) < 0x00006000)) - { - /* access to the circular buffer */ - address &= 0x1FFF ; - // printf("wifi: circbuf write at %04X, %04X, readcsr=%04X, wrcsr=%04X(%04X)\n", - // address, val, wifiMac.RXReadCursor << 1, wifiMac.RXHWWriteCursorReg << 1, wifiMac.RXHWWriteCursor << 1); - /* if((address == 0x0BFE) && (val == 0x061E)) - { - extern void emu_halt(); - emu_halt(); - }*/ - wifiMac.circularBuffer[address >> 1] = val ; - return ; - } - if (!(address & 0x00007000)) action = TRUE ; - /* mirrors => register address */ - address &= 0x00000FFF ; - //if((address < 0x158) || ((address > 0x168) && (address < 0x17C)) || (address > 0x184)) - // printf("wifi write at %08X, %04X\n", address, val); -/* FILE *f = fopen("wifidbg.txt", "a"); - fprintf(f, "wifi write at %08X, %04X\n", address, val); - fclose(f);*/ - switch (address) - { - case REG_WIFI_ID: - break ; - case REG_WIFI_MODE: - if (val & 0x4000) - { - /* does some resets */ - wifiMac.RXRangeBegin = 0x4000 ; - /* this bit does not save */ - val &= ~0x4000 ; - } - - if(val & 0x0001) - { - wifiMac.rfStatus = 0x0009; - wifiMac.rfPins = 0x0004; - } - - wifiMac.macMode = val ; - break ; - case REG_WIFI_WEP: - wifiMac.wepMode = val ; - break ; - case REG_WIFI_IE: - wifiMac.IE.val = val ; - //printf("wifi ie write %04X\n", val); - break ; - case REG_WIFI_IF: - wifiMac.IF.val &= ~val ; /* clear flagging bits */ - break ; - case REG_WIFI_MAC0: - case REG_WIFI_MAC1: - case REG_WIFI_MAC2: - wifiMac.mac.words[(address - REG_WIFI_MAC0) >> 1] = val ; - break ; - case REG_WIFI_BSS0: - case REG_WIFI_BSS1: - case REG_WIFI_BSS2: - wifiMac.bss.words[(address - REG_WIFI_BSS0) >> 1] = val ; - break ; - case REG_WIFI_RETRYLIMIT: - wifiMac.retryLimit = val ; - break ; - case REG_WIFI_WEPCNT: - wifiMac.WEP_enable = (val & 0x8000) != 0 ; - break ; - case REG_WIFI_POWERSTATE: - wifiMac.powerOn = ((val & 0x0002)?TRUE:FALSE); - if(wifiMac.powerOn) WIFI_triggerIRQ(11); - break; - case REG_WIFI_FORCEPS: - if((val & 0x8000) && (!wifiMac.powerOnPending)) - { - /* BOOL newPower = ((val & 0x0001)?FALSE:TRUE); - if(newPower != wifiMac.powerOn) - { - if(!newPower) - wifiMac.powerOn = FALSE; - else - wifiMac.powerOnPending = TRUE; - }*/ - wifiMac.powerOn = ((val & 0x0001) ? FALSE : TRUE); - } - break; - case REG_WIFI_POWERACK: - if((val == 0x0000) && wifiMac.powerOnPending) - { - wifiMac.powerOn = TRUE; - wifiMac.powerOnPending = FALSE; - } - break; - case REG_WIFI_RXCNT: - wifiMac.RXCnt = val; - if(wifiMac.RXCnt & 0x0001) - { - wifiMac.RXHWWriteCursor = wifiMac.RXHWWriteCursorReg = wifiMac.RXHWWriteCursorLatched; - //printf("wifi: write wrcsr %04X\n", wifiMac.RXHWWriteCursorReg); - } - break; - case REG_WIFI_RXRANGEBEGIN: - wifiMac.RXRangeBegin = val ; - if(wifiMac.RXHWWriteCursor < ((val & 0x1FFE) >> 1)) - wifiMac.RXHWWriteCursor = ((val & 0x1FFE) >> 1); - //printf("wifi: rx range begin=%04X\n", val); - break ; - case REG_WIFI_RXRANGEEND: - wifiMac.RXRangeEnd = val ; - if(wifiMac.RXHWWriteCursor >= ((val & 0x1FFE) >> 1)) - wifiMac.RXHWWriteCursor = ((wifiMac.RXRangeBegin & 0x1FFE) >> 1); - //printf("wifi: rx range end=%04X\n", val); - break ; - case REG_WIFI_WRITECSRLATCH: - if (action) /* only when action register and CSR change enabled */ - { - wifiMac.RXHWWriteCursorLatched = val ; - } - break ; - case REG_WIFI_CIRCBUFRADR: - wifiMac.CircBufReadAddress = (val & 0x1FFE); - break ; - case REG_WIFI_RXREADCSR: - //printf("wifi: write readcsr: %04X\n", val << 1); - wifiMac.RXReadCursor = val ; - break ; - case REG_WIFI_CIRCBUFWADR: - wifiMac.CircBufWriteAddress = val ; - break ; - case REG_WIFI_CIRCBUFWRITE: - /* set value into the circ buffer, and move cursor to the next hword on action */ - //printf("wifi: circbuf fifo write at %04X, %04X (action=%i)\n", (wifiMac.CircBufWriteAddress & 0x1FFF), val, action); - wifiMac.circularBuffer[(wifiMac.CircBufWriteAddress >> 1) & 0xFFF] = val ; - if (action) - { - /* move to next hword */ - wifiMac.CircBufWriteAddress+=2 ; - if (wifiMac.CircBufWriteAddress == wifiMac.CircBufWrEnd) - { - /* on end of buffer, add skip hwords to it */ - wifiMac.CircBufWrEnd += wifiMac.CircBufWrSkip * 2 ; - } - } - break ; - case REG_WIFI_CIRCBUFWR_SKIP: - wifiMac.CircBufWrSkip = val ; - break ; - case REG_WIFI_BEACONTRANS: - wifiMac.BEACONSlot = val & 0x7FFF ; - wifiMac.BEACON_enable = (val & 0x8000) != 0 ; - //printf("wifi beacon: enable=%s, addr=%04X\n", (wifiMac.BEACON_enable?"yes":"no"), (wifiMac.BEACONSlot<<1)); - break ; - case REG_WIFI_TXLOC1: - case REG_WIFI_TXLOC2: - case REG_WIFI_TXLOC3: - wifiMac.TXSlot[(address - REG_WIFI_TXLOC1) >> 2] = val ; - break ; - case REG_WIFI_TXOPT: -#if 0 - if (val == 0xFFFF) - { - /* reset TX logic */ - /* CHECKME */ - // wifiMac.TXSlot[0] = 0 ; wifiMac.TXSlot[1] = 0 ; wifiMac.TXSlot[2] = 0 ; - wifiMac.TXOpt = 0 ; - wifiMac.TXCnt = 0 ; - } else - { - wifiMac.TXOpt = val ; - } -#endif - wifiMac.TXCnt &= ~val; - break ; - case REG_WIFI_TXCNT: - wifiMac.TXCnt |= val ; - if (val & 0x01) WIFI_TXStart(0) ; - if (val & 0x04) WIFI_TXStart(1) ; - if (val & 0x08) WIFI_TXStart(2) ; - /* if(val&0x04) - { - extern void emu_halt(); - emu_halt(); - }*/ - break ; - case REG_WIFI_RFIOCNT: - WIFI_setRF_CNT(val) ; - break ; - case REG_WIFI_RFIOBSY: - /* CHECKME: read only? */ - break ; - case REG_WIFI_RFIODATA1: - WIFI_setRF_DATA(val,0) ; - break ; - case REG_WIFI_RFIODATA2: - WIFI_setRF_DATA(val,1) ; - break ; - case REG_WIFI_USCOUNTERCNT: - wifiMac.usecEnable = (val & 1)==1 ; - break ; - case REG_WIFI_USCOMPARECNT: - wifiMac.ucmpEnable = (val & 1)==1 ; - break ; - case REG_WIFI_BBSIOCNT: - WIFI_setBB_CNT(val) ; - break ; - case REG_WIFI_BBSIOWRITE: - WIFI_setBB_DATA(val&0xFF) ; - break ; - case REG_WIFI_RXBUF_COUNT: - wifiMac.RXBufCount = val & 0x0FFF ; - break ; - case REG_WIFI_EXTRACOUNTCNT: - wifiMac.eCountEnable = (val & 0x0001) ; - break ; - case REG_WIFI_EXTRACOUNT: - wifiMac.eCount = val ; - break ; - case REG_WIFI_POWER_US: - wifiMac.crystalEnabled = !(val & 0x0001) ; - break ; - case REG_WIFI_IF_SET: - WIFI_triggerIRQMask(val) ; - break ; - case REG_WIFI_CIRCBUFRD_END: - wifiMac.CircBufRdEnd = (val & 0x1FFE) ; - break ; - case REG_WIFI_CIRCBUFRD_SKIP: - wifiMac.CircBufRdSkip = val & 0xFFF ; - break ; - case REG_WIFI_AID_LOW: - wifiMac.pid = val & 0x0F ; - break ; - case REG_WIFI_AID_HIGH: - wifiMac.aid = val & 0x07FF ; - break ; - //case 0x36: - //case 0x38: - //case 0x3C: - //case 0x40: - // printf("wifi power reg %03X write %04X\n", address, val); - // break; - case 0xD0: - // printf("wifi: rxfilter=%04X\n", val); - break; - default: - // printf("wifi: write unhandled reg %03X, %04X\n", address, val); - // val = 0 ; /* not handled yet */ - break ; - } - - wifiMac.ioMem[address >> 1] = val; -} -//int packet_arrived=0; -u16 WIFI_read16(u32 address) -{ - BOOL action = FALSE ; - u16 temp ; - if (!(MMU_read32(ARMCPU_ARM7,REG_PWRCNT) & 0x0002)) return 0 ; /* access to wifi hardware was disabled */ - if ((address & 0xFF800000) != 0x04800000) return 0 ; /* error: the address does not describe a wifi register */ - - WIFI_LOG(5, "Read at address %08X\n", address); - - /* the first 0x1000 bytes are mirrored at +0x1000,+0x2000,+0x3000,+06000,+0x7000 */ - /* only the first mirror causes an special action */ - /* the gap at +0x4000 is filled with the circular bufferspace */ - /* the so created 0x8000 byte block is then mirrored till 0x04FFFFFF */ - /* see: http://www.akkit.org/info/dswifi.htm#Wifihwcap */ - if (((address & 0x00007000) >= 0x00004000) && ((address & 0x00007000) < 0x00006000)) - { - /* access to the circular buffer */ - // printf("wifi: circbuf read at %04X, %04X, readcsr=%04X, wrcsr=%04X(%04X)\n", - // address, wifiMac.circularBuffer[(address & 0x1FFF) >> 1], wifiMac.RXReadCursor << 1, wifiMac.RXHWWriteCursorReg << 1, wifiMac.RXHWWriteCursor << 1); - /*if(((address == 0x04804C38) || - (address == 0x04804C04)) && - (wifiMac.circularBuffer[(address & 0x1FFF) >> 1] != 0x0000) && - (wifiMac.circularBuffer[(address & 0x1FFF) >> 1] != 0x5A5A) && - (wifiMac.circularBuffer[(address & 0x1FFF) >> 1] != 0xA5A5)) - { - extern void emu_halt(); - emu_halt(); - }*/ - - // hax - /* if(packet_arrived) - { - if(address == 0x04804C38) - return 0x0010; - if(address == 0x04804C3E) - return 0x0014; - - if(address == 0x048047D0) - return 0x0010; - if(address == 0x048047D6) - return 0x0014; - }*/ - - return wifiMac.circularBuffer[(address & 0x1FFF) >> 1] ; - } - if (!(address & 0x00007000)) action = TRUE ; - //if((address != 0x04808214) && (address != 0x0480803C) && (address != 0x048080F8) && (address != 0x048080FA) && (address != 0x0480819C)) - /* mirrors => register address */ - address &= 0x00000FFF ; -// if((address < 0x158) || ((address > 0x168) && (address < 0x17C)) || (address > 0x184)) -// printf("wifi read at %08X\n", address); -/* FILE *f = fopen("wifidbg.txt", "a"); - fprintf(f, "wifi read at %08X\n", address); - fclose(f);*/ - switch (address) - { - case REG_WIFI_ID: - return WIFI_CHIPID ; - case REG_WIFI_MODE: - return wifiMac.macMode ; - case REG_WIFI_WEP: - return wifiMac.wepMode ; - case REG_WIFI_IE: - //printf("wifi: read ie (%04X)\n", wifiMac.IE.val); - return wifiMac.IE.val ; - case REG_WIFI_IF: - //printf("wifi: read if (%04X)\n", wifiMac.IF.val); - return wifiMac.IF.val ; - case REG_WIFI_POWERSTATE: - return ((wifiMac.powerOn ? 0x0000 : 0x0200) | (wifiMac.powerOnPending ? 0x0102 : 0x0000)); - case REG_WIFI_RFIODATA1: - return WIFI_getRF_DATA(0) ; - case REG_WIFI_RFIODATA2: - return WIFI_getRF_DATA(1) ; - case REG_WIFI_RFIOBSY: - case REG_WIFI_BBSIOBUSY: - return 0 ; /* we are never busy :p */ - case REG_WIFI_BBSIOREAD: - return WIFI_getBB_DATA() ; - case REG_WIFI_RANDOM: - /* FIXME: random generator */ -// return (rand() & 0x7FF); // disabled (no wonder there were desyncs...) - - // probably not right, but it's better than using the unsaved and shared rand(). - // at the very least, rand() shouldn't be used when movieMode is active. - { - u16 returnValue = wifiMac.randomSeed; - wifiMac.randomSeed = (wifiMac.randomSeed & 1) ^ (((wifiMac.randomSeed << 1) & 0x7FE) | ((wifiMac.randomSeed >> 10) & 0x1)); - return returnValue; - } - - return 0 ; - case REG_WIFI_MAC0: - case REG_WIFI_MAC1: - case REG_WIFI_MAC2: - //printf("read mac addr: word %i = %02X\n", (address - REG_WIFI_MAC0) >> 1, wifiMac.mac.words[(address - REG_WIFI_MAC0) >> 1]); - return wifiMac.mac.words[(address - REG_WIFI_MAC0) >> 1] ; - case REG_WIFI_BSS0: - case REG_WIFI_BSS1: - case REG_WIFI_BSS2: - //printf("read bssid addr: word %i = %02X\n", (address - REG_WIFI_BSS0) >> 1, wifiMac.bss.words[(address - REG_WIFI_BSS0) >> 1]); - return wifiMac.bss.words[(address - REG_WIFI_BSS0) >> 1] ; - case REG_WIFI_RXCNT: - return wifiMac.RXCnt; - case REG_WIFI_RXRANGEBEGIN: - return wifiMac.RXRangeBegin ; - case REG_WIFI_CIRCBUFREAD: - temp = wifiMac.circularBuffer[((wifiMac.RXRangeBegin + wifiMac.CircBufReadAddress) >> 1) & 0x0FFF] ; - //printf("wifi: circbuf fifo read at %04X, action=%i\n", (wifiMac.RXRangeBegin + wifiMac.CircBufReadAddress), action); - if (action) - { - wifiMac.CircBufReadAddress += 2 ; - wifiMac.CircBufReadAddress &= 0x1FFE ; - if (wifiMac.CircBufReadAddress + wifiMac.RXRangeBegin == wifiMac.RXRangeEnd) - { - wifiMac.CircBufReadAddress = 0 ; - } else - { - /* skip does not fire after a reset */ - if (wifiMac.CircBufReadAddress == wifiMac.CircBufRdEnd) - { - wifiMac.CircBufReadAddress += wifiMac.CircBufRdSkip * 2 ; - wifiMac.CircBufReadAddress &= 0x1FFE ; - if (wifiMac.CircBufReadAddress + wifiMac.RXRangeBegin == wifiMac.RXRangeEnd) wifiMac.CircBufReadAddress = 0 ; - } - } - if (wifiMac.RXBufCount > 0) - { - if (wifiMac.RXBufCount == 1) - { - WIFI_triggerIRQ(9) ; - } - wifiMac.RXBufCount-- ; - } - } - return temp; - case REG_WIFI_CIRCBUFRADR: - return wifiMac.CircBufReadAddress ; - case REG_WIFI_RXHWWRITECSR: - //printf("wifi: read writecsr (%04X)\n", wifiMac.RXHWWriteCursorReg); - return wifiMac.RXHWWriteCursorReg; - //return wifiMac.RXReadCursor; - case REG_WIFI_RXREADCSR: - //printf("wifi: read readcsr (%04X)\n", wifiMac.RXReadCursor); - return wifiMac.RXReadCursor; - //return wifiMac.RXHWWriteCursorReg; - case REG_WIFI_RXBUF_COUNT: - return wifiMac.RXBufCount ; - case REG_WIFI_TXREQ_READ: - return wifiMac.TXCnt; - case REG_WIFI_TXBUSY: - return ((wifiMac.txSlotBusy[0] ? 0x01 : 0x00) | (wifiMac.txSlotBusy[1] ? 0x04 : 0x00) | (wifiMac.txSlotBusy[2] ? 0x08 : 0x00)); - case REG_WIFI_TXSTAT: - return wifiMac.TXStat; - case REG_WIFI_EXTRACOUNTCNT: - return wifiMac.eCountEnable?1:0 ; - case REG_WIFI_EXTRACOUNT: - return wifiMac.eCount ; - case REG_WIFI_USCOMPARE0: - return (u16)wifiMac.usec; - case REG_WIFI_USCOMPARE1: - return (u16)(wifiMac.usec >> 16); - case REG_WIFI_USCOMPARE2: - return (u16)(wifiMac.usec >> 32); - case REG_WIFI_USCOMPARE3: - return (u16)(wifiMac.usec >> 48); - case REG_WIFI_POWER_US: - return wifiMac.crystalEnabled?0:1 ; - case REG_WIFI_CIRCBUFRD_END: - return wifiMac.CircBufRdEnd ; - case REG_WIFI_CIRCBUFRD_SKIP: - return wifiMac.CircBufRdSkip ; - case REG_WIFI_AID_LOW: - return wifiMac.pid ; - case REG_WIFI_AID_HIGH: - return wifiMac.aid ; - case 0x214: - //printf("wifi: read rfstatus (%04X)\n", wifiMac.rfStatus); - return 0x0009; - //return wifiMac.rfStatus; - case 0x19C: - //assert(false); //luigi, please pick something to return from here - //printf("wifi: read rfpins (%04X)\n", wifiMac.rfPins); - //return wifiMac.rfPins; - return 0x0004; - default: - // printf("wifi: read unhandled reg %03X\n", address); - return wifiMac.ioMem[address >> 1]; - } -} - - -void WIFI_usTrigger() -{ - if (wifiMac.crystalEnabled) - { - /* a usec (=3F03 cycles) has passed */ - if (wifiMac.usecEnable) - wifiMac.usec++ ; - if (wifiMac.eCountEnable) - { - if (wifiMac.eCount > 0) - { - wifiMac.eCount-- ; - } - } - } - if ((wifiMac.ucmpEnable) && (wifiMac.ucmp == wifiMac.usec)) - { - WIFI_triggerIRQ(WIFI_IRQ_TIMEBEACON) ; - } - - if((wifiMac.usec & 3) == 0) - { - int slot = wifiMac.txCurSlot; - - if(wifiMac.txSlotBusy[slot]) - { - wifiMac.txSlotRemainingBytes[slot]--; - if(wifiMac.txSlotRemainingBytes[slot] == 0) - { - wifiMac.txSlotBusy[slot] = 0; - - wifiCom->SendPacket((u8*)&wifiMac.circularBuffer[wifiMac.txSlotAddr[slot]], wifiMac.txSlotLen[slot]); - - while((wifiMac.txSlotBusy[wifiMac.txCurSlot] == 0) && (wifiMac.txCurSlot > 0)) - wifiMac.txCurSlot--; - - wifiMac.circularBuffer[wifiMac.txSlotAddr[slot]] = 0x0001; - wifiMac.circularBuffer[wifiMac.txSlotAddr[slot]+4] &= 0x00FF; - - wifiMac.TXStat = (0x0001 | (slot << 12)); - - WIFI_triggerIRQ(WIFI_IRQ_SENDCOMPLETE); - - //wifiMac.rfStatus = 0x0001; - //wifiMac.rfPins = 0x0084; - wifiMac.rfStatus = 0x0009; - wifiMac.rfPins = 0x0004; - - WIFI_LOG(3, "TX slot %i finished sending its packet. Next is slot %i. TXStat = %04X\n", - slot, wifiMac.txCurSlot, wifiMac.TXStat); - } - } - } - - wifiCom->usTrigger(); -} - -/******************************************************************************* - - Ad-hoc communication interface - - *******************************************************************************/ - -bool Adhoc_Init() -{ - return true; -} - -void Adhoc_DeInit() -{ -} - -void Adhoc_Reset() -{ -} - -void Adhoc_SendPacket(u8* packet, u32 len) -{ -} - -void Adhoc_usTrigger() -{ -} - -WifiComInterface Adhoc = { - Adhoc_Init, - Adhoc_DeInit, - Adhoc_Reset, - Adhoc_SendPacket, - Adhoc_usTrigger -}; - -/******************************************************************************* - - SoftAP (fake wifi access point) - - *******************************************************************************/ - -u8 SoftAP_MACAddr[6] = {0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D}; - -u8 SoftAP_Beacon[] = { - /* 802.11 header */ - 0x80, 0x00, // Frame control - 0x00, 0x00, // Duration ID - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Receiver - 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // Sender - 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // BSSID - 0x00, 0x00, // Sequence control - - /* Frame body */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Timestamp - 0x64, 0x00, // Beacon interval - 0x0F, 0x00, // Capablilty information - 0x00, 0x06, 'S', 'o', 'f', 't', 'A', 'P', // SSID - 0x01, 0x02, 0x82, 0x84, // Supported rates - 0x05, 0x04, 0x00, 0x00, 0x00, 0x00, // TIM - - /* CRC32 */ - 0x00, 0x00, 0x00, 0x00 -}; - -u8 SoftAP_ProbeResponse[] = { - /* 802.11 header */ - 0x50, 0x00, // Frame control - 0x00, 0x00, // Duration ID - 0x00, 0x09, 0xBF, 0x12, 0x34, 0x56, // Receiver - 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // Sender - 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // BSSID - 0x00, 0x00, // Sequence control - - /* Frame body */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Timestamp - 0x64, 0x00, // Beacon interval - 0x01, 0x00, // Capablilty information - 0x00, 0x06, 'S', 'o', 'f', 't', 'A', 'P', // SSID - 0x01, 0x02, 0x82, 0x84, // Supported rates - - /* CRC32 */ - 0x00, 0x00, 0x00, 0x00 -}; - -u8 SoftAP_AuthFrame[] = { - /* 802.11 header */ - 0xB0, 0x00, // Frame control - 0x00, 0x00, // Duration ID - 0x00, 0x09, 0xBF, 0x12, 0x34, 0x56, // Receiver - 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // Sender - 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // BSSID - 0x00, 0x00, // Sequence control - - /* Frame body */ - 0x00, 0x00, // Authentication algorithm - 0x02, 0x00, // Authentication sequence - 0x00, 0x00, // Status - - /* CRC32 */ - 0x00, 0x00, 0x00, 0x00 -}; - -u8 SoftAP_AssocResponse[] = { - /* 802.11 header */ - 0x10, 0x00, // Frame control - 0x00, 0x00, // Duration ID - 0x00, 0x09, 0xBF, 0x12, 0x34, 0x56, // Receiver - 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // Sender - 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // BSSID - 0x00, 0x00, // Sequence control - - /* Frame body */ - 0x0F, 0x00, // Capability information - 0x00, 0x00, // Status - 0x01, 0xC0, // Assocation ID - 0x01, 0x02, 0x82, 0x84, // Supported rates - - /* CRC32 */ - 0x00, 0x00, 0x00, 0x00 -}; - -//todo - make a class to wrap this -//todo - zeromus - inspect memory leak safety of all this -static pcap_if_t * WIFI_index_device(pcap_if_t *alldevs, int index) { - pcap_if_t *curr = alldevs; - for(int i=0;inext; - return curr; -} - -bool SoftAP_Init() -{ - - wifiMac.SoftAP.usecCounter = 0; - - wifiMac.SoftAP.curPacketSize = 0; - wifiMac.SoftAP.curPacketPos = 0; - wifiMac.SoftAP.curPacketSending = FALSE; - -#if 0 - char errbuf[PCAP_ERRBUF_SIZE]; - pcap_if_t *alldevs; - - if(wifi_netEnabled) - { - if(desmume_pcap_findalldevs(&alldevs, errbuf) == -1) - { - printf("SoftAP: PCAP error with pcap_findalldevs_ex(): %s\n", errbuf); - return false; - } - - wifi_bridge = desmume_pcap_open(WIFI_index_device(alldevs,CommonSettings.wifi.infraBridgeAdapter)->name, PACKET_SIZE, 0, 1, errbuf); - if(wifi_bridge == NULL) - { - printf("SoftAP: PCAP error with pcap_open(): %s\n", errbuf); - return false; - } - - desmume_pcap_freealldevs(alldevs); - } -#endif - - return true; -} - -void SoftAP_DeInit() -{ - if(wifi_netEnabled) - { - if(wifi_bridge != NULL) - desmume_pcap_close(wifi_bridge); - } -} - -void SoftAP_Reset() -{ - wifiMac.SoftAP.usecCounter = 0; - - wifiMac.SoftAP.curPacketSize = 0; - wifiMac.SoftAP.curPacketPos = 0; - wifiMac.SoftAP.curPacketSending = FALSE; -} - -INLINE void SoftAP_MakeRXHeader(u16 flags, u16 xferRate, u16 len, u8 maxRSSI, u8 minRSSI) -{ - *(u16*)&wifiMac.SoftAP.curPacket[0] = flags; - - // Unknown (usually 0x0400) - wifiMac.SoftAP.curPacket[2] = 0x40; - wifiMac.SoftAP.curPacket[3] = 0x00; - - // Time since last packet??? Random??? Left unchanged??? - wifiMac.SoftAP.curPacket[4] = 0x01; - wifiMac.SoftAP.curPacket[5] = 0x00; - - *(u16*)&wifiMac.SoftAP.curPacket[6] = xferRate; - - *(u16*)&wifiMac.SoftAP.curPacket[8] = WIFI_alignedLen(len); - - wifiMac.SoftAP.curPacket[10] = maxRSSI; - wifiMac.SoftAP.curPacket[11] = minRSSI; -} - -void SoftAP_SendPacket(u8 *packet, u32 len) -{ - u32 alignedLen = WIFI_alignedLen(len); - u16 frameCtl = *(u16*)&packet[12]; - - WIFI_LOG(3, "SoftAP: Received a packet of length %i bytes (%i aligned). Frame control = %04X\n", - len, alignedLen, frameCtl); - - switch((frameCtl >> 2) & 0x3) - { - case 0x0: // Management - { - switch((frameCtl >> 4) & 0xF) - { - case 0x4: // Probe request (Nintendo WFC config util) - { - u32 packetLen = sizeof(SoftAP_ProbeResponse); - u32 totalLen = (packetLen + 12); - - // Make the RX header - // About the packet length: - // GBATek says the length entry of the RX header is the length of the IEEE - // header and frame body, without including the FCS. But the Nintendo WFC - // config util expects this length to be the length of the IEEE header and - // the frame body AND the FCS. Actually, it expects WRCSR to be equal to - // (READCSR + 12 + packet_length). - SoftAP_MakeRXHeader(0x0010, 20, packetLen, 0, 0); - - // Copy the probe response template - memcpy(&wifiMac.SoftAP.curPacket[12], SoftAP_ProbeResponse, packetLen); - - // Add the MAC address - memcpy(&wifiMac.SoftAP.curPacket[12 + 4], FW_Mac, 6); - - // The timestamp - u64 timestamp = (wifiMac.SoftAP.usecCounter / 1000); // FIXME: is it correct? - *(u64*)&wifiMac.SoftAP.curPacket[12 + 24] = timestamp; - - // And the CRC32 (FCS) - u32 crc32 = WIFI_getCRC32(&wifiMac.SoftAP.curPacket[12], (packetLen - 4)); - *(u32*)&wifiMac.SoftAP.curPacket[12 + packetLen - 4] = crc32; - - // Let's prepare to send - wifiMac.SoftAP.curPacketSize = totalLen; - wifiMac.SoftAP.curPacketPos = 0; - wifiMac.SoftAP.curPacketSending = TRUE; - } - break; - - case 0xB: // Authentication - { - u32 packetLen = sizeof(SoftAP_AuthFrame); - u32 totalLen = (packetLen + 12); - - // Make the RX header - SoftAP_MakeRXHeader(0x0010, 20, packetLen, 0, 0); - - // Copy the authentication frame template - memcpy(&wifiMac.SoftAP.curPacket[12], SoftAP_AuthFrame, packetLen); - - // Add the MAC address - memcpy(&wifiMac.SoftAP.curPacket[12 + 4], FW_Mac, 6); - - // And the CRC32 (FCS) - u32 crc32 = WIFI_getCRC32(&wifiMac.SoftAP.curPacket[12], (packetLen - 4)); - *(u32*)&wifiMac.SoftAP.curPacket[12 + packetLen - 4] = crc32; - - // Let's prepare to send - wifiMac.SoftAP.curPacketSize = totalLen; - wifiMac.SoftAP.curPacketPos = 0; - wifiMac.SoftAP.curPacketSending = TRUE; - } - break; - - case 0x0: // Association request - { - u32 packetLen = sizeof(SoftAP_AssocResponse); - u32 totalLen = (packetLen + 12); - - // Make the RX header - SoftAP_MakeRXHeader(0x0010, 20, packetLen, 0, 0); - - // Copy the association response template - memcpy(&wifiMac.SoftAP.curPacket[12], SoftAP_AssocResponse, packetLen); - - // Add the MAC address - memcpy(&wifiMac.SoftAP.curPacket[12 + 4], FW_Mac, 6); - - // And the CRC32 (FCS) - u32 crc32 = WIFI_getCRC32(&wifiMac.SoftAP.curPacket[12], (packetLen - 4)); - *(u32*)&wifiMac.SoftAP.curPacket[12 + packetLen - 4] = crc32; - - // Let's prepare to send - wifiMac.SoftAP.curPacketSize = totalLen; - wifiMac.SoftAP.curPacketPos = 0; - wifiMac.SoftAP.curPacketSending = TRUE; - } - break; - } - } - break; - - case 0x2: // Data - { - // We convert the packet into an Ethernet packet - - u32 eflen = (alignedLen - 4 - 30 + 14); - u8 *ethernetframe = new u8[eflen]; - - // Destination address - ethernetframe[0] = packet[28]; - ethernetframe[1] = packet[29]; - ethernetframe[2] = packet[30]; - ethernetframe[3] = packet[31]; - ethernetframe[4] = packet[32]; - ethernetframe[5] = packet[33]; - - // Source address - ethernetframe[6] = packet[22]; - ethernetframe[7] = packet[23]; - ethernetframe[8] = packet[24]; - ethernetframe[9] = packet[25]; - ethernetframe[10] = packet[26]; - ethernetframe[11] = packet[27]; - - // EtherType - ethernetframe[12] = packet[42]; - ethernetframe[13] = packet[43]; - - // Frame body - memcpy((ethernetframe + 14), (packet + 44), (alignedLen - 30 - 4)); - - // Checksum - // TODO ? - - if(wifi_netEnabled) //dont try to pcap out the packet unless network is enabled - desmume_pcap_sendpacket(wifi_bridge, ethernetframe, eflen); - - delete ethernetframe; - } - break; - } -} - -INLINE void SoftAP_SendBeacon() -{ - u32 packetLen = sizeof(SoftAP_Beacon); - u32 totalLen = (packetLen + 12); - - // Make the RX header - SoftAP_MakeRXHeader(0x0011, 20, packetLen, 0, 0); - - // Copy the beacon template - memcpy(&wifiMac.SoftAP.curPacket[12], SoftAP_Beacon, packetLen); - - // Add the timestamp - u64 timestamp = (wifiMac.SoftAP.usecCounter / 1000); // FIXME: is it correct? - *(u64*)&wifiMac.SoftAP.curPacket[12 + 24] = timestamp; - - // And the CRC32 (FCS) - u32 crc32 = WIFI_getCRC32(&wifiMac.SoftAP.curPacket[12], (packetLen - 4)); - *(u32*)&wifiMac.SoftAP.curPacket[12 + packetLen - 4] = crc32; - - // Let's prepare to send - wifiMac.SoftAP.curPacketSize = totalLen; - wifiMac.SoftAP.curPacketPos = 0; - wifiMac.SoftAP.curPacketSending = TRUE; -} - -void SoftAP_usTrigger() -{ - wifiMac.SoftAP.usecCounter++; - - if(!wifiMac.SoftAP.curPacketSending) - { - //if(wifiMac.ioMem[0xD0 >> 1] & 0x0400) - { - //zero sez: every 1/10 second? does it have to be precise? this is so costly.. - //if((wifiMac.SoftAP.usecCounter % 100000) == 0) - if((wifiMac.SoftAP.usecCounter & 131071) == 0) - { - SoftAP_SendBeacon(); - } - } - } - - /* Given a connection of 2 megabits per second, */ - /* we take ~4 microseconds to transfer a byte, */ - /* ie ~8 microseconds to transfer a word. */ - if((wifiMac.SoftAP.curPacketSending) && !(wifiMac.SoftAP.usecCounter & 7)) - { - if(wifiMac.SoftAP.curPacketPos >= 0) - { - if(wifiMac.SoftAP.curPacketPos == 0) - { - WIFI_triggerIRQ(WIFI_IRQ_RECVSTART); - - wifiMac.rfStatus = 0x0009; - wifiMac.rfPins = 0x0004; - - // printf("wifi: softap: started sending packet at %04X\n", wifiMac.RXHWWriteCursor << 1); - // wifiMac.SoftAP.curPacketPos += 2; - } - else - { - wifiMac.rfStatus = 0x0001; - wifiMac.rfPins = 0x0084; - } - - u16 word = (wifiMac.SoftAP.curPacket[wifiMac.SoftAP.curPacketPos] | (wifiMac.SoftAP.curPacket[wifiMac.SoftAP.curPacketPos+1] << 8)); - WIFI_RXPutWord(word); - } - - wifiMac.SoftAP.curPacketPos += 2; - if(wifiMac.SoftAP.curPacketPos >= wifiMac.SoftAP.curPacketSize) - { - wifiMac.SoftAP.curPacketSize = 0; - wifiMac.SoftAP.curPacketPos = 0; - wifiMac.SoftAP.curPacketSending = FALSE; - - wifiMac.RXHWWriteCursorReg = ((wifiMac.RXHWWriteCursor + 1) & (~1)); - - WIFI_triggerIRQ(WIFI_IRQ_RECVCOMPLETE); - - // hax - //packet_arrived=1; - - //printf("wifi: softap: finished sending packet. end at %04X (aligned=%04X)\n", wifiMac.RXHWWriteCursor << 1, wifiMac.RXHWWriteCursorReg << 1); - } - } -} - -WifiComInterface SoftAP = { - SoftAP_Init, - SoftAP_DeInit, - SoftAP_Reset, - SoftAP_SendPacket, - SoftAP_usTrigger -}; - - -WifiComInterface* wifiComs[] = { - &Adhoc, - &SoftAP, - NULL -}; - -#endif +/* Copyright (C) 2007 Tim Seidel + Copyright (C) 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include "wifi.h" +#include "armcpu.h" +#include "NDSSystem.h" +#include "debug.h" + +#ifdef EXPERIMENTAL_WIFI + +#ifdef WIN32 +#include "windriver.h" +#else +#include "pcap/pcap.h" +#endif + +wifimac_t wifiMac; +bool wifi_netEnabled = false; +pcap_t *wifi_bridge = NULL; + +#endif + +/******************************************************************************* + + Firmware info needed for wifi, if no firmware image is available + see: http://www.akkit.org/info/dswifi.htm#WifiInit + + written in bytes, to avoid endianess issues + + *******************************************************************************/ + +u8 FW_Mac[6] = { 0x00, 0x09, 0xBF, 0x12, 0x34, 0x56 } ; +const u8 FW_WIFIInit[32] = { 0x02,0x00, 0x17,0x00, 0x26,0x00, 0x18,0x18, + 0x48,0x00, 0x40,0x48, 0x58,0x00, 0x42,0x00, + 0x40,0x01, 0x64,0x80, 0xE0,0xE0, 0x43,0x24, + 0x0E,0x00, 0x32,0x00, 0xF4,0x01, 0x01,0x01 } ; +const u8 FW_BBInit[105] = { 0x6D, 0x9E, 0x40, 0x05, + 0x1B, 0x6C, 0x48, 0x80, + 0x38, 0x00, 0x35, 0x07, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0xb0, 0x00, 0x04, 0x01, + 0xd8, 0xff, 0xff, 0xc7, + 0xbb, 0x01, 0xb6, 0x7f, + 0x5a, 0x01, 0x3f, 0x01, + 0x3f, 0x36, 0x36, 0x00, + 0x78, 0x28, 0x55, 0x08, + 0x28, 0x16, 0x00, 0x01, + 0x0e, 0x20, 0x02, 0x98, + 0x98, 0x1f, 0x0a, 0x08, + 0x04, 0x01, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xfe, + 0xfe, 0xfe, 0xfe, 0xfc, + 0xfa, 0xfa, 0xf8, 0xf8, + 0xf6, 0xa5, 0x12, 0x14, + 0x12, 0x41, 0x23, 0x03, + 0x04, 0x70, 0x35, 0x0E, + 0x16, 0x16, 0x00, 0x00, + 0x06, 0x01, 0xff, 0xfe, + 0xff, 0xff, 0x00, 0x0e, + 0x13, 0x00, 0x00, 0x28, + 0x1c + } ; +const u8 FW_RFInit[36] = { 0x07, 0xC0, 0x00, + 0x03, 0x9C, 0x12, + 0x28, 0x17, 0x14, + 0xba, 0xe8, 0x1a, + 0x6f, 0x45, 0x1d, + 0xfa, 0xff, 0x23, + 0x30, 0x1d, 0x24, + 0x01, 0x00, 0x28, + 0x00, 0x00, 0x2c, + 0x03, 0x9c, 0x06, + 0x22, 0x00, 0x08, + 0x6f, 0xff, 0x0d + } ; +const u8 FW_RFChannel[6*14] = { 0x28, 0x17, 0x14, /* Channel 1 */ + 0xba, 0xe8, 0x1a, + 0x37, 0x17, 0x14, /* Channel 2 */ + 0x46, 0x17, 0x19, + 0x45, 0x17, 0x14, /* Channel 3 */ + 0xd1, 0x45, 0x1b, + 0x54, 0x17, 0x14, /* Channel 4 */ + 0x5d, 0x74, 0x19, + 0x62, 0x17, 0x14, /* Channel 5 */ + 0xe9, 0xa2, 0x1b, + 0x71, 0x17, 0x14, /* Channel 6 */ + 0x74, 0xd1, 0x19, + 0x80, 0x17, 0x14, /* Channel 7 */ + 0x00, 0x00, 0x18, + 0x8e, 0x17, 0x14, /* Channel 8 */ + 0x8c, 0x2e, 0x1a, + 0x9d, 0x17, 0x14, /* Channel 9 */ + 0x17, 0x5d, 0x18, + 0xab, 0x17, 0x14, /* Channel 10 */ + 0xa3, 0x8b, 0x1a, + 0xba, 0x17, 0x14, /* Channel 11 */ + 0x2f, 0xba, 0x18, + 0xc8, 0x17, 0x14, /* Channel 12 */ + 0xba, 0xe8, 0x1a, + 0xd7, 0x17, 0x14, /* Channel 13 */ + 0x46, 0x17, 0x19, + 0xfa, 0x17, 0x14, /* Channel 14 */ + 0x2f, 0xba, 0x18 + } ; +const u8 FW_BBChannel[14] = { 0xb3, 0xb3, 0xb3, 0xb3, 0xb3, /* channel 1- 6 */ + 0xb4, 0xb4, 0xb4, 0xb4, 0xb4, /* channel 7-10 */ + 0xb5, 0xb5, /* channel 11-12 */ + 0xb6, 0xb6 /* channel 13-14 */ + } ; + +/* Note : the values are inspired from what I found in a firmware image from my DS */ + +FW_WFCProfile FW_WFCProfile1 = {"SoftAP", + "", + "", + "", + "", + "", + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + 0, + "", + 0, + 0, + 0, + {0, 0, 0, 0, 0, 0, 0}, + 0, + {0xBA, 0xA0, 0x35, 0xE7, 0x01, 0xD0, 0x05, 0xAD, 0x39, 0x0F, 0x40, 0x1C, 0x2B, 0x2C}, + {0, 0} + } ; + +FW_WFCProfile FW_WFCProfile2 = {"", + "", + "", + "", + "", + "", + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + 0, + "", + 0, + 0, + 0xFF, + {0, 0, 0, 0, 0, 0, 0}, + 0, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0} + } ; + +FW_WFCProfile FW_WFCProfile3 = {"", + "", + "", + "", + "", + "", + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + 0, + "", + 0, + 0, + 0xFF, + {0, 0, 0, 0, 0, 0, 0}, + 0, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0} + } ; + +#ifdef EXPERIMENTAL_WIFI + +/******************************************************************************* + + Logging + + *******************************************************************************/ + +// 0: disable logging +// 1: lowest logging, shows most important messages such as errors +// 2: low logging, shows things such as warnings +// 3: medium logging, for debugging, shows lots of stuff +// 4: high logging, for debugging, shows almost everything, may slow down +// 5: highest logging, for debugging, shows everything, may slow down a lot +#define WIFI_LOGGING_LEVEL 3 + +#if (WIFI_LOGGING_LEVEL >= 1) +#define WIFI_LOG(level, ...) if(level <= WIFI_LOGGING_LEVEL) LOGC(8, "WIFI: "__VA_ARGS__); +#else +#define WIFI_LOG(level, ...) +#endif + +/******************************************************************************* + + Helpers + + *******************************************************************************/ + +INLINE u32 WIFI_alignedLen(u32 len) +{ + return ((len + 3) & ~3); +} + +#ifdef WIN32 +static pcap_t *desmume_pcap_open(const char *source, int snaplen, int flags, + int read_timeout, char *errbuf) +{ + return PCAP::pcap_open(source, snaplen, flags, read_timeout, NULL, errbuf); +} + +static int desmume_pcap_findalldevs(pcap_if_t **alldevs, char *errbuf) +{ + return PCAP::pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, alldevs, errbuf); +} + +static void desmume_pcap_freealldevs(pcap_if_t *alldevs) +{ + return PCAP::pcap_freealldevs(alldevs); +} + +static void desmume_pcap_close(pcap_t *p) +{ + return PCAP::pcap_close(p); +} + +static int desmume_pcap_sendpacket(pcap_t *p, u_char *buf, int size) +{ + return PCAP::pcap_sendpacket(p, buf, size); +} + +#else +static pcap_t *desmume_pcap_open(const char *device, int snaplen, int promisc, + int to_ms, char *errbuf) +{ + return pcap_open_live(device, snaplen, promisc, to_ms, errbuf); +} + +static int desmume_pcap_findalldevs(pcap_if_t **alldevs, char *errbuf) +{ + return pcap_findalldevs(alldevs, errbuf); +} + +static void desmume_pcap_freealldevs(pcap_if_t *alldevs) +{ + return pcap_freealldevs(alldevs); +} + +static void desmume_pcap_close(pcap_t *p) +{ + return pcap_close(p); +} + +static int desmume_pcap_sendpacket(pcap_t *p, u_char *buf, int size) +{ + return pcap_sendpacket(p, buf, size); +} +#endif + +/******************************************************************************* + + CRC32 (http://www.codeproject.com/KB/recipes/crc32_large.aspx) + + *******************************************************************************/ + +u32 WIFI_CRC32Table[256]; + +static u32 reflect(u32 ref, char ch) +{ + u32 value = 0; + + for(int i = 1; i < (ch + 1); i++) + { + if (ref & 1) + value |= 1 << (ch - i); + ref >>= 1; + } + + return value; +} + +static u32 WIFI_getCRC32(u8 *data, int len) +{ + u32 crc = 0xFFFFFFFF; + + while(len--) + crc = (crc >> 8) ^ WIFI_CRC32Table[(crc & 0xFF) ^ *data++]; + + return (crc ^ 0xFFFFFFFF); +} + +static void WIFI_initCRC32Table() +{ + static bool initialized = false; + if(initialized) return; + initialized = true; + + u32 polynomial = 0x04C11DB7; + + for(int i = 0; i < 0x100; i++) + { + WIFI_CRC32Table[i] = reflect(i, 8) << 24; + for(int j = 0; j < 8; j++) + WIFI_CRC32Table[i] = (WIFI_CRC32Table[i] << 1) ^ (WIFI_CRC32Table[i] & (1 << 31) ? polynomial : 0); + WIFI_CRC32Table[i] = reflect(WIFI_CRC32Table[i], 32); + } +} + +/******************************************************************************* + + RF-Chip + + *******************************************************************************/ + +static void WIFI_resetRF(rffilter_t *rf) { + /* reinitialize RF chip with the default values refer RF2958 docs */ + /* CFG1 */ + rf->CFG1.bits.IF_VGA_REG_EN = 1 ; + rf->CFG1.bits.IF_VCO_REG_EN = 1 ; + rf->CFG1.bits.RF_VCO_REG_EN = 1 ; + rf->CFG1.bits.HYBERNATE = 0 ; + rf->CFG1.bits.REF_SEL = 0 ; + /* IFPLL1 */ + rf->IFPLL1.bits.DAC = 3 ; + rf->IFPLL1.bits.P1 = 0 ; + rf->IFPLL1.bits.LD_EN1 = 0 ; + rf->IFPLL1.bits.AUTOCAL_EN1 = 0 ; + rf->IFPLL1.bits.PDP1 = 1 ; + rf->IFPLL1.bits.CPL1 = 0 ; + rf->IFPLL1.bits.LPF1 = 0 ; + rf->IFPLL1.bits.VTC_EN1 = 1 ; + rf->IFPLL1.bits.KV_EN1 = 0 ; + rf->IFPLL1.bits.PLL_EN1 = 0 ; + /* IFPLL2 */ + rf->IFPLL2.bits.IF_N = 0x22 ; + /* IFPLL3 */ + rf->IFPLL3.bits.KV_DEF1 = 8 ; + rf->IFPLL3.bits.CT_DEF1 = 7 ; + rf->IFPLL3.bits.DN1 = 0x1FF ; + /* RFPLL1 */ + rf->RFPLL1.bits.DAC = 3 ; + rf->RFPLL1.bits.P = 0 ; + rf->RFPLL1.bits.LD_EN = 0 ; + rf->RFPLL1.bits.AUTOCAL_EN = 0 ; + rf->RFPLL1.bits.PDP = 1 ; + rf->RFPLL1.bits.CPL = 0 ; + rf->RFPLL1.bits.LPF = 0 ; + rf->RFPLL1.bits.VTC_EN = 0 ; + rf->RFPLL1.bits.KV_EN = 0 ; + rf->RFPLL1.bits.PLL_EN = 0 ; + /* RFPLL2 */ + rf->RFPLL2.bits.NUM2 = 0 ; + rf->RFPLL2.bits.N2 = 0x5E ; + /* RFPLL3 */ + rf->RFPLL3.bits.NUM2 = 0 ; + /* RFPLL4 */ + rf->RFPLL4.bits.KV_DEF = 8 ; + rf->RFPLL4.bits.CT_DEF = 7 ; + rf->RFPLL4.bits.DN = 0x145 ; + /* CAL1 */ + rf->CAL1.bits.LD_WINDOW = 2 ; + rf->CAL1.bits.M_CT_VALUE = 8 ; + rf->CAL1.bits.TLOCK = 7 ; + rf->CAL1.bits.TVCO = 0x0F ; + /* TXRX1 */ + rf->TXRX1.bits.TXBYPASS = 0 ; + rf->TXRX1.bits.INTBIASEN = 0 ; + rf->TXRX1.bits.TXENMODE = 0 ; + rf->TXRX1.bits.TXDIFFMODE = 0 ; + rf->TXRX1.bits.TXLPFBW = 2 ; + rf->TXRX1.bits.RXLPFBW = 2 ; + rf->TXRX1.bits.TXVGC = 0 ; + rf->TXRX1.bits.PCONTROL = 0 ; + rf->TXRX1.bits.RXDCFBBYPS = 0 ; + /* PCNT1 */ + rf->PCNT1.bits.TX_DELAY = 0 ; + rf->PCNT1.bits.PC_OFFSET = 0 ; + rf->PCNT1.bits.P_DESIRED = 0 ; + rf->PCNT1.bits.MID_BIAS = 0 ; + /* PCNT2 */ + rf->PCNT2.bits.MIN_POWER = 0 ; + rf->PCNT2.bits.MID_POWER = 0 ; + rf->PCNT2.bits.MAX_POWER = 0 ; + /* VCOT1 */ + rf->VCOT1.bits.AUX1 = 0 ; + rf->VCOT1.bits.AUX = 0 ; +} ; + + +void WIFI_setRF_CNT(wifimac_t *wifi, u16 val) +{ +// printf("write rf cnt %04X\n", val); + if (!wifi->rfIOStatus.bits.busy) + wifi->rfIOCnt.val = val ; +} + +void WIFI_setRF_DATA(wifimac_t *wifi, u16 val, u8 part) +{ +// printf("write rf data %04X %s part\n", val, (part?"high":"low")); + if (!wifi->rfIOStatus.bits.busy) + { + rfIOData_t *rfreg = (rfIOData_t *)&wifi->RF; + switch (wifi->rfIOCnt.bits.readOperation) + { + case 1: /* read from RF chip */ + /* low part of data is ignored on reads */ + /* on high part, the address is read, and the data at this is written back */ + if (part==1) + { + wifi->rfIOData.array16[part] = val ; + if (wifi->rfIOData.bits.address > (sizeof(wifi->RF) / 4)) return ; /* out of bound */ + /* get content of the addressed register */ + wifi->rfIOData.bits.content = rfreg[wifi->rfIOData.bits.address].bits.content ; + } + break ; + case 0: /* write to RF chip */ + wifi->rfIOData.array16[part] = val ; + if (wifi->rfIOData.bits.address > (sizeof(wifi->RF) / 4)) return ; /* out of bound */ + /* the actual transfer is done on high part write */ + if (part==1) + { + switch (wifi->rfIOData.bits.address) + { + case 5: /* write to upper part of the frequency filter */ + case 6: /* write to lower part of the frequency filter */ + { + u32 channelFreqN ; + rfreg[wifi->rfIOData.bits.address].bits.content = wifi->rfIOData.bits.content ; + /* get the complete rfpll.n */ + channelFreqN = (u32)wifi->RF.RFPLL3.bits.NUM2 + ((u32)wifi->RF.RFPLL2.bits.NUM2 << 18) + ((u32)wifi->RF.RFPLL2.bits.N2 << 24) ; + /* frequency setting is out of range */ + if (channelFreqN<0x00A2E8BA) return ; + /* substract base frequency (channel 1) */ + channelFreqN -= 0x00A2E8BA ; + } + return ; + case 13: + /* special purpose register: TEST1, on write, the RF chip resets */ + WIFI_resetRF(&wifi->RF) ; + return ; + } + /* set content of the addressed register */ + rfreg[wifi->rfIOData.bits.address].bits.content = wifi->rfIOData.bits.content ; + } + break ; + } + } +} + +u16 WIFI_getRF_DATA(wifimac_t *wifi, u8 part) +{ +// printf("read rf data %s part\n", (part?"high":"low")); + if (!wifi->rfIOStatus.bits.busy) + { + return wifi->rfIOData.array16[part] ; + } else + { /* data is not (yet) available */ + return 0 ; + } + } + +u16 WIFI_getRF_STATUS(wifimac_t *wifi) +{ +// printf("read rf status\n"); + return wifi->rfIOStatus.val ; +} + +/******************************************************************************* + + BB-Chip + + *******************************************************************************/ + +void WIFI_setBB_CNT(wifimac_t *wifi,u16 val) +{ + wifi->bbIOCnt.val = val; + + if(wifi->bbIOCnt.bits.mode == 1) + wifi->BB.data[wifi->bbIOCnt.bits.address] = wifi->bbDataToWrite; +} + +u8 WIFI_getBB_DATA(wifimac_t *wifi) +{ + if((!wifi->bbIOCnt.bits.enable) || (wifi->bbIOCnt.bits.mode != 2)) + return 0; + + return wifi->BB.data[wifi->bbIOCnt.bits.address]; +// if ((wifi->bbIOCnt.bits.mode != 2) || !(wifi->bbIOCnt.bits.enable)) return 0 ; /* not for read or disabled */ +// return wifi->BB.data[wifi->bbIOCnt.bits.address] ; +} + +void WIFI_setBB_DATA(wifimac_t *wifi, u8 val) +{ + wifi->bbDataToWrite = (val); +// if ((wifi->bbIOCnt.bits.mode != 1) || !(wifi->bbIOCnt.bits.enable)) return ; /* not for write or disabled */ +// wifi->BB.data[wifi->bbIOCnt.bits.address] = val ; +} + +/******************************************************************************* + + wifimac IO: a lot of the wifi regs are action registers, that are mirrored + without action, so the default IO via MMU.c does not seem to + be very suitable + + all registers are 16 bit + + *******************************************************************************/ + +static void WIFI_triggerIRQMask(wifimac_t *wifi, u16 mask) +{ + u16 oResult,nResult ; + oResult = wifi->IE.val & wifi->IF.val ; + wifi->IF.val = wifi->IF.val | (mask & ~0x0400) ; + nResult = wifi->IE.val & wifi->IF.val ; + //printf("wifi: trigger irq: ie=%04X, if=%04X, mask=%08X, oldresult=%04X, newresult=%04X\n", + // wifi->IE.val, wifi->IF.val, mask, oResult, nResult); + if (!oResult && nResult) + { + NDS_makeARM7Int(24) ; /* cascade it via arm7 wifi irq */ + } +} + +static void WIFI_triggerIRQ(wifimac_t *wifi, u8 irq) +{ + WIFI_triggerIRQMask(wifi,1<RF) ; + wifi_netEnabled = false; + if(driver->WIFI_Host_InitSystem()) + { + wifi_netEnabled = true; + } + wifi->powerOn = FALSE; + wifi->powerOnPending = FALSE; + + wifi->rfStatus = 0x0000; + wifi->rfPins = 0x0004; +} + +static void WIFI_RXPutWord(wifimac_t *wifi,u16 val) +{ +// printf("wifi: rx circbuf write attempt: rxcnt=%04X, rxread=%04X, rxwrite=%04X\n", +// wifi->RXCnt, wifi->RXReadCursor, wifi->RXHWWriteCursor); + /* abort when RX data queuing is not enabled */ + if (!(wifi->RXCnt & 0x8000)) return ; + /* abort when ringbuffer is full */ + //if (wifi->RXReadCursor == wifi->RXHWWriteCursor) return ; + /*if(wifi->RXHWWriteCursor >= wifi->RXReadCursor) + { + printf("WIFI: write cursor (%04X) above READCSR (%04X). Cannot write received packet.\n", + wifi->RXHWWriteCursor, wifi->RXReadCursor); + return; + }*/ + /* write the data to cursor position */ + wifi->circularBuffer[wifi->RXHWWriteCursor & 0xFFF] = val; +// printf("wifi: written word %04X to circbuf addr %04X\n", val, (wifi->RXHWWriteCursor << 1)); + /* move cursor by one */ + //printf("written one word to %04X (start %04X, end %04X), ", wifi->RXHWWriteCursor, wifi->RXRangeBegin, wifi->RXRangeEnd); + wifi->RXHWWriteCursor++ ; + /* wrap around */ +// wifi->RXHWWriteCursor %= (wifi->RXRangeEnd - wifi->RXRangeBegin) >> 1 ; +// printf("new addr=%04X\n", wifi->RXHWWriteCursor); + if(wifi->RXHWWriteCursor >= ((wifi->RXRangeEnd & 0x1FFE) >> 1)) + wifi->RXHWWriteCursor = ((wifi->RXRangeBegin & 0x1FFE) >> 1); +} + +static void WIFI_TXStart(wifimac_t *wifi,u8 slot) +{ + WIFI_LOG(3, "TX slot %i trying to send a packet: TXCnt = %04X, TXBufLoc = %04X\n", + slot, wifi->TXCnt, wifi->TXSlot[slot]); + + if (wifi->TXSlot[slot] & 0x8000) /* is slot enabled? */ + { + u16 txLen; + /* the address has to be somewhere in the circular buffer, so drop the other bits */ + u16 address = (wifi->TXSlot[slot] & 0x0FFF); + /* is there even enough space for the header (6 hwords) in the tx buffer? */ + if (address > 0x1000-6) + { + WIFI_LOG(1, "TX slot %i trying to send a packet overflowing from the TX buffer (address %04X). Attempt ignored.\n", + slot, (address << 1)); + return; + } + + /* 12 byte header TX Header: http://www.akkit.org/info/dswifi.htm#FmtTx */ + txLen = wifi->circularBuffer[address+5]; + /* zero length */ + if (txLen == 0) + { + WIFI_LOG(1, "TX slot %i trying to send a packet with length field set to zero. Attempt ignored.\n", + slot); + return; + } + /* unsupported txRate */ + switch (wifi->circularBuffer[address+4] & 0xFF) + { + case 10: /* 1 mbit */ + case 20: /* 2 mbit */ + break; + default: /* other rates */ + WIFI_LOG(1, "TX slot %i trying to send a packet with transfer rate field set to an invalid value of %i. Attempt ignored.\n", + slot, wifi->circularBuffer[address+4] & 0xFF); + return; + } + + /* FIXME: calculate FCS */ + + WIFI_triggerIRQ(wifi, WIFI_IRQ_SENDSTART) ; + + if(slot > wifi->txCurSlot) + wifi->txCurSlot = slot; + + wifi->txSlotBusy[slot] = 1; + wifi->txSlotAddr[slot] = address; + wifi->txSlotLen[slot] = txLen; + wifi->txSlotRemainingBytes[slot] = (txLen + 12); + + wifi->rfStatus = 0x0003; + wifi->rfPins = 0x0046; + +#if 0 + WIFI_SoftAP_RecvPacketFromDS(wifi, (u8*)&wifi->circularBuffer[address+6], txLen); + WIFI_triggerIRQ(wifi, WIFI_IRQ_SENDCOMPLETE) ; + + wifi->circularBuffer[address] = 0x0001; + wifi->circularBuffer[address+4] &= 0x00FF; +#endif + } +} + +void WIFI_write16(wifimac_t *wifi,u32 address, u16 val) +{ + BOOL action = FALSE ; + if (!(MMU_read32(ARMCPU_ARM7,REG_PWRCNT) & 0x0002)) return ; /* access to wifi hardware was disabled */ + if ((address & 0xFF800000) != 0x04800000) return ; /* error: the address does not describe a wifi register */ + + WIFI_LOG(5, "Write at address %08X, %04X\n", address, val); + + /* the first 0x1000 bytes are mirrored at +0x1000,+0x2000,+0x3000,+06000,+0x7000 */ + /* only the first mirror causes an special action */ + /* the gap at +0x4000 is filled with the circular bufferspace */ + /* the so created 0x8000 byte block is then mirrored till 0x04FFFFFF */ + /* see: http://www.akkit.org/info/dswifi.htm#Wifihwcap */ + if (((address & 0x00007000) >= 0x00004000) && ((address & 0x00007000) < 0x00006000)) + { + /* access to the circular buffer */ + address &= 0x1FFF ; + // printf("wifi: circbuf write at %04X, %04X, readcsr=%04X, wrcsr=%04X(%04X)\n", + // address, val, wifi->RXReadCursor << 1, wifi->RXHWWriteCursorReg << 1, wifi->RXHWWriteCursor << 1); + /* if((address == 0x0BFE) && (val == 0x061E)) + { + extern void emu_halt(); + emu_halt(); + }*/ + wifi->circularBuffer[address >> 1] = val ; + return ; + } + if (!(address & 0x00007000)) action = TRUE ; + /* mirrors => register address */ + address &= 0x00000FFF ; + //if((address < 0x158) || ((address > 0x168) && (address < 0x17C)) || (address > 0x184)) + // printf("wifi write at %08X, %04X\n", address, val); +/* FILE *f = fopen("wifidbg.txt", "a"); + fprintf(f, "wifi write at %08X, %04X\n", address, val); + fclose(f);*/ + switch (address) + { + case REG_WIFI_ID: + break ; + case REG_WIFI_MODE: + if (val & 0x4000) + { + /* does some resets */ + wifi->RXRangeBegin = 0x4000 ; + /* this bit does not save */ + val &= ~0x4000 ; + } + + if(val & 0x0001) + { + wifi->rfStatus = 0x0009; + wifi->rfPins = 0x0004; + } + + wifi->macMode = val ; + break ; + case REG_WIFI_WEP: + wifi->wepMode = val ; + break ; + case REG_WIFI_IE: + wifi->IE.val = val ; + //printf("wifi ie write %04X\n", val); + break ; + case REG_WIFI_IF: + wifi->IF.val &= ~val ; /* clear flagging bits */ + break ; + case REG_WIFI_MAC0: + case REG_WIFI_MAC1: + case REG_WIFI_MAC2: + wifi->mac.words[(address - REG_WIFI_MAC0) >> 1] = val ; + break ; + case REG_WIFI_BSS0: + case REG_WIFI_BSS1: + case REG_WIFI_BSS2: + wifi->bss.words[(address - REG_WIFI_BSS0) >> 1] = val ; + break ; + case REG_WIFI_RETRYLIMIT: + wifi->retryLimit = val ; + break ; + case REG_WIFI_WEPCNT: + wifi->WEP_enable = (val & 0x8000) != 0 ; + break ; + case REG_WIFI_POWERSTATE: + wifi->powerOn = ((val & 0x0002)?TRUE:FALSE); + if(wifi->powerOn) WIFI_triggerIRQ(wifi, 11); + break; + case REG_WIFI_FORCEPS: + if((val & 0x8000) && (!wifi->powerOnPending)) + { + /* BOOL newPower = ((val & 0x0001)?FALSE:TRUE); + if(newPower != wifi->powerOn) + { + if(!newPower) + wifi->powerOn = FALSE; + else + wifi->powerOnPending = TRUE; + }*/ + wifi->powerOn = ((val & 0x0001) ? FALSE : TRUE); + } + break; + case REG_WIFI_POWERACK: + if((val == 0x0000) && wifi->powerOnPending) + { + wifi->powerOn = TRUE; + wifi->powerOnPending = FALSE; + } + break; + case REG_WIFI_RXCNT: + wifi->RXCnt = val; + if(wifi->RXCnt & 0x0001) + { + wifi->RXHWWriteCursor = wifi->RXHWWriteCursorReg = wifi->RXHWWriteCursorLatched; + //printf("wifi: write wrcsr %04X\n", wifi->RXHWWriteCursorReg); + } + break; + case REG_WIFI_RXRANGEBEGIN: + wifi->RXRangeBegin = val ; + if(wifi->RXHWWriteCursor < ((val & 0x1FFE) >> 1)) + wifi->RXHWWriteCursor = ((val & 0x1FFE) >> 1); + //printf("wifi: rx range begin=%04X\n", val); + break ; + case REG_WIFI_RXRANGEEND: + wifi->RXRangeEnd = val ; + if(wifi->RXHWWriteCursor >= ((val & 0x1FFE) >> 1)) + wifi->RXHWWriteCursor = ((wifi->RXRangeBegin & 0x1FFE) >> 1); + //printf("wifi: rx range end=%04X\n", val); + break ; + case REG_WIFI_WRITECSRLATCH: + if (action) /* only when action register and CSR change enabled */ + { + wifi->RXHWWriteCursorLatched = val ; + } + break ; + case REG_WIFI_CIRCBUFRADR: + wifi->CircBufReadAddress = (val & 0x1FFE); + break ; + case REG_WIFI_RXREADCSR: + //printf("wifi: write readcsr: %04X\n", val << 1); + wifi->RXReadCursor = val ; + break ; + case REG_WIFI_CIRCBUFWADR: + wifi->CircBufWriteAddress = val ; + break ; + case REG_WIFI_CIRCBUFWRITE: + /* set value into the circ buffer, and move cursor to the next hword on action */ + //printf("wifi: circbuf fifo write at %04X, %04X (action=%i)\n", (wifi->CircBufWriteAddress & 0x1FFF), val, action); + wifi->circularBuffer[(wifi->CircBufWriteAddress >> 1) & 0xFFF] = val ; + if (action) + { + /* move to next hword */ + wifi->CircBufWriteAddress+=2 ; + if (wifi->CircBufWriteAddress == wifi->CircBufWrEnd) + { + /* on end of buffer, add skip hwords to it */ + wifi->CircBufWrEnd += wifi->CircBufWrSkip * 2 ; + } + } + break ; + case REG_WIFI_CIRCBUFWR_SKIP: + wifi->CircBufWrSkip = val ; + break ; + case REG_WIFI_BEACONTRANS: + wifi->BEACONSlot = val & 0x7FFF ; + wifi->BEACON_enable = (val & 0x8000) != 0 ; + //printf("wifi beacon: enable=%s, addr=%04X\n", (wifi->BEACON_enable?"yes":"no"), (wifi->BEACONSlot<<1)); + break ; + case REG_WIFI_TXLOC1: + case REG_WIFI_TXLOC2: + case REG_WIFI_TXLOC3: + wifi->TXSlot[(address - REG_WIFI_TXLOC1) >> 2] = val ; + break ; + case REG_WIFI_TXOPT: +#if 0 + if (val == 0xFFFF) + { + /* reset TX logic */ + /* CHECKME */ + // wifi->TXSlot[0] = 0 ; wifi->TXSlot[1] = 0 ; wifi->TXSlot[2] = 0 ; + wifi->TXOpt = 0 ; + wifi->TXCnt = 0 ; + } else + { + wifi->TXOpt = val ; + } +#endif + wifi->TXCnt &= ~val; + break ; + case REG_WIFI_TXCNT: + wifi->TXCnt |= val ; + if (val & 0x01) WIFI_TXStart(wifi,0) ; + if (val & 0x04) WIFI_TXStart(wifi,1) ; + if (val & 0x08) WIFI_TXStart(wifi,2) ; + /* if(val&0x04) + { + extern void emu_halt(); + emu_halt(); + }*/ + break ; + case REG_WIFI_RFIOCNT: + WIFI_setRF_CNT(wifi,val) ; + break ; + case REG_WIFI_RFIOBSY: + /* CHECKME: read only? */ + break ; + case REG_WIFI_RFIODATA1: + WIFI_setRF_DATA(wifi,val,0) ; + break ; + case REG_WIFI_RFIODATA2: + WIFI_setRF_DATA(wifi,val,1) ; + break ; + case REG_WIFI_USCOUNTERCNT: + wifi->usecEnable = (val & 1)==1 ; + break ; + case REG_WIFI_USCOMPARECNT: + wifi->ucmpEnable = (val & 1)==1 ; + break ; + case REG_WIFI_BBSIOCNT: + WIFI_setBB_CNT(wifi,val) ; + break ; + case REG_WIFI_BBSIOWRITE: + WIFI_setBB_DATA(wifi,val&0xFF) ; + break ; + case REG_WIFI_RXBUF_COUNT: + wifi->RXBufCount = val & 0x0FFF ; + break ; + case REG_WIFI_EXTRACOUNTCNT: + wifi->eCountEnable = (val & 0x0001) ; + break ; + case REG_WIFI_EXTRACOUNT: + wifi->eCount = val ; + break ; + case REG_WIFI_POWER_US: + wifi->crystalEnabled = !(val & 0x0001) ; + break ; + case REG_WIFI_IF_SET: + WIFI_triggerIRQMask(wifi,val) ; + break ; + case REG_WIFI_CIRCBUFRD_END: + wifi->CircBufRdEnd = (val & 0x1FFE) ; + break ; + case REG_WIFI_CIRCBUFRD_SKIP: + wifi->CircBufRdSkip = val & 0xFFF ; + break ; + case REG_WIFI_AID_LOW: + wifi->pid = val & 0x0F ; + break ; + case REG_WIFI_AID_HIGH: + wifi->aid = val & 0x07FF ; + break ; + //case 0x36: + //case 0x38: + //case 0x3C: + //case 0x40: + // printf("wifi power reg %03X write %04X\n", address, val); + // break; + case 0xD0: + // printf("wifi: rxfilter=%04X\n", val); + break; + default: + // printf("wifi: write unhandled reg %03X, %04X\n", address, val); + // val = 0 ; /* not handled yet */ + break ; + } + + wifi->ioMem[address >> 1] = val; +} +//int packet_arrived=0; +u16 WIFI_read16(wifimac_t *wifi,u32 address) +{ + BOOL action = FALSE ; + u16 temp ; + if (!(MMU_read32(ARMCPU_ARM7,REG_PWRCNT) & 0x0002)) return 0 ; /* access to wifi hardware was disabled */ + if ((address & 0xFF800000) != 0x04800000) return 0 ; /* error: the address does not describe a wifi register */ + + WIFI_LOG(5, "Read at address %08X\n", address); + + /* the first 0x1000 bytes are mirrored at +0x1000,+0x2000,+0x3000,+06000,+0x7000 */ + /* only the first mirror causes an special action */ + /* the gap at +0x4000 is filled with the circular bufferspace */ + /* the so created 0x8000 byte block is then mirrored till 0x04FFFFFF */ + /* see: http://www.akkit.org/info/dswifi.htm#Wifihwcap */ + if (((address & 0x00007000) >= 0x00004000) && ((address & 0x00007000) < 0x00006000)) + { + /* access to the circular buffer */ + // printf("wifi: circbuf read at %04X, %04X, readcsr=%04X, wrcsr=%04X(%04X)\n", + // address, wifi->circularBuffer[(address & 0x1FFF) >> 1], wifi->RXReadCursor << 1, wifi->RXHWWriteCursorReg << 1, wifi->RXHWWriteCursor << 1); + /*if(((address == 0x04804C38) || + (address == 0x04804C04)) && + (wifi->circularBuffer[(address & 0x1FFF) >> 1] != 0x0000) && + (wifi->circularBuffer[(address & 0x1FFF) >> 1] != 0x5A5A) && + (wifi->circularBuffer[(address & 0x1FFF) >> 1] != 0xA5A5)) + { + extern void emu_halt(); + emu_halt(); + }*/ + + // hax + /* if(packet_arrived) + { + if(address == 0x04804C38) + return 0x0010; + if(address == 0x04804C3E) + return 0x0014; + + if(address == 0x048047D0) + return 0x0010; + if(address == 0x048047D6) + return 0x0014; + }*/ + + return wifi->circularBuffer[(address & 0x1FFF) >> 1] ; + } + if (!(address & 0x00007000)) action = TRUE ; + //if((address != 0x04808214) && (address != 0x0480803C) && (address != 0x048080F8) && (address != 0x048080FA) && (address != 0x0480819C)) + /* mirrors => register address */ + address &= 0x00000FFF ; +// if((address < 0x158) || ((address > 0x168) && (address < 0x17C)) || (address > 0x184)) +// printf("wifi read at %08X\n", address); +/* FILE *f = fopen("wifidbg.txt", "a"); + fprintf(f, "wifi read at %08X\n", address); + fclose(f);*/ + switch (address) + { + case REG_WIFI_ID: + return WIFI_CHIPID ; + case REG_WIFI_MODE: + return wifi->macMode ; + case REG_WIFI_WEP: + return wifi->wepMode ; + case REG_WIFI_IE: + //printf("wifi: read ie (%04X)\n", wifi->IE.val); + return wifi->IE.val ; + case REG_WIFI_IF: + //printf("wifi: read if (%04X)\n", wifi->IF.val); + return wifi->IF.val ; + case REG_WIFI_POWERSTATE: + return ((wifi->powerOn ? 0x0000 : 0x0200) | (wifi->powerOnPending ? 0x0102 : 0x0000)); + case REG_WIFI_RFIODATA1: + return WIFI_getRF_DATA(wifi,0) ; + case REG_WIFI_RFIODATA2: + return WIFI_getRF_DATA(wifi,1) ; + case REG_WIFI_RFIOBSY: + case REG_WIFI_BBSIOBUSY: + return 0 ; /* we are never busy :p */ + case REG_WIFI_BBSIOREAD: + return WIFI_getBB_DATA(wifi) ; + case REG_WIFI_RANDOM: + /* FIXME: random generator */ + return (rand() & 0x7FF); + return 0 ; + case REG_WIFI_MAC0: + case REG_WIFI_MAC1: + case REG_WIFI_MAC2: + //printf("read mac addr: word %i = %02X\n", (address - REG_WIFI_MAC0) >> 1, wifi->mac.words[(address - REG_WIFI_MAC0) >> 1]); + return wifi->mac.words[(address - REG_WIFI_MAC0) >> 1] ; + case REG_WIFI_BSS0: + case REG_WIFI_BSS1: + case REG_WIFI_BSS2: + //printf("read bssid addr: word %i = %02X\n", (address - REG_WIFI_BSS0) >> 1, wifi->bss.words[(address - REG_WIFI_BSS0) >> 1]); + return wifi->bss.words[(address - REG_WIFI_BSS0) >> 1] ; + case REG_WIFI_RXCNT: + return wifi->RXCnt; + case REG_WIFI_RXRANGEBEGIN: + return wifi->RXRangeBegin ; + case REG_WIFI_CIRCBUFREAD: + temp = wifi->circularBuffer[((wifi->RXRangeBegin + wifi->CircBufReadAddress) >> 1) & 0x0FFF] ; + //printf("wifi: circbuf fifo read at %04X, action=%i\n", (wifi->RXRangeBegin + wifi->CircBufReadAddress), action); + if (action) + { + wifi->CircBufReadAddress += 2 ; + wifi->CircBufReadAddress &= 0x1FFE ; + if (wifi->CircBufReadAddress + wifi->RXRangeBegin == wifi->RXRangeEnd) + { + wifi->CircBufReadAddress = 0 ; + } else + { + /* skip does not fire after a reset */ + if (wifi->CircBufReadAddress == wifi->CircBufRdEnd) + { + wifi->CircBufReadAddress += wifi->CircBufRdSkip * 2 ; + wifi->CircBufReadAddress &= 0x1FFE ; + if (wifi->CircBufReadAddress + wifi->RXRangeBegin == wifi->RXRangeEnd) wifi->CircBufReadAddress = 0 ; + } + } + if (wifi->RXBufCount > 0) + { + if (wifi->RXBufCount == 1) + { + WIFI_triggerIRQ(wifi,9) ; + } + wifi->RXBufCount-- ; + } + } + return temp; + case REG_WIFI_CIRCBUFRADR: + return wifi->CircBufReadAddress ; + case REG_WIFI_RXHWWRITECSR: + //printf("wifi: read writecsr (%04X)\n", wifi->RXHWWriteCursorReg); + return wifi->RXHWWriteCursorReg; + //return wifi->RXReadCursor; + case REG_WIFI_RXREADCSR: + //printf("wifi: read readcsr (%04X)\n", wifi->RXReadCursor); + return wifi->RXReadCursor; + //return wifi->RXHWWriteCursorReg; + case REG_WIFI_RXBUF_COUNT: + return wifi->RXBufCount ; + case REG_WIFI_TXREQ_READ: + return wifi->TXCnt; + case REG_WIFI_TXBUSY: + return ((wifi->txSlotBusy[0] ? 0x01 : 0x00) | (wifi->txSlotBusy[1] ? 0x04 : 0x00) | (wifi->txSlotBusy[2] ? 0x08 : 0x00)); + case REG_WIFI_TXSTAT: + return wifi->TXStat; + case REG_WIFI_EXTRACOUNTCNT: + return wifi->eCountEnable?1:0 ; + case REG_WIFI_EXTRACOUNT: + return wifi->eCount ; + case REG_WIFI_USCOMPARE0: + return (u16)wifi->usec; + case REG_WIFI_USCOMPARE1: + return (u16)(wifi->usec >> 16); + case REG_WIFI_USCOMPARE2: + return (u16)(wifi->usec >> 32); + case REG_WIFI_USCOMPARE3: + return (u16)(wifi->usec >> 48); + case REG_WIFI_POWER_US: + return wifi->crystalEnabled?0:1 ; + case REG_WIFI_CIRCBUFRD_END: + return wifi->CircBufRdEnd ; + case REG_WIFI_CIRCBUFRD_SKIP: + return wifi->CircBufRdSkip ; + case REG_WIFI_AID_LOW: + return wifi->pid ; + case REG_WIFI_AID_HIGH: + return wifi->aid ; + case 0x214: + //printf("wifi: read rfstatus (%04X)\n", wifi->rfStatus); + return 0x0009; + //return wifi->rfStatus; + case 0x19C: + //assert(false); //luigi, please pick something to return from here + //printf("wifi: read rfpins (%04X)\n", wifi->rfPins); + //return wifi->rfPins; + return 0x0004; + default: + // printf("wifi: read unhandled reg %03X\n", address); + return wifi->ioMem[address >> 1]; + } +} + + +void WIFI_usTrigger(wifimac_t *wifi) +{ + if (wifi->crystalEnabled) + { + /* a usec (=3F03 cycles) has passed */ + if (wifi->usecEnable) + wifi->usec++ ; + if (wifi->eCountEnable) + { + if (wifi->eCount > 0) + { + wifi->eCount-- ; + } + } + } + if ((wifi->ucmpEnable) && (wifi->ucmp == wifi->usec)) + { + WIFI_triggerIRQ(wifi, WIFI_IRQ_TIMEBEACON) ; + } + + if((wifi->usec & 3) == 0) + { + int slot = wifi->txCurSlot; + + if(wifi->txSlotBusy[slot]) + { + wifi->txSlotRemainingBytes[slot]--; + if(wifi->txSlotRemainingBytes[slot] == 0) + { + wifi->txSlotBusy[slot] = 0; + + WIFI_SoftAP_RecvPacketFromDS(wifi, (u8*)&wifi->circularBuffer[wifi->txSlotAddr[slot]], wifi->txSlotLen[slot]); + + while((wifi->txSlotBusy[wifi->txCurSlot] == 0) && (wifi->txCurSlot > 0)) + wifi->txCurSlot--; + + wifi->circularBuffer[wifi->txSlotAddr[slot]] = 0x0001; + wifi->circularBuffer[wifi->txSlotAddr[slot]+4] &= 0x00FF; + + wifi->TXStat = (0x0001 | (slot << 12)); + + WIFI_triggerIRQ(wifi, WIFI_IRQ_SENDCOMPLETE); + + //wifi->rfStatus = 0x0001; + //wifi->rfPins = 0x0084; + wifi->rfStatus = 0x0009; + wifi->rfPins = 0x0004; + + WIFI_LOG(3, "TX slot %i finished sending its packet. Next is slot %i. TXStat = %04X\n", + slot, wifi->txCurSlot, wifi->TXStat); + } + } + } +} + +/******************************************************************************* + + SoftAP (fake wifi access point) + + *******************************************************************************/ + +u8 SoftAP_MACAddr[6] = {0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D}; + +u8 SoftAP_Beacon[] = { + /* 802.11 header */ + 0x80, 0x00, // Frame control + 0x00, 0x00, // Duration ID + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Receiver + 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // Sender + 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // BSSID + 0x00, 0x00, // Sequence control + + /* Frame body */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Timestamp + 0x64, 0x00, // Beacon interval + 0x0F, 0x00, // Capablilty information + 0x00, 0x06, 'S', 'o', 'f', 't', 'A', 'P', // SSID + 0x01, 0x02, 0x82, 0x84, // Supported rates + 0x05, 0x04, 0x00, 0x00, 0x00, 0x00, // TIM + + /* CRC32 */ + 0x00, 0x00, 0x00, 0x00 +}; + +u8 SoftAP_ProbeResponse[] = { + /* 802.11 header */ + 0x50, 0x00, // Frame control + 0x00, 0x00, // Duration ID + 0x00, 0x09, 0xBF, 0x12, 0x34, 0x56, // Receiver + 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // Sender + 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // BSSID + 0x00, 0x00, // Sequence control + + /* Frame body */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Timestamp + 0x64, 0x00, // Beacon interval + 0x01, 0x00, // Capablilty information + 0x00, 0x06, 'S', 'o', 'f', 't', 'A', 'P', // SSID + 0x01, 0x02, 0x82, 0x84, // Supported rates + + /* CRC32 */ + 0x00, 0x00, 0x00, 0x00 +}; + +u8 SoftAP_AuthFrame[] = { + /* 802.11 header */ + 0xB0, 0x00, // Frame control + 0x00, 0x00, // Duration ID + 0x00, 0x09, 0xBF, 0x12, 0x34, 0x56, // Receiver + 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // Sender + 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // BSSID + 0x00, 0x00, // Sequence control + + /* Frame body */ + 0x00, 0x00, // Authentication algorithm + 0x02, 0x00, // Authentication sequence + 0x00, 0x00, // Status + + /* CRC32 */ + 0x00, 0x00, 0x00, 0x00 +}; + +u8 SoftAP_AssocResponse[] = { + /* 802.11 header */ + 0x10, 0x00, // Frame control + 0x00, 0x00, // Duration ID + 0x00, 0x09, 0xBF, 0x12, 0x34, 0x56, // Receiver + 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // Sender + 0x00, 0xF0, 0x1A, 0x2B, 0x3C, 0x4D, // BSSID + 0x00, 0x00, // Sequence control + + /* Frame body */ + 0x0F, 0x00, // Capability information + 0x00, 0x00, // Status + 0x01, 0xC0, // Assocation ID + 0x01, 0x02, 0x82, 0x84, // Supported rates + + /* CRC32 */ + 0x00, 0x00, 0x00, 0x00 +}; + +//todo - make a class to wrap this +//todo - zeromus - inspect memory leak safety of all this +static pcap_if_t * WIFI_index_device(pcap_if_t *alldevs, int index) { + pcap_if_t *curr = alldevs; + for(int i=0;inext; + return curr; +} + +int WIFI_SoftAP_Init(wifimac_t *wifi) +{ + char errbuf[PCAP_ERRBUF_SIZE]; + pcap_if_t *alldevs; + + wifi->SoftAP.usecCounter = 0; + + wifi->SoftAP.curPacketSize = 0; + wifi->SoftAP.curPacketPos = 0; + wifi->SoftAP.curPacketSending = FALSE; + + if(wifi_netEnabled) + { + if(desmume_pcap_findalldevs(&alldevs, errbuf) == -1) + { + printf("SoftAP: PCAP error with pcap_findalldevs_ex(): %s\n", errbuf); + return 0; + } + + wifi_bridge = desmume_pcap_open(WIFI_index_device(alldevs,CommonSettings.wifiBridgeAdapterNum)->name, PACKET_SIZE, 0, 1, errbuf); + if(wifi_bridge == NULL) + { + printf("SoftAP: PCAP error with pcap_open(): %s\n", errbuf); + return 0; + } + + desmume_pcap_freealldevs(alldevs); + } + + return 1; +} + +void WIFI_SoftAP_Shutdown(wifimac_t *wifi) +{ + if(wifi_netEnabled) + { + if(wifi_bridge != NULL) + desmume_pcap_close(wifi_bridge); + } +} + +static void WIFI_SoftAP_MakeRXHeader(wifimac_t *wifi, u16 flags, u16 xferRate, u16 len, u8 maxRSSI, u8 minRSSI) +{ + *(u16*)&wifi->SoftAP.curPacket[0] = flags; + + // Unknown (usually 0x0400) + wifi->SoftAP.curPacket[2] = 0x40; + wifi->SoftAP.curPacket[3] = 0x00; + + // Time since last packet??? Random??? Left unchanged??? + wifi->SoftAP.curPacket[4] = 0x01; + wifi->SoftAP.curPacket[5] = 0x00; + + *(u16*)&wifi->SoftAP.curPacket[6] = xferRate; + + *(u16*)&wifi->SoftAP.curPacket[8] = WIFI_alignedLen(len); + + wifi->SoftAP.curPacket[10] = maxRSSI; + wifi->SoftAP.curPacket[11] = minRSSI; +} + +void WIFI_SoftAP_RecvPacketFromDS(wifimac_t *wifi, u8 *packet, int len) +{ + int alignedLen = WIFI_alignedLen(len); + u16 frameCtl = *(u16*)&packet[12]; + + WIFI_LOG(3, "SoftAP: Received a packet of length %i bytes (%i aligned). Frame control = %04X\n", + len, alignedLen, frameCtl); + + switch((frameCtl >> 2) & 0x3) + { + case 0x0: // Management + { + switch((frameCtl >> 4) & 0xF) + { + case 0x4: // Probe request (Nintendo WFC config util) + { + int packetLen = sizeof(SoftAP_ProbeResponse); + int totalLen = (packetLen + 12); + + // Make the RX header + // About the packet length: + // GBATek says the length entry of the RX header is the length of the IEEE + // header and frame body, without including the FCS. But the Nintendo WFC + // config util expects this length to be the length of the IEEE header and + // the frame body AND the FCS. Actually, it expects WRCSR to be equal to + // (READCSR + 12 + packet_length). + WIFI_SoftAP_MakeRXHeader(wifi, 0x0010, 20, packetLen, 0, 0); + + // Copy the probe response template + memcpy(&wifi->SoftAP.curPacket[12], SoftAP_ProbeResponse, packetLen); + + // Add the MAC address + memcpy(&wifi->SoftAP.curPacket[12 + 4], FW_Mac, 6); + + // The timestamp + u64 timestamp = (wifi->SoftAP.usecCounter / 1000); // FIXME: is it correct? + *(u64*)&wifi->SoftAP.curPacket[12 + 24] = timestamp; + + // And the CRC32 (FCS) + u32 crc32 = WIFI_getCRC32(&wifi->SoftAP.curPacket[12], (packetLen - 4)); + *(u32*)&wifi->SoftAP.curPacket[12 + packetLen - 4] = crc32; + + // Let's prepare to send + wifi->SoftAP.curPacketSize = totalLen; + wifi->SoftAP.curPacketPos = 0; + wifi->SoftAP.curPacketSending = TRUE; + } + break; + + case 0xB: // Authentication + { + int packetLen = sizeof(SoftAP_AuthFrame); + int totalLen = (packetLen + 12); + + // Make the RX header + WIFI_SoftAP_MakeRXHeader(wifi, 0x0010, 20, packetLen, 0, 0); + + // Copy the authentication frame template + memcpy(&wifi->SoftAP.curPacket[12], SoftAP_AuthFrame, packetLen); + + // Add the MAC address + memcpy(&wifi->SoftAP.curPacket[12 + 4], FW_Mac, 6); + + // And the CRC32 (FCS) + u32 crc32 = WIFI_getCRC32(&wifi->SoftAP.curPacket[12], (packetLen - 4)); + *(u32*)&wifi->SoftAP.curPacket[12 + packetLen - 4] = crc32; + + // Let's prepare to send + wifi->SoftAP.curPacketSize = totalLen; + wifi->SoftAP.curPacketPos = 0; + wifi->SoftAP.curPacketSending = TRUE; + } + break; + + case 0x0: // Association request + { + int packetLen = sizeof(SoftAP_AssocResponse); + int totalLen = (packetLen + 12); + + // Make the RX header + WIFI_SoftAP_MakeRXHeader(wifi, 0x0010, 20, packetLen, 0, 0); + + // Copy the association response template + memcpy(&wifi->SoftAP.curPacket[12], SoftAP_AssocResponse, packetLen); + + // Add the MAC address + memcpy(&wifi->SoftAP.curPacket[12 + 4], FW_Mac, 6); + + // And the CRC32 (FCS) + u32 crc32 = WIFI_getCRC32(&wifi->SoftAP.curPacket[12], (packetLen - 4)); + *(u32*)&wifi->SoftAP.curPacket[12 + packetLen - 4] = crc32; + + // Let's prepare to send + wifi->SoftAP.curPacketSize = totalLen; + wifi->SoftAP.curPacketPos = 0; + wifi->SoftAP.curPacketSending = TRUE; + } + break; + } + } + break; + + case 0x2: // Data + { + // We convert the packet into an Ethernet packet + + int eflen = (alignedLen - 4 - 30 + 14); + u8 *ethernetframe = new u8[eflen]; + + // Destination address + ethernetframe[0] = packet[28]; + ethernetframe[1] = packet[29]; + ethernetframe[2] = packet[30]; + ethernetframe[3] = packet[31]; + ethernetframe[4] = packet[32]; + ethernetframe[5] = packet[33]; + + // Source address + ethernetframe[6] = packet[22]; + ethernetframe[7] = packet[23]; + ethernetframe[8] = packet[24]; + ethernetframe[9] = packet[25]; + ethernetframe[10] = packet[26]; + ethernetframe[11] = packet[27]; + + // EtherType + ethernetframe[12] = packet[42]; + ethernetframe[13] = packet[43]; + + // Frame body + memcpy((ethernetframe + 14), (packet + 44), (alignedLen - 30 - 4)); + + // Checksum + // TODO ? + + if(wifi_netEnabled) //dont try to pcap out the packet unless network is enabled + desmume_pcap_sendpacket(wifi_bridge, ethernetframe, eflen); + + delete ethernetframe; + } + break; + } +} + +static void WIFI_SoftAP_SendBeacon(wifimac_t *wifi) +{ + int packetLen = sizeof(SoftAP_Beacon); + int totalLen = (packetLen + 12); + + // Make the RX header + WIFI_SoftAP_MakeRXHeader(wifi, 0x0011, 20, packetLen, 0, 0); + + // Copy the beacon template + memcpy(&wifi->SoftAP.curPacket[12], SoftAP_Beacon, packetLen); + + // Add the timestamp + u64 timestamp = (wifi->SoftAP.usecCounter / 1000); // FIXME: is it correct? + *(u64*)&wifi->SoftAP.curPacket[12 + 24] = timestamp; + + // And the CRC32 (FCS) + u32 crc32 = WIFI_getCRC32(&wifi->SoftAP.curPacket[12], (packetLen - 4)); + *(u32*)&wifi->SoftAP.curPacket[12 + packetLen - 4] = crc32; + + // Let's prepare to send + wifi->SoftAP.curPacketSize = totalLen; + wifi->SoftAP.curPacketPos = 0; + wifi->SoftAP.curPacketSending = TRUE; +} + +void WIFI_SoftAP_usTrigger(wifimac_t *wifi) +{ + wifi->SoftAP.usecCounter++; + + if(!wifi->SoftAP.curPacketSending) + { + //if(wifi->ioMem[0xD0 >> 1] & 0x0400) + { + //zero sez: every 1/10 second? does it have to be precise? this is so costly.. + //if((wifi->SoftAP.usecCounter % 100000) == 0) + if((wifi->SoftAP.usecCounter & 131071) == 0) + { + WIFI_SoftAP_SendBeacon(wifi); + } + } + } + + /* Given a connection of 2 megabits per second, */ + /* we take ~4 microseconds to transfer a byte, */ + /* ie ~8 microseconds to transfer a word. */ + if((wifi->SoftAP.curPacketSending) && !(wifi->SoftAP.usecCounter & 7)) + { + if(wifi->SoftAP.curPacketPos >= 0) + { + if(wifi->SoftAP.curPacketPos == 0) + { + WIFI_triggerIRQ(wifi, WIFI_IRQ_RECVSTART); + + wifi->rfStatus = 0x0009; + wifi->rfPins = 0x0004; + + // printf("wifi: softap: started sending packet at %04X\n", wifi->RXHWWriteCursor << 1); + // wifi->SoftAP.curPacketPos += 2; + } + else + { + wifi->rfStatus = 0x0001; + wifi->rfPins = 0x0084; + } + + u16 word = (wifi->SoftAP.curPacket[wifi->SoftAP.curPacketPos] | (wifi->SoftAP.curPacket[wifi->SoftAP.curPacketPos+1] << 8)); + WIFI_RXPutWord(wifi, word); + } + + wifi->SoftAP.curPacketPos += 2; + if(wifi->SoftAP.curPacketPos >= wifi->SoftAP.curPacketSize) + { + wifi->SoftAP.curPacketSize = 0; + wifi->SoftAP.curPacketPos = 0; + wifi->SoftAP.curPacketSending = FALSE; + + wifi->RXHWWriteCursorReg = ((wifi->RXHWWriteCursor + 1) & (~1)); + + WIFI_triggerIRQ(wifi, WIFI_IRQ_RECVCOMPLETE); + + // hax + //packet_arrived=1; + + //printf("wifi: softap: finished sending packet. end at %04X (aligned=%04X)\n", wifi->RXHWWriteCursor << 1, wifi->RXHWWriteCursorReg << 1); + } + } +} + +#endif diff --git a/desmume/src/wifi.h b/src/wifi.h similarity index 89% rename from desmume/src/wifi.h rename to src/wifi.h index f50cba435..5d459b9f2 100644 --- a/desmume/src/wifi.h +++ b/src/wifi.h @@ -1,549 +1,564 @@ -/* Copyright (C) 2007 Tim Seidel - Copyright (C) 2008-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifndef WIFI_H -#define WIFI_H - -#include -#include "types.h" - -#ifdef EXPERIMENTAL_WIFI - -#define HAVE_REMOTE -#define WPCAP -#define PACKET_SIZE 65535 -#define _INC_STDIO - -#endif - -#define REG_WIFI_ID 0x000 -#define REG_WIFI_MODE 0x004 -#define REG_WIFI_WEP 0x006 -#define REG_WIFI_IF 0x010 -#define REG_WIFI_IE 0x012 -#define REG_WIFI_MAC0 0x018 -#define REG_WIFI_MAC1 0x01A -#define REG_WIFI_MAC2 0x01C -#define REG_WIFI_BSS0 0x020 -#define REG_WIFI_BSS1 0x022 -#define REG_WIFI_BSS2 0x024 -#define REG_WIFI_AID_LOW 0x028 -#define REG_WIFI_AID_HIGH 0x02A -#define REG_WIFI_RETRYLIMIT 0x02C -#define REG_WIFI_RXCNT 0x030 -#define REG_WIFI_WEPCNT 0x032 -#define REG_WIFI_POWER_US 0x036 -#define REG_WIFI_POWERSTATE 0x03C -#define REG_WIFI_FORCEPS 0x040 -#define REG_WIFI_RANDOM 0x044 -#define REG_WIFI_RXRANGEBEGIN 0x050 -#define REG_WIFI_RXRANGEEND 0x052 -#define REG_WIFI_RXHWWRITECSR 0x054 -#define REG_WIFI_WRITECSRLATCH 0x056 -#define REG_WIFI_CIRCBUFRADR 0x058 -#define REG_WIFI_RXREADCSR 0x05A -#define REG_WIFI_RXBUF_COUNT 0x05C -#define REG_WIFI_CIRCBUFREAD 0x060 -#define REG_WIFI_CIRCBUFRD_END 0x062 -#define REG_WIFI_CIRCBUFRD_SKIP 0x064 -#define REG_WIFI_CIRCBUFWADR 0x068 -#define REG_WIFI_CIRCBUFWRITE 0x070 -#define REG_WIFI_CIRCBUFWR_END 0x074 -#define REG_WIFI_CIRCBUFWR_SKIP 0x076 -#define REG_WIFI_BEACONTRANS 0x080 -#define REG_WIFI_LISTENCOUNT 0x088 -#define REG_WIFI_BEACONPERIOD 0x08C -#define REG_WIFI_LISTENINT 0x08E -#define REG_WIFI_TXLOC1 0x0A0 -#define REG_WIFI_TXLOC2 0x0A4 -#define REG_WIFI_TXLOC3 0x0A8 -#define REG_WIFI_TXOPT 0x0AC -#define REG_WIFI_TXCNT 0x0AE -#define REG_WIFI_TXREQ_READ 0x0B0 -#define REG_WIFI_TXBUSY 0x0B6 -#define REG_WIFI_TXSTAT 0x0B8 -#define REG_WIFI_RXFILTER 0x0D0 -#define REG_WIFI_USCOUNTERCNT 0x0E8 -#define REG_WIFI_USCOMPARECNT 0x0EA -#define REG_WIFI_EXTRACOUNTCNT 0x0EE -#define REG_WIFI_USCOMPARE0 0x0F0 -#define REG_WIFI_USCOMPARE1 0x0F2 -#define REG_WIFI_USCOMPARE2 0x0F4 -#define REG_WIFI_USCOMPARE3 0x0F6 -#define REG_WIFI_USCOUNTER0 0x0F8 -#define REG_WIFI_USCOUNTER1 0x0FA -#define REG_WIFI_USCOUNTER2 0x0FC -#define REG_WIFI_USCOUNTER3 0x0FE -#define REG_WIFI_EXTRACOUNT 0x118 -#define REG_WIFI_BBSIOCNT 0x158 -#define REG_WIFI_BBSIOWRITE 0x15A -#define REG_WIFI_BBSIOREAD 0x15C -#define REG_WIFI_BBSIOBUSY 0x15E -#define REG_WIFI_RFIODATA2 0x17C -#define REG_WIFI_RFIODATA1 0x17E -#define REG_WIFI_RFIOBSY 0x180 -#define REG_WIFI_RFIOCNT 0x184 -#define REG_WIFI_IF_SET 0x21C -#define REG_WIFI_POWERACK 0x2D0 - -/* WIFI misc constants */ -#define WIFI_CHIPID 0x1440 /* emulates "old" wifi chip, new is 0xC340 */ -#define REG_PWRCNT 0x04000304 - -/* Referenced as RF_ in dswifi: rffilter_t */ -/* based on the documentation for the RF2958 chip of RF Micro Devices */ -/* using the register names as in docs ( http://www.rfmd.com/pdfs/2958.pdf )*/ -/* even tho every register only has 18 bits we are using u32 */ -typedef struct rffilter_t -{ - union CFG1 - { - struct - { -/* 0*/ unsigned IF_VGA_REG_EN:1; -/* 1*/ unsigned IF_VCO_REG_EN:1; -/* 2*/ unsigned RF_VCO_REG_EN:1; -/* 3*/ unsigned HYBERNATE:1; -/* 4*/ unsigned :10; -/*14*/ unsigned REF_SEL:2; -/*16*/ unsigned :2 ; - } bits ; - u32 val ; - } CFG1 ; - union IFPLL1 - { - struct - { -/* 0*/ unsigned DAC:4; -/* 4*/ unsigned :5; -/* 9*/ unsigned P1:1; -/*10*/ unsigned LD_EN1:1; -/*11*/ unsigned AUTOCAL_EN1:1; -/*12*/ unsigned PDP1:1; -/*13*/ unsigned CPL1:1; -/*14*/ unsigned LPF1:1; -/*15*/ unsigned VTC_EN1:1; -/*16*/ unsigned KV_EN1:1; -/*17*/ unsigned PLL_EN1:1; - } bits ; - u32 val ; - } IFPLL1 ; - union IFPLL2 - { - struct - { -/* 0*/ unsigned IF_N:16; -/*16*/ unsigned :2; - } bits ; - u32 val ; - } IFPLL2 ; - union IFPLL3 - { - struct - { -/* 0*/ unsigned KV_DEF1:4; -/* 4*/ unsigned CT_DEF1:4; -/* 8*/ unsigned DN1:9; -/*17*/ unsigned :1; - } bits ; - u32 val ; - } IFPLL3 ; - union RFPLL1 - { - struct - { -/* 0*/ unsigned DAC:4; -/* 4*/ unsigned :5; -/* 9*/ unsigned P:1; -/*10*/ unsigned LD_EN:1; -/*11*/ unsigned AUTOCAL_EN:1; -/*12*/ unsigned PDP:1; -/*13*/ unsigned CPL:1; -/*14*/ unsigned LPF:1; -/*15*/ unsigned VTC_EN:1; -/*16*/ unsigned KV_EN:1; -/*17*/ unsigned PLL_EN:1; - } bits ; - u32 val ; - } RFPLL1 ; - union RFPLL2 - { - struct - { -/* 0*/ unsigned NUM2:6; -/* 6*/ unsigned N2:12; - } bits ; - u32 val ; - } RFPLL2 ; - union RFPLL3 - { - struct - { -/* 0*/ unsigned NUM2:18; - } bits ; - u32 val ; - } RFPLL3 ; - union RFPLL4 - { - struct - { -/* 0*/ unsigned KV_DEF:4; -/* 4*/ unsigned CT_DEF:4; -/* 8*/ unsigned DN:9; -/*17*/ unsigned :1; - } bits ; - u32 val ; - } RFPLL4 ; - union CAL1 - { - struct - { -/* 0*/ unsigned LD_WINDOW:3; -/* 3*/ unsigned M_CT_VALUE:5; -/* 8*/ unsigned TLOCK:5; -/*13*/ unsigned TVCO:5; - } bits ; - u32 val ; - } CAL1 ; - union TXRX1 - { - struct - { -/* 0*/ unsigned TXBYPASS:1; -/* 1*/ unsigned INTBIASEN:1; -/* 2*/ unsigned TXENMODE:1; -/* 3*/ unsigned TXDIFFMODE:1; -/* 4*/ unsigned TXLPFBW:3; -/* 7*/ unsigned RXLPFBW:3; -/*10*/ unsigned TXVGC:5; -/*15*/ unsigned PCONTROL:2; -/*17*/ unsigned RXDCFBBYPS:1; - } bits ; - u32 val ; - } TXRX1 ; - union PCNT1 - { - struct - { -/* 0*/ unsigned TX_DELAY:3; -/* 3*/ unsigned PC_OFFSET:6; -/* 9*/ unsigned P_DESIRED:6; -/*15*/ unsigned MID_BIAS:3; - } bits ; - u32 val ; - } PCNT1 ; - union PCNT2 - { - struct - { -/* 0*/ unsigned MIN_POWER:6; -/* 6*/ unsigned MID_POWER:6; -/*12*/ unsigned MAX_POWER:6; - } bits ; - u32 val ; - } PCNT2 ; - union VCOT1 - { - struct - { -/* 0*/ unsigned :16; -/*16*/ unsigned AUX1:1; -/*17*/ unsigned AUX:1; - } bits ; - u32 val ; - } VCOT1 ; -} rffilter_t ; - -/* baseband chip refered as BB_, dataformat is unknown yet */ -/* it has at least 105 bytes of functional data */ -typedef struct -{ - u8 data[105] ; -} bb_t ; - -/* communication interface between RF,BB and the mac */ -typedef union -{ - struct { -/* 0*/ unsigned wordsize:5; -/* 5*/ unsigned :2; -/* 7*/ unsigned readOperation:1; -/* 8*/ unsigned :8; - } bits ; - u16 val ; -} rfIOCnt_t ; - -typedef union -{ - struct { -/* 0*/ unsigned busy:1; -/* 1*/ unsigned :15; - } bits ; - u16 val ; -} rfIOStat_t ; - -typedef union -{ - struct { -/* 0*/ unsigned content:18 ; -/*18*/ unsigned address:5; -/*23*/ unsigned :9; - } bits ; - struct { -/* 0*/ unsigned low:16 ; -/*16*/ unsigned high:16 ; - } val16 ; - u16 array16[2] ; - u32 val ; -} rfIOData_t ; - -typedef union -{ - struct { -/* 0*/ unsigned address:7; -/* 7*/ unsigned :5; -/*12*/ unsigned mode:2; -/*14*/ unsigned enable:1; -/*15*/ unsigned :1; - } bits ; - u16 val ; -} bbIOCnt_t ; - -#define WIFI_IRQ_RECVCOMPLETE 0 -#define WIFI_IRQ_SENDCOMPLETE 1 -#define WIFI_IRQ_COUNTUP 2 -#define WIFI_IRQ_SENDERROR 3 -#define WIFI_IRQ_STATCOUNTUP 4 -#define WIFI_IRQ_STATACKUP 5 -#define WIFI_IRQ_RECVSTART 6 -#define WIFI_IRQ_SENDSTART 7 -#define WIFI_IRQ_RFWAKEUP 11 -#define WIFI_IRQ_TIMEBEACON 14 -#define WIFI_IRQ_TIMEPREBEACON 15 - -/* definition of the irq bitfields for wifi irq's (cascaded at arm7 irq #24) */ -typedef union -{ - struct - { -/* 0*/ unsigned recv_complete:1; -/* 1*/ unsigned send_complete:1; -/* 2*/ unsigned recv_countup:1; -/* 3*/ unsigned send_error:1; -/* 4*/ unsigned stat_countup:1; -/* 5*/ unsigned stat_ackup:1; -/* 6*/ unsigned recv_start:1; -/* 7*/ unsigned send_start:1; -/* 8*/ unsigned :3; -/*11*/ unsigned rf_wakeup:1; -/*12*/ unsigned :2; -/*14*/ unsigned time_beacon:1; -/*15*/ unsigned time_prebeacon:1; - } bits ; - u16 val ; -} wifiirq_t ; - -/* wifimac_t: the buildin mac (arm7 addressrange: 0x04800000-0x04FFFFFF )*/ -/* http://www.akkit.org/info/dswifi.htm#WifiIOMap */ - -typedef struct -{ - /* power */ - BOOL powerOn; - BOOL powerOnPending; - - /* status */ - u16 rfStatus; - u16 rfPins; - - /* wifi interrupt handling */ - wifiirq_t IE ; - wifiirq_t IF ; - - /* modes */ - u16 macMode ; - u16 wepMode ; - BOOL WEP_enable ; - - /* sending */ - u16 TXSlot[3] ; - u16 TXCnt ; - u16 TXOpt ; - u16 TXStat; - u16 BEACONSlot ; - BOOL BEACON_enable ; - u8 txCurSlot; - u8 txSlotBusy[3]; - u32 txSlotAddr[3]; - u32 txSlotLen[3]; - u32 txSlotRemainingBytes[3]; - - /* receiving */ - u16 RXCnt ; - u16 RXCheckCounter ; - - /* addressing/handshaking */ - union - { - //TODO - is this endian safe? don't think so - u16 words[3] ; - u8 bytes[6] ; - } mac ; - union - { - u16 words[3] ; - u8 bytes[6] ; - } bss ; - u16 aid ; - u16 pid ; /* player ID or aid_low */ - u16 retryLimit ; - - /* timing */ - BOOL crystalEnabled ; - u64 usec ; - BOOL usecEnable ; - u64 ucmp ; - BOOL ucmpEnable ; - u16 eCount ; - BOOL eCountEnable ; - - /* subchips */ - rffilter_t RF ; - bb_t BB ; - - /* subchip communications */ - rfIOCnt_t rfIOCnt ; - rfIOStat_t rfIOStatus ; - rfIOData_t rfIOData ; - bbIOCnt_t bbIOCnt ; - - u8 bbDataToWrite; - - /* buffers */ - u16 circularBuffer[0x1000] ; - u16 RXRangeBegin ; - u16 RXRangeEnd ; - u16 RXHWWriteCursor ; - u16 RXHWWriteCursorReg; - u16 RXHWWriteCursorLatched; - u16 RXReadCursor ; - u16 RXUnits ; - u16 RXBufCount ; - u16 CircBufReadAddress ; - u16 CircBufWriteAddress ; - u16 CircBufRdEnd ; - u16 CircBufRdSkip ; - u16 CircBufWrEnd ; - u16 CircBufWrSkip ; - - /* tx packets */ - s32 curPacketSize[3]; - s32 curPacketPos[3]; - BOOL curPacketSending[3]; - - /* i/o mem */ - u16 ioMem[0x800]; - - /* others */ - u16 randomSeed ; - - /* SoftAP */ - struct _SoftAP - { - u64 usecCounter; - - u8 curPacket[4096]; - s32 curPacketSize; - s32 curPacketPos; - BOOL curPacketSending; - - } SoftAP; - -} wifimac_t ; - -// desmume host communication -#ifdef EXPERIMENTAL_WIFI -typedef struct pcap pcap_t; -extern pcap_t *wifi_bridge; -#endif -extern bool wifi_netEnabled; - -extern wifimac_t wifiMac; - -bool WIFI_Init(); -void WIFI_DeInit(); -void WIFI_Reset(); - -/* subchip communication IO functions */ -void WIFI_setRF_CNT(u16 val) ; -void WIFI_setRF_DATA(u16 val, u8 part) ; -u16 WIFI_getRF_DATA(u8 part) ; -u16 WIFI_getRF_STATUS() ; - -void WIFI_setBB_CNT(u16 val) ; -u8 WIFI_getBB_DATA() ; -void WIFI_setBB_DATA(u8 val) ; - -/* wifimac io */ -void WIFI_write16(u32 address, u16 val) ; -u16 WIFI_read16(u32 address) ; - -/* wifimac timing */ -void WIFI_usTrigger() ; - - -/* DS WFC profile data documented here : */ -/* http://dsdev.bigredpimp.com/2006/07/31/aoss-wfc-profile-data/ */ -/* Note : we use bytes to avoid endianness issues */ -typedef struct _FW_WFCProfile -{ - char SSID[32]; - char SSID_WEP64[32]; - char WEPKEY_PART1[16]; - char WEPKEY_PART2[16]; - char WEPKEY_PART3[16]; - char WEPKEY_PART4[16]; - u8 IP_ADDRESS[4]; - u8 GATEWAY[4]; - u8 PRIM_DNS[4]; - u8 SEC_DNS[4]; - u8 SUBNET_MASK; - u8 WEP64_KEY_AOSS[20]; - u8 UNK1; - u8 WEP_MODE; - u8 STATUS; - u8 UNK2[7]; - u8 UNK3; - u8 UNK4[14]; - u8 CRC16[2]; - -} FW_WFCProfile; - -/* wifi data to be stored in firmware, when no firmware image was loaded */ -extern u8 FW_Mac[6]; -extern const u8 FW_WIFIInit[32] ; -extern const u8 FW_BBInit[105] ; -extern const u8 FW_RFInit[36] ; -extern const u8 FW_RFChannel[6*14] ; -extern const u8 FW_BBChannel[14] ; -extern FW_WFCProfile FW_WFCProfile1; -extern FW_WFCProfile FW_WFCProfile2; -extern FW_WFCProfile FW_WFCProfile3; - -#endif +/* Copyright (C) 2007 Tim Seidel + Copyright (C) 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef WIFI_H +#define WIFI_H + +#include +#include "types.h" + +#ifdef EXPERIMENTAL_WIFI + +#define HAVE_REMOTE +#define WPCAP +#define PACKET_SIZE 65535 +#define _INC_STDIO + + +#define REG_WIFI_ID 0x000 +#define REG_WIFI_MODE 0x004 +#define REG_WIFI_WEP 0x006 +#define REG_WIFI_IF 0x010 +#define REG_WIFI_IE 0x012 +#define REG_WIFI_MAC0 0x018 +#define REG_WIFI_MAC1 0x01A +#define REG_WIFI_MAC2 0x01C +#define REG_WIFI_BSS0 0x020 +#define REG_WIFI_BSS1 0x022 +#define REG_WIFI_BSS2 0x024 +#define REG_WIFI_AID_LOW 0x028 +#define REG_WIFI_AID_HIGH 0x02A +#define REG_WIFI_RETRYLIMIT 0x02C +#define REG_WIFI_RXCNT 0x030 +#define REG_WIFI_WEPCNT 0x032 +#define REG_WIFI_POWER_US 0x036 +#define REG_WIFI_POWERSTATE 0x03C +#define REG_WIFI_FORCEPS 0x040 +#define REG_WIFI_RANDOM 0x044 +#define REG_WIFI_RXRANGEBEGIN 0x050 +#define REG_WIFI_RXRANGEEND 0x052 +#define REG_WIFI_RXHWWRITECSR 0x054 +#define REG_WIFI_WRITECSRLATCH 0x056 +#define REG_WIFI_CIRCBUFRADR 0x058 +#define REG_WIFI_RXREADCSR 0x05A +#define REG_WIFI_RXBUF_COUNT 0x05C +#define REG_WIFI_CIRCBUFREAD 0x060 +#define REG_WIFI_CIRCBUFRD_END 0x062 +#define REG_WIFI_CIRCBUFRD_SKIP 0x064 +#define REG_WIFI_CIRCBUFWADR 0x068 +#define REG_WIFI_CIRCBUFWRITE 0x070 +#define REG_WIFI_CIRCBUFWR_END 0x074 +#define REG_WIFI_CIRCBUFWR_SKIP 0x076 +#define REG_WIFI_BEACONTRANS 0x080 +#define REG_WIFI_LISTENCOUNT 0x088 +#define REG_WIFI_BEACONPERIOD 0x08C +#define REG_WIFI_LISTENINT 0x08E +#define REG_WIFI_TXLOC1 0x0A0 +#define REG_WIFI_TXLOC2 0x0A4 +#define REG_WIFI_TXLOC3 0x0A8 +#define REG_WIFI_TXOPT 0x0AC +#define REG_WIFI_TXCNT 0x0AE +#define REG_WIFI_TXREQ_READ 0x0B0 +#define REG_WIFI_TXBUSY 0x0B6 +#define REG_WIFI_TXSTAT 0x0B8 +#define REG_WIFI_RXFILTER 0x0D0 +#define REG_WIFI_USCOUNTERCNT 0x0E8 +#define REG_WIFI_USCOMPARECNT 0x0EA +#define REG_WIFI_EXTRACOUNTCNT 0x0EE +#define REG_WIFI_USCOMPARE0 0x0F0 +#define REG_WIFI_USCOMPARE1 0x0F2 +#define REG_WIFI_USCOMPARE2 0x0F4 +#define REG_WIFI_USCOMPARE3 0x0F6 +#define REG_WIFI_USCOUNTER0 0x0F8 +#define REG_WIFI_USCOUNTER1 0x0FA +#define REG_WIFI_USCOUNTER2 0x0FC +#define REG_WIFI_USCOUNTER3 0x0FE +#define REG_WIFI_EXTRACOUNT 0x118 +#define REG_WIFI_BBSIOCNT 0x158 +#define REG_WIFI_BBSIOWRITE 0x15A +#define REG_WIFI_BBSIOREAD 0x15C +#define REG_WIFI_BBSIOBUSY 0x15E +#define REG_WIFI_RFIODATA2 0x17C +#define REG_WIFI_RFIODATA1 0x17E +#define REG_WIFI_RFIOBSY 0x180 +#define REG_WIFI_RFIOCNT 0x184 +#define REG_WIFI_IF_SET 0x21C +#define REG_WIFI_POWERACK 0x2D0 + +/* WIFI misc constants */ +#define WIFI_CHIPID 0x1440 /* emulates "old" wifi chip, new is 0xC340 */ +#define REG_PWRCNT 0x04000304 + +/* Referenced as RF_ in dswifi: rffilter_t */ +/* based on the documentation for the RF2958 chip of RF Micro Devices */ +/* using the register names as in docs ( http://www.rfmd.com/pdfs/2958.pdf )*/ +/* even tho every register only has 18 bits we are using u32 */ +typedef struct rffilter_t +{ + union CFG1 + { + struct + { +/* 0*/ unsigned IF_VGA_REG_EN:1; +/* 1*/ unsigned IF_VCO_REG_EN:1; +/* 2*/ unsigned RF_VCO_REG_EN:1; +/* 3*/ unsigned HYBERNATE:1; +/* 4*/ unsigned :10; +/*14*/ unsigned REF_SEL:2; +/*16*/ unsigned :2 ; + } bits ; + u32 val ; + } CFG1 ; + union IFPLL1 + { + struct + { +/* 0*/ unsigned DAC:4; +/* 4*/ unsigned :5; +/* 9*/ unsigned P1:1; +/*10*/ unsigned LD_EN1:1; +/*11*/ unsigned AUTOCAL_EN1:1; +/*12*/ unsigned PDP1:1; +/*13*/ unsigned CPL1:1; +/*14*/ unsigned LPF1:1; +/*15*/ unsigned VTC_EN1:1; +/*16*/ unsigned KV_EN1:1; +/*17*/ unsigned PLL_EN1:1; + } bits ; + u32 val ; + } IFPLL1 ; + union IFPLL2 + { + struct + { +/* 0*/ unsigned IF_N:16; +/*16*/ unsigned :2; + } bits ; + u32 val ; + } IFPLL2 ; + union IFPLL3 + { + struct + { +/* 0*/ unsigned KV_DEF1:4; +/* 4*/ unsigned CT_DEF1:4; +/* 8*/ unsigned DN1:9; +/*17*/ unsigned :1; + } bits ; + u32 val ; + } IFPLL3 ; + union RFPLL1 + { + struct + { +/* 0*/ unsigned DAC:4; +/* 4*/ unsigned :5; +/* 9*/ unsigned P:1; +/*10*/ unsigned LD_EN:1; +/*11*/ unsigned AUTOCAL_EN:1; +/*12*/ unsigned PDP:1; +/*13*/ unsigned CPL:1; +/*14*/ unsigned LPF:1; +/*15*/ unsigned VTC_EN:1; +/*16*/ unsigned KV_EN:1; +/*17*/ unsigned PLL_EN:1; + } bits ; + u32 val ; + } RFPLL1 ; + union RFPLL2 + { + struct + { +/* 0*/ unsigned NUM2:6; +/* 6*/ unsigned N2:12; + } bits ; + u32 val ; + } RFPLL2 ; + union RFPLL3 + { + struct + { +/* 0*/ unsigned NUM2:18; + } bits ; + u32 val ; + } RFPLL3 ; + union RFPLL4 + { + struct + { +/* 0*/ unsigned KV_DEF:4; +/* 4*/ unsigned CT_DEF:4; +/* 8*/ unsigned DN:9; +/*17*/ unsigned :1; + } bits ; + u32 val ; + } RFPLL4 ; + union CAL1 + { + struct + { +/* 0*/ unsigned LD_WINDOW:3; +/* 3*/ unsigned M_CT_VALUE:5; +/* 8*/ unsigned TLOCK:5; +/*13*/ unsigned TVCO:5; + } bits ; + u32 val ; + } CAL1 ; + union TXRX1 + { + struct + { +/* 0*/ unsigned TXBYPASS:1; +/* 1*/ unsigned INTBIASEN:1; +/* 2*/ unsigned TXENMODE:1; +/* 3*/ unsigned TXDIFFMODE:1; +/* 4*/ unsigned TXLPFBW:3; +/* 7*/ unsigned RXLPFBW:3; +/*10*/ unsigned TXVGC:5; +/*15*/ unsigned PCONTROL:2; +/*17*/ unsigned RXDCFBBYPS:1; + } bits ; + u32 val ; + } TXRX1 ; + union PCNT1 + { + struct + { +/* 0*/ unsigned TX_DELAY:3; +/* 3*/ unsigned PC_OFFSET:6; +/* 9*/ unsigned P_DESIRED:6; +/*15*/ unsigned MID_BIAS:3; + } bits ; + u32 val ; + } PCNT1 ; + union PCNT2 + { + struct + { +/* 0*/ unsigned MIN_POWER:6; +/* 6*/ unsigned MID_POWER:6; +/*12*/ unsigned MAX_POWER:6; + } bits ; + u32 val ; + } PCNT2 ; + union VCOT1 + { + struct + { +/* 0*/ unsigned :16; +/*16*/ unsigned AUX1:1; +/*17*/ unsigned AUX:1; + } bits ; + u32 val ; + } VCOT1 ; +} rffilter_t ; + +/* baseband chip refered as BB_, dataformat is unknown yet */ +/* it has at least 105 bytes of functional data */ +typedef struct +{ + u8 data[105] ; +} bb_t ; + +/* communication interface between RF,BB and the mac */ +typedef union +{ + struct { +/* 0*/ unsigned wordsize:5; +/* 5*/ unsigned :2; +/* 7*/ unsigned readOperation:1; +/* 8*/ unsigned :8; + } bits ; + u16 val ; +} rfIOCnt_t ; + +typedef union +{ + struct { +/* 0*/ unsigned busy:1; +/* 1*/ unsigned :15; + } bits ; + u16 val ; +} rfIOStat_t ; + +typedef union +{ + struct { +/* 0*/ unsigned content:18 ; +/*18*/ unsigned address:5; +/*23*/ unsigned :9; + } bits ; + struct { +/* 0*/ unsigned low:16 ; +/*16*/ unsigned high:16 ; + } val16 ; + u16 array16[2] ; + u32 val ; +} rfIOData_t ; + +typedef union +{ + struct { +/* 0*/ unsigned address:7; +/* 7*/ unsigned :5; +/*12*/ unsigned mode:2; +/*14*/ unsigned enable:1; +/*15*/ unsigned :1; + } bits ; + u16 val ; +} bbIOCnt_t ; + +#define WIFI_IRQ_RECVCOMPLETE 0 +#define WIFI_IRQ_SENDCOMPLETE 1 +#define WIFI_IRQ_COUNTUP 2 +#define WIFI_IRQ_SENDERROR 3 +#define WIFI_IRQ_STATCOUNTUP 4 +#define WIFI_IRQ_STATACKUP 5 +#define WIFI_IRQ_RECVSTART 6 +#define WIFI_IRQ_SENDSTART 7 +#define WIFI_IRQ_RFWAKEUP 11 +#define WIFI_IRQ_TIMEBEACON 14 +#define WIFI_IRQ_TIMEPREBEACON 15 + +/* definition of the irq bitfields for wifi irq's (cascaded at arm7 irq #24) */ +typedef union +{ + struct + { +/* 0*/ unsigned recv_complete:1; +/* 1*/ unsigned send_complete:1; +/* 2*/ unsigned recv_countup:1; +/* 3*/ unsigned send_error:1; +/* 4*/ unsigned stat_countup:1; +/* 5*/ unsigned stat_ackup:1; +/* 6*/ unsigned recv_start:1; +/* 7*/ unsigned send_start:1; +/* 8*/ unsigned :3; +/*11*/ unsigned rf_wakeup:1; +/*12*/ unsigned :2; +/*14*/ unsigned time_beacon:1; +/*15*/ unsigned time_prebeacon:1; + } bits ; + u16 val ; +} wifiirq_t ; + +/* wifimac_t: the buildin mac (arm7 addressrange: 0x04800000-0x04FFFFFF )*/ +/* http://www.akkit.org/info/dswifi.htm#WifiIOMap */ + +typedef struct +{ + /* power */ + BOOL powerOn; + BOOL powerOnPending; + + /* status */ + u16 rfStatus; + u16 rfPins; + + /* wifi interrupt handling */ + wifiirq_t IE ; + wifiirq_t IF ; + + /* modes */ + u16 macMode ; + u16 wepMode ; + BOOL WEP_enable ; + + /* sending */ + u16 TXSlot[3] ; + u16 TXCnt ; + u16 TXOpt ; + u16 TXStat; + u16 BEACONSlot ; + BOOL BEACON_enable ; + u8 txCurSlot; + u8 txSlotBusy[3]; + u32 txSlotAddr[3]; + u32 txSlotLen[3]; + u32 txSlotRemainingBytes[3]; + + /* receiving */ + u16 RXCnt ; + u16 RXCheckCounter ; + + /* addressing/handshaking */ + union + { + //TODO - is this endian safe? don't think so + u16 words[3] ; + u8 bytes[6] ; + } mac ; + union + { + u16 words[3] ; + u8 bytes[6] ; + } bss ; + u16 aid ; + u16 pid ; /* player ID or aid_low */ + u16 retryLimit ; + + /* timing */ + BOOL crystalEnabled ; + u64 usec ; + BOOL usecEnable ; + u64 ucmp ; + BOOL ucmpEnable ; + u16 eCount ; + BOOL eCountEnable ; + + /* subchips */ + rffilter_t RF ; + bb_t BB ; + + /* subchip communications */ + rfIOCnt_t rfIOCnt ; + rfIOStat_t rfIOStatus ; + rfIOData_t rfIOData ; + bbIOCnt_t bbIOCnt ; + + u8 bbDataToWrite; + + /* buffers */ + u16 circularBuffer[0x1000] ; + u16 RXRangeBegin ; + u16 RXRangeEnd ; + u16 RXHWWriteCursor ; + u16 RXHWWriteCursorReg; + u16 RXHWWriteCursorLatched; + u16 RXReadCursor ; + u16 RXUnits ; + u16 RXBufCount ; + u16 CircBufReadAddress ; + u16 CircBufWriteAddress ; + u16 CircBufRdEnd ; + u16 CircBufRdSkip ; + u16 CircBufWrEnd ; + u16 CircBufWrSkip ; + + /* tx packets */ + s32 curPacketSize[3]; + s32 curPacketPos[3]; + BOOL curPacketSending[3]; + + /* i/o mem */ + u16 ioMem[0x800]; + + /* others */ + u16 randomSeed ; + + /* SoftAP */ + struct _SoftAP + { + u64 usecCounter; + + u8 curPacket[4096]; + s32 curPacketSize; + s32 curPacketPos; + BOOL curPacketSending; + + } SoftAP; + +} wifimac_t ; + + +// desmume host communication +typedef struct pcap pcap_t; +extern bool wifi_netEnabled; +extern pcap_t *wifi_bridge; + +extern wifimac_t wifiMac; + +void WIFI_Init(wifimac_t *wifi); + +/* subchip communication IO functions */ +void WIFI_setRF_CNT(wifimac_t *wifi, u16 val) ; +void WIFI_setRF_DATA(wifimac_t *wifi, u16 val, u8 part) ; +u16 WIFI_getRF_DATA(wifimac_t *wifi, u8 part) ; +u16 WIFI_getRF_STATUS(wifimac_t *wifi) ; + +void WIFI_setBB_CNT(wifimac_t *wifi,u16 val) ; +u8 WIFI_getBB_DATA(wifimac_t *wifi) ; +void WIFI_setBB_DATA(wifimac_t *wifi, u8 val) ; + +/* wifimac io */ +void WIFI_write16(wifimac_t *wifi,u32 address, u16 val) ; +u16 WIFI_read16(wifimac_t *wifi,u32 address) ; + +/* wifimac timing */ +void WIFI_usTrigger(wifimac_t *wifi) ; + +/* SoftAP */ + +typedef struct _WIFI_FrameHeader +{ + u8 FrameControl[2]; + u8 DurationID[2]; + u8 Receiver[6]; + u8 Sender[6]; + u8 BSSID[6]; + u8 SeqCtl[2]; + +} WIFI_FrameHeader; + +int WIFI_SoftAP_Init(wifimac_t *wifi); +void WIFI_SoftAP_Shutdown(wifimac_t *wifi); +void WIFI_SoftAP_RecvPacketFromDS(wifimac_t *wifi, u8 *packet, int len); +void WIFI_SoftAP_usTrigger(wifimac_t *wifi); + +#endif + +/* DS WFC profile data documented here : */ +/* http://dsdev.bigredpimp.com/2006/07/31/aoss-wfc-profile-data/ */ +/* Note : we use bytes to avoid endianness issues */ +typedef struct _FW_WFCProfile +{ + char SSID[32]; + char SSID_WEP64[32]; + char WEPKEY_PART1[16]; + char WEPKEY_PART2[16]; + char WEPKEY_PART3[16]; + char WEPKEY_PART4[16]; + u8 IP_ADDRESS[4]; + u8 GATEWAY[4]; + u8 PRIM_DNS[4]; + u8 SEC_DNS[4]; + u8 SUBNET_MASK; + u8 WEP64_KEY_AOSS[20]; + u8 UNK1; + u8 WEP_MODE; + u8 STATUS; + u8 UNK2[7]; + u8 UNK3; + u8 UNK4[14]; + u8 CRC16[2]; + +} FW_WFCProfile; + +/* wifi data to be stored in firmware, when no firmware image was loaded */ +extern u8 FW_Mac[6]; +extern const u8 FW_WIFIInit[32] ; +extern const u8 FW_BBInit[105] ; +extern const u8 FW_RFInit[36] ; +extern const u8 FW_RFChannel[6*14] ; +extern const u8 FW_BBChannel[14] ; +extern FW_WFCProfile FW_WFCProfile1; +extern FW_WFCProfile FW_WFCProfile2; +extern FW_WFCProfile FW_WFCProfile3; + +#endif diff --git a/desmume/src/windows/7z/7zip.lib b/src/windows/7z/7zip.lib similarity index 100% rename from desmume/src/windows/7z/7zip.lib rename to src/windows/7z/7zip.lib diff --git a/desmume/src/windows/7z/7zip.vcproj b/src/windows/7z/7zip.vcproj similarity index 100% rename from desmume/src/windows/7z/7zip.vcproj rename to src/windows/7z/7zip.vcproj diff --git a/desmume/src/windows/7z/C/7zCrc.c b/src/windows/7z/C/7zCrc.c similarity index 100% rename from desmume/src/windows/7z/C/7zCrc.c rename to src/windows/7z/C/7zCrc.c diff --git a/desmume/src/windows/7z/C/7zCrc.h b/src/windows/7z/C/7zCrc.h similarity index 100% rename from desmume/src/windows/7z/C/7zCrc.h rename to src/windows/7z/C/7zCrc.h diff --git a/desmume/src/windows/7z/C/Aes.c b/src/windows/7z/C/Aes.c similarity index 100% rename from desmume/src/windows/7z/C/Aes.c rename to src/windows/7z/C/Aes.c diff --git a/desmume/src/windows/7z/C/Aes.h b/src/windows/7z/C/Aes.h similarity index 100% rename from desmume/src/windows/7z/C/Aes.h rename to src/windows/7z/C/Aes.h diff --git a/desmume/src/windows/7z/C/Alloc.c b/src/windows/7z/C/Alloc.c similarity index 100% rename from desmume/src/windows/7z/C/Alloc.c rename to src/windows/7z/C/Alloc.c diff --git a/desmume/src/windows/7z/C/Alloc.h b/src/windows/7z/C/Alloc.h similarity index 100% rename from desmume/src/windows/7z/C/Alloc.h rename to src/windows/7z/C/Alloc.h diff --git a/desmume/src/windows/7z/C/Bra.c b/src/windows/7z/C/Bra.c similarity index 100% rename from desmume/src/windows/7z/C/Bra.c rename to src/windows/7z/C/Bra.c diff --git a/desmume/src/windows/7z/C/Bra.h b/src/windows/7z/C/Bra.h similarity index 100% rename from desmume/src/windows/7z/C/Bra.h rename to src/windows/7z/C/Bra.h diff --git a/desmume/src/windows/7z/C/Bra86.c b/src/windows/7z/C/Bra86.c similarity index 100% rename from desmume/src/windows/7z/C/Bra86.c rename to src/windows/7z/C/Bra86.c diff --git a/desmume/src/windows/7z/C/BraIA64.c b/src/windows/7z/C/BraIA64.c similarity index 100% rename from desmume/src/windows/7z/C/BraIA64.c rename to src/windows/7z/C/BraIA64.c diff --git a/desmume/src/windows/7z/C/BwtSort.c b/src/windows/7z/C/BwtSort.c similarity index 100% rename from desmume/src/windows/7z/C/BwtSort.c rename to src/windows/7z/C/BwtSort.c diff --git a/desmume/src/windows/7z/C/BwtSort.h b/src/windows/7z/C/BwtSort.h similarity index 100% rename from desmume/src/windows/7z/C/BwtSort.h rename to src/windows/7z/C/BwtSort.h diff --git a/desmume/src/windows/7z/C/CpuArch.h b/src/windows/7z/C/CpuArch.h similarity index 100% rename from desmume/src/windows/7z/C/CpuArch.h rename to src/windows/7z/C/CpuArch.h diff --git a/desmume/src/windows/7z/C/HuffEnc.c b/src/windows/7z/C/HuffEnc.c similarity index 100% rename from desmume/src/windows/7z/C/HuffEnc.c rename to src/windows/7z/C/HuffEnc.c diff --git a/desmume/src/windows/7z/C/HuffEnc.h b/src/windows/7z/C/HuffEnc.h similarity index 100% rename from desmume/src/windows/7z/C/HuffEnc.h rename to src/windows/7z/C/HuffEnc.h diff --git a/desmume/src/windows/7z/C/LzFind.c b/src/windows/7z/C/LzFind.c similarity index 100% rename from desmume/src/windows/7z/C/LzFind.c rename to src/windows/7z/C/LzFind.c diff --git a/desmume/src/windows/7z/C/LzFind.h b/src/windows/7z/C/LzFind.h similarity index 100% rename from desmume/src/windows/7z/C/LzFind.h rename to src/windows/7z/C/LzFind.h diff --git a/desmume/src/windows/7z/C/LzFindMt.c b/src/windows/7z/C/LzFindMt.c similarity index 100% rename from desmume/src/windows/7z/C/LzFindMt.c rename to src/windows/7z/C/LzFindMt.c diff --git a/desmume/src/windows/7z/C/LzFindMt.h b/src/windows/7z/C/LzFindMt.h similarity index 100% rename from desmume/src/windows/7z/C/LzFindMt.h rename to src/windows/7z/C/LzFindMt.h diff --git a/desmume/src/windows/7z/C/LzHash.h b/src/windows/7z/C/LzHash.h similarity index 100% rename from desmume/src/windows/7z/C/LzHash.h rename to src/windows/7z/C/LzHash.h diff --git a/desmume/src/windows/7z/C/LzmaDec.c b/src/windows/7z/C/LzmaDec.c similarity index 100% rename from desmume/src/windows/7z/C/LzmaDec.c rename to src/windows/7z/C/LzmaDec.c diff --git a/desmume/src/windows/7z/C/LzmaDec.h b/src/windows/7z/C/LzmaDec.h similarity index 100% rename from desmume/src/windows/7z/C/LzmaDec.h rename to src/windows/7z/C/LzmaDec.h diff --git a/desmume/src/windows/7z/C/LzmaEnc.c b/src/windows/7z/C/LzmaEnc.c similarity index 100% rename from desmume/src/windows/7z/C/LzmaEnc.c rename to src/windows/7z/C/LzmaEnc.c diff --git a/desmume/src/windows/7z/C/LzmaEnc.h b/src/windows/7z/C/LzmaEnc.h similarity index 100% rename from desmume/src/windows/7z/C/LzmaEnc.h rename to src/windows/7z/C/LzmaEnc.h diff --git a/desmume/src/windows/7z/C/RotateDefs.h b/src/windows/7z/C/RotateDefs.h similarity index 100% rename from desmume/src/windows/7z/C/RotateDefs.h rename to src/windows/7z/C/RotateDefs.h diff --git a/desmume/src/windows/7z/C/Sha256.c b/src/windows/7z/C/Sha256.c similarity index 100% rename from desmume/src/windows/7z/C/Sha256.c rename to src/windows/7z/C/Sha256.c diff --git a/desmume/src/windows/7z/C/Sha256.h b/src/windows/7z/C/Sha256.h similarity index 100% rename from desmume/src/windows/7z/C/Sha256.h rename to src/windows/7z/C/Sha256.h diff --git a/desmume/src/windows/7z/C/Sort.c b/src/windows/7z/C/Sort.c similarity index 100% rename from desmume/src/windows/7z/C/Sort.c rename to src/windows/7z/C/Sort.c diff --git a/desmume/src/windows/7z/C/Sort.h b/src/windows/7z/C/Sort.h similarity index 100% rename from desmume/src/windows/7z/C/Sort.h rename to src/windows/7z/C/Sort.h diff --git a/desmume/src/windows/7z/C/Threads.c b/src/windows/7z/C/Threads.c similarity index 100% rename from desmume/src/windows/7z/C/Threads.c rename to src/windows/7z/C/Threads.c diff --git a/desmume/src/windows/7z/C/Threads.h b/src/windows/7z/C/Threads.h similarity index 100% rename from desmume/src/windows/7z/C/Threads.h rename to src/windows/7z/C/Threads.h diff --git a/desmume/src/windows/7z/C/Types.h b/src/windows/7z/C/Types.h similarity index 100% rename from desmume/src/windows/7z/C/Types.h rename to src/windows/7z/C/Types.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zCompressionMode.cpp b/src/windows/7z/CPP/7zip/Archive/7z/7zCompressionMode.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zCompressionMode.cpp rename to src/windows/7z/CPP/7zip/Archive/7z/7zCompressionMode.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zCompressionMode.h b/src/windows/7z/CPP/7zip/Archive/7z/7zCompressionMode.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zCompressionMode.h rename to src/windows/7z/CPP/7zip/Archive/7z/7zCompressionMode.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zDecode.cpp b/src/windows/7z/CPP/7zip/Archive/7z/7zDecode.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zDecode.cpp rename to src/windows/7z/CPP/7zip/Archive/7z/7zDecode.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zDecode.h b/src/windows/7z/CPP/7zip/Archive/7z/7zDecode.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zDecode.h rename to src/windows/7z/CPP/7zip/Archive/7z/7zDecode.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zExtract.cpp b/src/windows/7z/CPP/7zip/Archive/7z/7zExtract.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zExtract.cpp rename to src/windows/7z/CPP/7zip/Archive/7z/7zExtract.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zFolderInStream.cpp b/src/windows/7z/CPP/7zip/Archive/7z/7zFolderInStream.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zFolderInStream.cpp rename to src/windows/7z/CPP/7zip/Archive/7z/7zFolderInStream.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zFolderInStream.h b/src/windows/7z/CPP/7zip/Archive/7z/7zFolderInStream.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zFolderInStream.h rename to src/windows/7z/CPP/7zip/Archive/7z/7zFolderInStream.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zFolderOutStream.cpp b/src/windows/7z/CPP/7zip/Archive/7z/7zFolderOutStream.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zFolderOutStream.cpp rename to src/windows/7z/CPP/7zip/Archive/7z/7zFolderOutStream.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zFolderOutStream.h b/src/windows/7z/CPP/7zip/Archive/7z/7zFolderOutStream.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zFolderOutStream.h rename to src/windows/7z/CPP/7zip/Archive/7z/7zFolderOutStream.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zHandler.cpp b/src/windows/7z/CPP/7zip/Archive/7z/7zHandler.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zHandler.cpp rename to src/windows/7z/CPP/7zip/Archive/7z/7zHandler.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zHandler.h b/src/windows/7z/CPP/7zip/Archive/7z/7zHandler.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zHandler.h rename to src/windows/7z/CPP/7zip/Archive/7z/7zHandler.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zHeader.cpp b/src/windows/7z/CPP/7zip/Archive/7z/7zHeader.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zHeader.cpp rename to src/windows/7z/CPP/7zip/Archive/7z/7zHeader.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zHeader.h b/src/windows/7z/CPP/7zip/Archive/7z/7zHeader.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zHeader.h rename to src/windows/7z/CPP/7zip/Archive/7z/7zHeader.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zIn.cpp b/src/windows/7z/CPP/7zip/Archive/7z/7zIn.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zIn.cpp rename to src/windows/7z/CPP/7zip/Archive/7z/7zIn.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zIn.h b/src/windows/7z/CPP/7zip/Archive/7z/7zIn.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zIn.h rename to src/windows/7z/CPP/7zip/Archive/7z/7zIn.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zItem.h b/src/windows/7z/CPP/7zip/Archive/7z/7zItem.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zItem.h rename to src/windows/7z/CPP/7zip/Archive/7z/7zItem.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zProperties.cpp b/src/windows/7z/CPP/7zip/Archive/7z/7zProperties.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zProperties.cpp rename to src/windows/7z/CPP/7zip/Archive/7z/7zProperties.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zProperties.h b/src/windows/7z/CPP/7zip/Archive/7z/7zProperties.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zProperties.h rename to src/windows/7z/CPP/7zip/Archive/7z/7zProperties.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zRegister.cpp b/src/windows/7z/CPP/7zip/Archive/7z/7zRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zRegister.cpp rename to src/windows/7z/CPP/7zip/Archive/7z/7zRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zSpecStream.cpp b/src/windows/7z/CPP/7zip/Archive/7z/7zSpecStream.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zSpecStream.cpp rename to src/windows/7z/CPP/7zip/Archive/7z/7zSpecStream.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/7zSpecStream.h b/src/windows/7z/CPP/7zip/Archive/7z/7zSpecStream.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/7zSpecStream.h rename to src/windows/7z/CPP/7zip/Archive/7z/7zSpecStream.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/7z/StdAfx.h b/src/windows/7z/CPP/7zip/Archive/7z/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/7z/StdAfx.h rename to src/windows/7z/CPP/7zip/Archive/7z/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/ArchiveExports.cpp b/src/windows/7z/CPP/7zip/Archive/ArchiveExports.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/ArchiveExports.cpp rename to src/windows/7z/CPP/7zip/Archive/ArchiveExports.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/BZip2/BZip2Handler.cpp b/src/windows/7z/CPP/7zip/Archive/BZip2/BZip2Handler.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/BZip2/BZip2Handler.cpp rename to src/windows/7z/CPP/7zip/Archive/BZip2/BZip2Handler.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/BZip2/BZip2Handler.h b/src/windows/7z/CPP/7zip/Archive/BZip2/BZip2Handler.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/BZip2/BZip2Handler.h rename to src/windows/7z/CPP/7zip/Archive/BZip2/BZip2Handler.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/BZip2/BZip2Item.h b/src/windows/7z/CPP/7zip/Archive/BZip2/BZip2Item.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/BZip2/BZip2Item.h rename to src/windows/7z/CPP/7zip/Archive/BZip2/BZip2Item.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/BZip2/StdAfx.h b/src/windows/7z/CPP/7zip/Archive/BZip2/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/BZip2/StdAfx.h rename to src/windows/7z/CPP/7zip/Archive/BZip2/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/BZip2/bz2Register.cpp b/src/windows/7z/CPP/7zip/Archive/BZip2/bz2Register.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/BZip2/bz2Register.cpp rename to src/windows/7z/CPP/7zip/Archive/BZip2/bz2Register.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2.cpp b/src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2.cpp rename to src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2.h b/src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2.h rename to src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2MT.cpp b/src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2MT.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2MT.cpp rename to src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2MT.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2MT.h b/src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2MT.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2MT.h rename to src/windows/7z/CPP/7zip/Archive/Common/CoderMixer2MT.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/DummyOutStream.cpp b/src/windows/7z/CPP/7zip/Archive/Common/DummyOutStream.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/DummyOutStream.cpp rename to src/windows/7z/CPP/7zip/Archive/Common/DummyOutStream.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/DummyOutStream.h b/src/windows/7z/CPP/7zip/Archive/Common/DummyOutStream.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/DummyOutStream.h rename to src/windows/7z/CPP/7zip/Archive/Common/DummyOutStream.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/FindSignature.cpp b/src/windows/7z/CPP/7zip/Archive/Common/FindSignature.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/FindSignature.cpp rename to src/windows/7z/CPP/7zip/Archive/Common/FindSignature.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/FindSignature.h b/src/windows/7z/CPP/7zip/Archive/Common/FindSignature.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/FindSignature.h rename to src/windows/7z/CPP/7zip/Archive/Common/FindSignature.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/InStreamWithCRC.cpp b/src/windows/7z/CPP/7zip/Archive/Common/InStreamWithCRC.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/InStreamWithCRC.cpp rename to src/windows/7z/CPP/7zip/Archive/Common/InStreamWithCRC.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/InStreamWithCRC.h b/src/windows/7z/CPP/7zip/Archive/Common/InStreamWithCRC.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/InStreamWithCRC.h rename to src/windows/7z/CPP/7zip/Archive/Common/InStreamWithCRC.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/ItemNameUtils.cpp b/src/windows/7z/CPP/7zip/Archive/Common/ItemNameUtils.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/ItemNameUtils.cpp rename to src/windows/7z/CPP/7zip/Archive/Common/ItemNameUtils.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/ItemNameUtils.h b/src/windows/7z/CPP/7zip/Archive/Common/ItemNameUtils.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/ItemNameUtils.h rename to src/windows/7z/CPP/7zip/Archive/Common/ItemNameUtils.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/MultiStream.cpp b/src/windows/7z/CPP/7zip/Archive/Common/MultiStream.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/MultiStream.cpp rename to src/windows/7z/CPP/7zip/Archive/Common/MultiStream.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/MultiStream.h b/src/windows/7z/CPP/7zip/Archive/Common/MultiStream.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/MultiStream.h rename to src/windows/7z/CPP/7zip/Archive/Common/MultiStream.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp b/src/windows/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp rename to src/windows/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.h b/src/windows/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.h rename to src/windows/7z/CPP/7zip/Archive/Common/OutStreamWithCRC.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/ParseProperties.cpp b/src/windows/7z/CPP/7zip/Archive/Common/ParseProperties.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/ParseProperties.cpp rename to src/windows/7z/CPP/7zip/Archive/Common/ParseProperties.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/ParseProperties.h b/src/windows/7z/CPP/7zip/Archive/Common/ParseProperties.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/ParseProperties.h rename to src/windows/7z/CPP/7zip/Archive/Common/ParseProperties.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Common/StdAfx.h b/src/windows/7z/CPP/7zip/Archive/Common/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Common/StdAfx.h rename to src/windows/7z/CPP/7zip/Archive/Common/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/DllExports2.cpp b/src/windows/7z/CPP/7zip/Archive/DllExports2.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/DllExports2.cpp rename to src/windows/7z/CPP/7zip/Archive/DllExports2.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipHandler.cpp b/src/windows/7z/CPP/7zip/Archive/GZip/GZipHandler.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipHandler.cpp rename to src/windows/7z/CPP/7zip/Archive/GZip/GZipHandler.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipHandler.h b/src/windows/7z/CPP/7zip/Archive/GZip/GZipHandler.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipHandler.h rename to src/windows/7z/CPP/7zip/Archive/GZip/GZipHandler.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipHeader.cpp b/src/windows/7z/CPP/7zip/Archive/GZip/GZipHeader.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipHeader.cpp rename to src/windows/7z/CPP/7zip/Archive/GZip/GZipHeader.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipHeader.h b/src/windows/7z/CPP/7zip/Archive/GZip/GZipHeader.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipHeader.h rename to src/windows/7z/CPP/7zip/Archive/GZip/GZipHeader.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipIn.cpp b/src/windows/7z/CPP/7zip/Archive/GZip/GZipIn.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipIn.cpp rename to src/windows/7z/CPP/7zip/Archive/GZip/GZipIn.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipIn.h b/src/windows/7z/CPP/7zip/Archive/GZip/GZipIn.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipIn.h rename to src/windows/7z/CPP/7zip/Archive/GZip/GZipIn.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipItem.h b/src/windows/7z/CPP/7zip/Archive/GZip/GZipItem.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipItem.h rename to src/windows/7z/CPP/7zip/Archive/GZip/GZipItem.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipRegister.cpp b/src/windows/7z/CPP/7zip/Archive/GZip/GZipRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipRegister.cpp rename to src/windows/7z/CPP/7zip/Archive/GZip/GZipRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipUpdate.h b/src/windows/7z/CPP/7zip/Archive/GZip/GZipUpdate.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/GZip/GZipUpdate.h rename to src/windows/7z/CPP/7zip/Archive/GZip/GZipUpdate.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/GZip/StdAfx.h b/src/windows/7z/CPP/7zip/Archive/GZip/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/GZip/StdAfx.h rename to src/windows/7z/CPP/7zip/Archive/GZip/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/IArchive.h b/src/windows/7z/CPP/7zip/Archive/IArchive.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/IArchive.h rename to src/windows/7z/CPP/7zip/Archive/IArchive.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhCRC.cpp b/src/windows/7z/CPP/7zip/Archive/Lzh/LzhCRC.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhCRC.cpp rename to src/windows/7z/CPP/7zip/Archive/Lzh/LzhCRC.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhCRC.h b/src/windows/7z/CPP/7zip/Archive/Lzh/LzhCRC.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhCRC.h rename to src/windows/7z/CPP/7zip/Archive/Lzh/LzhCRC.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhHandler.cpp b/src/windows/7z/CPP/7zip/Archive/Lzh/LzhHandler.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhHandler.cpp rename to src/windows/7z/CPP/7zip/Archive/Lzh/LzhHandler.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhHandler.h b/src/windows/7z/CPP/7zip/Archive/Lzh/LzhHandler.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhHandler.h rename to src/windows/7z/CPP/7zip/Archive/Lzh/LzhHandler.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhHeader.h b/src/windows/7z/CPP/7zip/Archive/Lzh/LzhHeader.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhHeader.h rename to src/windows/7z/CPP/7zip/Archive/Lzh/LzhHeader.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhIn.cpp b/src/windows/7z/CPP/7zip/Archive/Lzh/LzhIn.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhIn.cpp rename to src/windows/7z/CPP/7zip/Archive/Lzh/LzhIn.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhIn.h b/src/windows/7z/CPP/7zip/Archive/Lzh/LzhIn.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhIn.h rename to src/windows/7z/CPP/7zip/Archive/Lzh/LzhIn.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhItem.h b/src/windows/7z/CPP/7zip/Archive/Lzh/LzhItem.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhItem.h rename to src/windows/7z/CPP/7zip/Archive/Lzh/LzhItem.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.cpp b/src/windows/7z/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.cpp rename to src/windows/7z/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h b/src/windows/7z/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h rename to src/windows/7z/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhRegister.cpp b/src/windows/7z/CPP/7zip/Archive/Lzh/LzhRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzh/LzhRegister.cpp rename to src/windows/7z/CPP/7zip/Archive/Lzh/LzhRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzh/StdAfx.h b/src/windows/7z/CPP/7zip/Archive/Lzh/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzh/StdAfx.h rename to src/windows/7z/CPP/7zip/Archive/Lzh/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaArcRegister.cpp b/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaArcRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaArcRegister.cpp rename to src/windows/7z/CPP/7zip/Archive/Lzma/LzmaArcRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp b/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp rename to src/windows/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h b/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h rename to src/windows/7z/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaHandler.cpp b/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaHandler.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaHandler.cpp rename to src/windows/7z/CPP/7zip/Archive/Lzma/LzmaHandler.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaHandler.h b/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaHandler.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaHandler.h rename to src/windows/7z/CPP/7zip/Archive/Lzma/LzmaHandler.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaIn.cpp b/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaIn.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaIn.cpp rename to src/windows/7z/CPP/7zip/Archive/Lzma/LzmaIn.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaIn.h b/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaIn.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaIn.h rename to src/windows/7z/CPP/7zip/Archive/Lzma/LzmaIn.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaItem.h b/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaItem.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzma/LzmaItem.h rename to src/windows/7z/CPP/7zip/Archive/Lzma/LzmaItem.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Lzma/StdAfx.h b/src/windows/7z/CPP/7zip/Archive/Lzma/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Lzma/StdAfx.h rename to src/windows/7z/CPP/7zip/Archive/Lzma/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarHandler.cpp b/src/windows/7z/CPP/7zip/Archive/Rar/RarHandler.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarHandler.cpp rename to src/windows/7z/CPP/7zip/Archive/Rar/RarHandler.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarHandler.h b/src/windows/7z/CPP/7zip/Archive/Rar/RarHandler.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarHandler.h rename to src/windows/7z/CPP/7zip/Archive/Rar/RarHandler.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarHeader.cpp b/src/windows/7z/CPP/7zip/Archive/Rar/RarHeader.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarHeader.cpp rename to src/windows/7z/CPP/7zip/Archive/Rar/RarHeader.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarHeader.h b/src/windows/7z/CPP/7zip/Archive/Rar/RarHeader.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarHeader.h rename to src/windows/7z/CPP/7zip/Archive/Rar/RarHeader.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarIn.cpp b/src/windows/7z/CPP/7zip/Archive/Rar/RarIn.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarIn.cpp rename to src/windows/7z/CPP/7zip/Archive/Rar/RarIn.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarIn.h b/src/windows/7z/CPP/7zip/Archive/Rar/RarIn.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarIn.h rename to src/windows/7z/CPP/7zip/Archive/Rar/RarIn.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarItem.cpp b/src/windows/7z/CPP/7zip/Archive/Rar/RarItem.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarItem.cpp rename to src/windows/7z/CPP/7zip/Archive/Rar/RarItem.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarItem.h b/src/windows/7z/CPP/7zip/Archive/Rar/RarItem.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarItem.h rename to src/windows/7z/CPP/7zip/Archive/Rar/RarItem.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarRegister.cpp b/src/windows/7z/CPP/7zip/Archive/Rar/RarRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarRegister.cpp rename to src/windows/7z/CPP/7zip/Archive/Rar/RarRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp b/src/windows/7z/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp rename to src/windows/7z/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarVolumeInStream.h b/src/windows/7z/CPP/7zip/Archive/Rar/RarVolumeInStream.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Rar/RarVolumeInStream.h rename to src/windows/7z/CPP/7zip/Archive/Rar/RarVolumeInStream.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Rar/StdAfx.h b/src/windows/7z/CPP/7zip/Archive/Rar/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Rar/StdAfx.h rename to src/windows/7z/CPP/7zip/Archive/Rar/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Split/SplitHandler.cpp b/src/windows/7z/CPP/7zip/Archive/Split/SplitHandler.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Split/SplitHandler.cpp rename to src/windows/7z/CPP/7zip/Archive/Split/SplitHandler.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Split/SplitHandler.h b/src/windows/7z/CPP/7zip/Archive/Split/SplitHandler.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Split/SplitHandler.h rename to src/windows/7z/CPP/7zip/Archive/Split/SplitHandler.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Split/SplitRegister.cpp b/src/windows/7z/CPP/7zip/Archive/Split/SplitRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Split/SplitRegister.cpp rename to src/windows/7z/CPP/7zip/Archive/Split/SplitRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Split/StdAfx.h b/src/windows/7z/CPP/7zip/Archive/Split/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Split/StdAfx.h rename to src/windows/7z/CPP/7zip/Archive/Split/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/StdAfx.h b/src/windows/7z/CPP/7zip/Archive/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/StdAfx.h rename to src/windows/7z/CPP/7zip/Archive/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Tar/StdAfx.h b/src/windows/7z/CPP/7zip/Archive/Tar/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Tar/StdAfx.h rename to src/windows/7z/CPP/7zip/Archive/Tar/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarHandler.cpp b/src/windows/7z/CPP/7zip/Archive/Tar/TarHandler.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarHandler.cpp rename to src/windows/7z/CPP/7zip/Archive/Tar/TarHandler.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarHandler.h b/src/windows/7z/CPP/7zip/Archive/Tar/TarHandler.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarHandler.h rename to src/windows/7z/CPP/7zip/Archive/Tar/TarHandler.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarHeader.cpp b/src/windows/7z/CPP/7zip/Archive/Tar/TarHeader.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarHeader.cpp rename to src/windows/7z/CPP/7zip/Archive/Tar/TarHeader.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarHeader.h b/src/windows/7z/CPP/7zip/Archive/Tar/TarHeader.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarHeader.h rename to src/windows/7z/CPP/7zip/Archive/Tar/TarHeader.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarIn.cpp b/src/windows/7z/CPP/7zip/Archive/Tar/TarIn.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarIn.cpp rename to src/windows/7z/CPP/7zip/Archive/Tar/TarIn.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarIn.h b/src/windows/7z/CPP/7zip/Archive/Tar/TarIn.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarIn.h rename to src/windows/7z/CPP/7zip/Archive/Tar/TarIn.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarItem.h b/src/windows/7z/CPP/7zip/Archive/Tar/TarItem.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarItem.h rename to src/windows/7z/CPP/7zip/Archive/Tar/TarItem.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarRegister.cpp b/src/windows/7z/CPP/7zip/Archive/Tar/TarRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Tar/TarRegister.cpp rename to src/windows/7z/CPP/7zip/Archive/Tar/TarRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Zip/StdAfx.h b/src/windows/7z/CPP/7zip/Archive/Zip/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Zip/StdAfx.h rename to src/windows/7z/CPP/7zip/Archive/Zip/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipCompressionMode.h b/src/windows/7z/CPP/7zip/Archive/Zip/ZipCompressionMode.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipCompressionMode.h rename to src/windows/7z/CPP/7zip/Archive/Zip/ZipCompressionMode.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipHandler.cpp b/src/windows/7z/CPP/7zip/Archive/Zip/ZipHandler.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipHandler.cpp rename to src/windows/7z/CPP/7zip/Archive/Zip/ZipHandler.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipHandler.h b/src/windows/7z/CPP/7zip/Archive/Zip/ZipHandler.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipHandler.h rename to src/windows/7z/CPP/7zip/Archive/Zip/ZipHandler.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipHeader.cpp b/src/windows/7z/CPP/7zip/Archive/Zip/ZipHeader.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipHeader.cpp rename to src/windows/7z/CPP/7zip/Archive/Zip/ZipHeader.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipHeader.h b/src/windows/7z/CPP/7zip/Archive/Zip/ZipHeader.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipHeader.h rename to src/windows/7z/CPP/7zip/Archive/Zip/ZipHeader.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipIn.cpp b/src/windows/7z/CPP/7zip/Archive/Zip/ZipIn.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipIn.cpp rename to src/windows/7z/CPP/7zip/Archive/Zip/ZipIn.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipIn.h b/src/windows/7z/CPP/7zip/Archive/Zip/ZipIn.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipIn.h rename to src/windows/7z/CPP/7zip/Archive/Zip/ZipIn.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipItem.cpp b/src/windows/7z/CPP/7zip/Archive/Zip/ZipItem.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipItem.cpp rename to src/windows/7z/CPP/7zip/Archive/Zip/ZipItem.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipItem.h b/src/windows/7z/CPP/7zip/Archive/Zip/ZipItem.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipItem.h rename to src/windows/7z/CPP/7zip/Archive/Zip/ZipItem.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipItemEx.h b/src/windows/7z/CPP/7zip/Archive/Zip/ZipItemEx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipItemEx.h rename to src/windows/7z/CPP/7zip/Archive/Zip/ZipItemEx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipRegister.cpp b/src/windows/7z/CPP/7zip/Archive/Zip/ZipRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Archive/Zip/ZipRegister.cpp rename to src/windows/7z/CPP/7zip/Archive/Zip/ZipRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/CreateCoder.cpp b/src/windows/7z/CPP/7zip/Common/CreateCoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/CreateCoder.cpp rename to src/windows/7z/CPP/7zip/Common/CreateCoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/CreateCoder.h b/src/windows/7z/CPP/7zip/Common/CreateCoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/CreateCoder.h rename to src/windows/7z/CPP/7zip/Common/CreateCoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/DeclareArcs.h b/src/windows/7z/CPP/7zip/Common/DeclareArcs.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/DeclareArcs.h rename to src/windows/7z/CPP/7zip/Common/DeclareArcs.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/DeclareCodecs.h b/src/windows/7z/CPP/7zip/Common/DeclareCodecs.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/DeclareCodecs.h rename to src/windows/7z/CPP/7zip/Common/DeclareCodecs.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/FilterCoder.cpp b/src/windows/7z/CPP/7zip/Common/FilterCoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/FilterCoder.cpp rename to src/windows/7z/CPP/7zip/Common/FilterCoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/FilterCoder.h b/src/windows/7z/CPP/7zip/Common/FilterCoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/FilterCoder.h rename to src/windows/7z/CPP/7zip/Common/FilterCoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/InBuffer.cpp b/src/windows/7z/CPP/7zip/Common/InBuffer.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/InBuffer.cpp rename to src/windows/7z/CPP/7zip/Common/InBuffer.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/InBuffer.h b/src/windows/7z/CPP/7zip/Common/InBuffer.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/InBuffer.h rename to src/windows/7z/CPP/7zip/Common/InBuffer.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/InOutTempBuffer.cpp b/src/windows/7z/CPP/7zip/Common/InOutTempBuffer.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/InOutTempBuffer.cpp rename to src/windows/7z/CPP/7zip/Common/InOutTempBuffer.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/InOutTempBuffer.h b/src/windows/7z/CPP/7zip/Common/InOutTempBuffer.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/InOutTempBuffer.h rename to src/windows/7z/CPP/7zip/Common/InOutTempBuffer.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/LimitedStreams.cpp b/src/windows/7z/CPP/7zip/Common/LimitedStreams.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/LimitedStreams.cpp rename to src/windows/7z/CPP/7zip/Common/LimitedStreams.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/LimitedStreams.h b/src/windows/7z/CPP/7zip/Common/LimitedStreams.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/LimitedStreams.h rename to src/windows/7z/CPP/7zip/Common/LimitedStreams.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/LockedStream.cpp b/src/windows/7z/CPP/7zip/Common/LockedStream.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/LockedStream.cpp rename to src/windows/7z/CPP/7zip/Common/LockedStream.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/LockedStream.h b/src/windows/7z/CPP/7zip/Common/LockedStream.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/LockedStream.h rename to src/windows/7z/CPP/7zip/Common/LockedStream.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/MemBlocks.cpp b/src/windows/7z/CPP/7zip/Common/MemBlocks.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/MemBlocks.cpp rename to src/windows/7z/CPP/7zip/Common/MemBlocks.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/MemBlocks.h b/src/windows/7z/CPP/7zip/Common/MemBlocks.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/MemBlocks.h rename to src/windows/7z/CPP/7zip/Common/MemBlocks.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/MethodId.cpp b/src/windows/7z/CPP/7zip/Common/MethodId.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/MethodId.cpp rename to src/windows/7z/CPP/7zip/Common/MethodId.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/MethodId.h b/src/windows/7z/CPP/7zip/Common/MethodId.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/MethodId.h rename to src/windows/7z/CPP/7zip/Common/MethodId.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/MethodProps.cpp b/src/windows/7z/CPP/7zip/Common/MethodProps.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/MethodProps.cpp rename to src/windows/7z/CPP/7zip/Common/MethodProps.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/MethodProps.h b/src/windows/7z/CPP/7zip/Common/MethodProps.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/MethodProps.h rename to src/windows/7z/CPP/7zip/Common/MethodProps.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/OffsetStream.cpp b/src/windows/7z/CPP/7zip/Common/OffsetStream.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/OffsetStream.cpp rename to src/windows/7z/CPP/7zip/Common/OffsetStream.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/OffsetStream.h b/src/windows/7z/CPP/7zip/Common/OffsetStream.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/OffsetStream.h rename to src/windows/7z/CPP/7zip/Common/OffsetStream.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/OutBuffer.cpp b/src/windows/7z/CPP/7zip/Common/OutBuffer.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/OutBuffer.cpp rename to src/windows/7z/CPP/7zip/Common/OutBuffer.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/OutBuffer.h b/src/windows/7z/CPP/7zip/Common/OutBuffer.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/OutBuffer.h rename to src/windows/7z/CPP/7zip/Common/OutBuffer.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/OutMemStream.cpp b/src/windows/7z/CPP/7zip/Common/OutMemStream.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/OutMemStream.cpp rename to src/windows/7z/CPP/7zip/Common/OutMemStream.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/OutMemStream.h b/src/windows/7z/CPP/7zip/Common/OutMemStream.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/OutMemStream.h rename to src/windows/7z/CPP/7zip/Common/OutMemStream.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/ProgressMt.cpp b/src/windows/7z/CPP/7zip/Common/ProgressMt.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/ProgressMt.cpp rename to src/windows/7z/CPP/7zip/Common/ProgressMt.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/ProgressMt.h b/src/windows/7z/CPP/7zip/Common/ProgressMt.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/ProgressMt.h rename to src/windows/7z/CPP/7zip/Common/ProgressMt.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/ProgressUtils.cpp b/src/windows/7z/CPP/7zip/Common/ProgressUtils.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/ProgressUtils.cpp rename to src/windows/7z/CPP/7zip/Common/ProgressUtils.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/ProgressUtils.h b/src/windows/7z/CPP/7zip/Common/ProgressUtils.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/ProgressUtils.h rename to src/windows/7z/CPP/7zip/Common/ProgressUtils.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/RegisterArc.h b/src/windows/7z/CPP/7zip/Common/RegisterArc.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/RegisterArc.h rename to src/windows/7z/CPP/7zip/Common/RegisterArc.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/RegisterCodec.h b/src/windows/7z/CPP/7zip/Common/RegisterCodec.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/RegisterCodec.h rename to src/windows/7z/CPP/7zip/Common/RegisterCodec.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/StdAfx.h b/src/windows/7z/CPP/7zip/Common/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/StdAfx.h rename to src/windows/7z/CPP/7zip/Common/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/StreamBinder.cpp b/src/windows/7z/CPP/7zip/Common/StreamBinder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/StreamBinder.cpp rename to src/windows/7z/CPP/7zip/Common/StreamBinder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/StreamBinder.h b/src/windows/7z/CPP/7zip/Common/StreamBinder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/StreamBinder.h rename to src/windows/7z/CPP/7zip/Common/StreamBinder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/StreamObjects.cpp b/src/windows/7z/CPP/7zip/Common/StreamObjects.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/StreamObjects.cpp rename to src/windows/7z/CPP/7zip/Common/StreamObjects.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/StreamObjects.h b/src/windows/7z/CPP/7zip/Common/StreamObjects.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/StreamObjects.h rename to src/windows/7z/CPP/7zip/Common/StreamObjects.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/StreamUtils.cpp b/src/windows/7z/CPP/7zip/Common/StreamUtils.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/StreamUtils.cpp rename to src/windows/7z/CPP/7zip/Common/StreamUtils.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/StreamUtils.h b/src/windows/7z/CPP/7zip/Common/StreamUtils.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/StreamUtils.h rename to src/windows/7z/CPP/7zip/Common/StreamUtils.h diff --git a/desmume/src/windows/7z/CPP/7zip/Common/VirtThread.cpp b/src/windows/7z/CPP/7zip/Common/VirtThread.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/VirtThread.cpp rename to src/windows/7z/CPP/7zip/Common/VirtThread.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Common/VirtThread.h b/src/windows/7z/CPP/7zip/Common/VirtThread.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Common/VirtThread.h rename to src/windows/7z/CPP/7zip/Common/VirtThread.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BZip2Const.h b/src/windows/7z/CPP/7zip/Compress/BZip2Const.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BZip2Const.h rename to src/windows/7z/CPP/7zip/Compress/BZip2Const.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BZip2Crc.cpp b/src/windows/7z/CPP/7zip/Compress/BZip2Crc.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BZip2Crc.cpp rename to src/windows/7z/CPP/7zip/Compress/BZip2Crc.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BZip2Crc.h b/src/windows/7z/CPP/7zip/Compress/BZip2Crc.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BZip2Crc.h rename to src/windows/7z/CPP/7zip/Compress/BZip2Crc.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BZip2Decoder.cpp b/src/windows/7z/CPP/7zip/Compress/BZip2Decoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BZip2Decoder.cpp rename to src/windows/7z/CPP/7zip/Compress/BZip2Decoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BZip2Decoder.h b/src/windows/7z/CPP/7zip/Compress/BZip2Decoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BZip2Decoder.h rename to src/windows/7z/CPP/7zip/Compress/BZip2Decoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BZip2Register.cpp b/src/windows/7z/CPP/7zip/Compress/BZip2Register.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BZip2Register.cpp rename to src/windows/7z/CPP/7zip/Compress/BZip2Register.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Bcj2Coder.cpp b/src/windows/7z/CPP/7zip/Compress/Bcj2Coder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Bcj2Coder.cpp rename to src/windows/7z/CPP/7zip/Compress/Bcj2Coder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Bcj2Coder.h b/src/windows/7z/CPP/7zip/Compress/Bcj2Coder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Bcj2Coder.h rename to src/windows/7z/CPP/7zip/Compress/Bcj2Coder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Bcj2Register.cpp b/src/windows/7z/CPP/7zip/Compress/Bcj2Register.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Bcj2Register.cpp rename to src/windows/7z/CPP/7zip/Compress/Bcj2Register.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BcjCoder.cpp b/src/windows/7z/CPP/7zip/Compress/BcjCoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BcjCoder.cpp rename to src/windows/7z/CPP/7zip/Compress/BcjCoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BcjCoder.h b/src/windows/7z/CPP/7zip/Compress/BcjCoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BcjCoder.h rename to src/windows/7z/CPP/7zip/Compress/BcjCoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BcjRegister.cpp b/src/windows/7z/CPP/7zip/Compress/BcjRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BcjRegister.cpp rename to src/windows/7z/CPP/7zip/Compress/BcjRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BitlDecoder.cpp b/src/windows/7z/CPP/7zip/Compress/BitlDecoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BitlDecoder.cpp rename to src/windows/7z/CPP/7zip/Compress/BitlDecoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BitlDecoder.h b/src/windows/7z/CPP/7zip/Compress/BitlDecoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BitlDecoder.h rename to src/windows/7z/CPP/7zip/Compress/BitlDecoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BitmDecoder.h b/src/windows/7z/CPP/7zip/Compress/BitmDecoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BitmDecoder.h rename to src/windows/7z/CPP/7zip/Compress/BitmDecoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BranchCoder.cpp b/src/windows/7z/CPP/7zip/Compress/BranchCoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BranchCoder.cpp rename to src/windows/7z/CPP/7zip/Compress/BranchCoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BranchCoder.h b/src/windows/7z/CPP/7zip/Compress/BranchCoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BranchCoder.h rename to src/windows/7z/CPP/7zip/Compress/BranchCoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BranchMisc.cpp b/src/windows/7z/CPP/7zip/Compress/BranchMisc.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BranchMisc.cpp rename to src/windows/7z/CPP/7zip/Compress/BranchMisc.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BranchMisc.h b/src/windows/7z/CPP/7zip/Compress/BranchMisc.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BranchMisc.h rename to src/windows/7z/CPP/7zip/Compress/BranchMisc.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/BranchRegister.cpp b/src/windows/7z/CPP/7zip/Compress/BranchRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/BranchRegister.cpp rename to src/windows/7z/CPP/7zip/Compress/BranchRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/ByteSwap.cpp b/src/windows/7z/CPP/7zip/Compress/ByteSwap.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/ByteSwap.cpp rename to src/windows/7z/CPP/7zip/Compress/ByteSwap.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/ByteSwap.h b/src/windows/7z/CPP/7zip/Compress/ByteSwap.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/ByteSwap.h rename to src/windows/7z/CPP/7zip/Compress/ByteSwap.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/ByteSwapRegister.cpp b/src/windows/7z/CPP/7zip/Compress/ByteSwapRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/ByteSwapRegister.cpp rename to src/windows/7z/CPP/7zip/Compress/ByteSwapRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Codec.def b/src/windows/7z/CPP/7zip/Compress/Codec.def similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Codec.def rename to src/windows/7z/CPP/7zip/Compress/Codec.def diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/CodecExports.cpp b/src/windows/7z/CPP/7zip/Compress/CodecExports.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/CodecExports.cpp rename to src/windows/7z/CPP/7zip/Compress/CodecExports.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/CopyCoder.cpp b/src/windows/7z/CPP/7zip/Compress/CopyCoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/CopyCoder.cpp rename to src/windows/7z/CPP/7zip/Compress/CopyCoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/CopyCoder.h b/src/windows/7z/CPP/7zip/Compress/CopyCoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/CopyCoder.h rename to src/windows/7z/CPP/7zip/Compress/CopyCoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/CopyRegister.cpp b/src/windows/7z/CPP/7zip/Compress/CopyRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/CopyRegister.cpp rename to src/windows/7z/CPP/7zip/Compress/CopyRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Deflate64Register.cpp b/src/windows/7z/CPP/7zip/Compress/Deflate64Register.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Deflate64Register.cpp rename to src/windows/7z/CPP/7zip/Compress/Deflate64Register.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/DeflateConst.h b/src/windows/7z/CPP/7zip/Compress/DeflateConst.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/DeflateConst.h rename to src/windows/7z/CPP/7zip/Compress/DeflateConst.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/DeflateDecoder.cpp b/src/windows/7z/CPP/7zip/Compress/DeflateDecoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/DeflateDecoder.cpp rename to src/windows/7z/CPP/7zip/Compress/DeflateDecoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/DeflateDecoder.h b/src/windows/7z/CPP/7zip/Compress/DeflateDecoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/DeflateDecoder.h rename to src/windows/7z/CPP/7zip/Compress/DeflateDecoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/DeflateNsisRegister.cpp b/src/windows/7z/CPP/7zip/Compress/DeflateNsisRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/DeflateNsisRegister.cpp rename to src/windows/7z/CPP/7zip/Compress/DeflateNsisRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/DeflateRegister.cpp b/src/windows/7z/CPP/7zip/Compress/DeflateRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/DeflateRegister.cpp rename to src/windows/7z/CPP/7zip/Compress/DeflateRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/HuffmanDecoder.h b/src/windows/7z/CPP/7zip/Compress/HuffmanDecoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/HuffmanDecoder.h rename to src/windows/7z/CPP/7zip/Compress/HuffmanDecoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/ImplodeDecoder.cpp b/src/windows/7z/CPP/7zip/Compress/ImplodeDecoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/ImplodeDecoder.cpp rename to src/windows/7z/CPP/7zip/Compress/ImplodeDecoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/ImplodeDecoder.h b/src/windows/7z/CPP/7zip/Compress/ImplodeDecoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/ImplodeDecoder.h rename to src/windows/7z/CPP/7zip/Compress/ImplodeDecoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp b/src/windows/7z/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp rename to src/windows/7z/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/ImplodeHuffmanDecoder.h b/src/windows/7z/CPP/7zip/Compress/ImplodeHuffmanDecoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/ImplodeHuffmanDecoder.h rename to src/windows/7z/CPP/7zip/Compress/ImplodeHuffmanDecoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/LzOutWindow.cpp b/src/windows/7z/CPP/7zip/Compress/LzOutWindow.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/LzOutWindow.cpp rename to src/windows/7z/CPP/7zip/Compress/LzOutWindow.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/LzOutWindow.h b/src/windows/7z/CPP/7zip/Compress/LzOutWindow.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/LzOutWindow.h rename to src/windows/7z/CPP/7zip/Compress/LzOutWindow.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/LzhDecoder.cpp b/src/windows/7z/CPP/7zip/Compress/LzhDecoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/LzhDecoder.cpp rename to src/windows/7z/CPP/7zip/Compress/LzhDecoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/LzhDecoder.h b/src/windows/7z/CPP/7zip/Compress/LzhDecoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/LzhDecoder.h rename to src/windows/7z/CPP/7zip/Compress/LzhDecoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/LzmaDecoder.cpp b/src/windows/7z/CPP/7zip/Compress/LzmaDecoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/LzmaDecoder.cpp rename to src/windows/7z/CPP/7zip/Compress/LzmaDecoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/LzmaDecoder.h b/src/windows/7z/CPP/7zip/Compress/LzmaDecoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/LzmaDecoder.h rename to src/windows/7z/CPP/7zip/Compress/LzmaDecoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/LzmaRegister.cpp b/src/windows/7z/CPP/7zip/Compress/LzmaRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/LzmaRegister.cpp rename to src/windows/7z/CPP/7zip/Compress/LzmaRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Mtf8.h b/src/windows/7z/CPP/7zip/Compress/Mtf8.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Mtf8.h rename to src/windows/7z/CPP/7zip/Compress/Mtf8.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/PpmdContext.h b/src/windows/7z/CPP/7zip/Compress/PpmdContext.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/PpmdContext.h rename to src/windows/7z/CPP/7zip/Compress/PpmdContext.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/PpmdDecode.h b/src/windows/7z/CPP/7zip/Compress/PpmdDecode.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/PpmdDecode.h rename to src/windows/7z/CPP/7zip/Compress/PpmdDecode.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/PpmdDecoder.cpp b/src/windows/7z/CPP/7zip/Compress/PpmdDecoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/PpmdDecoder.cpp rename to src/windows/7z/CPP/7zip/Compress/PpmdDecoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/PpmdDecoder.h b/src/windows/7z/CPP/7zip/Compress/PpmdDecoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/PpmdDecoder.h rename to src/windows/7z/CPP/7zip/Compress/PpmdDecoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/PpmdRegister.cpp b/src/windows/7z/CPP/7zip/Compress/PpmdRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/PpmdRegister.cpp rename to src/windows/7z/CPP/7zip/Compress/PpmdRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/PpmdSubAlloc.h b/src/windows/7z/CPP/7zip/Compress/PpmdSubAlloc.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/PpmdSubAlloc.h rename to src/windows/7z/CPP/7zip/Compress/PpmdSubAlloc.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/PpmdType.h b/src/windows/7z/CPP/7zip/Compress/PpmdType.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/PpmdType.h rename to src/windows/7z/CPP/7zip/Compress/PpmdType.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/RangeCoder.h b/src/windows/7z/CPP/7zip/Compress/RangeCoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/RangeCoder.h rename to src/windows/7z/CPP/7zip/Compress/RangeCoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/RangeCoderBit.h b/src/windows/7z/CPP/7zip/Compress/RangeCoderBit.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/RangeCoderBit.h rename to src/windows/7z/CPP/7zip/Compress/RangeCoderBit.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Rar1Decoder.cpp b/src/windows/7z/CPP/7zip/Compress/Rar1Decoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Rar1Decoder.cpp rename to src/windows/7z/CPP/7zip/Compress/Rar1Decoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Rar1Decoder.h b/src/windows/7z/CPP/7zip/Compress/Rar1Decoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Rar1Decoder.h rename to src/windows/7z/CPP/7zip/Compress/Rar1Decoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Rar2Decoder.cpp b/src/windows/7z/CPP/7zip/Compress/Rar2Decoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Rar2Decoder.cpp rename to src/windows/7z/CPP/7zip/Compress/Rar2Decoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Rar2Decoder.h b/src/windows/7z/CPP/7zip/Compress/Rar2Decoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Rar2Decoder.h rename to src/windows/7z/CPP/7zip/Compress/Rar2Decoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Rar3Decoder.cpp b/src/windows/7z/CPP/7zip/Compress/Rar3Decoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Rar3Decoder.cpp rename to src/windows/7z/CPP/7zip/Compress/Rar3Decoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Rar3Decoder.h b/src/windows/7z/CPP/7zip/Compress/Rar3Decoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Rar3Decoder.h rename to src/windows/7z/CPP/7zip/Compress/Rar3Decoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Rar3Vm.cpp b/src/windows/7z/CPP/7zip/Compress/Rar3Vm.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Rar3Vm.cpp rename to src/windows/7z/CPP/7zip/Compress/Rar3Vm.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/Rar3Vm.h b/src/windows/7z/CPP/7zip/Compress/Rar3Vm.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/Rar3Vm.h rename to src/windows/7z/CPP/7zip/Compress/Rar3Vm.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/RarCodecsRegister.cpp b/src/windows/7z/CPP/7zip/Compress/RarCodecsRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/RarCodecsRegister.cpp rename to src/windows/7z/CPP/7zip/Compress/RarCodecsRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/ShrinkDecoder.cpp b/src/windows/7z/CPP/7zip/Compress/ShrinkDecoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/ShrinkDecoder.cpp rename to src/windows/7z/CPP/7zip/Compress/ShrinkDecoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/ShrinkDecoder.h b/src/windows/7z/CPP/7zip/Compress/ShrinkDecoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/ShrinkDecoder.h rename to src/windows/7z/CPP/7zip/Compress/ShrinkDecoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/StdAfx.h b/src/windows/7z/CPP/7zip/Compress/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/StdAfx.h rename to src/windows/7z/CPP/7zip/Compress/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/ZlibDecoder.cpp b/src/windows/7z/CPP/7zip/Compress/ZlibDecoder.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/ZlibDecoder.cpp rename to src/windows/7z/CPP/7zip/Compress/ZlibDecoder.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Compress/ZlibDecoder.h b/src/windows/7z/CPP/7zip/Compress/ZlibDecoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Compress/ZlibDecoder.h rename to src/windows/7z/CPP/7zip/Compress/ZlibDecoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/7zAes.cpp b/src/windows/7z/CPP/7zip/Crypto/7zAes.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/7zAes.cpp rename to src/windows/7z/CPP/7zip/Crypto/7zAes.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/7zAes.h b/src/windows/7z/CPP/7zip/Crypto/7zAes.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/7zAes.h rename to src/windows/7z/CPP/7zip/Crypto/7zAes.h diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/7zAesRegister.cpp b/src/windows/7z/CPP/7zip/Crypto/7zAesRegister.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/7zAesRegister.cpp rename to src/windows/7z/CPP/7zip/Crypto/7zAesRegister.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/HmacSha1.cpp b/src/windows/7z/CPP/7zip/Crypto/HmacSha1.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/HmacSha1.cpp rename to src/windows/7z/CPP/7zip/Crypto/HmacSha1.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/HmacSha1.h b/src/windows/7z/CPP/7zip/Crypto/HmacSha1.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/HmacSha1.h rename to src/windows/7z/CPP/7zip/Crypto/HmacSha1.h diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/MyAes.cpp b/src/windows/7z/CPP/7zip/Crypto/MyAes.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/MyAes.cpp rename to src/windows/7z/CPP/7zip/Crypto/MyAes.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/MyAes.h b/src/windows/7z/CPP/7zip/Crypto/MyAes.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/MyAes.h rename to src/windows/7z/CPP/7zip/Crypto/MyAes.h diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp b/src/windows/7z/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp rename to src/windows/7z/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/Pbkdf2HmacSha1.h b/src/windows/7z/CPP/7zip/Crypto/Pbkdf2HmacSha1.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/Pbkdf2HmacSha1.h rename to src/windows/7z/CPP/7zip/Crypto/Pbkdf2HmacSha1.h diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/RandGen.cpp b/src/windows/7z/CPP/7zip/Crypto/RandGen.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/RandGen.cpp rename to src/windows/7z/CPP/7zip/Crypto/RandGen.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/RandGen.h b/src/windows/7z/CPP/7zip/Crypto/RandGen.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/RandGen.h rename to src/windows/7z/CPP/7zip/Crypto/RandGen.h diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/Rar20Crypto.cpp b/src/windows/7z/CPP/7zip/Crypto/Rar20Crypto.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/Rar20Crypto.cpp rename to src/windows/7z/CPP/7zip/Crypto/Rar20Crypto.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/Rar20Crypto.h b/src/windows/7z/CPP/7zip/Crypto/Rar20Crypto.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/Rar20Crypto.h rename to src/windows/7z/CPP/7zip/Crypto/Rar20Crypto.h diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/RarAes.cpp b/src/windows/7z/CPP/7zip/Crypto/RarAes.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/RarAes.cpp rename to src/windows/7z/CPP/7zip/Crypto/RarAes.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/RarAes.h b/src/windows/7z/CPP/7zip/Crypto/RarAes.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/RarAes.h rename to src/windows/7z/CPP/7zip/Crypto/RarAes.h diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/Sha1.cpp b/src/windows/7z/CPP/7zip/Crypto/Sha1.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/Sha1.cpp rename to src/windows/7z/CPP/7zip/Crypto/Sha1.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/Sha1.h b/src/windows/7z/CPP/7zip/Crypto/Sha1.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/Sha1.h rename to src/windows/7z/CPP/7zip/Crypto/Sha1.h diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/StdAfx.h b/src/windows/7z/CPP/7zip/Crypto/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/StdAfx.h rename to src/windows/7z/CPP/7zip/Crypto/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/WzAes.cpp b/src/windows/7z/CPP/7zip/Crypto/WzAes.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/WzAes.cpp rename to src/windows/7z/CPP/7zip/Crypto/WzAes.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/WzAes.h b/src/windows/7z/CPP/7zip/Crypto/WzAes.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/WzAes.h rename to src/windows/7z/CPP/7zip/Crypto/WzAes.h diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/ZipCrypto.cpp b/src/windows/7z/CPP/7zip/Crypto/ZipCrypto.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/ZipCrypto.cpp rename to src/windows/7z/CPP/7zip/Crypto/ZipCrypto.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/ZipCrypto.h b/src/windows/7z/CPP/7zip/Crypto/ZipCrypto.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/ZipCrypto.h rename to src/windows/7z/CPP/7zip/Crypto/ZipCrypto.h diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/ZipStrong.cpp b/src/windows/7z/CPP/7zip/Crypto/ZipStrong.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/ZipStrong.cpp rename to src/windows/7z/CPP/7zip/Crypto/ZipStrong.cpp diff --git a/desmume/src/windows/7z/CPP/7zip/Crypto/ZipStrong.h b/src/windows/7z/CPP/7zip/Crypto/ZipStrong.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/Crypto/ZipStrong.h rename to src/windows/7z/CPP/7zip/Crypto/ZipStrong.h diff --git a/desmume/src/windows/7z/CPP/7zip/ICoder.h b/src/windows/7z/CPP/7zip/ICoder.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/ICoder.h rename to src/windows/7z/CPP/7zip/ICoder.h diff --git a/desmume/src/windows/7z/CPP/7zip/IDecl.h b/src/windows/7z/CPP/7zip/IDecl.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/IDecl.h rename to src/windows/7z/CPP/7zip/IDecl.h diff --git a/desmume/src/windows/7z/CPP/7zip/IPassword.h b/src/windows/7z/CPP/7zip/IPassword.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/IPassword.h rename to src/windows/7z/CPP/7zip/IPassword.h diff --git a/desmume/src/windows/7z/CPP/7zip/IProgress.h b/src/windows/7z/CPP/7zip/IProgress.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/IProgress.h rename to src/windows/7z/CPP/7zip/IProgress.h diff --git a/desmume/src/windows/7z/CPP/7zip/IStream.h b/src/windows/7z/CPP/7zip/IStream.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/IStream.h rename to src/windows/7z/CPP/7zip/IStream.h diff --git a/desmume/src/windows/7z/CPP/7zip/PropID.h b/src/windows/7z/CPP/7zip/PropID.h similarity index 100% rename from desmume/src/windows/7z/CPP/7zip/PropID.h rename to src/windows/7z/CPP/7zip/PropID.h diff --git a/desmume/src/windows/7z/CPP/Common/Buffer.h b/src/windows/7z/CPP/Common/Buffer.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/Buffer.h rename to src/windows/7z/CPP/Common/Buffer.h diff --git a/desmume/src/windows/7z/CPP/Common/CRC.cpp b/src/windows/7z/CPP/Common/CRC.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Common/CRC.cpp rename to src/windows/7z/CPP/Common/CRC.cpp diff --git a/desmume/src/windows/7z/CPP/Common/ComTry.h b/src/windows/7z/CPP/Common/ComTry.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/ComTry.h rename to src/windows/7z/CPP/Common/ComTry.h diff --git a/desmume/src/windows/7z/CPP/Common/Defs.h b/src/windows/7z/CPP/Common/Defs.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/Defs.h rename to src/windows/7z/CPP/Common/Defs.h diff --git a/desmume/src/windows/7z/CPP/Common/DynamicBuffer.h b/src/windows/7z/CPP/Common/DynamicBuffer.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/DynamicBuffer.h rename to src/windows/7z/CPP/Common/DynamicBuffer.h diff --git a/desmume/src/windows/7z/CPP/Common/InitializeStaticLib.h b/src/windows/7z/CPP/Common/InitializeStaticLib.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/InitializeStaticLib.h rename to src/windows/7z/CPP/Common/InitializeStaticLib.h diff --git a/desmume/src/windows/7z/CPP/Common/IntToString.cpp b/src/windows/7z/CPP/Common/IntToString.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Common/IntToString.cpp rename to src/windows/7z/CPP/Common/IntToString.cpp diff --git a/desmume/src/windows/7z/CPP/Common/IntToString.h b/src/windows/7z/CPP/Common/IntToString.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/IntToString.h rename to src/windows/7z/CPP/Common/IntToString.h diff --git a/desmume/src/windows/7z/CPP/Common/MyCom.h b/src/windows/7z/CPP/Common/MyCom.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyCom.h rename to src/windows/7z/CPP/Common/MyCom.h diff --git a/desmume/src/windows/7z/CPP/Common/MyException.h b/src/windows/7z/CPP/Common/MyException.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyException.h rename to src/windows/7z/CPP/Common/MyException.h diff --git a/desmume/src/windows/7z/CPP/Common/MyInitGuid.h b/src/windows/7z/CPP/Common/MyInitGuid.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyInitGuid.h rename to src/windows/7z/CPP/Common/MyInitGuid.h diff --git a/desmume/src/windows/7z/CPP/Common/MyMap.cpp b/src/windows/7z/CPP/Common/MyMap.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyMap.cpp rename to src/windows/7z/CPP/Common/MyMap.cpp diff --git a/desmume/src/windows/7z/CPP/Common/MyMap.h b/src/windows/7z/CPP/Common/MyMap.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyMap.h rename to src/windows/7z/CPP/Common/MyMap.h diff --git a/desmume/src/windows/7z/CPP/Common/MyString.cpp b/src/windows/7z/CPP/Common/MyString.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyString.cpp rename to src/windows/7z/CPP/Common/MyString.cpp diff --git a/desmume/src/windows/7z/CPP/Common/MyString.h b/src/windows/7z/CPP/Common/MyString.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyString.h rename to src/windows/7z/CPP/Common/MyString.h diff --git a/desmume/src/windows/7z/CPP/Common/MyUnknown.h b/src/windows/7z/CPP/Common/MyUnknown.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyUnknown.h rename to src/windows/7z/CPP/Common/MyUnknown.h diff --git a/desmume/src/windows/7z/CPP/Common/MyVector.cpp b/src/windows/7z/CPP/Common/MyVector.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyVector.cpp rename to src/windows/7z/CPP/Common/MyVector.cpp diff --git a/desmume/src/windows/7z/CPP/Common/MyVector.h b/src/windows/7z/CPP/Common/MyVector.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyVector.h rename to src/windows/7z/CPP/Common/MyVector.h diff --git a/desmume/src/windows/7z/CPP/Common/MyWindows.h b/src/windows/7z/CPP/Common/MyWindows.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyWindows.h rename to src/windows/7z/CPP/Common/MyWindows.h diff --git a/desmume/src/windows/7z/CPP/Common/MyXml.cpp b/src/windows/7z/CPP/Common/MyXml.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyXml.cpp rename to src/windows/7z/CPP/Common/MyXml.cpp diff --git a/desmume/src/windows/7z/CPP/Common/MyXml.h b/src/windows/7z/CPP/Common/MyXml.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/MyXml.h rename to src/windows/7z/CPP/Common/MyXml.h diff --git a/desmume/src/windows/7z/CPP/Common/NewHandler.cpp b/src/windows/7z/CPP/Common/NewHandler.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Common/NewHandler.cpp rename to src/windows/7z/CPP/Common/NewHandler.cpp diff --git a/desmume/src/windows/7z/CPP/Common/NewHandler.h b/src/windows/7z/CPP/Common/NewHandler.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/NewHandler.h rename to src/windows/7z/CPP/Common/NewHandler.h diff --git a/desmume/src/windows/7z/CPP/Common/StringConvert.cpp b/src/windows/7z/CPP/Common/StringConvert.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Common/StringConvert.cpp rename to src/windows/7z/CPP/Common/StringConvert.cpp diff --git a/desmume/src/windows/7z/CPP/Common/StringConvert.h b/src/windows/7z/CPP/Common/StringConvert.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/StringConvert.h rename to src/windows/7z/CPP/Common/StringConvert.h diff --git a/desmume/src/windows/7z/CPP/Common/StringToInt.cpp b/src/windows/7z/CPP/Common/StringToInt.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Common/StringToInt.cpp rename to src/windows/7z/CPP/Common/StringToInt.cpp diff --git a/desmume/src/windows/7z/CPP/Common/StringToInt.h b/src/windows/7z/CPP/Common/StringToInt.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/StringToInt.h rename to src/windows/7z/CPP/Common/StringToInt.h diff --git a/desmume/src/windows/7z/CPP/Common/Types.h b/src/windows/7z/CPP/Common/Types.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/Types.h rename to src/windows/7z/CPP/Common/Types.h diff --git a/desmume/src/windows/7z/CPP/Common/UTFConvert.cpp b/src/windows/7z/CPP/Common/UTFConvert.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Common/UTFConvert.cpp rename to src/windows/7z/CPP/Common/UTFConvert.cpp diff --git a/desmume/src/windows/7z/CPP/Common/UTFConvert.h b/src/windows/7z/CPP/Common/UTFConvert.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/UTFConvert.h rename to src/windows/7z/CPP/Common/UTFConvert.h diff --git a/desmume/src/windows/7z/CPP/Common/Wildcard.cpp b/src/windows/7z/CPP/Common/Wildcard.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Common/Wildcard.cpp rename to src/windows/7z/CPP/Common/Wildcard.cpp diff --git a/desmume/src/windows/7z/CPP/Common/Wildcard.h b/src/windows/7z/CPP/Common/Wildcard.h similarity index 100% rename from desmume/src/windows/7z/CPP/Common/Wildcard.h rename to src/windows/7z/CPP/Common/Wildcard.h diff --git a/desmume/src/windows/7z/CPP/Windows/Defs.h b/src/windows/7z/CPP/Windows/Defs.h similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/Defs.h rename to src/windows/7z/CPP/Windows/Defs.h diff --git a/desmume/src/windows/7z/CPP/Windows/FileDir.cpp b/src/windows/7z/CPP/Windows/FileDir.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/FileDir.cpp rename to src/windows/7z/CPP/Windows/FileDir.cpp diff --git a/desmume/src/windows/7z/CPP/Windows/FileDir.h b/src/windows/7z/CPP/Windows/FileDir.h similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/FileDir.h rename to src/windows/7z/CPP/Windows/FileDir.h diff --git a/desmume/src/windows/7z/CPP/Windows/FileFind.cpp b/src/windows/7z/CPP/Windows/FileFind.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/FileFind.cpp rename to src/windows/7z/CPP/Windows/FileFind.cpp diff --git a/desmume/src/windows/7z/CPP/Windows/FileFind.h b/src/windows/7z/CPP/Windows/FileFind.h similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/FileFind.h rename to src/windows/7z/CPP/Windows/FileFind.h diff --git a/desmume/src/windows/7z/CPP/Windows/FileIO.cpp b/src/windows/7z/CPP/Windows/FileIO.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/FileIO.cpp rename to src/windows/7z/CPP/Windows/FileIO.cpp diff --git a/desmume/src/windows/7z/CPP/Windows/FileIO.h b/src/windows/7z/CPP/Windows/FileIO.h similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/FileIO.h rename to src/windows/7z/CPP/Windows/FileIO.h diff --git a/desmume/src/windows/7z/CPP/Windows/FileName.h b/src/windows/7z/CPP/Windows/FileName.h similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/FileName.h rename to src/windows/7z/CPP/Windows/FileName.h diff --git a/desmume/src/windows/7z/CPP/Windows/Handle.h b/src/windows/7z/CPP/Windows/Handle.h similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/Handle.h rename to src/windows/7z/CPP/Windows/Handle.h diff --git a/desmume/src/windows/7z/CPP/Windows/PropVariant.cpp b/src/windows/7z/CPP/Windows/PropVariant.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/PropVariant.cpp rename to src/windows/7z/CPP/Windows/PropVariant.cpp diff --git a/desmume/src/windows/7z/CPP/Windows/PropVariant.h b/src/windows/7z/CPP/Windows/PropVariant.h similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/PropVariant.h rename to src/windows/7z/CPP/Windows/PropVariant.h diff --git a/desmume/src/windows/7z/CPP/Windows/StdAfx.h b/src/windows/7z/CPP/Windows/StdAfx.h similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/StdAfx.h rename to src/windows/7z/CPP/Windows/StdAfx.h diff --git a/desmume/src/windows/7z/CPP/Windows/Synchronization.h b/src/windows/7z/CPP/Windows/Synchronization.h similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/Synchronization.h rename to src/windows/7z/CPP/Windows/Synchronization.h diff --git a/desmume/src/windows/7z/CPP/Windows/Thread.h b/src/windows/7z/CPP/Windows/Thread.h similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/Thread.h rename to src/windows/7z/CPP/Windows/Thread.h diff --git a/desmume/src/windows/7z/CPP/Windows/Time.cpp b/src/windows/7z/CPP/Windows/Time.cpp similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/Time.cpp rename to src/windows/7z/CPP/Windows/Time.cpp diff --git a/desmume/src/windows/7z/CPP/Windows/Time.h b/src/windows/7z/CPP/Windows/Time.h similarity index 100% rename from desmume/src/windows/7z/CPP/Windows/Time.h rename to src/windows/7z/CPP/Windows/Time.h diff --git a/desmume/src/windows/7z/DOC/License.txt b/src/windows/7z/DOC/License.txt similarity index 100% rename from desmume/src/windows/7z/DOC/License.txt rename to src/windows/7z/DOC/License.txt diff --git a/desmume/src/windows/7z/DOC/gpl.txt b/src/windows/7z/DOC/gpl.txt similarity index 100% rename from desmume/src/windows/7z/DOC/gpl.txt rename to src/windows/7z/DOC/gpl.txt diff --git a/desmume/src/windows/7z/DOC/readme.txt b/src/windows/7z/DOC/readme.txt similarity index 100% rename from desmume/src/windows/7z/DOC/readme.txt rename to src/windows/7z/DOC/readme.txt diff --git a/desmume/src/windows/7z/DOC/unRarLicense.txt b/src/windows/7z/DOC/unRarLicense.txt similarity index 100% rename from desmume/src/windows/7z/DOC/unRarLicense.txt rename to src/windows/7z/DOC/unRarLicense.txt diff --git a/desmume/src/windows/7zip.cpp b/src/windows/7zip.cpp similarity index 100% rename from desmume/src/windows/7zip.cpp rename to src/windows/7zip.cpp diff --git a/desmume/src/windows/7zip.h b/src/windows/7zip.h similarity index 100% rename from desmume/src/windows/7zip.h rename to src/windows/7zip.h diff --git a/desmume/src/windows/7zipstreams.h b/src/windows/7zipstreams.h similarity index 100% rename from desmume/src/windows/7zipstreams.h rename to src/windows/7zipstreams.h diff --git a/desmume/src/windows/AboutBox.cpp b/src/windows/AboutBox.cpp similarity index 95% rename from desmume/src/windows/AboutBox.cpp rename to src/windows/AboutBox.cpp index 068db7409..af0e5dc91 100644 --- a/desmume/src/windows/AboutBox.cpp +++ b/src/windows/AboutBox.cpp @@ -1,135 +1,134 @@ -/* AboutBox.cpp - - Copyright (C) 2008-2009 shash - Copyright (C) 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - - -#include "../common.h" -#include "version.h" - -#include "AboutBox.h" -#include "resource.h" - -#define ABOUT_TIMER_ID 110222 -#define PER_PAGE_TEAM 23 -#define SIZE_SCROLL_BUFFER PER_PAGE_TEAM + TEAM -const char *team[] = { - "Current Team", - "------------", - "Guillaume Duhamel", - "Normmatt", - "Bernat Muńoz (shash)", - "Riccardo Magliocchetti", - "Max Tabachenko (CrazyMax)", - "zeromus", - "Luigi__", - "adelikat", - "matusz", - "pa__", - "gocha", - "nitsuja", - "", - "Contributors", - "------------", - "Allustar", - "amponzi", - "Anthony Molinaro", - "ape", - "Damien Nozay (damdoum)", - "delfare", - "Romain Vallet", - "snkmad", - "Theo Berkau", - "thoduv", - "Tim Seidel (Mighty Max)", - "Pascal Giard (evilynux)", - "Ben Jaques (masscat)", - "Jeff Bland", - "", - "Honorary Nagmasters", - "(Thanks to our super testers for this release!)", - "------------", - "nash679", - "pokefan999", - "dottorleo", - "", - "average time from bug checkin to bugreport:", - "23 seconds", -}; - -const int TEAM = ARRAY_SIZE(team); - -u8 scroll_start; -u8 scroll_buffer[SIZE_SCROLL_BUFFER][255]; - -BOOL CALLBACK AboutBox_Proc (HWND dialog, UINT message,WPARAM wparam,LPARAM lparam) -{ - switch(message) - { - case WM_INITDIALOG: - { - char buf[2048]; - memset(buf, 0, sizeof(buf)); - wsprintf(buf, "version %s", DESMUME_VERSION_STRING DESMUME_COMPILER_DETAIL); - SetDlgItemText(dialog, IDC_TXT_VERSION, buf); - - memset(buf, 0, sizeof(buf)); - wsprintf(buf, "compiled: %s %s", __DATE__,__TIME__); - SetDlgItemText(dialog, IDC_TXT_COMPILED, buf); - - for (int i = 0; i < SIZE_SCROLL_BUFFER; i++) - strcpy((char *)scroll_buffer[i], "\n"); - for (int i = 0; i < TEAM; i++) - { - strcpy((char *)scroll_buffer[i + PER_PAGE_TEAM], team[i]); - strcat((char *)scroll_buffer[i + PER_PAGE_TEAM], "\n"); - } - SetTimer(dialog, ABOUT_TIMER_ID, 400, (TIMERPROC) NULL); - scroll_start = 1; - break; - } - - case WM_COMMAND: - { - if((HIWORD(wparam) == BN_CLICKED)&&(((int)LOWORD(wparam)) == IDC_FERMER)) - { - KillTimer(dialog, ABOUT_TIMER_ID); - EndDialog(dialog,0); - return 1; - } - break; - } - - case WM_TIMER: - { - char buf[4096]; - memset(buf, 0, sizeof(buf)); - for (int i = 0; i < PER_PAGE_TEAM; i++) - if(i+scroll_start < SIZE_SCROLL_BUFFER) - strcat(buf, (char *)scroll_buffer[i + scroll_start]); - scroll_start++; - if (scroll_start >= SIZE_SCROLL_BUFFER) - scroll_start = 0; - SetDlgItemText(dialog, IDC_AUTHORS_LIST, buf); - break; - } - } - return 0; -} +/* AboutBox.cpp + + Copyright (C) 2008-2009 shash + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + + +#include "../common.h" +#include "version.h" + +#include "AboutBox.h" +#include "resource.h" + +#define ABOUT_TIMER_ID 110222 +#define PER_PAGE_TEAM 23 +#define SIZE_SCROLL_BUFFER PER_PAGE_TEAM + TEAM +const char *team[] = { + "Current Team", + "------------", + "Guillaume Duhamel", + "Normmatt", + "Bernat Muńoz (shash)", + "Riccardo Magliocchetti", + "Max Tabachenko (CrazyMax)", + "zeromus", + "Luigi__", + "adelikat", + "matusz", + "pa__", + "gocha", + "", + "Contributors", + "------------", + "Allustar", + "amponzi", + "Anthony Molinaro", + "ape", + "Damien Nozay (damdoum)", + "delfare", + "Romain Vallet", + "snkmad", + "Theo Berkau", + "thoduv", + "Tim Seidel (Mighty Max)", + "Pascal Giard (evilynux)", + "Ben Jaques (masscat)", + "Jeff Bland", + "", + "Honorary Nagmasters", + "(Thanks to our super testers for this release!)", + "------------", + "nash679", + "pokefan999", + "dottorleo", + "lbalbalba", + "", + "average time from bug checkin to bugreport:", + "23 seconds", +}; + +const int TEAM = ARRAY_SIZE(team); + +u8 scroll_start; +u8 scroll_buffer[SIZE_SCROLL_BUFFER][255]; + +BOOL CALLBACK AboutBox_Proc (HWND dialog, UINT message,WPARAM wparam,LPARAM lparam) +{ + switch(message) + { + case WM_INITDIALOG: + { + char buf[2048]; + memset(buf, 0, sizeof(buf)); + wsprintf(buf, "version %s", DESMUME_VERSION_STRING DESMUME_COMPILER_DETAIL); + SetDlgItemText(dialog, IDC_TXT_VERSION, buf); + + memset(buf, 0, sizeof(buf)); + wsprintf(buf, "compiled: %s %s", __DATE__,__TIME__); + SetDlgItemText(dialog, IDC_TXT_COMPILED, buf); + + for (int i = 0; i < SIZE_SCROLL_BUFFER; i++) + strcpy((char *)scroll_buffer[i], "\n"); + for (int i = 0; i < TEAM; i++) + { + strcpy((char *)scroll_buffer[i + PER_PAGE_TEAM], team[i]); + strcat((char *)scroll_buffer[i + PER_PAGE_TEAM], "\n"); + } + SetTimer(dialog, ABOUT_TIMER_ID, 400, (TIMERPROC) NULL); + scroll_start = 1; + break; + } + + case WM_COMMAND: + { + if((HIWORD(wparam) == BN_CLICKED)&&(((int)LOWORD(wparam)) == IDC_FERMER)) + { + KillTimer(dialog, ABOUT_TIMER_ID); + EndDialog(dialog,0); + return 1; + } + break; + } + + case WM_TIMER: + { + char buf[4096]; + memset(buf, 0, sizeof(buf)); + for (int i = 0; i < PER_PAGE_TEAM; i++) + if(i+scroll_start < SIZE_SCROLL_BUFFER) + strcat(buf, (char *)scroll_buffer[i + scroll_start]); + scroll_start++; + if (scroll_start >= SIZE_SCROLL_BUFFER) + scroll_start = 0; + SetDlgItemText(dialog, IDC_AUTHORS_LIST, buf); + break; + } + } + return 0; +} diff --git a/desmume/src/windows/AboutBox.h b/src/windows/AboutBox.h similarity index 96% rename from desmume/src/windows/AboutBox.h rename to src/windows/AboutBox.h index ac53852e8..be6d84f7b 100644 --- a/desmume/src/windows/AboutBox.h +++ b/src/windows/AboutBox.h @@ -1,26 +1,26 @@ -/* - Copyright (C) 2008 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef ABOUTBOX_H -#define ABOUTBOX_H - -extern BOOL CALLBACK AboutBox_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam); - +/* + Copyright (C) 2008 shash + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef ABOUTBOX_H +#define ABOUTBOX_H + +extern BOOL CALLBACK AboutBox_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam); + #endif \ No newline at end of file diff --git a/desmume/src/windows/CWindow.cpp b/src/windows/CWindow.cpp similarity index 96% rename from desmume/src/windows/CWindow.cpp rename to src/windows/CWindow.cpp index 0874a7f62..df29b6b40 100644 --- a/desmume/src/windows/CWindow.cpp +++ b/src/windows/CWindow.cpp @@ -1,368 +1,368 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "CWindow.h" -#include "debug.h" - -WINCLASS::WINCLASS(LPSTR rclass, HINSTANCE hInst) -{ - memset(regclass, 0, sizeof(regclass)); - memcpy(regclass, rclass, strlen(rclass)); - - hwnd = NULL; - hmenu = NULL; - hInstance = hInst; - - minWidth = 0; - minHeight = 0; -} - -WINCLASS::~WINCLASS() -{ -} - -bool WINCLASS::create(LPSTR caption, int x, int y, int width, int height, int style, HMENU menu) -{ - if (hwnd != NULL) return false; - - hwnd = CreateWindow(regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL); - - if (hwnd != NULL) return true; - return false; -} - -bool WINCLASS::createEx(LPSTR caption, int x, int y, int width, int height, int style, int styleEx, HMENU menu) -{ - if (hwnd != NULL) return false; - - hwnd = CreateWindowEx(styleEx, regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL); - - if (hwnd != NULL) return true; - return false; -} - -bool WINCLASS::setMenu(HMENU menu) -{ - hmenu = menu; - return SetMenu(hwnd, hmenu)==TRUE; -} - -DWORD WINCLASS::checkMenu(UINT idd, bool check) -{ - return CheckMenuItem(hmenu, idd, MF_BYCOMMAND | (check?MF_CHECKED:MF_UNCHECKED)); -} - -HWND WINCLASS::getHWnd() -{ - return hwnd; -} - -void WINCLASS::Show(int mode) -{ - ShowWindow(hwnd, mode); -} - -void WINCLASS::Hide() -{ - ShowWindow(hwnd, SW_HIDE); -} - -void WINCLASS::setMinSize(int width, int height) -{ - minWidth = width; - minHeight = height; -} - -void WINCLASS::sizingMsg(WPARAM wParam, LPARAM lParam, LONG keepRatio) -{ - RECT *rect = (RECT*)lParam; - - int prevRight = rect->right; - int prevBottom = rect->bottom; - - int _minWidth, _minHeight; - - int xborder, yborder; - int ymenu, ymenunew; - int ycaption; - - MENUBARINFO mbi; - - /* Get the size of the border */ - xborder = GetSystemMetrics(SM_CXSIZEFRAME); - yborder = GetSystemMetrics(SM_CYSIZEFRAME); - - /* Get the size of the menu bar */ - ZeroMemory(&mbi, sizeof(mbi)); - mbi.cbSize = sizeof(mbi); - GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); - ymenu = (mbi.rcBar.bottom - mbi.rcBar.top + 1); - - /* Get the size of the caption bar */ - ycaption = GetSystemMetrics(SM_CYCAPTION); - - /* Calculate the minimum size in pixels */ - _minWidth = (xborder + minWidth + xborder); - _minHeight = (ycaption + yborder + ymenu + minHeight + yborder); - - /* Clamp the size to the minimum size (256x384) */ - rect->right = (rect->left + std::max(_minWidth, (int)(rect->right - rect->left))); - rect->bottom = (rect->top + std::max(_minHeight, (int)(rect->bottom - rect->top))); - - bool horizontalDrag = (wParam == WMSZ_LEFT) || (wParam == WMSZ_RIGHT); - bool verticalDrag = (wParam == WMSZ_TOP) || (wParam == WMSZ_BOTTOM); - if(verticalDrag && !(keepRatio & KEEPY)) - { - int clientHeight = rect->bottom - rect->top - ycaption - yborder - ymenu - yborder; - if(clientHeight < minHeight) - rect->bottom += minHeight - clientHeight; - } - else if(horizontalDrag && !(keepRatio & KEEPX)) - { - int clientWidth = rect->right - rect->left - xborder - xborder; - if(clientWidth < minWidth) - rect->right += minWidth - clientWidth; - } - else - { - /* Apply the ratio stuff */ - - float ratio1 = ((rect->right - rect->left - xborder - xborder ) / (float)minWidth); - float ratio2 = ((rect->bottom - rect->top - ycaption - yborder - ymenu - yborder) / (float)minHeight); - LONG correctedHeight = (LONG)((rect->top + ycaption + yborder + ymenu + (minHeight * ratio1) + yborder)); - LONG correctedWidth = (LONG)((rect->left + xborder + (minWidth * ratio2) + xborder)); - - if(keepRatio & KEEPX) - { - if((keepRatio & KEEPY) || (rect->bottom < correctedHeight)) - { - if(verticalDrag) - rect->right = correctedWidth; - else - rect->bottom = correctedHeight; - } - } - else - { - if((keepRatio & KEEPY) && (rect->right < correctedWidth)) - { - if(horizontalDrag) - rect->bottom = correctedHeight; - else - rect->right = correctedWidth; - } - } - } - - /* Check if the height of the menu has changed during the resize */ - ZeroMemory(&mbi, sizeof(mbi)); - mbi.cbSize = sizeof(mbi); - GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); - ymenunew = (mbi.rcBar.bottom - mbi.rcBar.top + 1); - - if(ymenunew != ymenu) - rect->bottom += (ymenunew - ymenu); - - // prevent "pushing" the window across the screen when resizing from the left or top - if(wParam == WMSZ_LEFT || wParam == WMSZ_TOPLEFT || wParam == WMSZ_BOTTOMLEFT) - { - rect->left -= rect->right - prevRight; - rect->right = prevRight; - } - if(wParam == WMSZ_TOP || wParam == WMSZ_TOPLEFT || wParam == WMSZ_TOPRIGHT) - { - rect->top -= rect->bottom - prevBottom; - rect->bottom = prevBottom; - } -} - -void WINCLASS::setClientSize(int width, int height) -{ - int xborder, yborder; - int ymenu, ymenunew; - int ycaption; - - MENUBARINFO mbi; - - RECT wndRect; - int finalx, finaly; - - /* Get the size of the border */ - xborder = GetSystemMetrics(SM_CXSIZEFRAME); - yborder = GetSystemMetrics(SM_CYSIZEFRAME); - - /* Get the size of the menu bar */ - ZeroMemory(&mbi, sizeof(mbi)); - mbi.cbSize = sizeof(mbi); - GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); - ymenu = (mbi.rcBar.bottom - mbi.rcBar.top + 1); - - /* Get the size of the caption bar */ - ycaption = GetSystemMetrics(SM_CYCAPTION); - - /* Finally, resize the window */ - GetWindowRect(hwnd, &wndRect); - finalx = (xborder + width + xborder); - finaly = (ycaption + yborder + ymenu + height + yborder); - MoveWindow(hwnd, wndRect.left, wndRect.top, finalx, finaly, TRUE); - - /* Oops, we also need to check if the height */ - /* of the menu bar has changed after the resize */ - ZeroMemory(&mbi, sizeof(mbi)); - mbi.cbSize = sizeof(mbi); - GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); - ymenunew = (mbi.rcBar.bottom - mbi.rcBar.top + 1); - - if(ymenunew != ymenu) - MoveWindow(hwnd, wndRect.left, wndRect.top, finalx, (finaly + (ymenunew - ymenu)), TRUE); -} - -//========================================================= Thread class -extern DWORD WINAPI ThreadProc(LPVOID lpParameter) -{ - THREADCLASS *tmp = (THREADCLASS *)lpParameter; - return tmp->ThreadFunc(); -} - -THREADCLASS::THREADCLASS() -{ - hThread = NULL; -} - -THREADCLASS::~THREADCLASS() -{ - closeThread(); -} - -void THREADCLASS::closeThread() -{ - if (hThread) - { - CloseHandle(hThread); - hThread = NULL; - } -} - -bool THREADCLASS::createThread() -{ - if (hThread) return false; - - hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &threadID); - if (!hThread) return false; - //WaitForSingleObject(hThread, INFINITE); - return true; -} - -//========================================================= Tools class -TOOLSCLASS::TOOLSCLASS(HINSTANCE hInst, int IDD, DLGPROC dlgproc) -{ - this->dlgproc = dlgproc; - hwnd = NULL; - hInstance = hInst; - idd=IDD; - memset(class_name, 0, sizeof(class_name)); - memset(class_name2, 0, sizeof(class_name2)); -} - -TOOLSCLASS::~TOOLSCLASS() -{ - close(); -} - -bool TOOLSCLASS::open() -{ - if (!createThread()) return false; - return true; -} - -bool TOOLSCLASS::close() -{ - return true; -} - -DWORD TOOLSCLASS::ThreadFunc() -{ - MSG messages; - LOG("Start thread\n"); - - GetLastError(); - hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(idd), NULL, (DLGPROC) dlgproc); - - if (!hwnd) - { - LOG("error creating dialog\n"); - return (-2); - } - - ShowWindow(hwnd, SW_SHOW); - UpdateWindow(hwnd); - - while (GetMessage (&messages, NULL, 0, 0)) - { - TranslateMessage(&messages); - DispatchMessage(&messages); - } - - unregClass(); - hwnd = NULL; - - closeThread(); - return 0; -} - -void TOOLSCLASS::regClass(LPSTR class_name, WNDPROC wproc, bool SecondReg) -{ - WNDCLASSEX wc; - - wc.cbSize = sizeof(wc); - if (SecondReg) - strcpy(this->class_name2, class_name); - else - strcpy(this->class_name, class_name); - - wc.lpszClassName = class_name; - wc.hInstance = hInstance; - wc.lpfnWndProc = wproc; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); - wc.style = 0; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hIconSm = 0; - - RegisterClassEx(&wc); -} - -void TOOLSCLASS::unregClass() -{ - if (class_name[0]) - { - UnregisterClass(class_name, hInstance); - } - if (class_name2[0]) - { - UnregisterClass(class_name2, hInstance); - } - memset(class_name, 0, sizeof(class_name)); - memset(class_name2, 0, sizeof(class_name2)); -} +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "CWindow.h" +#include "debug.h" + +WINCLASS::WINCLASS(LPSTR rclass, HINSTANCE hInst) +{ + memset(regclass, 0, sizeof(regclass)); + memcpy(regclass, rclass, strlen(rclass)); + + hwnd = NULL; + hmenu = NULL; + hInstance = hInst; + + minWidth = 0; + minHeight = 0; +} + +WINCLASS::~WINCLASS() +{ +} + +bool WINCLASS::create(LPSTR caption, int x, int y, int width, int height, int style, HMENU menu) +{ + if (hwnd != NULL) return false; + + hwnd = CreateWindow(regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL); + + if (hwnd != NULL) return true; + return false; +} + +bool WINCLASS::createEx(LPSTR caption, int x, int y, int width, int height, int style, int styleEx, HMENU menu) +{ + if (hwnd != NULL) return false; + + hwnd = CreateWindowEx(styleEx, regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL); + + if (hwnd != NULL) return true; + return false; +} + +bool WINCLASS::setMenu(HMENU menu) +{ + hmenu = menu; + return SetMenu(hwnd, hmenu)==TRUE; +} + +DWORD WINCLASS::checkMenu(UINT idd, bool check) +{ + return CheckMenuItem(hmenu, idd, MF_BYCOMMAND | (check?MF_CHECKED:MF_UNCHECKED)); +} + +HWND WINCLASS::getHWnd() +{ + return hwnd; +} + +void WINCLASS::Show(int mode) +{ + ShowWindow(hwnd, mode); +} + +void WINCLASS::Hide() +{ + ShowWindow(hwnd, SW_HIDE); +} + +void WINCLASS::setMinSize(int width, int height) +{ + minWidth = width; + minHeight = height; +} + +void WINCLASS::sizingMsg(WPARAM wParam, LPARAM lParam, LONG keepRatio) +{ + RECT *rect = (RECT*)lParam; + + int prevRight = rect->right; + int prevBottom = rect->bottom; + + int _minWidth, _minHeight; + + int xborder, yborder; + int ymenu, ymenunew; + int ycaption; + + MENUBARINFO mbi; + + /* Get the size of the border */ + xborder = GetSystemMetrics(SM_CXSIZEFRAME); + yborder = GetSystemMetrics(SM_CYSIZEFRAME); + + /* Get the size of the menu bar */ + ZeroMemory(&mbi, sizeof(mbi)); + mbi.cbSize = sizeof(mbi); + GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); + ymenu = (mbi.rcBar.bottom - mbi.rcBar.top + 1); + + /* Get the size of the caption bar */ + ycaption = GetSystemMetrics(SM_CYCAPTION); + + /* Calculate the minimum size in pixels */ + _minWidth = (xborder + minWidth + xborder); + _minHeight = (ycaption + yborder + ymenu + minHeight + yborder); + + /* Clamp the size to the minimum size (256x384) */ + rect->right = (rect->left + std::max(_minWidth, (int)(rect->right - rect->left))); + rect->bottom = (rect->top + std::max(_minHeight, (int)(rect->bottom - rect->top))); + + bool horizontalDrag = (wParam == WMSZ_LEFT) || (wParam == WMSZ_RIGHT); + bool verticalDrag = (wParam == WMSZ_TOP) || (wParam == WMSZ_BOTTOM); + if(verticalDrag && !(keepRatio & KEEPY)) + { + int clientHeight = rect->bottom - rect->top - ycaption - yborder - ymenu - yborder; + if(clientHeight < minHeight) + rect->bottom += minHeight - clientHeight; + } + else if(horizontalDrag && !(keepRatio & KEEPX)) + { + int clientWidth = rect->right - rect->left - xborder - xborder; + if(clientWidth < minWidth) + rect->right += minWidth - clientWidth; + } + else + { + /* Apply the ratio stuff */ + + float ratio1 = ((rect->right - rect->left - xborder - xborder ) / (float)minWidth); + float ratio2 = ((rect->bottom - rect->top - ycaption - yborder - ymenu - yborder) / (float)minHeight); + LONG correctedHeight = (LONG)((rect->top + ycaption + yborder + ymenu + (minHeight * ratio1) + yborder)); + LONG correctedWidth = (LONG)((rect->left + xborder + (minWidth * ratio2) + xborder)); + + if(keepRatio & KEEPX) + { + if((keepRatio & KEEPY) || (rect->bottom < correctedHeight)) + { + if(verticalDrag) + rect->right = correctedWidth; + else + rect->bottom = correctedHeight; + } + } + else + { + if((keepRatio & KEEPY) && (rect->right < correctedWidth)) + { + if(horizontalDrag) + rect->bottom = correctedHeight; + else + rect->right = correctedWidth; + } + } + } + + /* Check if the height of the menu has changed during the resize */ + ZeroMemory(&mbi, sizeof(mbi)); + mbi.cbSize = sizeof(mbi); + GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); + ymenunew = (mbi.rcBar.bottom - mbi.rcBar.top + 1); + + if(ymenunew != ymenu) + rect->bottom += (ymenunew - ymenu); + + // prevent "pushing" the window across the screen when resizing from the left or top + if(wParam == WMSZ_LEFT || wParam == WMSZ_TOPLEFT || wParam == WMSZ_BOTTOMLEFT) + { + rect->left -= rect->right - prevRight; + rect->right = prevRight; + } + if(wParam == WMSZ_TOP || wParam == WMSZ_TOPLEFT || wParam == WMSZ_TOPRIGHT) + { + rect->top -= rect->bottom - prevBottom; + rect->bottom = prevBottom; + } +} + +void WINCLASS::setClientSize(int width, int height) +{ + int xborder, yborder; + int ymenu, ymenunew; + int ycaption; + + MENUBARINFO mbi; + + RECT wndRect; + int finalx, finaly; + + /* Get the size of the border */ + xborder = GetSystemMetrics(SM_CXSIZEFRAME); + yborder = GetSystemMetrics(SM_CYSIZEFRAME); + + /* Get the size of the menu bar */ + ZeroMemory(&mbi, sizeof(mbi)); + mbi.cbSize = sizeof(mbi); + GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); + ymenu = (mbi.rcBar.bottom - mbi.rcBar.top + 1); + + /* Get the size of the caption bar */ + ycaption = GetSystemMetrics(SM_CYCAPTION); + + /* Finally, resize the window */ + GetWindowRect(hwnd, &wndRect); + finalx = (xborder + width + xborder); + finaly = (ycaption + yborder + ymenu + height + yborder); + MoveWindow(hwnd, wndRect.left, wndRect.top, finalx, finaly, TRUE); + + /* Oops, we also need to check if the height */ + /* of the menu bar has changed after the resize */ + ZeroMemory(&mbi, sizeof(mbi)); + mbi.cbSize = sizeof(mbi); + GetMenuBarInfo(hwnd, OBJID_MENU, 0, &mbi); + ymenunew = (mbi.rcBar.bottom - mbi.rcBar.top + 1); + + if(ymenunew != ymenu) + MoveWindow(hwnd, wndRect.left, wndRect.top, finalx, (finaly + (ymenunew - ymenu)), TRUE); +} + +//========================================================= Thread class +extern DWORD WINAPI ThreadProc(LPVOID lpParameter) +{ + THREADCLASS *tmp = (THREADCLASS *)lpParameter; + return tmp->ThreadFunc(); +} + +THREADCLASS::THREADCLASS() +{ + hThread = NULL; +} + +THREADCLASS::~THREADCLASS() +{ + closeThread(); +} + +void THREADCLASS::closeThread() +{ + if (hThread) + { + CloseHandle(hThread); + hThread = NULL; + } +} + +bool THREADCLASS::createThread() +{ + if (hThread) return false; + + hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &threadID); + if (!hThread) return false; + //WaitForSingleObject(hThread, INFINITE); + return true; +} + +//========================================================= Tools class +TOOLSCLASS::TOOLSCLASS(HINSTANCE hInst, int IDD, DLGPROC dlgproc) +{ + this->dlgproc = dlgproc; + hwnd = NULL; + hInstance = hInst; + idd=IDD; + memset(class_name, 0, sizeof(class_name)); + memset(class_name2, 0, sizeof(class_name2)); +} + +TOOLSCLASS::~TOOLSCLASS() +{ + close(); +} + +bool TOOLSCLASS::open() +{ + if (!createThread()) return false; + return true; +} + +bool TOOLSCLASS::close() +{ + return true; +} + +DWORD TOOLSCLASS::ThreadFunc() +{ + MSG messages; + LOG("Start thread\n"); + + GetLastError(); + hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(idd), NULL, (DLGPROC) dlgproc); + + if (!hwnd) + { + LOG("error creating dialog\n"); + return (-2); + } + + ShowWindow(hwnd, SW_SHOW); + UpdateWindow(hwnd); + + while (GetMessage (&messages, NULL, 0, 0)) + { + TranslateMessage(&messages); + DispatchMessage(&messages); + } + + unregClass(); + hwnd = NULL; + + closeThread(); + return 0; +} + +void TOOLSCLASS::regClass(LPSTR class_name, WNDPROC wproc, bool SecondReg) +{ + WNDCLASSEX wc; + + wc.cbSize = sizeof(wc); + if (SecondReg) + strcpy(this->class_name2, class_name); + else + strcpy(this->class_name, class_name); + + wc.lpszClassName = class_name; + wc.hInstance = hInstance; + wc.lpfnWndProc = wproc; + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hIcon = 0; + wc.lpszMenuName = 0; + wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); + wc.style = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hIconSm = 0; + + RegisterClassEx(&wc); +} + +void TOOLSCLASS::unregClass() +{ + if (class_name[0]) + { + UnregisterClass(class_name, hInstance); + } + if (class_name2[0]) + { + UnregisterClass(class_name2, hInstance); + } + memset(class_name, 0, sizeof(class_name)); + memset(class_name2, 0, sizeof(class_name2)); +} diff --git a/desmume/src/windows/CWindow.h b/src/windows/CWindow.h similarity index 95% rename from desmume/src/windows/CWindow.h rename to src/windows/CWindow.h index a7ff3e9ed..42fdde0c1 100644 --- a/desmume/src/windows/CWindow.h +++ b/src/windows/CWindow.h @@ -1,103 +1,103 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef CWINDOW_H -#define CWINDOW_H - -#include "../common.h" - -class WINCLASS -{ -private: - HWND hwnd; - HMENU hmenu; - HINSTANCE hInstance; - char regclass[256]; - int minWidth, minHeight; -public: - WINCLASS(LPSTR rclass, HINSTANCE hInst); - ~WINCLASS(); - - bool create(LPSTR caption, int x, int y, int width, int height, int style, - HMENU menu); - bool createEx(LPSTR caption, int x, int y, int width, int height, int style, int styleEx, - HMENU menu); - - bool setMenu(HMENU menu); - DWORD checkMenu(UINT idd, bool check); - - void Show(int mode); - void Hide(); - - HWND getHWnd(); - - void setMinSize(int width, int height); - - enum // keepRatio flags - { - NOKEEP = 0x0, - KEEPX = 0x1, - KEEPY = 0x2, - }; - - void sizingMsg(WPARAM wParam, LPARAM lParam, LONG keepRatio = NOKEEP); - void setClientSize(int width, int height); -}; - -class THREADCLASS -{ - friend DWORD WINAPI ThreadProc(LPVOID lpParameter); - HANDLE hThread; - -public: - THREADCLASS(); - virtual ~THREADCLASS(); - bool createThread(); - void closeThread(); - -protected: - DWORD threadID; - virtual DWORD ThreadFunc()=NULL; -}; - -class TOOLSCLASS : public THREADCLASS -{ -private: - HWND hwnd; - HINSTANCE hInstance; - DLGPROC dlgproc; - int idd; - char class_name[256]; - char class_name2[256]; - -protected: - DWORD ThreadFunc(); - -public: - TOOLSCLASS(HINSTANCE hInst, int IDD, DLGPROC wndproc); - virtual ~TOOLSCLASS(); - bool open(); - bool close(); - void regClass(LPSTR class_name, WNDPROC wproc, bool SecondReg = false); - void unregClass(); -}; - -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef CWINDOW_H +#define CWINDOW_H + +#include "../common.h" + +class WINCLASS +{ +private: + HWND hwnd; + HMENU hmenu; + HINSTANCE hInstance; + char regclass[256]; + int minWidth, minHeight; +public: + WINCLASS(LPSTR rclass, HINSTANCE hInst); + ~WINCLASS(); + + bool create(LPSTR caption, int x, int y, int width, int height, int style, + HMENU menu); + bool createEx(LPSTR caption, int x, int y, int width, int height, int style, int styleEx, + HMENU menu); + + bool setMenu(HMENU menu); + DWORD checkMenu(UINT idd, bool check); + + void Show(int mode); + void Hide(); + + HWND getHWnd(); + + void setMinSize(int width, int height); + + enum // keepRatio flags + { + NOKEEP = 0x0, + KEEPX = 0x1, + KEEPY = 0x2, + }; + + void sizingMsg(WPARAM wParam, LPARAM lParam, LONG keepRatio = NOKEEP); + void setClientSize(int width, int height); +}; + +class THREADCLASS +{ + friend DWORD WINAPI ThreadProc(LPVOID lpParameter); + HANDLE hThread; + +public: + THREADCLASS(); + virtual ~THREADCLASS(); + bool createThread(); + void closeThread(); + +protected: + DWORD threadID; + virtual DWORD ThreadFunc()=NULL; +}; + +class TOOLSCLASS : public THREADCLASS +{ +private: + HWND hwnd; + HINSTANCE hInstance; + DLGPROC dlgproc; + int idd; + char class_name[256]; + char class_name2[256]; + +protected: + DWORD ThreadFunc(); + +public: + TOOLSCLASS(HINSTANCE hInst, int IDD, DLGPROC wndproc); + virtual ~TOOLSCLASS(); + bool open(); + bool close(); + void regClass(LPSTR class_name, WNDPROC wproc, bool SecondReg = false); + void unregClass(); +}; + +#endif diff --git a/desmume/src/windows/DeSmuME.ico b/src/windows/DeSmuME.ico similarity index 100% rename from desmume/src/windows/DeSmuME.ico rename to src/windows/DeSmuME.ico diff --git a/desmume/src/windows/DeSmuME_2005.sln b/src/windows/DeSmuME_2005.sln similarity index 100% rename from desmume/src/windows/DeSmuME_2005.sln rename to src/windows/DeSmuME_2005.sln diff --git a/desmume/src/windows/DeSmuME_2005.vcproj b/src/windows/DeSmuME_2005.vcproj similarity index 89% rename from desmume/src/windows/DeSmuME_2005.vcproj rename to src/windows/DeSmuME_2005.vcproj index 891bbdbc0..ec9045328 100644 --- a/desmume/src/windows/DeSmuME_2005.vcproj +++ b/src/windows/DeSmuME_2005.vcproj @@ -52,7 +52,7 @@ EnableFiberSafeOptimizations="false" WholeProgramOptimization="false" AdditionalIncludeDirectories=".;..;"lua\lua-5.1.4\src";"glib-2.20.1\build";"glib-2.20.1\build\glib";.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples" - PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;DEBUG;_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;SPU_INTERPOLATE;HAVE_LIBZ;HAVE_LIBZZIP;NOMINMAX;EXPERIMENTAL_WIFI" + PreprocessorDefinitions="DEBUG;_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;SPU_INTERPOLATE;HAVE_LIBZ;HAVE_LIBZZIP;NOMINMAX;EXPERIMENTAL_WIFI" ExceptionHandling="1" BasicRuntimeChecks="0" BufferSecurityCheck="true" @@ -146,7 +146,7 @@ EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" AdditionalIncludeDirectories=".;..;"lua\lua-5.1.4\src";"glib-2.20.1\build";"glib-2.20.1\build\glib";.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples" - PreprocessorDefinitions="_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;SPU_INTERPOLATE;NOMINMAX;NDEBUG;RELEASE;EXPERIMENTAL_WIFI" + PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;SPU_INTERPOLATE;NOMINMAX;NDEBUG;RELEASE;EXPERIMENTAL_WIFI" StringPooling="true" ExceptionHandling="1" BasicRuntimeChecks="0" @@ -244,7 +244,7 @@ EnableFiberSafeOptimizations="true" WholeProgramOptimization="false" AdditionalIncludeDirectories=".;..;"lua\lua-5.1.4\src";"glib-2.20.1\build";"glib-2.20.1\build\glib";.\zlib123;.\zziplib;.\winpcap;userconfig;defaultconfig;.\7z;.\agg\include;.\agg\examples" - PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;SPU_INTERPOLATE;NOMINMAX;NDEBUG;RELEASE;EXPERIMENTAL_WIFI" + PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;GLIB_STATIC_COMPILATION;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;SPU_INTERPOLATE;NOMINMAX;NDEBUG;RELEASE;EXPERIMENTAL_WIFI" StringPooling="true" ExceptionHandling="1" BasicRuntimeChecks="0" @@ -254,8 +254,7 @@ EnableEnhancedInstructionSet="2" FloatingPointModel="2" RuntimeTypeInfo="false" - WarningLevel="3" - WarnAsError="false" + WarningLevel="2" DebugInformationFormat="3" CallingConvention="0" CompileAs="0" @@ -599,26 +598,6 @@ > - - - - - - - - - - + + + + + + + + + + + + + + + @@ -739,6 +754,10 @@ > + + @@ -943,6 +962,14 @@ RelativePath="..\GPU_osd.h" > + + + + @@ -1075,6 +1102,10 @@ RelativePath="..\saves.h" > + + diff --git a/desmume/src/windows/DeSmuME_2008.sln b/src/windows/DeSmuME_2008.sln similarity index 100% rename from desmume/src/windows/DeSmuME_2008.sln rename to src/windows/DeSmuME_2008.sln diff --git a/src/windows/DeSmuME_2008.suo b/src/windows/DeSmuME_2008.suo new file mode 100644 index 000000000..a1547c435 Binary files /dev/null and b/src/windows/DeSmuME_2008.suo differ diff --git a/desmume/src/windows/DeSmuME_2008.vcproj b/src/windows/DeSmuME_2008.vcproj similarity index 76% rename from desmume/src/windows/DeSmuME_2008.vcproj rename to src/windows/DeSmuME_2008.vcproj index 68a061993..fb13e16eb 100644 --- a/desmume/src/windows/DeSmuME_2008.vcproj +++ b/src/windows/DeSmuME_2008.vcproj @@ -521,6 +521,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -557,6 +693,10 @@ + + @@ -577,6 +717,10 @@ RelativePath=".\aviout.cpp" > + + @@ -593,6 +737,14 @@ RelativePath=".\CWindow.cpp" > + + + + @@ -609,10 +761,22 @@ RelativePath=".\hotkey.cpp" > + + + + + + @@ -621,10 +785,26 @@ RelativePath=".\main.cpp" > + + + + + + + + @@ -637,94 +817,46 @@ RelativePath=".\OpenArchive.h" > + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - + + @@ -927,6 +1055,10 @@ RelativePath="..\driver.h" > + + diff --git a/desmume/src/windows/DeSmuME_2010.sln b/src/windows/DeSmuME_2010.sln similarity index 100% rename from desmume/src/windows/DeSmuME_2010.sln rename to src/windows/DeSmuME_2010.sln diff --git a/desmume/src/windows/DeSmuME_2010.vcxproj b/src/windows/DeSmuME_2010.vcxproj similarity index 97% rename from desmume/src/windows/DeSmuME_2010.vcxproj rename to src/windows/DeSmuME_2010.vcxproj index 3b8cfdbc4..9af93753b 100644 --- a/desmume/src/windows/DeSmuME_2010.vcxproj +++ b/src/windows/DeSmuME_2010.vcxproj @@ -300,6 +300,7 @@ + @@ -311,6 +312,7 @@ + diff --git a/desmume/src/windows/DeSmuME_Intel.icproj b/src/windows/DeSmuME_Intel.icproj similarity index 100% rename from desmume/src/windows/DeSmuME_Intel.icproj rename to src/windows/DeSmuME_Intel.icproj diff --git a/desmume/src/windows/DeSmuME_Intel.sln b/src/windows/DeSmuME_Intel.sln similarity index 100% rename from desmume/src/windows/DeSmuME_Intel.sln rename to src/windows/DeSmuME_Intel.sln diff --git a/desmume/src/windows/DeSmuME_Intel.vcproj b/src/windows/DeSmuME_Intel.vcproj similarity index 100% rename from desmume/src/windows/DeSmuME_Intel.vcproj rename to src/windows/DeSmuME_Intel.vcproj diff --git a/desmume/src/windows/DeSmuME_x64.manifest b/src/windows/DeSmuME_x64.manifest similarity index 100% rename from desmume/src/windows/DeSmuME_x64.manifest rename to src/windows/DeSmuME_x64.manifest diff --git a/desmume/src/windows/DeSmuME_x86.manifest b/src/windows/DeSmuME_x86.manifest similarity index 100% rename from desmume/src/windows/DeSmuME_x86.manifest rename to src/windows/DeSmuME_x86.manifest diff --git a/desmume/src/windows/FirmConfig.cpp b/src/windows/FirmConfig.cpp similarity index 97% rename from desmume/src/windows/FirmConfig.cpp rename to src/windows/FirmConfig.cpp index 5055dbb66..0ddc4b279 100644 --- a/desmume/src/windows/FirmConfig.cpp +++ b/src/windows/FirmConfig.cpp @@ -1,165 +1,165 @@ -/* - Copyright (C) 2007 Normmatt - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include "../common.h" -#include -#include -#include - -#include "CWindow.h" - -#include "resource.h" -#include "FirmConfig.h" - -#include "../debug.h" -#include "../NDSSystem.h" - -static char nickname_buffer[11]; -static char message_buffer[27]; - -const char firmLang[6][16] = {"Japanese","English","French","German","Italian","Spanish"}; -const char firmColor[16][16] = {"Gray","Brown","Red","Pink","Orange","Yellow","Lime Green", - "Green","Dark Green","Sea Green","Turquoise","Blue", - "Dark Blue","Dark Purple","Violet","Magenta"}; -const char firmDay[31][16] = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14", - "15","16","17","18","19","20","21","22","23","24","25","26", - "27","28","29","30","31"}; -const char firmMonth[12][16] = {"January","Feburary","March","April","May","June","July", - "August","September","October","November","December"}; - -static void WriteFirmConfig( struct NDS_fw_config_data *fw_config) -{ - char temp_str[27]; - int i; - - WritePrivateProfileInt("Firmware","favColor", fw_config->fav_colour,IniName); - WritePrivateProfileInt("Firmware","bMonth", fw_config->birth_month,IniName); - WritePrivateProfileInt("Firmware","bDay",fw_config->birth_day,IniName); - WritePrivateProfileInt("Firmware","Language",fw_config->language,IniName); - - /* FIXME: harshly only use the lower byte of the UTF-16 character. - * This would cause strange behaviour if the user could set UTF-16 but - * they cannot yet. - */ - for ( i = 0; i < fw_config->nickname_len; i++) { - temp_str[i] = fw_config->nickname[i]; - } - temp_str[i] = '\0'; - WritePrivateProfileString("Firmware", "nickName", temp_str, IniName); - - for ( i = 0; i < fw_config->message_len; i++) { - temp_str[i] = fw_config->message[i]; - } - temp_str[i] = '\0'; - WritePrivateProfileString("Firmware","Message", temp_str, IniName); -} - -BOOL CALLBACK FirmConfig_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam) -{ - struct NDS_fw_config_data *fw_config = &win_fw_config; - int i; - char temp_str[27]; - - switch(komunikat) - { - case WM_INITDIALOG: - for(i=0;i<6;i++) SendDlgItemMessage(dialog,IDC_COMBO4,CB_ADDSTRING,0,(LPARAM)&firmLang[i]); - for(i=0;i<12;i++) SendDlgItemMessage(dialog,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)&firmMonth[i]); - for(i=0;i<16;i++) SendDlgItemMessage(dialog,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)&firmColor[i]); - for(i=0;i<31;i++) SendDlgItemMessage(dialog,IDC_COMBO3,CB_ADDSTRING,0,(LPARAM)&firmDay[i]); - SendDlgItemMessage(dialog,IDC_COMBO1,CB_SETCURSEL,fw_config->fav_colour,0); - SendDlgItemMessage(dialog,IDC_COMBO2,CB_SETCURSEL,fw_config->birth_month-1,0); - SendDlgItemMessage(dialog,IDC_COMBO3,CB_SETCURSEL,fw_config->birth_day-1,0); - SendDlgItemMessage(dialog,IDC_COMBO4,CB_SETCURSEL,fw_config->language,0); - SendDlgItemMessage(dialog,IDC_EDIT1,EM_SETLIMITTEXT,10,0); - SendDlgItemMessage(dialog,IDC_EDIT2,EM_SETLIMITTEXT,26,0); - SendDlgItemMessage(dialog,IDC_EDIT1,EM_SETSEL,0,10); - SendDlgItemMessage(dialog,IDC_EDIT2,EM_SETSEL,0,26); - - for ( i = 0; i < fw_config->nickname_len; i++) { - nickname_buffer[i] = fw_config->nickname[i]; - } - nickname_buffer[i] = '\0'; - SendDlgItemMessage(dialog,IDC_EDIT1,WM_SETTEXT,0,(LPARAM)nickname_buffer); - - for ( i = 0; i < fw_config->message_len; i++) { - message_buffer[i] = fw_config->message[i]; - } - message_buffer[i] = '\0'; - SendDlgItemMessage(dialog,IDC_EDIT2,WM_SETTEXT,0,(LPARAM)message_buffer); - break; - - case WM_COMMAND: - if((HIWORD(wparam)==BN_CLICKED)&&(((int)LOWORD(wparam))==IDOK)) - { - int char_index; - LRESULT res; - fw_config->fav_colour = SendDlgItemMessage(dialog,IDC_COMBO1,CB_GETCURSEL,0,0); - fw_config->birth_month = 1 + SendDlgItemMessage(dialog,IDC_COMBO2,CB_GETCURSEL,0,0); - fw_config->birth_day = 1 + SendDlgItemMessage(dialog,IDC_COMBO3,CB_GETCURSEL,0,0); - fw_config->language = SendDlgItemMessage(dialog,IDC_COMBO4,CB_GETCURSEL,0,0); - - *(WORD *)temp_str = 10; - res = SendDlgItemMessage(dialog,IDC_EDIT1,EM_GETLINE,0,(LPARAM)temp_str); - - if ( res > 0) { - temp_str[res] = '\0'; - fw_config->nickname_len = strlen( temp_str); - } - else { - strcpy( temp_str, "yopyop"); - fw_config->nickname_len = strlen( temp_str); - } - for ( char_index = 0; char_index < fw_config->nickname_len; char_index++) { - fw_config->nickname[char_index] = temp_str[char_index]; - } - - *(WORD *)temp_str = 26; - res = SendDlgItemMessage(dialog,IDC_EDIT2,EM_GETLINE,0,(LPARAM)temp_str); - if ( res > 0) { - temp_str[res] = '\0'; - fw_config->message_len = strlen( temp_str); - } - else { - fw_config->message_len = 0; - } - for ( char_index = 0; char_index < fw_config->message_len; char_index++) { - fw_config->message[char_index] = temp_str[char_index]; - } - - WriteFirmConfig( fw_config); - EndDialog(dialog,0); - NDS_CreateDummyFirmware( fw_config); - return 1; - } - else - if((HIWORD(wparam)==BN_CLICKED)&&(((int)LOWORD(wparam))==IDCANCEL)) - { - EndDialog(dialog, 0); - return 0; - } - break; - } - return 0; -} - - +/* + Copyright (C) 2007 Normmatt + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include "../common.h" +#include +#include +#include + +#include "CWindow.h" + +#include "resource.h" +#include "FirmConfig.h" + +#include "../debug.h" +#include "../NDSSystem.h" + +static char nickname_buffer[11]; +static char message_buffer[27]; + +const char firmLang[6][16] = {"Japanese","English","French","German","Italian","Spanish"}; +const char firmColor[16][16] = {"Gray","Brown","Red","Pink","Orange","Yellow","Lime Green", + "Green","Dark Green","Sea Green","Turquoise","Blue", + "Dark Blue","Dark Purple","Violet","Magenta"}; +const char firmDay[31][16] = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14", + "15","16","17","18","19","20","21","22","23","24","25","26", + "27","28","29","30","31"}; +const char firmMonth[12][16] = {"January","Feburary","March","April","May","June","July", + "August","September","October","November","December"}; + +static void WriteFirmConfig( struct NDS_fw_config_data *fw_config) +{ + char temp_str[27]; + int i; + + WritePrivateProfileInt("Firmware","favColor", fw_config->fav_colour,IniName); + WritePrivateProfileInt("Firmware","bMonth", fw_config->birth_month,IniName); + WritePrivateProfileInt("Firmware","bDay",fw_config->birth_day,IniName); + WritePrivateProfileInt("Firmware","Language",fw_config->language,IniName); + + /* FIXME: harshly only use the lower byte of the UTF-16 character. + * This would cause strange behaviour if the user could set UTF-16 but + * they cannot yet. + */ + for ( i = 0; i < fw_config->nickname_len; i++) { + temp_str[i] = fw_config->nickname[i]; + } + temp_str[i] = '\0'; + WritePrivateProfileString("Firmware", "nickName", temp_str, IniName); + + for ( i = 0; i < fw_config->message_len; i++) { + temp_str[i] = fw_config->message[i]; + } + temp_str[i] = '\0'; + WritePrivateProfileString("Firmware","Message", temp_str, IniName); +} + +BOOL CALLBACK FirmConfig_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam) +{ + struct NDS_fw_config_data *fw_config = &win_fw_config; + int i; + char temp_str[27]; + + switch(komunikat) + { + case WM_INITDIALOG: + for(i=0;i<6;i++) SendDlgItemMessage(dialog,IDC_COMBO4,CB_ADDSTRING,0,(LPARAM)&firmLang[i]); + for(i=0;i<12;i++) SendDlgItemMessage(dialog,IDC_COMBO2,CB_ADDSTRING,0,(LPARAM)&firmMonth[i]); + for(i=0;i<16;i++) SendDlgItemMessage(dialog,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)&firmColor[i]); + for(i=0;i<31;i++) SendDlgItemMessage(dialog,IDC_COMBO3,CB_ADDSTRING,0,(LPARAM)&firmDay[i]); + SendDlgItemMessage(dialog,IDC_COMBO1,CB_SETCURSEL,fw_config->fav_colour,0); + SendDlgItemMessage(dialog,IDC_COMBO2,CB_SETCURSEL,fw_config->birth_month-1,0); + SendDlgItemMessage(dialog,IDC_COMBO3,CB_SETCURSEL,fw_config->birth_day-1,0); + SendDlgItemMessage(dialog,IDC_COMBO4,CB_SETCURSEL,fw_config->language,0); + SendDlgItemMessage(dialog,IDC_EDIT1,EM_SETLIMITTEXT,10,0); + SendDlgItemMessage(dialog,IDC_EDIT2,EM_SETLIMITTEXT,26,0); + SendDlgItemMessage(dialog,IDC_EDIT1,EM_SETSEL,0,10); + SendDlgItemMessage(dialog,IDC_EDIT2,EM_SETSEL,0,26); + + for ( i = 0; i < fw_config->nickname_len; i++) { + nickname_buffer[i] = fw_config->nickname[i]; + } + nickname_buffer[i] = '\0'; + SendDlgItemMessage(dialog,IDC_EDIT1,WM_SETTEXT,0,(LPARAM)nickname_buffer); + + for ( i = 0; i < fw_config->message_len; i++) { + message_buffer[i] = fw_config->message[i]; + } + message_buffer[i] = '\0'; + SendDlgItemMessage(dialog,IDC_EDIT2,WM_SETTEXT,0,(LPARAM)message_buffer); + break; + + case WM_COMMAND: + if((HIWORD(wparam)==BN_CLICKED)&&(((int)LOWORD(wparam))==IDOK)) + { + int char_index; + LRESULT res; + fw_config->fav_colour = SendDlgItemMessage(dialog,IDC_COMBO1,CB_GETCURSEL,0,0); + fw_config->birth_month = 1 + SendDlgItemMessage(dialog,IDC_COMBO2,CB_GETCURSEL,0,0); + fw_config->birth_day = 1 + SendDlgItemMessage(dialog,IDC_COMBO3,CB_GETCURSEL,0,0); + fw_config->language = SendDlgItemMessage(dialog,IDC_COMBO4,CB_GETCURSEL,0,0); + + *(WORD *)temp_str = 10; + res = SendDlgItemMessage(dialog,IDC_EDIT1,EM_GETLINE,0,(LPARAM)temp_str); + + if ( res > 0) { + temp_str[res] = '\0'; + fw_config->nickname_len = strlen( temp_str); + } + else { + strcpy( temp_str, "yopyop"); + fw_config->nickname_len = strlen( temp_str); + } + for ( char_index = 0; char_index < fw_config->nickname_len; char_index++) { + fw_config->nickname[char_index] = temp_str[char_index]; + } + + *(WORD *)temp_str = 26; + res = SendDlgItemMessage(dialog,IDC_EDIT2,EM_GETLINE,0,(LPARAM)temp_str); + if ( res > 0) { + temp_str[res] = '\0'; + fw_config->message_len = strlen( temp_str); + } + else { + fw_config->message_len = 0; + } + for ( char_index = 0; char_index < fw_config->message_len; char_index++) { + fw_config->message[char_index] = temp_str[char_index]; + } + + WriteFirmConfig( fw_config); + EndDialog(dialog,0); + NDS_CreateDummyFirmware( fw_config); + return 1; + } + else + if((HIWORD(wparam)==BN_CLICKED)&&(((int)LOWORD(wparam))==IDCANCEL)) + { + EndDialog(dialog, 0); + return 0; + } + break; + } + return 0; +} + + diff --git a/desmume/src/windows/FirmConfig.h b/src/windows/FirmConfig.h similarity index 97% rename from desmume/src/windows/FirmConfig.h rename to src/windows/FirmConfig.h index 245bf25f9..b9764fd2c 100644 --- a/desmume/src/windows/FirmConfig.h +++ b/src/windows/FirmConfig.h @@ -1,28 +1,28 @@ -/* - Copyright (C) 2007 Normmatt - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef FIRMCONFIG_H -#define FIRMCONFIG_H - -extern struct NDS_fw_config_data win_fw_config; - -BOOL CALLBACK FirmConfig_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam); - -#endif +/* + Copyright (C) 2007 Normmatt + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef FIRMCONFIG_H +#define FIRMCONFIG_H + +extern struct NDS_fw_config_data win_fw_config; + +BOOL CALLBACK FirmConfig_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam); + +#endif diff --git a/desmume/src/windows/GL/glext.h b/src/windows/GL/glext.h similarity index 98% rename from desmume/src/windows/GL/glext.h rename to src/windows/GL/glext.h index 8a82753a6..d982c5a18 100644 --- a/desmume/src/windows/GL/glext.h +++ b/src/windows/GL/glext.h @@ -1,8460 +1,8460 @@ -#ifndef __glext_h_ -#define __glext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated 2008/11/14 */ -/* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 44 - -#ifndef GL_VERSION_1_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_RESCALE_NORMAL 0x803A -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif - -#ifndef GL_ARB_imaging -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -#endif - -#ifndef GL_VERSION_1_3 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_SUBTRACT 0x84E7 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -#endif - -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE -#define GL_FOG_COORD GL_FOG_COORDINATE -#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE -#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE -#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER -#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING -#define GL_SRC0_RGB GL_SOURCE0_RGB -#define GL_SRC1_RGB GL_SOURCE1_RGB -#define GL_SRC2_RGB GL_SOURCE2_RGB -#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA -#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA -#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA -#endif - -#ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_COORDS 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_VERSION_2_1 -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_SLUMINANCE_ALPHA 0x8C44 -#define GL_SLUMINANCE8_ALPHA8 0x8C45 -#define GL_SLUMINANCE 0x8C46 -#define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#define GL_COMPRESSED_SLUMINANCE 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B -#endif - -#ifndef GL_VERSION_3_0 -#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB -#define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0 -#define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1 -#define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2 -#define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3 -#define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4 -#define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5 -#define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_CONTEXT_FLAGS 0x821E -#define GL_DEPTH_BUFFER 0x8223 -#define GL_STENCIL_BUFFER 0x8224 -#define GL_COMPRESSED_RED 0x8225 -#define GL_COMPRESSED_RG 0x8226 -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 -#define GL_RGBA32F 0x8814 -#define GL_RGB32F 0x8815 -#define GL_RGBA16F 0x881A -#define GL_RGB16F 0x881B -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B -#define GL_CLAMP_READ_COLOR 0x891C -#define GL_FIXED_ONLY 0x891D -#define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_TEXTURE_1D_ARRAY 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define GL_R11F_G11F_B10F 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define GL_RGB9_E5 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define GL_PRIMITIVES_GENERATED 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define GL_RASTERIZER_DISCARD 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define GL_INTERLEAVED_ATTRIBS 0x8C8C -#define GL_SEPARATE_ATTRIBS 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define GL_RGBA32UI 0x8D70 -#define GL_RGB32UI 0x8D71 -#define GL_RGBA16UI 0x8D76 -#define GL_RGB16UI 0x8D77 -#define GL_RGBA8UI 0x8D7C -#define GL_RGB8UI 0x8D7D -#define GL_RGBA32I 0x8D82 -#define GL_RGB32I 0x8D83 -#define GL_RGBA16I 0x8D88 -#define GL_RGB16I 0x8D89 -#define GL_RGBA8I 0x8D8E -#define GL_RGB8I 0x8D8F -#define GL_RED_INTEGER 0x8D94 -#define GL_GREEN_INTEGER 0x8D95 -#define GL_BLUE_INTEGER 0x8D96 -#define GL_ALPHA_INTEGER 0x8D97 -#define GL_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_BGR_INTEGER 0x8D9A -#define GL_BGRA_INTEGER 0x8D9B -#define GL_SAMPLER_1D_ARRAY 0x8DC0 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define GL_UNSIGNED_INT_VEC2 0x8DC6 -#define GL_UNSIGNED_INT_VEC3 0x8DC7 -#define GL_UNSIGNED_INT_VEC4 0x8DC8 -#define GL_INT_SAMPLER_1D 0x8DC9 -#define GL_INT_SAMPLER_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define GL_QUERY_WAIT 0x8E13 -#define GL_QUERY_NO_WAIT 0x8E14 -#define GL_QUERY_BY_REGION_WAIT 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 -/* Reuse tokens from ARB_depth_buffer_float */ -/* reuse GL_DEPTH_COMPONENT32F */ -/* reuse GL_DEPTH32F_STENCIL8 */ -/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_DEFAULT */ -/* reuse GL_FRAMEBUFFER_UNDEFINED */ -/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ -/* reuse GL_INDEX */ -/* reuse GL_MAX_RENDERBUFFER_SIZE */ -/* reuse GL_DEPTH_STENCIL */ -/* reuse GL_UNSIGNED_INT_24_8 */ -/* reuse GL_DEPTH24_STENCIL8 */ -/* reuse GL_TEXTURE_STENCIL_SIZE */ -/* reuse GL_TEXTURE_RED_TYPE */ -/* reuse GL_TEXTURE_GREEN_TYPE */ -/* reuse GL_TEXTURE_BLUE_TYPE */ -/* reuse GL_TEXTURE_ALPHA_TYPE */ -/* reuse GL_TEXTURE_LUMINANCE_TYPE */ -/* reuse GL_TEXTURE_INTENSITY_TYPE */ -/* reuse GL_TEXTURE_DEPTH_TYPE */ -/* reuse GL_UNSIGNED_NORMALIZED */ -/* reuse GL_FRAMEBUFFER_BINDING */ -/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_BINDING */ -/* reuse GL_READ_FRAMEBUFFER */ -/* reuse GL_DRAW_FRAMEBUFFER */ -/* reuse GL_READ_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_SAMPLES */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* reuse GL_FRAMEBUFFER_COMPLETE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ -/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ -/* reuse GL_MAX_COLOR_ATTACHMENTS */ -/* reuse GL_COLOR_ATTACHMENT0 */ -/* reuse GL_COLOR_ATTACHMENT1 */ -/* reuse GL_COLOR_ATTACHMENT2 */ -/* reuse GL_COLOR_ATTACHMENT3 */ -/* reuse GL_COLOR_ATTACHMENT4 */ -/* reuse GL_COLOR_ATTACHMENT5 */ -/* reuse GL_COLOR_ATTACHMENT6 */ -/* reuse GL_COLOR_ATTACHMENT7 */ -/* reuse GL_COLOR_ATTACHMENT8 */ -/* reuse GL_COLOR_ATTACHMENT9 */ -/* reuse GL_COLOR_ATTACHMENT10 */ -/* reuse GL_COLOR_ATTACHMENT11 */ -/* reuse GL_COLOR_ATTACHMENT12 */ -/* reuse GL_COLOR_ATTACHMENT13 */ -/* reuse GL_COLOR_ATTACHMENT14 */ -/* reuse GL_COLOR_ATTACHMENT15 */ -/* reuse GL_DEPTH_ATTACHMENT */ -/* reuse GL_STENCIL_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER */ -/* reuse GL_RENDERBUFFER */ -/* reuse GL_RENDERBUFFER_WIDTH */ -/* reuse GL_RENDERBUFFER_HEIGHT */ -/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ -/* reuse GL_STENCIL_INDEX1 */ -/* reuse GL_STENCIL_INDEX4 */ -/* reuse GL_STENCIL_INDEX8 */ -/* reuse GL_STENCIL_INDEX16 */ -/* reuse GL_RENDERBUFFER_RED_SIZE */ -/* reuse GL_RENDERBUFFER_GREEN_SIZE */ -/* reuse GL_RENDERBUFFER_BLUE_SIZE */ -/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ -/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ -/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ -/* reuse GL_MAX_SAMPLES */ -/* Reuse tokens from ARB_framebuffer_sRGB */ -/* reuse GL_FRAMEBUFFER_SRGB */ -/* Reuse tokens from ARB_half_float_vertex */ -/* reuse GL_HALF_FLOAT */ -/* Reuse tokens from ARB_map_buffer_range */ -/* reuse GL_MAP_READ_BIT */ -/* reuse GL_MAP_WRITE_BIT */ -/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ -/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ -/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ -/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ -/* Reuse tokens from ARB_texture_compression_rgtc */ -/* reuse GL_COMPRESSED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_RG_RGTC2 */ -/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ -/* Reuse tokens from ARB_texture_rg */ -/* reuse GL_RG */ -/* reuse GL_RG_INTEGER */ -/* reuse GL_R8 */ -/* reuse GL_R16 */ -/* reuse GL_RG8 */ -/* reuse GL_RG16 */ -/* reuse GL_R16F */ -/* reuse GL_R32F */ -/* reuse GL_RG16F */ -/* reuse GL_RG32F */ -/* reuse GL_R8I */ -/* reuse GL_R8UI */ -/* reuse GL_R16I */ -/* reuse GL_R16UI */ -/* reuse GL_R32I */ -/* reuse GL_R32UI */ -/* reuse GL_RG8I */ -/* reuse GL_RG8UI */ -/* reuse GL_RG16I */ -/* reuse GL_RG16UI */ -/* reuse GL_RG32I */ -/* reuse GL_RG32UI */ -/* Reuse tokens from ARB_vertex_array_object */ -/* reuse GL_VERTEX_ARRAY_BINDING */ -#endif - -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#endif - -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif - -#ifndef GL_ARB_texture_env_add -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -#ifndef GL_ARB_texture_compression -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif - -#ifndef GL_ARB_point_parameters -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - -#ifndef GL_ARB_shadow -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif - -#ifndef GL_ARB_window_pos -#endif - -#ifndef GL_ARB_vertex_program -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif - -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#endif - -#ifndef GL_ARB_point_sprite -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -#ifndef GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#endif - -#ifndef GL_ARB_draw_instanced -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_INDEX 0x8222 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#endif - -#ifndef GL_ARB_geometry_shader4 -#define GL_LINES_ADJACENCY_ARB 0x000A -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B -#define GL_TRIANGLES_ADJACENCY_ARB 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_HALF_FLOAT 0x140B -#endif - -#ifndef GL_ARB_instanced_arrays -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#endif - -#ifndef GL_ARB_texture_rg -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -#endif - -#ifndef GL_EXT_abgr -#define GL_ABGR_EXT 0x8000 -#endif - -#ifndef GL_EXT_blend_color -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#endif - -#ifndef GL_EXT_texture -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif - -#ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -#endif - -#ifndef GL_EXT_subtexture -#endif - -#ifndef GL_EXT_copy_texture -#endif - -#ifndef GL_EXT_histogram -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#endif - -#ifndef GL_EXT_convolution -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#endif - -#ifndef GL_SGI_color_matrix -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif - -#ifndef GL_SGI_color_table -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#endif - -#ifndef GL_SGIS_texture4D -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif - -#ifndef GL_EXT_cmyka -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif - -#ifndef GL_EXT_texture_object -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif - -#ifndef GL_SGIS_multisample -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif - -#ifndef GL_EXT_vertex_array -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#endif - -#ifndef GL_EXT_misc_attribute -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif - -#ifndef GL_SGIX_shadow -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif - -#ifndef GL_EXT_blend_logic_op -#endif - -#ifndef GL_SGIX_interlace -#define GL_INTERLACE_SGIX 0x8094 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif - -#ifndef GL_SGIS_texture_select -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif - -#ifndef GL_EXT_point_parameters -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#endif - -#ifndef GL_SGIX_instruments -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif - -#ifndef GL_SGIX_framezoom -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#endif - -#ifndef GL_FfdMaskSGIX -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#endif - -#ifndef GL_SGIX_flush_raster -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif - -#ifndef GL_HP_image_transform -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif - -#ifndef GL_INGR_palette_buffer -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif - -#ifndef GL_EXT_color_subtable -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_LIST_PRIORITY_SGIX 0x8182 -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif - -#ifndef GL_EXT_index_texture -#endif - -#ifndef GL_EXT_index_material -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#endif - -#ifndef GL_EXT_index_func -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#endif - -#ifndef GL_WIN_phong_shading -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif - -#ifndef GL_WIN_specular_fog -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif - -#ifndef GL_EXT_light_texture -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -/* reuse GL_FRAGMENT_DEPTH_EXT */ -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif - -#ifndef GL_SGIX_impact_pixel_texture -#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#endif - -#ifndef GL_EXT_bgra -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif - -#ifndef GL_SGIX_async -#define GL_ASYNC_MARKER_SGIX 0x8329 -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif - -#ifndef GL_INTEL_texture_scissor -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#endif - -#ifndef GL_HP_occlusion_test -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_EXT_secondary_color -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -#endif - -#ifndef GL_EXT_multi_draw_arrays -#endif - -#ifndef GL_EXT_fog_coord -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_FOG_SCALE_SGIX 0x81FC -#define GL_FOG_SCALE_VALUE_SGIX 0x81FD -#endif - -#ifndef GL_SUNX_constant_data -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#endif - -#ifndef GL_SUN_global_alpha -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#endif - -#ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#endif - -#ifndef GL_SUN_vertex -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif - -#ifndef GL_INGR_color_clamp -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INTERLACE_READ_INGR 0x8568 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif - -#ifndef GL_EXT_texture_cube_map -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif - -#ifndef GL_EXT_texture_env_add -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT GL_MODELVIEW -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#endif - -#ifndef GL_NV_register_combiners -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -/* reuse GL_TEXTURE0_ARB */ -/* reuse GL_TEXTURE1_ARB */ -/* reuse GL_ZERO */ -/* reuse GL_NONE */ -/* reuse GL_FOG */ -#endif - -#ifndef GL_NV_fog_distance -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -/* reuse GL_EYE_PLANE */ -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif - -#ifndef GL_NV_blend_square -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif - -#ifndef GL_MESA_resize_buffers -#endif - -#ifndef GL_MESA_window_pos -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_CULL_VERTEX_IBM 103050 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#endif - -#ifndef GL_SGIX_subsample -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif - -#ifndef GL_SGI_depth_pass_instrument -#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif - -#ifndef GL_3DFX_tbuffer -#endif - -#ifndef GL_EXT_multisample -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif - -#ifndef GL_SGIX_resample -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif - -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -#ifndef GL_NV_evaluators -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -#endif - -#ifndef GL_NV_texture_compression_vtc -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif - -#ifndef GL_NV_texture_shader -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif - -#ifndef GL_NV_vertex_program -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif - -#ifndef GL_OML_interlace -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif - -#ifndef GL_OML_subsample -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif - -#ifndef GL_OML_resample -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -#endif - -#ifndef GL_ATI_element_array -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#endif - -#ifndef GL_SUN_mesh_array -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -#ifndef GL_NV_occlusion_query -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif - -#ifndef GL_NV_point_sprite -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif - -#ifndef GL_NV_vertex_program1_1 -#endif - -#ifndef GL_EXT_shadow_funcs -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif - -#ifndef GL_APPLE_element_array -#define GL_ELEMENT_ARRAY_APPLE 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A -#endif - -#ifndef GL_APPLE_fence -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -#ifndef GL_S3_s3tc -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif - -#ifndef GL_ATI_texture_float -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif - -#ifndef GL_NV_float_buffer -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif - -#ifndef GL_NV_fragment_program -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -#endif - -#ifndef GL_NV_half_float -#define GL_HALF_FLOAT_NV 0x140B -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#endif - -#ifndef GL_NV_primitive_restart -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif - -#ifndef GL_NV_vertex_program2 -#endif - -#ifndef GL_ATI_map_object_buffer -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#endif - -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#endif - -#ifndef GL_MESA_pack_invert -#define GL_PACK_INVERT_MESA 0x8758 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif - -#ifndef GL_NV_fragment_program_option -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif - -#ifndef GL_NV_vertex_program2_option -/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ -/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ -#endif - -#ifndef GL_NV_vertex_program3 -/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#endif - -#ifndef GL_GREMEDY_string_marker -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#endif - -#ifndef GL_EXT_stencil_clear_tag -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 -#endif - -#ifndef GL_EXT_texture_sRGB -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E -#endif - -#ifndef GL_EXT_timer_query -#define GL_TIME_ELAPSED_EXT 0x88BF -#endif - -#ifndef GL_EXT_gpu_program_parameters -#endif - -#ifndef GL_APPLE_flush_buffer_range -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -#endif - -#ifndef GL_NV_gpu_program4 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 -#endif - -#ifndef GL_NV_geometry_program4 -#define GL_LINES_ADJACENCY_EXT 0x000A -#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B -#define GL_TRIANGLES_ADJACENCY_EXT 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -#endif - -#ifndef GL_EXT_geometry_shader4 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ -/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ -/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ -/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 -/* reuse GL_LINES_ADJACENCY_EXT */ -/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ -/* reuse GL_TRIANGLES_ADJACENCY_EXT */ -/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -/* reuse GL_PROGRAM_POINT_SIZE_EXT */ -#endif - -#ifndef GL_NV_vertex_program4 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD -#endif - -#ifndef GL_EXT_gpu_shader4 -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 -#endif - -#ifndef GL_EXT_draw_instanced -#endif - -#ifndef GL_EXT_packed_float -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C -#endif - -#ifndef GL_EXT_texture_array -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -#endif - -#ifndef GL_EXT_texture_buffer_object -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E -#endif - -#ifndef GL_EXT_texture_compression_latc -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 -#endif - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE -#endif - -#ifndef GL_EXT_texture_shared_exponent -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F -#endif - -#ifndef GL_NV_depth_buffer_float -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF -#endif - -#ifndef GL_NV_fragment_program4 -#endif - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#endif - -#ifndef GL_NV_geometry_shader4 -#endif - -#ifndef GL_NV_parameter_buffer_object -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 -#endif - -#ifndef GL_EXT_draw_buffers2 -#endif - -#ifndef GL_NV_transform_feedback -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F -#endif - -#ifndef GL_EXT_bindable_uniform -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF -#endif - -#ifndef GL_EXT_texture_integer -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E -#endif - -#ifndef GL_GREMEDY_frame_terminator -#endif - -#ifndef GL_NV_conditional_render -#define GL_QUERY_WAIT_NV 0x8E13 -#define GL_QUERY_NO_WAIT_NV 0x8E14 -#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 -#endif - -#ifndef GL_NV_present_video -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B -#endif - -#ifndef GL_EXT_transform_feedback -#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F -#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -#endif - -#ifndef GL_EXT_direct_state_access -#define GL_PROGRAM_MATRIX_EXT 0x8E2D -#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F -#endif - -#ifndef GL_EXT_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_EXT_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 -#endif - -#ifndef GL_NV_explicit_multisample -#define GL_SAMPLE_POSITION_NV 0x8E50 -#define GL_SAMPLE_MASK_NV 0x8E51 -#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 -#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#endif - -#ifndef GL_NV_transform_feedback2 -#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 -#endif - - -/*************************************************************/ - -#include -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; /* native character */ -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for handling shader object handles and program/shader text */ -typedef char GLcharARB; /* native character */ -typedef unsigned int GLhandleARB; /* shader object handle */ -#endif - -/* GL types for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glxext.h, so must be protected */ -#define GLEXT_64_TYPES_DEFINED -/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ -/* (as used in the GL_EXT_timer_query extension). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -#elif defined(__sun__) || defined(__digital__) -#include -#if defined(__STDC__) -#if defined(__arch64__) || defined(_LP64) -typedef long int int64_t; -typedef unsigned long int uint64_t; -#else -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#endif /* __arch64__ */ -#endif /* __STDC__ */ -#elif defined( __VMS ) || defined(__sgi) -#include -#elif defined(__SCO__) || defined(__USLC__) -#include -#elif defined(__UNIXOS2__) || defined(__SOL64__) -typedef long int int32_t; -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#elif defined(_WIN32) && defined(__GNUC__) -#include -#elif defined(_WIN32) -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -#include /* Fallback option */ -#endif -#endif - -#ifndef GL_EXT_timer_query -typedef int64_t GLint64EXT; -typedef uint64_t GLuint64EXT; -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); -GLAPI void APIENTRY glBlendEquation (GLenum); -GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogram (GLenum); -GLAPI void APIENTRY glResetMinmax (GLenum); -GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum); -GLAPI void APIENTRY glClientActiveTexture (GLenum); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glFogCoordf (GLfloat); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *); -GLAPI void APIENTRY glFogCoordd (GLdouble); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); -GLAPI void APIENTRY glPointParameteri (GLenum, GLint); -GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); -GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos2i (GLint, GLint); -GLAPI void APIENTRY glWindowPos2iv (const GLint *); -GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *); -GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3iv (const GLint *); -GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQuery (GLuint); -GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); -GLAPI void APIENTRY glEndQuery (GLenum); -GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); -GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint); -GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); -GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); -GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); -GLAPI void APIENTRY glAttachShader (GLuint, GLuint); -GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); -GLAPI void APIENTRY glCompileShader (GLuint); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum); -GLAPI void APIENTRY glDeleteProgram (GLuint); -GLAPI void APIENTRY glDeleteShader (GLuint); -GLAPI void APIENTRY glDetachShader (GLuint, GLuint); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); -GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgram (GLuint); -GLAPI GLboolean APIENTRY glIsShader (GLuint); -GLAPI void APIENTRY glLinkProgram (GLuint); -GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); -GLAPI void APIENTRY glUseProgram (GLuint); -GLAPI void APIENTRY glUniform1f (GLint, GLfloat); -GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1i (GLint, GLint); -GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glValidateProgram (GLuint); -GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformMatrix2x3fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3x2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix2x4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4x2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3x4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4x3fv (GLint, GLsizei, GLboolean, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 -/* OpenGL 3.0 also reuses entry points from these extensions: */ -/* ARB_framebuffer_object */ -/* ARB_map_buffer_range */ -/* ARB_vertex_array_object */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaski (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); -GLAPI void APIENTRY glGetBooleani_v (GLenum, GLuint, GLboolean *); -GLAPI void APIENTRY glGetIntegeri_v (GLenum, GLuint, GLint *); -GLAPI void APIENTRY glEnablei (GLenum, GLuint); -GLAPI void APIENTRY glDisablei (GLenum, GLuint); -GLAPI GLboolean APIENTRY glIsEnabledi (GLenum, GLuint); -GLAPI void APIENTRY glBeginTransformFeedback (GLenum); -GLAPI void APIENTRY glEndTransformFeedback (void); -GLAPI void APIENTRY glBindBufferRange (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); -GLAPI void APIENTRY glBindBufferBase (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint, GLsizei, const GLint *, GLenum); -GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint, GLuint, GLint *); -GLAPI void APIENTRY glClampColor (GLenum, GLenum); -GLAPI void APIENTRY glBeginConditionalRender (GLuint, GLenum); -GLAPI void APIENTRY glEndConditionalRender (void); -GLAPI void APIENTRY glVertexAttribI1i (GLuint, GLint); -GLAPI void APIENTRY glVertexAttribI2i (GLuint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI3i (GLuint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI4i (GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI1ui (GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI2ui (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI3ui (GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI4ui (GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI1iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI2iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI3iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI4iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI1uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI2uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI3uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI4uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI4bv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttribI4sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttribI4ubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttribI4usv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribIPointer (GLuint, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetVertexAttribIiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint, GLenum, GLuint *); -GLAPI void APIENTRY glGetUniformuiv (GLuint, GLint, GLuint *); -GLAPI void APIENTRY glBindFragDataLocation (GLuint, GLuint, const GLchar *); -GLAPI GLint APIENTRY glGetFragDataLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glUniform1ui (GLint, GLuint); -GLAPI void APIENTRY glUniform2ui (GLint, GLuint, GLuint); -GLAPI void APIENTRY glUniform3ui (GLint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glUniform4ui (GLint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glUniform1uiv (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glUniform2uiv (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glUniform3uiv (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glUniform4uiv (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glTexParameterIiv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glTexParameterIuiv (GLenum, GLenum, const GLuint *); -GLAPI void APIENTRY glGetTexParameterIiv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetTexParameterIuiv (GLenum, GLenum, GLuint *); -GLAPI void APIENTRY glClearBufferiv (GLenum, GLint, const GLint *); -GLAPI void APIENTRY glClearBufferuiv (GLenum, GLint, const GLuint *); -GLAPI void APIENTRY glClearBufferfv (GLenum, GLint, const GLfloat *); -GLAPI void APIENTRY glClearBufferfi (GLenum, GLint, GLfloat, GLint); -GLAPI const GLubyte * APIENTRY glGetStringi (GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLint *location); -typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -#endif - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#endif - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); -#endif - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#endif - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#endif - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); -GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); -GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); -GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); -GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); -GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexBlendARB (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#endif - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#endif - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#endif - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#endif - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); -GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); -GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); -GLAPI void APIENTRY glEndQueryARB (GLenum); -GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); -GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); -GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1iARB (GLint, GLint); -GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -#endif - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 -#endif - -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint); -GLAPI void APIENTRY glBindRenderbuffer (GLenum, GLuint); -GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenRenderbuffers (GLsizei, GLuint *); -GLAPI void APIENTRY glRenderbufferStorage (GLenum, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum, GLenum, GLint *); -GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint); -GLAPI void APIENTRY glBindFramebuffer (GLenum, GLuint); -GLAPI void APIENTRY glDeleteFramebuffers (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFramebuffers (GLsizei, GLuint *); -GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum); -GLAPI void APIENTRY glFramebufferTexture1D (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture2D (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture3D (GLenum, GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGenerateMipmap (GLenum); -GLAPI void APIENTRY glBlitFramebuffer (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); -GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glFramebufferTextureLayer (GLenum, GLenum, GLuint, GLint, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 -#endif - -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriARB (GLuint, GLenum, GLint); -GLAPI void APIENTRY glFramebufferTextureARB (GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum, GLenum, GLuint, GLint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 -#endif - -#ifndef GL_ARB_instanced_arrays -#define GL_ARB_instanced_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisor (GLuint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapBufferRange (GLenum, GLintptr, GLsizeiptr, GLbitfield); -GLAPI void APIENTRY glFlushMappedBufferRange (GLenum, GLintptr, GLsizeiptr); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferARB (GLenum, GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 -#endif - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArray (GLuint); -GLAPI void APIENTRY glDeleteVertexArrays (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenVertexArrays (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsVertexArray (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); -#endif - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#endif - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#endif - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#endif - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogramEXT (GLenum); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#endif - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 -#endif - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#endif - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#endif - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#endif - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#endif - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint); -GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); -GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); -GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#endif - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#endif - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#endif - -#ifndef GL_SGIX_texture_select -#define GL_SGIX_texture_select 1 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#endif - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#endif - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -GLAPI void APIENTRY glDeformSGIX (GLbitfield); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#endif - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#endif - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#endif - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); -GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); -GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#endif - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#endif - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#endif - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum); -GLAPI void APIENTRY glTextureLightEXT (GLenum); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#endif - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#endif - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); -GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -#endif - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#endif - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); -GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); -GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); -GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *); -GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); -GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); -GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); -GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_SGIX_fog_scale 1 -#endif - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); -#endif - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -#endif - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#endif - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); -#endif - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); -#endif - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#endif - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#endif - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); -#endif - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -#endif - -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 -#endif - -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#endif - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#endif - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#endif - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif - -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#endif - -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); -GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFinishFenceNV (GLuint); -GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); -GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#endif - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#endif - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); -GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 -#endif - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#endif - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#endif - -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); -GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); -GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); -GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); -GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); -GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); -GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); -GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); -GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); -GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); -GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#endif - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#endif - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 -#endif - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#endif - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#endif - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -/* This is really a WGL extension, but defines some associated GL enums. - * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. - */ -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#endif - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#endif - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 -#endif - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#endif - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#endif - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#endif - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 -#endif - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#endif - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -#endif - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 -#endif - -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilClearTagEXT (GLsizei, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); -#endif - -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlitFramebufferEXT (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 -#endif - -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint, GLenum, GLint64EXT *); -GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint, GLenum, GLuint64EXT *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); -#endif - -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif - -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum, GLintptr, GLsizeiptr); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); -#endif - -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum, GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum, GLuint, const GLint *); -GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum, GLuint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum, GLuint, const GLuint *); -GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum, GLuint, GLsizei, const GLuint *); -GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum, GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum, GLuint, const GLint *); -GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum, GLuint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum, GLuint, const GLuint *); -GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum, GLuint, GLsizei, const GLuint *); -GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum, GLuint, GLint *); -GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum, GLuint, GLuint *); -GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum, GLuint, GLint *); -GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum, GLuint, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -#endif - -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramVertexLimitNV (GLenum, GLint); -GLAPI void APIENTRY glFramebufferTextureEXT (GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum, GLenum, GLuint, GLint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif - -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriEXT (GLuint, GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); -#endif - -#ifndef GL_NV_vertex_program4 -#define GL_NV_vertex_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint, GLint); -GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); -#endif - -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformuivEXT (GLuint, GLint, GLuint *); -GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint, GLuint, const GLchar *); -GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint, const GLchar *); -GLAPI void APIENTRY glUniform1uiEXT (GLint, GLuint); -GLAPI void APIENTRY glUniform2uiEXT (GLint, GLuint, GLuint); -GLAPI void APIENTRY glUniform3uiEXT (GLint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glUniform4uiEXT (GLint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glUniform1uivEXT (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glUniform2uivEXT (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glUniform3uivEXT (GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glUniform4uivEXT (GLint, GLsizei, const GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -#endif - -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 -#endif - -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 -#endif - -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferEXT (GLenum, GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#endif - -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 -#endif - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 -#endif - -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 -#endif - -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthRangedNV (GLdouble, GLdouble); -GLAPI void APIENTRY glClearDepthdNV (GLdouble); -GLAPI void APIENTRY glDepthBoundsdNV (GLdouble, GLdouble); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -#endif - -#ifndef GL_NV_fragment_program4 -#define GL_NV_fragment_program4 1 -#endif - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum, GLsizei, GLsizei, GLenum, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 -#endif - -#ifndef GL_NV_geometry_shader4 -#define GL_NV_geometry_shader4 1 -#endif - -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum, GLuint, GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum, GLuint, GLuint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum, GLuint, GLuint, GLsizei, const GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); -#endif - -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); -GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum, GLuint, GLboolean *); -GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum, GLuint, GLint *); -GLAPI void APIENTRY glEnableIndexedEXT (GLenum, GLuint); -GLAPI void APIENTRY glDisableIndexedEXT (GLenum, GLuint); -GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); -#endif - -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum); -GLAPI void APIENTRY glEndTransformFeedbackNV (void); -GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint, const GLint *, GLenum); -GLAPI void APIENTRY glBindBufferRangeNV (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); -GLAPI void APIENTRY glBindBufferOffsetNV (GLenum, GLuint, GLuint, GLintptr); -GLAPI void APIENTRY glBindBufferBaseNV (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint, GLsizei, const GLint *, GLenum); -GLAPI void APIENTRY glActiveVaryingNV (GLuint, const GLchar *); -GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint, const GLchar *); -GLAPI void APIENTRY glGetActiveVaryingNV (GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint, GLuint, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -#endif - -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformBufferEXT (GLuint, GLint, GLuint); -GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint, GLint); -GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); -typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); -#endif - -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexParameterIivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glTexParameterIuivEXT (GLenum, GLenum, const GLuint *); -GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum, GLenum, GLuint *); -GLAPI void APIENTRY glClearColorIiEXT (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glClearColorIuiEXT (GLuint, GLuint, GLuint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif - -#ifndef GL_GREMEDY_frame_terminator -#define GL_GREMEDY_frame_terminator 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); -#endif - -#ifndef GL_NV_conditional_render -#define GL_NV_conditional_render 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint, GLenum); -GLAPI void APIENTRY glEndConditionalRenderNV (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); -#endif - -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 -#endif - -#ifndef GL_EXT_transform_feedback -#define GL_EXT_transform_feedback 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum); -GLAPI void APIENTRY glEndTransformFeedbackEXT (void); -GLAPI void APIENTRY glBindBufferRangeEXT (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); -GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum, GLuint, GLuint, GLintptr); -GLAPI void APIENTRY glBindBufferBaseEXT (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint, GLsizei, const GLint *, GLenum); -GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint, GLuint, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLint *location); -#endif - -#ifndef GL_EXT_direct_state_access -#define GL_EXT_direct_state_access 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield); -GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield); -GLAPI void APIENTRY glMatrixLoadfEXT (GLenum, const GLfloat *); -GLAPI void APIENTRY glMatrixLoaddEXT (GLenum, const GLdouble *); -GLAPI void APIENTRY glMatrixMultfEXT (GLenum, const GLfloat *); -GLAPI void APIENTRY glMatrixMultdEXT (GLenum, const GLdouble *); -GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum); -GLAPI void APIENTRY glMatrixRotatefEXT (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMatrixRotatedEXT (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMatrixScalefEXT (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMatrixScaledEXT (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMatrixFrustumEXT (GLenum, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMatrixOrthoEXT (GLenum, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMatrixPopEXT (GLenum); -GLAPI void APIENTRY glMatrixPushEXT (GLenum); -GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum, const GLfloat *); -GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum, const GLdouble *); -GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum, const GLfloat *); -GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum, const GLdouble *); -GLAPI void APIENTRY glTextureParameterfEXT (GLuint, GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glTextureParameterfvEXT (GLuint, GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glTextureParameteriEXT (GLuint, GLenum, GLenum, GLint); -GLAPI void APIENTRY glTextureParameterivEXT (GLuint, GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glTextureImage1DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTextureImage2DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint, GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetTextureImageEXT (GLuint, GLenum, GLint, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint, GLenum, GLint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint, GLenum, GLint, GLenum, GLint *); -GLAPI void APIENTRY glTextureImage3DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum, GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum, GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum, GLenum, GLenum, GLint); -GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum, GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum, GLenum, GLint, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum, GLenum, GLint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum, GLenum, GLint, GLenum, GLint *); -GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glBindMultiTextureEXT (GLenum, GLenum, GLuint); -GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum, GLuint); -GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum, GLuint); -GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum, GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum, GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexEnviEXT (GLenum, GLenum, GLenum, GLint); -GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum, GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexGendEXT (GLenum, GLenum, GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexGendvEXT (GLenum, GLenum, GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexGenfEXT (GLenum, GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum, GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexGeniEXT (GLenum, GLenum, GLenum, GLint); -GLAPI void APIENTRY glMultiTexGenivEXT (GLenum, GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum, GLenum, GLenum, GLdouble *); -GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum, GLuint, GLvoid* *); -GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint, GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint, GLenum, GLint, GLvoid *); -GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum, GLenum, GLint, GLvoid *); -GLAPI void APIENTRY glNamedProgramStringEXT (GLuint, GLenum, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint, GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint, GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint, GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint, GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint, GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint, GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint, GLenum, GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint, GLenum, GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint, GLenum, GLuint, const GLint *); -GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint, GLenum, GLuint, GLsizei, const GLint *); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint, GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint, GLenum, GLuint, const GLuint *); -GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint, GLenum, GLuint, GLsizei, const GLuint *); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint, GLenum, GLuint, GLint *); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint, GLenum, GLuint, GLuint *); -GLAPI void APIENTRY glTextureParameterIivEXT (GLuint, GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint, GLenum, GLenum, const GLuint *); -GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint, GLenum, GLenum, GLuint *); -GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum, GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum, GLenum, GLenum, const GLuint *); -GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum, GLenum, GLenum, GLuint *); -GLAPI void APIENTRY glProgramUniform1fEXT (GLuint, GLint, GLfloat); -GLAPI void APIENTRY glProgramUniform2fEXT (GLuint, GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramUniform3fEXT (GLuint, GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramUniform4fEXT (GLuint, GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramUniform1iEXT (GLuint, GLint, GLint); -GLAPI void APIENTRY glProgramUniform2iEXT (GLuint, GLint, GLint, GLint); -GLAPI void APIENTRY glProgramUniform3iEXT (GLuint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glProgramUniform4iEXT (GLuint, GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint, GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint, GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint, GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint, GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint, GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint, GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint, GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint, GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint, GLint, GLuint); -GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint, GLint, GLuint, GLuint); -GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint, GLint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint, GLint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint, GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint, GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint, GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint, GLint, GLsizei, const GLuint *); -GLAPI void APIENTRY glNamedBufferDataEXT (GLuint, GLsizeiptr, const GLvoid *, GLenum); -GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint, GLintptr, GLsizeiptr, const GLvoid *); -GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint, GLenum); -GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint); -GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint, GLenum, GLvoid* *); -GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint, GLintptr, GLsizeiptr, GLvoid *); -GLAPI void APIENTRY glTextureBufferEXT (GLuint, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glMultiTexBufferEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint, GLenum, GLint *); -GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint, GLenum); -GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint, GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint, GLenum); -GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum, GLenum); -GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint, GLenum); -GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint, GLsizei, const GLenum *); -GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint, GLenum); -GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint, GLsizei, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint, GLsizei, GLsizei, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint, GLenum, GLuint, GLint); -GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint, GLenum, GLuint, GLint, GLenum); -GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint, GLenum, GLuint); -GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum, GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); -typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); -typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); -typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); -#endif - -#ifndef GL_EXT_vertex_array_bgra -#define GL_EXT_vertex_array_bgra 1 -#endif - -#ifndef GL_EXT_texture_swizzle -#define GL_EXT_texture_swizzle 1 -#endif - -#ifndef GL_NV_explicit_multisample -#define GL_NV_explicit_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetMultisamplefvNV (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint, GLbitfield); -GLAPI void APIENTRY glTexRenderbufferNV (GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); -typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); -#endif - -#ifndef GL_NV_transform_feedback2 -#define GL_NV_transform_feedback2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum, GLuint); -GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint); -GLAPI void APIENTRY glPauseTransformFeedbackNV (void); -GLAPI void APIENTRY glResumeTransformFeedbackNV (void); -GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); -#endif - - -#ifdef __cplusplus -} -#endif - -#endif - +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated 2008/11/14 */ +/* Current version at http://www.opengl.org/registry/ */ +#define GL_GLEXT_VERSION 44 + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE +#define GL_FOG_COORD GL_FOG_COORDINATE +#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE +#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE +#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER +#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING +#define GL_SRC0_RGB GL_SOURCE0_RGB +#define GL_SRC1_RGB GL_SOURCE1_RGB +#define GL_SRC2_RGB GL_SOURCE2_RGB +#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA +#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif + +#ifndef GL_VERSION_2_1 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +#endif + +#ifndef GL_VERSION_3_0 +#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB +#define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0 +#define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1 +#define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2 +#define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3 +#define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4 +#define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5 +#define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_DEPTH_BUFFER 0x8223 +#define GL_STENCIL_BUFFER 0x8224 +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_ALPHA_INTEGER 0x8D97 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +/* Reuse tokens from ARB_depth_buffer_float */ +/* reuse GL_DEPTH_COMPONENT32F */ +/* reuse GL_DEPTH32F_STENCIL8 */ +/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_DEFAULT */ +/* reuse GL_FRAMEBUFFER_UNDEFINED */ +/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ +/* reuse GL_INDEX */ +/* reuse GL_MAX_RENDERBUFFER_SIZE */ +/* reuse GL_DEPTH_STENCIL */ +/* reuse GL_UNSIGNED_INT_24_8 */ +/* reuse GL_DEPTH24_STENCIL8 */ +/* reuse GL_TEXTURE_STENCIL_SIZE */ +/* reuse GL_TEXTURE_RED_TYPE */ +/* reuse GL_TEXTURE_GREEN_TYPE */ +/* reuse GL_TEXTURE_BLUE_TYPE */ +/* reuse GL_TEXTURE_ALPHA_TYPE */ +/* reuse GL_TEXTURE_LUMINANCE_TYPE */ +/* reuse GL_TEXTURE_INTENSITY_TYPE */ +/* reuse GL_TEXTURE_DEPTH_TYPE */ +/* reuse GL_UNSIGNED_NORMALIZED */ +/* reuse GL_FRAMEBUFFER_BINDING */ +/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_BINDING */ +/* reuse GL_READ_FRAMEBUFFER */ +/* reuse GL_DRAW_FRAMEBUFFER */ +/* reuse GL_READ_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_SAMPLES */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* reuse GL_FRAMEBUFFER_COMPLETE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ +/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ +/* reuse GL_MAX_COLOR_ATTACHMENTS */ +/* reuse GL_COLOR_ATTACHMENT0 */ +/* reuse GL_COLOR_ATTACHMENT1 */ +/* reuse GL_COLOR_ATTACHMENT2 */ +/* reuse GL_COLOR_ATTACHMENT3 */ +/* reuse GL_COLOR_ATTACHMENT4 */ +/* reuse GL_COLOR_ATTACHMENT5 */ +/* reuse GL_COLOR_ATTACHMENT6 */ +/* reuse GL_COLOR_ATTACHMENT7 */ +/* reuse GL_COLOR_ATTACHMENT8 */ +/* reuse GL_COLOR_ATTACHMENT9 */ +/* reuse GL_COLOR_ATTACHMENT10 */ +/* reuse GL_COLOR_ATTACHMENT11 */ +/* reuse GL_COLOR_ATTACHMENT12 */ +/* reuse GL_COLOR_ATTACHMENT13 */ +/* reuse GL_COLOR_ATTACHMENT14 */ +/* reuse GL_COLOR_ATTACHMENT15 */ +/* reuse GL_DEPTH_ATTACHMENT */ +/* reuse GL_STENCIL_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER */ +/* reuse GL_RENDERBUFFER */ +/* reuse GL_RENDERBUFFER_WIDTH */ +/* reuse GL_RENDERBUFFER_HEIGHT */ +/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ +/* reuse GL_STENCIL_INDEX1 */ +/* reuse GL_STENCIL_INDEX4 */ +/* reuse GL_STENCIL_INDEX8 */ +/* reuse GL_STENCIL_INDEX16 */ +/* reuse GL_RENDERBUFFER_RED_SIZE */ +/* reuse GL_RENDERBUFFER_GREEN_SIZE */ +/* reuse GL_RENDERBUFFER_BLUE_SIZE */ +/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ +/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ +/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ +/* reuse GL_MAX_SAMPLES */ +/* Reuse tokens from ARB_framebuffer_sRGB */ +/* reuse GL_FRAMEBUFFER_SRGB */ +/* Reuse tokens from ARB_half_float_vertex */ +/* reuse GL_HALF_FLOAT */ +/* Reuse tokens from ARB_map_buffer_range */ +/* reuse GL_MAP_READ_BIT */ +/* reuse GL_MAP_WRITE_BIT */ +/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ +/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ +/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ +/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ +/* Reuse tokens from ARB_texture_compression_rgtc */ +/* reuse GL_COMPRESSED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_RG_RGTC2 */ +/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ +/* Reuse tokens from ARB_texture_rg */ +/* reuse GL_RG */ +/* reuse GL_RG_INTEGER */ +/* reuse GL_R8 */ +/* reuse GL_R16 */ +/* reuse GL_RG8 */ +/* reuse GL_RG16 */ +/* reuse GL_R16F */ +/* reuse GL_R32F */ +/* reuse GL_RG16F */ +/* reuse GL_RG32F */ +/* reuse GL_R8I */ +/* reuse GL_R8UI */ +/* reuse GL_R16I */ +/* reuse GL_R16UI */ +/* reuse GL_R32I */ +/* reuse GL_R32UI */ +/* reuse GL_RG8I */ +/* reuse GL_RG8UI */ +/* reuse GL_RG16I */ +/* reuse GL_RG16UI */ +/* reuse GL_RG32I */ +/* reuse GL_RG32UI */ +/* Reuse tokens from ARB_vertex_array_object */ +/* reuse GL_VERTEX_ARRAY_BINDING */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#endif + +#ifndef GL_ARB_draw_instanced +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_INDEX 0x8222 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_HALF_FLOAT 0x140B +#endif + +#ifndef GL_ARB_instanced_arrays +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#endif + +#ifndef GL_ARB_texture_rg +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif + +#ifndef GL_EXT_timer_query +#define GL_TIME_ELAPSED_EXT 0x88BF +#endif + +#ifndef GL_EXT_gpu_program_parameters +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ +/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ +/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ +/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +/* reuse GL_LINES_ADJACENCY_EXT */ +/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ +/* reuse GL_TRIANGLES_ADJACENCY_EXT */ +/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +/* reuse GL_PROGRAM_POINT_SIZE_EXT */ +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#endif + +#ifndef GL_EXT_draw_instanced +#endif + +#ifndef GL_EXT_packed_float +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif + +#ifndef GL_EXT_texture_array +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +#endif + +#ifndef GL_NV_fragment_program4 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif + +#ifndef GL_NV_geometry_shader4 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +#endif + +#ifndef GL_EXT_draw_buffers2 +#endif + +#ifndef GL_NV_transform_feedback +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +#endif + +#ifndef GL_EXT_texture_integer +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +#endif + +#ifndef GL_GREMEDY_frame_terminator +#endif + +#ifndef GL_NV_conditional_render +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +#endif + +#ifndef GL_NV_present_video +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +#endif + +#ifndef GL_EXT_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; /* native character */ +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for handling shader object handles and program/shader text */ +typedef char GLcharARB; /* native character */ +typedef unsigned int GLhandleARB; /* shader object handle */ +#endif + +/* GL types for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +#include /* Fallback option */ +#endif +#endif + +#ifndef GL_EXT_timer_query +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); +GLAPI void APIENTRY glBlendEquation (GLenum); +GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogram (GLenum); +GLAPI void APIENTRY glResetMinmax (GLenum); +GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum); +GLAPI void APIENTRY glClientActiveTexture (GLenum); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glFogCoordf (GLfloat); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *); +GLAPI void APIENTRY glFogCoordd (GLdouble); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); +GLAPI void APIENTRY glPointParameteri (GLenum, GLint); +GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); +GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos2i (GLint, GLint); +GLAPI void APIENTRY glWindowPos2iv (const GLint *); +GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *); +GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3iv (const GLint *); +GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQuery (GLuint); +GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); +GLAPI void APIENTRY glEndQuery (GLenum); +GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); +GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint); +GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); +GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); +GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); +GLAPI void APIENTRY glAttachShader (GLuint, GLuint); +GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); +GLAPI void APIENTRY glCompileShader (GLuint); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum); +GLAPI void APIENTRY glDeleteProgram (GLuint); +GLAPI void APIENTRY glDeleteShader (GLuint); +GLAPI void APIENTRY glDetachShader (GLuint, GLuint); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); +GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgram (GLuint); +GLAPI GLboolean APIENTRY glIsShader (GLuint); +GLAPI void APIENTRY glLinkProgram (GLuint); +GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); +GLAPI void APIENTRY glUseProgram (GLuint); +GLAPI void APIENTRY glUniform1f (GLint, GLfloat); +GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1i (GLint, GLint); +GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glValidateProgram (GLuint); +GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint, GLsizei, GLboolean, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +/* OpenGL 3.0 also reuses entry points from these extensions: */ +/* ARB_framebuffer_object */ +/* ARB_map_buffer_range */ +/* ARB_vertex_array_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glGetBooleani_v (GLenum, GLuint, GLboolean *); +GLAPI void APIENTRY glGetIntegeri_v (GLenum, GLuint, GLint *); +GLAPI void APIENTRY glEnablei (GLenum, GLuint); +GLAPI void APIENTRY glDisablei (GLenum, GLuint); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum, GLuint); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); +GLAPI void APIENTRY glBindBufferBase (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint, GLsizei, const GLint *, GLenum); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint, GLuint, GLint *); +GLAPI void APIENTRY glClampColor (GLenum, GLenum); +GLAPI void APIENTRY glBeginConditionalRender (GLuint, GLenum); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribI1i (GLuint, GLint); +GLAPI void APIENTRY glVertexAttribI2i (GLuint, GLint, GLint); +GLAPI void APIENTRY glVertexAttribI3i (GLuint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexAttribI4i (GLuint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint, GLenum, GLuint *); +GLAPI void APIENTRY glGetUniformuiv (GLuint, GLint, GLuint *); +GLAPI void APIENTRY glBindFragDataLocation (GLuint, GLuint, const GLchar *); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glUniform1ui (GLint, GLuint); +GLAPI void APIENTRY glUniform2ui (GLint, GLuint, GLuint); +GLAPI void APIENTRY glUniform3ui (GLint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glUniform4ui (GLint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glUniform1uiv (GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glUniform2uiv (GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glUniform3uiv (GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glUniform4uiv (GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glTexParameterIiv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glTexParameterIuiv (GLenum, GLenum, const GLuint *); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum, GLenum, GLuint *); +GLAPI void APIENTRY glClearBufferiv (GLenum, GLint, const GLint *); +GLAPI void APIENTRY glClearBufferuiv (GLenum, GLint, const GLuint *); +GLAPI void APIENTRY glClearBufferfv (GLenum, GLint, const GLfloat *); +GLAPI void APIENTRY glClearBufferfi (GLenum, GLint, GLfloat, GLint); +GLAPI const GLubyte * APIENTRY glGetStringi (GLenum, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); +GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); +GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); +GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); +GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); +GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexBlendARB (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); +GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); +GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); +GLAPI void APIENTRY glEndQueryARB (GLenum); +GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); +GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); +GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1iARB (GLint, GLint); +GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint); +GLAPI void APIENTRY glBindRenderbuffer (GLenum, GLuint); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei, GLuint *); +GLAPI void APIENTRY glRenderbufferStorage (GLenum, GLenum, GLsizei, GLsizei); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum, GLenum, GLint *); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint); +GLAPI void APIENTRY glBindFramebuffer (GLenum, GLuint); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFramebuffers (GLsizei, GLuint *); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum, GLenum, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGenerateMipmap (GLenum); +GLAPI void APIENTRY glBlitFramebuffer (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum, GLsizei, GLenum, GLsizei, GLsizei); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum, GLenum, GLuint, GLint, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint, GLenum, GLint); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum, GLenum, GLuint, GLint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisor (GLuint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapBufferRange (GLenum, GLintptr, GLsizeiptr, GLbitfield); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum, GLintptr, GLsizeiptr); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum, GLenum, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArray (GLuint); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenVertexArrays (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogramEXT (GLenum); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint); +GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); +GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); +GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +GLAPI void APIENTRY glDeformSGIX (GLbitfield); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); +GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); +GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum); +GLAPI void APIENTRY glTextureLightEXT (GLenum); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); +GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); +GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); +GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); +GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *); +GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); +GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); +GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); +GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); +GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFinishFenceNV (GLuint); +GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); +GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); +GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); +GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); +GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); +GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); +GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); +GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); +GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); +GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); +GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); +GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); +GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#endif + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint, GLenum, GLint64EXT *); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint, GLenum, GLuint64EXT *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum, GLintptr, GLsizeiptr); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum, GLuint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum, GLuint, const GLint *); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum, GLuint, GLsizei, const GLint *); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum, GLuint, const GLuint *); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum, GLuint, GLsizei, const GLuint *); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum, GLuint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum, GLuint, const GLint *); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum, GLuint, GLsizei, const GLint *); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum, GLuint, const GLuint *); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum, GLuint, GLsizei, const GLuint *); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum, GLuint, GLint *); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum, GLuint, GLuint *); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum, GLuint, GLint *); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum, GLuint, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum, GLint); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum, GLenum, GLuint, GLint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint, GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint, GLint); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint, GLint, GLint); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint, GLint, GLuint *); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint, GLuint, const GLchar *); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint, const GLchar *); +GLAPI void APIENTRY glUniform1uiEXT (GLint, GLuint); +GLAPI void APIENTRY glUniform2uiEXT (GLint, GLuint, GLuint); +GLAPI void APIENTRY glUniform3uiEXT (GLint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glUniform4uiEXT (GLint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glUniform1uivEXT (GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glUniform2uivEXT (GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glUniform3uivEXT (GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glUniform4uivEXT (GLint, GLsizei, const GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#endif + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#endif + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum, GLenum, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble, GLdouble); +GLAPI void APIENTRY glClearDepthdNV (GLdouble); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble, GLdouble); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#endif + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum, GLsizei, GLsizei, GLenum, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#endif + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum, GLuint, GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum, GLuint, GLuint, GLsizei, const GLint *); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum, GLuint, GLuint, GLsizei, const GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +#endif + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum, GLuint, GLboolean *); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum, GLuint, GLint *); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum, GLuint); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum, GLuint); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +#endif + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint, const GLint *, GLenum); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum, GLuint, GLuint, GLintptr); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint, GLsizei, const GLint *, GLenum); +GLAPI void APIENTRY glActiveVaryingNV (GLuint, const GLchar *); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint, const GLchar *); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint, GLuint, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint, GLint, GLuint); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint, GLint); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#endif + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum, GLenum, const GLuint *); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum, GLenum, GLuint *); +GLAPI void APIENTRY glClearColorIiEXT (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint, GLuint, GLuint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#endif + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint, GLenum); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#endif + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum, GLuint, GLuint, GLintptr); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint, GLsizei, const GLint *, GLenum); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint, GLuint, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLint *location); +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield); +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum, const GLfloat *); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum, const GLdouble *); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum, const GLfloat *); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum, const GLdouble *); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMatrixPopEXT (GLenum); +GLAPI void APIENTRY glMatrixPushEXT (GLenum); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum, const GLfloat *); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum, const GLdouble *); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum, const GLfloat *); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum, const GLdouble *); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint, GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint, GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint, GLenum, GLenum, GLint); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint, GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint, GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint, GLenum, GLint, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint, GLenum, GLint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint, GLenum, GLint, GLenum, GLint *); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum, GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum, GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum, GLenum, GLenum, GLint); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum, GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum, GLenum, GLint, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum, GLenum, GLint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum, GLenum, GLint, GLenum, GLint *); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum, GLenum, GLuint); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum, GLuint); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum, GLuint); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum, GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum, GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum, GLenum, GLenum, GLint); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum, GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum, GLenum, GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum, GLenum, GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum, GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum, GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum, GLenum, GLenum, GLint); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum, GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum, GLenum, GLenum, GLdouble *); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum, GLuint, GLvoid* *); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint, GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint, GLenum, GLint, GLvoid *); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum, GLenum, GLint, GLvoid *); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint, GLenum, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint, GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint, GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint, GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint, GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint, GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint, GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint, GLenum, GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint, GLenum, GLuint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint, GLenum, GLuint, const GLint *); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint, GLenum, GLuint, GLsizei, const GLint *); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint, GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint, GLenum, GLuint, const GLuint *); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint, GLenum, GLuint, GLsizei, const GLuint *); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint, GLenum, GLuint, GLint *); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint, GLenum, GLuint, GLuint *); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint, GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint, GLenum, GLenum, const GLuint *); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint, GLenum, GLenum, GLuint *); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum, GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum, GLenum, GLenum, const GLuint *); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum, GLenum, GLenum, GLuint *); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint, GLint, GLfloat); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint, GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint, GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint, GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint, GLint, GLint); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint, GLint, GLint, GLint); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint, GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint, GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint, GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint, GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint, GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint, GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint, GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint, GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint, GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint, GLint, GLuint); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint, GLint, GLuint, GLuint); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint, GLint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint, GLint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint, GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint, GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint, GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint, GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint, GLsizeiptr, const GLvoid *, GLenum); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint, GLintptr, GLsizeiptr, const GLvoid *); +GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint, GLenum); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint, GLenum, GLvoid* *); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint, GLintptr, GLsizeiptr, GLvoid *); +GLAPI void APIENTRY glTextureBufferEXT (GLuint, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint, GLenum, GLsizei, GLsizei); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint, GLenum, GLint *); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint, GLenum); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint, GLenum, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint, GLenum); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum, GLenum); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint, GLenum); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint, GLsizei, const GLenum *); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint, GLenum); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint, GLsizei, GLenum, GLsizei, GLsizei); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint, GLsizei, GLsizei, GLenum, GLsizei, GLsizei); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint, GLenum, GLuint, GLint); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint, GLenum, GLuint, GLint, GLenum); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint, GLenum, GLuint); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum, GLenum, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +#endif + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint, GLbitfield); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum, GLuint); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/desmume/src/windows/IORegView.cpp b/src/windows/IORegView.cpp similarity index 88% rename from desmume/src/windows/IORegView.cpp rename to src/windows/IORegView.cpp index 526440912..58246124b 100644 --- a/desmume/src/windows/IORegView.cpp +++ b/src/windows/IORegView.cpp @@ -1,172 +1,172 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "ioregview.h" -#include -#include "debug.h" -#include "resource.h" -#include "../MMU.h" -#include "../armcpu.h" - -typedef struct -{ - u32 autoup_secs; - bool autoup; -} ioregview_struct; - -ioregview_struct *IORegView; - -LRESULT Ioreg_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - TCHAR text[80]; - - hdc = BeginPaint(hwnd, &ps); - - // ARM9 registers - sprintf(text, "0x%08X", (int)((u32 *)MMU.ARM9_DTCM)[0x3FFC>>2]); - SetWindowText(GetDlgItem(hwnd, IDC_INTHAND9), text); - - sprintf(text, "0x%08X", (int)MMU.reg_IE[ARMCPU_ARM9]); - SetWindowText(GetDlgItem(hwnd, IDC_IE9), text); - - sprintf(text, "0x%08X", (int)MMU.reg_IF[ARMCPU_ARM9]); - SetWindowText(GetDlgItem(hwnd, IDC_IF9), text); - - sprintf(text, "%s", ((int)(MMU.reg_IME[ARMCPU_ARM9]) & 0x01)?"enabled":"disabled"); - SetWindowText(GetDlgItem(hwnd, IDC_IME9), text); - - sprintf(text, "0x%08X", ((u16 *)MMU.ARM9_REG)[0x0000>>1]); - SetWindowText(GetDlgItem(hwnd, IDC_DISPCNTA9), text); - - sprintf(text, "0x%08X", ((u16 *)MMU.ARM9_REG)[0x0004>>1]); - SetWindowText(GetDlgItem(hwnd, IDC_DISPSTATA9), text); - - sprintf(text, "0x%08X", ((u16 *)MMU.ARM9_REG)[0x1000>>1]); - SetWindowText(GetDlgItem(hwnd, IDC_DISPCNTB9), text); - - sprintf(text, "0x%08X", ((u16 *)MMU.ARM9_REG)[0x1004>>1]); - SetWindowText(GetDlgItem(hwnd, IDC_DISPSTATB9), text); - - sprintf(text, "0x%08X", (int)((u32 *)MMU.ARM9_REG)[0x180>>2]); - SetWindowText(GetDlgItem(hwnd, IDC_IPCSYNC9), text); - - sprintf(text, "0x%08X", (int)((u32 *)MMU.ARM9_REG)[0x184>>2]); - SetWindowText(GetDlgItem(hwnd, IDC_IPCFIFO9), text); - - sprintf(text, "0x%08X", (int)((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x600>>2]); - SetWindowText(GetDlgItem(hwnd, IDC_GXSTAT9), text); - - // ARM7 registers - sprintf(text, "0x%08X", (int)MMU.reg_IE[ARMCPU_ARM7]); - SetWindowText(GetDlgItem(hwnd, IDC_IE7), text); - - sprintf(text, "0x%08X", (int)MMU.reg_IF[ARMCPU_ARM7]); - SetWindowText(GetDlgItem(hwnd, IDC_IF7), text); - - sprintf(text, "%s", ((int)(MMU.reg_IME[ARMCPU_ARM7]) & 0x01)?"enabled":"disabled"); - SetWindowText(GetDlgItem(hwnd, IDC_IME7), text); - - sprintf(text, "0x%08X", (int)((u32 *)MMU.ARM7_REG)[0x180>>2]); - SetWindowText(GetDlgItem(hwnd, IDC_IPCSYNC7), text); - - sprintf(text, "0x%08X", (int)((u32 *)MMU.ARM7_REG)[0x184>>2]); - SetWindowText(GetDlgItem(hwnd, IDC_IPCFIFO7), text); - EndPaint(hwnd, &ps); - - return 0; -} - -BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG : - IORegView = new ioregview_struct; - memset(IORegView, 0, sizeof(ioregview_struct)); - IORegView->autoup_secs = 1; - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETRANGE, 0, MAKELONG(99, 1)); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETPOS32, 0, IORegView->autoup_secs); - return 1; - case WM_CLOSE : - if(IORegView->autoup) - { - KillTimer(hwnd, IDT_VIEW_IOREG); - IORegView->autoup = false; - } - - if (IORegView!=NULL) - { - delete IORegView; - IORegView = NULL; - } - PostQuitMessage(0); - return 1; - case WM_PAINT: - Ioreg_OnPaint(hwnd, wParam, lParam); - return 1; - case WM_TIMER: - SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); - return 1; - case WM_COMMAND : - if(IORegView == NULL) return 0; - switch (LOWORD (wParam)) - { - case IDC_FERMER : - SendMessage(hwnd, WM_CLOSE, 0, 0); - return 1; - case IDC_AUTO_UPDATE : - if(IORegView->autoup) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); - KillTimer(hwnd, IDT_VIEW_IOREG); - IORegView->autoup = FALSE; - return 1; - } - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); - IORegView->autoup = TRUE; - SetTimer(hwnd, IDT_VIEW_IOREG, IORegView->autoup_secs*20, (TIMERPROC) NULL); - return 1; - case IDC_AUTO_UPDATE_SECS: - { - int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); - if (t != IORegView->autoup_secs) - { - IORegView->autoup_secs = t; - if (IORegView->autoup) - SetTimer(hwnd, IDT_VIEW_IOREG, - IORegView->autoup_secs*20, (TIMERPROC) NULL); - } - } - return 1; - case IDC_REFRESH: - InvalidateRect(hwnd, NULL, FALSE); - return 1; - } - return 0; - } - return FALSE; -} +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "ioregview.h" +#include +#include "debug.h" +#include "resource.h" +#include "../MMU.h" +#include "../armcpu.h" + +typedef struct +{ + u32 autoup_secs; + bool autoup; +} ioregview_struct; + +ioregview_struct *IORegView; + +LRESULT Ioreg_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + TCHAR text[80]; + + hdc = BeginPaint(hwnd, &ps); + + // ARM9 registers + sprintf(text, "0x%08X", (int)((u32 *)ARM9Mem.ARM9_DTCM)[0x3FFC>>2]); + SetWindowText(GetDlgItem(hwnd, IDC_INTHAND9), text); + + sprintf(text, "0x%08X", (int)MMU.reg_IE[ARMCPU_ARM9]); + SetWindowText(GetDlgItem(hwnd, IDC_IE9), text); + + sprintf(text, "0x%08X", (int)MMU.reg_IF[ARMCPU_ARM9]); + SetWindowText(GetDlgItem(hwnd, IDC_IF9), text); + + sprintf(text, "%s", ((int)(MMU.reg_IME[ARMCPU_ARM9]) & 0x01)?"enabled":"disabled"); + SetWindowText(GetDlgItem(hwnd, IDC_IME9), text); + + sprintf(text, "0x%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x0000>>1]); + SetWindowText(GetDlgItem(hwnd, IDC_DISPCNTA9), text); + + sprintf(text, "0x%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x0004>>1]); + SetWindowText(GetDlgItem(hwnd, IDC_DISPSTATA9), text); + + sprintf(text, "0x%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x1000>>1]); + SetWindowText(GetDlgItem(hwnd, IDC_DISPCNTB9), text); + + sprintf(text, "0x%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x1004>>1]); + SetWindowText(GetDlgItem(hwnd, IDC_DISPSTATB9), text); + + sprintf(text, "0x%08X", (int)((u32 *)ARM9Mem.ARM9_REG)[0x180>>2]); + SetWindowText(GetDlgItem(hwnd, IDC_IPCSYNC9), text); + + sprintf(text, "0x%08X", (int)((u32 *)ARM9Mem.ARM9_REG)[0x184>>2]); + SetWindowText(GetDlgItem(hwnd, IDC_IPCFIFO9), text); + + sprintf(text, "0x%08X", (int)((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x600>>2]); + SetWindowText(GetDlgItem(hwnd, IDC_GXSTAT9), text); + + // ARM7 registers + sprintf(text, "0x%08X", (int)MMU.reg_IE[ARMCPU_ARM7]); + SetWindowText(GetDlgItem(hwnd, IDC_IE7), text); + + sprintf(text, "0x%08X", (int)MMU.reg_IF[ARMCPU_ARM7]); + SetWindowText(GetDlgItem(hwnd, IDC_IF7), text); + + sprintf(text, "%s", ((int)(MMU.reg_IME[ARMCPU_ARM7]) & 0x01)?"enabled":"disabled"); + SetWindowText(GetDlgItem(hwnd, IDC_IME7), text); + + sprintf(text, "0x%08X", (int)((u32 *)MMU.ARM7_REG)[0x180>>2]); + SetWindowText(GetDlgItem(hwnd, IDC_IPCSYNC7), text); + + sprintf(text, "0x%08X", (int)((u32 *)MMU.ARM7_REG)[0x184>>2]); + SetWindowText(GetDlgItem(hwnd, IDC_IPCFIFO7), text); + EndPaint(hwnd, &ps); + + return 0; +} + +BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG : + IORegView = new ioregview_struct; + memset(IORegView, 0, sizeof(ioregview_struct)); + IORegView->autoup_secs = 1; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, IORegView->autoup_secs); + return 1; + case WM_CLOSE : + if(IORegView->autoup) + { + KillTimer(hwnd, IDT_VIEW_IOREG); + IORegView->autoup = false; + } + + if (IORegView!=NULL) + { + delete IORegView; + IORegView = NULL; + } + PostQuitMessage(0); + return 1; + case WM_PAINT: + Ioreg_OnPaint(hwnd, wParam, lParam); + return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; + case WM_COMMAND : + if(IORegView == NULL) return 0; + switch (LOWORD (wParam)) + { + case IDC_FERMER : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 1; + case IDC_AUTO_UPDATE : + if(IORegView->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_IOREG); + IORegView->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + IORegView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_IOREG, IORegView->autoup_secs*20, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (t != IORegView->autoup_secs) + { + IORegView->autoup_secs = t; + if (IORegView->autoup) + SetTimer(hwnd, IDT_VIEW_IOREG, + IORegView->autoup_secs*20, (TIMERPROC) NULL); + } + } + return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; + } + return 0; + } + return FALSE; +} diff --git a/desmume/src/windows/IORegView.h b/src/windows/IORegView.h similarity index 97% rename from desmume/src/windows/IORegView.h rename to src/windows/IORegView.h index f5431ea78..d76aa8751 100644 --- a/desmume/src/windows/IORegView.h +++ b/src/windows/IORegView.h @@ -1,28 +1,28 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef IO_REG_H -#define IO_REG_H -#include "../common.h" - -extern BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef IO_REG_H +#define IO_REG_H +#include "../common.h" + +extern BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + +#endif diff --git a/desmume/src/windows/Makefile.am b/src/windows/Makefile.am similarity index 100% rename from desmume/src/windows/Makefile.am rename to src/windows/Makefile.am diff --git a/desmume/src/windows/Makefile.win b/src/windows/Makefile.win similarity index 100% rename from desmume/src/windows/Makefile.win rename to src/windows/Makefile.win diff --git a/desmume/src/windows/OpenArchive.cpp b/src/windows/OpenArchive.cpp similarity index 100% rename from desmume/src/windows/OpenArchive.cpp rename to src/windows/OpenArchive.cpp diff --git a/desmume/src/windows/OpenArchive.h b/src/windows/OpenArchive.h similarity index 100% rename from desmume/src/windows/OpenArchive.h rename to src/windows/OpenArchive.h diff --git a/desmume/src/windows/afxres.h b/src/windows/afxres.h similarity index 100% rename from desmume/src/windows/afxres.h rename to src/windows/afxres.h diff --git a/desmume/src/windows/agg/agg-2.5.lib b/src/windows/agg/agg-2.5.lib similarity index 100% rename from desmume/src/windows/agg/agg-2.5.lib rename to src/windows/agg/agg-2.5.lib diff --git a/desmume/src/windows/agg/agg-2.5.sln b/src/windows/agg/agg-2.5.sln similarity index 100% rename from desmume/src/windows/agg/agg-2.5.sln rename to src/windows/agg/agg-2.5.sln diff --git a/desmume/src/windows/agg/agg-2.5.vcproj b/src/windows/agg/agg-2.5.vcproj similarity index 100% rename from desmume/src/windows/agg/agg-2.5.vcproj rename to src/windows/agg/agg-2.5.vcproj diff --git a/desmume/src/windows/agg/examples/pixel_formats.h b/src/windows/agg/examples/pixel_formats.h similarity index 100% rename from desmume/src/windows/agg/examples/pixel_formats.h rename to src/windows/agg/examples/pixel_formats.h diff --git a/desmume/src/windows/agg/font_freetype/agg_font_freetype.cpp b/src/windows/agg/font_freetype/agg_font_freetype.cpp similarity index 100% rename from desmume/src/windows/agg/font_freetype/agg_font_freetype.cpp rename to src/windows/agg/font_freetype/agg_font_freetype.cpp diff --git a/desmume/src/windows/agg/font_freetype/agg_font_freetype.h b/src/windows/agg/font_freetype/agg_font_freetype.h similarity index 100% rename from desmume/src/windows/agg/font_freetype/agg_font_freetype.h rename to src/windows/agg/font_freetype/agg_font_freetype.h diff --git a/desmume/src/windows/agg/font_win32_tt/agg_font_win32_tt.cpp b/src/windows/agg/font_win32_tt/agg_font_win32_tt.cpp similarity index 100% rename from desmume/src/windows/agg/font_win32_tt/agg_font_win32_tt.cpp rename to src/windows/agg/font_win32_tt/agg_font_win32_tt.cpp diff --git a/desmume/src/windows/agg/font_win32_tt/agg_font_win32_tt.h b/src/windows/agg/font_win32_tt/agg_font_win32_tt.h similarity index 100% rename from desmume/src/windows/agg/font_win32_tt/agg_font_win32_tt.h rename to src/windows/agg/font_win32_tt/agg_font_win32_tt.h diff --git a/desmume/src/windows/agg/include/agg_alpha_mask_u8.h b/src/windows/agg/include/agg_alpha_mask_u8.h similarity index 100% rename from desmume/src/windows/agg/include/agg_alpha_mask_u8.h rename to src/windows/agg/include/agg_alpha_mask_u8.h diff --git a/desmume/src/windows/agg/include/agg_arc.h b/src/windows/agg/include/agg_arc.h similarity index 100% rename from desmume/src/windows/agg/include/agg_arc.h rename to src/windows/agg/include/agg_arc.h diff --git a/desmume/src/windows/agg/include/agg_array.h b/src/windows/agg/include/agg_array.h similarity index 100% rename from desmume/src/windows/agg/include/agg_array.h rename to src/windows/agg/include/agg_array.h diff --git a/desmume/src/windows/agg/include/agg_arrowhead.h b/src/windows/agg/include/agg_arrowhead.h similarity index 100% rename from desmume/src/windows/agg/include/agg_arrowhead.h rename to src/windows/agg/include/agg_arrowhead.h diff --git a/desmume/src/windows/agg/include/agg_basics.h b/src/windows/agg/include/agg_basics.h similarity index 100% rename from desmume/src/windows/agg/include/agg_basics.h rename to src/windows/agg/include/agg_basics.h diff --git a/desmume/src/windows/agg/include/agg_bezier_arc.h b/src/windows/agg/include/agg_bezier_arc.h similarity index 100% rename from desmume/src/windows/agg/include/agg_bezier_arc.h rename to src/windows/agg/include/agg_bezier_arc.h diff --git a/desmume/src/windows/agg/include/agg_bitset_iterator.h b/src/windows/agg/include/agg_bitset_iterator.h similarity index 100% rename from desmume/src/windows/agg/include/agg_bitset_iterator.h rename to src/windows/agg/include/agg_bitset_iterator.h diff --git a/desmume/src/windows/agg/include/agg_blur.h b/src/windows/agg/include/agg_blur.h similarity index 100% rename from desmume/src/windows/agg/include/agg_blur.h rename to src/windows/agg/include/agg_blur.h diff --git a/desmume/src/windows/agg/include/agg_bounding_rect.h b/src/windows/agg/include/agg_bounding_rect.h similarity index 100% rename from desmume/src/windows/agg/include/agg_bounding_rect.h rename to src/windows/agg/include/agg_bounding_rect.h diff --git a/desmume/src/windows/agg/include/agg_bspline.h b/src/windows/agg/include/agg_bspline.h similarity index 100% rename from desmume/src/windows/agg/include/agg_bspline.h rename to src/windows/agg/include/agg_bspline.h diff --git a/desmume/src/windows/agg/include/agg_clip_liang_barsky.h b/src/windows/agg/include/agg_clip_liang_barsky.h similarity index 100% rename from desmume/src/windows/agg/include/agg_clip_liang_barsky.h rename to src/windows/agg/include/agg_clip_liang_barsky.h diff --git a/desmume/src/windows/agg/include/agg_color_gray.h b/src/windows/agg/include/agg_color_gray.h similarity index 100% rename from desmume/src/windows/agg/include/agg_color_gray.h rename to src/windows/agg/include/agg_color_gray.h diff --git a/desmume/src/windows/agg/include/agg_color_rgba.h b/src/windows/agg/include/agg_color_rgba.h similarity index 100% rename from desmume/src/windows/agg/include/agg_color_rgba.h rename to src/windows/agg/include/agg_color_rgba.h diff --git a/desmume/src/windows/agg/include/agg_config.h b/src/windows/agg/include/agg_config.h similarity index 100% rename from desmume/src/windows/agg/include/agg_config.h rename to src/windows/agg/include/agg_config.h diff --git a/desmume/src/windows/agg/include/agg_conv_adaptor_vcgen.h b/src/windows/agg/include/agg_conv_adaptor_vcgen.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_adaptor_vcgen.h rename to src/windows/agg/include/agg_conv_adaptor_vcgen.h diff --git a/desmume/src/windows/agg/include/agg_conv_adaptor_vpgen.h b/src/windows/agg/include/agg_conv_adaptor_vpgen.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_adaptor_vpgen.h rename to src/windows/agg/include/agg_conv_adaptor_vpgen.h diff --git a/desmume/src/windows/agg/include/agg_conv_bspline.h b/src/windows/agg/include/agg_conv_bspline.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_bspline.h rename to src/windows/agg/include/agg_conv_bspline.h diff --git a/desmume/src/windows/agg/include/agg_conv_clip_polygon.h b/src/windows/agg/include/agg_conv_clip_polygon.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_clip_polygon.h rename to src/windows/agg/include/agg_conv_clip_polygon.h diff --git a/desmume/src/windows/agg/include/agg_conv_clip_polyline.h b/src/windows/agg/include/agg_conv_clip_polyline.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_clip_polyline.h rename to src/windows/agg/include/agg_conv_clip_polyline.h diff --git a/desmume/src/windows/agg/include/agg_conv_close_polygon.h b/src/windows/agg/include/agg_conv_close_polygon.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_close_polygon.h rename to src/windows/agg/include/agg_conv_close_polygon.h diff --git a/desmume/src/windows/agg/include/agg_conv_concat.h b/src/windows/agg/include/agg_conv_concat.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_concat.h rename to src/windows/agg/include/agg_conv_concat.h diff --git a/desmume/src/windows/agg/include/agg_conv_contour.h b/src/windows/agg/include/agg_conv_contour.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_contour.h rename to src/windows/agg/include/agg_conv_contour.h diff --git a/desmume/src/windows/agg/include/agg_conv_curve.h b/src/windows/agg/include/agg_conv_curve.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_curve.h rename to src/windows/agg/include/agg_conv_curve.h diff --git a/desmume/src/windows/agg/include/agg_conv_dash.h b/src/windows/agg/include/agg_conv_dash.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_dash.h rename to src/windows/agg/include/agg_conv_dash.h diff --git a/desmume/src/windows/agg/include/agg_conv_gpc.h b/src/windows/agg/include/agg_conv_gpc.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_gpc.h rename to src/windows/agg/include/agg_conv_gpc.h diff --git a/desmume/src/windows/agg/include/agg_conv_marker.h b/src/windows/agg/include/agg_conv_marker.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_marker.h rename to src/windows/agg/include/agg_conv_marker.h diff --git a/desmume/src/windows/agg/include/agg_conv_marker_adaptor.h b/src/windows/agg/include/agg_conv_marker_adaptor.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_marker_adaptor.h rename to src/windows/agg/include/agg_conv_marker_adaptor.h diff --git a/desmume/src/windows/agg/include/agg_conv_segmentator.h b/src/windows/agg/include/agg_conv_segmentator.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_segmentator.h rename to src/windows/agg/include/agg_conv_segmentator.h diff --git a/desmume/src/windows/agg/include/agg_conv_shorten_path.h b/src/windows/agg/include/agg_conv_shorten_path.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_shorten_path.h rename to src/windows/agg/include/agg_conv_shorten_path.h diff --git a/desmume/src/windows/agg/include/agg_conv_smooth_poly1.h b/src/windows/agg/include/agg_conv_smooth_poly1.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_smooth_poly1.h rename to src/windows/agg/include/agg_conv_smooth_poly1.h diff --git a/desmume/src/windows/agg/include/agg_conv_stroke.h b/src/windows/agg/include/agg_conv_stroke.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_stroke.h rename to src/windows/agg/include/agg_conv_stroke.h diff --git a/desmume/src/windows/agg/include/agg_conv_transform.h b/src/windows/agg/include/agg_conv_transform.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_transform.h rename to src/windows/agg/include/agg_conv_transform.h diff --git a/desmume/src/windows/agg/include/agg_conv_unclose_polygon.h b/src/windows/agg/include/agg_conv_unclose_polygon.h similarity index 100% rename from desmume/src/windows/agg/include/agg_conv_unclose_polygon.h rename to src/windows/agg/include/agg_conv_unclose_polygon.h diff --git a/desmume/src/windows/agg/include/agg_curves.h b/src/windows/agg/include/agg_curves.h similarity index 100% rename from desmume/src/windows/agg/include/agg_curves.h rename to src/windows/agg/include/agg_curves.h diff --git a/desmume/src/windows/agg/include/agg_dda_line.h b/src/windows/agg/include/agg_dda_line.h similarity index 100% rename from desmume/src/windows/agg/include/agg_dda_line.h rename to src/windows/agg/include/agg_dda_line.h diff --git a/desmume/src/windows/agg/include/agg_ellipse.h b/src/windows/agg/include/agg_ellipse.h similarity index 100% rename from desmume/src/windows/agg/include/agg_ellipse.h rename to src/windows/agg/include/agg_ellipse.h diff --git a/desmume/src/windows/agg/include/agg_ellipse_bresenham.h b/src/windows/agg/include/agg_ellipse_bresenham.h similarity index 100% rename from desmume/src/windows/agg/include/agg_ellipse_bresenham.h rename to src/windows/agg/include/agg_ellipse_bresenham.h diff --git a/desmume/src/windows/agg/include/agg_embedded_raster_fonts.h b/src/windows/agg/include/agg_embedded_raster_fonts.h similarity index 100% rename from desmume/src/windows/agg/include/agg_embedded_raster_fonts.h rename to src/windows/agg/include/agg_embedded_raster_fonts.h diff --git a/desmume/src/windows/agg/include/agg_font_cache_manager.h b/src/windows/agg/include/agg_font_cache_manager.h similarity index 100% rename from desmume/src/windows/agg/include/agg_font_cache_manager.h rename to src/windows/agg/include/agg_font_cache_manager.h diff --git a/desmume/src/windows/agg/include/agg_gamma_functions.h b/src/windows/agg/include/agg_gamma_functions.h similarity index 100% rename from desmume/src/windows/agg/include/agg_gamma_functions.h rename to src/windows/agg/include/agg_gamma_functions.h diff --git a/desmume/src/windows/agg/include/agg_gamma_lut.h b/src/windows/agg/include/agg_gamma_lut.h similarity index 100% rename from desmume/src/windows/agg/include/agg_gamma_lut.h rename to src/windows/agg/include/agg_gamma_lut.h diff --git a/desmume/src/windows/agg/include/agg_glyph_raster_bin.h b/src/windows/agg/include/agg_glyph_raster_bin.h similarity index 100% rename from desmume/src/windows/agg/include/agg_glyph_raster_bin.h rename to src/windows/agg/include/agg_glyph_raster_bin.h diff --git a/desmume/src/windows/agg/include/agg_gradient_lut.h b/src/windows/agg/include/agg_gradient_lut.h similarity index 100% rename from desmume/src/windows/agg/include/agg_gradient_lut.h rename to src/windows/agg/include/agg_gradient_lut.h diff --git a/desmume/src/windows/agg/include/agg_gsv_text.h b/src/windows/agg/include/agg_gsv_text.h similarity index 100% rename from desmume/src/windows/agg/include/agg_gsv_text.h rename to src/windows/agg/include/agg_gsv_text.h diff --git a/desmume/src/windows/agg/include/agg_image_accessors.h b/src/windows/agg/include/agg_image_accessors.h similarity index 100% rename from desmume/src/windows/agg/include/agg_image_accessors.h rename to src/windows/agg/include/agg_image_accessors.h diff --git a/desmume/src/windows/agg/include/agg_image_filters.h b/src/windows/agg/include/agg_image_filters.h similarity index 100% rename from desmume/src/windows/agg/include/agg_image_filters.h rename to src/windows/agg/include/agg_image_filters.h diff --git a/desmume/src/windows/agg/include/agg_line_aa_basics.h b/src/windows/agg/include/agg_line_aa_basics.h similarity index 100% rename from desmume/src/windows/agg/include/agg_line_aa_basics.h rename to src/windows/agg/include/agg_line_aa_basics.h diff --git a/desmume/src/windows/agg/include/agg_math.h b/src/windows/agg/include/agg_math.h similarity index 100% rename from desmume/src/windows/agg/include/agg_math.h rename to src/windows/agg/include/agg_math.h diff --git a/desmume/src/windows/agg/include/agg_math_stroke.h b/src/windows/agg/include/agg_math_stroke.h similarity index 100% rename from desmume/src/windows/agg/include/agg_math_stroke.h rename to src/windows/agg/include/agg_math_stroke.h diff --git a/desmume/src/windows/agg/include/agg_path_length.h b/src/windows/agg/include/agg_path_length.h similarity index 100% rename from desmume/src/windows/agg/include/agg_path_length.h rename to src/windows/agg/include/agg_path_length.h diff --git a/desmume/src/windows/agg/include/agg_path_storage.h b/src/windows/agg/include/agg_path_storage.h similarity index 100% rename from desmume/src/windows/agg/include/agg_path_storage.h rename to src/windows/agg/include/agg_path_storage.h diff --git a/desmume/src/windows/agg/include/agg_path_storage_integer.h b/src/windows/agg/include/agg_path_storage_integer.h similarity index 100% rename from desmume/src/windows/agg/include/agg_path_storage_integer.h rename to src/windows/agg/include/agg_path_storage_integer.h diff --git a/desmume/src/windows/agg/include/agg_pattern_filters_rgba.h b/src/windows/agg/include/agg_pattern_filters_rgba.h similarity index 100% rename from desmume/src/windows/agg/include/agg_pattern_filters_rgba.h rename to src/windows/agg/include/agg_pattern_filters_rgba.h diff --git a/desmume/src/windows/agg/include/agg_pixfmt_amask_adaptor.h b/src/windows/agg/include/agg_pixfmt_amask_adaptor.h similarity index 100% rename from desmume/src/windows/agg/include/agg_pixfmt_amask_adaptor.h rename to src/windows/agg/include/agg_pixfmt_amask_adaptor.h diff --git a/desmume/src/windows/agg/include/agg_pixfmt_gray.h b/src/windows/agg/include/agg_pixfmt_gray.h similarity index 100% rename from desmume/src/windows/agg/include/agg_pixfmt_gray.h rename to src/windows/agg/include/agg_pixfmt_gray.h diff --git a/desmume/src/windows/agg/include/agg_pixfmt_rgb.h b/src/windows/agg/include/agg_pixfmt_rgb.h similarity index 100% rename from desmume/src/windows/agg/include/agg_pixfmt_rgb.h rename to src/windows/agg/include/agg_pixfmt_rgb.h diff --git a/desmume/src/windows/agg/include/agg_pixfmt_rgb_packed.h b/src/windows/agg/include/agg_pixfmt_rgb_packed.h similarity index 100% rename from desmume/src/windows/agg/include/agg_pixfmt_rgb_packed.h rename to src/windows/agg/include/agg_pixfmt_rgb_packed.h diff --git a/desmume/src/windows/agg/include/agg_pixfmt_rgba.h b/src/windows/agg/include/agg_pixfmt_rgba.h similarity index 100% rename from desmume/src/windows/agg/include/agg_pixfmt_rgba.h rename to src/windows/agg/include/agg_pixfmt_rgba.h diff --git a/desmume/src/windows/agg/include/agg_pixfmt_transposer.h b/src/windows/agg/include/agg_pixfmt_transposer.h similarity index 100% rename from desmume/src/windows/agg/include/agg_pixfmt_transposer.h rename to src/windows/agg/include/agg_pixfmt_transposer.h diff --git a/desmume/src/windows/agg/include/agg_rasterizer_cells_aa.h b/src/windows/agg/include/agg_rasterizer_cells_aa.h similarity index 100% rename from desmume/src/windows/agg/include/agg_rasterizer_cells_aa.h rename to src/windows/agg/include/agg_rasterizer_cells_aa.h diff --git a/desmume/src/windows/agg/include/agg_rasterizer_compound_aa.h b/src/windows/agg/include/agg_rasterizer_compound_aa.h similarity index 100% rename from desmume/src/windows/agg/include/agg_rasterizer_compound_aa.h rename to src/windows/agg/include/agg_rasterizer_compound_aa.h diff --git a/desmume/src/windows/agg/include/agg_rasterizer_outline.h b/src/windows/agg/include/agg_rasterizer_outline.h similarity index 100% rename from desmume/src/windows/agg/include/agg_rasterizer_outline.h rename to src/windows/agg/include/agg_rasterizer_outline.h diff --git a/desmume/src/windows/agg/include/agg_rasterizer_outline_aa.h b/src/windows/agg/include/agg_rasterizer_outline_aa.h similarity index 100% rename from desmume/src/windows/agg/include/agg_rasterizer_outline_aa.h rename to src/windows/agg/include/agg_rasterizer_outline_aa.h diff --git a/desmume/src/windows/agg/include/agg_rasterizer_scanline_aa.h b/src/windows/agg/include/agg_rasterizer_scanline_aa.h similarity index 100% rename from desmume/src/windows/agg/include/agg_rasterizer_scanline_aa.h rename to src/windows/agg/include/agg_rasterizer_scanline_aa.h diff --git a/desmume/src/windows/agg/include/agg_rasterizer_sl_clip.h b/src/windows/agg/include/agg_rasterizer_sl_clip.h similarity index 100% rename from desmume/src/windows/agg/include/agg_rasterizer_sl_clip.h rename to src/windows/agg/include/agg_rasterizer_sl_clip.h diff --git a/desmume/src/windows/agg/include/agg_renderer_base.h b/src/windows/agg/include/agg_renderer_base.h similarity index 100% rename from desmume/src/windows/agg/include/agg_renderer_base.h rename to src/windows/agg/include/agg_renderer_base.h diff --git a/desmume/src/windows/agg/include/agg_renderer_markers.h b/src/windows/agg/include/agg_renderer_markers.h similarity index 100% rename from desmume/src/windows/agg/include/agg_renderer_markers.h rename to src/windows/agg/include/agg_renderer_markers.h diff --git a/desmume/src/windows/agg/include/agg_renderer_mclip.h b/src/windows/agg/include/agg_renderer_mclip.h similarity index 100% rename from desmume/src/windows/agg/include/agg_renderer_mclip.h rename to src/windows/agg/include/agg_renderer_mclip.h diff --git a/desmume/src/windows/agg/include/agg_renderer_outline_aa.h b/src/windows/agg/include/agg_renderer_outline_aa.h similarity index 100% rename from desmume/src/windows/agg/include/agg_renderer_outline_aa.h rename to src/windows/agg/include/agg_renderer_outline_aa.h diff --git a/desmume/src/windows/agg/include/agg_renderer_outline_image.h b/src/windows/agg/include/agg_renderer_outline_image.h similarity index 100% rename from desmume/src/windows/agg/include/agg_renderer_outline_image.h rename to src/windows/agg/include/agg_renderer_outline_image.h diff --git a/desmume/src/windows/agg/include/agg_renderer_primitives.h b/src/windows/agg/include/agg_renderer_primitives.h similarity index 100% rename from desmume/src/windows/agg/include/agg_renderer_primitives.h rename to src/windows/agg/include/agg_renderer_primitives.h diff --git a/desmume/src/windows/agg/include/agg_renderer_raster_text.h b/src/windows/agg/include/agg_renderer_raster_text.h similarity index 100% rename from desmume/src/windows/agg/include/agg_renderer_raster_text.h rename to src/windows/agg/include/agg_renderer_raster_text.h diff --git a/desmume/src/windows/agg/include/agg_renderer_scanline.h b/src/windows/agg/include/agg_renderer_scanline.h similarity index 100% rename from desmume/src/windows/agg/include/agg_renderer_scanline.h rename to src/windows/agg/include/agg_renderer_scanline.h diff --git a/desmume/src/windows/agg/include/agg_rendering_buffer.h b/src/windows/agg/include/agg_rendering_buffer.h similarity index 100% rename from desmume/src/windows/agg/include/agg_rendering_buffer.h rename to src/windows/agg/include/agg_rendering_buffer.h diff --git a/desmume/src/windows/agg/include/agg_rendering_buffer_dynarow.h b/src/windows/agg/include/agg_rendering_buffer_dynarow.h similarity index 100% rename from desmume/src/windows/agg/include/agg_rendering_buffer_dynarow.h rename to src/windows/agg/include/agg_rendering_buffer_dynarow.h diff --git a/desmume/src/windows/agg/include/agg_rounded_rect.h b/src/windows/agg/include/agg_rounded_rect.h similarity index 100% rename from desmume/src/windows/agg/include/agg_rounded_rect.h rename to src/windows/agg/include/agg_rounded_rect.h diff --git a/desmume/src/windows/agg/include/agg_scanline_bin.h b/src/windows/agg/include/agg_scanline_bin.h similarity index 100% rename from desmume/src/windows/agg/include/agg_scanline_bin.h rename to src/windows/agg/include/agg_scanline_bin.h diff --git a/desmume/src/windows/agg/include/agg_scanline_boolean_algebra.h b/src/windows/agg/include/agg_scanline_boolean_algebra.h similarity index 100% rename from desmume/src/windows/agg/include/agg_scanline_boolean_algebra.h rename to src/windows/agg/include/agg_scanline_boolean_algebra.h diff --git a/desmume/src/windows/agg/include/agg_scanline_p.h b/src/windows/agg/include/agg_scanline_p.h similarity index 100% rename from desmume/src/windows/agg/include/agg_scanline_p.h rename to src/windows/agg/include/agg_scanline_p.h diff --git a/desmume/src/windows/agg/include/agg_scanline_storage_aa.h b/src/windows/agg/include/agg_scanline_storage_aa.h similarity index 100% rename from desmume/src/windows/agg/include/agg_scanline_storage_aa.h rename to src/windows/agg/include/agg_scanline_storage_aa.h diff --git a/desmume/src/windows/agg/include/agg_scanline_storage_bin.h b/src/windows/agg/include/agg_scanline_storage_bin.h similarity index 100% rename from desmume/src/windows/agg/include/agg_scanline_storage_bin.h rename to src/windows/agg/include/agg_scanline_storage_bin.h diff --git a/desmume/src/windows/agg/include/agg_scanline_u.h b/src/windows/agg/include/agg_scanline_u.h similarity index 100% rename from desmume/src/windows/agg/include/agg_scanline_u.h rename to src/windows/agg/include/agg_scanline_u.h diff --git a/desmume/src/windows/agg/include/agg_shorten_path.h b/src/windows/agg/include/agg_shorten_path.h similarity index 100% rename from desmume/src/windows/agg/include/agg_shorten_path.h rename to src/windows/agg/include/agg_shorten_path.h diff --git a/desmume/src/windows/agg/include/agg_simul_eq.h b/src/windows/agg/include/agg_simul_eq.h similarity index 100% rename from desmume/src/windows/agg/include/agg_simul_eq.h rename to src/windows/agg/include/agg_simul_eq.h diff --git a/desmume/src/windows/agg/include/agg_span_allocator.h b/src/windows/agg/include/agg_span_allocator.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_allocator.h rename to src/windows/agg/include/agg_span_allocator.h diff --git a/desmume/src/windows/agg/include/agg_span_converter.h b/src/windows/agg/include/agg_span_converter.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_converter.h rename to src/windows/agg/include/agg_span_converter.h diff --git a/desmume/src/windows/agg/include/agg_span_gouraud.h b/src/windows/agg/include/agg_span_gouraud.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_gouraud.h rename to src/windows/agg/include/agg_span_gouraud.h diff --git a/desmume/src/windows/agg/include/agg_span_gouraud_gray.h b/src/windows/agg/include/agg_span_gouraud_gray.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_gouraud_gray.h rename to src/windows/agg/include/agg_span_gouraud_gray.h diff --git a/desmume/src/windows/agg/include/agg_span_gouraud_rgba.h b/src/windows/agg/include/agg_span_gouraud_rgba.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_gouraud_rgba.h rename to src/windows/agg/include/agg_span_gouraud_rgba.h diff --git a/desmume/src/windows/agg/include/agg_span_gradient.h b/src/windows/agg/include/agg_span_gradient.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_gradient.h rename to src/windows/agg/include/agg_span_gradient.h diff --git a/desmume/src/windows/agg/include/agg_span_gradient_alpha.h b/src/windows/agg/include/agg_span_gradient_alpha.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_gradient_alpha.h rename to src/windows/agg/include/agg_span_gradient_alpha.h diff --git a/desmume/src/windows/agg/include/agg_span_image_filter.h b/src/windows/agg/include/agg_span_image_filter.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_image_filter.h rename to src/windows/agg/include/agg_span_image_filter.h diff --git a/desmume/src/windows/agg/include/agg_span_image_filter_gray.h b/src/windows/agg/include/agg_span_image_filter_gray.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_image_filter_gray.h rename to src/windows/agg/include/agg_span_image_filter_gray.h diff --git a/desmume/src/windows/agg/include/agg_span_image_filter_rgb.h b/src/windows/agg/include/agg_span_image_filter_rgb.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_image_filter_rgb.h rename to src/windows/agg/include/agg_span_image_filter_rgb.h diff --git a/desmume/src/windows/agg/include/agg_span_image_filter_rgba.h b/src/windows/agg/include/agg_span_image_filter_rgba.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_image_filter_rgba.h rename to src/windows/agg/include/agg_span_image_filter_rgba.h diff --git a/desmume/src/windows/agg/include/agg_span_interpolator_adaptor.h b/src/windows/agg/include/agg_span_interpolator_adaptor.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_interpolator_adaptor.h rename to src/windows/agg/include/agg_span_interpolator_adaptor.h diff --git a/desmume/src/windows/agg/include/agg_span_interpolator_linear.h b/src/windows/agg/include/agg_span_interpolator_linear.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_interpolator_linear.h rename to src/windows/agg/include/agg_span_interpolator_linear.h diff --git a/desmume/src/windows/agg/include/agg_span_interpolator_persp.h b/src/windows/agg/include/agg_span_interpolator_persp.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_interpolator_persp.h rename to src/windows/agg/include/agg_span_interpolator_persp.h diff --git a/desmume/src/windows/agg/include/agg_span_interpolator_trans.h b/src/windows/agg/include/agg_span_interpolator_trans.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_interpolator_trans.h rename to src/windows/agg/include/agg_span_interpolator_trans.h diff --git a/desmume/src/windows/agg/include/agg_span_pattern_gray.h b/src/windows/agg/include/agg_span_pattern_gray.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_pattern_gray.h rename to src/windows/agg/include/agg_span_pattern_gray.h diff --git a/desmume/src/windows/agg/include/agg_span_pattern_rgb.h b/src/windows/agg/include/agg_span_pattern_rgb.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_pattern_rgb.h rename to src/windows/agg/include/agg_span_pattern_rgb.h diff --git a/desmume/src/windows/agg/include/agg_span_pattern_rgba.h b/src/windows/agg/include/agg_span_pattern_rgba.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_pattern_rgba.h rename to src/windows/agg/include/agg_span_pattern_rgba.h diff --git a/desmume/src/windows/agg/include/agg_span_solid.h b/src/windows/agg/include/agg_span_solid.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_solid.h rename to src/windows/agg/include/agg_span_solid.h diff --git a/desmume/src/windows/agg/include/agg_span_subdiv_adaptor.h b/src/windows/agg/include/agg_span_subdiv_adaptor.h similarity index 100% rename from desmume/src/windows/agg/include/agg_span_subdiv_adaptor.h rename to src/windows/agg/include/agg_span_subdiv_adaptor.h diff --git a/desmume/src/windows/agg/include/agg_trans_affine.h b/src/windows/agg/include/agg_trans_affine.h similarity index 100% rename from desmume/src/windows/agg/include/agg_trans_affine.h rename to src/windows/agg/include/agg_trans_affine.h diff --git a/desmume/src/windows/agg/include/agg_trans_bilinear.h b/src/windows/agg/include/agg_trans_bilinear.h similarity index 100% rename from desmume/src/windows/agg/include/agg_trans_bilinear.h rename to src/windows/agg/include/agg_trans_bilinear.h diff --git a/desmume/src/windows/agg/include/agg_trans_double_path.h b/src/windows/agg/include/agg_trans_double_path.h similarity index 100% rename from desmume/src/windows/agg/include/agg_trans_double_path.h rename to src/windows/agg/include/agg_trans_double_path.h diff --git a/desmume/src/windows/agg/include/agg_trans_perspective.h b/src/windows/agg/include/agg_trans_perspective.h similarity index 100% rename from desmume/src/windows/agg/include/agg_trans_perspective.h rename to src/windows/agg/include/agg_trans_perspective.h diff --git a/desmume/src/windows/agg/include/agg_trans_single_path.h b/src/windows/agg/include/agg_trans_single_path.h similarity index 100% rename from desmume/src/windows/agg/include/agg_trans_single_path.h rename to src/windows/agg/include/agg_trans_single_path.h diff --git a/desmume/src/windows/agg/include/agg_trans_viewport.h b/src/windows/agg/include/agg_trans_viewport.h similarity index 100% rename from desmume/src/windows/agg/include/agg_trans_viewport.h rename to src/windows/agg/include/agg_trans_viewport.h diff --git a/desmume/src/windows/agg/include/agg_trans_warp_magnifier.h b/src/windows/agg/include/agg_trans_warp_magnifier.h similarity index 100% rename from desmume/src/windows/agg/include/agg_trans_warp_magnifier.h rename to src/windows/agg/include/agg_trans_warp_magnifier.h diff --git a/desmume/src/windows/agg/include/agg_vcgen_bspline.h b/src/windows/agg/include/agg_vcgen_bspline.h similarity index 100% rename from desmume/src/windows/agg/include/agg_vcgen_bspline.h rename to src/windows/agg/include/agg_vcgen_bspline.h diff --git a/desmume/src/windows/agg/include/agg_vcgen_contour.h b/src/windows/agg/include/agg_vcgen_contour.h similarity index 100% rename from desmume/src/windows/agg/include/agg_vcgen_contour.h rename to src/windows/agg/include/agg_vcgen_contour.h diff --git a/desmume/src/windows/agg/include/agg_vcgen_dash.h b/src/windows/agg/include/agg_vcgen_dash.h similarity index 100% rename from desmume/src/windows/agg/include/agg_vcgen_dash.h rename to src/windows/agg/include/agg_vcgen_dash.h diff --git a/desmume/src/windows/agg/include/agg_vcgen_markers_term.h b/src/windows/agg/include/agg_vcgen_markers_term.h similarity index 100% rename from desmume/src/windows/agg/include/agg_vcgen_markers_term.h rename to src/windows/agg/include/agg_vcgen_markers_term.h diff --git a/desmume/src/windows/agg/include/agg_vcgen_smooth_poly1.h b/src/windows/agg/include/agg_vcgen_smooth_poly1.h similarity index 100% rename from desmume/src/windows/agg/include/agg_vcgen_smooth_poly1.h rename to src/windows/agg/include/agg_vcgen_smooth_poly1.h diff --git a/desmume/src/windows/agg/include/agg_vcgen_stroke.h b/src/windows/agg/include/agg_vcgen_stroke.h similarity index 100% rename from desmume/src/windows/agg/include/agg_vcgen_stroke.h rename to src/windows/agg/include/agg_vcgen_stroke.h diff --git a/desmume/src/windows/agg/include/agg_vcgen_vertex_sequence.h b/src/windows/agg/include/agg_vcgen_vertex_sequence.h similarity index 100% rename from desmume/src/windows/agg/include/agg_vcgen_vertex_sequence.h rename to src/windows/agg/include/agg_vcgen_vertex_sequence.h diff --git a/desmume/src/windows/agg/include/agg_vertex_sequence.h b/src/windows/agg/include/agg_vertex_sequence.h similarity index 100% rename from desmume/src/windows/agg/include/agg_vertex_sequence.h rename to src/windows/agg/include/agg_vertex_sequence.h diff --git a/desmume/src/windows/agg/include/agg_vpgen_clip_polygon.h b/src/windows/agg/include/agg_vpgen_clip_polygon.h similarity index 100% rename from desmume/src/windows/agg/include/agg_vpgen_clip_polygon.h rename to src/windows/agg/include/agg_vpgen_clip_polygon.h diff --git a/desmume/src/windows/agg/include/agg_vpgen_clip_polyline.h b/src/windows/agg/include/agg_vpgen_clip_polyline.h similarity index 100% rename from desmume/src/windows/agg/include/agg_vpgen_clip_polyline.h rename to src/windows/agg/include/agg_vpgen_clip_polyline.h diff --git a/desmume/src/windows/agg/include/agg_vpgen_segmentator.h b/src/windows/agg/include/agg_vpgen_segmentator.h similarity index 100% rename from desmume/src/windows/agg/include/agg_vpgen_segmentator.h rename to src/windows/agg/include/agg_vpgen_segmentator.h diff --git a/desmume/src/windows/agg/include/ctrl/agg_bezier_ctrl.h b/src/windows/agg/include/ctrl/agg_bezier_ctrl.h similarity index 100% rename from desmume/src/windows/agg/include/ctrl/agg_bezier_ctrl.h rename to src/windows/agg/include/ctrl/agg_bezier_ctrl.h diff --git a/desmume/src/windows/agg/include/ctrl/agg_cbox_ctrl.h b/src/windows/agg/include/ctrl/agg_cbox_ctrl.h similarity index 100% rename from desmume/src/windows/agg/include/ctrl/agg_cbox_ctrl.h rename to src/windows/agg/include/ctrl/agg_cbox_ctrl.h diff --git a/desmume/src/windows/agg/include/ctrl/agg_ctrl.h b/src/windows/agg/include/ctrl/agg_ctrl.h similarity index 100% rename from desmume/src/windows/agg/include/ctrl/agg_ctrl.h rename to src/windows/agg/include/ctrl/agg_ctrl.h diff --git a/desmume/src/windows/agg/include/ctrl/agg_gamma_ctrl.h b/src/windows/agg/include/ctrl/agg_gamma_ctrl.h similarity index 100% rename from desmume/src/windows/agg/include/ctrl/agg_gamma_ctrl.h rename to src/windows/agg/include/ctrl/agg_gamma_ctrl.h diff --git a/desmume/src/windows/agg/include/ctrl/agg_gamma_spline.h b/src/windows/agg/include/ctrl/agg_gamma_spline.h similarity index 100% rename from desmume/src/windows/agg/include/ctrl/agg_gamma_spline.h rename to src/windows/agg/include/ctrl/agg_gamma_spline.h diff --git a/desmume/src/windows/agg/include/ctrl/agg_polygon_ctrl.h b/src/windows/agg/include/ctrl/agg_polygon_ctrl.h similarity index 100% rename from desmume/src/windows/agg/include/ctrl/agg_polygon_ctrl.h rename to src/windows/agg/include/ctrl/agg_polygon_ctrl.h diff --git a/desmume/src/windows/agg/include/ctrl/agg_rbox_ctrl.h b/src/windows/agg/include/ctrl/agg_rbox_ctrl.h similarity index 100% rename from desmume/src/windows/agg/include/ctrl/agg_rbox_ctrl.h rename to src/windows/agg/include/ctrl/agg_rbox_ctrl.h diff --git a/desmume/src/windows/agg/include/ctrl/agg_scale_ctrl.h b/src/windows/agg/include/ctrl/agg_scale_ctrl.h similarity index 100% rename from desmume/src/windows/agg/include/ctrl/agg_scale_ctrl.h rename to src/windows/agg/include/ctrl/agg_scale_ctrl.h diff --git a/desmume/src/windows/agg/include/ctrl/agg_slider_ctrl.h b/src/windows/agg/include/ctrl/agg_slider_ctrl.h similarity index 100% rename from desmume/src/windows/agg/include/ctrl/agg_slider_ctrl.h rename to src/windows/agg/include/ctrl/agg_slider_ctrl.h diff --git a/desmume/src/windows/agg/include/ctrl/agg_spline_ctrl.h b/src/windows/agg/include/ctrl/agg_spline_ctrl.h similarity index 100% rename from desmume/src/windows/agg/include/ctrl/agg_spline_ctrl.h rename to src/windows/agg/include/ctrl/agg_spline_ctrl.h diff --git a/desmume/src/windows/agg/include/platform/agg_platform_support.h b/src/windows/agg/include/platform/agg_platform_support.h similarity index 100% rename from desmume/src/windows/agg/include/platform/agg_platform_support.h rename to src/windows/agg/include/platform/agg_platform_support.h diff --git a/desmume/src/windows/agg/include/platform/mac/agg_mac_pmap.h b/src/windows/agg/include/platform/mac/agg_mac_pmap.h similarity index 100% rename from desmume/src/windows/agg/include/platform/mac/agg_mac_pmap.h rename to src/windows/agg/include/platform/mac/agg_mac_pmap.h diff --git a/desmume/src/windows/agg/include/platform/win32/agg_win32_bmp.h b/src/windows/agg/include/platform/win32/agg_win32_bmp.h similarity index 100% rename from desmume/src/windows/agg/include/platform/win32/agg_win32_bmp.h rename to src/windows/agg/include/platform/win32/agg_win32_bmp.h diff --git a/desmume/src/windows/agg/include/util/agg_color_conv.h b/src/windows/agg/include/util/agg_color_conv.h similarity index 100% rename from desmume/src/windows/agg/include/util/agg_color_conv.h rename to src/windows/agg/include/util/agg_color_conv.h diff --git a/desmume/src/windows/agg/include/util/agg_color_conv_rgb16.h b/src/windows/agg/include/util/agg_color_conv_rgb16.h similarity index 100% rename from desmume/src/windows/agg/include/util/agg_color_conv_rgb16.h rename to src/windows/agg/include/util/agg_color_conv_rgb16.h diff --git a/desmume/src/windows/agg/include/util/agg_color_conv_rgb8.h b/src/windows/agg/include/util/agg_color_conv_rgb8.h similarity index 100% rename from desmume/src/windows/agg/include/util/agg_color_conv_rgb8.h rename to src/windows/agg/include/util/agg_color_conv_rgb8.h diff --git a/desmume/src/windows/agg/src/ChangeLog b/src/windows/agg/src/ChangeLog similarity index 100% rename from desmume/src/windows/agg/src/ChangeLog rename to src/windows/agg/src/ChangeLog diff --git a/desmume/src/windows/agg/src/Makefile b/src/windows/agg/src/Makefile similarity index 100% rename from desmume/src/windows/agg/src/Makefile rename to src/windows/agg/src/Makefile diff --git a/desmume/src/windows/agg/src/agg_arc.cpp b/src/windows/agg/src/agg_arc.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_arc.cpp rename to src/windows/agg/src/agg_arc.cpp diff --git a/desmume/src/windows/agg/src/agg_arrowhead.cpp b/src/windows/agg/src/agg_arrowhead.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_arrowhead.cpp rename to src/windows/agg/src/agg_arrowhead.cpp diff --git a/desmume/src/windows/agg/src/agg_bezier_arc.cpp b/src/windows/agg/src/agg_bezier_arc.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_bezier_arc.cpp rename to src/windows/agg/src/agg_bezier_arc.cpp diff --git a/desmume/src/windows/agg/src/agg_bspline.cpp b/src/windows/agg/src/agg_bspline.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_bspline.cpp rename to src/windows/agg/src/agg_bspline.cpp diff --git a/desmume/src/windows/agg/src/agg_curves.cpp b/src/windows/agg/src/agg_curves.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_curves.cpp rename to src/windows/agg/src/agg_curves.cpp diff --git a/desmume/src/windows/agg/src/agg_embedded_raster_fonts.cpp b/src/windows/agg/src/agg_embedded_raster_fonts.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_embedded_raster_fonts.cpp rename to src/windows/agg/src/agg_embedded_raster_fonts.cpp diff --git a/desmume/src/windows/agg/src/agg_gsv_text.cpp b/src/windows/agg/src/agg_gsv_text.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_gsv_text.cpp rename to src/windows/agg/src/agg_gsv_text.cpp diff --git a/desmume/src/windows/agg/src/agg_image_filters.cpp b/src/windows/agg/src/agg_image_filters.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_image_filters.cpp rename to src/windows/agg/src/agg_image_filters.cpp diff --git a/desmume/src/windows/agg/src/agg_line_aa_basics.cpp b/src/windows/agg/src/agg_line_aa_basics.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_line_aa_basics.cpp rename to src/windows/agg/src/agg_line_aa_basics.cpp diff --git a/desmume/src/windows/agg/src/agg_line_profile_aa.cpp b/src/windows/agg/src/agg_line_profile_aa.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_line_profile_aa.cpp rename to src/windows/agg/src/agg_line_profile_aa.cpp diff --git a/desmume/src/windows/agg/src/agg_rounded_rect.cpp b/src/windows/agg/src/agg_rounded_rect.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_rounded_rect.cpp rename to src/windows/agg/src/agg_rounded_rect.cpp diff --git a/desmume/src/windows/agg/src/agg_sqrt_tables.cpp b/src/windows/agg/src/agg_sqrt_tables.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_sqrt_tables.cpp rename to src/windows/agg/src/agg_sqrt_tables.cpp diff --git a/desmume/src/windows/agg/src/agg_trans_affine.cpp b/src/windows/agg/src/agg_trans_affine.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_trans_affine.cpp rename to src/windows/agg/src/agg_trans_affine.cpp diff --git a/desmume/src/windows/agg/src/agg_trans_double_path.cpp b/src/windows/agg/src/agg_trans_double_path.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_trans_double_path.cpp rename to src/windows/agg/src/agg_trans_double_path.cpp diff --git a/desmume/src/windows/agg/src/agg_trans_single_path.cpp b/src/windows/agg/src/agg_trans_single_path.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_trans_single_path.cpp rename to src/windows/agg/src/agg_trans_single_path.cpp diff --git a/desmume/src/windows/agg/src/agg_trans_warp_magnifier.cpp b/src/windows/agg/src/agg_trans_warp_magnifier.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_trans_warp_magnifier.cpp rename to src/windows/agg/src/agg_trans_warp_magnifier.cpp diff --git a/desmume/src/windows/agg/src/agg_vcgen_bspline.cpp b/src/windows/agg/src/agg_vcgen_bspline.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_vcgen_bspline.cpp rename to src/windows/agg/src/agg_vcgen_bspline.cpp diff --git a/desmume/src/windows/agg/src/agg_vcgen_contour.cpp b/src/windows/agg/src/agg_vcgen_contour.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_vcgen_contour.cpp rename to src/windows/agg/src/agg_vcgen_contour.cpp diff --git a/desmume/src/windows/agg/src/agg_vcgen_dash.cpp b/src/windows/agg/src/agg_vcgen_dash.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_vcgen_dash.cpp rename to src/windows/agg/src/agg_vcgen_dash.cpp diff --git a/desmume/src/windows/agg/src/agg_vcgen_markers_term.cpp b/src/windows/agg/src/agg_vcgen_markers_term.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_vcgen_markers_term.cpp rename to src/windows/agg/src/agg_vcgen_markers_term.cpp diff --git a/desmume/src/windows/agg/src/agg_vcgen_smooth_poly1.cpp b/src/windows/agg/src/agg_vcgen_smooth_poly1.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_vcgen_smooth_poly1.cpp rename to src/windows/agg/src/agg_vcgen_smooth_poly1.cpp diff --git a/desmume/src/windows/agg/src/agg_vcgen_stroke.cpp b/src/windows/agg/src/agg_vcgen_stroke.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_vcgen_stroke.cpp rename to src/windows/agg/src/agg_vcgen_stroke.cpp diff --git a/desmume/src/windows/agg/src/agg_vpgen_clip_polygon.cpp b/src/windows/agg/src/agg_vpgen_clip_polygon.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_vpgen_clip_polygon.cpp rename to src/windows/agg/src/agg_vpgen_clip_polygon.cpp diff --git a/desmume/src/windows/agg/src/agg_vpgen_clip_polyline.cpp b/src/windows/agg/src/agg_vpgen_clip_polyline.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_vpgen_clip_polyline.cpp rename to src/windows/agg/src/agg_vpgen_clip_polyline.cpp diff --git a/desmume/src/windows/agg/src/agg_vpgen_segmentator.cpp b/src/windows/agg/src/agg_vpgen_segmentator.cpp similarity index 100% rename from desmume/src/windows/agg/src/agg_vpgen_segmentator.cpp rename to src/windows/agg/src/agg_vpgen_segmentator.cpp diff --git a/desmume/src/windows/agg/src/authors b/src/windows/agg/src/authors similarity index 100% rename from desmume/src/windows/agg/src/authors rename to src/windows/agg/src/authors diff --git a/desmume/src/windows/agg/src/autogen.sh b/src/windows/agg/src/autogen.sh similarity index 100% rename from desmume/src/windows/agg/src/autogen.sh rename to src/windows/agg/src/autogen.sh diff --git a/desmume/src/windows/agg/src/configure.in b/src/windows/agg/src/configure.in similarity index 100% rename from desmume/src/windows/agg/src/configure.in rename to src/windows/agg/src/configure.in diff --git a/desmume/src/windows/agg/src/copying b/src/windows/agg/src/copying similarity index 100% rename from desmume/src/windows/agg/src/copying rename to src/windows/agg/src/copying diff --git a/desmume/src/windows/agg/src/ctrl/agg_bezier_ctrl.cpp b/src/windows/agg/src/ctrl/agg_bezier_ctrl.cpp similarity index 100% rename from desmume/src/windows/agg/src/ctrl/agg_bezier_ctrl.cpp rename to src/windows/agg/src/ctrl/agg_bezier_ctrl.cpp diff --git a/desmume/src/windows/agg/src/ctrl/agg_cbox_ctrl.cpp b/src/windows/agg/src/ctrl/agg_cbox_ctrl.cpp similarity index 100% rename from desmume/src/windows/agg/src/ctrl/agg_cbox_ctrl.cpp rename to src/windows/agg/src/ctrl/agg_cbox_ctrl.cpp diff --git a/desmume/src/windows/agg/src/ctrl/agg_gamma_ctrl.cpp b/src/windows/agg/src/ctrl/agg_gamma_ctrl.cpp similarity index 100% rename from desmume/src/windows/agg/src/ctrl/agg_gamma_ctrl.cpp rename to src/windows/agg/src/ctrl/agg_gamma_ctrl.cpp diff --git a/desmume/src/windows/agg/src/ctrl/agg_gamma_spline.cpp b/src/windows/agg/src/ctrl/agg_gamma_spline.cpp similarity index 100% rename from desmume/src/windows/agg/src/ctrl/agg_gamma_spline.cpp rename to src/windows/agg/src/ctrl/agg_gamma_spline.cpp diff --git a/desmume/src/windows/agg/src/ctrl/agg_polygon_ctrl.cpp b/src/windows/agg/src/ctrl/agg_polygon_ctrl.cpp similarity index 100% rename from desmume/src/windows/agg/src/ctrl/agg_polygon_ctrl.cpp rename to src/windows/agg/src/ctrl/agg_polygon_ctrl.cpp diff --git a/desmume/src/windows/agg/src/ctrl/agg_rbox_ctrl.cpp b/src/windows/agg/src/ctrl/agg_rbox_ctrl.cpp similarity index 100% rename from desmume/src/windows/agg/src/ctrl/agg_rbox_ctrl.cpp rename to src/windows/agg/src/ctrl/agg_rbox_ctrl.cpp diff --git a/desmume/src/windows/agg/src/ctrl/agg_scale_ctrl.cpp b/src/windows/agg/src/ctrl/agg_scale_ctrl.cpp similarity index 100% rename from desmume/src/windows/agg/src/ctrl/agg_scale_ctrl.cpp rename to src/windows/agg/src/ctrl/agg_scale_ctrl.cpp diff --git a/desmume/src/windows/agg/src/ctrl/agg_slider_ctrl.cpp b/src/windows/agg/src/ctrl/agg_slider_ctrl.cpp similarity index 100% rename from desmume/src/windows/agg/src/ctrl/agg_slider_ctrl.cpp rename to src/windows/agg/src/ctrl/agg_slider_ctrl.cpp diff --git a/desmume/src/windows/agg/src/ctrl/agg_spline_ctrl.cpp b/src/windows/agg/src/ctrl/agg_spline_ctrl.cpp similarity index 100% rename from desmume/src/windows/agg/src/ctrl/agg_spline_ctrl.cpp rename to src/windows/agg/src/ctrl/agg_spline_ctrl.cpp diff --git a/desmume/src/windows/agg/src/install b/src/windows/agg/src/install similarity index 100% rename from desmume/src/windows/agg/src/install rename to src/windows/agg/src/install diff --git a/desmume/src/windows/agg/src/news b/src/windows/agg/src/news similarity index 100% rename from desmume/src/windows/agg/src/news rename to src/windows/agg/src/news diff --git a/desmume/src/windows/agg/src/platform/win32/agg_platform_support.cpp b/src/windows/agg/src/platform/win32/agg_platform_support.cpp similarity index 100% rename from desmume/src/windows/agg/src/platform/win32/agg_platform_support.cpp rename to src/windows/agg/src/platform/win32/agg_platform_support.cpp diff --git a/desmume/src/windows/agg/src/platform/win32/agg_win32_bmp.cpp b/src/windows/agg/src/platform/win32/agg_win32_bmp.cpp similarity index 100% rename from desmume/src/windows/agg/src/platform/win32/agg_win32_bmp.cpp rename to src/windows/agg/src/platform/win32/agg_win32_bmp.cpp diff --git a/desmume/src/windows/agg/src/readme b/src/windows/agg/src/readme similarity index 100% rename from desmume/src/windows/agg/src/readme rename to src/windows/agg/src/readme diff --git a/desmume/src/windows/aviout.cpp b/src/windows/aviout.cpp similarity index 96% rename from desmume/src/windows/aviout.cpp rename to src/windows/aviout.cpp index a6cb1f0e5..d369d4e99 100644 --- a/desmume/src/windows/aviout.cpp +++ b/src/windows/aviout.cpp @@ -1,484 +1,484 @@ -/* aviout.cpp - - Copyright (C) 2006-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "main.h" -#include "types.h" -#include "windriver.h" -#include "console.h" -#include "gfx3d.h" -#include "aviout.h" -#include "../GPU_osd.h" - -#include -#include -#include - -#include "debug.h" - -static void EMU_PrintError(const char* msg) { - LOG(msg); -} - -static void EMU_PrintMessage(const char* msg) { - LOG(msg); -} - -//extern PALETTEENTRY *color_palette; -//extern WAVEFORMATEX wf; -//extern int soundo; - -#define VIDEO_STREAM 0 -#define AUDIO_STREAM 1 - -#define VIDEO_WIDTH 256 - -static struct AVIFile -{ - int valid; - int fps; - int fps_scale; - - int video_added; - BITMAPINFOHEADER bitmap_format; - - int sound_added; - WAVEFORMATEX wave_format; - - AVISTREAMINFO avi_video_header; - AVISTREAMINFO avi_sound_header; - PAVIFILE avi_file; - PAVISTREAM streams[2]; - PAVISTREAM compressed_streams[2]; - - AVICOMPRESSOPTIONS compress_options[2]; - AVICOMPRESSOPTIONS* compress_options_ptr[2]; - - int video_frames; - int sound_samples; - - u8 convert_buffer[256*384*3]; - int start_scanline; - int end_scanline; - - long tBytes, ByteBuffer; - - u8 audio_buffer[44100*2*2]; // 1 second buffer - int audio_buffer_pos; -} *avi_file = NULL; - -struct VideoSystemInfo -{ - int start_scanline; - int end_scanline; - int fps; -}; - - -static char saved_cur_avi_fnameandext[MAX_PATH]; -static char saved_avi_fname[MAX_PATH]; -static char saved_avi_ext[MAX_PATH]; -static int avi_segnum=0; -//static FILE* avi_check_file=0; -static struct AVIFile saved_avi_info; -static int use_prev_options=0; -static bool use_sound=false; - - - -static bool truncate_existing(const char* filename) -{ - // this is only here because AVIFileOpen doesn't seem to do it for us - FILE* fd = fopen(filename, "wb"); - if(fd) - { - fclose(fd); - return 1; - } - - return 0; -} - -static int avi_audiosegment_size(struct AVIFile* avi_out) -{ - if(!avi_out || !avi_out->valid || !avi_out->sound_added) - return 0; - - assert(avi_out->wave_format.nAvgBytesPerSec <= sizeof(avi_out->audio_buffer)); - return avi_out->wave_format.nAvgBytesPerSec; -} - -static void avi_create(struct AVIFile** avi_out) -{ - *avi_out = (struct AVIFile*)malloc(sizeof(struct AVIFile)); - memset(*avi_out, 0, sizeof(struct AVIFile)); - AVIFileInit(); -} - -static void avi_destroy(struct AVIFile** avi_out) -{ - if(!(*avi_out)) - return; - - if((*avi_out)->sound_added) - { - if((*avi_out)->compressed_streams[AUDIO_STREAM]) - { - if ((*avi_out)->audio_buffer_pos > 0) { - if(FAILED(AVIStreamWrite(avi_file->compressed_streams[AUDIO_STREAM], - avi_file->sound_samples, (*avi_out)->audio_buffer_pos / (*avi_out)->wave_format.nBlockAlign, - (*avi_out)->audio_buffer, (*avi_out)->audio_buffer_pos, 0, NULL, &avi_file->ByteBuffer))) - { - avi_file->valid = 0; - } - (*avi_out)->sound_samples += (*avi_out)->audio_buffer_pos / (*avi_out)->wave_format.nBlockAlign; - (*avi_out)->tBytes += avi_file->ByteBuffer; - (*avi_out)->audio_buffer_pos = 0; - } - - LONG test = AVIStreamClose((*avi_out)->compressed_streams[AUDIO_STREAM]); - (*avi_out)->compressed_streams[AUDIO_STREAM] = NULL; - (*avi_out)->streams[AUDIO_STREAM] = NULL; // compressed_streams[AUDIO_STREAM] is just a copy of streams[AUDIO_STREAM] - } - } - - if((*avi_out)->video_added) - { - if((*avi_out)->compressed_streams[VIDEO_STREAM]) - { - AVIStreamClose((*avi_out)->compressed_streams[VIDEO_STREAM]); - (*avi_out)->compressed_streams[VIDEO_STREAM] = NULL; - } - - if((*avi_out)->streams[VIDEO_STREAM]) - { - AVIStreamClose((*avi_out)->streams[VIDEO_STREAM]); - (*avi_out)->streams[VIDEO_STREAM] = NULL; - } - } - - if((*avi_out)->avi_file) - { - AVIFileClose((*avi_out)->avi_file); - (*avi_out)->avi_file = NULL; - } - - free(*avi_out); - *avi_out = NULL; -} - -static void set_video_format(const BITMAPINFOHEADER* bitmap_format, struct AVIFile* avi_out) -{ - memcpy(&((*avi_out).bitmap_format), bitmap_format, sizeof(BITMAPINFOHEADER)); - (*avi_out).video_added = 1; -} - -static void set_sound_format(const WAVEFORMATEX* wave_format, struct AVIFile* avi_out) -{ - memcpy(&((*avi_out).wave_format), wave_format, sizeof(WAVEFORMATEX)); - (*avi_out).sound_added = 1; -} - -static int avi_open(const char* filename, const BITMAPINFOHEADER* pbmih, const WAVEFORMATEX* pwfex) -{ - int error = 1; - int result = 0; - - do - { - // close existing first - DRV_AviEnd(); - - if(!truncate_existing(filename)) - break; - - if(!pbmih) - break; - - // create the object - avi_create(&avi_file); - - // set video size and framerate - /*avi_file->start_scanline = vsi->start_scanline; - avi_file->end_scanline = vsi->end_scanline; - avi_file->fps = vsi->fps; - avi_file->fps_scale = 16777216-1; - avi_file->convert_buffer = new u8[256*384*3];*/ - - // open the file - if(FAILED(AVIFileOpen(&avi_file->avi_file, filename, OF_CREATE | OF_WRITE, NULL))) - break; - - // create the video stream - set_video_format(pbmih, avi_file); - - memset(&avi_file->avi_video_header, 0, sizeof(AVISTREAMINFO)); - avi_file->avi_video_header.fccType = streamtypeVIDEO; - avi_file->avi_video_header.dwScale = 6*355*263; - avi_file->avi_video_header.dwRate = 33513982; - avi_file->avi_video_header.dwSuggestedBufferSize = avi_file->bitmap_format.biSizeImage; - if(FAILED(AVIFileCreateStream(avi_file->avi_file, &avi_file->streams[VIDEO_STREAM], &avi_file->avi_video_header))) - break; - - if(use_prev_options) - { - avi_file->compress_options[VIDEO_STREAM] = saved_avi_info.compress_options[VIDEO_STREAM]; - avi_file->compress_options_ptr[VIDEO_STREAM] = &avi_file->compress_options[0]; - } - else - { - // get compression options - memset(&avi_file->compress_options[VIDEO_STREAM], 0, sizeof(AVICOMPRESSOPTIONS)); - avi_file->compress_options_ptr[VIDEO_STREAM] = &avi_file->compress_options[0]; -//retryAviSaveOptions: //mbg merge 7/17/06 removed - error = 0; - if(!AVISaveOptions(MainWindow->getHWnd(), 0, 1, &avi_file->streams[VIDEO_STREAM], &avi_file->compress_options_ptr[VIDEO_STREAM])) - break; - error = 1; - } - - // create compressed stream - if(FAILED(AVIMakeCompressedStream(&avi_file->compressed_streams[VIDEO_STREAM], avi_file->streams[VIDEO_STREAM], &avi_file->compress_options[VIDEO_STREAM], NULL))) - break; - - // set the stream format - if(FAILED(AVIStreamSetFormat(avi_file->compressed_streams[VIDEO_STREAM], 0, (void*)&avi_file->bitmap_format, avi_file->bitmap_format.biSize))) - break; - - // add sound (if requested) - if(pwfex) - { - // add audio format - set_sound_format(pwfex, avi_file); - - // create the audio stream - memset(&avi_file->avi_sound_header, 0, sizeof(AVISTREAMINFO)); - avi_file->avi_sound_header.fccType = streamtypeAUDIO; - avi_file->avi_sound_header.dwQuality = (DWORD)-1; - avi_file->avi_sound_header.dwScale = avi_file->wave_format.nBlockAlign; - avi_file->avi_sound_header.dwRate = avi_file->wave_format.nAvgBytesPerSec; - avi_file->avi_sound_header.dwSampleSize = avi_file->wave_format.nBlockAlign; - avi_file->avi_sound_header.dwInitialFrames = 1; - if(FAILED(AVIFileCreateStream(avi_file->avi_file, &avi_file->streams[AUDIO_STREAM], &avi_file->avi_sound_header))) - break; - - // AVISaveOptions doesn't seem to work for audio streams - // so here we just copy the pointer for the compressed stream - avi_file->compressed_streams[AUDIO_STREAM] = avi_file->streams[AUDIO_STREAM]; - - // set the stream format - if(FAILED(AVIStreamSetFormat(avi_file->compressed_streams[AUDIO_STREAM], 0, (void*)&avi_file->wave_format, sizeof(WAVEFORMATEX)))) - break; - } - - // initialize counters - avi_file->video_frames = 0; - avi_file->sound_samples = 0; - avi_file->tBytes = 0; - avi_file->ByteBuffer = 0; - avi_file->audio_buffer_pos = 0; - - // success - error = 0; - result = 1; - avi_file->valid = 1; - - } while(0); - - if(!result) - { - avi_destroy(&avi_file); - if(error) - EMU_PrintError("Error writing AVI file"); - } - - return result; -} - -//converts 16bpp to 24bpp and flips -static void do_video_conversion(const u16* buffer) -{ - u8* outbuf = avi_file->convert_buffer + 256*(384-1)*3; - - for(int y=0;y<384;y++) - { - for(int x=0;x<256;x++) - { - u16 col16 = *buffer++; - col16 &=0x7FFF; - u32 col24 = color_15bit_to_24bit[col16]; - *outbuf++ = (col24>>16)&0xFF; - *outbuf++ = (col24>>8)&0xFF; - *outbuf++ = col24&0xFF; - } - - outbuf -= 256*3*2; - } -} - - -static bool AviNextSegment() -{ - char avi_fname[MAX_PATH]; - strcpy(avi_fname,saved_avi_fname); - char avi_fname_temp[MAX_PATH]; - sprintf(avi_fname_temp, "%s_part%d%s", avi_fname, avi_segnum+2, saved_avi_ext); - saved_avi_info=*avi_file; - use_prev_options=1; - avi_segnum++; - bool ret = DRV_AviBegin(avi_fname_temp); - use_prev_options=0; - strcpy(saved_avi_fname,avi_fname); - return ret; -} - - -bool DRV_AviBegin(const char* fname) -{ - DRV_AviEnd(); - - BITMAPINFOHEADER bi; - memset(&bi, 0, sizeof(bi)); - bi.biSize = 0x28; - bi.biPlanes = 1; - bi.biBitCount = 24; - bi.biWidth = 256; - bi.biHeight = 384; - bi.biSizeImage = 3 * 256 * 384; - - WAVEFORMATEX wf; - wf.cbSize = sizeof(WAVEFORMATEX); - wf.nAvgBytesPerSec = 44100 * 4; - wf.nBlockAlign = 4; - wf.nChannels = 2; - wf.nSamplesPerSec = 44100; - wf.wBitsPerSample = 16; - wf.wFormatTag = WAVE_FORMAT_PCM; - - - saved_avi_ext[0]='\0'; - - //mbg 8/10/08 - decide whether there will be sound in this movie - //if this is a new movie.. - /*if(!avi_file) { - if(FSettings.SndRate) - use_sound = true; - else use_sound = false; - }*/ - - //mbg 8/10/08 - if there is no sound in this movie, then dont open the audio stream - WAVEFORMATEX* pwf = &wf; - //if(!use_sound) - // pwf = 0; - - - if(!avi_open(fname, &bi, pwf)) - { - saved_avi_fname[0]='\0'; - return 0; - } - - // Don't display at file splits - if(!avi_segnum) { - EMU_PrintMessage("AVI recording started."); - osd->addLine("AVI recording started."); - } - - strncpy(saved_cur_avi_fnameandext,fname,MAX_PATH); - strncpy(saved_avi_fname,fname,MAX_PATH); - char* dot = strrchr(saved_avi_fname, '.'); - if(dot && dot > strrchr(saved_avi_fname, '/') && dot > strrchr(saved_avi_fname, '\\')) - { - strcpy(saved_avi_ext,dot); - dot[0]='\0'; - } - return 1; -} - -void DRV_AviVideoUpdate(const u16* buffer) -{ - if(!avi_file || !avi_file->valid) - return; - - do_video_conversion(buffer); - - if(FAILED(AVIStreamWrite(avi_file->compressed_streams[VIDEO_STREAM], - avi_file->video_frames, 1, avi_file->convert_buffer, - avi_file->bitmap_format.biSizeImage, AVIIF_KEYFRAME, - NULL, &avi_file->ByteBuffer))) - { - avi_file->valid = 0; - return; - } - - avi_file->video_frames++; - avi_file->tBytes += avi_file->ByteBuffer; - - // segment / split AVI when it's almost 2 GB (2000MB, to be precise) - if(!(avi_file->video_frames % 60) && avi_file->tBytes > 2097152000) - AviNextSegment(); -} - -bool AVI_IsRecording() -{ - return avi_file && avi_file->valid; -} -void DRV_AviSoundUpdate(void* soundData, int soundLen) -{ - if(!AVI_IsRecording() || !avi_file->sound_added) - return; - - const int audioSegmentSize = avi_audiosegment_size(avi_file); - const int samplesPerSegment = audioSegmentSize / avi_file->wave_format.nBlockAlign; - const int soundSize = soundLen * avi_file->wave_format.nBlockAlign; - int nBytes = soundSize; - while (avi_file->audio_buffer_pos + nBytes > audioSegmentSize) { - const int bytesToTransfer = audioSegmentSize - avi_file->audio_buffer_pos; - memcpy(&avi_file->audio_buffer[avi_file->audio_buffer_pos], &((u8*)soundData)[soundSize - nBytes], bytesToTransfer); - nBytes -= bytesToTransfer; - - if(FAILED(AVIStreamWrite(avi_file->compressed_streams[AUDIO_STREAM], - avi_file->sound_samples, samplesPerSegment, - avi_file->audio_buffer, audioSegmentSize, 0, NULL, &avi_file->ByteBuffer))) - { - avi_file->valid = 0; - return; - } - avi_file->sound_samples += samplesPerSegment; - avi_file->tBytes += avi_file->ByteBuffer; - avi_file->audio_buffer_pos = 0; - } - memcpy(&avi_file->audio_buffer[avi_file->audio_buffer_pos], &((u8*)soundData)[soundSize - nBytes], nBytes); - avi_file->audio_buffer_pos += nBytes; -} - -void DRV_AviEnd() -{ - if(!avi_file) - return; - - // Don't display if we're just starting another segment - if(avi_file->tBytes <= 2097152000) { - EMU_PrintMessage("AVI recording ended."); - osd->addLine("AVI recording ended."); - } - - avi_destroy(&avi_file); -} +/* aviout.cpp + + Copyright (C) 2006-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "main.h" +#include "types.h" +#include "windriver.h" +#include "console.h" +#include "gfx3d.h" +#include "aviout.h" +#include "../GPU_osd.h" + +#include +#include +#include + +#include "debug.h" + +static void EMU_PrintError(const char* msg) { + LOG(msg); +} + +static void EMU_PrintMessage(const char* msg) { + LOG(msg); +} + +//extern PALETTEENTRY *color_palette; +//extern WAVEFORMATEX wf; +//extern int soundo; + +#define VIDEO_STREAM 0 +#define AUDIO_STREAM 1 + +#define VIDEO_WIDTH 256 + +static struct AVIFile +{ + int valid; + int fps; + int fps_scale; + + int video_added; + BITMAPINFOHEADER bitmap_format; + + int sound_added; + WAVEFORMATEX wave_format; + + AVISTREAMINFO avi_video_header; + AVISTREAMINFO avi_sound_header; + PAVIFILE avi_file; + PAVISTREAM streams[2]; + PAVISTREAM compressed_streams[2]; + + AVICOMPRESSOPTIONS compress_options[2]; + AVICOMPRESSOPTIONS* compress_options_ptr[2]; + + int video_frames; + int sound_samples; + + u8 convert_buffer[256*384*3]; + int start_scanline; + int end_scanline; + + long tBytes, ByteBuffer; + + u8 audio_buffer[44100*2*2]; // 1 second buffer + int audio_buffer_pos; +} *avi_file = NULL; + +struct VideoSystemInfo +{ + int start_scanline; + int end_scanline; + int fps; +}; + + +static char saved_cur_avi_fnameandext[MAX_PATH]; +static char saved_avi_fname[MAX_PATH]; +static char saved_avi_ext[MAX_PATH]; +static int avi_segnum=0; +//static FILE* avi_check_file=0; +static struct AVIFile saved_avi_info; +static int use_prev_options=0; +static bool use_sound=false; + + + +static bool truncate_existing(const char* filename) +{ + // this is only here because AVIFileOpen doesn't seem to do it for us + FILE* fd = fopen(filename, "wb"); + if(fd) + { + fclose(fd); + return 1; + } + + return 0; +} + +static int avi_audiosegment_size(struct AVIFile* avi_out) +{ + if(!avi_out || !avi_out->valid || !avi_out->sound_added) + return 0; + + assert(avi_out->wave_format.nAvgBytesPerSec <= sizeof(avi_out->audio_buffer)); + return avi_out->wave_format.nAvgBytesPerSec; +} + +static void avi_create(struct AVIFile** avi_out) +{ + *avi_out = (struct AVIFile*)malloc(sizeof(struct AVIFile)); + memset(*avi_out, 0, sizeof(struct AVIFile)); + AVIFileInit(); +} + +static void avi_destroy(struct AVIFile** avi_out) +{ + if(!(*avi_out)) + return; + + if((*avi_out)->sound_added) + { + if((*avi_out)->compressed_streams[AUDIO_STREAM]) + { + if ((*avi_out)->audio_buffer_pos > 0) { + if(FAILED(AVIStreamWrite(avi_file->compressed_streams[AUDIO_STREAM], + avi_file->sound_samples, (*avi_out)->audio_buffer_pos / (*avi_out)->wave_format.nBlockAlign, + (*avi_out)->audio_buffer, (*avi_out)->audio_buffer_pos, 0, NULL, &avi_file->ByteBuffer))) + { + avi_file->valid = 0; + } + (*avi_out)->sound_samples += (*avi_out)->audio_buffer_pos / (*avi_out)->wave_format.nBlockAlign; + (*avi_out)->tBytes += avi_file->ByteBuffer; + (*avi_out)->audio_buffer_pos = 0; + } + + LONG test = AVIStreamClose((*avi_out)->compressed_streams[AUDIO_STREAM]); + (*avi_out)->compressed_streams[AUDIO_STREAM] = NULL; + (*avi_out)->streams[AUDIO_STREAM] = NULL; // compressed_streams[AUDIO_STREAM] is just a copy of streams[AUDIO_STREAM] + } + } + + if((*avi_out)->video_added) + { + if((*avi_out)->compressed_streams[VIDEO_STREAM]) + { + AVIStreamClose((*avi_out)->compressed_streams[VIDEO_STREAM]); + (*avi_out)->compressed_streams[VIDEO_STREAM] = NULL; + } + + if((*avi_out)->streams[VIDEO_STREAM]) + { + AVIStreamClose((*avi_out)->streams[VIDEO_STREAM]); + (*avi_out)->streams[VIDEO_STREAM] = NULL; + } + } + + if((*avi_out)->avi_file) + { + AVIFileClose((*avi_out)->avi_file); + (*avi_out)->avi_file = NULL; + } + + free(*avi_out); + *avi_out = NULL; +} + +static void set_video_format(const BITMAPINFOHEADER* bitmap_format, struct AVIFile* avi_out) +{ + memcpy(&((*avi_out).bitmap_format), bitmap_format, sizeof(BITMAPINFOHEADER)); + (*avi_out).video_added = 1; +} + +static void set_sound_format(const WAVEFORMATEX* wave_format, struct AVIFile* avi_out) +{ + memcpy(&((*avi_out).wave_format), wave_format, sizeof(WAVEFORMATEX)); + (*avi_out).sound_added = 1; +} + +static int avi_open(const char* filename, const BITMAPINFOHEADER* pbmih, const WAVEFORMATEX* pwfex) +{ + int error = 1; + int result = 0; + + do + { + // close existing first + DRV_AviEnd(); + + if(!truncate_existing(filename)) + break; + + if(!pbmih) + break; + + // create the object + avi_create(&avi_file); + + // set video size and framerate + /*avi_file->start_scanline = vsi->start_scanline; + avi_file->end_scanline = vsi->end_scanline; + avi_file->fps = vsi->fps; + avi_file->fps_scale = 16777216-1; + avi_file->convert_buffer = new u8[256*384*3];*/ + + // open the file + if(FAILED(AVIFileOpen(&avi_file->avi_file, filename, OF_CREATE | OF_WRITE, NULL))) + break; + + // create the video stream + set_video_format(pbmih, avi_file); + + memset(&avi_file->avi_video_header, 0, sizeof(AVISTREAMINFO)); + avi_file->avi_video_header.fccType = streamtypeVIDEO; + avi_file->avi_video_header.dwScale = 6*355*263; + avi_file->avi_video_header.dwRate = 33513982; + avi_file->avi_video_header.dwSuggestedBufferSize = avi_file->bitmap_format.biSizeImage; + if(FAILED(AVIFileCreateStream(avi_file->avi_file, &avi_file->streams[VIDEO_STREAM], &avi_file->avi_video_header))) + break; + + if(use_prev_options) + { + avi_file->compress_options[VIDEO_STREAM] = saved_avi_info.compress_options[VIDEO_STREAM]; + avi_file->compress_options_ptr[VIDEO_STREAM] = &avi_file->compress_options[0]; + } + else + { + // get compression options + memset(&avi_file->compress_options[VIDEO_STREAM], 0, sizeof(AVICOMPRESSOPTIONS)); + avi_file->compress_options_ptr[VIDEO_STREAM] = &avi_file->compress_options[0]; +//retryAviSaveOptions: //mbg merge 7/17/06 removed + error = 0; + if(!AVISaveOptions(MainWindow->getHWnd(), 0, 1, &avi_file->streams[VIDEO_STREAM], &avi_file->compress_options_ptr[VIDEO_STREAM])) + break; + error = 1; + } + + // create compressed stream + if(FAILED(AVIMakeCompressedStream(&avi_file->compressed_streams[VIDEO_STREAM], avi_file->streams[VIDEO_STREAM], &avi_file->compress_options[VIDEO_STREAM], NULL))) + break; + + // set the stream format + if(FAILED(AVIStreamSetFormat(avi_file->compressed_streams[VIDEO_STREAM], 0, (void*)&avi_file->bitmap_format, avi_file->bitmap_format.biSize))) + break; + + // add sound (if requested) + if(pwfex) + { + // add audio format + set_sound_format(pwfex, avi_file); + + // create the audio stream + memset(&avi_file->avi_sound_header, 0, sizeof(AVISTREAMINFO)); + avi_file->avi_sound_header.fccType = streamtypeAUDIO; + avi_file->avi_sound_header.dwQuality = (DWORD)-1; + avi_file->avi_sound_header.dwScale = avi_file->wave_format.nBlockAlign; + avi_file->avi_sound_header.dwRate = avi_file->wave_format.nAvgBytesPerSec; + avi_file->avi_sound_header.dwSampleSize = avi_file->wave_format.nBlockAlign; + avi_file->avi_sound_header.dwInitialFrames = 1; + if(FAILED(AVIFileCreateStream(avi_file->avi_file, &avi_file->streams[AUDIO_STREAM], &avi_file->avi_sound_header))) + break; + + // AVISaveOptions doesn't seem to work for audio streams + // so here we just copy the pointer for the compressed stream + avi_file->compressed_streams[AUDIO_STREAM] = avi_file->streams[AUDIO_STREAM]; + + // set the stream format + if(FAILED(AVIStreamSetFormat(avi_file->compressed_streams[AUDIO_STREAM], 0, (void*)&avi_file->wave_format, sizeof(WAVEFORMATEX)))) + break; + } + + // initialize counters + avi_file->video_frames = 0; + avi_file->sound_samples = 0; + avi_file->tBytes = 0; + avi_file->ByteBuffer = 0; + avi_file->audio_buffer_pos = 0; + + // success + error = 0; + result = 1; + avi_file->valid = 1; + + } while(0); + + if(!result) + { + avi_destroy(&avi_file); + if(error) + EMU_PrintError("Error writing AVI file"); + } + + return result; +} + +//converts 16bpp to 24bpp and flips +static void do_video_conversion(const u16* buffer) +{ + u8* outbuf = avi_file->convert_buffer + 256*(384-1)*3; + + for(int y=0;y<384;y++) + { + for(int x=0;x<256;x++) + { + u16 col16 = *buffer++; + col16 &=0x7FFF; + u32 col24 = color_15bit_to_24bit[col16]; + *outbuf++ = (col24>>16)&0xFF; + *outbuf++ = (col24>>8)&0xFF; + *outbuf++ = col24&0xFF; + } + + outbuf -= 256*3*2; + } +} + + +static bool AviNextSegment() +{ + char avi_fname[MAX_PATH]; + strcpy(avi_fname,saved_avi_fname); + char avi_fname_temp[MAX_PATH]; + sprintf(avi_fname_temp, "%s_part%d%s", avi_fname, avi_segnum+2, saved_avi_ext); + saved_avi_info=*avi_file; + use_prev_options=1; + avi_segnum++; + bool ret = DRV_AviBegin(avi_fname_temp); + use_prev_options=0; + strcpy(saved_avi_fname,avi_fname); + return ret; +} + + +bool DRV_AviBegin(const char* fname) +{ + DRV_AviEnd(); + + BITMAPINFOHEADER bi; + memset(&bi, 0, sizeof(bi)); + bi.biSize = 0x28; + bi.biPlanes = 1; + bi.biBitCount = 24; + bi.biWidth = 256; + bi.biHeight = 384; + bi.biSizeImage = 3 * 256 * 384; + + WAVEFORMATEX wf; + wf.cbSize = sizeof(WAVEFORMATEX); + wf.nAvgBytesPerSec = 44100 * 4; + wf.nBlockAlign = 4; + wf.nChannels = 2; + wf.nSamplesPerSec = 44100; + wf.wBitsPerSample = 16; + wf.wFormatTag = WAVE_FORMAT_PCM; + + + saved_avi_ext[0]='\0'; + + //mbg 8/10/08 - decide whether there will be sound in this movie + //if this is a new movie.. + /*if(!avi_file) { + if(FSettings.SndRate) + use_sound = true; + else use_sound = false; + }*/ + + //mbg 8/10/08 - if there is no sound in this movie, then dont open the audio stream + WAVEFORMATEX* pwf = &wf; + //if(!use_sound) + // pwf = 0; + + + if(!avi_open(fname, &bi, pwf)) + { + saved_avi_fname[0]='\0'; + return 0; + } + + // Don't display at file splits + if(!avi_segnum) { + EMU_PrintMessage("AVI recording started."); + osd->addLine("AVI recording started."); + } + + strncpy(saved_cur_avi_fnameandext,fname,MAX_PATH); + strncpy(saved_avi_fname,fname,MAX_PATH); + char* dot = strrchr(saved_avi_fname, '.'); + if(dot && dot > strrchr(saved_avi_fname, '/') && dot > strrchr(saved_avi_fname, '\\')) + { + strcpy(saved_avi_ext,dot); + dot[0]='\0'; + } + return 1; +} + +void DRV_AviVideoUpdate(const u16* buffer) +{ + if(!avi_file || !avi_file->valid) + return; + + do_video_conversion(buffer); + + if(FAILED(AVIStreamWrite(avi_file->compressed_streams[VIDEO_STREAM], + avi_file->video_frames, 1, avi_file->convert_buffer, + avi_file->bitmap_format.biSizeImage, AVIIF_KEYFRAME, + NULL, &avi_file->ByteBuffer))) + { + avi_file->valid = 0; + return; + } + + avi_file->video_frames++; + avi_file->tBytes += avi_file->ByteBuffer; + + // segment / split AVI when it's almost 2 GB (2000MB, to be precise) + if(!(avi_file->video_frames % 60) && avi_file->tBytes > 2097152000) + AviNextSegment(); +} + +bool AVI_IsRecording() +{ + return avi_file && avi_file->valid; +} +void DRV_AviSoundUpdate(void* soundData, int soundLen) +{ + if(!AVI_IsRecording() || !avi_file->sound_added) + return; + + const int audioSegmentSize = avi_audiosegment_size(avi_file); + const int samplesPerSegment = audioSegmentSize / avi_file->wave_format.nBlockAlign; + const int soundSize = soundLen * avi_file->wave_format.nBlockAlign; + int nBytes = soundSize; + while (avi_file->audio_buffer_pos + nBytes > audioSegmentSize) { + const int bytesToTransfer = audioSegmentSize - avi_file->audio_buffer_pos; + memcpy(&avi_file->audio_buffer[avi_file->audio_buffer_pos], &((u8*)soundData)[soundSize - nBytes], bytesToTransfer); + nBytes -= bytesToTransfer; + + if(FAILED(AVIStreamWrite(avi_file->compressed_streams[AUDIO_STREAM], + avi_file->sound_samples, samplesPerSegment, + avi_file->audio_buffer, audioSegmentSize, 0, NULL, &avi_file->ByteBuffer))) + { + avi_file->valid = 0; + return; + } + avi_file->sound_samples += samplesPerSegment; + avi_file->tBytes += avi_file->ByteBuffer; + avi_file->audio_buffer_pos = 0; + } + memcpy(&avi_file->audio_buffer[avi_file->audio_buffer_pos], &((u8*)soundData)[soundSize - nBytes], nBytes); + avi_file->audio_buffer_pos += nBytes; +} + +void DRV_AviEnd() +{ + if(!avi_file) + return; + + // Don't display if we're just starting another segment + if(avi_file->tBytes <= 2097152000) { + EMU_PrintMessage("AVI recording ended."); + osd->addLine("AVI recording ended."); + } + + avi_destroy(&avi_file); +} diff --git a/desmume/src/windows/aviout.h b/src/windows/aviout.h similarity index 97% rename from desmume/src/windows/aviout.h rename to src/windows/aviout.h index 4f6d8a2be..225076e36 100644 --- a/desmume/src/windows/aviout.h +++ b/src/windows/aviout.h @@ -1,31 +1,31 @@ -/* aviout.h - - Copyright (C) 2006-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _AVIOUT_H_ -#define _AVIOUT_H_ - -bool DRV_AviBegin(const char* fname); -void DRV_AviEnd(); -void DRV_AviSoundUpdate(void* soundData, int soundLen); -bool AVI_IsRecording(); -void DRV_AviVideoUpdate(const u16* buffer); - -#endif +/* aviout.h + + Copyright (C) 2006-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _AVIOUT_H_ +#define _AVIOUT_H_ + +bool DRV_AviBegin(const char* fname); +void DRV_AviEnd(); +void DRV_AviSoundUpdate(void* soundData, int soundLen); +bool AVI_IsRecording(); +void DRV_AviVideoUpdate(const u16* buffer); + +#endif diff --git a/desmume/src/windows/bitmap1.bmp b/src/windows/bitmap1.bmp similarity index 100% rename from desmume/src/windows/bitmap1.bmp rename to src/windows/bitmap1.bmp diff --git a/desmume/src/windows/cheatsWin.cpp b/src/windows/cheatsWin.cpp similarity index 96% rename from desmume/src/windows/cheatsWin.cpp rename to src/windows/cheatsWin.cpp index 1d9a0466a..e564f9072 100644 --- a/desmume/src/windows/cheatsWin.cpp +++ b/src/windows/cheatsWin.cpp @@ -1,1272 +1,1272 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "cheatsWin.h" -#include -#include "../cheatSystem.h" -#include "resource.h" -#include "../debug.h" - -static u8 searchType = 0; -static u8 searchSize = 0; -static u8 searchSign = 0; -static u8 searchStep = 0; -static u8 searchComp = 0; -static HWND hBRestart = NULL; -static HWND hBView = NULL; -static HWND hBSearch = NULL; -static u32 exactVal = 0; -static u32 searchNumberResults = 0; - -static u32 searchAddAddress = 0; -static u32 searchAddValue = 0; -static u8 searchAddMode = 0; -static u8 searchAddFreeze = 1; -static u8 searchAddSize = 0; -static char editBuf[3][75] = { 0 }; -static u32 cheatEditPos = 0; -static u8 cheatXXtype = 0; -static u8 cheatXXaction = 0; - -static HWND searchWnd = NULL; -static HWND searchListView = NULL; -static HWND cheatListView = NULL; -static WNDPROC oldEditProc = NULL; -static WNDPROC oldEditProcHEX = NULL; - -CHEATS_LIST tempCheat; - -u32 searchIDDs[2][4] = { - { IDD_CHEAT_SEARCH_MAIN, IDD_CHEAT_SEARCH_EXACT, IDD_CHEAT_SEARCH_RESULT, NULL }, - { IDD_CHEAT_SEARCH_MAIN, IDD_CHEAT_SEARCH_RESULT, IDD_CHEAT_SEARCH_COMP, IDD_CHEAT_SEARCH_RESULT} -}; - -u32 searchSizeIDDs[4] = { IDC_RADIO1, IDC_RADIO2, IDC_RADIO3, IDC_RADIO4 }; -u32 searchSignIDDs[2] = { IDC_RADIO5, IDC_RADIO6 }; -u32 searchTypeIDDs[2] = { IDC_RADIO7, IDC_RADIO8 }; -u32 searchCompIDDs[4] = { IDC_RADIO1, IDC_RADIO2, IDC_RADIO3, IDC_RADIO4 }; - -u32 searchRangeIDDs[4] = { IDC_STATIC_S1, IDC_STATIC_S2, IDC_STATIC_S3, IDC_STATIC_S4 }; -char *searchRangeText[2][4] = { {"[0..255]", "[0..65536]", "[0..16777215]", "[0..4294967295]"}, - {"[-128..127]", "[-32168..32767]", "[-8388608..8388607]", "[-2147483648..2147483647]"}}; - -u32 searchRange[4][2] = { - { 0, 255 }, - { 0, 65536 }, - { 0, 16777215 }, - { 0, 4294967295 } - }; - -LRESULT CALLBACK EditValueProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - // TODO: check paste - if (msg == WM_CHAR) - { - switch (wParam) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - break; - case '-': - { - u8 pos = 0; - SendMessage(hwnd, EM_GETSEL, (WPARAM)&pos, NULL); - if (pos != 0) wParam = 0; - } - break; - - case VK_BACK: - break; - default: - wParam = 0; - break; - } - - } - - return CallWindowProc(oldEditProc, hwnd, msg, wParam, lParam); -} - -LRESULT CALLBACK EditValueHEXProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - // TODO: check paste - if (msg == WM_CHAR) - { - switch (wParam) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - break; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - wParam -= 32; - break; - case VK_BACK: - break; - default: - wParam = 0; - break; - } - - } - - return CallWindowProc(oldEditProcHEX, hwnd, msg, wParam, lParam); -} - -BOOL CALLBACK CheatsAddProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - static WNDPROC saveOldEditProc = NULL; - - switch(msg) - { - case WM_INITDIALOG: - { - saveOldEditProc = oldEditProc; - SendMessage(GetDlgItem(dialog, IDC_EDIT1), EM_SETLIMITTEXT, 6, 0); - SendMessage(GetDlgItem(dialog, IDC_EDIT2), EM_SETLIMITTEXT, 10, 0); - SendMessage(GetDlgItem(dialog, IDC_EDIT3), EM_SETLIMITTEXT, 75, 0); - oldEditProcHEX = (WNDPROC)SetWindowLongPtr(GetDlgItem(dialog, IDC_EDIT1), GWLP_WNDPROC, (LONG)EditValueHEXProc); - oldEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(dialog, IDC_EDIT2), GWLP_WNDPROC, (LONG)EditValueProc); - - if (searchAddMode == 1) - { - char buf[10]; - searchAddAddress &= 0x00FFFFFF; - wsprintf(buf, "%06X", searchAddAddress); - SetWindowText(GetDlgItem(dialog, IDC_EDIT1), buf); - wsprintf(buf, "%i", searchAddValue); - SetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf); - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - EnableWindow(GetDlgItem(dialog, IDC_EDIT1), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_RADIO1), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_RADIO2), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_RADIO3), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_RADIO4), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_RADIO8), FALSE); - } - else - { - SetWindowText(GetDlgItem(dialog, IDC_EDIT2), "0"); - CheckDlgButton(dialog, IDC_RADIO1, BST_CHECKED); - } - - memset(editBuf, 0, sizeof(editBuf)); - - GetWindowText(GetDlgItem(dialog, IDC_EDIT1), editBuf[0], 10); - GetWindowText(GetDlgItem(dialog, IDC_EDIT2), editBuf[1], 10); - - CheckDlgButton(dialog, IDC_CHECK1, BST_CHECKED); - CheckDlgButton(dialog, searchSizeIDDs[searchAddSize], BST_CHECKED); - } - return TRUE; - - case WM_COMMAND: - { - switch (LOWORD(wparam)) - { - case IDOK: - { - u32 tmp_addr = 0; - sscanf_s(editBuf[0], "%x", &tmp_addr); - - if (cheatsAdd(searchAddSize, tmp_addr, atol(editBuf[1]), editBuf[2], searchAddFreeze)) - { - if ((searchAddMode == 0) || (cheatsSave() && searchAddMode == 1)) - { - oldEditProc = saveOldEditProc; - searchAddAddress = tmp_addr; - searchAddValue = atol(editBuf[1]); - - EndDialog(dialog, TRUE); - } - } - } - return TRUE; - - case IDCANCEL: - oldEditProc = saveOldEditProc; - EndDialog(dialog, FALSE); - return TRUE; - - case IDC_EDIT1: // address - { - if (HIWORD(wparam) == EN_UPDATE) - { - GetWindowText(GetDlgItem(dialog, IDC_EDIT1), editBuf[0], 8); - if ( (strlen(editBuf[0]) < 6) || (!strlen(editBuf[1])) ) - { - EnableWindow(GetDlgItem(dialog, IDOK), FALSE); - return TRUE; - } - - u32 val = 0; - sscanf_s(editBuf[0], "%x", &val); - val &= 0x00FFFFFF; - if (val > 0x400000) - { - EnableWindow(GetDlgItem(dialog, IDOK), FALSE); - return TRUE; - } - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - } - return TRUE; - } - - case IDC_EDIT2: // value - { - if (HIWORD(wparam) == EN_UPDATE) - { - GetWindowText(GetDlgItem(dialog, IDC_EDIT2), editBuf[1], 10); - if ( (strlen(editBuf[0]) < 6) || (!strlen(editBuf[1])) ) - { - EnableWindow(GetDlgItem(dialog, IDOK), FALSE); - return TRUE; - } - - u32 val = atol(editBuf[1]); - if (val > searchRange[searchAddSize][1]) - { - EnableWindow(GetDlgItem(dialog, IDOK), FALSE); - return TRUE; - } - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - } - return TRUE; - } - - case IDC_EDIT3: // description - { - if (HIWORD(wparam) == EN_UPDATE) - GetWindowText(GetDlgItem(dialog, IDC_EDIT3), editBuf[2], 75); - return TRUE; - } - - case IDC_RADIO1: // 1 byte - searchAddSize = 0; - return TRUE; - case IDC_RADIO2: // 2 bytes - searchAddSize = 1; - return TRUE; - case IDC_RADIO3: // 3 bytes - searchAddSize = 2; - return TRUE; - case IDC_RADIO4: // 4 bytes - searchAddSize = 3; - return TRUE; - - case IDC_CHECK1: - { - if (IsDlgButtonChecked(dialog, IDC_CHECK1) == BST_CHECKED) - searchAddFreeze = 1; - else - searchAddFreeze = 0; - } - } - } - } - return FALSE; -} - -BOOL CALLBACK CheatsEditProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - static WNDPROC saveOldEditProc = NULL; - char buf[100] = {0}, buf2[100] = {0}; - - switch(msg) - { - case WM_INITDIALOG: - { - saveOldEditProc = oldEditProc; - SendMessage(GetDlgItem(dialog, IDC_EDIT1), EM_SETLIMITTEXT, 6, 0); - SendMessage(GetDlgItem(dialog, IDC_EDIT2), EM_SETLIMITTEXT, 10, 0); - SendMessage(GetDlgItem(dialog, IDC_EDIT3), EM_SETLIMITTEXT, 75, 0); - oldEditProcHEX = (WNDPROC)SetWindowLongPtr(GetDlgItem(dialog, IDC_EDIT1), GWLP_WNDPROC, (LONG)EditValueHEXProc); - oldEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(dialog, IDC_EDIT2), GWLP_WNDPROC, (LONG)EditValueProc); - - cheatsGet(&tempCheat, cheatEditPos); - - memset(buf, 0, 100); - memset(buf2, 0, 100); - tempCheat.hi[0] &= 0x00FFFFFF; - wsprintf(buf, "%06X", tempCheat.hi[0]); - SetWindowText(GetDlgItem(dialog, IDC_EDIT1), buf); - wsprintf(buf, "%i", tempCheat.lo[0]); - SetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf); - strcpy(buf, tempCheat.description); - SetWindowText(GetDlgItem(dialog, IDC_EDIT3), buf); - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - - CheckDlgButton(dialog, IDC_CHECK1, tempCheat.enabled?BST_CHECKED:BST_UNCHECKED); - CheckDlgButton(dialog, searchSizeIDDs[tempCheat.size], BST_CHECKED); - SetWindowText(GetDlgItem(dialog, IDOK), "Update"); - } - return TRUE; - - case WM_COMMAND: - { - switch (LOWORD(wparam)) - { - case IDOK: - { - if (cheatsUpdate(tempCheat.size, tempCheat.hi[0], tempCheat.lo[0], tempCheat.description, tempCheat.enabled, cheatEditPos)) - { - oldEditProc = saveOldEditProc; - EndDialog(dialog, TRUE); - } - } - return TRUE; - - case IDCANCEL: - oldEditProc = saveOldEditProc; - EndDialog(dialog, FALSE); - return TRUE; - - case IDC_EDIT1: // address - { - if (HIWORD(wparam) == EN_UPDATE) - { - GetWindowText(GetDlgItem(dialog, IDC_EDIT1), buf, 8); - GetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf2, 10); - if ( (strlen(buf) < 6) || (!strlen(buf2)) ) - { - EnableWindow(GetDlgItem(dialog, IDOK), FALSE); - return TRUE; - } - - u32 val = 0; - sscanf_s(buf, "%x", &val); - val &= 0x00FFFFFF; - if (val > 0x400000) - { - EnableWindow(GetDlgItem(dialog, IDOK), FALSE); - return TRUE; - } - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - tempCheat.hi[0] = val; - } - return TRUE; - } - - case IDC_EDIT2: // value - { - if (HIWORD(wparam) == EN_UPDATE) - { - GetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf, 10); - GetWindowText(GetDlgItem(dialog, IDC_EDIT1), buf2, 8); - if ( (strlen(buf2) < 6) || (!strlen(buf)) ) - { - EnableWindow(GetDlgItem(dialog, IDOK), FALSE); - return TRUE; - } - - u32 val = atol(buf); - if (val > searchRange[tempCheat.size][1]) - { - EnableWindow(GetDlgItem(dialog, IDOK), FALSE); - return TRUE; - } - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - tempCheat.lo[0] = val; - } - return TRUE; - } - - case IDC_EDIT3: // description - { - if (HIWORD(wparam) == EN_UPDATE) - GetWindowText(GetDlgItem(dialog, IDC_EDIT3), tempCheat.description, 75); - return TRUE; - } - - case IDC_RADIO1: // 1 byte - tempCheat.size = 0; - return TRUE; - case IDC_RADIO2: // 2 bytes - tempCheat.size = 1; - return TRUE; - case IDC_RADIO3: // 3 bytes - tempCheat.size = 2; - return TRUE; - case IDC_RADIO4: // 4 bytes - tempCheat.size = 3; - return TRUE; - - case IDC_CHECK1: // freeze - { - if (IsDlgButtonChecked(dialog, IDC_CHECK1) == BST_CHECKED) - tempCheat.enabled = 1; - else - tempCheat.enabled = 0; - } - } - } - } - return FALSE; -} -//============================================================================== Action Replay -BOOL CALLBACK CheatsAdd_XX_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - SendMessage(GetDlgItem(dialog, IDC_EDIT2), EM_FMTLINES, (WPARAM)TRUE, (LPARAM)0); - - if (cheatXXtype == 0) - { - if (cheatXXaction == 0) // add - { - SetWindowText(dialog, "Add Action Replay code"); - tempCheat.enabled = TRUE; - } - else // edit - { - SetWindowText(dialog, "Edit Action Replay code"); - } - } - else - { - if (cheatXXaction == 0) // add - { - SetWindowText(dialog, "Add Codebreaker code"); - tempCheat.enabled = TRUE; - } - else // edit - { - SetWindowText(dialog, "Edit Codebreaker code"); - } - } - - if (cheatXXaction != 0) - { - char buf[sizeof(tempCheat.hi)+sizeof(tempCheat.lo)] = { 0 }; - memset(buf, 0, sizeof(buf)); - - cheatGetXXcodeString(tempCheat, buf); - SetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf); - SetWindowText(GetDlgItem(dialog, IDC_EDIT3), tempCheat.description); - - EnableWindow(GetDlgItem(dialog, IDOK), (strlen(buf) > 16)?TRUE:FALSE); - SetWindowText(GetDlgItem(dialog, IDOK), "Update"); - } - CheckDlgButton(dialog, IDC_CHECK1, tempCheat.enabled?BST_CHECKED:BST_UNCHECKED); - - SendMessage(GetDlgItem(dialog, IDC_EDIT2), EM_SETLIMITTEXT, sizeof(tempCheat.hi)+sizeof(tempCheat.lo), 0); - SendMessage(GetDlgItem(dialog, IDC_EDIT3), EM_SETLIMITTEXT, sizeof(tempCheat.description), 0); - } - return TRUE; - - case WM_COMMAND: - { - switch (LOWORD(wparam)) - { - case IDOK: - { - char buf[sizeof(tempCheat.hi)+sizeof(tempCheat.lo)] = { 0 }; - - memset(buf, 0, sizeof(buf)); - GetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf, sizeof(buf)); - - if (cheatXXtype == 0) // Action Replay - { - if (cheatXXaction == 0) // add - { - if (!cheatsAdd_AR(buf, tempCheat.description, tempCheat.enabled)) - { - MessageBox(dialog, "Syntax error in Action Replay code.\nTry again", "DeSmuME", - MB_OK | MB_ICONERROR); - return FALSE; - } - } - else // edit - { - if (!cheatsUpdate_AR(buf, tempCheat.description, tempCheat.enabled, cheatEditPos)) - { - MessageBox(dialog, "Syntax error in Action Replay code.\nTry again", "DeSmuME", - MB_OK | MB_ICONERROR); - return FALSE; - } - } - } - else - { - if (cheatXXaction == 0) // add - { - if (!cheatsAdd_CB(buf, tempCheat.description, tempCheat.enabled)) - { - MessageBox(dialog, "Syntax error in Codebreaker code.\nTry again", "DeSmuME", - MB_OK | MB_ICONERROR); - return FALSE; - } - } - else // edit - { - if (!cheatsUpdate_CB(buf, tempCheat.description, tempCheat.enabled, cheatEditPos)) - { - MessageBox(dialog, "Syntax error in Codebreaker code.\nTry again", "DeSmuME", - MB_OK | MB_ICONERROR); - return FALSE; - } - } - } - EndDialog(dialog, TRUE); - } - return TRUE; - - case IDCANCEL: - EndDialog(dialog, FALSE); - return TRUE; - - case IDC_EDIT2: // code - if (HIWORD(wparam) == EN_UPDATE) - { - char buf[sizeof(tempCheat.hi)+sizeof(tempCheat.lo)] = { 0 }; - - memset(buf, 0, sizeof(buf)); - GetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf, sizeof(buf)); - if (strlen(buf) < 17) // min size of code "CXXXXXXX YYYYYYYY" - { - EnableWindow(GetDlgItem(dialog, IDOK), FALSE); - return TRUE; - } - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - } - return TRUE; - - case IDC_EDIT3: // description - if (HIWORD(wparam) == EN_UPDATE) - { - memset(tempCheat.description, 0, sizeof(tempCheat.description)); - GetWindowText(GetDlgItem(dialog, IDC_EDIT3), tempCheat.description, sizeof(tempCheat.description)); - } - return TRUE; - - case IDC_CHECK1: - if (IsDlgButtonChecked(dialog, IDC_CHECK1) == BST_CHECKED) - tempCheat.enabled = 1; - else - tempCheat.enabled = 0; - return TRUE; - } - } - } - return FALSE; -} -//============================================================================== -BOOL CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - LV_COLUMN lvColumn; - u32 address = 0; - u32 val = 0; - - cheatListView = GetDlgItem(dialog, IDC_LIST1); - - ListView_SetExtendedListViewStyle(cheatListView, LVS_EX_FULLROWSELECT | LVS_EX_TWOCLICKACTIVATE); - - memset(&lvColumn,0,sizeof(LV_COLUMN)); - lvColumn.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT; - - lvColumn.fmt=LVCFMT_CENTER; - lvColumn.cx=20; - lvColumn.pszText="X"; - ListView_InsertColumn(cheatListView, 0, &lvColumn); - - lvColumn.fmt=LVCFMT_LEFT; - lvColumn.cx=84; - lvColumn.pszText="Address"; - ListView_InsertColumn(cheatListView, 1, &lvColumn); - lvColumn.cx=100; - lvColumn.pszText="Value"; - ListView_InsertColumn(cheatListView, 2, &lvColumn); - lvColumn.cx=245; - lvColumn.pszText="Description"; - ListView_InsertColumn(cheatListView, 3, &lvColumn); - lvColumn.fmt=LVCFMT_CENTER; - - LVITEM lvi; - memset(&lvi,0,sizeof(LVITEM)); - lvi.mask = LVIF_TEXT|LVIF_STATE; - lvi.iItem = INT_MAX; - - cheatsGetListReset(); - SendMessage(cheatListView, WM_SETREDRAW, (WPARAM)FALSE,0); - while (cheatsGetList(&tempCheat)) - { - char buf[256]; - if (tempCheat.enabled) - lvi.pszText= "X"; - else - lvi.pszText= ""; - switch (tempCheat.type) - { - case 0: // Internal - { - u32 row = ListView_InsertItem(cheatListView, &lvi); - wsprintf(buf, "0x02%06X", tempCheat.hi[0]); - ListView_SetItemText(cheatListView, row, 1, buf); - ltoa(tempCheat.lo[0], buf, 10); - ListView_SetItemText(cheatListView, row, 2, buf); - ListView_SetItemText(cheatListView, row, 3, tempCheat.description); - break; - } - - case 1: // Action Replay - { - u32 row = ListView_InsertItem(cheatListView, &lvi); - ListView_SetItemText(cheatListView, row, 1, "Action"); - ListView_SetItemText(cheatListView, row, 2, "Replay"); - ListView_SetItemText(cheatListView, row, 3, tempCheat.description); - break; - } - - case 2: // Codebreaker - { - u32 row = ListView_InsertItem(cheatListView, &lvi); - ListView_SetItemText(cheatListView, row, 1, "Code"); - ListView_SetItemText(cheatListView, row, 2, "breaker"); - ListView_SetItemText(cheatListView, row, 3, tempCheat.description); - break; - } - } - } - SendMessage(cheatListView, WM_SETREDRAW, (WPARAM)TRUE,0); - - ListView_SetItemState(searchListView,0, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); - SetFocus(searchListView); - return TRUE; - } - - case WM_NOTIFY: - if (wparam == IDC_LIST1) - { - LPNMHDR tmp_msg = (LPNMHDR)lparam; - if ( tmp_msg->code == LVN_ITEMACTIVATE ) - { - cheatEditPos = ListView_GetNextItem(cheatListView, -1, LVNI_SELECTED|LVNI_FOCUSED); - cheatsGet(&tempCheat, cheatEditPos); - tempCheat.enabled = !tempCheat.enabled; - switch (tempCheat.type) - { - case 0: // internal - cheatsUpdate(tempCheat.size, tempCheat.hi[0], tempCheat.lo[0], tempCheat.description, tempCheat.enabled, cheatEditPos); - break; - - case 1: // Action Replay - cheatsUpdate_AR(NULL, NULL, tempCheat.enabled, cheatEditPos); - break; - - case 2: // Codebreaker - cheatsUpdate_CB(NULL, NULL, tempCheat.enabled, cheatEditPos); - break; - } - - - if (tempCheat.enabled) - ListView_SetItemText(cheatListView, cheatEditPos, 0, "X") - else - ListView_SetItemText(cheatListView, cheatEditPos, 0, ""); - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - } - - if ( tmp_msg->code == NM_CLICK ) - { - if (ListView_GetNextItem(cheatListView, -1, LVNI_SELECTED|LVNI_FOCUSED) != -1) - { - EnableWindow(GetDlgItem(dialog, IDC_BEDIT), TRUE); - EnableWindow(GetDlgItem(dialog, IDC_BREMOVE), TRUE); - } - else - { - EnableWindow(GetDlgItem(dialog, IDC_BEDIT), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_BREMOVE), FALSE); - } - } - - return TRUE; - } - return FALSE; - - case WM_COMMAND: - { - switch (LOWORD(wparam)) - { - case IDOK: - if (cheatsSave()) - { - EndDialog(dialog, TRUE); - } - else - MessageBox(dialog, "Can't save cheats to file","Error",MB_OK); - return TRUE; - case IDCANCEL: - EndDialog(dialog, FALSE); - return TRUE; - - case IDC_BADD: - { - searchAddAddress = 0;; - searchAddValue = 0; - searchAddMode = 0; - searchAddFreeze = 1; - if (DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_ADD), dialog, (DLGPROC) CheatsAddProc)) - { - LVITEM lvi; - char buf[256]; - - memset(&lvi,0,sizeof(LVITEM)); - lvi.mask = LVIF_TEXT|LVIF_STATE; - lvi.iItem = INT_MAX; - - if (searchAddFreeze) - lvi.pszText= "X"; - else - lvi.pszText= " "; - u32 row = ListView_InsertItem(cheatListView, &lvi); - wsprintf(buf, "0x02%06X", searchAddAddress); - ListView_SetItemText(cheatListView, row, 1, buf); - ltoa(searchAddValue, buf, 10); - ListView_SetItemText(cheatListView, row, 2, buf); - ListView_SetItemText(cheatListView, row, 3, editBuf[2]); - - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - } - } - return TRUE; - - case IDC_BADD_AR: - { - if (LOWORD(wparam) == IDC_BADD_AR) - { - cheatXXtype = 0; - } - else - if (LOWORD(wparam) == IDC_BADD_CB) - { - cheatXXtype = 1; - } - else - return TRUE; - cheatXXaction = 0; // 0 = add - - if (DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_ADD_XX_CODE), dialog, (DLGPROC) CheatsAdd_XX_Proc)) - { - LVITEM lvi; - - memset(&lvi,0,sizeof(LVITEM)); - lvi.mask = LVIF_TEXT|LVIF_STATE; - lvi.iItem = INT_MAX; - - if (tempCheat.enabled) - lvi.pszText= "X"; - else - lvi.pszText= " "; - u32 row = ListView_InsertItem(cheatListView, &lvi); - if (cheatXXtype == 0) - { - ListView_SetItemText(cheatListView, row, 1, "Action"); - ListView_SetItemText(cheatListView, row, 2, "Replay"); - } - else - { - ListView_SetItemText(cheatListView, row, 1, "Code"); - ListView_SetItemText(cheatListView, row, 2, "breaker"); - } - ListView_SetItemText(cheatListView, row, 3, tempCheat.description); - - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - } - } - return TRUE; - - case IDC_BEDIT: - { - cheatEditPos = ListView_GetNextItem(cheatListView, -1, LVNI_SELECTED|LVNI_FOCUSED); - if (cheatEditPos > cheatsGetSize()) return TRUE; - - cheatsGet(&tempCheat, cheatEditPos); - - switch (tempCheat.type) - { - case 0: // internal - if (DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_ADD), dialog, (DLGPROC) CheatsEditProc)) - { - char buf[256]; - cheatsGet(&tempCheat, cheatEditPos); - if (tempCheat.enabled) - ListView_SetItemText(cheatListView, cheatEditPos, 0, "X"); - wsprintf(buf, "0x02%06X", tempCheat.hi[0]); - ListView_SetItemText(cheatListView, cheatEditPos, 1, buf); - ltoa(tempCheat.lo[0], buf, 10); - ListView_SetItemText(cheatListView, cheatEditPos, 2, buf); - ListView_SetItemText(cheatListView, cheatEditPos, 3, tempCheat.description); - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - } - break; - - case 1: // Action replay - case 2: // Codebreaker - if (tempCheat.type == 1) - cheatXXtype = 0; - else - cheatXXtype = 1; - cheatXXaction = 1; // 1 = edit - - if (DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_ADD_XX_CODE), dialog, (DLGPROC) CheatsAdd_XX_Proc)) - { - cheatsGet(&tempCheat, cheatEditPos); - if (tempCheat.enabled) - ListView_SetItemText(cheatListView, cheatEditPos, 0, "X"); - - if (cheatXXtype == 0) - { - ListView_SetItemText(cheatListView, cheatEditPos, 1, "Action"); - ListView_SetItemText(cheatListView, cheatEditPos, 2, "Replay"); - } - else - { - ListView_SetItemText(cheatListView, cheatEditPos, 1, "Code"); - ListView_SetItemText(cheatListView, cheatEditPos, 2, "breaker"); - } - - ListView_SetItemText(cheatListView, cheatEditPos, 3, tempCheat.description); - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - } - break; - } - } - return TRUE; - - case IDC_BREMOVE: - { - int tmp_pos = ListView_GetNextItem(cheatListView, -1, LVNI_SELECTED|LVNI_FOCUSED); - if (tmp_pos != -1) - { - if (cheatsRemove(tmp_pos)) - { - ListView_DeleteItem(cheatListView, tmp_pos); - EnableWindow(GetDlgItem(dialog, IDOK), TRUE); - } - } - - } - return TRUE; - } - break; - } - } - return FALSE; -} - -void CheatsListDialog(HWND hwnd) -{ - if (!cheatsPush()) return; - memset(&tempCheat, 0, sizeof(CHEATS_LIST)); - u32 res=DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_LIST), hwnd, (DLGPROC) CheatsListBox_Proc); - if (res) - { - cheatsSave(); - cheatsStackClear(); - } - else - { - cheatsPop(); - } -} - - -// ================================================================================== Search -BOOL CALLBACK CheatsSearchExactWnd(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - EnableWindow(hBRestart, TRUE); - if (searchNumberResults) - EnableWindow(hBView, TRUE); - else - EnableWindow(hBView, FALSE); - EnableWindow(hBSearch, FALSE); - - SendMessage(GetDlgItem(dialog, IDC_EVALUE), EM_SETLIMITTEXT, 10, 0); - SetWindowText(GetDlgItem(dialog, IDC_STATIC_RANGE), searchRangeText[searchSign][searchSize]); - oldEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(dialog, IDC_EVALUE), GWLP_WNDPROC, (LONG)EditValueProc); - char buf[256]; - memset(buf, 0, 256); - ltoa(searchNumberResults, buf, 10); - SetWindowText(GetDlgItem(dialog, IDC_SNUMBER), buf); - SetFocus(GetDlgItem(dialog, IDC_EVALUE)); - break; - } - - case WM_COMMAND: - { - switch (LOWORD(wparam)) - { - case IDC_EVALUE: - { - if (HIWORD(wparam) == EN_UPDATE) - { - char buf[10]; - GetWindowText(GetDlgItem(dialog, IDC_EVALUE), buf, 10); - if (!strlen(buf)) - { - EnableWindow(hBSearch, FALSE); - return TRUE; - } - - u32 val = atol(buf); - if (val > searchRange[searchSize][1]) - { - EnableWindow(hBSearch, FALSE); - return TRUE; - } - EnableWindow(hBSearch, TRUE); - exactVal = val; - } - return TRUE; - } - } - break; - } - } - return FALSE; -} - -BOOL CALLBACK CheatsSearchCompWnd(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - EnableWindow(hBRestart, TRUE); - if (searchNumberResults) - EnableWindow(hBView, TRUE); - else - EnableWindow(hBView, FALSE); - EnableWindow(hBSearch, TRUE); - - CheckDlgButton(dialog, searchCompIDDs[searchComp], BST_CHECKED); - - char buf[256]; - ltoa(searchNumberResults, buf, 10); - SetWindowText(GetDlgItem(dialog, IDC_SNUMBER), buf); - break; - } - - case WM_COMMAND: - { - switch (LOWORD(wparam)) - { - case IDC_RADIO1: searchComp = 0; break; - case IDC_RADIO2: searchComp = 1; break; - case IDC_RADIO3: searchComp = 2; break; - case IDC_RADIO4: searchComp = 3; break; - } - break; - } - } - return FALSE; -} - -BOOL CALLBACK CheatsSearchResultWnd(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - EnableWindow(hBRestart, TRUE); - if (searchNumberResults) - EnableWindow(hBView, TRUE); - else - EnableWindow(hBView, FALSE); - EnableWindow(hBSearch, FALSE); - char buf[256]; - ltoa(searchNumberResults, buf, 10); - SetWindowText(GetDlgItem(dialog, IDC_SNUMBER), buf); - return TRUE; - } - } - return FALSE; -} - -BOOL CALLBACK CheatsSearchViewWnd(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - LV_COLUMN lvColumn; - u32 address = 0; - u32 val = 0; - - searchListView = GetDlgItem(dialog, IDC_LIST); - - ListView_SetExtendedListViewStyle(searchListView, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); - - memset(&lvColumn,0,sizeof(LV_COLUMN)); - lvColumn.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT; - lvColumn.fmt=LVCFMT_LEFT; - lvColumn.cx=94; - lvColumn.pszText="Address"; - ListView_InsertColumn(searchListView, 0, &lvColumn); - lvColumn.cx=130; - lvColumn.pszText="Value"; - ListView_InsertColumn(searchListView, 1, &lvColumn); - - LVITEM lvi; - memset(&lvi,0,sizeof(LVITEM)); - lvi.mask = LVIF_TEXT|LVIF_STATE; - lvi.iItem = INT_MAX; - - cheatSearchGetListReset(); - SendMessage(searchListView, WM_SETREDRAW, (WPARAM)FALSE,0); - while (cheatSearchGetList(&address, &val)) - { - char buf[256]; - wsprintf(buf, "0x02%06X", address); - lvi.pszText= buf; - u32 row = SendMessage(searchListView, LVM_INSERTITEM, 0, (LPARAM)&lvi); - _ltoa(val, buf, 10); - ListView_SetItemText(searchListView, row, 1, buf); - } - SendMessage(searchListView, WM_SETREDRAW, (WPARAM)TRUE,0); - ListView_SetItemState(searchListView,0, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); - SetFocus(searchListView); - } - return TRUE; - - case WM_COMMAND: - { - switch (LOWORD(wparam)) - { - case IDCANCEL: - ListView_DeleteAllItems(searchListView); - EndDialog(dialog, FALSE); - return TRUE; - case IDC_BADD: - { - u32 val = 0; - char buf[12]; - u32 pos = ListView_GetNextItem(searchListView, -1, LVNI_SELECTED|LVNI_FOCUSED); - ListView_GetItemText(searchListView, pos, 0, buf, 12); - sscanf_s(buf, "%x", &val); - searchAddAddress = val & 0x00FFFFFF; - ListView_GetItemText(searchListView, pos, 1, buf, 12); - searchAddValue = atol(buf); - searchAddMode = 1; - searchAddSize = searchSize; - DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_ADD), dialog, (DLGPROC) CheatsAddProc); - } - return TRUE; - } - } - } - return FALSE; -} - -BOOL CALLBACK CheatsSearchMainWnd(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - CheckDlgButton(dialog, searchSizeIDDs[searchSize], BST_CHECKED); - CheckDlgButton(dialog, searchSignIDDs[searchSign], BST_CHECKED); - CheckDlgButton(dialog, searchTypeIDDs[searchType], BST_CHECKED); - for (int i = 0; i < 4; i++) - SetWindowText(GetDlgItem(dialog, searchRangeIDDs[i]), searchRangeText[searchSign][i]); - EnableWindow(hBRestart, FALSE); - EnableWindow(hBView, FALSE); - EnableWindow(hBSearch, TRUE); - break; - } - - case WM_COMMAND: - { - switch (LOWORD(wparam)) - { - case IDC_RADIO1: // 1 byte - searchSize = 0; - return TRUE; - case IDC_RADIO2: // 2 bytes - searchSize = 1; - return TRUE; - case IDC_RADIO3: // 3 bytes - searchSize = 2; - return TRUE; - case IDC_RADIO4: // 4 bytes - searchSize = 3; - return TRUE; - - case IDC_RADIO5: // unsigned - searchSign = 0; - for (int i = 0; i < 4; i++) - SetWindowText(GetDlgItem(dialog, searchRangeIDDs[i]), searchRangeText[searchSign][i]); - return TRUE; - - case IDC_RADIO6: //signed - searchSign = 1; - for (int i = 0; i < 4; i++) - SetWindowText(GetDlgItem(dialog, searchRangeIDDs[i]), searchRangeText[searchSign][i]); - return TRUE; - - case IDC_RADIO7: // exact value search - searchType = 0; - return TRUE; - - case IDC_RADIO8: // comparative search - searchType = 1; - return TRUE; - } - return TRUE; - } - } - return FALSE; -} - -DLGPROC CheatsSearchSubWnds[2][4] = { - { CheatsSearchMainWnd, CheatsSearchExactWnd, CheatsSearchResultWnd, NULL }, - { CheatsSearchMainWnd, CheatsSearchResultWnd, CheatsSearchCompWnd, CheatsSearchResultWnd } -}; - -//============================================================================== -BOOL CALLBACK CheatsSearchProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - hBRestart = GetDlgItem(dialog, IDC_BRESTART); - hBView = GetDlgItem(dialog, IDC_BVIEW); - hBSearch = GetDlgItem(dialog, IDC_BSEARCH); - - searchWnd=CreateDialog(hAppInst, MAKEINTRESOURCE(searchIDDs[searchType][searchStep]), - dialog, (DLGPROC)CheatsSearchSubWnds[searchType][searchStep]); - return TRUE; - } - - case WM_COMMAND: - { - switch (LOWORD(wparam)) - { - case IDOK: - case IDCANCEL: - if (searchWnd) DestroyWindow(searchWnd); - EndDialog(dialog, FALSE); - return TRUE; - - case IDC_BVIEW: - DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_SEARCH_VIEW), dialog, (DLGPROC)CheatsSearchViewWnd); - return TRUE; - - case IDC_BSEARCH: - if (searchStep == 0) - cheatsSearchInit(searchType, searchSize, searchSign); - if (searchType == 0) - { - if (searchStep == 1) - searchNumberResults = cheatsSearchValue(exactVal); - } - else - { - if (searchStep == 2) - searchNumberResults = cheatsSearchComp(searchComp); - } - - searchStep++; - if (searchWnd) DestroyWindow(searchWnd); - searchWnd=CreateDialog(hAppInst, MAKEINTRESOURCE(searchIDDs[searchType][searchStep]), - dialog, (DLGPROC)CheatsSearchSubWnds[searchType][searchStep]); - if (searchType == 0) - { - if (searchStep == 2) searchStep = 1; - } - else - { - if (searchStep == 1) searchStep = 2; - if (searchStep == 3) searchStep = 2; - } - return TRUE; - - case IDC_BRESTART: - cheatsSearchClose(); - searchStep = 0; - searchNumberResults = 0; - if (searchWnd) DestroyWindow(searchWnd); - searchWnd=CreateDialog(hAppInst, MAKEINTRESOURCE(searchIDDs[searchType][searchStep]), - dialog, (DLGPROC)CheatsSearchSubWnds[searchType][searchStep]); - return TRUE; - } - break; - } - } - return FALSE; -} - -void CheatsSearchDialog(HWND hwnd) -{ - DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_SEARCH), hwnd, (DLGPROC) CheatsSearchProc); -} - -void CheatsSearchReset() -{ - searchType = 0; - searchSize = 0; - searchSign = 0; - searchStep = 0; - searchComp = 0; - searchAddSize = 0; - exactVal = 0; - searchNumberResults = 0; -} +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright 2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "cheatsWin.h" +#include +#include "../cheatSystem.h" +#include "resource.h" +#include "../debug.h" + +static u8 searchType = 0; +static u8 searchSize = 0; +static u8 searchSign = 0; +static u8 searchStep = 0; +static u8 searchComp = 0; +static HWND hBRestart = NULL; +static HWND hBView = NULL; +static HWND hBSearch = NULL; +static u32 exactVal = 0; +static u32 searchNumberResults = 0; + +static u32 searchAddAddress = 0; +static u32 searchAddValue = 0; +static u8 searchAddMode = 0; +static u8 searchAddFreeze = 1; +static u8 searchAddSize = 0; +static char editBuf[3][75] = { 0 }; +static u32 cheatEditPos = 0; +static u8 cheatXXtype = 0; +static u8 cheatXXaction = 0; + +static HWND searchWnd = NULL; +static HWND searchListView = NULL; +static HWND cheatListView = NULL; +static WNDPROC oldEditProc = NULL; +static WNDPROC oldEditProcHEX = NULL; + +CHEATS_LIST tempCheat; + +u32 searchIDDs[2][4] = { + { IDD_CHEAT_SEARCH_MAIN, IDD_CHEAT_SEARCH_EXACT, IDD_CHEAT_SEARCH_RESULT, NULL }, + { IDD_CHEAT_SEARCH_MAIN, IDD_CHEAT_SEARCH_RESULT, IDD_CHEAT_SEARCH_COMP, IDD_CHEAT_SEARCH_RESULT} +}; + +u32 searchSizeIDDs[4] = { IDC_RADIO1, IDC_RADIO2, IDC_RADIO3, IDC_RADIO4 }; +u32 searchSignIDDs[2] = { IDC_RADIO5, IDC_RADIO6 }; +u32 searchTypeIDDs[2] = { IDC_RADIO7, IDC_RADIO8 }; +u32 searchCompIDDs[4] = { IDC_RADIO1, IDC_RADIO2, IDC_RADIO3, IDC_RADIO4 }; + +u32 searchRangeIDDs[4] = { IDC_STATIC_S1, IDC_STATIC_S2, IDC_STATIC_S3, IDC_STATIC_S4 }; +char *searchRangeText[2][4] = { {"[0..255]", "[0..65536]", "[0..16777215]", "[0..4294967295]"}, + {"[-128..127]", "[-32168..32767]", "[-8388608..8388607]", "[-2147483648..2147483647]"}}; + +u32 searchRange[4][2] = { + { 0, 255 }, + { 0, 65536 }, + { 0, 16777215 }, + { 0, 4294967295 } + }; + +LRESULT CALLBACK EditValueProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + // TODO: check paste + if (msg == WM_CHAR) + { + switch (wParam) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + break; + case '-': + { + u8 pos = 0; + SendMessage(hwnd, EM_GETSEL, (WPARAM)&pos, NULL); + if (pos != 0) wParam = 0; + } + break; + + case VK_BACK: + break; + default: + wParam = 0; + break; + } + + } + + return CallWindowProc(oldEditProc, hwnd, msg, wParam, lParam); +} + +LRESULT CALLBACK EditValueHEXProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + // TODO: check paste + if (msg == WM_CHAR) + { + switch (wParam) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + break; + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + wParam -= 32; + break; + case VK_BACK: + break; + default: + wParam = 0; + break; + } + + } + + return CallWindowProc(oldEditProcHEX, hwnd, msg, wParam, lParam); +} + +BOOL CALLBACK CheatsAddProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + static WNDPROC saveOldEditProc = NULL; + + switch(msg) + { + case WM_INITDIALOG: + { + saveOldEditProc = oldEditProc; + SendMessage(GetDlgItem(dialog, IDC_EDIT1), EM_SETLIMITTEXT, 6, 0); + SendMessage(GetDlgItem(dialog, IDC_EDIT2), EM_SETLIMITTEXT, 10, 0); + SendMessage(GetDlgItem(dialog, IDC_EDIT3), EM_SETLIMITTEXT, 75, 0); + oldEditProcHEX = (WNDPROC)SetWindowLongPtr(GetDlgItem(dialog, IDC_EDIT1), GWLP_WNDPROC, (LONG)EditValueHEXProc); + oldEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(dialog, IDC_EDIT2), GWLP_WNDPROC, (LONG)EditValueProc); + + if (searchAddMode == 1) + { + char buf[10]; + searchAddAddress &= 0x00FFFFFF; + wsprintf(buf, "%06X", searchAddAddress); + SetWindowText(GetDlgItem(dialog, IDC_EDIT1), buf); + wsprintf(buf, "%i", searchAddValue); + SetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf); + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + EnableWindow(GetDlgItem(dialog, IDC_EDIT1), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_RADIO1), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_RADIO2), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_RADIO3), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_RADIO4), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_RADIO8), FALSE); + } + else + { + SetWindowText(GetDlgItem(dialog, IDC_EDIT2), "0"); + CheckDlgButton(dialog, IDC_RADIO1, BST_CHECKED); + } + + memset(editBuf, 0, sizeof(editBuf)); + + GetWindowText(GetDlgItem(dialog, IDC_EDIT1), editBuf[0], 10); + GetWindowText(GetDlgItem(dialog, IDC_EDIT2), editBuf[1], 10); + + CheckDlgButton(dialog, IDC_CHECK1, BST_CHECKED); + CheckDlgButton(dialog, searchSizeIDDs[searchAddSize], BST_CHECKED); + } + return TRUE; + + case WM_COMMAND: + { + switch (LOWORD(wparam)) + { + case IDOK: + { + u32 tmp_addr = 0; + sscanf_s(editBuf[0], "%x", &tmp_addr); + + if (cheatsAdd(searchAddSize, tmp_addr, atol(editBuf[1]), editBuf[2], searchAddFreeze)) + { + if ((searchAddMode == 0) || (cheatsSave() && searchAddMode == 1)) + { + oldEditProc = saveOldEditProc; + searchAddAddress = tmp_addr; + searchAddValue = atol(editBuf[1]); + + EndDialog(dialog, TRUE); + } + } + } + return TRUE; + + case IDCANCEL: + oldEditProc = saveOldEditProc; + EndDialog(dialog, FALSE); + return TRUE; + + case IDC_EDIT1: // address + { + if (HIWORD(wparam) == EN_UPDATE) + { + GetWindowText(GetDlgItem(dialog, IDC_EDIT1), editBuf[0], 8); + if ( (strlen(editBuf[0]) < 6) || (!strlen(editBuf[1])) ) + { + EnableWindow(GetDlgItem(dialog, IDOK), FALSE); + return TRUE; + } + + u32 val = 0; + sscanf_s(editBuf[0], "%x", &val); + val &= 0x00FFFFFF; + if (val > 0x400000) + { + EnableWindow(GetDlgItem(dialog, IDOK), FALSE); + return TRUE; + } + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + } + return TRUE; + } + + case IDC_EDIT2: // value + { + if (HIWORD(wparam) == EN_UPDATE) + { + GetWindowText(GetDlgItem(dialog, IDC_EDIT2), editBuf[1], 10); + if ( (strlen(editBuf[0]) < 6) || (!strlen(editBuf[1])) ) + { + EnableWindow(GetDlgItem(dialog, IDOK), FALSE); + return TRUE; + } + + u32 val = atol(editBuf[1]); + if (val > searchRange[searchAddSize][1]) + { + EnableWindow(GetDlgItem(dialog, IDOK), FALSE); + return TRUE; + } + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + } + return TRUE; + } + + case IDC_EDIT3: // description + { + if (HIWORD(wparam) == EN_UPDATE) + GetWindowText(GetDlgItem(dialog, IDC_EDIT3), editBuf[2], 75); + return TRUE; + } + + case IDC_RADIO1: // 1 byte + searchAddSize = 0; + return TRUE; + case IDC_RADIO2: // 2 bytes + searchAddSize = 1; + return TRUE; + case IDC_RADIO3: // 3 bytes + searchAddSize = 2; + return TRUE; + case IDC_RADIO4: // 4 bytes + searchAddSize = 3; + return TRUE; + + case IDC_CHECK1: + { + if (IsDlgButtonChecked(dialog, IDC_CHECK1) == BST_CHECKED) + searchAddFreeze = 1; + else + searchAddFreeze = 0; + } + } + } + } + return FALSE; +} + +BOOL CALLBACK CheatsEditProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + static WNDPROC saveOldEditProc = NULL; + char buf[100] = {0}, buf2[100] = {0}; + + switch(msg) + { + case WM_INITDIALOG: + { + saveOldEditProc = oldEditProc; + SendMessage(GetDlgItem(dialog, IDC_EDIT1), EM_SETLIMITTEXT, 6, 0); + SendMessage(GetDlgItem(dialog, IDC_EDIT2), EM_SETLIMITTEXT, 10, 0); + SendMessage(GetDlgItem(dialog, IDC_EDIT3), EM_SETLIMITTEXT, 75, 0); + oldEditProcHEX = (WNDPROC)SetWindowLongPtr(GetDlgItem(dialog, IDC_EDIT1), GWLP_WNDPROC, (LONG)EditValueHEXProc); + oldEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(dialog, IDC_EDIT2), GWLP_WNDPROC, (LONG)EditValueProc); + + cheatsGet(&tempCheat, cheatEditPos); + + memset(buf, 0, 100); + memset(buf2, 0, 100); + tempCheat.hi[0] &= 0x00FFFFFF; + wsprintf(buf, "%06X", tempCheat.hi[0]); + SetWindowText(GetDlgItem(dialog, IDC_EDIT1), buf); + wsprintf(buf, "%i", tempCheat.lo[0]); + SetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf); + strcpy(buf, tempCheat.description); + SetWindowText(GetDlgItem(dialog, IDC_EDIT3), buf); + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + + CheckDlgButton(dialog, IDC_CHECK1, tempCheat.enabled?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(dialog, searchSizeIDDs[tempCheat.size], BST_CHECKED); + SetWindowText(GetDlgItem(dialog, IDOK), "Update"); + } + return TRUE; + + case WM_COMMAND: + { + switch (LOWORD(wparam)) + { + case IDOK: + { + if (cheatsUpdate(tempCheat.size, tempCheat.hi[0], tempCheat.lo[0], tempCheat.description, tempCheat.enabled, cheatEditPos)) + { + oldEditProc = saveOldEditProc; + EndDialog(dialog, TRUE); + } + } + return TRUE; + + case IDCANCEL: + oldEditProc = saveOldEditProc; + EndDialog(dialog, FALSE); + return TRUE; + + case IDC_EDIT1: // address + { + if (HIWORD(wparam) == EN_UPDATE) + { + GetWindowText(GetDlgItem(dialog, IDC_EDIT1), buf, 8); + GetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf2, 10); + if ( (strlen(buf) < 6) || (!strlen(buf2)) ) + { + EnableWindow(GetDlgItem(dialog, IDOK), FALSE); + return TRUE; + } + + u32 val = 0; + sscanf_s(buf, "%x", &val); + val &= 0x00FFFFFF; + if (val > 0x400000) + { + EnableWindow(GetDlgItem(dialog, IDOK), FALSE); + return TRUE; + } + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + tempCheat.hi[0] = val; + } + return TRUE; + } + + case IDC_EDIT2: // value + { + if (HIWORD(wparam) == EN_UPDATE) + { + GetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf, 10); + GetWindowText(GetDlgItem(dialog, IDC_EDIT1), buf2, 8); + if ( (strlen(buf2) < 6) || (!strlen(buf)) ) + { + EnableWindow(GetDlgItem(dialog, IDOK), FALSE); + return TRUE; + } + + u32 val = atol(buf); + if (val > searchRange[tempCheat.size][1]) + { + EnableWindow(GetDlgItem(dialog, IDOK), FALSE); + return TRUE; + } + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + tempCheat.lo[0] = val; + } + return TRUE; + } + + case IDC_EDIT3: // description + { + if (HIWORD(wparam) == EN_UPDATE) + GetWindowText(GetDlgItem(dialog, IDC_EDIT3), tempCheat.description, 75); + return TRUE; + } + + case IDC_RADIO1: // 1 byte + tempCheat.size = 0; + return TRUE; + case IDC_RADIO2: // 2 bytes + tempCheat.size = 1; + return TRUE; + case IDC_RADIO3: // 3 bytes + tempCheat.size = 2; + return TRUE; + case IDC_RADIO4: // 4 bytes + tempCheat.size = 3; + return TRUE; + + case IDC_CHECK1: // freeze + { + if (IsDlgButtonChecked(dialog, IDC_CHECK1) == BST_CHECKED) + tempCheat.enabled = 1; + else + tempCheat.enabled = 0; + } + } + } + } + return FALSE; +} +//============================================================================== Action Replay +BOOL CALLBACK CheatsAdd_XX_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + SendMessage(GetDlgItem(dialog, IDC_EDIT2), EM_FMTLINES, (WPARAM)TRUE, (LPARAM)0); + + if (cheatXXtype == 0) + { + if (cheatXXaction == 0) // add + { + SetWindowText(dialog, "Add Action Replay code"); + tempCheat.enabled = TRUE; + } + else // edit + { + SetWindowText(dialog, "Edit Action Replay code"); + } + } + else + { + if (cheatXXaction == 0) // add + { + SetWindowText(dialog, "Add Codebreaker code"); + tempCheat.enabled = TRUE; + } + else // edit + { + SetWindowText(dialog, "Edit Codebreaker code"); + } + } + + if (cheatXXaction != 0) + { + char buf[sizeof(tempCheat.hi)+sizeof(tempCheat.lo)] = { 0 }; + memset(buf, 0, sizeof(buf)); + + cheatGetXXcodeString(tempCheat, buf); + SetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf); + SetWindowText(GetDlgItem(dialog, IDC_EDIT3), tempCheat.description); + + EnableWindow(GetDlgItem(dialog, IDOK), (strlen(buf) > 16)?TRUE:FALSE); + SetWindowText(GetDlgItem(dialog, IDOK), "Update"); + } + CheckDlgButton(dialog, IDC_CHECK1, tempCheat.enabled?BST_CHECKED:BST_UNCHECKED); + + SendMessage(GetDlgItem(dialog, IDC_EDIT2), EM_SETLIMITTEXT, sizeof(tempCheat.hi)+sizeof(tempCheat.lo), 0); + SendMessage(GetDlgItem(dialog, IDC_EDIT3), EM_SETLIMITTEXT, sizeof(tempCheat.description), 0); + } + return TRUE; + + case WM_COMMAND: + { + switch (LOWORD(wparam)) + { + case IDOK: + { + char buf[sizeof(tempCheat.hi)+sizeof(tempCheat.lo)] = { 0 }; + + memset(buf, 0, sizeof(buf)); + GetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf, sizeof(buf)); + + if (cheatXXtype == 0) // Action Replay + { + if (cheatXXaction == 0) // add + { + if (!cheatsAdd_AR(buf, tempCheat.description, tempCheat.enabled)) + { + MessageBox(dialog, "Syntax error in Action Replay code.\nTry again", "DeSmuME", + MB_OK | MB_ICONERROR); + return FALSE; + } + } + else // edit + { + if (!cheatsUpdate_AR(buf, tempCheat.description, tempCheat.enabled, cheatEditPos)) + { + MessageBox(dialog, "Syntax error in Action Replay code.\nTry again", "DeSmuME", + MB_OK | MB_ICONERROR); + return FALSE; + } + } + } + else + { + if (cheatXXaction == 0) // add + { + if (!cheatsAdd_CB(buf, tempCheat.description, tempCheat.enabled)) + { + MessageBox(dialog, "Syntax error in Codebreaker code.\nTry again", "DeSmuME", + MB_OK | MB_ICONERROR); + return FALSE; + } + } + else // edit + { + if (!cheatsUpdate_CB(buf, tempCheat.description, tempCheat.enabled, cheatEditPos)) + { + MessageBox(dialog, "Syntax error in Codebreaker code.\nTry again", "DeSmuME", + MB_OK | MB_ICONERROR); + return FALSE; + } + } + } + EndDialog(dialog, TRUE); + } + return TRUE; + + case IDCANCEL: + EndDialog(dialog, FALSE); + return TRUE; + + case IDC_EDIT2: // code + if (HIWORD(wparam) == EN_UPDATE) + { + char buf[sizeof(tempCheat.hi)+sizeof(tempCheat.lo)] = { 0 }; + + memset(buf, 0, sizeof(buf)); + GetWindowText(GetDlgItem(dialog, IDC_EDIT2), buf, sizeof(buf)); + if (strlen(buf) < 17) // min size of code "CXXXXXXX YYYYYYYY" + { + EnableWindow(GetDlgItem(dialog, IDOK), FALSE); + return TRUE; + } + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + } + return TRUE; + + case IDC_EDIT3: // description + if (HIWORD(wparam) == EN_UPDATE) + { + memset(tempCheat.description, 0, sizeof(tempCheat.description)); + GetWindowText(GetDlgItem(dialog, IDC_EDIT3), tempCheat.description, sizeof(tempCheat.description)); + } + return TRUE; + + case IDC_CHECK1: + if (IsDlgButtonChecked(dialog, IDC_CHECK1) == BST_CHECKED) + tempCheat.enabled = 1; + else + tempCheat.enabled = 0; + return TRUE; + } + } + } + return FALSE; +} +//============================================================================== +BOOL CALLBACK CheatsListBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + LV_COLUMN lvColumn; + u32 address = 0; + u32 val = 0; + + cheatListView = GetDlgItem(dialog, IDC_LIST1); + + ListView_SetExtendedListViewStyle(cheatListView, LVS_EX_FULLROWSELECT | LVS_EX_TWOCLICKACTIVATE); + + memset(&lvColumn,0,sizeof(LV_COLUMN)); + lvColumn.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT; + + lvColumn.fmt=LVCFMT_CENTER; + lvColumn.cx=20; + lvColumn.pszText="X"; + ListView_InsertColumn(cheatListView, 0, &lvColumn); + + lvColumn.fmt=LVCFMT_LEFT; + lvColumn.cx=84; + lvColumn.pszText="Address"; + ListView_InsertColumn(cheatListView, 1, &lvColumn); + lvColumn.cx=100; + lvColumn.pszText="Value"; + ListView_InsertColumn(cheatListView, 2, &lvColumn); + lvColumn.cx=245; + lvColumn.pszText="Description"; + ListView_InsertColumn(cheatListView, 3, &lvColumn); + lvColumn.fmt=LVCFMT_CENTER; + + LVITEM lvi; + memset(&lvi,0,sizeof(LVITEM)); + lvi.mask = LVIF_TEXT|LVIF_STATE; + lvi.iItem = INT_MAX; + + cheatsGetListReset(); + SendMessage(cheatListView, WM_SETREDRAW, (WPARAM)FALSE,0); + while (cheatsGetList(&tempCheat)) + { + char buf[256]; + if (tempCheat.enabled) + lvi.pszText= "X"; + else + lvi.pszText= ""; + switch (tempCheat.type) + { + case 0: // Internal + { + u32 row = ListView_InsertItem(cheatListView, &lvi); + wsprintf(buf, "0x02%06X", tempCheat.hi[0]); + ListView_SetItemText(cheatListView, row, 1, buf); + ltoa(tempCheat.lo[0], buf, 10); + ListView_SetItemText(cheatListView, row, 2, buf); + ListView_SetItemText(cheatListView, row, 3, tempCheat.description); + break; + } + + case 1: // Action Replay + { + u32 row = ListView_InsertItem(cheatListView, &lvi); + ListView_SetItemText(cheatListView, row, 1, "Action"); + ListView_SetItemText(cheatListView, row, 2, "Replay"); + ListView_SetItemText(cheatListView, row, 3, tempCheat.description); + break; + } + + case 2: // Codebreaker + { + u32 row = ListView_InsertItem(cheatListView, &lvi); + ListView_SetItemText(cheatListView, row, 1, "Code"); + ListView_SetItemText(cheatListView, row, 2, "breaker"); + ListView_SetItemText(cheatListView, row, 3, tempCheat.description); + break; + } + } + } + SendMessage(cheatListView, WM_SETREDRAW, (WPARAM)TRUE,0); + + ListView_SetItemState(searchListView,0, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); + SetFocus(searchListView); + return TRUE; + } + + case WM_NOTIFY: + if (wparam == IDC_LIST1) + { + LPNMHDR tmp_msg = (LPNMHDR)lparam; + if ( tmp_msg->code == LVN_ITEMACTIVATE ) + { + cheatEditPos = ListView_GetNextItem(cheatListView, -1, LVNI_SELECTED|LVNI_FOCUSED); + cheatsGet(&tempCheat, cheatEditPos); + tempCheat.enabled = !tempCheat.enabled; + switch (tempCheat.type) + { + case 0: // internal + cheatsUpdate(tempCheat.size, tempCheat.hi[0], tempCheat.lo[0], tempCheat.description, tempCheat.enabled, cheatEditPos); + break; + + case 1: // Action Replay + cheatsUpdate_AR(NULL, NULL, tempCheat.enabled, cheatEditPos); + break; + + case 2: // Codebreaker + cheatsUpdate_CB(NULL, NULL, tempCheat.enabled, cheatEditPos); + break; + } + + + if (tempCheat.enabled) + ListView_SetItemText(cheatListView, cheatEditPos, 0, "X") + else + ListView_SetItemText(cheatListView, cheatEditPos, 0, ""); + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + } + + if ( tmp_msg->code == NM_CLICK ) + { + if (ListView_GetNextItem(cheatListView, -1, LVNI_SELECTED|LVNI_FOCUSED) != -1) + { + EnableWindow(GetDlgItem(dialog, IDC_BEDIT), TRUE); + EnableWindow(GetDlgItem(dialog, IDC_BREMOVE), TRUE); + } + else + { + EnableWindow(GetDlgItem(dialog, IDC_BEDIT), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_BREMOVE), FALSE); + } + } + + return TRUE; + } + return FALSE; + + case WM_COMMAND: + { + switch (LOWORD(wparam)) + { + case IDOK: + if (cheatsSave()) + { + EndDialog(dialog, TRUE); + } + else + MessageBox(dialog, "Can't save cheats to file","Error",MB_OK); + return TRUE; + case IDCANCEL: + EndDialog(dialog, FALSE); + return TRUE; + + case IDC_BADD: + { + searchAddAddress = 0;; + searchAddValue = 0; + searchAddMode = 0; + searchAddFreeze = 1; + if (DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_ADD), dialog, (DLGPROC) CheatsAddProc)) + { + LVITEM lvi; + char buf[256]; + + memset(&lvi,0,sizeof(LVITEM)); + lvi.mask = LVIF_TEXT|LVIF_STATE; + lvi.iItem = INT_MAX; + + if (searchAddFreeze) + lvi.pszText= "X"; + else + lvi.pszText= " "; + u32 row = ListView_InsertItem(cheatListView, &lvi); + wsprintf(buf, "0x02%06X", searchAddAddress); + ListView_SetItemText(cheatListView, row, 1, buf); + ltoa(searchAddValue, buf, 10); + ListView_SetItemText(cheatListView, row, 2, buf); + ListView_SetItemText(cheatListView, row, 3, editBuf[2]); + + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + } + } + return TRUE; + + case IDC_BADD_AR: + { + if (LOWORD(wparam) == IDC_BADD_AR) + { + cheatXXtype = 0; + } + else + if (LOWORD(wparam) == IDC_BADD_CB) + { + cheatXXtype = 1; + } + else + return TRUE; + cheatXXaction = 0; // 0 = add + + if (DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_ADD_XX_CODE), dialog, (DLGPROC) CheatsAdd_XX_Proc)) + { + LVITEM lvi; + + memset(&lvi,0,sizeof(LVITEM)); + lvi.mask = LVIF_TEXT|LVIF_STATE; + lvi.iItem = INT_MAX; + + if (tempCheat.enabled) + lvi.pszText= "X"; + else + lvi.pszText= " "; + u32 row = ListView_InsertItem(cheatListView, &lvi); + if (cheatXXtype == 0) + { + ListView_SetItemText(cheatListView, row, 1, "Action"); + ListView_SetItemText(cheatListView, row, 2, "Replay"); + } + else + { + ListView_SetItemText(cheatListView, row, 1, "Code"); + ListView_SetItemText(cheatListView, row, 2, "breaker"); + } + ListView_SetItemText(cheatListView, row, 3, tempCheat.description); + + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + } + } + return TRUE; + + case IDC_BEDIT: + { + cheatEditPos = ListView_GetNextItem(cheatListView, -1, LVNI_SELECTED|LVNI_FOCUSED); + if (cheatEditPos > cheatsGetSize()) return TRUE; + + cheatsGet(&tempCheat, cheatEditPos); + + switch (tempCheat.type) + { + case 0: // internal + if (DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_ADD), dialog, (DLGPROC) CheatsEditProc)) + { + char buf[256]; + cheatsGet(&tempCheat, cheatEditPos); + if (tempCheat.enabled) + ListView_SetItemText(cheatListView, cheatEditPos, 0, "X"); + wsprintf(buf, "0x02%06X", tempCheat.hi[0]); + ListView_SetItemText(cheatListView, cheatEditPos, 1, buf); + ltoa(tempCheat.lo[0], buf, 10); + ListView_SetItemText(cheatListView, cheatEditPos, 2, buf); + ListView_SetItemText(cheatListView, cheatEditPos, 3, tempCheat.description); + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + } + break; + + case 1: // Action replay + case 2: // Codebreaker + if (tempCheat.type == 1) + cheatXXtype = 0; + else + cheatXXtype = 1; + cheatXXaction = 1; // 1 = edit + + if (DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_ADD_XX_CODE), dialog, (DLGPROC) CheatsAdd_XX_Proc)) + { + cheatsGet(&tempCheat, cheatEditPos); + if (tempCheat.enabled) + ListView_SetItemText(cheatListView, cheatEditPos, 0, "X"); + + if (cheatXXtype == 0) + { + ListView_SetItemText(cheatListView, cheatEditPos, 1, "Action"); + ListView_SetItemText(cheatListView, cheatEditPos, 2, "Replay"); + } + else + { + ListView_SetItemText(cheatListView, cheatEditPos, 1, "Code"); + ListView_SetItemText(cheatListView, cheatEditPos, 2, "breaker"); + } + + ListView_SetItemText(cheatListView, cheatEditPos, 3, tempCheat.description); + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + } + break; + } + } + return TRUE; + + case IDC_BREMOVE: + { + int tmp_pos = ListView_GetNextItem(cheatListView, -1, LVNI_SELECTED|LVNI_FOCUSED); + if (tmp_pos != -1) + { + if (cheatsRemove(tmp_pos)) + { + ListView_DeleteItem(cheatListView, tmp_pos); + EnableWindow(GetDlgItem(dialog, IDOK), TRUE); + } + } + + } + return TRUE; + } + break; + } + } + return FALSE; +} + +void CheatsListDialog(HWND hwnd) +{ + if (!cheatsPush()) return; + memset(&tempCheat, 0, sizeof(CHEATS_LIST)); + u32 res=DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_LIST), hwnd, (DLGPROC) CheatsListBox_Proc); + if (res) + { + cheatsSave(); + cheatsStackClear(); + } + else + { + cheatsPop(); + } +} + + +// ================================================================================== Search +BOOL CALLBACK CheatsSearchExactWnd(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + EnableWindow(hBRestart, TRUE); + if (searchNumberResults) + EnableWindow(hBView, TRUE); + else + EnableWindow(hBView, FALSE); + EnableWindow(hBSearch, FALSE); + + SendMessage(GetDlgItem(dialog, IDC_EVALUE), EM_SETLIMITTEXT, 10, 0); + SetWindowText(GetDlgItem(dialog, IDC_STATIC_RANGE), searchRangeText[searchSign][searchSize]); + oldEditProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(dialog, IDC_EVALUE), GWLP_WNDPROC, (LONG)EditValueProc); + char buf[256]; + memset(buf, 0, 256); + ltoa(searchNumberResults, buf, 10); + SetWindowText(GetDlgItem(dialog, IDC_SNUMBER), buf); + SetFocus(GetDlgItem(dialog, IDC_EVALUE)); + break; + } + + case WM_COMMAND: + { + switch (LOWORD(wparam)) + { + case IDC_EVALUE: + { + if (HIWORD(wparam) == EN_UPDATE) + { + char buf[10]; + GetWindowText(GetDlgItem(dialog, IDC_EVALUE), buf, 10); + if (!strlen(buf)) + { + EnableWindow(hBSearch, FALSE); + return TRUE; + } + + u32 val = atol(buf); + if (val > searchRange[searchSize][1]) + { + EnableWindow(hBSearch, FALSE); + return TRUE; + } + EnableWindow(hBSearch, TRUE); + exactVal = val; + } + return TRUE; + } + } + break; + } + } + return FALSE; +} + +BOOL CALLBACK CheatsSearchCompWnd(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + EnableWindow(hBRestart, TRUE); + if (searchNumberResults) + EnableWindow(hBView, TRUE); + else + EnableWindow(hBView, FALSE); + EnableWindow(hBSearch, TRUE); + + CheckDlgButton(dialog, searchCompIDDs[searchComp], BST_CHECKED); + + char buf[256]; + ltoa(searchNumberResults, buf, 10); + SetWindowText(GetDlgItem(dialog, IDC_SNUMBER), buf); + break; + } + + case WM_COMMAND: + { + switch (LOWORD(wparam)) + { + case IDC_RADIO1: searchComp = 0; break; + case IDC_RADIO2: searchComp = 1; break; + case IDC_RADIO3: searchComp = 2; break; + case IDC_RADIO4: searchComp = 3; break; + } + break; + } + } + return FALSE; +} + +BOOL CALLBACK CheatsSearchResultWnd(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + EnableWindow(hBRestart, TRUE); + if (searchNumberResults) + EnableWindow(hBView, TRUE); + else + EnableWindow(hBView, FALSE); + EnableWindow(hBSearch, FALSE); + char buf[256]; + ltoa(searchNumberResults, buf, 10); + SetWindowText(GetDlgItem(dialog, IDC_SNUMBER), buf); + return TRUE; + } + } + return FALSE; +} + +BOOL CALLBACK CheatsSearchViewWnd(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + LV_COLUMN lvColumn; + u32 address = 0; + u32 val = 0; + + searchListView = GetDlgItem(dialog, IDC_LIST); + + ListView_SetExtendedListViewStyle(searchListView, LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES); + + memset(&lvColumn,0,sizeof(LV_COLUMN)); + lvColumn.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT; + lvColumn.fmt=LVCFMT_LEFT; + lvColumn.cx=94; + lvColumn.pszText="Address"; + ListView_InsertColumn(searchListView, 0, &lvColumn); + lvColumn.cx=130; + lvColumn.pszText="Value"; + ListView_InsertColumn(searchListView, 1, &lvColumn); + + LVITEM lvi; + memset(&lvi,0,sizeof(LVITEM)); + lvi.mask = LVIF_TEXT|LVIF_STATE; + lvi.iItem = INT_MAX; + + cheatSearchGetListReset(); + SendMessage(searchListView, WM_SETREDRAW, (WPARAM)FALSE,0); + while (cheatSearchGetList(&address, &val)) + { + char buf[256]; + wsprintf(buf, "0x02%06X", address); + lvi.pszText= buf; + u32 row = SendMessage(searchListView, LVM_INSERTITEM, 0, (LPARAM)&lvi); + _ltoa(val, buf, 10); + ListView_SetItemText(searchListView, row, 1, buf); + } + SendMessage(searchListView, WM_SETREDRAW, (WPARAM)TRUE,0); + ListView_SetItemState(searchListView,0, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); + SetFocus(searchListView); + } + return TRUE; + + case WM_COMMAND: + { + switch (LOWORD(wparam)) + { + case IDCANCEL: + ListView_DeleteAllItems(searchListView); + EndDialog(dialog, FALSE); + return TRUE; + case IDC_BADD: + { + u32 val = 0; + char buf[12]; + u32 pos = ListView_GetNextItem(searchListView, -1, LVNI_SELECTED|LVNI_FOCUSED); + ListView_GetItemText(searchListView, pos, 0, buf, 12); + sscanf_s(buf, "%x", &val); + searchAddAddress = val & 0x00FFFFFF; + ListView_GetItemText(searchListView, pos, 1, buf, 12); + searchAddValue = atol(buf); + searchAddMode = 1; + searchAddSize = searchSize; + DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_ADD), dialog, (DLGPROC) CheatsAddProc); + } + return TRUE; + } + } + } + return FALSE; +} + +BOOL CALLBACK CheatsSearchMainWnd(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + CheckDlgButton(dialog, searchSizeIDDs[searchSize], BST_CHECKED); + CheckDlgButton(dialog, searchSignIDDs[searchSign], BST_CHECKED); + CheckDlgButton(dialog, searchTypeIDDs[searchType], BST_CHECKED); + for (int i = 0; i < 4; i++) + SetWindowText(GetDlgItem(dialog, searchRangeIDDs[i]), searchRangeText[searchSign][i]); + EnableWindow(hBRestart, FALSE); + EnableWindow(hBView, FALSE); + EnableWindow(hBSearch, TRUE); + break; + } + + case WM_COMMAND: + { + switch (LOWORD(wparam)) + { + case IDC_RADIO1: // 1 byte + searchSize = 0; + return TRUE; + case IDC_RADIO2: // 2 bytes + searchSize = 1; + return TRUE; + case IDC_RADIO3: // 3 bytes + searchSize = 2; + return TRUE; + case IDC_RADIO4: // 4 bytes + searchSize = 3; + return TRUE; + + case IDC_RADIO5: // unsigned + searchSign = 0; + for (int i = 0; i < 4; i++) + SetWindowText(GetDlgItem(dialog, searchRangeIDDs[i]), searchRangeText[searchSign][i]); + return TRUE; + + case IDC_RADIO6: //signed + searchSign = 1; + for (int i = 0; i < 4; i++) + SetWindowText(GetDlgItem(dialog, searchRangeIDDs[i]), searchRangeText[searchSign][i]); + return TRUE; + + case IDC_RADIO7: // exact value search + searchType = 0; + return TRUE; + + case IDC_RADIO8: // comparative search + searchType = 1; + return TRUE; + } + return TRUE; + } + } + return FALSE; +} + +DLGPROC CheatsSearchSubWnds[2][4] = { + { CheatsSearchMainWnd, CheatsSearchExactWnd, CheatsSearchResultWnd, NULL }, + { CheatsSearchMainWnd, CheatsSearchResultWnd, CheatsSearchCompWnd, CheatsSearchResultWnd } +}; + +//============================================================================== +BOOL CALLBACK CheatsSearchProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + hBRestart = GetDlgItem(dialog, IDC_BRESTART); + hBView = GetDlgItem(dialog, IDC_BVIEW); + hBSearch = GetDlgItem(dialog, IDC_BSEARCH); + + searchWnd=CreateDialog(hAppInst, MAKEINTRESOURCE(searchIDDs[searchType][searchStep]), + dialog, (DLGPROC)CheatsSearchSubWnds[searchType][searchStep]); + return TRUE; + } + + case WM_COMMAND: + { + switch (LOWORD(wparam)) + { + case IDOK: + case IDCANCEL: + if (searchWnd) DestroyWindow(searchWnd); + EndDialog(dialog, FALSE); + return TRUE; + + case IDC_BVIEW: + DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_SEARCH_VIEW), dialog, (DLGPROC)CheatsSearchViewWnd); + return TRUE; + + case IDC_BSEARCH: + if (searchStep == 0) + cheatsSearchInit(searchType, searchSize, searchSign); + if (searchType == 0) + { + if (searchStep == 1) + searchNumberResults = cheatsSearchValue(exactVal); + } + else + { + if (searchStep == 2) + searchNumberResults = cheatsSearchComp(searchComp); + } + + searchStep++; + if (searchWnd) DestroyWindow(searchWnd); + searchWnd=CreateDialog(hAppInst, MAKEINTRESOURCE(searchIDDs[searchType][searchStep]), + dialog, (DLGPROC)CheatsSearchSubWnds[searchType][searchStep]); + if (searchType == 0) + { + if (searchStep == 2) searchStep = 1; + } + else + { + if (searchStep == 1) searchStep = 2; + if (searchStep == 3) searchStep = 2; + } + return TRUE; + + case IDC_BRESTART: + cheatsSearchClose(); + searchStep = 0; + searchNumberResults = 0; + if (searchWnd) DestroyWindow(searchWnd); + searchWnd=CreateDialog(hAppInst, MAKEINTRESOURCE(searchIDDs[searchType][searchStep]), + dialog, (DLGPROC)CheatsSearchSubWnds[searchType][searchStep]); + return TRUE; + } + break; + } + } + return FALSE; +} + +void CheatsSearchDialog(HWND hwnd) +{ + DialogBox(hAppInst, MAKEINTRESOURCE(IDD_CHEAT_SEARCH), hwnd, (DLGPROC) CheatsSearchProc); +} + +void CheatsSearchReset() +{ + searchType = 0; + searchSize = 0; + searchSign = 0; + searchStep = 0; + searchComp = 0; + searchAddSize = 0; + exactVal = 0; + searchNumberResults = 0; +} diff --git a/desmume/src/windows/cheatsWin.h b/src/windows/cheatsWin.h similarity index 94% rename from desmume/src/windows/cheatsWin.h rename to src/windows/cheatsWin.h index 27cf3a4f5..7dc10bf89 100644 --- a/desmume/src/windows/cheatsWin.h +++ b/src/windows/cheatsWin.h @@ -1,28 +1,28 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "../common.h" - -extern void CheatsListDialog(HWND hwnd); -extern void CheatsSearchDialog(HWND hwnd); +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright 2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "../common.h" + +extern void CheatsListDialog(HWND hwnd); +extern void CheatsSearchDialog(HWND hwnd); extern void CheatsSearchReset(); \ No newline at end of file diff --git a/desmume/src/windows/colorctrl.cpp b/src/windows/colorctrl.cpp similarity index 96% rename from desmume/src/windows/colorctrl.cpp rename to src/windows/colorctrl.cpp index c7c2358fc..7890edc2e 100644 --- a/desmume/src/windows/colorctrl.cpp +++ b/src/windows/colorctrl.cpp @@ -1,158 +1,158 @@ -/* colorctrl.cpp - this file is part of DeSmuME - * - * Copyright (C) 2007 Acid Burn - * - * This file is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This file is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "../common.h" -#include -#include "colorctrl.h" - -static char szClassName[] = "DeSmuME_ColorCtrl"; - -LRESULT CALLBACK ColorCtrl_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -LRESULT ColorCtrl_OnPaint(ColorCtrl *ccp, WPARAM wParam, LPARAM lParam); -LRESULT ColorCtrl_OnNCCreate(HWND hWnd, WPARAM wParam, LPARAM lParam); -LRESULT ColorCtrl_OnNCDestroy(ColorCtrl *ccp, WPARAM wParam, LPARAM lParam); - -static ColorCtrl* ColorCtrl_Get(HWND hWnd) -{ - return (ColorCtrl*)GetWindowLong(hWnd, 0); -} - -void ColorCtrl_Register() -{ - WNDCLASSEX wc; - - wc.cbSize = sizeof(wc); - wc.lpszClassName = szClassName; - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = ColorCtrl_WndProc; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); - wc.style = 0; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(ColorCtrl*); - wc.hIconSm = 0; - - RegisterClassEx(&wc); -} - -HWND ColorCtrl_Create(HWND hParent) -{ - HWND hwndCtrl; - - hwndCtrl = CreateWindowEx( - WS_EX_CLIENTEDGE, // give it a standard border - szClassName, - NULL, - WS_VISIBLE | WS_CHILD, - 0, 0, 16, 16, - hParent, - NULL, GetModuleHandle(0), NULL - ); - - return hwndCtrl; -} - -LRESULT CALLBACK ColorCtrl_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - ColorCtrl *pCtrl = ColorCtrl_Get(hwnd); - - switch(msg) - { - case WM_NCCREATE: - return ColorCtrl_OnNCCreate(hwnd, wParam, lParam); - - case WM_NCDESTROY: - ColorCtrl_OnNCDestroy(pCtrl, wParam, lParam); - break; - - case WM_PAINT: - return ColorCtrl_OnPaint(pCtrl, wParam, lParam); - - case WM_ERASEBKGND: - return 1; - - default: - break; - } - - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -LRESULT ColorCtrl_OnNCCreate(HWND hWnd, WPARAM wParam, LPARAM lParam) -{ - // Allocate a new CustCtrl structure for this window. - ColorCtrl* pCtrl = (ColorCtrl*)malloc(sizeof(ColorCtrl)); - - // Failed to allocate, stop window creation. - if(pCtrl == NULL) - return FALSE; - - // Initialize the CustCtrl structure. - pCtrl->hWnd = hWnd; - pCtrl->color = 0; - - // Attach custom structure to this window. - SetWindowLong(hWnd, 0, (LONG)pCtrl); - - // Continue with window creation. - return TRUE; -} - -LRESULT ColorCtrl_OnNCDestroy(ColorCtrl *pCtrl, WPARAM wParam, LPARAM lParam) -{ - free(pCtrl); - return TRUE; -} - -LRESULT ColorCtrl_OnPaint(ColorCtrl *pCtrl, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - RECT rect; - HBRUSH brush; - - // Get a device context for this window - hdc = BeginPaint(pCtrl->hWnd, &ps); - - // Work out where to draw - GetClientRect(pCtrl->hWnd, &rect); - - // Create brush and fill - brush = CreateSolidBrush(pCtrl->color); - FillRect(hdc, &rect, brush); - - // Release the device context - EndPaint(pCtrl->hWnd, &ps); - - // free brush again - DeleteObject(brush); - - return 0; -} - -void ColorCtrl_SetColor(HWND hWnd, COLORREF color) -{ - ColorCtrl *pCtrl = ColorCtrl_Get(hWnd); - - pCtrl->color = color; - InvalidateRect(hWnd, NULL, FALSE); -} +/* colorctrl.cpp - this file is part of DeSmuME + * + * Copyright (C) 2007 Acid Burn + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "../common.h" +#include +#include "colorctrl.h" + +static char szClassName[] = "DeSmuME_ColorCtrl"; + +LRESULT CALLBACK ColorCtrl_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +LRESULT ColorCtrl_OnPaint(ColorCtrl *ccp, WPARAM wParam, LPARAM lParam); +LRESULT ColorCtrl_OnNCCreate(HWND hWnd, WPARAM wParam, LPARAM lParam); +LRESULT ColorCtrl_OnNCDestroy(ColorCtrl *ccp, WPARAM wParam, LPARAM lParam); + +static ColorCtrl* ColorCtrl_Get(HWND hWnd) +{ + return (ColorCtrl*)GetWindowLong(hWnd, 0); +} + +void ColorCtrl_Register() +{ + WNDCLASSEX wc; + + wc.cbSize = sizeof(wc); + wc.lpszClassName = szClassName; + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = ColorCtrl_WndProc; + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hIcon = 0; + wc.lpszMenuName = 0; + wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); + wc.style = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = sizeof(ColorCtrl*); + wc.hIconSm = 0; + + RegisterClassEx(&wc); +} + +HWND ColorCtrl_Create(HWND hParent) +{ + HWND hwndCtrl; + + hwndCtrl = CreateWindowEx( + WS_EX_CLIENTEDGE, // give it a standard border + szClassName, + NULL, + WS_VISIBLE | WS_CHILD, + 0, 0, 16, 16, + hParent, + NULL, GetModuleHandle(0), NULL + ); + + return hwndCtrl; +} + +LRESULT CALLBACK ColorCtrl_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + ColorCtrl *pCtrl = ColorCtrl_Get(hwnd); + + switch(msg) + { + case WM_NCCREATE: + return ColorCtrl_OnNCCreate(hwnd, wParam, lParam); + + case WM_NCDESTROY: + ColorCtrl_OnNCDestroy(pCtrl, wParam, lParam); + break; + + case WM_PAINT: + return ColorCtrl_OnPaint(pCtrl, wParam, lParam); + + case WM_ERASEBKGND: + return 1; + + default: + break; + } + + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +LRESULT ColorCtrl_OnNCCreate(HWND hWnd, WPARAM wParam, LPARAM lParam) +{ + // Allocate a new CustCtrl structure for this window. + ColorCtrl* pCtrl = (ColorCtrl*)malloc(sizeof(ColorCtrl)); + + // Failed to allocate, stop window creation. + if(pCtrl == NULL) + return FALSE; + + // Initialize the CustCtrl structure. + pCtrl->hWnd = hWnd; + pCtrl->color = 0; + + // Attach custom structure to this window. + SetWindowLong(hWnd, 0, (LONG)pCtrl); + + // Continue with window creation. + return TRUE; +} + +LRESULT ColorCtrl_OnNCDestroy(ColorCtrl *pCtrl, WPARAM wParam, LPARAM lParam) +{ + free(pCtrl); + return TRUE; +} + +LRESULT ColorCtrl_OnPaint(ColorCtrl *pCtrl, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + RECT rect; + HBRUSH brush; + + // Get a device context for this window + hdc = BeginPaint(pCtrl->hWnd, &ps); + + // Work out where to draw + GetClientRect(pCtrl->hWnd, &rect); + + // Create brush and fill + brush = CreateSolidBrush(pCtrl->color); + FillRect(hdc, &rect, brush); + + // Release the device context + EndPaint(pCtrl->hWnd, &ps); + + // free brush again + DeleteObject(brush); + + return 0; +} + +void ColorCtrl_SetColor(HWND hWnd, COLORREF color) +{ + ColorCtrl *pCtrl = ColorCtrl_Get(hWnd); + + pCtrl->color = color; + InvalidateRect(hWnd, NULL, FALSE); +} diff --git a/desmume/src/windows/colorctrl.h b/src/windows/colorctrl.h similarity index 94% rename from desmume/src/windows/colorctrl.h rename to src/windows/colorctrl.h index a10aed29a..7cff4060d 100644 --- a/desmume/src/windows/colorctrl.h +++ b/src/windows/colorctrl.h @@ -1,14 +1,14 @@ -#ifndef COLORCTRL_H -#define COLORCTRL_H - -typedef struct -{ - HWND hWnd; - COLORREF color; -} ColorCtrl; - -void ColorCtrl_Register(); -HWND ColorCtrl_Create(HWND hParent); -void ColorCtrl_SetColor(HWND hWnd, COLORREF color); - -#endif // COLORCTRL_H +#ifndef COLORCTRL_H +#define COLORCTRL_H + +typedef struct +{ + HWND hWnd; + COLORREF color; +} ColorCtrl; + +void ColorCtrl_Register(); +HWND ColorCtrl_Create(HWND hParent); +void ColorCtrl_SetColor(HWND hWnd, COLORREF color); + +#endif // COLORCTRL_H diff --git a/desmume/src/windows/config.h b/src/windows/config.h similarity index 92% rename from desmume/src/windows/config.h rename to src/windows/config.h index fbf96dd8e..fc3646704 100644 --- a/desmume/src/windows/config.h +++ b/src/windows/config.h @@ -1,6 +1,6 @@ -#ifndef _CONFIG_H -#define _CONFIG_H - -#include "userconfig.h" - -#endif +#ifndef _CONFIG_H +#define _CONFIG_H + +#include "userconfig.h" + +#endif diff --git a/desmume/src/windows/console.cpp b/src/windows/console.cpp similarity index 96% rename from desmume/src/windows/console.cpp rename to src/windows/console.cpp index f38b30ce3..9298b6c78 100644 --- a/desmume/src/windows/console.cpp +++ b/src/windows/console.cpp @@ -1,127 +1,127 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - Copyright 2008 CrazyMax (mtabachenko) - Copyright (C) 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "../common.h" -#include -#include -#include -#include "version.h" - - -///////////////////////////////////////////////////////////////// Console -#if !defined(PUBLIC_RELEASE) || defined(DEVELOPER) -#define BUFFER_SIZE 100 -HANDLE hConsole = NULL; -void printlog(const char *fmt, ...); - -void OpenConsole() -{ - COORD csize; - CONSOLE_SCREEN_BUFFER_INFO csbiInfo; - SMALL_RECT srect; - char buf[256]; - - //dont do anything if we're already attached - if (hConsole) return; - - //attach to an existing console (if we can; this is circuitous because AttachConsole wasnt added until XP) - //remember to abstract this late bound function notion if we end up having to do this anywhere else - bool attached = false; - HMODULE lib = LoadLibrary("kernel32.dll"); - if(lib) - { - typedef BOOL (WINAPI *_TAttachConsole)(DWORD dwProcessId); - _TAttachConsole _AttachConsole = (_TAttachConsole)GetProcAddress(lib,"AttachConsole"); - if(_AttachConsole) - { - if(_AttachConsole(-1)) - attached = true; - } - FreeLibrary(lib); - } - - //if we failed to attach, then alloc a new console - if(!attached) - { - AllocConsole(); - } - - hConsole = GetStdHandle(STD_OUTPUT_HANDLE); - - //redirect stdio - long lStdHandle = (long)hConsole; - int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); - if(hConHandle == -1) - return; //this fails from a visual studio command prompt - - FILE *fp = _fdopen( hConHandle, "w" ); - *stdout = *fp; - //and stderr - *stderr = *fp; - - memset(buf,0,256); - sprintf(buf,"%s OUTPUT", DESMUME_NAME_AND_VERSION); - SetConsoleTitle(TEXT(buf)); - csize.X = 60; - csize.Y = 800; - SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), csize); - GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo); - srect = csbiInfo.srWindow; - srect.Right = srect.Left + 99; - srect.Bottom = srect.Top + 64; - SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &srect); - SetConsoleCP(GetACP()); - SetConsoleOutputCP(GetACP()); - if(attached) printlog("\n"); - printlog("%s\n",DESMUME_NAME_AND_VERSION); - printlog("- compiled: %s %s\n\n",__DATE__,__TIME__); - - -} - -void CloseConsole() { - if (hConsole == NULL) return; - printlog("Closing..."); - FreeConsole(); - hConsole = NULL; -} - -void printlog(const char *fmt, ...) -{ - va_list list; - char msg[512]; - DWORD tmp; - - memset(msg,0,512); - - va_start(list,fmt); - _vsnprintf(msg,511,fmt,list); - va_end(list); - WriteConsole(hConsole,msg, (DWORD)strlen(msg), &tmp, 0); -} -#else - -void OpenConsole() {} -void CloseConsole() {} - -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + Copyright 2008 CrazyMax (mtabachenko) + Copyright (C) 2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "../common.h" +#include +#include +#include +#include "version.h" + + +///////////////////////////////////////////////////////////////// Console +#if !defined(PUBLIC_RELEASE) || defined(DEVELOPER) +#define BUFFER_SIZE 100 +HANDLE hConsole = NULL; +void printlog(const char *fmt, ...); + +void OpenConsole() +{ + COORD csize; + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + SMALL_RECT srect; + char buf[256]; + + //dont do anything if we're already attached + if (hConsole) return; + + //attach to an existing console (if we can; this is circuitous because AttachConsole wasnt added until XP) + //remember to abstract this late bound function notion if we end up having to do this anywhere else + bool attached = false; + HMODULE lib = LoadLibrary("kernel32.dll"); + if(lib) + { + typedef BOOL (WINAPI *_TAttachConsole)(DWORD dwProcessId); + _TAttachConsole _AttachConsole = (_TAttachConsole)GetProcAddress(lib,"AttachConsole"); + if(_AttachConsole) + { + if(_AttachConsole(-1)) + attached = true; + } + FreeLibrary(lib); + } + + //if we failed to attach, then alloc a new console + if(!attached) + { + AllocConsole(); + } + + hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + + //redirect stdio + long lStdHandle = (long)hConsole; + int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + if(hConHandle == -1) + return; //this fails from a visual studio command prompt + + FILE *fp = _fdopen( hConHandle, "w" ); + *stdout = *fp; + //and stderr + *stderr = *fp; + + memset(buf,0,256); + sprintf(buf,"%s OUTPUT", DESMUME_NAME_AND_VERSION); + SetConsoleTitle(TEXT(buf)); + csize.X = 60; + csize.Y = 800; + SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), csize); + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo); + srect = csbiInfo.srWindow; + srect.Right = srect.Left + 99; + srect.Bottom = srect.Top + 64; + SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &srect); + SetConsoleCP(GetACP()); + SetConsoleOutputCP(GetACP()); + if(attached) printlog("\n"); + printlog("%s\n",DESMUME_NAME_AND_VERSION); + printlog("- compiled: %s %s\n\n",__DATE__,__TIME__); + + +} + +void CloseConsole() { + if (hConsole == NULL) return; + printlog("Closing..."); + FreeConsole(); + hConsole = NULL; +} + +void printlog(const char *fmt, ...) +{ + va_list list; + char msg[512]; + DWORD tmp; + + memset(msg,0,512); + + va_start(list,fmt); + _vsnprintf(msg,511,fmt,list); + va_end(list); + WriteConsole(hConsole,msg, (DWORD)strlen(msg), &tmp, 0); +} +#else + +void OpenConsole() {} +void CloseConsole() {} + +#endif diff --git a/desmume/src/windows/console.h b/src/windows/console.h similarity index 95% rename from desmume/src/windows/console.h rename to src/windows/console.h index 193eb8ae2..5da99e387 100644 --- a/desmume/src/windows/console.h +++ b/src/windows/console.h @@ -1,41 +1,41 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright 2008 CrazyMax (mtabachenko) - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -#ifndef _CONSOLE_H_ -#define _CONSOLE_H_ - -#ifdef BETA_VERSION - -#include "../common.h" -#include -#include "debug.h" - -#else - -#define pringlog(...) - -#endif - -void OpenConsole(); -void CloseConsole(); - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright 2008 CrazyMax (mtabachenko) + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +#ifndef _CONSOLE_H_ +#define _CONSOLE_H_ + +#ifdef BETA_VERSION + +#include "../common.h" +#include +#include "debug.h" + +#else + +#define pringlog(...) + +#endif + +void OpenConsole(); +void CloseConsole(); + #endif \ No newline at end of file diff --git a/desmume/src/windows/defaultconfig/SubWCRev.bat b/src/windows/defaultconfig/SubWCRev.bat similarity index 100% rename from desmume/src/windows/defaultconfig/SubWCRev.bat rename to src/windows/defaultconfig/SubWCRev.bat diff --git a/desmume/src/windows/defaultconfig/SubWCRev.exe b/src/windows/defaultconfig/SubWCRev.exe similarity index 100% rename from desmume/src/windows/defaultconfig/SubWCRev.exe rename to src/windows/defaultconfig/SubWCRev.exe diff --git a/desmume/src/windows/defaultconfig/svnrev.h b/src/windows/defaultconfig/svnrev.h similarity index 100% rename from desmume/src/windows/defaultconfig/svnrev.h rename to src/windows/defaultconfig/svnrev.h diff --git a/desmume/src/windows/defaultconfig/svnrev_template.h b/src/windows/defaultconfig/svnrev_template.h similarity index 100% rename from desmume/src/windows/defaultconfig/svnrev_template.h rename to src/windows/defaultconfig/svnrev_template.h diff --git a/desmume/src/windows/defaultconfig/userconfig.h b/src/windows/defaultconfig/userconfig.h similarity index 65% rename from desmume/src/windows/defaultconfig/userconfig.h rename to src/windows/defaultconfig/userconfig.h index c0b89c83c..01d441d71 100644 --- a/desmume/src/windows/defaultconfig/userconfig.h +++ b/src/windows/defaultconfig/userconfig.h @@ -1,17 +1,13 @@ -#ifndef _USERCONFIG_H -#define _USERCONFIG_H - -//this is a default file. it should not be edited, or else you will mess up the defaults. -//to customize your build, place a customized copy in the userconfig directory -//(alongside this defaultconfig directory) - -//disables SSE and SSE2 optimizations (better change it in the vc++ codegen options too) -//note that you may have to use this if your compiler doesn't support standard SSE intrinsics -//#define NOSSE -//#define NOSSE2 - -//#define DEVELOPER //enables dev+ features -//#define GDB_STUB //enables the gdb stub. for some reason this is separate from dev+ for now - - -#endif //_USERCONFIG_H +#ifndef _USERCONFIG_H +#define _USERCONFIG_H + +//this is a default file. it should not be edited, or else you will mess up the defaults. +//to customize your build, place a customized copy in the userconfig directory +//(alongside this defaultconfig directory) + +//#define NOSSE2 //disables SSE2 optimizations (better change it in the vc++ codegen options too) +//#define DEVELOPER //enables dev+ features +//#define GDB_STUB //enables the gdb stub. for some reason this is separate from dev+ for now + + +#endif //_USERCONFIG_H diff --git a/desmume/src/windows/directx/DxErr8.lib b/src/windows/directx/DxErr8.lib similarity index 100% rename from desmume/src/windows/directx/DxErr8.lib rename to src/windows/directx/DxErr8.lib diff --git a/desmume/src/windows/directx/ddraw.h b/src/windows/directx/ddraw.h similarity index 97% rename from desmume/src/windows/directx/ddraw.h rename to src/windows/directx/ddraw.h index e66314bfc..0f204f844 100644 --- a/desmume/src/windows/directx/ddraw.h +++ b/src/windows/directx/ddraw.h @@ -1,5792 +1,5792 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: ddraw.h - * Content: DirectDraw include file - * - ***************************************************************************/ - -#ifndef __DDRAW_INCLUDED__ -#define __DDRAW_INCLUDED__ - -//Disable the nameless union warning when building internally -#undef ENABLE_NAMELESS_UNION_PRAGMA -#ifdef DIRECTX_REDIST -#define ENABLE_NAMELESS_UNION_PRAGMA -#endif - -#ifdef ENABLE_NAMELESS_UNION_PRAGMA -#pragma warning(disable:4201) -#endif - -/* - * If you wish an application built against the newest version of DirectDraw - * to run against an older DirectDraw run time then define DIRECTDRAW_VERSION - * to be the earlies version of DirectDraw you wish to run against. For, - * example if you wish an application to run against a DX 3 runtime define - * DIRECTDRAW_VERSION to be 0x0300. - */ -#ifndef DIRECTDRAW_VERSION -#define DIRECTDRAW_VERSION 0x0700 -#endif /* DIRECTDRAW_VERSION */ - -#if defined( _WIN32 ) && !defined( _NO_COM ) -#define COM_NO_WINDOWS_H -#include -#else -#define IUnknown void -#if !defined( NT_BUILD_ENVIRONMENT ) && !defined(WINNT) - #define CO_E_NOTINITIALIZED 0x800401F0L -#endif -#endif - -#define _FACDD 0x876 -#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) - -#ifdef __cplusplus -extern "C" { -#endif - -// -// For compilers that don't support nameless unions, do a -// -// #define NONAMELESSUNION -// -// before #include -// -#ifndef DUMMYUNIONNAMEN -#if defined(__cplusplus) || !defined(NONAMELESSUNION) -#define DUMMYUNIONNAMEN(n) -#else -#define DUMMYUNIONNAMEN(n) u##n -#endif -#endif - -#ifndef MAKEFOURCC - #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ - ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) -#endif //defined(MAKEFOURCC) - -/* - * FOURCC codes for DX compressed-texture pixel formats - */ -#define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1')) -#define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2')) -#define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3')) -#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4')) -#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5')) - -/* - * GUIDS used by DirectDraw objects - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) - -DEFINE_GUID( CLSID_DirectDraw, 0xD7B70EE0,0x4340,0x11CF,0xB0,0x63,0x00,0x20,0xAF,0xC2,0xCD,0x35 ); -DEFINE_GUID( CLSID_DirectDraw7, 0x3c305196,0x50db,0x11d3,0x9c,0xfe,0x00,0xc0,0x4f,0xd9,0x30,0xc5 ); -DEFINE_GUID( CLSID_DirectDrawClipper, 0x593817A0,0x7DB3,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xb9,0x33,0x56 ); -DEFINE_GUID( IID_IDirectDraw, 0x6C14DB80,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); -DEFINE_GUID( IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 ); -DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 ); -DEFINE_GUID( IID_IDirectDraw7, 0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b ); -DEFINE_GUID( IID_IDirectDrawSurface, 0x6C14DB81,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); -DEFINE_GUID( IID_IDirectDrawSurface2, 0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27 ); -DEFINE_GUID( IID_IDirectDrawSurface3, 0xDA044E00,0x69B2,0x11D0,0xA1,0xD5,0x00,0xAA,0x00,0xB8,0xDF,0xBB ); -DEFINE_GUID( IID_IDirectDrawSurface4, 0x0B2B8630,0xAD35,0x11D0,0x8E,0xA6,0x00,0x60,0x97,0x97,0xEA,0x5B ); -DEFINE_GUID( IID_IDirectDrawSurface7, 0x06675a80,0x3b9b,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b ); -DEFINE_GUID( IID_IDirectDrawPalette, 0x6C14DB84,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); -DEFINE_GUID( IID_IDirectDrawClipper, 0x6C14DB85,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); -DEFINE_GUID( IID_IDirectDrawColorControl, 0x4B9F0EE0,0x0D7E,0x11D0,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8 ); -DEFINE_GUID( IID_IDirectDrawGammaControl, 0x69C11C3E,0xB46B,0x11D1,0xAD,0x7A,0x00,0xC0,0x4F,0xC2,0x9B,0x4E ); - -#endif - -/*============================================================================ - * - * DirectDraw Structures - * - * Various structures used to invoke DirectDraw. - * - *==========================================================================*/ - -struct IDirectDraw; -struct IDirectDrawSurface; -struct IDirectDrawPalette; -struct IDirectDrawClipper; - -typedef struct IDirectDraw FAR *LPDIRECTDRAW; -typedef struct IDirectDraw2 FAR *LPDIRECTDRAW2; -typedef struct IDirectDraw4 FAR *LPDIRECTDRAW4; -typedef struct IDirectDraw7 FAR *LPDIRECTDRAW7; -typedef struct IDirectDrawSurface FAR *LPDIRECTDRAWSURFACE; -typedef struct IDirectDrawSurface2 FAR *LPDIRECTDRAWSURFACE2; -typedef struct IDirectDrawSurface3 FAR *LPDIRECTDRAWSURFACE3; -typedef struct IDirectDrawSurface4 FAR *LPDIRECTDRAWSURFACE4; -typedef struct IDirectDrawSurface7 FAR *LPDIRECTDRAWSURFACE7; -typedef struct IDirectDrawPalette FAR *LPDIRECTDRAWPALETTE; -typedef struct IDirectDrawClipper FAR *LPDIRECTDRAWCLIPPER; -typedef struct IDirectDrawColorControl FAR *LPDIRECTDRAWCOLORCONTROL; -typedef struct IDirectDrawGammaControl FAR *LPDIRECTDRAWGAMMACONTROL; - -typedef struct _DDFXROP FAR *LPDDFXROP; -typedef struct _DDSURFACEDESC FAR *LPDDSURFACEDESC; -typedef struct _DDSURFACEDESC2 FAR *LPDDSURFACEDESC2; -typedef struct _DDCOLORCONTROL FAR *LPDDCOLORCONTROL; - -/* - * API's - */ -#if (defined (WIN32) || defined( _WIN32 ) ) && !defined( _NO_COM ) -//#if defined( _WIN32 ) && !defined( _NO_ENUM ) - typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKA)(GUID FAR *, LPSTR, LPSTR, LPVOID); - typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKW)(GUID FAR *, LPWSTR, LPWSTR, LPVOID); - extern HRESULT WINAPI DirectDrawEnumerateW( LPDDENUMCALLBACKW lpCallback, LPVOID lpContext ); - extern HRESULT WINAPI DirectDrawEnumerateA( LPDDENUMCALLBACKA lpCallback, LPVOID lpContext ); - /* - * Protect against old SDKs - */ - #if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) - #define HMONITOR_DECLARED - DECLARE_HANDLE(HMONITOR); - #endif - typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXA)(GUID FAR *, LPSTR, LPSTR, LPVOID, HMONITOR); - typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXW)(GUID FAR *, LPWSTR, LPWSTR, LPVOID, HMONITOR); - extern HRESULT WINAPI DirectDrawEnumerateExW( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags); - extern HRESULT WINAPI DirectDrawEnumerateExA( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags); - typedef HRESULT (WINAPI * LPDIRECTDRAWENUMERATEEXA)( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags); - typedef HRESULT (WINAPI * LPDIRECTDRAWENUMERATEEXW)( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags); - - #ifdef UNICODE - typedef LPDDENUMCALLBACKW LPDDENUMCALLBACK; - #define DirectDrawEnumerate DirectDrawEnumerateW - typedef LPDDENUMCALLBACKEXW LPDDENUMCALLBACKEX; - typedef LPDIRECTDRAWENUMERATEEXW LPDIRECTDRAWENUMERATEEX; - #define DirectDrawEnumerateEx DirectDrawEnumerateExW - #else - typedef LPDDENUMCALLBACKA LPDDENUMCALLBACK; - #define DirectDrawEnumerate DirectDrawEnumerateA - typedef LPDDENUMCALLBACKEXA LPDDENUMCALLBACKEX; - typedef LPDIRECTDRAWENUMERATEEXA LPDIRECTDRAWENUMERATEEX; - #define DirectDrawEnumerateEx DirectDrawEnumerateExA - #endif - extern HRESULT WINAPI DirectDrawCreate( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter ); - extern HRESULT WINAPI DirectDrawCreateEx( GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid,IUnknown FAR *pUnkOuter ); - extern HRESULT WINAPI DirectDrawCreateClipper( DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter ); -#endif -/* - * Flags for DirectDrawEnumerateEx - * DirectDrawEnumerateEx supercedes DirectDrawEnumerate. You must use GetProcAddress to - * obtain a function pointer (of type LPDIRECTDRAWENUMERATEEX) to DirectDrawEnumerateEx. - * By default, only the primary display device is enumerated. - * DirectDrawEnumerate is equivalent to DirectDrawEnumerate(,,DDENUM_NONDISPLAYDEVICES) - */ - -/* - * This flag causes enumeration of any GDI display devices which are part of - * the Windows Desktop - */ -#define DDENUM_ATTACHEDSECONDARYDEVICES 0x00000001L - -/* - * This flag causes enumeration of any GDI display devices which are not - * part of the Windows Desktop - */ -#define DDENUM_DETACHEDSECONDARYDEVICES 0x00000002L - -/* - * This flag causes enumeration of non-display devices - */ -#define DDENUM_NONDISPLAYDEVICES 0x00000004L - - -#define REGSTR_KEY_DDHW_DESCRIPTION "Description" -#define REGSTR_KEY_DDHW_DRIVERNAME "DriverName" -#define REGSTR_PATH_DDHW "Hardware\\DirectDrawDrivers" - -#define DDCREATE_HARDWAREONLY 0x00000001l -#define DDCREATE_EMULATIONONLY 0x00000002l - -#if defined(WINNT) || !defined(WIN32) -typedef long HRESULT; -#endif - -//#ifndef WINNT -typedef HRESULT (FAR PASCAL * LPDDENUMMODESCALLBACK)(LPDDSURFACEDESC, LPVOID); -typedef HRESULT (FAR PASCAL * LPDDENUMMODESCALLBACK2)(LPDDSURFACEDESC2, LPVOID); -typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK)(LPDIRECTDRAWSURFACE, LPDDSURFACEDESC, LPVOID); -typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK2)(LPDIRECTDRAWSURFACE4, LPDDSURFACEDESC2, LPVOID); -typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK7)(LPDIRECTDRAWSURFACE7, LPDDSURFACEDESC2, LPVOID); -//#endif - -/* - * Generic pixel format with 8-bit RGB and alpha components - */ -typedef struct _DDARGB -{ - BYTE blue; - BYTE green; - BYTE red; - BYTE alpha; -} DDARGB; - -typedef DDARGB FAR *LPDDARGB; - -/* - * This version of the structure remains for backwards source compatibility. - * The DDARGB structure is the one that should be used for all DirectDraw APIs. - */ -typedef struct _DDRGBA -{ - BYTE red; - BYTE green; - BYTE blue; - BYTE alpha; -} DDRGBA; - -typedef DDRGBA FAR *LPDDRGBA; - - -/* - * DDCOLORKEY - */ -typedef struct _DDCOLORKEY -{ - DWORD dwColorSpaceLowValue; // low boundary of color space that is to - // be treated as Color Key, inclusive - DWORD dwColorSpaceHighValue; // high boundary of color space that is - // to be treated as Color Key, inclusive -} DDCOLORKEY; - -typedef DDCOLORKEY FAR* LPDDCOLORKEY; - -/* - * DDBLTFX - * Used to pass override information to the DIRECTDRAWSURFACE callback Blt. - */ -typedef struct _DDBLTFX -{ - DWORD dwSize; // size of structure - DWORD dwDDFX; // FX operations - DWORD dwROP; // Win32 raster operations - DWORD dwDDROP; // Raster operations new for DirectDraw - DWORD dwRotationAngle; // Rotation angle for blt - DWORD dwZBufferOpCode; // ZBuffer compares - DWORD dwZBufferLow; // Low limit of Z buffer - DWORD dwZBufferHigh; // High limit of Z buffer - DWORD dwZBufferBaseDest; // Destination base value - DWORD dwZDestConstBitDepth; // Bit depth used to specify Z constant for destination - union - { - DWORD dwZDestConst; // Constant to use as Z buffer for dest - LPDIRECTDRAWSURFACE lpDDSZBufferDest; // Surface to use as Z buffer for dest - } DUMMYUNIONNAMEN(1); - DWORD dwZSrcConstBitDepth; // Bit depth used to specify Z constant for source - union - { - DWORD dwZSrcConst; // Constant to use as Z buffer for src - LPDIRECTDRAWSURFACE lpDDSZBufferSrc; // Surface to use as Z buffer for src - } DUMMYUNIONNAMEN(2); - DWORD dwAlphaEdgeBlendBitDepth; // Bit depth used to specify constant for alpha edge blend - DWORD dwAlphaEdgeBlend; // Alpha for edge blending - DWORD dwReserved; - DWORD dwAlphaDestConstBitDepth; // Bit depth used to specify alpha constant for destination - union - { - DWORD dwAlphaDestConst; // Constant to use as Alpha Channel - LPDIRECTDRAWSURFACE lpDDSAlphaDest; // Surface to use as Alpha Channel - } DUMMYUNIONNAMEN(3); - DWORD dwAlphaSrcConstBitDepth; // Bit depth used to specify alpha constant for source - union - { - DWORD dwAlphaSrcConst; // Constant to use as Alpha Channel - LPDIRECTDRAWSURFACE lpDDSAlphaSrc; // Surface to use as Alpha Channel - } DUMMYUNIONNAMEN(4); - union - { - DWORD dwFillColor; // color in RGB or Palettized - DWORD dwFillDepth; // depth value for z-buffer - DWORD dwFillPixel; // pixel value for RGBA or RGBZ - LPDIRECTDRAWSURFACE lpDDSPattern; // Surface to use as pattern - } DUMMYUNIONNAMEN(5); - DDCOLORKEY ddckDestColorkey; // DestColorkey override - DDCOLORKEY ddckSrcColorkey; // SrcColorkey override -} DDBLTFX; - -typedef DDBLTFX FAR* LPDDBLTFX; - - - -/* - * DDSCAPS - */ -typedef struct _DDSCAPS -{ - DWORD dwCaps; // capabilities of surface wanted -} DDSCAPS; - -typedef DDSCAPS FAR* LPDDSCAPS; - - -/* - * DDOSCAPS - */ -typedef struct _DDOSCAPS -{ - DWORD dwCaps; // capabilities of surface wanted -} DDOSCAPS; - -typedef DDOSCAPS FAR* LPDDOSCAPS; - -/* - * This structure is used internally by DirectDraw. - */ -typedef struct _DDSCAPSEX -{ - DWORD dwCaps2; - DWORD dwCaps3; - union - { - DWORD dwCaps4; - DWORD dwVolumeDepth; - } DUMMYUNIONNAMEN(1); -} DDSCAPSEX, FAR * LPDDSCAPSEX; - -/* - * DDSCAPS2 - */ -typedef struct _DDSCAPS2 -{ - DWORD dwCaps; // capabilities of surface wanted - DWORD dwCaps2; - DWORD dwCaps3; - union - { - DWORD dwCaps4; - DWORD dwVolumeDepth; - } DUMMYUNIONNAMEN(1); -} DDSCAPS2; - -typedef DDSCAPS2 FAR* LPDDSCAPS2; - -/* - * DDCAPS - */ -#define DD_ROP_SPACE (256/32) // space required to store ROP array -/* - * NOTE: Our choosen structure number scheme is to append a single digit to - * the end of the structure giving the version that structure is associated - * with. - */ - -/* - * This structure represents the DDCAPS structure released in DirectDraw 1.0. It is used internally - * by DirectDraw to interpret caps passed into ddraw by drivers written prior to the release of DirectDraw 2.0. - * New applications should use the DDCAPS structure defined below. - */ -typedef struct _DDCAPS_DX1 -{ - DWORD dwSize; // size of the DDDRIVERCAPS structure - DWORD dwCaps; // driver specific capabilities - DWORD dwCaps2; // more driver specific capabilites - DWORD dwCKeyCaps; // color key capabilities of the surface - DWORD dwFXCaps; // driver specific stretching and effects capabilites - DWORD dwFXAlphaCaps; // alpha driver specific capabilities - DWORD dwPalCaps; // palette capabilities - DWORD dwSVCaps; // stereo vision capabilities - DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 - DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 - DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 - DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 - DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 - DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 - DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 - DWORD dwVidMemTotal; // total amount of video memory - DWORD dwVidMemFree; // amount of free video memory - DWORD dwMaxVisibleOverlays; // maximum number of visible overlays - DWORD dwCurrVisibleOverlays; // current number of visible overlays - DWORD dwNumFourCCCodes; // number of four cc codes - DWORD dwAlignBoundarySrc; // source rectangle alignment - DWORD dwAlignSizeSrc; // source rectangle byte size - DWORD dwAlignBoundaryDest; // dest rectangle alignment - DWORD dwAlignSizeDest; // dest rectangle byte size - DWORD dwAlignStrideAlign; // stride alignment - DWORD dwRops[DD_ROP_SPACE]; // ROPS supported - DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities - DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMinLiveVideoStretch; // OBSOLETE! This field remains for compatability reasons only - DWORD dwMaxLiveVideoStretch; // OBSOLETE! This field remains for compatability reasons only - DWORD dwMinHwCodecStretch; // OBSOLETE! This field remains for compatability reasons only - DWORD dwMaxHwCodecStretch; // OBSOLETE! This field remains for compatability reasons only - DWORD dwReserved1; // reserved - DWORD dwReserved2; // reserved - DWORD dwReserved3; // reserved -} DDCAPS_DX1; - -typedef DDCAPS_DX1 FAR* LPDDCAPS_DX1; - -/* - * This structure is the DDCAPS structure as it was in version 2 and 3 of Direct X. - * It is present for back compatability. - */ -typedef struct _DDCAPS_DX3 -{ - DWORD dwSize; // size of the DDDRIVERCAPS structure - DWORD dwCaps; // driver specific capabilities - DWORD dwCaps2; // more driver specific capabilites - DWORD dwCKeyCaps; // color key capabilities of the surface - DWORD dwFXCaps; // driver specific stretching and effects capabilites - DWORD dwFXAlphaCaps; // alpha driver specific capabilities - DWORD dwPalCaps; // palette capabilities - DWORD dwSVCaps; // stereo vision capabilities - DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 - DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 - DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 - DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 - DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 - DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 - DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 - DWORD dwVidMemTotal; // total amount of video memory - DWORD dwVidMemFree; // amount of free video memory - DWORD dwMaxVisibleOverlays; // maximum number of visible overlays - DWORD dwCurrVisibleOverlays; // current number of visible overlays - DWORD dwNumFourCCCodes; // number of four cc codes - DWORD dwAlignBoundarySrc; // source rectangle alignment - DWORD dwAlignSizeSrc; // source rectangle byte size - DWORD dwAlignBoundaryDest; // dest rectangle alignment - DWORD dwAlignSizeDest; // dest rectangle byte size - DWORD dwAlignStrideAlign; // stride alignment - DWORD dwRops[DD_ROP_SPACE]; // ROPS supported - DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities - DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 - DWORD dwReserved1; // reserved - DWORD dwReserved2; // reserved - DWORD dwReserved3; // reserved - DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts - DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts - DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts - DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts - DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts - DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts - DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts - DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts - DWORD dwSSBCaps; // driver specific capabilities for System->System blts - DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts - DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts - DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts - DWORD dwReserved4; // reserved - DWORD dwReserved5; // reserved - DWORD dwReserved6; // reserved -} DDCAPS_DX3; -typedef DDCAPS_DX3 FAR* LPDDCAPS_DX3; - -/* - * This structure is the DDCAPS structure as it was in version 5 of Direct X. - * It is present for back compatability. - */ -typedef struct _DDCAPS_DX5 -{ -/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure -/* 4*/ DWORD dwCaps; // driver specific capabilities -/* 8*/ DWORD dwCaps2; // more driver specific capabilites -/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface -/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites -/* 14*/ DWORD dwFXAlphaCaps; // alpha driver specific capabilities -/* 18*/ DWORD dwPalCaps; // palette capabilities -/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities -/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 -/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 -/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 -/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 -/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 -/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 -/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 -/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory -/* 40*/ DWORD dwVidMemFree; // amount of free video memory -/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays -/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays -/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes -/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment -/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size -/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment -/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size -/* 60*/ DWORD dwAlignStrideAlign; // stride alignment -/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported -/* 84*/ DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities -/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* a0*/ DWORD dwReserved1; // reserved -/* a4*/ DWORD dwReserved2; // reserved -/* a8*/ DWORD dwReserved3; // reserved -/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts -/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts -/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts -/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts -/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts -/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts -/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts -/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts -/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts -/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts -/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts -/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts -// Members added for DX5: -/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports -/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used -/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts -/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts -/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts -/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts -/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts -/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts -} DDCAPS_DX5; -typedef DDCAPS_DX5 FAR* LPDDCAPS_DX5; - -typedef struct _DDCAPS_DX6 -{ -/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure -/* 4*/ DWORD dwCaps; // driver specific capabilities -/* 8*/ DWORD dwCaps2; // more driver specific capabilites -/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface -/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites -/* 14*/ DWORD dwFXAlphaCaps; // alpha caps -/* 18*/ DWORD dwPalCaps; // palette capabilities -/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities -/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 -/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 -/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 -/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 -/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 -/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 -/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 -/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory -/* 40*/ DWORD dwVidMemFree; // amount of free video memory -/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays -/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays -/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes -/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment -/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size -/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment -/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size -/* 60*/ DWORD dwAlignStrideAlign; // stride alignment -/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported -/* 84*/ DDSCAPS ddsOldCaps; // Was DDSCAPS ddsCaps. ddsCaps is of type DDSCAPS2 for DX6 -/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* a0*/ DWORD dwReserved1; // reserved -/* a4*/ DWORD dwReserved2; // reserved -/* a8*/ DWORD dwReserved3; // reserved -/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts -/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts -/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts -/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts -/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts -/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts -/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts -/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts -/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts -/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts -/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts -/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts -/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports -/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used -/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts -/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts -/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts -/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts -/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts -/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts -// Members added for DX6 release -/*16c*/ DDSCAPS2 ddsCaps; // Surface Caps -} DDCAPS_DX6; -typedef DDCAPS_DX6 FAR* LPDDCAPS_DX6; - -typedef struct _DDCAPS_DX7 -{ -/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure -/* 4*/ DWORD dwCaps; // driver specific capabilities -/* 8*/ DWORD dwCaps2; // more driver specific capabilites -/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface -/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites -/* 14*/ DWORD dwFXAlphaCaps; // alpha driver specific capabilities -/* 18*/ DWORD dwPalCaps; // palette capabilities -/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities -/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 -/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 -/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 -/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 -/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 -/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 -/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 -/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory -/* 40*/ DWORD dwVidMemFree; // amount of free video memory -/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays -/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays -/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes -/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment -/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size -/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment -/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size -/* 60*/ DWORD dwAlignStrideAlign; // stride alignment -/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported -/* 84*/ DDSCAPS ddsOldCaps; // Was DDSCAPS ddsCaps. ddsCaps is of type DDSCAPS2 for DX6 -/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 -/* a0*/ DWORD dwReserved1; // reserved -/* a4*/ DWORD dwReserved2; // reserved -/* a8*/ DWORD dwReserved3; // reserved -/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts -/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts -/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts -/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts -/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts -/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts -/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts -/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts -/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts -/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts -/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts -/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts -/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports -/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used -/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts -/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts -/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts -/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts -/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts -/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts -// Members added for DX6 release -/*16c*/ DDSCAPS2 ddsCaps; // Surface Caps -} DDCAPS_DX7; -typedef DDCAPS_DX7 FAR* LPDDCAPS_DX7; - - -#if DIRECTDRAW_VERSION <= 0x300 - typedef DDCAPS_DX3 DDCAPS; -#elif DIRECTDRAW_VERSION <= 0x500 - typedef DDCAPS_DX5 DDCAPS; -#elif DIRECTDRAW_VERSION <= 0x600 - typedef DDCAPS_DX6 DDCAPS; -#else - typedef DDCAPS_DX7 DDCAPS; -#endif - -typedef DDCAPS FAR* LPDDCAPS; - - - -/* - * DDPIXELFORMAT - */ -typedef struct _DDPIXELFORMAT -{ - DWORD dwSize; // size of structure - DWORD dwFlags; // pixel format flags - DWORD dwFourCC; // (FOURCC code) - union - { - DWORD dwRGBBitCount; // how many bits per pixel - DWORD dwYUVBitCount; // how many bits per pixel - DWORD dwZBufferBitDepth; // how many total bits/pixel in z buffer (including any stencil bits) - DWORD dwAlphaBitDepth; // how many bits for alpha channels - DWORD dwLuminanceBitCount; // how many bits per pixel - DWORD dwBumpBitCount; // how many bits per "buxel", total - DWORD dwPrivateFormatBitCount;// Bits per pixel of private driver formats. Only valid in texture - // format list and if DDPF_D3DFORMAT is set - } DUMMYUNIONNAMEN(1); - union - { - DWORD dwRBitMask; // mask for red bit - DWORD dwYBitMask; // mask for Y bits - DWORD dwStencilBitDepth; // how many stencil bits (note: dwZBufferBitDepth-dwStencilBitDepth is total Z-only bits) - DWORD dwLuminanceBitMask; // mask for luminance bits - DWORD dwBumpDuBitMask; // mask for bump map U delta bits - DWORD dwOperations; // DDPF_D3DFORMAT Operations - } DUMMYUNIONNAMEN(2); - union - { - DWORD dwGBitMask; // mask for green bits - DWORD dwUBitMask; // mask for U bits - DWORD dwZBitMask; // mask for Z bits - DWORD dwBumpDvBitMask; // mask for bump map V delta bits - struct - { - WORD wFlipMSTypes; // Multisample methods supported via flip for this D3DFORMAT - WORD wBltMSTypes; // Multisample methods supported via blt for this D3DFORMAT - } MultiSampleCaps; - - } DUMMYUNIONNAMEN(3); - union - { - DWORD dwBBitMask; // mask for blue bits - DWORD dwVBitMask; // mask for V bits - DWORD dwStencilBitMask; // mask for stencil bits - DWORD dwBumpLuminanceBitMask; // mask for luminance in bump map - } DUMMYUNIONNAMEN(4); - union - { - DWORD dwRGBAlphaBitMask; // mask for alpha channel - DWORD dwYUVAlphaBitMask; // mask for alpha channel - DWORD dwLuminanceAlphaBitMask;// mask for alpha channel - DWORD dwRGBZBitMask; // mask for Z channel - DWORD dwYUVZBitMask; // mask for Z channel - } DUMMYUNIONNAMEN(5); -} DDPIXELFORMAT; - -typedef DDPIXELFORMAT FAR* LPDDPIXELFORMAT; - -/* - * DDOVERLAYFX - */ -typedef struct _DDOVERLAYFX -{ - DWORD dwSize; // size of structure - DWORD dwAlphaEdgeBlendBitDepth; // Bit depth used to specify constant for alpha edge blend - DWORD dwAlphaEdgeBlend; // Constant to use as alpha for edge blend - DWORD dwReserved; - DWORD dwAlphaDestConstBitDepth; // Bit depth used to specify alpha constant for destination - union - { - DWORD dwAlphaDestConst; // Constant to use as alpha channel for dest - LPDIRECTDRAWSURFACE lpDDSAlphaDest; // Surface to use as alpha channel for dest - } DUMMYUNIONNAMEN(1); - DWORD dwAlphaSrcConstBitDepth; // Bit depth used to specify alpha constant for source - union - { - DWORD dwAlphaSrcConst; // Constant to use as alpha channel for src - LPDIRECTDRAWSURFACE lpDDSAlphaSrc; // Surface to use as alpha channel for src - } DUMMYUNIONNAMEN(2); - DDCOLORKEY dckDestColorkey; // DestColorkey override - DDCOLORKEY dckSrcColorkey; // DestColorkey override - DWORD dwDDFX; // Overlay FX - DWORD dwFlags; // flags -} DDOVERLAYFX; - -typedef DDOVERLAYFX FAR *LPDDOVERLAYFX; - - -/* - * DDBLTBATCH: BltBatch entry structure - */ -typedef struct _DDBLTBATCH -{ - LPRECT lprDest; - LPDIRECTDRAWSURFACE lpDDSSrc; - LPRECT lprSrc; - DWORD dwFlags; - LPDDBLTFX lpDDBltFx; -} DDBLTBATCH; - -typedef DDBLTBATCH FAR * LPDDBLTBATCH; - - -/* - * DDGAMMARAMP - */ -typedef struct _DDGAMMARAMP -{ - WORD red[256]; - WORD green[256]; - WORD blue[256]; -} DDGAMMARAMP; -typedef DDGAMMARAMP FAR * LPDDGAMMARAMP; - -/* - * This is the structure within which DirectDraw returns data about the current graphics driver and chipset - */ - -#define MAX_DDDEVICEID_STRING 512 - -typedef struct tagDDDEVICEIDENTIFIER -{ - /* - * These elements are for presentation to the user only. They should not be used to identify particular - * drivers, since this is unreliable and many different strings may be associated with the same - * device, and the same driver from different vendors. - */ - char szDriver[MAX_DDDEVICEID_STRING]; - char szDescription[MAX_DDDEVICEID_STRING]; - - /* - * This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons - * on the whole 64 bits. Caution should be exercised if you use this element to identify problematic - * drivers. It is recommended that guidDeviceIdentifier is used for this purpose. - * - * This version has the form: - * wProduct = HIWORD(liDriverVersion.HighPart) - * wVersion = LOWORD(liDriverVersion.HighPart) - * wSubVersion = HIWORD(liDriverVersion.LowPart) - * wBuild = LOWORD(liDriverVersion.LowPart) - */ -#ifdef _WIN32 - LARGE_INTEGER liDriverVersion; /* Defined for applications and other 32 bit components */ -#else - DWORD dwDriverVersionLowPart; /* Defined for 16 bit driver components */ - DWORD dwDriverVersionHighPart; -#endif - - - /* - * These elements can be used to identify particular chipsets. Use with extreme caution. - * dwVendorId Identifies the manufacturer. May be zero if unknown. - * dwDeviceId Identifies the type of chipset. May be zero if unknown. - * dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown. - * dwRevision Identifies the revision level of the chipset. May be zero if unknown. - */ - DWORD dwVendorId; - DWORD dwDeviceId; - DWORD dwSubSysId; - DWORD dwRevision; - - /* - * This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the - * driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to - * reprofile the graphics subsystem. - * This element can also be used to identify particular problematic drivers. - */ - GUID guidDeviceIdentifier; -} DDDEVICEIDENTIFIER, * LPDDDEVICEIDENTIFIER; - -typedef struct tagDDDEVICEIDENTIFIER2 -{ - /* - * These elements are for presentation to the user only. They should not be used to identify particular - * drivers, since this is unreliable and many different strings may be associated with the same - * device, and the same driver from different vendors. - */ - char szDriver[MAX_DDDEVICEID_STRING]; - char szDescription[MAX_DDDEVICEID_STRING]; - - /* - * This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons - * on the whole 64 bits. Caution should be exercised if you use this element to identify problematic - * drivers. It is recommended that guidDeviceIdentifier is used for this purpose. - * - * This version has the form: - * wProduct = HIWORD(liDriverVersion.HighPart) - * wVersion = LOWORD(liDriverVersion.HighPart) - * wSubVersion = HIWORD(liDriverVersion.LowPart) - * wBuild = LOWORD(liDriverVersion.LowPart) - */ -#ifdef _WIN32 - LARGE_INTEGER liDriverVersion; /* Defined for applications and other 32 bit components */ -#else - DWORD dwDriverVersionLowPart; /* Defined for 16 bit driver components */ - DWORD dwDriverVersionHighPart; -#endif - - - /* - * These elements can be used to identify particular chipsets. Use with extreme caution. - * dwVendorId Identifies the manufacturer. May be zero if unknown. - * dwDeviceId Identifies the type of chipset. May be zero if unknown. - * dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown. - * dwRevision Identifies the revision level of the chipset. May be zero if unknown. - */ - DWORD dwVendorId; - DWORD dwDeviceId; - DWORD dwSubSysId; - DWORD dwRevision; - - /* - * This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the - * driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to - * reprofile the graphics subsystem. - * This element can also be used to identify particular problematic drivers. - */ - GUID guidDeviceIdentifier; - - /* - * This element is used to determine the Windows Hardware Quality Lab (WHQL) - * certification level for this driver/device pair. - */ - DWORD dwWHQLLevel; - -} DDDEVICEIDENTIFIER2, * LPDDDEVICEIDENTIFIER2; - -/* - * Flags for the IDirectDraw4::GetDeviceIdentifier method - */ - -/* - * This flag causes GetDeviceIdentifier to return information about the host (typically 2D) adapter in a system equipped - * with a stacked secondary 3D adapter. Such an adapter appears to the application as if it were part of the - * host adapter, but is typically physcially located on a separate card. The stacked secondary's information is - * returned when GetDeviceIdentifier's dwFlags field is zero, since this most accurately reflects the qualities - * of the DirectDraw object involved. - */ -#define DDGDI_GETHOSTIDENTIFIER 0x00000001L - -/* - * Macros for interpretting DDEVICEIDENTIFIER2.dwWHQLLevel - */ -#define GET_WHQL_YEAR( dwWHQLLevel ) \ - ( (dwWHQLLevel) / 0x10000 ) -#define GET_WHQL_MONTH( dwWHQLLevel ) \ - ( ( (dwWHQLLevel) / 0x100 ) & 0x00ff ) -#define GET_WHQL_DAY( dwWHQLLevel ) \ - ( (dwWHQLLevel) & 0xff ) - - -/* - * callbacks - */ -typedef DWORD (FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper, HWND hWnd, DWORD code, LPVOID lpContext ); -#ifdef STREAMING -typedef DWORD (FAR PASCAL *LPSURFACESTREAMINGCALLBACK)(DWORD); -#endif - - -/* - * INTERACES FOLLOW: - * IDirectDraw - * IDirectDrawClipper - * IDirectDrawPalette - * IDirectDrawSurface - */ - -/* - * IDirectDraw - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDraw -DECLARE_INTERFACE_( IDirectDraw, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDraw methods ***/ - STDMETHOD(Compact)(THIS) PURE; - STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *) PURE; - STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * ) PURE; - STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK ) PURE; - STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK ) PURE; - STDMETHOD(FlipToGDISurface)(THIS) PURE; - STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; - STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC) PURE; - STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; - STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE FAR *) PURE; - STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; - STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; - STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; - STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; - STDMETHOD(RestoreDisplayMode)(THIS) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; - STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD) PURE; - STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDraw_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDraw_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDraw_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDraw_Compact(p) (p)->lpVtbl->Compact(p) -#define IDirectDraw_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) -#define IDirectDraw_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) -#define IDirectDraw_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) -#define IDirectDraw_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) -#define IDirectDraw_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) -#define IDirectDraw_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) -#define IDirectDraw_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) -#define IDirectDraw_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) -#define IDirectDraw_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) -#define IDirectDraw_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) -#define IDirectDraw_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) -#define IDirectDraw_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) -#define IDirectDraw_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) -#define IDirectDraw_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) -#define IDirectDraw_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) -#define IDirectDraw_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) -#define IDirectDraw_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) -#define IDirectDraw_SetDisplayMode(p, a, b, c) (p)->lpVtbl->SetDisplayMode(p, a, b, c) -#define IDirectDraw_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) -#else -#define IDirectDraw_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDraw_AddRef(p) (p)->AddRef() -#define IDirectDraw_Release(p) (p)->Release() -#define IDirectDraw_Compact(p) (p)->Compact() -#define IDirectDraw_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) -#define IDirectDraw_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) -#define IDirectDraw_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) -#define IDirectDraw_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) -#define IDirectDraw_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) -#define IDirectDraw_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) -#define IDirectDraw_FlipToGDISurface(p) (p)->FlipToGDISurface() -#define IDirectDraw_GetCaps(p, a, b) (p)->GetCaps(a, b) -#define IDirectDraw_GetDisplayMode(p, a) (p)->GetDisplayMode(a) -#define IDirectDraw_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) -#define IDirectDraw_GetGDISurface(p, a) (p)->GetGDISurface(a) -#define IDirectDraw_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) -#define IDirectDraw_GetScanLine(p, a) (p)->GetScanLine(a) -#define IDirectDraw_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) -#define IDirectDraw_Initialize(p, a) (p)->Initialize(a) -#define IDirectDraw_RestoreDisplayMode(p) (p)->RestoreDisplayMode() -#define IDirectDraw_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) -#define IDirectDraw_SetDisplayMode(p, a, b, c) (p)->SetDisplayMode(a, b, c) -#define IDirectDraw_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) -#endif - -#endif - -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDraw2 -DECLARE_INTERFACE_( IDirectDraw2, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDraw methods ***/ - STDMETHOD(Compact)(THIS) PURE; - STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *) PURE; - STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * ) PURE; - STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK ) PURE; - STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK ) PURE; - STDMETHOD(FlipToGDISurface)(THIS) PURE; - STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; - STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC) PURE; - STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; - STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE FAR *) PURE; - STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; - STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; - STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; - STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; - STDMETHOD(RestoreDisplayMode)(THIS) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; - STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; - STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS, LPDWORD, LPDWORD) PURE; -}; -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDraw2_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDraw2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDraw2_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDraw2_Compact(p) (p)->lpVtbl->Compact(p) -#define IDirectDraw2_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) -#define IDirectDraw2_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) -#define IDirectDraw2_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) -#define IDirectDraw2_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) -#define IDirectDraw2_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) -#define IDirectDraw2_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) -#define IDirectDraw2_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) -#define IDirectDraw2_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) -#define IDirectDraw2_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) -#define IDirectDraw2_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) -#define IDirectDraw2_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) -#define IDirectDraw2_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) -#define IDirectDraw2_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) -#define IDirectDraw2_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) -#define IDirectDraw2_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) -#define IDirectDraw2_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) -#define IDirectDraw2_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) -#define IDirectDraw2_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) -#define IDirectDraw2_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) -#define IDirectDraw2_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) -#else -#define IDirectDraw2_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDraw2_AddRef(p) (p)->AddRef() -#define IDirectDraw2_Release(p) (p)->Release() -#define IDirectDraw2_Compact(p) (p)->Compact() -#define IDirectDraw2_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) -#define IDirectDraw2_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) -#define IDirectDraw2_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) -#define IDirectDraw2_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) -#define IDirectDraw2_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) -#define IDirectDraw2_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) -#define IDirectDraw2_FlipToGDISurface(p) (p)->FlipToGDISurface() -#define IDirectDraw2_GetCaps(p, a, b) (p)->GetCaps(a, b) -#define IDirectDraw2_GetDisplayMode(p, a) (p)->GetDisplayMode(a) -#define IDirectDraw2_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) -#define IDirectDraw2_GetGDISurface(p, a) (p)->GetGDISurface(a) -#define IDirectDraw2_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) -#define IDirectDraw2_GetScanLine(p, a) (p)->GetScanLine(a) -#define IDirectDraw2_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) -#define IDirectDraw2_Initialize(p, a) (p)->Initialize(a) -#define IDirectDraw2_RestoreDisplayMode(p) (p)->RestoreDisplayMode() -#define IDirectDraw2_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) -#define IDirectDraw2_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) -#define IDirectDraw2_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) -#define IDirectDraw2_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) -#endif - -#endif - -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDraw4 -DECLARE_INTERFACE_( IDirectDraw4, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDraw methods ***/ - STDMETHOD(Compact)(THIS) PURE; - STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE4 FAR *, IUnknown FAR *) PURE; - STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE4, LPDIRECTDRAWSURFACE4 FAR * ) PURE; - STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC2, LPVOID, LPDDENUMMODESCALLBACK2 ) PURE; - STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK2 ) PURE; - STDMETHOD(FlipToGDISurface)(THIS) PURE; - STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; - STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC2) PURE; - STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; - STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE4 FAR *) PURE; - STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; - STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; - STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; - STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; - STDMETHOD(RestoreDisplayMode)(THIS) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; - STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; - STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2, LPDWORD, LPDWORD) PURE; - /*** Added in the V4 Interface ***/ - STDMETHOD(GetSurfaceFromDC) (THIS_ HDC, LPDIRECTDRAWSURFACE4 *) PURE; - STDMETHOD(RestoreAllSurfaces)(THIS) PURE; - STDMETHOD(TestCooperativeLevel)(THIS) PURE; - STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER, DWORD ) PURE; -}; -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDraw4_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDraw4_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDraw4_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDraw4_Compact(p) (p)->lpVtbl->Compact(p) -#define IDirectDraw4_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) -#define IDirectDraw4_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) -#define IDirectDraw4_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) -#define IDirectDraw4_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) -#define IDirectDraw4_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) -#define IDirectDraw4_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) -#define IDirectDraw4_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) -#define IDirectDraw4_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) -#define IDirectDraw4_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) -#define IDirectDraw4_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) -#define IDirectDraw4_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) -#define IDirectDraw4_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) -#define IDirectDraw4_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) -#define IDirectDraw4_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) -#define IDirectDraw4_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) -#define IDirectDraw4_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) -#define IDirectDraw4_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) -#define IDirectDraw4_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) -#define IDirectDraw4_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) -#define IDirectDraw4_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) -#define IDirectDraw4_GetSurfaceFromDC(p, a, b) (p)->lpVtbl->GetSurfaceFromDC(p, a, b) -#define IDirectDraw4_RestoreAllSurfaces(p) (p)->lpVtbl->RestoreAllSurfaces(p) -#define IDirectDraw4_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) -#define IDirectDraw4_GetDeviceIdentifier(p,a,b) (p)->lpVtbl->GetDeviceIdentifier(p,a,b) -#else -#define IDirectDraw4_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDraw4_AddRef(p) (p)->AddRef() -#define IDirectDraw4_Release(p) (p)->Release() -#define IDirectDraw4_Compact(p) (p)->Compact() -#define IDirectDraw4_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) -#define IDirectDraw4_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) -#define IDirectDraw4_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) -#define IDirectDraw4_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) -#define IDirectDraw4_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) -#define IDirectDraw4_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) -#define IDirectDraw4_FlipToGDISurface(p) (p)->FlipToGDISurface() -#define IDirectDraw4_GetCaps(p, a, b) (p)->GetCaps(a, b) -#define IDirectDraw4_GetDisplayMode(p, a) (p)->GetDisplayMode(a) -#define IDirectDraw4_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) -#define IDirectDraw4_GetGDISurface(p, a) (p)->GetGDISurface(a) -#define IDirectDraw4_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) -#define IDirectDraw4_GetScanLine(p, a) (p)->GetScanLine(a) -#define IDirectDraw4_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) -#define IDirectDraw4_Initialize(p, a) (p)->Initialize(a) -#define IDirectDraw4_RestoreDisplayMode(p) (p)->RestoreDisplayMode() -#define IDirectDraw4_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) -#define IDirectDraw4_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) -#define IDirectDraw4_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) -#define IDirectDraw4_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) -#define IDirectDraw4_GetSurfaceFromDC(p, a, b) (p)->GetSurfaceFromDC(a, b) -#define IDirectDraw4_RestoreAllSurfaces(p) (p)->RestoreAllSurfaces() -#define IDirectDraw4_TestCooperativeLevel(p) (p)->TestCooperativeLevel() -#define IDirectDraw4_GetDeviceIdentifier(p,a,b) (p)->GetDeviceIdentifier(a,b) -#endif - -#endif - -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDraw7 -DECLARE_INTERFACE_( IDirectDraw7, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDraw methods ***/ - STDMETHOD(Compact)(THIS) PURE; - STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; - STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE7 FAR *, IUnknown FAR *) PURE; - STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE7, LPDIRECTDRAWSURFACE7 FAR * ) PURE; - STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC2, LPVOID, LPDDENUMMODESCALLBACK2 ) PURE; - STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK7 ) PURE; - STDMETHOD(FlipToGDISurface)(THIS) PURE; - STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; - STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC2) PURE; - STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; - STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE7 FAR *) PURE; - STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; - STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; - STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; - STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; - STDMETHOD(RestoreDisplayMode)(THIS) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; - STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; - STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2, LPDWORD, LPDWORD) PURE; - /*** Added in the V4 Interface ***/ - STDMETHOD(GetSurfaceFromDC) (THIS_ HDC, LPDIRECTDRAWSURFACE7 *) PURE; - STDMETHOD(RestoreAllSurfaces)(THIS) PURE; - STDMETHOD(TestCooperativeLevel)(THIS) PURE; - STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER2, DWORD ) PURE; - STDMETHOD(StartModeTest)(THIS_ LPSIZE, DWORD, DWORD ) PURE; - STDMETHOD(EvaluateMode)(THIS_ DWORD, DWORD * ) PURE; -}; -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDraw7_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDraw7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDraw7_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDraw7_Compact(p) (p)->lpVtbl->Compact(p) -#define IDirectDraw7_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) -#define IDirectDraw7_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) -#define IDirectDraw7_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) -#define IDirectDraw7_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) -#define IDirectDraw7_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) -#define IDirectDraw7_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) -#define IDirectDraw7_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) -#define IDirectDraw7_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) -#define IDirectDraw7_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) -#define IDirectDraw7_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) -#define IDirectDraw7_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) -#define IDirectDraw7_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) -#define IDirectDraw7_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) -#define IDirectDraw7_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) -#define IDirectDraw7_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) -#define IDirectDraw7_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) -#define IDirectDraw7_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) -#define IDirectDraw7_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) -#define IDirectDraw7_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) -#define IDirectDraw7_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) -#define IDirectDraw7_GetSurfaceFromDC(p, a, b) (p)->lpVtbl->GetSurfaceFromDC(p, a, b) -#define IDirectDraw7_RestoreAllSurfaces(p) (p)->lpVtbl->RestoreAllSurfaces(p) -#define IDirectDraw7_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) -#define IDirectDraw7_GetDeviceIdentifier(p,a,b) (p)->lpVtbl->GetDeviceIdentifier(p,a,b) -#define IDirectDraw7_StartModeTest(p,a,b,c) (p)->lpVtbl->StartModeTest(p,a,b,c) -#define IDirectDraw7_EvaluateMode(p,a,b) (p)->lpVtbl->EvaluateMode(p,a,b) -#else -#define IDirectDraw7_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDraw7_AddRef(p) (p)->AddRef() -#define IDirectDraw7_Release(p) (p)->Release() -#define IDirectDraw7_Compact(p) (p)->Compact() -#define IDirectDraw7_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) -#define IDirectDraw7_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) -#define IDirectDraw7_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) -#define IDirectDraw7_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) -#define IDirectDraw7_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) -#define IDirectDraw7_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) -#define IDirectDraw7_FlipToGDISurface(p) (p)->FlipToGDISurface() -#define IDirectDraw7_GetCaps(p, a, b) (p)->GetCaps(a, b) -#define IDirectDraw7_GetDisplayMode(p, a) (p)->GetDisplayMode(a) -#define IDirectDraw7_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) -#define IDirectDraw7_GetGDISurface(p, a) (p)->GetGDISurface(a) -#define IDirectDraw7_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) -#define IDirectDraw7_GetScanLine(p, a) (p)->GetScanLine(a) -#define IDirectDraw7_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) -#define IDirectDraw7_Initialize(p, a) (p)->Initialize(a) -#define IDirectDraw7_RestoreDisplayMode(p) (p)->RestoreDisplayMode() -#define IDirectDraw7_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) -#define IDirectDraw7_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) -#define IDirectDraw7_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) -#define IDirectDraw7_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) -#define IDirectDraw7_GetSurfaceFromDC(p, a, b) (p)->GetSurfaceFromDC(a, b) -#define IDirectDraw7_RestoreAllSurfaces(p) (p)->RestoreAllSurfaces() -#define IDirectDraw7_TestCooperativeLevel(p) (p)->TestCooperativeLevel() -#define IDirectDraw7_GetDeviceIdentifier(p,a,b) (p)->GetDeviceIdentifier(a,b) -#define IDirectDraw7_StartModeTest(p,a,b,c) (p)->lpVtbl->StartModeTest(a,b,c) -#define IDirectDraw7_EvaluateMode(p,a,b) (p)->lpVtbl->EvaluateMode(a,b) -#endif - -#endif - - -/* - * IDirectDrawPalette - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDrawPalette -DECLARE_INTERFACE_( IDirectDrawPalette, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawPalette methods ***/ - STDMETHOD(GetCaps)(THIS_ LPDWORD) PURE; - STDMETHOD(GetEntries)(THIS_ DWORD,DWORD,DWORD,LPPALETTEENTRY) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, DWORD, LPPALETTEENTRY) PURE; - STDMETHOD(SetEntries)(THIS_ DWORD,DWORD,DWORD,LPPALETTEENTRY) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawPalette_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDrawPalette_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawPalette_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawPalette_GetCaps(p, a) (p)->lpVtbl->GetCaps(p, a) -#define IDirectDrawPalette_GetEntries(p, a, b, c, d) (p)->lpVtbl->GetEntries(p, a, b, c, d) -#define IDirectDrawPalette_Initialize(p, a, b, c) (p)->lpVtbl->Initialize(p, a, b, c) -#define IDirectDrawPalette_SetEntries(p, a, b, c, d) (p)->lpVtbl->SetEntries(p, a, b, c, d) -#else -#define IDirectDrawPalette_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDrawPalette_AddRef(p) (p)->AddRef() -#define IDirectDrawPalette_Release(p) (p)->Release() -#define IDirectDrawPalette_GetCaps(p, a) (p)->GetCaps(a) -#define IDirectDrawPalette_GetEntries(p, a, b, c, d) (p)->GetEntries(a, b, c, d) -#define IDirectDrawPalette_Initialize(p, a, b, c) (p)->Initialize(a, b, c) -#define IDirectDrawPalette_SetEntries(p, a, b, c, d) (p)->SetEntries(a, b, c, d) -#endif - -#endif - - -/* - * IDirectDrawClipper - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDrawClipper -DECLARE_INTERFACE_( IDirectDrawClipper, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawClipper methods ***/ - STDMETHOD(GetClipList)(THIS_ LPRECT, LPRGNDATA, LPDWORD) PURE; - STDMETHOD(GetHWnd)(THIS_ HWND FAR *) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, DWORD) PURE; - STDMETHOD(IsClipListChanged)(THIS_ BOOL FAR *) PURE; - STDMETHOD(SetClipList)(THIS_ LPRGNDATA,DWORD) PURE; - STDMETHOD(SetHWnd)(THIS_ DWORD, HWND ) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawClipper_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDrawClipper_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawClipper_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawClipper_GetClipList(p, a, b, c) (p)->lpVtbl->GetClipList(p, a, b, c) -#define IDirectDrawClipper_GetHWnd(p, a) (p)->lpVtbl->GetHWnd(p, a) -#define IDirectDrawClipper_Initialize(p, a, b) (p)->lpVtbl->Initialize(p, a, b) -#define IDirectDrawClipper_IsClipListChanged(p, a) (p)->lpVtbl->IsClipListChanged(p, a) -#define IDirectDrawClipper_SetClipList(p, a, b) (p)->lpVtbl->SetClipList(p, a, b) -#define IDirectDrawClipper_SetHWnd(p, a, b) (p)->lpVtbl->SetHWnd(p, a, b) -#else -#define IDirectDrawClipper_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDrawClipper_AddRef(p) (p)->AddRef() -#define IDirectDrawClipper_Release(p) (p)->Release() -#define IDirectDrawClipper_GetClipList(p, a, b, c) (p)->GetClipList(a, b, c) -#define IDirectDrawClipper_GetHWnd(p, a) (p)->GetHWnd(a) -#define IDirectDrawClipper_Initialize(p, a, b) (p)->Initialize(a, b) -#define IDirectDrawClipper_IsClipListChanged(p, a) (p)->IsClipListChanged(a) -#define IDirectDrawClipper_SetClipList(p, a, b) (p)->SetClipList(a, b) -#define IDirectDrawClipper_SetHWnd(p, a, b) (p)->SetHWnd(a, b) -#endif - -#endif - -/* - * IDirectDrawSurface and related interfaces - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDrawSurface -DECLARE_INTERFACE_( IDirectDrawSurface, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawSurface methods ***/ - STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE) PURE; - STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; - STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE, LPRECT,DWORD, LPDDBLTFX) PURE; - STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; - STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE, LPRECT,DWORD) PURE; - STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE) PURE; - STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; - STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; - STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE, DWORD) PURE; - STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE FAR *) PURE; - STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; - STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; - STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; - STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; - STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; - STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; - STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; - STDMETHOD(IsLost)(THIS) PURE; - STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; - STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; - STDMETHOD(Restore)(THIS) PURE; - STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; - STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; - STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; - STDMETHOD(Unlock)(THIS_ LPVOID) PURE; - STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE,LPRECT,DWORD, LPDDOVERLAYFX) PURE; - STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; - STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawSurface_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectDrawSurface_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawSurface_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawSurface_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) -#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) -#define IDirectDrawSurface_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) -#define IDirectDrawSurface_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) -#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) -#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) -#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) -#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) -#define IDirectDrawSurface_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) -#define IDirectDrawSurface_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) -#define IDirectDrawSurface_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) -#define IDirectDrawSurface_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) -#define IDirectDrawSurface_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) -#define IDirectDrawSurface_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) -#define IDirectDrawSurface_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) -#define IDirectDrawSurface_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) -#define IDirectDrawSurface_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) -#define IDirectDrawSurface_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) -#define IDirectDrawSurface_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) -#define IDirectDrawSurface_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) -#define IDirectDrawSurface_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectDrawSurface_IsLost(p) (p)->lpVtbl->IsLost(p) -#define IDirectDrawSurface_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirectDrawSurface_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) -#define IDirectDrawSurface_Restore(p) (p)->lpVtbl->Restore(p) -#define IDirectDrawSurface_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) -#define IDirectDrawSurface_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) -#define IDirectDrawSurface_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) -#define IDirectDrawSurface_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) -#define IDirectDrawSurface_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) -#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) -#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) -#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) -#else -#define IDirectDrawSurface_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectDrawSurface_AddRef(p) (p)->AddRef() -#define IDirectDrawSurface_Release(p) (p)->Release() -#define IDirectDrawSurface_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) -#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) -#define IDirectDrawSurface_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) -#define IDirectDrawSurface_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) -#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) -#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) -#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) -#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) -#define IDirectDrawSurface_Flip(p,a,b) (p)->Flip(a,b) -#define IDirectDrawSurface_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) -#define IDirectDrawSurface_GetBltStatus(p,a) (p)->GetBltStatus(a) -#define IDirectDrawSurface_GetCaps(p,b) (p)->GetCaps(b) -#define IDirectDrawSurface_GetClipper(p,a) (p)->GetClipper(a) -#define IDirectDrawSurface_GetColorKey(p,a,b) (p)->GetColorKey(a,b) -#define IDirectDrawSurface_GetDC(p,a) (p)->GetDC(a) -#define IDirectDrawSurface_GetFlipStatus(p,a) (p)->GetFlipStatus(a) -#define IDirectDrawSurface_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) -#define IDirectDrawSurface_GetPalette(p,a) (p)->GetPalette(a) -#define IDirectDrawSurface_GetPixelFormat(p,a) (p)->GetPixelFormat(a) -#define IDirectDrawSurface_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) -#define IDirectDrawSurface_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectDrawSurface_IsLost(p) (p)->IsLost() -#define IDirectDrawSurface_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirectDrawSurface_ReleaseDC(p,a) (p)->ReleaseDC(a) -#define IDirectDrawSurface_Restore(p) (p)->Restore() -#define IDirectDrawSurface_SetClipper(p,a) (p)->SetClipper(a) -#define IDirectDrawSurface_SetColorKey(p,a,b) (p)->SetColorKey(a,b) -#define IDirectDrawSurface_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) -#define IDirectDrawSurface_SetPalette(p,a) (p)->SetPalette(a) -#define IDirectDrawSurface_Unlock(p,b) (p)->Unlock(b) -#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) -#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) -#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) -#endif - -/* - * IDirectDrawSurface2 and related interfaces - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface2 -DECLARE_INTERFACE_( IDirectDrawSurface2, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawSurface methods ***/ - STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE2) PURE; - STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; - STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE2, LPRECT,DWORD, LPDDBLTFX) PURE; - STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; - STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE2, LPRECT,DWORD) PURE; - STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE2) PURE; - STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; - STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; - STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE2, DWORD) PURE; - STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE2 FAR *) PURE; - STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; - STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; - STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; - STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; - STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; - STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; - STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; - STDMETHOD(IsLost)(THIS) PURE; - STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; - STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; - STDMETHOD(Restore)(THIS) PURE; - STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; - STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; - STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; - STDMETHOD(Unlock)(THIS_ LPVOID) PURE; - STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE2,LPRECT,DWORD, LPDDOVERLAYFX) PURE; - STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; - STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE2) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; - STDMETHOD(PageLock)(THIS_ DWORD) PURE; - STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawSurface2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectDrawSurface2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawSurface2_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawSurface2_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) -#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) -#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) -#define IDirectDrawSurface2_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) -#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) -#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) -#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) -#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) -#define IDirectDrawSurface2_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) -#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) -#define IDirectDrawSurface2_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) -#define IDirectDrawSurface2_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) -#define IDirectDrawSurface2_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) -#define IDirectDrawSurface2_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) -#define IDirectDrawSurface2_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) -#define IDirectDrawSurface2_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) -#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) -#define IDirectDrawSurface2_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) -#define IDirectDrawSurface2_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) -#define IDirectDrawSurface2_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) -#define IDirectDrawSurface2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectDrawSurface2_IsLost(p) (p)->lpVtbl->IsLost(p) -#define IDirectDrawSurface2_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirectDrawSurface2_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) -#define IDirectDrawSurface2_Restore(p) (p)->lpVtbl->Restore(p) -#define IDirectDrawSurface2_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) -#define IDirectDrawSurface2_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) -#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) -#define IDirectDrawSurface2_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) -#define IDirectDrawSurface2_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) -#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) -#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) -#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) -#define IDirectDrawSurface2_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) -#define IDirectDrawSurface2_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) -#define IDirectDrawSurface2_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) -#else -#define IDirectDrawSurface2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectDrawSurface2_AddRef(p) (p)->AddRef() -#define IDirectDrawSurface2_Release(p) (p)->Release() -#define IDirectDrawSurface2_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) -#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) -#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) -#define IDirectDrawSurface2_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) -#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) -#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) -#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) -#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) -#define IDirectDrawSurface2_Flip(p,a,b) (p)->Flip(a,b) -#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) -#define IDirectDrawSurface2_GetBltStatus(p,a) (p)->GetBltStatus(a) -#define IDirectDrawSurface2_GetCaps(p,b) (p)->GetCaps(b) -#define IDirectDrawSurface2_GetClipper(p,a) (p)->GetClipper(a) -#define IDirectDrawSurface2_GetColorKey(p,a,b) (p)->GetColorKey(a,b) -#define IDirectDrawSurface2_GetDC(p,a) (p)->GetDC(a) -#define IDirectDrawSurface2_GetFlipStatus(p,a) (p)->GetFlipStatus(a) -#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) -#define IDirectDrawSurface2_GetPalette(p,a) (p)->GetPalette(a) -#define IDirectDrawSurface2_GetPixelFormat(p,a) (p)->GetPixelFormat(a) -#define IDirectDrawSurface2_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) -#define IDirectDrawSurface2_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectDrawSurface2_IsLost(p) (p)->IsLost() -#define IDirectDrawSurface2_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirectDrawSurface2_ReleaseDC(p,a) (p)->ReleaseDC(a) -#define IDirectDrawSurface2_Restore(p) (p)->Restore() -#define IDirectDrawSurface2_SetClipper(p,a) (p)->SetClipper(a) -#define IDirectDrawSurface2_SetColorKey(p,a,b) (p)->SetColorKey(a,b) -#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) -#define IDirectDrawSurface2_SetPalette(p,a) (p)->SetPalette(a) -#define IDirectDrawSurface2_Unlock(p,b) (p)->Unlock(b) -#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) -#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) -#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) -#define IDirectDrawSurface2_GetDDInterface(p,a) (p)->GetDDInterface(a) -#define IDirectDrawSurface2_PageLock(p,a) (p)->PageLock(a) -#define IDirectDrawSurface2_PageUnlock(p,a) (p)->PageUnlock(a) -#endif - -/* - * IDirectDrawSurface3 and related interfaces - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface3 -DECLARE_INTERFACE_( IDirectDrawSurface3, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawSurface methods ***/ - STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE3) PURE; - STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; - STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE3, LPRECT,DWORD, LPDDBLTFX) PURE; - STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; - STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE3, LPRECT,DWORD) PURE; - STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE3) PURE; - STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; - STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; - STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE3, DWORD) PURE; - STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE3 FAR *) PURE; - STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; - STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; - STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; - STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; - STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; - STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; - STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; - STDMETHOD(IsLost)(THIS) PURE; - STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; - STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; - STDMETHOD(Restore)(THIS) PURE; - STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; - STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; - STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; - STDMETHOD(Unlock)(THIS_ LPVOID) PURE; - STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE3,LPRECT,DWORD, LPDDOVERLAYFX) PURE; - STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; - STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE3) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; - STDMETHOD(PageLock)(THIS_ DWORD) PURE; - STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; - /*** Added in the V3 interface ***/ - STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC, DWORD) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawSurface3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectDrawSurface3_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawSurface3_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawSurface3_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) -#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) -#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) -#define IDirectDrawSurface3_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) -#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) -#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) -#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) -#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) -#define IDirectDrawSurface3_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) -#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) -#define IDirectDrawSurface3_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) -#define IDirectDrawSurface3_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) -#define IDirectDrawSurface3_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) -#define IDirectDrawSurface3_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) -#define IDirectDrawSurface3_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) -#define IDirectDrawSurface3_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) -#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) -#define IDirectDrawSurface3_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) -#define IDirectDrawSurface3_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) -#define IDirectDrawSurface3_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) -#define IDirectDrawSurface3_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectDrawSurface3_IsLost(p) (p)->lpVtbl->IsLost(p) -#define IDirectDrawSurface3_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirectDrawSurface3_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) -#define IDirectDrawSurface3_Restore(p) (p)->lpVtbl->Restore(p) -#define IDirectDrawSurface3_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) -#define IDirectDrawSurface3_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) -#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) -#define IDirectDrawSurface3_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) -#define IDirectDrawSurface3_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) -#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) -#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) -#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) -#define IDirectDrawSurface3_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) -#define IDirectDrawSurface3_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) -#define IDirectDrawSurface3_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) -#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) -#else -#define IDirectDrawSurface3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectDrawSurface3_AddRef(p) (p)->AddRef() -#define IDirectDrawSurface3_Release(p) (p)->Release() -#define IDirectDrawSurface3_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) -#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) -#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) -#define IDirectDrawSurface3_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) -#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) -#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) -#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) -#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) -#define IDirectDrawSurface3_Flip(p,a,b) (p)->Flip(a,b) -#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) -#define IDirectDrawSurface3_GetBltStatus(p,a) (p)->GetBltStatus(a) -#define IDirectDrawSurface3_GetCaps(p,b) (p)->GetCaps(b) -#define IDirectDrawSurface3_GetClipper(p,a) (p)->GetClipper(a) -#define IDirectDrawSurface3_GetColorKey(p,a,b) (p)->GetColorKey(a,b) -#define IDirectDrawSurface3_GetDC(p,a) (p)->GetDC(a) -#define IDirectDrawSurface3_GetFlipStatus(p,a) (p)->GetFlipStatus(a) -#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) -#define IDirectDrawSurface3_GetPalette(p,a) (p)->GetPalette(a) -#define IDirectDrawSurface3_GetPixelFormat(p,a) (p)->GetPixelFormat(a) -#define IDirectDrawSurface3_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) -#define IDirectDrawSurface3_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectDrawSurface3_IsLost(p) (p)->IsLost() -#define IDirectDrawSurface3_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirectDrawSurface3_ReleaseDC(p,a) (p)->ReleaseDC(a) -#define IDirectDrawSurface3_Restore(p) (p)->Restore() -#define IDirectDrawSurface3_SetClipper(p,a) (p)->SetClipper(a) -#define IDirectDrawSurface3_SetColorKey(p,a,b) (p)->SetColorKey(a,b) -#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) -#define IDirectDrawSurface3_SetPalette(p,a) (p)->SetPalette(a) -#define IDirectDrawSurface3_Unlock(p,b) (p)->Unlock(b) -#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) -#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) -#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) -#define IDirectDrawSurface3_GetDDInterface(p,a) (p)->GetDDInterface(a) -#define IDirectDrawSurface3_PageLock(p,a) (p)->PageLock(a) -#define IDirectDrawSurface3_PageUnlock(p,a) (p)->PageUnlock(a) -#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) -#endif - -/* - * IDirectDrawSurface4 and related interfaces - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface4 -DECLARE_INTERFACE_( IDirectDrawSurface4, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawSurface methods ***/ - STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE4) PURE; - STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; - STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE4, LPRECT,DWORD, LPDDBLTFX) PURE; - STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; - STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE4, LPRECT,DWORD) PURE; - STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE4) PURE; - STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK2) PURE; - STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK2) PURE; - STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE4, DWORD) PURE; - STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2, LPDIRECTDRAWSURFACE4 FAR *) PURE; - STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2) PURE; - STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; - STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; - STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; - STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; - STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; - STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC2) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC2) PURE; - STDMETHOD(IsLost)(THIS) PURE; - STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC2,DWORD,HANDLE) PURE; - STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; - STDMETHOD(Restore)(THIS) PURE; - STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; - STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; - STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; - STDMETHOD(Unlock)(THIS_ LPRECT) PURE; - STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE4,LPRECT,DWORD, LPDDOVERLAYFX) PURE; - STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; - STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE4) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; - STDMETHOD(PageLock)(THIS_ DWORD) PURE; - STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; - /*** Added in the v3 interface ***/ - STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC2, DWORD) PURE; - /*** Added in the v4 interface ***/ - STDMETHOD(SetPrivateData)(THIS_ REFGUID, LPVOID, DWORD, DWORD) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID, LPVOID, LPDWORD) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID) PURE; - STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD) PURE; - STDMETHOD(ChangeUniquenessValue)(THIS) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawSurface4_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectDrawSurface4_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawSurface4_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawSurface4_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) -#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) -#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) -#define IDirectDrawSurface4_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) -#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) -#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) -#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) -#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) -#define IDirectDrawSurface4_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) -#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) -#define IDirectDrawSurface4_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) -#define IDirectDrawSurface4_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) -#define IDirectDrawSurface4_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) -#define IDirectDrawSurface4_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) -#define IDirectDrawSurface4_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) -#define IDirectDrawSurface4_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) -#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) -#define IDirectDrawSurface4_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) -#define IDirectDrawSurface4_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) -#define IDirectDrawSurface4_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) -#define IDirectDrawSurface4_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectDrawSurface4_IsLost(p) (p)->lpVtbl->IsLost(p) -#define IDirectDrawSurface4_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirectDrawSurface4_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) -#define IDirectDrawSurface4_Restore(p) (p)->lpVtbl->Restore(p) -#define IDirectDrawSurface4_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) -#define IDirectDrawSurface4_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) -#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) -#define IDirectDrawSurface4_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) -#define IDirectDrawSurface4_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) -#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) -#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) -#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) -#define IDirectDrawSurface4_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) -#define IDirectDrawSurface4_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) -#define IDirectDrawSurface4_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) -#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) -#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirectDrawSurface4_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirectDrawSurface4_GetUniquenessValue(p, a) (p)->lpVtbl->GetUniquenessValue(p, a) -#define IDirectDrawSurface4_ChangeUniquenessValue(p) (p)->lpVtbl->ChangeUniquenessValue(p) -#else -#define IDirectDrawSurface4_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectDrawSurface4_AddRef(p) (p)->AddRef() -#define IDirectDrawSurface4_Release(p) (p)->Release() -#define IDirectDrawSurface4_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) -#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) -#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) -#define IDirectDrawSurface4_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) -#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) -#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) -#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) -#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) -#define IDirectDrawSurface4_Flip(p,a,b) (p)->Flip(a,b) -#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) -#define IDirectDrawSurface4_GetBltStatus(p,a) (p)->GetBltStatus(a) -#define IDirectDrawSurface4_GetCaps(p,b) (p)->GetCaps(b) -#define IDirectDrawSurface4_GetClipper(p,a) (p)->GetClipper(a) -#define IDirectDrawSurface4_GetColorKey(p,a,b) (p)->GetColorKey(a,b) -#define IDirectDrawSurface4_GetDC(p,a) (p)->GetDC(a) -#define IDirectDrawSurface4_GetFlipStatus(p,a) (p)->GetFlipStatus(a) -#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) -#define IDirectDrawSurface4_GetPalette(p,a) (p)->GetPalette(a) -#define IDirectDrawSurface4_GetPixelFormat(p,a) (p)->GetPixelFormat(a) -#define IDirectDrawSurface4_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) -#define IDirectDrawSurface4_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectDrawSurface4_IsLost(p) (p)->IsLost() -#define IDirectDrawSurface4_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirectDrawSurface4_ReleaseDC(p,a) (p)->ReleaseDC(a) -#define IDirectDrawSurface4_Restore(p) (p)->Restore() -#define IDirectDrawSurface4_SetClipper(p,a) (p)->SetClipper(a) -#define IDirectDrawSurface4_SetColorKey(p,a,b) (p)->SetColorKey(a,b) -#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) -#define IDirectDrawSurface4_SetPalette(p,a) (p)->SetPalette(a) -#define IDirectDrawSurface4_Unlock(p,b) (p)->Unlock(b) -#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) -#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) -#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) -#define IDirectDrawSurface4_GetDDInterface(p,a) (p)->GetDDInterface(a) -#define IDirectDrawSurface4_PageLock(p,a) (p)->PageLock(a) -#define IDirectDrawSurface4_PageUnlock(p,a) (p)->PageUnlock(a) -#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) -#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirectDrawSurface4_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirectDrawSurface4_GetUniquenessValue(p, a) (p)->GetUniquenessValue(a) -#define IDirectDrawSurface4_ChangeUniquenessValue(p) (p)->ChangeUniquenessValue() -#endif - -/* - * IDirectDrawSurface7 and related interfaces - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface7 -DECLARE_INTERFACE_( IDirectDrawSurface7, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawSurface methods ***/ - STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE7) PURE; - STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; - STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE7, LPRECT,DWORD, LPDDBLTFX) PURE; - STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; - STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE7, LPRECT,DWORD) PURE; - STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE7) PURE; - STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK7) PURE; - STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK7) PURE; - STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE7, DWORD) PURE; - STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2, LPDIRECTDRAWSURFACE7 FAR *) PURE; - STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2) PURE; - STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; - STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; - STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; - STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; - STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; - STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; - STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC2) PURE; - STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC2) PURE; - STDMETHOD(IsLost)(THIS) PURE; - STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC2,DWORD,HANDLE) PURE; - STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; - STDMETHOD(Restore)(THIS) PURE; - STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; - STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; - STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; - STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; - STDMETHOD(Unlock)(THIS_ LPRECT) PURE; - STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE7,LPRECT,DWORD, LPDDOVERLAYFX) PURE; - STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; - STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE7) PURE; - /*** Added in the v2 interface ***/ - STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; - STDMETHOD(PageLock)(THIS_ DWORD) PURE; - STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; - /*** Added in the v3 interface ***/ - STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC2, DWORD) PURE; - /*** Added in the v4 interface ***/ - STDMETHOD(SetPrivateData)(THIS_ REFGUID, LPVOID, DWORD, DWORD) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID, LPVOID, LPDWORD) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID) PURE; - STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD) PURE; - STDMETHOD(ChangeUniquenessValue)(THIS) PURE; - /*** Moved Texture7 methods here ***/ - STDMETHOD(SetPriority)(THIS_ DWORD) PURE; - STDMETHOD(GetPriority)(THIS_ LPDWORD) PURE; - STDMETHOD(SetLOD)(THIS_ DWORD) PURE; - STDMETHOD(GetLOD)(THIS_ LPDWORD) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawSurface7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectDrawSurface7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawSurface7_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawSurface7_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) -#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) -#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) -#define IDirectDrawSurface7_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) -#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) -#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) -#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) -#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) -#define IDirectDrawSurface7_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) -#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) -#define IDirectDrawSurface7_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) -#define IDirectDrawSurface7_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) -#define IDirectDrawSurface7_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) -#define IDirectDrawSurface7_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) -#define IDirectDrawSurface7_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) -#define IDirectDrawSurface7_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) -#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) -#define IDirectDrawSurface7_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) -#define IDirectDrawSurface7_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) -#define IDirectDrawSurface7_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) -#define IDirectDrawSurface7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectDrawSurface7_IsLost(p) (p)->lpVtbl->IsLost(p) -#define IDirectDrawSurface7_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirectDrawSurface7_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) -#define IDirectDrawSurface7_Restore(p) (p)->lpVtbl->Restore(p) -#define IDirectDrawSurface7_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) -#define IDirectDrawSurface7_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) -#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) -#define IDirectDrawSurface7_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) -#define IDirectDrawSurface7_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) -#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) -#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) -#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) -#define IDirectDrawSurface7_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) -#define IDirectDrawSurface7_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) -#define IDirectDrawSurface7_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) -#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) -#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirectDrawSurface7_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirectDrawSurface7_GetUniquenessValue(p, a) (p)->lpVtbl->GetUniquenessValue(p, a) -#define IDirectDrawSurface7_ChangeUniquenessValue(p) (p)->lpVtbl->ChangeUniquenessValue(p) -#define IDirectDrawSurface7_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirectDrawSurface7_GetPriority(p,a) (p)->lpVtbl->GetPriority(p,a) -#define IDirectDrawSurface7_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirectDrawSurface7_GetLOD(p,a) (p)->lpVtbl->GetLOD(p,a) -#else -#define IDirectDrawSurface7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectDrawSurface7_AddRef(p) (p)->AddRef() -#define IDirectDrawSurface7_Release(p) (p)->Release() -#define IDirectDrawSurface7_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) -#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) -#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) -#define IDirectDrawSurface7_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) -#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) -#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) -#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) -#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) -#define IDirectDrawSurface7_Flip(p,a,b) (p)->Flip(a,b) -#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) -#define IDirectDrawSurface7_GetBltStatus(p,a) (p)->GetBltStatus(a) -#define IDirectDrawSurface7_GetCaps(p,b) (p)->GetCaps(b) -#define IDirectDrawSurface7_GetClipper(p,a) (p)->GetClipper(a) -#define IDirectDrawSurface7_GetColorKey(p,a,b) (p)->GetColorKey(a,b) -#define IDirectDrawSurface7_GetDC(p,a) (p)->GetDC(a) -#define IDirectDrawSurface7_GetFlipStatus(p,a) (p)->GetFlipStatus(a) -#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) -#define IDirectDrawSurface7_GetPalette(p,a) (p)->GetPalette(a) -#define IDirectDrawSurface7_GetPixelFormat(p,a) (p)->GetPixelFormat(a) -#define IDirectDrawSurface7_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) -#define IDirectDrawSurface7_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectDrawSurface7_IsLost(p) (p)->IsLost() -#define IDirectDrawSurface7_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirectDrawSurface7_ReleaseDC(p,a) (p)->ReleaseDC(a) -#define IDirectDrawSurface7_Restore(p) (p)->Restore() -#define IDirectDrawSurface7_SetClipper(p,a) (p)->SetClipper(a) -#define IDirectDrawSurface7_SetColorKey(p,a,b) (p)->SetColorKey(a,b) -#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) -#define IDirectDrawSurface7_SetPalette(p,a) (p)->SetPalette(a) -#define IDirectDrawSurface7_Unlock(p,b) (p)->Unlock(b) -#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) -#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) -#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) -#define IDirectDrawSurface7_GetDDInterface(p,a) (p)->GetDDInterface(a) -#define IDirectDrawSurface7_PageLock(p,a) (p)->PageLock(a) -#define IDirectDrawSurface7_PageUnlock(p,a) (p)->PageUnlock(a) -#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) -#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirectDrawSurface7_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirectDrawSurface7_GetUniquenessValue(p, a) (p)->GetUniquenessValue(a) -#define IDirectDrawSurface7_ChangeUniquenessValue(p) (p)->ChangeUniquenessValue() -#define IDirectDrawSurface7_SetPriority(p,a) (p)->SetPriority(a) -#define IDirectDrawSurface7_GetPriority(p,a) (p)->GetPriority(a) -#define IDirectDrawSurface7_SetLOD(p,a) (p)->SetLOD(a) -#define IDirectDrawSurface7_GetLOD(p,a) (p)->GetLOD(a) -#endif - - -/* - * IDirectDrawColorControl - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDrawColorControl -DECLARE_INTERFACE_( IDirectDrawColorControl, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawColorControl methods ***/ - STDMETHOD(GetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; - STDMETHOD(SetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawColorControl_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDrawColorControl_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawColorControl_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawColorControl_GetColorControls(p, a) (p)->lpVtbl->GetColorControls(p, a) -#define IDirectDrawColorControl_SetColorControls(p, a) (p)->lpVtbl->SetColorControls(p, a) -#else -#define IDirectDrawColorControl_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDrawColorControl_AddRef(p) (p)->AddRef() -#define IDirectDrawColorControl_Release(p) (p)->Release() -#define IDirectDrawColorControl_GetColorControls(p, a) (p)->GetColorControls(a) -#define IDirectDrawColorControl_SetColorControls(p, a) (p)->SetColorControls(a) -#endif - -#endif - - -/* - * IDirectDrawGammaControl - */ -#if defined( _WIN32 ) && !defined( _NO_COM ) -#undef INTERFACE -#define INTERFACE IDirectDrawGammaControl -DECLARE_INTERFACE_( IDirectDrawGammaControl, IUnknown ) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - /*** IDirectDrawGammaControl methods ***/ - STDMETHOD(GetGammaRamp)(THIS_ DWORD, LPDDGAMMARAMP) PURE; - STDMETHOD(SetGammaRamp)(THIS_ DWORD, LPDDGAMMARAMP) PURE; -}; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectDrawGammaControl_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) -#define IDirectDrawGammaControl_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectDrawGammaControl_Release(p) (p)->lpVtbl->Release(p) -#define IDirectDrawGammaControl_GetGammaRamp(p, a, b) (p)->lpVtbl->GetGammaRamp(p, a, b) -#define IDirectDrawGammaControl_SetGammaRamp(p, a, b) (p)->lpVtbl->SetGammaRamp(p, a, b) -#else -#define IDirectDrawGammaControl_QueryInterface(p, a, b) (p)->QueryInterface(a, b) -#define IDirectDrawGammaControl_AddRef(p) (p)->AddRef() -#define IDirectDrawGammaControl_Release(p) (p)->Release() -#define IDirectDrawGammaControl_GetGammaRamp(p, a, b) (p)->GetGammaRamp(a, b) -#define IDirectDrawGammaControl_SetGammaRamp(p, a, b) (p)->SetGammaRamp(a, b) -#endif - -#endif - - - -#endif - - -/* - * DDSURFACEDESC - */ -typedef struct _DDSURFACEDESC -{ - DWORD dwSize; // size of the DDSURFACEDESC structure - DWORD dwFlags; // determines what fields are valid - DWORD dwHeight; // height of surface to be created - DWORD dwWidth; // width of input surface - union - { - LONG lPitch; // distance to start of next line (return value only) - DWORD dwLinearSize; // Formless late-allocated optimized surface size - } DUMMYUNIONNAMEN(1); - DWORD dwBackBufferCount; // number of back buffers requested - union - { - DWORD dwMipMapCount; // number of mip-map levels requested - DWORD dwZBufferBitDepth; // depth of Z buffer requested - DWORD dwRefreshRate; // refresh rate (used when display mode is described) - } DUMMYUNIONNAMEN(2); - DWORD dwAlphaBitDepth; // depth of alpha buffer requested - DWORD dwReserved; // reserved - LPVOID lpSurface; // pointer to the associated surface memory - DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use - DDCOLORKEY ddckCKDestBlt; // color key for destination blt use - DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use - DDCOLORKEY ddckCKSrcBlt; // color key for source blt use - DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface - DDSCAPS ddsCaps; // direct draw surface capabilities -} DDSURFACEDESC; - -/* - * DDSURFACEDESC2 - */ -typedef struct _DDSURFACEDESC2 -{ - DWORD dwSize; // size of the DDSURFACEDESC structure - DWORD dwFlags; // determines what fields are valid - DWORD dwHeight; // height of surface to be created - DWORD dwWidth; // width of input surface - union - { - LONG lPitch; // distance to start of next line (return value only) - DWORD dwLinearSize; // Formless late-allocated optimized surface size - } DUMMYUNIONNAMEN(1); - union - { - DWORD dwBackBufferCount; // number of back buffers requested - DWORD dwDepth; // the depth if this is a volume texture - } DUMMYUNIONNAMEN(5); - union - { - DWORD dwMipMapCount; // number of mip-map levels requestde - // dwZBufferBitDepth removed, use ddpfPixelFormat one instead - DWORD dwRefreshRate; // refresh rate (used when display mode is described) - DWORD dwSrcVBHandle; // The source used in VB::Optimize - } DUMMYUNIONNAMEN(2); - DWORD dwAlphaBitDepth; // depth of alpha buffer requested - DWORD dwReserved; // reserved - LPVOID lpSurface; // pointer to the associated surface memory - union - { - DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use - DWORD dwEmptyFaceColor; // Physical color for empty cubemap faces - } DUMMYUNIONNAMEN(3); - DDCOLORKEY ddckCKDestBlt; // color key for destination blt use - DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use - DDCOLORKEY ddckCKSrcBlt; // color key for source blt use - union - { - DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface - DWORD dwFVF; // vertex format description of vertex buffers - } DUMMYUNIONNAMEN(4); - DDSCAPS2 ddsCaps; // direct draw surface capabilities - DWORD dwTextureStage; // stage in multitexture cascade -} DDSURFACEDESC2; - -/* - * ddsCaps field is valid. - */ -#define DDSD_CAPS 0x00000001l // default - -/* - * dwHeight field is valid. - */ -#define DDSD_HEIGHT 0x00000002l - -/* - * dwWidth field is valid. - */ -#define DDSD_WIDTH 0x00000004l - -/* - * lPitch is valid. - */ -#define DDSD_PITCH 0x00000008l - -/* - * dwBackBufferCount is valid. - */ -#define DDSD_BACKBUFFERCOUNT 0x00000020l - -/* - * dwZBufferBitDepth is valid. (shouldnt be used in DDSURFACEDESC2) - */ -#define DDSD_ZBUFFERBITDEPTH 0x00000040l - -/* - * dwAlphaBitDepth is valid. - */ -#define DDSD_ALPHABITDEPTH 0x00000080l - - -/* - * lpSurface is valid. - */ -#define DDSD_LPSURFACE 0x00000800l - -/* - * ddpfPixelFormat is valid. - */ -#define DDSD_PIXELFORMAT 0x00001000l - -/* - * ddckCKDestOverlay is valid. - */ -#define DDSD_CKDESTOVERLAY 0x00002000l - -/* - * ddckCKDestBlt is valid. - */ -#define DDSD_CKDESTBLT 0x00004000l - -/* - * ddckCKSrcOverlay is valid. - */ -#define DDSD_CKSRCOVERLAY 0x00008000l - -/* - * ddckCKSrcBlt is valid. - */ -#define DDSD_CKSRCBLT 0x00010000l - -/* - * dwMipMapCount is valid. - */ -#define DDSD_MIPMAPCOUNT 0x00020000l - - /* - * dwRefreshRate is valid - */ -#define DDSD_REFRESHRATE 0x00040000l - -/* - * dwLinearSize is valid - */ -#define DDSD_LINEARSIZE 0x00080000l - -/* - * dwTextureStage is valid - */ -#define DDSD_TEXTURESTAGE 0x00100000l -/* - * dwFVF is valid - */ -#define DDSD_FVF 0x00200000l -/* - * dwSrcVBHandle is valid - */ -#define DDSD_SRCVBHANDLE 0x00400000l - -/* - * dwDepth is valid - */ -#define DDSD_DEPTH 0x00800000l - -/* - * All input fields are valid. - */ -#define DDSD_ALL 0x00fff9eel - -/* - * DDOPTSURFACEDESC - */ -typedef struct _DDOPTSURFACEDESC -{ - DWORD dwSize; // size of the DDOPTSURFACEDESC structure - DWORD dwFlags; // determines what fields are valid - DDSCAPS2 ddSCaps; // Common caps like: Memory type - DDOSCAPS ddOSCaps; // Common caps like: Memory type - GUID guid; // Compression technique GUID - DWORD dwCompressionRatio; // Compression ratio -} DDOPTSURFACEDESC; - -/* - * guid field is valid. - */ -#define DDOSD_GUID 0x00000001l - -/* - * dwCompressionRatio field is valid. - */ -#define DDOSD_COMPRESSION_RATIO 0x00000002l - -/* - * ddSCaps field is valid. - */ -#define DDOSD_SCAPS 0x00000004l - -/* - * ddOSCaps field is valid. - */ -#define DDOSD_OSCAPS 0x00000008l - -/* - * All input fields are valid. - */ -#define DDOSD_ALL 0x0000000fl - -/* - * The surface's optimized pixelformat is compressed - */ -#define DDOSDCAPS_OPTCOMPRESSED 0x00000001l - -/* - * The surface's optimized pixelformat is reordered - */ -#define DDOSDCAPS_OPTREORDERED 0x00000002l - -/* - * The opt surface is a monolithic mipmap - */ -#define DDOSDCAPS_MONOLITHICMIPMAP 0x00000004l - -/* - * The valid Surf caps: - * #define DDSCAPS_SYSTEMMEMORY 0x00000800l - * #define DDSCAPS_VIDEOMEMORY 0x00004000l - * #define DDSCAPS_LOCALVIDMEM 0x10000000l - * #define DDSCAPS_NONLOCALVIDMEM 0x20000000l - */ -#define DDOSDCAPS_VALIDSCAPS 0x30004800l - -/* - * The valid OptSurf caps - */ -#define DDOSDCAPS_VALIDOSCAPS 0x00000007l - - -/* - * DDCOLORCONTROL - */ -typedef struct _DDCOLORCONTROL -{ - DWORD dwSize; - DWORD dwFlags; - LONG lBrightness; - LONG lContrast; - LONG lHue; - LONG lSaturation; - LONG lSharpness; - LONG lGamma; - LONG lColorEnable; - DWORD dwReserved1; -} DDCOLORCONTROL; - - -/* - * lBrightness field is valid. - */ -#define DDCOLOR_BRIGHTNESS 0x00000001l - -/* - * lContrast field is valid. - */ -#define DDCOLOR_CONTRAST 0x00000002l - -/* - * lHue field is valid. - */ -#define DDCOLOR_HUE 0x00000004l - -/* - * lSaturation field is valid. - */ -#define DDCOLOR_SATURATION 0x00000008l - -/* - * lSharpness field is valid. - */ -#define DDCOLOR_SHARPNESS 0x00000010l - -/* - * lGamma field is valid. - */ -#define DDCOLOR_GAMMA 0x00000020l - -/* - * lColorEnable field is valid. - */ -#define DDCOLOR_COLORENABLE 0x00000040l - - - -/*============================================================================ - * - * Direct Draw Capability Flags - * - * These flags are used to describe the capabilities of a given Surface. - * All flags are bit flags. - * - *==========================================================================*/ - -/**************************************************************************** - * - * DIRECTDRAWSURFACE CAPABILITY FLAGS - * - ****************************************************************************/ - -/* - * This bit is reserved. It should not be specified. - */ -#define DDSCAPS_RESERVED1 0x00000001l - -/* - * Indicates that this surface contains alpha-only information. - * (To determine if a surface is RGBA/YUVA, the pixel format must be - * interrogated.) - */ -#define DDSCAPS_ALPHA 0x00000002l - -/* - * Indicates that this surface is a backbuffer. It is generally - * set by CreateSurface when the DDSCAPS_FLIP capability bit is set. - * It indicates that this surface is THE back buffer of a surface - * flipping structure. DirectDraw supports N surfaces in a - * surface flipping structure. Only the surface that immediately - * precedeces the DDSCAPS_FRONTBUFFER has this capability bit set. - * The other surfaces are identified as back buffers by the presence - * of the DDSCAPS_FLIP capability, their attachment order, and the - * absence of the DDSCAPS_FRONTBUFFER and DDSCAPS_BACKBUFFER - * capabilities. The bit is sent to CreateSurface when a standalone - * back buffer is being created. This surface could be attached to - * a front buffer and/or back buffers to form a flipping surface - * structure after the CreateSurface call. See AddAttachments for - * a detailed description of the behaviors in this case. - */ -#define DDSCAPS_BACKBUFFER 0x00000004l - -/* - * Indicates a complex surface structure is being described. A - * complex surface structure results in the creation of more than - * one surface. The additional surfaces are attached to the root - * surface. The complex structure can only be destroyed by - * destroying the root. - */ -#define DDSCAPS_COMPLEX 0x00000008l - -/* - * Indicates that this surface is a part of a surface flipping structure. - * When it is passed to CreateSurface the DDSCAPS_FRONTBUFFER and - * DDSCAP_BACKBUFFER bits are not set. They are set by CreateSurface - * on the resulting creations. The dwBackBufferCount field in the - * DDSURFACEDESC structure must be set to at least 1 in order for - * the CreateSurface call to succeed. The DDSCAPS_COMPLEX capability - * must always be set with creating multiple surfaces through CreateSurface. - */ -#define DDSCAPS_FLIP 0x00000010l - -/* - * Indicates that this surface is THE front buffer of a surface flipping - * structure. It is generally set by CreateSurface when the DDSCAPS_FLIP - * capability bit is set. - * If this capability is sent to CreateSurface then a standalonw front buffer - * is created. This surface will not have the DDSCAPS_FLIP capability. - * It can be attached to other back buffers to form a flipping structure. - * See AddAttachments for a detailed description of the behaviors in this - * case. - */ -#define DDSCAPS_FRONTBUFFER 0x00000020l - -/* - * Indicates that this surface is any offscreen surface that is not an overlay, - * texture, zbuffer, front buffer, back buffer, or alpha surface. It is used - * to identify plain vanilla surfaces. - */ -#define DDSCAPS_OFFSCREENPLAIN 0x00000040l - -/* - * Indicates that this surface is an overlay. It may or may not be directly visible - * depending on whether or not it is currently being overlayed onto the primary - * surface. DDSCAPS_VISIBLE can be used to determine whether or not it is being - * overlayed at the moment. - */ -#define DDSCAPS_OVERLAY 0x00000080l - -/* - * Indicates that unique DirectDrawPalette objects can be created and - * attached to this surface. - */ -#define DDSCAPS_PALETTE 0x00000100l - -/* - * Indicates that this surface is the primary surface. The primary - * surface represents what the user is seeing at the moment. - */ -#define DDSCAPS_PRIMARYSURFACE 0x00000200l - - -/* - * This flag used to be DDSCAPS_PRIMARYSURFACELEFT, which is now - * obsolete. - */ -#define DDSCAPS_RESERVED3 0x00000400l -#define DDSCAPS_PRIMARYSURFACELEFT 0x00000000l - -/* - * Indicates that this surface memory was allocated in system memory - */ -#define DDSCAPS_SYSTEMMEMORY 0x00000800l - -/* - * Indicates that this surface can be used as a 3D texture. It does not - * indicate whether or not the surface is being used for that purpose. - */ -#define DDSCAPS_TEXTURE 0x00001000l - -/* - * Indicates that a surface may be a destination for 3D rendering. This - * bit must be set in order to query for a Direct3D Device Interface - * from this surface. - */ -#define DDSCAPS_3DDEVICE 0x00002000l - -/* - * Indicates that this surface exists in video memory. - */ -#define DDSCAPS_VIDEOMEMORY 0x00004000l - -/* - * Indicates that changes made to this surface are immediately visible. - * It is always set for the primary surface and is set for overlays while - * they are being overlayed and texture maps while they are being textured. - */ -#define DDSCAPS_VISIBLE 0x00008000l - -/* - * Indicates that only writes are permitted to the surface. Read accesses - * from the surface may or may not generate a protection fault, but the - * results of a read from this surface will not be meaningful. READ ONLY. - */ -#define DDSCAPS_WRITEONLY 0x00010000l - -/* - * Indicates that this surface is a z buffer. A z buffer does not contain - * displayable information. Instead it contains bit depth information that is - * used to determine which pixels are visible and which are obscured. - */ -#define DDSCAPS_ZBUFFER 0x00020000l - -/* - * Indicates surface will have a DC associated long term - */ -#define DDSCAPS_OWNDC 0x00040000l - -/* - * Indicates surface should be able to receive live video - */ -#define DDSCAPS_LIVEVIDEO 0x00080000l - -/* - * Indicates surface should be able to have a stream decompressed - * to it by the hardware. - */ -#define DDSCAPS_HWCODEC 0x00100000l - -/* - * Surface is a ModeX surface. - * - */ -#define DDSCAPS_MODEX 0x00200000l - -/* - * Indicates surface is one level of a mip-map. This surface will - * be attached to other DDSCAPS_MIPMAP surfaces to form the mip-map. - * This can be done explicitly, by creating a number of surfaces and - * attaching them with AddAttachedSurface or by implicitly by CreateSurface. - * If this bit is set then DDSCAPS_TEXTURE must also be set. - */ -#define DDSCAPS_MIPMAP 0x00400000l - -/* - * This bit is reserved. It should not be specified. - */ -#define DDSCAPS_RESERVED2 0x00800000l - - -/* - * Indicates that memory for the surface is not allocated until the surface - * is loaded (via the Direct3D texture Load() function). - */ -#define DDSCAPS_ALLOCONLOAD 0x04000000l - -/* - * Indicates that the surface will recieve data from a video port. - */ -#define DDSCAPS_VIDEOPORT 0x08000000l - -/* - * Indicates that a video memory surface is resident in true, local video - * memory rather than non-local video memory. If this flag is specified then - * so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with - * DDSCAPS_NONLOCALVIDMEM. - */ -#define DDSCAPS_LOCALVIDMEM 0x10000000l - -/* - * Indicates that a video memory surface is resident in non-local video - * memory rather than true, local video memory. If this flag is specified - * then so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with - * DDSCAPS_LOCALVIDMEM. - */ -#define DDSCAPS_NONLOCALVIDMEM 0x20000000l - -/* - * Indicates that this surface is a standard VGA mode surface, and not a - * ModeX surface. (This flag will never be set in combination with the - * DDSCAPS_MODEX flag). - */ -#define DDSCAPS_STANDARDVGAMODE 0x40000000l - -/* - * Indicates that this surface will be an optimized surface. This flag is - * currently only valid in conjunction with the DDSCAPS_TEXTURE flag. The surface - * will be created without any underlying video memory until loaded. - */ -#define DDSCAPS_OPTIMIZED 0x80000000l - - - -/* - * This bit is reserved - */ -#define DDSCAPS2_RESERVED4 0x00000002L -#define DDSCAPS2_HARDWAREDEINTERLACE 0x00000000L - -/* - * Indicates to the driver that this surface will be locked very frequently - * (for procedural textures, dynamic lightmaps, etc). Surfaces with this cap - * set must also have DDSCAPS_TEXTURE. This cap cannot be used with - * DDSCAPS2_HINTSTATIC and DDSCAPS2_OPAQUE. - */ -#define DDSCAPS2_HINTDYNAMIC 0x00000004L - -/* - * Indicates to the driver that this surface can be re-ordered/retiled on - * load. This operation will not change the size of the texture. It is - * relatively fast and symmetrical, since the application may lock these - * bits (although it will take a performance hit when doing so). Surfaces - * with this cap set must also have DDSCAPS_TEXTURE. This cap cannot be - * used with DDSCAPS2_HINTDYNAMIC and DDSCAPS2_OPAQUE. - */ -#define DDSCAPS2_HINTSTATIC 0x00000008L - -/* - * Indicates that the client would like this texture surface to be managed by the - * DirectDraw/Direct3D runtime. Surfaces with this cap set must also have - * DDSCAPS_TEXTURE set. - */ -#define DDSCAPS2_TEXTUREMANAGE 0x00000010L - -/* - * These bits are reserved for internal use */ -#define DDSCAPS2_RESERVED1 0x00000020L -#define DDSCAPS2_RESERVED2 0x00000040L - -/* - * Indicates to the driver that this surface will never be locked again. - * The driver is free to optimize this surface via retiling and actual compression. - * All calls to Lock() or Blts from this surface will fail. Surfaces with this - * cap set must also have DDSCAPS_TEXTURE. This cap cannot be used with - * DDSCAPS2_HINTDYNAMIC and DDSCAPS2_HINTSTATIC. - */ -#define DDSCAPS2_OPAQUE 0x00000080L - -/* - * Applications should set this bit at CreateSurface time to indicate that they - * intend to use antialiasing. Only valid if DDSCAPS_3DDEVICE is also set. - */ -#define DDSCAPS2_HINTANTIALIASING 0x00000100L - - -/* - * This flag is used at CreateSurface time to indicate that this set of - * surfaces is a cubic environment map - */ -#define DDSCAPS2_CUBEMAP 0x00000200L - -/* - * These flags preform two functions: - * - At CreateSurface time, they define which of the six cube faces are - * required by the application. - * - After creation, each face in the cubemap will have exactly one of these - * bits set. - */ -#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400L -#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800L -#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000L -#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000L -#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000L -#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000L - -/* - * This macro may be used to specify all faces of a cube map at CreateSurface time - */ -#define DDSCAPS2_CUBEMAP_ALLFACES ( DDSCAPS2_CUBEMAP_POSITIVEX |\ - DDSCAPS2_CUBEMAP_NEGATIVEX |\ - DDSCAPS2_CUBEMAP_POSITIVEY |\ - DDSCAPS2_CUBEMAP_NEGATIVEY |\ - DDSCAPS2_CUBEMAP_POSITIVEZ |\ - DDSCAPS2_CUBEMAP_NEGATIVEZ ) - - -/* - * This flag is an additional flag which is present on mipmap sublevels from DX7 onwards - * It enables easier use of GetAttachedSurface rather than EnumAttachedSurfaces for surface - * constructs such as Cube Maps, wherein there are more than one mipmap surface attached - * to the root surface. - * This caps bit is ignored by CreateSurface - */ -#define DDSCAPS2_MIPMAPSUBLEVEL 0x00010000L - -/* This flag indicates that the texture should be managed by D3D only */ -#define DDSCAPS2_D3DTEXTUREMANAGE 0x00020000L - -/* This flag indicates that the managed surface can be safely lost */ -#define DDSCAPS2_DONOTPERSIST 0x00040000L - -/* indicates that this surface is part of a stereo flipping chain */ -#define DDSCAPS2_STEREOSURFACELEFT 0x00080000L - - -/* - * Indicates that the surface is a volume. - * Can be combined with DDSCAPS_MIPMAP to indicate a multi-level volume - */ -#define DDSCAPS2_VOLUME 0x00200000L - -/* - * Indicates that the surface may be locked multiple times by the application. - * This cap cannot be used with DDSCAPS2_OPAQUE. - */ -#define DDSCAPS2_NOTUSERLOCKABLE 0x00400000L - -/* - * Indicates that the vertex buffer data can be used to render points and - * point sprites. - */ -#define DDSCAPS2_POINTS 0x00800000L - -/* - * Indicates that the vertex buffer data can be used to render rt pactches. - */ -#define DDSCAPS2_RTPATCHES 0x01000000L - -/* - * Indicates that the vertex buffer data can be used to render n patches. - */ -#define DDSCAPS2_NPATCHES 0x02000000L - -/* - * This bit is reserved for internal use - */ -#define DDSCAPS2_RESERVED3 0x04000000L - - -/* - * Indicates that the contents of the backbuffer do not have to be preserved - * the contents of the backbuffer after they are presented. - */ -#define DDSCAPS2_DISCARDBACKBUFFER 0x10000000L - -/* - * Indicates that all surfaces in this creation chain should be given an alpha channel. - * This flag will be set on primary surface chains that may have no explicit pixel format - * (and thus take on the format of the current display mode). - * The driver should infer that all these surfaces have a format having an alpha channel. - * (e.g. assume D3DFMT_A8R8G8B8 if the display mode is x888.) - */ -#define DDSCAPS2_ENABLEALPHACHANNEL 0x20000000L - -/* - * Indicates that all surfaces in this creation chain is extended primary surface format. - * This flag will be set on extended primary surface chains that always have explicit pixel - * format and the pixel format is typically GDI (Graphics Device Interface) couldn't handle, - * thus only used with fullscreen application. (e.g. D3DFMT_A2R10G10B10 format) - */ -#define DDSCAPS2_EXTENDEDFORMATPRIMARY 0x40000000L - -/* - * Indicates that all surfaces in this creation chain is additional primary surface. - * This flag will be set on primary surface chains which must present on the adapter - * id provided on dwCaps4. Typically this will be used to create secondary primary surface - * on DualView display adapter. - */ -#define DDSCAPS2_ADDITIONALPRIMARY 0x80000000L - -/* - * This is a mask that indicates the set of bits that may be set - * at createsurface time to indicate number of samples per pixel - * when multisampling - */ -#define DDSCAPS3_MULTISAMPLE_MASK 0x0000001FL - -/* - * This is a mask that indicates the set of bits that may be set - * at createsurface time to indicate the quality level of rendering - * for the current number of samples per pixel - */ -#define DDSCAPS3_MULTISAMPLE_QUALITY_MASK 0x000000E0L -#define DDSCAPS3_MULTISAMPLE_QUALITY_SHIFT 5 - -/* - * This bit is reserved for internal use - */ -#define DDSCAPS3_RESERVED1 0x00000100L - -/* - * This bit is reserved for internal use - */ -#define DDSCAPS3_RESERVED2 0x00000200L - -/* - * This indicates whether this surface has light-weight miplevels - */ -#define DDSCAPS3_LIGHTWEIGHTMIPMAP 0x00000400L - -/* - * This indicates that the mipsublevels for this surface are auto-generated - */ -#define DDSCAPS3_AUTOGENMIPMAP 0x00000800L - -/* - * This indicates that the mipsublevels for this surface are auto-generated - */ -#define DDSCAPS3_DMAP 0x00001000L - - - /**************************************************************************** - * - * DIRECTDRAW DRIVER CAPABILITY FLAGS - * - ****************************************************************************/ - -/* - * Display hardware has 3D acceleration. - */ -#define DDCAPS_3D 0x00000001l - -/* - * Indicates that DirectDraw will support only dest rectangles that are aligned - * on DIRECTDRAWCAPS.dwAlignBoundaryDest boundaries of the surface, respectively. - * READ ONLY. - */ -#define DDCAPS_ALIGNBOUNDARYDEST 0x00000002l - -/* - * Indicates that DirectDraw will support only source rectangles whose sizes in - * BYTEs are DIRECTDRAWCAPS.dwAlignSizeDest multiples, respectively. READ ONLY. - */ -#define DDCAPS_ALIGNSIZEDEST 0x00000004l -/* - * Indicates that DirectDraw will support only source rectangles that are aligned - * on DIRECTDRAWCAPS.dwAlignBoundarySrc boundaries of the surface, respectively. - * READ ONLY. - */ -#define DDCAPS_ALIGNBOUNDARYSRC 0x00000008l - -/* - * Indicates that DirectDraw will support only source rectangles whose sizes in - * BYTEs are DIRECTDRAWCAPS.dwAlignSizeSrc multiples, respectively. READ ONLY. - */ -#define DDCAPS_ALIGNSIZESRC 0x00000010l - -/* - * Indicates that DirectDraw will create video memory surfaces that have a stride - * alignment equal to DIRECTDRAWCAPS.dwAlignStride. READ ONLY. - */ -#define DDCAPS_ALIGNSTRIDE 0x00000020l - -/* - * Display hardware is capable of blt operations. - */ -#define DDCAPS_BLT 0x00000040l - -/* - * Display hardware is capable of asynchronous blt operations. - */ -#define DDCAPS_BLTQUEUE 0x00000080l - -/* - * Display hardware is capable of color space conversions during the blt operation. - */ -#define DDCAPS_BLTFOURCC 0x00000100l - -/* - * Display hardware is capable of stretching during blt operations. - */ -#define DDCAPS_BLTSTRETCH 0x00000200l - -/* - * Display hardware is shared with GDI. - */ -#define DDCAPS_GDI 0x00000400l - -/* - * Display hardware can overlay. - */ -#define DDCAPS_OVERLAY 0x00000800l - -/* - * Set if display hardware supports overlays but can not clip them. - */ -#define DDCAPS_OVERLAYCANTCLIP 0x00001000l - -/* - * Indicates that overlay hardware is capable of color space conversions during - * the overlay operation. - */ -#define DDCAPS_OVERLAYFOURCC 0x00002000l - -/* - * Indicates that stretching can be done by the overlay hardware. - */ -#define DDCAPS_OVERLAYSTRETCH 0x00004000l - -/* - * Indicates that unique DirectDrawPalettes can be created for DirectDrawSurfaces - * other than the primary surface. - */ -#define DDCAPS_PALETTE 0x00008000l - -/* - * Indicates that palette changes can be syncd with the veritcal refresh. - */ -#define DDCAPS_PALETTEVSYNC 0x00010000l - -/* - * Display hardware can return the current scan line. - */ -#define DDCAPS_READSCANLINE 0x00020000l - - -/* - * This flag used to bo DDCAPS_STEREOVIEW, which is now obsolete - */ -#define DDCAPS_RESERVED1 0x00040000l - -/* - * Display hardware is capable of generating a vertical blank interrupt. - */ -#define DDCAPS_VBI 0x00080000l - -/* - * Supports the use of z buffers with blt operations. - */ -#define DDCAPS_ZBLTS 0x00100000l - -/* - * Supports Z Ordering of overlays. - */ -#define DDCAPS_ZOVERLAYS 0x00200000l - -/* - * Supports color key - */ -#define DDCAPS_COLORKEY 0x00400000l - -/* - * Supports alpha surfaces - */ -#define DDCAPS_ALPHA 0x00800000l - -/* - * colorkey is hardware assisted(DDCAPS_COLORKEY will also be set) - */ -#define DDCAPS_COLORKEYHWASSIST 0x01000000l - -/* - * no hardware support at all - */ -#define DDCAPS_NOHARDWARE 0x02000000l - -/* - * Display hardware is capable of color fill with bltter - */ -#define DDCAPS_BLTCOLORFILL 0x04000000l - -/* - * Display hardware is bank switched, and potentially very slow at - * random access to VRAM. - */ -#define DDCAPS_BANKSWITCHED 0x08000000l - -/* - * Display hardware is capable of depth filling Z-buffers with bltter - */ -#define DDCAPS_BLTDEPTHFILL 0x10000000l - -/* - * Display hardware is capable of clipping while bltting. - */ -#define DDCAPS_CANCLIP 0x20000000l - -/* - * Display hardware is capable of clipping while stretch bltting. - */ -#define DDCAPS_CANCLIPSTRETCHED 0x40000000l - -/* - * Display hardware is capable of bltting to or from system memory - */ -#define DDCAPS_CANBLTSYSMEM 0x80000000l - - - /**************************************************************************** - * - * MORE DIRECTDRAW DRIVER CAPABILITY FLAGS (dwCaps2) - * - ****************************************************************************/ - -/* - * Display hardware is certified - */ -#define DDCAPS2_CERTIFIED 0x00000001l - -/* - * Driver cannot interleave 2D operations (lock and blt) to surfaces with - * Direct3D rendering operations between calls to BeginScene() and EndScene() - */ -#define DDCAPS2_NO2DDURING3DSCENE 0x00000002l - -/* - * Display hardware contains a video port - */ -#define DDCAPS2_VIDEOPORT 0x00000004l - -/* - * The overlay can be automatically flipped according to the video port - * VSYNCs, providing automatic doubled buffered display of video port - * data using an overlay - */ -#define DDCAPS2_AUTOFLIPOVERLAY 0x00000008l - -/* - * Overlay can display each field of interlaced data individually while - * it is interleaved in memory without causing jittery artifacts. - */ -#define DDCAPS2_CANBOBINTERLEAVED 0x00000010l - -/* - * Overlay can display each field of interlaced data individually while - * it is not interleaved in memory without causing jittery artifacts. - */ -#define DDCAPS2_CANBOBNONINTERLEAVED 0x00000020l - -/* - * The overlay surface contains color controls (brightness, sharpness, etc.) - */ -#define DDCAPS2_COLORCONTROLOVERLAY 0x00000040l - -/* - * The primary surface contains color controls (gamma, etc.) - */ -#define DDCAPS2_COLORCONTROLPRIMARY 0x00000080l - -/* - * RGBZ -> RGB supported for 16:16 RGB:Z - */ -#define DDCAPS2_CANDROPZ16BIT 0x00000100l - -/* - * Driver supports non-local video memory. - */ -#define DDCAPS2_NONLOCALVIDMEM 0x00000200l - -/* - * Dirver supports non-local video memory but has different capabilities for - * non-local video memory surfaces. If this bit is set then so must - * DDCAPS2_NONLOCALVIDMEM. - */ -#define DDCAPS2_NONLOCALVIDMEMCAPS 0x00000400l - -/* - * Driver neither requires nor prefers surfaces to be pagelocked when performing - * blts involving system memory surfaces - */ -#define DDCAPS2_NOPAGELOCKREQUIRED 0x00000800l - -/* - * Driver can create surfaces which are wider than the primary surface - */ -#define DDCAPS2_WIDESURFACES 0x00001000l - -/* - * Driver supports bob without using a video port by handling the - * DDFLIP_ODD and DDFLIP_EVEN flags specified in Flip. - */ -#define DDCAPS2_CANFLIPODDEVEN 0x00002000l - -/* - * Driver supports bob using hardware - */ -#define DDCAPS2_CANBOBHARDWARE 0x00004000l - -/* - * Driver supports bltting any FOURCC surface to another surface of the same FOURCC - */ -#define DDCAPS2_COPYFOURCC 0x00008000l - - -/* - * Driver supports loadable gamma ramps for the primary surface - */ -#define DDCAPS2_PRIMARYGAMMA 0x00020000l - -/* - * Driver can render in windowed mode. - */ -#define DDCAPS2_CANRENDERWINDOWED 0x00080000l - -/* - * A calibrator is available to adjust the gamma ramp according to the - * physical display properties so that the result will be identical on - * all calibrated systems. - */ -#define DDCAPS2_CANCALIBRATEGAMMA 0x00100000l - -/* - * Indicates that the driver will respond to DDFLIP_INTERVALn flags - */ -#define DDCAPS2_FLIPINTERVAL 0x00200000l - -/* - * Indicates that the driver will respond to DDFLIP_NOVSYNC - */ -#define DDCAPS2_FLIPNOVSYNC 0x00400000l - -/* - * Driver supports management of video memory, if this flag is ON, - * driver manages the texture if requested with DDSCAPS2_TEXTUREMANAGE on - * DirectX manages the texture if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on - */ -#define DDCAPS2_CANMANAGETEXTURE 0x00800000l - -/* - * The Direct3D texture manager uses this cap to decide whether to put managed - * surfaces in non-local video memory. If the cap is set, the texture manager will - * put managed surfaces in non-local vidmem. Drivers that cannot texture from - * local vidmem SHOULD NOT set this cap. - */ -#define DDCAPS2_TEXMANINNONLOCALVIDMEM 0x01000000l - -/* - * Indicates that the driver supports DX7 type of stereo in at least one mode (which may - * not necessarily be the current mode). Applications should use IDirectDraw7 (or higher) - * ::EnumDisplayModes and check the DDSURFACEDESC.ddsCaps.dwCaps2 field for the presence of - * DDSCAPS2_STEREOSURFACELEFT to check if a particular mode supports stereo. The application - * can also use IDirectDraw7(or higher)::GetDisplayMode to check the current mode. - */ -#define DDCAPS2_STEREO 0x02000000L - -/* - * This caps bit is intended for internal DirectDraw use. - * -It is only valid if DDCAPS2_NONLOCALVIDMEMCAPS is set. - * -If this bit is set, then DDCAPS_CANBLTSYSMEM MUST be set by the driver (and - * all the assoicated system memory blt caps must be correct). - * -It implies that the system->video blt caps in DDCAPS also apply to system to - * nonlocal blts. I.e. the dwSVBCaps, dwSVBCKeyCaps, dwSVBFXCaps and dwSVBRops - * members of DDCAPS (DDCORECAPS) are filled in correctly. - * -Any blt from system to nonlocal memory that matches these caps bits will - * be passed to the driver. - * - * NOTE: This is intended to enable the driver itself to do efficient reordering - * of textures. This is NOT meant to imply that hardware can write into AGP memory. - * This operation is not currently supported. - */ -#define DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL 0x04000000L - -/* - * was DDCAPS2_PUREHAL - */ -#define DDCAPS2_RESERVED1 0x08000000L - -/* - * Driver supports management of video memory, if this flag is ON, - * driver manages the resource if requested with DDSCAPS2_TEXTUREMANAGE on - * DirectX manages the resource if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on - */ -#define DDCAPS2_CANMANAGERESOURCE 0x10000000L - -/* - * Driver supports dynamic textures. This will allow the application to set - * D3DUSAGE_DYNAMIC (DDSCAPS2_HINTDYNAMIC for drivers) at texture create time. - * Video memory dynamic textures WILL be lockable by applications. It is - * expected that these locks will be very efficient (which implies that the - * driver should always maintain a linear copy, a pointer to which can be - * quickly handed out to the application). - */ -#define DDCAPS2_DYNAMICTEXTURES 0x20000000L - -/* - * Driver supports auto-generation of mipmaps. - */ -#define DDCAPS2_CANAUTOGENMIPMAP 0x40000000L - - -/**************************************************************************** - * - * DIRECTDRAW FX ALPHA CAPABILITY FLAGS - * - ****************************************************************************/ - -/* - * Supports alpha blending around the edge of a source color keyed surface. - * For Blt. - */ -#define DDFXALPHACAPS_BLTALPHAEDGEBLEND 0x00000001l - -/* - * Supports alpha information in the pixel format. The bit depth of alpha - * information in the pixel format can be 1,2,4, or 8. The alpha value becomes - * more opaque as the alpha value increases. (0 is transparent.) - * For Blt. - */ -#define DDFXALPHACAPS_BLTALPHAPIXELS 0x00000002l - -/* - * Supports alpha information in the pixel format. The bit depth of alpha - * information in the pixel format can be 1,2,4, or 8. The alpha value - * becomes more transparent as the alpha value increases. (0 is opaque.) - * This flag can only be set if DDCAPS_ALPHA is set. - * For Blt. - */ -#define DDFXALPHACAPS_BLTALPHAPIXELSNEG 0x00000004l - -/* - * Supports alpha only surfaces. The bit depth of an alpha only surface can be - * 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases. - * (0 is transparent.) - * For Blt. - */ -#define DDFXALPHACAPS_BLTALPHASURFACES 0x00000008l - -/* - * The depth of the alpha channel data can range can be 1,2,4, or 8. - * The NEG suffix indicates that this alpha channel becomes more transparent - * as the alpha value increases. (0 is opaque.) This flag can only be set if - * DDCAPS_ALPHA is set. - * For Blt. - */ -#define DDFXALPHACAPS_BLTALPHASURFACESNEG 0x00000010l - -/* - * Supports alpha blending around the edge of a source color keyed surface. - * For Overlays. - */ -#define DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND 0x00000020l - -/* - * Supports alpha information in the pixel format. The bit depth of alpha - * information in the pixel format can be 1,2,4, or 8. The alpha value becomes - * more opaque as the alpha value increases. (0 is transparent.) - * For Overlays. - */ -#define DDFXALPHACAPS_OVERLAYALPHAPIXELS 0x00000040l - -/* - * Supports alpha information in the pixel format. The bit depth of alpha - * information in the pixel format can be 1,2,4, or 8. The alpha value - * becomes more transparent as the alpha value increases. (0 is opaque.) - * This flag can only be set if DDCAPS_ALPHA is set. - * For Overlays. - */ -#define DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG 0x00000080l - -/* - * Supports alpha only surfaces. The bit depth of an alpha only surface can be - * 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases. - * (0 is transparent.) - * For Overlays. - */ -#define DDFXALPHACAPS_OVERLAYALPHASURFACES 0x00000100l - -/* - * The depth of the alpha channel data can range can be 1,2,4, or 8. - * The NEG suffix indicates that this alpha channel becomes more transparent - * as the alpha value increases. (0 is opaque.) This flag can only be set if - * DDCAPS_ALPHA is set. - * For Overlays. - */ -#define DDFXALPHACAPS_OVERLAYALPHASURFACESNEG 0x00000200l - -#if DIRECTDRAW_VERSION < 0x0600 -#endif //DIRECTDRAW_VERSION - - -/**************************************************************************** - * - * DIRECTDRAW FX CAPABILITY FLAGS - * - ****************************************************************************/ - -/* - * Uses arithmetic operations to stretch and shrink surfaces during blt - * rather than pixel doubling techniques. Along the Y axis. - */ -#define DDFXCAPS_BLTARITHSTRETCHY 0x00000020l - -/* - * Uses arithmetic operations to stretch during blt - * rather than pixel doubling techniques. Along the Y axis. Only - * works for x1, x2, etc. - */ -#define DDFXCAPS_BLTARITHSTRETCHYN 0x00000010l - -/* - * Supports mirroring left to right in blt. - */ -#define DDFXCAPS_BLTMIRRORLEFTRIGHT 0x00000040l - -/* - * Supports mirroring top to bottom in blt. - */ -#define DDFXCAPS_BLTMIRRORUPDOWN 0x00000080l - -/* - * Supports arbitrary rotation for blts. - */ -#define DDFXCAPS_BLTROTATION 0x00000100l - -/* - * Supports 90 degree rotations for blts. - */ -#define DDFXCAPS_BLTROTATION90 0x00000200l - -/* - * DirectDraw supports arbitrary shrinking of a surface along the - * x axis (horizontal direction) for blts. - */ -#define DDFXCAPS_BLTSHRINKX 0x00000400l - -/* - * DirectDraw supports integer shrinking (1x,2x,) of a surface - * along the x axis (horizontal direction) for blts. - */ -#define DDFXCAPS_BLTSHRINKXN 0x00000800l - -/* - * DirectDraw supports arbitrary shrinking of a surface along the - * y axis (horizontal direction) for blts. - */ -#define DDFXCAPS_BLTSHRINKY 0x00001000l - -/* - * DirectDraw supports integer shrinking (1x,2x,) of a surface - * along the y axis (vertical direction) for blts. - */ -#define DDFXCAPS_BLTSHRINKYN 0x00002000l - -/* - * DirectDraw supports arbitrary stretching of a surface along the - * x axis (horizontal direction) for blts. - */ -#define DDFXCAPS_BLTSTRETCHX 0x00004000l - -/* - * DirectDraw supports integer stretching (1x,2x,) of a surface - * along the x axis (horizontal direction) for blts. - */ -#define DDFXCAPS_BLTSTRETCHXN 0x00008000l - -/* - * DirectDraw supports arbitrary stretching of a surface along the - * y axis (horizontal direction) for blts. - */ -#define DDFXCAPS_BLTSTRETCHY 0x00010000l - -/* - * DirectDraw supports integer stretching (1x,2x,) of a surface - * along the y axis (vertical direction) for blts. - */ -#define DDFXCAPS_BLTSTRETCHYN 0x00020000l - -/* - * Uses arithmetic operations to stretch and shrink surfaces during - * overlay rather than pixel doubling techniques. Along the Y axis - * for overlays. - */ -#define DDFXCAPS_OVERLAYARITHSTRETCHY 0x00040000l - -/* - * Uses arithmetic operations to stretch surfaces during - * overlay rather than pixel doubling techniques. Along the Y axis - * for overlays. Only works for x1, x2, etc. - */ -#define DDFXCAPS_OVERLAYARITHSTRETCHYN 0x00000008l - -/* - * DirectDraw supports arbitrary shrinking of a surface along the - * x axis (horizontal direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSHRINKX 0x00080000l - -/* - * DirectDraw supports integer shrinking (1x,2x,) of a surface - * along the x axis (horizontal direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSHRINKXN 0x00100000l - -/* - * DirectDraw supports arbitrary shrinking of a surface along the - * y axis (horizontal direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSHRINKY 0x00200000l - -/* - * DirectDraw supports integer shrinking (1x,2x,) of a surface - * along the y axis (vertical direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSHRINKYN 0x00400000l - -/* - * DirectDraw supports arbitrary stretching of a surface along the - * x axis (horizontal direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSTRETCHX 0x00800000l - -/* - * DirectDraw supports integer stretching (1x,2x,) of a surface - * along the x axis (horizontal direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSTRETCHXN 0x01000000l - -/* - * DirectDraw supports arbitrary stretching of a surface along the - * y axis (horizontal direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSTRETCHY 0x02000000l - -/* - * DirectDraw supports integer stretching (1x,2x,) of a surface - * along the y axis (vertical direction) for overlays. - */ -#define DDFXCAPS_OVERLAYSTRETCHYN 0x04000000l - -/* - * DirectDraw supports mirroring of overlays across the vertical axis - */ -#define DDFXCAPS_OVERLAYMIRRORLEFTRIGHT 0x08000000l - -/* - * DirectDraw supports mirroring of overlays across the horizontal axis - */ -#define DDFXCAPS_OVERLAYMIRRORUPDOWN 0x10000000l - -/* - * DirectDraw supports deinterlacing of overlay surfaces - */ -#define DDFXCAPS_OVERLAYDEINTERLACE 0x20000000l - -/* - * Driver can do alpha blending for blits. - */ -#define DDFXCAPS_BLTALPHA 0x00000001l - - -/* - * Driver can do surface-reconstruction filtering for warped blits. - */ -#define DDFXCAPS_BLTFILTER DDFXCAPS_BLTARITHSTRETCHY - -/* - * Driver can do alpha blending for overlays. - */ -#define DDFXCAPS_OVERLAYALPHA 0x00000004l - - -/* - * Driver can do surface-reconstruction filtering for warped overlays. - */ -#define DDFXCAPS_OVERLAYFILTER DDFXCAPS_OVERLAYARITHSTRETCHY - -/**************************************************************************** - * - * DIRECTDRAW STEREO VIEW CAPABILITIES - * - ****************************************************************************/ - -/* - * This flag used to be DDSVCAPS_ENIGMA, which is now obsolete - */ - -#define DDSVCAPS_RESERVED1 0x00000001l - -/* - * This flag used to be DDSVCAPS_FLICKER, which is now obsolete - */ -#define DDSVCAPS_RESERVED2 0x00000002l - -/* - * This flag used to be DDSVCAPS_REDBLUE, which is now obsolete - */ -#define DDSVCAPS_RESERVED3 0x00000004l - -/* - * This flag used to be DDSVCAPS_SPLIT, which is now obsolete - */ -#define DDSVCAPS_RESERVED4 0x00000008l - -/* - * The stereo view is accomplished with switching technology - */ - -#define DDSVCAPS_STEREOSEQUENTIAL 0x00000010L - - - -/**************************************************************************** - * - * DIRECTDRAWPALETTE CAPABILITIES - * - ****************************************************************************/ - -/* - * Index is 4 bits. There are sixteen color entries in the palette table. - */ -#define DDPCAPS_4BIT 0x00000001l - -/* - * Index is onto a 8 bit color index. This field is only valid with the - * DDPCAPS_1BIT, DDPCAPS_2BIT or DDPCAPS_4BIT capability and the target - * surface is in 8bpp. Each color entry is one byte long and is an index - * into destination surface's 8bpp palette. - */ -#define DDPCAPS_8BITENTRIES 0x00000002l - -/* - * Index is 8 bits. There are 256 color entries in the palette table. - */ -#define DDPCAPS_8BIT 0x00000004l - -/* - * Indicates that this DIRECTDRAWPALETTE should use the palette color array - * passed into the lpDDColorArray parameter to initialize the DIRECTDRAWPALETTE - * object. - * This flag is obsolete. DirectDraw always initializes the color array from - * the lpDDColorArray parameter. The definition remains for source-level - * compatibility. - */ -#define DDPCAPS_INITIALIZE 0x00000000l - -/* - * This palette is the one attached to the primary surface. Changing this - * table has immediate effect on the display unless DDPSETPAL_VSYNC is specified - * and supported. - */ -#define DDPCAPS_PRIMARYSURFACE 0x00000010l - -/* - * This palette is the one attached to the primary surface left. Changing - * this table has immediate effect on the display for the left eye unless - * DDPSETPAL_VSYNC is specified and supported. - */ -#define DDPCAPS_PRIMARYSURFACELEFT 0x00000020l - -/* - * This palette can have all 256 entries defined - */ -#define DDPCAPS_ALLOW256 0x00000040l - -/* - * This palette can have modifications to it synced with the monitors - * refresh rate. - */ -#define DDPCAPS_VSYNC 0x00000080l - -/* - * Index is 1 bit. There are two color entries in the palette table. - */ -#define DDPCAPS_1BIT 0x00000100l - -/* - * Index is 2 bit. There are four color entries in the palette table. - */ -#define DDPCAPS_2BIT 0x00000200l - -/* - * The peFlags member of PALETTEENTRY denotes an 8 bit alpha value - */ -#define DDPCAPS_ALPHA 0x00000400l - - -/**************************************************************************** - * - * DIRECTDRAWPALETTE SETENTRY CONSTANTS - * - ****************************************************************************/ - - -/**************************************************************************** - * - * DIRECTDRAWPALETTE GETENTRY CONSTANTS - * - ****************************************************************************/ - -/* 0 is the only legal value */ - -/**************************************************************************** - * - * DIRECTDRAWSURFACE SETPRIVATEDATA CONSTANTS - * - ****************************************************************************/ - -/* - * The passed pointer is an IUnknown ptr. The cbData argument to SetPrivateData - * must be set to sizeof(IUnknown*). DirectDraw will call AddRef through this - * pointer and Release when the private data is destroyed. This includes when - * the surface or palette is destroyed before such priovate data is destroyed. - */ -#define DDSPD_IUNKNOWNPOINTER 0x00000001L - -/* - * Private data is only valid for the current state of the object, - * as determined by the uniqueness value. - */ -#define DDSPD_VOLATILE 0x00000002L - - -/**************************************************************************** - * - * DIRECTDRAWSURFACE SETPALETTE CONSTANTS - * - ****************************************************************************/ - - -/**************************************************************************** - * - * DIRECTDRAW BITDEPTH CONSTANTS - * - * NOTE: These are only used to indicate supported bit depths. These - * are flags only, they are not to be used as an actual bit depth. The - * absolute numbers 1, 2, 4, 8, 16, 24 and 32 are used to indicate actual - * bit depths in a surface or for changing the display mode. - * - ****************************************************************************/ - -/* - * 1 bit per pixel. - */ -#define DDBD_1 0x00004000l - -/* - * 2 bits per pixel. - */ -#define DDBD_2 0x00002000l - -/* - * 4 bits per pixel. - */ -#define DDBD_4 0x00001000l - -/* - * 8 bits per pixel. - */ -#define DDBD_8 0x00000800l - -/* - * 16 bits per pixel. - */ -#define DDBD_16 0x00000400l - -/* - * 24 bits per pixel. - */ -#define DDBD_24 0X00000200l - -/* - * 32 bits per pixel. - */ -#define DDBD_32 0x00000100l - -/**************************************************************************** - * - * DIRECTDRAWSURFACE SET/GET COLOR KEY FLAGS - * - ****************************************************************************/ - -/* - * Set if the structure contains a color space. Not set if the structure - * contains a single color key. - */ -#define DDCKEY_COLORSPACE 0x00000001l - -/* - * Set if the structure specifies a color key or color space which is to be - * used as a destination color key for blt operations. - */ -#define DDCKEY_DESTBLT 0x00000002l - -/* - * Set if the structure specifies a color key or color space which is to be - * used as a destination color key for overlay operations. - */ -#define DDCKEY_DESTOVERLAY 0x00000004l - -/* - * Set if the structure specifies a color key or color space which is to be - * used as a source color key for blt operations. - */ -#define DDCKEY_SRCBLT 0x00000008l - -/* - * Set if the structure specifies a color key or color space which is to be - * used as a source color key for overlay operations. - */ -#define DDCKEY_SRCOVERLAY 0x00000010l - - -/**************************************************************************** - * - * DIRECTDRAW COLOR KEY CAPABILITY FLAGS - * - ****************************************************************************/ - -/* - * Supports transparent blting using a color key to identify the replaceable - * bits of the destination surface for RGB colors. - */ -#define DDCKEYCAPS_DESTBLT 0x00000001l - -/* - * Supports transparent blting using a color space to identify the replaceable - * bits of the destination surface for RGB colors. - */ -#define DDCKEYCAPS_DESTBLTCLRSPACE 0x00000002l - -/* - * Supports transparent blting using a color space to identify the replaceable - * bits of the destination surface for YUV colors. - */ -#define DDCKEYCAPS_DESTBLTCLRSPACEYUV 0x00000004l - -/* - * Supports transparent blting using a color key to identify the replaceable - * bits of the destination surface for YUV colors. - */ -#define DDCKEYCAPS_DESTBLTYUV 0x00000008l - -/* - * Supports overlaying using colorkeying of the replaceable bits of the surface - * being overlayed for RGB colors. - */ -#define DDCKEYCAPS_DESTOVERLAY 0x00000010l - -/* - * Supports a color space as the color key for the destination for RGB colors. - */ -#define DDCKEYCAPS_DESTOVERLAYCLRSPACE 0x00000020l - -/* - * Supports a color space as the color key for the destination for YUV colors. - */ -#define DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV 0x00000040l - -/* - * Supports only one active destination color key value for visible overlay - * surfaces. - */ -#define DDCKEYCAPS_DESTOVERLAYONEACTIVE 0x00000080l - -/* - * Supports overlaying using colorkeying of the replaceable bits of the - * surface being overlayed for YUV colors. - */ -#define DDCKEYCAPS_DESTOVERLAYYUV 0x00000100l - -/* - * Supports transparent blting using the color key for the source with - * this surface for RGB colors. - */ -#define DDCKEYCAPS_SRCBLT 0x00000200l - -/* - * Supports transparent blting using a color space for the source with - * this surface for RGB colors. - */ -#define DDCKEYCAPS_SRCBLTCLRSPACE 0x00000400l - -/* - * Supports transparent blting using a color space for the source with - * this surface for YUV colors. - */ -#define DDCKEYCAPS_SRCBLTCLRSPACEYUV 0x00000800l - -/* - * Supports transparent blting using the color key for the source with - * this surface for YUV colors. - */ -#define DDCKEYCAPS_SRCBLTYUV 0x00001000l - -/* - * Supports overlays using the color key for the source with this - * overlay surface for RGB colors. - */ -#define DDCKEYCAPS_SRCOVERLAY 0x00002000l - -/* - * Supports overlays using a color space as the source color key for - * the overlay surface for RGB colors. - */ -#define DDCKEYCAPS_SRCOVERLAYCLRSPACE 0x00004000l - -/* - * Supports overlays using a color space as the source color key for - * the overlay surface for YUV colors. - */ -#define DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV 0x00008000l - -/* - * Supports only one active source color key value for visible - * overlay surfaces. - */ -#define DDCKEYCAPS_SRCOVERLAYONEACTIVE 0x00010000l - -/* - * Supports overlays using the color key for the source with this - * overlay surface for YUV colors. - */ -#define DDCKEYCAPS_SRCOVERLAYYUV 0x00020000l - -/* - * there are no bandwidth trade-offs for using colorkey with an overlay - */ -#define DDCKEYCAPS_NOCOSTOVERLAY 0x00040000l - - -/**************************************************************************** - * - * DIRECTDRAW PIXELFORMAT FLAGS - * - ****************************************************************************/ - -/* - * The surface has alpha channel information in the pixel format. - */ -#define DDPF_ALPHAPIXELS 0x00000001l - -/* - * The pixel format contains alpha only information - */ -#define DDPF_ALPHA 0x00000002l - -/* - * The FourCC code is valid. - */ -#define DDPF_FOURCC 0x00000004l - -/* - * The surface is 4-bit color indexed. - */ -#define DDPF_PALETTEINDEXED4 0x00000008l - -/* - * The surface is indexed into a palette which stores indices - * into the destination surface's 8-bit palette. - */ -#define DDPF_PALETTEINDEXEDTO8 0x00000010l - -/* - * The surface is 8-bit color indexed. - */ -#define DDPF_PALETTEINDEXED8 0x00000020l - -/* - * The RGB data in the pixel format structure is valid. - */ -#define DDPF_RGB 0x00000040l - -/* - * The surface will accept pixel data in the format specified - * and compress it during the write. - */ -#define DDPF_COMPRESSED 0x00000080l - -/* - * The surface will accept RGB data and translate it during - * the write to YUV data. The format of the data to be written - * will be contained in the pixel format structure. The DDPF_RGB - * flag will be set. - */ -#define DDPF_RGBTOYUV 0x00000100l - -/* - * pixel format is YUV - YUV data in pixel format struct is valid - */ -#define DDPF_YUV 0x00000200l - -/* - * pixel format is a z buffer only surface - */ -#define DDPF_ZBUFFER 0x00000400l - -/* - * The surface is 1-bit color indexed. - */ -#define DDPF_PALETTEINDEXED1 0x00000800l - -/* - * The surface is 2-bit color indexed. - */ -#define DDPF_PALETTEINDEXED2 0x00001000l - -/* - * The surface contains Z information in the pixels - */ -#define DDPF_ZPIXELS 0x00002000l - -/* - * The surface contains stencil information along with Z - */ -#define DDPF_STENCILBUFFER 0x00004000l - -/* - * Premultiplied alpha format -- the color components have been - * premultiplied by the alpha component. - */ -#define DDPF_ALPHAPREMULT 0x00008000l - - -/* - * Luminance data in the pixel format is valid. - * Use this flag for luminance-only or luminance+alpha surfaces, - * the bit depth is then ddpf.dwLuminanceBitCount. - */ -#define DDPF_LUMINANCE 0x00020000l - -/* - * Luminance data in the pixel format is valid. - * Use this flag when hanging luminance off bumpmap surfaces, - * the bit mask for the luminance portion of the pixel is then - * ddpf.dwBumpLuminanceBitMask - */ -#define DDPF_BUMPLUMINANCE 0x00040000l - -/* - * Bump map dUdV data in the pixel format is valid. - */ -#define DDPF_BUMPDUDV 0x00080000l - - -/*=========================================================================== - * - * - * DIRECTDRAW CALLBACK FLAGS - * - * - *==========================================================================*/ - -/**************************************************************************** - * - * DIRECTDRAW ENUMSURFACES FLAGS - * - ****************************************************************************/ - -/* - * Enumerate all of the surfaces that meet the search criterion. - */ -#define DDENUMSURFACES_ALL 0x00000001l - -/* - * A search hit is a surface that matches the surface description. - */ -#define DDENUMSURFACES_MATCH 0x00000002l - -/* - * A search hit is a surface that does not match the surface description. - */ -#define DDENUMSURFACES_NOMATCH 0x00000004l - -/* - * Enumerate the first surface that can be created which meets the search criterion. - */ -#define DDENUMSURFACES_CANBECREATED 0x00000008l - -/* - * Enumerate the surfaces that already exist that meet the search criterion. - */ -#define DDENUMSURFACES_DOESEXIST 0x00000010l - - -/**************************************************************************** - * - * DIRECTDRAW SETDISPLAYMODE FLAGS - * - ****************************************************************************/ - -/* - * The desired mode is a standard VGA mode - */ -#define DDSDM_STANDARDVGAMODE 0x00000001l - - -/**************************************************************************** - * - * DIRECTDRAW ENUMDISPLAYMODES FLAGS - * - ****************************************************************************/ - -/* - * Enumerate Modes with different refresh rates. EnumDisplayModes guarantees - * that a particular mode will be enumerated only once. This flag specifies whether - * the refresh rate is taken into account when determining if a mode is unique. - */ -#define DDEDM_REFRESHRATES 0x00000001l - -/* - * Enumerate VGA modes. Specify this flag if you wish to enumerate supported VGA - * modes such as mode 0x13 in addition to the usual ModeX modes (which are always - * enumerated if the application has previously called SetCooperativeLevel with the - * DDSCL_ALLOWMODEX flag set). - */ -#define DDEDM_STANDARDVGAMODES 0x00000002L - - -/**************************************************************************** - * - * DIRECTDRAW SETCOOPERATIVELEVEL FLAGS - * - ****************************************************************************/ - -/* - * Exclusive mode owner will be responsible for the entire primary surface. - * GDI can be ignored. used with DD - */ -#define DDSCL_FULLSCREEN 0x00000001l - -/* - * allow CTRL_ALT_DEL to work while in fullscreen exclusive mode - */ -#define DDSCL_ALLOWREBOOT 0x00000002l - -/* - * prevents DDRAW from modifying the application window. - * prevents DDRAW from minimize/restore the application window on activation. - */ -#define DDSCL_NOWINDOWCHANGES 0x00000004l - -/* - * app wants to work as a regular Windows application - */ -#define DDSCL_NORMAL 0x00000008l - -/* - * app wants exclusive access - */ -#define DDSCL_EXCLUSIVE 0x00000010l - - -/* - * app can deal with non-windows display modes - */ -#define DDSCL_ALLOWMODEX 0x00000040l - -/* - * this window will receive the focus messages - */ -#define DDSCL_SETFOCUSWINDOW 0x00000080l - -/* - * this window is associated with the DDRAW object and will - * cover the screen in fullscreen mode - */ -#define DDSCL_SETDEVICEWINDOW 0x00000100l - -/* - * app wants DDRAW to create a window to be associated with the - * DDRAW object - */ -#define DDSCL_CREATEDEVICEWINDOW 0x00000200l - -/* - * App explicitly asks DDRAW/D3D to be multithread safe. This makes D3D - * take the global crtisec more frequently. - */ -#define DDSCL_MULTITHREADED 0x00000400l - -/* - * App specifies that it would like to keep the FPU set up for optimal Direct3D - * performance (single precision and exceptions disabled) so Direct3D - * does not need to explicitly set the FPU each time. This is assumed by - * default in DirectX 7. See also DDSCL_FPUPRESERVE - */ -#define DDSCL_FPUSETUP 0x00000800l - -/* - * App specifies that it needs either double precision FPU or FPU exceptions - * enabled. This makes Direct3D explicitly set the FPU state eah time it is - * called. Setting the flag will reduce Direct3D performance. The flag is - * assumed by default in DirectX 6 and earlier. See also DDSCL_FPUSETUP - */ -#define DDSCL_FPUPRESERVE 0x00001000l - - -/**************************************************************************** - * - * DIRECTDRAW BLT FLAGS - * - ****************************************************************************/ - -/* - * Use the alpha information in the pixel format or the alpha channel surface - * attached to the destination surface as the alpha channel for this blt. - */ -#define DDBLT_ALPHADEST 0x00000001l - -/* - * Use the dwConstAlphaDest field in the DDBLTFX structure as the alpha channel - * for the destination surface for this blt. - */ -#define DDBLT_ALPHADESTCONSTOVERRIDE 0x00000002l - -/* - * The NEG suffix indicates that the destination surface becomes more - * transparent as the alpha value increases. (0 is opaque) - */ -#define DDBLT_ALPHADESTNEG 0x00000004l - -/* - * Use the lpDDSAlphaDest field in the DDBLTFX structure as the alpha - * channel for the destination for this blt. - */ -#define DDBLT_ALPHADESTSURFACEOVERRIDE 0x00000008l - -/* - * Use the dwAlphaEdgeBlend field in the DDBLTFX structure as the alpha channel - * for the edges of the image that border the color key colors. - */ -#define DDBLT_ALPHAEDGEBLEND 0x00000010l - -/* - * Use the alpha information in the pixel format or the alpha channel surface - * attached to the source surface as the alpha channel for this blt. - */ -#define DDBLT_ALPHASRC 0x00000020l - -/* - * Use the dwConstAlphaSrc field in the DDBLTFX structure as the alpha channel - * for the source for this blt. - */ -#define DDBLT_ALPHASRCCONSTOVERRIDE 0x00000040l - -/* - * The NEG suffix indicates that the source surface becomes more transparent - * as the alpha value increases. (0 is opaque) - */ -#define DDBLT_ALPHASRCNEG 0x00000080l - -/* - * Use the lpDDSAlphaSrc field in the DDBLTFX structure as the alpha channel - * for the source for this blt. - */ -#define DDBLT_ALPHASRCSURFACEOVERRIDE 0x00000100l - -/* - * Do this blt asynchronously through the FIFO in the order received. If - * there is no room in the hardware FIFO fail the call. - */ -#define DDBLT_ASYNC 0x00000200l - -/* - * Uses the dwFillColor field in the DDBLTFX structure as the RGB color - * to fill the destination rectangle on the destination surface with. - */ -#define DDBLT_COLORFILL 0x00000400l - -/* - * Uses the dwDDFX field in the DDBLTFX structure to specify the effects - * to use for the blt. - */ -#define DDBLT_DDFX 0x00000800l - -/* - * Uses the dwDDROPS field in the DDBLTFX structure to specify the ROPS - * that are not part of the Win32 API. - */ -#define DDBLT_DDROPS 0x00001000l - -/* - * Use the color key associated with the destination surface. - */ -#define DDBLT_KEYDEST 0x00002000l - -/* - * Use the dckDestColorkey field in the DDBLTFX structure as the color key - * for the destination surface. - */ -#define DDBLT_KEYDESTOVERRIDE 0x00004000l - -/* - * Use the color key associated with the source surface. - */ -#define DDBLT_KEYSRC 0x00008000l - -/* - * Use the dckSrcColorkey field in the DDBLTFX structure as the color key - * for the source surface. - */ -#define DDBLT_KEYSRCOVERRIDE 0x00010000l - -/* - * Use the dwROP field in the DDBLTFX structure for the raster operation - * for this blt. These ROPs are the same as the ones defined in the Win32 API. - */ -#define DDBLT_ROP 0x00020000l - -/* - * Use the dwRotationAngle field in the DDBLTFX structure as the angle - * (specified in 1/100th of a degree) to rotate the surface. - */ -#define DDBLT_ROTATIONANGLE 0x00040000l - -/* - * Z-buffered blt using the z-buffers attached to the source and destination - * surfaces and the dwZBufferOpCode field in the DDBLTFX structure as the - * z-buffer opcode. - */ -#define DDBLT_ZBUFFER 0x00080000l - -/* - * Z-buffered blt using the dwConstDest Zfield and the dwZBufferOpCode field - * in the DDBLTFX structure as the z-buffer and z-buffer opcode respectively - * for the destination. - */ -#define DDBLT_ZBUFFERDESTCONSTOVERRIDE 0x00100000l - -/* - * Z-buffered blt using the lpDDSDestZBuffer field and the dwZBufferOpCode - * field in the DDBLTFX structure as the z-buffer and z-buffer opcode - * respectively for the destination. - */ -#define DDBLT_ZBUFFERDESTOVERRIDE 0x00200000l - -/* - * Z-buffered blt using the dwConstSrcZ field and the dwZBufferOpCode field - * in the DDBLTFX structure as the z-buffer and z-buffer opcode respectively - * for the source. - */ -#define DDBLT_ZBUFFERSRCCONSTOVERRIDE 0x00400000l - -/* - * Z-buffered blt using the lpDDSSrcZBuffer field and the dwZBufferOpCode - * field in the DDBLTFX structure as the z-buffer and z-buffer opcode - * respectively for the source. - */ -#define DDBLT_ZBUFFERSRCOVERRIDE 0x00800000l - -/* - * wait until the device is ready to handle the blt - * this will cause blt to not return DDERR_WASSTILLDRAWING - */ -#define DDBLT_WAIT 0x01000000l - -/* - * Uses the dwFillDepth field in the DDBLTFX structure as the depth value - * to fill the destination rectangle on the destination Z-buffer surface - * with. - */ -#define DDBLT_DEPTHFILL 0x02000000l - - -/* - * Return immediately (with DDERR_WASSTILLDRAWING) if the device is not - * ready to schedule the blt at the time Blt() is called. - */ -#define DDBLT_DONOTWAIT 0x08000000l - -/* - * These flags indicate a presentation blt (i.e. a blt - * that moves surface contents from an offscreen back buffer to the primary - * surface). The driver is not allowed to "queue" more than three such blts. - * The "end" of the presentation blt is indicated, since the - * blt may be clipped, in which case the runtime will call the driver with - * several blts. All blts (even if not clipped) are tagged with DDBLT_PRESENTATION - * and the last (even if not clipped) additionally with DDBLT_LAST_PRESENTATION. - * Thus the true rule is that the driver must not schedule a DDBLT_PRESENTATION - * blt if there are 3 or more DDBLT_PRESENTLAST blts in the hardware pipe. - * If there are such blts in the pipe, the driver should return DDERR_WASSTILLDRAWING - * until the oldest queued DDBLT_LAST_PRESENTATION blts has been retired (i.e. the - * pixels have been actually written to the primary surface). Once the oldest blt - * has been retired, the driver is free to schedule the current blt. - * The goal is to provide a mechanism whereby the device's hardware queue never - * gets more than 3 frames ahead of the frames being generated by the application. - * When excessive queueing occurs, applications become unusable because the application - * visibly lags user input, and such problems make windowed interactive applications impossible. - * Some drivers may not have sufficient knowledge of their hardware's FIFO to know - * when a certain blt has been retired. Such drivers should code cautiously, and - * simply not allow any frames to be queued at all. DDBLT_LAST_PRESENTATION should cause - * such drivers to return DDERR_WASSTILLDRAWING until the accelerator is completely - * finished- exactly as if the application had called Lock on the source surface - * before calling Blt. - * In other words, the driver is allowed and encouraged to - * generate as much latency as it can, but never more than 3 frames worth. - * Implementation detail: Drivers should count blts against the SOURCE surface, not - * against the primary surface. This enables multiple parallel windowed application - * to function more optimally. - * This flag is passed only to DX8 or higher drivers. - * - * APPLICATIONS DO NOT SET THESE FLAGS. THEY ARE SET BY THE DIRECTDRAW RUNTIME. - * - */ -#define DDBLT_PRESENTATION 0x10000000l -#define DDBLT_LAST_PRESENTATION 0x20000000l - -/* - * If DDBLT_EXTENDED_FLAGS is set, then the driver should re-interpret - * other flags according to the definitions that follow. - * For example, bit 0 (0x00000001L) means DDBLT_ALPHADEST, unless - * DDBLT_EXTENDED_FLAGS is also set, in which case bit 0 means - * DDBLT_EXTENDED_LINEAR_CONTENT. - * Only DirectX9 and higher drivers will be given extended blt flags. - * Only flags explicitly mentioned here should be re-interpreted. - * All other flags retain their original meanings. - * - * List of re-interpreted flags: - * - * Bit Hex value New meaning old meaning - * --------------------------------------------------------------- - * 2 0x00000004 DDBLT_EXTENDED_LINEAR_CONTENT DDBLT_ALPHADESTNEG - * 4 0x00000010 DDBLT_EXTENDED_PRESENTATION_STRETCHFACTOR DDBLT_ALPHAEDGEBLEND - * - * - * NOTE: APPLICATIONS SHOULD NOT SET THIS FLAG. THIS FLAG IS INTENDED - * FOR USE BY THE DIRECT3D RUNTIME. - */ -#define DDBLT_EXTENDED_FLAGS 0x40000000l - -/* - * EXTENDED FLAG. SEE DEFINITION OF DDBLT_EXTENDED_FLAGS. - * This flag indidcates that the source surface contains content in a - * linear color space. The driver may perform gamma correction to the - * desktop color space (i.e. sRGB, gamma 2.2) as part of this blt. - * If the device can perform such a conversion as part of the copy, - * the driver should also set D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION - * - * NOTE: APPLICATIONS SHOULD NOT SET THIS FLAG. THIS FLAG IS INTENDED - * FOR USE BY THE DIRECT3D RUNTIME. Use IDirect3DSwapChain9::Present - * and specify D3DPRESENT_LINEAR_CONTENT in order to use this functionality. - */ -#define DDBLT_EXTENDED_LINEAR_CONTENT 0x00000004l - - -/**************************************************************************** - * - * BLTFAST FLAGS - * - ****************************************************************************/ - -#define DDBLTFAST_NOCOLORKEY 0x00000000 -#define DDBLTFAST_SRCCOLORKEY 0x00000001 -#define DDBLTFAST_DESTCOLORKEY 0x00000002 -#define DDBLTFAST_WAIT 0x00000010 -#define DDBLTFAST_DONOTWAIT 0x00000020 - -/**************************************************************************** - * - * FLIP FLAGS - * - ****************************************************************************/ - -#define DDFLIP_WAIT 0x00000001L - -/* - * Indicates that the target surface contains the even field of video data. - * This flag is only valid with an overlay surface. - */ -#define DDFLIP_EVEN 0x00000002L - -/* - * Indicates that the target surface contains the odd field of video data. - * This flag is only valid with an overlay surface. - */ -#define DDFLIP_ODD 0x00000004L - -/* - * Causes DirectDraw to perform the physical flip immediately and return - * to the application. Typically, what was the front buffer but is now the back - * buffer will still be visible (depending on timing) until the next vertical - * retrace. Subsequent operations involving the two flipped surfaces will - * not check to see if the physical flip has finished (i.e. will not return - * DDERR_WASSTILLDRAWING for that reason (but may for other reasons)). - * This allows an application to perform Flips at a higher frequency than the - * monitor refresh rate, but may introduce visible artifacts. - * Only effective if DDCAPS2_FLIPNOVSYNC is set. If that bit is not set, - * DDFLIP_NOVSYNC has no effect. - */ -#define DDFLIP_NOVSYNC 0x00000008L - - -/* - * Flip Interval Flags. These flags indicate how many vertical retraces to wait between - * each flip. The default is one. DirectDraw will return DDERR_WASSTILLDRAWING for each - * surface involved in the flip until the specified number of vertical retraces has - * ocurred. Only effective if DDCAPS2_FLIPINTERVAL is set. If that bit is not set, - * DDFLIP_INTERVALn has no effect. - */ - -/* - * DirectDraw will flip on every other vertical sync - */ -#define DDFLIP_INTERVAL2 0x02000000L - - -/* - * DirectDraw will flip on every third vertical sync - */ -#define DDFLIP_INTERVAL3 0x03000000L - - -/* - * DirectDraw will flip on every fourth vertical sync - */ -#define DDFLIP_INTERVAL4 0x04000000L - -/* - * DirectDraw will flip and display a main stereo surface - */ -#define DDFLIP_STEREO 0x00000010L - -/* - * On IDirectDrawSurface7 and higher interfaces, the default is DDFLIP_WAIT. If you wish - * to override the default and use time when the accelerator is busy (as denoted by - * the DDERR_WASSTILLDRAWING return code) then use DDFLIP_DONOTWAIT. - */ -#define DDFLIP_DONOTWAIT 0x00000020L - - -/**************************************************************************** - * - * DIRECTDRAW SURFACE OVERLAY FLAGS - * - ****************************************************************************/ - -/* - * Use the alpha information in the pixel format or the alpha channel surface - * attached to the destination surface as the alpha channel for the - * destination overlay. - */ -#define DDOVER_ALPHADEST 0x00000001l - -/* - * Use the dwConstAlphaDest field in the DDOVERLAYFX structure as the - * destination alpha channel for this overlay. - */ -#define DDOVER_ALPHADESTCONSTOVERRIDE 0x00000002l - -/* - * The NEG suffix indicates that the destination surface becomes more - * transparent as the alpha value increases. - */ -#define DDOVER_ALPHADESTNEG 0x00000004l - -/* - * Use the lpDDSAlphaDest field in the DDOVERLAYFX structure as the alpha - * channel destination for this overlay. - */ -#define DDOVER_ALPHADESTSURFACEOVERRIDE 0x00000008l - -/* - * Use the dwAlphaEdgeBlend field in the DDOVERLAYFX structure as the alpha - * channel for the edges of the image that border the color key colors. - */ -#define DDOVER_ALPHAEDGEBLEND 0x00000010l - -/* - * Use the alpha information in the pixel format or the alpha channel surface - * attached to the source surface as the source alpha channel for this overlay. - */ -#define DDOVER_ALPHASRC 0x00000020l - -/* - * Use the dwConstAlphaSrc field in the DDOVERLAYFX structure as the source - * alpha channel for this overlay. - */ -#define DDOVER_ALPHASRCCONSTOVERRIDE 0x00000040l - -/* - * The NEG suffix indicates that the source surface becomes more transparent - * as the alpha value increases. - */ -#define DDOVER_ALPHASRCNEG 0x00000080l - -/* - * Use the lpDDSAlphaSrc field in the DDOVERLAYFX structure as the alpha channel - * source for this overlay. - */ -#define DDOVER_ALPHASRCSURFACEOVERRIDE 0x00000100l - -/* - * Turn this overlay off. - */ -#define DDOVER_HIDE 0x00000200l - -/* - * Use the color key associated with the destination surface. - */ -#define DDOVER_KEYDEST 0x00000400l - -/* - * Use the dckDestColorkey field in the DDOVERLAYFX structure as the color key - * for the destination surface - */ -#define DDOVER_KEYDESTOVERRIDE 0x00000800l - -/* - * Use the color key associated with the source surface. - */ -#define DDOVER_KEYSRC 0x00001000l - -/* - * Use the dckSrcColorkey field in the DDOVERLAYFX structure as the color key - * for the source surface. - */ -#define DDOVER_KEYSRCOVERRIDE 0x00002000l - -/* - * Turn this overlay on. - */ -#define DDOVER_SHOW 0x00004000l - -/* - * Add a dirty rect to an emulated overlayed surface. - */ -#define DDOVER_ADDDIRTYRECT 0x00008000l - -/* - * Redraw all dirty rects on an emulated overlayed surface. - */ -#define DDOVER_REFRESHDIRTYRECTS 0x00010000l - -/* - * Redraw the entire surface on an emulated overlayed surface. - */ -#define DDOVER_REFRESHALL 0x00020000l - - -/* - * Use the overlay FX flags to define special overlay FX - */ -#define DDOVER_DDFX 0x00080000l - -/* - * Autoflip the overlay when ever the video port autoflips - */ -#define DDOVER_AUTOFLIP 0x00100000l - -/* - * Display each field of video port data individually without - * causing any jittery artifacts - */ -#define DDOVER_BOB 0x00200000l - -/* - * Indicates that bob/weave decisions should not be overridden by other - * interfaces. - */ -#define DDOVER_OVERRIDEBOBWEAVE 0x00400000l - -/* - * Indicates that the surface memory is composed of interleaved fields. - */ -#define DDOVER_INTERLEAVED 0x00800000l - -/* - * Indicates that bob will be performed using hardware rather than - * software or emulated. - */ -#define DDOVER_BOBHARDWARE 0x01000000l - -/* - * Indicates that overlay FX structure contains valid ARGB scaling factors. - */ -#define DDOVER_ARGBSCALEFACTORS 0x02000000l - -/* - * Indicates that ARGB scaling factors can be degraded to fit driver capabilities. - */ -#define DDOVER_DEGRADEARGBSCALING 0x04000000l - - -/**************************************************************************** - * - * DIRECTDRAWSURFACE LOCK FLAGS - * - ****************************************************************************/ - -/* - * The default. Set to indicate that Lock should return a valid memory pointer - * to the top of the specified rectangle. If no rectangle is specified then a - * pointer to the top of the surface is returned. - */ -#define DDLOCK_SURFACEMEMORYPTR 0x00000000L // default - -/* - * Set to indicate that Lock should wait until it can obtain a valid memory - * pointer before returning. If this bit is set, Lock will never return - * DDERR_WASSTILLDRAWING. - */ -#define DDLOCK_WAIT 0x00000001L - -/* - * Set if an event handle is being passed to Lock. Lock will trigger the event - * when it can return the surface memory pointer requested. - */ -#define DDLOCK_EVENT 0x00000002L - -/* - * Indicates that the surface being locked will only be read from. - */ -#define DDLOCK_READONLY 0x00000010L - -/* - * Indicates that the surface being locked will only be written to - */ -#define DDLOCK_WRITEONLY 0x00000020L - - -/* - * Indicates that a system wide lock should not be taken when this surface - * is locked. This has several advantages (cursor responsiveness, ability - * to call more Windows functions, easier debugging) when locking video - * memory surfaces. However, an application specifying this flag must - * comply with a number of conditions documented in the help file. - * Furthermore, this flag cannot be specified when locking the primary. - */ -#define DDLOCK_NOSYSLOCK 0x00000800L - -/* - * Used only with Direct3D Vertex Buffer Locks. Indicates that no vertices - * that were referred to in Draw*PrimtiveVB calls since the start of the - * frame (or the last lock without this flag) will be modified during the - * lock. This can be useful when one is only appending data to the vertex - * buffer - */ -#define DDLOCK_NOOVERWRITE 0x00001000L - -/* - * Indicates that no assumptions will be made about the contents of the - * surface or vertex buffer during this lock. - * This enables two things: - * - Direct3D or the driver may provide an alternative memory - * area as the vertex buffer. This is useful when one plans to clear the - * contents of the vertex buffer and fill in new data. - * - Drivers sometimes store surface data in a re-ordered format. - * When the application locks the surface, the driver is forced to un-re-order - * the surface data before allowing the application to see the surface contents. - * This flag is a hint to the driver that it can skip the un-re-ordering process - * since the application plans to overwrite every single pixel in the surface - * or locked rectangle (and so erase any un-re-ordered pixels anyway). - * Applications should always set this flag when they intend to overwrite the entire - * surface or locked rectangle. - */ -#define DDLOCK_DISCARDCONTENTS 0x00002000L - /* - * DDLOCK_OKTOSWAP is an older, less informative name for DDLOCK_DISCARDCONTENTS - */ -#define DDLOCK_OKTOSWAP 0x00002000L - -/* - * On IDirectDrawSurface7 and higher interfaces, the default is DDLOCK_WAIT. If you wish - * to override the default and use time when the accelerator is busy (as denoted by - * the DDERR_WASSTILLDRAWING return code) then use DDLOCK_DONOTWAIT. - */ -#define DDLOCK_DONOTWAIT 0x00004000L - -/* - * This indicates volume texture lock with front and back specified. - */ -#define DDLOCK_HASVOLUMETEXTUREBOXRECT 0x00008000L - -/* - * This indicates that the driver should not update dirty rect information for this lock. - */ -#define DDLOCK_NODIRTYUPDATE 0x00010000L - - -/**************************************************************************** - * - * DIRECTDRAWSURFACE PAGELOCK FLAGS - * - ****************************************************************************/ - -/* - * No flags defined at present - */ - - -/**************************************************************************** - * - * DIRECTDRAWSURFACE PAGEUNLOCK FLAGS - * - ****************************************************************************/ - -/* - * No flags defined at present - */ - - -/**************************************************************************** - * - * DIRECTDRAWSURFACE BLT FX FLAGS - * - ****************************************************************************/ - -/* - * If stretching, use arithmetic stretching along the Y axis for this blt. - */ -#define DDBLTFX_ARITHSTRETCHY 0x00000001l - -/* - * Do this blt mirroring the surface left to right. Spin the - * surface around its y-axis. - */ -#define DDBLTFX_MIRRORLEFTRIGHT 0x00000002l - -/* - * Do this blt mirroring the surface up and down. Spin the surface - * around its x-axis. - */ -#define DDBLTFX_MIRRORUPDOWN 0x00000004l - -/* - * Schedule this blt to avoid tearing. - */ -#define DDBLTFX_NOTEARING 0x00000008l - -/* - * Do this blt rotating the surface one hundred and eighty degrees. - */ -#define DDBLTFX_ROTATE180 0x00000010l - -/* - * Do this blt rotating the surface two hundred and seventy degrees. - */ -#define DDBLTFX_ROTATE270 0x00000020l - -/* - * Do this blt rotating the surface ninety degrees. - */ -#define DDBLTFX_ROTATE90 0x00000040l - -/* - * Do this z blt using dwZBufferLow and dwZBufferHigh as range values - * specified to limit the bits copied from the source surface. - */ -#define DDBLTFX_ZBUFFERRANGE 0x00000080l - -/* - * Do this z blt adding the dwZBufferBaseDest to each of the sources z values - * before comparing it with the desting z values. - */ -#define DDBLTFX_ZBUFFERBASEDEST 0x00000100l - -/**************************************************************************** - * - * DIRECTDRAWSURFACE OVERLAY FX FLAGS - * - ****************************************************************************/ - -/* - * If stretching, use arithmetic stretching along the Y axis for this overlay. - */ -#define DDOVERFX_ARITHSTRETCHY 0x00000001l - -/* - * Mirror the overlay across the vertical axis - */ -#define DDOVERFX_MIRRORLEFTRIGHT 0x00000002l - -/* - * Mirror the overlay across the horizontal axis - */ -#define DDOVERFX_MIRRORUPDOWN 0x00000004l - -/* - * Deinterlace the overlay, if possible - */ -#define DDOVERFX_DEINTERLACE 0x00000008l - - -/**************************************************************************** - * - * DIRECTDRAW WAITFORVERTICALBLANK FLAGS - * - ****************************************************************************/ - -/* - * return when the vertical blank interval begins - */ -#define DDWAITVB_BLOCKBEGIN 0x00000001l - -/* - * set up an event to trigger when the vertical blank begins - */ -#define DDWAITVB_BLOCKBEGINEVENT 0x00000002l - -/* - * return when the vertical blank interval ends and display begins - */ -#define DDWAITVB_BLOCKEND 0x00000004l - -/**************************************************************************** - * - * DIRECTDRAW GETFLIPSTATUS FLAGS - * - ****************************************************************************/ - -/* - * is it OK to flip now? - */ -#define DDGFS_CANFLIP 0x00000001l - -/* - * is the last flip finished? - */ -#define DDGFS_ISFLIPDONE 0x00000002l - -/**************************************************************************** - * - * DIRECTDRAW GETBLTSTATUS FLAGS - * - ****************************************************************************/ - -/* - * is it OK to blt now? - */ -#define DDGBS_CANBLT 0x00000001l - -/* - * is the blt to the surface finished? - */ -#define DDGBS_ISBLTDONE 0x00000002l - - -/**************************************************************************** - * - * DIRECTDRAW ENUMOVERLAYZORDER FLAGS - * - ****************************************************************************/ - -/* - * Enumerate overlays back to front. - */ -#define DDENUMOVERLAYZ_BACKTOFRONT 0x00000000l - -/* - * Enumerate overlays front to back - */ -#define DDENUMOVERLAYZ_FRONTTOBACK 0x00000001l - -/**************************************************************************** - * - * DIRECTDRAW UPDATEOVERLAYZORDER FLAGS - * - ****************************************************************************/ - -/* - * Send overlay to front - */ -#define DDOVERZ_SENDTOFRONT 0x00000000l - -/* - * Send overlay to back - */ -#define DDOVERZ_SENDTOBACK 0x00000001l - -/* - * Move Overlay forward - */ -#define DDOVERZ_MOVEFORWARD 0x00000002l - -/* - * Move Overlay backward - */ -#define DDOVERZ_MOVEBACKWARD 0x00000003l - -/* - * Move Overlay in front of relative surface - */ -#define DDOVERZ_INSERTINFRONTOF 0x00000004l - -/* - * Move Overlay in back of relative surface - */ -#define DDOVERZ_INSERTINBACKOF 0x00000005l - - -/**************************************************************************** - * - * DIRECTDRAW SETGAMMARAMP FLAGS - * - ****************************************************************************/ - -/* - * Request calibrator to adjust the gamma ramp according to the physical - * properties of the display so that the result should appear identical - * on all systems. - */ -#define DDSGR_CALIBRATE 0x00000001L - - -/**************************************************************************** - * - * DIRECTDRAW STARTMODETEST FLAGS - * - ****************************************************************************/ - -/* - * Indicates that the mode being tested has passed - */ -#define DDSMT_ISTESTREQUIRED 0x00000001L - - -/**************************************************************************** - * - * DIRECTDRAW EVALUATEMODE FLAGS - * - ****************************************************************************/ - -/* - * Indicates that the mode being tested has passed - */ -#define DDEM_MODEPASSED 0x00000001L - -/* - * Indicates that the mode being tested has failed - */ -#define DDEM_MODEFAILED 0x00000002L - - -/*=========================================================================== - * - * - * DIRECTDRAW RETURN CODES - * - * The return values from DirectDraw Commands and Surface that return an HRESULT - * are codes from DirectDraw concerning the results of the action - * requested by DirectDraw. - * - *==========================================================================*/ - -/* - * Status is OK - * - * Issued by: DirectDraw Commands and all callbacks - */ -#define DD_OK S_OK -#define DD_FALSE S_FALSE - -/**************************************************************************** - * - * DIRECTDRAW ENUMCALLBACK RETURN VALUES - * - * EnumCallback returns are used to control the flow of the DIRECTDRAW and - * DIRECTDRAWSURFACE object enumerations. They can only be returned by - * enumeration callback routines. - * - ****************************************************************************/ - -/* - * stop the enumeration - */ -#define DDENUMRET_CANCEL 0 - -/* - * continue the enumeration - */ -#define DDENUMRET_OK 1 - -/**************************************************************************** - * - * DIRECTDRAW ERRORS - * - * Errors are represented by negative values and cannot be combined. - * - ****************************************************************************/ - -/* - * This object is already initialized - */ -#define DDERR_ALREADYINITIALIZED MAKE_DDHRESULT( 5 ) - -/* - * This surface can not be attached to the requested surface. - */ -#define DDERR_CANNOTATTACHSURFACE MAKE_DDHRESULT( 10 ) - -/* - * This surface can not be detached from the requested surface. - */ -#define DDERR_CANNOTDETACHSURFACE MAKE_DDHRESULT( 20 ) - -/* - * Support is currently not available. - */ -#define DDERR_CURRENTLYNOTAVAIL MAKE_DDHRESULT( 40 ) - -/* - * An exception was encountered while performing the requested operation - */ -#define DDERR_EXCEPTION MAKE_DDHRESULT( 55 ) - -/* - * Generic failure. - */ -#define DDERR_GENERIC E_FAIL - -/* - * Height of rectangle provided is not a multiple of reqd alignment - */ -#define DDERR_HEIGHTALIGN MAKE_DDHRESULT( 90 ) - -/* - * Unable to match primary surface creation request with existing - * primary surface. - */ -#define DDERR_INCOMPATIBLEPRIMARY MAKE_DDHRESULT( 95 ) - -/* - * One or more of the caps bits passed to the callback are incorrect. - */ -#define DDERR_INVALIDCAPS MAKE_DDHRESULT( 100 ) - -/* - * DirectDraw does not support provided Cliplist. - */ -#define DDERR_INVALIDCLIPLIST MAKE_DDHRESULT( 110 ) - -/* - * DirectDraw does not support the requested mode - */ -#define DDERR_INVALIDMODE MAKE_DDHRESULT( 120 ) - -/* - * DirectDraw received a pointer that was an invalid DIRECTDRAW object. - */ -#define DDERR_INVALIDOBJECT MAKE_DDHRESULT( 130 ) - -/* - * One or more of the parameters passed to the callback function are - * incorrect. - */ -#define DDERR_INVALIDPARAMS E_INVALIDARG - -/* - * pixel format was invalid as specified - */ -#define DDERR_INVALIDPIXELFORMAT MAKE_DDHRESULT( 145 ) - -/* - * Rectangle provided was invalid. - */ -#define DDERR_INVALIDRECT MAKE_DDHRESULT( 150 ) - -/* - * Operation could not be carried out because one or more surfaces are locked - */ -#define DDERR_LOCKEDSURFACES MAKE_DDHRESULT( 160 ) - -/* - * There is no 3D present. - */ -#define DDERR_NO3D MAKE_DDHRESULT( 170 ) - -/* - * Operation could not be carried out because there is no alpha accleration - * hardware present or available. - */ -#define DDERR_NOALPHAHW MAKE_DDHRESULT( 180 ) - -/* - * Operation could not be carried out because there is no stereo - * hardware present or available. - */ -#define DDERR_NOSTEREOHARDWARE MAKE_DDHRESULT( 181 ) - -/* - * Operation could not be carried out because there is no hardware - * present which supports stereo surfaces - */ -#define DDERR_NOSURFACELEFT MAKE_DDHRESULT( 182 ) - - - -/* - * no clip list available - */ -#define DDERR_NOCLIPLIST MAKE_DDHRESULT( 205 ) - -/* - * Operation could not be carried out because there is no color conversion - * hardware present or available. - */ -#define DDERR_NOCOLORCONVHW MAKE_DDHRESULT( 210 ) - -/* - * Create function called without DirectDraw object method SetCooperativeLevel - * being called. - */ -#define DDERR_NOCOOPERATIVELEVELSET MAKE_DDHRESULT( 212 ) - -/* - * Surface doesn't currently have a color key - */ -#define DDERR_NOCOLORKEY MAKE_DDHRESULT( 215 ) - -/* - * Operation could not be carried out because there is no hardware support - * of the dest color key. - */ -#define DDERR_NOCOLORKEYHW MAKE_DDHRESULT( 220 ) - -/* - * No DirectDraw support possible with current display driver - */ -#define DDERR_NODIRECTDRAWSUPPORT MAKE_DDHRESULT( 222 ) - -/* - * Operation requires the application to have exclusive mode but the - * application does not have exclusive mode. - */ -#define DDERR_NOEXCLUSIVEMODE MAKE_DDHRESULT( 225 ) - -/* - * Flipping visible surfaces is not supported. - */ -#define DDERR_NOFLIPHW MAKE_DDHRESULT( 230 ) - -/* - * There is no GDI present. - */ -#define DDERR_NOGDI MAKE_DDHRESULT( 240 ) - -/* - * Operation could not be carried out because there is no hardware present - * or available. - */ -#define DDERR_NOMIRRORHW MAKE_DDHRESULT( 250 ) - -/* - * Requested item was not found - */ -#define DDERR_NOTFOUND MAKE_DDHRESULT( 255 ) - -/* - * Operation could not be carried out because there is no overlay hardware - * present or available. - */ -#define DDERR_NOOVERLAYHW MAKE_DDHRESULT( 260 ) - -/* - * Operation could not be carried out because the source and destination - * rectangles are on the same surface and overlap each other. - */ -#define DDERR_OVERLAPPINGRECTS MAKE_DDHRESULT( 270 ) - -/* - * Operation could not be carried out because there is no appropriate raster - * op hardware present or available. - */ -#define DDERR_NORASTEROPHW MAKE_DDHRESULT( 280 ) - -/* - * Operation could not be carried out because there is no rotation hardware - * present or available. - */ -#define DDERR_NOROTATIONHW MAKE_DDHRESULT( 290 ) - -/* - * Operation could not be carried out because there is no hardware support - * for stretching - */ -#define DDERR_NOSTRETCHHW MAKE_DDHRESULT( 310 ) - -/* - * DirectDrawSurface is not in 4 bit color palette and the requested operation - * requires 4 bit color palette. - */ -#define DDERR_NOT4BITCOLOR MAKE_DDHRESULT( 316 ) - -/* - * DirectDrawSurface is not in 4 bit color index palette and the requested - * operation requires 4 bit color index palette. - */ -#define DDERR_NOT4BITCOLORINDEX MAKE_DDHRESULT( 317 ) - -/* - * DirectDraw Surface is not in 8 bit color mode and the requested operation - * requires 8 bit color. - */ -#define DDERR_NOT8BITCOLOR MAKE_DDHRESULT( 320 ) - -/* - * Operation could not be carried out because there is no texture mapping - * hardware present or available. - */ -#define DDERR_NOTEXTUREHW MAKE_DDHRESULT( 330 ) - -/* - * Operation could not be carried out because there is no hardware support - * for vertical blank synchronized operations. - */ -#define DDERR_NOVSYNCHW MAKE_DDHRESULT( 335 ) - -/* - * Operation could not be carried out because there is no hardware support - * for zbuffer blting. - */ -#define DDERR_NOZBUFFERHW MAKE_DDHRESULT( 340 ) - -/* - * Overlay surfaces could not be z layered based on their BltOrder because - * the hardware does not support z layering of overlays. - */ -#define DDERR_NOZOVERLAYHW MAKE_DDHRESULT( 350 ) - -/* - * The hardware needed for the requested operation has already been - * allocated. - */ -#define DDERR_OUTOFCAPS MAKE_DDHRESULT( 360 ) - -/* - * DirectDraw does not have enough memory to perform the operation. - */ -#define DDERR_OUTOFMEMORY E_OUTOFMEMORY - -/* - * DirectDraw does not have enough memory to perform the operation. - */ -#define DDERR_OUTOFVIDEOMEMORY MAKE_DDHRESULT( 380 ) - -/* - * hardware does not support clipped overlays - */ -#define DDERR_OVERLAYCANTCLIP MAKE_DDHRESULT( 382 ) - -/* - * Can only have ony color key active at one time for overlays - */ -#define DDERR_OVERLAYCOLORKEYONLYONEACTIVE MAKE_DDHRESULT( 384 ) - -/* - * Access to this palette is being refused because the palette is already - * locked by another thread. - */ -#define DDERR_PALETTEBUSY MAKE_DDHRESULT( 387 ) - -/* - * No src color key specified for this operation. - */ -#define DDERR_COLORKEYNOTSET MAKE_DDHRESULT( 400 ) - -/* - * This surface is already attached to the surface it is being attached to. - */ -#define DDERR_SURFACEALREADYATTACHED MAKE_DDHRESULT( 410 ) - -/* - * This surface is already a dependency of the surface it is being made a - * dependency of. - */ -#define DDERR_SURFACEALREADYDEPENDENT MAKE_DDHRESULT( 420 ) - -/* - * Access to this surface is being refused because the surface is already - * locked by another thread. - */ -#define DDERR_SURFACEBUSY MAKE_DDHRESULT( 430 ) - -/* - * Access to this surface is being refused because no driver exists - * which can supply a pointer to the surface. - * This is most likely to happen when attempting to lock the primary - * surface when no DCI provider is present. - * Will also happen on attempts to lock an optimized surface. - */ -#define DDERR_CANTLOCKSURFACE MAKE_DDHRESULT( 435 ) - -/* - * Access to Surface refused because Surface is obscured. - */ -#define DDERR_SURFACEISOBSCURED MAKE_DDHRESULT( 440 ) - -/* - * Access to this surface is being refused because the surface is gone. - * The DIRECTDRAWSURFACE object representing this surface should - * have Restore called on it. - */ -#define DDERR_SURFACELOST MAKE_DDHRESULT( 450 ) - -/* - * The requested surface is not attached. - */ -#define DDERR_SURFACENOTATTACHED MAKE_DDHRESULT( 460 ) - -/* - * Height requested by DirectDraw is too large. - */ -#define DDERR_TOOBIGHEIGHT MAKE_DDHRESULT( 470 ) - -/* - * Size requested by DirectDraw is too large -- The individual height and - * width are OK. - */ -#define DDERR_TOOBIGSIZE MAKE_DDHRESULT( 480 ) - -/* - * Width requested by DirectDraw is too large. - */ -#define DDERR_TOOBIGWIDTH MAKE_DDHRESULT( 490 ) - -/* - * Action not supported. - */ -#define DDERR_UNSUPPORTED E_NOTIMPL - -/* - * Pixel format requested is unsupported by DirectDraw - */ -#define DDERR_UNSUPPORTEDFORMAT MAKE_DDHRESULT( 510 ) - -/* - * Bitmask in the pixel format requested is unsupported by DirectDraw - */ -#define DDERR_UNSUPPORTEDMASK MAKE_DDHRESULT( 520 ) - -/* - * The specified stream contains invalid data - */ -#define DDERR_INVALIDSTREAM MAKE_DDHRESULT( 521 ) - -/* - * vertical blank is in progress - */ -#define DDERR_VERTICALBLANKINPROGRESS MAKE_DDHRESULT( 537 ) - -/* - * Informs DirectDraw that the previous Blt which is transfering information - * to or from this Surface is incomplete. - */ -#define DDERR_WASSTILLDRAWING MAKE_DDHRESULT( 540 ) - - -/* - * The specified surface type requires specification of the COMPLEX flag - */ -#define DDERR_DDSCAPSCOMPLEXREQUIRED MAKE_DDHRESULT( 542 ) - - -/* - * Rectangle provided was not horizontally aligned on reqd. boundary - */ -#define DDERR_XALIGN MAKE_DDHRESULT( 560 ) - -/* - * The GUID passed to DirectDrawCreate is not a valid DirectDraw driver - * identifier. - */ -#define DDERR_INVALIDDIRECTDRAWGUID MAKE_DDHRESULT( 561 ) - -/* - * A DirectDraw object representing this driver has already been created - * for this process. - */ -#define DDERR_DIRECTDRAWALREADYCREATED MAKE_DDHRESULT( 562 ) - -/* - * A hardware only DirectDraw object creation was attempted but the driver - * did not support any hardware. - */ -#define DDERR_NODIRECTDRAWHW MAKE_DDHRESULT( 563 ) - -/* - * this process already has created a primary surface - */ -#define DDERR_PRIMARYSURFACEALREADYEXISTS MAKE_DDHRESULT( 564 ) - -/* - * software emulation not available. - */ -#define DDERR_NOEMULATION MAKE_DDHRESULT( 565 ) - -/* - * region passed to Clipper::GetClipList is too small. - */ -#define DDERR_REGIONTOOSMALL MAKE_DDHRESULT( 566 ) - -/* - * an attempt was made to set a clip list for a clipper objec that - * is already monitoring an hwnd. - */ -#define DDERR_CLIPPERISUSINGHWND MAKE_DDHRESULT( 567 ) - -/* - * No clipper object attached to surface object - */ -#define DDERR_NOCLIPPERATTACHED MAKE_DDHRESULT( 568 ) - -/* - * Clipper notification requires an HWND or - * no HWND has previously been set as the CooperativeLevel HWND. - */ -#define DDERR_NOHWND MAKE_DDHRESULT( 569 ) - -/* - * HWND used by DirectDraw CooperativeLevel has been subclassed, - * this prevents DirectDraw from restoring state. - */ -#define DDERR_HWNDSUBCLASSED MAKE_DDHRESULT( 570 ) - -/* - * The CooperativeLevel HWND has already been set. - * It can not be reset while the process has surfaces or palettes created. - */ -#define DDERR_HWNDALREADYSET MAKE_DDHRESULT( 571 ) - -/* - * No palette object attached to this surface. - */ -#define DDERR_NOPALETTEATTACHED MAKE_DDHRESULT( 572 ) - -/* - * No hardware support for 16 or 256 color palettes. - */ -#define DDERR_NOPALETTEHW MAKE_DDHRESULT( 573 ) - -/* - * If a clipper object is attached to the source surface passed into a - * BltFast call. - */ -#define DDERR_BLTFASTCANTCLIP MAKE_DDHRESULT( 574 ) - -/* - * No blter. - */ -#define DDERR_NOBLTHW MAKE_DDHRESULT( 575 ) - -/* - * No DirectDraw ROP hardware. - */ -#define DDERR_NODDROPSHW MAKE_DDHRESULT( 576 ) - -/* - * returned when GetOverlayPosition is called on a hidden overlay - */ -#define DDERR_OVERLAYNOTVISIBLE MAKE_DDHRESULT( 577 ) - -/* - * returned when GetOverlayPosition is called on a overlay that UpdateOverlay - * has never been called on to establish a destionation. - */ -#define DDERR_NOOVERLAYDEST MAKE_DDHRESULT( 578 ) - -/* - * returned when the position of the overlay on the destionation is no longer - * legal for that destionation. - */ -#define DDERR_INVALIDPOSITION MAKE_DDHRESULT( 579 ) - -/* - * returned when an overlay member is called for a non-overlay surface - */ -#define DDERR_NOTAOVERLAYSURFACE MAKE_DDHRESULT( 580 ) - -/* - * An attempt was made to set the cooperative level when it was already - * set to exclusive. - */ -#define DDERR_EXCLUSIVEMODEALREADYSET MAKE_DDHRESULT( 581 ) - -/* - * An attempt has been made to flip a surface that is not flippable. - */ -#define DDERR_NOTFLIPPABLE MAKE_DDHRESULT( 582 ) - -/* - * Can't duplicate primary & 3D surfaces, or surfaces that are implicitly - * created. - */ -#define DDERR_CANTDUPLICATE MAKE_DDHRESULT( 583 ) - -/* - * Surface was not locked. An attempt to unlock a surface that was not - * locked at all, or by this process, has been attempted. - */ -#define DDERR_NOTLOCKED MAKE_DDHRESULT( 584 ) - -/* - * Windows can not create any more DCs, or a DC was requested for a paltte-indexed - * surface when the surface had no palette AND the display mode was not palette-indexed - * (in this case DirectDraw cannot select a proper palette into the DC) - */ -#define DDERR_CANTCREATEDC MAKE_DDHRESULT( 585 ) - -/* - * No DC was ever created for this surface. - */ -#define DDERR_NODC MAKE_DDHRESULT( 586 ) - -/* - * This surface can not be restored because it was created in a different - * mode. - */ -#define DDERR_WRONGMODE MAKE_DDHRESULT( 587 ) - -/* - * This surface can not be restored because it is an implicitly created - * surface. - */ -#define DDERR_IMPLICITLYCREATED MAKE_DDHRESULT( 588 ) - -/* - * The surface being used is not a palette-based surface - */ -#define DDERR_NOTPALETTIZED MAKE_DDHRESULT( 589 ) - - -/* - * The display is currently in an unsupported mode - */ -#define DDERR_UNSUPPORTEDMODE MAKE_DDHRESULT( 590 ) - -/* - * Operation could not be carried out because there is no mip-map - * texture mapping hardware present or available. - */ -#define DDERR_NOMIPMAPHW MAKE_DDHRESULT( 591 ) - -/* - * The requested action could not be performed because the surface was of - * the wrong type. - */ -#define DDERR_INVALIDSURFACETYPE MAKE_DDHRESULT( 592 ) - - -/* - * Device does not support optimized surfaces, therefore no video memory optimized surfaces - */ -#define DDERR_NOOPTIMIZEHW MAKE_DDHRESULT( 600 ) - -/* - * Surface is an optimized surface, but has not yet been allocated any memory - */ -#define DDERR_NOTLOADED MAKE_DDHRESULT( 601 ) - -/* - * Attempt was made to create or set a device window without first setting - * the focus window - */ -#define DDERR_NOFOCUSWINDOW MAKE_DDHRESULT( 602 ) - -/* - * Attempt was made to set a palette on a mipmap sublevel - */ -#define DDERR_NOTONMIPMAPSUBLEVEL MAKE_DDHRESULT( 603 ) - -/* - * A DC has already been returned for this surface. Only one DC can be - * retrieved per surface. - */ -#define DDERR_DCALREADYCREATED MAKE_DDHRESULT( 620 ) - -/* - * An attempt was made to allocate non-local video memory from a device - * that does not support non-local video memory. - */ -#define DDERR_NONONLOCALVIDMEM MAKE_DDHRESULT( 630 ) - -/* - * The attempt to page lock a surface failed. - */ -#define DDERR_CANTPAGELOCK MAKE_DDHRESULT( 640 ) - - -/* - * The attempt to page unlock a surface failed. - */ -#define DDERR_CANTPAGEUNLOCK MAKE_DDHRESULT( 660 ) - -/* - * An attempt was made to page unlock a surface with no outstanding page locks. - */ -#define DDERR_NOTPAGELOCKED MAKE_DDHRESULT( 680 ) - -/* - * There is more data available than the specified buffer size could hold - */ -#define DDERR_MOREDATA MAKE_DDHRESULT( 690 ) - -/* - * The data has expired and is therefore no longer valid. - */ -#define DDERR_EXPIRED MAKE_DDHRESULT( 691 ) - -/* - * The mode test has finished executing. - */ -#define DDERR_TESTFINISHED MAKE_DDHRESULT( 692 ) - -/* - * The mode test has switched to a new mode. - */ -#define DDERR_NEWMODE MAKE_DDHRESULT( 693 ) - -/* - * D3D has not yet been initialized. - */ -#define DDERR_D3DNOTINITIALIZED MAKE_DDHRESULT( 694 ) - -/* - * The video port is not active - */ -#define DDERR_VIDEONOTACTIVE MAKE_DDHRESULT( 695 ) - -/* - * The monitor does not have EDID data. - */ -#define DDERR_NOMONITORINFORMATION MAKE_DDHRESULT( 696 ) - -/* - * The driver does not enumerate display mode refresh rates. - */ -#define DDERR_NODRIVERSUPPORT MAKE_DDHRESULT( 697 ) - -/* - * Surfaces created by one direct draw device cannot be used directly by - * another direct draw device. - */ -#define DDERR_DEVICEDOESNTOWNSURFACE MAKE_DDHRESULT( 699 ) - - - -/* - * An attempt was made to invoke an interface member of a DirectDraw object - * created by CoCreateInstance() before it was initialized. - */ -#define DDERR_NOTINITIALIZED CO_E_NOTINITIALIZED - - -/* Alpha bit depth constants */ - - -#ifdef __cplusplus -}; -#endif - -#ifdef ENABLE_NAMELESS_UNION_PRAGMA -#pragma warning(default:4201) -#endif - -#endif //__DDRAW_INCLUDED__ - - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: ddraw.h + * Content: DirectDraw include file + * + ***************************************************************************/ + +#ifndef __DDRAW_INCLUDED__ +#define __DDRAW_INCLUDED__ + +//Disable the nameless union warning when building internally +#undef ENABLE_NAMELESS_UNION_PRAGMA +#ifdef DIRECTX_REDIST +#define ENABLE_NAMELESS_UNION_PRAGMA +#endif + +#ifdef ENABLE_NAMELESS_UNION_PRAGMA +#pragma warning(disable:4201) +#endif + +/* + * If you wish an application built against the newest version of DirectDraw + * to run against an older DirectDraw run time then define DIRECTDRAW_VERSION + * to be the earlies version of DirectDraw you wish to run against. For, + * example if you wish an application to run against a DX 3 runtime define + * DIRECTDRAW_VERSION to be 0x0300. + */ +#ifndef DIRECTDRAW_VERSION +#define DIRECTDRAW_VERSION 0x0700 +#endif /* DIRECTDRAW_VERSION */ + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#define COM_NO_WINDOWS_H +#include +#else +#define IUnknown void +#if !defined( NT_BUILD_ENVIRONMENT ) && !defined(WINNT) + #define CO_E_NOTINITIALIZED 0x800401F0L +#endif +#endif + +#define _FACDD 0x876 +#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) + +#ifdef __cplusplus +extern "C" { +#endif + +// +// For compilers that don't support nameless unions, do a +// +// #define NONAMELESSUNION +// +// before #include +// +#ifndef DUMMYUNIONNAMEN +#if defined(__cplusplus) || !defined(NONAMELESSUNION) +#define DUMMYUNIONNAMEN(n) +#else +#define DUMMYUNIONNAMEN(n) u##n +#endif +#endif + +#ifndef MAKEFOURCC + #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ + ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ + ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) +#endif //defined(MAKEFOURCC) + +/* + * FOURCC codes for DX compressed-texture pixel formats + */ +#define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1')) +#define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2')) +#define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3')) +#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4')) +#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5')) + +/* + * GUIDS used by DirectDraw objects + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) + +DEFINE_GUID( CLSID_DirectDraw, 0xD7B70EE0,0x4340,0x11CF,0xB0,0x63,0x00,0x20,0xAF,0xC2,0xCD,0x35 ); +DEFINE_GUID( CLSID_DirectDraw7, 0x3c305196,0x50db,0x11d3,0x9c,0xfe,0x00,0xc0,0x4f,0xd9,0x30,0xc5 ); +DEFINE_GUID( CLSID_DirectDrawClipper, 0x593817A0,0x7DB3,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xb9,0x33,0x56 ); +DEFINE_GUID( IID_IDirectDraw, 0x6C14DB80,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 ); +DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 ); +DEFINE_GUID( IID_IDirectDraw7, 0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b ); +DEFINE_GUID( IID_IDirectDrawSurface, 0x6C14DB81,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDrawSurface2, 0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27 ); +DEFINE_GUID( IID_IDirectDrawSurface3, 0xDA044E00,0x69B2,0x11D0,0xA1,0xD5,0x00,0xAA,0x00,0xB8,0xDF,0xBB ); +DEFINE_GUID( IID_IDirectDrawSurface4, 0x0B2B8630,0xAD35,0x11D0,0x8E,0xA6,0x00,0x60,0x97,0x97,0xEA,0x5B ); +DEFINE_GUID( IID_IDirectDrawSurface7, 0x06675a80,0x3b9b,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b ); +DEFINE_GUID( IID_IDirectDrawPalette, 0x6C14DB84,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDrawClipper, 0x6C14DB85,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); +DEFINE_GUID( IID_IDirectDrawColorControl, 0x4B9F0EE0,0x0D7E,0x11D0,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8 ); +DEFINE_GUID( IID_IDirectDrawGammaControl, 0x69C11C3E,0xB46B,0x11D1,0xAD,0x7A,0x00,0xC0,0x4F,0xC2,0x9B,0x4E ); + +#endif + +/*============================================================================ + * + * DirectDraw Structures + * + * Various structures used to invoke DirectDraw. + * + *==========================================================================*/ + +struct IDirectDraw; +struct IDirectDrawSurface; +struct IDirectDrawPalette; +struct IDirectDrawClipper; + +typedef struct IDirectDraw FAR *LPDIRECTDRAW; +typedef struct IDirectDraw2 FAR *LPDIRECTDRAW2; +typedef struct IDirectDraw4 FAR *LPDIRECTDRAW4; +typedef struct IDirectDraw7 FAR *LPDIRECTDRAW7; +typedef struct IDirectDrawSurface FAR *LPDIRECTDRAWSURFACE; +typedef struct IDirectDrawSurface2 FAR *LPDIRECTDRAWSURFACE2; +typedef struct IDirectDrawSurface3 FAR *LPDIRECTDRAWSURFACE3; +typedef struct IDirectDrawSurface4 FAR *LPDIRECTDRAWSURFACE4; +typedef struct IDirectDrawSurface7 FAR *LPDIRECTDRAWSURFACE7; +typedef struct IDirectDrawPalette FAR *LPDIRECTDRAWPALETTE; +typedef struct IDirectDrawClipper FAR *LPDIRECTDRAWCLIPPER; +typedef struct IDirectDrawColorControl FAR *LPDIRECTDRAWCOLORCONTROL; +typedef struct IDirectDrawGammaControl FAR *LPDIRECTDRAWGAMMACONTROL; + +typedef struct _DDFXROP FAR *LPDDFXROP; +typedef struct _DDSURFACEDESC FAR *LPDDSURFACEDESC; +typedef struct _DDSURFACEDESC2 FAR *LPDDSURFACEDESC2; +typedef struct _DDCOLORCONTROL FAR *LPDDCOLORCONTROL; + +/* + * API's + */ +#if (defined (WIN32) || defined( _WIN32 ) ) && !defined( _NO_COM ) +//#if defined( _WIN32 ) && !defined( _NO_ENUM ) + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKA)(GUID FAR *, LPSTR, LPSTR, LPVOID); + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKW)(GUID FAR *, LPWSTR, LPWSTR, LPVOID); + extern HRESULT WINAPI DirectDrawEnumerateW( LPDDENUMCALLBACKW lpCallback, LPVOID lpContext ); + extern HRESULT WINAPI DirectDrawEnumerateA( LPDDENUMCALLBACKA lpCallback, LPVOID lpContext ); + /* + * Protect against old SDKs + */ + #if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) + #define HMONITOR_DECLARED + DECLARE_HANDLE(HMONITOR); + #endif + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXA)(GUID FAR *, LPSTR, LPSTR, LPVOID, HMONITOR); + typedef BOOL (FAR PASCAL * LPDDENUMCALLBACKEXW)(GUID FAR *, LPWSTR, LPWSTR, LPVOID, HMONITOR); + extern HRESULT WINAPI DirectDrawEnumerateExW( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags); + extern HRESULT WINAPI DirectDrawEnumerateExA( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags); + typedef HRESULT (WINAPI * LPDIRECTDRAWENUMERATEEXA)( LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags); + typedef HRESULT (WINAPI * LPDIRECTDRAWENUMERATEEXW)( LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags); + + #ifdef UNICODE + typedef LPDDENUMCALLBACKW LPDDENUMCALLBACK; + #define DirectDrawEnumerate DirectDrawEnumerateW + typedef LPDDENUMCALLBACKEXW LPDDENUMCALLBACKEX; + typedef LPDIRECTDRAWENUMERATEEXW LPDIRECTDRAWENUMERATEEX; + #define DirectDrawEnumerateEx DirectDrawEnumerateExW + #else + typedef LPDDENUMCALLBACKA LPDDENUMCALLBACK; + #define DirectDrawEnumerate DirectDrawEnumerateA + typedef LPDDENUMCALLBACKEXA LPDDENUMCALLBACKEX; + typedef LPDIRECTDRAWENUMERATEEXA LPDIRECTDRAWENUMERATEEX; + #define DirectDrawEnumerateEx DirectDrawEnumerateExA + #endif + extern HRESULT WINAPI DirectDrawCreate( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter ); + extern HRESULT WINAPI DirectDrawCreateEx( GUID FAR * lpGuid, LPVOID *lplpDD, REFIID iid,IUnknown FAR *pUnkOuter ); + extern HRESULT WINAPI DirectDrawCreateClipper( DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter ); +#endif +/* + * Flags for DirectDrawEnumerateEx + * DirectDrawEnumerateEx supercedes DirectDrawEnumerate. You must use GetProcAddress to + * obtain a function pointer (of type LPDIRECTDRAWENUMERATEEX) to DirectDrawEnumerateEx. + * By default, only the primary display device is enumerated. + * DirectDrawEnumerate is equivalent to DirectDrawEnumerate(,,DDENUM_NONDISPLAYDEVICES) + */ + +/* + * This flag causes enumeration of any GDI display devices which are part of + * the Windows Desktop + */ +#define DDENUM_ATTACHEDSECONDARYDEVICES 0x00000001L + +/* + * This flag causes enumeration of any GDI display devices which are not + * part of the Windows Desktop + */ +#define DDENUM_DETACHEDSECONDARYDEVICES 0x00000002L + +/* + * This flag causes enumeration of non-display devices + */ +#define DDENUM_NONDISPLAYDEVICES 0x00000004L + + +#define REGSTR_KEY_DDHW_DESCRIPTION "Description" +#define REGSTR_KEY_DDHW_DRIVERNAME "DriverName" +#define REGSTR_PATH_DDHW "Hardware\\DirectDrawDrivers" + +#define DDCREATE_HARDWAREONLY 0x00000001l +#define DDCREATE_EMULATIONONLY 0x00000002l + +#if defined(WINNT) || !defined(WIN32) +typedef long HRESULT; +#endif + +//#ifndef WINNT +typedef HRESULT (FAR PASCAL * LPDDENUMMODESCALLBACK)(LPDDSURFACEDESC, LPVOID); +typedef HRESULT (FAR PASCAL * LPDDENUMMODESCALLBACK2)(LPDDSURFACEDESC2, LPVOID); +typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK)(LPDIRECTDRAWSURFACE, LPDDSURFACEDESC, LPVOID); +typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK2)(LPDIRECTDRAWSURFACE4, LPDDSURFACEDESC2, LPVOID); +typedef HRESULT (FAR PASCAL * LPDDENUMSURFACESCALLBACK7)(LPDIRECTDRAWSURFACE7, LPDDSURFACEDESC2, LPVOID); +//#endif + +/* + * Generic pixel format with 8-bit RGB and alpha components + */ +typedef struct _DDARGB +{ + BYTE blue; + BYTE green; + BYTE red; + BYTE alpha; +} DDARGB; + +typedef DDARGB FAR *LPDDARGB; + +/* + * This version of the structure remains for backwards source compatibility. + * The DDARGB structure is the one that should be used for all DirectDraw APIs. + */ +typedef struct _DDRGBA +{ + BYTE red; + BYTE green; + BYTE blue; + BYTE alpha; +} DDRGBA; + +typedef DDRGBA FAR *LPDDRGBA; + + +/* + * DDCOLORKEY + */ +typedef struct _DDCOLORKEY +{ + DWORD dwColorSpaceLowValue; // low boundary of color space that is to + // be treated as Color Key, inclusive + DWORD dwColorSpaceHighValue; // high boundary of color space that is + // to be treated as Color Key, inclusive +} DDCOLORKEY; + +typedef DDCOLORKEY FAR* LPDDCOLORKEY; + +/* + * DDBLTFX + * Used to pass override information to the DIRECTDRAWSURFACE callback Blt. + */ +typedef struct _DDBLTFX +{ + DWORD dwSize; // size of structure + DWORD dwDDFX; // FX operations + DWORD dwROP; // Win32 raster operations + DWORD dwDDROP; // Raster operations new for DirectDraw + DWORD dwRotationAngle; // Rotation angle for blt + DWORD dwZBufferOpCode; // ZBuffer compares + DWORD dwZBufferLow; // Low limit of Z buffer + DWORD dwZBufferHigh; // High limit of Z buffer + DWORD dwZBufferBaseDest; // Destination base value + DWORD dwZDestConstBitDepth; // Bit depth used to specify Z constant for destination + union + { + DWORD dwZDestConst; // Constant to use as Z buffer for dest + LPDIRECTDRAWSURFACE lpDDSZBufferDest; // Surface to use as Z buffer for dest + } DUMMYUNIONNAMEN(1); + DWORD dwZSrcConstBitDepth; // Bit depth used to specify Z constant for source + union + { + DWORD dwZSrcConst; // Constant to use as Z buffer for src + LPDIRECTDRAWSURFACE lpDDSZBufferSrc; // Surface to use as Z buffer for src + } DUMMYUNIONNAMEN(2); + DWORD dwAlphaEdgeBlendBitDepth; // Bit depth used to specify constant for alpha edge blend + DWORD dwAlphaEdgeBlend; // Alpha for edge blending + DWORD dwReserved; + DWORD dwAlphaDestConstBitDepth; // Bit depth used to specify alpha constant for destination + union + { + DWORD dwAlphaDestConst; // Constant to use as Alpha Channel + LPDIRECTDRAWSURFACE lpDDSAlphaDest; // Surface to use as Alpha Channel + } DUMMYUNIONNAMEN(3); + DWORD dwAlphaSrcConstBitDepth; // Bit depth used to specify alpha constant for source + union + { + DWORD dwAlphaSrcConst; // Constant to use as Alpha Channel + LPDIRECTDRAWSURFACE lpDDSAlphaSrc; // Surface to use as Alpha Channel + } DUMMYUNIONNAMEN(4); + union + { + DWORD dwFillColor; // color in RGB or Palettized + DWORD dwFillDepth; // depth value for z-buffer + DWORD dwFillPixel; // pixel value for RGBA or RGBZ + LPDIRECTDRAWSURFACE lpDDSPattern; // Surface to use as pattern + } DUMMYUNIONNAMEN(5); + DDCOLORKEY ddckDestColorkey; // DestColorkey override + DDCOLORKEY ddckSrcColorkey; // SrcColorkey override +} DDBLTFX; + +typedef DDBLTFX FAR* LPDDBLTFX; + + + +/* + * DDSCAPS + */ +typedef struct _DDSCAPS +{ + DWORD dwCaps; // capabilities of surface wanted +} DDSCAPS; + +typedef DDSCAPS FAR* LPDDSCAPS; + + +/* + * DDOSCAPS + */ +typedef struct _DDOSCAPS +{ + DWORD dwCaps; // capabilities of surface wanted +} DDOSCAPS; + +typedef DDOSCAPS FAR* LPDDOSCAPS; + +/* + * This structure is used internally by DirectDraw. + */ +typedef struct _DDSCAPSEX +{ + DWORD dwCaps2; + DWORD dwCaps3; + union + { + DWORD dwCaps4; + DWORD dwVolumeDepth; + } DUMMYUNIONNAMEN(1); +} DDSCAPSEX, FAR * LPDDSCAPSEX; + +/* + * DDSCAPS2 + */ +typedef struct _DDSCAPS2 +{ + DWORD dwCaps; // capabilities of surface wanted + DWORD dwCaps2; + DWORD dwCaps3; + union + { + DWORD dwCaps4; + DWORD dwVolumeDepth; + } DUMMYUNIONNAMEN(1); +} DDSCAPS2; + +typedef DDSCAPS2 FAR* LPDDSCAPS2; + +/* + * DDCAPS + */ +#define DD_ROP_SPACE (256/32) // space required to store ROP array +/* + * NOTE: Our choosen structure number scheme is to append a single digit to + * the end of the structure giving the version that structure is associated + * with. + */ + +/* + * This structure represents the DDCAPS structure released in DirectDraw 1.0. It is used internally + * by DirectDraw to interpret caps passed into ddraw by drivers written prior to the release of DirectDraw 2.0. + * New applications should use the DDCAPS structure defined below. + */ +typedef struct _DDCAPS_DX1 +{ + DWORD dwSize; // size of the DDDRIVERCAPS structure + DWORD dwCaps; // driver specific capabilities + DWORD dwCaps2; // more driver specific capabilites + DWORD dwCKeyCaps; // color key capabilities of the surface + DWORD dwFXCaps; // driver specific stretching and effects capabilites + DWORD dwFXAlphaCaps; // alpha driver specific capabilities + DWORD dwPalCaps; // palette capabilities + DWORD dwSVCaps; // stereo vision capabilities + DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 + DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 + DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 + DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 + DWORD dwVidMemTotal; // total amount of video memory + DWORD dwVidMemFree; // amount of free video memory + DWORD dwMaxVisibleOverlays; // maximum number of visible overlays + DWORD dwCurrVisibleOverlays; // current number of visible overlays + DWORD dwNumFourCCCodes; // number of four cc codes + DWORD dwAlignBoundarySrc; // source rectangle alignment + DWORD dwAlignSizeSrc; // source rectangle byte size + DWORD dwAlignBoundaryDest; // dest rectangle alignment + DWORD dwAlignSizeDest; // dest rectangle byte size + DWORD dwAlignStrideAlign; // stride alignment + DWORD dwRops[DD_ROP_SPACE]; // ROPS supported + DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities + DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMinLiveVideoStretch; // OBSOLETE! This field remains for compatability reasons only + DWORD dwMaxLiveVideoStretch; // OBSOLETE! This field remains for compatability reasons only + DWORD dwMinHwCodecStretch; // OBSOLETE! This field remains for compatability reasons only + DWORD dwMaxHwCodecStretch; // OBSOLETE! This field remains for compatability reasons only + DWORD dwReserved1; // reserved + DWORD dwReserved2; // reserved + DWORD dwReserved3; // reserved +} DDCAPS_DX1; + +typedef DDCAPS_DX1 FAR* LPDDCAPS_DX1; + +/* + * This structure is the DDCAPS structure as it was in version 2 and 3 of Direct X. + * It is present for back compatability. + */ +typedef struct _DDCAPS_DX3 +{ + DWORD dwSize; // size of the DDDRIVERCAPS structure + DWORD dwCaps; // driver specific capabilities + DWORD dwCaps2; // more driver specific capabilites + DWORD dwCKeyCaps; // color key capabilities of the surface + DWORD dwFXCaps; // driver specific stretching and effects capabilites + DWORD dwFXAlphaCaps; // alpha driver specific capabilities + DWORD dwPalCaps; // palette capabilities + DWORD dwSVCaps; // stereo vision capabilities + DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 + DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 + DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 + DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 + DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 + DWORD dwVidMemTotal; // total amount of video memory + DWORD dwVidMemFree; // amount of free video memory + DWORD dwMaxVisibleOverlays; // maximum number of visible overlays + DWORD dwCurrVisibleOverlays; // current number of visible overlays + DWORD dwNumFourCCCodes; // number of four cc codes + DWORD dwAlignBoundarySrc; // source rectangle alignment + DWORD dwAlignSizeSrc; // source rectangle byte size + DWORD dwAlignBoundaryDest; // dest rectangle alignment + DWORD dwAlignSizeDest; // dest rectangle byte size + DWORD dwAlignStrideAlign; // stride alignment + DWORD dwRops[DD_ROP_SPACE]; // ROPS supported + DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities + DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + DWORD dwReserved1; // reserved + DWORD dwReserved2; // reserved + DWORD dwReserved3; // reserved + DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts + DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts + DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts + DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts + DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts + DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts + DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts + DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts + DWORD dwSSBCaps; // driver specific capabilities for System->System blts + DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts + DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts + DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts + DWORD dwReserved4; // reserved + DWORD dwReserved5; // reserved + DWORD dwReserved6; // reserved +} DDCAPS_DX3; +typedef DDCAPS_DX3 FAR* LPDDCAPS_DX3; + +/* + * This structure is the DDCAPS structure as it was in version 5 of Direct X. + * It is present for back compatability. + */ +typedef struct _DDCAPS_DX5 +{ +/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure +/* 4*/ DWORD dwCaps; // driver specific capabilities +/* 8*/ DWORD dwCaps2; // more driver specific capabilites +/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface +/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites +/* 14*/ DWORD dwFXAlphaCaps; // alpha driver specific capabilities +/* 18*/ DWORD dwPalCaps; // palette capabilities +/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities +/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 +/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 +/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 +/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 +/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 +/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 +/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 +/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory +/* 40*/ DWORD dwVidMemFree; // amount of free video memory +/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays +/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays +/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes +/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment +/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size +/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment +/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size +/* 60*/ DWORD dwAlignStrideAlign; // stride alignment +/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported +/* 84*/ DDSCAPS ddsCaps; // DDSCAPS structure has all the general capabilities +/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* a0*/ DWORD dwReserved1; // reserved +/* a4*/ DWORD dwReserved2; // reserved +/* a8*/ DWORD dwReserved3; // reserved +/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts +/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts +/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts +/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts +/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts +/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts +/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts +/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts +/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts +/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts +/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts +/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts +// Members added for DX5: +/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports +/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used +/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts +/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts +/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts +/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts +/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts +/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts +} DDCAPS_DX5; +typedef DDCAPS_DX5 FAR* LPDDCAPS_DX5; + +typedef struct _DDCAPS_DX6 +{ +/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure +/* 4*/ DWORD dwCaps; // driver specific capabilities +/* 8*/ DWORD dwCaps2; // more driver specific capabilites +/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface +/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites +/* 14*/ DWORD dwFXAlphaCaps; // alpha caps +/* 18*/ DWORD dwPalCaps; // palette capabilities +/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities +/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 +/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 +/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 +/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 +/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 +/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 +/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 +/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory +/* 40*/ DWORD dwVidMemFree; // amount of free video memory +/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays +/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays +/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes +/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment +/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size +/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment +/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size +/* 60*/ DWORD dwAlignStrideAlign; // stride alignment +/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported +/* 84*/ DDSCAPS ddsOldCaps; // Was DDSCAPS ddsCaps. ddsCaps is of type DDSCAPS2 for DX6 +/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* a0*/ DWORD dwReserved1; // reserved +/* a4*/ DWORD dwReserved2; // reserved +/* a8*/ DWORD dwReserved3; // reserved +/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts +/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts +/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts +/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts +/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts +/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts +/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts +/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts +/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts +/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts +/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts +/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts +/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports +/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used +/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts +/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts +/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts +/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts +/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts +/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts +// Members added for DX6 release +/*16c*/ DDSCAPS2 ddsCaps; // Surface Caps +} DDCAPS_DX6; +typedef DDCAPS_DX6 FAR* LPDDCAPS_DX6; + +typedef struct _DDCAPS_DX7 +{ +/* 0*/ DWORD dwSize; // size of the DDDRIVERCAPS structure +/* 4*/ DWORD dwCaps; // driver specific capabilities +/* 8*/ DWORD dwCaps2; // more driver specific capabilites +/* c*/ DWORD dwCKeyCaps; // color key capabilities of the surface +/* 10*/ DWORD dwFXCaps; // driver specific stretching and effects capabilites +/* 14*/ DWORD dwFXAlphaCaps; // alpha driver specific capabilities +/* 18*/ DWORD dwPalCaps; // palette capabilities +/* 1c*/ DWORD dwSVCaps; // stereo vision capabilities +/* 20*/ DWORD dwAlphaBltConstBitDepths; // DDBD_2,4,8 +/* 24*/ DWORD dwAlphaBltPixelBitDepths; // DDBD_1,2,4,8 +/* 28*/ DWORD dwAlphaBltSurfaceBitDepths; // DDBD_1,2,4,8 +/* 2c*/ DWORD dwAlphaOverlayConstBitDepths; // DDBD_2,4,8 +/* 30*/ DWORD dwAlphaOverlayPixelBitDepths; // DDBD_1,2,4,8 +/* 34*/ DWORD dwAlphaOverlaySurfaceBitDepths; // DDBD_1,2,4,8 +/* 38*/ DWORD dwZBufferBitDepths; // DDBD_8,16,24,32 +/* 3c*/ DWORD dwVidMemTotal; // total amount of video memory +/* 40*/ DWORD dwVidMemFree; // amount of free video memory +/* 44*/ DWORD dwMaxVisibleOverlays; // maximum number of visible overlays +/* 48*/ DWORD dwCurrVisibleOverlays; // current number of visible overlays +/* 4c*/ DWORD dwNumFourCCCodes; // number of four cc codes +/* 50*/ DWORD dwAlignBoundarySrc; // source rectangle alignment +/* 54*/ DWORD dwAlignSizeSrc; // source rectangle byte size +/* 58*/ DWORD dwAlignBoundaryDest; // dest rectangle alignment +/* 5c*/ DWORD dwAlignSizeDest; // dest rectangle byte size +/* 60*/ DWORD dwAlignStrideAlign; // stride alignment +/* 64*/ DWORD dwRops[DD_ROP_SPACE]; // ROPS supported +/* 84*/ DDSCAPS ddsOldCaps; // Was DDSCAPS ddsCaps. ddsCaps is of type DDSCAPS2 for DX6 +/* 88*/ DWORD dwMinOverlayStretch; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 8c*/ DWORD dwMaxOverlayStretch; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 90*/ DWORD dwMinLiveVideoStretch; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 94*/ DWORD dwMaxLiveVideoStretch; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 98*/ DWORD dwMinHwCodecStretch; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* 9c*/ DWORD dwMaxHwCodecStretch; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 +/* a0*/ DWORD dwReserved1; // reserved +/* a4*/ DWORD dwReserved2; // reserved +/* a8*/ DWORD dwReserved3; // reserved +/* ac*/ DWORD dwSVBCaps; // driver specific capabilities for System->Vmem blts +/* b0*/ DWORD dwSVBCKeyCaps; // driver color key capabilities for System->Vmem blts +/* b4*/ DWORD dwSVBFXCaps; // driver FX capabilities for System->Vmem blts +/* b8*/ DWORD dwSVBRops[DD_ROP_SPACE];// ROPS supported for System->Vmem blts +/* d8*/ DWORD dwVSBCaps; // driver specific capabilities for Vmem->System blts +/* dc*/ DWORD dwVSBCKeyCaps; // driver color key capabilities for Vmem->System blts +/* e0*/ DWORD dwVSBFXCaps; // driver FX capabilities for Vmem->System blts +/* e4*/ DWORD dwVSBRops[DD_ROP_SPACE];// ROPS supported for Vmem->System blts +/*104*/ DWORD dwSSBCaps; // driver specific capabilities for System->System blts +/*108*/ DWORD dwSSBCKeyCaps; // driver color key capabilities for System->System blts +/*10c*/ DWORD dwSSBFXCaps; // driver FX capabilities for System->System blts +/*110*/ DWORD dwSSBRops[DD_ROP_SPACE];// ROPS supported for System->System blts +/*130*/ DWORD dwMaxVideoPorts; // maximum number of usable video ports +/*134*/ DWORD dwCurrVideoPorts; // current number of video ports used +/*138*/ DWORD dwSVBCaps2; // more driver specific capabilities for System->Vmem blts +/*13c*/ DWORD dwNLVBCaps; // driver specific capabilities for non-local->local vidmem blts +/*140*/ DWORD dwNLVBCaps2; // more driver specific capabilities non-local->local vidmem blts +/*144*/ DWORD dwNLVBCKeyCaps; // driver color key capabilities for non-local->local vidmem blts +/*148*/ DWORD dwNLVBFXCaps; // driver FX capabilities for non-local->local blts +/*14c*/ DWORD dwNLVBRops[DD_ROP_SPACE]; // ROPS supported for non-local->local blts +// Members added for DX6 release +/*16c*/ DDSCAPS2 ddsCaps; // Surface Caps +} DDCAPS_DX7; +typedef DDCAPS_DX7 FAR* LPDDCAPS_DX7; + + +#if DIRECTDRAW_VERSION <= 0x300 + typedef DDCAPS_DX3 DDCAPS; +#elif DIRECTDRAW_VERSION <= 0x500 + typedef DDCAPS_DX5 DDCAPS; +#elif DIRECTDRAW_VERSION <= 0x600 + typedef DDCAPS_DX6 DDCAPS; +#else + typedef DDCAPS_DX7 DDCAPS; +#endif + +typedef DDCAPS FAR* LPDDCAPS; + + + +/* + * DDPIXELFORMAT + */ +typedef struct _DDPIXELFORMAT +{ + DWORD dwSize; // size of structure + DWORD dwFlags; // pixel format flags + DWORD dwFourCC; // (FOURCC code) + union + { + DWORD dwRGBBitCount; // how many bits per pixel + DWORD dwYUVBitCount; // how many bits per pixel + DWORD dwZBufferBitDepth; // how many total bits/pixel in z buffer (including any stencil bits) + DWORD dwAlphaBitDepth; // how many bits for alpha channels + DWORD dwLuminanceBitCount; // how many bits per pixel + DWORD dwBumpBitCount; // how many bits per "buxel", total + DWORD dwPrivateFormatBitCount;// Bits per pixel of private driver formats. Only valid in texture + // format list and if DDPF_D3DFORMAT is set + } DUMMYUNIONNAMEN(1); + union + { + DWORD dwRBitMask; // mask for red bit + DWORD dwYBitMask; // mask for Y bits + DWORD dwStencilBitDepth; // how many stencil bits (note: dwZBufferBitDepth-dwStencilBitDepth is total Z-only bits) + DWORD dwLuminanceBitMask; // mask for luminance bits + DWORD dwBumpDuBitMask; // mask for bump map U delta bits + DWORD dwOperations; // DDPF_D3DFORMAT Operations + } DUMMYUNIONNAMEN(2); + union + { + DWORD dwGBitMask; // mask for green bits + DWORD dwUBitMask; // mask for U bits + DWORD dwZBitMask; // mask for Z bits + DWORD dwBumpDvBitMask; // mask for bump map V delta bits + struct + { + WORD wFlipMSTypes; // Multisample methods supported via flip for this D3DFORMAT + WORD wBltMSTypes; // Multisample methods supported via blt for this D3DFORMAT + } MultiSampleCaps; + + } DUMMYUNIONNAMEN(3); + union + { + DWORD dwBBitMask; // mask for blue bits + DWORD dwVBitMask; // mask for V bits + DWORD dwStencilBitMask; // mask for stencil bits + DWORD dwBumpLuminanceBitMask; // mask for luminance in bump map + } DUMMYUNIONNAMEN(4); + union + { + DWORD dwRGBAlphaBitMask; // mask for alpha channel + DWORD dwYUVAlphaBitMask; // mask for alpha channel + DWORD dwLuminanceAlphaBitMask;// mask for alpha channel + DWORD dwRGBZBitMask; // mask for Z channel + DWORD dwYUVZBitMask; // mask for Z channel + } DUMMYUNIONNAMEN(5); +} DDPIXELFORMAT; + +typedef DDPIXELFORMAT FAR* LPDDPIXELFORMAT; + +/* + * DDOVERLAYFX + */ +typedef struct _DDOVERLAYFX +{ + DWORD dwSize; // size of structure + DWORD dwAlphaEdgeBlendBitDepth; // Bit depth used to specify constant for alpha edge blend + DWORD dwAlphaEdgeBlend; // Constant to use as alpha for edge blend + DWORD dwReserved; + DWORD dwAlphaDestConstBitDepth; // Bit depth used to specify alpha constant for destination + union + { + DWORD dwAlphaDestConst; // Constant to use as alpha channel for dest + LPDIRECTDRAWSURFACE lpDDSAlphaDest; // Surface to use as alpha channel for dest + } DUMMYUNIONNAMEN(1); + DWORD dwAlphaSrcConstBitDepth; // Bit depth used to specify alpha constant for source + union + { + DWORD dwAlphaSrcConst; // Constant to use as alpha channel for src + LPDIRECTDRAWSURFACE lpDDSAlphaSrc; // Surface to use as alpha channel for src + } DUMMYUNIONNAMEN(2); + DDCOLORKEY dckDestColorkey; // DestColorkey override + DDCOLORKEY dckSrcColorkey; // DestColorkey override + DWORD dwDDFX; // Overlay FX + DWORD dwFlags; // flags +} DDOVERLAYFX; + +typedef DDOVERLAYFX FAR *LPDDOVERLAYFX; + + +/* + * DDBLTBATCH: BltBatch entry structure + */ +typedef struct _DDBLTBATCH +{ + LPRECT lprDest; + LPDIRECTDRAWSURFACE lpDDSSrc; + LPRECT lprSrc; + DWORD dwFlags; + LPDDBLTFX lpDDBltFx; +} DDBLTBATCH; + +typedef DDBLTBATCH FAR * LPDDBLTBATCH; + + +/* + * DDGAMMARAMP + */ +typedef struct _DDGAMMARAMP +{ + WORD red[256]; + WORD green[256]; + WORD blue[256]; +} DDGAMMARAMP; +typedef DDGAMMARAMP FAR * LPDDGAMMARAMP; + +/* + * This is the structure within which DirectDraw returns data about the current graphics driver and chipset + */ + +#define MAX_DDDEVICEID_STRING 512 + +typedef struct tagDDDEVICEIDENTIFIER +{ + /* + * These elements are for presentation to the user only. They should not be used to identify particular + * drivers, since this is unreliable and many different strings may be associated with the same + * device, and the same driver from different vendors. + */ + char szDriver[MAX_DDDEVICEID_STRING]; + char szDescription[MAX_DDDEVICEID_STRING]; + + /* + * This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons + * on the whole 64 bits. Caution should be exercised if you use this element to identify problematic + * drivers. It is recommended that guidDeviceIdentifier is used for this purpose. + * + * This version has the form: + * wProduct = HIWORD(liDriverVersion.HighPart) + * wVersion = LOWORD(liDriverVersion.HighPart) + * wSubVersion = HIWORD(liDriverVersion.LowPart) + * wBuild = LOWORD(liDriverVersion.LowPart) + */ +#ifdef _WIN32 + LARGE_INTEGER liDriverVersion; /* Defined for applications and other 32 bit components */ +#else + DWORD dwDriverVersionLowPart; /* Defined for 16 bit driver components */ + DWORD dwDriverVersionHighPart; +#endif + + + /* + * These elements can be used to identify particular chipsets. Use with extreme caution. + * dwVendorId Identifies the manufacturer. May be zero if unknown. + * dwDeviceId Identifies the type of chipset. May be zero if unknown. + * dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown. + * dwRevision Identifies the revision level of the chipset. May be zero if unknown. + */ + DWORD dwVendorId; + DWORD dwDeviceId; + DWORD dwSubSysId; + DWORD dwRevision; + + /* + * This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the + * driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to + * reprofile the graphics subsystem. + * This element can also be used to identify particular problematic drivers. + */ + GUID guidDeviceIdentifier; +} DDDEVICEIDENTIFIER, * LPDDDEVICEIDENTIFIER; + +typedef struct tagDDDEVICEIDENTIFIER2 +{ + /* + * These elements are for presentation to the user only. They should not be used to identify particular + * drivers, since this is unreliable and many different strings may be associated with the same + * device, and the same driver from different vendors. + */ + char szDriver[MAX_DDDEVICEID_STRING]; + char szDescription[MAX_DDDEVICEID_STRING]; + + /* + * This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons + * on the whole 64 bits. Caution should be exercised if you use this element to identify problematic + * drivers. It is recommended that guidDeviceIdentifier is used for this purpose. + * + * This version has the form: + * wProduct = HIWORD(liDriverVersion.HighPart) + * wVersion = LOWORD(liDriverVersion.HighPart) + * wSubVersion = HIWORD(liDriverVersion.LowPart) + * wBuild = LOWORD(liDriverVersion.LowPart) + */ +#ifdef _WIN32 + LARGE_INTEGER liDriverVersion; /* Defined for applications and other 32 bit components */ +#else + DWORD dwDriverVersionLowPart; /* Defined for 16 bit driver components */ + DWORD dwDriverVersionHighPart; +#endif + + + /* + * These elements can be used to identify particular chipsets. Use with extreme caution. + * dwVendorId Identifies the manufacturer. May be zero if unknown. + * dwDeviceId Identifies the type of chipset. May be zero if unknown. + * dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown. + * dwRevision Identifies the revision level of the chipset. May be zero if unknown. + */ + DWORD dwVendorId; + DWORD dwDeviceId; + DWORD dwSubSysId; + DWORD dwRevision; + + /* + * This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the + * driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to + * reprofile the graphics subsystem. + * This element can also be used to identify particular problematic drivers. + */ + GUID guidDeviceIdentifier; + + /* + * This element is used to determine the Windows Hardware Quality Lab (WHQL) + * certification level for this driver/device pair. + */ + DWORD dwWHQLLevel; + +} DDDEVICEIDENTIFIER2, * LPDDDEVICEIDENTIFIER2; + +/* + * Flags for the IDirectDraw4::GetDeviceIdentifier method + */ + +/* + * This flag causes GetDeviceIdentifier to return information about the host (typically 2D) adapter in a system equipped + * with a stacked secondary 3D adapter. Such an adapter appears to the application as if it were part of the + * host adapter, but is typically physcially located on a separate card. The stacked secondary's information is + * returned when GetDeviceIdentifier's dwFlags field is zero, since this most accurately reflects the qualities + * of the DirectDraw object involved. + */ +#define DDGDI_GETHOSTIDENTIFIER 0x00000001L + +/* + * Macros for interpretting DDEVICEIDENTIFIER2.dwWHQLLevel + */ +#define GET_WHQL_YEAR( dwWHQLLevel ) \ + ( (dwWHQLLevel) / 0x10000 ) +#define GET_WHQL_MONTH( dwWHQLLevel ) \ + ( ( (dwWHQLLevel) / 0x100 ) & 0x00ff ) +#define GET_WHQL_DAY( dwWHQLLevel ) \ + ( (dwWHQLLevel) & 0xff ) + + +/* + * callbacks + */ +typedef DWORD (FAR PASCAL *LPCLIPPERCALLBACK)(LPDIRECTDRAWCLIPPER lpDDClipper, HWND hWnd, DWORD code, LPVOID lpContext ); +#ifdef STREAMING +typedef DWORD (FAR PASCAL *LPSURFACESTREAMINGCALLBACK)(DWORD); +#endif + + +/* + * INTERACES FOLLOW: + * IDirectDraw + * IDirectDrawClipper + * IDirectDrawPalette + * IDirectDrawSurface + */ + +/* + * IDirectDraw + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDraw +DECLARE_INTERFACE_( IDirectDraw, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDraw methods ***/ + STDMETHOD(Compact)(THIS) PURE; + STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *) PURE; + STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * ) PURE; + STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK ) PURE; + STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK ) PURE; + STDMETHOD(FlipToGDISurface)(THIS) PURE; + STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; + STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; + STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE FAR *) PURE; + STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; + STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; + STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; + STDMETHOD(RestoreDisplayMode)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; + STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD) PURE; + STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDraw_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDraw_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDraw_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDraw_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectDraw_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) +#define IDirectDraw_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) +#define IDirectDraw_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) +#define IDirectDraw_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) +#define IDirectDraw_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) +#define IDirectDraw_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) +#define IDirectDraw_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) +#define IDirectDraw_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) +#define IDirectDraw_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) +#define IDirectDraw_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) +#define IDirectDraw_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) +#define IDirectDraw_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) +#define IDirectDraw_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) +#define IDirectDraw_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) +#define IDirectDraw_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) +#define IDirectDraw_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) +#define IDirectDraw_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) +#define IDirectDraw_SetDisplayMode(p, a, b, c) (p)->lpVtbl->SetDisplayMode(p, a, b, c) +#define IDirectDraw_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) +#else +#define IDirectDraw_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDraw_AddRef(p) (p)->AddRef() +#define IDirectDraw_Release(p) (p)->Release() +#define IDirectDraw_Compact(p) (p)->Compact() +#define IDirectDraw_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) +#define IDirectDraw_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) +#define IDirectDraw_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) +#define IDirectDraw_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) +#define IDirectDraw_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) +#define IDirectDraw_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) +#define IDirectDraw_FlipToGDISurface(p) (p)->FlipToGDISurface() +#define IDirectDraw_GetCaps(p, a, b) (p)->GetCaps(a, b) +#define IDirectDraw_GetDisplayMode(p, a) (p)->GetDisplayMode(a) +#define IDirectDraw_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) +#define IDirectDraw_GetGDISurface(p, a) (p)->GetGDISurface(a) +#define IDirectDraw_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) +#define IDirectDraw_GetScanLine(p, a) (p)->GetScanLine(a) +#define IDirectDraw_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) +#define IDirectDraw_Initialize(p, a) (p)->Initialize(a) +#define IDirectDraw_RestoreDisplayMode(p) (p)->RestoreDisplayMode() +#define IDirectDraw_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) +#define IDirectDraw_SetDisplayMode(p, a, b, c) (p)->SetDisplayMode(a, b, c) +#define IDirectDraw_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) +#endif + +#endif + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDraw2 +DECLARE_INTERFACE_( IDirectDraw2, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDraw methods ***/ + STDMETHOD(Compact)(THIS) PURE; + STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC, LPDIRECTDRAWSURFACE FAR *, IUnknown FAR *) PURE; + STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * ) PURE; + STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC, LPVOID, LPDDENUMMODESCALLBACK ) PURE; + STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK ) PURE; + STDMETHOD(FlipToGDISurface)(THIS) PURE; + STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; + STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; + STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE FAR *) PURE; + STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; + STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; + STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; + STDMETHOD(RestoreDisplayMode)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; + STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; + STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS, LPDWORD, LPDWORD) PURE; +}; +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDraw2_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDraw2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDraw2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDraw2_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectDraw2_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) +#define IDirectDraw2_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) +#define IDirectDraw2_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) +#define IDirectDraw2_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) +#define IDirectDraw2_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) +#define IDirectDraw2_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) +#define IDirectDraw2_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) +#define IDirectDraw2_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) +#define IDirectDraw2_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) +#define IDirectDraw2_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) +#define IDirectDraw2_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) +#define IDirectDraw2_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) +#define IDirectDraw2_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) +#define IDirectDraw2_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) +#define IDirectDraw2_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) +#define IDirectDraw2_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) +#define IDirectDraw2_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) +#define IDirectDraw2_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) +#define IDirectDraw2_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) +#define IDirectDraw2_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) +#else +#define IDirectDraw2_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDraw2_AddRef(p) (p)->AddRef() +#define IDirectDraw2_Release(p) (p)->Release() +#define IDirectDraw2_Compact(p) (p)->Compact() +#define IDirectDraw2_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) +#define IDirectDraw2_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) +#define IDirectDraw2_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) +#define IDirectDraw2_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) +#define IDirectDraw2_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) +#define IDirectDraw2_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) +#define IDirectDraw2_FlipToGDISurface(p) (p)->FlipToGDISurface() +#define IDirectDraw2_GetCaps(p, a, b) (p)->GetCaps(a, b) +#define IDirectDraw2_GetDisplayMode(p, a) (p)->GetDisplayMode(a) +#define IDirectDraw2_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) +#define IDirectDraw2_GetGDISurface(p, a) (p)->GetGDISurface(a) +#define IDirectDraw2_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) +#define IDirectDraw2_GetScanLine(p, a) (p)->GetScanLine(a) +#define IDirectDraw2_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) +#define IDirectDraw2_Initialize(p, a) (p)->Initialize(a) +#define IDirectDraw2_RestoreDisplayMode(p) (p)->RestoreDisplayMode() +#define IDirectDraw2_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) +#define IDirectDraw2_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) +#define IDirectDraw2_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) +#define IDirectDraw2_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) +#endif + +#endif + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDraw4 +DECLARE_INTERFACE_( IDirectDraw4, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDraw methods ***/ + STDMETHOD(Compact)(THIS) PURE; + STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE4 FAR *, IUnknown FAR *) PURE; + STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE4, LPDIRECTDRAWSURFACE4 FAR * ) PURE; + STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC2, LPVOID, LPDDENUMMODESCALLBACK2 ) PURE; + STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK2 ) PURE; + STDMETHOD(FlipToGDISurface)(THIS) PURE; + STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; + STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC2) PURE; + STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; + STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE4 FAR *) PURE; + STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; + STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; + STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; + STDMETHOD(RestoreDisplayMode)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; + STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; + STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2, LPDWORD, LPDWORD) PURE; + /*** Added in the V4 Interface ***/ + STDMETHOD(GetSurfaceFromDC) (THIS_ HDC, LPDIRECTDRAWSURFACE4 *) PURE; + STDMETHOD(RestoreAllSurfaces)(THIS) PURE; + STDMETHOD(TestCooperativeLevel)(THIS) PURE; + STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER, DWORD ) PURE; +}; +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDraw4_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDraw4_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDraw4_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDraw4_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectDraw4_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) +#define IDirectDraw4_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) +#define IDirectDraw4_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) +#define IDirectDraw4_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) +#define IDirectDraw4_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) +#define IDirectDraw4_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) +#define IDirectDraw4_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) +#define IDirectDraw4_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) +#define IDirectDraw4_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) +#define IDirectDraw4_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) +#define IDirectDraw4_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) +#define IDirectDraw4_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) +#define IDirectDraw4_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) +#define IDirectDraw4_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) +#define IDirectDraw4_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) +#define IDirectDraw4_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) +#define IDirectDraw4_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) +#define IDirectDraw4_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) +#define IDirectDraw4_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) +#define IDirectDraw4_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) +#define IDirectDraw4_GetSurfaceFromDC(p, a, b) (p)->lpVtbl->GetSurfaceFromDC(p, a, b) +#define IDirectDraw4_RestoreAllSurfaces(p) (p)->lpVtbl->RestoreAllSurfaces(p) +#define IDirectDraw4_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) +#define IDirectDraw4_GetDeviceIdentifier(p,a,b) (p)->lpVtbl->GetDeviceIdentifier(p,a,b) +#else +#define IDirectDraw4_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDraw4_AddRef(p) (p)->AddRef() +#define IDirectDraw4_Release(p) (p)->Release() +#define IDirectDraw4_Compact(p) (p)->Compact() +#define IDirectDraw4_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) +#define IDirectDraw4_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) +#define IDirectDraw4_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) +#define IDirectDraw4_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) +#define IDirectDraw4_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) +#define IDirectDraw4_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) +#define IDirectDraw4_FlipToGDISurface(p) (p)->FlipToGDISurface() +#define IDirectDraw4_GetCaps(p, a, b) (p)->GetCaps(a, b) +#define IDirectDraw4_GetDisplayMode(p, a) (p)->GetDisplayMode(a) +#define IDirectDraw4_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) +#define IDirectDraw4_GetGDISurface(p, a) (p)->GetGDISurface(a) +#define IDirectDraw4_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) +#define IDirectDraw4_GetScanLine(p, a) (p)->GetScanLine(a) +#define IDirectDraw4_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) +#define IDirectDraw4_Initialize(p, a) (p)->Initialize(a) +#define IDirectDraw4_RestoreDisplayMode(p) (p)->RestoreDisplayMode() +#define IDirectDraw4_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) +#define IDirectDraw4_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) +#define IDirectDraw4_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) +#define IDirectDraw4_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) +#define IDirectDraw4_GetSurfaceFromDC(p, a, b) (p)->GetSurfaceFromDC(a, b) +#define IDirectDraw4_RestoreAllSurfaces(p) (p)->RestoreAllSurfaces() +#define IDirectDraw4_TestCooperativeLevel(p) (p)->TestCooperativeLevel() +#define IDirectDraw4_GetDeviceIdentifier(p,a,b) (p)->GetDeviceIdentifier(a,b) +#endif + +#endif + +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDraw7 +DECLARE_INTERFACE_( IDirectDraw7, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDraw methods ***/ + STDMETHOD(Compact)(THIS) PURE; + STDMETHOD(CreateClipper)(THIS_ DWORD, LPDIRECTDRAWCLIPPER FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreatePalette)(THIS_ DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE FAR*, IUnknown FAR * ) PURE; + STDMETHOD(CreateSurface)(THIS_ LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE7 FAR *, IUnknown FAR *) PURE; + STDMETHOD(DuplicateSurface)( THIS_ LPDIRECTDRAWSURFACE7, LPDIRECTDRAWSURFACE7 FAR * ) PURE; + STDMETHOD(EnumDisplayModes)( THIS_ DWORD, LPDDSURFACEDESC2, LPVOID, LPDDENUMMODESCALLBACK2 ) PURE; + STDMETHOD(EnumSurfaces)(THIS_ DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK7 ) PURE; + STDMETHOD(FlipToGDISurface)(THIS) PURE; + STDMETHOD(GetCaps)( THIS_ LPDDCAPS, LPDDCAPS) PURE; + STDMETHOD(GetDisplayMode)( THIS_ LPDDSURFACEDESC2) PURE; + STDMETHOD(GetFourCCCodes)(THIS_ LPDWORD, LPDWORD ) PURE; + STDMETHOD(GetGDISurface)(THIS_ LPDIRECTDRAWSURFACE7 FAR *) PURE; + STDMETHOD(GetMonitorFrequency)(THIS_ LPDWORD) PURE; + STDMETHOD(GetScanLine)(THIS_ LPDWORD) PURE; + STDMETHOD(GetVerticalBlankStatus)(THIS_ LPBOOL ) PURE; + STDMETHOD(Initialize)(THIS_ GUID FAR *) PURE; + STDMETHOD(RestoreDisplayMode)(THIS) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND, DWORD) PURE; + STDMETHOD(SetDisplayMode)(THIS_ DWORD, DWORD,DWORD, DWORD, DWORD) PURE; + STDMETHOD(WaitForVerticalBlank)(THIS_ DWORD, HANDLE ) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetAvailableVidMem)(THIS_ LPDDSCAPS2, LPDWORD, LPDWORD) PURE; + /*** Added in the V4 Interface ***/ + STDMETHOD(GetSurfaceFromDC) (THIS_ HDC, LPDIRECTDRAWSURFACE7 *) PURE; + STDMETHOD(RestoreAllSurfaces)(THIS) PURE; + STDMETHOD(TestCooperativeLevel)(THIS) PURE; + STDMETHOD(GetDeviceIdentifier)(THIS_ LPDDDEVICEIDENTIFIER2, DWORD ) PURE; + STDMETHOD(StartModeTest)(THIS_ LPSIZE, DWORD, DWORD ) PURE; + STDMETHOD(EvaluateMode)(THIS_ DWORD, DWORD * ) PURE; +}; +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDraw7_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDraw7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDraw7_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDraw7_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectDraw7_CreateClipper(p, a, b, c) (p)->lpVtbl->CreateClipper(p, a, b, c) +#define IDirectDraw7_CreatePalette(p, a, b, c, d) (p)->lpVtbl->CreatePalette(p, a, b, c, d) +#define IDirectDraw7_CreateSurface(p, a, b, c) (p)->lpVtbl->CreateSurface(p, a, b, c) +#define IDirectDraw7_DuplicateSurface(p, a, b) (p)->lpVtbl->DuplicateSurface(p, a, b) +#define IDirectDraw7_EnumDisplayModes(p, a, b, c, d) (p)->lpVtbl->EnumDisplayModes(p, a, b, c, d) +#define IDirectDraw7_EnumSurfaces(p, a, b, c, d) (p)->lpVtbl->EnumSurfaces(p, a, b, c, d) +#define IDirectDraw7_FlipToGDISurface(p) (p)->lpVtbl->FlipToGDISurface(p) +#define IDirectDraw7_GetCaps(p, a, b) (p)->lpVtbl->GetCaps(p, a, b) +#define IDirectDraw7_GetDisplayMode(p, a) (p)->lpVtbl->GetDisplayMode(p, a) +#define IDirectDraw7_GetFourCCCodes(p, a, b) (p)->lpVtbl->GetFourCCCodes(p, a, b) +#define IDirectDraw7_GetGDISurface(p, a) (p)->lpVtbl->GetGDISurface(p, a) +#define IDirectDraw7_GetMonitorFrequency(p, a) (p)->lpVtbl->GetMonitorFrequency(p, a) +#define IDirectDraw7_GetScanLine(p, a) (p)->lpVtbl->GetScanLine(p, a) +#define IDirectDraw7_GetVerticalBlankStatus(p, a) (p)->lpVtbl->GetVerticalBlankStatus(p, a) +#define IDirectDraw7_Initialize(p, a) (p)->lpVtbl->Initialize(p, a) +#define IDirectDraw7_RestoreDisplayMode(p) (p)->lpVtbl->RestoreDisplayMode(p) +#define IDirectDraw7_SetCooperativeLevel(p, a, b) (p)->lpVtbl->SetCooperativeLevel(p, a, b) +#define IDirectDraw7_SetDisplayMode(p, a, b, c, d, e) (p)->lpVtbl->SetDisplayMode(p, a, b, c, d, e) +#define IDirectDraw7_WaitForVerticalBlank(p, a, b) (p)->lpVtbl->WaitForVerticalBlank(p, a, b) +#define IDirectDraw7_GetAvailableVidMem(p, a, b, c) (p)->lpVtbl->GetAvailableVidMem(p, a, b, c) +#define IDirectDraw7_GetSurfaceFromDC(p, a, b) (p)->lpVtbl->GetSurfaceFromDC(p, a, b) +#define IDirectDraw7_RestoreAllSurfaces(p) (p)->lpVtbl->RestoreAllSurfaces(p) +#define IDirectDraw7_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) +#define IDirectDraw7_GetDeviceIdentifier(p,a,b) (p)->lpVtbl->GetDeviceIdentifier(p,a,b) +#define IDirectDraw7_StartModeTest(p,a,b,c) (p)->lpVtbl->StartModeTest(p,a,b,c) +#define IDirectDraw7_EvaluateMode(p,a,b) (p)->lpVtbl->EvaluateMode(p,a,b) +#else +#define IDirectDraw7_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDraw7_AddRef(p) (p)->AddRef() +#define IDirectDraw7_Release(p) (p)->Release() +#define IDirectDraw7_Compact(p) (p)->Compact() +#define IDirectDraw7_CreateClipper(p, a, b, c) (p)->CreateClipper(a, b, c) +#define IDirectDraw7_CreatePalette(p, a, b, c, d) (p)->CreatePalette(a, b, c, d) +#define IDirectDraw7_CreateSurface(p, a, b, c) (p)->CreateSurface(a, b, c) +#define IDirectDraw7_DuplicateSurface(p, a, b) (p)->DuplicateSurface(a, b) +#define IDirectDraw7_EnumDisplayModes(p, a, b, c, d) (p)->EnumDisplayModes(a, b, c, d) +#define IDirectDraw7_EnumSurfaces(p, a, b, c, d) (p)->EnumSurfaces(a, b, c, d) +#define IDirectDraw7_FlipToGDISurface(p) (p)->FlipToGDISurface() +#define IDirectDraw7_GetCaps(p, a, b) (p)->GetCaps(a, b) +#define IDirectDraw7_GetDisplayMode(p, a) (p)->GetDisplayMode(a) +#define IDirectDraw7_GetFourCCCodes(p, a, b) (p)->GetFourCCCodes(a, b) +#define IDirectDraw7_GetGDISurface(p, a) (p)->GetGDISurface(a) +#define IDirectDraw7_GetMonitorFrequency(p, a) (p)->GetMonitorFrequency(a) +#define IDirectDraw7_GetScanLine(p, a) (p)->GetScanLine(a) +#define IDirectDraw7_GetVerticalBlankStatus(p, a) (p)->GetVerticalBlankStatus(a) +#define IDirectDraw7_Initialize(p, a) (p)->Initialize(a) +#define IDirectDraw7_RestoreDisplayMode(p) (p)->RestoreDisplayMode() +#define IDirectDraw7_SetCooperativeLevel(p, a, b) (p)->SetCooperativeLevel(a, b) +#define IDirectDraw7_SetDisplayMode(p, a, b, c, d, e) (p)->SetDisplayMode(a, b, c, d, e) +#define IDirectDraw7_WaitForVerticalBlank(p, a, b) (p)->WaitForVerticalBlank(a, b) +#define IDirectDraw7_GetAvailableVidMem(p, a, b, c) (p)->GetAvailableVidMem(a, b, c) +#define IDirectDraw7_GetSurfaceFromDC(p, a, b) (p)->GetSurfaceFromDC(a, b) +#define IDirectDraw7_RestoreAllSurfaces(p) (p)->RestoreAllSurfaces() +#define IDirectDraw7_TestCooperativeLevel(p) (p)->TestCooperativeLevel() +#define IDirectDraw7_GetDeviceIdentifier(p,a,b) (p)->GetDeviceIdentifier(a,b) +#define IDirectDraw7_StartModeTest(p,a,b,c) (p)->lpVtbl->StartModeTest(a,b,c) +#define IDirectDraw7_EvaluateMode(p,a,b) (p)->lpVtbl->EvaluateMode(a,b) +#endif + +#endif + + +/* + * IDirectDrawPalette + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawPalette +DECLARE_INTERFACE_( IDirectDrawPalette, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawPalette methods ***/ + STDMETHOD(GetCaps)(THIS_ LPDWORD) PURE; + STDMETHOD(GetEntries)(THIS_ DWORD,DWORD,DWORD,LPPALETTEENTRY) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, DWORD, LPPALETTEENTRY) PURE; + STDMETHOD(SetEntries)(THIS_ DWORD,DWORD,DWORD,LPPALETTEENTRY) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawPalette_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDrawPalette_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawPalette_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawPalette_GetCaps(p, a) (p)->lpVtbl->GetCaps(p, a) +#define IDirectDrawPalette_GetEntries(p, a, b, c, d) (p)->lpVtbl->GetEntries(p, a, b, c, d) +#define IDirectDrawPalette_Initialize(p, a, b, c) (p)->lpVtbl->Initialize(p, a, b, c) +#define IDirectDrawPalette_SetEntries(p, a, b, c, d) (p)->lpVtbl->SetEntries(p, a, b, c, d) +#else +#define IDirectDrawPalette_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDrawPalette_AddRef(p) (p)->AddRef() +#define IDirectDrawPalette_Release(p) (p)->Release() +#define IDirectDrawPalette_GetCaps(p, a) (p)->GetCaps(a) +#define IDirectDrawPalette_GetEntries(p, a, b, c, d) (p)->GetEntries(a, b, c, d) +#define IDirectDrawPalette_Initialize(p, a, b, c) (p)->Initialize(a, b, c) +#define IDirectDrawPalette_SetEntries(p, a, b, c, d) (p)->SetEntries(a, b, c, d) +#endif + +#endif + + +/* + * IDirectDrawClipper + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawClipper +DECLARE_INTERFACE_( IDirectDrawClipper, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawClipper methods ***/ + STDMETHOD(GetClipList)(THIS_ LPRECT, LPRGNDATA, LPDWORD) PURE; + STDMETHOD(GetHWnd)(THIS_ HWND FAR *) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, DWORD) PURE; + STDMETHOD(IsClipListChanged)(THIS_ BOOL FAR *) PURE; + STDMETHOD(SetClipList)(THIS_ LPRGNDATA,DWORD) PURE; + STDMETHOD(SetHWnd)(THIS_ DWORD, HWND ) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawClipper_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDrawClipper_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawClipper_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawClipper_GetClipList(p, a, b, c) (p)->lpVtbl->GetClipList(p, a, b, c) +#define IDirectDrawClipper_GetHWnd(p, a) (p)->lpVtbl->GetHWnd(p, a) +#define IDirectDrawClipper_Initialize(p, a, b) (p)->lpVtbl->Initialize(p, a, b) +#define IDirectDrawClipper_IsClipListChanged(p, a) (p)->lpVtbl->IsClipListChanged(p, a) +#define IDirectDrawClipper_SetClipList(p, a, b) (p)->lpVtbl->SetClipList(p, a, b) +#define IDirectDrawClipper_SetHWnd(p, a, b) (p)->lpVtbl->SetHWnd(p, a, b) +#else +#define IDirectDrawClipper_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDrawClipper_AddRef(p) (p)->AddRef() +#define IDirectDrawClipper_Release(p) (p)->Release() +#define IDirectDrawClipper_GetClipList(p, a, b, c) (p)->GetClipList(a, b, c) +#define IDirectDrawClipper_GetHWnd(p, a) (p)->GetHWnd(a) +#define IDirectDrawClipper_Initialize(p, a, b) (p)->Initialize(a, b) +#define IDirectDrawClipper_IsClipListChanged(p, a) (p)->IsClipListChanged(a) +#define IDirectDrawClipper_SetClipList(p, a, b) (p)->SetClipList(a, b) +#define IDirectDrawClipper_SetHWnd(p, a, b) (p)->SetHWnd(a, b) +#endif + +#endif + +/* + * IDirectDrawSurface and related interfaces + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawSurface +DECLARE_INTERFACE_( IDirectDrawSurface, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPVOID) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#else +#define IDirectDrawSurface_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface_Release(p) (p)->Release() +#define IDirectDrawSurface_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface_Restore(p) (p)->Restore() +#define IDirectDrawSurface_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#endif + +/* + * IDirectDrawSurface2 and related interfaces + */ +#undef INTERFACE +#define INTERFACE IDirectDrawSurface2 +DECLARE_INTERFACE_( IDirectDrawSurface2, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE2) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE2, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE2, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE2) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE2, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE2 FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPVOID) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE2,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE2) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; + STDMETHOD(PageLock)(THIS_ DWORD) PURE; + STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface2_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface2_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface2_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface2_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface2_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface2_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface2_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface2_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface2_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface2_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface2_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface2_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface2_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface2_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface2_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface2_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface2_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface2_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface2_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface2_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#define IDirectDrawSurface2_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) +#define IDirectDrawSurface2_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) +#define IDirectDrawSurface2_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) +#else +#define IDirectDrawSurface2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface2_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface2_Release(p) (p)->Release() +#define IDirectDrawSurface2_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface2_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface2_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface2_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface2_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface2_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface2_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface2_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface2_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface2_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface2_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface2_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface2_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface2_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface2_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface2_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface2_Restore(p) (p)->Restore() +#define IDirectDrawSurface2_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface2_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface2_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface2_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#define IDirectDrawSurface2_GetDDInterface(p,a) (p)->GetDDInterface(a) +#define IDirectDrawSurface2_PageLock(p,a) (p)->PageLock(a) +#define IDirectDrawSurface2_PageUnlock(p,a) (p)->PageUnlock(a) +#endif + +/* + * IDirectDrawSurface3 and related interfaces + */ +#undef INTERFACE +#define INTERFACE IDirectDrawSurface3 +DECLARE_INTERFACE_( IDirectDrawSurface3, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE3) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE3, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE3, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE3) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE3, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS, LPDIRECTDRAWSURFACE3 FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPVOID) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE3,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE3) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; + STDMETHOD(PageLock)(THIS_ DWORD) PURE; + STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; + /*** Added in the V3 interface ***/ + STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC, DWORD) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface3_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface3_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface3_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface3_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface3_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface3_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface3_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface3_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface3_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface3_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface3_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface3_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface3_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface3_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface3_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface3_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface3_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface3_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface3_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface3_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface3_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface3_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface3_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface3_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#define IDirectDrawSurface3_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) +#define IDirectDrawSurface3_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) +#define IDirectDrawSurface3_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) +#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) +#else +#define IDirectDrawSurface3_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface3_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface3_Release(p) (p)->Release() +#define IDirectDrawSurface3_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface3_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface3_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface3_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface3_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface3_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface3_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface3_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface3_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface3_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface3_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface3_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface3_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface3_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface3_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface3_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface3_Restore(p) (p)->Restore() +#define IDirectDrawSurface3_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface3_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface3_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface3_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#define IDirectDrawSurface3_GetDDInterface(p,a) (p)->GetDDInterface(a) +#define IDirectDrawSurface3_PageLock(p,a) (p)->PageLock(a) +#define IDirectDrawSurface3_PageUnlock(p,a) (p)->PageUnlock(a) +#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) +#endif + +/* + * IDirectDrawSurface4 and related interfaces + */ +#undef INTERFACE +#define INTERFACE IDirectDrawSurface4 +DECLARE_INTERFACE_( IDirectDrawSurface4, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE4) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE4, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE4, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE4) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK2) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK2) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE4, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2, LPDIRECTDRAWSURFACE4 FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC2) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC2) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC2,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPRECT) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE4,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE4) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; + STDMETHOD(PageLock)(THIS_ DWORD) PURE; + STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; + /*** Added in the v3 interface ***/ + STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC2, DWORD) PURE; + /*** Added in the v4 interface ***/ + STDMETHOD(SetPrivateData)(THIS_ REFGUID, LPVOID, DWORD, DWORD) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID, LPVOID, LPDWORD) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID) PURE; + STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD) PURE; + STDMETHOD(ChangeUniquenessValue)(THIS) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface4_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface4_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface4_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface4_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface4_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface4_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface4_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface4_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface4_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface4_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface4_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface4_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface4_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface4_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface4_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface4_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface4_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface4_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface4_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface4_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface4_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface4_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface4_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface4_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#define IDirectDrawSurface4_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) +#define IDirectDrawSurface4_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) +#define IDirectDrawSurface4_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) +#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) +#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirectDrawSurface4_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirectDrawSurface4_GetUniquenessValue(p, a) (p)->lpVtbl->GetUniquenessValue(p, a) +#define IDirectDrawSurface4_ChangeUniquenessValue(p) (p)->lpVtbl->ChangeUniquenessValue(p) +#else +#define IDirectDrawSurface4_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface4_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface4_Release(p) (p)->Release() +#define IDirectDrawSurface4_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface4_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface4_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface4_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface4_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface4_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface4_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface4_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface4_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface4_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface4_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface4_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface4_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface4_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface4_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface4_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface4_Restore(p) (p)->Restore() +#define IDirectDrawSurface4_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface4_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface4_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface4_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#define IDirectDrawSurface4_GetDDInterface(p,a) (p)->GetDDInterface(a) +#define IDirectDrawSurface4_PageLock(p,a) (p)->PageLock(a) +#define IDirectDrawSurface4_PageUnlock(p,a) (p)->PageUnlock(a) +#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) +#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirectDrawSurface4_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirectDrawSurface4_GetUniquenessValue(p, a) (p)->GetUniquenessValue(a) +#define IDirectDrawSurface4_ChangeUniquenessValue(p) (p)->ChangeUniquenessValue() +#endif + +/* + * IDirectDrawSurface7 and related interfaces + */ +#undef INTERFACE +#define INTERFACE IDirectDrawSurface7 +DECLARE_INTERFACE_( IDirectDrawSurface7, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawSurface methods ***/ + STDMETHOD(AddAttachedSurface)(THIS_ LPDIRECTDRAWSURFACE7) PURE; + STDMETHOD(AddOverlayDirtyRect)(THIS_ LPRECT) PURE; + STDMETHOD(Blt)(THIS_ LPRECT,LPDIRECTDRAWSURFACE7, LPRECT,DWORD, LPDDBLTFX) PURE; + STDMETHOD(BltBatch)(THIS_ LPDDBLTBATCH, DWORD, DWORD ) PURE; + STDMETHOD(BltFast)(THIS_ DWORD,DWORD,LPDIRECTDRAWSURFACE7, LPRECT,DWORD) PURE; + STDMETHOD(DeleteAttachedSurface)(THIS_ DWORD,LPDIRECTDRAWSURFACE7) PURE; + STDMETHOD(EnumAttachedSurfaces)(THIS_ LPVOID,LPDDENUMSURFACESCALLBACK7) PURE; + STDMETHOD(EnumOverlayZOrders)(THIS_ DWORD,LPVOID,LPDDENUMSURFACESCALLBACK7) PURE; + STDMETHOD(Flip)(THIS_ LPDIRECTDRAWSURFACE7, DWORD) PURE; + STDMETHOD(GetAttachedSurface)(THIS_ LPDDSCAPS2, LPDIRECTDRAWSURFACE7 FAR *) PURE; + STDMETHOD(GetBltStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetCaps)(THIS_ LPDDSCAPS2) PURE; + STDMETHOD(GetClipper)(THIS_ LPDIRECTDRAWCLIPPER FAR*) PURE; + STDMETHOD(GetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(GetDC)(THIS_ HDC FAR *) PURE; + STDMETHOD(GetFlipStatus)(THIS_ DWORD) PURE; + STDMETHOD(GetOverlayPosition)(THIS_ LPLONG, LPLONG ) PURE; + STDMETHOD(GetPalette)(THIS_ LPDIRECTDRAWPALETTE FAR*) PURE; + STDMETHOD(GetPixelFormat)(THIS_ LPDDPIXELFORMAT) PURE; + STDMETHOD(GetSurfaceDesc)(THIS_ LPDDSURFACEDESC2) PURE; + STDMETHOD(Initialize)(THIS_ LPDIRECTDRAW, LPDDSURFACEDESC2) PURE; + STDMETHOD(IsLost)(THIS) PURE; + STDMETHOD(Lock)(THIS_ LPRECT,LPDDSURFACEDESC2,DWORD,HANDLE) PURE; + STDMETHOD(ReleaseDC)(THIS_ HDC) PURE; + STDMETHOD(Restore)(THIS) PURE; + STDMETHOD(SetClipper)(THIS_ LPDIRECTDRAWCLIPPER) PURE; + STDMETHOD(SetColorKey)(THIS_ DWORD, LPDDCOLORKEY) PURE; + STDMETHOD(SetOverlayPosition)(THIS_ LONG, LONG ) PURE; + STDMETHOD(SetPalette)(THIS_ LPDIRECTDRAWPALETTE) PURE; + STDMETHOD(Unlock)(THIS_ LPRECT) PURE; + STDMETHOD(UpdateOverlay)(THIS_ LPRECT, LPDIRECTDRAWSURFACE7,LPRECT,DWORD, LPDDOVERLAYFX) PURE; + STDMETHOD(UpdateOverlayDisplay)(THIS_ DWORD) PURE; + STDMETHOD(UpdateOverlayZOrder)(THIS_ DWORD, LPDIRECTDRAWSURFACE7) PURE; + /*** Added in the v2 interface ***/ + STDMETHOD(GetDDInterface)(THIS_ LPVOID FAR *) PURE; + STDMETHOD(PageLock)(THIS_ DWORD) PURE; + STDMETHOD(PageUnlock)(THIS_ DWORD) PURE; + /*** Added in the v3 interface ***/ + STDMETHOD(SetSurfaceDesc)(THIS_ LPDDSURFACEDESC2, DWORD) PURE; + /*** Added in the v4 interface ***/ + STDMETHOD(SetPrivateData)(THIS_ REFGUID, LPVOID, DWORD, DWORD) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID, LPVOID, LPDWORD) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID) PURE; + STDMETHOD(GetUniquenessValue)(THIS_ LPDWORD) PURE; + STDMETHOD(ChangeUniquenessValue)(THIS) PURE; + /*** Moved Texture7 methods here ***/ + STDMETHOD(SetPriority)(THIS_ DWORD) PURE; + STDMETHOD(GetPriority)(THIS_ LPDWORD) PURE; + STDMETHOD(SetLOD)(THIS_ DWORD) PURE; + STDMETHOD(GetLOD)(THIS_ LPDWORD) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawSurface7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectDrawSurface7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawSurface7_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawSurface7_AddAttachedSurface(p,a) (p)->lpVtbl->AddAttachedSurface(p,a) +#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) (p)->lpVtbl->AddOverlayDirtyRect(p,a) +#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) (p)->lpVtbl->Blt(p,a,b,c,d,e) +#define IDirectDrawSurface7_BltBatch(p,a,b,c) (p)->lpVtbl->BltBatch(p,a,b,c) +#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) (p)->lpVtbl->BltFast(p,a,b,c,d,e) +#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) (p)->lpVtbl->DeleteAttachedSurface(p,a,b) +#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) (p)->lpVtbl->EnumAttachedSurfaces(p,a,b) +#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) (p)->lpVtbl->EnumOverlayZOrders(p,a,b,c) +#define IDirectDrawSurface7_Flip(p,a,b) (p)->lpVtbl->Flip(p,a,b) +#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) (p)->lpVtbl->GetAttachedSurface(p,a,b) +#define IDirectDrawSurface7_GetBltStatus(p,a) (p)->lpVtbl->GetBltStatus(p,a) +#define IDirectDrawSurface7_GetCaps(p,b) (p)->lpVtbl->GetCaps(p,b) +#define IDirectDrawSurface7_GetClipper(p,a) (p)->lpVtbl->GetClipper(p,a) +#define IDirectDrawSurface7_GetColorKey(p,a,b) (p)->lpVtbl->GetColorKey(p,a,b) +#define IDirectDrawSurface7_GetDC(p,a) (p)->lpVtbl->GetDC(p,a) +#define IDirectDrawSurface7_GetFlipStatus(p,a) (p)->lpVtbl->GetFlipStatus(p,a) +#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) (p)->lpVtbl->GetOverlayPosition(p,a,b) +#define IDirectDrawSurface7_GetPalette(p,a) (p)->lpVtbl->GetPalette(p,a) +#define IDirectDrawSurface7_GetPixelFormat(p,a) (p)->lpVtbl->GetPixelFormat(p,a) +#define IDirectDrawSurface7_GetSurfaceDesc(p,a) (p)->lpVtbl->GetSurfaceDesc(p,a) +#define IDirectDrawSurface7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectDrawSurface7_IsLost(p) (p)->lpVtbl->IsLost(p) +#define IDirectDrawSurface7_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirectDrawSurface7_ReleaseDC(p,a) (p)->lpVtbl->ReleaseDC(p,a) +#define IDirectDrawSurface7_Restore(p) (p)->lpVtbl->Restore(p) +#define IDirectDrawSurface7_SetClipper(p,a) (p)->lpVtbl->SetClipper(p,a) +#define IDirectDrawSurface7_SetColorKey(p,a,b) (p)->lpVtbl->SetColorKey(p,a,b) +#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) (p)->lpVtbl->SetOverlayPosition(p,a,b) +#define IDirectDrawSurface7_SetPalette(p,a) (p)->lpVtbl->SetPalette(p,a) +#define IDirectDrawSurface7_Unlock(p,b) (p)->lpVtbl->Unlock(p,b) +#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) (p)->lpVtbl->UpdateOverlay(p,a,b,c,d,e) +#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) (p)->lpVtbl->UpdateOverlayDisplay(p,a) +#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) (p)->lpVtbl->UpdateOverlayZOrder(p,a,b) +#define IDirectDrawSurface7_GetDDInterface(p,a) (p)->lpVtbl->GetDDInterface(p,a) +#define IDirectDrawSurface7_PageLock(p,a) (p)->lpVtbl->PageLock(p,a) +#define IDirectDrawSurface7_PageUnlock(p,a) (p)->lpVtbl->PageUnlock(p,a) +#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) (p)->lpVtbl->SetSurfaceDesc(p,a,b) +#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirectDrawSurface7_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirectDrawSurface7_GetUniquenessValue(p, a) (p)->lpVtbl->GetUniquenessValue(p, a) +#define IDirectDrawSurface7_ChangeUniquenessValue(p) (p)->lpVtbl->ChangeUniquenessValue(p) +#define IDirectDrawSurface7_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirectDrawSurface7_GetPriority(p,a) (p)->lpVtbl->GetPriority(p,a) +#define IDirectDrawSurface7_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirectDrawSurface7_GetLOD(p,a) (p)->lpVtbl->GetLOD(p,a) +#else +#define IDirectDrawSurface7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectDrawSurface7_AddRef(p) (p)->AddRef() +#define IDirectDrawSurface7_Release(p) (p)->Release() +#define IDirectDrawSurface7_AddAttachedSurface(p,a) (p)->AddAttachedSurface(a) +#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) (p)->AddOverlayDirtyRect(a) +#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) (p)->Blt(a,b,c,d,e) +#define IDirectDrawSurface7_BltBatch(p,a,b,c) (p)->BltBatch(a,b,c) +#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) (p)->BltFast(a,b,c,d,e) +#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) (p)->DeleteAttachedSurface(a,b) +#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) (p)->EnumAttachedSurfaces(a,b) +#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) (p)->EnumOverlayZOrders(a,b,c) +#define IDirectDrawSurface7_Flip(p,a,b) (p)->Flip(a,b) +#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) (p)->GetAttachedSurface(a,b) +#define IDirectDrawSurface7_GetBltStatus(p,a) (p)->GetBltStatus(a) +#define IDirectDrawSurface7_GetCaps(p,b) (p)->GetCaps(b) +#define IDirectDrawSurface7_GetClipper(p,a) (p)->GetClipper(a) +#define IDirectDrawSurface7_GetColorKey(p,a,b) (p)->GetColorKey(a,b) +#define IDirectDrawSurface7_GetDC(p,a) (p)->GetDC(a) +#define IDirectDrawSurface7_GetFlipStatus(p,a) (p)->GetFlipStatus(a) +#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) (p)->GetOverlayPosition(a,b) +#define IDirectDrawSurface7_GetPalette(p,a) (p)->GetPalette(a) +#define IDirectDrawSurface7_GetPixelFormat(p,a) (p)->GetPixelFormat(a) +#define IDirectDrawSurface7_GetSurfaceDesc(p,a) (p)->GetSurfaceDesc(a) +#define IDirectDrawSurface7_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectDrawSurface7_IsLost(p) (p)->IsLost() +#define IDirectDrawSurface7_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirectDrawSurface7_ReleaseDC(p,a) (p)->ReleaseDC(a) +#define IDirectDrawSurface7_Restore(p) (p)->Restore() +#define IDirectDrawSurface7_SetClipper(p,a) (p)->SetClipper(a) +#define IDirectDrawSurface7_SetColorKey(p,a,b) (p)->SetColorKey(a,b) +#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) (p)->SetOverlayPosition(a,b) +#define IDirectDrawSurface7_SetPalette(p,a) (p)->SetPalette(a) +#define IDirectDrawSurface7_Unlock(p,b) (p)->Unlock(b) +#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) (p)->UpdateOverlay(a,b,c,d,e) +#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) (p)->UpdateOverlayDisplay(a) +#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) (p)->UpdateOverlayZOrder(a,b) +#define IDirectDrawSurface7_GetDDInterface(p,a) (p)->GetDDInterface(a) +#define IDirectDrawSurface7_PageLock(p,a) (p)->PageLock(a) +#define IDirectDrawSurface7_PageUnlock(p,a) (p)->PageUnlock(a) +#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) (p)->SetSurfaceDesc(a,b) +#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirectDrawSurface7_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirectDrawSurface7_GetUniquenessValue(p, a) (p)->GetUniquenessValue(a) +#define IDirectDrawSurface7_ChangeUniquenessValue(p) (p)->ChangeUniquenessValue() +#define IDirectDrawSurface7_SetPriority(p,a) (p)->SetPriority(a) +#define IDirectDrawSurface7_GetPriority(p,a) (p)->GetPriority(a) +#define IDirectDrawSurface7_SetLOD(p,a) (p)->SetLOD(a) +#define IDirectDrawSurface7_GetLOD(p,a) (p)->GetLOD(a) +#endif + + +/* + * IDirectDrawColorControl + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawColorControl +DECLARE_INTERFACE_( IDirectDrawColorControl, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawColorControl methods ***/ + STDMETHOD(GetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; + STDMETHOD(SetColorControls)(THIS_ LPDDCOLORCONTROL) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawColorControl_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDrawColorControl_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawColorControl_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawColorControl_GetColorControls(p, a) (p)->lpVtbl->GetColorControls(p, a) +#define IDirectDrawColorControl_SetColorControls(p, a) (p)->lpVtbl->SetColorControls(p, a) +#else +#define IDirectDrawColorControl_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDrawColorControl_AddRef(p) (p)->AddRef() +#define IDirectDrawColorControl_Release(p) (p)->Release() +#define IDirectDrawColorControl_GetColorControls(p, a) (p)->GetColorControls(a) +#define IDirectDrawColorControl_SetColorControls(p, a) (p)->SetColorControls(a) +#endif + +#endif + + +/* + * IDirectDrawGammaControl + */ +#if defined( _WIN32 ) && !defined( _NO_COM ) +#undef INTERFACE +#define INTERFACE IDirectDrawGammaControl +DECLARE_INTERFACE_( IDirectDrawGammaControl, IUnknown ) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + /*** IDirectDrawGammaControl methods ***/ + STDMETHOD(GetGammaRamp)(THIS_ DWORD, LPDDGAMMARAMP) PURE; + STDMETHOD(SetGammaRamp)(THIS_ DWORD, LPDDGAMMARAMP) PURE; +}; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectDrawGammaControl_QueryInterface(p, a, b) (p)->lpVtbl->QueryInterface(p, a, b) +#define IDirectDrawGammaControl_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectDrawGammaControl_Release(p) (p)->lpVtbl->Release(p) +#define IDirectDrawGammaControl_GetGammaRamp(p, a, b) (p)->lpVtbl->GetGammaRamp(p, a, b) +#define IDirectDrawGammaControl_SetGammaRamp(p, a, b) (p)->lpVtbl->SetGammaRamp(p, a, b) +#else +#define IDirectDrawGammaControl_QueryInterface(p, a, b) (p)->QueryInterface(a, b) +#define IDirectDrawGammaControl_AddRef(p) (p)->AddRef() +#define IDirectDrawGammaControl_Release(p) (p)->Release() +#define IDirectDrawGammaControl_GetGammaRamp(p, a, b) (p)->GetGammaRamp(a, b) +#define IDirectDrawGammaControl_SetGammaRamp(p, a, b) (p)->SetGammaRamp(a, b) +#endif + +#endif + + + +#endif + + +/* + * DDSURFACEDESC + */ +typedef struct _DDSURFACEDESC +{ + DWORD dwSize; // size of the DDSURFACEDESC structure + DWORD dwFlags; // determines what fields are valid + DWORD dwHeight; // height of surface to be created + DWORD dwWidth; // width of input surface + union + { + LONG lPitch; // distance to start of next line (return value only) + DWORD dwLinearSize; // Formless late-allocated optimized surface size + } DUMMYUNIONNAMEN(1); + DWORD dwBackBufferCount; // number of back buffers requested + union + { + DWORD dwMipMapCount; // number of mip-map levels requested + DWORD dwZBufferBitDepth; // depth of Z buffer requested + DWORD dwRefreshRate; // refresh rate (used when display mode is described) + } DUMMYUNIONNAMEN(2); + DWORD dwAlphaBitDepth; // depth of alpha buffer requested + DWORD dwReserved; // reserved + LPVOID lpSurface; // pointer to the associated surface memory + DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use + DDCOLORKEY ddckCKDestBlt; // color key for destination blt use + DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use + DDCOLORKEY ddckCKSrcBlt; // color key for source blt use + DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface + DDSCAPS ddsCaps; // direct draw surface capabilities +} DDSURFACEDESC; + +/* + * DDSURFACEDESC2 + */ +typedef struct _DDSURFACEDESC2 +{ + DWORD dwSize; // size of the DDSURFACEDESC structure + DWORD dwFlags; // determines what fields are valid + DWORD dwHeight; // height of surface to be created + DWORD dwWidth; // width of input surface + union + { + LONG lPitch; // distance to start of next line (return value only) + DWORD dwLinearSize; // Formless late-allocated optimized surface size + } DUMMYUNIONNAMEN(1); + union + { + DWORD dwBackBufferCount; // number of back buffers requested + DWORD dwDepth; // the depth if this is a volume texture + } DUMMYUNIONNAMEN(5); + union + { + DWORD dwMipMapCount; // number of mip-map levels requestde + // dwZBufferBitDepth removed, use ddpfPixelFormat one instead + DWORD dwRefreshRate; // refresh rate (used when display mode is described) + DWORD dwSrcVBHandle; // The source used in VB::Optimize + } DUMMYUNIONNAMEN(2); + DWORD dwAlphaBitDepth; // depth of alpha buffer requested + DWORD dwReserved; // reserved + LPVOID lpSurface; // pointer to the associated surface memory + union + { + DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use + DWORD dwEmptyFaceColor; // Physical color for empty cubemap faces + } DUMMYUNIONNAMEN(3); + DDCOLORKEY ddckCKDestBlt; // color key for destination blt use + DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use + DDCOLORKEY ddckCKSrcBlt; // color key for source blt use + union + { + DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface + DWORD dwFVF; // vertex format description of vertex buffers + } DUMMYUNIONNAMEN(4); + DDSCAPS2 ddsCaps; // direct draw surface capabilities + DWORD dwTextureStage; // stage in multitexture cascade +} DDSURFACEDESC2; + +/* + * ddsCaps field is valid. + */ +#define DDSD_CAPS 0x00000001l // default + +/* + * dwHeight field is valid. + */ +#define DDSD_HEIGHT 0x00000002l + +/* + * dwWidth field is valid. + */ +#define DDSD_WIDTH 0x00000004l + +/* + * lPitch is valid. + */ +#define DDSD_PITCH 0x00000008l + +/* + * dwBackBufferCount is valid. + */ +#define DDSD_BACKBUFFERCOUNT 0x00000020l + +/* + * dwZBufferBitDepth is valid. (shouldnt be used in DDSURFACEDESC2) + */ +#define DDSD_ZBUFFERBITDEPTH 0x00000040l + +/* + * dwAlphaBitDepth is valid. + */ +#define DDSD_ALPHABITDEPTH 0x00000080l + + +/* + * lpSurface is valid. + */ +#define DDSD_LPSURFACE 0x00000800l + +/* + * ddpfPixelFormat is valid. + */ +#define DDSD_PIXELFORMAT 0x00001000l + +/* + * ddckCKDestOverlay is valid. + */ +#define DDSD_CKDESTOVERLAY 0x00002000l + +/* + * ddckCKDestBlt is valid. + */ +#define DDSD_CKDESTBLT 0x00004000l + +/* + * ddckCKSrcOverlay is valid. + */ +#define DDSD_CKSRCOVERLAY 0x00008000l + +/* + * ddckCKSrcBlt is valid. + */ +#define DDSD_CKSRCBLT 0x00010000l + +/* + * dwMipMapCount is valid. + */ +#define DDSD_MIPMAPCOUNT 0x00020000l + + /* + * dwRefreshRate is valid + */ +#define DDSD_REFRESHRATE 0x00040000l + +/* + * dwLinearSize is valid + */ +#define DDSD_LINEARSIZE 0x00080000l + +/* + * dwTextureStage is valid + */ +#define DDSD_TEXTURESTAGE 0x00100000l +/* + * dwFVF is valid + */ +#define DDSD_FVF 0x00200000l +/* + * dwSrcVBHandle is valid + */ +#define DDSD_SRCVBHANDLE 0x00400000l + +/* + * dwDepth is valid + */ +#define DDSD_DEPTH 0x00800000l + +/* + * All input fields are valid. + */ +#define DDSD_ALL 0x00fff9eel + +/* + * DDOPTSURFACEDESC + */ +typedef struct _DDOPTSURFACEDESC +{ + DWORD dwSize; // size of the DDOPTSURFACEDESC structure + DWORD dwFlags; // determines what fields are valid + DDSCAPS2 ddSCaps; // Common caps like: Memory type + DDOSCAPS ddOSCaps; // Common caps like: Memory type + GUID guid; // Compression technique GUID + DWORD dwCompressionRatio; // Compression ratio +} DDOPTSURFACEDESC; + +/* + * guid field is valid. + */ +#define DDOSD_GUID 0x00000001l + +/* + * dwCompressionRatio field is valid. + */ +#define DDOSD_COMPRESSION_RATIO 0x00000002l + +/* + * ddSCaps field is valid. + */ +#define DDOSD_SCAPS 0x00000004l + +/* + * ddOSCaps field is valid. + */ +#define DDOSD_OSCAPS 0x00000008l + +/* + * All input fields are valid. + */ +#define DDOSD_ALL 0x0000000fl + +/* + * The surface's optimized pixelformat is compressed + */ +#define DDOSDCAPS_OPTCOMPRESSED 0x00000001l + +/* + * The surface's optimized pixelformat is reordered + */ +#define DDOSDCAPS_OPTREORDERED 0x00000002l + +/* + * The opt surface is a monolithic mipmap + */ +#define DDOSDCAPS_MONOLITHICMIPMAP 0x00000004l + +/* + * The valid Surf caps: + * #define DDSCAPS_SYSTEMMEMORY 0x00000800l + * #define DDSCAPS_VIDEOMEMORY 0x00004000l + * #define DDSCAPS_LOCALVIDMEM 0x10000000l + * #define DDSCAPS_NONLOCALVIDMEM 0x20000000l + */ +#define DDOSDCAPS_VALIDSCAPS 0x30004800l + +/* + * The valid OptSurf caps + */ +#define DDOSDCAPS_VALIDOSCAPS 0x00000007l + + +/* + * DDCOLORCONTROL + */ +typedef struct _DDCOLORCONTROL +{ + DWORD dwSize; + DWORD dwFlags; + LONG lBrightness; + LONG lContrast; + LONG lHue; + LONG lSaturation; + LONG lSharpness; + LONG lGamma; + LONG lColorEnable; + DWORD dwReserved1; +} DDCOLORCONTROL; + + +/* + * lBrightness field is valid. + */ +#define DDCOLOR_BRIGHTNESS 0x00000001l + +/* + * lContrast field is valid. + */ +#define DDCOLOR_CONTRAST 0x00000002l + +/* + * lHue field is valid. + */ +#define DDCOLOR_HUE 0x00000004l + +/* + * lSaturation field is valid. + */ +#define DDCOLOR_SATURATION 0x00000008l + +/* + * lSharpness field is valid. + */ +#define DDCOLOR_SHARPNESS 0x00000010l + +/* + * lGamma field is valid. + */ +#define DDCOLOR_GAMMA 0x00000020l + +/* + * lColorEnable field is valid. + */ +#define DDCOLOR_COLORENABLE 0x00000040l + + + +/*============================================================================ + * + * Direct Draw Capability Flags + * + * These flags are used to describe the capabilities of a given Surface. + * All flags are bit flags. + * + *==========================================================================*/ + +/**************************************************************************** + * + * DIRECTDRAWSURFACE CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * This bit is reserved. It should not be specified. + */ +#define DDSCAPS_RESERVED1 0x00000001l + +/* + * Indicates that this surface contains alpha-only information. + * (To determine if a surface is RGBA/YUVA, the pixel format must be + * interrogated.) + */ +#define DDSCAPS_ALPHA 0x00000002l + +/* + * Indicates that this surface is a backbuffer. It is generally + * set by CreateSurface when the DDSCAPS_FLIP capability bit is set. + * It indicates that this surface is THE back buffer of a surface + * flipping structure. DirectDraw supports N surfaces in a + * surface flipping structure. Only the surface that immediately + * precedeces the DDSCAPS_FRONTBUFFER has this capability bit set. + * The other surfaces are identified as back buffers by the presence + * of the DDSCAPS_FLIP capability, their attachment order, and the + * absence of the DDSCAPS_FRONTBUFFER and DDSCAPS_BACKBUFFER + * capabilities. The bit is sent to CreateSurface when a standalone + * back buffer is being created. This surface could be attached to + * a front buffer and/or back buffers to form a flipping surface + * structure after the CreateSurface call. See AddAttachments for + * a detailed description of the behaviors in this case. + */ +#define DDSCAPS_BACKBUFFER 0x00000004l + +/* + * Indicates a complex surface structure is being described. A + * complex surface structure results in the creation of more than + * one surface. The additional surfaces are attached to the root + * surface. The complex structure can only be destroyed by + * destroying the root. + */ +#define DDSCAPS_COMPLEX 0x00000008l + +/* + * Indicates that this surface is a part of a surface flipping structure. + * When it is passed to CreateSurface the DDSCAPS_FRONTBUFFER and + * DDSCAP_BACKBUFFER bits are not set. They are set by CreateSurface + * on the resulting creations. The dwBackBufferCount field in the + * DDSURFACEDESC structure must be set to at least 1 in order for + * the CreateSurface call to succeed. The DDSCAPS_COMPLEX capability + * must always be set with creating multiple surfaces through CreateSurface. + */ +#define DDSCAPS_FLIP 0x00000010l + +/* + * Indicates that this surface is THE front buffer of a surface flipping + * structure. It is generally set by CreateSurface when the DDSCAPS_FLIP + * capability bit is set. + * If this capability is sent to CreateSurface then a standalonw front buffer + * is created. This surface will not have the DDSCAPS_FLIP capability. + * It can be attached to other back buffers to form a flipping structure. + * See AddAttachments for a detailed description of the behaviors in this + * case. + */ +#define DDSCAPS_FRONTBUFFER 0x00000020l + +/* + * Indicates that this surface is any offscreen surface that is not an overlay, + * texture, zbuffer, front buffer, back buffer, or alpha surface. It is used + * to identify plain vanilla surfaces. + */ +#define DDSCAPS_OFFSCREENPLAIN 0x00000040l + +/* + * Indicates that this surface is an overlay. It may or may not be directly visible + * depending on whether or not it is currently being overlayed onto the primary + * surface. DDSCAPS_VISIBLE can be used to determine whether or not it is being + * overlayed at the moment. + */ +#define DDSCAPS_OVERLAY 0x00000080l + +/* + * Indicates that unique DirectDrawPalette objects can be created and + * attached to this surface. + */ +#define DDSCAPS_PALETTE 0x00000100l + +/* + * Indicates that this surface is the primary surface. The primary + * surface represents what the user is seeing at the moment. + */ +#define DDSCAPS_PRIMARYSURFACE 0x00000200l + + +/* + * This flag used to be DDSCAPS_PRIMARYSURFACELEFT, which is now + * obsolete. + */ +#define DDSCAPS_RESERVED3 0x00000400l +#define DDSCAPS_PRIMARYSURFACELEFT 0x00000000l + +/* + * Indicates that this surface memory was allocated in system memory + */ +#define DDSCAPS_SYSTEMMEMORY 0x00000800l + +/* + * Indicates that this surface can be used as a 3D texture. It does not + * indicate whether or not the surface is being used for that purpose. + */ +#define DDSCAPS_TEXTURE 0x00001000l + +/* + * Indicates that a surface may be a destination for 3D rendering. This + * bit must be set in order to query for a Direct3D Device Interface + * from this surface. + */ +#define DDSCAPS_3DDEVICE 0x00002000l + +/* + * Indicates that this surface exists in video memory. + */ +#define DDSCAPS_VIDEOMEMORY 0x00004000l + +/* + * Indicates that changes made to this surface are immediately visible. + * It is always set for the primary surface and is set for overlays while + * they are being overlayed and texture maps while they are being textured. + */ +#define DDSCAPS_VISIBLE 0x00008000l + +/* + * Indicates that only writes are permitted to the surface. Read accesses + * from the surface may or may not generate a protection fault, but the + * results of a read from this surface will not be meaningful. READ ONLY. + */ +#define DDSCAPS_WRITEONLY 0x00010000l + +/* + * Indicates that this surface is a z buffer. A z buffer does not contain + * displayable information. Instead it contains bit depth information that is + * used to determine which pixels are visible and which are obscured. + */ +#define DDSCAPS_ZBUFFER 0x00020000l + +/* + * Indicates surface will have a DC associated long term + */ +#define DDSCAPS_OWNDC 0x00040000l + +/* + * Indicates surface should be able to receive live video + */ +#define DDSCAPS_LIVEVIDEO 0x00080000l + +/* + * Indicates surface should be able to have a stream decompressed + * to it by the hardware. + */ +#define DDSCAPS_HWCODEC 0x00100000l + +/* + * Surface is a ModeX surface. + * + */ +#define DDSCAPS_MODEX 0x00200000l + +/* + * Indicates surface is one level of a mip-map. This surface will + * be attached to other DDSCAPS_MIPMAP surfaces to form the mip-map. + * This can be done explicitly, by creating a number of surfaces and + * attaching them with AddAttachedSurface or by implicitly by CreateSurface. + * If this bit is set then DDSCAPS_TEXTURE must also be set. + */ +#define DDSCAPS_MIPMAP 0x00400000l + +/* + * This bit is reserved. It should not be specified. + */ +#define DDSCAPS_RESERVED2 0x00800000l + + +/* + * Indicates that memory for the surface is not allocated until the surface + * is loaded (via the Direct3D texture Load() function). + */ +#define DDSCAPS_ALLOCONLOAD 0x04000000l + +/* + * Indicates that the surface will recieve data from a video port. + */ +#define DDSCAPS_VIDEOPORT 0x08000000l + +/* + * Indicates that a video memory surface is resident in true, local video + * memory rather than non-local video memory. If this flag is specified then + * so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with + * DDSCAPS_NONLOCALVIDMEM. + */ +#define DDSCAPS_LOCALVIDMEM 0x10000000l + +/* + * Indicates that a video memory surface is resident in non-local video + * memory rather than true, local video memory. If this flag is specified + * then so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with + * DDSCAPS_LOCALVIDMEM. + */ +#define DDSCAPS_NONLOCALVIDMEM 0x20000000l + +/* + * Indicates that this surface is a standard VGA mode surface, and not a + * ModeX surface. (This flag will never be set in combination with the + * DDSCAPS_MODEX flag). + */ +#define DDSCAPS_STANDARDVGAMODE 0x40000000l + +/* + * Indicates that this surface will be an optimized surface. This flag is + * currently only valid in conjunction with the DDSCAPS_TEXTURE flag. The surface + * will be created without any underlying video memory until loaded. + */ +#define DDSCAPS_OPTIMIZED 0x80000000l + + + +/* + * This bit is reserved + */ +#define DDSCAPS2_RESERVED4 0x00000002L +#define DDSCAPS2_HARDWAREDEINTERLACE 0x00000000L + +/* + * Indicates to the driver that this surface will be locked very frequently + * (for procedural textures, dynamic lightmaps, etc). Surfaces with this cap + * set must also have DDSCAPS_TEXTURE. This cap cannot be used with + * DDSCAPS2_HINTSTATIC and DDSCAPS2_OPAQUE. + */ +#define DDSCAPS2_HINTDYNAMIC 0x00000004L + +/* + * Indicates to the driver that this surface can be re-ordered/retiled on + * load. This operation will not change the size of the texture. It is + * relatively fast and symmetrical, since the application may lock these + * bits (although it will take a performance hit when doing so). Surfaces + * with this cap set must also have DDSCAPS_TEXTURE. This cap cannot be + * used with DDSCAPS2_HINTDYNAMIC and DDSCAPS2_OPAQUE. + */ +#define DDSCAPS2_HINTSTATIC 0x00000008L + +/* + * Indicates that the client would like this texture surface to be managed by the + * DirectDraw/Direct3D runtime. Surfaces with this cap set must also have + * DDSCAPS_TEXTURE set. + */ +#define DDSCAPS2_TEXTUREMANAGE 0x00000010L + +/* + * These bits are reserved for internal use */ +#define DDSCAPS2_RESERVED1 0x00000020L +#define DDSCAPS2_RESERVED2 0x00000040L + +/* + * Indicates to the driver that this surface will never be locked again. + * The driver is free to optimize this surface via retiling and actual compression. + * All calls to Lock() or Blts from this surface will fail. Surfaces with this + * cap set must also have DDSCAPS_TEXTURE. This cap cannot be used with + * DDSCAPS2_HINTDYNAMIC and DDSCAPS2_HINTSTATIC. + */ +#define DDSCAPS2_OPAQUE 0x00000080L + +/* + * Applications should set this bit at CreateSurface time to indicate that they + * intend to use antialiasing. Only valid if DDSCAPS_3DDEVICE is also set. + */ +#define DDSCAPS2_HINTANTIALIASING 0x00000100L + + +/* + * This flag is used at CreateSurface time to indicate that this set of + * surfaces is a cubic environment map + */ +#define DDSCAPS2_CUBEMAP 0x00000200L + +/* + * These flags preform two functions: + * - At CreateSurface time, they define which of the six cube faces are + * required by the application. + * - After creation, each face in the cubemap will have exactly one of these + * bits set. + */ +#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400L +#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800L +#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000L +#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000L +#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000L +#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000L + +/* + * This macro may be used to specify all faces of a cube map at CreateSurface time + */ +#define DDSCAPS2_CUBEMAP_ALLFACES ( DDSCAPS2_CUBEMAP_POSITIVEX |\ + DDSCAPS2_CUBEMAP_NEGATIVEX |\ + DDSCAPS2_CUBEMAP_POSITIVEY |\ + DDSCAPS2_CUBEMAP_NEGATIVEY |\ + DDSCAPS2_CUBEMAP_POSITIVEZ |\ + DDSCAPS2_CUBEMAP_NEGATIVEZ ) + + +/* + * This flag is an additional flag which is present on mipmap sublevels from DX7 onwards + * It enables easier use of GetAttachedSurface rather than EnumAttachedSurfaces for surface + * constructs such as Cube Maps, wherein there are more than one mipmap surface attached + * to the root surface. + * This caps bit is ignored by CreateSurface + */ +#define DDSCAPS2_MIPMAPSUBLEVEL 0x00010000L + +/* This flag indicates that the texture should be managed by D3D only */ +#define DDSCAPS2_D3DTEXTUREMANAGE 0x00020000L + +/* This flag indicates that the managed surface can be safely lost */ +#define DDSCAPS2_DONOTPERSIST 0x00040000L + +/* indicates that this surface is part of a stereo flipping chain */ +#define DDSCAPS2_STEREOSURFACELEFT 0x00080000L + + +/* + * Indicates that the surface is a volume. + * Can be combined with DDSCAPS_MIPMAP to indicate a multi-level volume + */ +#define DDSCAPS2_VOLUME 0x00200000L + +/* + * Indicates that the surface may be locked multiple times by the application. + * This cap cannot be used with DDSCAPS2_OPAQUE. + */ +#define DDSCAPS2_NOTUSERLOCKABLE 0x00400000L + +/* + * Indicates that the vertex buffer data can be used to render points and + * point sprites. + */ +#define DDSCAPS2_POINTS 0x00800000L + +/* + * Indicates that the vertex buffer data can be used to render rt pactches. + */ +#define DDSCAPS2_RTPATCHES 0x01000000L + +/* + * Indicates that the vertex buffer data can be used to render n patches. + */ +#define DDSCAPS2_NPATCHES 0x02000000L + +/* + * This bit is reserved for internal use + */ +#define DDSCAPS2_RESERVED3 0x04000000L + + +/* + * Indicates that the contents of the backbuffer do not have to be preserved + * the contents of the backbuffer after they are presented. + */ +#define DDSCAPS2_DISCARDBACKBUFFER 0x10000000L + +/* + * Indicates that all surfaces in this creation chain should be given an alpha channel. + * This flag will be set on primary surface chains that may have no explicit pixel format + * (and thus take on the format of the current display mode). + * The driver should infer that all these surfaces have a format having an alpha channel. + * (e.g. assume D3DFMT_A8R8G8B8 if the display mode is x888.) + */ +#define DDSCAPS2_ENABLEALPHACHANNEL 0x20000000L + +/* + * Indicates that all surfaces in this creation chain is extended primary surface format. + * This flag will be set on extended primary surface chains that always have explicit pixel + * format and the pixel format is typically GDI (Graphics Device Interface) couldn't handle, + * thus only used with fullscreen application. (e.g. D3DFMT_A2R10G10B10 format) + */ +#define DDSCAPS2_EXTENDEDFORMATPRIMARY 0x40000000L + +/* + * Indicates that all surfaces in this creation chain is additional primary surface. + * This flag will be set on primary surface chains which must present on the adapter + * id provided on dwCaps4. Typically this will be used to create secondary primary surface + * on DualView display adapter. + */ +#define DDSCAPS2_ADDITIONALPRIMARY 0x80000000L + +/* + * This is a mask that indicates the set of bits that may be set + * at createsurface time to indicate number of samples per pixel + * when multisampling + */ +#define DDSCAPS3_MULTISAMPLE_MASK 0x0000001FL + +/* + * This is a mask that indicates the set of bits that may be set + * at createsurface time to indicate the quality level of rendering + * for the current number of samples per pixel + */ +#define DDSCAPS3_MULTISAMPLE_QUALITY_MASK 0x000000E0L +#define DDSCAPS3_MULTISAMPLE_QUALITY_SHIFT 5 + +/* + * This bit is reserved for internal use + */ +#define DDSCAPS3_RESERVED1 0x00000100L + +/* + * This bit is reserved for internal use + */ +#define DDSCAPS3_RESERVED2 0x00000200L + +/* + * This indicates whether this surface has light-weight miplevels + */ +#define DDSCAPS3_LIGHTWEIGHTMIPMAP 0x00000400L + +/* + * This indicates that the mipsublevels for this surface are auto-generated + */ +#define DDSCAPS3_AUTOGENMIPMAP 0x00000800L + +/* + * This indicates that the mipsublevels for this surface are auto-generated + */ +#define DDSCAPS3_DMAP 0x00001000L + + + /**************************************************************************** + * + * DIRECTDRAW DRIVER CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * Display hardware has 3D acceleration. + */ +#define DDCAPS_3D 0x00000001l + +/* + * Indicates that DirectDraw will support only dest rectangles that are aligned + * on DIRECTDRAWCAPS.dwAlignBoundaryDest boundaries of the surface, respectively. + * READ ONLY. + */ +#define DDCAPS_ALIGNBOUNDARYDEST 0x00000002l + +/* + * Indicates that DirectDraw will support only source rectangles whose sizes in + * BYTEs are DIRECTDRAWCAPS.dwAlignSizeDest multiples, respectively. READ ONLY. + */ +#define DDCAPS_ALIGNSIZEDEST 0x00000004l +/* + * Indicates that DirectDraw will support only source rectangles that are aligned + * on DIRECTDRAWCAPS.dwAlignBoundarySrc boundaries of the surface, respectively. + * READ ONLY. + */ +#define DDCAPS_ALIGNBOUNDARYSRC 0x00000008l + +/* + * Indicates that DirectDraw will support only source rectangles whose sizes in + * BYTEs are DIRECTDRAWCAPS.dwAlignSizeSrc multiples, respectively. READ ONLY. + */ +#define DDCAPS_ALIGNSIZESRC 0x00000010l + +/* + * Indicates that DirectDraw will create video memory surfaces that have a stride + * alignment equal to DIRECTDRAWCAPS.dwAlignStride. READ ONLY. + */ +#define DDCAPS_ALIGNSTRIDE 0x00000020l + +/* + * Display hardware is capable of blt operations. + */ +#define DDCAPS_BLT 0x00000040l + +/* + * Display hardware is capable of asynchronous blt operations. + */ +#define DDCAPS_BLTQUEUE 0x00000080l + +/* + * Display hardware is capable of color space conversions during the blt operation. + */ +#define DDCAPS_BLTFOURCC 0x00000100l + +/* + * Display hardware is capable of stretching during blt operations. + */ +#define DDCAPS_BLTSTRETCH 0x00000200l + +/* + * Display hardware is shared with GDI. + */ +#define DDCAPS_GDI 0x00000400l + +/* + * Display hardware can overlay. + */ +#define DDCAPS_OVERLAY 0x00000800l + +/* + * Set if display hardware supports overlays but can not clip them. + */ +#define DDCAPS_OVERLAYCANTCLIP 0x00001000l + +/* + * Indicates that overlay hardware is capable of color space conversions during + * the overlay operation. + */ +#define DDCAPS_OVERLAYFOURCC 0x00002000l + +/* + * Indicates that stretching can be done by the overlay hardware. + */ +#define DDCAPS_OVERLAYSTRETCH 0x00004000l + +/* + * Indicates that unique DirectDrawPalettes can be created for DirectDrawSurfaces + * other than the primary surface. + */ +#define DDCAPS_PALETTE 0x00008000l + +/* + * Indicates that palette changes can be syncd with the veritcal refresh. + */ +#define DDCAPS_PALETTEVSYNC 0x00010000l + +/* + * Display hardware can return the current scan line. + */ +#define DDCAPS_READSCANLINE 0x00020000l + + +/* + * This flag used to bo DDCAPS_STEREOVIEW, which is now obsolete + */ +#define DDCAPS_RESERVED1 0x00040000l + +/* + * Display hardware is capable of generating a vertical blank interrupt. + */ +#define DDCAPS_VBI 0x00080000l + +/* + * Supports the use of z buffers with blt operations. + */ +#define DDCAPS_ZBLTS 0x00100000l + +/* + * Supports Z Ordering of overlays. + */ +#define DDCAPS_ZOVERLAYS 0x00200000l + +/* + * Supports color key + */ +#define DDCAPS_COLORKEY 0x00400000l + +/* + * Supports alpha surfaces + */ +#define DDCAPS_ALPHA 0x00800000l + +/* + * colorkey is hardware assisted(DDCAPS_COLORKEY will also be set) + */ +#define DDCAPS_COLORKEYHWASSIST 0x01000000l + +/* + * no hardware support at all + */ +#define DDCAPS_NOHARDWARE 0x02000000l + +/* + * Display hardware is capable of color fill with bltter + */ +#define DDCAPS_BLTCOLORFILL 0x04000000l + +/* + * Display hardware is bank switched, and potentially very slow at + * random access to VRAM. + */ +#define DDCAPS_BANKSWITCHED 0x08000000l + +/* + * Display hardware is capable of depth filling Z-buffers with bltter + */ +#define DDCAPS_BLTDEPTHFILL 0x10000000l + +/* + * Display hardware is capable of clipping while bltting. + */ +#define DDCAPS_CANCLIP 0x20000000l + +/* + * Display hardware is capable of clipping while stretch bltting. + */ +#define DDCAPS_CANCLIPSTRETCHED 0x40000000l + +/* + * Display hardware is capable of bltting to or from system memory + */ +#define DDCAPS_CANBLTSYSMEM 0x80000000l + + + /**************************************************************************** + * + * MORE DIRECTDRAW DRIVER CAPABILITY FLAGS (dwCaps2) + * + ****************************************************************************/ + +/* + * Display hardware is certified + */ +#define DDCAPS2_CERTIFIED 0x00000001l + +/* + * Driver cannot interleave 2D operations (lock and blt) to surfaces with + * Direct3D rendering operations between calls to BeginScene() and EndScene() + */ +#define DDCAPS2_NO2DDURING3DSCENE 0x00000002l + +/* + * Display hardware contains a video port + */ +#define DDCAPS2_VIDEOPORT 0x00000004l + +/* + * The overlay can be automatically flipped according to the video port + * VSYNCs, providing automatic doubled buffered display of video port + * data using an overlay + */ +#define DDCAPS2_AUTOFLIPOVERLAY 0x00000008l + +/* + * Overlay can display each field of interlaced data individually while + * it is interleaved in memory without causing jittery artifacts. + */ +#define DDCAPS2_CANBOBINTERLEAVED 0x00000010l + +/* + * Overlay can display each field of interlaced data individually while + * it is not interleaved in memory without causing jittery artifacts. + */ +#define DDCAPS2_CANBOBNONINTERLEAVED 0x00000020l + +/* + * The overlay surface contains color controls (brightness, sharpness, etc.) + */ +#define DDCAPS2_COLORCONTROLOVERLAY 0x00000040l + +/* + * The primary surface contains color controls (gamma, etc.) + */ +#define DDCAPS2_COLORCONTROLPRIMARY 0x00000080l + +/* + * RGBZ -> RGB supported for 16:16 RGB:Z + */ +#define DDCAPS2_CANDROPZ16BIT 0x00000100l + +/* + * Driver supports non-local video memory. + */ +#define DDCAPS2_NONLOCALVIDMEM 0x00000200l + +/* + * Dirver supports non-local video memory but has different capabilities for + * non-local video memory surfaces. If this bit is set then so must + * DDCAPS2_NONLOCALVIDMEM. + */ +#define DDCAPS2_NONLOCALVIDMEMCAPS 0x00000400l + +/* + * Driver neither requires nor prefers surfaces to be pagelocked when performing + * blts involving system memory surfaces + */ +#define DDCAPS2_NOPAGELOCKREQUIRED 0x00000800l + +/* + * Driver can create surfaces which are wider than the primary surface + */ +#define DDCAPS2_WIDESURFACES 0x00001000l + +/* + * Driver supports bob without using a video port by handling the + * DDFLIP_ODD and DDFLIP_EVEN flags specified in Flip. + */ +#define DDCAPS2_CANFLIPODDEVEN 0x00002000l + +/* + * Driver supports bob using hardware + */ +#define DDCAPS2_CANBOBHARDWARE 0x00004000l + +/* + * Driver supports bltting any FOURCC surface to another surface of the same FOURCC + */ +#define DDCAPS2_COPYFOURCC 0x00008000l + + +/* + * Driver supports loadable gamma ramps for the primary surface + */ +#define DDCAPS2_PRIMARYGAMMA 0x00020000l + +/* + * Driver can render in windowed mode. + */ +#define DDCAPS2_CANRENDERWINDOWED 0x00080000l + +/* + * A calibrator is available to adjust the gamma ramp according to the + * physical display properties so that the result will be identical on + * all calibrated systems. + */ +#define DDCAPS2_CANCALIBRATEGAMMA 0x00100000l + +/* + * Indicates that the driver will respond to DDFLIP_INTERVALn flags + */ +#define DDCAPS2_FLIPINTERVAL 0x00200000l + +/* + * Indicates that the driver will respond to DDFLIP_NOVSYNC + */ +#define DDCAPS2_FLIPNOVSYNC 0x00400000l + +/* + * Driver supports management of video memory, if this flag is ON, + * driver manages the texture if requested with DDSCAPS2_TEXTUREMANAGE on + * DirectX manages the texture if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on + */ +#define DDCAPS2_CANMANAGETEXTURE 0x00800000l + +/* + * The Direct3D texture manager uses this cap to decide whether to put managed + * surfaces in non-local video memory. If the cap is set, the texture manager will + * put managed surfaces in non-local vidmem. Drivers that cannot texture from + * local vidmem SHOULD NOT set this cap. + */ +#define DDCAPS2_TEXMANINNONLOCALVIDMEM 0x01000000l + +/* + * Indicates that the driver supports DX7 type of stereo in at least one mode (which may + * not necessarily be the current mode). Applications should use IDirectDraw7 (or higher) + * ::EnumDisplayModes and check the DDSURFACEDESC.ddsCaps.dwCaps2 field for the presence of + * DDSCAPS2_STEREOSURFACELEFT to check if a particular mode supports stereo. The application + * can also use IDirectDraw7(or higher)::GetDisplayMode to check the current mode. + */ +#define DDCAPS2_STEREO 0x02000000L + +/* + * This caps bit is intended for internal DirectDraw use. + * -It is only valid if DDCAPS2_NONLOCALVIDMEMCAPS is set. + * -If this bit is set, then DDCAPS_CANBLTSYSMEM MUST be set by the driver (and + * all the assoicated system memory blt caps must be correct). + * -It implies that the system->video blt caps in DDCAPS also apply to system to + * nonlocal blts. I.e. the dwSVBCaps, dwSVBCKeyCaps, dwSVBFXCaps and dwSVBRops + * members of DDCAPS (DDCORECAPS) are filled in correctly. + * -Any blt from system to nonlocal memory that matches these caps bits will + * be passed to the driver. + * + * NOTE: This is intended to enable the driver itself to do efficient reordering + * of textures. This is NOT meant to imply that hardware can write into AGP memory. + * This operation is not currently supported. + */ +#define DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL 0x04000000L + +/* + * was DDCAPS2_PUREHAL + */ +#define DDCAPS2_RESERVED1 0x08000000L + +/* + * Driver supports management of video memory, if this flag is ON, + * driver manages the resource if requested with DDSCAPS2_TEXTUREMANAGE on + * DirectX manages the resource if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on + */ +#define DDCAPS2_CANMANAGERESOURCE 0x10000000L + +/* + * Driver supports dynamic textures. This will allow the application to set + * D3DUSAGE_DYNAMIC (DDSCAPS2_HINTDYNAMIC for drivers) at texture create time. + * Video memory dynamic textures WILL be lockable by applications. It is + * expected that these locks will be very efficient (which implies that the + * driver should always maintain a linear copy, a pointer to which can be + * quickly handed out to the application). + */ +#define DDCAPS2_DYNAMICTEXTURES 0x20000000L + +/* + * Driver supports auto-generation of mipmaps. + */ +#define DDCAPS2_CANAUTOGENMIPMAP 0x40000000L + + +/**************************************************************************** + * + * DIRECTDRAW FX ALPHA CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * Supports alpha blending around the edge of a source color keyed surface. + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHAEDGEBLEND 0x00000001l + +/* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value becomes + * more opaque as the alpha value increases. (0 is transparent.) + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHAPIXELS 0x00000002l + +/* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value + * becomes more transparent as the alpha value increases. (0 is opaque.) + * This flag can only be set if DDCAPS_ALPHA is set. + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHAPIXELSNEG 0x00000004l + +/* + * Supports alpha only surfaces. The bit depth of an alpha only surface can be + * 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases. + * (0 is transparent.) + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHASURFACES 0x00000008l + +/* + * The depth of the alpha channel data can range can be 1,2,4, or 8. + * The NEG suffix indicates that this alpha channel becomes more transparent + * as the alpha value increases. (0 is opaque.) This flag can only be set if + * DDCAPS_ALPHA is set. + * For Blt. + */ +#define DDFXALPHACAPS_BLTALPHASURFACESNEG 0x00000010l + +/* + * Supports alpha blending around the edge of a source color keyed surface. + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND 0x00000020l + +/* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value becomes + * more opaque as the alpha value increases. (0 is transparent.) + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHAPIXELS 0x00000040l + +/* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value + * becomes more transparent as the alpha value increases. (0 is opaque.) + * This flag can only be set if DDCAPS_ALPHA is set. + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG 0x00000080l + +/* + * Supports alpha only surfaces. The bit depth of an alpha only surface can be + * 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases. + * (0 is transparent.) + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHASURFACES 0x00000100l + +/* + * The depth of the alpha channel data can range can be 1,2,4, or 8. + * The NEG suffix indicates that this alpha channel becomes more transparent + * as the alpha value increases. (0 is opaque.) This flag can only be set if + * DDCAPS_ALPHA is set. + * For Overlays. + */ +#define DDFXALPHACAPS_OVERLAYALPHASURFACESNEG 0x00000200l + +#if DIRECTDRAW_VERSION < 0x0600 +#endif //DIRECTDRAW_VERSION + + +/**************************************************************************** + * + * DIRECTDRAW FX CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * Uses arithmetic operations to stretch and shrink surfaces during blt + * rather than pixel doubling techniques. Along the Y axis. + */ +#define DDFXCAPS_BLTARITHSTRETCHY 0x00000020l + +/* + * Uses arithmetic operations to stretch during blt + * rather than pixel doubling techniques. Along the Y axis. Only + * works for x1, x2, etc. + */ +#define DDFXCAPS_BLTARITHSTRETCHYN 0x00000010l + +/* + * Supports mirroring left to right in blt. + */ +#define DDFXCAPS_BLTMIRRORLEFTRIGHT 0x00000040l + +/* + * Supports mirroring top to bottom in blt. + */ +#define DDFXCAPS_BLTMIRRORUPDOWN 0x00000080l + +/* + * Supports arbitrary rotation for blts. + */ +#define DDFXCAPS_BLTROTATION 0x00000100l + +/* + * Supports 90 degree rotations for blts. + */ +#define DDFXCAPS_BLTROTATION90 0x00000200l + +/* + * DirectDraw supports arbitrary shrinking of a surface along the + * x axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSHRINKX 0x00000400l + +/* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the x axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSHRINKXN 0x00000800l + +/* + * DirectDraw supports arbitrary shrinking of a surface along the + * y axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSHRINKY 0x00001000l + +/* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the y axis (vertical direction) for blts. + */ +#define DDFXCAPS_BLTSHRINKYN 0x00002000l + +/* + * DirectDraw supports arbitrary stretching of a surface along the + * x axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSTRETCHX 0x00004000l + +/* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the x axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSTRETCHXN 0x00008000l + +/* + * DirectDraw supports arbitrary stretching of a surface along the + * y axis (horizontal direction) for blts. + */ +#define DDFXCAPS_BLTSTRETCHY 0x00010000l + +/* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the y axis (vertical direction) for blts. + */ +#define DDFXCAPS_BLTSTRETCHYN 0x00020000l + +/* + * Uses arithmetic operations to stretch and shrink surfaces during + * overlay rather than pixel doubling techniques. Along the Y axis + * for overlays. + */ +#define DDFXCAPS_OVERLAYARITHSTRETCHY 0x00040000l + +/* + * Uses arithmetic operations to stretch surfaces during + * overlay rather than pixel doubling techniques. Along the Y axis + * for overlays. Only works for x1, x2, etc. + */ +#define DDFXCAPS_OVERLAYARITHSTRETCHYN 0x00000008l + +/* + * DirectDraw supports arbitrary shrinking of a surface along the + * x axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSHRINKX 0x00080000l + +/* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the x axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSHRINKXN 0x00100000l + +/* + * DirectDraw supports arbitrary shrinking of a surface along the + * y axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSHRINKY 0x00200000l + +/* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the y axis (vertical direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSHRINKYN 0x00400000l + +/* + * DirectDraw supports arbitrary stretching of a surface along the + * x axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSTRETCHX 0x00800000l + +/* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the x axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSTRETCHXN 0x01000000l + +/* + * DirectDraw supports arbitrary stretching of a surface along the + * y axis (horizontal direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSTRETCHY 0x02000000l + +/* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the y axis (vertical direction) for overlays. + */ +#define DDFXCAPS_OVERLAYSTRETCHYN 0x04000000l + +/* + * DirectDraw supports mirroring of overlays across the vertical axis + */ +#define DDFXCAPS_OVERLAYMIRRORLEFTRIGHT 0x08000000l + +/* + * DirectDraw supports mirroring of overlays across the horizontal axis + */ +#define DDFXCAPS_OVERLAYMIRRORUPDOWN 0x10000000l + +/* + * DirectDraw supports deinterlacing of overlay surfaces + */ +#define DDFXCAPS_OVERLAYDEINTERLACE 0x20000000l + +/* + * Driver can do alpha blending for blits. + */ +#define DDFXCAPS_BLTALPHA 0x00000001l + + +/* + * Driver can do surface-reconstruction filtering for warped blits. + */ +#define DDFXCAPS_BLTFILTER DDFXCAPS_BLTARITHSTRETCHY + +/* + * Driver can do alpha blending for overlays. + */ +#define DDFXCAPS_OVERLAYALPHA 0x00000004l + + +/* + * Driver can do surface-reconstruction filtering for warped overlays. + */ +#define DDFXCAPS_OVERLAYFILTER DDFXCAPS_OVERLAYARITHSTRETCHY + +/**************************************************************************** + * + * DIRECTDRAW STEREO VIEW CAPABILITIES + * + ****************************************************************************/ + +/* + * This flag used to be DDSVCAPS_ENIGMA, which is now obsolete + */ + +#define DDSVCAPS_RESERVED1 0x00000001l + +/* + * This flag used to be DDSVCAPS_FLICKER, which is now obsolete + */ +#define DDSVCAPS_RESERVED2 0x00000002l + +/* + * This flag used to be DDSVCAPS_REDBLUE, which is now obsolete + */ +#define DDSVCAPS_RESERVED3 0x00000004l + +/* + * This flag used to be DDSVCAPS_SPLIT, which is now obsolete + */ +#define DDSVCAPS_RESERVED4 0x00000008l + +/* + * The stereo view is accomplished with switching technology + */ + +#define DDSVCAPS_STEREOSEQUENTIAL 0x00000010L + + + +/**************************************************************************** + * + * DIRECTDRAWPALETTE CAPABILITIES + * + ****************************************************************************/ + +/* + * Index is 4 bits. There are sixteen color entries in the palette table. + */ +#define DDPCAPS_4BIT 0x00000001l + +/* + * Index is onto a 8 bit color index. This field is only valid with the + * DDPCAPS_1BIT, DDPCAPS_2BIT or DDPCAPS_4BIT capability and the target + * surface is in 8bpp. Each color entry is one byte long and is an index + * into destination surface's 8bpp palette. + */ +#define DDPCAPS_8BITENTRIES 0x00000002l + +/* + * Index is 8 bits. There are 256 color entries in the palette table. + */ +#define DDPCAPS_8BIT 0x00000004l + +/* + * Indicates that this DIRECTDRAWPALETTE should use the palette color array + * passed into the lpDDColorArray parameter to initialize the DIRECTDRAWPALETTE + * object. + * This flag is obsolete. DirectDraw always initializes the color array from + * the lpDDColorArray parameter. The definition remains for source-level + * compatibility. + */ +#define DDPCAPS_INITIALIZE 0x00000000l + +/* + * This palette is the one attached to the primary surface. Changing this + * table has immediate effect on the display unless DDPSETPAL_VSYNC is specified + * and supported. + */ +#define DDPCAPS_PRIMARYSURFACE 0x00000010l + +/* + * This palette is the one attached to the primary surface left. Changing + * this table has immediate effect on the display for the left eye unless + * DDPSETPAL_VSYNC is specified and supported. + */ +#define DDPCAPS_PRIMARYSURFACELEFT 0x00000020l + +/* + * This palette can have all 256 entries defined + */ +#define DDPCAPS_ALLOW256 0x00000040l + +/* + * This palette can have modifications to it synced with the monitors + * refresh rate. + */ +#define DDPCAPS_VSYNC 0x00000080l + +/* + * Index is 1 bit. There are two color entries in the palette table. + */ +#define DDPCAPS_1BIT 0x00000100l + +/* + * Index is 2 bit. There are four color entries in the palette table. + */ +#define DDPCAPS_2BIT 0x00000200l + +/* + * The peFlags member of PALETTEENTRY denotes an 8 bit alpha value + */ +#define DDPCAPS_ALPHA 0x00000400l + + +/**************************************************************************** + * + * DIRECTDRAWPALETTE SETENTRY CONSTANTS + * + ****************************************************************************/ + + +/**************************************************************************** + * + * DIRECTDRAWPALETTE GETENTRY CONSTANTS + * + ****************************************************************************/ + +/* 0 is the only legal value */ + +/**************************************************************************** + * + * DIRECTDRAWSURFACE SETPRIVATEDATA CONSTANTS + * + ****************************************************************************/ + +/* + * The passed pointer is an IUnknown ptr. The cbData argument to SetPrivateData + * must be set to sizeof(IUnknown*). DirectDraw will call AddRef through this + * pointer and Release when the private data is destroyed. This includes when + * the surface or palette is destroyed before such priovate data is destroyed. + */ +#define DDSPD_IUNKNOWNPOINTER 0x00000001L + +/* + * Private data is only valid for the current state of the object, + * as determined by the uniqueness value. + */ +#define DDSPD_VOLATILE 0x00000002L + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE SETPALETTE CONSTANTS + * + ****************************************************************************/ + + +/**************************************************************************** + * + * DIRECTDRAW BITDEPTH CONSTANTS + * + * NOTE: These are only used to indicate supported bit depths. These + * are flags only, they are not to be used as an actual bit depth. The + * absolute numbers 1, 2, 4, 8, 16, 24 and 32 are used to indicate actual + * bit depths in a surface or for changing the display mode. + * + ****************************************************************************/ + +/* + * 1 bit per pixel. + */ +#define DDBD_1 0x00004000l + +/* + * 2 bits per pixel. + */ +#define DDBD_2 0x00002000l + +/* + * 4 bits per pixel. + */ +#define DDBD_4 0x00001000l + +/* + * 8 bits per pixel. + */ +#define DDBD_8 0x00000800l + +/* + * 16 bits per pixel. + */ +#define DDBD_16 0x00000400l + +/* + * 24 bits per pixel. + */ +#define DDBD_24 0X00000200l + +/* + * 32 bits per pixel. + */ +#define DDBD_32 0x00000100l + +/**************************************************************************** + * + * DIRECTDRAWSURFACE SET/GET COLOR KEY FLAGS + * + ****************************************************************************/ + +/* + * Set if the structure contains a color space. Not set if the structure + * contains a single color key. + */ +#define DDCKEY_COLORSPACE 0x00000001l + +/* + * Set if the structure specifies a color key or color space which is to be + * used as a destination color key for blt operations. + */ +#define DDCKEY_DESTBLT 0x00000002l + +/* + * Set if the structure specifies a color key or color space which is to be + * used as a destination color key for overlay operations. + */ +#define DDCKEY_DESTOVERLAY 0x00000004l + +/* + * Set if the structure specifies a color key or color space which is to be + * used as a source color key for blt operations. + */ +#define DDCKEY_SRCBLT 0x00000008l + +/* + * Set if the structure specifies a color key or color space which is to be + * used as a source color key for overlay operations. + */ +#define DDCKEY_SRCOVERLAY 0x00000010l + + +/**************************************************************************** + * + * DIRECTDRAW COLOR KEY CAPABILITY FLAGS + * + ****************************************************************************/ + +/* + * Supports transparent blting using a color key to identify the replaceable + * bits of the destination surface for RGB colors. + */ +#define DDCKEYCAPS_DESTBLT 0x00000001l + +/* + * Supports transparent blting using a color space to identify the replaceable + * bits of the destination surface for RGB colors. + */ +#define DDCKEYCAPS_DESTBLTCLRSPACE 0x00000002l + +/* + * Supports transparent blting using a color space to identify the replaceable + * bits of the destination surface for YUV colors. + */ +#define DDCKEYCAPS_DESTBLTCLRSPACEYUV 0x00000004l + +/* + * Supports transparent blting using a color key to identify the replaceable + * bits of the destination surface for YUV colors. + */ +#define DDCKEYCAPS_DESTBLTYUV 0x00000008l + +/* + * Supports overlaying using colorkeying of the replaceable bits of the surface + * being overlayed for RGB colors. + */ +#define DDCKEYCAPS_DESTOVERLAY 0x00000010l + +/* + * Supports a color space as the color key for the destination for RGB colors. + */ +#define DDCKEYCAPS_DESTOVERLAYCLRSPACE 0x00000020l + +/* + * Supports a color space as the color key for the destination for YUV colors. + */ +#define DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV 0x00000040l + +/* + * Supports only one active destination color key value for visible overlay + * surfaces. + */ +#define DDCKEYCAPS_DESTOVERLAYONEACTIVE 0x00000080l + +/* + * Supports overlaying using colorkeying of the replaceable bits of the + * surface being overlayed for YUV colors. + */ +#define DDCKEYCAPS_DESTOVERLAYYUV 0x00000100l + +/* + * Supports transparent blting using the color key for the source with + * this surface for RGB colors. + */ +#define DDCKEYCAPS_SRCBLT 0x00000200l + +/* + * Supports transparent blting using a color space for the source with + * this surface for RGB colors. + */ +#define DDCKEYCAPS_SRCBLTCLRSPACE 0x00000400l + +/* + * Supports transparent blting using a color space for the source with + * this surface for YUV colors. + */ +#define DDCKEYCAPS_SRCBLTCLRSPACEYUV 0x00000800l + +/* + * Supports transparent blting using the color key for the source with + * this surface for YUV colors. + */ +#define DDCKEYCAPS_SRCBLTYUV 0x00001000l + +/* + * Supports overlays using the color key for the source with this + * overlay surface for RGB colors. + */ +#define DDCKEYCAPS_SRCOVERLAY 0x00002000l + +/* + * Supports overlays using a color space as the source color key for + * the overlay surface for RGB colors. + */ +#define DDCKEYCAPS_SRCOVERLAYCLRSPACE 0x00004000l + +/* + * Supports overlays using a color space as the source color key for + * the overlay surface for YUV colors. + */ +#define DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV 0x00008000l + +/* + * Supports only one active source color key value for visible + * overlay surfaces. + */ +#define DDCKEYCAPS_SRCOVERLAYONEACTIVE 0x00010000l + +/* + * Supports overlays using the color key for the source with this + * overlay surface for YUV colors. + */ +#define DDCKEYCAPS_SRCOVERLAYYUV 0x00020000l + +/* + * there are no bandwidth trade-offs for using colorkey with an overlay + */ +#define DDCKEYCAPS_NOCOSTOVERLAY 0x00040000l + + +/**************************************************************************** + * + * DIRECTDRAW PIXELFORMAT FLAGS + * + ****************************************************************************/ + +/* + * The surface has alpha channel information in the pixel format. + */ +#define DDPF_ALPHAPIXELS 0x00000001l + +/* + * The pixel format contains alpha only information + */ +#define DDPF_ALPHA 0x00000002l + +/* + * The FourCC code is valid. + */ +#define DDPF_FOURCC 0x00000004l + +/* + * The surface is 4-bit color indexed. + */ +#define DDPF_PALETTEINDEXED4 0x00000008l + +/* + * The surface is indexed into a palette which stores indices + * into the destination surface's 8-bit palette. + */ +#define DDPF_PALETTEINDEXEDTO8 0x00000010l + +/* + * The surface is 8-bit color indexed. + */ +#define DDPF_PALETTEINDEXED8 0x00000020l + +/* + * The RGB data in the pixel format structure is valid. + */ +#define DDPF_RGB 0x00000040l + +/* + * The surface will accept pixel data in the format specified + * and compress it during the write. + */ +#define DDPF_COMPRESSED 0x00000080l + +/* + * The surface will accept RGB data and translate it during + * the write to YUV data. The format of the data to be written + * will be contained in the pixel format structure. The DDPF_RGB + * flag will be set. + */ +#define DDPF_RGBTOYUV 0x00000100l + +/* + * pixel format is YUV - YUV data in pixel format struct is valid + */ +#define DDPF_YUV 0x00000200l + +/* + * pixel format is a z buffer only surface + */ +#define DDPF_ZBUFFER 0x00000400l + +/* + * The surface is 1-bit color indexed. + */ +#define DDPF_PALETTEINDEXED1 0x00000800l + +/* + * The surface is 2-bit color indexed. + */ +#define DDPF_PALETTEINDEXED2 0x00001000l + +/* + * The surface contains Z information in the pixels + */ +#define DDPF_ZPIXELS 0x00002000l + +/* + * The surface contains stencil information along with Z + */ +#define DDPF_STENCILBUFFER 0x00004000l + +/* + * Premultiplied alpha format -- the color components have been + * premultiplied by the alpha component. + */ +#define DDPF_ALPHAPREMULT 0x00008000l + + +/* + * Luminance data in the pixel format is valid. + * Use this flag for luminance-only or luminance+alpha surfaces, + * the bit depth is then ddpf.dwLuminanceBitCount. + */ +#define DDPF_LUMINANCE 0x00020000l + +/* + * Luminance data in the pixel format is valid. + * Use this flag when hanging luminance off bumpmap surfaces, + * the bit mask for the luminance portion of the pixel is then + * ddpf.dwBumpLuminanceBitMask + */ +#define DDPF_BUMPLUMINANCE 0x00040000l + +/* + * Bump map dUdV data in the pixel format is valid. + */ +#define DDPF_BUMPDUDV 0x00080000l + + +/*=========================================================================== + * + * + * DIRECTDRAW CALLBACK FLAGS + * + * + *==========================================================================*/ + +/**************************************************************************** + * + * DIRECTDRAW ENUMSURFACES FLAGS + * + ****************************************************************************/ + +/* + * Enumerate all of the surfaces that meet the search criterion. + */ +#define DDENUMSURFACES_ALL 0x00000001l + +/* + * A search hit is a surface that matches the surface description. + */ +#define DDENUMSURFACES_MATCH 0x00000002l + +/* + * A search hit is a surface that does not match the surface description. + */ +#define DDENUMSURFACES_NOMATCH 0x00000004l + +/* + * Enumerate the first surface that can be created which meets the search criterion. + */ +#define DDENUMSURFACES_CANBECREATED 0x00000008l + +/* + * Enumerate the surfaces that already exist that meet the search criterion. + */ +#define DDENUMSURFACES_DOESEXIST 0x00000010l + + +/**************************************************************************** + * + * DIRECTDRAW SETDISPLAYMODE FLAGS + * + ****************************************************************************/ + +/* + * The desired mode is a standard VGA mode + */ +#define DDSDM_STANDARDVGAMODE 0x00000001l + + +/**************************************************************************** + * + * DIRECTDRAW ENUMDISPLAYMODES FLAGS + * + ****************************************************************************/ + +/* + * Enumerate Modes with different refresh rates. EnumDisplayModes guarantees + * that a particular mode will be enumerated only once. This flag specifies whether + * the refresh rate is taken into account when determining if a mode is unique. + */ +#define DDEDM_REFRESHRATES 0x00000001l + +/* + * Enumerate VGA modes. Specify this flag if you wish to enumerate supported VGA + * modes such as mode 0x13 in addition to the usual ModeX modes (which are always + * enumerated if the application has previously called SetCooperativeLevel with the + * DDSCL_ALLOWMODEX flag set). + */ +#define DDEDM_STANDARDVGAMODES 0x00000002L + + +/**************************************************************************** + * + * DIRECTDRAW SETCOOPERATIVELEVEL FLAGS + * + ****************************************************************************/ + +/* + * Exclusive mode owner will be responsible for the entire primary surface. + * GDI can be ignored. used with DD + */ +#define DDSCL_FULLSCREEN 0x00000001l + +/* + * allow CTRL_ALT_DEL to work while in fullscreen exclusive mode + */ +#define DDSCL_ALLOWREBOOT 0x00000002l + +/* + * prevents DDRAW from modifying the application window. + * prevents DDRAW from minimize/restore the application window on activation. + */ +#define DDSCL_NOWINDOWCHANGES 0x00000004l + +/* + * app wants to work as a regular Windows application + */ +#define DDSCL_NORMAL 0x00000008l + +/* + * app wants exclusive access + */ +#define DDSCL_EXCLUSIVE 0x00000010l + + +/* + * app can deal with non-windows display modes + */ +#define DDSCL_ALLOWMODEX 0x00000040l + +/* + * this window will receive the focus messages + */ +#define DDSCL_SETFOCUSWINDOW 0x00000080l + +/* + * this window is associated with the DDRAW object and will + * cover the screen in fullscreen mode + */ +#define DDSCL_SETDEVICEWINDOW 0x00000100l + +/* + * app wants DDRAW to create a window to be associated with the + * DDRAW object + */ +#define DDSCL_CREATEDEVICEWINDOW 0x00000200l + +/* + * App explicitly asks DDRAW/D3D to be multithread safe. This makes D3D + * take the global crtisec more frequently. + */ +#define DDSCL_MULTITHREADED 0x00000400l + +/* + * App specifies that it would like to keep the FPU set up for optimal Direct3D + * performance (single precision and exceptions disabled) so Direct3D + * does not need to explicitly set the FPU each time. This is assumed by + * default in DirectX 7. See also DDSCL_FPUPRESERVE + */ +#define DDSCL_FPUSETUP 0x00000800l + +/* + * App specifies that it needs either double precision FPU or FPU exceptions + * enabled. This makes Direct3D explicitly set the FPU state eah time it is + * called. Setting the flag will reduce Direct3D performance. The flag is + * assumed by default in DirectX 6 and earlier. See also DDSCL_FPUSETUP + */ +#define DDSCL_FPUPRESERVE 0x00001000l + + +/**************************************************************************** + * + * DIRECTDRAW BLT FLAGS + * + ****************************************************************************/ + +/* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the destination surface as the alpha channel for this blt. + */ +#define DDBLT_ALPHADEST 0x00000001l + +/* + * Use the dwConstAlphaDest field in the DDBLTFX structure as the alpha channel + * for the destination surface for this blt. + */ +#define DDBLT_ALPHADESTCONSTOVERRIDE 0x00000002l + +/* + * The NEG suffix indicates that the destination surface becomes more + * transparent as the alpha value increases. (0 is opaque) + */ +#define DDBLT_ALPHADESTNEG 0x00000004l + +/* + * Use the lpDDSAlphaDest field in the DDBLTFX structure as the alpha + * channel for the destination for this blt. + */ +#define DDBLT_ALPHADESTSURFACEOVERRIDE 0x00000008l + +/* + * Use the dwAlphaEdgeBlend field in the DDBLTFX structure as the alpha channel + * for the edges of the image that border the color key colors. + */ +#define DDBLT_ALPHAEDGEBLEND 0x00000010l + +/* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the source surface as the alpha channel for this blt. + */ +#define DDBLT_ALPHASRC 0x00000020l + +/* + * Use the dwConstAlphaSrc field in the DDBLTFX structure as the alpha channel + * for the source for this blt. + */ +#define DDBLT_ALPHASRCCONSTOVERRIDE 0x00000040l + +/* + * The NEG suffix indicates that the source surface becomes more transparent + * as the alpha value increases. (0 is opaque) + */ +#define DDBLT_ALPHASRCNEG 0x00000080l + +/* + * Use the lpDDSAlphaSrc field in the DDBLTFX structure as the alpha channel + * for the source for this blt. + */ +#define DDBLT_ALPHASRCSURFACEOVERRIDE 0x00000100l + +/* + * Do this blt asynchronously through the FIFO in the order received. If + * there is no room in the hardware FIFO fail the call. + */ +#define DDBLT_ASYNC 0x00000200l + +/* + * Uses the dwFillColor field in the DDBLTFX structure as the RGB color + * to fill the destination rectangle on the destination surface with. + */ +#define DDBLT_COLORFILL 0x00000400l + +/* + * Uses the dwDDFX field in the DDBLTFX structure to specify the effects + * to use for the blt. + */ +#define DDBLT_DDFX 0x00000800l + +/* + * Uses the dwDDROPS field in the DDBLTFX structure to specify the ROPS + * that are not part of the Win32 API. + */ +#define DDBLT_DDROPS 0x00001000l + +/* + * Use the color key associated with the destination surface. + */ +#define DDBLT_KEYDEST 0x00002000l + +/* + * Use the dckDestColorkey field in the DDBLTFX structure as the color key + * for the destination surface. + */ +#define DDBLT_KEYDESTOVERRIDE 0x00004000l + +/* + * Use the color key associated with the source surface. + */ +#define DDBLT_KEYSRC 0x00008000l + +/* + * Use the dckSrcColorkey field in the DDBLTFX structure as the color key + * for the source surface. + */ +#define DDBLT_KEYSRCOVERRIDE 0x00010000l + +/* + * Use the dwROP field in the DDBLTFX structure for the raster operation + * for this blt. These ROPs are the same as the ones defined in the Win32 API. + */ +#define DDBLT_ROP 0x00020000l + +/* + * Use the dwRotationAngle field in the DDBLTFX structure as the angle + * (specified in 1/100th of a degree) to rotate the surface. + */ +#define DDBLT_ROTATIONANGLE 0x00040000l + +/* + * Z-buffered blt using the z-buffers attached to the source and destination + * surfaces and the dwZBufferOpCode field in the DDBLTFX structure as the + * z-buffer opcode. + */ +#define DDBLT_ZBUFFER 0x00080000l + +/* + * Z-buffered blt using the dwConstDest Zfield and the dwZBufferOpCode field + * in the DDBLTFX structure as the z-buffer and z-buffer opcode respectively + * for the destination. + */ +#define DDBLT_ZBUFFERDESTCONSTOVERRIDE 0x00100000l + +/* + * Z-buffered blt using the lpDDSDestZBuffer field and the dwZBufferOpCode + * field in the DDBLTFX structure as the z-buffer and z-buffer opcode + * respectively for the destination. + */ +#define DDBLT_ZBUFFERDESTOVERRIDE 0x00200000l + +/* + * Z-buffered blt using the dwConstSrcZ field and the dwZBufferOpCode field + * in the DDBLTFX structure as the z-buffer and z-buffer opcode respectively + * for the source. + */ +#define DDBLT_ZBUFFERSRCCONSTOVERRIDE 0x00400000l + +/* + * Z-buffered blt using the lpDDSSrcZBuffer field and the dwZBufferOpCode + * field in the DDBLTFX structure as the z-buffer and z-buffer opcode + * respectively for the source. + */ +#define DDBLT_ZBUFFERSRCOVERRIDE 0x00800000l + +/* + * wait until the device is ready to handle the blt + * this will cause blt to not return DDERR_WASSTILLDRAWING + */ +#define DDBLT_WAIT 0x01000000l + +/* + * Uses the dwFillDepth field in the DDBLTFX structure as the depth value + * to fill the destination rectangle on the destination Z-buffer surface + * with. + */ +#define DDBLT_DEPTHFILL 0x02000000l + + +/* + * Return immediately (with DDERR_WASSTILLDRAWING) if the device is not + * ready to schedule the blt at the time Blt() is called. + */ +#define DDBLT_DONOTWAIT 0x08000000l + +/* + * These flags indicate a presentation blt (i.e. a blt + * that moves surface contents from an offscreen back buffer to the primary + * surface). The driver is not allowed to "queue" more than three such blts. + * The "end" of the presentation blt is indicated, since the + * blt may be clipped, in which case the runtime will call the driver with + * several blts. All blts (even if not clipped) are tagged with DDBLT_PRESENTATION + * and the last (even if not clipped) additionally with DDBLT_LAST_PRESENTATION. + * Thus the true rule is that the driver must not schedule a DDBLT_PRESENTATION + * blt if there are 3 or more DDBLT_PRESENTLAST blts in the hardware pipe. + * If there are such blts in the pipe, the driver should return DDERR_WASSTILLDRAWING + * until the oldest queued DDBLT_LAST_PRESENTATION blts has been retired (i.e. the + * pixels have been actually written to the primary surface). Once the oldest blt + * has been retired, the driver is free to schedule the current blt. + * The goal is to provide a mechanism whereby the device's hardware queue never + * gets more than 3 frames ahead of the frames being generated by the application. + * When excessive queueing occurs, applications become unusable because the application + * visibly lags user input, and such problems make windowed interactive applications impossible. + * Some drivers may not have sufficient knowledge of their hardware's FIFO to know + * when a certain blt has been retired. Such drivers should code cautiously, and + * simply not allow any frames to be queued at all. DDBLT_LAST_PRESENTATION should cause + * such drivers to return DDERR_WASSTILLDRAWING until the accelerator is completely + * finished- exactly as if the application had called Lock on the source surface + * before calling Blt. + * In other words, the driver is allowed and encouraged to + * generate as much latency as it can, but never more than 3 frames worth. + * Implementation detail: Drivers should count blts against the SOURCE surface, not + * against the primary surface. This enables multiple parallel windowed application + * to function more optimally. + * This flag is passed only to DX8 or higher drivers. + * + * APPLICATIONS DO NOT SET THESE FLAGS. THEY ARE SET BY THE DIRECTDRAW RUNTIME. + * + */ +#define DDBLT_PRESENTATION 0x10000000l +#define DDBLT_LAST_PRESENTATION 0x20000000l + +/* + * If DDBLT_EXTENDED_FLAGS is set, then the driver should re-interpret + * other flags according to the definitions that follow. + * For example, bit 0 (0x00000001L) means DDBLT_ALPHADEST, unless + * DDBLT_EXTENDED_FLAGS is also set, in which case bit 0 means + * DDBLT_EXTENDED_LINEAR_CONTENT. + * Only DirectX9 and higher drivers will be given extended blt flags. + * Only flags explicitly mentioned here should be re-interpreted. + * All other flags retain their original meanings. + * + * List of re-interpreted flags: + * + * Bit Hex value New meaning old meaning + * --------------------------------------------------------------- + * 2 0x00000004 DDBLT_EXTENDED_LINEAR_CONTENT DDBLT_ALPHADESTNEG + * 4 0x00000010 DDBLT_EXTENDED_PRESENTATION_STRETCHFACTOR DDBLT_ALPHAEDGEBLEND + * + * + * NOTE: APPLICATIONS SHOULD NOT SET THIS FLAG. THIS FLAG IS INTENDED + * FOR USE BY THE DIRECT3D RUNTIME. + */ +#define DDBLT_EXTENDED_FLAGS 0x40000000l + +/* + * EXTENDED FLAG. SEE DEFINITION OF DDBLT_EXTENDED_FLAGS. + * This flag indidcates that the source surface contains content in a + * linear color space. The driver may perform gamma correction to the + * desktop color space (i.e. sRGB, gamma 2.2) as part of this blt. + * If the device can perform such a conversion as part of the copy, + * the driver should also set D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION + * + * NOTE: APPLICATIONS SHOULD NOT SET THIS FLAG. THIS FLAG IS INTENDED + * FOR USE BY THE DIRECT3D RUNTIME. Use IDirect3DSwapChain9::Present + * and specify D3DPRESENT_LINEAR_CONTENT in order to use this functionality. + */ +#define DDBLT_EXTENDED_LINEAR_CONTENT 0x00000004l + + +/**************************************************************************** + * + * BLTFAST FLAGS + * + ****************************************************************************/ + +#define DDBLTFAST_NOCOLORKEY 0x00000000 +#define DDBLTFAST_SRCCOLORKEY 0x00000001 +#define DDBLTFAST_DESTCOLORKEY 0x00000002 +#define DDBLTFAST_WAIT 0x00000010 +#define DDBLTFAST_DONOTWAIT 0x00000020 + +/**************************************************************************** + * + * FLIP FLAGS + * + ****************************************************************************/ + +#define DDFLIP_WAIT 0x00000001L + +/* + * Indicates that the target surface contains the even field of video data. + * This flag is only valid with an overlay surface. + */ +#define DDFLIP_EVEN 0x00000002L + +/* + * Indicates that the target surface contains the odd field of video data. + * This flag is only valid with an overlay surface. + */ +#define DDFLIP_ODD 0x00000004L + +/* + * Causes DirectDraw to perform the physical flip immediately and return + * to the application. Typically, what was the front buffer but is now the back + * buffer will still be visible (depending on timing) until the next vertical + * retrace. Subsequent operations involving the two flipped surfaces will + * not check to see if the physical flip has finished (i.e. will not return + * DDERR_WASSTILLDRAWING for that reason (but may for other reasons)). + * This allows an application to perform Flips at a higher frequency than the + * monitor refresh rate, but may introduce visible artifacts. + * Only effective if DDCAPS2_FLIPNOVSYNC is set. If that bit is not set, + * DDFLIP_NOVSYNC has no effect. + */ +#define DDFLIP_NOVSYNC 0x00000008L + + +/* + * Flip Interval Flags. These flags indicate how many vertical retraces to wait between + * each flip. The default is one. DirectDraw will return DDERR_WASSTILLDRAWING for each + * surface involved in the flip until the specified number of vertical retraces has + * ocurred. Only effective if DDCAPS2_FLIPINTERVAL is set. If that bit is not set, + * DDFLIP_INTERVALn has no effect. + */ + +/* + * DirectDraw will flip on every other vertical sync + */ +#define DDFLIP_INTERVAL2 0x02000000L + + +/* + * DirectDraw will flip on every third vertical sync + */ +#define DDFLIP_INTERVAL3 0x03000000L + + +/* + * DirectDraw will flip on every fourth vertical sync + */ +#define DDFLIP_INTERVAL4 0x04000000L + +/* + * DirectDraw will flip and display a main stereo surface + */ +#define DDFLIP_STEREO 0x00000010L + +/* + * On IDirectDrawSurface7 and higher interfaces, the default is DDFLIP_WAIT. If you wish + * to override the default and use time when the accelerator is busy (as denoted by + * the DDERR_WASSTILLDRAWING return code) then use DDFLIP_DONOTWAIT. + */ +#define DDFLIP_DONOTWAIT 0x00000020L + + +/**************************************************************************** + * + * DIRECTDRAW SURFACE OVERLAY FLAGS + * + ****************************************************************************/ + +/* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the destination surface as the alpha channel for the + * destination overlay. + */ +#define DDOVER_ALPHADEST 0x00000001l + +/* + * Use the dwConstAlphaDest field in the DDOVERLAYFX structure as the + * destination alpha channel for this overlay. + */ +#define DDOVER_ALPHADESTCONSTOVERRIDE 0x00000002l + +/* + * The NEG suffix indicates that the destination surface becomes more + * transparent as the alpha value increases. + */ +#define DDOVER_ALPHADESTNEG 0x00000004l + +/* + * Use the lpDDSAlphaDest field in the DDOVERLAYFX structure as the alpha + * channel destination for this overlay. + */ +#define DDOVER_ALPHADESTSURFACEOVERRIDE 0x00000008l + +/* + * Use the dwAlphaEdgeBlend field in the DDOVERLAYFX structure as the alpha + * channel for the edges of the image that border the color key colors. + */ +#define DDOVER_ALPHAEDGEBLEND 0x00000010l + +/* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the source surface as the source alpha channel for this overlay. + */ +#define DDOVER_ALPHASRC 0x00000020l + +/* + * Use the dwConstAlphaSrc field in the DDOVERLAYFX structure as the source + * alpha channel for this overlay. + */ +#define DDOVER_ALPHASRCCONSTOVERRIDE 0x00000040l + +/* + * The NEG suffix indicates that the source surface becomes more transparent + * as the alpha value increases. + */ +#define DDOVER_ALPHASRCNEG 0x00000080l + +/* + * Use the lpDDSAlphaSrc field in the DDOVERLAYFX structure as the alpha channel + * source for this overlay. + */ +#define DDOVER_ALPHASRCSURFACEOVERRIDE 0x00000100l + +/* + * Turn this overlay off. + */ +#define DDOVER_HIDE 0x00000200l + +/* + * Use the color key associated with the destination surface. + */ +#define DDOVER_KEYDEST 0x00000400l + +/* + * Use the dckDestColorkey field in the DDOVERLAYFX structure as the color key + * for the destination surface + */ +#define DDOVER_KEYDESTOVERRIDE 0x00000800l + +/* + * Use the color key associated with the source surface. + */ +#define DDOVER_KEYSRC 0x00001000l + +/* + * Use the dckSrcColorkey field in the DDOVERLAYFX structure as the color key + * for the source surface. + */ +#define DDOVER_KEYSRCOVERRIDE 0x00002000l + +/* + * Turn this overlay on. + */ +#define DDOVER_SHOW 0x00004000l + +/* + * Add a dirty rect to an emulated overlayed surface. + */ +#define DDOVER_ADDDIRTYRECT 0x00008000l + +/* + * Redraw all dirty rects on an emulated overlayed surface. + */ +#define DDOVER_REFRESHDIRTYRECTS 0x00010000l + +/* + * Redraw the entire surface on an emulated overlayed surface. + */ +#define DDOVER_REFRESHALL 0x00020000l + + +/* + * Use the overlay FX flags to define special overlay FX + */ +#define DDOVER_DDFX 0x00080000l + +/* + * Autoflip the overlay when ever the video port autoflips + */ +#define DDOVER_AUTOFLIP 0x00100000l + +/* + * Display each field of video port data individually without + * causing any jittery artifacts + */ +#define DDOVER_BOB 0x00200000l + +/* + * Indicates that bob/weave decisions should not be overridden by other + * interfaces. + */ +#define DDOVER_OVERRIDEBOBWEAVE 0x00400000l + +/* + * Indicates that the surface memory is composed of interleaved fields. + */ +#define DDOVER_INTERLEAVED 0x00800000l + +/* + * Indicates that bob will be performed using hardware rather than + * software or emulated. + */ +#define DDOVER_BOBHARDWARE 0x01000000l + +/* + * Indicates that overlay FX structure contains valid ARGB scaling factors. + */ +#define DDOVER_ARGBSCALEFACTORS 0x02000000l + +/* + * Indicates that ARGB scaling factors can be degraded to fit driver capabilities. + */ +#define DDOVER_DEGRADEARGBSCALING 0x04000000l + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE LOCK FLAGS + * + ****************************************************************************/ + +/* + * The default. Set to indicate that Lock should return a valid memory pointer + * to the top of the specified rectangle. If no rectangle is specified then a + * pointer to the top of the surface is returned. + */ +#define DDLOCK_SURFACEMEMORYPTR 0x00000000L // default + +/* + * Set to indicate that Lock should wait until it can obtain a valid memory + * pointer before returning. If this bit is set, Lock will never return + * DDERR_WASSTILLDRAWING. + */ +#define DDLOCK_WAIT 0x00000001L + +/* + * Set if an event handle is being passed to Lock. Lock will trigger the event + * when it can return the surface memory pointer requested. + */ +#define DDLOCK_EVENT 0x00000002L + +/* + * Indicates that the surface being locked will only be read from. + */ +#define DDLOCK_READONLY 0x00000010L + +/* + * Indicates that the surface being locked will only be written to + */ +#define DDLOCK_WRITEONLY 0x00000020L + + +/* + * Indicates that a system wide lock should not be taken when this surface + * is locked. This has several advantages (cursor responsiveness, ability + * to call more Windows functions, easier debugging) when locking video + * memory surfaces. However, an application specifying this flag must + * comply with a number of conditions documented in the help file. + * Furthermore, this flag cannot be specified when locking the primary. + */ +#define DDLOCK_NOSYSLOCK 0x00000800L + +/* + * Used only with Direct3D Vertex Buffer Locks. Indicates that no vertices + * that were referred to in Draw*PrimtiveVB calls since the start of the + * frame (or the last lock without this flag) will be modified during the + * lock. This can be useful when one is only appending data to the vertex + * buffer + */ +#define DDLOCK_NOOVERWRITE 0x00001000L + +/* + * Indicates that no assumptions will be made about the contents of the + * surface or vertex buffer during this lock. + * This enables two things: + * - Direct3D or the driver may provide an alternative memory + * area as the vertex buffer. This is useful when one plans to clear the + * contents of the vertex buffer and fill in new data. + * - Drivers sometimes store surface data in a re-ordered format. + * When the application locks the surface, the driver is forced to un-re-order + * the surface data before allowing the application to see the surface contents. + * This flag is a hint to the driver that it can skip the un-re-ordering process + * since the application plans to overwrite every single pixel in the surface + * or locked rectangle (and so erase any un-re-ordered pixels anyway). + * Applications should always set this flag when they intend to overwrite the entire + * surface or locked rectangle. + */ +#define DDLOCK_DISCARDCONTENTS 0x00002000L + /* + * DDLOCK_OKTOSWAP is an older, less informative name for DDLOCK_DISCARDCONTENTS + */ +#define DDLOCK_OKTOSWAP 0x00002000L + +/* + * On IDirectDrawSurface7 and higher interfaces, the default is DDLOCK_WAIT. If you wish + * to override the default and use time when the accelerator is busy (as denoted by + * the DDERR_WASSTILLDRAWING return code) then use DDLOCK_DONOTWAIT. + */ +#define DDLOCK_DONOTWAIT 0x00004000L + +/* + * This indicates volume texture lock with front and back specified. + */ +#define DDLOCK_HASVOLUMETEXTUREBOXRECT 0x00008000L + +/* + * This indicates that the driver should not update dirty rect information for this lock. + */ +#define DDLOCK_NODIRTYUPDATE 0x00010000L + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE PAGELOCK FLAGS + * + ****************************************************************************/ + +/* + * No flags defined at present + */ + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE PAGEUNLOCK FLAGS + * + ****************************************************************************/ + +/* + * No flags defined at present + */ + + +/**************************************************************************** + * + * DIRECTDRAWSURFACE BLT FX FLAGS + * + ****************************************************************************/ + +/* + * If stretching, use arithmetic stretching along the Y axis for this blt. + */ +#define DDBLTFX_ARITHSTRETCHY 0x00000001l + +/* + * Do this blt mirroring the surface left to right. Spin the + * surface around its y-axis. + */ +#define DDBLTFX_MIRRORLEFTRIGHT 0x00000002l + +/* + * Do this blt mirroring the surface up and down. Spin the surface + * around its x-axis. + */ +#define DDBLTFX_MIRRORUPDOWN 0x00000004l + +/* + * Schedule this blt to avoid tearing. + */ +#define DDBLTFX_NOTEARING 0x00000008l + +/* + * Do this blt rotating the surface one hundred and eighty degrees. + */ +#define DDBLTFX_ROTATE180 0x00000010l + +/* + * Do this blt rotating the surface two hundred and seventy degrees. + */ +#define DDBLTFX_ROTATE270 0x00000020l + +/* + * Do this blt rotating the surface ninety degrees. + */ +#define DDBLTFX_ROTATE90 0x00000040l + +/* + * Do this z blt using dwZBufferLow and dwZBufferHigh as range values + * specified to limit the bits copied from the source surface. + */ +#define DDBLTFX_ZBUFFERRANGE 0x00000080l + +/* + * Do this z blt adding the dwZBufferBaseDest to each of the sources z values + * before comparing it with the desting z values. + */ +#define DDBLTFX_ZBUFFERBASEDEST 0x00000100l + +/**************************************************************************** + * + * DIRECTDRAWSURFACE OVERLAY FX FLAGS + * + ****************************************************************************/ + +/* + * If stretching, use arithmetic stretching along the Y axis for this overlay. + */ +#define DDOVERFX_ARITHSTRETCHY 0x00000001l + +/* + * Mirror the overlay across the vertical axis + */ +#define DDOVERFX_MIRRORLEFTRIGHT 0x00000002l + +/* + * Mirror the overlay across the horizontal axis + */ +#define DDOVERFX_MIRRORUPDOWN 0x00000004l + +/* + * Deinterlace the overlay, if possible + */ +#define DDOVERFX_DEINTERLACE 0x00000008l + + +/**************************************************************************** + * + * DIRECTDRAW WAITFORVERTICALBLANK FLAGS + * + ****************************************************************************/ + +/* + * return when the vertical blank interval begins + */ +#define DDWAITVB_BLOCKBEGIN 0x00000001l + +/* + * set up an event to trigger when the vertical blank begins + */ +#define DDWAITVB_BLOCKBEGINEVENT 0x00000002l + +/* + * return when the vertical blank interval ends and display begins + */ +#define DDWAITVB_BLOCKEND 0x00000004l + +/**************************************************************************** + * + * DIRECTDRAW GETFLIPSTATUS FLAGS + * + ****************************************************************************/ + +/* + * is it OK to flip now? + */ +#define DDGFS_CANFLIP 0x00000001l + +/* + * is the last flip finished? + */ +#define DDGFS_ISFLIPDONE 0x00000002l + +/**************************************************************************** + * + * DIRECTDRAW GETBLTSTATUS FLAGS + * + ****************************************************************************/ + +/* + * is it OK to blt now? + */ +#define DDGBS_CANBLT 0x00000001l + +/* + * is the blt to the surface finished? + */ +#define DDGBS_ISBLTDONE 0x00000002l + + +/**************************************************************************** + * + * DIRECTDRAW ENUMOVERLAYZORDER FLAGS + * + ****************************************************************************/ + +/* + * Enumerate overlays back to front. + */ +#define DDENUMOVERLAYZ_BACKTOFRONT 0x00000000l + +/* + * Enumerate overlays front to back + */ +#define DDENUMOVERLAYZ_FRONTTOBACK 0x00000001l + +/**************************************************************************** + * + * DIRECTDRAW UPDATEOVERLAYZORDER FLAGS + * + ****************************************************************************/ + +/* + * Send overlay to front + */ +#define DDOVERZ_SENDTOFRONT 0x00000000l + +/* + * Send overlay to back + */ +#define DDOVERZ_SENDTOBACK 0x00000001l + +/* + * Move Overlay forward + */ +#define DDOVERZ_MOVEFORWARD 0x00000002l + +/* + * Move Overlay backward + */ +#define DDOVERZ_MOVEBACKWARD 0x00000003l + +/* + * Move Overlay in front of relative surface + */ +#define DDOVERZ_INSERTINFRONTOF 0x00000004l + +/* + * Move Overlay in back of relative surface + */ +#define DDOVERZ_INSERTINBACKOF 0x00000005l + + +/**************************************************************************** + * + * DIRECTDRAW SETGAMMARAMP FLAGS + * + ****************************************************************************/ + +/* + * Request calibrator to adjust the gamma ramp according to the physical + * properties of the display so that the result should appear identical + * on all systems. + */ +#define DDSGR_CALIBRATE 0x00000001L + + +/**************************************************************************** + * + * DIRECTDRAW STARTMODETEST FLAGS + * + ****************************************************************************/ + +/* + * Indicates that the mode being tested has passed + */ +#define DDSMT_ISTESTREQUIRED 0x00000001L + + +/**************************************************************************** + * + * DIRECTDRAW EVALUATEMODE FLAGS + * + ****************************************************************************/ + +/* + * Indicates that the mode being tested has passed + */ +#define DDEM_MODEPASSED 0x00000001L + +/* + * Indicates that the mode being tested has failed + */ +#define DDEM_MODEFAILED 0x00000002L + + +/*=========================================================================== + * + * + * DIRECTDRAW RETURN CODES + * + * The return values from DirectDraw Commands and Surface that return an HRESULT + * are codes from DirectDraw concerning the results of the action + * requested by DirectDraw. + * + *==========================================================================*/ + +/* + * Status is OK + * + * Issued by: DirectDraw Commands and all callbacks + */ +#define DD_OK S_OK +#define DD_FALSE S_FALSE + +/**************************************************************************** + * + * DIRECTDRAW ENUMCALLBACK RETURN VALUES + * + * EnumCallback returns are used to control the flow of the DIRECTDRAW and + * DIRECTDRAWSURFACE object enumerations. They can only be returned by + * enumeration callback routines. + * + ****************************************************************************/ + +/* + * stop the enumeration + */ +#define DDENUMRET_CANCEL 0 + +/* + * continue the enumeration + */ +#define DDENUMRET_OK 1 + +/**************************************************************************** + * + * DIRECTDRAW ERRORS + * + * Errors are represented by negative values and cannot be combined. + * + ****************************************************************************/ + +/* + * This object is already initialized + */ +#define DDERR_ALREADYINITIALIZED MAKE_DDHRESULT( 5 ) + +/* + * This surface can not be attached to the requested surface. + */ +#define DDERR_CANNOTATTACHSURFACE MAKE_DDHRESULT( 10 ) + +/* + * This surface can not be detached from the requested surface. + */ +#define DDERR_CANNOTDETACHSURFACE MAKE_DDHRESULT( 20 ) + +/* + * Support is currently not available. + */ +#define DDERR_CURRENTLYNOTAVAIL MAKE_DDHRESULT( 40 ) + +/* + * An exception was encountered while performing the requested operation + */ +#define DDERR_EXCEPTION MAKE_DDHRESULT( 55 ) + +/* + * Generic failure. + */ +#define DDERR_GENERIC E_FAIL + +/* + * Height of rectangle provided is not a multiple of reqd alignment + */ +#define DDERR_HEIGHTALIGN MAKE_DDHRESULT( 90 ) + +/* + * Unable to match primary surface creation request with existing + * primary surface. + */ +#define DDERR_INCOMPATIBLEPRIMARY MAKE_DDHRESULT( 95 ) + +/* + * One or more of the caps bits passed to the callback are incorrect. + */ +#define DDERR_INVALIDCAPS MAKE_DDHRESULT( 100 ) + +/* + * DirectDraw does not support provided Cliplist. + */ +#define DDERR_INVALIDCLIPLIST MAKE_DDHRESULT( 110 ) + +/* + * DirectDraw does not support the requested mode + */ +#define DDERR_INVALIDMODE MAKE_DDHRESULT( 120 ) + +/* + * DirectDraw received a pointer that was an invalid DIRECTDRAW object. + */ +#define DDERR_INVALIDOBJECT MAKE_DDHRESULT( 130 ) + +/* + * One or more of the parameters passed to the callback function are + * incorrect. + */ +#define DDERR_INVALIDPARAMS E_INVALIDARG + +/* + * pixel format was invalid as specified + */ +#define DDERR_INVALIDPIXELFORMAT MAKE_DDHRESULT( 145 ) + +/* + * Rectangle provided was invalid. + */ +#define DDERR_INVALIDRECT MAKE_DDHRESULT( 150 ) + +/* + * Operation could not be carried out because one or more surfaces are locked + */ +#define DDERR_LOCKEDSURFACES MAKE_DDHRESULT( 160 ) + +/* + * There is no 3D present. + */ +#define DDERR_NO3D MAKE_DDHRESULT( 170 ) + +/* + * Operation could not be carried out because there is no alpha accleration + * hardware present or available. + */ +#define DDERR_NOALPHAHW MAKE_DDHRESULT( 180 ) + +/* + * Operation could not be carried out because there is no stereo + * hardware present or available. + */ +#define DDERR_NOSTEREOHARDWARE MAKE_DDHRESULT( 181 ) + +/* + * Operation could not be carried out because there is no hardware + * present which supports stereo surfaces + */ +#define DDERR_NOSURFACELEFT MAKE_DDHRESULT( 182 ) + + + +/* + * no clip list available + */ +#define DDERR_NOCLIPLIST MAKE_DDHRESULT( 205 ) + +/* + * Operation could not be carried out because there is no color conversion + * hardware present or available. + */ +#define DDERR_NOCOLORCONVHW MAKE_DDHRESULT( 210 ) + +/* + * Create function called without DirectDraw object method SetCooperativeLevel + * being called. + */ +#define DDERR_NOCOOPERATIVELEVELSET MAKE_DDHRESULT( 212 ) + +/* + * Surface doesn't currently have a color key + */ +#define DDERR_NOCOLORKEY MAKE_DDHRESULT( 215 ) + +/* + * Operation could not be carried out because there is no hardware support + * of the dest color key. + */ +#define DDERR_NOCOLORKEYHW MAKE_DDHRESULT( 220 ) + +/* + * No DirectDraw support possible with current display driver + */ +#define DDERR_NODIRECTDRAWSUPPORT MAKE_DDHRESULT( 222 ) + +/* + * Operation requires the application to have exclusive mode but the + * application does not have exclusive mode. + */ +#define DDERR_NOEXCLUSIVEMODE MAKE_DDHRESULT( 225 ) + +/* + * Flipping visible surfaces is not supported. + */ +#define DDERR_NOFLIPHW MAKE_DDHRESULT( 230 ) + +/* + * There is no GDI present. + */ +#define DDERR_NOGDI MAKE_DDHRESULT( 240 ) + +/* + * Operation could not be carried out because there is no hardware present + * or available. + */ +#define DDERR_NOMIRRORHW MAKE_DDHRESULT( 250 ) + +/* + * Requested item was not found + */ +#define DDERR_NOTFOUND MAKE_DDHRESULT( 255 ) + +/* + * Operation could not be carried out because there is no overlay hardware + * present or available. + */ +#define DDERR_NOOVERLAYHW MAKE_DDHRESULT( 260 ) + +/* + * Operation could not be carried out because the source and destination + * rectangles are on the same surface and overlap each other. + */ +#define DDERR_OVERLAPPINGRECTS MAKE_DDHRESULT( 270 ) + +/* + * Operation could not be carried out because there is no appropriate raster + * op hardware present or available. + */ +#define DDERR_NORASTEROPHW MAKE_DDHRESULT( 280 ) + +/* + * Operation could not be carried out because there is no rotation hardware + * present or available. + */ +#define DDERR_NOROTATIONHW MAKE_DDHRESULT( 290 ) + +/* + * Operation could not be carried out because there is no hardware support + * for stretching + */ +#define DDERR_NOSTRETCHHW MAKE_DDHRESULT( 310 ) + +/* + * DirectDrawSurface is not in 4 bit color palette and the requested operation + * requires 4 bit color palette. + */ +#define DDERR_NOT4BITCOLOR MAKE_DDHRESULT( 316 ) + +/* + * DirectDrawSurface is not in 4 bit color index palette and the requested + * operation requires 4 bit color index palette. + */ +#define DDERR_NOT4BITCOLORINDEX MAKE_DDHRESULT( 317 ) + +/* + * DirectDraw Surface is not in 8 bit color mode and the requested operation + * requires 8 bit color. + */ +#define DDERR_NOT8BITCOLOR MAKE_DDHRESULT( 320 ) + +/* + * Operation could not be carried out because there is no texture mapping + * hardware present or available. + */ +#define DDERR_NOTEXTUREHW MAKE_DDHRESULT( 330 ) + +/* + * Operation could not be carried out because there is no hardware support + * for vertical blank synchronized operations. + */ +#define DDERR_NOVSYNCHW MAKE_DDHRESULT( 335 ) + +/* + * Operation could not be carried out because there is no hardware support + * for zbuffer blting. + */ +#define DDERR_NOZBUFFERHW MAKE_DDHRESULT( 340 ) + +/* + * Overlay surfaces could not be z layered based on their BltOrder because + * the hardware does not support z layering of overlays. + */ +#define DDERR_NOZOVERLAYHW MAKE_DDHRESULT( 350 ) + +/* + * The hardware needed for the requested operation has already been + * allocated. + */ +#define DDERR_OUTOFCAPS MAKE_DDHRESULT( 360 ) + +/* + * DirectDraw does not have enough memory to perform the operation. + */ +#define DDERR_OUTOFMEMORY E_OUTOFMEMORY + +/* + * DirectDraw does not have enough memory to perform the operation. + */ +#define DDERR_OUTOFVIDEOMEMORY MAKE_DDHRESULT( 380 ) + +/* + * hardware does not support clipped overlays + */ +#define DDERR_OVERLAYCANTCLIP MAKE_DDHRESULT( 382 ) + +/* + * Can only have ony color key active at one time for overlays + */ +#define DDERR_OVERLAYCOLORKEYONLYONEACTIVE MAKE_DDHRESULT( 384 ) + +/* + * Access to this palette is being refused because the palette is already + * locked by another thread. + */ +#define DDERR_PALETTEBUSY MAKE_DDHRESULT( 387 ) + +/* + * No src color key specified for this operation. + */ +#define DDERR_COLORKEYNOTSET MAKE_DDHRESULT( 400 ) + +/* + * This surface is already attached to the surface it is being attached to. + */ +#define DDERR_SURFACEALREADYATTACHED MAKE_DDHRESULT( 410 ) + +/* + * This surface is already a dependency of the surface it is being made a + * dependency of. + */ +#define DDERR_SURFACEALREADYDEPENDENT MAKE_DDHRESULT( 420 ) + +/* + * Access to this surface is being refused because the surface is already + * locked by another thread. + */ +#define DDERR_SURFACEBUSY MAKE_DDHRESULT( 430 ) + +/* + * Access to this surface is being refused because no driver exists + * which can supply a pointer to the surface. + * This is most likely to happen when attempting to lock the primary + * surface when no DCI provider is present. + * Will also happen on attempts to lock an optimized surface. + */ +#define DDERR_CANTLOCKSURFACE MAKE_DDHRESULT( 435 ) + +/* + * Access to Surface refused because Surface is obscured. + */ +#define DDERR_SURFACEISOBSCURED MAKE_DDHRESULT( 440 ) + +/* + * Access to this surface is being refused because the surface is gone. + * The DIRECTDRAWSURFACE object representing this surface should + * have Restore called on it. + */ +#define DDERR_SURFACELOST MAKE_DDHRESULT( 450 ) + +/* + * The requested surface is not attached. + */ +#define DDERR_SURFACENOTATTACHED MAKE_DDHRESULT( 460 ) + +/* + * Height requested by DirectDraw is too large. + */ +#define DDERR_TOOBIGHEIGHT MAKE_DDHRESULT( 470 ) + +/* + * Size requested by DirectDraw is too large -- The individual height and + * width are OK. + */ +#define DDERR_TOOBIGSIZE MAKE_DDHRESULT( 480 ) + +/* + * Width requested by DirectDraw is too large. + */ +#define DDERR_TOOBIGWIDTH MAKE_DDHRESULT( 490 ) + +/* + * Action not supported. + */ +#define DDERR_UNSUPPORTED E_NOTIMPL + +/* + * Pixel format requested is unsupported by DirectDraw + */ +#define DDERR_UNSUPPORTEDFORMAT MAKE_DDHRESULT( 510 ) + +/* + * Bitmask in the pixel format requested is unsupported by DirectDraw + */ +#define DDERR_UNSUPPORTEDMASK MAKE_DDHRESULT( 520 ) + +/* + * The specified stream contains invalid data + */ +#define DDERR_INVALIDSTREAM MAKE_DDHRESULT( 521 ) + +/* + * vertical blank is in progress + */ +#define DDERR_VERTICALBLANKINPROGRESS MAKE_DDHRESULT( 537 ) + +/* + * Informs DirectDraw that the previous Blt which is transfering information + * to or from this Surface is incomplete. + */ +#define DDERR_WASSTILLDRAWING MAKE_DDHRESULT( 540 ) + + +/* + * The specified surface type requires specification of the COMPLEX flag + */ +#define DDERR_DDSCAPSCOMPLEXREQUIRED MAKE_DDHRESULT( 542 ) + + +/* + * Rectangle provided was not horizontally aligned on reqd. boundary + */ +#define DDERR_XALIGN MAKE_DDHRESULT( 560 ) + +/* + * The GUID passed to DirectDrawCreate is not a valid DirectDraw driver + * identifier. + */ +#define DDERR_INVALIDDIRECTDRAWGUID MAKE_DDHRESULT( 561 ) + +/* + * A DirectDraw object representing this driver has already been created + * for this process. + */ +#define DDERR_DIRECTDRAWALREADYCREATED MAKE_DDHRESULT( 562 ) + +/* + * A hardware only DirectDraw object creation was attempted but the driver + * did not support any hardware. + */ +#define DDERR_NODIRECTDRAWHW MAKE_DDHRESULT( 563 ) + +/* + * this process already has created a primary surface + */ +#define DDERR_PRIMARYSURFACEALREADYEXISTS MAKE_DDHRESULT( 564 ) + +/* + * software emulation not available. + */ +#define DDERR_NOEMULATION MAKE_DDHRESULT( 565 ) + +/* + * region passed to Clipper::GetClipList is too small. + */ +#define DDERR_REGIONTOOSMALL MAKE_DDHRESULT( 566 ) + +/* + * an attempt was made to set a clip list for a clipper objec that + * is already monitoring an hwnd. + */ +#define DDERR_CLIPPERISUSINGHWND MAKE_DDHRESULT( 567 ) + +/* + * No clipper object attached to surface object + */ +#define DDERR_NOCLIPPERATTACHED MAKE_DDHRESULT( 568 ) + +/* + * Clipper notification requires an HWND or + * no HWND has previously been set as the CooperativeLevel HWND. + */ +#define DDERR_NOHWND MAKE_DDHRESULT( 569 ) + +/* + * HWND used by DirectDraw CooperativeLevel has been subclassed, + * this prevents DirectDraw from restoring state. + */ +#define DDERR_HWNDSUBCLASSED MAKE_DDHRESULT( 570 ) + +/* + * The CooperativeLevel HWND has already been set. + * It can not be reset while the process has surfaces or palettes created. + */ +#define DDERR_HWNDALREADYSET MAKE_DDHRESULT( 571 ) + +/* + * No palette object attached to this surface. + */ +#define DDERR_NOPALETTEATTACHED MAKE_DDHRESULT( 572 ) + +/* + * No hardware support for 16 or 256 color palettes. + */ +#define DDERR_NOPALETTEHW MAKE_DDHRESULT( 573 ) + +/* + * If a clipper object is attached to the source surface passed into a + * BltFast call. + */ +#define DDERR_BLTFASTCANTCLIP MAKE_DDHRESULT( 574 ) + +/* + * No blter. + */ +#define DDERR_NOBLTHW MAKE_DDHRESULT( 575 ) + +/* + * No DirectDraw ROP hardware. + */ +#define DDERR_NODDROPSHW MAKE_DDHRESULT( 576 ) + +/* + * returned when GetOverlayPosition is called on a hidden overlay + */ +#define DDERR_OVERLAYNOTVISIBLE MAKE_DDHRESULT( 577 ) + +/* + * returned when GetOverlayPosition is called on a overlay that UpdateOverlay + * has never been called on to establish a destionation. + */ +#define DDERR_NOOVERLAYDEST MAKE_DDHRESULT( 578 ) + +/* + * returned when the position of the overlay on the destionation is no longer + * legal for that destionation. + */ +#define DDERR_INVALIDPOSITION MAKE_DDHRESULT( 579 ) + +/* + * returned when an overlay member is called for a non-overlay surface + */ +#define DDERR_NOTAOVERLAYSURFACE MAKE_DDHRESULT( 580 ) + +/* + * An attempt was made to set the cooperative level when it was already + * set to exclusive. + */ +#define DDERR_EXCLUSIVEMODEALREADYSET MAKE_DDHRESULT( 581 ) + +/* + * An attempt has been made to flip a surface that is not flippable. + */ +#define DDERR_NOTFLIPPABLE MAKE_DDHRESULT( 582 ) + +/* + * Can't duplicate primary & 3D surfaces, or surfaces that are implicitly + * created. + */ +#define DDERR_CANTDUPLICATE MAKE_DDHRESULT( 583 ) + +/* + * Surface was not locked. An attempt to unlock a surface that was not + * locked at all, or by this process, has been attempted. + */ +#define DDERR_NOTLOCKED MAKE_DDHRESULT( 584 ) + +/* + * Windows can not create any more DCs, or a DC was requested for a paltte-indexed + * surface when the surface had no palette AND the display mode was not palette-indexed + * (in this case DirectDraw cannot select a proper palette into the DC) + */ +#define DDERR_CANTCREATEDC MAKE_DDHRESULT( 585 ) + +/* + * No DC was ever created for this surface. + */ +#define DDERR_NODC MAKE_DDHRESULT( 586 ) + +/* + * This surface can not be restored because it was created in a different + * mode. + */ +#define DDERR_WRONGMODE MAKE_DDHRESULT( 587 ) + +/* + * This surface can not be restored because it is an implicitly created + * surface. + */ +#define DDERR_IMPLICITLYCREATED MAKE_DDHRESULT( 588 ) + +/* + * The surface being used is not a palette-based surface + */ +#define DDERR_NOTPALETTIZED MAKE_DDHRESULT( 589 ) + + +/* + * The display is currently in an unsupported mode + */ +#define DDERR_UNSUPPORTEDMODE MAKE_DDHRESULT( 590 ) + +/* + * Operation could not be carried out because there is no mip-map + * texture mapping hardware present or available. + */ +#define DDERR_NOMIPMAPHW MAKE_DDHRESULT( 591 ) + +/* + * The requested action could not be performed because the surface was of + * the wrong type. + */ +#define DDERR_INVALIDSURFACETYPE MAKE_DDHRESULT( 592 ) + + +/* + * Device does not support optimized surfaces, therefore no video memory optimized surfaces + */ +#define DDERR_NOOPTIMIZEHW MAKE_DDHRESULT( 600 ) + +/* + * Surface is an optimized surface, but has not yet been allocated any memory + */ +#define DDERR_NOTLOADED MAKE_DDHRESULT( 601 ) + +/* + * Attempt was made to create or set a device window without first setting + * the focus window + */ +#define DDERR_NOFOCUSWINDOW MAKE_DDHRESULT( 602 ) + +/* + * Attempt was made to set a palette on a mipmap sublevel + */ +#define DDERR_NOTONMIPMAPSUBLEVEL MAKE_DDHRESULT( 603 ) + +/* + * A DC has already been returned for this surface. Only one DC can be + * retrieved per surface. + */ +#define DDERR_DCALREADYCREATED MAKE_DDHRESULT( 620 ) + +/* + * An attempt was made to allocate non-local video memory from a device + * that does not support non-local video memory. + */ +#define DDERR_NONONLOCALVIDMEM MAKE_DDHRESULT( 630 ) + +/* + * The attempt to page lock a surface failed. + */ +#define DDERR_CANTPAGELOCK MAKE_DDHRESULT( 640 ) + + +/* + * The attempt to page unlock a surface failed. + */ +#define DDERR_CANTPAGEUNLOCK MAKE_DDHRESULT( 660 ) + +/* + * An attempt was made to page unlock a surface with no outstanding page locks. + */ +#define DDERR_NOTPAGELOCKED MAKE_DDHRESULT( 680 ) + +/* + * There is more data available than the specified buffer size could hold + */ +#define DDERR_MOREDATA MAKE_DDHRESULT( 690 ) + +/* + * The data has expired and is therefore no longer valid. + */ +#define DDERR_EXPIRED MAKE_DDHRESULT( 691 ) + +/* + * The mode test has finished executing. + */ +#define DDERR_TESTFINISHED MAKE_DDHRESULT( 692 ) + +/* + * The mode test has switched to a new mode. + */ +#define DDERR_NEWMODE MAKE_DDHRESULT( 693 ) + +/* + * D3D has not yet been initialized. + */ +#define DDERR_D3DNOTINITIALIZED MAKE_DDHRESULT( 694 ) + +/* + * The video port is not active + */ +#define DDERR_VIDEONOTACTIVE MAKE_DDHRESULT( 695 ) + +/* + * The monitor does not have EDID data. + */ +#define DDERR_NOMONITORINFORMATION MAKE_DDHRESULT( 696 ) + +/* + * The driver does not enumerate display mode refresh rates. + */ +#define DDERR_NODRIVERSUPPORT MAKE_DDHRESULT( 697 ) + +/* + * Surfaces created by one direct draw device cannot be used directly by + * another direct draw device. + */ +#define DDERR_DEVICEDOESNTOWNSURFACE MAKE_DDHRESULT( 699 ) + + + +/* + * An attempt was made to invoke an interface member of a DirectDraw object + * created by CoCreateInstance() before it was initialized. + */ +#define DDERR_NOTINITIALIZED CO_E_NOTINITIALIZED + + +/* Alpha bit depth constants */ + + +#ifdef __cplusplus +}; +#endif + +#ifdef ENABLE_NAMELESS_UNION_PRAGMA +#pragma warning(default:4201) +#endif + +#endif //__DDRAW_INCLUDED__ + + diff --git a/desmume/src/windows/directx/ddraw.lib b/src/windows/directx/ddraw.lib similarity index 100% rename from desmume/src/windows/directx/ddraw.lib rename to src/windows/directx/ddraw.lib diff --git a/desmume/src/windows/directx/dinput.h b/src/windows/directx/dinput.h similarity index 98% rename from desmume/src/windows/directx/dinput.h rename to src/windows/directx/dinput.h index 5aac25638..bf74e163c 100644 --- a/desmume/src/windows/directx/dinput.h +++ b/src/windows/directx/dinput.h @@ -1,4417 +1,4417 @@ -/**************************************************************************** - * - * Copyright (C) 1996-2000 Microsoft Corporation. All Rights Reserved. - * - * File: dinput.h - * Content: DirectInput include file - * - ****************************************************************************/ - -#ifndef __DINPUT_INCLUDED__ -#define __DINPUT_INCLUDED__ - -#ifndef DIJ_RINGZERO - -#ifdef _WIN32 -#define COM_NO_WINDOWS_H -#include -#endif - -#endif /* DIJ_RINGZERO */ - -#ifdef __cplusplus -extern "C" { -#endif - - - - - -/* - * To build applications for older versions of DirectInput - * - * #define DIRECTINPUT_VERSION [ 0x0300 | 0x0500 | 0x0700 ] - * - * before #include . By default, #include - * will produce a DirectX 8-compatible header file. - * - */ - -#define DIRECTINPUT_HEADER_VERSION 0x0800 -#ifndef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION DIRECTINPUT_HEADER_VERSION -#pragma message(__FILE__ ": DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800") -#endif - -#ifndef DIJ_RINGZERO - -/**************************************************************************** - * - * Class IDs - * - ****************************************************************************/ - -DEFINE_GUID(CLSID_DirectInput, 0x25E609E0,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(CLSID_DirectInputDevice, 0x25E609E1,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -DEFINE_GUID(CLSID_DirectInput8, 0x25E609E4,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(CLSID_DirectInputDevice8,0x25E609E5,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -/**************************************************************************** - * - * Interfaces - * - ****************************************************************************/ - -DEFINE_GUID(IID_IDirectInputA, 0x89521360,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputW, 0x89521361,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInput2A, 0x5944E662,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInput2W, 0x5944E663,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInput7A, 0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInput7W, 0x9A4CB685,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInput8A, 0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); -DEFINE_GUID(IID_IDirectInput8W, 0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); -DEFINE_GUID(IID_IDirectInputDeviceA, 0x5944E680,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDeviceW, 0x5944E681,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDevice2A,0x5944E682,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDevice2W,0x5944E683,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(IID_IDirectInputDevice7A,0x57D7C6BC,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInputDevice7W,0x57D7C6BD,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); -DEFINE_GUID(IID_IDirectInputDevice8A,0x54D41080,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); -DEFINE_GUID(IID_IDirectInputDevice8W,0x54D41081,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); -DEFINE_GUID(IID_IDirectInputEffect, 0xE7E1F7C0,0x88D2,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); - -/**************************************************************************** - * - * Predefined object types - * - ****************************************************************************/ - -DEFINE_GUID(GUID_XAxis, 0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_YAxis, 0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_ZAxis, 0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_RxAxis, 0xA36D02F4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_RyAxis, 0xA36D02F5,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_RzAxis, 0xA36D02E3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Slider, 0xA36D02E4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -DEFINE_GUID(GUID_Button, 0xA36D02F0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Key, 0x55728220,0xD33C,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -DEFINE_GUID(GUID_POV, 0xA36D02F2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -DEFINE_GUID(GUID_Unknown, 0xA36D02F3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -/**************************************************************************** - * - * Predefined product GUIDs - * - ****************************************************************************/ - -DEFINE_GUID(GUID_SysMouse, 0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysKeyboard,0x6F1D2B61,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_Joystick ,0x6F1D2B70,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysMouseEm, 0x6F1D2B80,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysMouseEm2,0x6F1D2B81,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysKeyboardEm, 0x6F1D2B82,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); -DEFINE_GUID(GUID_SysKeyboardEm2,0x6F1D2B83,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); - -/**************************************************************************** - * - * Predefined force feedback effects - * - ****************************************************************************/ - -DEFINE_GUID(GUID_ConstantForce, 0x13541C20,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_RampForce, 0x13541C21,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Square, 0x13541C22,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Sine, 0x13541C23,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Triangle, 0x13541C24,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_SawtoothUp, 0x13541C25,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_SawtoothDown, 0x13541C26,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Spring, 0x13541C27,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Damper, 0x13541C28,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Inertia, 0x13541C29,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_Friction, 0x13541C2A,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); -DEFINE_GUID(GUID_CustomForce, 0x13541C2B,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); - -#endif /* DIJ_RINGZERO */ - -/**************************************************************************** - * - * Interfaces and Structures... - * - ****************************************************************************/ - -#if(DIRECTINPUT_VERSION >= 0x0500) - -/**************************************************************************** - * - * IDirectInputEffect - * - ****************************************************************************/ - -#define DIEFT_ALL 0x00000000 - -#define DIEFT_CONSTANTFORCE 0x00000001 -#define DIEFT_RAMPFORCE 0x00000002 -#define DIEFT_PERIODIC 0x00000003 -#define DIEFT_CONDITION 0x00000004 -#define DIEFT_CUSTOMFORCE 0x00000005 -#define DIEFT_HARDWARE 0x000000FF -#define DIEFT_FFATTACK 0x00000200 -#define DIEFT_FFFADE 0x00000400 -#define DIEFT_SATURATION 0x00000800 -#define DIEFT_POSNEGCOEFFICIENTS 0x00001000 -#define DIEFT_POSNEGSATURATION 0x00002000 -#define DIEFT_DEADBAND 0x00004000 -#define DIEFT_STARTDELAY 0x00008000 -#define DIEFT_GETTYPE(n) LOBYTE(n) - -#define DI_DEGREES 100 -#define DI_FFNOMINALMAX 10000 -#define DI_SECONDS 1000000 - -typedef struct DICONSTANTFORCE { - LONG lMagnitude; -} DICONSTANTFORCE, *LPDICONSTANTFORCE; -typedef const DICONSTANTFORCE *LPCDICONSTANTFORCE; - -typedef struct DIRAMPFORCE { - LONG lStart; - LONG lEnd; -} DIRAMPFORCE, *LPDIRAMPFORCE; -typedef const DIRAMPFORCE *LPCDIRAMPFORCE; - -typedef struct DIPERIODIC { - DWORD dwMagnitude; - LONG lOffset; - DWORD dwPhase; - DWORD dwPeriod; -} DIPERIODIC, *LPDIPERIODIC; -typedef const DIPERIODIC *LPCDIPERIODIC; - -typedef struct DICONDITION { - LONG lOffset; - LONG lPositiveCoefficient; - LONG lNegativeCoefficient; - DWORD dwPositiveSaturation; - DWORD dwNegativeSaturation; - LONG lDeadBand; -} DICONDITION, *LPDICONDITION; -typedef const DICONDITION *LPCDICONDITION; - -typedef struct DICUSTOMFORCE { - DWORD cChannels; - DWORD dwSamplePeriod; - DWORD cSamples; - LPLONG rglForceData; -} DICUSTOMFORCE, *LPDICUSTOMFORCE; -typedef const DICUSTOMFORCE *LPCDICUSTOMFORCE; - - -typedef struct DIENVELOPE { - DWORD dwSize; /* sizeof(DIENVELOPE) */ - DWORD dwAttackLevel; - DWORD dwAttackTime; /* Microseconds */ - DWORD dwFadeLevel; - DWORD dwFadeTime; /* Microseconds */ -} DIENVELOPE, *LPDIENVELOPE; -typedef const DIENVELOPE *LPCDIENVELOPE; - - -/* This structure is defined for DirectX 5.0 compatibility */ -typedef struct DIEFFECT_DX5 { - DWORD dwSize; /* sizeof(DIEFFECT_DX5) */ - DWORD dwFlags; /* DIEFF_* */ - DWORD dwDuration; /* Microseconds */ - DWORD dwSamplePeriod; /* Microseconds */ - DWORD dwGain; - DWORD dwTriggerButton; /* or DIEB_NOTRIGGER */ - DWORD dwTriggerRepeatInterval; /* Microseconds */ - DWORD cAxes; /* Number of axes */ - LPDWORD rgdwAxes; /* Array of axes */ - LPLONG rglDirection; /* Array of directions */ - LPDIENVELOPE lpEnvelope; /* Optional */ - DWORD cbTypeSpecificParams; /* Size of params */ - LPVOID lpvTypeSpecificParams; /* Pointer to params */ -} DIEFFECT_DX5, *LPDIEFFECT_DX5; -typedef const DIEFFECT_DX5 *LPCDIEFFECT_DX5; - -typedef struct DIEFFECT { - DWORD dwSize; /* sizeof(DIEFFECT) */ - DWORD dwFlags; /* DIEFF_* */ - DWORD dwDuration; /* Microseconds */ - DWORD dwSamplePeriod; /* Microseconds */ - DWORD dwGain; - DWORD dwTriggerButton; /* or DIEB_NOTRIGGER */ - DWORD dwTriggerRepeatInterval; /* Microseconds */ - DWORD cAxes; /* Number of axes */ - LPDWORD rgdwAxes; /* Array of axes */ - LPLONG rglDirection; /* Array of directions */ - LPDIENVELOPE lpEnvelope; /* Optional */ - DWORD cbTypeSpecificParams; /* Size of params */ - LPVOID lpvTypeSpecificParams; /* Pointer to params */ -#if(DIRECTINPUT_VERSION >= 0x0600) - DWORD dwStartDelay; /* Microseconds */ -#endif /* DIRECTINPUT_VERSION >= 0x0600 */ -} DIEFFECT, *LPDIEFFECT; -typedef DIEFFECT DIEFFECT_DX6; -typedef LPDIEFFECT LPDIEFFECT_DX6; -typedef const DIEFFECT *LPCDIEFFECT; - - -#if(DIRECTINPUT_VERSION >= 0x0700) -#ifndef DIJ_RINGZERO -typedef struct DIFILEEFFECT{ - DWORD dwSize; - GUID GuidEffect; - LPCDIEFFECT lpDiEffect; - CHAR szFriendlyName[MAX_PATH]; -}DIFILEEFFECT, *LPDIFILEEFFECT; -typedef const DIFILEEFFECT *LPCDIFILEEFFECT; -typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSINFILECALLBACK)(LPCDIFILEEFFECT , LPVOID); -#endif /* DIJ_RINGZERO */ -#endif /* DIRECTINPUT_VERSION >= 0x0700 */ - -#define DIEFF_OBJECTIDS 0x00000001 -#define DIEFF_OBJECTOFFSETS 0x00000002 -#define DIEFF_CARTESIAN 0x00000010 -#define DIEFF_POLAR 0x00000020 -#define DIEFF_SPHERICAL 0x00000040 - -#define DIEP_DURATION 0x00000001 -#define DIEP_SAMPLEPERIOD 0x00000002 -#define DIEP_GAIN 0x00000004 -#define DIEP_TRIGGERBUTTON 0x00000008 -#define DIEP_TRIGGERREPEATINTERVAL 0x00000010 -#define DIEP_AXES 0x00000020 -#define DIEP_DIRECTION 0x00000040 -#define DIEP_ENVELOPE 0x00000080 -#define DIEP_TYPESPECIFICPARAMS 0x00000100 -#if(DIRECTINPUT_VERSION >= 0x0600) -#define DIEP_STARTDELAY 0x00000200 -#define DIEP_ALLPARAMS_DX5 0x000001FF -#define DIEP_ALLPARAMS 0x000003FF -#else /* DIRECTINPUT_VERSION < 0x0600 */ -#define DIEP_ALLPARAMS 0x000001FF -#endif /* DIRECTINPUT_VERSION < 0x0600 */ -#define DIEP_START 0x20000000 -#define DIEP_NORESTART 0x40000000 -#define DIEP_NODOWNLOAD 0x80000000 -#define DIEB_NOTRIGGER 0xFFFFFFFF - -#define DIES_SOLO 0x00000001 -#define DIES_NODOWNLOAD 0x80000000 - -#define DIEGES_PLAYING 0x00000001 -#define DIEGES_EMULATED 0x00000002 - -typedef struct DIEFFESCAPE { - DWORD dwSize; - DWORD dwCommand; - LPVOID lpvInBuffer; - DWORD cbInBuffer; - LPVOID lpvOutBuffer; - DWORD cbOutBuffer; -} DIEFFESCAPE, *LPDIEFFESCAPE; - -#ifndef DIJ_RINGZERO - -#undef INTERFACE -#define INTERFACE IDirectInputEffect - -DECLARE_INTERFACE_(IDirectInputEffect, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputEffect methods ***/ - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - STDMETHOD(GetEffectGuid)(THIS_ LPGUID) PURE; - STDMETHOD(GetParameters)(THIS_ LPDIEFFECT,DWORD) PURE; - STDMETHOD(SetParameters)(THIS_ LPCDIEFFECT,DWORD) PURE; - STDMETHOD(Start)(THIS_ DWORD,DWORD) PURE; - STDMETHOD(Stop)(THIS) PURE; - STDMETHOD(GetEffectStatus)(THIS_ LPDWORD) PURE; - STDMETHOD(Download)(THIS) PURE; - STDMETHOD(Unload)(THIS) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; -}; - -typedef struct IDirectInputEffect *LPDIRECTINPUTEFFECT; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputEffect_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputEffect_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputEffect_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputEffect_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectInputEffect_GetEffectGuid(p,a) (p)->lpVtbl->GetEffectGuid(p,a) -#define IDirectInputEffect_GetParameters(p,a,b) (p)->lpVtbl->GetParameters(p,a,b) -#define IDirectInputEffect_SetParameters(p,a,b) (p)->lpVtbl->SetParameters(p,a,b) -#define IDirectInputEffect_Start(p,a,b) (p)->lpVtbl->Start(p,a,b) -#define IDirectInputEffect_Stop(p) (p)->lpVtbl->Stop(p) -#define IDirectInputEffect_GetEffectStatus(p,a) (p)->lpVtbl->GetEffectStatus(p,a) -#define IDirectInputEffect_Download(p) (p)->lpVtbl->Download(p) -#define IDirectInputEffect_Unload(p) (p)->lpVtbl->Unload(p) -#define IDirectInputEffect_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#else -#define IDirectInputEffect_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputEffect_AddRef(p) (p)->AddRef() -#define IDirectInputEffect_Release(p) (p)->Release() -#define IDirectInputEffect_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectInputEffect_GetEffectGuid(p,a) (p)->GetEffectGuid(a) -#define IDirectInputEffect_GetParameters(p,a,b) (p)->GetParameters(a,b) -#define IDirectInputEffect_SetParameters(p,a,b) (p)->SetParameters(a,b) -#define IDirectInputEffect_Start(p,a,b) (p)->Start(a,b) -#define IDirectInputEffect_Stop(p) (p)->Stop() -#define IDirectInputEffect_GetEffectStatus(p,a) (p)->GetEffectStatus(a) -#define IDirectInputEffect_Download(p) (p)->Download() -#define IDirectInputEffect_Unload(p) (p)->Unload() -#define IDirectInputEffect_Escape(p,a) (p)->Escape(a) -#endif - -#endif /* DIJ_RINGZERO */ - -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -/**************************************************************************** - * - * IDirectInputDevice - * - ****************************************************************************/ - -#if DIRECTINPUT_VERSION <= 0x700 -#define DIDEVTYPE_DEVICE 1 -#define DIDEVTYPE_MOUSE 2 -#define DIDEVTYPE_KEYBOARD 3 -#define DIDEVTYPE_JOYSTICK 4 - -#else -#define DI8DEVCLASS_ALL 0 -#define DI8DEVCLASS_DEVICE 1 -#define DI8DEVCLASS_POINTER 2 -#define DI8DEVCLASS_KEYBOARD 3 -#define DI8DEVCLASS_GAMECTRL 4 - -#define DI8DEVTYPE_DEVICE 0x11 -#define DI8DEVTYPE_MOUSE 0x12 -#define DI8DEVTYPE_KEYBOARD 0x13 -#define DI8DEVTYPE_JOYSTICK 0x14 -#define DI8DEVTYPE_GAMEPAD 0x15 -#define DI8DEVTYPE_DRIVING 0x16 -#define DI8DEVTYPE_FLIGHT 0x17 -#define DI8DEVTYPE_1STPERSON 0x18 -#define DI8DEVTYPE_DEVICECTRL 0x19 -#define DI8DEVTYPE_SCREENPOINTER 0x1A -#define DI8DEVTYPE_REMOTE 0x1B -#define DI8DEVTYPE_SUPPLEMENTAL 0x1C -#endif /* DIRECTINPUT_VERSION <= 0x700 */ - -#define DIDEVTYPE_HID 0x00010000 - -#if DIRECTINPUT_VERSION <= 0x700 -#define DIDEVTYPEMOUSE_UNKNOWN 1 -#define DIDEVTYPEMOUSE_TRADITIONAL 2 -#define DIDEVTYPEMOUSE_FINGERSTICK 3 -#define DIDEVTYPEMOUSE_TOUCHPAD 4 -#define DIDEVTYPEMOUSE_TRACKBALL 5 - -#define DIDEVTYPEKEYBOARD_UNKNOWN 0 -#define DIDEVTYPEKEYBOARD_PCXT 1 -#define DIDEVTYPEKEYBOARD_OLIVETTI 2 -#define DIDEVTYPEKEYBOARD_PCAT 3 -#define DIDEVTYPEKEYBOARD_PCENH 4 -#define DIDEVTYPEKEYBOARD_NOKIA1050 5 -#define DIDEVTYPEKEYBOARD_NOKIA9140 6 -#define DIDEVTYPEKEYBOARD_NEC98 7 -#define DIDEVTYPEKEYBOARD_NEC98LAPTOP 8 -#define DIDEVTYPEKEYBOARD_NEC98106 9 -#define DIDEVTYPEKEYBOARD_JAPAN106 10 -#define DIDEVTYPEKEYBOARD_JAPANAX 11 -#define DIDEVTYPEKEYBOARD_J3100 12 - -#define DIDEVTYPEJOYSTICK_UNKNOWN 1 -#define DIDEVTYPEJOYSTICK_TRADITIONAL 2 -#define DIDEVTYPEJOYSTICK_FLIGHTSTICK 3 -#define DIDEVTYPEJOYSTICK_GAMEPAD 4 -#define DIDEVTYPEJOYSTICK_RUDDER 5 -#define DIDEVTYPEJOYSTICK_WHEEL 6 -#define DIDEVTYPEJOYSTICK_HEADTRACKER 7 - -#else -#define DI8DEVTYPEMOUSE_UNKNOWN 1 -#define DI8DEVTYPEMOUSE_TRADITIONAL 2 -#define DI8DEVTYPEMOUSE_FINGERSTICK 3 -#define DI8DEVTYPEMOUSE_TOUCHPAD 4 -#define DI8DEVTYPEMOUSE_TRACKBALL 5 -#define DI8DEVTYPEMOUSE_ABSOLUTE 6 - -#define DI8DEVTYPEKEYBOARD_UNKNOWN 0 -#define DI8DEVTYPEKEYBOARD_PCXT 1 -#define DI8DEVTYPEKEYBOARD_OLIVETTI 2 -#define DI8DEVTYPEKEYBOARD_PCAT 3 -#define DI8DEVTYPEKEYBOARD_PCENH 4 -#define DI8DEVTYPEKEYBOARD_NOKIA1050 5 -#define DI8DEVTYPEKEYBOARD_NOKIA9140 6 -#define DI8DEVTYPEKEYBOARD_NEC98 7 -#define DI8DEVTYPEKEYBOARD_NEC98LAPTOP 8 -#define DI8DEVTYPEKEYBOARD_NEC98106 9 -#define DI8DEVTYPEKEYBOARD_JAPAN106 10 -#define DI8DEVTYPEKEYBOARD_JAPANAX 11 -#define DI8DEVTYPEKEYBOARD_J3100 12 - -#define DI8DEVTYPE_LIMITEDGAMESUBTYPE 1 - -#define DI8DEVTYPEJOYSTICK_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEJOYSTICK_STANDARD 2 - -#define DI8DEVTYPEGAMEPAD_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEGAMEPAD_STANDARD 2 -#define DI8DEVTYPEGAMEPAD_TILT 3 - -#define DI8DEVTYPEDRIVING_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEDRIVING_COMBINEDPEDALS 2 -#define DI8DEVTYPEDRIVING_DUALPEDALS 3 -#define DI8DEVTYPEDRIVING_THREEPEDALS 4 -#define DI8DEVTYPEDRIVING_HANDHELD 5 - -#define DI8DEVTYPEFLIGHT_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPEFLIGHT_STICK 2 -#define DI8DEVTYPEFLIGHT_YOKE 3 -#define DI8DEVTYPEFLIGHT_RC 4 - -#define DI8DEVTYPE1STPERSON_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE -#define DI8DEVTYPE1STPERSON_UNKNOWN 2 -#define DI8DEVTYPE1STPERSON_SIXDOF 3 -#define DI8DEVTYPE1STPERSON_SHOOTER 4 - -#define DI8DEVTYPESCREENPTR_UNKNOWN 2 -#define DI8DEVTYPESCREENPTR_LIGHTGUN 3 -#define DI8DEVTYPESCREENPTR_LIGHTPEN 4 -#define DI8DEVTYPESCREENPTR_TOUCH 5 - -#define DI8DEVTYPEREMOTE_UNKNOWN 2 - -#define DI8DEVTYPEDEVICECTRL_UNKNOWN 2 -#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION 3 -#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED 4 - -#define DI8DEVTYPESUPPLEMENTAL_UNKNOWN 2 -#define DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER 3 -#define DI8DEVTYPESUPPLEMENTAL_HEADTRACKER 4 -#define DI8DEVTYPESUPPLEMENTAL_HANDTRACKER 5 -#define DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE 6 -#define DI8DEVTYPESUPPLEMENTAL_SHIFTER 7 -#define DI8DEVTYPESUPPLEMENTAL_THROTTLE 8 -#define DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE 9 -#define DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS 10 -#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS 11 -#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS 12 -#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS 13 -#endif /* DIRECTINPUT_VERSION <= 0x700 */ - -#define GET_DIDEVICE_TYPE(dwDevType) LOBYTE(dwDevType) -#define GET_DIDEVICE_SUBTYPE(dwDevType) HIBYTE(dwDevType) - -#if(DIRECTINPUT_VERSION >= 0x0500) -/* This structure is defined for DirectX 3.0 compatibility */ -typedef struct DIDEVCAPS_DX3 { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDevType; - DWORD dwAxes; - DWORD dwButtons; - DWORD dwPOVs; -} DIDEVCAPS_DX3, *LPDIDEVCAPS_DX3; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -typedef struct DIDEVCAPS { - DWORD dwSize; - DWORD dwFlags; - DWORD dwDevType; - DWORD dwAxes; - DWORD dwButtons; - DWORD dwPOVs; -#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFSamplePeriod; - DWORD dwFFMinTimeResolution; - DWORD dwFirmwareRevision; - DWORD dwHardwareRevision; - DWORD dwFFDriverVersion; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVCAPS, *LPDIDEVCAPS; - -#define DIDC_ATTACHED 0x00000001 -#define DIDC_POLLEDDEVICE 0x00000002 -#define DIDC_EMULATED 0x00000004 -#define DIDC_POLLEDDATAFORMAT 0x00000008 -#if(DIRECTINPUT_VERSION >= 0x0500) -#define DIDC_FORCEFEEDBACK 0x00000100 -#define DIDC_FFATTACK 0x00000200 -#define DIDC_FFFADE 0x00000400 -#define DIDC_SATURATION 0x00000800 -#define DIDC_POSNEGCOEFFICIENTS 0x00001000 -#define DIDC_POSNEGSATURATION 0x00002000 -#define DIDC_DEADBAND 0x00004000 -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -#define DIDC_STARTDELAY 0x00008000 -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIDC_ALIAS 0x00010000 -#define DIDC_PHANTOM 0x00020000 -#endif /* DIRECTINPUT_VERSION >= 0x050a */ -#if(DIRECTINPUT_VERSION >= 0x0800) -#define DIDC_HIDDEN 0x00040000 -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -#define DIDFT_ALL 0x00000000 - -#define DIDFT_RELAXIS 0x00000001 -#define DIDFT_ABSAXIS 0x00000002 -#define DIDFT_AXIS 0x00000003 - -#define DIDFT_PSHBUTTON 0x00000004 -#define DIDFT_TGLBUTTON 0x00000008 -#define DIDFT_BUTTON 0x0000000C - -#define DIDFT_POV 0x00000010 -#define DIDFT_COLLECTION 0x00000040 -#define DIDFT_NODATA 0x00000080 - -#define DIDFT_ANYINSTANCE 0x00FFFF00 -#define DIDFT_INSTANCEMASK DIDFT_ANYINSTANCE -#define DIDFT_MAKEINSTANCE(n) ((WORD)(n) << 8) -#define DIDFT_GETTYPE(n) LOBYTE(n) -#define DIDFT_GETINSTANCE(n) LOWORD((n) >> 8) -#define DIDFT_FFACTUATOR 0x01000000 -#define DIDFT_FFEFFECTTRIGGER 0x02000000 -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIDFT_OUTPUT 0x10000000 -#define DIDFT_VENDORDEFINED 0x04000000 -#define DIDFT_ALIAS 0x08000000 -#endif /* DIRECTINPUT_VERSION >= 0x050a */ -#ifndef DIDFT_OPTIONAL -#define DIDFT_OPTIONAL 0x80000000 -#endif - -#define DIDFT_ENUMCOLLECTION(n) ((WORD)(n) << 8) -#define DIDFT_NOCOLLECTION 0x00FFFF00 - -#ifndef DIJ_RINGZERO - -typedef struct _DIOBJECTDATAFORMAT { - const GUID *pguid; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; -} DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT; -typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT; - -typedef struct _DIDATAFORMAT { - DWORD dwSize; - DWORD dwObjSize; - DWORD dwFlags; - DWORD dwDataSize; - DWORD dwNumObjs; - LPDIOBJECTDATAFORMAT rgodf; -} DIDATAFORMAT, *LPDIDATAFORMAT; -typedef const DIDATAFORMAT *LPCDIDATAFORMAT; - -#define DIDF_ABSAXIS 0x00000001 -#define DIDF_RELAXIS 0x00000002 - -#ifdef __cplusplus -extern "C" { -#endif -extern const DIDATAFORMAT c_dfDIMouse; - -#if(DIRECTINPUT_VERSION >= 0x0700) -extern const DIDATAFORMAT c_dfDIMouse2; -#endif /* DIRECTINPUT_VERSION >= 0x0700 */ - -extern const DIDATAFORMAT c_dfDIKeyboard; - -#if(DIRECTINPUT_VERSION >= 0x0500) -extern const DIDATAFORMAT c_dfDIJoystick; -extern const DIDATAFORMAT c_dfDIJoystick2; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -#ifdef __cplusplus -}; -#endif - - -#if DIRECTINPUT_VERSION > 0x0700 - -typedef struct _DIACTIONA { - UINT_PTR uAppData; - DWORD dwSemantic; - OPTIONAL DWORD dwFlags; - OPTIONAL union { - LPCSTR lptszActionName; - UINT uResIdString; - }; - OPTIONAL GUID guidInstance; - OPTIONAL DWORD dwObjID; - OPTIONAL DWORD dwHow; -} DIACTIONA, *LPDIACTIONA ; -typedef struct _DIACTIONW { - UINT_PTR uAppData; - DWORD dwSemantic; - OPTIONAL DWORD dwFlags; - OPTIONAL union { - LPCWSTR lptszActionName; - UINT uResIdString; - }; - OPTIONAL GUID guidInstance; - OPTIONAL DWORD dwObjID; - OPTIONAL DWORD dwHow; -} DIACTIONW, *LPDIACTIONW ; -#ifdef UNICODE -typedef DIACTIONW DIACTION; -typedef LPDIACTIONW LPDIACTION; -#else -typedef DIACTIONA DIACTION; -typedef LPDIACTIONA LPDIACTION; -#endif // UNICODE - -typedef const DIACTIONA *LPCDIACTIONA; -typedef const DIACTIONW *LPCDIACTIONW; -#ifdef UNICODE -typedef DIACTIONW DIACTION; -typedef LPCDIACTIONW LPCDIACTION; -#else -typedef DIACTIONA DIACTION; -typedef LPCDIACTIONA LPCDIACTION; -#endif // UNICODE -typedef const DIACTION *LPCDIACTION; - - -#define DIA_FORCEFEEDBACK 0x00000001 -#define DIA_APPMAPPED 0x00000002 -#define DIA_APPNOMAP 0x00000004 -#define DIA_NORANGE 0x00000008 -#define DIA_APPFIXED 0x00000010 - -#define DIAH_UNMAPPED 0x00000000 -#define DIAH_USERCONFIG 0x00000001 -#define DIAH_APPREQUESTED 0x00000002 -#define DIAH_HWAPP 0x00000004 -#define DIAH_HWDEFAULT 0x00000008 -#define DIAH_DEFAULT 0x00000020 -#define DIAH_ERROR 0x80000000 - -typedef struct _DIACTIONFORMATA { - DWORD dwSize; - DWORD dwActionSize; - DWORD dwDataSize; - DWORD dwNumActions; - LPDIACTIONA rgoAction; - GUID guidActionMap; - DWORD dwGenre; - DWORD dwBufferSize; - OPTIONAL LONG lAxisMin; - OPTIONAL LONG lAxisMax; - OPTIONAL HINSTANCE hInstString; - FILETIME ftTimeStamp; - DWORD dwCRC; - CHAR tszActionMap[MAX_PATH]; -} DIACTIONFORMATA, *LPDIACTIONFORMATA; -typedef struct _DIACTIONFORMATW { - DWORD dwSize; - DWORD dwActionSize; - DWORD dwDataSize; - DWORD dwNumActions; - LPDIACTIONW rgoAction; - GUID guidActionMap; - DWORD dwGenre; - DWORD dwBufferSize; - OPTIONAL LONG lAxisMin; - OPTIONAL LONG lAxisMax; - OPTIONAL HINSTANCE hInstString; - FILETIME ftTimeStamp; - DWORD dwCRC; - WCHAR tszActionMap[MAX_PATH]; -} DIACTIONFORMATW, *LPDIACTIONFORMATW; -#ifdef UNICODE -typedef DIACTIONFORMATW DIACTIONFORMAT; -typedef LPDIACTIONFORMATW LPDIACTIONFORMAT; -#else -typedef DIACTIONFORMATA DIACTIONFORMAT; -typedef LPDIACTIONFORMATA LPDIACTIONFORMAT; -#endif // UNICODE -typedef const DIACTIONFORMATA *LPCDIACTIONFORMATA; -typedef const DIACTIONFORMATW *LPCDIACTIONFORMATW; -#ifdef UNICODE -typedef DIACTIONFORMATW DIACTIONFORMAT; -typedef LPCDIACTIONFORMATW LPCDIACTIONFORMAT; -#else -typedef DIACTIONFORMATA DIACTIONFORMAT; -typedef LPCDIACTIONFORMATA LPCDIACTIONFORMAT; -#endif // UNICODE -typedef const DIACTIONFORMAT *LPCDIACTIONFORMAT; - -#define DIAFTS_NEWDEVICELOW 0xFFFFFFFF -#define DIAFTS_NEWDEVICEHIGH 0xFFFFFFFF -#define DIAFTS_UNUSEDDEVICELOW 0x00000000 -#define DIAFTS_UNUSEDDEVICEHIGH 0x00000000 - -#define DIDBAM_DEFAULT 0x00000000 -#define DIDBAM_PRESERVE 0x00000001 -#define DIDBAM_INITIALIZE 0x00000002 -#define DIDBAM_HWDEFAULTS 0x00000004 - -#define DIDSAM_DEFAULT 0x00000000 -#define DIDSAM_NOUSER 0x00000001 -#define DIDSAM_FORCESAVE 0x00000002 - -#define DICD_DEFAULT 0x00000000 -#define DICD_EDIT 0x00000001 - -/* - * The following definition is normally defined in d3dtypes.h - */ -#ifndef D3DCOLOR_DEFINED -typedef DWORD D3DCOLOR; -#define D3DCOLOR_DEFINED -#endif - -typedef struct _DICOLORSET{ - DWORD dwSize; - D3DCOLOR cTextFore; - D3DCOLOR cTextHighlight; - D3DCOLOR cCalloutLine; - D3DCOLOR cCalloutHighlight; - D3DCOLOR cBorder; - D3DCOLOR cControlFill; - D3DCOLOR cHighlightFill; - D3DCOLOR cAreaFill; -} DICOLORSET, *LPDICOLORSET; -typedef const DICOLORSET *LPCDICOLORSET; - - -typedef struct _DICONFIGUREDEVICESPARAMSA{ - DWORD dwSize; - DWORD dwcUsers; - LPSTR lptszUserNames; - DWORD dwcFormats; - LPDIACTIONFORMATA lprgFormats; - HWND hwnd; - DICOLORSET dics; - IUnknown FAR * lpUnkDDSTarget; -} DICONFIGUREDEVICESPARAMSA, *LPDICONFIGUREDEVICESPARAMSA; -typedef struct _DICONFIGUREDEVICESPARAMSW{ - DWORD dwSize; - DWORD dwcUsers; - LPWSTR lptszUserNames; - DWORD dwcFormats; - LPDIACTIONFORMATW lprgFormats; - HWND hwnd; - DICOLORSET dics; - IUnknown FAR * lpUnkDDSTarget; -} DICONFIGUREDEVICESPARAMSW, *LPDICONFIGUREDEVICESPARAMSW; -#ifdef UNICODE -typedef DICONFIGUREDEVICESPARAMSW DICONFIGUREDEVICESPARAMS; -typedef LPDICONFIGUREDEVICESPARAMSW LPDICONFIGUREDEVICESPARAMS; -#else -typedef DICONFIGUREDEVICESPARAMSA DICONFIGUREDEVICESPARAMS; -typedef LPDICONFIGUREDEVICESPARAMSA LPDICONFIGUREDEVICESPARAMS; -#endif // UNICODE -typedef const DICONFIGUREDEVICESPARAMSA *LPCDICONFIGUREDEVICESPARAMSA; -typedef const DICONFIGUREDEVICESPARAMSW *LPCDICONFIGUREDEVICESPARAMSW; -#ifdef UNICODE -typedef DICONFIGUREDEVICESPARAMSW DICONFIGUREDEVICESPARAMS; -typedef LPCDICONFIGUREDEVICESPARAMSW LPCDICONFIGUREDEVICESPARAMS; -#else -typedef DICONFIGUREDEVICESPARAMSA DICONFIGUREDEVICESPARAMS; -typedef LPCDICONFIGUREDEVICESPARAMSA LPCDICONFIGUREDEVICESPARAMS; -#endif // UNICODE -typedef const DICONFIGUREDEVICESPARAMS *LPCDICONFIGUREDEVICESPARAMS; - - -#define DIDIFT_CONFIGURATION 0x00000001 -#define DIDIFT_OVERLAY 0x00000002 - -#define DIDAL_CENTERED 0x00000000 -#define DIDAL_LEFTALIGNED 0x00000001 -#define DIDAL_RIGHTALIGNED 0x00000002 -#define DIDAL_MIDDLE 0x00000000 -#define DIDAL_TOPALIGNED 0x00000004 -#define DIDAL_BOTTOMALIGNED 0x00000008 - -typedef struct _DIDEVICEIMAGEINFOA { - CHAR tszImagePath[MAX_PATH]; - DWORD dwFlags; - // These are valid if DIDIFT_OVERLAY is present in dwFlags. - DWORD dwViewID; - RECT rcOverlay; - DWORD dwObjID; - DWORD dwcValidPts; - POINT rgptCalloutLine[5]; - RECT rcCalloutRect; - DWORD dwTextAlign; -} DIDEVICEIMAGEINFOA, *LPDIDEVICEIMAGEINFOA; -typedef struct _DIDEVICEIMAGEINFOW { - WCHAR tszImagePath[MAX_PATH]; - DWORD dwFlags; - // These are valid if DIDIFT_OVERLAY is present in dwFlags. - DWORD dwViewID; - RECT rcOverlay; - DWORD dwObjID; - DWORD dwcValidPts; - POINT rgptCalloutLine[5]; - RECT rcCalloutRect; - DWORD dwTextAlign; -} DIDEVICEIMAGEINFOW, *LPDIDEVICEIMAGEINFOW; -#ifdef UNICODE -typedef DIDEVICEIMAGEINFOW DIDEVICEIMAGEINFO; -typedef LPDIDEVICEIMAGEINFOW LPDIDEVICEIMAGEINFO; -#else -typedef DIDEVICEIMAGEINFOA DIDEVICEIMAGEINFO; -typedef LPDIDEVICEIMAGEINFOA LPDIDEVICEIMAGEINFO; -#endif // UNICODE -typedef const DIDEVICEIMAGEINFOA *LPCDIDEVICEIMAGEINFOA; -typedef const DIDEVICEIMAGEINFOW *LPCDIDEVICEIMAGEINFOW; -#ifdef UNICODE -typedef DIDEVICEIMAGEINFOW DIDEVICEIMAGEINFO; -typedef LPCDIDEVICEIMAGEINFOW LPCDIDEVICEIMAGEINFO; -#else -typedef DIDEVICEIMAGEINFOA DIDEVICEIMAGEINFO; -typedef LPCDIDEVICEIMAGEINFOA LPCDIDEVICEIMAGEINFO; -#endif // UNICODE -typedef const DIDEVICEIMAGEINFO *LPCDIDEVICEIMAGEINFO; - -typedef struct _DIDEVICEIMAGEINFOHEADERA { - DWORD dwSize; - DWORD dwSizeImageInfo; - DWORD dwcViews; - DWORD dwcButtons; - DWORD dwcAxes; - DWORD dwcPOVs; - DWORD dwBufferSize; - DWORD dwBufferUsed; - LPDIDEVICEIMAGEINFOA lprgImageInfoArray; -} DIDEVICEIMAGEINFOHEADERA, *LPDIDEVICEIMAGEINFOHEADERA; -typedef struct _DIDEVICEIMAGEINFOHEADERW { - DWORD dwSize; - DWORD dwSizeImageInfo; - DWORD dwcViews; - DWORD dwcButtons; - DWORD dwcAxes; - DWORD dwcPOVs; - DWORD dwBufferSize; - DWORD dwBufferUsed; - LPDIDEVICEIMAGEINFOW lprgImageInfoArray; -} DIDEVICEIMAGEINFOHEADERW, *LPDIDEVICEIMAGEINFOHEADERW; -#ifdef UNICODE -typedef DIDEVICEIMAGEINFOHEADERW DIDEVICEIMAGEINFOHEADER; -typedef LPDIDEVICEIMAGEINFOHEADERW LPDIDEVICEIMAGEINFOHEADER; -#else -typedef DIDEVICEIMAGEINFOHEADERA DIDEVICEIMAGEINFOHEADER; -typedef LPDIDEVICEIMAGEINFOHEADERA LPDIDEVICEIMAGEINFOHEADER; -#endif // UNICODE -typedef const DIDEVICEIMAGEINFOHEADERA *LPCDIDEVICEIMAGEINFOHEADERA; -typedef const DIDEVICEIMAGEINFOHEADERW *LPCDIDEVICEIMAGEINFOHEADERW; -#ifdef UNICODE -typedef DIDEVICEIMAGEINFOHEADERW DIDEVICEIMAGEINFOHEADER; -typedef LPCDIDEVICEIMAGEINFOHEADERW LPCDIDEVICEIMAGEINFOHEADER; -#else -typedef DIDEVICEIMAGEINFOHEADERA DIDEVICEIMAGEINFOHEADER; -typedef LPCDIDEVICEIMAGEINFOHEADERA LPCDIDEVICEIMAGEINFOHEADER; -#endif // UNICODE -typedef const DIDEVICEIMAGEINFOHEADER *LPCDIDEVICEIMAGEINFOHEADER; - -#endif /* DIRECTINPUT_VERSION > 0x0700 */ - -#if(DIRECTINPUT_VERSION >= 0x0500) -/* These structures are defined for DirectX 3.0 compatibility */ - -typedef struct DIDEVICEOBJECTINSTANCE_DX3A { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - CHAR tszName[MAX_PATH]; -} DIDEVICEOBJECTINSTANCE_DX3A, *LPDIDEVICEOBJECTINSTANCE_DX3A; -typedef struct DIDEVICEOBJECTINSTANCE_DX3W { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - WCHAR tszName[MAX_PATH]; -} DIDEVICEOBJECTINSTANCE_DX3W, *LPDIDEVICEOBJECTINSTANCE_DX3W; -#ifdef UNICODE -typedef DIDEVICEOBJECTINSTANCE_DX3W DIDEVICEOBJECTINSTANCE_DX3; -typedef LPDIDEVICEOBJECTINSTANCE_DX3W LPDIDEVICEOBJECTINSTANCE_DX3; -#else -typedef DIDEVICEOBJECTINSTANCE_DX3A DIDEVICEOBJECTINSTANCE_DX3; -typedef LPDIDEVICEOBJECTINSTANCE_DX3A LPDIDEVICEOBJECTINSTANCE_DX3; -#endif // UNICODE -typedef const DIDEVICEOBJECTINSTANCE_DX3A *LPCDIDEVICEOBJECTINSTANCE_DX3A; -typedef const DIDEVICEOBJECTINSTANCE_DX3W *LPCDIDEVICEOBJECTINSTANCE_DX3W; -typedef const DIDEVICEOBJECTINSTANCE_DX3 *LPCDIDEVICEOBJECTINSTANCE_DX3; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -typedef struct DIDEVICEOBJECTINSTANCEA { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - CHAR tszName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFMaxForce; - DWORD dwFFForceResolution; - WORD wCollectionNumber; - WORD wDesignatorIndex; - WORD wUsagePage; - WORD wUsage; - DWORD dwDimension; - WORD wExponent; - WORD wReportId; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA; -typedef struct DIDEVICEOBJECTINSTANCEW { - DWORD dwSize; - GUID guidType; - DWORD dwOfs; - DWORD dwType; - DWORD dwFlags; - WCHAR tszName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - DWORD dwFFMaxForce; - DWORD dwFFForceResolution; - WORD wCollectionNumber; - WORD wDesignatorIndex; - WORD wUsagePage; - WORD wUsage; - DWORD dwDimension; - WORD wExponent; - WORD wReportId; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW; -#ifdef UNICODE -typedef DIDEVICEOBJECTINSTANCEW DIDEVICEOBJECTINSTANCE; -typedef LPDIDEVICEOBJECTINSTANCEW LPDIDEVICEOBJECTINSTANCE; -#else -typedef DIDEVICEOBJECTINSTANCEA DIDEVICEOBJECTINSTANCE; -typedef LPDIDEVICEOBJECTINSTANCEA LPDIDEVICEOBJECTINSTANCE; -#endif // UNICODE -typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA; -typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW; -typedef const DIDEVICEOBJECTINSTANCE *LPCDIDEVICEOBJECTINSTANCE; - -typedef BOOL (FAR PASCAL * LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA, LPVOID); -typedef BOOL (FAR PASCAL * LPDIENUMDEVICEOBJECTSCALLBACKW)(LPCDIDEVICEOBJECTINSTANCEW, LPVOID); -#ifdef UNICODE -#define LPDIENUMDEVICEOBJECTSCALLBACK LPDIENUMDEVICEOBJECTSCALLBACKW -#else -#define LPDIENUMDEVICEOBJECTSCALLBACK LPDIENUMDEVICEOBJECTSCALLBACKA -#endif // !UNICODE - -#if(DIRECTINPUT_VERSION >= 0x0500) -#define DIDOI_FFACTUATOR 0x00000001 -#define DIDOI_FFEFFECTTRIGGER 0x00000002 -#define DIDOI_POLLED 0x00008000 -#define DIDOI_ASPECTPOSITION 0x00000100 -#define DIDOI_ASPECTVELOCITY 0x00000200 -#define DIDOI_ASPECTACCEL 0x00000300 -#define DIDOI_ASPECTFORCE 0x00000400 -#define DIDOI_ASPECTMASK 0x00000F00 -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIDOI_GUIDISUSAGE 0x00010000 -#endif /* DIRECTINPUT_VERSION >= 0x050a */ - -typedef struct DIPROPHEADER { - DWORD dwSize; - DWORD dwHeaderSize; - DWORD dwObj; - DWORD dwHow; -} DIPROPHEADER, *LPDIPROPHEADER; -typedef const DIPROPHEADER *LPCDIPROPHEADER; - -#define DIPH_DEVICE 0 -#define DIPH_BYOFFSET 1 -#define DIPH_BYID 2 -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIPH_BYUSAGE 3 -#endif /* DIRECTINPUT_VERSION >= 0x050a */ - -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIMAKEUSAGEDWORD(UsagePage, Usage) \ - (DWORD)MAKELONG(Usage, UsagePage) -#endif /* DIRECTINPUT_VERSION >= 0x050a */ - -typedef struct DIPROPDWORD { - DIPROPHEADER diph; - DWORD dwData; -} DIPROPDWORD, *LPDIPROPDWORD; -typedef const DIPROPDWORD *LPCDIPROPDWORD; - -#if(DIRECTINPUT_VERSION >= 0x0800) -typedef struct DIPROPPOINTER { - DIPROPHEADER diph; - UINT_PTR uData; -} DIPROPPOINTER, *LPDIPROPPOINTER; -typedef const DIPROPPOINTER *LPCDIPROPPOINTER; -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -typedef struct DIPROPRANGE { - DIPROPHEADER diph; - LONG lMin; - LONG lMax; -} DIPROPRANGE, *LPDIPROPRANGE; -typedef const DIPROPRANGE *LPCDIPROPRANGE; - -#define DIPROPRANGE_NOMIN ((LONG)0x80000000) -#define DIPROPRANGE_NOMAX ((LONG)0x7FFFFFFF) - -#if(DIRECTINPUT_VERSION >= 0x050a) -typedef struct DIPROPCAL { - DIPROPHEADER diph; - LONG lMin; - LONG lCenter; - LONG lMax; -} DIPROPCAL, *LPDIPROPCAL; -typedef const DIPROPCAL *LPCDIPROPCAL; - -typedef struct DIPROPCALPOV { - DIPROPHEADER diph; - LONG lMin[5]; - LONG lMax[5]; -} DIPROPCALPOV, *LPDIPROPCALPOV; -typedef const DIPROPCALPOV *LPCDIPROPCALPOV; - -typedef struct DIPROPGUIDANDPATH { - DIPROPHEADER diph; - GUID guidClass; - WCHAR wszPath[MAX_PATH]; -} DIPROPGUIDANDPATH, *LPDIPROPGUIDANDPATH; -typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH; - -typedef struct DIPROPSTRING { - DIPROPHEADER diph; - WCHAR wsz[MAX_PATH]; -} DIPROPSTRING, *LPDIPROPSTRING; -typedef const DIPROPSTRING *LPCDIPROPSTRING; - -#endif /* DIRECTINPUT_VERSION >= 0x050a */ - -#if(DIRECTINPUT_VERSION >= 0x0800) -#define MAXCPOINTSNUM 8 - -typedef struct _CPOINT -{ - LONG lP; // raw value - DWORD dwLog; // logical_value / max_logical_value * 10000 -} CPOINT, *PCPOINT; - -typedef struct DIPROPCPOINTS { - DIPROPHEADER diph; - DWORD dwCPointsNum; - CPOINT cp[MAXCPOINTSNUM]; -} DIPROPCPOINTS, *LPDIPROPCPOINTS; -typedef const DIPROPCPOINTS *LPCDIPROPCPOINTS; -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - - -#ifdef __cplusplus -#define MAKEDIPROP(prop) (*(const GUID *)(prop)) -#else -#define MAKEDIPROP(prop) ((REFGUID)(prop)) -#endif - -#define DIPROP_BUFFERSIZE MAKEDIPROP(1) - -#define DIPROP_AXISMODE MAKEDIPROP(2) - -#define DIPROPAXISMODE_ABS 0 -#define DIPROPAXISMODE_REL 1 - -#define DIPROP_GRANULARITY MAKEDIPROP(3) - -#define DIPROP_RANGE MAKEDIPROP(4) - -#define DIPROP_DEADZONE MAKEDIPROP(5) - -#define DIPROP_SATURATION MAKEDIPROP(6) - -#define DIPROP_FFGAIN MAKEDIPROP(7) - -#define DIPROP_FFLOAD MAKEDIPROP(8) - -#define DIPROP_AUTOCENTER MAKEDIPROP(9) - -#define DIPROPAUTOCENTER_OFF 0 -#define DIPROPAUTOCENTER_ON 1 - -#define DIPROP_CALIBRATIONMODE MAKEDIPROP(10) - -#define DIPROPCALIBRATIONMODE_COOKED 0 -#define DIPROPCALIBRATIONMODE_RAW 1 - -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIPROP_CALIBRATION MAKEDIPROP(11) - -#define DIPROP_GUIDANDPATH MAKEDIPROP(12) - -#define DIPROP_INSTANCENAME MAKEDIPROP(13) - -#define DIPROP_PRODUCTNAME MAKEDIPROP(14) -#endif /* DIRECTINPUT_VERSION >= 0x050a */ - -#if(DIRECTINPUT_VERSION >= 0x05b2) -#define DIPROP_JOYSTICKID MAKEDIPROP(15) - -#define DIPROP_GETPORTDISPLAYNAME MAKEDIPROP(16) - -#endif /* DIRECTINPUT_VERSION >= 0x05b2 */ - -#if(DIRECTINPUT_VERSION >= 0x0700) -#define DIPROP_PHYSICALRANGE MAKEDIPROP(18) - -#define DIPROP_LOGICALRANGE MAKEDIPROP(19) -#endif /* DIRECTINPUT_VERSION >= 0x0700 */ - -#if(DIRECTINPUT_VERSION >= 0x0800) -#define DIPROP_KEYNAME MAKEDIPROP(20) - -#define DIPROP_CPOINTS MAKEDIPROP(21) - -#define DIPROP_APPDATA MAKEDIPROP(22) - -#define DIPROP_SCANCODE MAKEDIPROP(23) - -#define DIPROP_VIDPID MAKEDIPROP(24) - -#define DIPROP_USERNAME MAKEDIPROP(25) - -#define DIPROP_TYPENAME MAKEDIPROP(26) -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - - -typedef struct DIDEVICEOBJECTDATA_DX3 { - DWORD dwOfs; - DWORD dwData; - DWORD dwTimeStamp; - DWORD dwSequence; -} DIDEVICEOBJECTDATA_DX3, *LPDIDEVICEOBJECTDATA_DX3; -typedef const DIDEVICEOBJECTDATA_DX3 *LPCDIDEVICEOBJECTDATA_DX; - -typedef struct DIDEVICEOBJECTDATA { - DWORD dwOfs; - DWORD dwData; - DWORD dwTimeStamp; - DWORD dwSequence; -#if(DIRECTINPUT_VERSION >= 0x0800) - UINT_PTR uAppData; -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ -} DIDEVICEOBJECTDATA, *LPDIDEVICEOBJECTDATA; -typedef const DIDEVICEOBJECTDATA *LPCDIDEVICEOBJECTDATA; - -#define DIGDD_PEEK 0x00000001 - -#define DISEQUENCE_COMPARE(dwSequence1, cmp, dwSequence2) \ - ((int)((dwSequence1) - (dwSequence2)) cmp 0) -#define DISCL_EXCLUSIVE 0x00000001 -#define DISCL_NONEXCLUSIVE 0x00000002 -#define DISCL_FOREGROUND 0x00000004 -#define DISCL_BACKGROUND 0x00000008 -#define DISCL_NOWINKEY 0x00000010 - -#if(DIRECTINPUT_VERSION >= 0x0500) -/* These structures are defined for DirectX 3.0 compatibility */ - -typedef struct DIDEVICEINSTANCE_DX3A { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - CHAR tszInstanceName[MAX_PATH]; - CHAR tszProductName[MAX_PATH]; -} DIDEVICEINSTANCE_DX3A, *LPDIDEVICEINSTANCE_DX3A; -typedef struct DIDEVICEINSTANCE_DX3W { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - WCHAR tszInstanceName[MAX_PATH]; - WCHAR tszProductName[MAX_PATH]; -} DIDEVICEINSTANCE_DX3W, *LPDIDEVICEINSTANCE_DX3W; -#ifdef UNICODE -typedef DIDEVICEINSTANCE_DX3W DIDEVICEINSTANCE_DX3; -typedef LPDIDEVICEINSTANCE_DX3W LPDIDEVICEINSTANCE_DX3; -#else -typedef DIDEVICEINSTANCE_DX3A DIDEVICEINSTANCE_DX3; -typedef LPDIDEVICEINSTANCE_DX3A LPDIDEVICEINSTANCE_DX3; -#endif // UNICODE -typedef const DIDEVICEINSTANCE_DX3A *LPCDIDEVICEINSTANCE_DX3A; -typedef const DIDEVICEINSTANCE_DX3W *LPCDIDEVICEINSTANCE_DX3W; -typedef const DIDEVICEINSTANCE_DX3 *LPCDIDEVICEINSTANCE_DX3; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -typedef struct DIDEVICEINSTANCEA { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - CHAR tszInstanceName[MAX_PATH]; - CHAR tszProductName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - GUID guidFFDriver; - WORD wUsagePage; - WORD wUsage; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA; -typedef struct DIDEVICEINSTANCEW { - DWORD dwSize; - GUID guidInstance; - GUID guidProduct; - DWORD dwDevType; - WCHAR tszInstanceName[MAX_PATH]; - WCHAR tszProductName[MAX_PATH]; -#if(DIRECTINPUT_VERSION >= 0x0500) - GUID guidFFDriver; - WORD wUsagePage; - WORD wUsage; -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW; -#ifdef UNICODE -typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE; -typedef LPDIDEVICEINSTANCEW LPDIDEVICEINSTANCE; -#else -typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE; -typedef LPDIDEVICEINSTANCEA LPDIDEVICEINSTANCE; -#endif // UNICODE - -typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA; -typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW; -#ifdef UNICODE -typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE; -typedef LPCDIDEVICEINSTANCEW LPCDIDEVICEINSTANCE; -#else -typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE; -typedef LPCDIDEVICEINSTANCEA LPCDIDEVICEINSTANCE; -#endif // UNICODE -typedef const DIDEVICEINSTANCE *LPCDIDEVICEINSTANCE; - -#undef INTERFACE -#define INTERFACE IDirectInputDeviceW - -DECLARE_INTERFACE_(IDirectInputDeviceW, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDeviceW methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; -}; - -typedef struct IDirectInputDeviceW *LPDIRECTINPUTDEVICEW; - -#undef INTERFACE -#define INTERFACE IDirectInputDeviceA - -DECLARE_INTERFACE_(IDirectInputDeviceA, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDeviceA methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; -}; - -typedef struct IDirectInputDeviceA *LPDIRECTINPUTDEVICEA; - -#ifdef UNICODE -#define IID_IDirectInputDevice IID_IDirectInputDeviceW -#define IDirectInputDevice IDirectInputDeviceW -#define IDirectInputDeviceVtbl IDirectInputDeviceWVtbl -#else -#define IID_IDirectInputDevice IID_IDirectInputDeviceA -#define IDirectInputDevice IDirectInputDeviceA -#define IDirectInputDeviceVtbl IDirectInputDeviceAVtbl -#endif -typedef struct IDirectInputDevice *LPDIRECTINPUTDEVICE; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputDevice_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#else -#define IDirectInputDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice_AddRef(p) (p)->AddRef() -#define IDirectInputDevice_Release(p) (p)->Release() -#define IDirectInputDevice_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice_Acquire(p) (p)->Acquire() -#define IDirectInputDevice_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#endif - -#endif /* DIJ_RINGZERO */ - - -#if(DIRECTINPUT_VERSION >= 0x0500) - -#define DISFFC_RESET 0x00000001 -#define DISFFC_STOPALL 0x00000002 -#define DISFFC_PAUSE 0x00000004 -#define DISFFC_CONTINUE 0x00000008 -#define DISFFC_SETACTUATORSON 0x00000010 -#define DISFFC_SETACTUATORSOFF 0x00000020 - -#define DIGFFS_EMPTY 0x00000001 -#define DIGFFS_STOPPED 0x00000002 -#define DIGFFS_PAUSED 0x00000004 -#define DIGFFS_ACTUATORSON 0x00000010 -#define DIGFFS_ACTUATORSOFF 0x00000020 -#define DIGFFS_POWERON 0x00000040 -#define DIGFFS_POWEROFF 0x00000080 -#define DIGFFS_SAFETYSWITCHON 0x00000100 -#define DIGFFS_SAFETYSWITCHOFF 0x00000200 -#define DIGFFS_USERFFSWITCHON 0x00000400 -#define DIGFFS_USERFFSWITCHOFF 0x00000800 -#define DIGFFS_DEVICELOST 0x80000000 - -#ifndef DIJ_RINGZERO - -typedef struct DIEFFECTINFOA { - DWORD dwSize; - GUID guid; - DWORD dwEffType; - DWORD dwStaticParams; - DWORD dwDynamicParams; - CHAR tszName[MAX_PATH]; -} DIEFFECTINFOA, *LPDIEFFECTINFOA; -typedef struct DIEFFECTINFOW { - DWORD dwSize; - GUID guid; - DWORD dwEffType; - DWORD dwStaticParams; - DWORD dwDynamicParams; - WCHAR tszName[MAX_PATH]; -} DIEFFECTINFOW, *LPDIEFFECTINFOW; -#ifdef UNICODE -typedef DIEFFECTINFOW DIEFFECTINFO; -typedef LPDIEFFECTINFOW LPDIEFFECTINFO; -#else -typedef DIEFFECTINFOA DIEFFECTINFO; -typedef LPDIEFFECTINFOA LPDIEFFECTINFO; -#endif // UNICODE -typedef const DIEFFECTINFOA *LPCDIEFFECTINFOA; -typedef const DIEFFECTINFOW *LPCDIEFFECTINFOW; -typedef const DIEFFECTINFO *LPCDIEFFECTINFO; - -#define DISDD_CONTINUE 0x00000001 - -typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSCALLBACKA)(LPCDIEFFECTINFOA, LPVOID); -typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSCALLBACKW)(LPCDIEFFECTINFOW, LPVOID); -#ifdef UNICODE -#define LPDIENUMEFFECTSCALLBACK LPDIENUMEFFECTSCALLBACKW -#else -#define LPDIENUMEFFECTSCALLBACK LPDIENUMEFFECTSCALLBACKA -#endif // !UNICODE -typedef BOOL (FAR PASCAL * LPDIENUMCREATEDEFFECTOBJECTSCALLBACK)(LPDIRECTINPUTEFFECT, LPVOID); - -#undef INTERFACE -#define INTERFACE IDirectInputDevice2W - -DECLARE_INTERFACE_(IDirectInputDevice2W, IDirectInputDeviceW) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDeviceW methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - - /*** IDirectInputDevice2W methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; -}; - -typedef struct IDirectInputDevice2W *LPDIRECTINPUTDEVICE2W; - -#undef INTERFACE -#define INTERFACE IDirectInputDevice2A - -DECLARE_INTERFACE_(IDirectInputDevice2A, IDirectInputDeviceA) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDeviceA methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - - /*** IDirectInputDevice2A methods ***/ - STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; -}; - -typedef struct IDirectInputDevice2A *LPDIRECTINPUTDEVICE2A; - -#ifdef UNICODE -#define IID_IDirectInputDevice2 IID_IDirectInputDevice2W -#define IDirectInputDevice2 IDirectInputDevice2W -#define IDirectInputDevice2Vtbl IDirectInputDevice2WVtbl -#else -#define IID_IDirectInputDevice2 IID_IDirectInputDevice2A -#define IDirectInputDevice2 IDirectInputDevice2A -#define IDirectInputDevice2Vtbl IDirectInputDevice2AVtbl -#endif -typedef struct IDirectInputDevice2 *LPDIRECTINPUTDEVICE2; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice2_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputDevice2_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice2_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice2_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice2_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice2_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice2_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice2_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) -#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) -#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) -#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) -#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) -#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) -#define IDirectInputDevice2_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#define IDirectInputDevice2_Poll(p) (p)->lpVtbl->Poll(p) -#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) -#else -#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice2_AddRef(p) (p)->AddRef() -#define IDirectInputDevice2_Release(p) (p)->Release() -#define IDirectInputDevice2_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice2_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice2_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice2_Acquire(p) (p)->Acquire() -#define IDirectInputDevice2_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice2_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice2_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) -#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) -#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) -#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) -#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) -#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) -#define IDirectInputDevice2_Escape(p,a) (p)->Escape(a) -#define IDirectInputDevice2_Poll(p) (p)->Poll() -#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) -#endif - -#endif /* DIJ_RINGZERO */ - -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ - -#if(DIRECTINPUT_VERSION >= 0x0700) -#define DIFEF_DEFAULT 0x00000000 -#define DIFEF_INCLUDENONSTANDARD 0x00000001 -#define DIFEF_MODIFYIFNEEDED 0x00000010 - -#ifndef DIJ_RINGZERO - -#undef INTERFACE -#define INTERFACE IDirectInputDevice7W - -DECLARE_INTERFACE_(IDirectInputDevice7W, IDirectInputDevice2W) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDevice2W methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - - /*** IDirectInputDevice7W methods ***/ - STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; -}; - -typedef struct IDirectInputDevice7W *LPDIRECTINPUTDEVICE7W; - -#undef INTERFACE -#define INTERFACE IDirectInputDevice7A - -DECLARE_INTERFACE_(IDirectInputDevice7A, IDirectInputDevice2A) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDevice2A methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - - /*** IDirectInputDevice7A methods ***/ - STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; -}; - -typedef struct IDirectInputDevice7A *LPDIRECTINPUTDEVICE7A; - -#ifdef UNICODE -#define IID_IDirectInputDevice7 IID_IDirectInputDevice7W -#define IDirectInputDevice7 IDirectInputDevice7W -#define IDirectInputDevice7Vtbl IDirectInputDevice7WVtbl -#else -#define IID_IDirectInputDevice7 IID_IDirectInputDevice7A -#define IDirectInputDevice7 IDirectInputDevice7A -#define IDirectInputDevice7Vtbl IDirectInputDevice7AVtbl -#endif -typedef struct IDirectInputDevice7 *LPDIRECTINPUTDEVICE7; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice7_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputDevice7_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice7_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice7_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice7_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice7_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice7_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice7_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) -#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) -#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) -#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) -#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) -#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) -#define IDirectInputDevice7_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#define IDirectInputDevice7_Poll(p) (p)->lpVtbl->Poll(p) -#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) -#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) -#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) -#else -#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice7_AddRef(p) (p)->AddRef() -#define IDirectInputDevice7_Release(p) (p)->Release() -#define IDirectInputDevice7_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice7_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice7_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice7_Acquire(p) (p)->Acquire() -#define IDirectInputDevice7_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice7_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice7_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) -#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) -#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) -#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) -#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) -#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) -#define IDirectInputDevice7_Escape(p,a) (p)->Escape(a) -#define IDirectInputDevice7_Poll(p) (p)->Poll() -#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) -#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) -#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) -#endif - -#endif /* DIJ_RINGZERO */ - -#endif /* DIRECTINPUT_VERSION >= 0x0700 */ - -#if(DIRECTINPUT_VERSION >= 0x0800) - -#ifndef DIJ_RINGZERO - -#undef INTERFACE -#define INTERFACE IDirectInputDevice8W - -DECLARE_INTERFACE_(IDirectInputDevice8W, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDevice8W methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; - STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATW,LPCWSTR,DWORD) PURE; - STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATW,LPCWSTR,DWORD) PURE; - STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERW) PURE; -}; - -typedef struct IDirectInputDevice8W *LPDIRECTINPUTDEVICE8W; - -#undef INTERFACE -#define INTERFACE IDirectInputDevice8A - -DECLARE_INTERFACE_(IDirectInputDevice8A, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputDevice8A methods ***/ - STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; - STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; - STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; - STDMETHOD(Acquire)(THIS) PURE; - STDMETHOD(Unacquire)(THIS) PURE; - STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; - STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; - STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; - STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; - STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; - STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; - STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; - STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; - STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; - STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; - STDMETHOD(Poll)(THIS) PURE; - STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; - STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; - STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; - STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATA,LPCSTR,DWORD) PURE; - STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATA,LPCSTR,DWORD) PURE; - STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERA) PURE; -}; - -typedef struct IDirectInputDevice8A *LPDIRECTINPUTDEVICE8A; - -#ifdef UNICODE -#define IID_IDirectInputDevice8 IID_IDirectInputDevice8W -#define IDirectInputDevice8 IDirectInputDevice8W -#define IDirectInputDevice8Vtbl IDirectInputDevice8WVtbl -#else -#define IID_IDirectInputDevice8 IID_IDirectInputDevice8A -#define IDirectInputDevice8 IDirectInputDevice8A -#define IDirectInputDevice8Vtbl IDirectInputDevice8AVtbl -#endif -typedef struct IDirectInputDevice8 *LPDIRECTINPUTDEVICE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInputDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInputDevice8_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInputDevice8_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) -#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) -#define IDirectInputDevice8_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) -#define IDirectInputDevice8_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) -#define IDirectInputDevice8_Acquire(p) (p)->lpVtbl->Acquire(p) -#define IDirectInputDevice8_Unacquire(p) (p)->lpVtbl->Unacquire(p) -#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) -#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) -#define IDirectInputDevice8_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) -#define IDirectInputDevice8_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) -#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) -#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) -#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) -#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) -#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) -#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) -#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) -#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) -#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) -#define IDirectInputDevice8_Escape(p,a) (p)->lpVtbl->Escape(p,a) -#define IDirectInputDevice8_Poll(p) (p)->lpVtbl->Poll(p) -#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) -#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) -#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) -#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->lpVtbl->BuildActionMap(p,a,b,c) -#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->lpVtbl->SetActionMap(p,a,b,c) -#define IDirectInputDevice8_GetImageInfo(p,a) (p)->lpVtbl->GetImageInfo(p,a) -#else -#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInputDevice8_AddRef(p) (p)->AddRef() -#define IDirectInputDevice8_Release(p) (p)->Release() -#define IDirectInputDevice8_GetCapabilities(p,a) (p)->GetCapabilities(a) -#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) -#define IDirectInputDevice8_GetProperty(p,a,b) (p)->GetProperty(a,b) -#define IDirectInputDevice8_SetProperty(p,a,b) (p)->SetProperty(a,b) -#define IDirectInputDevice8_Acquire(p) (p)->Acquire() -#define IDirectInputDevice8_Unacquire(p) (p)->Unacquire() -#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) -#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) -#define IDirectInputDevice8_SetDataFormat(p,a) (p)->SetDataFormat(a) -#define IDirectInputDevice8_SetEventNotification(p,a) (p)->SetEventNotification(a) -#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) -#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) -#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->Initialize(a,b,c) -#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) -#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) -#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) -#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) -#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) -#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) -#define IDirectInputDevice8_Escape(p,a) (p)->Escape(a) -#define IDirectInputDevice8_Poll(p) (p)->Poll() -#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) -#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) -#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) -#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->BuildActionMap(a,b,c) -#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->SetActionMap(a,b,c) -#define IDirectInputDevice8_GetImageInfo(p,a) (p)->GetImageInfo(a) -#endif - -#endif /* DIJ_RINGZERO */ - -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -/**************************************************************************** - * - * Mouse - * - ****************************************************************************/ - -#ifndef DIJ_RINGZERO - -typedef struct _DIMOUSESTATE { - LONG lX; - LONG lY; - LONG lZ; - BYTE rgbButtons[4]; -} DIMOUSESTATE, *LPDIMOUSESTATE; - -#if DIRECTINPUT_VERSION >= 0x0700 -typedef struct _DIMOUSESTATE2 { - LONG lX; - LONG lY; - LONG lZ; - BYTE rgbButtons[8]; -} DIMOUSESTATE2, *LPDIMOUSESTATE2; -#endif - - -#define DIMOFS_X FIELD_OFFSET(DIMOUSESTATE, lX) -#define DIMOFS_Y FIELD_OFFSET(DIMOUSESTATE, lY) -#define DIMOFS_Z FIELD_OFFSET(DIMOUSESTATE, lZ) -#define DIMOFS_BUTTON0 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 0) -#define DIMOFS_BUTTON1 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 1) -#define DIMOFS_BUTTON2 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 2) -#define DIMOFS_BUTTON3 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 3) -#if (DIRECTINPUT_VERSION >= 0x0700) -#define DIMOFS_BUTTON4 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 4) -#define DIMOFS_BUTTON5 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 5) -#define DIMOFS_BUTTON6 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 6) -#define DIMOFS_BUTTON7 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 7) -#endif -#endif /* DIJ_RINGZERO */ - -/**************************************************************************** - * - * Keyboard - * - ****************************************************************************/ - -#ifndef DIJ_RINGZERO - -/**************************************************************************** - * - * DirectInput keyboard scan codes - * - ****************************************************************************/ -#define DIK_ESCAPE 0x01 -#define DIK_1 0x02 -#define DIK_2 0x03 -#define DIK_3 0x04 -#define DIK_4 0x05 -#define DIK_5 0x06 -#define DIK_6 0x07 -#define DIK_7 0x08 -#define DIK_8 0x09 -#define DIK_9 0x0A -#define DIK_0 0x0B -#define DIK_MINUS 0x0C /* - on main keyboard */ -#define DIK_EQUALS 0x0D -#define DIK_BACK 0x0E /* backspace */ -#define DIK_TAB 0x0F -#define DIK_Q 0x10 -#define DIK_W 0x11 -#define DIK_E 0x12 -#define DIK_R 0x13 -#define DIK_T 0x14 -#define DIK_Y 0x15 -#define DIK_U 0x16 -#define DIK_I 0x17 -#define DIK_O 0x18 -#define DIK_P 0x19 -#define DIK_LBRACKET 0x1A -#define DIK_RBRACKET 0x1B -#define DIK_RETURN 0x1C /* Enter on main keyboard */ -#define DIK_LCONTROL 0x1D -#define DIK_A 0x1E -#define DIK_S 0x1F -#define DIK_D 0x20 -#define DIK_F 0x21 -#define DIK_G 0x22 -#define DIK_H 0x23 -#define DIK_J 0x24 -#define DIK_K 0x25 -#define DIK_L 0x26 -#define DIK_SEMICOLON 0x27 -#define DIK_APOSTROPHE 0x28 -#define DIK_GRAVE 0x29 /* accent grave */ -#define DIK_LSHIFT 0x2A -#define DIK_BACKSLASH 0x2B -#define DIK_Z 0x2C -#define DIK_X 0x2D -#define DIK_C 0x2E -#define DIK_V 0x2F -#define DIK_B 0x30 -#define DIK_N 0x31 -#define DIK_M 0x32 -#define DIK_COMMA 0x33 -#define DIK_PERIOD 0x34 /* . on main keyboard */ -#define DIK_SLASH 0x35 /* / on main keyboard */ -#define DIK_RSHIFT 0x36 -#define DIK_MULTIPLY 0x37 /* * on numeric keypad */ -#define DIK_LMENU 0x38 /* left Alt */ -#define DIK_SPACE 0x39 -#define DIK_CAPITAL 0x3A -#define DIK_F1 0x3B -#define DIK_F2 0x3C -#define DIK_F3 0x3D -#define DIK_F4 0x3E -#define DIK_F5 0x3F -#define DIK_F6 0x40 -#define DIK_F7 0x41 -#define DIK_F8 0x42 -#define DIK_F9 0x43 -#define DIK_F10 0x44 -#define DIK_NUMLOCK 0x45 -#define DIK_SCROLL 0x46 /* Scroll Lock */ -#define DIK_NUMPAD7 0x47 -#define DIK_NUMPAD8 0x48 -#define DIK_NUMPAD9 0x49 -#define DIK_SUBTRACT 0x4A /* - on numeric keypad */ -#define DIK_NUMPAD4 0x4B -#define DIK_NUMPAD5 0x4C -#define DIK_NUMPAD6 0x4D -#define DIK_ADD 0x4E /* + on numeric keypad */ -#define DIK_NUMPAD1 0x4F -#define DIK_NUMPAD2 0x50 -#define DIK_NUMPAD3 0x51 -#define DIK_NUMPAD0 0x52 -#define DIK_DECIMAL 0x53 /* . on numeric keypad */ -#define DIK_OEM_102 0x56 /* <> or \| on RT 102-key keyboard (Non-U.S.) */ -#define DIK_F11 0x57 -#define DIK_F12 0x58 -#define DIK_F13 0x64 /* (NEC PC98) */ -#define DIK_F14 0x65 /* (NEC PC98) */ -#define DIK_F15 0x66 /* (NEC PC98) */ -#define DIK_KANA 0x70 /* (Japanese keyboard) */ -#define DIK_ABNT_C1 0x73 /* /? on Brazilian keyboard */ -#define DIK_CONVERT 0x79 /* (Japanese keyboard) */ -#define DIK_NOCONVERT 0x7B /* (Japanese keyboard) */ -#define DIK_YEN 0x7D /* (Japanese keyboard) */ -#define DIK_ABNT_C2 0x7E /* Numpad . on Brazilian keyboard */ -#define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */ -#define DIK_PREVTRACK 0x90 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ -#define DIK_AT 0x91 /* (NEC PC98) */ -#define DIK_COLON 0x92 /* (NEC PC98) */ -#define DIK_UNDERLINE 0x93 /* (NEC PC98) */ -#define DIK_KANJI 0x94 /* (Japanese keyboard) */ -#define DIK_STOP 0x95 /* (NEC PC98) */ -#define DIK_AX 0x96 /* (Japan AX) */ -#define DIK_UNLABELED 0x97 /* (J3100) */ -#define DIK_NEXTTRACK 0x99 /* Next Track */ -#define DIK_NUMPADENTER 0x9C /* Enter on numeric keypad */ -#define DIK_RCONTROL 0x9D -#define DIK_MUTE 0xA0 /* Mute */ -#define DIK_CALCULATOR 0xA1 /* Calculator */ -#define DIK_PLAYPAUSE 0xA2 /* Play / Pause */ -#define DIK_MEDIASTOP 0xA4 /* Media Stop */ -#define DIK_VOLUMEDOWN 0xAE /* Volume - */ -#define DIK_VOLUMEUP 0xB0 /* Volume + */ -#define DIK_WEBHOME 0xB2 /* Web home */ -#define DIK_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */ -#define DIK_DIVIDE 0xB5 /* / on numeric keypad */ -#define DIK_SYSRQ 0xB7 -#define DIK_RMENU 0xB8 /* right Alt */ -#define DIK_PAUSE 0xC5 /* Pause */ -#define DIK_HOME 0xC7 /* Home on arrow keypad */ -#define DIK_UP 0xC8 /* UpArrow on arrow keypad */ -#define DIK_PRIOR 0xC9 /* PgUp on arrow keypad */ -#define DIK_LEFT 0xCB /* LeftArrow on arrow keypad */ -#define DIK_RIGHT 0xCD /* RightArrow on arrow keypad */ -#define DIK_END 0xCF /* End on arrow keypad */ -#define DIK_DOWN 0xD0 /* DownArrow on arrow keypad */ -#define DIK_NEXT 0xD1 /* PgDn on arrow keypad */ -#define DIK_INSERT 0xD2 /* Insert on arrow keypad */ -#define DIK_DELETE 0xD3 /* Delete on arrow keypad */ -#define DIK_LWIN 0xDB /* Left Windows key */ -#define DIK_RWIN 0xDC /* Right Windows key */ -#define DIK_APPS 0xDD /* AppMenu key */ -#define DIK_POWER 0xDE /* System Power */ -#define DIK_SLEEP 0xDF /* System Sleep */ -#define DIK_WAKE 0xE3 /* System Wake */ -#define DIK_WEBSEARCH 0xE5 /* Web Search */ -#define DIK_WEBFAVORITES 0xE6 /* Web Favorites */ -#define DIK_WEBREFRESH 0xE7 /* Web Refresh */ -#define DIK_WEBSTOP 0xE8 /* Web Stop */ -#define DIK_WEBFORWARD 0xE9 /* Web Forward */ -#define DIK_WEBBACK 0xEA /* Web Back */ -#define DIK_MYCOMPUTER 0xEB /* My Computer */ -#define DIK_MAIL 0xEC /* Mail */ -#define DIK_MEDIASELECT 0xED /* Media Select */ - -/* - * Alternate names for keys, to facilitate transition from DOS. - */ -#define DIK_BACKSPACE DIK_BACK /* backspace */ -#define DIK_NUMPADSTAR DIK_MULTIPLY /* * on numeric keypad */ -#define DIK_LALT DIK_LMENU /* left Alt */ -#define DIK_CAPSLOCK DIK_CAPITAL /* CapsLock */ -#define DIK_NUMPADMINUS DIK_SUBTRACT /* - on numeric keypad */ -#define DIK_NUMPADPLUS DIK_ADD /* + on numeric keypad */ -#define DIK_NUMPADPERIOD DIK_DECIMAL /* . on numeric keypad */ -#define DIK_NUMPADSLASH DIK_DIVIDE /* / on numeric keypad */ -#define DIK_RALT DIK_RMENU /* right Alt */ -#define DIK_UPARROW DIK_UP /* UpArrow on arrow keypad */ -#define DIK_PGUP DIK_PRIOR /* PgUp on arrow keypad */ -#define DIK_LEFTARROW DIK_LEFT /* LeftArrow on arrow keypad */ -#define DIK_RIGHTARROW DIK_RIGHT /* RightArrow on arrow keypad */ -#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */ -#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */ - -/* - * Alternate names for keys originally not used on US keyboards. - */ -#define DIK_CIRCUMFLEX DIK_PREVTRACK /* Japanese keyboard */ - -#endif /* DIJ_RINGZERO */ - -/**************************************************************************** - * - * Joystick - * - ****************************************************************************/ - -#ifndef DIJ_RINGZERO - -typedef struct DIJOYSTATE { - LONG lX; /* x-axis position */ - LONG lY; /* y-axis position */ - LONG lZ; /* z-axis position */ - LONG lRx; /* x-axis rotation */ - LONG lRy; /* y-axis rotation */ - LONG lRz; /* z-axis rotation */ - LONG rglSlider[2]; /* extra axes positions */ - DWORD rgdwPOV[4]; /* POV directions */ - BYTE rgbButtons[32]; /* 32 buttons */ -} DIJOYSTATE, *LPDIJOYSTATE; - -typedef struct DIJOYSTATE2 { - LONG lX; /* x-axis position */ - LONG lY; /* y-axis position */ - LONG lZ; /* z-axis position */ - LONG lRx; /* x-axis rotation */ - LONG lRy; /* y-axis rotation */ - LONG lRz; /* z-axis rotation */ - LONG rglSlider[2]; /* extra axes positions */ - DWORD rgdwPOV[4]; /* POV directions */ - BYTE rgbButtons[128]; /* 128 buttons */ - LONG lVX; /* x-axis velocity */ - LONG lVY; /* y-axis velocity */ - LONG lVZ; /* z-axis velocity */ - LONG lVRx; /* x-axis angular velocity */ - LONG lVRy; /* y-axis angular velocity */ - LONG lVRz; /* z-axis angular velocity */ - LONG rglVSlider[2]; /* extra axes velocities */ - LONG lAX; /* x-axis acceleration */ - LONG lAY; /* y-axis acceleration */ - LONG lAZ; /* z-axis acceleration */ - LONG lARx; /* x-axis angular acceleration */ - LONG lARy; /* y-axis angular acceleration */ - LONG lARz; /* z-axis angular acceleration */ - LONG rglASlider[2]; /* extra axes accelerations */ - LONG lFX; /* x-axis force */ - LONG lFY; /* y-axis force */ - LONG lFZ; /* z-axis force */ - LONG lFRx; /* x-axis torque */ - LONG lFRy; /* y-axis torque */ - LONG lFRz; /* z-axis torque */ - LONG rglFSlider[2]; /* extra axes forces */ -} DIJOYSTATE2, *LPDIJOYSTATE2; - -#define DIJOFS_X FIELD_OFFSET(DIJOYSTATE, lX) -#define DIJOFS_Y FIELD_OFFSET(DIJOYSTATE, lY) -#define DIJOFS_Z FIELD_OFFSET(DIJOYSTATE, lZ) -#define DIJOFS_RX FIELD_OFFSET(DIJOYSTATE, lRx) -#define DIJOFS_RY FIELD_OFFSET(DIJOYSTATE, lRy) -#define DIJOFS_RZ FIELD_OFFSET(DIJOYSTATE, lRz) -#define DIJOFS_SLIDER(n) (FIELD_OFFSET(DIJOYSTATE, rglSlider) + \ - (n) * sizeof(LONG)) -#define DIJOFS_POV(n) (FIELD_OFFSET(DIJOYSTATE, rgdwPOV) + \ - (n) * sizeof(DWORD)) -#define DIJOFS_BUTTON(n) (FIELD_OFFSET(DIJOYSTATE, rgbButtons) + (n)) -#define DIJOFS_BUTTON0 DIJOFS_BUTTON(0) -#define DIJOFS_BUTTON1 DIJOFS_BUTTON(1) -#define DIJOFS_BUTTON2 DIJOFS_BUTTON(2) -#define DIJOFS_BUTTON3 DIJOFS_BUTTON(3) -#define DIJOFS_BUTTON4 DIJOFS_BUTTON(4) -#define DIJOFS_BUTTON5 DIJOFS_BUTTON(5) -#define DIJOFS_BUTTON6 DIJOFS_BUTTON(6) -#define DIJOFS_BUTTON7 DIJOFS_BUTTON(7) -#define DIJOFS_BUTTON8 DIJOFS_BUTTON(8) -#define DIJOFS_BUTTON9 DIJOFS_BUTTON(9) -#define DIJOFS_BUTTON10 DIJOFS_BUTTON(10) -#define DIJOFS_BUTTON11 DIJOFS_BUTTON(11) -#define DIJOFS_BUTTON12 DIJOFS_BUTTON(12) -#define DIJOFS_BUTTON13 DIJOFS_BUTTON(13) -#define DIJOFS_BUTTON14 DIJOFS_BUTTON(14) -#define DIJOFS_BUTTON15 DIJOFS_BUTTON(15) -#define DIJOFS_BUTTON16 DIJOFS_BUTTON(16) -#define DIJOFS_BUTTON17 DIJOFS_BUTTON(17) -#define DIJOFS_BUTTON18 DIJOFS_BUTTON(18) -#define DIJOFS_BUTTON19 DIJOFS_BUTTON(19) -#define DIJOFS_BUTTON20 DIJOFS_BUTTON(20) -#define DIJOFS_BUTTON21 DIJOFS_BUTTON(21) -#define DIJOFS_BUTTON22 DIJOFS_BUTTON(22) -#define DIJOFS_BUTTON23 DIJOFS_BUTTON(23) -#define DIJOFS_BUTTON24 DIJOFS_BUTTON(24) -#define DIJOFS_BUTTON25 DIJOFS_BUTTON(25) -#define DIJOFS_BUTTON26 DIJOFS_BUTTON(26) -#define DIJOFS_BUTTON27 DIJOFS_BUTTON(27) -#define DIJOFS_BUTTON28 DIJOFS_BUTTON(28) -#define DIJOFS_BUTTON29 DIJOFS_BUTTON(29) -#define DIJOFS_BUTTON30 DIJOFS_BUTTON(30) -#define DIJOFS_BUTTON31 DIJOFS_BUTTON(31) - - -#endif /* DIJ_RINGZERO */ - -/**************************************************************************** - * - * IDirectInput - * - ****************************************************************************/ - -#ifndef DIJ_RINGZERO - -#define DIENUM_STOP 0 -#define DIENUM_CONTINUE 1 - -typedef BOOL (FAR PASCAL * LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA, LPVOID); -typedef BOOL (FAR PASCAL * LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW, LPVOID); -#ifdef UNICODE -#define LPDIENUMDEVICESCALLBACK LPDIENUMDEVICESCALLBACKW -#else -#define LPDIENUMDEVICESCALLBACK LPDIENUMDEVICESCALLBACKA -#endif // !UNICODE -typedef BOOL (FAR PASCAL * LPDICONFIGUREDEVICESCALLBACK)(IUnknown FAR *, LPVOID); - -#define DIEDFL_ALLDEVICES 0x00000000 -#define DIEDFL_ATTACHEDONLY 0x00000001 -#if(DIRECTINPUT_VERSION >= 0x0500) -#define DIEDFL_FORCEFEEDBACK 0x00000100 -#endif /* DIRECTINPUT_VERSION >= 0x0500 */ -#if(DIRECTINPUT_VERSION >= 0x050a) -#define DIEDFL_INCLUDEALIASES 0x00010000 -#define DIEDFL_INCLUDEPHANTOMS 0x00020000 -#endif /* DIRECTINPUT_VERSION >= 0x050a */ -#if(DIRECTINPUT_VERSION >= 0x0800) -#define DIEDFL_INCLUDEHIDDEN 0x00040000 -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - - -#if(DIRECTINPUT_VERSION >= 0x0800) -typedef BOOL (FAR PASCAL * LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA, LPDIRECTINPUTDEVICE8A, DWORD, DWORD, LPVOID); -typedef BOOL (FAR PASCAL * LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW, LPDIRECTINPUTDEVICE8W, DWORD, DWORD, LPVOID); -#ifdef UNICODE -#define LPDIENUMDEVICESBYSEMANTICSCB LPDIENUMDEVICESBYSEMANTICSCBW -#else -#define LPDIENUMDEVICESBYSEMANTICSCB LPDIENUMDEVICESBYSEMANTICSCBA -#endif // !UNICODE -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -#if(DIRECTINPUT_VERSION >= 0x0800) -#define DIEDBS_MAPPEDPRI1 0x00000001 -#define DIEDBS_MAPPEDPRI2 0x00000002 -#define DIEDBS_RECENTDEVICE 0x00000010 -#define DIEDBS_NEWDEVICE 0x00000020 -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -#if(DIRECTINPUT_VERSION >= 0x0800) -#define DIEDBSFL_ATTACHEDONLY 0x00000000 -#define DIEDBSFL_THISUSER 0x00000010 -#define DIEDBSFL_FORCEFEEDBACK DIEDFL_FORCEFEEDBACK -#define DIEDBSFL_AVAILABLEDEVICES 0x00001000 -#define DIEDBSFL_MULTIMICEKEYBOARDS 0x00002000 -#define DIEDBSFL_NONGAMINGDEVICES 0x00004000 -#define DIEDBSFL_VALID 0x00007110 -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -#undef INTERFACE -#define INTERFACE IDirectInputW - -DECLARE_INTERFACE_(IDirectInputW, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputW methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; -}; - -typedef struct IDirectInputW *LPDIRECTINPUTW; - -#undef INTERFACE -#define INTERFACE IDirectInputA - -DECLARE_INTERFACE_(IDirectInputA, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputA methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; -}; - -typedef struct IDirectInputA *LPDIRECTINPUTA; - -#ifdef UNICODE -#define IID_IDirectInput IID_IDirectInputW -#define IDirectInput IDirectInputW -#define IDirectInputVtbl IDirectInputWVtbl -#else -#define IID_IDirectInput IID_IDirectInputA -#define IDirectInput IDirectInputA -#define IDirectInputVtbl IDirectInputAVtbl -#endif -typedef struct IDirectInput *LPDIRECTINPUT; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInput_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInput_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#else -#define IDirectInput_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput_AddRef(p) (p)->AddRef() -#define IDirectInput_Release(p) (p)->Release() -#define IDirectInput_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput_Initialize(p,a,b) (p)->Initialize(a,b) -#endif - -#undef INTERFACE -#define INTERFACE IDirectInput2W - -DECLARE_INTERFACE_(IDirectInput2W, IDirectInputW) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputW methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; - - /*** IDirectInput2W methods ***/ - STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; -}; - -typedef struct IDirectInput2W *LPDIRECTINPUT2W; - -#undef INTERFACE -#define INTERFACE IDirectInput2A - -DECLARE_INTERFACE_(IDirectInput2A, IDirectInputA) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInputA methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; - - /*** IDirectInput2A methods ***/ - STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; -}; - -typedef struct IDirectInput2A *LPDIRECTINPUT2A; - -#ifdef UNICODE -#define IID_IDirectInput2 IID_IDirectInput2W -#define IDirectInput2 IDirectInput2W -#define IDirectInput2Vtbl IDirectInput2WVtbl -#else -#define IID_IDirectInput2 IID_IDirectInput2A -#define IDirectInput2 IDirectInput2A -#define IDirectInput2Vtbl IDirectInput2AVtbl -#endif -typedef struct IDirectInput2 *LPDIRECTINPUT2; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInput2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput2_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput2_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInput2_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput2_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectInput2_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) -#else -#define IDirectInput2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput2_AddRef(p) (p)->AddRef() -#define IDirectInput2_Release(p) (p)->Release() -#define IDirectInput2_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput2_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput2_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectInput2_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) -#endif - - -#undef INTERFACE -#define INTERFACE IDirectInput7W - -DECLARE_INTERFACE_(IDirectInput7W, IDirectInput2W) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInput2W methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; - STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; - - /*** IDirectInput7W methods ***/ - STDMETHOD(CreateDeviceEx)(THIS_ REFGUID,REFIID,LPVOID *,LPUNKNOWN) PURE; -}; - -typedef struct IDirectInput7W *LPDIRECTINPUT7W; - -#undef INTERFACE -#define INTERFACE IDirectInput7A - -DECLARE_INTERFACE_(IDirectInput7A, IDirectInput2A) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInput2A methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; - STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; - - /*** IDirectInput7A methods ***/ - STDMETHOD(CreateDeviceEx)(THIS_ REFGUID,REFIID,LPVOID *,LPUNKNOWN) PURE; -}; - -typedef struct IDirectInput7A *LPDIRECTINPUT7A; - -#ifdef UNICODE -#define IID_IDirectInput7 IID_IDirectInput7W -#define IDirectInput7 IDirectInput7W -#define IDirectInput7Vtbl IDirectInput7WVtbl -#else -#define IID_IDirectInput7 IID_IDirectInput7A -#define IDirectInput7 IDirectInput7A -#define IDirectInput7Vtbl IDirectInput7AVtbl -#endif -typedef struct IDirectInput7 *LPDIRECTINPUT7; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInput7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput7_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput7_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInput7_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput7_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectInput7_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) -#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d) -#else -#define IDirectInput7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput7_AddRef(p) (p)->AddRef() -#define IDirectInput7_Release(p) (p)->Release() -#define IDirectInput7_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput7_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput7_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectInput7_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) -#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->CreateDeviceEx(a,b,c,d) -#endif - -#if(DIRECTINPUT_VERSION >= 0x0800) -#undef INTERFACE -#define INTERFACE IDirectInput8W - -DECLARE_INTERFACE_(IDirectInput8W, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInput8W methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICE8W *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; - STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; - STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR,LPDIACTIONFORMATW,LPDIENUMDEVICESBYSEMANTICSCBW,LPVOID,DWORD) PURE; - STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK,LPDICONFIGUREDEVICESPARAMSW,DWORD,LPVOID) PURE; -}; - -typedef struct IDirectInput8W *LPDIRECTINPUT8W; - -#undef INTERFACE -#define INTERFACE IDirectInput8A - -DECLARE_INTERFACE_(IDirectInput8A, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirectInput8A methods ***/ - STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICE8A *,LPUNKNOWN) PURE; - STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; - STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; - STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; - STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; - STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; - STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCSTR,LPDIACTIONFORMATA,LPDIENUMDEVICESBYSEMANTICSCBA,LPVOID,DWORD) PURE; - STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK,LPDICONFIGUREDEVICESPARAMSA,DWORD,LPVOID) PURE; -}; - -typedef struct IDirectInput8A *LPDIRECTINPUT8A; - -#ifdef UNICODE -#define IID_IDirectInput8 IID_IDirectInput8W -#define IDirectInput8 IDirectInput8W -#define IDirectInput8Vtbl IDirectInput8WVtbl -#else -#define IID_IDirectInput8 IID_IDirectInput8A -#define IDirectInput8 IDirectInput8A -#define IDirectInput8Vtbl IDirectInput8AVtbl -#endif -typedef struct IDirectInput8 *LPDIRECTINPUT8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectInput8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirectInput8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirectInput8_Release(p) (p)->lpVtbl->Release(p) -#define IDirectInput8_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) -#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) -#define IDirectInput8_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) -#define IDirectInput8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) -#define IDirectInput8_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectInput8_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) -#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e) -#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d) -#else -#define IDirectInput8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirectInput8_AddRef(p) (p)->AddRef() -#define IDirectInput8_Release(p) (p)->Release() -#define IDirectInput8_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) -#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) -#define IDirectInput8_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) -#define IDirectInput8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) -#define IDirectInput8_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectInput8_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) -#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->EnumDevicesBySemantics(a,b,c,d,e) -#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->ConfigureDevices(a,b,c,d) -#endif -#endif /* DIRECTINPUT_VERSION >= 0x0800 */ - -#if DIRECTINPUT_VERSION > 0x0700 - -extern HRESULT WINAPI DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); - -#else -extern HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter); -extern HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter); -#ifdef UNICODE -#define DirectInputCreate DirectInputCreateW -#else -#define DirectInputCreate DirectInputCreateA -#endif // !UNICODE - -extern HRESULT WINAPI DirectInputCreateEx(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); - -#endif /* DIRECTINPUT_VERSION > 0x700 */ - -#endif /* DIJ_RINGZERO */ - - -/**************************************************************************** - * - * Return Codes - * - ****************************************************************************/ - -/* - * The operation completed successfully. - */ -#define DI_OK S_OK - -/* - * The device exists but is not currently attached. - */ -#define DI_NOTATTACHED S_FALSE - -/* - * The device buffer overflowed. Some input was lost. - */ -#define DI_BUFFEROVERFLOW S_FALSE - -/* - * The change in device properties had no effect. - */ -#define DI_PROPNOEFFECT S_FALSE - -/* - * The operation had no effect. - */ -#define DI_NOEFFECT S_FALSE - -/* - * The device is a polled device. As a result, device buffering - * will not collect any data and event notifications will not be - * signalled until GetDeviceState is called. - */ -#define DI_POLLEDDEVICE ((HRESULT)0x00000002L) - -/* - * The parameters of the effect were successfully updated by - * IDirectInputEffect::SetParameters, but the effect was not - * downloaded because the device is not exclusively acquired - * or because the DIEP_NODOWNLOAD flag was passed. - */ -#define DI_DOWNLOADSKIPPED ((HRESULT)0x00000003L) - -/* - * The parameters of the effect were successfully updated by - * IDirectInputEffect::SetParameters, but in order to change - * the parameters, the effect needed to be restarted. - */ -#define DI_EFFECTRESTARTED ((HRESULT)0x00000004L) - -/* - * The parameters of the effect were successfully updated by - * IDirectInputEffect::SetParameters, but some of them were - * beyond the capabilities of the device and were truncated. - */ -#define DI_TRUNCATED ((HRESULT)0x00000008L) - -/* - * The settings have been successfully applied but could not be - * persisted. - */ -#define DI_SETTINGSNOTSAVED ((HRESULT)0x0000000BL) - -/* - * Equal to DI_EFFECTRESTARTED | DI_TRUNCATED. - */ -#define DI_TRUNCATEDANDRESTARTED ((HRESULT)0x0000000CL) - -/* - * A SUCCESS code indicating that settings cannot be modified. - */ -#define DI_WRITEPROTECT ((HRESULT)0x00000013L) - -/* - * The application requires a newer version of DirectInput. - */ -#define DIERR_OLDDIRECTINPUTVERSION \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION) - -/* - * The application was written for an unsupported prerelease version - * of DirectInput. - */ -#define DIERR_BETADIRECTINPUTVERSION \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_RMODE_APP) - -/* - * The object could not be created due to an incompatible driver version - * or mismatched or incomplete driver components. - */ -#define DIERR_BADDRIVERVER \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BAD_DRIVER_LEVEL) - -/* - * The device or device instance or effect is not registered with DirectInput. - */ -#define DIERR_DEVICENOTREG REGDB_E_CLASSNOTREG - -/* - * The requested object does not exist. - */ -#define DIERR_NOTFOUND \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) - -/* - * The requested object does not exist. - */ -#define DIERR_OBJECTNOTFOUND \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) - -/* - * An invalid parameter was passed to the returning function, - * or the object was not in a state that admitted the function - * to be called. - */ -#define DIERR_INVALIDPARAM E_INVALIDARG - -/* - * The specified interface is not supported by the object - */ -#define DIERR_NOINTERFACE E_NOINTERFACE - -/* - * An undetermined error occured inside the DInput subsystem - */ -#define DIERR_GENERIC E_FAIL - -/* - * The DInput subsystem couldn't allocate sufficient memory to complete the - * caller's request. - */ -#define DIERR_OUTOFMEMORY E_OUTOFMEMORY - -/* - * The function called is not supported at this time - */ -#define DIERR_UNSUPPORTED E_NOTIMPL - -/* - * This object has not been initialized - */ -#define DIERR_NOTINITIALIZED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_READY) - -/* - * This object is already initialized - */ -#define DIERR_ALREADYINITIALIZED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_INITIALIZED) - -/* - * This object does not support aggregation - */ -#define DIERR_NOAGGREGATION CLASS_E_NOAGGREGATION - -/* - * Another app has a higher priority level, preventing this call from - * succeeding. - */ -#define DIERR_OTHERAPPHASPRIO E_ACCESSDENIED - -/* - * Access to the device has been lost. It must be re-acquired. - */ -#define DIERR_INPUTLOST \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT) - -/* - * The operation cannot be performed while the device is acquired. - */ -#define DIERR_ACQUIRED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BUSY) - -/* - * The operation cannot be performed unless the device is acquired. - */ -#define DIERR_NOTACQUIRED \ - MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INVALID_ACCESS) - -/* - * The specified property cannot be changed. - */ -#define DIERR_READONLY E_ACCESSDENIED - -/* - * The device already has an event notification associated with it. - */ -#define DIERR_HANDLEEXISTS E_ACCESSDENIED - -/* - * Data is not yet available. - */ -#ifndef E_PENDING -#define E_PENDING 0x8000000AL -#endif - -/* - * Unable to IDirectInputJoyConfig_Acquire because the user - * does not have sufficient privileges to change the joystick - * configuration. - */ -#define DIERR_INSUFFICIENTPRIVS 0x80040200L - -/* - * The device is full. - */ -#define DIERR_DEVICEFULL 0x80040201L - -/* - * Not all the requested information fit into the buffer. - */ -#define DIERR_MOREDATA 0x80040202L - -/* - * The effect is not downloaded. - */ -#define DIERR_NOTDOWNLOADED 0x80040203L - -/* - * The device cannot be reinitialized because there are still effects - * attached to it. - */ -#define DIERR_HASEFFECTS 0x80040204L - -/* - * The operation cannot be performed unless the device is acquired - * in DISCL_EXCLUSIVE mode. - */ -#define DIERR_NOTEXCLUSIVEACQUIRED 0x80040205L - -/* - * The effect could not be downloaded because essential information - * is missing. For example, no axes have been associated with the - * effect, or no type-specific information has been created. - */ -#define DIERR_INCOMPLETEEFFECT 0x80040206L - -/* - * Attempted to read buffered device data from a device that is - * not buffered. - */ -#define DIERR_NOTBUFFERED 0x80040207L - -/* - * An attempt was made to modify parameters of an effect while it is - * playing. Not all hardware devices support altering the parameters - * of an effect while it is playing. - */ -#define DIERR_EFFECTPLAYING 0x80040208L - -/* - * The operation could not be completed because the device is not - * plugged in. - */ -#define DIERR_UNPLUGGED 0x80040209L - -/* - * SendDeviceData failed because more information was requested - * to be sent than can be sent to the device. Some devices have - * restrictions on how much data can be sent to them. (For example, - * there might be a limit on the number of buttons that can be - * pressed at once.) - */ -#define DIERR_REPORTFULL 0x8004020AL - - -/* - * A mapper file function failed because reading or writing the user or IHV - * settings file failed. - */ -#define DIERR_MAPFILEFAIL 0x8004020BL - - -/*--- DINPUT Mapper Definitions: New for Dx8 ---*/ - - -/*--- Keyboard - Physical Keyboard Device ---*/ - -#define DIKEYBOARD_ESCAPE 0x81000401 -#define DIKEYBOARD_1 0x81000402 -#define DIKEYBOARD_2 0x81000403 -#define DIKEYBOARD_3 0x81000404 -#define DIKEYBOARD_4 0x81000405 -#define DIKEYBOARD_5 0x81000406 -#define DIKEYBOARD_6 0x81000407 -#define DIKEYBOARD_7 0x81000408 -#define DIKEYBOARD_8 0x81000409 -#define DIKEYBOARD_9 0x8100040A -#define DIKEYBOARD_0 0x8100040B -#define DIKEYBOARD_MINUS 0x8100040C /* - on main keyboard */ -#define DIKEYBOARD_EQUALS 0x8100040D -#define DIKEYBOARD_BACK 0x8100040E /* backspace */ -#define DIKEYBOARD_TAB 0x8100040F -#define DIKEYBOARD_Q 0x81000410 -#define DIKEYBOARD_W 0x81000411 -#define DIKEYBOARD_E 0x81000412 -#define DIKEYBOARD_R 0x81000413 -#define DIKEYBOARD_T 0x81000414 -#define DIKEYBOARD_Y 0x81000415 -#define DIKEYBOARD_U 0x81000416 -#define DIKEYBOARD_I 0x81000417 -#define DIKEYBOARD_O 0x81000418 -#define DIKEYBOARD_P 0x81000419 -#define DIKEYBOARD_LBRACKET 0x8100041A -#define DIKEYBOARD_RBRACKET 0x8100041B -#define DIKEYBOARD_RETURN 0x8100041C /* Enter on main keyboard */ -#define DIKEYBOARD_LCONTROL 0x8100041D -#define DIKEYBOARD_A 0x8100041E -#define DIKEYBOARD_S 0x8100041F -#define DIKEYBOARD_D 0x81000420 -#define DIKEYBOARD_F 0x81000421 -#define DIKEYBOARD_G 0x81000422 -#define DIKEYBOARD_H 0x81000423 -#define DIKEYBOARD_J 0x81000424 -#define DIKEYBOARD_K 0x81000425 -#define DIKEYBOARD_L 0x81000426 -#define DIKEYBOARD_SEMICOLON 0x81000427 -#define DIKEYBOARD_APOSTROPHE 0x81000428 -#define DIKEYBOARD_GRAVE 0x81000429 /* accent grave */ -#define DIKEYBOARD_LSHIFT 0x8100042A -#define DIKEYBOARD_BACKSLASH 0x8100042B -#define DIKEYBOARD_Z 0x8100042C -#define DIKEYBOARD_X 0x8100042D -#define DIKEYBOARD_C 0x8100042E -#define DIKEYBOARD_V 0x8100042F -#define DIKEYBOARD_B 0x81000430 -#define DIKEYBOARD_N 0x81000431 -#define DIKEYBOARD_M 0x81000432 -#define DIKEYBOARD_COMMA 0x81000433 -#define DIKEYBOARD_PERIOD 0x81000434 /* . on main keyboard */ -#define DIKEYBOARD_SLASH 0x81000435 /* / on main keyboard */ -#define DIKEYBOARD_RSHIFT 0x81000436 -#define DIKEYBOARD_MULTIPLY 0x81000437 /* * on numeric keypad */ -#define DIKEYBOARD_LMENU 0x81000438 /* left Alt */ -#define DIKEYBOARD_SPACE 0x81000439 -#define DIKEYBOARD_CAPITAL 0x8100043A -#define DIKEYBOARD_F1 0x8100043B -#define DIKEYBOARD_F2 0x8100043C -#define DIKEYBOARD_F3 0x8100043D -#define DIKEYBOARD_F4 0x8100043E -#define DIKEYBOARD_F5 0x8100043F -#define DIKEYBOARD_F6 0x81000440 -#define DIKEYBOARD_F7 0x81000441 -#define DIKEYBOARD_F8 0x81000442 -#define DIKEYBOARD_F9 0x81000443 -#define DIKEYBOARD_F10 0x81000444 -#define DIKEYBOARD_NUMLOCK 0x81000445 -#define DIKEYBOARD_SCROLL 0x81000446 /* Scroll Lock */ -#define DIKEYBOARD_NUMPAD7 0x81000447 -#define DIKEYBOARD_NUMPAD8 0x81000448 -#define DIKEYBOARD_NUMPAD9 0x81000449 -#define DIKEYBOARD_SUBTRACT 0x8100044A /* - on numeric keypad */ -#define DIKEYBOARD_NUMPAD4 0x8100044B -#define DIKEYBOARD_NUMPAD5 0x8100044C -#define DIKEYBOARD_NUMPAD6 0x8100044D -#define DIKEYBOARD_ADD 0x8100044E /* + on numeric keypad */ -#define DIKEYBOARD_NUMPAD1 0x8100044F -#define DIKEYBOARD_NUMPAD2 0x81000450 -#define DIKEYBOARD_NUMPAD3 0x81000451 -#define DIKEYBOARD_NUMPAD0 0x81000452 -#define DIKEYBOARD_DECIMAL 0x81000453 /* . on numeric keypad */ -#define DIKEYBOARD_OEM_102 0x81000456 /* <> or \| on RT 102-key keyboard (Non-U.S.) */ -#define DIKEYBOARD_F11 0x81000457 -#define DIKEYBOARD_F12 0x81000458 -#define DIKEYBOARD_F13 0x81000464 /* (NEC PC98) */ -#define DIKEYBOARD_F14 0x81000465 /* (NEC PC98) */ -#define DIKEYBOARD_F15 0x81000466 /* (NEC PC98) */ -#define DIKEYBOARD_KANA 0x81000470 /* (Japanese keyboard) */ -#define DIKEYBOARD_ABNT_C1 0x81000473 /* /? on Brazilian keyboard */ -#define DIKEYBOARD_CONVERT 0x81000479 /* (Japanese keyboard) */ -#define DIKEYBOARD_NOCONVERT 0x8100047B /* (Japanese keyboard) */ -#define DIKEYBOARD_YEN 0x8100047D /* (Japanese keyboard) */ -#define DIKEYBOARD_ABNT_C2 0x8100047E /* Numpad . on Brazilian keyboard */ -#define DIKEYBOARD_NUMPADEQUALS 0x8100048D /* = on numeric keypad (NEC PC98) */ -#define DIKEYBOARD_PREVTRACK 0x81000490 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ -#define DIKEYBOARD_AT 0x81000491 /* (NEC PC98) */ -#define DIKEYBOARD_COLON 0x81000492 /* (NEC PC98) */ -#define DIKEYBOARD_UNDERLINE 0x81000493 /* (NEC PC98) */ -#define DIKEYBOARD_KANJI 0x81000494 /* (Japanese keyboard) */ -#define DIKEYBOARD_STOP 0x81000495 /* (NEC PC98) */ -#define DIKEYBOARD_AX 0x81000496 /* (Japan AX) */ -#define DIKEYBOARD_UNLABELED 0x81000497 /* (J3100) */ -#define DIKEYBOARD_NEXTTRACK 0x81000499 /* Next Track */ -#define DIKEYBOARD_NUMPADENTER 0x8100049C /* Enter on numeric keypad */ -#define DIKEYBOARD_RCONTROL 0x8100049D -#define DIKEYBOARD_MUTE 0x810004A0 /* Mute */ -#define DIKEYBOARD_CALCULATOR 0x810004A1 /* Calculator */ -#define DIKEYBOARD_PLAYPAUSE 0x810004A2 /* Play / Pause */ -#define DIKEYBOARD_MEDIASTOP 0x810004A4 /* Media Stop */ -#define DIKEYBOARD_VOLUMEDOWN 0x810004AE /* Volume - */ -#define DIKEYBOARD_VOLUMEUP 0x810004B0 /* Volume + */ -#define DIKEYBOARD_WEBHOME 0x810004B2 /* Web home */ -#define DIKEYBOARD_NUMPADCOMMA 0x810004B3 /* , on numeric keypad (NEC PC98) */ -#define DIKEYBOARD_DIVIDE 0x810004B5 /* / on numeric keypad */ -#define DIKEYBOARD_SYSRQ 0x810004B7 -#define DIKEYBOARD_RMENU 0x810004B8 /* right Alt */ -#define DIKEYBOARD_PAUSE 0x810004C5 /* Pause */ -#define DIKEYBOARD_HOME 0x810004C7 /* Home on arrow keypad */ -#define DIKEYBOARD_UP 0x810004C8 /* UpArrow on arrow keypad */ -#define DIKEYBOARD_PRIOR 0x810004C9 /* PgUp on arrow keypad */ -#define DIKEYBOARD_LEFT 0x810004CB /* LeftArrow on arrow keypad */ -#define DIKEYBOARD_RIGHT 0x810004CD /* RightArrow on arrow keypad */ -#define DIKEYBOARD_END 0x810004CF /* End on arrow keypad */ -#define DIKEYBOARD_DOWN 0x810004D0 /* DownArrow on arrow keypad */ -#define DIKEYBOARD_NEXT 0x810004D1 /* PgDn on arrow keypad */ -#define DIKEYBOARD_INSERT 0x810004D2 /* Insert on arrow keypad */ -#define DIKEYBOARD_DELETE 0x810004D3 /* Delete on arrow keypad */ -#define DIKEYBOARD_LWIN 0x810004DB /* Left Windows key */ -#define DIKEYBOARD_RWIN 0x810004DC /* Right Windows key */ -#define DIKEYBOARD_APPS 0x810004DD /* AppMenu key */ -#define DIKEYBOARD_POWER 0x810004DE /* System Power */ -#define DIKEYBOARD_SLEEP 0x810004DF /* System Sleep */ -#define DIKEYBOARD_WAKE 0x810004E3 /* System Wake */ -#define DIKEYBOARD_WEBSEARCH 0x810004E5 /* Web Search */ -#define DIKEYBOARD_WEBFAVORITES 0x810004E6 /* Web Favorites */ -#define DIKEYBOARD_WEBREFRESH 0x810004E7 /* Web Refresh */ -#define DIKEYBOARD_WEBSTOP 0x810004E8 /* Web Stop */ -#define DIKEYBOARD_WEBFORWARD 0x810004E9 /* Web Forward */ -#define DIKEYBOARD_WEBBACK 0x810004EA /* Web Back */ -#define DIKEYBOARD_MYCOMPUTER 0x810004EB /* My Computer */ -#define DIKEYBOARD_MAIL 0x810004EC /* Mail */ -#define DIKEYBOARD_MEDIASELECT 0x810004ED /* Media Select */ - - -/*--- MOUSE - Physical Mouse Device ---*/ - -#define DIMOUSE_XAXISAB (0x82000200 |DIMOFS_X ) /* X Axis-absolute: Some mice natively report absolute coordinates */ -#define DIMOUSE_YAXISAB (0x82000200 |DIMOFS_Y ) /* Y Axis-absolute: Some mice natively report absolute coordinates */ -#define DIMOUSE_XAXIS (0x82000300 |DIMOFS_X ) /* X Axis */ -#define DIMOUSE_YAXIS (0x82000300 |DIMOFS_Y ) /* Y Axis */ -#define DIMOUSE_WHEEL (0x82000300 |DIMOFS_Z ) /* Z Axis */ -#define DIMOUSE_BUTTON0 (0x82000400 |DIMOFS_BUTTON0) /* Button 0 */ -#define DIMOUSE_BUTTON1 (0x82000400 |DIMOFS_BUTTON1) /* Button 1 */ -#define DIMOUSE_BUTTON2 (0x82000400 |DIMOFS_BUTTON2) /* Button 2 */ -#define DIMOUSE_BUTTON3 (0x82000400 |DIMOFS_BUTTON3) /* Button 3 */ -#define DIMOUSE_BUTTON4 (0x82000400 |DIMOFS_BUTTON4) /* Button 4 */ -#define DIMOUSE_BUTTON5 (0x82000400 |DIMOFS_BUTTON5) /* Button 5 */ -#define DIMOUSE_BUTTON6 (0x82000400 |DIMOFS_BUTTON6) /* Button 6 */ -#define DIMOUSE_BUTTON7 (0x82000400 |DIMOFS_BUTTON7) /* Button 7 */ - - -/*--- VOICE - Physical Dplay Voice Device ---*/ - -#define DIVOICE_CHANNEL1 0x83000401 -#define DIVOICE_CHANNEL2 0x83000402 -#define DIVOICE_CHANNEL3 0x83000403 -#define DIVOICE_CHANNEL4 0x83000404 -#define DIVOICE_CHANNEL5 0x83000405 -#define DIVOICE_CHANNEL6 0x83000406 -#define DIVOICE_CHANNEL7 0x83000407 -#define DIVOICE_CHANNEL8 0x83000408 -#define DIVOICE_TEAM 0x83000409 -#define DIVOICE_ALL 0x8300040A -#define DIVOICE_RECORDMUTE 0x8300040B -#define DIVOICE_PLAYBACKMUTE 0x8300040C -#define DIVOICE_TRANSMIT 0x8300040D - -#define DIVOICE_VOICECOMMAND 0x83000410 - - -/*--- Driving Simulator - Racing - Vehicle control is primary objective ---*/ -#define DIVIRTUAL_DRIVING_RACE 0x01000000 -#define DIAXIS_DRIVINGR_STEER 0x01008A01 /* Steering */ -#define DIAXIS_DRIVINGR_ACCELERATE 0x01039202 /* Accelerate */ -#define DIAXIS_DRIVINGR_BRAKE 0x01041203 /* Brake-Axis */ -#define DIBUTTON_DRIVINGR_SHIFTUP 0x01000C01 /* Shift to next higher gear */ -#define DIBUTTON_DRIVINGR_SHIFTDOWN 0x01000C02 /* Shift to next lower gear */ -#define DIBUTTON_DRIVINGR_VIEW 0x01001C03 /* Cycle through view options */ -#define DIBUTTON_DRIVINGR_MENU 0x010004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIAXIS_DRIVINGR_ACCEL_AND_BRAKE 0x01014A04 /* Some devices combine accelerate and brake in a single axis */ -#define DIHATSWITCH_DRIVINGR_GLANCE 0x01004601 /* Look around */ -#define DIBUTTON_DRIVINGR_BRAKE 0x01004C04 /* Brake-button */ -#define DIBUTTON_DRIVINGR_DASHBOARD 0x01004405 /* Select next dashboard option */ -#define DIBUTTON_DRIVINGR_AIDS 0x01004406 /* Driver correction aids */ -#define DIBUTTON_DRIVINGR_MAP 0x01004407 /* Display Driving Map */ -#define DIBUTTON_DRIVINGR_BOOST 0x01004408 /* Turbo Boost */ -#define DIBUTTON_DRIVINGR_PIT 0x01004409 /* Pit stop notification */ -#define DIBUTTON_DRIVINGR_ACCELERATE_LINK 0x0103D4E0 /* Fallback Accelerate button */ -#define DIBUTTON_DRIVINGR_STEER_LEFT_LINK 0x0100CCE4 /* Fallback Steer Left button */ -#define DIBUTTON_DRIVINGR_STEER_RIGHT_LINK 0x0100CCEC /* Fallback Steer Right button */ -#define DIBUTTON_DRIVINGR_GLANCE_LEFT_LINK 0x0107C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_DRIVINGR_GLANCE_RIGHT_LINK 0x0107C4EC /* Fallback Glance Right button */ -#define DIBUTTON_DRIVINGR_DEVICE 0x010044FE /* Show input device and controls */ -#define DIBUTTON_DRIVINGR_PAUSE 0x010044FC /* Start / Pause / Restart game */ - -/*--- Driving Simulator - Combat - Combat from within a vehicle is primary objective ---*/ -#define DIVIRTUAL_DRIVING_COMBAT 0x02000000 -#define DIAXIS_DRIVINGC_STEER 0x02008A01 /* Steering */ -#define DIAXIS_DRIVINGC_ACCELERATE 0x02039202 /* Accelerate */ -#define DIAXIS_DRIVINGC_BRAKE 0x02041203 /* Brake-axis */ -#define DIBUTTON_DRIVINGC_FIRE 0x02000C01 /* Fire */ -#define DIBUTTON_DRIVINGC_WEAPONS 0x02000C02 /* Select next weapon */ -#define DIBUTTON_DRIVINGC_TARGET 0x02000C03 /* Select next available target */ -#define DIBUTTON_DRIVINGC_MENU 0x020004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIAXIS_DRIVINGC_ACCEL_AND_BRAKE 0x02014A04 /* Some devices combine accelerate and brake in a single axis */ -#define DIHATSWITCH_DRIVINGC_GLANCE 0x02004601 /* Look around */ -#define DIBUTTON_DRIVINGC_SHIFTUP 0x02004C04 /* Shift to next higher gear */ -#define DIBUTTON_DRIVINGC_SHIFTDOWN 0x02004C05 /* Shift to next lower gear */ -#define DIBUTTON_DRIVINGC_DASHBOARD 0x02004406 /* Select next dashboard option */ -#define DIBUTTON_DRIVINGC_AIDS 0x02004407 /* Driver correction aids */ -#define DIBUTTON_DRIVINGC_BRAKE 0x02004C08 /* Brake-button */ -#define DIBUTTON_DRIVINGC_FIRESECONDARY 0x02004C09 /* Alternative fire button */ -#define DIBUTTON_DRIVINGC_ACCELERATE_LINK 0x0203D4E0 /* Fallback Accelerate button */ -#define DIBUTTON_DRIVINGC_STEER_LEFT_LINK 0x0200CCE4 /* Fallback Steer Left button */ -#define DIBUTTON_DRIVINGC_STEER_RIGHT_LINK 0x0200CCEC /* Fallback Steer Right button */ -#define DIBUTTON_DRIVINGC_GLANCE_LEFT_LINK 0x0207C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_DRIVINGC_GLANCE_RIGHT_LINK 0x0207C4EC /* Fallback Glance Right button */ -#define DIBUTTON_DRIVINGC_DEVICE 0x020044FE /* Show input device and controls */ -#define DIBUTTON_DRIVINGC_PAUSE 0x020044FC /* Start / Pause / Restart game */ - -/*--- Driving Simulator - Tank - Combat from withing a tank is primary objective ---*/ -#define DIVIRTUAL_DRIVING_TANK 0x03000000 -#define DIAXIS_DRIVINGT_STEER 0x03008A01 /* Turn tank left / right */ -#define DIAXIS_DRIVINGT_BARREL 0x03010202 /* Raise / lower barrel */ -#define DIAXIS_DRIVINGT_ACCELERATE 0x03039203 /* Accelerate */ -#define DIAXIS_DRIVINGT_ROTATE 0x03020204 /* Turn barrel left / right */ -#define DIBUTTON_DRIVINGT_FIRE 0x03000C01 /* Fire */ -#define DIBUTTON_DRIVINGT_WEAPONS 0x03000C02 /* Select next weapon */ -#define DIBUTTON_DRIVINGT_TARGET 0x03000C03 /* Selects next available target */ -#define DIBUTTON_DRIVINGT_MENU 0x030004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_DRIVINGT_GLANCE 0x03004601 /* Look around */ -#define DIAXIS_DRIVINGT_BRAKE 0x03045205 /* Brake-axis */ -#define DIAXIS_DRIVINGT_ACCEL_AND_BRAKE 0x03014A06 /* Some devices combine accelerate and brake in a single axis */ -#define DIBUTTON_DRIVINGT_VIEW 0x03005C04 /* Cycle through view options */ -#define DIBUTTON_DRIVINGT_DASHBOARD 0x03005C05 /* Select next dashboard option */ -#define DIBUTTON_DRIVINGT_BRAKE 0x03004C06 /* Brake-button */ -#define DIBUTTON_DRIVINGT_FIRESECONDARY 0x03004C07 /* Alternative fire button */ -#define DIBUTTON_DRIVINGT_ACCELERATE_LINK 0x0303D4E0 /* Fallback Accelerate button */ -#define DIBUTTON_DRIVINGT_STEER_LEFT_LINK 0x0300CCE4 /* Fallback Steer Left button */ -#define DIBUTTON_DRIVINGT_STEER_RIGHT_LINK 0x0300CCEC /* Fallback Steer Right button */ -#define DIBUTTON_DRIVINGT_BARREL_UP_LINK 0x030144E0 /* Fallback Barrel up button */ -#define DIBUTTON_DRIVINGT_BARREL_DOWN_LINK 0x030144E8 /* Fallback Barrel down button */ -#define DIBUTTON_DRIVINGT_ROTATE_LEFT_LINK 0x030244E4 /* Fallback Rotate left button */ -#define DIBUTTON_DRIVINGT_ROTATE_RIGHT_LINK 0x030244EC /* Fallback Rotate right button */ -#define DIBUTTON_DRIVINGT_GLANCE_LEFT_LINK 0x0307C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_DRIVINGT_GLANCE_RIGHT_LINK 0x0307C4EC /* Fallback Glance Right button */ -#define DIBUTTON_DRIVINGT_DEVICE 0x030044FE /* Show input device and controls */ -#define DIBUTTON_DRIVINGT_PAUSE 0x030044FC /* Start / Pause / Restart game */ - -/*--- Flight Simulator - Civilian - Plane control is the primary objective ---*/ -#define DIVIRTUAL_FLYING_CIVILIAN 0x04000000 -#define DIAXIS_FLYINGC_BANK 0x04008A01 /* Roll ship left / right */ -#define DIAXIS_FLYINGC_PITCH 0x04010A02 /* Nose up / down */ -#define DIAXIS_FLYINGC_THROTTLE 0x04039203 /* Throttle */ -#define DIBUTTON_FLYINGC_VIEW 0x04002401 /* Cycle through view options */ -#define DIBUTTON_FLYINGC_DISPLAY 0x04002402 /* Select next dashboard / heads up display option */ -#define DIBUTTON_FLYINGC_GEAR 0x04002C03 /* Gear up / down */ -#define DIBUTTON_FLYINGC_MENU 0x040004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_FLYINGC_GLANCE 0x04004601 /* Look around */ -#define DIAXIS_FLYINGC_BRAKE 0x04046A04 /* Apply Brake */ -#define DIAXIS_FLYINGC_RUDDER 0x04025205 /* Yaw ship left/right */ -#define DIAXIS_FLYINGC_FLAPS 0x04055A06 /* Flaps */ -#define DIBUTTON_FLYINGC_FLAPSUP 0x04006404 /* Increment stepping up until fully retracted */ -#define DIBUTTON_FLYINGC_FLAPSDOWN 0x04006405 /* Decrement stepping down until fully extended */ -#define DIBUTTON_FLYINGC_BRAKE_LINK 0x04046CE0 /* Fallback brake button */ -#define DIBUTTON_FLYINGC_FASTER_LINK 0x0403D4E0 /* Fallback throttle up button */ -#define DIBUTTON_FLYINGC_SLOWER_LINK 0x0403D4E8 /* Fallback throttle down button */ -#define DIBUTTON_FLYINGC_GLANCE_LEFT_LINK 0x0407C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_FLYINGC_GLANCE_RIGHT_LINK 0x0407C4EC /* Fallback Glance Right button */ -#define DIBUTTON_FLYINGC_GLANCE_UP_LINK 0x0407C4E0 /* Fallback Glance Up button */ -#define DIBUTTON_FLYINGC_GLANCE_DOWN_LINK 0x0407C4E8 /* Fallback Glance Down button */ -#define DIBUTTON_FLYINGC_DEVICE 0x040044FE /* Show input device and controls */ -#define DIBUTTON_FLYINGC_PAUSE 0x040044FC /* Start / Pause / Restart game */ - -/*--- Flight Simulator - Military - Aerial combat is the primary objective ---*/ -#define DIVIRTUAL_FLYING_MILITARY 0x05000000 -#define DIAXIS_FLYINGM_BANK 0x05008A01 /* Bank - Roll ship left / right */ -#define DIAXIS_FLYINGM_PITCH 0x05010A02 /* Pitch - Nose up / down */ -#define DIAXIS_FLYINGM_THROTTLE 0x05039203 /* Throttle - faster / slower */ -#define DIBUTTON_FLYINGM_FIRE 0x05000C01 /* Fire */ -#define DIBUTTON_FLYINGM_WEAPONS 0x05000C02 /* Select next weapon */ -#define DIBUTTON_FLYINGM_TARGET 0x05000C03 /* Selects next available target */ -#define DIBUTTON_FLYINGM_MENU 0x050004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_FLYINGM_GLANCE 0x05004601 /* Look around */ -#define DIBUTTON_FLYINGM_COUNTER 0x05005C04 /* Activate counter measures */ -#define DIAXIS_FLYINGM_RUDDER 0x05024A04 /* Rudder - Yaw ship left/right */ -#define DIAXIS_FLYINGM_BRAKE 0x05046205 /* Brake-axis */ -#define DIBUTTON_FLYINGM_VIEW 0x05006405 /* Cycle through view options */ -#define DIBUTTON_FLYINGM_DISPLAY 0x05006406 /* Select next dashboard option */ -#define DIAXIS_FLYINGM_FLAPS 0x05055206 /* Flaps */ -#define DIBUTTON_FLYINGM_FLAPSUP 0x05005407 /* Increment stepping up until fully retracted */ -#define DIBUTTON_FLYINGM_FLAPSDOWN 0x05005408 /* Decrement stepping down until fully extended */ -#define DIBUTTON_FLYINGM_FIRESECONDARY 0x05004C09 /* Alternative fire button */ -#define DIBUTTON_FLYINGM_GEAR 0x0500640A /* Gear up / down */ -#define DIBUTTON_FLYINGM_BRAKE_LINK 0x050464E0 /* Fallback brake button */ -#define DIBUTTON_FLYINGM_FASTER_LINK 0x0503D4E0 /* Fallback throttle up button */ -#define DIBUTTON_FLYINGM_SLOWER_LINK 0x0503D4E8 /* Fallback throttle down button */ -#define DIBUTTON_FLYINGM_GLANCE_LEFT_LINK 0x0507C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_FLYINGM_GLANCE_RIGHT_LINK 0x0507C4EC /* Fallback Glance Right button */ -#define DIBUTTON_FLYINGM_GLANCE_UP_LINK 0x0507C4E0 /* Fallback Glance Up button */ -#define DIBUTTON_FLYINGM_GLANCE_DOWN_LINK 0x0507C4E8 /* Fallback Glance Down button */ -#define DIBUTTON_FLYINGM_DEVICE 0x050044FE /* Show input device and controls */ -#define DIBUTTON_FLYINGM_PAUSE 0x050044FC /* Start / Pause / Restart game */ - -/*--- Flight Simulator - Combat Helicopter - Combat from helicopter is primary objective ---*/ -#define DIVIRTUAL_FLYING_HELICOPTER 0x06000000 -#define DIAXIS_FLYINGH_BANK 0x06008A01 /* Bank - Roll ship left / right */ -#define DIAXIS_FLYINGH_PITCH 0x06010A02 /* Pitch - Nose up / down */ -#define DIAXIS_FLYINGH_COLLECTIVE 0x06018A03 /* Collective - Blade pitch/power */ -#define DIBUTTON_FLYINGH_FIRE 0x06001401 /* Fire */ -#define DIBUTTON_FLYINGH_WEAPONS 0x06001402 /* Select next weapon */ -#define DIBUTTON_FLYINGH_TARGET 0x06001403 /* Selects next available target */ -#define DIBUTTON_FLYINGH_MENU 0x060004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_FLYINGH_GLANCE 0x06004601 /* Look around */ -#define DIAXIS_FLYINGH_TORQUE 0x06025A04 /* Torque - Rotate ship around left / right axis */ -#define DIAXIS_FLYINGH_THROTTLE 0x0603DA05 /* Throttle */ -#define DIBUTTON_FLYINGH_COUNTER 0x06005404 /* Activate counter measures */ -#define DIBUTTON_FLYINGH_VIEW 0x06006405 /* Cycle through view options */ -#define DIBUTTON_FLYINGH_GEAR 0x06006406 /* Gear up / down */ -#define DIBUTTON_FLYINGH_FIRESECONDARY 0x06004C07 /* Alternative fire button */ -#define DIBUTTON_FLYINGH_FASTER_LINK 0x0603DCE0 /* Fallback throttle up button */ -#define DIBUTTON_FLYINGH_SLOWER_LINK 0x0603DCE8 /* Fallback throttle down button */ -#define DIBUTTON_FLYINGH_GLANCE_LEFT_LINK 0x0607C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_FLYINGH_GLANCE_RIGHT_LINK 0x0607C4EC /* Fallback Glance Right button */ -#define DIBUTTON_FLYINGH_GLANCE_UP_LINK 0x0607C4E0 /* Fallback Glance Up button */ -#define DIBUTTON_FLYINGH_GLANCE_DOWN_LINK 0x0607C4E8 /* Fallback Glance Down button */ -#define DIBUTTON_FLYINGH_DEVICE 0x060044FE /* Show input device and controls */ -#define DIBUTTON_FLYINGH_PAUSE 0x060044FC /* Start / Pause / Restart game */ - -/*--- Space Simulator - Combat - Space Simulator with weapons ---*/ -#define DIVIRTUAL_SPACESIM 0x07000000 -#define DIAXIS_SPACESIM_LATERAL 0x07008201 /* Move ship left / right */ -#define DIAXIS_SPACESIM_MOVE 0x07010202 /* Move ship forward/backward */ -#define DIAXIS_SPACESIM_THROTTLE 0x07038203 /* Throttle - Engine speed */ -#define DIBUTTON_SPACESIM_FIRE 0x07000401 /* Fire */ -#define DIBUTTON_SPACESIM_WEAPONS 0x07000402 /* Select next weapon */ -#define DIBUTTON_SPACESIM_TARGET 0x07000403 /* Selects next available target */ -#define DIBUTTON_SPACESIM_MENU 0x070004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_SPACESIM_GLANCE 0x07004601 /* Look around */ -#define DIAXIS_SPACESIM_CLIMB 0x0701C204 /* Climb - Pitch ship up/down */ -#define DIAXIS_SPACESIM_ROTATE 0x07024205 /* Rotate - Turn ship left/right */ -#define DIBUTTON_SPACESIM_VIEW 0x07004404 /* Cycle through view options */ -#define DIBUTTON_SPACESIM_DISPLAY 0x07004405 /* Select next dashboard / heads up display option */ -#define DIBUTTON_SPACESIM_RAISE 0x07004406 /* Raise ship while maintaining current pitch */ -#define DIBUTTON_SPACESIM_LOWER 0x07004407 /* Lower ship while maintaining current pitch */ -#define DIBUTTON_SPACESIM_GEAR 0x07004408 /* Gear up / down */ -#define DIBUTTON_SPACESIM_FIRESECONDARY 0x07004409 /* Alternative fire button */ -#define DIBUTTON_SPACESIM_LEFT_LINK 0x0700C4E4 /* Fallback move left button */ -#define DIBUTTON_SPACESIM_RIGHT_LINK 0x0700C4EC /* Fallback move right button */ -#define DIBUTTON_SPACESIM_FORWARD_LINK 0x070144E0 /* Fallback move forward button */ -#define DIBUTTON_SPACESIM_BACKWARD_LINK 0x070144E8 /* Fallback move backwards button */ -#define DIBUTTON_SPACESIM_FASTER_LINK 0x0703C4E0 /* Fallback throttle up button */ -#define DIBUTTON_SPACESIM_SLOWER_LINK 0x0703C4E8 /* Fallback throttle down button */ -#define DIBUTTON_SPACESIM_TURN_LEFT_LINK 0x070244E4 /* Fallback turn left button */ -#define DIBUTTON_SPACESIM_TURN_RIGHT_LINK 0x070244EC /* Fallback turn right button */ -#define DIBUTTON_SPACESIM_GLANCE_LEFT_LINK 0x0707C4E4 /* Fallback Glance Left button */ -#define DIBUTTON_SPACESIM_GLANCE_RIGHT_LINK 0x0707C4EC /* Fallback Glance Right button */ -#define DIBUTTON_SPACESIM_GLANCE_UP_LINK 0x0707C4E0 /* Fallback Glance Up button */ -#define DIBUTTON_SPACESIM_GLANCE_DOWN_LINK 0x0707C4E8 /* Fallback Glance Down button */ -#define DIBUTTON_SPACESIM_DEVICE 0x070044FE /* Show input device and controls */ -#define DIBUTTON_SPACESIM_PAUSE 0x070044FC /* Start / Pause / Restart game */ - -/*--- Fighting - First Person - Hand to Hand combat is primary objective ---*/ -#define DIVIRTUAL_FIGHTING_HAND2HAND 0x08000000 -#define DIAXIS_FIGHTINGH_LATERAL 0x08008201 /* Sidestep left/right */ -#define DIAXIS_FIGHTINGH_MOVE 0x08010202 /* Move forward/backward */ -#define DIBUTTON_FIGHTINGH_PUNCH 0x08000401 /* Punch */ -#define DIBUTTON_FIGHTINGH_KICK 0x08000402 /* Kick */ -#define DIBUTTON_FIGHTINGH_BLOCK 0x08000403 /* Block */ -#define DIBUTTON_FIGHTINGH_CROUCH 0x08000404 /* Crouch */ -#define DIBUTTON_FIGHTINGH_JUMP 0x08000405 /* Jump */ -#define DIBUTTON_FIGHTINGH_SPECIAL1 0x08000406 /* Apply first special move */ -#define DIBUTTON_FIGHTINGH_SPECIAL2 0x08000407 /* Apply second special move */ -#define DIBUTTON_FIGHTINGH_MENU 0x080004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_FIGHTINGH_SELECT 0x08004408 /* Select special move */ -#define DIHATSWITCH_FIGHTINGH_SLIDE 0x08004601 /* Look around */ -#define DIBUTTON_FIGHTINGH_DISPLAY 0x08004409 /* Shows next on-screen display option */ -#define DIAXIS_FIGHTINGH_ROTATE 0x08024203 /* Rotate - Turn body left/right */ -#define DIBUTTON_FIGHTINGH_DODGE 0x0800440A /* Dodge */ -#define DIBUTTON_FIGHTINGH_LEFT_LINK 0x0800C4E4 /* Fallback left sidestep button */ -#define DIBUTTON_FIGHTINGH_RIGHT_LINK 0x0800C4EC /* Fallback right sidestep button */ -#define DIBUTTON_FIGHTINGH_FORWARD_LINK 0x080144E0 /* Fallback forward button */ -#define DIBUTTON_FIGHTINGH_BACKWARD_LINK 0x080144E8 /* Fallback backward button */ -#define DIBUTTON_FIGHTINGH_DEVICE 0x080044FE /* Show input device and controls */ -#define DIBUTTON_FIGHTINGH_PAUSE 0x080044FC /* Start / Pause / Restart game */ - -/*--- Fighting - First Person Shooting - Navigation and combat are primary objectives ---*/ -#define DIVIRTUAL_FIGHTING_FPS 0x09000000 -#define DIAXIS_FPS_ROTATE 0x09008201 /* Rotate character left/right */ -#define DIAXIS_FPS_MOVE 0x09010202 /* Move forward/backward */ -#define DIBUTTON_FPS_FIRE 0x09000401 /* Fire */ -#define DIBUTTON_FPS_WEAPONS 0x09000402 /* Select next weapon */ -#define DIBUTTON_FPS_APPLY 0x09000403 /* Use item */ -#define DIBUTTON_FPS_SELECT 0x09000404 /* Select next inventory item */ -#define DIBUTTON_FPS_CROUCH 0x09000405 /* Crouch/ climb down/ swim down */ -#define DIBUTTON_FPS_JUMP 0x09000406 /* Jump/ climb up/ swim up */ -#define DIAXIS_FPS_LOOKUPDOWN 0x09018203 /* Look up / down */ -#define DIBUTTON_FPS_STRAFE 0x09000407 /* Enable strafing while active */ -#define DIBUTTON_FPS_MENU 0x090004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_FPS_GLANCE 0x09004601 /* Look around */ -#define DIBUTTON_FPS_DISPLAY 0x09004408 /* Shows next on-screen display option/ map */ -#define DIAXIS_FPS_SIDESTEP 0x09024204 /* Sidestep */ -#define DIBUTTON_FPS_DODGE 0x09004409 /* Dodge */ -#define DIBUTTON_FPS_GLANCEL 0x0900440A /* Glance Left */ -#define DIBUTTON_FPS_GLANCER 0x0900440B /* Glance Right */ -#define DIBUTTON_FPS_FIRESECONDARY 0x0900440C /* Alternative fire button */ -#define DIBUTTON_FPS_ROTATE_LEFT_LINK 0x0900C4E4 /* Fallback rotate left button */ -#define DIBUTTON_FPS_ROTATE_RIGHT_LINK 0x0900C4EC /* Fallback rotate right button */ -#define DIBUTTON_FPS_FORWARD_LINK 0x090144E0 /* Fallback forward button */ -#define DIBUTTON_FPS_BACKWARD_LINK 0x090144E8 /* Fallback backward button */ -#define DIBUTTON_FPS_GLANCE_UP_LINK 0x0901C4E0 /* Fallback look up button */ -#define DIBUTTON_FPS_GLANCE_DOWN_LINK 0x0901C4E8 /* Fallback look down button */ -#define DIBUTTON_FPS_STEP_LEFT_LINK 0x090244E4 /* Fallback step left button */ -#define DIBUTTON_FPS_STEP_RIGHT_LINK 0x090244EC /* Fallback step right button */ -#define DIBUTTON_FPS_DEVICE 0x090044FE /* Show input device and controls */ -#define DIBUTTON_FPS_PAUSE 0x090044FC /* Start / Pause / Restart game */ - -/*--- Fighting - Third Person action - Perspective of camera is behind the main character ---*/ -#define DIVIRTUAL_FIGHTING_THIRDPERSON 0x0A000000 -#define DIAXIS_TPS_TURN 0x0A020201 /* Turn left/right */ -#define DIAXIS_TPS_MOVE 0x0A010202 /* Move forward/backward */ -#define DIBUTTON_TPS_RUN 0x0A000401 /* Run or walk toggle switch */ -#define DIBUTTON_TPS_ACTION 0x0A000402 /* Action Button */ -#define DIBUTTON_TPS_SELECT 0x0A000403 /* Select next weapon */ -#define DIBUTTON_TPS_USE 0x0A000404 /* Use inventory item currently selected */ -#define DIBUTTON_TPS_JUMP 0x0A000405 /* Character Jumps */ -#define DIBUTTON_TPS_MENU 0x0A0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_TPS_GLANCE 0x0A004601 /* Look around */ -#define DIBUTTON_TPS_VIEW 0x0A004406 /* Select camera view */ -#define DIBUTTON_TPS_STEPLEFT 0x0A004407 /* Character takes a left step */ -#define DIBUTTON_TPS_STEPRIGHT 0x0A004408 /* Character takes a right step */ -#define DIAXIS_TPS_STEP 0x0A00C203 /* Character steps left/right */ -#define DIBUTTON_TPS_DODGE 0x0A004409 /* Character dodges or ducks */ -#define DIBUTTON_TPS_INVENTORY 0x0A00440A /* Cycle through inventory */ -#define DIBUTTON_TPS_TURN_LEFT_LINK 0x0A0244E4 /* Fallback turn left button */ -#define DIBUTTON_TPS_TURN_RIGHT_LINK 0x0A0244EC /* Fallback turn right button */ -#define DIBUTTON_TPS_FORWARD_LINK 0x0A0144E0 /* Fallback forward button */ -#define DIBUTTON_TPS_BACKWARD_LINK 0x0A0144E8 /* Fallback backward button */ -#define DIBUTTON_TPS_GLANCE_UP_LINK 0x0A07C4E0 /* Fallback look up button */ -#define DIBUTTON_TPS_GLANCE_DOWN_LINK 0x0A07C4E8 /* Fallback look down button */ -#define DIBUTTON_TPS_GLANCE_LEFT_LINK 0x0A07C4E4 /* Fallback glance up button */ -#define DIBUTTON_TPS_GLANCE_RIGHT_LINK 0x0A07C4EC /* Fallback glance right button */ -#define DIBUTTON_TPS_DEVICE 0x0A0044FE /* Show input device and controls */ -#define DIBUTTON_TPS_PAUSE 0x0A0044FC /* Start / Pause / Restart game */ - -/*--- Strategy - Role Playing - Navigation and problem solving are primary actions ---*/ -#define DIVIRTUAL_STRATEGY_ROLEPLAYING 0x0B000000 -#define DIAXIS_STRATEGYR_LATERAL 0x0B008201 /* sidestep - left/right */ -#define DIAXIS_STRATEGYR_MOVE 0x0B010202 /* move forward/backward */ -#define DIBUTTON_STRATEGYR_GET 0x0B000401 /* Acquire item */ -#define DIBUTTON_STRATEGYR_APPLY 0x0B000402 /* Use selected item */ -#define DIBUTTON_STRATEGYR_SELECT 0x0B000403 /* Select nextitem */ -#define DIBUTTON_STRATEGYR_ATTACK 0x0B000404 /* Attack */ -#define DIBUTTON_STRATEGYR_CAST 0x0B000405 /* Cast Spell */ -#define DIBUTTON_STRATEGYR_CROUCH 0x0B000406 /* Crouch */ -#define DIBUTTON_STRATEGYR_JUMP 0x0B000407 /* Jump */ -#define DIBUTTON_STRATEGYR_MENU 0x0B0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_STRATEGYR_GLANCE 0x0B004601 /* Look around */ -#define DIBUTTON_STRATEGYR_MAP 0x0B004408 /* Cycle through map options */ -#define DIBUTTON_STRATEGYR_DISPLAY 0x0B004409 /* Shows next on-screen display option */ -#define DIAXIS_STRATEGYR_ROTATE 0x0B024203 /* Turn body left/right */ -#define DIBUTTON_STRATEGYR_LEFT_LINK 0x0B00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_STRATEGYR_RIGHT_LINK 0x0B00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_STRATEGYR_FORWARD_LINK 0x0B0144E0 /* Fallback move forward button */ -#define DIBUTTON_STRATEGYR_BACK_LINK 0x0B0144E8 /* Fallback move backward button */ -#define DIBUTTON_STRATEGYR_ROTATE_LEFT_LINK 0x0B0244E4 /* Fallback turn body left button */ -#define DIBUTTON_STRATEGYR_ROTATE_RIGHT_LINK 0x0B0244EC /* Fallback turn body right button */ -#define DIBUTTON_STRATEGYR_DEVICE 0x0B0044FE /* Show input device and controls */ -#define DIBUTTON_STRATEGYR_PAUSE 0x0B0044FC /* Start / Pause / Restart game */ - -/*--- Strategy - Turn based - Navigation and problem solving are primary actions ---*/ -#define DIVIRTUAL_STRATEGY_TURN 0x0C000000 -#define DIAXIS_STRATEGYT_LATERAL 0x0C008201 /* Sidestep left/right */ -#define DIAXIS_STRATEGYT_MOVE 0x0C010202 /* Move forward/backwards */ -#define DIBUTTON_STRATEGYT_SELECT 0x0C000401 /* Select unit or object */ -#define DIBUTTON_STRATEGYT_INSTRUCT 0x0C000402 /* Cycle through instructions */ -#define DIBUTTON_STRATEGYT_APPLY 0x0C000403 /* Apply selected instruction */ -#define DIBUTTON_STRATEGYT_TEAM 0x0C000404 /* Select next team / cycle through all */ -#define DIBUTTON_STRATEGYT_TURN 0x0C000405 /* Indicate turn over */ -#define DIBUTTON_STRATEGYT_MENU 0x0C0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_STRATEGYT_ZOOM 0x0C004406 /* Zoom - in / out */ -#define DIBUTTON_STRATEGYT_MAP 0x0C004407 /* cycle through map options */ -#define DIBUTTON_STRATEGYT_DISPLAY 0x0C004408 /* shows next on-screen display options */ -#define DIBUTTON_STRATEGYT_LEFT_LINK 0x0C00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_STRATEGYT_RIGHT_LINK 0x0C00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_STRATEGYT_FORWARD_LINK 0x0C0144E0 /* Fallback move forward button */ -#define DIBUTTON_STRATEGYT_BACK_LINK 0x0C0144E8 /* Fallback move back button */ -#define DIBUTTON_STRATEGYT_DEVICE 0x0C0044FE /* Show input device and controls */ -#define DIBUTTON_STRATEGYT_PAUSE 0x0C0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Hunting - Hunting ---*/ -#define DIVIRTUAL_SPORTS_HUNTING 0x0D000000 -#define DIAXIS_HUNTING_LATERAL 0x0D008201 /* sidestep left/right */ -#define DIAXIS_HUNTING_MOVE 0x0D010202 /* move forward/backwards */ -#define DIBUTTON_HUNTING_FIRE 0x0D000401 /* Fire selected weapon */ -#define DIBUTTON_HUNTING_AIM 0x0D000402 /* Select aim/move */ -#define DIBUTTON_HUNTING_WEAPON 0x0D000403 /* Select next weapon */ -#define DIBUTTON_HUNTING_BINOCULAR 0x0D000404 /* Look through Binoculars */ -#define DIBUTTON_HUNTING_CALL 0x0D000405 /* Make animal call */ -#define DIBUTTON_HUNTING_MAP 0x0D000406 /* View Map */ -#define DIBUTTON_HUNTING_SPECIAL 0x0D000407 /* Special game operation */ -#define DIBUTTON_HUNTING_MENU 0x0D0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_HUNTING_GLANCE 0x0D004601 /* Look around */ -#define DIBUTTON_HUNTING_DISPLAY 0x0D004408 /* show next on-screen display option */ -#define DIAXIS_HUNTING_ROTATE 0x0D024203 /* Turn body left/right */ -#define DIBUTTON_HUNTING_CROUCH 0x0D004409 /* Crouch/ Climb / Swim down */ -#define DIBUTTON_HUNTING_JUMP 0x0D00440A /* Jump/ Climb up / Swim up */ -#define DIBUTTON_HUNTING_FIRESECONDARY 0x0D00440B /* Alternative fire button */ -#define DIBUTTON_HUNTING_LEFT_LINK 0x0D00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_HUNTING_RIGHT_LINK 0x0D00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_HUNTING_FORWARD_LINK 0x0D0144E0 /* Fallback move forward button */ -#define DIBUTTON_HUNTING_BACK_LINK 0x0D0144E8 /* Fallback move back button */ -#define DIBUTTON_HUNTING_ROTATE_LEFT_LINK 0x0D0244E4 /* Fallback turn body left button */ -#define DIBUTTON_HUNTING_ROTATE_RIGHT_LINK 0x0D0244EC /* Fallback turn body right button */ -#define DIBUTTON_HUNTING_DEVICE 0x0D0044FE /* Show input device and controls */ -#define DIBUTTON_HUNTING_PAUSE 0x0D0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Fishing - Catching Fish is primary objective ---*/ -#define DIVIRTUAL_SPORTS_FISHING 0x0E000000 -#define DIAXIS_FISHING_LATERAL 0x0E008201 /* sidestep left/right */ -#define DIAXIS_FISHING_MOVE 0x0E010202 /* move forward/backwards */ -#define DIBUTTON_FISHING_CAST 0x0E000401 /* Cast line */ -#define DIBUTTON_FISHING_TYPE 0x0E000402 /* Select cast type */ -#define DIBUTTON_FISHING_BINOCULAR 0x0E000403 /* Look through Binocular */ -#define DIBUTTON_FISHING_BAIT 0x0E000404 /* Select type of Bait */ -#define DIBUTTON_FISHING_MAP 0x0E000405 /* View Map */ -#define DIBUTTON_FISHING_MENU 0x0E0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_FISHING_GLANCE 0x0E004601 /* Look around */ -#define DIBUTTON_FISHING_DISPLAY 0x0E004406 /* Show next on-screen display option */ -#define DIAXIS_FISHING_ROTATE 0x0E024203 /* Turn character left / right */ -#define DIBUTTON_FISHING_CROUCH 0x0E004407 /* Crouch/ Climb / Swim down */ -#define DIBUTTON_FISHING_JUMP 0x0E004408 /* Jump/ Climb up / Swim up */ -#define DIBUTTON_FISHING_LEFT_LINK 0x0E00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_FISHING_RIGHT_LINK 0x0E00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_FISHING_FORWARD_LINK 0x0E0144E0 /* Fallback move forward button */ -#define DIBUTTON_FISHING_BACK_LINK 0x0E0144E8 /* Fallback move back button */ -#define DIBUTTON_FISHING_ROTATE_LEFT_LINK 0x0E0244E4 /* Fallback turn body left button */ -#define DIBUTTON_FISHING_ROTATE_RIGHT_LINK 0x0E0244EC /* Fallback turn body right button */ -#define DIBUTTON_FISHING_DEVICE 0x0E0044FE /* Show input device and controls */ -#define DIBUTTON_FISHING_PAUSE 0x0E0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Baseball - Batting - Batter control is primary objective ---*/ -#define DIVIRTUAL_SPORTS_BASEBALL_BAT 0x0F000000 -#define DIAXIS_BASEBALLB_LATERAL 0x0F008201 /* Aim left / right */ -#define DIAXIS_BASEBALLB_MOVE 0x0F010202 /* Aim up / down */ -#define DIBUTTON_BASEBALLB_SELECT 0x0F000401 /* cycle through swing options */ -#define DIBUTTON_BASEBALLB_NORMAL 0x0F000402 /* normal swing */ -#define DIBUTTON_BASEBALLB_POWER 0x0F000403 /* swing for the fence */ -#define DIBUTTON_BASEBALLB_BUNT 0x0F000404 /* bunt */ -#define DIBUTTON_BASEBALLB_STEAL 0x0F000405 /* Base runner attempts to steal a base */ -#define DIBUTTON_BASEBALLB_BURST 0x0F000406 /* Base runner invokes burst of speed */ -#define DIBUTTON_BASEBALLB_SLIDE 0x0F000407 /* Base runner slides into base */ -#define DIBUTTON_BASEBALLB_CONTACT 0x0F000408 /* Contact swing */ -#define DIBUTTON_BASEBALLB_MENU 0x0F0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_BASEBALLB_NOSTEAL 0x0F004409 /* Base runner goes back to a base */ -#define DIBUTTON_BASEBALLB_BOX 0x0F00440A /* Enter or exit batting box */ -#define DIBUTTON_BASEBALLB_LEFT_LINK 0x0F00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_BASEBALLB_RIGHT_LINK 0x0F00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_BASEBALLB_FORWARD_LINK 0x0F0144E0 /* Fallback move forward button */ -#define DIBUTTON_BASEBALLB_BACK_LINK 0x0F0144E8 /* Fallback move back button */ -#define DIBUTTON_BASEBALLB_DEVICE 0x0F0044FE /* Show input device and controls */ -#define DIBUTTON_BASEBALLB_PAUSE 0x0F0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Baseball - Pitching - Pitcher control is primary objective ---*/ -#define DIVIRTUAL_SPORTS_BASEBALL_PITCH 0x10000000 -#define DIAXIS_BASEBALLP_LATERAL 0x10008201 /* Aim left / right */ -#define DIAXIS_BASEBALLP_MOVE 0x10010202 /* Aim up / down */ -#define DIBUTTON_BASEBALLP_SELECT 0x10000401 /* cycle through pitch selections */ -#define DIBUTTON_BASEBALLP_PITCH 0x10000402 /* throw pitch */ -#define DIBUTTON_BASEBALLP_BASE 0x10000403 /* select base to throw to */ -#define DIBUTTON_BASEBALLP_THROW 0x10000404 /* throw to base */ -#define DIBUTTON_BASEBALLP_FAKE 0x10000405 /* Fake a throw to a base */ -#define DIBUTTON_BASEBALLP_MENU 0x100004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_BASEBALLP_WALK 0x10004406 /* Throw intentional walk / pitch out */ -#define DIBUTTON_BASEBALLP_LOOK 0x10004407 /* Look at runners on bases */ -#define DIBUTTON_BASEBALLP_LEFT_LINK 0x1000C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_BASEBALLP_RIGHT_LINK 0x1000C4EC /* Fallback sidestep right button */ -#define DIBUTTON_BASEBALLP_FORWARD_LINK 0x100144E0 /* Fallback move forward button */ -#define DIBUTTON_BASEBALLP_BACK_LINK 0x100144E8 /* Fallback move back button */ -#define DIBUTTON_BASEBALLP_DEVICE 0x100044FE /* Show input device and controls */ -#define DIBUTTON_BASEBALLP_PAUSE 0x100044FC /* Start / Pause / Restart game */ - -/*--- Sports - Baseball - Fielding - Fielder control is primary objective ---*/ -#define DIVIRTUAL_SPORTS_BASEBALL_FIELD 0x11000000 -#define DIAXIS_BASEBALLF_LATERAL 0x11008201 /* Aim left / right */ -#define DIAXIS_BASEBALLF_MOVE 0x11010202 /* Aim up / down */ -#define DIBUTTON_BASEBALLF_NEAREST 0x11000401 /* Switch to fielder nearest to the ball */ -#define DIBUTTON_BASEBALLF_THROW1 0x11000402 /* Make conservative throw */ -#define DIBUTTON_BASEBALLF_THROW2 0x11000403 /* Make aggressive throw */ -#define DIBUTTON_BASEBALLF_BURST 0x11000404 /* Invoke burst of speed */ -#define DIBUTTON_BASEBALLF_JUMP 0x11000405 /* Jump to catch ball */ -#define DIBUTTON_BASEBALLF_DIVE 0x11000406 /* Dive to catch ball */ -#define DIBUTTON_BASEBALLF_MENU 0x110004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_BASEBALLF_SHIFTIN 0x11004407 /* Shift the infield positioning */ -#define DIBUTTON_BASEBALLF_SHIFTOUT 0x11004408 /* Shift the outfield positioning */ -#define DIBUTTON_BASEBALLF_AIM_LEFT_LINK 0x1100C4E4 /* Fallback aim left button */ -#define DIBUTTON_BASEBALLF_AIM_RIGHT_LINK 0x1100C4EC /* Fallback aim right button */ -#define DIBUTTON_BASEBALLF_FORWARD_LINK 0x110144E0 /* Fallback move forward button */ -#define DIBUTTON_BASEBALLF_BACK_LINK 0x110144E8 /* Fallback move back button */ -#define DIBUTTON_BASEBALLF_DEVICE 0x110044FE /* Show input device and controls */ -#define DIBUTTON_BASEBALLF_PAUSE 0x110044FC /* Start / Pause / Restart game */ - -/*--- Sports - Basketball - Offense - Offense ---*/ -#define DIVIRTUAL_SPORTS_BASKETBALL_OFFENSE 0x12000000 -#define DIAXIS_BBALLO_LATERAL 0x12008201 /* left / right */ -#define DIAXIS_BBALLO_MOVE 0x12010202 /* up / down */ -#define DIBUTTON_BBALLO_SHOOT 0x12000401 /* shoot basket */ -#define DIBUTTON_BBALLO_DUNK 0x12000402 /* dunk basket */ -#define DIBUTTON_BBALLO_PASS 0x12000403 /* throw pass */ -#define DIBUTTON_BBALLO_FAKE 0x12000404 /* fake shot or pass */ -#define DIBUTTON_BBALLO_SPECIAL 0x12000405 /* apply special move */ -#define DIBUTTON_BBALLO_PLAYER 0x12000406 /* select next player */ -#define DIBUTTON_BBALLO_BURST 0x12000407 /* invoke burst */ -#define DIBUTTON_BBALLO_CALL 0x12000408 /* call for ball / pass to me */ -#define DIBUTTON_BBALLO_MENU 0x120004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_BBALLO_GLANCE 0x12004601 /* scroll view */ -#define DIBUTTON_BBALLO_SCREEN 0x12004409 /* Call for screen */ -#define DIBUTTON_BBALLO_PLAY 0x1200440A /* Call for specific offensive play */ -#define DIBUTTON_BBALLO_JAB 0x1200440B /* Initiate fake drive to basket */ -#define DIBUTTON_BBALLO_POST 0x1200440C /* Perform post move */ -#define DIBUTTON_BBALLO_TIMEOUT 0x1200440D /* Time Out */ -#define DIBUTTON_BBALLO_SUBSTITUTE 0x1200440E /* substitute one player for another */ -#define DIBUTTON_BBALLO_LEFT_LINK 0x1200C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_BBALLO_RIGHT_LINK 0x1200C4EC /* Fallback sidestep right button */ -#define DIBUTTON_BBALLO_FORWARD_LINK 0x120144E0 /* Fallback move forward button */ -#define DIBUTTON_BBALLO_BACK_LINK 0x120144E8 /* Fallback move back button */ -#define DIBUTTON_BBALLO_DEVICE 0x120044FE /* Show input device and controls */ -#define DIBUTTON_BBALLO_PAUSE 0x120044FC /* Start / Pause / Restart game */ - -/*--- Sports - Basketball - Defense - Defense ---*/ -#define DIVIRTUAL_SPORTS_BASKETBALL_DEFENSE 0x13000000 -#define DIAXIS_BBALLD_LATERAL 0x13008201 /* left / right */ -#define DIAXIS_BBALLD_MOVE 0x13010202 /* up / down */ -#define DIBUTTON_BBALLD_JUMP 0x13000401 /* jump to block shot */ -#define DIBUTTON_BBALLD_STEAL 0x13000402 /* attempt to steal ball */ -#define DIBUTTON_BBALLD_FAKE 0x13000403 /* fake block or steal */ -#define DIBUTTON_BBALLD_SPECIAL 0x13000404 /* apply special move */ -#define DIBUTTON_BBALLD_PLAYER 0x13000405 /* select next player */ -#define DIBUTTON_BBALLD_BURST 0x13000406 /* invoke burst */ -#define DIBUTTON_BBALLD_PLAY 0x13000407 /* call for specific defensive play */ -#define DIBUTTON_BBALLD_MENU 0x130004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_BBALLD_GLANCE 0x13004601 /* scroll view */ -#define DIBUTTON_BBALLD_TIMEOUT 0x13004408 /* Time Out */ -#define DIBUTTON_BBALLD_SUBSTITUTE 0x13004409 /* substitute one player for another */ -#define DIBUTTON_BBALLD_LEFT_LINK 0x1300C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_BBALLD_RIGHT_LINK 0x1300C4EC /* Fallback sidestep right button */ -#define DIBUTTON_BBALLD_FORWARD_LINK 0x130144E0 /* Fallback move forward button */ -#define DIBUTTON_BBALLD_BACK_LINK 0x130144E8 /* Fallback move back button */ -#define DIBUTTON_BBALLD_DEVICE 0x130044FE /* Show input device and controls */ -#define DIBUTTON_BBALLD_PAUSE 0x130044FC /* Start / Pause / Restart game */ - -/*--- Sports - Football - Play - Play selection ---*/ -#define DIVIRTUAL_SPORTS_FOOTBALL_FIELD 0x14000000 -#define DIBUTTON_FOOTBALLP_PLAY 0x14000401 /* cycle through available plays */ -#define DIBUTTON_FOOTBALLP_SELECT 0x14000402 /* select play */ -#define DIBUTTON_FOOTBALLP_HELP 0x14000403 /* Bring up pop-up help */ -#define DIBUTTON_FOOTBALLP_MENU 0x140004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_FOOTBALLP_DEVICE 0x140044FE /* Show input device and controls */ -#define DIBUTTON_FOOTBALLP_PAUSE 0x140044FC /* Start / Pause / Restart game */ - -/*--- Sports - Football - QB - Offense: Quarterback / Kicker ---*/ -#define DIVIRTUAL_SPORTS_FOOTBALL_QBCK 0x15000000 -#define DIAXIS_FOOTBALLQ_LATERAL 0x15008201 /* Move / Aim: left / right */ -#define DIAXIS_FOOTBALLQ_MOVE 0x15010202 /* Move / Aim: up / down */ -#define DIBUTTON_FOOTBALLQ_SELECT 0x15000401 /* Select */ -#define DIBUTTON_FOOTBALLQ_SNAP 0x15000402 /* snap ball - start play */ -#define DIBUTTON_FOOTBALLQ_JUMP 0x15000403 /* jump over defender */ -#define DIBUTTON_FOOTBALLQ_SLIDE 0x15000404 /* Dive/Slide */ -#define DIBUTTON_FOOTBALLQ_PASS 0x15000405 /* throws pass to receiver */ -#define DIBUTTON_FOOTBALLQ_FAKE 0x15000406 /* pump fake pass or fake kick */ -#define DIBUTTON_FOOTBALLQ_MENU 0x150004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_FOOTBALLQ_FAKESNAP 0x15004407 /* Fake snap */ -#define DIBUTTON_FOOTBALLQ_MOTION 0x15004408 /* Send receivers in motion */ -#define DIBUTTON_FOOTBALLQ_AUDIBLE 0x15004409 /* Change offensive play at line of scrimmage */ -#define DIBUTTON_FOOTBALLQ_LEFT_LINK 0x1500C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_FOOTBALLQ_RIGHT_LINK 0x1500C4EC /* Fallback sidestep right button */ -#define DIBUTTON_FOOTBALLQ_FORWARD_LINK 0x150144E0 /* Fallback move forward button */ -#define DIBUTTON_FOOTBALLQ_BACK_LINK 0x150144E8 /* Fallback move back button */ -#define DIBUTTON_FOOTBALLQ_DEVICE 0x150044FE /* Show input device and controls */ -#define DIBUTTON_FOOTBALLQ_PAUSE 0x150044FC /* Start / Pause / Restart game */ - -/*--- Sports - Football - Offense - Offense - Runner ---*/ -#define DIVIRTUAL_SPORTS_FOOTBALL_OFFENSE 0x16000000 -#define DIAXIS_FOOTBALLO_LATERAL 0x16008201 /* Move / Aim: left / right */ -#define DIAXIS_FOOTBALLO_MOVE 0x16010202 /* Move / Aim: up / down */ -#define DIBUTTON_FOOTBALLO_JUMP 0x16000401 /* jump or hurdle over defender */ -#define DIBUTTON_FOOTBALLO_LEFTARM 0x16000402 /* holds out left arm */ -#define DIBUTTON_FOOTBALLO_RIGHTARM 0x16000403 /* holds out right arm */ -#define DIBUTTON_FOOTBALLO_THROW 0x16000404 /* throw pass or lateral ball to another runner */ -#define DIBUTTON_FOOTBALLO_SPIN 0x16000405 /* Spin to avoid defenders */ -#define DIBUTTON_FOOTBALLO_MENU 0x160004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_FOOTBALLO_JUKE 0x16004406 /* Use special move to avoid defenders */ -#define DIBUTTON_FOOTBALLO_SHOULDER 0x16004407 /* Lower shoulder to run over defenders */ -#define DIBUTTON_FOOTBALLO_TURBO 0x16004408 /* Speed burst past defenders */ -#define DIBUTTON_FOOTBALLO_DIVE 0x16004409 /* Dive over defenders */ -#define DIBUTTON_FOOTBALLO_ZOOM 0x1600440A /* Zoom view in / out */ -#define DIBUTTON_FOOTBALLO_SUBSTITUTE 0x1600440B /* substitute one player for another */ -#define DIBUTTON_FOOTBALLO_LEFT_LINK 0x1600C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_FOOTBALLO_RIGHT_LINK 0x1600C4EC /* Fallback sidestep right button */ -#define DIBUTTON_FOOTBALLO_FORWARD_LINK 0x160144E0 /* Fallback move forward button */ -#define DIBUTTON_FOOTBALLO_BACK_LINK 0x160144E8 /* Fallback move back button */ -#define DIBUTTON_FOOTBALLO_DEVICE 0x160044FE /* Show input device and controls */ -#define DIBUTTON_FOOTBALLO_PAUSE 0x160044FC /* Start / Pause / Restart game */ - -/*--- Sports - Football - Defense - Defense ---*/ -#define DIVIRTUAL_SPORTS_FOOTBALL_DEFENSE 0x17000000 -#define DIAXIS_FOOTBALLD_LATERAL 0x17008201 /* Move / Aim: left / right */ -#define DIAXIS_FOOTBALLD_MOVE 0x17010202 /* Move / Aim: up / down */ -#define DIBUTTON_FOOTBALLD_PLAY 0x17000401 /* cycle through available plays */ -#define DIBUTTON_FOOTBALLD_SELECT 0x17000402 /* select player closest to the ball */ -#define DIBUTTON_FOOTBALLD_JUMP 0x17000403 /* jump to intercept or block */ -#define DIBUTTON_FOOTBALLD_TACKLE 0x17000404 /* tackler runner */ -#define DIBUTTON_FOOTBALLD_FAKE 0x17000405 /* hold down to fake tackle or intercept */ -#define DIBUTTON_FOOTBALLD_SUPERTACKLE 0x17000406 /* Initiate special tackle */ -#define DIBUTTON_FOOTBALLD_MENU 0x170004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_FOOTBALLD_SPIN 0x17004407 /* Spin to beat offensive line */ -#define DIBUTTON_FOOTBALLD_SWIM 0x17004408 /* Swim to beat the offensive line */ -#define DIBUTTON_FOOTBALLD_BULLRUSH 0x17004409 /* Bull rush the offensive line */ -#define DIBUTTON_FOOTBALLD_RIP 0x1700440A /* Rip the offensive line */ -#define DIBUTTON_FOOTBALLD_AUDIBLE 0x1700440B /* Change defensive play at the line of scrimmage */ -#define DIBUTTON_FOOTBALLD_ZOOM 0x1700440C /* Zoom view in / out */ -#define DIBUTTON_FOOTBALLD_SUBSTITUTE 0x1700440D /* substitute one player for another */ -#define DIBUTTON_FOOTBALLD_LEFT_LINK 0x1700C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_FOOTBALLD_RIGHT_LINK 0x1700C4EC /* Fallback sidestep right button */ -#define DIBUTTON_FOOTBALLD_FORWARD_LINK 0x170144E0 /* Fallback move forward button */ -#define DIBUTTON_FOOTBALLD_BACK_LINK 0x170144E8 /* Fallback move back button */ -#define DIBUTTON_FOOTBALLD_DEVICE 0x170044FE /* Show input device and controls */ -#define DIBUTTON_FOOTBALLD_PAUSE 0x170044FC /* Start / Pause / Restart game */ - -/*--- Sports - Golf - ---*/ -#define DIVIRTUAL_SPORTS_GOLF 0x18000000 -#define DIAXIS_GOLF_LATERAL 0x18008201 /* Move / Aim: left / right */ -#define DIAXIS_GOLF_MOVE 0x18010202 /* Move / Aim: up / down */ -#define DIBUTTON_GOLF_SWING 0x18000401 /* swing club */ -#define DIBUTTON_GOLF_SELECT 0x18000402 /* cycle between: club / swing strength / ball arc / ball spin */ -#define DIBUTTON_GOLF_UP 0x18000403 /* increase selection */ -#define DIBUTTON_GOLF_DOWN 0x18000404 /* decrease selection */ -#define DIBUTTON_GOLF_TERRAIN 0x18000405 /* shows terrain detail */ -#define DIBUTTON_GOLF_FLYBY 0x18000406 /* view the hole via a flyby */ -#define DIBUTTON_GOLF_MENU 0x180004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_GOLF_SCROLL 0x18004601 /* scroll view */ -#define DIBUTTON_GOLF_ZOOM 0x18004407 /* Zoom view in / out */ -#define DIBUTTON_GOLF_TIMEOUT 0x18004408 /* Call for time out */ -#define DIBUTTON_GOLF_SUBSTITUTE 0x18004409 /* substitute one player for another */ -#define DIBUTTON_GOLF_LEFT_LINK 0x1800C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_GOLF_RIGHT_LINK 0x1800C4EC /* Fallback sidestep right button */ -#define DIBUTTON_GOLF_FORWARD_LINK 0x180144E0 /* Fallback move forward button */ -#define DIBUTTON_GOLF_BACK_LINK 0x180144E8 /* Fallback move back button */ -#define DIBUTTON_GOLF_DEVICE 0x180044FE /* Show input device and controls */ -#define DIBUTTON_GOLF_PAUSE 0x180044FC /* Start / Pause / Restart game */ - -/*--- Sports - Hockey - Offense - Offense ---*/ -#define DIVIRTUAL_SPORTS_HOCKEY_OFFENSE 0x19000000 -#define DIAXIS_HOCKEYO_LATERAL 0x19008201 /* Move / Aim: left / right */ -#define DIAXIS_HOCKEYO_MOVE 0x19010202 /* Move / Aim: up / down */ -#define DIBUTTON_HOCKEYO_SHOOT 0x19000401 /* Shoot */ -#define DIBUTTON_HOCKEYO_PASS 0x19000402 /* pass the puck */ -#define DIBUTTON_HOCKEYO_BURST 0x19000403 /* invoke speed burst */ -#define DIBUTTON_HOCKEYO_SPECIAL 0x19000404 /* invoke special move */ -#define DIBUTTON_HOCKEYO_FAKE 0x19000405 /* hold down to fake pass or kick */ -#define DIBUTTON_HOCKEYO_MENU 0x190004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_HOCKEYO_SCROLL 0x19004601 /* scroll view */ -#define DIBUTTON_HOCKEYO_ZOOM 0x19004406 /* Zoom view in / out */ -#define DIBUTTON_HOCKEYO_STRATEGY 0x19004407 /* Invoke coaching menu for strategy help */ -#define DIBUTTON_HOCKEYO_TIMEOUT 0x19004408 /* Call for time out */ -#define DIBUTTON_HOCKEYO_SUBSTITUTE 0x19004409 /* substitute one player for another */ -#define DIBUTTON_HOCKEYO_LEFT_LINK 0x1900C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_HOCKEYO_RIGHT_LINK 0x1900C4EC /* Fallback sidestep right button */ -#define DIBUTTON_HOCKEYO_FORWARD_LINK 0x190144E0 /* Fallback move forward button */ -#define DIBUTTON_HOCKEYO_BACK_LINK 0x190144E8 /* Fallback move back button */ -#define DIBUTTON_HOCKEYO_DEVICE 0x190044FE /* Show input device and controls */ -#define DIBUTTON_HOCKEYO_PAUSE 0x190044FC /* Start / Pause / Restart game */ - -/*--- Sports - Hockey - Defense - Defense ---*/ -#define DIVIRTUAL_SPORTS_HOCKEY_DEFENSE 0x1A000000 -#define DIAXIS_HOCKEYD_LATERAL 0x1A008201 /* Move / Aim: left / right */ -#define DIAXIS_HOCKEYD_MOVE 0x1A010202 /* Move / Aim: up / down */ -#define DIBUTTON_HOCKEYD_PLAYER 0x1A000401 /* control player closest to the puck */ -#define DIBUTTON_HOCKEYD_STEAL 0x1A000402 /* attempt steal */ -#define DIBUTTON_HOCKEYD_BURST 0x1A000403 /* speed burst or body check */ -#define DIBUTTON_HOCKEYD_BLOCK 0x1A000404 /* block puck */ -#define DIBUTTON_HOCKEYD_FAKE 0x1A000405 /* hold down to fake tackle or intercept */ -#define DIBUTTON_HOCKEYD_MENU 0x1A0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_HOCKEYD_SCROLL 0x1A004601 /* scroll view */ -#define DIBUTTON_HOCKEYD_ZOOM 0x1A004406 /* Zoom view in / out */ -#define DIBUTTON_HOCKEYD_STRATEGY 0x1A004407 /* Invoke coaching menu for strategy help */ -#define DIBUTTON_HOCKEYD_TIMEOUT 0x1A004408 /* Call for time out */ -#define DIBUTTON_HOCKEYD_SUBSTITUTE 0x1A004409 /* substitute one player for another */ -#define DIBUTTON_HOCKEYD_LEFT_LINK 0x1A00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_HOCKEYD_RIGHT_LINK 0x1A00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_HOCKEYD_FORWARD_LINK 0x1A0144E0 /* Fallback move forward button */ -#define DIBUTTON_HOCKEYD_BACK_LINK 0x1A0144E8 /* Fallback move back button */ -#define DIBUTTON_HOCKEYD_DEVICE 0x1A0044FE /* Show input device and controls */ -#define DIBUTTON_HOCKEYD_PAUSE 0x1A0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Hockey - Goalie - Goal tending ---*/ -#define DIVIRTUAL_SPORTS_HOCKEY_GOALIE 0x1B000000 -#define DIAXIS_HOCKEYG_LATERAL 0x1B008201 /* Move / Aim: left / right */ -#define DIAXIS_HOCKEYG_MOVE 0x1B010202 /* Move / Aim: up / down */ -#define DIBUTTON_HOCKEYG_PASS 0x1B000401 /* pass puck */ -#define DIBUTTON_HOCKEYG_POKE 0x1B000402 /* poke / check / hack */ -#define DIBUTTON_HOCKEYG_STEAL 0x1B000403 /* attempt steal */ -#define DIBUTTON_HOCKEYG_BLOCK 0x1B000404 /* block puck */ -#define DIBUTTON_HOCKEYG_MENU 0x1B0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_HOCKEYG_SCROLL 0x1B004601 /* scroll view */ -#define DIBUTTON_HOCKEYG_ZOOM 0x1B004405 /* Zoom view in / out */ -#define DIBUTTON_HOCKEYG_STRATEGY 0x1B004406 /* Invoke coaching menu for strategy help */ -#define DIBUTTON_HOCKEYG_TIMEOUT 0x1B004407 /* Call for time out */ -#define DIBUTTON_HOCKEYG_SUBSTITUTE 0x1B004408 /* substitute one player for another */ -#define DIBUTTON_HOCKEYG_LEFT_LINK 0x1B00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_HOCKEYG_RIGHT_LINK 0x1B00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_HOCKEYG_FORWARD_LINK 0x1B0144E0 /* Fallback move forward button */ -#define DIBUTTON_HOCKEYG_BACK_LINK 0x1B0144E8 /* Fallback move back button */ -#define DIBUTTON_HOCKEYG_DEVICE 0x1B0044FE /* Show input device and controls */ -#define DIBUTTON_HOCKEYG_PAUSE 0x1B0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Mountain Biking - ---*/ -#define DIVIRTUAL_SPORTS_BIKING_MOUNTAIN 0x1C000000 -#define DIAXIS_BIKINGM_TURN 0x1C008201 /* left / right */ -#define DIAXIS_BIKINGM_PEDAL 0x1C010202 /* Pedal faster / slower / brake */ -#define DIBUTTON_BIKINGM_JUMP 0x1C000401 /* jump over obstacle */ -#define DIBUTTON_BIKINGM_CAMERA 0x1C000402 /* switch camera view */ -#define DIBUTTON_BIKINGM_SPECIAL1 0x1C000403 /* perform first special move */ -#define DIBUTTON_BIKINGM_SELECT 0x1C000404 /* Select */ -#define DIBUTTON_BIKINGM_SPECIAL2 0x1C000405 /* perform second special move */ -#define DIBUTTON_BIKINGM_MENU 0x1C0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_BIKINGM_SCROLL 0x1C004601 /* scroll view */ -#define DIBUTTON_BIKINGM_ZOOM 0x1C004406 /* Zoom view in / out */ -#define DIAXIS_BIKINGM_BRAKE 0x1C044203 /* Brake axis */ -#define DIBUTTON_BIKINGM_LEFT_LINK 0x1C00C4E4 /* Fallback turn left button */ -#define DIBUTTON_BIKINGM_RIGHT_LINK 0x1C00C4EC /* Fallback turn right button */ -#define DIBUTTON_BIKINGM_FASTER_LINK 0x1C0144E0 /* Fallback pedal faster button */ -#define DIBUTTON_BIKINGM_SLOWER_LINK 0x1C0144E8 /* Fallback pedal slower button */ -#define DIBUTTON_BIKINGM_BRAKE_BUTTON_LINK 0x1C0444E8 /* Fallback brake button */ -#define DIBUTTON_BIKINGM_DEVICE 0x1C0044FE /* Show input device and controls */ -#define DIBUTTON_BIKINGM_PAUSE 0x1C0044FC /* Start / Pause / Restart game */ - -/*--- Sports: Skiing / Snowboarding / Skateboarding - ---*/ -#define DIVIRTUAL_SPORTS_SKIING 0x1D000000 -#define DIAXIS_SKIING_TURN 0x1D008201 /* left / right */ -#define DIAXIS_SKIING_SPEED 0x1D010202 /* faster / slower */ -#define DIBUTTON_SKIING_JUMP 0x1D000401 /* Jump */ -#define DIBUTTON_SKIING_CROUCH 0x1D000402 /* crouch down */ -#define DIBUTTON_SKIING_CAMERA 0x1D000403 /* switch camera view */ -#define DIBUTTON_SKIING_SPECIAL1 0x1D000404 /* perform first special move */ -#define DIBUTTON_SKIING_SELECT 0x1D000405 /* Select */ -#define DIBUTTON_SKIING_SPECIAL2 0x1D000406 /* perform second special move */ -#define DIBUTTON_SKIING_MENU 0x1D0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_SKIING_GLANCE 0x1D004601 /* scroll view */ -#define DIBUTTON_SKIING_ZOOM 0x1D004407 /* Zoom view in / out */ -#define DIBUTTON_SKIING_LEFT_LINK 0x1D00C4E4 /* Fallback turn left button */ -#define DIBUTTON_SKIING_RIGHT_LINK 0x1D00C4EC /* Fallback turn right button */ -#define DIBUTTON_SKIING_FASTER_LINK 0x1D0144E0 /* Fallback increase speed button */ -#define DIBUTTON_SKIING_SLOWER_LINK 0x1D0144E8 /* Fallback decrease speed button */ -#define DIBUTTON_SKIING_DEVICE 0x1D0044FE /* Show input device and controls */ -#define DIBUTTON_SKIING_PAUSE 0x1D0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Soccer - Offense - Offense ---*/ -#define DIVIRTUAL_SPORTS_SOCCER_OFFENSE 0x1E000000 -#define DIAXIS_SOCCERO_LATERAL 0x1E008201 /* Move / Aim: left / right */ -#define DIAXIS_SOCCERO_MOVE 0x1E010202 /* Move / Aim: up / down */ -#define DIAXIS_SOCCERO_BEND 0x1E018203 /* Bend to soccer shot/pass */ -#define DIBUTTON_SOCCERO_SHOOT 0x1E000401 /* Shoot the ball */ -#define DIBUTTON_SOCCERO_PASS 0x1E000402 /* Pass */ -#define DIBUTTON_SOCCERO_FAKE 0x1E000403 /* Fake */ -#define DIBUTTON_SOCCERO_PLAYER 0x1E000404 /* Select next player */ -#define DIBUTTON_SOCCERO_SPECIAL1 0x1E000405 /* Apply special move */ -#define DIBUTTON_SOCCERO_SELECT 0x1E000406 /* Select special move */ -#define DIBUTTON_SOCCERO_MENU 0x1E0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_SOCCERO_GLANCE 0x1E004601 /* scroll view */ -#define DIBUTTON_SOCCERO_SUBSTITUTE 0x1E004407 /* Substitute one player for another */ -#define DIBUTTON_SOCCERO_SHOOTLOW 0x1E004408 /* Shoot the ball low */ -#define DIBUTTON_SOCCERO_SHOOTHIGH 0x1E004409 /* Shoot the ball high */ -#define DIBUTTON_SOCCERO_PASSTHRU 0x1E00440A /* Make a thru pass */ -#define DIBUTTON_SOCCERO_SPRINT 0x1E00440B /* Sprint / turbo boost */ -#define DIBUTTON_SOCCERO_CONTROL 0x1E00440C /* Obtain control of the ball */ -#define DIBUTTON_SOCCERO_HEAD 0x1E00440D /* Attempt to head the ball */ -#define DIBUTTON_SOCCERO_LEFT_LINK 0x1E00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_SOCCERO_RIGHT_LINK 0x1E00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_SOCCERO_FORWARD_LINK 0x1E0144E0 /* Fallback move forward button */ -#define DIBUTTON_SOCCERO_BACK_LINK 0x1E0144E8 /* Fallback move back button */ -#define DIBUTTON_SOCCERO_DEVICE 0x1E0044FE /* Show input device and controls */ -#define DIBUTTON_SOCCERO_PAUSE 0x1E0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Soccer - Defense - Defense ---*/ -#define DIVIRTUAL_SPORTS_SOCCER_DEFENSE 0x1F000000 -#define DIAXIS_SOCCERD_LATERAL 0x1F008201 /* Move / Aim: left / right */ -#define DIAXIS_SOCCERD_MOVE 0x1F010202 /* Move / Aim: up / down */ -#define DIBUTTON_SOCCERD_BLOCK 0x1F000401 /* Attempt to block shot */ -#define DIBUTTON_SOCCERD_STEAL 0x1F000402 /* Attempt to steal ball */ -#define DIBUTTON_SOCCERD_FAKE 0x1F000403 /* Fake a block or a steal */ -#define DIBUTTON_SOCCERD_PLAYER 0x1F000404 /* Select next player */ -#define DIBUTTON_SOCCERD_SPECIAL 0x1F000405 /* Apply special move */ -#define DIBUTTON_SOCCERD_SELECT 0x1F000406 /* Select special move */ -#define DIBUTTON_SOCCERD_SLIDE 0x1F000407 /* Attempt a slide tackle */ -#define DIBUTTON_SOCCERD_MENU 0x1F0004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_SOCCERD_GLANCE 0x1F004601 /* scroll view */ -#define DIBUTTON_SOCCERD_FOUL 0x1F004408 /* Initiate a foul / hard-foul */ -#define DIBUTTON_SOCCERD_HEAD 0x1F004409 /* Attempt a Header */ -#define DIBUTTON_SOCCERD_CLEAR 0x1F00440A /* Attempt to clear the ball down the field */ -#define DIBUTTON_SOCCERD_GOALIECHARGE 0x1F00440B /* Make the goalie charge out of the box */ -#define DIBUTTON_SOCCERD_SUBSTITUTE 0x1F00440C /* Substitute one player for another */ -#define DIBUTTON_SOCCERD_LEFT_LINK 0x1F00C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_SOCCERD_RIGHT_LINK 0x1F00C4EC /* Fallback sidestep right button */ -#define DIBUTTON_SOCCERD_FORWARD_LINK 0x1F0144E0 /* Fallback move forward button */ -#define DIBUTTON_SOCCERD_BACK_LINK 0x1F0144E8 /* Fallback move back button */ -#define DIBUTTON_SOCCERD_DEVICE 0x1F0044FE /* Show input device and controls */ -#define DIBUTTON_SOCCERD_PAUSE 0x1F0044FC /* Start / Pause / Restart game */ - -/*--- Sports - Racquet - Tennis - Table-Tennis - Squash ---*/ -#define DIVIRTUAL_SPORTS_RACQUET 0x20000000 -#define DIAXIS_RACQUET_LATERAL 0x20008201 /* Move / Aim: left / right */ -#define DIAXIS_RACQUET_MOVE 0x20010202 /* Move / Aim: up / down */ -#define DIBUTTON_RACQUET_SWING 0x20000401 /* Swing racquet */ -#define DIBUTTON_RACQUET_BACKSWING 0x20000402 /* Swing backhand */ -#define DIBUTTON_RACQUET_SMASH 0x20000403 /* Smash shot */ -#define DIBUTTON_RACQUET_SPECIAL 0x20000404 /* Special shot */ -#define DIBUTTON_RACQUET_SELECT 0x20000405 /* Select special shot */ -#define DIBUTTON_RACQUET_MENU 0x200004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_RACQUET_GLANCE 0x20004601 /* scroll view */ -#define DIBUTTON_RACQUET_TIMEOUT 0x20004406 /* Call for time out */ -#define DIBUTTON_RACQUET_SUBSTITUTE 0x20004407 /* Substitute one player for another */ -#define DIBUTTON_RACQUET_LEFT_LINK 0x2000C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_RACQUET_RIGHT_LINK 0x2000C4EC /* Fallback sidestep right button */ -#define DIBUTTON_RACQUET_FORWARD_LINK 0x200144E0 /* Fallback move forward button */ -#define DIBUTTON_RACQUET_BACK_LINK 0x200144E8 /* Fallback move back button */ -#define DIBUTTON_RACQUET_DEVICE 0x200044FE /* Show input device and controls */ -#define DIBUTTON_RACQUET_PAUSE 0x200044FC /* Start / Pause / Restart game */ - -/*--- Arcade- 2D - Side to Side movement ---*/ -#define DIVIRTUAL_ARCADE_SIDE2SIDE 0x21000000 -#define DIAXIS_ARCADES_LATERAL 0x21008201 /* left / right */ -#define DIAXIS_ARCADES_MOVE 0x21010202 /* up / down */ -#define DIBUTTON_ARCADES_THROW 0x21000401 /* throw object */ -#define DIBUTTON_ARCADES_CARRY 0x21000402 /* carry object */ -#define DIBUTTON_ARCADES_ATTACK 0x21000403 /* attack */ -#define DIBUTTON_ARCADES_SPECIAL 0x21000404 /* apply special move */ -#define DIBUTTON_ARCADES_SELECT 0x21000405 /* select special move */ -#define DIBUTTON_ARCADES_MENU 0x210004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_ARCADES_VIEW 0x21004601 /* scroll view left / right / up / down */ -#define DIBUTTON_ARCADES_LEFT_LINK 0x2100C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_ARCADES_RIGHT_LINK 0x2100C4EC /* Fallback sidestep right button */ -#define DIBUTTON_ARCADES_FORWARD_LINK 0x210144E0 /* Fallback move forward button */ -#define DIBUTTON_ARCADES_BACK_LINK 0x210144E8 /* Fallback move back button */ -#define DIBUTTON_ARCADES_VIEW_UP_LINK 0x2107C4E0 /* Fallback scroll view up button */ -#define DIBUTTON_ARCADES_VIEW_DOWN_LINK 0x2107C4E8 /* Fallback scroll view down button */ -#define DIBUTTON_ARCADES_VIEW_LEFT_LINK 0x2107C4E4 /* Fallback scroll view left button */ -#define DIBUTTON_ARCADES_VIEW_RIGHT_LINK 0x2107C4EC /* Fallback scroll view right button */ -#define DIBUTTON_ARCADES_DEVICE 0x210044FE /* Show input device and controls */ -#define DIBUTTON_ARCADES_PAUSE 0x210044FC /* Start / Pause / Restart game */ - -/*--- Arcade - Platform Game - Character moves around on screen ---*/ -#define DIVIRTUAL_ARCADE_PLATFORM 0x22000000 -#define DIAXIS_ARCADEP_LATERAL 0x22008201 /* Left / right */ -#define DIAXIS_ARCADEP_MOVE 0x22010202 /* Up / down */ -#define DIBUTTON_ARCADEP_JUMP 0x22000401 /* Jump */ -#define DIBUTTON_ARCADEP_FIRE 0x22000402 /* Fire */ -#define DIBUTTON_ARCADEP_CROUCH 0x22000403 /* Crouch */ -#define DIBUTTON_ARCADEP_SPECIAL 0x22000404 /* Apply special move */ -#define DIBUTTON_ARCADEP_SELECT 0x22000405 /* Select special move */ -#define DIBUTTON_ARCADEP_MENU 0x220004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_ARCADEP_VIEW 0x22004601 /* Scroll view */ -#define DIBUTTON_ARCADEP_FIRESECONDARY 0x22004406 /* Alternative fire button */ -#define DIBUTTON_ARCADEP_LEFT_LINK 0x2200C4E4 /* Fallback sidestep left button */ -#define DIBUTTON_ARCADEP_RIGHT_LINK 0x2200C4EC /* Fallback sidestep right button */ -#define DIBUTTON_ARCADEP_FORWARD_LINK 0x220144E0 /* Fallback move forward button */ -#define DIBUTTON_ARCADEP_BACK_LINK 0x220144E8 /* Fallback move back button */ -#define DIBUTTON_ARCADEP_VIEW_UP_LINK 0x2207C4E0 /* Fallback scroll view up button */ -#define DIBUTTON_ARCADEP_VIEW_DOWN_LINK 0x2207C4E8 /* Fallback scroll view down button */ -#define DIBUTTON_ARCADEP_VIEW_LEFT_LINK 0x2207C4E4 /* Fallback scroll view left button */ -#define DIBUTTON_ARCADEP_VIEW_RIGHT_LINK 0x2207C4EC /* Fallback scroll view right button */ -#define DIBUTTON_ARCADEP_DEVICE 0x220044FE /* Show input device and controls */ -#define DIBUTTON_ARCADEP_PAUSE 0x220044FC /* Start / Pause / Restart game */ - -/*--- CAD - 2D Object Control - Controls to select and move objects in 2D ---*/ -#define DIVIRTUAL_CAD_2DCONTROL 0x23000000 -#define DIAXIS_2DCONTROL_LATERAL 0x23008201 /* Move view left / right */ -#define DIAXIS_2DCONTROL_MOVE 0x23010202 /* Move view up / down */ -#define DIAXIS_2DCONTROL_INOUT 0x23018203 /* Zoom - in / out */ -#define DIBUTTON_2DCONTROL_SELECT 0x23000401 /* Select Object */ -#define DIBUTTON_2DCONTROL_SPECIAL1 0x23000402 /* Do first special operation */ -#define DIBUTTON_2DCONTROL_SPECIAL 0x23000403 /* Select special operation */ -#define DIBUTTON_2DCONTROL_SPECIAL2 0x23000404 /* Do second special operation */ -#define DIBUTTON_2DCONTROL_MENU 0x230004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_2DCONTROL_HATSWITCH 0x23004601 /* Hat switch */ -#define DIAXIS_2DCONTROL_ROTATEZ 0x23024204 /* Rotate view clockwise / counterclockwise */ -#define DIBUTTON_2DCONTROL_DISPLAY 0x23004405 /* Shows next on-screen display options */ -#define DIBUTTON_2DCONTROL_DEVICE 0x230044FE /* Show input device and controls */ -#define DIBUTTON_2DCONTROL_PAUSE 0x230044FC /* Start / Pause / Restart game */ - -/*--- CAD - 3D object control - Controls to select and move objects within a 3D environment ---*/ -#define DIVIRTUAL_CAD_3DCONTROL 0x24000000 -#define DIAXIS_3DCONTROL_LATERAL 0x24008201 /* Move view left / right */ -#define DIAXIS_3DCONTROL_MOVE 0x24010202 /* Move view up / down */ -#define DIAXIS_3DCONTROL_INOUT 0x24018203 /* Zoom - in / out */ -#define DIBUTTON_3DCONTROL_SELECT 0x24000401 /* Select Object */ -#define DIBUTTON_3DCONTROL_SPECIAL1 0x24000402 /* Do first special operation */ -#define DIBUTTON_3DCONTROL_SPECIAL 0x24000403 /* Select special operation */ -#define DIBUTTON_3DCONTROL_SPECIAL2 0x24000404 /* Do second special operation */ -#define DIBUTTON_3DCONTROL_MENU 0x240004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_3DCONTROL_HATSWITCH 0x24004601 /* Hat switch */ -#define DIAXIS_3DCONTROL_ROTATEX 0x24034204 /* Rotate view forward or up / backward or down */ -#define DIAXIS_3DCONTROL_ROTATEY 0x2402C205 /* Rotate view clockwise / counterclockwise */ -#define DIAXIS_3DCONTROL_ROTATEZ 0x24024206 /* Rotate view left / right */ -#define DIBUTTON_3DCONTROL_DISPLAY 0x24004405 /* Show next on-screen display options */ -#define DIBUTTON_3DCONTROL_DEVICE 0x240044FE /* Show input device and controls */ -#define DIBUTTON_3DCONTROL_PAUSE 0x240044FC /* Start / Pause / Restart game */ - -/*--- CAD - 3D Navigation - Fly through - Controls for 3D modeling ---*/ -#define DIVIRTUAL_CAD_FLYBY 0x25000000 -#define DIAXIS_CADF_LATERAL 0x25008201 /* move view left / right */ -#define DIAXIS_CADF_MOVE 0x25010202 /* move view up / down */ -#define DIAXIS_CADF_INOUT 0x25018203 /* in / out */ -#define DIBUTTON_CADF_SELECT 0x25000401 /* Select Object */ -#define DIBUTTON_CADF_SPECIAL1 0x25000402 /* do first special operation */ -#define DIBUTTON_CADF_SPECIAL 0x25000403 /* Select special operation */ -#define DIBUTTON_CADF_SPECIAL2 0x25000404 /* do second special operation */ -#define DIBUTTON_CADF_MENU 0x250004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_CADF_HATSWITCH 0x25004601 /* Hat switch */ -#define DIAXIS_CADF_ROTATEX 0x25034204 /* Rotate view forward or up / backward or down */ -#define DIAXIS_CADF_ROTATEY 0x2502C205 /* Rotate view clockwise / counterclockwise */ -#define DIAXIS_CADF_ROTATEZ 0x25024206 /* Rotate view left / right */ -#define DIBUTTON_CADF_DISPLAY 0x25004405 /* shows next on-screen display options */ -#define DIBUTTON_CADF_DEVICE 0x250044FE /* Show input device and controls */ -#define DIBUTTON_CADF_PAUSE 0x250044FC /* Start / Pause / Restart game */ - -/*--- CAD - 3D Model Control - Controls for 3D modeling ---*/ -#define DIVIRTUAL_CAD_MODEL 0x26000000 -#define DIAXIS_CADM_LATERAL 0x26008201 /* move view left / right */ -#define DIAXIS_CADM_MOVE 0x26010202 /* move view up / down */ -#define DIAXIS_CADM_INOUT 0x26018203 /* in / out */ -#define DIBUTTON_CADM_SELECT 0x26000401 /* Select Object */ -#define DIBUTTON_CADM_SPECIAL1 0x26000402 /* do first special operation */ -#define DIBUTTON_CADM_SPECIAL 0x26000403 /* Select special operation */ -#define DIBUTTON_CADM_SPECIAL2 0x26000404 /* do second special operation */ -#define DIBUTTON_CADM_MENU 0x260004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIHATSWITCH_CADM_HATSWITCH 0x26004601 /* Hat switch */ -#define DIAXIS_CADM_ROTATEX 0x26034204 /* Rotate view forward or up / backward or down */ -#define DIAXIS_CADM_ROTATEY 0x2602C205 /* Rotate view clockwise / counterclockwise */ -#define DIAXIS_CADM_ROTATEZ 0x26024206 /* Rotate view left / right */ -#define DIBUTTON_CADM_DISPLAY 0x26004405 /* shows next on-screen display options */ -#define DIBUTTON_CADM_DEVICE 0x260044FE /* Show input device and controls */ -#define DIBUTTON_CADM_PAUSE 0x260044FC /* Start / Pause / Restart game */ - -/*--- Control - Media Equipment - Remote ---*/ -#define DIVIRTUAL_REMOTE_CONTROL 0x27000000 -#define DIAXIS_REMOTE_SLIDER 0x27050201 /* Slider for adjustment: volume / color / bass / etc */ -#define DIBUTTON_REMOTE_MUTE 0x27000401 /* Set volume on current device to zero */ -#define DIBUTTON_REMOTE_SELECT 0x27000402 /* Next/previous: channel/ track / chapter / picture / station */ -#define DIBUTTON_REMOTE_PLAY 0x27002403 /* Start or pause entertainment on current device */ -#define DIBUTTON_REMOTE_CUE 0x27002404 /* Move through current media */ -#define DIBUTTON_REMOTE_REVIEW 0x27002405 /* Move through current media */ -#define DIBUTTON_REMOTE_CHANGE 0x27002406 /* Select next device */ -#define DIBUTTON_REMOTE_RECORD 0x27002407 /* Start recording the current media */ -#define DIBUTTON_REMOTE_MENU 0x270004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIAXIS_REMOTE_SLIDER2 0x27054202 /* Slider for adjustment: volume */ -#define DIBUTTON_REMOTE_TV 0x27005C08 /* Select TV */ -#define DIBUTTON_REMOTE_CABLE 0x27005C09 /* Select cable box */ -#define DIBUTTON_REMOTE_CD 0x27005C0A /* Select CD player */ -#define DIBUTTON_REMOTE_VCR 0x27005C0B /* Select VCR */ -#define DIBUTTON_REMOTE_TUNER 0x27005C0C /* Select tuner */ -#define DIBUTTON_REMOTE_DVD 0x27005C0D /* Select DVD player */ -#define DIBUTTON_REMOTE_ADJUST 0x27005C0E /* Enter device adjustment menu */ -#define DIBUTTON_REMOTE_DIGIT0 0x2700540F /* Digit 0 */ -#define DIBUTTON_REMOTE_DIGIT1 0x27005410 /* Digit 1 */ -#define DIBUTTON_REMOTE_DIGIT2 0x27005411 /* Digit 2 */ -#define DIBUTTON_REMOTE_DIGIT3 0x27005412 /* Digit 3 */ -#define DIBUTTON_REMOTE_DIGIT4 0x27005413 /* Digit 4 */ -#define DIBUTTON_REMOTE_DIGIT5 0x27005414 /* Digit 5 */ -#define DIBUTTON_REMOTE_DIGIT6 0x27005415 /* Digit 6 */ -#define DIBUTTON_REMOTE_DIGIT7 0x27005416 /* Digit 7 */ -#define DIBUTTON_REMOTE_DIGIT8 0x27005417 /* Digit 8 */ -#define DIBUTTON_REMOTE_DIGIT9 0x27005418 /* Digit 9 */ -#define DIBUTTON_REMOTE_DEVICE 0x270044FE /* Show input device and controls */ -#define DIBUTTON_REMOTE_PAUSE 0x270044FC /* Start / Pause / Restart game */ - -/*--- Control- Web - Help or Browser ---*/ -#define DIVIRTUAL_BROWSER_CONTROL 0x28000000 -#define DIAXIS_BROWSER_LATERAL 0x28008201 /* Move on screen pointer */ -#define DIAXIS_BROWSER_MOVE 0x28010202 /* Move on screen pointer */ -#define DIBUTTON_BROWSER_SELECT 0x28000401 /* Select current item */ -#define DIAXIS_BROWSER_VIEW 0x28018203 /* Move view up/down */ -#define DIBUTTON_BROWSER_REFRESH 0x28000402 /* Refresh */ -#define DIBUTTON_BROWSER_MENU 0x280004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_BROWSER_SEARCH 0x28004403 /* Use search tool */ -#define DIBUTTON_BROWSER_STOP 0x28004404 /* Cease current update */ -#define DIBUTTON_BROWSER_HOME 0x28004405 /* Go directly to "home" location */ -#define DIBUTTON_BROWSER_FAVORITES 0x28004406 /* Mark current site as favorite */ -#define DIBUTTON_BROWSER_NEXT 0x28004407 /* Select Next page */ -#define DIBUTTON_BROWSER_PREVIOUS 0x28004408 /* Select Previous page */ -#define DIBUTTON_BROWSER_HISTORY 0x28004409 /* Show/Hide History */ -#define DIBUTTON_BROWSER_PRINT 0x2800440A /* Print current page */ -#define DIBUTTON_BROWSER_DEVICE 0x280044FE /* Show input device and controls */ -#define DIBUTTON_BROWSER_PAUSE 0x280044FC /* Start / Pause / Restart game */ - -/*--- Driving Simulator - Giant Walking Robot - Walking tank with weapons ---*/ -#define DIVIRTUAL_DRIVING_MECHA 0x29000000 -#define DIAXIS_MECHA_STEER 0x29008201 /* Turns mecha left/right */ -#define DIAXIS_MECHA_TORSO 0x29010202 /* Tilts torso forward/backward */ -#define DIAXIS_MECHA_ROTATE 0x29020203 /* Turns torso left/right */ -#define DIAXIS_MECHA_THROTTLE 0x29038204 /* Engine Speed */ -#define DIBUTTON_MECHA_FIRE 0x29000401 /* Fire */ -#define DIBUTTON_MECHA_WEAPONS 0x29000402 /* Select next weapon group */ -#define DIBUTTON_MECHA_TARGET 0x29000403 /* Select closest enemy available target */ -#define DIBUTTON_MECHA_REVERSE 0x29000404 /* Toggles throttle in/out of reverse */ -#define DIBUTTON_MECHA_ZOOM 0x29000405 /* Zoom in/out targeting reticule */ -#define DIBUTTON_MECHA_JUMP 0x29000406 /* Fires jump jets */ -#define DIBUTTON_MECHA_MENU 0x290004FD /* Show menu options */ -/*--- Priority 2 controls ---*/ - -#define DIBUTTON_MECHA_CENTER 0x29004407 /* Center torso to legs */ -#define DIHATSWITCH_MECHA_GLANCE 0x29004601 /* Look around */ -#define DIBUTTON_MECHA_VIEW 0x29004408 /* Cycle through view options */ -#define DIBUTTON_MECHA_FIRESECONDARY 0x29004409 /* Alternative fire button */ -#define DIBUTTON_MECHA_LEFT_LINK 0x2900C4E4 /* Fallback steer left button */ -#define DIBUTTON_MECHA_RIGHT_LINK 0x2900C4EC /* Fallback steer right button */ -#define DIBUTTON_MECHA_FORWARD_LINK 0x290144E0 /* Fallback tilt torso forward button */ -#define DIBUTTON_MECHA_BACK_LINK 0x290144E8 /* Fallback tilt toroso backward button */ -#define DIBUTTON_MECHA_ROTATE_LEFT_LINK 0x290244E4 /* Fallback rotate toroso right button */ -#define DIBUTTON_MECHA_ROTATE_RIGHT_LINK 0x290244EC /* Fallback rotate torso left button */ -#define DIBUTTON_MECHA_FASTER_LINK 0x2903C4E0 /* Fallback increase engine speed */ -#define DIBUTTON_MECHA_SLOWER_LINK 0x2903C4E8 /* Fallback decrease engine speed */ -#define DIBUTTON_MECHA_DEVICE 0x290044FE /* Show input device and controls */ -#define DIBUTTON_MECHA_PAUSE 0x290044FC /* Start / Pause / Restart game */ - -/* - * "ANY" semantics can be used as a last resort to get mappings for actions - * that match nothing in the chosen virtual genre. These semantics will be - * mapped at a lower priority that virtual genre semantics. Also, hardware - * vendors will not be able to provide sensible mappings for these unless - * they provide application specific mappings. - */ -#define DIAXIS_ANY_X_1 0xFF00C201 -#define DIAXIS_ANY_X_2 0xFF00C202 -#define DIAXIS_ANY_Y_1 0xFF014201 -#define DIAXIS_ANY_Y_2 0xFF014202 -#define DIAXIS_ANY_Z_1 0xFF01C201 -#define DIAXIS_ANY_Z_2 0xFF01C202 -#define DIAXIS_ANY_R_1 0xFF024201 -#define DIAXIS_ANY_R_2 0xFF024202 -#define DIAXIS_ANY_U_1 0xFF02C201 -#define DIAXIS_ANY_U_2 0xFF02C202 -#define DIAXIS_ANY_V_1 0xFF034201 -#define DIAXIS_ANY_V_2 0xFF034202 -#define DIAXIS_ANY_A_1 0xFF03C201 -#define DIAXIS_ANY_A_2 0xFF03C202 -#define DIAXIS_ANY_B_1 0xFF044201 -#define DIAXIS_ANY_B_2 0xFF044202 -#define DIAXIS_ANY_C_1 0xFF04C201 -#define DIAXIS_ANY_C_2 0xFF04C202 -#define DIAXIS_ANY_S_1 0xFF054201 -#define DIAXIS_ANY_S_2 0xFF054202 - -#define DIAXIS_ANY_1 0xFF004201 -#define DIAXIS_ANY_2 0xFF004202 -#define DIAXIS_ANY_3 0xFF004203 -#define DIAXIS_ANY_4 0xFF004204 - -#define DIPOV_ANY_1 0xFF004601 -#define DIPOV_ANY_2 0xFF004602 -#define DIPOV_ANY_3 0xFF004603 -#define DIPOV_ANY_4 0xFF004604 - -#define DIBUTTON_ANY(instance) ( 0xFF004400 | instance ) - - -#ifdef __cplusplus -}; -#endif - -#endif /* __DINPUT_INCLUDED__ */ - -/**************************************************************************** - * - * Definitions for non-IDirectInput (VJoyD) features defined more recently - * than the current sdk files - * - ****************************************************************************/ - -#ifdef _INC_MMSYSTEM -#ifndef MMNOJOY - -#ifndef __VJOYDX_INCLUDED__ -#define __VJOYDX_INCLUDED__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Flag to indicate that the dwReserved2 field of the JOYINFOEX structure - * contains mini-driver specific data to be passed by VJoyD to the mini- - * driver instead of doing a poll. - */ -#define JOY_PASSDRIVERDATA 0x10000000l - -/* - * Informs the joystick driver that the configuration has been changed - * and should be reloaded from the registery. - * dwFlags is reserved and should be set to zero - */ -WINMMAPI MMRESULT WINAPI joyConfigChanged( DWORD dwFlags ); - -#ifndef DIJ_RINGZERO -/* - * Invoke the joystick control panel directly, using the passed window handle - * as the parent of the dialog. This API is only supported for compatibility - * purposes; new applications should use the RunControlPanel method of a - * device interface for a game controller. - * The API is called by using the function pointer returned by - * GetProcAddress( hCPL, TEXT("ShowJoyCPL") ) where hCPL is a HMODULE returned - * by LoadLibrary( TEXT("joy.cpl") ). The typedef is provided to allow - * declaration and casting of an appropriately typed variable. - */ -void WINAPI ShowJoyCPL( HWND hWnd ); -typedef void (WINAPI* LPFNSHOWJOYCPL)( HWND hWnd ); -#endif /* DIJ_RINGZERO */ - - -/* - * Hardware Setting indicating that the device is a headtracker - */ -#define JOY_HWS_ISHEADTRACKER 0x02000000l - -/* - * Hardware Setting indicating that the VxD is used to replace - * the standard analog polling - */ -#define JOY_HWS_ISGAMEPORTDRIVER 0x04000000l - -/* - * Hardware Setting indicating that the driver needs a standard - * gameport in order to communicate with the device. - */ -#define JOY_HWS_ISANALOGPORTDRIVER 0x08000000l - -/* - * Hardware Setting indicating that VJoyD should not load this - * driver, it will be loaded externally and will register with - * VJoyD of it's own accord. - */ -#define JOY_HWS_AUTOLOAD 0x10000000l - -/* - * Hardware Setting indicating that the driver acquires any - * resources needed without needing a devnode through VJoyD. - */ -#define JOY_HWS_NODEVNODE 0x20000000l - - -/* - * Hardware Setting indicating that the device is a gameport bus - */ -#define JOY_HWS_ISGAMEPORTBUS 0x80000000l -#define JOY_HWS_GAMEPORTBUSBUSY 0x00000001l - -/* - * Usage Setting indicating that the settings are volatile and - * should be removed if still present on a reboot. - */ -#define JOY_US_VOLATILE 0x00000008L - -#ifdef __cplusplus -}; -#endif - -#endif /* __VJOYDX_INCLUDED__ */ - -#endif /* not MMNOJOY */ -#endif /* _INC_MMSYSTEM */ - -/**************************************************************************** - * - * Definitions for non-IDirectInput (VJoyD) features defined more recently - * than the current ddk files - * - ****************************************************************************/ - -#ifndef DIJ_RINGZERO - -#ifdef _INC_MMDDK -#ifndef MMNOJOYDEV - -#ifndef __VJOYDXD_INCLUDED__ -#define __VJOYDXD_INCLUDED__ -/* - * Poll type in which the do_other field of the JOYOEMPOLLDATA - * structure contains mini-driver specific data passed from an app. - */ -#define JOY_OEMPOLL_PASSDRIVERDATA 7 - -#endif /* __VJOYDXD_INCLUDED__ */ - -#endif /* not MMNOJOYDEV */ -#endif /* _INC_MMDDK */ - -#endif /* DIJ_RINGZERO */ - +/**************************************************************************** + * + * Copyright (C) 1996-2000 Microsoft Corporation. All Rights Reserved. + * + * File: dinput.h + * Content: DirectInput include file + * + ****************************************************************************/ + +#ifndef __DINPUT_INCLUDED__ +#define __DINPUT_INCLUDED__ + +#ifndef DIJ_RINGZERO + +#ifdef _WIN32 +#define COM_NO_WINDOWS_H +#include +#endif + +#endif /* DIJ_RINGZERO */ + +#ifdef __cplusplus +extern "C" { +#endif + + + + + +/* + * To build applications for older versions of DirectInput + * + * #define DIRECTINPUT_VERSION [ 0x0300 | 0x0500 | 0x0700 ] + * + * before #include . By default, #include + * will produce a DirectX 8-compatible header file. + * + */ + +#define DIRECTINPUT_HEADER_VERSION 0x0800 +#ifndef DIRECTINPUT_VERSION +#define DIRECTINPUT_VERSION DIRECTINPUT_HEADER_VERSION +#pragma message(__FILE__ ": DIRECTINPUT_VERSION undefined. Defaulting to version 0x0800") +#endif + +#ifndef DIJ_RINGZERO + +/**************************************************************************** + * + * Class IDs + * + ****************************************************************************/ + +DEFINE_GUID(CLSID_DirectInput, 0x25E609E0,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(CLSID_DirectInputDevice, 0x25E609E1,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +DEFINE_GUID(CLSID_DirectInput8, 0x25E609E4,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(CLSID_DirectInputDevice8,0x25E609E5,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +/**************************************************************************** + * + * Interfaces + * + ****************************************************************************/ + +DEFINE_GUID(IID_IDirectInputA, 0x89521360,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputW, 0x89521361,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInput2A, 0x5944E662,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInput2W, 0x5944E663,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInput7A, 0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); +DEFINE_GUID(IID_IDirectInput7W, 0x9A4CB685,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); +DEFINE_GUID(IID_IDirectInput8A, 0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); +DEFINE_GUID(IID_IDirectInput8W, 0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00); +DEFINE_GUID(IID_IDirectInputDeviceA, 0x5944E680,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputDeviceW, 0x5944E681,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputDevice2A,0x5944E682,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputDevice2W,0x5944E683,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(IID_IDirectInputDevice7A,0x57D7C6BC,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); +DEFINE_GUID(IID_IDirectInputDevice7W,0x57D7C6BD,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE); +DEFINE_GUID(IID_IDirectInputDevice8A,0x54D41080,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); +DEFINE_GUID(IID_IDirectInputDevice8W,0x54D41081,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79); +DEFINE_GUID(IID_IDirectInputEffect, 0xE7E1F7C0,0x88D2,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); + +/**************************************************************************** + * + * Predefined object types + * + ****************************************************************************/ + +DEFINE_GUID(GUID_XAxis, 0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_YAxis, 0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_ZAxis, 0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_RxAxis, 0xA36D02F4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_RyAxis, 0xA36D02F5,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_RzAxis, 0xA36D02E3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_Slider, 0xA36D02E4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +DEFINE_GUID(GUID_Button, 0xA36D02F0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_Key, 0x55728220,0xD33C,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +DEFINE_GUID(GUID_POV, 0xA36D02F2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +DEFINE_GUID(GUID_Unknown, 0xA36D02F3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +/**************************************************************************** + * + * Predefined product GUIDs + * + ****************************************************************************/ + +DEFINE_GUID(GUID_SysMouse, 0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysKeyboard,0x6F1D2B61,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_Joystick ,0x6F1D2B70,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysMouseEm, 0x6F1D2B80,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysMouseEm2,0x6F1D2B81,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysKeyboardEm, 0x6F1D2B82,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); +DEFINE_GUID(GUID_SysKeyboardEm2,0x6F1D2B83,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00); + +/**************************************************************************** + * + * Predefined force feedback effects + * + ****************************************************************************/ + +DEFINE_GUID(GUID_ConstantForce, 0x13541C20,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_RampForce, 0x13541C21,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Square, 0x13541C22,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Sine, 0x13541C23,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Triangle, 0x13541C24,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_SawtoothUp, 0x13541C25,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_SawtoothDown, 0x13541C26,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Spring, 0x13541C27,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Damper, 0x13541C28,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Inertia, 0x13541C29,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_Friction, 0x13541C2A,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); +DEFINE_GUID(GUID_CustomForce, 0x13541C2B,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35); + +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * Interfaces and Structures... + * + ****************************************************************************/ + +#if(DIRECTINPUT_VERSION >= 0x0500) + +/**************************************************************************** + * + * IDirectInputEffect + * + ****************************************************************************/ + +#define DIEFT_ALL 0x00000000 + +#define DIEFT_CONSTANTFORCE 0x00000001 +#define DIEFT_RAMPFORCE 0x00000002 +#define DIEFT_PERIODIC 0x00000003 +#define DIEFT_CONDITION 0x00000004 +#define DIEFT_CUSTOMFORCE 0x00000005 +#define DIEFT_HARDWARE 0x000000FF +#define DIEFT_FFATTACK 0x00000200 +#define DIEFT_FFFADE 0x00000400 +#define DIEFT_SATURATION 0x00000800 +#define DIEFT_POSNEGCOEFFICIENTS 0x00001000 +#define DIEFT_POSNEGSATURATION 0x00002000 +#define DIEFT_DEADBAND 0x00004000 +#define DIEFT_STARTDELAY 0x00008000 +#define DIEFT_GETTYPE(n) LOBYTE(n) + +#define DI_DEGREES 100 +#define DI_FFNOMINALMAX 10000 +#define DI_SECONDS 1000000 + +typedef struct DICONSTANTFORCE { + LONG lMagnitude; +} DICONSTANTFORCE, *LPDICONSTANTFORCE; +typedef const DICONSTANTFORCE *LPCDICONSTANTFORCE; + +typedef struct DIRAMPFORCE { + LONG lStart; + LONG lEnd; +} DIRAMPFORCE, *LPDIRAMPFORCE; +typedef const DIRAMPFORCE *LPCDIRAMPFORCE; + +typedef struct DIPERIODIC { + DWORD dwMagnitude; + LONG lOffset; + DWORD dwPhase; + DWORD dwPeriod; +} DIPERIODIC, *LPDIPERIODIC; +typedef const DIPERIODIC *LPCDIPERIODIC; + +typedef struct DICONDITION { + LONG lOffset; + LONG lPositiveCoefficient; + LONG lNegativeCoefficient; + DWORD dwPositiveSaturation; + DWORD dwNegativeSaturation; + LONG lDeadBand; +} DICONDITION, *LPDICONDITION; +typedef const DICONDITION *LPCDICONDITION; + +typedef struct DICUSTOMFORCE { + DWORD cChannels; + DWORD dwSamplePeriod; + DWORD cSamples; + LPLONG rglForceData; +} DICUSTOMFORCE, *LPDICUSTOMFORCE; +typedef const DICUSTOMFORCE *LPCDICUSTOMFORCE; + + +typedef struct DIENVELOPE { + DWORD dwSize; /* sizeof(DIENVELOPE) */ + DWORD dwAttackLevel; + DWORD dwAttackTime; /* Microseconds */ + DWORD dwFadeLevel; + DWORD dwFadeTime; /* Microseconds */ +} DIENVELOPE, *LPDIENVELOPE; +typedef const DIENVELOPE *LPCDIENVELOPE; + + +/* This structure is defined for DirectX 5.0 compatibility */ +typedef struct DIEFFECT_DX5 { + DWORD dwSize; /* sizeof(DIEFFECT_DX5) */ + DWORD dwFlags; /* DIEFF_* */ + DWORD dwDuration; /* Microseconds */ + DWORD dwSamplePeriod; /* Microseconds */ + DWORD dwGain; + DWORD dwTriggerButton; /* or DIEB_NOTRIGGER */ + DWORD dwTriggerRepeatInterval; /* Microseconds */ + DWORD cAxes; /* Number of axes */ + LPDWORD rgdwAxes; /* Array of axes */ + LPLONG rglDirection; /* Array of directions */ + LPDIENVELOPE lpEnvelope; /* Optional */ + DWORD cbTypeSpecificParams; /* Size of params */ + LPVOID lpvTypeSpecificParams; /* Pointer to params */ +} DIEFFECT_DX5, *LPDIEFFECT_DX5; +typedef const DIEFFECT_DX5 *LPCDIEFFECT_DX5; + +typedef struct DIEFFECT { + DWORD dwSize; /* sizeof(DIEFFECT) */ + DWORD dwFlags; /* DIEFF_* */ + DWORD dwDuration; /* Microseconds */ + DWORD dwSamplePeriod; /* Microseconds */ + DWORD dwGain; + DWORD dwTriggerButton; /* or DIEB_NOTRIGGER */ + DWORD dwTriggerRepeatInterval; /* Microseconds */ + DWORD cAxes; /* Number of axes */ + LPDWORD rgdwAxes; /* Array of axes */ + LPLONG rglDirection; /* Array of directions */ + LPDIENVELOPE lpEnvelope; /* Optional */ + DWORD cbTypeSpecificParams; /* Size of params */ + LPVOID lpvTypeSpecificParams; /* Pointer to params */ +#if(DIRECTINPUT_VERSION >= 0x0600) + DWORD dwStartDelay; /* Microseconds */ +#endif /* DIRECTINPUT_VERSION >= 0x0600 */ +} DIEFFECT, *LPDIEFFECT; +typedef DIEFFECT DIEFFECT_DX6; +typedef LPDIEFFECT LPDIEFFECT_DX6; +typedef const DIEFFECT *LPCDIEFFECT; + + +#if(DIRECTINPUT_VERSION >= 0x0700) +#ifndef DIJ_RINGZERO +typedef struct DIFILEEFFECT{ + DWORD dwSize; + GUID GuidEffect; + LPCDIEFFECT lpDiEffect; + CHAR szFriendlyName[MAX_PATH]; +}DIFILEEFFECT, *LPDIFILEEFFECT; +typedef const DIFILEEFFECT *LPCDIFILEEFFECT; +typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSINFILECALLBACK)(LPCDIFILEEFFECT , LPVOID); +#endif /* DIJ_RINGZERO */ +#endif /* DIRECTINPUT_VERSION >= 0x0700 */ + +#define DIEFF_OBJECTIDS 0x00000001 +#define DIEFF_OBJECTOFFSETS 0x00000002 +#define DIEFF_CARTESIAN 0x00000010 +#define DIEFF_POLAR 0x00000020 +#define DIEFF_SPHERICAL 0x00000040 + +#define DIEP_DURATION 0x00000001 +#define DIEP_SAMPLEPERIOD 0x00000002 +#define DIEP_GAIN 0x00000004 +#define DIEP_TRIGGERBUTTON 0x00000008 +#define DIEP_TRIGGERREPEATINTERVAL 0x00000010 +#define DIEP_AXES 0x00000020 +#define DIEP_DIRECTION 0x00000040 +#define DIEP_ENVELOPE 0x00000080 +#define DIEP_TYPESPECIFICPARAMS 0x00000100 +#if(DIRECTINPUT_VERSION >= 0x0600) +#define DIEP_STARTDELAY 0x00000200 +#define DIEP_ALLPARAMS_DX5 0x000001FF +#define DIEP_ALLPARAMS 0x000003FF +#else /* DIRECTINPUT_VERSION < 0x0600 */ +#define DIEP_ALLPARAMS 0x000001FF +#endif /* DIRECTINPUT_VERSION < 0x0600 */ +#define DIEP_START 0x20000000 +#define DIEP_NORESTART 0x40000000 +#define DIEP_NODOWNLOAD 0x80000000 +#define DIEB_NOTRIGGER 0xFFFFFFFF + +#define DIES_SOLO 0x00000001 +#define DIES_NODOWNLOAD 0x80000000 + +#define DIEGES_PLAYING 0x00000001 +#define DIEGES_EMULATED 0x00000002 + +typedef struct DIEFFESCAPE { + DWORD dwSize; + DWORD dwCommand; + LPVOID lpvInBuffer; + DWORD cbInBuffer; + LPVOID lpvOutBuffer; + DWORD cbOutBuffer; +} DIEFFESCAPE, *LPDIEFFESCAPE; + +#ifndef DIJ_RINGZERO + +#undef INTERFACE +#define INTERFACE IDirectInputEffect + +DECLARE_INTERFACE_(IDirectInputEffect, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputEffect methods ***/ + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(GetEffectGuid)(THIS_ LPGUID) PURE; + STDMETHOD(GetParameters)(THIS_ LPDIEFFECT,DWORD) PURE; + STDMETHOD(SetParameters)(THIS_ LPCDIEFFECT,DWORD) PURE; + STDMETHOD(Start)(THIS_ DWORD,DWORD) PURE; + STDMETHOD(Stop)(THIS) PURE; + STDMETHOD(GetEffectStatus)(THIS_ LPDWORD) PURE; + STDMETHOD(Download)(THIS) PURE; + STDMETHOD(Unload)(THIS) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; +}; + +typedef struct IDirectInputEffect *LPDIRECTINPUTEFFECT; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputEffect_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputEffect_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputEffect_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputEffect_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectInputEffect_GetEffectGuid(p,a) (p)->lpVtbl->GetEffectGuid(p,a) +#define IDirectInputEffect_GetParameters(p,a,b) (p)->lpVtbl->GetParameters(p,a,b) +#define IDirectInputEffect_SetParameters(p,a,b) (p)->lpVtbl->SetParameters(p,a,b) +#define IDirectInputEffect_Start(p,a,b) (p)->lpVtbl->Start(p,a,b) +#define IDirectInputEffect_Stop(p) (p)->lpVtbl->Stop(p) +#define IDirectInputEffect_GetEffectStatus(p,a) (p)->lpVtbl->GetEffectStatus(p,a) +#define IDirectInputEffect_Download(p) (p)->lpVtbl->Download(p) +#define IDirectInputEffect_Unload(p) (p)->lpVtbl->Unload(p) +#define IDirectInputEffect_Escape(p,a) (p)->lpVtbl->Escape(p,a) +#else +#define IDirectInputEffect_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputEffect_AddRef(p) (p)->AddRef() +#define IDirectInputEffect_Release(p) (p)->Release() +#define IDirectInputEffect_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectInputEffect_GetEffectGuid(p,a) (p)->GetEffectGuid(a) +#define IDirectInputEffect_GetParameters(p,a,b) (p)->GetParameters(a,b) +#define IDirectInputEffect_SetParameters(p,a,b) (p)->SetParameters(a,b) +#define IDirectInputEffect_Start(p,a,b) (p)->Start(a,b) +#define IDirectInputEffect_Stop(p) (p)->Stop() +#define IDirectInputEffect_GetEffectStatus(p,a) (p)->GetEffectStatus(a) +#define IDirectInputEffect_Download(p) (p)->Download() +#define IDirectInputEffect_Unload(p) (p)->Unload() +#define IDirectInputEffect_Escape(p,a) (p)->Escape(a) +#endif + +#endif /* DIJ_RINGZERO */ + +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +/**************************************************************************** + * + * IDirectInputDevice + * + ****************************************************************************/ + +#if DIRECTINPUT_VERSION <= 0x700 +#define DIDEVTYPE_DEVICE 1 +#define DIDEVTYPE_MOUSE 2 +#define DIDEVTYPE_KEYBOARD 3 +#define DIDEVTYPE_JOYSTICK 4 + +#else +#define DI8DEVCLASS_ALL 0 +#define DI8DEVCLASS_DEVICE 1 +#define DI8DEVCLASS_POINTER 2 +#define DI8DEVCLASS_KEYBOARD 3 +#define DI8DEVCLASS_GAMECTRL 4 + +#define DI8DEVTYPE_DEVICE 0x11 +#define DI8DEVTYPE_MOUSE 0x12 +#define DI8DEVTYPE_KEYBOARD 0x13 +#define DI8DEVTYPE_JOYSTICK 0x14 +#define DI8DEVTYPE_GAMEPAD 0x15 +#define DI8DEVTYPE_DRIVING 0x16 +#define DI8DEVTYPE_FLIGHT 0x17 +#define DI8DEVTYPE_1STPERSON 0x18 +#define DI8DEVTYPE_DEVICECTRL 0x19 +#define DI8DEVTYPE_SCREENPOINTER 0x1A +#define DI8DEVTYPE_REMOTE 0x1B +#define DI8DEVTYPE_SUPPLEMENTAL 0x1C +#endif /* DIRECTINPUT_VERSION <= 0x700 */ + +#define DIDEVTYPE_HID 0x00010000 + +#if DIRECTINPUT_VERSION <= 0x700 +#define DIDEVTYPEMOUSE_UNKNOWN 1 +#define DIDEVTYPEMOUSE_TRADITIONAL 2 +#define DIDEVTYPEMOUSE_FINGERSTICK 3 +#define DIDEVTYPEMOUSE_TOUCHPAD 4 +#define DIDEVTYPEMOUSE_TRACKBALL 5 + +#define DIDEVTYPEKEYBOARD_UNKNOWN 0 +#define DIDEVTYPEKEYBOARD_PCXT 1 +#define DIDEVTYPEKEYBOARD_OLIVETTI 2 +#define DIDEVTYPEKEYBOARD_PCAT 3 +#define DIDEVTYPEKEYBOARD_PCENH 4 +#define DIDEVTYPEKEYBOARD_NOKIA1050 5 +#define DIDEVTYPEKEYBOARD_NOKIA9140 6 +#define DIDEVTYPEKEYBOARD_NEC98 7 +#define DIDEVTYPEKEYBOARD_NEC98LAPTOP 8 +#define DIDEVTYPEKEYBOARD_NEC98106 9 +#define DIDEVTYPEKEYBOARD_JAPAN106 10 +#define DIDEVTYPEKEYBOARD_JAPANAX 11 +#define DIDEVTYPEKEYBOARD_J3100 12 + +#define DIDEVTYPEJOYSTICK_UNKNOWN 1 +#define DIDEVTYPEJOYSTICK_TRADITIONAL 2 +#define DIDEVTYPEJOYSTICK_FLIGHTSTICK 3 +#define DIDEVTYPEJOYSTICK_GAMEPAD 4 +#define DIDEVTYPEJOYSTICK_RUDDER 5 +#define DIDEVTYPEJOYSTICK_WHEEL 6 +#define DIDEVTYPEJOYSTICK_HEADTRACKER 7 + +#else +#define DI8DEVTYPEMOUSE_UNKNOWN 1 +#define DI8DEVTYPEMOUSE_TRADITIONAL 2 +#define DI8DEVTYPEMOUSE_FINGERSTICK 3 +#define DI8DEVTYPEMOUSE_TOUCHPAD 4 +#define DI8DEVTYPEMOUSE_TRACKBALL 5 +#define DI8DEVTYPEMOUSE_ABSOLUTE 6 + +#define DI8DEVTYPEKEYBOARD_UNKNOWN 0 +#define DI8DEVTYPEKEYBOARD_PCXT 1 +#define DI8DEVTYPEKEYBOARD_OLIVETTI 2 +#define DI8DEVTYPEKEYBOARD_PCAT 3 +#define DI8DEVTYPEKEYBOARD_PCENH 4 +#define DI8DEVTYPEKEYBOARD_NOKIA1050 5 +#define DI8DEVTYPEKEYBOARD_NOKIA9140 6 +#define DI8DEVTYPEKEYBOARD_NEC98 7 +#define DI8DEVTYPEKEYBOARD_NEC98LAPTOP 8 +#define DI8DEVTYPEKEYBOARD_NEC98106 9 +#define DI8DEVTYPEKEYBOARD_JAPAN106 10 +#define DI8DEVTYPEKEYBOARD_JAPANAX 11 +#define DI8DEVTYPEKEYBOARD_J3100 12 + +#define DI8DEVTYPE_LIMITEDGAMESUBTYPE 1 + +#define DI8DEVTYPEJOYSTICK_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPEJOYSTICK_STANDARD 2 + +#define DI8DEVTYPEGAMEPAD_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPEGAMEPAD_STANDARD 2 +#define DI8DEVTYPEGAMEPAD_TILT 3 + +#define DI8DEVTYPEDRIVING_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPEDRIVING_COMBINEDPEDALS 2 +#define DI8DEVTYPEDRIVING_DUALPEDALS 3 +#define DI8DEVTYPEDRIVING_THREEPEDALS 4 +#define DI8DEVTYPEDRIVING_HANDHELD 5 + +#define DI8DEVTYPEFLIGHT_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPEFLIGHT_STICK 2 +#define DI8DEVTYPEFLIGHT_YOKE 3 +#define DI8DEVTYPEFLIGHT_RC 4 + +#define DI8DEVTYPE1STPERSON_LIMITED DI8DEVTYPE_LIMITEDGAMESUBTYPE +#define DI8DEVTYPE1STPERSON_UNKNOWN 2 +#define DI8DEVTYPE1STPERSON_SIXDOF 3 +#define DI8DEVTYPE1STPERSON_SHOOTER 4 + +#define DI8DEVTYPESCREENPTR_UNKNOWN 2 +#define DI8DEVTYPESCREENPTR_LIGHTGUN 3 +#define DI8DEVTYPESCREENPTR_LIGHTPEN 4 +#define DI8DEVTYPESCREENPTR_TOUCH 5 + +#define DI8DEVTYPEREMOTE_UNKNOWN 2 + +#define DI8DEVTYPEDEVICECTRL_UNKNOWN 2 +#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION 3 +#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED 4 + +#define DI8DEVTYPESUPPLEMENTAL_UNKNOWN 2 +#define DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER 3 +#define DI8DEVTYPESUPPLEMENTAL_HEADTRACKER 4 +#define DI8DEVTYPESUPPLEMENTAL_HANDTRACKER 5 +#define DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE 6 +#define DI8DEVTYPESUPPLEMENTAL_SHIFTER 7 +#define DI8DEVTYPESUPPLEMENTAL_THROTTLE 8 +#define DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE 9 +#define DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS 10 +#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS 11 +#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS 12 +#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS 13 +#endif /* DIRECTINPUT_VERSION <= 0x700 */ + +#define GET_DIDEVICE_TYPE(dwDevType) LOBYTE(dwDevType) +#define GET_DIDEVICE_SUBTYPE(dwDevType) HIBYTE(dwDevType) + +#if(DIRECTINPUT_VERSION >= 0x0500) +/* This structure is defined for DirectX 3.0 compatibility */ +typedef struct DIDEVCAPS_DX3 { + DWORD dwSize; + DWORD dwFlags; + DWORD dwDevType; + DWORD dwAxes; + DWORD dwButtons; + DWORD dwPOVs; +} DIDEVCAPS_DX3, *LPDIDEVCAPS_DX3; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +typedef struct DIDEVCAPS { + DWORD dwSize; + DWORD dwFlags; + DWORD dwDevType; + DWORD dwAxes; + DWORD dwButtons; + DWORD dwPOVs; +#if(DIRECTINPUT_VERSION >= 0x0500) + DWORD dwFFSamplePeriod; + DWORD dwFFMinTimeResolution; + DWORD dwFirmwareRevision; + DWORD dwHardwareRevision; + DWORD dwFFDriverVersion; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVCAPS, *LPDIDEVCAPS; + +#define DIDC_ATTACHED 0x00000001 +#define DIDC_POLLEDDEVICE 0x00000002 +#define DIDC_EMULATED 0x00000004 +#define DIDC_POLLEDDATAFORMAT 0x00000008 +#if(DIRECTINPUT_VERSION >= 0x0500) +#define DIDC_FORCEFEEDBACK 0x00000100 +#define DIDC_FFATTACK 0x00000200 +#define DIDC_FFFADE 0x00000400 +#define DIDC_SATURATION 0x00000800 +#define DIDC_POSNEGCOEFFICIENTS 0x00001000 +#define DIDC_POSNEGSATURATION 0x00002000 +#define DIDC_DEADBAND 0x00004000 +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +#define DIDC_STARTDELAY 0x00008000 +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIDC_ALIAS 0x00010000 +#define DIDC_PHANTOM 0x00020000 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIDC_HIDDEN 0x00040000 +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#define DIDFT_ALL 0x00000000 + +#define DIDFT_RELAXIS 0x00000001 +#define DIDFT_ABSAXIS 0x00000002 +#define DIDFT_AXIS 0x00000003 + +#define DIDFT_PSHBUTTON 0x00000004 +#define DIDFT_TGLBUTTON 0x00000008 +#define DIDFT_BUTTON 0x0000000C + +#define DIDFT_POV 0x00000010 +#define DIDFT_COLLECTION 0x00000040 +#define DIDFT_NODATA 0x00000080 + +#define DIDFT_ANYINSTANCE 0x00FFFF00 +#define DIDFT_INSTANCEMASK DIDFT_ANYINSTANCE +#define DIDFT_MAKEINSTANCE(n) ((WORD)(n) << 8) +#define DIDFT_GETTYPE(n) LOBYTE(n) +#define DIDFT_GETINSTANCE(n) LOWORD((n) >> 8) +#define DIDFT_FFACTUATOR 0x01000000 +#define DIDFT_FFEFFECTTRIGGER 0x02000000 +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIDFT_OUTPUT 0x10000000 +#define DIDFT_VENDORDEFINED 0x04000000 +#define DIDFT_ALIAS 0x08000000 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ +#ifndef DIDFT_OPTIONAL +#define DIDFT_OPTIONAL 0x80000000 +#endif + +#define DIDFT_ENUMCOLLECTION(n) ((WORD)(n) << 8) +#define DIDFT_NOCOLLECTION 0x00FFFF00 + +#ifndef DIJ_RINGZERO + +typedef struct _DIOBJECTDATAFORMAT { + const GUID *pguid; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; +} DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT; +typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT; + +typedef struct _DIDATAFORMAT { + DWORD dwSize; + DWORD dwObjSize; + DWORD dwFlags; + DWORD dwDataSize; + DWORD dwNumObjs; + LPDIOBJECTDATAFORMAT rgodf; +} DIDATAFORMAT, *LPDIDATAFORMAT; +typedef const DIDATAFORMAT *LPCDIDATAFORMAT; + +#define DIDF_ABSAXIS 0x00000001 +#define DIDF_RELAXIS 0x00000002 + +#ifdef __cplusplus +extern "C" { +#endif +extern const DIDATAFORMAT c_dfDIMouse; + +#if(DIRECTINPUT_VERSION >= 0x0700) +extern const DIDATAFORMAT c_dfDIMouse2; +#endif /* DIRECTINPUT_VERSION >= 0x0700 */ + +extern const DIDATAFORMAT c_dfDIKeyboard; + +#if(DIRECTINPUT_VERSION >= 0x0500) +extern const DIDATAFORMAT c_dfDIJoystick; +extern const DIDATAFORMAT c_dfDIJoystick2; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +#ifdef __cplusplus +}; +#endif + + +#if DIRECTINPUT_VERSION > 0x0700 + +typedef struct _DIACTIONA { + UINT_PTR uAppData; + DWORD dwSemantic; + OPTIONAL DWORD dwFlags; + OPTIONAL union { + LPCSTR lptszActionName; + UINT uResIdString; + }; + OPTIONAL GUID guidInstance; + OPTIONAL DWORD dwObjID; + OPTIONAL DWORD dwHow; +} DIACTIONA, *LPDIACTIONA ; +typedef struct _DIACTIONW { + UINT_PTR uAppData; + DWORD dwSemantic; + OPTIONAL DWORD dwFlags; + OPTIONAL union { + LPCWSTR lptszActionName; + UINT uResIdString; + }; + OPTIONAL GUID guidInstance; + OPTIONAL DWORD dwObjID; + OPTIONAL DWORD dwHow; +} DIACTIONW, *LPDIACTIONW ; +#ifdef UNICODE +typedef DIACTIONW DIACTION; +typedef LPDIACTIONW LPDIACTION; +#else +typedef DIACTIONA DIACTION; +typedef LPDIACTIONA LPDIACTION; +#endif // UNICODE + +typedef const DIACTIONA *LPCDIACTIONA; +typedef const DIACTIONW *LPCDIACTIONW; +#ifdef UNICODE +typedef DIACTIONW DIACTION; +typedef LPCDIACTIONW LPCDIACTION; +#else +typedef DIACTIONA DIACTION; +typedef LPCDIACTIONA LPCDIACTION; +#endif // UNICODE +typedef const DIACTION *LPCDIACTION; + + +#define DIA_FORCEFEEDBACK 0x00000001 +#define DIA_APPMAPPED 0x00000002 +#define DIA_APPNOMAP 0x00000004 +#define DIA_NORANGE 0x00000008 +#define DIA_APPFIXED 0x00000010 + +#define DIAH_UNMAPPED 0x00000000 +#define DIAH_USERCONFIG 0x00000001 +#define DIAH_APPREQUESTED 0x00000002 +#define DIAH_HWAPP 0x00000004 +#define DIAH_HWDEFAULT 0x00000008 +#define DIAH_DEFAULT 0x00000020 +#define DIAH_ERROR 0x80000000 + +typedef struct _DIACTIONFORMATA { + DWORD dwSize; + DWORD dwActionSize; + DWORD dwDataSize; + DWORD dwNumActions; + LPDIACTIONA rgoAction; + GUID guidActionMap; + DWORD dwGenre; + DWORD dwBufferSize; + OPTIONAL LONG lAxisMin; + OPTIONAL LONG lAxisMax; + OPTIONAL HINSTANCE hInstString; + FILETIME ftTimeStamp; + DWORD dwCRC; + CHAR tszActionMap[MAX_PATH]; +} DIACTIONFORMATA, *LPDIACTIONFORMATA; +typedef struct _DIACTIONFORMATW { + DWORD dwSize; + DWORD dwActionSize; + DWORD dwDataSize; + DWORD dwNumActions; + LPDIACTIONW rgoAction; + GUID guidActionMap; + DWORD dwGenre; + DWORD dwBufferSize; + OPTIONAL LONG lAxisMin; + OPTIONAL LONG lAxisMax; + OPTIONAL HINSTANCE hInstString; + FILETIME ftTimeStamp; + DWORD dwCRC; + WCHAR tszActionMap[MAX_PATH]; +} DIACTIONFORMATW, *LPDIACTIONFORMATW; +#ifdef UNICODE +typedef DIACTIONFORMATW DIACTIONFORMAT; +typedef LPDIACTIONFORMATW LPDIACTIONFORMAT; +#else +typedef DIACTIONFORMATA DIACTIONFORMAT; +typedef LPDIACTIONFORMATA LPDIACTIONFORMAT; +#endif // UNICODE +typedef const DIACTIONFORMATA *LPCDIACTIONFORMATA; +typedef const DIACTIONFORMATW *LPCDIACTIONFORMATW; +#ifdef UNICODE +typedef DIACTIONFORMATW DIACTIONFORMAT; +typedef LPCDIACTIONFORMATW LPCDIACTIONFORMAT; +#else +typedef DIACTIONFORMATA DIACTIONFORMAT; +typedef LPCDIACTIONFORMATA LPCDIACTIONFORMAT; +#endif // UNICODE +typedef const DIACTIONFORMAT *LPCDIACTIONFORMAT; + +#define DIAFTS_NEWDEVICELOW 0xFFFFFFFF +#define DIAFTS_NEWDEVICEHIGH 0xFFFFFFFF +#define DIAFTS_UNUSEDDEVICELOW 0x00000000 +#define DIAFTS_UNUSEDDEVICEHIGH 0x00000000 + +#define DIDBAM_DEFAULT 0x00000000 +#define DIDBAM_PRESERVE 0x00000001 +#define DIDBAM_INITIALIZE 0x00000002 +#define DIDBAM_HWDEFAULTS 0x00000004 + +#define DIDSAM_DEFAULT 0x00000000 +#define DIDSAM_NOUSER 0x00000001 +#define DIDSAM_FORCESAVE 0x00000002 + +#define DICD_DEFAULT 0x00000000 +#define DICD_EDIT 0x00000001 + +/* + * The following definition is normally defined in d3dtypes.h + */ +#ifndef D3DCOLOR_DEFINED +typedef DWORD D3DCOLOR; +#define D3DCOLOR_DEFINED +#endif + +typedef struct _DICOLORSET{ + DWORD dwSize; + D3DCOLOR cTextFore; + D3DCOLOR cTextHighlight; + D3DCOLOR cCalloutLine; + D3DCOLOR cCalloutHighlight; + D3DCOLOR cBorder; + D3DCOLOR cControlFill; + D3DCOLOR cHighlightFill; + D3DCOLOR cAreaFill; +} DICOLORSET, *LPDICOLORSET; +typedef const DICOLORSET *LPCDICOLORSET; + + +typedef struct _DICONFIGUREDEVICESPARAMSA{ + DWORD dwSize; + DWORD dwcUsers; + LPSTR lptszUserNames; + DWORD dwcFormats; + LPDIACTIONFORMATA lprgFormats; + HWND hwnd; + DICOLORSET dics; + IUnknown FAR * lpUnkDDSTarget; +} DICONFIGUREDEVICESPARAMSA, *LPDICONFIGUREDEVICESPARAMSA; +typedef struct _DICONFIGUREDEVICESPARAMSW{ + DWORD dwSize; + DWORD dwcUsers; + LPWSTR lptszUserNames; + DWORD dwcFormats; + LPDIACTIONFORMATW lprgFormats; + HWND hwnd; + DICOLORSET dics; + IUnknown FAR * lpUnkDDSTarget; +} DICONFIGUREDEVICESPARAMSW, *LPDICONFIGUREDEVICESPARAMSW; +#ifdef UNICODE +typedef DICONFIGUREDEVICESPARAMSW DICONFIGUREDEVICESPARAMS; +typedef LPDICONFIGUREDEVICESPARAMSW LPDICONFIGUREDEVICESPARAMS; +#else +typedef DICONFIGUREDEVICESPARAMSA DICONFIGUREDEVICESPARAMS; +typedef LPDICONFIGUREDEVICESPARAMSA LPDICONFIGUREDEVICESPARAMS; +#endif // UNICODE +typedef const DICONFIGUREDEVICESPARAMSA *LPCDICONFIGUREDEVICESPARAMSA; +typedef const DICONFIGUREDEVICESPARAMSW *LPCDICONFIGUREDEVICESPARAMSW; +#ifdef UNICODE +typedef DICONFIGUREDEVICESPARAMSW DICONFIGUREDEVICESPARAMS; +typedef LPCDICONFIGUREDEVICESPARAMSW LPCDICONFIGUREDEVICESPARAMS; +#else +typedef DICONFIGUREDEVICESPARAMSA DICONFIGUREDEVICESPARAMS; +typedef LPCDICONFIGUREDEVICESPARAMSA LPCDICONFIGUREDEVICESPARAMS; +#endif // UNICODE +typedef const DICONFIGUREDEVICESPARAMS *LPCDICONFIGUREDEVICESPARAMS; + + +#define DIDIFT_CONFIGURATION 0x00000001 +#define DIDIFT_OVERLAY 0x00000002 + +#define DIDAL_CENTERED 0x00000000 +#define DIDAL_LEFTALIGNED 0x00000001 +#define DIDAL_RIGHTALIGNED 0x00000002 +#define DIDAL_MIDDLE 0x00000000 +#define DIDAL_TOPALIGNED 0x00000004 +#define DIDAL_BOTTOMALIGNED 0x00000008 + +typedef struct _DIDEVICEIMAGEINFOA { + CHAR tszImagePath[MAX_PATH]; + DWORD dwFlags; + // These are valid if DIDIFT_OVERLAY is present in dwFlags. + DWORD dwViewID; + RECT rcOverlay; + DWORD dwObjID; + DWORD dwcValidPts; + POINT rgptCalloutLine[5]; + RECT rcCalloutRect; + DWORD dwTextAlign; +} DIDEVICEIMAGEINFOA, *LPDIDEVICEIMAGEINFOA; +typedef struct _DIDEVICEIMAGEINFOW { + WCHAR tszImagePath[MAX_PATH]; + DWORD dwFlags; + // These are valid if DIDIFT_OVERLAY is present in dwFlags. + DWORD dwViewID; + RECT rcOverlay; + DWORD dwObjID; + DWORD dwcValidPts; + POINT rgptCalloutLine[5]; + RECT rcCalloutRect; + DWORD dwTextAlign; +} DIDEVICEIMAGEINFOW, *LPDIDEVICEIMAGEINFOW; +#ifdef UNICODE +typedef DIDEVICEIMAGEINFOW DIDEVICEIMAGEINFO; +typedef LPDIDEVICEIMAGEINFOW LPDIDEVICEIMAGEINFO; +#else +typedef DIDEVICEIMAGEINFOA DIDEVICEIMAGEINFO; +typedef LPDIDEVICEIMAGEINFOA LPDIDEVICEIMAGEINFO; +#endif // UNICODE +typedef const DIDEVICEIMAGEINFOA *LPCDIDEVICEIMAGEINFOA; +typedef const DIDEVICEIMAGEINFOW *LPCDIDEVICEIMAGEINFOW; +#ifdef UNICODE +typedef DIDEVICEIMAGEINFOW DIDEVICEIMAGEINFO; +typedef LPCDIDEVICEIMAGEINFOW LPCDIDEVICEIMAGEINFO; +#else +typedef DIDEVICEIMAGEINFOA DIDEVICEIMAGEINFO; +typedef LPCDIDEVICEIMAGEINFOA LPCDIDEVICEIMAGEINFO; +#endif // UNICODE +typedef const DIDEVICEIMAGEINFO *LPCDIDEVICEIMAGEINFO; + +typedef struct _DIDEVICEIMAGEINFOHEADERA { + DWORD dwSize; + DWORD dwSizeImageInfo; + DWORD dwcViews; + DWORD dwcButtons; + DWORD dwcAxes; + DWORD dwcPOVs; + DWORD dwBufferSize; + DWORD dwBufferUsed; + LPDIDEVICEIMAGEINFOA lprgImageInfoArray; +} DIDEVICEIMAGEINFOHEADERA, *LPDIDEVICEIMAGEINFOHEADERA; +typedef struct _DIDEVICEIMAGEINFOHEADERW { + DWORD dwSize; + DWORD dwSizeImageInfo; + DWORD dwcViews; + DWORD dwcButtons; + DWORD dwcAxes; + DWORD dwcPOVs; + DWORD dwBufferSize; + DWORD dwBufferUsed; + LPDIDEVICEIMAGEINFOW lprgImageInfoArray; +} DIDEVICEIMAGEINFOHEADERW, *LPDIDEVICEIMAGEINFOHEADERW; +#ifdef UNICODE +typedef DIDEVICEIMAGEINFOHEADERW DIDEVICEIMAGEINFOHEADER; +typedef LPDIDEVICEIMAGEINFOHEADERW LPDIDEVICEIMAGEINFOHEADER; +#else +typedef DIDEVICEIMAGEINFOHEADERA DIDEVICEIMAGEINFOHEADER; +typedef LPDIDEVICEIMAGEINFOHEADERA LPDIDEVICEIMAGEINFOHEADER; +#endif // UNICODE +typedef const DIDEVICEIMAGEINFOHEADERA *LPCDIDEVICEIMAGEINFOHEADERA; +typedef const DIDEVICEIMAGEINFOHEADERW *LPCDIDEVICEIMAGEINFOHEADERW; +#ifdef UNICODE +typedef DIDEVICEIMAGEINFOHEADERW DIDEVICEIMAGEINFOHEADER; +typedef LPCDIDEVICEIMAGEINFOHEADERW LPCDIDEVICEIMAGEINFOHEADER; +#else +typedef DIDEVICEIMAGEINFOHEADERA DIDEVICEIMAGEINFOHEADER; +typedef LPCDIDEVICEIMAGEINFOHEADERA LPCDIDEVICEIMAGEINFOHEADER; +#endif // UNICODE +typedef const DIDEVICEIMAGEINFOHEADER *LPCDIDEVICEIMAGEINFOHEADER; + +#endif /* DIRECTINPUT_VERSION > 0x0700 */ + +#if(DIRECTINPUT_VERSION >= 0x0500) +/* These structures are defined for DirectX 3.0 compatibility */ + +typedef struct DIDEVICEOBJECTINSTANCE_DX3A { + DWORD dwSize; + GUID guidType; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; + CHAR tszName[MAX_PATH]; +} DIDEVICEOBJECTINSTANCE_DX3A, *LPDIDEVICEOBJECTINSTANCE_DX3A; +typedef struct DIDEVICEOBJECTINSTANCE_DX3W { + DWORD dwSize; + GUID guidType; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; + WCHAR tszName[MAX_PATH]; +} DIDEVICEOBJECTINSTANCE_DX3W, *LPDIDEVICEOBJECTINSTANCE_DX3W; +#ifdef UNICODE +typedef DIDEVICEOBJECTINSTANCE_DX3W DIDEVICEOBJECTINSTANCE_DX3; +typedef LPDIDEVICEOBJECTINSTANCE_DX3W LPDIDEVICEOBJECTINSTANCE_DX3; +#else +typedef DIDEVICEOBJECTINSTANCE_DX3A DIDEVICEOBJECTINSTANCE_DX3; +typedef LPDIDEVICEOBJECTINSTANCE_DX3A LPDIDEVICEOBJECTINSTANCE_DX3; +#endif // UNICODE +typedef const DIDEVICEOBJECTINSTANCE_DX3A *LPCDIDEVICEOBJECTINSTANCE_DX3A; +typedef const DIDEVICEOBJECTINSTANCE_DX3W *LPCDIDEVICEOBJECTINSTANCE_DX3W; +typedef const DIDEVICEOBJECTINSTANCE_DX3 *LPCDIDEVICEOBJECTINSTANCE_DX3; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +typedef struct DIDEVICEOBJECTINSTANCEA { + DWORD dwSize; + GUID guidType; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; + CHAR tszName[MAX_PATH]; +#if(DIRECTINPUT_VERSION >= 0x0500) + DWORD dwFFMaxForce; + DWORD dwFFForceResolution; + WORD wCollectionNumber; + WORD wDesignatorIndex; + WORD wUsagePage; + WORD wUsage; + DWORD dwDimension; + WORD wExponent; + WORD wReportId; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA; +typedef struct DIDEVICEOBJECTINSTANCEW { + DWORD dwSize; + GUID guidType; + DWORD dwOfs; + DWORD dwType; + DWORD dwFlags; + WCHAR tszName[MAX_PATH]; +#if(DIRECTINPUT_VERSION >= 0x0500) + DWORD dwFFMaxForce; + DWORD dwFFForceResolution; + WORD wCollectionNumber; + WORD wDesignatorIndex; + WORD wUsagePage; + WORD wUsage; + DWORD dwDimension; + WORD wExponent; + WORD wReportId; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW; +#ifdef UNICODE +typedef DIDEVICEOBJECTINSTANCEW DIDEVICEOBJECTINSTANCE; +typedef LPDIDEVICEOBJECTINSTANCEW LPDIDEVICEOBJECTINSTANCE; +#else +typedef DIDEVICEOBJECTINSTANCEA DIDEVICEOBJECTINSTANCE; +typedef LPDIDEVICEOBJECTINSTANCEA LPDIDEVICEOBJECTINSTANCE; +#endif // UNICODE +typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA; +typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW; +typedef const DIDEVICEOBJECTINSTANCE *LPCDIDEVICEOBJECTINSTANCE; + +typedef BOOL (FAR PASCAL * LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA, LPVOID); +typedef BOOL (FAR PASCAL * LPDIENUMDEVICEOBJECTSCALLBACKW)(LPCDIDEVICEOBJECTINSTANCEW, LPVOID); +#ifdef UNICODE +#define LPDIENUMDEVICEOBJECTSCALLBACK LPDIENUMDEVICEOBJECTSCALLBACKW +#else +#define LPDIENUMDEVICEOBJECTSCALLBACK LPDIENUMDEVICEOBJECTSCALLBACKA +#endif // !UNICODE + +#if(DIRECTINPUT_VERSION >= 0x0500) +#define DIDOI_FFACTUATOR 0x00000001 +#define DIDOI_FFEFFECTTRIGGER 0x00000002 +#define DIDOI_POLLED 0x00008000 +#define DIDOI_ASPECTPOSITION 0x00000100 +#define DIDOI_ASPECTVELOCITY 0x00000200 +#define DIDOI_ASPECTACCEL 0x00000300 +#define DIDOI_ASPECTFORCE 0x00000400 +#define DIDOI_ASPECTMASK 0x00000F00 +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIDOI_GUIDISUSAGE 0x00010000 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +typedef struct DIPROPHEADER { + DWORD dwSize; + DWORD dwHeaderSize; + DWORD dwObj; + DWORD dwHow; +} DIPROPHEADER, *LPDIPROPHEADER; +typedef const DIPROPHEADER *LPCDIPROPHEADER; + +#define DIPH_DEVICE 0 +#define DIPH_BYOFFSET 1 +#define DIPH_BYID 2 +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIPH_BYUSAGE 3 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIMAKEUSAGEDWORD(UsagePage, Usage) \ + (DWORD)MAKELONG(Usage, UsagePage) +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +typedef struct DIPROPDWORD { + DIPROPHEADER diph; + DWORD dwData; +} DIPROPDWORD, *LPDIPROPDWORD; +typedef const DIPROPDWORD *LPCDIPROPDWORD; + +#if(DIRECTINPUT_VERSION >= 0x0800) +typedef struct DIPROPPOINTER { + DIPROPHEADER diph; + UINT_PTR uData; +} DIPROPPOINTER, *LPDIPROPPOINTER; +typedef const DIPROPPOINTER *LPCDIPROPPOINTER; +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +typedef struct DIPROPRANGE { + DIPROPHEADER diph; + LONG lMin; + LONG lMax; +} DIPROPRANGE, *LPDIPROPRANGE; +typedef const DIPROPRANGE *LPCDIPROPRANGE; + +#define DIPROPRANGE_NOMIN ((LONG)0x80000000) +#define DIPROPRANGE_NOMAX ((LONG)0x7FFFFFFF) + +#if(DIRECTINPUT_VERSION >= 0x050a) +typedef struct DIPROPCAL { + DIPROPHEADER diph; + LONG lMin; + LONG lCenter; + LONG lMax; +} DIPROPCAL, *LPDIPROPCAL; +typedef const DIPROPCAL *LPCDIPROPCAL; + +typedef struct DIPROPCALPOV { + DIPROPHEADER diph; + LONG lMin[5]; + LONG lMax[5]; +} DIPROPCALPOV, *LPDIPROPCALPOV; +typedef const DIPROPCALPOV *LPCDIPROPCALPOV; + +typedef struct DIPROPGUIDANDPATH { + DIPROPHEADER diph; + GUID guidClass; + WCHAR wszPath[MAX_PATH]; +} DIPROPGUIDANDPATH, *LPDIPROPGUIDANDPATH; +typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH; + +typedef struct DIPROPSTRING { + DIPROPHEADER diph; + WCHAR wsz[MAX_PATH]; +} DIPROPSTRING, *LPDIPROPSTRING; +typedef const DIPROPSTRING *LPCDIPROPSTRING; + +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +#if(DIRECTINPUT_VERSION >= 0x0800) +#define MAXCPOINTSNUM 8 + +typedef struct _CPOINT +{ + LONG lP; // raw value + DWORD dwLog; // logical_value / max_logical_value * 10000 +} CPOINT, *PCPOINT; + +typedef struct DIPROPCPOINTS { + DIPROPHEADER diph; + DWORD dwCPointsNum; + CPOINT cp[MAXCPOINTSNUM]; +} DIPROPCPOINTS, *LPDIPROPCPOINTS; +typedef const DIPROPCPOINTS *LPCDIPROPCPOINTS; +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + + +#ifdef __cplusplus +#define MAKEDIPROP(prop) (*(const GUID *)(prop)) +#else +#define MAKEDIPROP(prop) ((REFGUID)(prop)) +#endif + +#define DIPROP_BUFFERSIZE MAKEDIPROP(1) + +#define DIPROP_AXISMODE MAKEDIPROP(2) + +#define DIPROPAXISMODE_ABS 0 +#define DIPROPAXISMODE_REL 1 + +#define DIPROP_GRANULARITY MAKEDIPROP(3) + +#define DIPROP_RANGE MAKEDIPROP(4) + +#define DIPROP_DEADZONE MAKEDIPROP(5) + +#define DIPROP_SATURATION MAKEDIPROP(6) + +#define DIPROP_FFGAIN MAKEDIPROP(7) + +#define DIPROP_FFLOAD MAKEDIPROP(8) + +#define DIPROP_AUTOCENTER MAKEDIPROP(9) + +#define DIPROPAUTOCENTER_OFF 0 +#define DIPROPAUTOCENTER_ON 1 + +#define DIPROP_CALIBRATIONMODE MAKEDIPROP(10) + +#define DIPROPCALIBRATIONMODE_COOKED 0 +#define DIPROPCALIBRATIONMODE_RAW 1 + +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIPROP_CALIBRATION MAKEDIPROP(11) + +#define DIPROP_GUIDANDPATH MAKEDIPROP(12) + +#define DIPROP_INSTANCENAME MAKEDIPROP(13) + +#define DIPROP_PRODUCTNAME MAKEDIPROP(14) +#endif /* DIRECTINPUT_VERSION >= 0x050a */ + +#if(DIRECTINPUT_VERSION >= 0x05b2) +#define DIPROP_JOYSTICKID MAKEDIPROP(15) + +#define DIPROP_GETPORTDISPLAYNAME MAKEDIPROP(16) + +#endif /* DIRECTINPUT_VERSION >= 0x05b2 */ + +#if(DIRECTINPUT_VERSION >= 0x0700) +#define DIPROP_PHYSICALRANGE MAKEDIPROP(18) + +#define DIPROP_LOGICALRANGE MAKEDIPROP(19) +#endif /* DIRECTINPUT_VERSION >= 0x0700 */ + +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIPROP_KEYNAME MAKEDIPROP(20) + +#define DIPROP_CPOINTS MAKEDIPROP(21) + +#define DIPROP_APPDATA MAKEDIPROP(22) + +#define DIPROP_SCANCODE MAKEDIPROP(23) + +#define DIPROP_VIDPID MAKEDIPROP(24) + +#define DIPROP_USERNAME MAKEDIPROP(25) + +#define DIPROP_TYPENAME MAKEDIPROP(26) +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + + +typedef struct DIDEVICEOBJECTDATA_DX3 { + DWORD dwOfs; + DWORD dwData; + DWORD dwTimeStamp; + DWORD dwSequence; +} DIDEVICEOBJECTDATA_DX3, *LPDIDEVICEOBJECTDATA_DX3; +typedef const DIDEVICEOBJECTDATA_DX3 *LPCDIDEVICEOBJECTDATA_DX; + +typedef struct DIDEVICEOBJECTDATA { + DWORD dwOfs; + DWORD dwData; + DWORD dwTimeStamp; + DWORD dwSequence; +#if(DIRECTINPUT_VERSION >= 0x0800) + UINT_PTR uAppData; +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ +} DIDEVICEOBJECTDATA, *LPDIDEVICEOBJECTDATA; +typedef const DIDEVICEOBJECTDATA *LPCDIDEVICEOBJECTDATA; + +#define DIGDD_PEEK 0x00000001 + +#define DISEQUENCE_COMPARE(dwSequence1, cmp, dwSequence2) \ + ((int)((dwSequence1) - (dwSequence2)) cmp 0) +#define DISCL_EXCLUSIVE 0x00000001 +#define DISCL_NONEXCLUSIVE 0x00000002 +#define DISCL_FOREGROUND 0x00000004 +#define DISCL_BACKGROUND 0x00000008 +#define DISCL_NOWINKEY 0x00000010 + +#if(DIRECTINPUT_VERSION >= 0x0500) +/* These structures are defined for DirectX 3.0 compatibility */ + +typedef struct DIDEVICEINSTANCE_DX3A { + DWORD dwSize; + GUID guidInstance; + GUID guidProduct; + DWORD dwDevType; + CHAR tszInstanceName[MAX_PATH]; + CHAR tszProductName[MAX_PATH]; +} DIDEVICEINSTANCE_DX3A, *LPDIDEVICEINSTANCE_DX3A; +typedef struct DIDEVICEINSTANCE_DX3W { + DWORD dwSize; + GUID guidInstance; + GUID guidProduct; + DWORD dwDevType; + WCHAR tszInstanceName[MAX_PATH]; + WCHAR tszProductName[MAX_PATH]; +} DIDEVICEINSTANCE_DX3W, *LPDIDEVICEINSTANCE_DX3W; +#ifdef UNICODE +typedef DIDEVICEINSTANCE_DX3W DIDEVICEINSTANCE_DX3; +typedef LPDIDEVICEINSTANCE_DX3W LPDIDEVICEINSTANCE_DX3; +#else +typedef DIDEVICEINSTANCE_DX3A DIDEVICEINSTANCE_DX3; +typedef LPDIDEVICEINSTANCE_DX3A LPDIDEVICEINSTANCE_DX3; +#endif // UNICODE +typedef const DIDEVICEINSTANCE_DX3A *LPCDIDEVICEINSTANCE_DX3A; +typedef const DIDEVICEINSTANCE_DX3W *LPCDIDEVICEINSTANCE_DX3W; +typedef const DIDEVICEINSTANCE_DX3 *LPCDIDEVICEINSTANCE_DX3; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +typedef struct DIDEVICEINSTANCEA { + DWORD dwSize; + GUID guidInstance; + GUID guidProduct; + DWORD dwDevType; + CHAR tszInstanceName[MAX_PATH]; + CHAR tszProductName[MAX_PATH]; +#if(DIRECTINPUT_VERSION >= 0x0500) + GUID guidFFDriver; + WORD wUsagePage; + WORD wUsage; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA; +typedef struct DIDEVICEINSTANCEW { + DWORD dwSize; + GUID guidInstance; + GUID guidProduct; + DWORD dwDevType; + WCHAR tszInstanceName[MAX_PATH]; + WCHAR tszProductName[MAX_PATH]; +#if(DIRECTINPUT_VERSION >= 0x0500) + GUID guidFFDriver; + WORD wUsagePage; + WORD wUsage; +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW; +#ifdef UNICODE +typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE; +typedef LPDIDEVICEINSTANCEW LPDIDEVICEINSTANCE; +#else +typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE; +typedef LPDIDEVICEINSTANCEA LPDIDEVICEINSTANCE; +#endif // UNICODE + +typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA; +typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW; +#ifdef UNICODE +typedef DIDEVICEINSTANCEW DIDEVICEINSTANCE; +typedef LPCDIDEVICEINSTANCEW LPCDIDEVICEINSTANCE; +#else +typedef DIDEVICEINSTANCEA DIDEVICEINSTANCE; +typedef LPCDIDEVICEINSTANCEA LPCDIDEVICEINSTANCE; +#endif // UNICODE +typedef const DIDEVICEINSTANCE *LPCDIDEVICEINSTANCE; + +#undef INTERFACE +#define INTERFACE IDirectInputDeviceW + +DECLARE_INTERFACE_(IDirectInputDeviceW, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDeviceW methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; +}; + +typedef struct IDirectInputDeviceW *LPDIRECTINPUTDEVICEW; + +#undef INTERFACE +#define INTERFACE IDirectInputDeviceA + +DECLARE_INTERFACE_(IDirectInputDeviceA, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDeviceA methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; +}; + +typedef struct IDirectInputDeviceA *LPDIRECTINPUTDEVICEA; + +#ifdef UNICODE +#define IID_IDirectInputDevice IID_IDirectInputDeviceW +#define IDirectInputDevice IDirectInputDeviceW +#define IDirectInputDeviceVtbl IDirectInputDeviceWVtbl +#else +#define IID_IDirectInputDevice IID_IDirectInputDeviceA +#define IDirectInputDevice IDirectInputDeviceA +#define IDirectInputDeviceVtbl IDirectInputDeviceAVtbl +#endif +typedef struct IDirectInputDevice *LPDIRECTINPUTDEVICE; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputDevice_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputDevice_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputDevice_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) +#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) +#define IDirectInputDevice_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) +#define IDirectInputDevice_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) +#define IDirectInputDevice_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputDevice_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) +#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) +#define IDirectInputDevice_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) +#define IDirectInputDevice_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) +#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) +#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) +#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInputDevice_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#else +#define IDirectInputDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputDevice_AddRef(p) (p)->AddRef() +#define IDirectInputDevice_Release(p) (p)->Release() +#define IDirectInputDevice_GetCapabilities(p,a) (p)->GetCapabilities(a) +#define IDirectInputDevice_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) +#define IDirectInputDevice_GetProperty(p,a,b) (p)->GetProperty(a,b) +#define IDirectInputDevice_SetProperty(p,a,b) (p)->SetProperty(a,b) +#define IDirectInputDevice_Acquire(p) (p)->Acquire() +#define IDirectInputDevice_Unacquire(p) (p)->Unacquire() +#define IDirectInputDevice_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) +#define IDirectInputDevice_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) +#define IDirectInputDevice_SetDataFormat(p,a) (p)->SetDataFormat(a) +#define IDirectInputDevice_SetEventNotification(p,a) (p)->SetEventNotification(a) +#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputDevice_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) +#define IDirectInputDevice_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) +#define IDirectInputDevice_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInputDevice_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#endif + +#endif /* DIJ_RINGZERO */ + + +#if(DIRECTINPUT_VERSION >= 0x0500) + +#define DISFFC_RESET 0x00000001 +#define DISFFC_STOPALL 0x00000002 +#define DISFFC_PAUSE 0x00000004 +#define DISFFC_CONTINUE 0x00000008 +#define DISFFC_SETACTUATORSON 0x00000010 +#define DISFFC_SETACTUATORSOFF 0x00000020 + +#define DIGFFS_EMPTY 0x00000001 +#define DIGFFS_STOPPED 0x00000002 +#define DIGFFS_PAUSED 0x00000004 +#define DIGFFS_ACTUATORSON 0x00000010 +#define DIGFFS_ACTUATORSOFF 0x00000020 +#define DIGFFS_POWERON 0x00000040 +#define DIGFFS_POWEROFF 0x00000080 +#define DIGFFS_SAFETYSWITCHON 0x00000100 +#define DIGFFS_SAFETYSWITCHOFF 0x00000200 +#define DIGFFS_USERFFSWITCHON 0x00000400 +#define DIGFFS_USERFFSWITCHOFF 0x00000800 +#define DIGFFS_DEVICELOST 0x80000000 + +#ifndef DIJ_RINGZERO + +typedef struct DIEFFECTINFOA { + DWORD dwSize; + GUID guid; + DWORD dwEffType; + DWORD dwStaticParams; + DWORD dwDynamicParams; + CHAR tszName[MAX_PATH]; +} DIEFFECTINFOA, *LPDIEFFECTINFOA; +typedef struct DIEFFECTINFOW { + DWORD dwSize; + GUID guid; + DWORD dwEffType; + DWORD dwStaticParams; + DWORD dwDynamicParams; + WCHAR tszName[MAX_PATH]; +} DIEFFECTINFOW, *LPDIEFFECTINFOW; +#ifdef UNICODE +typedef DIEFFECTINFOW DIEFFECTINFO; +typedef LPDIEFFECTINFOW LPDIEFFECTINFO; +#else +typedef DIEFFECTINFOA DIEFFECTINFO; +typedef LPDIEFFECTINFOA LPDIEFFECTINFO; +#endif // UNICODE +typedef const DIEFFECTINFOA *LPCDIEFFECTINFOA; +typedef const DIEFFECTINFOW *LPCDIEFFECTINFOW; +typedef const DIEFFECTINFO *LPCDIEFFECTINFO; + +#define DISDD_CONTINUE 0x00000001 + +typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSCALLBACKA)(LPCDIEFFECTINFOA, LPVOID); +typedef BOOL (FAR PASCAL * LPDIENUMEFFECTSCALLBACKW)(LPCDIEFFECTINFOW, LPVOID); +#ifdef UNICODE +#define LPDIENUMEFFECTSCALLBACK LPDIENUMEFFECTSCALLBACKW +#else +#define LPDIENUMEFFECTSCALLBACK LPDIENUMEFFECTSCALLBACKA +#endif // !UNICODE +typedef BOOL (FAR PASCAL * LPDIENUMCREATEDEFFECTOBJECTSCALLBACK)(LPDIRECTINPUTEFFECT, LPVOID); + +#undef INTERFACE +#define INTERFACE IDirectInputDevice2W + +DECLARE_INTERFACE_(IDirectInputDevice2W, IDirectInputDeviceW) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDeviceW methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + + /*** IDirectInputDevice2W methods ***/ + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; +}; + +typedef struct IDirectInputDevice2W *LPDIRECTINPUTDEVICE2W; + +#undef INTERFACE +#define INTERFACE IDirectInputDevice2A + +DECLARE_INTERFACE_(IDirectInputDevice2A, IDirectInputDeviceA) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDeviceA methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + + /*** IDirectInputDevice2A methods ***/ + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; +}; + +typedef struct IDirectInputDevice2A *LPDIRECTINPUTDEVICE2A; + +#ifdef UNICODE +#define IID_IDirectInputDevice2 IID_IDirectInputDevice2W +#define IDirectInputDevice2 IDirectInputDevice2W +#define IDirectInputDevice2Vtbl IDirectInputDevice2WVtbl +#else +#define IID_IDirectInputDevice2 IID_IDirectInputDevice2A +#define IDirectInputDevice2 IDirectInputDevice2A +#define IDirectInputDevice2Vtbl IDirectInputDevice2AVtbl +#endif +typedef struct IDirectInputDevice2 *LPDIRECTINPUTDEVICE2; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputDevice2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputDevice2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputDevice2_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) +#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) +#define IDirectInputDevice2_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) +#define IDirectInputDevice2_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) +#define IDirectInputDevice2_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputDevice2_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) +#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) +#define IDirectInputDevice2_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) +#define IDirectInputDevice2_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) +#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) +#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) +#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) +#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) +#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) +#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) +#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) +#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) +#define IDirectInputDevice2_Escape(p,a) (p)->lpVtbl->Escape(p,a) +#define IDirectInputDevice2_Poll(p) (p)->lpVtbl->Poll(p) +#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) +#else +#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputDevice2_AddRef(p) (p)->AddRef() +#define IDirectInputDevice2_Release(p) (p)->Release() +#define IDirectInputDevice2_GetCapabilities(p,a) (p)->GetCapabilities(a) +#define IDirectInputDevice2_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) +#define IDirectInputDevice2_GetProperty(p,a,b) (p)->GetProperty(a,b) +#define IDirectInputDevice2_SetProperty(p,a,b) (p)->SetProperty(a,b) +#define IDirectInputDevice2_Acquire(p) (p)->Acquire() +#define IDirectInputDevice2_Unacquire(p) (p)->Unacquire() +#define IDirectInputDevice2_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) +#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) +#define IDirectInputDevice2_SetDataFormat(p,a) (p)->SetDataFormat(a) +#define IDirectInputDevice2_SetEventNotification(p,a) (p)->SetEventNotification(a) +#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputDevice2_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) +#define IDirectInputDevice2_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) +#define IDirectInputDevice2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInputDevice2_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectInputDevice2_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) +#define IDirectInputDevice2_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) +#define IDirectInputDevice2_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) +#define IDirectInputDevice2_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) +#define IDirectInputDevice2_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) +#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) +#define IDirectInputDevice2_Escape(p,a) (p)->Escape(a) +#define IDirectInputDevice2_Poll(p) (p)->Poll() +#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) +#endif + +#endif /* DIJ_RINGZERO */ + +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ + +#if(DIRECTINPUT_VERSION >= 0x0700) +#define DIFEF_DEFAULT 0x00000000 +#define DIFEF_INCLUDENONSTANDARD 0x00000001 +#define DIFEF_MODIFYIFNEEDED 0x00000010 + +#ifndef DIJ_RINGZERO + +#undef INTERFACE +#define INTERFACE IDirectInputDevice7W + +DECLARE_INTERFACE_(IDirectInputDevice7W, IDirectInputDevice2W) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDevice2W methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + + /*** IDirectInputDevice7W methods ***/ + STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; +}; + +typedef struct IDirectInputDevice7W *LPDIRECTINPUTDEVICE7W; + +#undef INTERFACE +#define INTERFACE IDirectInputDevice7A + +DECLARE_INTERFACE_(IDirectInputDevice7A, IDirectInputDevice2A) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDevice2A methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + + /*** IDirectInputDevice7A methods ***/ + STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; +}; + +typedef struct IDirectInputDevice7A *LPDIRECTINPUTDEVICE7A; + +#ifdef UNICODE +#define IID_IDirectInputDevice7 IID_IDirectInputDevice7W +#define IDirectInputDevice7 IDirectInputDevice7W +#define IDirectInputDevice7Vtbl IDirectInputDevice7WVtbl +#else +#define IID_IDirectInputDevice7 IID_IDirectInputDevice7A +#define IDirectInputDevice7 IDirectInputDevice7A +#define IDirectInputDevice7Vtbl IDirectInputDevice7AVtbl +#endif +typedef struct IDirectInputDevice7 *LPDIRECTINPUTDEVICE7; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputDevice7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputDevice7_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputDevice7_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) +#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) +#define IDirectInputDevice7_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) +#define IDirectInputDevice7_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) +#define IDirectInputDevice7_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputDevice7_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) +#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) +#define IDirectInputDevice7_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) +#define IDirectInputDevice7_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) +#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) +#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) +#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) +#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) +#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) +#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) +#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) +#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) +#define IDirectInputDevice7_Escape(p,a) (p)->lpVtbl->Escape(p,a) +#define IDirectInputDevice7_Poll(p) (p)->lpVtbl->Poll(p) +#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) +#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) +#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) +#else +#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputDevice7_AddRef(p) (p)->AddRef() +#define IDirectInputDevice7_Release(p) (p)->Release() +#define IDirectInputDevice7_GetCapabilities(p,a) (p)->GetCapabilities(a) +#define IDirectInputDevice7_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) +#define IDirectInputDevice7_GetProperty(p,a,b) (p)->GetProperty(a,b) +#define IDirectInputDevice7_SetProperty(p,a,b) (p)->SetProperty(a,b) +#define IDirectInputDevice7_Acquire(p) (p)->Acquire() +#define IDirectInputDevice7_Unacquire(p) (p)->Unacquire() +#define IDirectInputDevice7_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) +#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) +#define IDirectInputDevice7_SetDataFormat(p,a) (p)->SetDataFormat(a) +#define IDirectInputDevice7_SetEventNotification(p,a) (p)->SetEventNotification(a) +#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputDevice7_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) +#define IDirectInputDevice7_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) +#define IDirectInputDevice7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInputDevice7_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectInputDevice7_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) +#define IDirectInputDevice7_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) +#define IDirectInputDevice7_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) +#define IDirectInputDevice7_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) +#define IDirectInputDevice7_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) +#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) +#define IDirectInputDevice7_Escape(p,a) (p)->Escape(a) +#define IDirectInputDevice7_Poll(p) (p)->Poll() +#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) +#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) +#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) +#endif + +#endif /* DIJ_RINGZERO */ + +#endif /* DIRECTINPUT_VERSION >= 0x0700 */ + +#if(DIRECTINPUT_VERSION >= 0x0800) + +#ifndef DIJ_RINGZERO + +#undef INTERFACE +#define INTERFACE IDirectInputDevice8W + +DECLARE_INTERFACE_(IDirectInputDevice8W, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDevice8W methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; + STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATW,LPCWSTR,DWORD) PURE; + STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATW,LPCWSTR,DWORD) PURE; + STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERW) PURE; +}; + +typedef struct IDirectInputDevice8W *LPDIRECTINPUTDEVICE8W; + +#undef INTERFACE +#define INTERFACE IDirectInputDevice8A + +DECLARE_INTERFACE_(IDirectInputDevice8A, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputDevice8A methods ***/ + STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS) PURE; + STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetProperty)(THIS_ REFGUID,LPDIPROPHEADER) PURE; + STDMETHOD(SetProperty)(THIS_ REFGUID,LPCDIPROPHEADER) PURE; + STDMETHOD(Acquire)(THIS) PURE; + STDMETHOD(Unacquire)(THIS) PURE; + STDMETHOD(GetDeviceState)(THIS_ DWORD,LPVOID) PURE; + STDMETHOD(GetDeviceData)(THIS_ DWORD,LPDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT) PURE; + STDMETHOD(SetEventNotification)(THIS_ HANDLE) PURE; + STDMETHOD(SetCooperativeLevel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA,DWORD,DWORD) PURE; + STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD,REFGUID) PURE; + STDMETHOD(CreateEffect)(THIS_ REFGUID,LPCDIEFFECT,LPDIRECTINPUTEFFECT *,LPUNKNOWN) PURE; + STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA,REFGUID) PURE; + STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD) PURE; + STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD) PURE; + STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE; + STDMETHOD(Poll)(THIS) PURE; + STDMETHOD(SendDeviceData)(THIS_ DWORD,LPCDIDEVICEOBJECTDATA,LPDWORD,DWORD) PURE; + STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR,LPDIENUMEFFECTSINFILECALLBACK,LPVOID,DWORD) PURE; + STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR,DWORD,LPDIFILEEFFECT,DWORD) PURE; + STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATA,LPCSTR,DWORD) PURE; + STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATA,LPCSTR,DWORD) PURE; + STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERA) PURE; +}; + +typedef struct IDirectInputDevice8A *LPDIRECTINPUTDEVICE8A; + +#ifdef UNICODE +#define IID_IDirectInputDevice8 IID_IDirectInputDevice8W +#define IDirectInputDevice8 IDirectInputDevice8W +#define IDirectInputDevice8Vtbl IDirectInputDevice8WVtbl +#else +#define IID_IDirectInputDevice8 IID_IDirectInputDevice8A +#define IDirectInputDevice8 IDirectInputDevice8A +#define IDirectInputDevice8Vtbl IDirectInputDevice8AVtbl +#endif +typedef struct IDirectInputDevice8 *LPDIRECTINPUTDEVICE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInputDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInputDevice8_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInputDevice8_GetCapabilities(p,a) (p)->lpVtbl->GetCapabilities(p,a) +#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->lpVtbl->EnumObjects(p,a,b,c) +#define IDirectInputDevice8_GetProperty(p,a,b) (p)->lpVtbl->GetProperty(p,a,b) +#define IDirectInputDevice8_SetProperty(p,a,b) (p)->lpVtbl->SetProperty(p,a,b) +#define IDirectInputDevice8_Acquire(p) (p)->lpVtbl->Acquire(p) +#define IDirectInputDevice8_Unacquire(p) (p)->lpVtbl->Unacquire(p) +#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->lpVtbl->GetDeviceState(p,a,b) +#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->lpVtbl->GetDeviceData(p,a,b,c,d) +#define IDirectInputDevice8_SetDataFormat(p,a) (p)->lpVtbl->SetDataFormat(p,a) +#define IDirectInputDevice8_SetEventNotification(p,a) (p)->lpVtbl->SetEventNotification(p,a) +#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->lpVtbl->GetObjectInfo(p,a,b,c) +#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->lpVtbl->GetDeviceInfo(p,a) +#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->lpVtbl->Initialize(p,a,b,c) +#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->lpVtbl->CreateEffect(p,a,b,c,d) +#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->lpVtbl->EnumEffects(p,a,b,c) +#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->lpVtbl->GetEffectInfo(p,a,b) +#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->lpVtbl->GetForceFeedbackState(p,a) +#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->lpVtbl->SendForceFeedbackCommand(p,a) +#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c) +#define IDirectInputDevice8_Escape(p,a) (p)->lpVtbl->Escape(p,a) +#define IDirectInputDevice8_Poll(p) (p)->lpVtbl->Poll(p) +#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->lpVtbl->SendDeviceData(p,a,b,c,d) +#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d) +#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d) +#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->lpVtbl->BuildActionMap(p,a,b,c) +#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->lpVtbl->SetActionMap(p,a,b,c) +#define IDirectInputDevice8_GetImageInfo(p,a) (p)->lpVtbl->GetImageInfo(p,a) +#else +#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInputDevice8_AddRef(p) (p)->AddRef() +#define IDirectInputDevice8_Release(p) (p)->Release() +#define IDirectInputDevice8_GetCapabilities(p,a) (p)->GetCapabilities(a) +#define IDirectInputDevice8_EnumObjects(p,a,b,c) (p)->EnumObjects(a,b,c) +#define IDirectInputDevice8_GetProperty(p,a,b) (p)->GetProperty(a,b) +#define IDirectInputDevice8_SetProperty(p,a,b) (p)->SetProperty(a,b) +#define IDirectInputDevice8_Acquire(p) (p)->Acquire() +#define IDirectInputDevice8_Unacquire(p) (p)->Unacquire() +#define IDirectInputDevice8_GetDeviceState(p,a,b) (p)->GetDeviceState(a,b) +#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d) (p)->GetDeviceData(a,b,c,d) +#define IDirectInputDevice8_SetDataFormat(p,a) (p)->SetDataFormat(a) +#define IDirectInputDevice8_SetEventNotification(p,a) (p)->SetEventNotification(a) +#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectInputDevice8_GetObjectInfo(p,a,b,c) (p)->GetObjectInfo(a,b,c) +#define IDirectInputDevice8_GetDeviceInfo(p,a) (p)->GetDeviceInfo(a) +#define IDirectInputDevice8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInputDevice8_Initialize(p,a,b,c) (p)->Initialize(a,b,c) +#define IDirectInputDevice8_CreateEffect(p,a,b,c,d) (p)->CreateEffect(a,b,c,d) +#define IDirectInputDevice8_EnumEffects(p,a,b,c) (p)->EnumEffects(a,b,c) +#define IDirectInputDevice8_GetEffectInfo(p,a,b) (p)->GetEffectInfo(a,b) +#define IDirectInputDevice8_GetForceFeedbackState(p,a) (p)->GetForceFeedbackState(a) +#define IDirectInputDevice8_SendForceFeedbackCommand(p,a) (p)->SendForceFeedbackCommand(a) +#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c) +#define IDirectInputDevice8_Escape(p,a) (p)->Escape(a) +#define IDirectInputDevice8_Poll(p) (p)->Poll() +#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d) (p)->SendDeviceData(a,b,c,d) +#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d) +#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d) +#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->BuildActionMap(a,b,c) +#define IDirectInputDevice8_SetActionMap(p,a,b,c) (p)->SetActionMap(a,b,c) +#define IDirectInputDevice8_GetImageInfo(p,a) (p)->GetImageInfo(a) +#endif + +#endif /* DIJ_RINGZERO */ + +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +/**************************************************************************** + * + * Mouse + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +typedef struct _DIMOUSESTATE { + LONG lX; + LONG lY; + LONG lZ; + BYTE rgbButtons[4]; +} DIMOUSESTATE, *LPDIMOUSESTATE; + +#if DIRECTINPUT_VERSION >= 0x0700 +typedef struct _DIMOUSESTATE2 { + LONG lX; + LONG lY; + LONG lZ; + BYTE rgbButtons[8]; +} DIMOUSESTATE2, *LPDIMOUSESTATE2; +#endif + + +#define DIMOFS_X FIELD_OFFSET(DIMOUSESTATE, lX) +#define DIMOFS_Y FIELD_OFFSET(DIMOUSESTATE, lY) +#define DIMOFS_Z FIELD_OFFSET(DIMOUSESTATE, lZ) +#define DIMOFS_BUTTON0 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 0) +#define DIMOFS_BUTTON1 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 1) +#define DIMOFS_BUTTON2 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 2) +#define DIMOFS_BUTTON3 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 3) +#if (DIRECTINPUT_VERSION >= 0x0700) +#define DIMOFS_BUTTON4 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 4) +#define DIMOFS_BUTTON5 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 5) +#define DIMOFS_BUTTON6 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 6) +#define DIMOFS_BUTTON7 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 7) +#endif +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * Keyboard + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +/**************************************************************************** + * + * DirectInput keyboard scan codes + * + ****************************************************************************/ +#define DIK_ESCAPE 0x01 +#define DIK_1 0x02 +#define DIK_2 0x03 +#define DIK_3 0x04 +#define DIK_4 0x05 +#define DIK_5 0x06 +#define DIK_6 0x07 +#define DIK_7 0x08 +#define DIK_8 0x09 +#define DIK_9 0x0A +#define DIK_0 0x0B +#define DIK_MINUS 0x0C /* - on main keyboard */ +#define DIK_EQUALS 0x0D +#define DIK_BACK 0x0E /* backspace */ +#define DIK_TAB 0x0F +#define DIK_Q 0x10 +#define DIK_W 0x11 +#define DIK_E 0x12 +#define DIK_R 0x13 +#define DIK_T 0x14 +#define DIK_Y 0x15 +#define DIK_U 0x16 +#define DIK_I 0x17 +#define DIK_O 0x18 +#define DIK_P 0x19 +#define DIK_LBRACKET 0x1A +#define DIK_RBRACKET 0x1B +#define DIK_RETURN 0x1C /* Enter on main keyboard */ +#define DIK_LCONTROL 0x1D +#define DIK_A 0x1E +#define DIK_S 0x1F +#define DIK_D 0x20 +#define DIK_F 0x21 +#define DIK_G 0x22 +#define DIK_H 0x23 +#define DIK_J 0x24 +#define DIK_K 0x25 +#define DIK_L 0x26 +#define DIK_SEMICOLON 0x27 +#define DIK_APOSTROPHE 0x28 +#define DIK_GRAVE 0x29 /* accent grave */ +#define DIK_LSHIFT 0x2A +#define DIK_BACKSLASH 0x2B +#define DIK_Z 0x2C +#define DIK_X 0x2D +#define DIK_C 0x2E +#define DIK_V 0x2F +#define DIK_B 0x30 +#define DIK_N 0x31 +#define DIK_M 0x32 +#define DIK_COMMA 0x33 +#define DIK_PERIOD 0x34 /* . on main keyboard */ +#define DIK_SLASH 0x35 /* / on main keyboard */ +#define DIK_RSHIFT 0x36 +#define DIK_MULTIPLY 0x37 /* * on numeric keypad */ +#define DIK_LMENU 0x38 /* left Alt */ +#define DIK_SPACE 0x39 +#define DIK_CAPITAL 0x3A +#define DIK_F1 0x3B +#define DIK_F2 0x3C +#define DIK_F3 0x3D +#define DIK_F4 0x3E +#define DIK_F5 0x3F +#define DIK_F6 0x40 +#define DIK_F7 0x41 +#define DIK_F8 0x42 +#define DIK_F9 0x43 +#define DIK_F10 0x44 +#define DIK_NUMLOCK 0x45 +#define DIK_SCROLL 0x46 /* Scroll Lock */ +#define DIK_NUMPAD7 0x47 +#define DIK_NUMPAD8 0x48 +#define DIK_NUMPAD9 0x49 +#define DIK_SUBTRACT 0x4A /* - on numeric keypad */ +#define DIK_NUMPAD4 0x4B +#define DIK_NUMPAD5 0x4C +#define DIK_NUMPAD6 0x4D +#define DIK_ADD 0x4E /* + on numeric keypad */ +#define DIK_NUMPAD1 0x4F +#define DIK_NUMPAD2 0x50 +#define DIK_NUMPAD3 0x51 +#define DIK_NUMPAD0 0x52 +#define DIK_DECIMAL 0x53 /* . on numeric keypad */ +#define DIK_OEM_102 0x56 /* <> or \| on RT 102-key keyboard (Non-U.S.) */ +#define DIK_F11 0x57 +#define DIK_F12 0x58 +#define DIK_F13 0x64 /* (NEC PC98) */ +#define DIK_F14 0x65 /* (NEC PC98) */ +#define DIK_F15 0x66 /* (NEC PC98) */ +#define DIK_KANA 0x70 /* (Japanese keyboard) */ +#define DIK_ABNT_C1 0x73 /* /? on Brazilian keyboard */ +#define DIK_CONVERT 0x79 /* (Japanese keyboard) */ +#define DIK_NOCONVERT 0x7B /* (Japanese keyboard) */ +#define DIK_YEN 0x7D /* (Japanese keyboard) */ +#define DIK_ABNT_C2 0x7E /* Numpad . on Brazilian keyboard */ +#define DIK_NUMPADEQUALS 0x8D /* = on numeric keypad (NEC PC98) */ +#define DIK_PREVTRACK 0x90 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ +#define DIK_AT 0x91 /* (NEC PC98) */ +#define DIK_COLON 0x92 /* (NEC PC98) */ +#define DIK_UNDERLINE 0x93 /* (NEC PC98) */ +#define DIK_KANJI 0x94 /* (Japanese keyboard) */ +#define DIK_STOP 0x95 /* (NEC PC98) */ +#define DIK_AX 0x96 /* (Japan AX) */ +#define DIK_UNLABELED 0x97 /* (J3100) */ +#define DIK_NEXTTRACK 0x99 /* Next Track */ +#define DIK_NUMPADENTER 0x9C /* Enter on numeric keypad */ +#define DIK_RCONTROL 0x9D +#define DIK_MUTE 0xA0 /* Mute */ +#define DIK_CALCULATOR 0xA1 /* Calculator */ +#define DIK_PLAYPAUSE 0xA2 /* Play / Pause */ +#define DIK_MEDIASTOP 0xA4 /* Media Stop */ +#define DIK_VOLUMEDOWN 0xAE /* Volume - */ +#define DIK_VOLUMEUP 0xB0 /* Volume + */ +#define DIK_WEBHOME 0xB2 /* Web home */ +#define DIK_NUMPADCOMMA 0xB3 /* , on numeric keypad (NEC PC98) */ +#define DIK_DIVIDE 0xB5 /* / on numeric keypad */ +#define DIK_SYSRQ 0xB7 +#define DIK_RMENU 0xB8 /* right Alt */ +#define DIK_PAUSE 0xC5 /* Pause */ +#define DIK_HOME 0xC7 /* Home on arrow keypad */ +#define DIK_UP 0xC8 /* UpArrow on arrow keypad */ +#define DIK_PRIOR 0xC9 /* PgUp on arrow keypad */ +#define DIK_LEFT 0xCB /* LeftArrow on arrow keypad */ +#define DIK_RIGHT 0xCD /* RightArrow on arrow keypad */ +#define DIK_END 0xCF /* End on arrow keypad */ +#define DIK_DOWN 0xD0 /* DownArrow on arrow keypad */ +#define DIK_NEXT 0xD1 /* PgDn on arrow keypad */ +#define DIK_INSERT 0xD2 /* Insert on arrow keypad */ +#define DIK_DELETE 0xD3 /* Delete on arrow keypad */ +#define DIK_LWIN 0xDB /* Left Windows key */ +#define DIK_RWIN 0xDC /* Right Windows key */ +#define DIK_APPS 0xDD /* AppMenu key */ +#define DIK_POWER 0xDE /* System Power */ +#define DIK_SLEEP 0xDF /* System Sleep */ +#define DIK_WAKE 0xE3 /* System Wake */ +#define DIK_WEBSEARCH 0xE5 /* Web Search */ +#define DIK_WEBFAVORITES 0xE6 /* Web Favorites */ +#define DIK_WEBREFRESH 0xE7 /* Web Refresh */ +#define DIK_WEBSTOP 0xE8 /* Web Stop */ +#define DIK_WEBFORWARD 0xE9 /* Web Forward */ +#define DIK_WEBBACK 0xEA /* Web Back */ +#define DIK_MYCOMPUTER 0xEB /* My Computer */ +#define DIK_MAIL 0xEC /* Mail */ +#define DIK_MEDIASELECT 0xED /* Media Select */ + +/* + * Alternate names for keys, to facilitate transition from DOS. + */ +#define DIK_BACKSPACE DIK_BACK /* backspace */ +#define DIK_NUMPADSTAR DIK_MULTIPLY /* * on numeric keypad */ +#define DIK_LALT DIK_LMENU /* left Alt */ +#define DIK_CAPSLOCK DIK_CAPITAL /* CapsLock */ +#define DIK_NUMPADMINUS DIK_SUBTRACT /* - on numeric keypad */ +#define DIK_NUMPADPLUS DIK_ADD /* + on numeric keypad */ +#define DIK_NUMPADPERIOD DIK_DECIMAL /* . on numeric keypad */ +#define DIK_NUMPADSLASH DIK_DIVIDE /* / on numeric keypad */ +#define DIK_RALT DIK_RMENU /* right Alt */ +#define DIK_UPARROW DIK_UP /* UpArrow on arrow keypad */ +#define DIK_PGUP DIK_PRIOR /* PgUp on arrow keypad */ +#define DIK_LEFTARROW DIK_LEFT /* LeftArrow on arrow keypad */ +#define DIK_RIGHTARROW DIK_RIGHT /* RightArrow on arrow keypad */ +#define DIK_DOWNARROW DIK_DOWN /* DownArrow on arrow keypad */ +#define DIK_PGDN DIK_NEXT /* PgDn on arrow keypad */ + +/* + * Alternate names for keys originally not used on US keyboards. + */ +#define DIK_CIRCUMFLEX DIK_PREVTRACK /* Japanese keyboard */ + +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * Joystick + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +typedef struct DIJOYSTATE { + LONG lX; /* x-axis position */ + LONG lY; /* y-axis position */ + LONG lZ; /* z-axis position */ + LONG lRx; /* x-axis rotation */ + LONG lRy; /* y-axis rotation */ + LONG lRz; /* z-axis rotation */ + LONG rglSlider[2]; /* extra axes positions */ + DWORD rgdwPOV[4]; /* POV directions */ + BYTE rgbButtons[32]; /* 32 buttons */ +} DIJOYSTATE, *LPDIJOYSTATE; + +typedef struct DIJOYSTATE2 { + LONG lX; /* x-axis position */ + LONG lY; /* y-axis position */ + LONG lZ; /* z-axis position */ + LONG lRx; /* x-axis rotation */ + LONG lRy; /* y-axis rotation */ + LONG lRz; /* z-axis rotation */ + LONG rglSlider[2]; /* extra axes positions */ + DWORD rgdwPOV[4]; /* POV directions */ + BYTE rgbButtons[128]; /* 128 buttons */ + LONG lVX; /* x-axis velocity */ + LONG lVY; /* y-axis velocity */ + LONG lVZ; /* z-axis velocity */ + LONG lVRx; /* x-axis angular velocity */ + LONG lVRy; /* y-axis angular velocity */ + LONG lVRz; /* z-axis angular velocity */ + LONG rglVSlider[2]; /* extra axes velocities */ + LONG lAX; /* x-axis acceleration */ + LONG lAY; /* y-axis acceleration */ + LONG lAZ; /* z-axis acceleration */ + LONG lARx; /* x-axis angular acceleration */ + LONG lARy; /* y-axis angular acceleration */ + LONG lARz; /* z-axis angular acceleration */ + LONG rglASlider[2]; /* extra axes accelerations */ + LONG lFX; /* x-axis force */ + LONG lFY; /* y-axis force */ + LONG lFZ; /* z-axis force */ + LONG lFRx; /* x-axis torque */ + LONG lFRy; /* y-axis torque */ + LONG lFRz; /* z-axis torque */ + LONG rglFSlider[2]; /* extra axes forces */ +} DIJOYSTATE2, *LPDIJOYSTATE2; + +#define DIJOFS_X FIELD_OFFSET(DIJOYSTATE, lX) +#define DIJOFS_Y FIELD_OFFSET(DIJOYSTATE, lY) +#define DIJOFS_Z FIELD_OFFSET(DIJOYSTATE, lZ) +#define DIJOFS_RX FIELD_OFFSET(DIJOYSTATE, lRx) +#define DIJOFS_RY FIELD_OFFSET(DIJOYSTATE, lRy) +#define DIJOFS_RZ FIELD_OFFSET(DIJOYSTATE, lRz) +#define DIJOFS_SLIDER(n) (FIELD_OFFSET(DIJOYSTATE, rglSlider) + \ + (n) * sizeof(LONG)) +#define DIJOFS_POV(n) (FIELD_OFFSET(DIJOYSTATE, rgdwPOV) + \ + (n) * sizeof(DWORD)) +#define DIJOFS_BUTTON(n) (FIELD_OFFSET(DIJOYSTATE, rgbButtons) + (n)) +#define DIJOFS_BUTTON0 DIJOFS_BUTTON(0) +#define DIJOFS_BUTTON1 DIJOFS_BUTTON(1) +#define DIJOFS_BUTTON2 DIJOFS_BUTTON(2) +#define DIJOFS_BUTTON3 DIJOFS_BUTTON(3) +#define DIJOFS_BUTTON4 DIJOFS_BUTTON(4) +#define DIJOFS_BUTTON5 DIJOFS_BUTTON(5) +#define DIJOFS_BUTTON6 DIJOFS_BUTTON(6) +#define DIJOFS_BUTTON7 DIJOFS_BUTTON(7) +#define DIJOFS_BUTTON8 DIJOFS_BUTTON(8) +#define DIJOFS_BUTTON9 DIJOFS_BUTTON(9) +#define DIJOFS_BUTTON10 DIJOFS_BUTTON(10) +#define DIJOFS_BUTTON11 DIJOFS_BUTTON(11) +#define DIJOFS_BUTTON12 DIJOFS_BUTTON(12) +#define DIJOFS_BUTTON13 DIJOFS_BUTTON(13) +#define DIJOFS_BUTTON14 DIJOFS_BUTTON(14) +#define DIJOFS_BUTTON15 DIJOFS_BUTTON(15) +#define DIJOFS_BUTTON16 DIJOFS_BUTTON(16) +#define DIJOFS_BUTTON17 DIJOFS_BUTTON(17) +#define DIJOFS_BUTTON18 DIJOFS_BUTTON(18) +#define DIJOFS_BUTTON19 DIJOFS_BUTTON(19) +#define DIJOFS_BUTTON20 DIJOFS_BUTTON(20) +#define DIJOFS_BUTTON21 DIJOFS_BUTTON(21) +#define DIJOFS_BUTTON22 DIJOFS_BUTTON(22) +#define DIJOFS_BUTTON23 DIJOFS_BUTTON(23) +#define DIJOFS_BUTTON24 DIJOFS_BUTTON(24) +#define DIJOFS_BUTTON25 DIJOFS_BUTTON(25) +#define DIJOFS_BUTTON26 DIJOFS_BUTTON(26) +#define DIJOFS_BUTTON27 DIJOFS_BUTTON(27) +#define DIJOFS_BUTTON28 DIJOFS_BUTTON(28) +#define DIJOFS_BUTTON29 DIJOFS_BUTTON(29) +#define DIJOFS_BUTTON30 DIJOFS_BUTTON(30) +#define DIJOFS_BUTTON31 DIJOFS_BUTTON(31) + + +#endif /* DIJ_RINGZERO */ + +/**************************************************************************** + * + * IDirectInput + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +#define DIENUM_STOP 0 +#define DIENUM_CONTINUE 1 + +typedef BOOL (FAR PASCAL * LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA, LPVOID); +typedef BOOL (FAR PASCAL * LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW, LPVOID); +#ifdef UNICODE +#define LPDIENUMDEVICESCALLBACK LPDIENUMDEVICESCALLBACKW +#else +#define LPDIENUMDEVICESCALLBACK LPDIENUMDEVICESCALLBACKA +#endif // !UNICODE +typedef BOOL (FAR PASCAL * LPDICONFIGUREDEVICESCALLBACK)(IUnknown FAR *, LPVOID); + +#define DIEDFL_ALLDEVICES 0x00000000 +#define DIEDFL_ATTACHEDONLY 0x00000001 +#if(DIRECTINPUT_VERSION >= 0x0500) +#define DIEDFL_FORCEFEEDBACK 0x00000100 +#endif /* DIRECTINPUT_VERSION >= 0x0500 */ +#if(DIRECTINPUT_VERSION >= 0x050a) +#define DIEDFL_INCLUDEALIASES 0x00010000 +#define DIEDFL_INCLUDEPHANTOMS 0x00020000 +#endif /* DIRECTINPUT_VERSION >= 0x050a */ +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIEDFL_INCLUDEHIDDEN 0x00040000 +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + + +#if(DIRECTINPUT_VERSION >= 0x0800) +typedef BOOL (FAR PASCAL * LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA, LPDIRECTINPUTDEVICE8A, DWORD, DWORD, LPVOID); +typedef BOOL (FAR PASCAL * LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW, LPDIRECTINPUTDEVICE8W, DWORD, DWORD, LPVOID); +#ifdef UNICODE +#define LPDIENUMDEVICESBYSEMANTICSCB LPDIENUMDEVICESBYSEMANTICSCBW +#else +#define LPDIENUMDEVICESBYSEMANTICSCB LPDIENUMDEVICESBYSEMANTICSCBA +#endif // !UNICODE +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIEDBS_MAPPEDPRI1 0x00000001 +#define DIEDBS_MAPPEDPRI2 0x00000002 +#define DIEDBS_RECENTDEVICE 0x00000010 +#define DIEDBS_NEWDEVICE 0x00000020 +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#if(DIRECTINPUT_VERSION >= 0x0800) +#define DIEDBSFL_ATTACHEDONLY 0x00000000 +#define DIEDBSFL_THISUSER 0x00000010 +#define DIEDBSFL_FORCEFEEDBACK DIEDFL_FORCEFEEDBACK +#define DIEDBSFL_AVAILABLEDEVICES 0x00001000 +#define DIEDBSFL_MULTIMICEKEYBOARDS 0x00002000 +#define DIEDBSFL_NONGAMINGDEVICES 0x00004000 +#define DIEDBSFL_VALID 0x00007110 +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#undef INTERFACE +#define INTERFACE IDirectInputW + +DECLARE_INTERFACE_(IDirectInputW, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputW methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; +}; + +typedef struct IDirectInputW *LPDIRECTINPUTW; + +#undef INTERFACE +#define INTERFACE IDirectInputA + +DECLARE_INTERFACE_(IDirectInputA, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputA methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; +}; + +typedef struct IDirectInputA *LPDIRECTINPUTA; + +#ifdef UNICODE +#define IID_IDirectInput IID_IDirectInputW +#define IDirectInput IDirectInputW +#define IDirectInputVtbl IDirectInputWVtbl +#else +#define IID_IDirectInput IID_IDirectInputA +#define IDirectInput IDirectInputA +#define IDirectInputVtbl IDirectInputAVtbl +#endif +typedef struct IDirectInput *LPDIRECTINPUT; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInput_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInput_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInput_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInput_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectInput_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) +#define IDirectInput_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInput_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#else +#define IDirectInput_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInput_AddRef(p) (p)->AddRef() +#define IDirectInput_Release(p) (p)->Release() +#define IDirectInput_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectInput_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) +#define IDirectInput_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInput_Initialize(p,a,b) (p)->Initialize(a,b) +#endif + +#undef INTERFACE +#define INTERFACE IDirectInput2W + +DECLARE_INTERFACE_(IDirectInput2W, IDirectInputW) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputW methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + + /*** IDirectInput2W methods ***/ + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; +}; + +typedef struct IDirectInput2W *LPDIRECTINPUT2W; + +#undef INTERFACE +#define INTERFACE IDirectInput2A + +DECLARE_INTERFACE_(IDirectInput2A, IDirectInputA) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInputA methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + + /*** IDirectInput2A methods ***/ + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; +}; + +typedef struct IDirectInput2A *LPDIRECTINPUT2A; + +#ifdef UNICODE +#define IID_IDirectInput2 IID_IDirectInput2W +#define IDirectInput2 IDirectInput2W +#define IDirectInput2Vtbl IDirectInput2WVtbl +#else +#define IID_IDirectInput2 IID_IDirectInput2A +#define IDirectInput2 IDirectInput2A +#define IDirectInput2Vtbl IDirectInput2AVtbl +#endif +typedef struct IDirectInput2 *LPDIRECTINPUT2; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInput2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInput2_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInput2_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInput2_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectInput2_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) +#define IDirectInput2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInput2_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectInput2_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) +#else +#define IDirectInput2_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInput2_AddRef(p) (p)->AddRef() +#define IDirectInput2_Release(p) (p)->Release() +#define IDirectInput2_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectInput2_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) +#define IDirectInput2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInput2_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectInput2_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) +#endif + + +#undef INTERFACE +#define INTERFACE IDirectInput7W + +DECLARE_INTERFACE_(IDirectInput7W, IDirectInput2W) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInput2W methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEW *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; + + /*** IDirectInput7W methods ***/ + STDMETHOD(CreateDeviceEx)(THIS_ REFGUID,REFIID,LPVOID *,LPUNKNOWN) PURE; +}; + +typedef struct IDirectInput7W *LPDIRECTINPUT7W; + +#undef INTERFACE +#define INTERFACE IDirectInput7A + +DECLARE_INTERFACE_(IDirectInput7A, IDirectInput2A) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInput2A methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICEA *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; + + /*** IDirectInput7A methods ***/ + STDMETHOD(CreateDeviceEx)(THIS_ REFGUID,REFIID,LPVOID *,LPUNKNOWN) PURE; +}; + +typedef struct IDirectInput7A *LPDIRECTINPUT7A; + +#ifdef UNICODE +#define IID_IDirectInput7 IID_IDirectInput7W +#define IDirectInput7 IDirectInput7W +#define IDirectInput7Vtbl IDirectInput7WVtbl +#else +#define IID_IDirectInput7 IID_IDirectInput7A +#define IDirectInput7 IDirectInput7A +#define IDirectInput7Vtbl IDirectInput7AVtbl +#endif +typedef struct IDirectInput7 *LPDIRECTINPUT7; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInput7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInput7_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInput7_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInput7_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectInput7_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) +#define IDirectInput7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInput7_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectInput7_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) +#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d) +#else +#define IDirectInput7_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInput7_AddRef(p) (p)->AddRef() +#define IDirectInput7_Release(p) (p)->Release() +#define IDirectInput7_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectInput7_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) +#define IDirectInput7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInput7_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectInput7_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) +#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->CreateDeviceEx(a,b,c,d) +#endif + +#if(DIRECTINPUT_VERSION >= 0x0800) +#undef INTERFACE +#define INTERFACE IDirectInput8W + +DECLARE_INTERFACE_(IDirectInput8W, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInput8W methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICE8W *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKW,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCWSTR,LPGUID) PURE; + STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR,LPDIACTIONFORMATW,LPDIENUMDEVICESBYSEMANTICSCBW,LPVOID,DWORD) PURE; + STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK,LPDICONFIGUREDEVICESPARAMSW,DWORD,LPVOID) PURE; +}; + +typedef struct IDirectInput8W *LPDIRECTINPUT8W; + +#undef INTERFACE +#define INTERFACE IDirectInput8A + +DECLARE_INTERFACE_(IDirectInput8A, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirectInput8A methods ***/ + STDMETHOD(CreateDevice)(THIS_ REFGUID,LPDIRECTINPUTDEVICE8A *,LPUNKNOWN) PURE; + STDMETHOD(EnumDevices)(THIS_ DWORD,LPDIENUMDEVICESCALLBACKA,LPVOID,DWORD) PURE; + STDMETHOD(GetDeviceStatus)(THIS_ REFGUID) PURE; + STDMETHOD(RunControlPanel)(THIS_ HWND,DWORD) PURE; + STDMETHOD(Initialize)(THIS_ HINSTANCE,DWORD) PURE; + STDMETHOD(FindDevice)(THIS_ REFGUID,LPCSTR,LPGUID) PURE; + STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCSTR,LPDIACTIONFORMATA,LPDIENUMDEVICESBYSEMANTICSCBA,LPVOID,DWORD) PURE; + STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK,LPDICONFIGUREDEVICESPARAMSA,DWORD,LPVOID) PURE; +}; + +typedef struct IDirectInput8A *LPDIRECTINPUT8A; + +#ifdef UNICODE +#define IID_IDirectInput8 IID_IDirectInput8W +#define IDirectInput8 IDirectInput8W +#define IDirectInput8Vtbl IDirectInput8WVtbl +#else +#define IID_IDirectInput8 IID_IDirectInput8A +#define IDirectInput8 IDirectInput8A +#define IDirectInput8Vtbl IDirectInput8AVtbl +#endif +typedef struct IDirectInput8 *LPDIRECTINPUT8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectInput8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirectInput8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirectInput8_Release(p) (p)->lpVtbl->Release(p) +#define IDirectInput8_CreateDevice(p,a,b,c) (p)->lpVtbl->CreateDevice(p,a,b,c) +#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d) +#define IDirectInput8_GetDeviceStatus(p,a) (p)->lpVtbl->GetDeviceStatus(p,a) +#define IDirectInput8_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b) +#define IDirectInput8_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectInput8_FindDevice(p,a,b,c) (p)->lpVtbl->FindDevice(p,a,b,c) +#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e) +#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d) +#else +#define IDirectInput8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirectInput8_AddRef(p) (p)->AddRef() +#define IDirectInput8_Release(p) (p)->Release() +#define IDirectInput8_CreateDevice(p,a,b,c) (p)->CreateDevice(a,b,c) +#define IDirectInput8_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d) +#define IDirectInput8_GetDeviceStatus(p,a) (p)->GetDeviceStatus(a) +#define IDirectInput8_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b) +#define IDirectInput8_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectInput8_FindDevice(p,a,b,c) (p)->FindDevice(a,b,c) +#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->EnumDevicesBySemantics(a,b,c,d,e) +#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->ConfigureDevices(a,b,c,d) +#endif +#endif /* DIRECTINPUT_VERSION >= 0x0800 */ + +#if DIRECTINPUT_VERSION > 0x0700 + +extern HRESULT WINAPI DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); + +#else +extern HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter); +extern HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter); +#ifdef UNICODE +#define DirectInputCreate DirectInputCreateW +#else +#define DirectInputCreate DirectInputCreateA +#endif // !UNICODE + +extern HRESULT WINAPI DirectInputCreateEx(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter); + +#endif /* DIRECTINPUT_VERSION > 0x700 */ + +#endif /* DIJ_RINGZERO */ + + +/**************************************************************************** + * + * Return Codes + * + ****************************************************************************/ + +/* + * The operation completed successfully. + */ +#define DI_OK S_OK + +/* + * The device exists but is not currently attached. + */ +#define DI_NOTATTACHED S_FALSE + +/* + * The device buffer overflowed. Some input was lost. + */ +#define DI_BUFFEROVERFLOW S_FALSE + +/* + * The change in device properties had no effect. + */ +#define DI_PROPNOEFFECT S_FALSE + +/* + * The operation had no effect. + */ +#define DI_NOEFFECT S_FALSE + +/* + * The device is a polled device. As a result, device buffering + * will not collect any data and event notifications will not be + * signalled until GetDeviceState is called. + */ +#define DI_POLLEDDEVICE ((HRESULT)0x00000002L) + +/* + * The parameters of the effect were successfully updated by + * IDirectInputEffect::SetParameters, but the effect was not + * downloaded because the device is not exclusively acquired + * or because the DIEP_NODOWNLOAD flag was passed. + */ +#define DI_DOWNLOADSKIPPED ((HRESULT)0x00000003L) + +/* + * The parameters of the effect were successfully updated by + * IDirectInputEffect::SetParameters, but in order to change + * the parameters, the effect needed to be restarted. + */ +#define DI_EFFECTRESTARTED ((HRESULT)0x00000004L) + +/* + * The parameters of the effect were successfully updated by + * IDirectInputEffect::SetParameters, but some of them were + * beyond the capabilities of the device and were truncated. + */ +#define DI_TRUNCATED ((HRESULT)0x00000008L) + +/* + * The settings have been successfully applied but could not be + * persisted. + */ +#define DI_SETTINGSNOTSAVED ((HRESULT)0x0000000BL) + +/* + * Equal to DI_EFFECTRESTARTED | DI_TRUNCATED. + */ +#define DI_TRUNCATEDANDRESTARTED ((HRESULT)0x0000000CL) + +/* + * A SUCCESS code indicating that settings cannot be modified. + */ +#define DI_WRITEPROTECT ((HRESULT)0x00000013L) + +/* + * The application requires a newer version of DirectInput. + */ +#define DIERR_OLDDIRECTINPUTVERSION \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION) + +/* + * The application was written for an unsupported prerelease version + * of DirectInput. + */ +#define DIERR_BETADIRECTINPUTVERSION \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_RMODE_APP) + +/* + * The object could not be created due to an incompatible driver version + * or mismatched or incomplete driver components. + */ +#define DIERR_BADDRIVERVER \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BAD_DRIVER_LEVEL) + +/* + * The device or device instance or effect is not registered with DirectInput. + */ +#define DIERR_DEVICENOTREG REGDB_E_CLASSNOTREG + +/* + * The requested object does not exist. + */ +#define DIERR_NOTFOUND \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) + +/* + * The requested object does not exist. + */ +#define DIERR_OBJECTNOTFOUND \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND) + +/* + * An invalid parameter was passed to the returning function, + * or the object was not in a state that admitted the function + * to be called. + */ +#define DIERR_INVALIDPARAM E_INVALIDARG + +/* + * The specified interface is not supported by the object + */ +#define DIERR_NOINTERFACE E_NOINTERFACE + +/* + * An undetermined error occured inside the DInput subsystem + */ +#define DIERR_GENERIC E_FAIL + +/* + * The DInput subsystem couldn't allocate sufficient memory to complete the + * caller's request. + */ +#define DIERR_OUTOFMEMORY E_OUTOFMEMORY + +/* + * The function called is not supported at this time + */ +#define DIERR_UNSUPPORTED E_NOTIMPL + +/* + * This object has not been initialized + */ +#define DIERR_NOTINITIALIZED \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_READY) + +/* + * This object is already initialized + */ +#define DIERR_ALREADYINITIALIZED \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_INITIALIZED) + +/* + * This object does not support aggregation + */ +#define DIERR_NOAGGREGATION CLASS_E_NOAGGREGATION + +/* + * Another app has a higher priority level, preventing this call from + * succeeding. + */ +#define DIERR_OTHERAPPHASPRIO E_ACCESSDENIED + +/* + * Access to the device has been lost. It must be re-acquired. + */ +#define DIERR_INPUTLOST \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT) + +/* + * The operation cannot be performed while the device is acquired. + */ +#define DIERR_ACQUIRED \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BUSY) + +/* + * The operation cannot be performed unless the device is acquired. + */ +#define DIERR_NOTACQUIRED \ + MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INVALID_ACCESS) + +/* + * The specified property cannot be changed. + */ +#define DIERR_READONLY E_ACCESSDENIED + +/* + * The device already has an event notification associated with it. + */ +#define DIERR_HANDLEEXISTS E_ACCESSDENIED + +/* + * Data is not yet available. + */ +#ifndef E_PENDING +#define E_PENDING 0x8000000AL +#endif + +/* + * Unable to IDirectInputJoyConfig_Acquire because the user + * does not have sufficient privileges to change the joystick + * configuration. + */ +#define DIERR_INSUFFICIENTPRIVS 0x80040200L + +/* + * The device is full. + */ +#define DIERR_DEVICEFULL 0x80040201L + +/* + * Not all the requested information fit into the buffer. + */ +#define DIERR_MOREDATA 0x80040202L + +/* + * The effect is not downloaded. + */ +#define DIERR_NOTDOWNLOADED 0x80040203L + +/* + * The device cannot be reinitialized because there are still effects + * attached to it. + */ +#define DIERR_HASEFFECTS 0x80040204L + +/* + * The operation cannot be performed unless the device is acquired + * in DISCL_EXCLUSIVE mode. + */ +#define DIERR_NOTEXCLUSIVEACQUIRED 0x80040205L + +/* + * The effect could not be downloaded because essential information + * is missing. For example, no axes have been associated with the + * effect, or no type-specific information has been created. + */ +#define DIERR_INCOMPLETEEFFECT 0x80040206L + +/* + * Attempted to read buffered device data from a device that is + * not buffered. + */ +#define DIERR_NOTBUFFERED 0x80040207L + +/* + * An attempt was made to modify parameters of an effect while it is + * playing. Not all hardware devices support altering the parameters + * of an effect while it is playing. + */ +#define DIERR_EFFECTPLAYING 0x80040208L + +/* + * The operation could not be completed because the device is not + * plugged in. + */ +#define DIERR_UNPLUGGED 0x80040209L + +/* + * SendDeviceData failed because more information was requested + * to be sent than can be sent to the device. Some devices have + * restrictions on how much data can be sent to them. (For example, + * there might be a limit on the number of buttons that can be + * pressed at once.) + */ +#define DIERR_REPORTFULL 0x8004020AL + + +/* + * A mapper file function failed because reading or writing the user or IHV + * settings file failed. + */ +#define DIERR_MAPFILEFAIL 0x8004020BL + + +/*--- DINPUT Mapper Definitions: New for Dx8 ---*/ + + +/*--- Keyboard + Physical Keyboard Device ---*/ + +#define DIKEYBOARD_ESCAPE 0x81000401 +#define DIKEYBOARD_1 0x81000402 +#define DIKEYBOARD_2 0x81000403 +#define DIKEYBOARD_3 0x81000404 +#define DIKEYBOARD_4 0x81000405 +#define DIKEYBOARD_5 0x81000406 +#define DIKEYBOARD_6 0x81000407 +#define DIKEYBOARD_7 0x81000408 +#define DIKEYBOARD_8 0x81000409 +#define DIKEYBOARD_9 0x8100040A +#define DIKEYBOARD_0 0x8100040B +#define DIKEYBOARD_MINUS 0x8100040C /* - on main keyboard */ +#define DIKEYBOARD_EQUALS 0x8100040D +#define DIKEYBOARD_BACK 0x8100040E /* backspace */ +#define DIKEYBOARD_TAB 0x8100040F +#define DIKEYBOARD_Q 0x81000410 +#define DIKEYBOARD_W 0x81000411 +#define DIKEYBOARD_E 0x81000412 +#define DIKEYBOARD_R 0x81000413 +#define DIKEYBOARD_T 0x81000414 +#define DIKEYBOARD_Y 0x81000415 +#define DIKEYBOARD_U 0x81000416 +#define DIKEYBOARD_I 0x81000417 +#define DIKEYBOARD_O 0x81000418 +#define DIKEYBOARD_P 0x81000419 +#define DIKEYBOARD_LBRACKET 0x8100041A +#define DIKEYBOARD_RBRACKET 0x8100041B +#define DIKEYBOARD_RETURN 0x8100041C /* Enter on main keyboard */ +#define DIKEYBOARD_LCONTROL 0x8100041D +#define DIKEYBOARD_A 0x8100041E +#define DIKEYBOARD_S 0x8100041F +#define DIKEYBOARD_D 0x81000420 +#define DIKEYBOARD_F 0x81000421 +#define DIKEYBOARD_G 0x81000422 +#define DIKEYBOARD_H 0x81000423 +#define DIKEYBOARD_J 0x81000424 +#define DIKEYBOARD_K 0x81000425 +#define DIKEYBOARD_L 0x81000426 +#define DIKEYBOARD_SEMICOLON 0x81000427 +#define DIKEYBOARD_APOSTROPHE 0x81000428 +#define DIKEYBOARD_GRAVE 0x81000429 /* accent grave */ +#define DIKEYBOARD_LSHIFT 0x8100042A +#define DIKEYBOARD_BACKSLASH 0x8100042B +#define DIKEYBOARD_Z 0x8100042C +#define DIKEYBOARD_X 0x8100042D +#define DIKEYBOARD_C 0x8100042E +#define DIKEYBOARD_V 0x8100042F +#define DIKEYBOARD_B 0x81000430 +#define DIKEYBOARD_N 0x81000431 +#define DIKEYBOARD_M 0x81000432 +#define DIKEYBOARD_COMMA 0x81000433 +#define DIKEYBOARD_PERIOD 0x81000434 /* . on main keyboard */ +#define DIKEYBOARD_SLASH 0x81000435 /* / on main keyboard */ +#define DIKEYBOARD_RSHIFT 0x81000436 +#define DIKEYBOARD_MULTIPLY 0x81000437 /* * on numeric keypad */ +#define DIKEYBOARD_LMENU 0x81000438 /* left Alt */ +#define DIKEYBOARD_SPACE 0x81000439 +#define DIKEYBOARD_CAPITAL 0x8100043A +#define DIKEYBOARD_F1 0x8100043B +#define DIKEYBOARD_F2 0x8100043C +#define DIKEYBOARD_F3 0x8100043D +#define DIKEYBOARD_F4 0x8100043E +#define DIKEYBOARD_F5 0x8100043F +#define DIKEYBOARD_F6 0x81000440 +#define DIKEYBOARD_F7 0x81000441 +#define DIKEYBOARD_F8 0x81000442 +#define DIKEYBOARD_F9 0x81000443 +#define DIKEYBOARD_F10 0x81000444 +#define DIKEYBOARD_NUMLOCK 0x81000445 +#define DIKEYBOARD_SCROLL 0x81000446 /* Scroll Lock */ +#define DIKEYBOARD_NUMPAD7 0x81000447 +#define DIKEYBOARD_NUMPAD8 0x81000448 +#define DIKEYBOARD_NUMPAD9 0x81000449 +#define DIKEYBOARD_SUBTRACT 0x8100044A /* - on numeric keypad */ +#define DIKEYBOARD_NUMPAD4 0x8100044B +#define DIKEYBOARD_NUMPAD5 0x8100044C +#define DIKEYBOARD_NUMPAD6 0x8100044D +#define DIKEYBOARD_ADD 0x8100044E /* + on numeric keypad */ +#define DIKEYBOARD_NUMPAD1 0x8100044F +#define DIKEYBOARD_NUMPAD2 0x81000450 +#define DIKEYBOARD_NUMPAD3 0x81000451 +#define DIKEYBOARD_NUMPAD0 0x81000452 +#define DIKEYBOARD_DECIMAL 0x81000453 /* . on numeric keypad */ +#define DIKEYBOARD_OEM_102 0x81000456 /* <> or \| on RT 102-key keyboard (Non-U.S.) */ +#define DIKEYBOARD_F11 0x81000457 +#define DIKEYBOARD_F12 0x81000458 +#define DIKEYBOARD_F13 0x81000464 /* (NEC PC98) */ +#define DIKEYBOARD_F14 0x81000465 /* (NEC PC98) */ +#define DIKEYBOARD_F15 0x81000466 /* (NEC PC98) */ +#define DIKEYBOARD_KANA 0x81000470 /* (Japanese keyboard) */ +#define DIKEYBOARD_ABNT_C1 0x81000473 /* /? on Brazilian keyboard */ +#define DIKEYBOARD_CONVERT 0x81000479 /* (Japanese keyboard) */ +#define DIKEYBOARD_NOCONVERT 0x8100047B /* (Japanese keyboard) */ +#define DIKEYBOARD_YEN 0x8100047D /* (Japanese keyboard) */ +#define DIKEYBOARD_ABNT_C2 0x8100047E /* Numpad . on Brazilian keyboard */ +#define DIKEYBOARD_NUMPADEQUALS 0x8100048D /* = on numeric keypad (NEC PC98) */ +#define DIKEYBOARD_PREVTRACK 0x81000490 /* Previous Track (DIK_CIRCUMFLEX on Japanese keyboard) */ +#define DIKEYBOARD_AT 0x81000491 /* (NEC PC98) */ +#define DIKEYBOARD_COLON 0x81000492 /* (NEC PC98) */ +#define DIKEYBOARD_UNDERLINE 0x81000493 /* (NEC PC98) */ +#define DIKEYBOARD_KANJI 0x81000494 /* (Japanese keyboard) */ +#define DIKEYBOARD_STOP 0x81000495 /* (NEC PC98) */ +#define DIKEYBOARD_AX 0x81000496 /* (Japan AX) */ +#define DIKEYBOARD_UNLABELED 0x81000497 /* (J3100) */ +#define DIKEYBOARD_NEXTTRACK 0x81000499 /* Next Track */ +#define DIKEYBOARD_NUMPADENTER 0x8100049C /* Enter on numeric keypad */ +#define DIKEYBOARD_RCONTROL 0x8100049D +#define DIKEYBOARD_MUTE 0x810004A0 /* Mute */ +#define DIKEYBOARD_CALCULATOR 0x810004A1 /* Calculator */ +#define DIKEYBOARD_PLAYPAUSE 0x810004A2 /* Play / Pause */ +#define DIKEYBOARD_MEDIASTOP 0x810004A4 /* Media Stop */ +#define DIKEYBOARD_VOLUMEDOWN 0x810004AE /* Volume - */ +#define DIKEYBOARD_VOLUMEUP 0x810004B0 /* Volume + */ +#define DIKEYBOARD_WEBHOME 0x810004B2 /* Web home */ +#define DIKEYBOARD_NUMPADCOMMA 0x810004B3 /* , on numeric keypad (NEC PC98) */ +#define DIKEYBOARD_DIVIDE 0x810004B5 /* / on numeric keypad */ +#define DIKEYBOARD_SYSRQ 0x810004B7 +#define DIKEYBOARD_RMENU 0x810004B8 /* right Alt */ +#define DIKEYBOARD_PAUSE 0x810004C5 /* Pause */ +#define DIKEYBOARD_HOME 0x810004C7 /* Home on arrow keypad */ +#define DIKEYBOARD_UP 0x810004C8 /* UpArrow on arrow keypad */ +#define DIKEYBOARD_PRIOR 0x810004C9 /* PgUp on arrow keypad */ +#define DIKEYBOARD_LEFT 0x810004CB /* LeftArrow on arrow keypad */ +#define DIKEYBOARD_RIGHT 0x810004CD /* RightArrow on arrow keypad */ +#define DIKEYBOARD_END 0x810004CF /* End on arrow keypad */ +#define DIKEYBOARD_DOWN 0x810004D0 /* DownArrow on arrow keypad */ +#define DIKEYBOARD_NEXT 0x810004D1 /* PgDn on arrow keypad */ +#define DIKEYBOARD_INSERT 0x810004D2 /* Insert on arrow keypad */ +#define DIKEYBOARD_DELETE 0x810004D3 /* Delete on arrow keypad */ +#define DIKEYBOARD_LWIN 0x810004DB /* Left Windows key */ +#define DIKEYBOARD_RWIN 0x810004DC /* Right Windows key */ +#define DIKEYBOARD_APPS 0x810004DD /* AppMenu key */ +#define DIKEYBOARD_POWER 0x810004DE /* System Power */ +#define DIKEYBOARD_SLEEP 0x810004DF /* System Sleep */ +#define DIKEYBOARD_WAKE 0x810004E3 /* System Wake */ +#define DIKEYBOARD_WEBSEARCH 0x810004E5 /* Web Search */ +#define DIKEYBOARD_WEBFAVORITES 0x810004E6 /* Web Favorites */ +#define DIKEYBOARD_WEBREFRESH 0x810004E7 /* Web Refresh */ +#define DIKEYBOARD_WEBSTOP 0x810004E8 /* Web Stop */ +#define DIKEYBOARD_WEBFORWARD 0x810004E9 /* Web Forward */ +#define DIKEYBOARD_WEBBACK 0x810004EA /* Web Back */ +#define DIKEYBOARD_MYCOMPUTER 0x810004EB /* My Computer */ +#define DIKEYBOARD_MAIL 0x810004EC /* Mail */ +#define DIKEYBOARD_MEDIASELECT 0x810004ED /* Media Select */ + + +/*--- MOUSE + Physical Mouse Device ---*/ + +#define DIMOUSE_XAXISAB (0x82000200 |DIMOFS_X ) /* X Axis-absolute: Some mice natively report absolute coordinates */ +#define DIMOUSE_YAXISAB (0x82000200 |DIMOFS_Y ) /* Y Axis-absolute: Some mice natively report absolute coordinates */ +#define DIMOUSE_XAXIS (0x82000300 |DIMOFS_X ) /* X Axis */ +#define DIMOUSE_YAXIS (0x82000300 |DIMOFS_Y ) /* Y Axis */ +#define DIMOUSE_WHEEL (0x82000300 |DIMOFS_Z ) /* Z Axis */ +#define DIMOUSE_BUTTON0 (0x82000400 |DIMOFS_BUTTON0) /* Button 0 */ +#define DIMOUSE_BUTTON1 (0x82000400 |DIMOFS_BUTTON1) /* Button 1 */ +#define DIMOUSE_BUTTON2 (0x82000400 |DIMOFS_BUTTON2) /* Button 2 */ +#define DIMOUSE_BUTTON3 (0x82000400 |DIMOFS_BUTTON3) /* Button 3 */ +#define DIMOUSE_BUTTON4 (0x82000400 |DIMOFS_BUTTON4) /* Button 4 */ +#define DIMOUSE_BUTTON5 (0x82000400 |DIMOFS_BUTTON5) /* Button 5 */ +#define DIMOUSE_BUTTON6 (0x82000400 |DIMOFS_BUTTON6) /* Button 6 */ +#define DIMOUSE_BUTTON7 (0x82000400 |DIMOFS_BUTTON7) /* Button 7 */ + + +/*--- VOICE + Physical Dplay Voice Device ---*/ + +#define DIVOICE_CHANNEL1 0x83000401 +#define DIVOICE_CHANNEL2 0x83000402 +#define DIVOICE_CHANNEL3 0x83000403 +#define DIVOICE_CHANNEL4 0x83000404 +#define DIVOICE_CHANNEL5 0x83000405 +#define DIVOICE_CHANNEL6 0x83000406 +#define DIVOICE_CHANNEL7 0x83000407 +#define DIVOICE_CHANNEL8 0x83000408 +#define DIVOICE_TEAM 0x83000409 +#define DIVOICE_ALL 0x8300040A +#define DIVOICE_RECORDMUTE 0x8300040B +#define DIVOICE_PLAYBACKMUTE 0x8300040C +#define DIVOICE_TRANSMIT 0x8300040D + +#define DIVOICE_VOICECOMMAND 0x83000410 + + +/*--- Driving Simulator - Racing + Vehicle control is primary objective ---*/ +#define DIVIRTUAL_DRIVING_RACE 0x01000000 +#define DIAXIS_DRIVINGR_STEER 0x01008A01 /* Steering */ +#define DIAXIS_DRIVINGR_ACCELERATE 0x01039202 /* Accelerate */ +#define DIAXIS_DRIVINGR_BRAKE 0x01041203 /* Brake-Axis */ +#define DIBUTTON_DRIVINGR_SHIFTUP 0x01000C01 /* Shift to next higher gear */ +#define DIBUTTON_DRIVINGR_SHIFTDOWN 0x01000C02 /* Shift to next lower gear */ +#define DIBUTTON_DRIVINGR_VIEW 0x01001C03 /* Cycle through view options */ +#define DIBUTTON_DRIVINGR_MENU 0x010004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIAXIS_DRIVINGR_ACCEL_AND_BRAKE 0x01014A04 /* Some devices combine accelerate and brake in a single axis */ +#define DIHATSWITCH_DRIVINGR_GLANCE 0x01004601 /* Look around */ +#define DIBUTTON_DRIVINGR_BRAKE 0x01004C04 /* Brake-button */ +#define DIBUTTON_DRIVINGR_DASHBOARD 0x01004405 /* Select next dashboard option */ +#define DIBUTTON_DRIVINGR_AIDS 0x01004406 /* Driver correction aids */ +#define DIBUTTON_DRIVINGR_MAP 0x01004407 /* Display Driving Map */ +#define DIBUTTON_DRIVINGR_BOOST 0x01004408 /* Turbo Boost */ +#define DIBUTTON_DRIVINGR_PIT 0x01004409 /* Pit stop notification */ +#define DIBUTTON_DRIVINGR_ACCELERATE_LINK 0x0103D4E0 /* Fallback Accelerate button */ +#define DIBUTTON_DRIVINGR_STEER_LEFT_LINK 0x0100CCE4 /* Fallback Steer Left button */ +#define DIBUTTON_DRIVINGR_STEER_RIGHT_LINK 0x0100CCEC /* Fallback Steer Right button */ +#define DIBUTTON_DRIVINGR_GLANCE_LEFT_LINK 0x0107C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_DRIVINGR_GLANCE_RIGHT_LINK 0x0107C4EC /* Fallback Glance Right button */ +#define DIBUTTON_DRIVINGR_DEVICE 0x010044FE /* Show input device and controls */ +#define DIBUTTON_DRIVINGR_PAUSE 0x010044FC /* Start / Pause / Restart game */ + +/*--- Driving Simulator - Combat + Combat from within a vehicle is primary objective ---*/ +#define DIVIRTUAL_DRIVING_COMBAT 0x02000000 +#define DIAXIS_DRIVINGC_STEER 0x02008A01 /* Steering */ +#define DIAXIS_DRIVINGC_ACCELERATE 0x02039202 /* Accelerate */ +#define DIAXIS_DRIVINGC_BRAKE 0x02041203 /* Brake-axis */ +#define DIBUTTON_DRIVINGC_FIRE 0x02000C01 /* Fire */ +#define DIBUTTON_DRIVINGC_WEAPONS 0x02000C02 /* Select next weapon */ +#define DIBUTTON_DRIVINGC_TARGET 0x02000C03 /* Select next available target */ +#define DIBUTTON_DRIVINGC_MENU 0x020004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIAXIS_DRIVINGC_ACCEL_AND_BRAKE 0x02014A04 /* Some devices combine accelerate and brake in a single axis */ +#define DIHATSWITCH_DRIVINGC_GLANCE 0x02004601 /* Look around */ +#define DIBUTTON_DRIVINGC_SHIFTUP 0x02004C04 /* Shift to next higher gear */ +#define DIBUTTON_DRIVINGC_SHIFTDOWN 0x02004C05 /* Shift to next lower gear */ +#define DIBUTTON_DRIVINGC_DASHBOARD 0x02004406 /* Select next dashboard option */ +#define DIBUTTON_DRIVINGC_AIDS 0x02004407 /* Driver correction aids */ +#define DIBUTTON_DRIVINGC_BRAKE 0x02004C08 /* Brake-button */ +#define DIBUTTON_DRIVINGC_FIRESECONDARY 0x02004C09 /* Alternative fire button */ +#define DIBUTTON_DRIVINGC_ACCELERATE_LINK 0x0203D4E0 /* Fallback Accelerate button */ +#define DIBUTTON_DRIVINGC_STEER_LEFT_LINK 0x0200CCE4 /* Fallback Steer Left button */ +#define DIBUTTON_DRIVINGC_STEER_RIGHT_LINK 0x0200CCEC /* Fallback Steer Right button */ +#define DIBUTTON_DRIVINGC_GLANCE_LEFT_LINK 0x0207C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_DRIVINGC_GLANCE_RIGHT_LINK 0x0207C4EC /* Fallback Glance Right button */ +#define DIBUTTON_DRIVINGC_DEVICE 0x020044FE /* Show input device and controls */ +#define DIBUTTON_DRIVINGC_PAUSE 0x020044FC /* Start / Pause / Restart game */ + +/*--- Driving Simulator - Tank + Combat from withing a tank is primary objective ---*/ +#define DIVIRTUAL_DRIVING_TANK 0x03000000 +#define DIAXIS_DRIVINGT_STEER 0x03008A01 /* Turn tank left / right */ +#define DIAXIS_DRIVINGT_BARREL 0x03010202 /* Raise / lower barrel */ +#define DIAXIS_DRIVINGT_ACCELERATE 0x03039203 /* Accelerate */ +#define DIAXIS_DRIVINGT_ROTATE 0x03020204 /* Turn barrel left / right */ +#define DIBUTTON_DRIVINGT_FIRE 0x03000C01 /* Fire */ +#define DIBUTTON_DRIVINGT_WEAPONS 0x03000C02 /* Select next weapon */ +#define DIBUTTON_DRIVINGT_TARGET 0x03000C03 /* Selects next available target */ +#define DIBUTTON_DRIVINGT_MENU 0x030004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_DRIVINGT_GLANCE 0x03004601 /* Look around */ +#define DIAXIS_DRIVINGT_BRAKE 0x03045205 /* Brake-axis */ +#define DIAXIS_DRIVINGT_ACCEL_AND_BRAKE 0x03014A06 /* Some devices combine accelerate and brake in a single axis */ +#define DIBUTTON_DRIVINGT_VIEW 0x03005C04 /* Cycle through view options */ +#define DIBUTTON_DRIVINGT_DASHBOARD 0x03005C05 /* Select next dashboard option */ +#define DIBUTTON_DRIVINGT_BRAKE 0x03004C06 /* Brake-button */ +#define DIBUTTON_DRIVINGT_FIRESECONDARY 0x03004C07 /* Alternative fire button */ +#define DIBUTTON_DRIVINGT_ACCELERATE_LINK 0x0303D4E0 /* Fallback Accelerate button */ +#define DIBUTTON_DRIVINGT_STEER_LEFT_LINK 0x0300CCE4 /* Fallback Steer Left button */ +#define DIBUTTON_DRIVINGT_STEER_RIGHT_LINK 0x0300CCEC /* Fallback Steer Right button */ +#define DIBUTTON_DRIVINGT_BARREL_UP_LINK 0x030144E0 /* Fallback Barrel up button */ +#define DIBUTTON_DRIVINGT_BARREL_DOWN_LINK 0x030144E8 /* Fallback Barrel down button */ +#define DIBUTTON_DRIVINGT_ROTATE_LEFT_LINK 0x030244E4 /* Fallback Rotate left button */ +#define DIBUTTON_DRIVINGT_ROTATE_RIGHT_LINK 0x030244EC /* Fallback Rotate right button */ +#define DIBUTTON_DRIVINGT_GLANCE_LEFT_LINK 0x0307C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_DRIVINGT_GLANCE_RIGHT_LINK 0x0307C4EC /* Fallback Glance Right button */ +#define DIBUTTON_DRIVINGT_DEVICE 0x030044FE /* Show input device and controls */ +#define DIBUTTON_DRIVINGT_PAUSE 0x030044FC /* Start / Pause / Restart game */ + +/*--- Flight Simulator - Civilian + Plane control is the primary objective ---*/ +#define DIVIRTUAL_FLYING_CIVILIAN 0x04000000 +#define DIAXIS_FLYINGC_BANK 0x04008A01 /* Roll ship left / right */ +#define DIAXIS_FLYINGC_PITCH 0x04010A02 /* Nose up / down */ +#define DIAXIS_FLYINGC_THROTTLE 0x04039203 /* Throttle */ +#define DIBUTTON_FLYINGC_VIEW 0x04002401 /* Cycle through view options */ +#define DIBUTTON_FLYINGC_DISPLAY 0x04002402 /* Select next dashboard / heads up display option */ +#define DIBUTTON_FLYINGC_GEAR 0x04002C03 /* Gear up / down */ +#define DIBUTTON_FLYINGC_MENU 0x040004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FLYINGC_GLANCE 0x04004601 /* Look around */ +#define DIAXIS_FLYINGC_BRAKE 0x04046A04 /* Apply Brake */ +#define DIAXIS_FLYINGC_RUDDER 0x04025205 /* Yaw ship left/right */ +#define DIAXIS_FLYINGC_FLAPS 0x04055A06 /* Flaps */ +#define DIBUTTON_FLYINGC_FLAPSUP 0x04006404 /* Increment stepping up until fully retracted */ +#define DIBUTTON_FLYINGC_FLAPSDOWN 0x04006405 /* Decrement stepping down until fully extended */ +#define DIBUTTON_FLYINGC_BRAKE_LINK 0x04046CE0 /* Fallback brake button */ +#define DIBUTTON_FLYINGC_FASTER_LINK 0x0403D4E0 /* Fallback throttle up button */ +#define DIBUTTON_FLYINGC_SLOWER_LINK 0x0403D4E8 /* Fallback throttle down button */ +#define DIBUTTON_FLYINGC_GLANCE_LEFT_LINK 0x0407C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_FLYINGC_GLANCE_RIGHT_LINK 0x0407C4EC /* Fallback Glance Right button */ +#define DIBUTTON_FLYINGC_GLANCE_UP_LINK 0x0407C4E0 /* Fallback Glance Up button */ +#define DIBUTTON_FLYINGC_GLANCE_DOWN_LINK 0x0407C4E8 /* Fallback Glance Down button */ +#define DIBUTTON_FLYINGC_DEVICE 0x040044FE /* Show input device and controls */ +#define DIBUTTON_FLYINGC_PAUSE 0x040044FC /* Start / Pause / Restart game */ + +/*--- Flight Simulator - Military + Aerial combat is the primary objective ---*/ +#define DIVIRTUAL_FLYING_MILITARY 0x05000000 +#define DIAXIS_FLYINGM_BANK 0x05008A01 /* Bank - Roll ship left / right */ +#define DIAXIS_FLYINGM_PITCH 0x05010A02 /* Pitch - Nose up / down */ +#define DIAXIS_FLYINGM_THROTTLE 0x05039203 /* Throttle - faster / slower */ +#define DIBUTTON_FLYINGM_FIRE 0x05000C01 /* Fire */ +#define DIBUTTON_FLYINGM_WEAPONS 0x05000C02 /* Select next weapon */ +#define DIBUTTON_FLYINGM_TARGET 0x05000C03 /* Selects next available target */ +#define DIBUTTON_FLYINGM_MENU 0x050004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FLYINGM_GLANCE 0x05004601 /* Look around */ +#define DIBUTTON_FLYINGM_COUNTER 0x05005C04 /* Activate counter measures */ +#define DIAXIS_FLYINGM_RUDDER 0x05024A04 /* Rudder - Yaw ship left/right */ +#define DIAXIS_FLYINGM_BRAKE 0x05046205 /* Brake-axis */ +#define DIBUTTON_FLYINGM_VIEW 0x05006405 /* Cycle through view options */ +#define DIBUTTON_FLYINGM_DISPLAY 0x05006406 /* Select next dashboard option */ +#define DIAXIS_FLYINGM_FLAPS 0x05055206 /* Flaps */ +#define DIBUTTON_FLYINGM_FLAPSUP 0x05005407 /* Increment stepping up until fully retracted */ +#define DIBUTTON_FLYINGM_FLAPSDOWN 0x05005408 /* Decrement stepping down until fully extended */ +#define DIBUTTON_FLYINGM_FIRESECONDARY 0x05004C09 /* Alternative fire button */ +#define DIBUTTON_FLYINGM_GEAR 0x0500640A /* Gear up / down */ +#define DIBUTTON_FLYINGM_BRAKE_LINK 0x050464E0 /* Fallback brake button */ +#define DIBUTTON_FLYINGM_FASTER_LINK 0x0503D4E0 /* Fallback throttle up button */ +#define DIBUTTON_FLYINGM_SLOWER_LINK 0x0503D4E8 /* Fallback throttle down button */ +#define DIBUTTON_FLYINGM_GLANCE_LEFT_LINK 0x0507C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_FLYINGM_GLANCE_RIGHT_LINK 0x0507C4EC /* Fallback Glance Right button */ +#define DIBUTTON_FLYINGM_GLANCE_UP_LINK 0x0507C4E0 /* Fallback Glance Up button */ +#define DIBUTTON_FLYINGM_GLANCE_DOWN_LINK 0x0507C4E8 /* Fallback Glance Down button */ +#define DIBUTTON_FLYINGM_DEVICE 0x050044FE /* Show input device and controls */ +#define DIBUTTON_FLYINGM_PAUSE 0x050044FC /* Start / Pause / Restart game */ + +/*--- Flight Simulator - Combat Helicopter + Combat from helicopter is primary objective ---*/ +#define DIVIRTUAL_FLYING_HELICOPTER 0x06000000 +#define DIAXIS_FLYINGH_BANK 0x06008A01 /* Bank - Roll ship left / right */ +#define DIAXIS_FLYINGH_PITCH 0x06010A02 /* Pitch - Nose up / down */ +#define DIAXIS_FLYINGH_COLLECTIVE 0x06018A03 /* Collective - Blade pitch/power */ +#define DIBUTTON_FLYINGH_FIRE 0x06001401 /* Fire */ +#define DIBUTTON_FLYINGH_WEAPONS 0x06001402 /* Select next weapon */ +#define DIBUTTON_FLYINGH_TARGET 0x06001403 /* Selects next available target */ +#define DIBUTTON_FLYINGH_MENU 0x060004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FLYINGH_GLANCE 0x06004601 /* Look around */ +#define DIAXIS_FLYINGH_TORQUE 0x06025A04 /* Torque - Rotate ship around left / right axis */ +#define DIAXIS_FLYINGH_THROTTLE 0x0603DA05 /* Throttle */ +#define DIBUTTON_FLYINGH_COUNTER 0x06005404 /* Activate counter measures */ +#define DIBUTTON_FLYINGH_VIEW 0x06006405 /* Cycle through view options */ +#define DIBUTTON_FLYINGH_GEAR 0x06006406 /* Gear up / down */ +#define DIBUTTON_FLYINGH_FIRESECONDARY 0x06004C07 /* Alternative fire button */ +#define DIBUTTON_FLYINGH_FASTER_LINK 0x0603DCE0 /* Fallback throttle up button */ +#define DIBUTTON_FLYINGH_SLOWER_LINK 0x0603DCE8 /* Fallback throttle down button */ +#define DIBUTTON_FLYINGH_GLANCE_LEFT_LINK 0x0607C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_FLYINGH_GLANCE_RIGHT_LINK 0x0607C4EC /* Fallback Glance Right button */ +#define DIBUTTON_FLYINGH_GLANCE_UP_LINK 0x0607C4E0 /* Fallback Glance Up button */ +#define DIBUTTON_FLYINGH_GLANCE_DOWN_LINK 0x0607C4E8 /* Fallback Glance Down button */ +#define DIBUTTON_FLYINGH_DEVICE 0x060044FE /* Show input device and controls */ +#define DIBUTTON_FLYINGH_PAUSE 0x060044FC /* Start / Pause / Restart game */ + +/*--- Space Simulator - Combat + Space Simulator with weapons ---*/ +#define DIVIRTUAL_SPACESIM 0x07000000 +#define DIAXIS_SPACESIM_LATERAL 0x07008201 /* Move ship left / right */ +#define DIAXIS_SPACESIM_MOVE 0x07010202 /* Move ship forward/backward */ +#define DIAXIS_SPACESIM_THROTTLE 0x07038203 /* Throttle - Engine speed */ +#define DIBUTTON_SPACESIM_FIRE 0x07000401 /* Fire */ +#define DIBUTTON_SPACESIM_WEAPONS 0x07000402 /* Select next weapon */ +#define DIBUTTON_SPACESIM_TARGET 0x07000403 /* Selects next available target */ +#define DIBUTTON_SPACESIM_MENU 0x070004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_SPACESIM_GLANCE 0x07004601 /* Look around */ +#define DIAXIS_SPACESIM_CLIMB 0x0701C204 /* Climb - Pitch ship up/down */ +#define DIAXIS_SPACESIM_ROTATE 0x07024205 /* Rotate - Turn ship left/right */ +#define DIBUTTON_SPACESIM_VIEW 0x07004404 /* Cycle through view options */ +#define DIBUTTON_SPACESIM_DISPLAY 0x07004405 /* Select next dashboard / heads up display option */ +#define DIBUTTON_SPACESIM_RAISE 0x07004406 /* Raise ship while maintaining current pitch */ +#define DIBUTTON_SPACESIM_LOWER 0x07004407 /* Lower ship while maintaining current pitch */ +#define DIBUTTON_SPACESIM_GEAR 0x07004408 /* Gear up / down */ +#define DIBUTTON_SPACESIM_FIRESECONDARY 0x07004409 /* Alternative fire button */ +#define DIBUTTON_SPACESIM_LEFT_LINK 0x0700C4E4 /* Fallback move left button */ +#define DIBUTTON_SPACESIM_RIGHT_LINK 0x0700C4EC /* Fallback move right button */ +#define DIBUTTON_SPACESIM_FORWARD_LINK 0x070144E0 /* Fallback move forward button */ +#define DIBUTTON_SPACESIM_BACKWARD_LINK 0x070144E8 /* Fallback move backwards button */ +#define DIBUTTON_SPACESIM_FASTER_LINK 0x0703C4E0 /* Fallback throttle up button */ +#define DIBUTTON_SPACESIM_SLOWER_LINK 0x0703C4E8 /* Fallback throttle down button */ +#define DIBUTTON_SPACESIM_TURN_LEFT_LINK 0x070244E4 /* Fallback turn left button */ +#define DIBUTTON_SPACESIM_TURN_RIGHT_LINK 0x070244EC /* Fallback turn right button */ +#define DIBUTTON_SPACESIM_GLANCE_LEFT_LINK 0x0707C4E4 /* Fallback Glance Left button */ +#define DIBUTTON_SPACESIM_GLANCE_RIGHT_LINK 0x0707C4EC /* Fallback Glance Right button */ +#define DIBUTTON_SPACESIM_GLANCE_UP_LINK 0x0707C4E0 /* Fallback Glance Up button */ +#define DIBUTTON_SPACESIM_GLANCE_DOWN_LINK 0x0707C4E8 /* Fallback Glance Down button */ +#define DIBUTTON_SPACESIM_DEVICE 0x070044FE /* Show input device and controls */ +#define DIBUTTON_SPACESIM_PAUSE 0x070044FC /* Start / Pause / Restart game */ + +/*--- Fighting - First Person + Hand to Hand combat is primary objective ---*/ +#define DIVIRTUAL_FIGHTING_HAND2HAND 0x08000000 +#define DIAXIS_FIGHTINGH_LATERAL 0x08008201 /* Sidestep left/right */ +#define DIAXIS_FIGHTINGH_MOVE 0x08010202 /* Move forward/backward */ +#define DIBUTTON_FIGHTINGH_PUNCH 0x08000401 /* Punch */ +#define DIBUTTON_FIGHTINGH_KICK 0x08000402 /* Kick */ +#define DIBUTTON_FIGHTINGH_BLOCK 0x08000403 /* Block */ +#define DIBUTTON_FIGHTINGH_CROUCH 0x08000404 /* Crouch */ +#define DIBUTTON_FIGHTINGH_JUMP 0x08000405 /* Jump */ +#define DIBUTTON_FIGHTINGH_SPECIAL1 0x08000406 /* Apply first special move */ +#define DIBUTTON_FIGHTINGH_SPECIAL2 0x08000407 /* Apply second special move */ +#define DIBUTTON_FIGHTINGH_MENU 0x080004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FIGHTINGH_SELECT 0x08004408 /* Select special move */ +#define DIHATSWITCH_FIGHTINGH_SLIDE 0x08004601 /* Look around */ +#define DIBUTTON_FIGHTINGH_DISPLAY 0x08004409 /* Shows next on-screen display option */ +#define DIAXIS_FIGHTINGH_ROTATE 0x08024203 /* Rotate - Turn body left/right */ +#define DIBUTTON_FIGHTINGH_DODGE 0x0800440A /* Dodge */ +#define DIBUTTON_FIGHTINGH_LEFT_LINK 0x0800C4E4 /* Fallback left sidestep button */ +#define DIBUTTON_FIGHTINGH_RIGHT_LINK 0x0800C4EC /* Fallback right sidestep button */ +#define DIBUTTON_FIGHTINGH_FORWARD_LINK 0x080144E0 /* Fallback forward button */ +#define DIBUTTON_FIGHTINGH_BACKWARD_LINK 0x080144E8 /* Fallback backward button */ +#define DIBUTTON_FIGHTINGH_DEVICE 0x080044FE /* Show input device and controls */ +#define DIBUTTON_FIGHTINGH_PAUSE 0x080044FC /* Start / Pause / Restart game */ + +/*--- Fighting - First Person Shooting + Navigation and combat are primary objectives ---*/ +#define DIVIRTUAL_FIGHTING_FPS 0x09000000 +#define DIAXIS_FPS_ROTATE 0x09008201 /* Rotate character left/right */ +#define DIAXIS_FPS_MOVE 0x09010202 /* Move forward/backward */ +#define DIBUTTON_FPS_FIRE 0x09000401 /* Fire */ +#define DIBUTTON_FPS_WEAPONS 0x09000402 /* Select next weapon */ +#define DIBUTTON_FPS_APPLY 0x09000403 /* Use item */ +#define DIBUTTON_FPS_SELECT 0x09000404 /* Select next inventory item */ +#define DIBUTTON_FPS_CROUCH 0x09000405 /* Crouch/ climb down/ swim down */ +#define DIBUTTON_FPS_JUMP 0x09000406 /* Jump/ climb up/ swim up */ +#define DIAXIS_FPS_LOOKUPDOWN 0x09018203 /* Look up / down */ +#define DIBUTTON_FPS_STRAFE 0x09000407 /* Enable strafing while active */ +#define DIBUTTON_FPS_MENU 0x090004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FPS_GLANCE 0x09004601 /* Look around */ +#define DIBUTTON_FPS_DISPLAY 0x09004408 /* Shows next on-screen display option/ map */ +#define DIAXIS_FPS_SIDESTEP 0x09024204 /* Sidestep */ +#define DIBUTTON_FPS_DODGE 0x09004409 /* Dodge */ +#define DIBUTTON_FPS_GLANCEL 0x0900440A /* Glance Left */ +#define DIBUTTON_FPS_GLANCER 0x0900440B /* Glance Right */ +#define DIBUTTON_FPS_FIRESECONDARY 0x0900440C /* Alternative fire button */ +#define DIBUTTON_FPS_ROTATE_LEFT_LINK 0x0900C4E4 /* Fallback rotate left button */ +#define DIBUTTON_FPS_ROTATE_RIGHT_LINK 0x0900C4EC /* Fallback rotate right button */ +#define DIBUTTON_FPS_FORWARD_LINK 0x090144E0 /* Fallback forward button */ +#define DIBUTTON_FPS_BACKWARD_LINK 0x090144E8 /* Fallback backward button */ +#define DIBUTTON_FPS_GLANCE_UP_LINK 0x0901C4E0 /* Fallback look up button */ +#define DIBUTTON_FPS_GLANCE_DOWN_LINK 0x0901C4E8 /* Fallback look down button */ +#define DIBUTTON_FPS_STEP_LEFT_LINK 0x090244E4 /* Fallback step left button */ +#define DIBUTTON_FPS_STEP_RIGHT_LINK 0x090244EC /* Fallback step right button */ +#define DIBUTTON_FPS_DEVICE 0x090044FE /* Show input device and controls */ +#define DIBUTTON_FPS_PAUSE 0x090044FC /* Start / Pause / Restart game */ + +/*--- Fighting - Third Person action + Perspective of camera is behind the main character ---*/ +#define DIVIRTUAL_FIGHTING_THIRDPERSON 0x0A000000 +#define DIAXIS_TPS_TURN 0x0A020201 /* Turn left/right */ +#define DIAXIS_TPS_MOVE 0x0A010202 /* Move forward/backward */ +#define DIBUTTON_TPS_RUN 0x0A000401 /* Run or walk toggle switch */ +#define DIBUTTON_TPS_ACTION 0x0A000402 /* Action Button */ +#define DIBUTTON_TPS_SELECT 0x0A000403 /* Select next weapon */ +#define DIBUTTON_TPS_USE 0x0A000404 /* Use inventory item currently selected */ +#define DIBUTTON_TPS_JUMP 0x0A000405 /* Character Jumps */ +#define DIBUTTON_TPS_MENU 0x0A0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_TPS_GLANCE 0x0A004601 /* Look around */ +#define DIBUTTON_TPS_VIEW 0x0A004406 /* Select camera view */ +#define DIBUTTON_TPS_STEPLEFT 0x0A004407 /* Character takes a left step */ +#define DIBUTTON_TPS_STEPRIGHT 0x0A004408 /* Character takes a right step */ +#define DIAXIS_TPS_STEP 0x0A00C203 /* Character steps left/right */ +#define DIBUTTON_TPS_DODGE 0x0A004409 /* Character dodges or ducks */ +#define DIBUTTON_TPS_INVENTORY 0x0A00440A /* Cycle through inventory */ +#define DIBUTTON_TPS_TURN_LEFT_LINK 0x0A0244E4 /* Fallback turn left button */ +#define DIBUTTON_TPS_TURN_RIGHT_LINK 0x0A0244EC /* Fallback turn right button */ +#define DIBUTTON_TPS_FORWARD_LINK 0x0A0144E0 /* Fallback forward button */ +#define DIBUTTON_TPS_BACKWARD_LINK 0x0A0144E8 /* Fallback backward button */ +#define DIBUTTON_TPS_GLANCE_UP_LINK 0x0A07C4E0 /* Fallback look up button */ +#define DIBUTTON_TPS_GLANCE_DOWN_LINK 0x0A07C4E8 /* Fallback look down button */ +#define DIBUTTON_TPS_GLANCE_LEFT_LINK 0x0A07C4E4 /* Fallback glance up button */ +#define DIBUTTON_TPS_GLANCE_RIGHT_LINK 0x0A07C4EC /* Fallback glance right button */ +#define DIBUTTON_TPS_DEVICE 0x0A0044FE /* Show input device and controls */ +#define DIBUTTON_TPS_PAUSE 0x0A0044FC /* Start / Pause / Restart game */ + +/*--- Strategy - Role Playing + Navigation and problem solving are primary actions ---*/ +#define DIVIRTUAL_STRATEGY_ROLEPLAYING 0x0B000000 +#define DIAXIS_STRATEGYR_LATERAL 0x0B008201 /* sidestep - left/right */ +#define DIAXIS_STRATEGYR_MOVE 0x0B010202 /* move forward/backward */ +#define DIBUTTON_STRATEGYR_GET 0x0B000401 /* Acquire item */ +#define DIBUTTON_STRATEGYR_APPLY 0x0B000402 /* Use selected item */ +#define DIBUTTON_STRATEGYR_SELECT 0x0B000403 /* Select nextitem */ +#define DIBUTTON_STRATEGYR_ATTACK 0x0B000404 /* Attack */ +#define DIBUTTON_STRATEGYR_CAST 0x0B000405 /* Cast Spell */ +#define DIBUTTON_STRATEGYR_CROUCH 0x0B000406 /* Crouch */ +#define DIBUTTON_STRATEGYR_JUMP 0x0B000407 /* Jump */ +#define DIBUTTON_STRATEGYR_MENU 0x0B0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_STRATEGYR_GLANCE 0x0B004601 /* Look around */ +#define DIBUTTON_STRATEGYR_MAP 0x0B004408 /* Cycle through map options */ +#define DIBUTTON_STRATEGYR_DISPLAY 0x0B004409 /* Shows next on-screen display option */ +#define DIAXIS_STRATEGYR_ROTATE 0x0B024203 /* Turn body left/right */ +#define DIBUTTON_STRATEGYR_LEFT_LINK 0x0B00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_STRATEGYR_RIGHT_LINK 0x0B00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_STRATEGYR_FORWARD_LINK 0x0B0144E0 /* Fallback move forward button */ +#define DIBUTTON_STRATEGYR_BACK_LINK 0x0B0144E8 /* Fallback move backward button */ +#define DIBUTTON_STRATEGYR_ROTATE_LEFT_LINK 0x0B0244E4 /* Fallback turn body left button */ +#define DIBUTTON_STRATEGYR_ROTATE_RIGHT_LINK 0x0B0244EC /* Fallback turn body right button */ +#define DIBUTTON_STRATEGYR_DEVICE 0x0B0044FE /* Show input device and controls */ +#define DIBUTTON_STRATEGYR_PAUSE 0x0B0044FC /* Start / Pause / Restart game */ + +/*--- Strategy - Turn based + Navigation and problem solving are primary actions ---*/ +#define DIVIRTUAL_STRATEGY_TURN 0x0C000000 +#define DIAXIS_STRATEGYT_LATERAL 0x0C008201 /* Sidestep left/right */ +#define DIAXIS_STRATEGYT_MOVE 0x0C010202 /* Move forward/backwards */ +#define DIBUTTON_STRATEGYT_SELECT 0x0C000401 /* Select unit or object */ +#define DIBUTTON_STRATEGYT_INSTRUCT 0x0C000402 /* Cycle through instructions */ +#define DIBUTTON_STRATEGYT_APPLY 0x0C000403 /* Apply selected instruction */ +#define DIBUTTON_STRATEGYT_TEAM 0x0C000404 /* Select next team / cycle through all */ +#define DIBUTTON_STRATEGYT_TURN 0x0C000405 /* Indicate turn over */ +#define DIBUTTON_STRATEGYT_MENU 0x0C0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_STRATEGYT_ZOOM 0x0C004406 /* Zoom - in / out */ +#define DIBUTTON_STRATEGYT_MAP 0x0C004407 /* cycle through map options */ +#define DIBUTTON_STRATEGYT_DISPLAY 0x0C004408 /* shows next on-screen display options */ +#define DIBUTTON_STRATEGYT_LEFT_LINK 0x0C00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_STRATEGYT_RIGHT_LINK 0x0C00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_STRATEGYT_FORWARD_LINK 0x0C0144E0 /* Fallback move forward button */ +#define DIBUTTON_STRATEGYT_BACK_LINK 0x0C0144E8 /* Fallback move back button */ +#define DIBUTTON_STRATEGYT_DEVICE 0x0C0044FE /* Show input device and controls */ +#define DIBUTTON_STRATEGYT_PAUSE 0x0C0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Hunting + Hunting ---*/ +#define DIVIRTUAL_SPORTS_HUNTING 0x0D000000 +#define DIAXIS_HUNTING_LATERAL 0x0D008201 /* sidestep left/right */ +#define DIAXIS_HUNTING_MOVE 0x0D010202 /* move forward/backwards */ +#define DIBUTTON_HUNTING_FIRE 0x0D000401 /* Fire selected weapon */ +#define DIBUTTON_HUNTING_AIM 0x0D000402 /* Select aim/move */ +#define DIBUTTON_HUNTING_WEAPON 0x0D000403 /* Select next weapon */ +#define DIBUTTON_HUNTING_BINOCULAR 0x0D000404 /* Look through Binoculars */ +#define DIBUTTON_HUNTING_CALL 0x0D000405 /* Make animal call */ +#define DIBUTTON_HUNTING_MAP 0x0D000406 /* View Map */ +#define DIBUTTON_HUNTING_SPECIAL 0x0D000407 /* Special game operation */ +#define DIBUTTON_HUNTING_MENU 0x0D0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_HUNTING_GLANCE 0x0D004601 /* Look around */ +#define DIBUTTON_HUNTING_DISPLAY 0x0D004408 /* show next on-screen display option */ +#define DIAXIS_HUNTING_ROTATE 0x0D024203 /* Turn body left/right */ +#define DIBUTTON_HUNTING_CROUCH 0x0D004409 /* Crouch/ Climb / Swim down */ +#define DIBUTTON_HUNTING_JUMP 0x0D00440A /* Jump/ Climb up / Swim up */ +#define DIBUTTON_HUNTING_FIRESECONDARY 0x0D00440B /* Alternative fire button */ +#define DIBUTTON_HUNTING_LEFT_LINK 0x0D00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_HUNTING_RIGHT_LINK 0x0D00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_HUNTING_FORWARD_LINK 0x0D0144E0 /* Fallback move forward button */ +#define DIBUTTON_HUNTING_BACK_LINK 0x0D0144E8 /* Fallback move back button */ +#define DIBUTTON_HUNTING_ROTATE_LEFT_LINK 0x0D0244E4 /* Fallback turn body left button */ +#define DIBUTTON_HUNTING_ROTATE_RIGHT_LINK 0x0D0244EC /* Fallback turn body right button */ +#define DIBUTTON_HUNTING_DEVICE 0x0D0044FE /* Show input device and controls */ +#define DIBUTTON_HUNTING_PAUSE 0x0D0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Fishing + Catching Fish is primary objective ---*/ +#define DIVIRTUAL_SPORTS_FISHING 0x0E000000 +#define DIAXIS_FISHING_LATERAL 0x0E008201 /* sidestep left/right */ +#define DIAXIS_FISHING_MOVE 0x0E010202 /* move forward/backwards */ +#define DIBUTTON_FISHING_CAST 0x0E000401 /* Cast line */ +#define DIBUTTON_FISHING_TYPE 0x0E000402 /* Select cast type */ +#define DIBUTTON_FISHING_BINOCULAR 0x0E000403 /* Look through Binocular */ +#define DIBUTTON_FISHING_BAIT 0x0E000404 /* Select type of Bait */ +#define DIBUTTON_FISHING_MAP 0x0E000405 /* View Map */ +#define DIBUTTON_FISHING_MENU 0x0E0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_FISHING_GLANCE 0x0E004601 /* Look around */ +#define DIBUTTON_FISHING_DISPLAY 0x0E004406 /* Show next on-screen display option */ +#define DIAXIS_FISHING_ROTATE 0x0E024203 /* Turn character left / right */ +#define DIBUTTON_FISHING_CROUCH 0x0E004407 /* Crouch/ Climb / Swim down */ +#define DIBUTTON_FISHING_JUMP 0x0E004408 /* Jump/ Climb up / Swim up */ +#define DIBUTTON_FISHING_LEFT_LINK 0x0E00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_FISHING_RIGHT_LINK 0x0E00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_FISHING_FORWARD_LINK 0x0E0144E0 /* Fallback move forward button */ +#define DIBUTTON_FISHING_BACK_LINK 0x0E0144E8 /* Fallback move back button */ +#define DIBUTTON_FISHING_ROTATE_LEFT_LINK 0x0E0244E4 /* Fallback turn body left button */ +#define DIBUTTON_FISHING_ROTATE_RIGHT_LINK 0x0E0244EC /* Fallback turn body right button */ +#define DIBUTTON_FISHING_DEVICE 0x0E0044FE /* Show input device and controls */ +#define DIBUTTON_FISHING_PAUSE 0x0E0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Baseball - Batting + Batter control is primary objective ---*/ +#define DIVIRTUAL_SPORTS_BASEBALL_BAT 0x0F000000 +#define DIAXIS_BASEBALLB_LATERAL 0x0F008201 /* Aim left / right */ +#define DIAXIS_BASEBALLB_MOVE 0x0F010202 /* Aim up / down */ +#define DIBUTTON_BASEBALLB_SELECT 0x0F000401 /* cycle through swing options */ +#define DIBUTTON_BASEBALLB_NORMAL 0x0F000402 /* normal swing */ +#define DIBUTTON_BASEBALLB_POWER 0x0F000403 /* swing for the fence */ +#define DIBUTTON_BASEBALLB_BUNT 0x0F000404 /* bunt */ +#define DIBUTTON_BASEBALLB_STEAL 0x0F000405 /* Base runner attempts to steal a base */ +#define DIBUTTON_BASEBALLB_BURST 0x0F000406 /* Base runner invokes burst of speed */ +#define DIBUTTON_BASEBALLB_SLIDE 0x0F000407 /* Base runner slides into base */ +#define DIBUTTON_BASEBALLB_CONTACT 0x0F000408 /* Contact swing */ +#define DIBUTTON_BASEBALLB_MENU 0x0F0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_BASEBALLB_NOSTEAL 0x0F004409 /* Base runner goes back to a base */ +#define DIBUTTON_BASEBALLB_BOX 0x0F00440A /* Enter or exit batting box */ +#define DIBUTTON_BASEBALLB_LEFT_LINK 0x0F00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_BASEBALLB_RIGHT_LINK 0x0F00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_BASEBALLB_FORWARD_LINK 0x0F0144E0 /* Fallback move forward button */ +#define DIBUTTON_BASEBALLB_BACK_LINK 0x0F0144E8 /* Fallback move back button */ +#define DIBUTTON_BASEBALLB_DEVICE 0x0F0044FE /* Show input device and controls */ +#define DIBUTTON_BASEBALLB_PAUSE 0x0F0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Baseball - Pitching + Pitcher control is primary objective ---*/ +#define DIVIRTUAL_SPORTS_BASEBALL_PITCH 0x10000000 +#define DIAXIS_BASEBALLP_LATERAL 0x10008201 /* Aim left / right */ +#define DIAXIS_BASEBALLP_MOVE 0x10010202 /* Aim up / down */ +#define DIBUTTON_BASEBALLP_SELECT 0x10000401 /* cycle through pitch selections */ +#define DIBUTTON_BASEBALLP_PITCH 0x10000402 /* throw pitch */ +#define DIBUTTON_BASEBALLP_BASE 0x10000403 /* select base to throw to */ +#define DIBUTTON_BASEBALLP_THROW 0x10000404 /* throw to base */ +#define DIBUTTON_BASEBALLP_FAKE 0x10000405 /* Fake a throw to a base */ +#define DIBUTTON_BASEBALLP_MENU 0x100004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_BASEBALLP_WALK 0x10004406 /* Throw intentional walk / pitch out */ +#define DIBUTTON_BASEBALLP_LOOK 0x10004407 /* Look at runners on bases */ +#define DIBUTTON_BASEBALLP_LEFT_LINK 0x1000C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_BASEBALLP_RIGHT_LINK 0x1000C4EC /* Fallback sidestep right button */ +#define DIBUTTON_BASEBALLP_FORWARD_LINK 0x100144E0 /* Fallback move forward button */ +#define DIBUTTON_BASEBALLP_BACK_LINK 0x100144E8 /* Fallback move back button */ +#define DIBUTTON_BASEBALLP_DEVICE 0x100044FE /* Show input device and controls */ +#define DIBUTTON_BASEBALLP_PAUSE 0x100044FC /* Start / Pause / Restart game */ + +/*--- Sports - Baseball - Fielding + Fielder control is primary objective ---*/ +#define DIVIRTUAL_SPORTS_BASEBALL_FIELD 0x11000000 +#define DIAXIS_BASEBALLF_LATERAL 0x11008201 /* Aim left / right */ +#define DIAXIS_BASEBALLF_MOVE 0x11010202 /* Aim up / down */ +#define DIBUTTON_BASEBALLF_NEAREST 0x11000401 /* Switch to fielder nearest to the ball */ +#define DIBUTTON_BASEBALLF_THROW1 0x11000402 /* Make conservative throw */ +#define DIBUTTON_BASEBALLF_THROW2 0x11000403 /* Make aggressive throw */ +#define DIBUTTON_BASEBALLF_BURST 0x11000404 /* Invoke burst of speed */ +#define DIBUTTON_BASEBALLF_JUMP 0x11000405 /* Jump to catch ball */ +#define DIBUTTON_BASEBALLF_DIVE 0x11000406 /* Dive to catch ball */ +#define DIBUTTON_BASEBALLF_MENU 0x110004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_BASEBALLF_SHIFTIN 0x11004407 /* Shift the infield positioning */ +#define DIBUTTON_BASEBALLF_SHIFTOUT 0x11004408 /* Shift the outfield positioning */ +#define DIBUTTON_BASEBALLF_AIM_LEFT_LINK 0x1100C4E4 /* Fallback aim left button */ +#define DIBUTTON_BASEBALLF_AIM_RIGHT_LINK 0x1100C4EC /* Fallback aim right button */ +#define DIBUTTON_BASEBALLF_FORWARD_LINK 0x110144E0 /* Fallback move forward button */ +#define DIBUTTON_BASEBALLF_BACK_LINK 0x110144E8 /* Fallback move back button */ +#define DIBUTTON_BASEBALLF_DEVICE 0x110044FE /* Show input device and controls */ +#define DIBUTTON_BASEBALLF_PAUSE 0x110044FC /* Start / Pause / Restart game */ + +/*--- Sports - Basketball - Offense + Offense ---*/ +#define DIVIRTUAL_SPORTS_BASKETBALL_OFFENSE 0x12000000 +#define DIAXIS_BBALLO_LATERAL 0x12008201 /* left / right */ +#define DIAXIS_BBALLO_MOVE 0x12010202 /* up / down */ +#define DIBUTTON_BBALLO_SHOOT 0x12000401 /* shoot basket */ +#define DIBUTTON_BBALLO_DUNK 0x12000402 /* dunk basket */ +#define DIBUTTON_BBALLO_PASS 0x12000403 /* throw pass */ +#define DIBUTTON_BBALLO_FAKE 0x12000404 /* fake shot or pass */ +#define DIBUTTON_BBALLO_SPECIAL 0x12000405 /* apply special move */ +#define DIBUTTON_BBALLO_PLAYER 0x12000406 /* select next player */ +#define DIBUTTON_BBALLO_BURST 0x12000407 /* invoke burst */ +#define DIBUTTON_BBALLO_CALL 0x12000408 /* call for ball / pass to me */ +#define DIBUTTON_BBALLO_MENU 0x120004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_BBALLO_GLANCE 0x12004601 /* scroll view */ +#define DIBUTTON_BBALLO_SCREEN 0x12004409 /* Call for screen */ +#define DIBUTTON_BBALLO_PLAY 0x1200440A /* Call for specific offensive play */ +#define DIBUTTON_BBALLO_JAB 0x1200440B /* Initiate fake drive to basket */ +#define DIBUTTON_BBALLO_POST 0x1200440C /* Perform post move */ +#define DIBUTTON_BBALLO_TIMEOUT 0x1200440D /* Time Out */ +#define DIBUTTON_BBALLO_SUBSTITUTE 0x1200440E /* substitute one player for another */ +#define DIBUTTON_BBALLO_LEFT_LINK 0x1200C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_BBALLO_RIGHT_LINK 0x1200C4EC /* Fallback sidestep right button */ +#define DIBUTTON_BBALLO_FORWARD_LINK 0x120144E0 /* Fallback move forward button */ +#define DIBUTTON_BBALLO_BACK_LINK 0x120144E8 /* Fallback move back button */ +#define DIBUTTON_BBALLO_DEVICE 0x120044FE /* Show input device and controls */ +#define DIBUTTON_BBALLO_PAUSE 0x120044FC /* Start / Pause / Restart game */ + +/*--- Sports - Basketball - Defense + Defense ---*/ +#define DIVIRTUAL_SPORTS_BASKETBALL_DEFENSE 0x13000000 +#define DIAXIS_BBALLD_LATERAL 0x13008201 /* left / right */ +#define DIAXIS_BBALLD_MOVE 0x13010202 /* up / down */ +#define DIBUTTON_BBALLD_JUMP 0x13000401 /* jump to block shot */ +#define DIBUTTON_BBALLD_STEAL 0x13000402 /* attempt to steal ball */ +#define DIBUTTON_BBALLD_FAKE 0x13000403 /* fake block or steal */ +#define DIBUTTON_BBALLD_SPECIAL 0x13000404 /* apply special move */ +#define DIBUTTON_BBALLD_PLAYER 0x13000405 /* select next player */ +#define DIBUTTON_BBALLD_BURST 0x13000406 /* invoke burst */ +#define DIBUTTON_BBALLD_PLAY 0x13000407 /* call for specific defensive play */ +#define DIBUTTON_BBALLD_MENU 0x130004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_BBALLD_GLANCE 0x13004601 /* scroll view */ +#define DIBUTTON_BBALLD_TIMEOUT 0x13004408 /* Time Out */ +#define DIBUTTON_BBALLD_SUBSTITUTE 0x13004409 /* substitute one player for another */ +#define DIBUTTON_BBALLD_LEFT_LINK 0x1300C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_BBALLD_RIGHT_LINK 0x1300C4EC /* Fallback sidestep right button */ +#define DIBUTTON_BBALLD_FORWARD_LINK 0x130144E0 /* Fallback move forward button */ +#define DIBUTTON_BBALLD_BACK_LINK 0x130144E8 /* Fallback move back button */ +#define DIBUTTON_BBALLD_DEVICE 0x130044FE /* Show input device and controls */ +#define DIBUTTON_BBALLD_PAUSE 0x130044FC /* Start / Pause / Restart game */ + +/*--- Sports - Football - Play + Play selection ---*/ +#define DIVIRTUAL_SPORTS_FOOTBALL_FIELD 0x14000000 +#define DIBUTTON_FOOTBALLP_PLAY 0x14000401 /* cycle through available plays */ +#define DIBUTTON_FOOTBALLP_SELECT 0x14000402 /* select play */ +#define DIBUTTON_FOOTBALLP_HELP 0x14000403 /* Bring up pop-up help */ +#define DIBUTTON_FOOTBALLP_MENU 0x140004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FOOTBALLP_DEVICE 0x140044FE /* Show input device and controls */ +#define DIBUTTON_FOOTBALLP_PAUSE 0x140044FC /* Start / Pause / Restart game */ + +/*--- Sports - Football - QB + Offense: Quarterback / Kicker ---*/ +#define DIVIRTUAL_SPORTS_FOOTBALL_QBCK 0x15000000 +#define DIAXIS_FOOTBALLQ_LATERAL 0x15008201 /* Move / Aim: left / right */ +#define DIAXIS_FOOTBALLQ_MOVE 0x15010202 /* Move / Aim: up / down */ +#define DIBUTTON_FOOTBALLQ_SELECT 0x15000401 /* Select */ +#define DIBUTTON_FOOTBALLQ_SNAP 0x15000402 /* snap ball - start play */ +#define DIBUTTON_FOOTBALLQ_JUMP 0x15000403 /* jump over defender */ +#define DIBUTTON_FOOTBALLQ_SLIDE 0x15000404 /* Dive/Slide */ +#define DIBUTTON_FOOTBALLQ_PASS 0x15000405 /* throws pass to receiver */ +#define DIBUTTON_FOOTBALLQ_FAKE 0x15000406 /* pump fake pass or fake kick */ +#define DIBUTTON_FOOTBALLQ_MENU 0x150004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FOOTBALLQ_FAKESNAP 0x15004407 /* Fake snap */ +#define DIBUTTON_FOOTBALLQ_MOTION 0x15004408 /* Send receivers in motion */ +#define DIBUTTON_FOOTBALLQ_AUDIBLE 0x15004409 /* Change offensive play at line of scrimmage */ +#define DIBUTTON_FOOTBALLQ_LEFT_LINK 0x1500C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_FOOTBALLQ_RIGHT_LINK 0x1500C4EC /* Fallback sidestep right button */ +#define DIBUTTON_FOOTBALLQ_FORWARD_LINK 0x150144E0 /* Fallback move forward button */ +#define DIBUTTON_FOOTBALLQ_BACK_LINK 0x150144E8 /* Fallback move back button */ +#define DIBUTTON_FOOTBALLQ_DEVICE 0x150044FE /* Show input device and controls */ +#define DIBUTTON_FOOTBALLQ_PAUSE 0x150044FC /* Start / Pause / Restart game */ + +/*--- Sports - Football - Offense + Offense - Runner ---*/ +#define DIVIRTUAL_SPORTS_FOOTBALL_OFFENSE 0x16000000 +#define DIAXIS_FOOTBALLO_LATERAL 0x16008201 /* Move / Aim: left / right */ +#define DIAXIS_FOOTBALLO_MOVE 0x16010202 /* Move / Aim: up / down */ +#define DIBUTTON_FOOTBALLO_JUMP 0x16000401 /* jump or hurdle over defender */ +#define DIBUTTON_FOOTBALLO_LEFTARM 0x16000402 /* holds out left arm */ +#define DIBUTTON_FOOTBALLO_RIGHTARM 0x16000403 /* holds out right arm */ +#define DIBUTTON_FOOTBALLO_THROW 0x16000404 /* throw pass or lateral ball to another runner */ +#define DIBUTTON_FOOTBALLO_SPIN 0x16000405 /* Spin to avoid defenders */ +#define DIBUTTON_FOOTBALLO_MENU 0x160004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FOOTBALLO_JUKE 0x16004406 /* Use special move to avoid defenders */ +#define DIBUTTON_FOOTBALLO_SHOULDER 0x16004407 /* Lower shoulder to run over defenders */ +#define DIBUTTON_FOOTBALLO_TURBO 0x16004408 /* Speed burst past defenders */ +#define DIBUTTON_FOOTBALLO_DIVE 0x16004409 /* Dive over defenders */ +#define DIBUTTON_FOOTBALLO_ZOOM 0x1600440A /* Zoom view in / out */ +#define DIBUTTON_FOOTBALLO_SUBSTITUTE 0x1600440B /* substitute one player for another */ +#define DIBUTTON_FOOTBALLO_LEFT_LINK 0x1600C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_FOOTBALLO_RIGHT_LINK 0x1600C4EC /* Fallback sidestep right button */ +#define DIBUTTON_FOOTBALLO_FORWARD_LINK 0x160144E0 /* Fallback move forward button */ +#define DIBUTTON_FOOTBALLO_BACK_LINK 0x160144E8 /* Fallback move back button */ +#define DIBUTTON_FOOTBALLO_DEVICE 0x160044FE /* Show input device and controls */ +#define DIBUTTON_FOOTBALLO_PAUSE 0x160044FC /* Start / Pause / Restart game */ + +/*--- Sports - Football - Defense + Defense ---*/ +#define DIVIRTUAL_SPORTS_FOOTBALL_DEFENSE 0x17000000 +#define DIAXIS_FOOTBALLD_LATERAL 0x17008201 /* Move / Aim: left / right */ +#define DIAXIS_FOOTBALLD_MOVE 0x17010202 /* Move / Aim: up / down */ +#define DIBUTTON_FOOTBALLD_PLAY 0x17000401 /* cycle through available plays */ +#define DIBUTTON_FOOTBALLD_SELECT 0x17000402 /* select player closest to the ball */ +#define DIBUTTON_FOOTBALLD_JUMP 0x17000403 /* jump to intercept or block */ +#define DIBUTTON_FOOTBALLD_TACKLE 0x17000404 /* tackler runner */ +#define DIBUTTON_FOOTBALLD_FAKE 0x17000405 /* hold down to fake tackle or intercept */ +#define DIBUTTON_FOOTBALLD_SUPERTACKLE 0x17000406 /* Initiate special tackle */ +#define DIBUTTON_FOOTBALLD_MENU 0x170004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_FOOTBALLD_SPIN 0x17004407 /* Spin to beat offensive line */ +#define DIBUTTON_FOOTBALLD_SWIM 0x17004408 /* Swim to beat the offensive line */ +#define DIBUTTON_FOOTBALLD_BULLRUSH 0x17004409 /* Bull rush the offensive line */ +#define DIBUTTON_FOOTBALLD_RIP 0x1700440A /* Rip the offensive line */ +#define DIBUTTON_FOOTBALLD_AUDIBLE 0x1700440B /* Change defensive play at the line of scrimmage */ +#define DIBUTTON_FOOTBALLD_ZOOM 0x1700440C /* Zoom view in / out */ +#define DIBUTTON_FOOTBALLD_SUBSTITUTE 0x1700440D /* substitute one player for another */ +#define DIBUTTON_FOOTBALLD_LEFT_LINK 0x1700C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_FOOTBALLD_RIGHT_LINK 0x1700C4EC /* Fallback sidestep right button */ +#define DIBUTTON_FOOTBALLD_FORWARD_LINK 0x170144E0 /* Fallback move forward button */ +#define DIBUTTON_FOOTBALLD_BACK_LINK 0x170144E8 /* Fallback move back button */ +#define DIBUTTON_FOOTBALLD_DEVICE 0x170044FE /* Show input device and controls */ +#define DIBUTTON_FOOTBALLD_PAUSE 0x170044FC /* Start / Pause / Restart game */ + +/*--- Sports - Golf + ---*/ +#define DIVIRTUAL_SPORTS_GOLF 0x18000000 +#define DIAXIS_GOLF_LATERAL 0x18008201 /* Move / Aim: left / right */ +#define DIAXIS_GOLF_MOVE 0x18010202 /* Move / Aim: up / down */ +#define DIBUTTON_GOLF_SWING 0x18000401 /* swing club */ +#define DIBUTTON_GOLF_SELECT 0x18000402 /* cycle between: club / swing strength / ball arc / ball spin */ +#define DIBUTTON_GOLF_UP 0x18000403 /* increase selection */ +#define DIBUTTON_GOLF_DOWN 0x18000404 /* decrease selection */ +#define DIBUTTON_GOLF_TERRAIN 0x18000405 /* shows terrain detail */ +#define DIBUTTON_GOLF_FLYBY 0x18000406 /* view the hole via a flyby */ +#define DIBUTTON_GOLF_MENU 0x180004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_GOLF_SCROLL 0x18004601 /* scroll view */ +#define DIBUTTON_GOLF_ZOOM 0x18004407 /* Zoom view in / out */ +#define DIBUTTON_GOLF_TIMEOUT 0x18004408 /* Call for time out */ +#define DIBUTTON_GOLF_SUBSTITUTE 0x18004409 /* substitute one player for another */ +#define DIBUTTON_GOLF_LEFT_LINK 0x1800C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_GOLF_RIGHT_LINK 0x1800C4EC /* Fallback sidestep right button */ +#define DIBUTTON_GOLF_FORWARD_LINK 0x180144E0 /* Fallback move forward button */ +#define DIBUTTON_GOLF_BACK_LINK 0x180144E8 /* Fallback move back button */ +#define DIBUTTON_GOLF_DEVICE 0x180044FE /* Show input device and controls */ +#define DIBUTTON_GOLF_PAUSE 0x180044FC /* Start / Pause / Restart game */ + +/*--- Sports - Hockey - Offense + Offense ---*/ +#define DIVIRTUAL_SPORTS_HOCKEY_OFFENSE 0x19000000 +#define DIAXIS_HOCKEYO_LATERAL 0x19008201 /* Move / Aim: left / right */ +#define DIAXIS_HOCKEYO_MOVE 0x19010202 /* Move / Aim: up / down */ +#define DIBUTTON_HOCKEYO_SHOOT 0x19000401 /* Shoot */ +#define DIBUTTON_HOCKEYO_PASS 0x19000402 /* pass the puck */ +#define DIBUTTON_HOCKEYO_BURST 0x19000403 /* invoke speed burst */ +#define DIBUTTON_HOCKEYO_SPECIAL 0x19000404 /* invoke special move */ +#define DIBUTTON_HOCKEYO_FAKE 0x19000405 /* hold down to fake pass or kick */ +#define DIBUTTON_HOCKEYO_MENU 0x190004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_HOCKEYO_SCROLL 0x19004601 /* scroll view */ +#define DIBUTTON_HOCKEYO_ZOOM 0x19004406 /* Zoom view in / out */ +#define DIBUTTON_HOCKEYO_STRATEGY 0x19004407 /* Invoke coaching menu for strategy help */ +#define DIBUTTON_HOCKEYO_TIMEOUT 0x19004408 /* Call for time out */ +#define DIBUTTON_HOCKEYO_SUBSTITUTE 0x19004409 /* substitute one player for another */ +#define DIBUTTON_HOCKEYO_LEFT_LINK 0x1900C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_HOCKEYO_RIGHT_LINK 0x1900C4EC /* Fallback sidestep right button */ +#define DIBUTTON_HOCKEYO_FORWARD_LINK 0x190144E0 /* Fallback move forward button */ +#define DIBUTTON_HOCKEYO_BACK_LINK 0x190144E8 /* Fallback move back button */ +#define DIBUTTON_HOCKEYO_DEVICE 0x190044FE /* Show input device and controls */ +#define DIBUTTON_HOCKEYO_PAUSE 0x190044FC /* Start / Pause / Restart game */ + +/*--- Sports - Hockey - Defense + Defense ---*/ +#define DIVIRTUAL_SPORTS_HOCKEY_DEFENSE 0x1A000000 +#define DIAXIS_HOCKEYD_LATERAL 0x1A008201 /* Move / Aim: left / right */ +#define DIAXIS_HOCKEYD_MOVE 0x1A010202 /* Move / Aim: up / down */ +#define DIBUTTON_HOCKEYD_PLAYER 0x1A000401 /* control player closest to the puck */ +#define DIBUTTON_HOCKEYD_STEAL 0x1A000402 /* attempt steal */ +#define DIBUTTON_HOCKEYD_BURST 0x1A000403 /* speed burst or body check */ +#define DIBUTTON_HOCKEYD_BLOCK 0x1A000404 /* block puck */ +#define DIBUTTON_HOCKEYD_FAKE 0x1A000405 /* hold down to fake tackle or intercept */ +#define DIBUTTON_HOCKEYD_MENU 0x1A0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_HOCKEYD_SCROLL 0x1A004601 /* scroll view */ +#define DIBUTTON_HOCKEYD_ZOOM 0x1A004406 /* Zoom view in / out */ +#define DIBUTTON_HOCKEYD_STRATEGY 0x1A004407 /* Invoke coaching menu for strategy help */ +#define DIBUTTON_HOCKEYD_TIMEOUT 0x1A004408 /* Call for time out */ +#define DIBUTTON_HOCKEYD_SUBSTITUTE 0x1A004409 /* substitute one player for another */ +#define DIBUTTON_HOCKEYD_LEFT_LINK 0x1A00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_HOCKEYD_RIGHT_LINK 0x1A00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_HOCKEYD_FORWARD_LINK 0x1A0144E0 /* Fallback move forward button */ +#define DIBUTTON_HOCKEYD_BACK_LINK 0x1A0144E8 /* Fallback move back button */ +#define DIBUTTON_HOCKEYD_DEVICE 0x1A0044FE /* Show input device and controls */ +#define DIBUTTON_HOCKEYD_PAUSE 0x1A0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Hockey - Goalie + Goal tending ---*/ +#define DIVIRTUAL_SPORTS_HOCKEY_GOALIE 0x1B000000 +#define DIAXIS_HOCKEYG_LATERAL 0x1B008201 /* Move / Aim: left / right */ +#define DIAXIS_HOCKEYG_MOVE 0x1B010202 /* Move / Aim: up / down */ +#define DIBUTTON_HOCKEYG_PASS 0x1B000401 /* pass puck */ +#define DIBUTTON_HOCKEYG_POKE 0x1B000402 /* poke / check / hack */ +#define DIBUTTON_HOCKEYG_STEAL 0x1B000403 /* attempt steal */ +#define DIBUTTON_HOCKEYG_BLOCK 0x1B000404 /* block puck */ +#define DIBUTTON_HOCKEYG_MENU 0x1B0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_HOCKEYG_SCROLL 0x1B004601 /* scroll view */ +#define DIBUTTON_HOCKEYG_ZOOM 0x1B004405 /* Zoom view in / out */ +#define DIBUTTON_HOCKEYG_STRATEGY 0x1B004406 /* Invoke coaching menu for strategy help */ +#define DIBUTTON_HOCKEYG_TIMEOUT 0x1B004407 /* Call for time out */ +#define DIBUTTON_HOCKEYG_SUBSTITUTE 0x1B004408 /* substitute one player for another */ +#define DIBUTTON_HOCKEYG_LEFT_LINK 0x1B00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_HOCKEYG_RIGHT_LINK 0x1B00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_HOCKEYG_FORWARD_LINK 0x1B0144E0 /* Fallback move forward button */ +#define DIBUTTON_HOCKEYG_BACK_LINK 0x1B0144E8 /* Fallback move back button */ +#define DIBUTTON_HOCKEYG_DEVICE 0x1B0044FE /* Show input device and controls */ +#define DIBUTTON_HOCKEYG_PAUSE 0x1B0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Mountain Biking + ---*/ +#define DIVIRTUAL_SPORTS_BIKING_MOUNTAIN 0x1C000000 +#define DIAXIS_BIKINGM_TURN 0x1C008201 /* left / right */ +#define DIAXIS_BIKINGM_PEDAL 0x1C010202 /* Pedal faster / slower / brake */ +#define DIBUTTON_BIKINGM_JUMP 0x1C000401 /* jump over obstacle */ +#define DIBUTTON_BIKINGM_CAMERA 0x1C000402 /* switch camera view */ +#define DIBUTTON_BIKINGM_SPECIAL1 0x1C000403 /* perform first special move */ +#define DIBUTTON_BIKINGM_SELECT 0x1C000404 /* Select */ +#define DIBUTTON_BIKINGM_SPECIAL2 0x1C000405 /* perform second special move */ +#define DIBUTTON_BIKINGM_MENU 0x1C0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_BIKINGM_SCROLL 0x1C004601 /* scroll view */ +#define DIBUTTON_BIKINGM_ZOOM 0x1C004406 /* Zoom view in / out */ +#define DIAXIS_BIKINGM_BRAKE 0x1C044203 /* Brake axis */ +#define DIBUTTON_BIKINGM_LEFT_LINK 0x1C00C4E4 /* Fallback turn left button */ +#define DIBUTTON_BIKINGM_RIGHT_LINK 0x1C00C4EC /* Fallback turn right button */ +#define DIBUTTON_BIKINGM_FASTER_LINK 0x1C0144E0 /* Fallback pedal faster button */ +#define DIBUTTON_BIKINGM_SLOWER_LINK 0x1C0144E8 /* Fallback pedal slower button */ +#define DIBUTTON_BIKINGM_BRAKE_BUTTON_LINK 0x1C0444E8 /* Fallback brake button */ +#define DIBUTTON_BIKINGM_DEVICE 0x1C0044FE /* Show input device and controls */ +#define DIBUTTON_BIKINGM_PAUSE 0x1C0044FC /* Start / Pause / Restart game */ + +/*--- Sports: Skiing / Snowboarding / Skateboarding + ---*/ +#define DIVIRTUAL_SPORTS_SKIING 0x1D000000 +#define DIAXIS_SKIING_TURN 0x1D008201 /* left / right */ +#define DIAXIS_SKIING_SPEED 0x1D010202 /* faster / slower */ +#define DIBUTTON_SKIING_JUMP 0x1D000401 /* Jump */ +#define DIBUTTON_SKIING_CROUCH 0x1D000402 /* crouch down */ +#define DIBUTTON_SKIING_CAMERA 0x1D000403 /* switch camera view */ +#define DIBUTTON_SKIING_SPECIAL1 0x1D000404 /* perform first special move */ +#define DIBUTTON_SKIING_SELECT 0x1D000405 /* Select */ +#define DIBUTTON_SKIING_SPECIAL2 0x1D000406 /* perform second special move */ +#define DIBUTTON_SKIING_MENU 0x1D0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_SKIING_GLANCE 0x1D004601 /* scroll view */ +#define DIBUTTON_SKIING_ZOOM 0x1D004407 /* Zoom view in / out */ +#define DIBUTTON_SKIING_LEFT_LINK 0x1D00C4E4 /* Fallback turn left button */ +#define DIBUTTON_SKIING_RIGHT_LINK 0x1D00C4EC /* Fallback turn right button */ +#define DIBUTTON_SKIING_FASTER_LINK 0x1D0144E0 /* Fallback increase speed button */ +#define DIBUTTON_SKIING_SLOWER_LINK 0x1D0144E8 /* Fallback decrease speed button */ +#define DIBUTTON_SKIING_DEVICE 0x1D0044FE /* Show input device and controls */ +#define DIBUTTON_SKIING_PAUSE 0x1D0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Soccer - Offense + Offense ---*/ +#define DIVIRTUAL_SPORTS_SOCCER_OFFENSE 0x1E000000 +#define DIAXIS_SOCCERO_LATERAL 0x1E008201 /* Move / Aim: left / right */ +#define DIAXIS_SOCCERO_MOVE 0x1E010202 /* Move / Aim: up / down */ +#define DIAXIS_SOCCERO_BEND 0x1E018203 /* Bend to soccer shot/pass */ +#define DIBUTTON_SOCCERO_SHOOT 0x1E000401 /* Shoot the ball */ +#define DIBUTTON_SOCCERO_PASS 0x1E000402 /* Pass */ +#define DIBUTTON_SOCCERO_FAKE 0x1E000403 /* Fake */ +#define DIBUTTON_SOCCERO_PLAYER 0x1E000404 /* Select next player */ +#define DIBUTTON_SOCCERO_SPECIAL1 0x1E000405 /* Apply special move */ +#define DIBUTTON_SOCCERO_SELECT 0x1E000406 /* Select special move */ +#define DIBUTTON_SOCCERO_MENU 0x1E0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_SOCCERO_GLANCE 0x1E004601 /* scroll view */ +#define DIBUTTON_SOCCERO_SUBSTITUTE 0x1E004407 /* Substitute one player for another */ +#define DIBUTTON_SOCCERO_SHOOTLOW 0x1E004408 /* Shoot the ball low */ +#define DIBUTTON_SOCCERO_SHOOTHIGH 0x1E004409 /* Shoot the ball high */ +#define DIBUTTON_SOCCERO_PASSTHRU 0x1E00440A /* Make a thru pass */ +#define DIBUTTON_SOCCERO_SPRINT 0x1E00440B /* Sprint / turbo boost */ +#define DIBUTTON_SOCCERO_CONTROL 0x1E00440C /* Obtain control of the ball */ +#define DIBUTTON_SOCCERO_HEAD 0x1E00440D /* Attempt to head the ball */ +#define DIBUTTON_SOCCERO_LEFT_LINK 0x1E00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_SOCCERO_RIGHT_LINK 0x1E00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_SOCCERO_FORWARD_LINK 0x1E0144E0 /* Fallback move forward button */ +#define DIBUTTON_SOCCERO_BACK_LINK 0x1E0144E8 /* Fallback move back button */ +#define DIBUTTON_SOCCERO_DEVICE 0x1E0044FE /* Show input device and controls */ +#define DIBUTTON_SOCCERO_PAUSE 0x1E0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Soccer - Defense + Defense ---*/ +#define DIVIRTUAL_SPORTS_SOCCER_DEFENSE 0x1F000000 +#define DIAXIS_SOCCERD_LATERAL 0x1F008201 /* Move / Aim: left / right */ +#define DIAXIS_SOCCERD_MOVE 0x1F010202 /* Move / Aim: up / down */ +#define DIBUTTON_SOCCERD_BLOCK 0x1F000401 /* Attempt to block shot */ +#define DIBUTTON_SOCCERD_STEAL 0x1F000402 /* Attempt to steal ball */ +#define DIBUTTON_SOCCERD_FAKE 0x1F000403 /* Fake a block or a steal */ +#define DIBUTTON_SOCCERD_PLAYER 0x1F000404 /* Select next player */ +#define DIBUTTON_SOCCERD_SPECIAL 0x1F000405 /* Apply special move */ +#define DIBUTTON_SOCCERD_SELECT 0x1F000406 /* Select special move */ +#define DIBUTTON_SOCCERD_SLIDE 0x1F000407 /* Attempt a slide tackle */ +#define DIBUTTON_SOCCERD_MENU 0x1F0004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_SOCCERD_GLANCE 0x1F004601 /* scroll view */ +#define DIBUTTON_SOCCERD_FOUL 0x1F004408 /* Initiate a foul / hard-foul */ +#define DIBUTTON_SOCCERD_HEAD 0x1F004409 /* Attempt a Header */ +#define DIBUTTON_SOCCERD_CLEAR 0x1F00440A /* Attempt to clear the ball down the field */ +#define DIBUTTON_SOCCERD_GOALIECHARGE 0x1F00440B /* Make the goalie charge out of the box */ +#define DIBUTTON_SOCCERD_SUBSTITUTE 0x1F00440C /* Substitute one player for another */ +#define DIBUTTON_SOCCERD_LEFT_LINK 0x1F00C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_SOCCERD_RIGHT_LINK 0x1F00C4EC /* Fallback sidestep right button */ +#define DIBUTTON_SOCCERD_FORWARD_LINK 0x1F0144E0 /* Fallback move forward button */ +#define DIBUTTON_SOCCERD_BACK_LINK 0x1F0144E8 /* Fallback move back button */ +#define DIBUTTON_SOCCERD_DEVICE 0x1F0044FE /* Show input device and controls */ +#define DIBUTTON_SOCCERD_PAUSE 0x1F0044FC /* Start / Pause / Restart game */ + +/*--- Sports - Racquet + Tennis - Table-Tennis - Squash ---*/ +#define DIVIRTUAL_SPORTS_RACQUET 0x20000000 +#define DIAXIS_RACQUET_LATERAL 0x20008201 /* Move / Aim: left / right */ +#define DIAXIS_RACQUET_MOVE 0x20010202 /* Move / Aim: up / down */ +#define DIBUTTON_RACQUET_SWING 0x20000401 /* Swing racquet */ +#define DIBUTTON_RACQUET_BACKSWING 0x20000402 /* Swing backhand */ +#define DIBUTTON_RACQUET_SMASH 0x20000403 /* Smash shot */ +#define DIBUTTON_RACQUET_SPECIAL 0x20000404 /* Special shot */ +#define DIBUTTON_RACQUET_SELECT 0x20000405 /* Select special shot */ +#define DIBUTTON_RACQUET_MENU 0x200004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_RACQUET_GLANCE 0x20004601 /* scroll view */ +#define DIBUTTON_RACQUET_TIMEOUT 0x20004406 /* Call for time out */ +#define DIBUTTON_RACQUET_SUBSTITUTE 0x20004407 /* Substitute one player for another */ +#define DIBUTTON_RACQUET_LEFT_LINK 0x2000C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_RACQUET_RIGHT_LINK 0x2000C4EC /* Fallback sidestep right button */ +#define DIBUTTON_RACQUET_FORWARD_LINK 0x200144E0 /* Fallback move forward button */ +#define DIBUTTON_RACQUET_BACK_LINK 0x200144E8 /* Fallback move back button */ +#define DIBUTTON_RACQUET_DEVICE 0x200044FE /* Show input device and controls */ +#define DIBUTTON_RACQUET_PAUSE 0x200044FC /* Start / Pause / Restart game */ + +/*--- Arcade- 2D + Side to Side movement ---*/ +#define DIVIRTUAL_ARCADE_SIDE2SIDE 0x21000000 +#define DIAXIS_ARCADES_LATERAL 0x21008201 /* left / right */ +#define DIAXIS_ARCADES_MOVE 0x21010202 /* up / down */ +#define DIBUTTON_ARCADES_THROW 0x21000401 /* throw object */ +#define DIBUTTON_ARCADES_CARRY 0x21000402 /* carry object */ +#define DIBUTTON_ARCADES_ATTACK 0x21000403 /* attack */ +#define DIBUTTON_ARCADES_SPECIAL 0x21000404 /* apply special move */ +#define DIBUTTON_ARCADES_SELECT 0x21000405 /* select special move */ +#define DIBUTTON_ARCADES_MENU 0x210004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_ARCADES_VIEW 0x21004601 /* scroll view left / right / up / down */ +#define DIBUTTON_ARCADES_LEFT_LINK 0x2100C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_ARCADES_RIGHT_LINK 0x2100C4EC /* Fallback sidestep right button */ +#define DIBUTTON_ARCADES_FORWARD_LINK 0x210144E0 /* Fallback move forward button */ +#define DIBUTTON_ARCADES_BACK_LINK 0x210144E8 /* Fallback move back button */ +#define DIBUTTON_ARCADES_VIEW_UP_LINK 0x2107C4E0 /* Fallback scroll view up button */ +#define DIBUTTON_ARCADES_VIEW_DOWN_LINK 0x2107C4E8 /* Fallback scroll view down button */ +#define DIBUTTON_ARCADES_VIEW_LEFT_LINK 0x2107C4E4 /* Fallback scroll view left button */ +#define DIBUTTON_ARCADES_VIEW_RIGHT_LINK 0x2107C4EC /* Fallback scroll view right button */ +#define DIBUTTON_ARCADES_DEVICE 0x210044FE /* Show input device and controls */ +#define DIBUTTON_ARCADES_PAUSE 0x210044FC /* Start / Pause / Restart game */ + +/*--- Arcade - Platform Game + Character moves around on screen ---*/ +#define DIVIRTUAL_ARCADE_PLATFORM 0x22000000 +#define DIAXIS_ARCADEP_LATERAL 0x22008201 /* Left / right */ +#define DIAXIS_ARCADEP_MOVE 0x22010202 /* Up / down */ +#define DIBUTTON_ARCADEP_JUMP 0x22000401 /* Jump */ +#define DIBUTTON_ARCADEP_FIRE 0x22000402 /* Fire */ +#define DIBUTTON_ARCADEP_CROUCH 0x22000403 /* Crouch */ +#define DIBUTTON_ARCADEP_SPECIAL 0x22000404 /* Apply special move */ +#define DIBUTTON_ARCADEP_SELECT 0x22000405 /* Select special move */ +#define DIBUTTON_ARCADEP_MENU 0x220004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_ARCADEP_VIEW 0x22004601 /* Scroll view */ +#define DIBUTTON_ARCADEP_FIRESECONDARY 0x22004406 /* Alternative fire button */ +#define DIBUTTON_ARCADEP_LEFT_LINK 0x2200C4E4 /* Fallback sidestep left button */ +#define DIBUTTON_ARCADEP_RIGHT_LINK 0x2200C4EC /* Fallback sidestep right button */ +#define DIBUTTON_ARCADEP_FORWARD_LINK 0x220144E0 /* Fallback move forward button */ +#define DIBUTTON_ARCADEP_BACK_LINK 0x220144E8 /* Fallback move back button */ +#define DIBUTTON_ARCADEP_VIEW_UP_LINK 0x2207C4E0 /* Fallback scroll view up button */ +#define DIBUTTON_ARCADEP_VIEW_DOWN_LINK 0x2207C4E8 /* Fallback scroll view down button */ +#define DIBUTTON_ARCADEP_VIEW_LEFT_LINK 0x2207C4E4 /* Fallback scroll view left button */ +#define DIBUTTON_ARCADEP_VIEW_RIGHT_LINK 0x2207C4EC /* Fallback scroll view right button */ +#define DIBUTTON_ARCADEP_DEVICE 0x220044FE /* Show input device and controls */ +#define DIBUTTON_ARCADEP_PAUSE 0x220044FC /* Start / Pause / Restart game */ + +/*--- CAD - 2D Object Control + Controls to select and move objects in 2D ---*/ +#define DIVIRTUAL_CAD_2DCONTROL 0x23000000 +#define DIAXIS_2DCONTROL_LATERAL 0x23008201 /* Move view left / right */ +#define DIAXIS_2DCONTROL_MOVE 0x23010202 /* Move view up / down */ +#define DIAXIS_2DCONTROL_INOUT 0x23018203 /* Zoom - in / out */ +#define DIBUTTON_2DCONTROL_SELECT 0x23000401 /* Select Object */ +#define DIBUTTON_2DCONTROL_SPECIAL1 0x23000402 /* Do first special operation */ +#define DIBUTTON_2DCONTROL_SPECIAL 0x23000403 /* Select special operation */ +#define DIBUTTON_2DCONTROL_SPECIAL2 0x23000404 /* Do second special operation */ +#define DIBUTTON_2DCONTROL_MENU 0x230004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_2DCONTROL_HATSWITCH 0x23004601 /* Hat switch */ +#define DIAXIS_2DCONTROL_ROTATEZ 0x23024204 /* Rotate view clockwise / counterclockwise */ +#define DIBUTTON_2DCONTROL_DISPLAY 0x23004405 /* Shows next on-screen display options */ +#define DIBUTTON_2DCONTROL_DEVICE 0x230044FE /* Show input device and controls */ +#define DIBUTTON_2DCONTROL_PAUSE 0x230044FC /* Start / Pause / Restart game */ + +/*--- CAD - 3D object control + Controls to select and move objects within a 3D environment ---*/ +#define DIVIRTUAL_CAD_3DCONTROL 0x24000000 +#define DIAXIS_3DCONTROL_LATERAL 0x24008201 /* Move view left / right */ +#define DIAXIS_3DCONTROL_MOVE 0x24010202 /* Move view up / down */ +#define DIAXIS_3DCONTROL_INOUT 0x24018203 /* Zoom - in / out */ +#define DIBUTTON_3DCONTROL_SELECT 0x24000401 /* Select Object */ +#define DIBUTTON_3DCONTROL_SPECIAL1 0x24000402 /* Do first special operation */ +#define DIBUTTON_3DCONTROL_SPECIAL 0x24000403 /* Select special operation */ +#define DIBUTTON_3DCONTROL_SPECIAL2 0x24000404 /* Do second special operation */ +#define DIBUTTON_3DCONTROL_MENU 0x240004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_3DCONTROL_HATSWITCH 0x24004601 /* Hat switch */ +#define DIAXIS_3DCONTROL_ROTATEX 0x24034204 /* Rotate view forward or up / backward or down */ +#define DIAXIS_3DCONTROL_ROTATEY 0x2402C205 /* Rotate view clockwise / counterclockwise */ +#define DIAXIS_3DCONTROL_ROTATEZ 0x24024206 /* Rotate view left / right */ +#define DIBUTTON_3DCONTROL_DISPLAY 0x24004405 /* Show next on-screen display options */ +#define DIBUTTON_3DCONTROL_DEVICE 0x240044FE /* Show input device and controls */ +#define DIBUTTON_3DCONTROL_PAUSE 0x240044FC /* Start / Pause / Restart game */ + +/*--- CAD - 3D Navigation - Fly through + Controls for 3D modeling ---*/ +#define DIVIRTUAL_CAD_FLYBY 0x25000000 +#define DIAXIS_CADF_LATERAL 0x25008201 /* move view left / right */ +#define DIAXIS_CADF_MOVE 0x25010202 /* move view up / down */ +#define DIAXIS_CADF_INOUT 0x25018203 /* in / out */ +#define DIBUTTON_CADF_SELECT 0x25000401 /* Select Object */ +#define DIBUTTON_CADF_SPECIAL1 0x25000402 /* do first special operation */ +#define DIBUTTON_CADF_SPECIAL 0x25000403 /* Select special operation */ +#define DIBUTTON_CADF_SPECIAL2 0x25000404 /* do second special operation */ +#define DIBUTTON_CADF_MENU 0x250004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_CADF_HATSWITCH 0x25004601 /* Hat switch */ +#define DIAXIS_CADF_ROTATEX 0x25034204 /* Rotate view forward or up / backward or down */ +#define DIAXIS_CADF_ROTATEY 0x2502C205 /* Rotate view clockwise / counterclockwise */ +#define DIAXIS_CADF_ROTATEZ 0x25024206 /* Rotate view left / right */ +#define DIBUTTON_CADF_DISPLAY 0x25004405 /* shows next on-screen display options */ +#define DIBUTTON_CADF_DEVICE 0x250044FE /* Show input device and controls */ +#define DIBUTTON_CADF_PAUSE 0x250044FC /* Start / Pause / Restart game */ + +/*--- CAD - 3D Model Control + Controls for 3D modeling ---*/ +#define DIVIRTUAL_CAD_MODEL 0x26000000 +#define DIAXIS_CADM_LATERAL 0x26008201 /* move view left / right */ +#define DIAXIS_CADM_MOVE 0x26010202 /* move view up / down */ +#define DIAXIS_CADM_INOUT 0x26018203 /* in / out */ +#define DIBUTTON_CADM_SELECT 0x26000401 /* Select Object */ +#define DIBUTTON_CADM_SPECIAL1 0x26000402 /* do first special operation */ +#define DIBUTTON_CADM_SPECIAL 0x26000403 /* Select special operation */ +#define DIBUTTON_CADM_SPECIAL2 0x26000404 /* do second special operation */ +#define DIBUTTON_CADM_MENU 0x260004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIHATSWITCH_CADM_HATSWITCH 0x26004601 /* Hat switch */ +#define DIAXIS_CADM_ROTATEX 0x26034204 /* Rotate view forward or up / backward or down */ +#define DIAXIS_CADM_ROTATEY 0x2602C205 /* Rotate view clockwise / counterclockwise */ +#define DIAXIS_CADM_ROTATEZ 0x26024206 /* Rotate view left / right */ +#define DIBUTTON_CADM_DISPLAY 0x26004405 /* shows next on-screen display options */ +#define DIBUTTON_CADM_DEVICE 0x260044FE /* Show input device and controls */ +#define DIBUTTON_CADM_PAUSE 0x260044FC /* Start / Pause / Restart game */ + +/*--- Control - Media Equipment + Remote ---*/ +#define DIVIRTUAL_REMOTE_CONTROL 0x27000000 +#define DIAXIS_REMOTE_SLIDER 0x27050201 /* Slider for adjustment: volume / color / bass / etc */ +#define DIBUTTON_REMOTE_MUTE 0x27000401 /* Set volume on current device to zero */ +#define DIBUTTON_REMOTE_SELECT 0x27000402 /* Next/previous: channel/ track / chapter / picture / station */ +#define DIBUTTON_REMOTE_PLAY 0x27002403 /* Start or pause entertainment on current device */ +#define DIBUTTON_REMOTE_CUE 0x27002404 /* Move through current media */ +#define DIBUTTON_REMOTE_REVIEW 0x27002405 /* Move through current media */ +#define DIBUTTON_REMOTE_CHANGE 0x27002406 /* Select next device */ +#define DIBUTTON_REMOTE_RECORD 0x27002407 /* Start recording the current media */ +#define DIBUTTON_REMOTE_MENU 0x270004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIAXIS_REMOTE_SLIDER2 0x27054202 /* Slider for adjustment: volume */ +#define DIBUTTON_REMOTE_TV 0x27005C08 /* Select TV */ +#define DIBUTTON_REMOTE_CABLE 0x27005C09 /* Select cable box */ +#define DIBUTTON_REMOTE_CD 0x27005C0A /* Select CD player */ +#define DIBUTTON_REMOTE_VCR 0x27005C0B /* Select VCR */ +#define DIBUTTON_REMOTE_TUNER 0x27005C0C /* Select tuner */ +#define DIBUTTON_REMOTE_DVD 0x27005C0D /* Select DVD player */ +#define DIBUTTON_REMOTE_ADJUST 0x27005C0E /* Enter device adjustment menu */ +#define DIBUTTON_REMOTE_DIGIT0 0x2700540F /* Digit 0 */ +#define DIBUTTON_REMOTE_DIGIT1 0x27005410 /* Digit 1 */ +#define DIBUTTON_REMOTE_DIGIT2 0x27005411 /* Digit 2 */ +#define DIBUTTON_REMOTE_DIGIT3 0x27005412 /* Digit 3 */ +#define DIBUTTON_REMOTE_DIGIT4 0x27005413 /* Digit 4 */ +#define DIBUTTON_REMOTE_DIGIT5 0x27005414 /* Digit 5 */ +#define DIBUTTON_REMOTE_DIGIT6 0x27005415 /* Digit 6 */ +#define DIBUTTON_REMOTE_DIGIT7 0x27005416 /* Digit 7 */ +#define DIBUTTON_REMOTE_DIGIT8 0x27005417 /* Digit 8 */ +#define DIBUTTON_REMOTE_DIGIT9 0x27005418 /* Digit 9 */ +#define DIBUTTON_REMOTE_DEVICE 0x270044FE /* Show input device and controls */ +#define DIBUTTON_REMOTE_PAUSE 0x270044FC /* Start / Pause / Restart game */ + +/*--- Control- Web + Help or Browser ---*/ +#define DIVIRTUAL_BROWSER_CONTROL 0x28000000 +#define DIAXIS_BROWSER_LATERAL 0x28008201 /* Move on screen pointer */ +#define DIAXIS_BROWSER_MOVE 0x28010202 /* Move on screen pointer */ +#define DIBUTTON_BROWSER_SELECT 0x28000401 /* Select current item */ +#define DIAXIS_BROWSER_VIEW 0x28018203 /* Move view up/down */ +#define DIBUTTON_BROWSER_REFRESH 0x28000402 /* Refresh */ +#define DIBUTTON_BROWSER_MENU 0x280004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_BROWSER_SEARCH 0x28004403 /* Use search tool */ +#define DIBUTTON_BROWSER_STOP 0x28004404 /* Cease current update */ +#define DIBUTTON_BROWSER_HOME 0x28004405 /* Go directly to "home" location */ +#define DIBUTTON_BROWSER_FAVORITES 0x28004406 /* Mark current site as favorite */ +#define DIBUTTON_BROWSER_NEXT 0x28004407 /* Select Next page */ +#define DIBUTTON_BROWSER_PREVIOUS 0x28004408 /* Select Previous page */ +#define DIBUTTON_BROWSER_HISTORY 0x28004409 /* Show/Hide History */ +#define DIBUTTON_BROWSER_PRINT 0x2800440A /* Print current page */ +#define DIBUTTON_BROWSER_DEVICE 0x280044FE /* Show input device and controls */ +#define DIBUTTON_BROWSER_PAUSE 0x280044FC /* Start / Pause / Restart game */ + +/*--- Driving Simulator - Giant Walking Robot + Walking tank with weapons ---*/ +#define DIVIRTUAL_DRIVING_MECHA 0x29000000 +#define DIAXIS_MECHA_STEER 0x29008201 /* Turns mecha left/right */ +#define DIAXIS_MECHA_TORSO 0x29010202 /* Tilts torso forward/backward */ +#define DIAXIS_MECHA_ROTATE 0x29020203 /* Turns torso left/right */ +#define DIAXIS_MECHA_THROTTLE 0x29038204 /* Engine Speed */ +#define DIBUTTON_MECHA_FIRE 0x29000401 /* Fire */ +#define DIBUTTON_MECHA_WEAPONS 0x29000402 /* Select next weapon group */ +#define DIBUTTON_MECHA_TARGET 0x29000403 /* Select closest enemy available target */ +#define DIBUTTON_MECHA_REVERSE 0x29000404 /* Toggles throttle in/out of reverse */ +#define DIBUTTON_MECHA_ZOOM 0x29000405 /* Zoom in/out targeting reticule */ +#define DIBUTTON_MECHA_JUMP 0x29000406 /* Fires jump jets */ +#define DIBUTTON_MECHA_MENU 0x290004FD /* Show menu options */ +/*--- Priority 2 controls ---*/ + +#define DIBUTTON_MECHA_CENTER 0x29004407 /* Center torso to legs */ +#define DIHATSWITCH_MECHA_GLANCE 0x29004601 /* Look around */ +#define DIBUTTON_MECHA_VIEW 0x29004408 /* Cycle through view options */ +#define DIBUTTON_MECHA_FIRESECONDARY 0x29004409 /* Alternative fire button */ +#define DIBUTTON_MECHA_LEFT_LINK 0x2900C4E4 /* Fallback steer left button */ +#define DIBUTTON_MECHA_RIGHT_LINK 0x2900C4EC /* Fallback steer right button */ +#define DIBUTTON_MECHA_FORWARD_LINK 0x290144E0 /* Fallback tilt torso forward button */ +#define DIBUTTON_MECHA_BACK_LINK 0x290144E8 /* Fallback tilt toroso backward button */ +#define DIBUTTON_MECHA_ROTATE_LEFT_LINK 0x290244E4 /* Fallback rotate toroso right button */ +#define DIBUTTON_MECHA_ROTATE_RIGHT_LINK 0x290244EC /* Fallback rotate torso left button */ +#define DIBUTTON_MECHA_FASTER_LINK 0x2903C4E0 /* Fallback increase engine speed */ +#define DIBUTTON_MECHA_SLOWER_LINK 0x2903C4E8 /* Fallback decrease engine speed */ +#define DIBUTTON_MECHA_DEVICE 0x290044FE /* Show input device and controls */ +#define DIBUTTON_MECHA_PAUSE 0x290044FC /* Start / Pause / Restart game */ + +/* + * "ANY" semantics can be used as a last resort to get mappings for actions + * that match nothing in the chosen virtual genre. These semantics will be + * mapped at a lower priority that virtual genre semantics. Also, hardware + * vendors will not be able to provide sensible mappings for these unless + * they provide application specific mappings. + */ +#define DIAXIS_ANY_X_1 0xFF00C201 +#define DIAXIS_ANY_X_2 0xFF00C202 +#define DIAXIS_ANY_Y_1 0xFF014201 +#define DIAXIS_ANY_Y_2 0xFF014202 +#define DIAXIS_ANY_Z_1 0xFF01C201 +#define DIAXIS_ANY_Z_2 0xFF01C202 +#define DIAXIS_ANY_R_1 0xFF024201 +#define DIAXIS_ANY_R_2 0xFF024202 +#define DIAXIS_ANY_U_1 0xFF02C201 +#define DIAXIS_ANY_U_2 0xFF02C202 +#define DIAXIS_ANY_V_1 0xFF034201 +#define DIAXIS_ANY_V_2 0xFF034202 +#define DIAXIS_ANY_A_1 0xFF03C201 +#define DIAXIS_ANY_A_2 0xFF03C202 +#define DIAXIS_ANY_B_1 0xFF044201 +#define DIAXIS_ANY_B_2 0xFF044202 +#define DIAXIS_ANY_C_1 0xFF04C201 +#define DIAXIS_ANY_C_2 0xFF04C202 +#define DIAXIS_ANY_S_1 0xFF054201 +#define DIAXIS_ANY_S_2 0xFF054202 + +#define DIAXIS_ANY_1 0xFF004201 +#define DIAXIS_ANY_2 0xFF004202 +#define DIAXIS_ANY_3 0xFF004203 +#define DIAXIS_ANY_4 0xFF004204 + +#define DIPOV_ANY_1 0xFF004601 +#define DIPOV_ANY_2 0xFF004602 +#define DIPOV_ANY_3 0xFF004603 +#define DIPOV_ANY_4 0xFF004604 + +#define DIBUTTON_ANY(instance) ( 0xFF004400 | instance ) + + +#ifdef __cplusplus +}; +#endif + +#endif /* __DINPUT_INCLUDED__ */ + +/**************************************************************************** + * + * Definitions for non-IDirectInput (VJoyD) features defined more recently + * than the current sdk files + * + ****************************************************************************/ + +#ifdef _INC_MMSYSTEM +#ifndef MMNOJOY + +#ifndef __VJOYDX_INCLUDED__ +#define __VJOYDX_INCLUDED__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Flag to indicate that the dwReserved2 field of the JOYINFOEX structure + * contains mini-driver specific data to be passed by VJoyD to the mini- + * driver instead of doing a poll. + */ +#define JOY_PASSDRIVERDATA 0x10000000l + +/* + * Informs the joystick driver that the configuration has been changed + * and should be reloaded from the registery. + * dwFlags is reserved and should be set to zero + */ +WINMMAPI MMRESULT WINAPI joyConfigChanged( DWORD dwFlags ); + +#ifndef DIJ_RINGZERO +/* + * Invoke the joystick control panel directly, using the passed window handle + * as the parent of the dialog. This API is only supported for compatibility + * purposes; new applications should use the RunControlPanel method of a + * device interface for a game controller. + * The API is called by using the function pointer returned by + * GetProcAddress( hCPL, TEXT("ShowJoyCPL") ) where hCPL is a HMODULE returned + * by LoadLibrary( TEXT("joy.cpl") ). The typedef is provided to allow + * declaration and casting of an appropriately typed variable. + */ +void WINAPI ShowJoyCPL( HWND hWnd ); +typedef void (WINAPI* LPFNSHOWJOYCPL)( HWND hWnd ); +#endif /* DIJ_RINGZERO */ + + +/* + * Hardware Setting indicating that the device is a headtracker + */ +#define JOY_HWS_ISHEADTRACKER 0x02000000l + +/* + * Hardware Setting indicating that the VxD is used to replace + * the standard analog polling + */ +#define JOY_HWS_ISGAMEPORTDRIVER 0x04000000l + +/* + * Hardware Setting indicating that the driver needs a standard + * gameport in order to communicate with the device. + */ +#define JOY_HWS_ISANALOGPORTDRIVER 0x08000000l + +/* + * Hardware Setting indicating that VJoyD should not load this + * driver, it will be loaded externally and will register with + * VJoyD of it's own accord. + */ +#define JOY_HWS_AUTOLOAD 0x10000000l + +/* + * Hardware Setting indicating that the driver acquires any + * resources needed without needing a devnode through VJoyD. + */ +#define JOY_HWS_NODEVNODE 0x20000000l + + +/* + * Hardware Setting indicating that the device is a gameport bus + */ +#define JOY_HWS_ISGAMEPORTBUS 0x80000000l +#define JOY_HWS_GAMEPORTBUSBUSY 0x00000001l + +/* + * Usage Setting indicating that the settings are volatile and + * should be removed if still present on a reboot. + */ +#define JOY_US_VOLATILE 0x00000008L + +#ifdef __cplusplus +}; +#endif + +#endif /* __VJOYDX_INCLUDED__ */ + +#endif /* not MMNOJOY */ +#endif /* _INC_MMSYSTEM */ + +/**************************************************************************** + * + * Definitions for non-IDirectInput (VJoyD) features defined more recently + * than the current ddk files + * + ****************************************************************************/ + +#ifndef DIJ_RINGZERO + +#ifdef _INC_MMDDK +#ifndef MMNOJOYDEV + +#ifndef __VJOYDXD_INCLUDED__ +#define __VJOYDXD_INCLUDED__ +/* + * Poll type in which the do_other field of the JOYOEMPOLLDATA + * structure contains mini-driver specific data passed from an app. + */ +#define JOY_OEMPOLL_PASSDRIVERDATA 7 + +#endif /* __VJOYDXD_INCLUDED__ */ + +#endif /* not MMNOJOYDEV */ +#endif /* _INC_MMDDK */ + +#endif /* DIJ_RINGZERO */ + diff --git a/desmume/src/windows/directx/dinput8.lib b/src/windows/directx/dinput8.lib similarity index 100% rename from desmume/src/windows/directx/dinput8.lib rename to src/windows/directx/dinput8.lib diff --git a/desmume/src/windows/directx/dsound.h b/src/windows/directx/dsound.h similarity index 97% rename from desmume/src/windows/directx/dsound.h rename to src/windows/directx/dsound.h index 8020a660b..c088b63a3 100644 --- a/desmume/src/windows/directx/dsound.h +++ b/src/windows/directx/dsound.h @@ -1,2358 +1,2358 @@ -/*==========================================================================; - * - * Copyright (c) Microsoft Corporation. All rights reserved. - * - * File: dsound.h - * Content: DirectSound include file - * - **************************************************************************/ - -#define COM_NO_WINDOWS_H -#include -#include - -#ifndef DIRECTSOUND_VERSION -#define DIRECTSOUND_VERSION 0x0900 /* Version 9.0 */ -#endif - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -#ifndef __DSOUND_INCLUDED__ -#define __DSOUND_INCLUDED__ - -/* Type definitions shared with Direct3D */ - -#ifndef DX_SHARED_DEFINES - -typedef float D3DVALUE, *LPD3DVALUE; - -#ifndef D3DCOLOR_DEFINED -typedef DWORD D3DCOLOR; -#define D3DCOLOR_DEFINED -#endif - -#ifndef LPD3DCOLOR_DEFINED -typedef DWORD *LPD3DCOLOR; -#define LPD3DCOLOR_DEFINED -#endif - -#ifndef D3DVECTOR_DEFINED -typedef struct _D3DVECTOR { - float x; - float y; - float z; -} D3DVECTOR; -#define D3DVECTOR_DEFINED -#endif - -#ifndef LPD3DVECTOR_DEFINED -typedef D3DVECTOR *LPD3DVECTOR; -#define LPD3DVECTOR_DEFINED -#endif - -#define DX_SHARED_DEFINES -#endif // DX_SHARED_DEFINES - -#define _FACDS 0x878 /* DirectSound's facility code */ -#define MAKE_DSHRESULT(code) MAKE_HRESULT(1, _FACDS, code) - -// DirectSound Component GUID {47D4D946-62E8-11CF-93BC-444553540000} -DEFINE_GUID(CLSID_DirectSound, 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); - -// DirectSound 8.0 Component GUID {3901CC3F-84B5-4FA4-BA35-AA8172B8A09B} -DEFINE_GUID(CLSID_DirectSound8, 0x3901cc3f, 0x84b5, 0x4fa4, 0xba, 0x35, 0xaa, 0x81, 0x72, 0xb8, 0xa0, 0x9b); - -// DirectSound Capture Component GUID {B0210780-89CD-11D0-AF08-00A0C925CD16} -DEFINE_GUID(CLSID_DirectSoundCapture, 0xb0210780, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); - -// DirectSound 8.0 Capture Component GUID {E4BCAC13-7F99-4908-9A8E-74E3BF24B6E1} -DEFINE_GUID(CLSID_DirectSoundCapture8, 0xe4bcac13, 0x7f99, 0x4908, 0x9a, 0x8e, 0x74, 0xe3, 0xbf, 0x24, 0xb6, 0xe1); - -// DirectSound Full Duplex Component GUID {FEA4300C-7959-4147-B26A-2377B9E7A91D} -DEFINE_GUID(CLSID_DirectSoundFullDuplex, 0xfea4300c, 0x7959, 0x4147, 0xb2, 0x6a, 0x23, 0x77, 0xb9, 0xe7, 0xa9, 0x1d); - - -// DirectSound default playback device GUID {DEF00000-9C6D-47ED-AAF1-4DDA8F2B5C03} -DEFINE_GUID(DSDEVID_DefaultPlayback, 0xdef00000, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); - -// DirectSound default capture device GUID {DEF00001-9C6D-47ED-AAF1-4DDA8F2B5C03} -DEFINE_GUID(DSDEVID_DefaultCapture, 0xdef00001, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); - -// DirectSound default device for voice playback {DEF00002-9C6D-47ED-AAF1-4DDA8F2B5C03} -DEFINE_GUID(DSDEVID_DefaultVoicePlayback, 0xdef00002, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); - -// DirectSound default device for voice capture {DEF00003-9C6D-47ED-AAF1-4DDA8F2B5C03} -DEFINE_GUID(DSDEVID_DefaultVoiceCapture, 0xdef00003, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); - - -// -// Forward declarations for interfaces. -// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined -// - -#ifdef __cplusplus -struct IDirectSound; -struct IDirectSoundBuffer; -struct IDirectSound3DListener; -struct IDirectSound3DBuffer; -struct IDirectSoundCapture; -struct IDirectSoundCaptureBuffer; -struct IDirectSoundNotify; -#endif // __cplusplus - - -// -// DirectSound 8.0 interfaces. -// - -#if DIRECTSOUND_VERSION >= 0x0800 - -#ifdef __cplusplus -struct IDirectSound8; -struct IDirectSoundBuffer8; -struct IDirectSoundCaptureBuffer8; -struct IDirectSoundFXGargle; -struct IDirectSoundFXChorus; -struct IDirectSoundFXFlanger; -struct IDirectSoundFXEcho; -struct IDirectSoundFXDistortion; -struct IDirectSoundFXCompressor; -struct IDirectSoundFXParamEq; -struct IDirectSoundFXWavesReverb; -struct IDirectSoundFXI3DL2Reverb; -struct IDirectSoundCaptureFXAec; -struct IDirectSoundCaptureFXNoiseSuppress; -struct IDirectSoundFullDuplex; -#endif // __cplusplus - -// IDirectSound8, IDirectSoundBuffer8 and IDirectSoundCaptureBuffer8 are the -// only DirectSound 7.0 interfaces with changed functionality in version 8.0. -// The other level 8 interfaces as equivalent to their level 7 counterparts: - -#define IDirectSoundCapture8 IDirectSoundCapture -#define IDirectSound3DListener8 IDirectSound3DListener -#define IDirectSound3DBuffer8 IDirectSound3DBuffer -#define IDirectSoundNotify8 IDirectSoundNotify -#define IDirectSoundFXGargle8 IDirectSoundFXGargle -#define IDirectSoundFXChorus8 IDirectSoundFXChorus -#define IDirectSoundFXFlanger8 IDirectSoundFXFlanger -#define IDirectSoundFXEcho8 IDirectSoundFXEcho -#define IDirectSoundFXDistortion8 IDirectSoundFXDistortion -#define IDirectSoundFXCompressor8 IDirectSoundFXCompressor -#define IDirectSoundFXParamEq8 IDirectSoundFXParamEq -#define IDirectSoundFXWavesReverb8 IDirectSoundFXWavesReverb -#define IDirectSoundFXI3DL2Reverb8 IDirectSoundFXI3DL2Reverb -#define IDirectSoundCaptureFXAec8 IDirectSoundCaptureFXAec -#define IDirectSoundCaptureFXNoiseSuppress8 IDirectSoundCaptureFXNoiseSuppress -#define IDirectSoundFullDuplex8 IDirectSoundFullDuplex - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -typedef struct IDirectSound *LPDIRECTSOUND; -typedef struct IDirectSoundBuffer *LPDIRECTSOUNDBUFFER; -typedef struct IDirectSound3DListener *LPDIRECTSOUND3DLISTENER; -typedef struct IDirectSound3DBuffer *LPDIRECTSOUND3DBUFFER; -typedef struct IDirectSoundCapture *LPDIRECTSOUNDCAPTURE; -typedef struct IDirectSoundCaptureBuffer *LPDIRECTSOUNDCAPTUREBUFFER; -typedef struct IDirectSoundNotify *LPDIRECTSOUNDNOTIFY; - - -#if DIRECTSOUND_VERSION >= 0x0800 - -typedef struct IDirectSoundFXGargle *LPDIRECTSOUNDFXGARGLE; -typedef struct IDirectSoundFXChorus *LPDIRECTSOUNDFXCHORUS; -typedef struct IDirectSoundFXFlanger *LPDIRECTSOUNDFXFLANGER; -typedef struct IDirectSoundFXEcho *LPDIRECTSOUNDFXECHO; -typedef struct IDirectSoundFXDistortion *LPDIRECTSOUNDFXDISTORTION; -typedef struct IDirectSoundFXCompressor *LPDIRECTSOUNDFXCOMPRESSOR; -typedef struct IDirectSoundFXParamEq *LPDIRECTSOUNDFXPARAMEQ; -typedef struct IDirectSoundFXWavesReverb *LPDIRECTSOUNDFXWAVESREVERB; -typedef struct IDirectSoundFXI3DL2Reverb *LPDIRECTSOUNDFXI3DL2REVERB; -typedef struct IDirectSoundCaptureFXAec *LPDIRECTSOUNDCAPTUREFXAEC; -typedef struct IDirectSoundCaptureFXNoiseSuppress *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS; -typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX; - -typedef struct IDirectSound8 *LPDIRECTSOUND8; -typedef struct IDirectSoundBuffer8 *LPDIRECTSOUNDBUFFER8; -typedef struct IDirectSound3DListener8 *LPDIRECTSOUND3DLISTENER8; -typedef struct IDirectSound3DBuffer8 *LPDIRECTSOUND3DBUFFER8; -typedef struct IDirectSoundCapture8 *LPDIRECTSOUNDCAPTURE8; -typedef struct IDirectSoundCaptureBuffer8 *LPDIRECTSOUNDCAPTUREBUFFER8; -typedef struct IDirectSoundNotify8 *LPDIRECTSOUNDNOTIFY8; -typedef struct IDirectSoundFXGargle8 *LPDIRECTSOUNDFXGARGLE8; -typedef struct IDirectSoundFXChorus8 *LPDIRECTSOUNDFXCHORUS8; -typedef struct IDirectSoundFXFlanger8 *LPDIRECTSOUNDFXFLANGER8; -typedef struct IDirectSoundFXEcho8 *LPDIRECTSOUNDFXECHO8; -typedef struct IDirectSoundFXDistortion8 *LPDIRECTSOUNDFXDISTORTION8; -typedef struct IDirectSoundFXCompressor8 *LPDIRECTSOUNDFXCOMPRESSOR8; -typedef struct IDirectSoundFXParamEq8 *LPDIRECTSOUNDFXPARAMEQ8; -typedef struct IDirectSoundFXWavesReverb8 *LPDIRECTSOUNDFXWAVESREVERB8; -typedef struct IDirectSoundFXI3DL2Reverb8 *LPDIRECTSOUNDFXI3DL2REVERB8; -typedef struct IDirectSoundCaptureFXAec8 *LPDIRECTSOUNDCAPTUREFXAEC8; -typedef struct IDirectSoundCaptureFXNoiseSuppress8 *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS8; -typedef struct IDirectSoundFullDuplex8 *LPDIRECTSOUNDFULLDUPLEX8; - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// IID definitions for the unchanged DirectSound 8.0 interfaces -// - -#if DIRECTSOUND_VERSION >= 0x0800 - -#define IID_IDirectSoundCapture8 IID_IDirectSoundCapture -#define IID_IDirectSound3DListener8 IID_IDirectSound3DListener -#define IID_IDirectSound3DBuffer8 IID_IDirectSound3DBuffer -#define IID_IDirectSoundNotify8 IID_IDirectSoundNotify -#define IID_IDirectSoundFXGargle8 IID_IDirectSoundFXGargle -#define IID_IDirectSoundFXChorus8 IID_IDirectSoundFXChorus -#define IID_IDirectSoundFXFlanger8 IID_IDirectSoundFXFlanger -#define IID_IDirectSoundFXEcho8 IID_IDirectSoundFXEcho -#define IID_IDirectSoundFXDistortion8 IID_IDirectSoundFXDistortion -#define IID_IDirectSoundFXCompressor8 IID_IDirectSoundFXCompressor -#define IID_IDirectSoundFXParamEq8 IID_IDirectSoundFXParamEq -#define IID_IDirectSoundFXWavesReverb8 IID_IDirectSoundFXWavesReverb -#define IID_IDirectSoundFXI3DL2Reverb8 IID_IDirectSoundFXI3DL2Reverb -#define IID_IDirectSoundCaptureFXAec8 IID_IDirectSoundCaptureFXAec -#define IID_IDirectSoundCaptureFXNoiseSuppress8 IID_IDirectSoundCaptureFXNoiseSuppress -#define IID_IDirectSoundFullDuplex8 IID_IDirectSoundFullDuplex - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// Compatibility typedefs -// - -#ifndef _LPCWAVEFORMATEX_DEFINED -#define _LPCWAVEFORMATEX_DEFINED -typedef const WAVEFORMATEX *LPCWAVEFORMATEX; -#endif // _LPCWAVEFORMATEX_DEFINED - -#ifndef __LPCGUID_DEFINED__ -#define __LPCGUID_DEFINED__ -typedef const GUID *LPCGUID; -#endif // __LPCGUID_DEFINED__ - -typedef LPDIRECTSOUND *LPLPDIRECTSOUND; -typedef LPDIRECTSOUNDBUFFER *LPLPDIRECTSOUNDBUFFER; -typedef LPDIRECTSOUND3DLISTENER *LPLPDIRECTSOUND3DLISTENER; -typedef LPDIRECTSOUND3DBUFFER *LPLPDIRECTSOUND3DBUFFER; -typedef LPDIRECTSOUNDCAPTURE *LPLPDIRECTSOUNDCAPTURE; -typedef LPDIRECTSOUNDCAPTUREBUFFER *LPLPDIRECTSOUNDCAPTUREBUFFER; -typedef LPDIRECTSOUNDNOTIFY *LPLPDIRECTSOUNDNOTIFY; - -#if DIRECTSOUND_VERSION >= 0x0800 -typedef LPDIRECTSOUND8 *LPLPDIRECTSOUND8; -typedef LPDIRECTSOUNDBUFFER8 *LPLPDIRECTSOUNDBUFFER8; -typedef LPDIRECTSOUNDCAPTURE8 *LPLPDIRECTSOUNDCAPTURE8; -typedef LPDIRECTSOUNDCAPTUREBUFFER8 *LPLPDIRECTSOUNDCAPTUREBUFFER8; -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// Structures -// - -typedef struct _DSCAPS -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwMinSecondarySampleRate; - DWORD dwMaxSecondarySampleRate; - DWORD dwPrimaryBuffers; - DWORD dwMaxHwMixingAllBuffers; - DWORD dwMaxHwMixingStaticBuffers; - DWORD dwMaxHwMixingStreamingBuffers; - DWORD dwFreeHwMixingAllBuffers; - DWORD dwFreeHwMixingStaticBuffers; - DWORD dwFreeHwMixingStreamingBuffers; - DWORD dwMaxHw3DAllBuffers; - DWORD dwMaxHw3DStaticBuffers; - DWORD dwMaxHw3DStreamingBuffers; - DWORD dwFreeHw3DAllBuffers; - DWORD dwFreeHw3DStaticBuffers; - DWORD dwFreeHw3DStreamingBuffers; - DWORD dwTotalHwMemBytes; - DWORD dwFreeHwMemBytes; - DWORD dwMaxContigFreeHwMemBytes; - DWORD dwUnlockTransferRateHwBuffers; - DWORD dwPlayCpuOverheadSwBuffers; - DWORD dwReserved1; - DWORD dwReserved2; -} DSCAPS, *LPDSCAPS; - -typedef const DSCAPS *LPCDSCAPS; - -typedef struct _DSBCAPS -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwBufferBytes; - DWORD dwUnlockTransferRate; - DWORD dwPlayCpuOverhead; -} DSBCAPS, *LPDSBCAPS; - -typedef const DSBCAPS *LPCDSBCAPS; - -#if DIRECTSOUND_VERSION >= 0x0800 - - typedef struct _DSEFFECTDESC - { - DWORD dwSize; - DWORD dwFlags; - GUID guidDSFXClass; - DWORD_PTR dwReserved1; - DWORD_PTR dwReserved2; - } DSEFFECTDESC, *LPDSEFFECTDESC; - typedef const DSEFFECTDESC *LPCDSEFFECTDESC; - - #define DSFX_LOCHARDWARE 0x00000001 - #define DSFX_LOCSOFTWARE 0x00000002 - - enum - { - DSFXR_PRESENT, // 0 - DSFXR_LOCHARDWARE, // 1 - DSFXR_LOCSOFTWARE, // 2 - DSFXR_UNALLOCATED, // 3 - DSFXR_FAILED, // 4 - DSFXR_UNKNOWN, // 5 - DSFXR_SENDLOOP // 6 - }; - - typedef struct _DSCEFFECTDESC - { - DWORD dwSize; - DWORD dwFlags; - GUID guidDSCFXClass; - GUID guidDSCFXInstance; - DWORD dwReserved1; - DWORD dwReserved2; - } DSCEFFECTDESC, *LPDSCEFFECTDESC; - typedef const DSCEFFECTDESC *LPCDSCEFFECTDESC; - - #define DSCFX_LOCHARDWARE 0x00000001 - #define DSCFX_LOCSOFTWARE 0x00000002 - - #define DSCFXR_LOCHARDWARE 0x00000010 - #define DSCFXR_LOCSOFTWARE 0x00000020 - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -typedef struct _DSBUFFERDESC -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwBufferBytes; - DWORD dwReserved; - LPWAVEFORMATEX lpwfxFormat; -#if DIRECTSOUND_VERSION >= 0x0700 - GUID guid3DAlgorithm; -#endif -} DSBUFFERDESC, *LPDSBUFFERDESC; - -typedef const DSBUFFERDESC *LPCDSBUFFERDESC; - -// Older version of this structure: - -typedef struct _DSBUFFERDESC1 -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwBufferBytes; - DWORD dwReserved; - LPWAVEFORMATEX lpwfxFormat; -} DSBUFFERDESC1, *LPDSBUFFERDESC1; - -typedef const DSBUFFERDESC1 *LPCDSBUFFERDESC1; - -typedef struct _DS3DBUFFER -{ - DWORD dwSize; - D3DVECTOR vPosition; - D3DVECTOR vVelocity; - DWORD dwInsideConeAngle; - DWORD dwOutsideConeAngle; - D3DVECTOR vConeOrientation; - LONG lConeOutsideVolume; - D3DVALUE flMinDistance; - D3DVALUE flMaxDistance; - DWORD dwMode; -} DS3DBUFFER, *LPDS3DBUFFER; - -typedef const DS3DBUFFER *LPCDS3DBUFFER; - -typedef struct _DS3DLISTENER -{ - DWORD dwSize; - D3DVECTOR vPosition; - D3DVECTOR vVelocity; - D3DVECTOR vOrientFront; - D3DVECTOR vOrientTop; - D3DVALUE flDistanceFactor; - D3DVALUE flRolloffFactor; - D3DVALUE flDopplerFactor; -} DS3DLISTENER, *LPDS3DLISTENER; - -typedef const DS3DLISTENER *LPCDS3DLISTENER; - -typedef struct _DSCCAPS -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwFormats; - DWORD dwChannels; -} DSCCAPS, *LPDSCCAPS; - -typedef const DSCCAPS *LPCDSCCAPS; - -typedef struct _DSCBUFFERDESC1 -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwBufferBytes; - DWORD dwReserved; - LPWAVEFORMATEX lpwfxFormat; -} DSCBUFFERDESC1, *LPDSCBUFFERDESC1; - -typedef struct _DSCBUFFERDESC -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwBufferBytes; - DWORD dwReserved; - LPWAVEFORMATEX lpwfxFormat; -#if DIRECTSOUND_VERSION >= 0x0800 - DWORD dwFXCount; - LPDSCEFFECTDESC lpDSCFXDesc; -#endif -} DSCBUFFERDESC, *LPDSCBUFFERDESC; - -typedef const DSCBUFFERDESC *LPCDSCBUFFERDESC; - -typedef struct _DSCBCAPS -{ - DWORD dwSize; - DWORD dwFlags; - DWORD dwBufferBytes; - DWORD dwReserved; -} DSCBCAPS, *LPDSCBCAPS; - -typedef const DSCBCAPS *LPCDSCBCAPS; - -typedef struct _DSBPOSITIONNOTIFY -{ - DWORD dwOffset; - HANDLE hEventNotify; -} DSBPOSITIONNOTIFY, *LPDSBPOSITIONNOTIFY; - -typedef const DSBPOSITIONNOTIFY *LPCDSBPOSITIONNOTIFY; - -// -// DirectSound API -// - -typedef BOOL (CALLBACK *LPDSENUMCALLBACKA)(LPGUID, LPCSTR, LPCSTR, LPVOID); -typedef BOOL (CALLBACK *LPDSENUMCALLBACKW)(LPGUID, LPCWSTR, LPCWSTR, LPVOID); - -extern HRESULT WINAPI DirectSoundCreate(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter); -extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext); -extern HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext); - -extern HRESULT WINAPI DirectSoundCaptureCreate(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE *ppDSC, LPUNKNOWN pUnkOuter); -extern HRESULT WINAPI DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext); -extern HRESULT WINAPI DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext); - -#if DIRECTSOUND_VERSION >= 0x0800 -extern HRESULT WINAPI DirectSoundCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter); -extern HRESULT WINAPI DirectSoundCaptureCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE8 *ppDSC8, LPUNKNOWN pUnkOuter); -extern HRESULT WINAPI DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevice, LPCGUID pcGuidRenderDevice, - LPCDSCBUFFERDESC pcDSCBufferDesc, LPCDSBUFFERDESC pcDSBufferDesc, HWND hWnd, - DWORD dwLevel, LPDIRECTSOUNDFULLDUPLEX* ppDSFD, LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8, - LPDIRECTSOUNDBUFFER8 *ppDSBuffer8, LPUNKNOWN pUnkOuter); -#define DirectSoundFullDuplexCreate8 DirectSoundFullDuplexCreate - -extern HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest); -#endif // DIRECTSOUND_VERSION >= 0x0800 - -#ifdef UNICODE -#define LPDSENUMCALLBACK LPDSENUMCALLBACKW -#define DirectSoundEnumerate DirectSoundEnumerateW -#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateW -#else // UNICODE -#define LPDSENUMCALLBACK LPDSENUMCALLBACKA -#define DirectSoundEnumerate DirectSoundEnumerateA -#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateA -#endif // UNICODE - -// -// IUnknown -// - -#if !defined(__cplusplus) || defined(CINTERFACE) -#ifndef IUnknown_QueryInterface -#define IUnknown_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#endif // IUnknown_QueryInterface -#ifndef IUnknown_AddRef -#define IUnknown_AddRef(p) (p)->lpVtbl->AddRef(p) -#endif // IUnknown_AddRef -#ifndef IUnknown_Release -#define IUnknown_Release(p) (p)->lpVtbl->Release(p) -#endif // IUnknown_Release -#else // !defined(__cplusplus) || defined(CINTERFACE) -#ifndef IUnknown_QueryInterface -#define IUnknown_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#endif // IUnknown_QueryInterface -#ifndef IUnknown_AddRef -#define IUnknown_AddRef(p) (p)->AddRef() -#endif // IUnknown_AddRef -#ifndef IUnknown_Release -#define IUnknown_Release(p) (p)->Release() -#endif // IUnknown_Release -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#ifndef __IReferenceClock_INTERFACE_DEFINED__ -#define __IReferenceClock_INTERFACE_DEFINED__ - -typedef LONGLONG REFERENCE_TIME; -typedef REFERENCE_TIME *LPREFERENCE_TIME; - -DEFINE_GUID(IID_IReferenceClock, 0x56a86897, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70); - -#undef INTERFACE -#define INTERFACE IReferenceClock - -DECLARE_INTERFACE_(IReferenceClock, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IReferenceClock methods - STDMETHOD(GetTime) (THIS_ REFERENCE_TIME *pTime) PURE; - STDMETHOD(AdviseTime) (THIS_ REFERENCE_TIME rtBaseTime, REFERENCE_TIME rtStreamTime, - HANDLE hEvent, LPDWORD pdwAdviseCookie) PURE; - STDMETHOD(AdvisePeriodic) (THIS_ REFERENCE_TIME rtStartTime, REFERENCE_TIME rtPeriodTime, - HANDLE hSemaphore, LPDWORD pdwAdviseCookie) PURE; - STDMETHOD(Unadvise) (THIS_ DWORD dwAdviseCookie) PURE; -}; - -#endif // __IReferenceClock_INTERFACE_DEFINED__ - -#ifndef IReferenceClock_QueryInterface - -#define IReferenceClock_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IReferenceClock_AddRef(p) IUnknown_AddRef(p) -#define IReferenceClock_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IReferenceClock_GetTime(p,a) (p)->lpVtbl->GetTime(p,a) -#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->lpVtbl->AdviseTime(p,a,b,c,d) -#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->lpVtbl->AdvisePeriodic(p,a,b,c,d) -#define IReferenceClock_Unadvise(p,a) (p)->lpVtbl->Unadvise(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IReferenceClock_GetTime(p,a) (p)->GetTime(a) -#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->AdviseTime(a,b,c,d) -#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->AdvisePeriodic(a,b,c,d) -#define IReferenceClock_Unadvise(p,a) (p)->Unadvise(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#endif // IReferenceClock_QueryInterface - -// -// IDirectSound -// - -DEFINE_GUID(IID_IDirectSound, 0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); - -#undef INTERFACE -#define INTERFACE IDirectSound - -DECLARE_INTERFACE_(IDirectSound, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSound methods - STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE; - STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE; - STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE; - STDMETHOD(Compact) (THIS) PURE; - STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE; - STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE; - STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; -}; - -#define IDirectSound_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSound_AddRef(p) IUnknown_AddRef(p) -#define IDirectSound_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->lpVtbl->CreateSoundBuffer(p,a,b,c) -#define IDirectSound_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) -#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->lpVtbl->DuplicateSoundBuffer(p,a,b) -#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) -#define IDirectSound_Compact(p) (p)->lpVtbl->Compact(p) -#define IDirectSound_GetSpeakerConfig(p,a) (p)->lpVtbl->GetSpeakerConfig(p,a) -#define IDirectSound_SetSpeakerConfig(p,b) (p)->lpVtbl->SetSpeakerConfig(p,b) -#define IDirectSound_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->CreateSoundBuffer(a,b,c) -#define IDirectSound_GetCaps(p,a) (p)->GetCaps(a) -#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->DuplicateSoundBuffer(a,b) -#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) -#define IDirectSound_Compact(p) (p)->Compact() -#define IDirectSound_GetSpeakerConfig(p,a) (p)->GetSpeakerConfig(a) -#define IDirectSound_SetSpeakerConfig(p,b) (p)->SetSpeakerConfig(b) -#define IDirectSound_Initialize(p,a) (p)->Initialize(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#if DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSound8 -// - -DEFINE_GUID(IID_IDirectSound8, 0xC50A7E93, 0xF395, 0x4834, 0x9E, 0xF6, 0x7F, 0xA9, 0x9D, 0xE5, 0x09, 0x66); - -#undef INTERFACE -#define INTERFACE IDirectSound8 - -DECLARE_INTERFACE_(IDirectSound8, IDirectSound) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSound methods - STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE; - STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE; - STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE; - STDMETHOD(Compact) (THIS) PURE; - STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE; - STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE; - STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; - - // IDirectSound8 methods - STDMETHOD(VerifyCertification) (THIS_ LPDWORD pdwCertified) PURE; -}; - -#define IDirectSound8_QueryInterface(p,a,b) IDirectSound_QueryInterface(p,a,b) -#define IDirectSound8_AddRef(p) IDirectSound_AddRef(p) -#define IDirectSound8_Release(p) IDirectSound_Release(p) -#define IDirectSound8_CreateSoundBuffer(p,a,b,c) IDirectSound_CreateSoundBuffer(p,a,b,c) -#define IDirectSound8_GetCaps(p,a) IDirectSound_GetCaps(p,a) -#define IDirectSound8_DuplicateSoundBuffer(p,a,b) IDirectSound_DuplicateSoundBuffer(p,a,b) -#define IDirectSound8_SetCooperativeLevel(p,a,b) IDirectSound_SetCooperativeLevel(p,a,b) -#define IDirectSound8_Compact(p) IDirectSound_Compact(p) -#define IDirectSound8_GetSpeakerConfig(p,a) IDirectSound_GetSpeakerConfig(p,a) -#define IDirectSound8_SetSpeakerConfig(p,a) IDirectSound_SetSpeakerConfig(p,a) -#define IDirectSound8_Initialize(p,a) IDirectSound_Initialize(p,a) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound8_VerifyCertification(p,a) (p)->lpVtbl->VerifyCertification(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound8_VerifyCertification(p,a) (p)->VerifyCertification(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSoundBuffer -// - -DEFINE_GUID(IID_IDirectSoundBuffer, 0x279AFA85, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); - -#undef INTERFACE -#define INTERFACE IDirectSoundBuffer - -DECLARE_INTERFACE_(IDirectSoundBuffer, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundBuffer methods - STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE; - STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; - STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE; - STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE; - STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE; - STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE; - STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, - LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; - STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE; - STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE; - STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE; - STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE; - STDMETHOD(SetPan) (THIS_ LONG lPan) PURE; - STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE; - STDMETHOD(Stop) (THIS) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; - STDMETHOD(Restore) (THIS) PURE; -}; - -#define IDirectSoundBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundBuffer_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundBuffer_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) -#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b) -#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c) -#define IDirectSoundBuffer_GetVolume(p,a) (p)->lpVtbl->GetVolume(p,a) -#define IDirectSoundBuffer_GetPan(p,a) (p)->lpVtbl->GetPan(p,a) -#define IDirectSoundBuffer_GetFrequency(p,a) (p)->lpVtbl->GetFrequency(p,a) -#define IDirectSoundBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a) -#define IDirectSoundBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g) -#define IDirectSoundBuffer_Play(p,a,b,c) (p)->lpVtbl->Play(p,a,b,c) -#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->lpVtbl->SetCurrentPosition(p,a) -#define IDirectSoundBuffer_SetFormat(p,a) (p)->lpVtbl->SetFormat(p,a) -#define IDirectSoundBuffer_SetVolume(p,a) (p)->lpVtbl->SetVolume(p,a) -#define IDirectSoundBuffer_SetPan(p,a) (p)->lpVtbl->SetPan(p,a) -#define IDirectSoundBuffer_SetFrequency(p,a) (p)->lpVtbl->SetFrequency(p,a) -#define IDirectSoundBuffer_Stop(p) (p)->lpVtbl->Stop(p) -#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d) -#define IDirectSoundBuffer_Restore(p) (p)->lpVtbl->Restore(p) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundBuffer_GetCaps(p,a) (p)->GetCaps(a) -#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b) -#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c) -#define IDirectSoundBuffer_GetVolume(p,a) (p)->GetVolume(a) -#define IDirectSoundBuffer_GetPan(p,a) (p)->GetPan(a) -#define IDirectSoundBuffer_GetFrequency(p,a) (p)->GetFrequency(a) -#define IDirectSoundBuffer_GetStatus(p,a) (p)->GetStatus(a) -#define IDirectSoundBuffer_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g) -#define IDirectSoundBuffer_Play(p,a,b,c) (p)->Play(a,b,c) -#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->SetCurrentPosition(a) -#define IDirectSoundBuffer_SetFormat(p,a) (p)->SetFormat(a) -#define IDirectSoundBuffer_SetVolume(p,a) (p)->SetVolume(a) -#define IDirectSoundBuffer_SetPan(p,a) (p)->SetPan(a) -#define IDirectSoundBuffer_SetFrequency(p,a) (p)->SetFrequency(a) -#define IDirectSoundBuffer_Stop(p) (p)->Stop() -#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d) -#define IDirectSoundBuffer_Restore(p) (p)->Restore() -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#if DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSoundBuffer8 -// - -DEFINE_GUID(IID_IDirectSoundBuffer8, 0x6825a449, 0x7524, 0x4d82, 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e); - -#undef INTERFACE -#define INTERFACE IDirectSoundBuffer8 - -DECLARE_INTERFACE_(IDirectSoundBuffer8, IDirectSoundBuffer) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundBuffer methods - STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE; - STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; - STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE; - STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE; - STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE; - STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE; - STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, - LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; - STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE; - STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE; - STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE; - STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE; - STDMETHOD(SetPan) (THIS_ LONG lPan) PURE; - STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE; - STDMETHOD(Stop) (THIS) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; - STDMETHOD(Restore) (THIS) PURE; - - // IDirectSoundBuffer8 methods - STDMETHOD(SetFX) (THIS_ DWORD dwEffectsCount, LPDSEFFECTDESC pDSFXDesc, LPDWORD pdwResultCodes) PURE; - STDMETHOD(AcquireResources) (THIS_ DWORD dwFlags, DWORD dwEffectsCount, LPDWORD pdwResultCodes) PURE; - STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE; -}; - -// Special GUID meaning "select all objects" for use in GetObjectInPath() -DEFINE_GUID(GUID_All_Objects, 0xaa114de5, 0xc262, 0x4169, 0xa1, 0xc8, 0x23, 0xd6, 0x98, 0xcc, 0x73, 0xb5); - -#define IDirectSoundBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundBuffer8_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundBuffer8_Release(p) IUnknown_Release(p) - -#define IDirectSoundBuffer8_GetCaps(p,a) IDirectSoundBuffer_GetCaps(p,a) -#define IDirectSoundBuffer8_GetCurrentPosition(p,a,b) IDirectSoundBuffer_GetCurrentPosition(p,a,b) -#define IDirectSoundBuffer8_GetFormat(p,a,b,c) IDirectSoundBuffer_GetFormat(p,a,b,c) -#define IDirectSoundBuffer8_GetVolume(p,a) IDirectSoundBuffer_GetVolume(p,a) -#define IDirectSoundBuffer8_GetPan(p,a) IDirectSoundBuffer_GetPan(p,a) -#define IDirectSoundBuffer8_GetFrequency(p,a) IDirectSoundBuffer_GetFrequency(p,a) -#define IDirectSoundBuffer8_GetStatus(p,a) IDirectSoundBuffer_GetStatus(p,a) -#define IDirectSoundBuffer8_Initialize(p,a,b) IDirectSoundBuffer_Initialize(p,a,b) -#define IDirectSoundBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) -#define IDirectSoundBuffer8_Play(p,a,b,c) IDirectSoundBuffer_Play(p,a,b,c) -#define IDirectSoundBuffer8_SetCurrentPosition(p,a) IDirectSoundBuffer_SetCurrentPosition(p,a) -#define IDirectSoundBuffer8_SetFormat(p,a) IDirectSoundBuffer_SetFormat(p,a) -#define IDirectSoundBuffer8_SetVolume(p,a) IDirectSoundBuffer_SetVolume(p,a) -#define IDirectSoundBuffer8_SetPan(p,a) IDirectSoundBuffer_SetPan(p,a) -#define IDirectSoundBuffer8_SetFrequency(p,a) IDirectSoundBuffer_SetFrequency(p,a) -#define IDirectSoundBuffer8_Stop(p) IDirectSoundBuffer_Stop(p) -#define IDirectSoundBuffer8_Unlock(p,a,b,c,d) IDirectSoundBuffer_Unlock(p,a,b,c,d) -#define IDirectSoundBuffer8_Restore(p) IDirectSoundBuffer_Restore(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->lpVtbl->SetFX(p,a,b,c) -#define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->lpVtbl->AcquireResources(p,a,b,c) -#define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->SetFX(a,b,c) -#define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->AcquireResources(a,b,c) -#define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSound3DListener -// - -DEFINE_GUID(IID_IDirectSound3DListener, 0x279AFA84, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); - -#undef INTERFACE -#define INTERFACE IDirectSound3DListener - -DECLARE_INTERFACE_(IDirectSound3DListener, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSound3DListener methods - STDMETHOD(GetAllParameters) (THIS_ LPDS3DLISTENER pListener) PURE; - STDMETHOD(GetDistanceFactor) (THIS_ D3DVALUE* pflDistanceFactor) PURE; - STDMETHOD(GetDopplerFactor) (THIS_ D3DVALUE* pflDopplerFactor) PURE; - STDMETHOD(GetOrientation) (THIS_ D3DVECTOR* pvOrientFront, D3DVECTOR* pvOrientTop) PURE; - STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE; - STDMETHOD(GetRolloffFactor) (THIS_ D3DVALUE* pflRolloffFactor) PURE; - STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE; - STDMETHOD(SetAllParameters) (THIS_ LPCDS3DLISTENER pcListener, DWORD dwApply) PURE; - STDMETHOD(SetDistanceFactor) (THIS_ D3DVALUE flDistanceFactor, DWORD dwApply) PURE; - STDMETHOD(SetDopplerFactor) (THIS_ D3DVALUE flDopplerFactor, DWORD dwApply) PURE; - STDMETHOD(SetOrientation) (THIS_ D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront, - D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop, DWORD dwApply) PURE; - STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; - STDMETHOD(SetRolloffFactor) (THIS_ D3DVALUE flRolloffFactor, DWORD dwApply) PURE; - STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; - STDMETHOD(CommitDeferredSettings) (THIS) PURE; -}; - -#define IDirectSound3DListener_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSound3DListener_AddRef(p) IUnknown_AddRef(p) -#define IDirectSound3DListener_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound3DListener_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->lpVtbl->GetDistanceFactor(p,a) -#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->lpVtbl->GetDopplerFactor(p,a) -#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->lpVtbl->GetOrientation(p,a,b) -#define IDirectSound3DListener_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a) -#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->lpVtbl->GetRolloffFactor(p,a) -#define IDirectSound3DListener_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a) -#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b) -#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->lpVtbl->SetDistanceFactor(p,a,b) -#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->lpVtbl->SetDopplerFactor(p,a,b) -#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->lpVtbl->SetOrientation(p,a,b,c,d,e,f,g) -#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d) -#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->lpVtbl->SetRolloffFactor(p,a,b) -#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d) -#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->lpVtbl->CommitDeferredSettings(p) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound3DListener_GetAllParameters(p,a) (p)->GetAllParameters(a) -#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->GetDistanceFactor(a) -#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->GetDopplerFactor(a) -#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->GetOrientation(a,b) -#define IDirectSound3DListener_GetPosition(p,a) (p)->GetPosition(a) -#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->GetRolloffFactor(a) -#define IDirectSound3DListener_GetVelocity(p,a) (p)->GetVelocity(a) -#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b) -#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->SetDistanceFactor(a,b) -#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->SetDopplerFactor(a,b) -#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->SetOrientation(a,b,c,d,e,f,g) -#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d) -#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->SetRolloffFactor(a,b) -#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d) -#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->CommitDeferredSettings() -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSound3DBuffer -// - -DEFINE_GUID(IID_IDirectSound3DBuffer, 0x279AFA86, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); - -#undef INTERFACE -#define INTERFACE IDirectSound3DBuffer - -DECLARE_INTERFACE_(IDirectSound3DBuffer, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSound3DBuffer methods - STDMETHOD(GetAllParameters) (THIS_ LPDS3DBUFFER pDs3dBuffer) PURE; - STDMETHOD(GetConeAngles) (THIS_ LPDWORD pdwInsideConeAngle, LPDWORD pdwOutsideConeAngle) PURE; - STDMETHOD(GetConeOrientation) (THIS_ D3DVECTOR* pvOrientation) PURE; - STDMETHOD(GetConeOutsideVolume) (THIS_ LPLONG plConeOutsideVolume) PURE; - STDMETHOD(GetMaxDistance) (THIS_ D3DVALUE* pflMaxDistance) PURE; - STDMETHOD(GetMinDistance) (THIS_ D3DVALUE* pflMinDistance) PURE; - STDMETHOD(GetMode) (THIS_ LPDWORD pdwMode) PURE; - STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE; - STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE; - STDMETHOD(SetAllParameters) (THIS_ LPCDS3DBUFFER pcDs3dBuffer, DWORD dwApply) PURE; - STDMETHOD(SetConeAngles) (THIS_ DWORD dwInsideConeAngle, DWORD dwOutsideConeAngle, DWORD dwApply) PURE; - STDMETHOD(SetConeOrientation) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; - STDMETHOD(SetConeOutsideVolume) (THIS_ LONG lConeOutsideVolume, DWORD dwApply) PURE; - STDMETHOD(SetMaxDistance) (THIS_ D3DVALUE flMaxDistance, DWORD dwApply) PURE; - STDMETHOD(SetMinDistance) (THIS_ D3DVALUE flMinDistance, DWORD dwApply) PURE; - STDMETHOD(SetMode) (THIS_ DWORD dwMode, DWORD dwApply) PURE; - STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; - STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; -}; - -#define IDirectSound3DBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSound3DBuffer_AddRef(p) IUnknown_AddRef(p) -#define IDirectSound3DBuffer_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->lpVtbl->GetConeAngles(p,a,b) -#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->lpVtbl->GetConeOrientation(p,a) -#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->lpVtbl->GetConeOutsideVolume(p,a) -#define IDirectSound3DBuffer_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a) -#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->lpVtbl->GetMinDistance(p,a) -#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->lpVtbl->GetMaxDistance(p,a) -#define IDirectSound3DBuffer_GetMode(p,a) (p)->lpVtbl->GetMode(p,a) -#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a) -#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b) -#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->lpVtbl->SetConeAngles(p,a,b,c) -#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->lpVtbl->SetConeOrientation(p,a,b,c,d) -#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->lpVtbl->SetConeOutsideVolume(p,a,b) -#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d) -#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->lpVtbl->SetMinDistance(p,a,b) -#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->lpVtbl->SetMaxDistance(p,a,b) -#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->lpVtbl->SetMode(p,a,b) -#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->GetAllParameters(a) -#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->GetConeAngles(a,b) -#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->GetConeOrientation(a) -#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->GetConeOutsideVolume(a) -#define IDirectSound3DBuffer_GetPosition(p,a) (p)->GetPosition(a) -#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->GetMinDistance(a) -#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->GetMaxDistance(a) -#define IDirectSound3DBuffer_GetMode(p,a) (p)->GetMode(a) -#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->GetVelocity(a) -#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b) -#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->SetConeAngles(a,b,c) -#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->SetConeOrientation(a,b,c,d) -#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->SetConeOutsideVolume(a,b) -#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d) -#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->SetMinDistance(a,b) -#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->SetMaxDistance(a,b) -#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->SetMode(a,b) -#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundCapture -// - -DEFINE_GUID(IID_IDirectSoundCapture, 0xb0210781, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); - -#undef INTERFACE -#define INTERFACE IDirectSoundCapture - -DECLARE_INTERFACE_(IDirectSoundCapture, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundCapture methods - STDMETHOD(CreateCaptureBuffer) (THIS_ LPCDSCBUFFERDESC pcDSCBufferDesc, LPDIRECTSOUNDCAPTUREBUFFER *ppDSCBuffer, LPUNKNOWN pUnkOuter) PURE; - STDMETHOD(GetCaps) (THIS_ LPDSCCAPS pDSCCaps) PURE; - STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; -}; - -#define IDirectSoundCapture_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundCapture_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundCapture_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->lpVtbl->CreateCaptureBuffer(p,a,b,c) -#define IDirectSoundCapture_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) -#define IDirectSoundCapture_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->CreateCaptureBuffer(a,b,c) -#define IDirectSoundCapture_GetCaps(p,a) (p)->GetCaps(a) -#define IDirectSoundCapture_Initialize(p,a) (p)->Initialize(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundCaptureBuffer -// - -DEFINE_GUID(IID_IDirectSoundCaptureBuffer, 0xb0210782, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); - -#undef INTERFACE -#define INTERFACE IDirectSoundCaptureBuffer - -DECLARE_INTERFACE_(IDirectSoundCaptureBuffer, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundCaptureBuffer methods - STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE; - STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; - STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE; - STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, - LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; - STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(Stop) (THIS) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; -}; - -#define IDirectSoundCaptureBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundCaptureBuffer_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundCaptureBuffer_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) -#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b) -#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c) -#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a) -#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) -#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g) -#define IDirectSoundCaptureBuffer_Start(p,a) (p)->lpVtbl->Start(p,a) -#define IDirectSoundCaptureBuffer_Stop(p) (p)->lpVtbl->Stop(p) -#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->GetCaps(a) -#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b) -#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c) -#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->GetStatus(a) -#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->Initialize(a,b) -#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g) -#define IDirectSoundCaptureBuffer_Start(p,a) (p)->Start(a) -#define IDirectSoundCaptureBuffer_Stop(p) (p)->Stop() -#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - - -#if DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSoundCaptureBuffer8 -// - -DEFINE_GUID(IID_IDirectSoundCaptureBuffer8, 0x990df4, 0xdbb, 0x4872, 0x83, 0x3e, 0x6d, 0x30, 0x3e, 0x80, 0xae, 0xb6); - -#undef INTERFACE -#define INTERFACE IDirectSoundCaptureBuffer8 - -DECLARE_INTERFACE_(IDirectSoundCaptureBuffer8, IDirectSoundCaptureBuffer) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundCaptureBuffer methods - STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE; - STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE; - STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; - STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE; - STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, - LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; - STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(Stop) (THIS) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; - - // IDirectSoundCaptureBuffer8 methods - STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE; - STDMETHOD(GetFXStatus) (DWORD dwFXCount, LPDWORD pdwFXStatus) PURE; -}; - -#define IDirectSoundCaptureBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundCaptureBuffer8_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundCaptureBuffer8_Release(p) IUnknown_Release(p) - -#define IDirectSoundCaptureBuffer8_GetCaps(p,a) IDirectSoundCaptureBuffer_GetCaps(p,a) -#define IDirectSoundCaptureBuffer8_GetCurrentPosition(p,a,b) IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) -#define IDirectSoundCaptureBuffer8_GetFormat(p,a,b,c) IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) -#define IDirectSoundCaptureBuffer8_GetStatus(p,a) IDirectSoundCaptureBuffer_GetStatus(p,a) -#define IDirectSoundCaptureBuffer8_Initialize(p,a,b) IDirectSoundCaptureBuffer_Initialize(p,a,b) -#define IDirectSoundCaptureBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) -#define IDirectSoundCaptureBuffer8_Start(p,a) IDirectSoundCaptureBuffer_Start(p,a) -#define IDirectSoundCaptureBuffer8_Stop(p) IDirectSoundCaptureBuffer_Stop(p)) -#define IDirectSoundCaptureBuffer8_Unlock(p,a,b,c,d) IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d) -#define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->lpVtbl->GetFXStatus(p,a,b) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d) -#define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->GetFXStatus(a,b) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSoundNotify -// - -DEFINE_GUID(IID_IDirectSoundNotify, 0xb0210783, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); - -#undef INTERFACE -#define INTERFACE IDirectSoundNotify - -DECLARE_INTERFACE_(IDirectSoundNotify, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundNotify methods - STDMETHOD(SetNotificationPositions) (THIS_ DWORD dwPositionNotifies, LPCDSBPOSITIONNOTIFY pcPositionNotifies) PURE; -}; - -#define IDirectSoundNotify_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundNotify_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundNotify_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->lpVtbl->SetNotificationPositions(p,a,b) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->SetNotificationPositions(a,b) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IKsPropertySet -// - -#ifndef _IKsPropertySet_ -#define _IKsPropertySet_ - -#ifdef __cplusplus -// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined -struct IKsPropertySet; -#endif // __cplusplus - -typedef struct IKsPropertySet *LPKSPROPERTYSET; - -#define KSPROPERTY_SUPPORT_GET 0x00000001 -#define KSPROPERTY_SUPPORT_SET 0x00000002 - -DEFINE_GUID(IID_IKsPropertySet, 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93); - -#undef INTERFACE -#define INTERFACE IKsPropertySet - -DECLARE_INTERFACE_(IKsPropertySet, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IKsPropertySet methods - STDMETHOD(Get) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength, - LPVOID pPropertyData, ULONG ulDataLength, PULONG pulBytesReturned) PURE; - STDMETHOD(Set) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength, - LPVOID pPropertyData, ULONG ulDataLength) PURE; - STDMETHOD(QuerySupport) (THIS_ REFGUID rguidPropSet, ULONG ulId, PULONG pulTypeSupport) PURE; -}; - -#define IKsPropertySet_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IKsPropertySet_AddRef(p) IUnknown_AddRef(p) -#define IKsPropertySet_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->lpVtbl->Get(p,a,b,c,d,e,f,g) -#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->lpVtbl->Set(p,a,b,c,d,e,f) -#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->lpVtbl->QuerySupport(p,a,b,c) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->Get(a,b,c,d,e,f,g) -#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->Set(a,b,c,d,e,f) -#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->QuerySupport(a,b,c) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#endif // _IKsPropertySet_ - -#if DIRECTSOUND_VERSION >= 0x0800 - -// -// IDirectSoundFXGargle -// - -DEFINE_GUID(IID_IDirectSoundFXGargle, 0xd616f352, 0xd622, 0x11ce, 0xaa, 0xc5, 0x00, 0x20, 0xaf, 0x0b, 0x99, 0xa3); - -typedef struct _DSFXGargle -{ - DWORD dwRateHz; // Rate of modulation in hz - DWORD dwWaveShape; // DSFXGARGLE_WAVE_xxx -} DSFXGargle, *LPDSFXGargle; - -#define DSFXGARGLE_WAVE_TRIANGLE 0 -#define DSFXGARGLE_WAVE_SQUARE 1 - -typedef const DSFXGargle *LPCDSFXGargle; - -#define DSFXGARGLE_RATEHZ_MIN 1 -#define DSFXGARGLE_RATEHZ_MAX 1000 - -#undef INTERFACE -#define INTERFACE IDirectSoundFXGargle - -DECLARE_INTERFACE_(IDirectSoundFXGargle, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXGargle methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXGargle pcDsFxGargle) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXGargle pDsFxGargle) PURE; -}; - -#define IDirectSoundFXGargle_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXGargle_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXGargle_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXChorus -// - -DEFINE_GUID(IID_IDirectSoundFXChorus, 0x880842e3, 0x145f, 0x43e6, 0xa9, 0x34, 0xa7, 0x18, 0x06, 0xe5, 0x05, 0x47); - -typedef struct _DSFXChorus -{ - FLOAT fWetDryMix; - FLOAT fDepth; - FLOAT fFeedback; - FLOAT fFrequency; - LONG lWaveform; // LFO shape; DSFXCHORUS_WAVE_xxx - FLOAT fDelay; - LONG lPhase; -} DSFXChorus, *LPDSFXChorus; - -typedef const DSFXChorus *LPCDSFXChorus; - -#define DSFXCHORUS_WAVE_TRIANGLE 0 -#define DSFXCHORUS_WAVE_SIN 1 - -#define DSFXCHORUS_WETDRYMIX_MIN 0.0f -#define DSFXCHORUS_WETDRYMIX_MAX 100.0f -#define DSFXCHORUS_DEPTH_MIN 0.0f -#define DSFXCHORUS_DEPTH_MAX 100.0f -#define DSFXCHORUS_FEEDBACK_MIN -99.0f -#define DSFXCHORUS_FEEDBACK_MAX 99.0f -#define DSFXCHORUS_FREQUENCY_MIN 0.0f -#define DSFXCHORUS_FREQUENCY_MAX 10.0f -#define DSFXCHORUS_DELAY_MIN 0.0f -#define DSFXCHORUS_DELAY_MAX 20.0f -#define DSFXCHORUS_PHASE_MIN 0 -#define DSFXCHORUS_PHASE_MAX 4 - -#define DSFXCHORUS_PHASE_NEG_180 0 -#define DSFXCHORUS_PHASE_NEG_90 1 -#define DSFXCHORUS_PHASE_ZERO 2 -#define DSFXCHORUS_PHASE_90 3 -#define DSFXCHORUS_PHASE_180 4 - -#undef INTERFACE -#define INTERFACE IDirectSoundFXChorus - -DECLARE_INTERFACE_(IDirectSoundFXChorus, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXChorus methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXChorus pcDsFxChorus) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXChorus pDsFxChorus) PURE; -}; - -#define IDirectSoundFXChorus_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXChorus_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXChorus_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXFlanger -// - -DEFINE_GUID(IID_IDirectSoundFXFlanger, 0x903e9878, 0x2c92, 0x4072, 0x9b, 0x2c, 0xea, 0x68, 0xf5, 0x39, 0x67, 0x83); - -typedef struct _DSFXFlanger -{ - FLOAT fWetDryMix; - FLOAT fDepth; - FLOAT fFeedback; - FLOAT fFrequency; - LONG lWaveform; - FLOAT fDelay; - LONG lPhase; -} DSFXFlanger, *LPDSFXFlanger; - -typedef const DSFXFlanger *LPCDSFXFlanger; - -#define DSFXFLANGER_WAVE_TRIANGLE 0 -#define DSFXFLANGER_WAVE_SIN 1 - -#define DSFXFLANGER_WETDRYMIX_MIN 0.0f -#define DSFXFLANGER_WETDRYMIX_MAX 100.0f -#define DSFXFLANGER_FREQUENCY_MIN 0.0f -#define DSFXFLANGER_FREQUENCY_MAX 10.0f -#define DSFXFLANGER_DEPTH_MIN 0.0f -#define DSFXFLANGER_DEPTH_MAX 100.0f -#define DSFXFLANGER_PHASE_MIN 0 -#define DSFXFLANGER_PHASE_MAX 4 -#define DSFXFLANGER_FEEDBACK_MIN -99.0f -#define DSFXFLANGER_FEEDBACK_MAX 99.0f -#define DSFXFLANGER_DELAY_MIN 0.0f -#define DSFXFLANGER_DELAY_MAX 4.0f - -#define DSFXFLANGER_PHASE_NEG_180 0 -#define DSFXFLANGER_PHASE_NEG_90 1 -#define DSFXFLANGER_PHASE_ZERO 2 -#define DSFXFLANGER_PHASE_90 3 -#define DSFXFLANGER_PHASE_180 4 - -#undef INTERFACE -#define INTERFACE IDirectSoundFXFlanger - -DECLARE_INTERFACE_(IDirectSoundFXFlanger, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXFlanger methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXFlanger pcDsFxFlanger) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXFlanger pDsFxFlanger) PURE; -}; - -#define IDirectSoundFXFlanger_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXFlanger_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXFlanger_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXEcho -// - -DEFINE_GUID(IID_IDirectSoundFXEcho, 0x8bd28edf, 0x50db, 0x4e92, 0xa2, 0xbd, 0x44, 0x54, 0x88, 0xd1, 0xed, 0x42); - -typedef struct _DSFXEcho -{ - FLOAT fWetDryMix; - FLOAT fFeedback; - FLOAT fLeftDelay; - FLOAT fRightDelay; - LONG lPanDelay; -} DSFXEcho, *LPDSFXEcho; - -typedef const DSFXEcho *LPCDSFXEcho; - -#define DSFXECHO_WETDRYMIX_MIN 0.0f -#define DSFXECHO_WETDRYMIX_MAX 100.0f -#define DSFXECHO_FEEDBACK_MIN 0.0f -#define DSFXECHO_FEEDBACK_MAX 100.0f -#define DSFXECHO_LEFTDELAY_MIN 1.0f -#define DSFXECHO_LEFTDELAY_MAX 2000.0f -#define DSFXECHO_RIGHTDELAY_MIN 1.0f -#define DSFXECHO_RIGHTDELAY_MAX 2000.0f -#define DSFXECHO_PANDELAY_MIN 0 -#define DSFXECHO_PANDELAY_MAX 1 - -#undef INTERFACE -#define INTERFACE IDirectSoundFXEcho - -DECLARE_INTERFACE_(IDirectSoundFXEcho, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXEcho methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXEcho pcDsFxEcho) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXEcho pDsFxEcho) PURE; -}; - -#define IDirectSoundFXEcho_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXEcho_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXEcho_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXDistortion -// - -DEFINE_GUID(IID_IDirectSoundFXDistortion, 0x8ecf4326, 0x455f, 0x4d8b, 0xbd, 0xa9, 0x8d, 0x5d, 0x3e, 0x9e, 0x3e, 0x0b); - -typedef struct _DSFXDistortion -{ - FLOAT fGain; - FLOAT fEdge; - FLOAT fPostEQCenterFrequency; - FLOAT fPostEQBandwidth; - FLOAT fPreLowpassCutoff; -} DSFXDistortion, *LPDSFXDistortion; - -typedef const DSFXDistortion *LPCDSFXDistortion; - -#define DSFXDISTORTION_GAIN_MIN -60.0f -#define DSFXDISTORTION_GAIN_MAX 0.0f -#define DSFXDISTORTION_EDGE_MIN 0.0f -#define DSFXDISTORTION_EDGE_MAX 100.0f -#define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MIN 100.0f -#define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MAX 8000.0f -#define DSFXDISTORTION_POSTEQBANDWIDTH_MIN 100.0f -#define DSFXDISTORTION_POSTEQBANDWIDTH_MAX 8000.0f -#define DSFXDISTORTION_PRELOWPASSCUTOFF_MIN 100.0f -#define DSFXDISTORTION_PRELOWPASSCUTOFF_MAX 8000.0f - -#undef INTERFACE -#define INTERFACE IDirectSoundFXDistortion - -DECLARE_INTERFACE_(IDirectSoundFXDistortion, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXDistortion methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXDistortion pcDsFxDistortion) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXDistortion pDsFxDistortion) PURE; -}; - -#define IDirectSoundFXDistortion_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXDistortion_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXDistortion_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXCompressor -// - -DEFINE_GUID(IID_IDirectSoundFXCompressor, 0x4bbd1154, 0x62f6, 0x4e2c, 0xa1, 0x5c, 0xd3, 0xb6, 0xc4, 0x17, 0xf7, 0xa0); - -typedef struct _DSFXCompressor -{ - FLOAT fGain; - FLOAT fAttack; - FLOAT fRelease; - FLOAT fThreshold; - FLOAT fRatio; - FLOAT fPredelay; -} DSFXCompressor, *LPDSFXCompressor; - -typedef const DSFXCompressor *LPCDSFXCompressor; - -#define DSFXCOMPRESSOR_GAIN_MIN -60.0f -#define DSFXCOMPRESSOR_GAIN_MAX 60.0f -#define DSFXCOMPRESSOR_ATTACK_MIN 0.01f -#define DSFXCOMPRESSOR_ATTACK_MAX 500.0f -#define DSFXCOMPRESSOR_RELEASE_MIN 50.0f -#define DSFXCOMPRESSOR_RELEASE_MAX 3000.0f -#define DSFXCOMPRESSOR_THRESHOLD_MIN -60.0f -#define DSFXCOMPRESSOR_THRESHOLD_MAX 0.0f -#define DSFXCOMPRESSOR_RATIO_MIN 1.0f -#define DSFXCOMPRESSOR_RATIO_MAX 100.0f -#define DSFXCOMPRESSOR_PREDELAY_MIN 0.0f -#define DSFXCOMPRESSOR_PREDELAY_MAX 4.0f - -#undef INTERFACE -#define INTERFACE IDirectSoundFXCompressor - -DECLARE_INTERFACE_(IDirectSoundFXCompressor, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXCompressor methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXCompressor pcDsFxCompressor) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXCompressor pDsFxCompressor) PURE; -}; - -#define IDirectSoundFXCompressor_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXCompressor_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXCompressor_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXParamEq -// - -DEFINE_GUID(IID_IDirectSoundFXParamEq, 0xc03ca9fe, 0xfe90, 0x4204, 0x80, 0x78, 0x82, 0x33, 0x4c, 0xd1, 0x77, 0xda); - -typedef struct _DSFXParamEq -{ - FLOAT fCenter; - FLOAT fBandwidth; - FLOAT fGain; -} DSFXParamEq, *LPDSFXParamEq; - -typedef const DSFXParamEq *LPCDSFXParamEq; - -#define DSFXPARAMEQ_CENTER_MIN 80.0f -#define DSFXPARAMEQ_CENTER_MAX 16000.0f -#define DSFXPARAMEQ_BANDWIDTH_MIN 1.0f -#define DSFXPARAMEQ_BANDWIDTH_MAX 36.0f -#define DSFXPARAMEQ_GAIN_MIN -15.0f -#define DSFXPARAMEQ_GAIN_MAX 15.0f - -#undef INTERFACE -#define INTERFACE IDirectSoundFXParamEq - -DECLARE_INTERFACE_(IDirectSoundFXParamEq, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXParamEq methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXParamEq pcDsFxParamEq) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXParamEq pDsFxParamEq) PURE; -}; - -#define IDirectSoundFXParamEq_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXParamEq_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXParamEq_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXI3DL2Reverb -// - -DEFINE_GUID(IID_IDirectSoundFXI3DL2Reverb, 0x4b166a6a, 0x0d66, 0x43f3, 0x80, 0xe3, 0xee, 0x62, 0x80, 0xde, 0xe1, 0xa4); - -typedef struct _DSFXI3DL2Reverb -{ - LONG lRoom; // [-10000, 0] default: -1000 mB - LONG lRoomHF; // [-10000, 0] default: 0 mB - FLOAT flRoomRolloffFactor; // [0.0, 10.0] default: 0.0 - FLOAT flDecayTime; // [0.1, 20.0] default: 1.49s - FLOAT flDecayHFRatio; // [0.1, 2.0] default: 0.83 - LONG lReflections; // [-10000, 1000] default: -2602 mB - FLOAT flReflectionsDelay; // [0.0, 0.3] default: 0.007 s - LONG lReverb; // [-10000, 2000] default: 200 mB - FLOAT flReverbDelay; // [0.0, 0.1] default: 0.011 s - FLOAT flDiffusion; // [0.0, 100.0] default: 100.0 % - FLOAT flDensity; // [0.0, 100.0] default: 100.0 % - FLOAT flHFReference; // [20.0, 20000.0] default: 5000.0 Hz -} DSFXI3DL2Reverb, *LPDSFXI3DL2Reverb; - -typedef const DSFXI3DL2Reverb *LPCDSFXI3DL2Reverb; - -#define DSFX_I3DL2REVERB_ROOM_MIN (-10000) -#define DSFX_I3DL2REVERB_ROOM_MAX 0 -#define DSFX_I3DL2REVERB_ROOM_DEFAULT (-1000) - -#define DSFX_I3DL2REVERB_ROOMHF_MIN (-10000) -#define DSFX_I3DL2REVERB_ROOMHF_MAX 0 -#define DSFX_I3DL2REVERB_ROOMHF_DEFAULT (-100) - -#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MIN 0.0f -#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MAX 10.0f -#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_DEFAULT 0.0f - -#define DSFX_I3DL2REVERB_DECAYTIME_MIN 0.1f -#define DSFX_I3DL2REVERB_DECAYTIME_MAX 20.0f -#define DSFX_I3DL2REVERB_DECAYTIME_DEFAULT 1.49f - -#define DSFX_I3DL2REVERB_DECAYHFRATIO_MIN 0.1f -#define DSFX_I3DL2REVERB_DECAYHFRATIO_MAX 2.0f -#define DSFX_I3DL2REVERB_DECAYHFRATIO_DEFAULT 0.83f - -#define DSFX_I3DL2REVERB_REFLECTIONS_MIN (-10000) -#define DSFX_I3DL2REVERB_REFLECTIONS_MAX 1000 -#define DSFX_I3DL2REVERB_REFLECTIONS_DEFAULT (-2602) - -#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MIN 0.0f -#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MAX 0.3f -#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_DEFAULT 0.007f - -#define DSFX_I3DL2REVERB_REVERB_MIN (-10000) -#define DSFX_I3DL2REVERB_REVERB_MAX 2000 -#define DSFX_I3DL2REVERB_REVERB_DEFAULT (200) - -#define DSFX_I3DL2REVERB_REVERBDELAY_MIN 0.0f -#define DSFX_I3DL2REVERB_REVERBDELAY_MAX 0.1f -#define DSFX_I3DL2REVERB_REVERBDELAY_DEFAULT 0.011f - -#define DSFX_I3DL2REVERB_DIFFUSION_MIN 0.0f -#define DSFX_I3DL2REVERB_DIFFUSION_MAX 100.0f -#define DSFX_I3DL2REVERB_DIFFUSION_DEFAULT 100.0f - -#define DSFX_I3DL2REVERB_DENSITY_MIN 0.0f -#define DSFX_I3DL2REVERB_DENSITY_MAX 100.0f -#define DSFX_I3DL2REVERB_DENSITY_DEFAULT 100.0f - -#define DSFX_I3DL2REVERB_HFREFERENCE_MIN 20.0f -#define DSFX_I3DL2REVERB_HFREFERENCE_MAX 20000.0f -#define DSFX_I3DL2REVERB_HFREFERENCE_DEFAULT 5000.0f - -#define DSFX_I3DL2REVERB_QUALITY_MIN 0 -#define DSFX_I3DL2REVERB_QUALITY_MAX 3 -#define DSFX_I3DL2REVERB_QUALITY_DEFAULT 2 - -#undef INTERFACE -#define INTERFACE IDirectSoundFXI3DL2Reverb - -DECLARE_INTERFACE_(IDirectSoundFXI3DL2Reverb, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXI3DL2Reverb methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXI3DL2Reverb pcDsFxI3DL2Reverb) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXI3DL2Reverb pDsFxI3DL2Reverb) PURE; - STDMETHOD(SetPreset) (THIS_ DWORD dwPreset) PURE; - STDMETHOD(GetPreset) (THIS_ LPDWORD pdwPreset) PURE; - STDMETHOD(SetQuality) (THIS_ LONG lQuality) PURE; - STDMETHOD(GetQuality) (THIS_ LONG *plQuality) PURE; -}; - -#define IDirectSoundFXI3DL2Reverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXI3DL2Reverb_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXI3DL2Reverb_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->lpVtbl->SetPreset(p,a) -#define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->lpVtbl->GetPreset(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->GetAllParameters(a) -#define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->SetPreset(a) -#define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->GetPreset(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundFXWavesReverb -// - -DEFINE_GUID(IID_IDirectSoundFXWavesReverb,0x46858c3a,0x0dc6,0x45e3,0xb7,0x60,0xd4,0xee,0xf1,0x6c,0xb3,0x25); - -typedef struct _DSFXWavesReverb -{ - FLOAT fInGain; // [-96.0,0.0] default: 0.0 dB - FLOAT fReverbMix; // [-96.0,0.0] default: 0.0 db - FLOAT fReverbTime; // [0.001,3000.0] default: 1000.0 ms - FLOAT fHighFreqRTRatio; // [0.001,0.999] default: 0.001 -} DSFXWavesReverb, *LPDSFXWavesReverb; - -typedef const DSFXWavesReverb *LPCDSFXWavesReverb; - -#define DSFX_WAVESREVERB_INGAIN_MIN -96.0f -#define DSFX_WAVESREVERB_INGAIN_MAX 0.0f -#define DSFX_WAVESREVERB_INGAIN_DEFAULT 0.0f -#define DSFX_WAVESREVERB_REVERBMIX_MIN -96.0f -#define DSFX_WAVESREVERB_REVERBMIX_MAX 0.0f -#define DSFX_WAVESREVERB_REVERBMIX_DEFAULT 0.0f -#define DSFX_WAVESREVERB_REVERBTIME_MIN 0.001f -#define DSFX_WAVESREVERB_REVERBTIME_MAX 3000.0f -#define DSFX_WAVESREVERB_REVERBTIME_DEFAULT 1000.0f -#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MIN 0.001f -#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MAX 0.999f -#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_DEFAULT 0.001f - -#undef INTERFACE -#define INTERFACE IDirectSoundFXWavesReverb - -DECLARE_INTERFACE_(IDirectSoundFXWavesReverb, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFXWavesReverb methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSFXWavesReverb pcDsFxWavesReverb) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSFXWavesReverb pDsFxWavesReverb) PURE; -}; - -#define IDirectSoundFXWavesReverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFXWavesReverb_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFXWavesReverb_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -// -// IDirectSoundCaptureFXAec -// - -DEFINE_GUID(IID_IDirectSoundCaptureFXAec, 0xad74143d, 0x903d, 0x4ab7, 0x80, 0x66, 0x28, 0xd3, 0x63, 0x03, 0x6d, 0x65); - -typedef struct _DSCFXAec -{ - BOOL fEnable; - BOOL fNoiseFill; - DWORD dwMode; -} DSCFXAec, *LPDSCFXAec; - -typedef const DSCFXAec *LPCDSCFXAec; - -// These match the AEC_MODE_* constants in the DDK's ksmedia.h file -#define DSCFX_AEC_MODE_PASS_THROUGH 0x0 -#define DSCFX_AEC_MODE_HALF_DUPLEX 0x1 -#define DSCFX_AEC_MODE_FULL_DUPLEX 0x2 - -// These match the AEC_STATUS_* constants in ksmedia.h -#define DSCFX_AEC_STATUS_HISTORY_UNINITIALIZED 0x0 -#define DSCFX_AEC_STATUS_HISTORY_CONTINUOUSLY_CONVERGED 0x1 -#define DSCFX_AEC_STATUS_HISTORY_PREVIOUSLY_DIVERGED 0x2 -#define DSCFX_AEC_STATUS_CURRENTLY_CONVERGED 0x8 - -#undef INTERFACE -#define INTERFACE IDirectSoundCaptureFXAec - -DECLARE_INTERFACE_(IDirectSoundCaptureFXAec, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundCaptureFXAec methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXAec pDscFxAec) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSCFXAec pDscFxAec) PURE; - STDMETHOD(GetStatus) (THIS_ PDWORD pdwStatus) PURE; - STDMETHOD(Reset) (THIS) PURE; -}; - -#define IDirectSoundCaptureFXAec_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundCaptureFXAec_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundCaptureFXAec_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - - -// -// IDirectSoundCaptureFXNoiseSuppress -// - -DEFINE_GUID(IID_IDirectSoundCaptureFXNoiseSuppress, 0xed311e41, 0xfbae, 0x4175, 0x96, 0x25, 0xcd, 0x8, 0x54, 0xf6, 0x93, 0xca); - -typedef struct _DSCFXNoiseSuppress -{ - BOOL fEnable; -} DSCFXNoiseSuppress, *LPDSCFXNoiseSuppress; - -typedef const DSCFXNoiseSuppress *LPCDSCFXNoiseSuppress; - -#undef INTERFACE -#define INTERFACE IDirectSoundCaptureFXNoiseSuppress - -DECLARE_INTERFACE_(IDirectSoundCaptureFXNoiseSuppress, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundCaptureFXNoiseSuppress methods - STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXNoiseSuppress pcDscFxNoiseSuppress) PURE; - STDMETHOD(GetAllParameters) (THIS_ LPDSCFXNoiseSuppress pDscFxNoiseSuppress) PURE; - STDMETHOD(Reset) (THIS) PURE; -}; - -#define IDirectSoundCaptureFXNoiseSuppress_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundCaptureFXNoiseSuppress_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundCaptureFXNoiseSuppress_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) -#define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->SetAllParameters(a) -#define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->GetAllParameters(a) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - - -// -// IDirectSoundFullDuplex -// - -#ifndef _IDirectSoundFullDuplex_ -#define _IDirectSoundFullDuplex_ - -#ifdef __cplusplus -// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined -struct IDirectSoundFullDuplex; -#endif // __cplusplus - -typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX; - -DEFINE_GUID(IID_IDirectSoundFullDuplex, 0xedcb4c7a, 0xdaab, 0x4216, 0xa4, 0x2e, 0x6c, 0x50, 0x59, 0x6d, 0xdc, 0x1d); - -#undef INTERFACE -#define INTERFACE IDirectSoundFullDuplex - -DECLARE_INTERFACE_(IDirectSoundFullDuplex, IUnknown) -{ - // IUnknown methods - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG,AddRef) (THIS) PURE; - STDMETHOD_(ULONG,Release) (THIS) PURE; - - // IDirectSoundFullDuplex methods - STDMETHOD(Initialize) (THIS_ LPCGUID pCaptureGuid, LPCGUID pRenderGuid, LPCDSCBUFFERDESC lpDscBufferDesc, LPCDSBUFFERDESC lpDsBufferDesc, HWND hWnd, DWORD dwLevel, LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8, LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8) PURE; -}; - -#define IDirectSoundFullDuplex_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) -#define IDirectSoundFullDuplex_AddRef(p) IUnknown_AddRef(p) -#define IDirectSoundFullDuplex_Release(p) IUnknown_Release(p) - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->Initialize(p,a,b,c,d,e,f,g,h) -#else // !defined(__cplusplus) || defined(CINTERFACE) -#define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->Initialize(a,b,c,d,e,f,g,h) -#endif // !defined(__cplusplus) || defined(CINTERFACE) - -#endif // _IDirectSoundFullDuplex_ - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -// -// Return Codes -// - -// The function completed successfully -#define DS_OK S_OK - -// The call succeeded, but we had to substitute the 3D algorithm -#define DS_NO_VIRTUALIZATION MAKE_HRESULT(0, _FACDS, 10) - -// The call failed because resources (such as a priority level) -// were already being used by another caller -#define DSERR_ALLOCATED MAKE_DSHRESULT(10) - -// The control (vol, pan, etc.) requested by the caller is not available -#define DSERR_CONTROLUNAVAIL MAKE_DSHRESULT(30) - -// An invalid parameter was passed to the returning function -#define DSERR_INVALIDPARAM E_INVALIDARG - -// This call is not valid for the current state of this object -#define DSERR_INVALIDCALL MAKE_DSHRESULT(50) - -// An undetermined error occurred inside the DirectSound subsystem -#define DSERR_GENERIC E_FAIL - -// The caller does not have the priority level required for the function to -// succeed -#define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70) - -// Not enough free memory is available to complete the operation -#define DSERR_OUTOFMEMORY E_OUTOFMEMORY - -// The specified WAVE format is not supported -#define DSERR_BADFORMAT MAKE_DSHRESULT(100) - -// The function called is not supported at this time -#define DSERR_UNSUPPORTED E_NOTIMPL - -// No sound driver is available for use -#define DSERR_NODRIVER MAKE_DSHRESULT(120) - -// This object is already initialized -#define DSERR_ALREADYINITIALIZED MAKE_DSHRESULT(130) - -// This object does not support aggregation -#define DSERR_NOAGGREGATION CLASS_E_NOAGGREGATION - -// The buffer memory has been lost, and must be restored -#define DSERR_BUFFERLOST MAKE_DSHRESULT(150) - -// Another app has a higher priority level, preventing this call from -// succeeding -#define DSERR_OTHERAPPHASPRIO MAKE_DSHRESULT(160) - -// This object has not been initialized -#define DSERR_UNINITIALIZED MAKE_DSHRESULT(170) - -// The requested COM interface is not available -#define DSERR_NOINTERFACE E_NOINTERFACE - -// Access is denied -#define DSERR_ACCESSDENIED E_ACCESSDENIED - -// Tried to create a DSBCAPS_CTRLFX buffer shorter than DSBSIZE_FX_MIN milliseconds -#define DSERR_BUFFERTOOSMALL MAKE_DSHRESULT(180) - -// Attempt to use DirectSound 8 functionality on an older DirectSound object -#define DSERR_DS8_REQUIRED MAKE_DSHRESULT(190) - -// A circular loop of send effects was detected -#define DSERR_SENDLOOP MAKE_DSHRESULT(200) - -// The GUID specified in an audiopath file does not match a valid MIXIN buffer -#define DSERR_BADSENDBUFFERGUID MAKE_DSHRESULT(210) - -// The object requested was not found (numerically equal to DMUS_E_NOT_FOUND) -#define DSERR_OBJECTNOTFOUND MAKE_DSHRESULT(4449) - -// The effects requested could not be found on the system, or they were found -// but in the wrong order, or in the wrong hardware/software locations. -#define DSERR_FXUNAVAILABLE MAKE_DSHRESULT(220) - -// -// Flags -// - -#define DSCAPS_PRIMARYMONO 0x00000001 -#define DSCAPS_PRIMARYSTEREO 0x00000002 -#define DSCAPS_PRIMARY8BIT 0x00000004 -#define DSCAPS_PRIMARY16BIT 0x00000008 -#define DSCAPS_CONTINUOUSRATE 0x00000010 -#define DSCAPS_EMULDRIVER 0x00000020 -#define DSCAPS_CERTIFIED 0x00000040 -#define DSCAPS_SECONDARYMONO 0x00000100 -#define DSCAPS_SECONDARYSTEREO 0x00000200 -#define DSCAPS_SECONDARY8BIT 0x00000400 -#define DSCAPS_SECONDARY16BIT 0x00000800 - -#define DSSCL_NORMAL 0x00000001 -#define DSSCL_PRIORITY 0x00000002 -#define DSSCL_EXCLUSIVE 0x00000003 -#define DSSCL_WRITEPRIMARY 0x00000004 - -#define DSSPEAKER_DIRECTOUT 0x00000000 -#define DSSPEAKER_HEADPHONE 0x00000001 -#define DSSPEAKER_MONO 0x00000002 -#define DSSPEAKER_QUAD 0x00000003 -#define DSSPEAKER_STEREO 0x00000004 -#define DSSPEAKER_SURROUND 0x00000005 -#define DSSPEAKER_5POINT1 0x00000006 -#define DSSPEAKER_7POINT1 0x00000007 - -#define DSSPEAKER_GEOMETRY_MIN 0x00000005 // 5 degrees -#define DSSPEAKER_GEOMETRY_NARROW 0x0000000A // 10 degrees -#define DSSPEAKER_GEOMETRY_WIDE 0x00000014 // 20 degrees -#define DSSPEAKER_GEOMETRY_MAX 0x000000B4 // 180 degrees - -#define DSSPEAKER_COMBINED(c, g) ((DWORD)(((BYTE)(c)) | ((DWORD)((BYTE)(g))) << 16)) -#define DSSPEAKER_CONFIG(a) ((BYTE)(a)) -#define DSSPEAKER_GEOMETRY(a) ((BYTE)(((DWORD)(a) >> 16) & 0x00FF)) - -#define DSBCAPS_PRIMARYBUFFER 0x00000001 -#define DSBCAPS_STATIC 0x00000002 -#define DSBCAPS_LOCHARDWARE 0x00000004 -#define DSBCAPS_LOCSOFTWARE 0x00000008 -#define DSBCAPS_CTRL3D 0x00000010 -#define DSBCAPS_CTRLFREQUENCY 0x00000020 -#define DSBCAPS_CTRLPAN 0x00000040 -#define DSBCAPS_CTRLVOLUME 0x00000080 -#define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100 -#define DSBCAPS_CTRLFX 0x00000200 -#define DSBCAPS_STICKYFOCUS 0x00004000 -#define DSBCAPS_GLOBALFOCUS 0x00008000 -#define DSBCAPS_GETCURRENTPOSITION2 0x00010000 -#define DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000 -#define DSBCAPS_LOCDEFER 0x00040000 - -#define DSBPLAY_LOOPING 0x00000001 -#define DSBPLAY_LOCHARDWARE 0x00000002 -#define DSBPLAY_LOCSOFTWARE 0x00000004 -#define DSBPLAY_TERMINATEBY_TIME 0x00000008 -#define DSBPLAY_TERMINATEBY_DISTANCE 0x000000010 -#define DSBPLAY_TERMINATEBY_PRIORITY 0x000000020 - -#define DSBSTATUS_PLAYING 0x00000001 -#define DSBSTATUS_BUFFERLOST 0x00000002 -#define DSBSTATUS_LOOPING 0x00000004 -#define DSBSTATUS_LOCHARDWARE 0x00000008 -#define DSBSTATUS_LOCSOFTWARE 0x00000010 -#define DSBSTATUS_TERMINATED 0x00000020 - -#define DSBLOCK_FROMWRITECURSOR 0x00000001 -#define DSBLOCK_ENTIREBUFFER 0x00000002 - -#define DSBFREQUENCY_ORIGINAL 0 -#define DSBFREQUENCY_MIN 100 -#if DIRECTSOUND_VERSION >= 0x0900 -#define DSBFREQUENCY_MAX 200000 -#else -#define DSBFREQUENCY_MAX 100000 -#endif - -#define DSBPAN_LEFT -10000 -#define DSBPAN_CENTER 0 -#define DSBPAN_RIGHT 10000 - -#define DSBVOLUME_MIN -10000 -#define DSBVOLUME_MAX 0 - -#define DSBSIZE_MIN 4 -#define DSBSIZE_MAX 0x0FFFFFFF -#define DSBSIZE_FX_MIN 150 // NOTE: Milliseconds, not bytes - -#define DS3DMODE_NORMAL 0x00000000 -#define DS3DMODE_HEADRELATIVE 0x00000001 -#define DS3DMODE_DISABLE 0x00000002 - -#define DS3D_IMMEDIATE 0x00000000 -#define DS3D_DEFERRED 0x00000001 - -#define DS3D_MINDISTANCEFACTOR FLT_MIN -#define DS3D_MAXDISTANCEFACTOR FLT_MAX -#define DS3D_DEFAULTDISTANCEFACTOR 1.0f - -#define DS3D_MINROLLOFFFACTOR 0.0f -#define DS3D_MAXROLLOFFFACTOR 10.0f -#define DS3D_DEFAULTROLLOFFFACTOR 1.0f - -#define DS3D_MINDOPPLERFACTOR 0.0f -#define DS3D_MAXDOPPLERFACTOR 10.0f -#define DS3D_DEFAULTDOPPLERFACTOR 1.0f - -#define DS3D_DEFAULTMINDISTANCE 1.0f -#define DS3D_DEFAULTMAXDISTANCE 1000000000.0f - -#define DS3D_MINCONEANGLE 0 -#define DS3D_MAXCONEANGLE 360 -#define DS3D_DEFAULTCONEANGLE 360 - -#define DS3D_DEFAULTCONEOUTSIDEVOLUME DSBVOLUME_MAX - -// IDirectSoundCapture attributes - -#define DSCCAPS_EMULDRIVER DSCAPS_EMULDRIVER -#define DSCCAPS_CERTIFIED DSCAPS_CERTIFIED -#define DSCCAPS_MULTIPLECAPTURE 0x00000001 - -// IDirectSoundCaptureBuffer attributes - -#define DSCBCAPS_WAVEMAPPED 0x80000000 - -#if DIRECTSOUND_VERSION >= 0x0800 -#define DSCBCAPS_CTRLFX 0x00000200 -#endif - - -#define DSCBLOCK_ENTIREBUFFER 0x00000001 - -#define DSCBSTATUS_CAPTURING 0x00000001 -#define DSCBSTATUS_LOOPING 0x00000002 - -#define DSCBSTART_LOOPING 0x00000001 - -#define DSBPN_OFFSETSTOP 0xFFFFFFFF - -#define DS_CERTIFIED 0x00000000 -#define DS_UNCERTIFIED 0x00000001 - - -// -// Flags for the I3DL2 effects -// - -// -// I3DL2 Material Presets -// - -enum -{ - DSFX_I3DL2_MATERIAL_PRESET_SINGLEWINDOW, - DSFX_I3DL2_MATERIAL_PRESET_DOUBLEWINDOW, - DSFX_I3DL2_MATERIAL_PRESET_THINDOOR, - DSFX_I3DL2_MATERIAL_PRESET_THICKDOOR, - DSFX_I3DL2_MATERIAL_PRESET_WOODWALL, - DSFX_I3DL2_MATERIAL_PRESET_BRICKWALL, - DSFX_I3DL2_MATERIAL_PRESET_STONEWALL, - DSFX_I3DL2_MATERIAL_PRESET_CURTAIN -}; - -#define I3DL2_MATERIAL_PRESET_SINGLEWINDOW -2800,0.71f -#define I3DL2_MATERIAL_PRESET_DOUBLEWINDOW -5000,0.40f -#define I3DL2_MATERIAL_PRESET_THINDOOR -1800,0.66f -#define I3DL2_MATERIAL_PRESET_THICKDOOR -4400,0.64f -#define I3DL2_MATERIAL_PRESET_WOODWALL -4000,0.50f -#define I3DL2_MATERIAL_PRESET_BRICKWALL -5000,0.60f -#define I3DL2_MATERIAL_PRESET_STONEWALL -6000,0.68f -#define I3DL2_MATERIAL_PRESET_CURTAIN -1200,0.15f - -enum -{ - DSFX_I3DL2_ENVIRONMENT_PRESET_DEFAULT, - DSFX_I3DL2_ENVIRONMENT_PRESET_GENERIC, - DSFX_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL, - DSFX_I3DL2_ENVIRONMENT_PRESET_ROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_BATHROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_STONEROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM, - DSFX_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL, - DSFX_I3DL2_ENVIRONMENT_PRESET_CAVE, - DSFX_I3DL2_ENVIRONMENT_PRESET_ARENA, - DSFX_I3DL2_ENVIRONMENT_PRESET_HANGAR, - DSFX_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY, - DSFX_I3DL2_ENVIRONMENT_PRESET_HALLWAY, - DSFX_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR, - DSFX_I3DL2_ENVIRONMENT_PRESET_ALLEY, - DSFX_I3DL2_ENVIRONMENT_PRESET_FOREST, - DSFX_I3DL2_ENVIRONMENT_PRESET_CITY, - DSFX_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS, - DSFX_I3DL2_ENVIRONMENT_PRESET_QUARRY, - DSFX_I3DL2_ENVIRONMENT_PRESET_PLAIN, - DSFX_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT, - DSFX_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE, - DSFX_I3DL2_ENVIRONMENT_PRESET_UNDERWATER, - DSFX_I3DL2_ENVIRONMENT_PRESET_SMALLROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEROOM, - DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL, - DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEHALL, - DSFX_I3DL2_ENVIRONMENT_PRESET_PLATE -}; - -// -// I3DL2 Reverberation Presets Values -// - -#define I3DL2_ENVIRONMENT_PRESET_DEFAULT -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_GENERIC -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_PADDEDCELL -1000,-6000, 0.0f, 0.17f, 0.10f, -1204, 0.001f, 207, 0.002f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_ROOM -1000, -454, 0.0f, 0.40f, 0.83f, -1646, 0.002f, 53, 0.003f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_BATHROOM -1000,-1200, 0.0f, 1.49f, 0.54f, -370, 0.007f, 1030, 0.011f, 100.0f, 60.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_LIVINGROOM -1000,-6000, 0.0f, 0.50f, 0.10f, -1376, 0.003f, -1104, 0.004f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_STONEROOM -1000, -300, 0.0f, 2.31f, 0.64f, -711, 0.012f, 83, 0.017f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_AUDITORIUM -1000, -476, 0.0f, 4.32f, 0.59f, -789, 0.020f, -289, 0.030f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_CONCERTHALL -1000, -500, 0.0f, 3.92f, 0.70f, -1230, 0.020f, -2, 0.029f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_CAVE -1000, 0, 0.0f, 2.91f, 1.30f, -602, 0.015f, -302, 0.022f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_ARENA -1000, -698, 0.0f, 7.24f, 0.33f, -1166, 0.020f, 16, 0.030f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_HANGAR -1000,-1000, 0.0f,10.05f, 0.23f, -602, 0.020f, 198, 0.030f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY -1000,-4000, 0.0f, 0.30f, 0.10f, -1831, 0.002f, -1630, 0.030f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_HALLWAY -1000, -300, 0.0f, 1.49f, 0.59f, -1219, 0.007f, 441, 0.011f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR -1000, -237, 0.0f, 2.70f, 0.79f, -1214, 0.013f, 395, 0.020f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_ALLEY -1000, -270, 0.0f, 1.49f, 0.86f, -1204, 0.007f, -4, 0.011f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_FOREST -1000,-3300, 0.0f, 1.49f, 0.54f, -2560, 0.162f, -613, 0.088f, 79.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_CITY -1000, -800, 0.0f, 1.49f, 0.67f, -2273, 0.007f, -2217, 0.011f, 50.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_MOUNTAINS -1000,-2500, 0.0f, 1.49f, 0.21f, -2780, 0.300f, -2014, 0.100f, 27.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_QUARRY -1000,-1000, 0.0f, 1.49f, 0.83f,-10000, 0.061f, 500, 0.025f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_PLAIN -1000,-2000, 0.0f, 1.49f, 0.50f, -2466, 0.179f, -2514, 0.100f, 21.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_PARKINGLOT -1000, 0, 0.0f, 1.65f, 1.50f, -1363, 0.008f, -1153, 0.012f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_SEWERPIPE -1000,-1000, 0.0f, 2.81f, 0.14f, 429, 0.014f, 648, 0.021f, 80.0f, 60.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_UNDERWATER -1000,-4000, 0.0f, 1.49f, 0.10f, -449, 0.007f, 1700, 0.011f, 100.0f, 100.0f, 5000.0f - -// -// Examples simulating 'musical' reverb presets -// -// Name Decay time Description -// Small Room 1.1s A small size room with a length of 5m or so. -// Medium Room 1.3s A medium size room with a length of 10m or so. -// Large Room 1.5s A large size room suitable for live performances. -// Medium Hall 1.8s A medium size concert hall. -// Large Hall 1.8s A large size concert hall suitable for a full orchestra. -// Plate 1.3s A plate reverb simulation. -// - -#define I3DL2_ENVIRONMENT_PRESET_SMALLROOM -1000, -600, 0.0f, 1.10f, 0.83f, -400, 0.005f, 500, 0.010f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM -1000, -600, 0.0f, 1.30f, 0.83f, -1000, 0.010f, -200, 0.020f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_LARGEROOM -1000, -600, 0.0f, 1.50f, 0.83f, -1600, 0.020f, -1000, 0.040f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL -1000, -600, 0.0f, 1.80f, 0.70f, -1300, 0.015f, -800, 0.030f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_LARGEHALL -1000, -600, 0.0f, 1.80f, 0.70f, -2000, 0.030f, -1400, 0.060f, 100.0f, 100.0f, 5000.0f -#define I3DL2_ENVIRONMENT_PRESET_PLATE -1000, -200, 0.0f, 1.30f, 0.90f, 0, 0.002f, 0, 0.010f, 100.0f, 75.0f, 5000.0f - -// -// DirectSound3D Algorithms -// - -// Default DirectSound3D algorithm {00000000-0000-0000-0000-000000000000} -#define DS3DALG_DEFAULT GUID_NULL - -// No virtualization (Pan3D) {C241333F-1C1B-11d2-94F5-00C04FC28ACA} -DEFINE_GUID(DS3DALG_NO_VIRTUALIZATION, 0xc241333f, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); - -// High-quality HRTF algorithm {C2413340-1C1B-11d2-94F5-00C04FC28ACA} -DEFINE_GUID(DS3DALG_HRTF_FULL, 0xc2413340, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); - -// Lower-quality HRTF algorithm {C2413342-1C1B-11d2-94F5-00C04FC28ACA} -DEFINE_GUID(DS3DALG_HRTF_LIGHT, 0xc2413342, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); - - -#if DIRECTSOUND_VERSION >= 0x0800 - -// -// DirectSound Internal Effect Algorithms -// - - -// Gargle {DAFD8210-5711-4B91-9FE3-F75B7AE279BF} -DEFINE_GUID(GUID_DSFX_STANDARD_GARGLE, 0xdafd8210, 0x5711, 0x4b91, 0x9f, 0xe3, 0xf7, 0x5b, 0x7a, 0xe2, 0x79, 0xbf); - -// Chorus {EFE6629C-81F7-4281-BD91-C9D604A95AF6} -DEFINE_GUID(GUID_DSFX_STANDARD_CHORUS, 0xefe6629c, 0x81f7, 0x4281, 0xbd, 0x91, 0xc9, 0xd6, 0x04, 0xa9, 0x5a, 0xf6); - -// Flanger {EFCA3D92-DFD8-4672-A603-7420894BAD98} -DEFINE_GUID(GUID_DSFX_STANDARD_FLANGER, 0xefca3d92, 0xdfd8, 0x4672, 0xa6, 0x03, 0x74, 0x20, 0x89, 0x4b, 0xad, 0x98); - -// Echo/Delay {EF3E932C-D40B-4F51-8CCF-3F98F1B29D5D} -DEFINE_GUID(GUID_DSFX_STANDARD_ECHO, 0xef3e932c, 0xd40b, 0x4f51, 0x8c, 0xcf, 0x3f, 0x98, 0xf1, 0xb2, 0x9d, 0x5d); - -// Distortion {EF114C90-CD1D-484E-96E5-09CFAF912A21} -DEFINE_GUID(GUID_DSFX_STANDARD_DISTORTION, 0xef114c90, 0xcd1d, 0x484e, 0x96, 0xe5, 0x09, 0xcf, 0xaf, 0x91, 0x2a, 0x21); - -// Compressor/Limiter {EF011F79-4000-406D-87AF-BFFB3FC39D57} -DEFINE_GUID(GUID_DSFX_STANDARD_COMPRESSOR, 0xef011f79, 0x4000, 0x406d, 0x87, 0xaf, 0xbf, 0xfb, 0x3f, 0xc3, 0x9d, 0x57); - -// Parametric Equalization {120CED89-3BF4-4173-A132-3CB406CF3231} -DEFINE_GUID(GUID_DSFX_STANDARD_PARAMEQ, 0x120ced89, 0x3bf4, 0x4173, 0xa1, 0x32, 0x3c, 0xb4, 0x06, 0xcf, 0x32, 0x31); - -// I3DL2 Environmental Reverberation: Reverb (Listener) Effect {EF985E71-D5C7-42D4-BA4D-2D073E2E96F4} -DEFINE_GUID(GUID_DSFX_STANDARD_I3DL2REVERB, 0xef985e71, 0xd5c7, 0x42d4, 0xba, 0x4d, 0x2d, 0x07, 0x3e, 0x2e, 0x96, 0xf4); - -// Waves Reverberation {87FC0268-9A55-4360-95AA-004A1D9DE26C} -DEFINE_GUID(GUID_DSFX_WAVES_REVERB, 0x87fc0268, 0x9a55, 0x4360, 0x95, 0xaa, 0x00, 0x4a, 0x1d, 0x9d, 0xe2, 0x6c); - -// -// DirectSound Capture Effect Algorithms -// - - -// Acoustic Echo Canceller {BF963D80-C559-11D0-8A2B-00A0C9255AC1} -// Matches KSNODETYPE_ACOUSTIC_ECHO_CANCEL in ksmedia.h -DEFINE_GUID(GUID_DSCFX_CLASS_AEC, 0xBF963D80L, 0xC559, 0x11D0, 0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1); - -// Microsoft AEC {CDEBB919-379A-488a-8765-F53CFD36DE40} -DEFINE_GUID(GUID_DSCFX_MS_AEC, 0xcdebb919, 0x379a, 0x488a, 0x87, 0x65, 0xf5, 0x3c, 0xfd, 0x36, 0xde, 0x40); - -// System AEC {1C22C56D-9879-4f5b-A389-27996DDC2810} -DEFINE_GUID(GUID_DSCFX_SYSTEM_AEC, 0x1c22c56d, 0x9879, 0x4f5b, 0xa3, 0x89, 0x27, 0x99, 0x6d, 0xdc, 0x28, 0x10); - -// Noise Supression {E07F903F-62FD-4e60-8CDD-DEA7236665B5} -// Matches KSNODETYPE_NOISE_SUPPRESS in post Windows ME DDK's ksmedia.h -DEFINE_GUID(GUID_DSCFX_CLASS_NS, 0xe07f903f, 0x62fd, 0x4e60, 0x8c, 0xdd, 0xde, 0xa7, 0x23, 0x66, 0x65, 0xb5); - -// Microsoft Noise Suppresion {11C5C73B-66E9-4ba1-A0BA-E814C6EED92D} -DEFINE_GUID(GUID_DSCFX_MS_NS, 0x11c5c73b, 0x66e9, 0x4ba1, 0xa0, 0xba, 0xe8, 0x14, 0xc6, 0xee, 0xd9, 0x2d); - -// System Noise Suppresion {5AB0882E-7274-4516-877D-4EEE99BA4FD0} -DEFINE_GUID(GUID_DSCFX_SYSTEM_NS, 0x5ab0882e, 0x7274, 0x4516, 0x87, 0x7d, 0x4e, 0xee, 0x99, 0xba, 0x4f, 0xd0); - -#endif // DIRECTSOUND_VERSION >= 0x0800 - -#endif // __DSOUND_INCLUDED__ - - - -#ifdef __cplusplus -}; -#endif // __cplusplus - - +/*==========================================================================; + * + * Copyright (c) Microsoft Corporation. All rights reserved. + * + * File: dsound.h + * Content: DirectSound include file + * + **************************************************************************/ + +#define COM_NO_WINDOWS_H +#include +#include + +#ifndef DIRECTSOUND_VERSION +#define DIRECTSOUND_VERSION 0x0900 /* Version 9.0 */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +#ifndef __DSOUND_INCLUDED__ +#define __DSOUND_INCLUDED__ + +/* Type definitions shared with Direct3D */ + +#ifndef DX_SHARED_DEFINES + +typedef float D3DVALUE, *LPD3DVALUE; + +#ifndef D3DCOLOR_DEFINED +typedef DWORD D3DCOLOR; +#define D3DCOLOR_DEFINED +#endif + +#ifndef LPD3DCOLOR_DEFINED +typedef DWORD *LPD3DCOLOR; +#define LPD3DCOLOR_DEFINED +#endif + +#ifndef D3DVECTOR_DEFINED +typedef struct _D3DVECTOR { + float x; + float y; + float z; +} D3DVECTOR; +#define D3DVECTOR_DEFINED +#endif + +#ifndef LPD3DVECTOR_DEFINED +typedef D3DVECTOR *LPD3DVECTOR; +#define LPD3DVECTOR_DEFINED +#endif + +#define DX_SHARED_DEFINES +#endif // DX_SHARED_DEFINES + +#define _FACDS 0x878 /* DirectSound's facility code */ +#define MAKE_DSHRESULT(code) MAKE_HRESULT(1, _FACDS, code) + +// DirectSound Component GUID {47D4D946-62E8-11CF-93BC-444553540000} +DEFINE_GUID(CLSID_DirectSound, 0x47d4d946, 0x62e8, 0x11cf, 0x93, 0xbc, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0); + +// DirectSound 8.0 Component GUID {3901CC3F-84B5-4FA4-BA35-AA8172B8A09B} +DEFINE_GUID(CLSID_DirectSound8, 0x3901cc3f, 0x84b5, 0x4fa4, 0xba, 0x35, 0xaa, 0x81, 0x72, 0xb8, 0xa0, 0x9b); + +// DirectSound Capture Component GUID {B0210780-89CD-11D0-AF08-00A0C925CD16} +DEFINE_GUID(CLSID_DirectSoundCapture, 0xb0210780, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); + +// DirectSound 8.0 Capture Component GUID {E4BCAC13-7F99-4908-9A8E-74E3BF24B6E1} +DEFINE_GUID(CLSID_DirectSoundCapture8, 0xe4bcac13, 0x7f99, 0x4908, 0x9a, 0x8e, 0x74, 0xe3, 0xbf, 0x24, 0xb6, 0xe1); + +// DirectSound Full Duplex Component GUID {FEA4300C-7959-4147-B26A-2377B9E7A91D} +DEFINE_GUID(CLSID_DirectSoundFullDuplex, 0xfea4300c, 0x7959, 0x4147, 0xb2, 0x6a, 0x23, 0x77, 0xb9, 0xe7, 0xa9, 0x1d); + + +// DirectSound default playback device GUID {DEF00000-9C6D-47ED-AAF1-4DDA8F2B5C03} +DEFINE_GUID(DSDEVID_DefaultPlayback, 0xdef00000, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); + +// DirectSound default capture device GUID {DEF00001-9C6D-47ED-AAF1-4DDA8F2B5C03} +DEFINE_GUID(DSDEVID_DefaultCapture, 0xdef00001, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); + +// DirectSound default device for voice playback {DEF00002-9C6D-47ED-AAF1-4DDA8F2B5C03} +DEFINE_GUID(DSDEVID_DefaultVoicePlayback, 0xdef00002, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); + +// DirectSound default device for voice capture {DEF00003-9C6D-47ED-AAF1-4DDA8F2B5C03} +DEFINE_GUID(DSDEVID_DefaultVoiceCapture, 0xdef00003, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03); + + +// +// Forward declarations for interfaces. +// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined +// + +#ifdef __cplusplus +struct IDirectSound; +struct IDirectSoundBuffer; +struct IDirectSound3DListener; +struct IDirectSound3DBuffer; +struct IDirectSoundCapture; +struct IDirectSoundCaptureBuffer; +struct IDirectSoundNotify; +#endif // __cplusplus + + +// +// DirectSound 8.0 interfaces. +// + +#if DIRECTSOUND_VERSION >= 0x0800 + +#ifdef __cplusplus +struct IDirectSound8; +struct IDirectSoundBuffer8; +struct IDirectSoundCaptureBuffer8; +struct IDirectSoundFXGargle; +struct IDirectSoundFXChorus; +struct IDirectSoundFXFlanger; +struct IDirectSoundFXEcho; +struct IDirectSoundFXDistortion; +struct IDirectSoundFXCompressor; +struct IDirectSoundFXParamEq; +struct IDirectSoundFXWavesReverb; +struct IDirectSoundFXI3DL2Reverb; +struct IDirectSoundCaptureFXAec; +struct IDirectSoundCaptureFXNoiseSuppress; +struct IDirectSoundFullDuplex; +#endif // __cplusplus + +// IDirectSound8, IDirectSoundBuffer8 and IDirectSoundCaptureBuffer8 are the +// only DirectSound 7.0 interfaces with changed functionality in version 8.0. +// The other level 8 interfaces as equivalent to their level 7 counterparts: + +#define IDirectSoundCapture8 IDirectSoundCapture +#define IDirectSound3DListener8 IDirectSound3DListener +#define IDirectSound3DBuffer8 IDirectSound3DBuffer +#define IDirectSoundNotify8 IDirectSoundNotify +#define IDirectSoundFXGargle8 IDirectSoundFXGargle +#define IDirectSoundFXChorus8 IDirectSoundFXChorus +#define IDirectSoundFXFlanger8 IDirectSoundFXFlanger +#define IDirectSoundFXEcho8 IDirectSoundFXEcho +#define IDirectSoundFXDistortion8 IDirectSoundFXDistortion +#define IDirectSoundFXCompressor8 IDirectSoundFXCompressor +#define IDirectSoundFXParamEq8 IDirectSoundFXParamEq +#define IDirectSoundFXWavesReverb8 IDirectSoundFXWavesReverb +#define IDirectSoundFXI3DL2Reverb8 IDirectSoundFXI3DL2Reverb +#define IDirectSoundCaptureFXAec8 IDirectSoundCaptureFXAec +#define IDirectSoundCaptureFXNoiseSuppress8 IDirectSoundCaptureFXNoiseSuppress +#define IDirectSoundFullDuplex8 IDirectSoundFullDuplex + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +typedef struct IDirectSound *LPDIRECTSOUND; +typedef struct IDirectSoundBuffer *LPDIRECTSOUNDBUFFER; +typedef struct IDirectSound3DListener *LPDIRECTSOUND3DLISTENER; +typedef struct IDirectSound3DBuffer *LPDIRECTSOUND3DBUFFER; +typedef struct IDirectSoundCapture *LPDIRECTSOUNDCAPTURE; +typedef struct IDirectSoundCaptureBuffer *LPDIRECTSOUNDCAPTUREBUFFER; +typedef struct IDirectSoundNotify *LPDIRECTSOUNDNOTIFY; + + +#if DIRECTSOUND_VERSION >= 0x0800 + +typedef struct IDirectSoundFXGargle *LPDIRECTSOUNDFXGARGLE; +typedef struct IDirectSoundFXChorus *LPDIRECTSOUNDFXCHORUS; +typedef struct IDirectSoundFXFlanger *LPDIRECTSOUNDFXFLANGER; +typedef struct IDirectSoundFXEcho *LPDIRECTSOUNDFXECHO; +typedef struct IDirectSoundFXDistortion *LPDIRECTSOUNDFXDISTORTION; +typedef struct IDirectSoundFXCompressor *LPDIRECTSOUNDFXCOMPRESSOR; +typedef struct IDirectSoundFXParamEq *LPDIRECTSOUNDFXPARAMEQ; +typedef struct IDirectSoundFXWavesReverb *LPDIRECTSOUNDFXWAVESREVERB; +typedef struct IDirectSoundFXI3DL2Reverb *LPDIRECTSOUNDFXI3DL2REVERB; +typedef struct IDirectSoundCaptureFXAec *LPDIRECTSOUNDCAPTUREFXAEC; +typedef struct IDirectSoundCaptureFXNoiseSuppress *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS; +typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX; + +typedef struct IDirectSound8 *LPDIRECTSOUND8; +typedef struct IDirectSoundBuffer8 *LPDIRECTSOUNDBUFFER8; +typedef struct IDirectSound3DListener8 *LPDIRECTSOUND3DLISTENER8; +typedef struct IDirectSound3DBuffer8 *LPDIRECTSOUND3DBUFFER8; +typedef struct IDirectSoundCapture8 *LPDIRECTSOUNDCAPTURE8; +typedef struct IDirectSoundCaptureBuffer8 *LPDIRECTSOUNDCAPTUREBUFFER8; +typedef struct IDirectSoundNotify8 *LPDIRECTSOUNDNOTIFY8; +typedef struct IDirectSoundFXGargle8 *LPDIRECTSOUNDFXGARGLE8; +typedef struct IDirectSoundFXChorus8 *LPDIRECTSOUNDFXCHORUS8; +typedef struct IDirectSoundFXFlanger8 *LPDIRECTSOUNDFXFLANGER8; +typedef struct IDirectSoundFXEcho8 *LPDIRECTSOUNDFXECHO8; +typedef struct IDirectSoundFXDistortion8 *LPDIRECTSOUNDFXDISTORTION8; +typedef struct IDirectSoundFXCompressor8 *LPDIRECTSOUNDFXCOMPRESSOR8; +typedef struct IDirectSoundFXParamEq8 *LPDIRECTSOUNDFXPARAMEQ8; +typedef struct IDirectSoundFXWavesReverb8 *LPDIRECTSOUNDFXWAVESREVERB8; +typedef struct IDirectSoundFXI3DL2Reverb8 *LPDIRECTSOUNDFXI3DL2REVERB8; +typedef struct IDirectSoundCaptureFXAec8 *LPDIRECTSOUNDCAPTUREFXAEC8; +typedef struct IDirectSoundCaptureFXNoiseSuppress8 *LPDIRECTSOUNDCAPTUREFXNOISESUPPRESS8; +typedef struct IDirectSoundFullDuplex8 *LPDIRECTSOUNDFULLDUPLEX8; + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// IID definitions for the unchanged DirectSound 8.0 interfaces +// + +#if DIRECTSOUND_VERSION >= 0x0800 + +#define IID_IDirectSoundCapture8 IID_IDirectSoundCapture +#define IID_IDirectSound3DListener8 IID_IDirectSound3DListener +#define IID_IDirectSound3DBuffer8 IID_IDirectSound3DBuffer +#define IID_IDirectSoundNotify8 IID_IDirectSoundNotify +#define IID_IDirectSoundFXGargle8 IID_IDirectSoundFXGargle +#define IID_IDirectSoundFXChorus8 IID_IDirectSoundFXChorus +#define IID_IDirectSoundFXFlanger8 IID_IDirectSoundFXFlanger +#define IID_IDirectSoundFXEcho8 IID_IDirectSoundFXEcho +#define IID_IDirectSoundFXDistortion8 IID_IDirectSoundFXDistortion +#define IID_IDirectSoundFXCompressor8 IID_IDirectSoundFXCompressor +#define IID_IDirectSoundFXParamEq8 IID_IDirectSoundFXParamEq +#define IID_IDirectSoundFXWavesReverb8 IID_IDirectSoundFXWavesReverb +#define IID_IDirectSoundFXI3DL2Reverb8 IID_IDirectSoundFXI3DL2Reverb +#define IID_IDirectSoundCaptureFXAec8 IID_IDirectSoundCaptureFXAec +#define IID_IDirectSoundCaptureFXNoiseSuppress8 IID_IDirectSoundCaptureFXNoiseSuppress +#define IID_IDirectSoundFullDuplex8 IID_IDirectSoundFullDuplex + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// Compatibility typedefs +// + +#ifndef _LPCWAVEFORMATEX_DEFINED +#define _LPCWAVEFORMATEX_DEFINED +typedef const WAVEFORMATEX *LPCWAVEFORMATEX; +#endif // _LPCWAVEFORMATEX_DEFINED + +#ifndef __LPCGUID_DEFINED__ +#define __LPCGUID_DEFINED__ +typedef const GUID *LPCGUID; +#endif // __LPCGUID_DEFINED__ + +typedef LPDIRECTSOUND *LPLPDIRECTSOUND; +typedef LPDIRECTSOUNDBUFFER *LPLPDIRECTSOUNDBUFFER; +typedef LPDIRECTSOUND3DLISTENER *LPLPDIRECTSOUND3DLISTENER; +typedef LPDIRECTSOUND3DBUFFER *LPLPDIRECTSOUND3DBUFFER; +typedef LPDIRECTSOUNDCAPTURE *LPLPDIRECTSOUNDCAPTURE; +typedef LPDIRECTSOUNDCAPTUREBUFFER *LPLPDIRECTSOUNDCAPTUREBUFFER; +typedef LPDIRECTSOUNDNOTIFY *LPLPDIRECTSOUNDNOTIFY; + +#if DIRECTSOUND_VERSION >= 0x0800 +typedef LPDIRECTSOUND8 *LPLPDIRECTSOUND8; +typedef LPDIRECTSOUNDBUFFER8 *LPLPDIRECTSOUNDBUFFER8; +typedef LPDIRECTSOUNDCAPTURE8 *LPLPDIRECTSOUNDCAPTURE8; +typedef LPDIRECTSOUNDCAPTUREBUFFER8 *LPLPDIRECTSOUNDCAPTUREBUFFER8; +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// Structures +// + +typedef struct _DSCAPS +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwMinSecondarySampleRate; + DWORD dwMaxSecondarySampleRate; + DWORD dwPrimaryBuffers; + DWORD dwMaxHwMixingAllBuffers; + DWORD dwMaxHwMixingStaticBuffers; + DWORD dwMaxHwMixingStreamingBuffers; + DWORD dwFreeHwMixingAllBuffers; + DWORD dwFreeHwMixingStaticBuffers; + DWORD dwFreeHwMixingStreamingBuffers; + DWORD dwMaxHw3DAllBuffers; + DWORD dwMaxHw3DStaticBuffers; + DWORD dwMaxHw3DStreamingBuffers; + DWORD dwFreeHw3DAllBuffers; + DWORD dwFreeHw3DStaticBuffers; + DWORD dwFreeHw3DStreamingBuffers; + DWORD dwTotalHwMemBytes; + DWORD dwFreeHwMemBytes; + DWORD dwMaxContigFreeHwMemBytes; + DWORD dwUnlockTransferRateHwBuffers; + DWORD dwPlayCpuOverheadSwBuffers; + DWORD dwReserved1; + DWORD dwReserved2; +} DSCAPS, *LPDSCAPS; + +typedef const DSCAPS *LPCDSCAPS; + +typedef struct _DSBCAPS +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwUnlockTransferRate; + DWORD dwPlayCpuOverhead; +} DSBCAPS, *LPDSBCAPS; + +typedef const DSBCAPS *LPCDSBCAPS; + +#if DIRECTSOUND_VERSION >= 0x0800 + + typedef struct _DSEFFECTDESC + { + DWORD dwSize; + DWORD dwFlags; + GUID guidDSFXClass; + DWORD_PTR dwReserved1; + DWORD_PTR dwReserved2; + } DSEFFECTDESC, *LPDSEFFECTDESC; + typedef const DSEFFECTDESC *LPCDSEFFECTDESC; + + #define DSFX_LOCHARDWARE 0x00000001 + #define DSFX_LOCSOFTWARE 0x00000002 + + enum + { + DSFXR_PRESENT, // 0 + DSFXR_LOCHARDWARE, // 1 + DSFXR_LOCSOFTWARE, // 2 + DSFXR_UNALLOCATED, // 3 + DSFXR_FAILED, // 4 + DSFXR_UNKNOWN, // 5 + DSFXR_SENDLOOP // 6 + }; + + typedef struct _DSCEFFECTDESC + { + DWORD dwSize; + DWORD dwFlags; + GUID guidDSCFXClass; + GUID guidDSCFXInstance; + DWORD dwReserved1; + DWORD dwReserved2; + } DSCEFFECTDESC, *LPDSCEFFECTDESC; + typedef const DSCEFFECTDESC *LPCDSCEFFECTDESC; + + #define DSCFX_LOCHARDWARE 0x00000001 + #define DSCFX_LOCSOFTWARE 0x00000002 + + #define DSCFXR_LOCHARDWARE 0x00000010 + #define DSCFXR_LOCSOFTWARE 0x00000020 + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +typedef struct _DSBUFFERDESC +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; + LPWAVEFORMATEX lpwfxFormat; +#if DIRECTSOUND_VERSION >= 0x0700 + GUID guid3DAlgorithm; +#endif +} DSBUFFERDESC, *LPDSBUFFERDESC; + +typedef const DSBUFFERDESC *LPCDSBUFFERDESC; + +// Older version of this structure: + +typedef struct _DSBUFFERDESC1 +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; + LPWAVEFORMATEX lpwfxFormat; +} DSBUFFERDESC1, *LPDSBUFFERDESC1; + +typedef const DSBUFFERDESC1 *LPCDSBUFFERDESC1; + +typedef struct _DS3DBUFFER +{ + DWORD dwSize; + D3DVECTOR vPosition; + D3DVECTOR vVelocity; + DWORD dwInsideConeAngle; + DWORD dwOutsideConeAngle; + D3DVECTOR vConeOrientation; + LONG lConeOutsideVolume; + D3DVALUE flMinDistance; + D3DVALUE flMaxDistance; + DWORD dwMode; +} DS3DBUFFER, *LPDS3DBUFFER; + +typedef const DS3DBUFFER *LPCDS3DBUFFER; + +typedef struct _DS3DLISTENER +{ + DWORD dwSize; + D3DVECTOR vPosition; + D3DVECTOR vVelocity; + D3DVECTOR vOrientFront; + D3DVECTOR vOrientTop; + D3DVALUE flDistanceFactor; + D3DVALUE flRolloffFactor; + D3DVALUE flDopplerFactor; +} DS3DLISTENER, *LPDS3DLISTENER; + +typedef const DS3DLISTENER *LPCDS3DLISTENER; + +typedef struct _DSCCAPS +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwFormats; + DWORD dwChannels; +} DSCCAPS, *LPDSCCAPS; + +typedef const DSCCAPS *LPCDSCCAPS; + +typedef struct _DSCBUFFERDESC1 +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; + LPWAVEFORMATEX lpwfxFormat; +} DSCBUFFERDESC1, *LPDSCBUFFERDESC1; + +typedef struct _DSCBUFFERDESC +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; + LPWAVEFORMATEX lpwfxFormat; +#if DIRECTSOUND_VERSION >= 0x0800 + DWORD dwFXCount; + LPDSCEFFECTDESC lpDSCFXDesc; +#endif +} DSCBUFFERDESC, *LPDSCBUFFERDESC; + +typedef const DSCBUFFERDESC *LPCDSCBUFFERDESC; + +typedef struct _DSCBCAPS +{ + DWORD dwSize; + DWORD dwFlags; + DWORD dwBufferBytes; + DWORD dwReserved; +} DSCBCAPS, *LPDSCBCAPS; + +typedef const DSCBCAPS *LPCDSCBCAPS; + +typedef struct _DSBPOSITIONNOTIFY +{ + DWORD dwOffset; + HANDLE hEventNotify; +} DSBPOSITIONNOTIFY, *LPDSBPOSITIONNOTIFY; + +typedef const DSBPOSITIONNOTIFY *LPCDSBPOSITIONNOTIFY; + +// +// DirectSound API +// + +typedef BOOL (CALLBACK *LPDSENUMCALLBACKA)(LPGUID, LPCSTR, LPCSTR, LPVOID); +typedef BOOL (CALLBACK *LPDSENUMCALLBACKW)(LPGUID, LPCWSTR, LPCWSTR, LPVOID); + +extern HRESULT WINAPI DirectSoundCreate(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter); +extern HRESULT WINAPI DirectSoundEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext); +extern HRESULT WINAPI DirectSoundEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext); + +extern HRESULT WINAPI DirectSoundCaptureCreate(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE *ppDSC, LPUNKNOWN pUnkOuter); +extern HRESULT WINAPI DirectSoundCaptureEnumerateA(LPDSENUMCALLBACKA pDSEnumCallback, LPVOID pContext); +extern HRESULT WINAPI DirectSoundCaptureEnumerateW(LPDSENUMCALLBACKW pDSEnumCallback, LPVOID pContext); + +#if DIRECTSOUND_VERSION >= 0x0800 +extern HRESULT WINAPI DirectSoundCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter); +extern HRESULT WINAPI DirectSoundCaptureCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUNDCAPTURE8 *ppDSC8, LPUNKNOWN pUnkOuter); +extern HRESULT WINAPI DirectSoundFullDuplexCreate(LPCGUID pcGuidCaptureDevice, LPCGUID pcGuidRenderDevice, + LPCDSCBUFFERDESC pcDSCBufferDesc, LPCDSBUFFERDESC pcDSBufferDesc, HWND hWnd, + DWORD dwLevel, LPDIRECTSOUNDFULLDUPLEX* ppDSFD, LPDIRECTSOUNDCAPTUREBUFFER8 *ppDSCBuffer8, + LPDIRECTSOUNDBUFFER8 *ppDSBuffer8, LPUNKNOWN pUnkOuter); +#define DirectSoundFullDuplexCreate8 DirectSoundFullDuplexCreate + +extern HRESULT WINAPI GetDeviceID(LPCGUID pGuidSrc, LPGUID pGuidDest); +#endif // DIRECTSOUND_VERSION >= 0x0800 + +#ifdef UNICODE +#define LPDSENUMCALLBACK LPDSENUMCALLBACKW +#define DirectSoundEnumerate DirectSoundEnumerateW +#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateW +#else // UNICODE +#define LPDSENUMCALLBACK LPDSENUMCALLBACKA +#define DirectSoundEnumerate DirectSoundEnumerateA +#define DirectSoundCaptureEnumerate DirectSoundCaptureEnumerateA +#endif // UNICODE + +// +// IUnknown +// + +#if !defined(__cplusplus) || defined(CINTERFACE) +#ifndef IUnknown_QueryInterface +#define IUnknown_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#endif // IUnknown_QueryInterface +#ifndef IUnknown_AddRef +#define IUnknown_AddRef(p) (p)->lpVtbl->AddRef(p) +#endif // IUnknown_AddRef +#ifndef IUnknown_Release +#define IUnknown_Release(p) (p)->lpVtbl->Release(p) +#endif // IUnknown_Release +#else // !defined(__cplusplus) || defined(CINTERFACE) +#ifndef IUnknown_QueryInterface +#define IUnknown_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#endif // IUnknown_QueryInterface +#ifndef IUnknown_AddRef +#define IUnknown_AddRef(p) (p)->AddRef() +#endif // IUnknown_AddRef +#ifndef IUnknown_Release +#define IUnknown_Release(p) (p)->Release() +#endif // IUnknown_Release +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#ifndef __IReferenceClock_INTERFACE_DEFINED__ +#define __IReferenceClock_INTERFACE_DEFINED__ + +typedef LONGLONG REFERENCE_TIME; +typedef REFERENCE_TIME *LPREFERENCE_TIME; + +DEFINE_GUID(IID_IReferenceClock, 0x56a86897, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70); + +#undef INTERFACE +#define INTERFACE IReferenceClock + +DECLARE_INTERFACE_(IReferenceClock, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IReferenceClock methods + STDMETHOD(GetTime) (THIS_ REFERENCE_TIME *pTime) PURE; + STDMETHOD(AdviseTime) (THIS_ REFERENCE_TIME rtBaseTime, REFERENCE_TIME rtStreamTime, + HANDLE hEvent, LPDWORD pdwAdviseCookie) PURE; + STDMETHOD(AdvisePeriodic) (THIS_ REFERENCE_TIME rtStartTime, REFERENCE_TIME rtPeriodTime, + HANDLE hSemaphore, LPDWORD pdwAdviseCookie) PURE; + STDMETHOD(Unadvise) (THIS_ DWORD dwAdviseCookie) PURE; +}; + +#endif // __IReferenceClock_INTERFACE_DEFINED__ + +#ifndef IReferenceClock_QueryInterface + +#define IReferenceClock_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IReferenceClock_AddRef(p) IUnknown_AddRef(p) +#define IReferenceClock_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IReferenceClock_GetTime(p,a) (p)->lpVtbl->GetTime(p,a) +#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->lpVtbl->AdviseTime(p,a,b,c,d) +#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->lpVtbl->AdvisePeriodic(p,a,b,c,d) +#define IReferenceClock_Unadvise(p,a) (p)->lpVtbl->Unadvise(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IReferenceClock_GetTime(p,a) (p)->GetTime(a) +#define IReferenceClock_AdviseTime(p,a,b,c,d) (p)->AdviseTime(a,b,c,d) +#define IReferenceClock_AdvisePeriodic(p,a,b,c,d) (p)->AdvisePeriodic(a,b,c,d) +#define IReferenceClock_Unadvise(p,a) (p)->Unadvise(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // IReferenceClock_QueryInterface + +// +// IDirectSound +// + +DEFINE_GUID(IID_IDirectSound, 0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); + +#undef INTERFACE +#define INTERFACE IDirectSound + +DECLARE_INTERFACE_(IDirectSound, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSound methods + STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE; + STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE; + STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE; + STDMETHOD(Compact) (THIS) PURE; + STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE; + STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE; + STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; +}; + +#define IDirectSound_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSound_AddRef(p) IUnknown_AddRef(p) +#define IDirectSound_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->lpVtbl->CreateSoundBuffer(p,a,b,c) +#define IDirectSound_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->lpVtbl->DuplicateSoundBuffer(p,a,b) +#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b) +#define IDirectSound_Compact(p) (p)->lpVtbl->Compact(p) +#define IDirectSound_GetSpeakerConfig(p,a) (p)->lpVtbl->GetSpeakerConfig(p,a) +#define IDirectSound_SetSpeakerConfig(p,b) (p)->lpVtbl->SetSpeakerConfig(p,b) +#define IDirectSound_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound_CreateSoundBuffer(p,a,b,c) (p)->CreateSoundBuffer(a,b,c) +#define IDirectSound_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectSound_DuplicateSoundBuffer(p,a,b) (p)->DuplicateSoundBuffer(a,b) +#define IDirectSound_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b) +#define IDirectSound_Compact(p) (p)->Compact() +#define IDirectSound_GetSpeakerConfig(p,a) (p)->GetSpeakerConfig(a) +#define IDirectSound_SetSpeakerConfig(p,b) (p)->SetSpeakerConfig(b) +#define IDirectSound_Initialize(p,a) (p)->Initialize(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSound8 +// + +DEFINE_GUID(IID_IDirectSound8, 0xC50A7E93, 0xF395, 0x4834, 0x9E, 0xF6, 0x7F, 0xA9, 0x9D, 0xE5, 0x09, 0x66); + +#undef INTERFACE +#define INTERFACE IDirectSound8 + +DECLARE_INTERFACE_(IDirectSound8, IDirectSound) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSound methods + STDMETHOD(CreateSoundBuffer) (THIS_ LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(GetCaps) (THIS_ LPDSCAPS pDSCaps) PURE; + STDMETHOD(DuplicateSoundBuffer) (THIS_ LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate) PURE; + STDMETHOD(SetCooperativeLevel) (THIS_ HWND hwnd, DWORD dwLevel) PURE; + STDMETHOD(Compact) (THIS) PURE; + STDMETHOD(GetSpeakerConfig) (THIS_ LPDWORD pdwSpeakerConfig) PURE; + STDMETHOD(SetSpeakerConfig) (THIS_ DWORD dwSpeakerConfig) PURE; + STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; + + // IDirectSound8 methods + STDMETHOD(VerifyCertification) (THIS_ LPDWORD pdwCertified) PURE; +}; + +#define IDirectSound8_QueryInterface(p,a,b) IDirectSound_QueryInterface(p,a,b) +#define IDirectSound8_AddRef(p) IDirectSound_AddRef(p) +#define IDirectSound8_Release(p) IDirectSound_Release(p) +#define IDirectSound8_CreateSoundBuffer(p,a,b,c) IDirectSound_CreateSoundBuffer(p,a,b,c) +#define IDirectSound8_GetCaps(p,a) IDirectSound_GetCaps(p,a) +#define IDirectSound8_DuplicateSoundBuffer(p,a,b) IDirectSound_DuplicateSoundBuffer(p,a,b) +#define IDirectSound8_SetCooperativeLevel(p,a,b) IDirectSound_SetCooperativeLevel(p,a,b) +#define IDirectSound8_Compact(p) IDirectSound_Compact(p) +#define IDirectSound8_GetSpeakerConfig(p,a) IDirectSound_GetSpeakerConfig(p,a) +#define IDirectSound8_SetSpeakerConfig(p,a) IDirectSound_SetSpeakerConfig(p,a) +#define IDirectSound8_Initialize(p,a) IDirectSound_Initialize(p,a) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound8_VerifyCertification(p,a) (p)->lpVtbl->VerifyCertification(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound8_VerifyCertification(p,a) (p)->VerifyCertification(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundBuffer +// + +DEFINE_GUID(IID_IDirectSoundBuffer, 0x279AFA85, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); + +#undef INTERFACE +#define INTERFACE IDirectSoundBuffer + +DECLARE_INTERFACE_(IDirectSoundBuffer, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundBuffer methods + STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE; + STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; + STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE; + STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE; + STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE; + STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; + STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE; + STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; + STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE; + STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE; + STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE; + STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE; + STDMETHOD(SetPan) (THIS_ LONG lPan) PURE; + STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE; + STDMETHOD(Stop) (THIS) PURE; + STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; + STDMETHOD(Restore) (THIS) PURE; +}; + +#define IDirectSoundBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundBuffer_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundBuffer_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b) +#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c) +#define IDirectSoundBuffer_GetVolume(p,a) (p)->lpVtbl->GetVolume(p,a) +#define IDirectSoundBuffer_GetPan(p,a) (p)->lpVtbl->GetPan(p,a) +#define IDirectSoundBuffer_GetFrequency(p,a) (p)->lpVtbl->GetFrequency(p,a) +#define IDirectSoundBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a) +#define IDirectSoundBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g) +#define IDirectSoundBuffer_Play(p,a,b,c) (p)->lpVtbl->Play(p,a,b,c) +#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->lpVtbl->SetCurrentPosition(p,a) +#define IDirectSoundBuffer_SetFormat(p,a) (p)->lpVtbl->SetFormat(p,a) +#define IDirectSoundBuffer_SetVolume(p,a) (p)->lpVtbl->SetVolume(p,a) +#define IDirectSoundBuffer_SetPan(p,a) (p)->lpVtbl->SetPan(p,a) +#define IDirectSoundBuffer_SetFrequency(p,a) (p)->lpVtbl->SetFrequency(p,a) +#define IDirectSoundBuffer_Stop(p) (p)->lpVtbl->Stop(p) +#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d) +#define IDirectSoundBuffer_Restore(p) (p)->lpVtbl->Restore(p) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundBuffer_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectSoundBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b) +#define IDirectSoundBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c) +#define IDirectSoundBuffer_GetVolume(p,a) (p)->GetVolume(a) +#define IDirectSoundBuffer_GetPan(p,a) (p)->GetPan(a) +#define IDirectSoundBuffer_GetFrequency(p,a) (p)->GetFrequency(a) +#define IDirectSoundBuffer_GetStatus(p,a) (p)->GetStatus(a) +#define IDirectSoundBuffer_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g) +#define IDirectSoundBuffer_Play(p,a,b,c) (p)->Play(a,b,c) +#define IDirectSoundBuffer_SetCurrentPosition(p,a) (p)->SetCurrentPosition(a) +#define IDirectSoundBuffer_SetFormat(p,a) (p)->SetFormat(a) +#define IDirectSoundBuffer_SetVolume(p,a) (p)->SetVolume(a) +#define IDirectSoundBuffer_SetPan(p,a) (p)->SetPan(a) +#define IDirectSoundBuffer_SetFrequency(p,a) (p)->SetFrequency(a) +#define IDirectSoundBuffer_Stop(p) (p)->Stop() +#define IDirectSoundBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d) +#define IDirectSoundBuffer_Restore(p) (p)->Restore() +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundBuffer8 +// + +DEFINE_GUID(IID_IDirectSoundBuffer8, 0x6825a449, 0x7524, 0x4d82, 0x92, 0x0f, 0x50, 0xe3, 0x6a, 0xb3, 0xab, 0x1e); + +#undef INTERFACE +#define INTERFACE IDirectSoundBuffer8 + +DECLARE_INTERFACE_(IDirectSoundBuffer8, IDirectSoundBuffer) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundBuffer methods + STDMETHOD(GetCaps) (THIS_ LPDSBCAPS pDSBufferCaps) PURE; + STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; + STDMETHOD(GetVolume) (THIS_ LPLONG plVolume) PURE; + STDMETHOD(GetPan) (THIS_ LPLONG plPan) PURE; + STDMETHOD(GetFrequency) (THIS_ LPDWORD pdwFrequency) PURE; + STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; + STDMETHOD(Initialize) (THIS_ LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc) PURE; + STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; + STDMETHOD(Play) (THIS_ DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) PURE; + STDMETHOD(SetCurrentPosition) (THIS_ DWORD dwNewPosition) PURE; + STDMETHOD(SetFormat) (THIS_ LPCWAVEFORMATEX pcfxFormat) PURE; + STDMETHOD(SetVolume) (THIS_ LONG lVolume) PURE; + STDMETHOD(SetPan) (THIS_ LONG lPan) PURE; + STDMETHOD(SetFrequency) (THIS_ DWORD dwFrequency) PURE; + STDMETHOD(Stop) (THIS) PURE; + STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; + STDMETHOD(Restore) (THIS) PURE; + + // IDirectSoundBuffer8 methods + STDMETHOD(SetFX) (THIS_ DWORD dwEffectsCount, LPDSEFFECTDESC pDSFXDesc, LPDWORD pdwResultCodes) PURE; + STDMETHOD(AcquireResources) (THIS_ DWORD dwFlags, DWORD dwEffectsCount, LPDWORD pdwResultCodes) PURE; + STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE; +}; + +// Special GUID meaning "select all objects" for use in GetObjectInPath() +DEFINE_GUID(GUID_All_Objects, 0xaa114de5, 0xc262, 0x4169, 0xa1, 0xc8, 0x23, 0xd6, 0x98, 0xcc, 0x73, 0xb5); + +#define IDirectSoundBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundBuffer8_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundBuffer8_Release(p) IUnknown_Release(p) + +#define IDirectSoundBuffer8_GetCaps(p,a) IDirectSoundBuffer_GetCaps(p,a) +#define IDirectSoundBuffer8_GetCurrentPosition(p,a,b) IDirectSoundBuffer_GetCurrentPosition(p,a,b) +#define IDirectSoundBuffer8_GetFormat(p,a,b,c) IDirectSoundBuffer_GetFormat(p,a,b,c) +#define IDirectSoundBuffer8_GetVolume(p,a) IDirectSoundBuffer_GetVolume(p,a) +#define IDirectSoundBuffer8_GetPan(p,a) IDirectSoundBuffer_GetPan(p,a) +#define IDirectSoundBuffer8_GetFrequency(p,a) IDirectSoundBuffer_GetFrequency(p,a) +#define IDirectSoundBuffer8_GetStatus(p,a) IDirectSoundBuffer_GetStatus(p,a) +#define IDirectSoundBuffer8_Initialize(p,a,b) IDirectSoundBuffer_Initialize(p,a,b) +#define IDirectSoundBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundBuffer_Lock(p,a,b,c,d,e,f,g) +#define IDirectSoundBuffer8_Play(p,a,b,c) IDirectSoundBuffer_Play(p,a,b,c) +#define IDirectSoundBuffer8_SetCurrentPosition(p,a) IDirectSoundBuffer_SetCurrentPosition(p,a) +#define IDirectSoundBuffer8_SetFormat(p,a) IDirectSoundBuffer_SetFormat(p,a) +#define IDirectSoundBuffer8_SetVolume(p,a) IDirectSoundBuffer_SetVolume(p,a) +#define IDirectSoundBuffer8_SetPan(p,a) IDirectSoundBuffer_SetPan(p,a) +#define IDirectSoundBuffer8_SetFrequency(p,a) IDirectSoundBuffer_SetFrequency(p,a) +#define IDirectSoundBuffer8_Stop(p) IDirectSoundBuffer_Stop(p) +#define IDirectSoundBuffer8_Unlock(p,a,b,c,d) IDirectSoundBuffer_Unlock(p,a,b,c,d) +#define IDirectSoundBuffer8_Restore(p) IDirectSoundBuffer_Restore(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->lpVtbl->SetFX(p,a,b,c) +#define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->lpVtbl->AcquireResources(p,a,b,c) +#define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundBuffer8_SetFX(p,a,b,c) (p)->SetFX(a,b,c) +#define IDirectSoundBuffer8_AcquireResources(p,a,b,c) (p)->AcquireResources(a,b,c) +#define IDirectSoundBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSound3DListener +// + +DEFINE_GUID(IID_IDirectSound3DListener, 0x279AFA84, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); + +#undef INTERFACE +#define INTERFACE IDirectSound3DListener + +DECLARE_INTERFACE_(IDirectSound3DListener, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSound3DListener methods + STDMETHOD(GetAllParameters) (THIS_ LPDS3DLISTENER pListener) PURE; + STDMETHOD(GetDistanceFactor) (THIS_ D3DVALUE* pflDistanceFactor) PURE; + STDMETHOD(GetDopplerFactor) (THIS_ D3DVALUE* pflDopplerFactor) PURE; + STDMETHOD(GetOrientation) (THIS_ D3DVECTOR* pvOrientFront, D3DVECTOR* pvOrientTop) PURE; + STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE; + STDMETHOD(GetRolloffFactor) (THIS_ D3DVALUE* pflRolloffFactor) PURE; + STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE; + STDMETHOD(SetAllParameters) (THIS_ LPCDS3DLISTENER pcListener, DWORD dwApply) PURE; + STDMETHOD(SetDistanceFactor) (THIS_ D3DVALUE flDistanceFactor, DWORD dwApply) PURE; + STDMETHOD(SetDopplerFactor) (THIS_ D3DVALUE flDopplerFactor, DWORD dwApply) PURE; + STDMETHOD(SetOrientation) (THIS_ D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront, + D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop, DWORD dwApply) PURE; + STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; + STDMETHOD(SetRolloffFactor) (THIS_ D3DVALUE flRolloffFactor, DWORD dwApply) PURE; + STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; + STDMETHOD(CommitDeferredSettings) (THIS) PURE; +}; + +#define IDirectSound3DListener_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSound3DListener_AddRef(p) IUnknown_AddRef(p) +#define IDirectSound3DListener_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound3DListener_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->lpVtbl->GetDistanceFactor(p,a) +#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->lpVtbl->GetDopplerFactor(p,a) +#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->lpVtbl->GetOrientation(p,a,b) +#define IDirectSound3DListener_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a) +#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->lpVtbl->GetRolloffFactor(p,a) +#define IDirectSound3DListener_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a) +#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b) +#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->lpVtbl->SetDistanceFactor(p,a,b) +#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->lpVtbl->SetDopplerFactor(p,a,b) +#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->lpVtbl->SetOrientation(p,a,b,c,d,e,f,g) +#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d) +#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->lpVtbl->SetRolloffFactor(p,a,b) +#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d) +#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->lpVtbl->CommitDeferredSettings(p) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound3DListener_GetAllParameters(p,a) (p)->GetAllParameters(a) +#define IDirectSound3DListener_GetDistanceFactor(p,a) (p)->GetDistanceFactor(a) +#define IDirectSound3DListener_GetDopplerFactor(p,a) (p)->GetDopplerFactor(a) +#define IDirectSound3DListener_GetOrientation(p,a,b) (p)->GetOrientation(a,b) +#define IDirectSound3DListener_GetPosition(p,a) (p)->GetPosition(a) +#define IDirectSound3DListener_GetRolloffFactor(p,a) (p)->GetRolloffFactor(a) +#define IDirectSound3DListener_GetVelocity(p,a) (p)->GetVelocity(a) +#define IDirectSound3DListener_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b) +#define IDirectSound3DListener_SetDistanceFactor(p,a,b) (p)->SetDistanceFactor(a,b) +#define IDirectSound3DListener_SetDopplerFactor(p,a,b) (p)->SetDopplerFactor(a,b) +#define IDirectSound3DListener_SetOrientation(p,a,b,c,d,e,f,g) (p)->SetOrientation(a,b,c,d,e,f,g) +#define IDirectSound3DListener_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d) +#define IDirectSound3DListener_SetRolloffFactor(p,a,b) (p)->SetRolloffFactor(a,b) +#define IDirectSound3DListener_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d) +#define IDirectSound3DListener_CommitDeferredSettings(p) (p)->CommitDeferredSettings() +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSound3DBuffer +// + +DEFINE_GUID(IID_IDirectSound3DBuffer, 0x279AFA86, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); + +#undef INTERFACE +#define INTERFACE IDirectSound3DBuffer + +DECLARE_INTERFACE_(IDirectSound3DBuffer, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSound3DBuffer methods + STDMETHOD(GetAllParameters) (THIS_ LPDS3DBUFFER pDs3dBuffer) PURE; + STDMETHOD(GetConeAngles) (THIS_ LPDWORD pdwInsideConeAngle, LPDWORD pdwOutsideConeAngle) PURE; + STDMETHOD(GetConeOrientation) (THIS_ D3DVECTOR* pvOrientation) PURE; + STDMETHOD(GetConeOutsideVolume) (THIS_ LPLONG plConeOutsideVolume) PURE; + STDMETHOD(GetMaxDistance) (THIS_ D3DVALUE* pflMaxDistance) PURE; + STDMETHOD(GetMinDistance) (THIS_ D3DVALUE* pflMinDistance) PURE; + STDMETHOD(GetMode) (THIS_ LPDWORD pdwMode) PURE; + STDMETHOD(GetPosition) (THIS_ D3DVECTOR* pvPosition) PURE; + STDMETHOD(GetVelocity) (THIS_ D3DVECTOR* pvVelocity) PURE; + STDMETHOD(SetAllParameters) (THIS_ LPCDS3DBUFFER pcDs3dBuffer, DWORD dwApply) PURE; + STDMETHOD(SetConeAngles) (THIS_ DWORD dwInsideConeAngle, DWORD dwOutsideConeAngle, DWORD dwApply) PURE; + STDMETHOD(SetConeOrientation) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; + STDMETHOD(SetConeOutsideVolume) (THIS_ LONG lConeOutsideVolume, DWORD dwApply) PURE; + STDMETHOD(SetMaxDistance) (THIS_ D3DVALUE flMaxDistance, DWORD dwApply) PURE; + STDMETHOD(SetMinDistance) (THIS_ D3DVALUE flMinDistance, DWORD dwApply) PURE; + STDMETHOD(SetMode) (THIS_ DWORD dwMode, DWORD dwApply) PURE; + STDMETHOD(SetPosition) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; + STDMETHOD(SetVelocity) (THIS_ D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply) PURE; +}; + +#define IDirectSound3DBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSound3DBuffer_AddRef(p) IUnknown_AddRef(p) +#define IDirectSound3DBuffer_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->lpVtbl->GetConeAngles(p,a,b) +#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->lpVtbl->GetConeOrientation(p,a) +#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->lpVtbl->GetConeOutsideVolume(p,a) +#define IDirectSound3DBuffer_GetPosition(p,a) (p)->lpVtbl->GetPosition(p,a) +#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->lpVtbl->GetMinDistance(p,a) +#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->lpVtbl->GetMaxDistance(p,a) +#define IDirectSound3DBuffer_GetMode(p,a) (p)->lpVtbl->GetMode(p,a) +#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->lpVtbl->GetVelocity(p,a) +#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->lpVtbl->SetAllParameters(p,a,b) +#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->lpVtbl->SetConeAngles(p,a,b,c) +#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->lpVtbl->SetConeOrientation(p,a,b,c,d) +#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->lpVtbl->SetConeOutsideVolume(p,a,b) +#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->lpVtbl->SetPosition(p,a,b,c,d) +#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->lpVtbl->SetMinDistance(p,a,b) +#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->lpVtbl->SetMaxDistance(p,a,b) +#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->lpVtbl->SetMode(p,a,b) +#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->lpVtbl->SetVelocity(p,a,b,c,d) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSound3DBuffer_GetAllParameters(p,a) (p)->GetAllParameters(a) +#define IDirectSound3DBuffer_GetConeAngles(p,a,b) (p)->GetConeAngles(a,b) +#define IDirectSound3DBuffer_GetConeOrientation(p,a) (p)->GetConeOrientation(a) +#define IDirectSound3DBuffer_GetConeOutsideVolume(p,a) (p)->GetConeOutsideVolume(a) +#define IDirectSound3DBuffer_GetPosition(p,a) (p)->GetPosition(a) +#define IDirectSound3DBuffer_GetMinDistance(p,a) (p)->GetMinDistance(a) +#define IDirectSound3DBuffer_GetMaxDistance(p,a) (p)->GetMaxDistance(a) +#define IDirectSound3DBuffer_GetMode(p,a) (p)->GetMode(a) +#define IDirectSound3DBuffer_GetVelocity(p,a) (p)->GetVelocity(a) +#define IDirectSound3DBuffer_SetAllParameters(p,a,b) (p)->SetAllParameters(a,b) +#define IDirectSound3DBuffer_SetConeAngles(p,a,b,c) (p)->SetConeAngles(a,b,c) +#define IDirectSound3DBuffer_SetConeOrientation(p,a,b,c,d) (p)->SetConeOrientation(a,b,c,d) +#define IDirectSound3DBuffer_SetConeOutsideVolume(p,a,b) (p)->SetConeOutsideVolume(a,b) +#define IDirectSound3DBuffer_SetPosition(p,a,b,c,d) (p)->SetPosition(a,b,c,d) +#define IDirectSound3DBuffer_SetMinDistance(p,a,b) (p)->SetMinDistance(a,b) +#define IDirectSound3DBuffer_SetMaxDistance(p,a,b) (p)->SetMaxDistance(a,b) +#define IDirectSound3DBuffer_SetMode(p,a,b) (p)->SetMode(a,b) +#define IDirectSound3DBuffer_SetVelocity(p,a,b,c,d) (p)->SetVelocity(a,b,c,d) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundCapture +// + +DEFINE_GUID(IID_IDirectSoundCapture, 0xb0210781, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); + +#undef INTERFACE +#define INTERFACE IDirectSoundCapture + +DECLARE_INTERFACE_(IDirectSoundCapture, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCapture methods + STDMETHOD(CreateCaptureBuffer) (THIS_ LPCDSCBUFFERDESC pcDSCBufferDesc, LPDIRECTSOUNDCAPTUREBUFFER *ppDSCBuffer, LPUNKNOWN pUnkOuter) PURE; + STDMETHOD(GetCaps) (THIS_ LPDSCCAPS pDSCCaps) PURE; + STDMETHOD(Initialize) (THIS_ LPCGUID pcGuidDevice) PURE; +}; + +#define IDirectSoundCapture_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCapture_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCapture_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->lpVtbl->CreateCaptureBuffer(p,a,b,c) +#define IDirectSoundCapture_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectSoundCapture_Initialize(p,a) (p)->lpVtbl->Initialize(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCapture_CreateCaptureBuffer(p,a,b,c) (p)->CreateCaptureBuffer(a,b,c) +#define IDirectSoundCapture_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectSoundCapture_Initialize(p,a) (p)->Initialize(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundCaptureBuffer +// + +DEFINE_GUID(IID_IDirectSoundCaptureBuffer, 0xb0210782, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); + +#undef INTERFACE +#define INTERFACE IDirectSoundCaptureBuffer + +DECLARE_INTERFACE_(IDirectSoundCaptureBuffer, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCaptureBuffer methods + STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE; + STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; + STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; + STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE; + STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; + STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE; + STDMETHOD(Stop) (THIS) PURE; + STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; +}; + +#define IDirectSoundCaptureBuffer_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCaptureBuffer_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCaptureBuffer_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->lpVtbl->GetCaps(p,a) +#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->lpVtbl->GetCurrentPosition(p,a,b) +#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->lpVtbl->GetFormat(p,a,b,c) +#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->lpVtbl->GetStatus(p,a) +#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b) +#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->lpVtbl->Lock(p,a,b,c,d,e,f,g) +#define IDirectSoundCaptureBuffer_Start(p,a) (p)->lpVtbl->Start(p,a) +#define IDirectSoundCaptureBuffer_Stop(p) (p)->lpVtbl->Stop(p) +#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->lpVtbl->Unlock(p,a,b,c,d) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureBuffer_GetCaps(p,a) (p)->GetCaps(a) +#define IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) (p)->GetCurrentPosition(a,b) +#define IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) (p)->GetFormat(a,b,c) +#define IDirectSoundCaptureBuffer_GetStatus(p,a) (p)->GetStatus(a) +#define IDirectSoundCaptureBuffer_Initialize(p,a,b) (p)->Initialize(a,b) +#define IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) (p)->Lock(a,b,c,d,e,f,g) +#define IDirectSoundCaptureBuffer_Start(p,a) (p)->Start(a) +#define IDirectSoundCaptureBuffer_Stop(p) (p)->Stop() +#define IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) (p)->Unlock(a,b,c,d) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundCaptureBuffer8 +// + +DEFINE_GUID(IID_IDirectSoundCaptureBuffer8, 0x990df4, 0xdbb, 0x4872, 0x83, 0x3e, 0x6d, 0x30, 0x3e, 0x80, 0xae, 0xb6); + +#undef INTERFACE +#define INTERFACE IDirectSoundCaptureBuffer8 + +DECLARE_INTERFACE_(IDirectSoundCaptureBuffer8, IDirectSoundCaptureBuffer) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCaptureBuffer methods + STDMETHOD(GetCaps) (THIS_ LPDSCBCAPS pDSCBCaps) PURE; + STDMETHOD(GetCurrentPosition) (THIS_ LPDWORD pdwCapturePosition, LPDWORD pdwReadPosition) PURE; + STDMETHOD(GetFormat) (THIS_ LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten) PURE; + STDMETHOD(GetStatus) (THIS_ LPDWORD pdwStatus) PURE; + STDMETHOD(Initialize) (THIS_ LPDIRECTSOUNDCAPTURE pDirectSoundCapture, LPCDSCBUFFERDESC pcDSCBufferDesc) PURE; + STDMETHOD(Lock) (THIS_ DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1, + LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags) PURE; + STDMETHOD(Start) (THIS_ DWORD dwFlags) PURE; + STDMETHOD(Stop) (THIS) PURE; + STDMETHOD(Unlock) (THIS_ LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2) PURE; + + // IDirectSoundCaptureBuffer8 methods + STDMETHOD(GetObjectInPath) (THIS_ REFGUID rguidObject, DWORD dwIndex, REFGUID rguidInterface, LPVOID *ppObject) PURE; + STDMETHOD(GetFXStatus) (DWORD dwFXCount, LPDWORD pdwFXStatus) PURE; +}; + +#define IDirectSoundCaptureBuffer8_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCaptureBuffer8_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCaptureBuffer8_Release(p) IUnknown_Release(p) + +#define IDirectSoundCaptureBuffer8_GetCaps(p,a) IDirectSoundCaptureBuffer_GetCaps(p,a) +#define IDirectSoundCaptureBuffer8_GetCurrentPosition(p,a,b) IDirectSoundCaptureBuffer_GetCurrentPosition(p,a,b) +#define IDirectSoundCaptureBuffer8_GetFormat(p,a,b,c) IDirectSoundCaptureBuffer_GetFormat(p,a,b,c) +#define IDirectSoundCaptureBuffer8_GetStatus(p,a) IDirectSoundCaptureBuffer_GetStatus(p,a) +#define IDirectSoundCaptureBuffer8_Initialize(p,a,b) IDirectSoundCaptureBuffer_Initialize(p,a,b) +#define IDirectSoundCaptureBuffer8_Lock(p,a,b,c,d,e,f,g) IDirectSoundCaptureBuffer_Lock(p,a,b,c,d,e,f,g) +#define IDirectSoundCaptureBuffer8_Start(p,a) IDirectSoundCaptureBuffer_Start(p,a) +#define IDirectSoundCaptureBuffer8_Stop(p) IDirectSoundCaptureBuffer_Stop(p)) +#define IDirectSoundCaptureBuffer8_Unlock(p,a,b,c,d) IDirectSoundCaptureBuffer_Unlock(p,a,b,c,d) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->lpVtbl->GetObjectInPath(p,a,b,c,d) +#define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->lpVtbl->GetFXStatus(p,a,b) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureBuffer8_GetObjectInPath(p,a,b,c,d) (p)->GetObjectInPath(a,b,c,d) +#define IDirectSoundCaptureBuffer8_GetFXStatus(p,a,b) (p)->GetFXStatus(a,b) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundNotify +// + +DEFINE_GUID(IID_IDirectSoundNotify, 0xb0210783, 0x89cd, 0x11d0, 0xaf, 0x8, 0x0, 0xa0, 0xc9, 0x25, 0xcd, 0x16); + +#undef INTERFACE +#define INTERFACE IDirectSoundNotify + +DECLARE_INTERFACE_(IDirectSoundNotify, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundNotify methods + STDMETHOD(SetNotificationPositions) (THIS_ DWORD dwPositionNotifies, LPCDSBPOSITIONNOTIFY pcPositionNotifies) PURE; +}; + +#define IDirectSoundNotify_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundNotify_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundNotify_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->lpVtbl->SetNotificationPositions(p,a,b) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundNotify_SetNotificationPositions(p,a,b) (p)->SetNotificationPositions(a,b) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IKsPropertySet +// + +#ifndef _IKsPropertySet_ +#define _IKsPropertySet_ + +#ifdef __cplusplus +// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined +struct IKsPropertySet; +#endif // __cplusplus + +typedef struct IKsPropertySet *LPKSPROPERTYSET; + +#define KSPROPERTY_SUPPORT_GET 0x00000001 +#define KSPROPERTY_SUPPORT_SET 0x00000002 + +DEFINE_GUID(IID_IKsPropertySet, 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93); + +#undef INTERFACE +#define INTERFACE IKsPropertySet + +DECLARE_INTERFACE_(IKsPropertySet, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IKsPropertySet methods + STDMETHOD(Get) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength, + LPVOID pPropertyData, ULONG ulDataLength, PULONG pulBytesReturned) PURE; + STDMETHOD(Set) (THIS_ REFGUID rguidPropSet, ULONG ulId, LPVOID pInstanceData, ULONG ulInstanceLength, + LPVOID pPropertyData, ULONG ulDataLength) PURE; + STDMETHOD(QuerySupport) (THIS_ REFGUID rguidPropSet, ULONG ulId, PULONG pulTypeSupport) PURE; +}; + +#define IKsPropertySet_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IKsPropertySet_AddRef(p) IUnknown_AddRef(p) +#define IKsPropertySet_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->lpVtbl->Get(p,a,b,c,d,e,f,g) +#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->lpVtbl->Set(p,a,b,c,d,e,f) +#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->lpVtbl->QuerySupport(p,a,b,c) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IKsPropertySet_Get(p,a,b,c,d,e,f,g) (p)->Get(a,b,c,d,e,f,g) +#define IKsPropertySet_Set(p,a,b,c,d,e,f) (p)->Set(a,b,c,d,e,f) +#define IKsPropertySet_QuerySupport(p,a,b,c) (p)->QuerySupport(a,b,c) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // _IKsPropertySet_ + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// IDirectSoundFXGargle +// + +DEFINE_GUID(IID_IDirectSoundFXGargle, 0xd616f352, 0xd622, 0x11ce, 0xaa, 0xc5, 0x00, 0x20, 0xaf, 0x0b, 0x99, 0xa3); + +typedef struct _DSFXGargle +{ + DWORD dwRateHz; // Rate of modulation in hz + DWORD dwWaveShape; // DSFXGARGLE_WAVE_xxx +} DSFXGargle, *LPDSFXGargle; + +#define DSFXGARGLE_WAVE_TRIANGLE 0 +#define DSFXGARGLE_WAVE_SQUARE 1 + +typedef const DSFXGargle *LPCDSFXGargle; + +#define DSFXGARGLE_RATEHZ_MIN 1 +#define DSFXGARGLE_RATEHZ_MAX 1000 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXGargle + +DECLARE_INTERFACE_(IDirectSoundFXGargle, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXGargle methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXGargle pcDsFxGargle) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXGargle pDsFxGargle) PURE; +}; + +#define IDirectSoundFXGargle_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXGargle_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXGargle_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXGargle_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXGargle_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXChorus +// + +DEFINE_GUID(IID_IDirectSoundFXChorus, 0x880842e3, 0x145f, 0x43e6, 0xa9, 0x34, 0xa7, 0x18, 0x06, 0xe5, 0x05, 0x47); + +typedef struct _DSFXChorus +{ + FLOAT fWetDryMix; + FLOAT fDepth; + FLOAT fFeedback; + FLOAT fFrequency; + LONG lWaveform; // LFO shape; DSFXCHORUS_WAVE_xxx + FLOAT fDelay; + LONG lPhase; +} DSFXChorus, *LPDSFXChorus; + +typedef const DSFXChorus *LPCDSFXChorus; + +#define DSFXCHORUS_WAVE_TRIANGLE 0 +#define DSFXCHORUS_WAVE_SIN 1 + +#define DSFXCHORUS_WETDRYMIX_MIN 0.0f +#define DSFXCHORUS_WETDRYMIX_MAX 100.0f +#define DSFXCHORUS_DEPTH_MIN 0.0f +#define DSFXCHORUS_DEPTH_MAX 100.0f +#define DSFXCHORUS_FEEDBACK_MIN -99.0f +#define DSFXCHORUS_FEEDBACK_MAX 99.0f +#define DSFXCHORUS_FREQUENCY_MIN 0.0f +#define DSFXCHORUS_FREQUENCY_MAX 10.0f +#define DSFXCHORUS_DELAY_MIN 0.0f +#define DSFXCHORUS_DELAY_MAX 20.0f +#define DSFXCHORUS_PHASE_MIN 0 +#define DSFXCHORUS_PHASE_MAX 4 + +#define DSFXCHORUS_PHASE_NEG_180 0 +#define DSFXCHORUS_PHASE_NEG_90 1 +#define DSFXCHORUS_PHASE_ZERO 2 +#define DSFXCHORUS_PHASE_90 3 +#define DSFXCHORUS_PHASE_180 4 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXChorus + +DECLARE_INTERFACE_(IDirectSoundFXChorus, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXChorus methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXChorus pcDsFxChorus) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXChorus pDsFxChorus) PURE; +}; + +#define IDirectSoundFXChorus_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXChorus_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXChorus_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXChorus_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXChorus_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXFlanger +// + +DEFINE_GUID(IID_IDirectSoundFXFlanger, 0x903e9878, 0x2c92, 0x4072, 0x9b, 0x2c, 0xea, 0x68, 0xf5, 0x39, 0x67, 0x83); + +typedef struct _DSFXFlanger +{ + FLOAT fWetDryMix; + FLOAT fDepth; + FLOAT fFeedback; + FLOAT fFrequency; + LONG lWaveform; + FLOAT fDelay; + LONG lPhase; +} DSFXFlanger, *LPDSFXFlanger; + +typedef const DSFXFlanger *LPCDSFXFlanger; + +#define DSFXFLANGER_WAVE_TRIANGLE 0 +#define DSFXFLANGER_WAVE_SIN 1 + +#define DSFXFLANGER_WETDRYMIX_MIN 0.0f +#define DSFXFLANGER_WETDRYMIX_MAX 100.0f +#define DSFXFLANGER_FREQUENCY_MIN 0.0f +#define DSFXFLANGER_FREQUENCY_MAX 10.0f +#define DSFXFLANGER_DEPTH_MIN 0.0f +#define DSFXFLANGER_DEPTH_MAX 100.0f +#define DSFXFLANGER_PHASE_MIN 0 +#define DSFXFLANGER_PHASE_MAX 4 +#define DSFXFLANGER_FEEDBACK_MIN -99.0f +#define DSFXFLANGER_FEEDBACK_MAX 99.0f +#define DSFXFLANGER_DELAY_MIN 0.0f +#define DSFXFLANGER_DELAY_MAX 4.0f + +#define DSFXFLANGER_PHASE_NEG_180 0 +#define DSFXFLANGER_PHASE_NEG_90 1 +#define DSFXFLANGER_PHASE_ZERO 2 +#define DSFXFLANGER_PHASE_90 3 +#define DSFXFLANGER_PHASE_180 4 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXFlanger + +DECLARE_INTERFACE_(IDirectSoundFXFlanger, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXFlanger methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXFlanger pcDsFxFlanger) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXFlanger pDsFxFlanger) PURE; +}; + +#define IDirectSoundFXFlanger_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXFlanger_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXFlanger_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXFlanger_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXFlanger_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXEcho +// + +DEFINE_GUID(IID_IDirectSoundFXEcho, 0x8bd28edf, 0x50db, 0x4e92, 0xa2, 0xbd, 0x44, 0x54, 0x88, 0xd1, 0xed, 0x42); + +typedef struct _DSFXEcho +{ + FLOAT fWetDryMix; + FLOAT fFeedback; + FLOAT fLeftDelay; + FLOAT fRightDelay; + LONG lPanDelay; +} DSFXEcho, *LPDSFXEcho; + +typedef const DSFXEcho *LPCDSFXEcho; + +#define DSFXECHO_WETDRYMIX_MIN 0.0f +#define DSFXECHO_WETDRYMIX_MAX 100.0f +#define DSFXECHO_FEEDBACK_MIN 0.0f +#define DSFXECHO_FEEDBACK_MAX 100.0f +#define DSFXECHO_LEFTDELAY_MIN 1.0f +#define DSFXECHO_LEFTDELAY_MAX 2000.0f +#define DSFXECHO_RIGHTDELAY_MIN 1.0f +#define DSFXECHO_RIGHTDELAY_MAX 2000.0f +#define DSFXECHO_PANDELAY_MIN 0 +#define DSFXECHO_PANDELAY_MAX 1 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXEcho + +DECLARE_INTERFACE_(IDirectSoundFXEcho, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXEcho methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXEcho pcDsFxEcho) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXEcho pDsFxEcho) PURE; +}; + +#define IDirectSoundFXEcho_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXEcho_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXEcho_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXEcho_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXEcho_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXDistortion +// + +DEFINE_GUID(IID_IDirectSoundFXDistortion, 0x8ecf4326, 0x455f, 0x4d8b, 0xbd, 0xa9, 0x8d, 0x5d, 0x3e, 0x9e, 0x3e, 0x0b); + +typedef struct _DSFXDistortion +{ + FLOAT fGain; + FLOAT fEdge; + FLOAT fPostEQCenterFrequency; + FLOAT fPostEQBandwidth; + FLOAT fPreLowpassCutoff; +} DSFXDistortion, *LPDSFXDistortion; + +typedef const DSFXDistortion *LPCDSFXDistortion; + +#define DSFXDISTORTION_GAIN_MIN -60.0f +#define DSFXDISTORTION_GAIN_MAX 0.0f +#define DSFXDISTORTION_EDGE_MIN 0.0f +#define DSFXDISTORTION_EDGE_MAX 100.0f +#define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MIN 100.0f +#define DSFXDISTORTION_POSTEQCENTERFREQUENCY_MAX 8000.0f +#define DSFXDISTORTION_POSTEQBANDWIDTH_MIN 100.0f +#define DSFXDISTORTION_POSTEQBANDWIDTH_MAX 8000.0f +#define DSFXDISTORTION_PRELOWPASSCUTOFF_MIN 100.0f +#define DSFXDISTORTION_PRELOWPASSCUTOFF_MAX 8000.0f + +#undef INTERFACE +#define INTERFACE IDirectSoundFXDistortion + +DECLARE_INTERFACE_(IDirectSoundFXDistortion, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXDistortion methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXDistortion pcDsFxDistortion) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXDistortion pDsFxDistortion) PURE; +}; + +#define IDirectSoundFXDistortion_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXDistortion_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXDistortion_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXDistortion_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXDistortion_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXCompressor +// + +DEFINE_GUID(IID_IDirectSoundFXCompressor, 0x4bbd1154, 0x62f6, 0x4e2c, 0xa1, 0x5c, 0xd3, 0xb6, 0xc4, 0x17, 0xf7, 0xa0); + +typedef struct _DSFXCompressor +{ + FLOAT fGain; + FLOAT fAttack; + FLOAT fRelease; + FLOAT fThreshold; + FLOAT fRatio; + FLOAT fPredelay; +} DSFXCompressor, *LPDSFXCompressor; + +typedef const DSFXCompressor *LPCDSFXCompressor; + +#define DSFXCOMPRESSOR_GAIN_MIN -60.0f +#define DSFXCOMPRESSOR_GAIN_MAX 60.0f +#define DSFXCOMPRESSOR_ATTACK_MIN 0.01f +#define DSFXCOMPRESSOR_ATTACK_MAX 500.0f +#define DSFXCOMPRESSOR_RELEASE_MIN 50.0f +#define DSFXCOMPRESSOR_RELEASE_MAX 3000.0f +#define DSFXCOMPRESSOR_THRESHOLD_MIN -60.0f +#define DSFXCOMPRESSOR_THRESHOLD_MAX 0.0f +#define DSFXCOMPRESSOR_RATIO_MIN 1.0f +#define DSFXCOMPRESSOR_RATIO_MAX 100.0f +#define DSFXCOMPRESSOR_PREDELAY_MIN 0.0f +#define DSFXCOMPRESSOR_PREDELAY_MAX 4.0f + +#undef INTERFACE +#define INTERFACE IDirectSoundFXCompressor + +DECLARE_INTERFACE_(IDirectSoundFXCompressor, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXCompressor methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXCompressor pcDsFxCompressor) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXCompressor pDsFxCompressor) PURE; +}; + +#define IDirectSoundFXCompressor_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXCompressor_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXCompressor_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXCompressor_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXCompressor_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXParamEq +// + +DEFINE_GUID(IID_IDirectSoundFXParamEq, 0xc03ca9fe, 0xfe90, 0x4204, 0x80, 0x78, 0x82, 0x33, 0x4c, 0xd1, 0x77, 0xda); + +typedef struct _DSFXParamEq +{ + FLOAT fCenter; + FLOAT fBandwidth; + FLOAT fGain; +} DSFXParamEq, *LPDSFXParamEq; + +typedef const DSFXParamEq *LPCDSFXParamEq; + +#define DSFXPARAMEQ_CENTER_MIN 80.0f +#define DSFXPARAMEQ_CENTER_MAX 16000.0f +#define DSFXPARAMEQ_BANDWIDTH_MIN 1.0f +#define DSFXPARAMEQ_BANDWIDTH_MAX 36.0f +#define DSFXPARAMEQ_GAIN_MIN -15.0f +#define DSFXPARAMEQ_GAIN_MAX 15.0f + +#undef INTERFACE +#define INTERFACE IDirectSoundFXParamEq + +DECLARE_INTERFACE_(IDirectSoundFXParamEq, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXParamEq methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXParamEq pcDsFxParamEq) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXParamEq pDsFxParamEq) PURE; +}; + +#define IDirectSoundFXParamEq_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXParamEq_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXParamEq_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXParamEq_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXParamEq_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXI3DL2Reverb +// + +DEFINE_GUID(IID_IDirectSoundFXI3DL2Reverb, 0x4b166a6a, 0x0d66, 0x43f3, 0x80, 0xe3, 0xee, 0x62, 0x80, 0xde, 0xe1, 0xa4); + +typedef struct _DSFXI3DL2Reverb +{ + LONG lRoom; // [-10000, 0] default: -1000 mB + LONG lRoomHF; // [-10000, 0] default: 0 mB + FLOAT flRoomRolloffFactor; // [0.0, 10.0] default: 0.0 + FLOAT flDecayTime; // [0.1, 20.0] default: 1.49s + FLOAT flDecayHFRatio; // [0.1, 2.0] default: 0.83 + LONG lReflections; // [-10000, 1000] default: -2602 mB + FLOAT flReflectionsDelay; // [0.0, 0.3] default: 0.007 s + LONG lReverb; // [-10000, 2000] default: 200 mB + FLOAT flReverbDelay; // [0.0, 0.1] default: 0.011 s + FLOAT flDiffusion; // [0.0, 100.0] default: 100.0 % + FLOAT flDensity; // [0.0, 100.0] default: 100.0 % + FLOAT flHFReference; // [20.0, 20000.0] default: 5000.0 Hz +} DSFXI3DL2Reverb, *LPDSFXI3DL2Reverb; + +typedef const DSFXI3DL2Reverb *LPCDSFXI3DL2Reverb; + +#define DSFX_I3DL2REVERB_ROOM_MIN (-10000) +#define DSFX_I3DL2REVERB_ROOM_MAX 0 +#define DSFX_I3DL2REVERB_ROOM_DEFAULT (-1000) + +#define DSFX_I3DL2REVERB_ROOMHF_MIN (-10000) +#define DSFX_I3DL2REVERB_ROOMHF_MAX 0 +#define DSFX_I3DL2REVERB_ROOMHF_DEFAULT (-100) + +#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MIN 0.0f +#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MAX 10.0f +#define DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_DEFAULT 0.0f + +#define DSFX_I3DL2REVERB_DECAYTIME_MIN 0.1f +#define DSFX_I3DL2REVERB_DECAYTIME_MAX 20.0f +#define DSFX_I3DL2REVERB_DECAYTIME_DEFAULT 1.49f + +#define DSFX_I3DL2REVERB_DECAYHFRATIO_MIN 0.1f +#define DSFX_I3DL2REVERB_DECAYHFRATIO_MAX 2.0f +#define DSFX_I3DL2REVERB_DECAYHFRATIO_DEFAULT 0.83f + +#define DSFX_I3DL2REVERB_REFLECTIONS_MIN (-10000) +#define DSFX_I3DL2REVERB_REFLECTIONS_MAX 1000 +#define DSFX_I3DL2REVERB_REFLECTIONS_DEFAULT (-2602) + +#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MIN 0.0f +#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_MAX 0.3f +#define DSFX_I3DL2REVERB_REFLECTIONSDELAY_DEFAULT 0.007f + +#define DSFX_I3DL2REVERB_REVERB_MIN (-10000) +#define DSFX_I3DL2REVERB_REVERB_MAX 2000 +#define DSFX_I3DL2REVERB_REVERB_DEFAULT (200) + +#define DSFX_I3DL2REVERB_REVERBDELAY_MIN 0.0f +#define DSFX_I3DL2REVERB_REVERBDELAY_MAX 0.1f +#define DSFX_I3DL2REVERB_REVERBDELAY_DEFAULT 0.011f + +#define DSFX_I3DL2REVERB_DIFFUSION_MIN 0.0f +#define DSFX_I3DL2REVERB_DIFFUSION_MAX 100.0f +#define DSFX_I3DL2REVERB_DIFFUSION_DEFAULT 100.0f + +#define DSFX_I3DL2REVERB_DENSITY_MIN 0.0f +#define DSFX_I3DL2REVERB_DENSITY_MAX 100.0f +#define DSFX_I3DL2REVERB_DENSITY_DEFAULT 100.0f + +#define DSFX_I3DL2REVERB_HFREFERENCE_MIN 20.0f +#define DSFX_I3DL2REVERB_HFREFERENCE_MAX 20000.0f +#define DSFX_I3DL2REVERB_HFREFERENCE_DEFAULT 5000.0f + +#define DSFX_I3DL2REVERB_QUALITY_MIN 0 +#define DSFX_I3DL2REVERB_QUALITY_MAX 3 +#define DSFX_I3DL2REVERB_QUALITY_DEFAULT 2 + +#undef INTERFACE +#define INTERFACE IDirectSoundFXI3DL2Reverb + +DECLARE_INTERFACE_(IDirectSoundFXI3DL2Reverb, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXI3DL2Reverb methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXI3DL2Reverb pcDsFxI3DL2Reverb) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXI3DL2Reverb pDsFxI3DL2Reverb) PURE; + STDMETHOD(SetPreset) (THIS_ DWORD dwPreset) PURE; + STDMETHOD(GetPreset) (THIS_ LPDWORD pdwPreset) PURE; + STDMETHOD(SetQuality) (THIS_ LONG lQuality) PURE; + STDMETHOD(GetQuality) (THIS_ LONG *plQuality) PURE; +}; + +#define IDirectSoundFXI3DL2Reverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXI3DL2Reverb_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXI3DL2Reverb_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->lpVtbl->SetPreset(p,a) +#define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->lpVtbl->GetPreset(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXI3DL2Reverb_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXI3DL2Reverb_GetAllParameters(p,a) (p)->GetAllParameters(a) +#define IDirectSoundFXI3DL2Reverb_SetPreset(p,a) (p)->SetPreset(a) +#define IDirectSoundFXI3DL2Reverb_GetPreset(p,a) (p)->GetPreset(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundFXWavesReverb +// + +DEFINE_GUID(IID_IDirectSoundFXWavesReverb,0x46858c3a,0x0dc6,0x45e3,0xb7,0x60,0xd4,0xee,0xf1,0x6c,0xb3,0x25); + +typedef struct _DSFXWavesReverb +{ + FLOAT fInGain; // [-96.0,0.0] default: 0.0 dB + FLOAT fReverbMix; // [-96.0,0.0] default: 0.0 db + FLOAT fReverbTime; // [0.001,3000.0] default: 1000.0 ms + FLOAT fHighFreqRTRatio; // [0.001,0.999] default: 0.001 +} DSFXWavesReverb, *LPDSFXWavesReverb; + +typedef const DSFXWavesReverb *LPCDSFXWavesReverb; + +#define DSFX_WAVESREVERB_INGAIN_MIN -96.0f +#define DSFX_WAVESREVERB_INGAIN_MAX 0.0f +#define DSFX_WAVESREVERB_INGAIN_DEFAULT 0.0f +#define DSFX_WAVESREVERB_REVERBMIX_MIN -96.0f +#define DSFX_WAVESREVERB_REVERBMIX_MAX 0.0f +#define DSFX_WAVESREVERB_REVERBMIX_DEFAULT 0.0f +#define DSFX_WAVESREVERB_REVERBTIME_MIN 0.001f +#define DSFX_WAVESREVERB_REVERBTIME_MAX 3000.0f +#define DSFX_WAVESREVERB_REVERBTIME_DEFAULT 1000.0f +#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MIN 0.001f +#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_MAX 0.999f +#define DSFX_WAVESREVERB_HIGHFREQRTRATIO_DEFAULT 0.001f + +#undef INTERFACE +#define INTERFACE IDirectSoundFXWavesReverb + +DECLARE_INTERFACE_(IDirectSoundFXWavesReverb, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFXWavesReverb methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSFXWavesReverb pcDsFxWavesReverb) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSFXWavesReverb pDsFxWavesReverb) PURE; +}; + +#define IDirectSoundFXWavesReverb_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFXWavesReverb_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFXWavesReverb_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFXWavesReverb_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundFXWavesReverb_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +// +// IDirectSoundCaptureFXAec +// + +DEFINE_GUID(IID_IDirectSoundCaptureFXAec, 0xad74143d, 0x903d, 0x4ab7, 0x80, 0x66, 0x28, 0xd3, 0x63, 0x03, 0x6d, 0x65); + +typedef struct _DSCFXAec +{ + BOOL fEnable; + BOOL fNoiseFill; + DWORD dwMode; +} DSCFXAec, *LPDSCFXAec; + +typedef const DSCFXAec *LPCDSCFXAec; + +// These match the AEC_MODE_* constants in the DDK's ksmedia.h file +#define DSCFX_AEC_MODE_PASS_THROUGH 0x0 +#define DSCFX_AEC_MODE_HALF_DUPLEX 0x1 +#define DSCFX_AEC_MODE_FULL_DUPLEX 0x2 + +// These match the AEC_STATUS_* constants in ksmedia.h +#define DSCFX_AEC_STATUS_HISTORY_UNINITIALIZED 0x0 +#define DSCFX_AEC_STATUS_HISTORY_CONTINUOUSLY_CONVERGED 0x1 +#define DSCFX_AEC_STATUS_HISTORY_PREVIOUSLY_DIVERGED 0x2 +#define DSCFX_AEC_STATUS_CURRENTLY_CONVERGED 0x8 + +#undef INTERFACE +#define INTERFACE IDirectSoundCaptureFXAec + +DECLARE_INTERFACE_(IDirectSoundCaptureFXAec, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCaptureFXAec methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXAec pDscFxAec) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSCFXAec pDscFxAec) PURE; + STDMETHOD(GetStatus) (THIS_ PDWORD pdwStatus) PURE; + STDMETHOD(Reset) (THIS) PURE; +}; + +#define IDirectSoundCaptureFXAec_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCaptureFXAec_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCaptureFXAec_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureFXAec_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundCaptureFXAec_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + + +// +// IDirectSoundCaptureFXNoiseSuppress +// + +DEFINE_GUID(IID_IDirectSoundCaptureFXNoiseSuppress, 0xed311e41, 0xfbae, 0x4175, 0x96, 0x25, 0xcd, 0x8, 0x54, 0xf6, 0x93, 0xca); + +typedef struct _DSCFXNoiseSuppress +{ + BOOL fEnable; +} DSCFXNoiseSuppress, *LPDSCFXNoiseSuppress; + +typedef const DSCFXNoiseSuppress *LPCDSCFXNoiseSuppress; + +#undef INTERFACE +#define INTERFACE IDirectSoundCaptureFXNoiseSuppress + +DECLARE_INTERFACE_(IDirectSoundCaptureFXNoiseSuppress, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundCaptureFXNoiseSuppress methods + STDMETHOD(SetAllParameters) (THIS_ LPCDSCFXNoiseSuppress pcDscFxNoiseSuppress) PURE; + STDMETHOD(GetAllParameters) (THIS_ LPDSCFXNoiseSuppress pDscFxNoiseSuppress) PURE; + STDMETHOD(Reset) (THIS) PURE; +}; + +#define IDirectSoundCaptureFXNoiseSuppress_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundCaptureFXNoiseSuppress_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundCaptureFXNoiseSuppress_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->lpVtbl->SetAllParameters(p,a) +#define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->lpVtbl->GetAllParameters(p,a) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundCaptureFXNoiseSuppress_SetAllParameters(p,a) (p)->SetAllParameters(a) +#define IDirectSoundCaptureFXNoiseSuppress_GetAllParameters(p,a) (p)->GetAllParameters(a) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + + +// +// IDirectSoundFullDuplex +// + +#ifndef _IDirectSoundFullDuplex_ +#define _IDirectSoundFullDuplex_ + +#ifdef __cplusplus +// 'struct' not 'class' per the way DECLARE_INTERFACE_ is defined +struct IDirectSoundFullDuplex; +#endif // __cplusplus + +typedef struct IDirectSoundFullDuplex *LPDIRECTSOUNDFULLDUPLEX; + +DEFINE_GUID(IID_IDirectSoundFullDuplex, 0xedcb4c7a, 0xdaab, 0x4216, 0xa4, 0x2e, 0x6c, 0x50, 0x59, 0x6d, 0xdc, 0x1d); + +#undef INTERFACE +#define INTERFACE IDirectSoundFullDuplex + +DECLARE_INTERFACE_(IDirectSoundFullDuplex, IUnknown) +{ + // IUnknown methods + STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; + STDMETHOD_(ULONG,AddRef) (THIS) PURE; + STDMETHOD_(ULONG,Release) (THIS) PURE; + + // IDirectSoundFullDuplex methods + STDMETHOD(Initialize) (THIS_ LPCGUID pCaptureGuid, LPCGUID pRenderGuid, LPCDSCBUFFERDESC lpDscBufferDesc, LPCDSBUFFERDESC lpDsBufferDesc, HWND hWnd, DWORD dwLevel, LPLPDIRECTSOUNDCAPTUREBUFFER8 lplpDirectSoundCaptureBuffer8, LPLPDIRECTSOUNDBUFFER8 lplpDirectSoundBuffer8) PURE; +}; + +#define IDirectSoundFullDuplex_QueryInterface(p,a,b) IUnknown_QueryInterface(p,a,b) +#define IDirectSoundFullDuplex_AddRef(p) IUnknown_AddRef(p) +#define IDirectSoundFullDuplex_Release(p) IUnknown_Release(p) + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->Initialize(p,a,b,c,d,e,f,g,h) +#else // !defined(__cplusplus) || defined(CINTERFACE) +#define IDirectSoundFullDuplex_Initialize(p,a,b,c,d,e,f,g,h) (p)->Initialize(a,b,c,d,e,f,g,h) +#endif // !defined(__cplusplus) || defined(CINTERFACE) + +#endif // _IDirectSoundFullDuplex_ + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +// +// Return Codes +// + +// The function completed successfully +#define DS_OK S_OK + +// The call succeeded, but we had to substitute the 3D algorithm +#define DS_NO_VIRTUALIZATION MAKE_HRESULT(0, _FACDS, 10) + +// The call failed because resources (such as a priority level) +// were already being used by another caller +#define DSERR_ALLOCATED MAKE_DSHRESULT(10) + +// The control (vol, pan, etc.) requested by the caller is not available +#define DSERR_CONTROLUNAVAIL MAKE_DSHRESULT(30) + +// An invalid parameter was passed to the returning function +#define DSERR_INVALIDPARAM E_INVALIDARG + +// This call is not valid for the current state of this object +#define DSERR_INVALIDCALL MAKE_DSHRESULT(50) + +// An undetermined error occurred inside the DirectSound subsystem +#define DSERR_GENERIC E_FAIL + +// The caller does not have the priority level required for the function to +// succeed +#define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70) + +// Not enough free memory is available to complete the operation +#define DSERR_OUTOFMEMORY E_OUTOFMEMORY + +// The specified WAVE format is not supported +#define DSERR_BADFORMAT MAKE_DSHRESULT(100) + +// The function called is not supported at this time +#define DSERR_UNSUPPORTED E_NOTIMPL + +// No sound driver is available for use +#define DSERR_NODRIVER MAKE_DSHRESULT(120) + +// This object is already initialized +#define DSERR_ALREADYINITIALIZED MAKE_DSHRESULT(130) + +// This object does not support aggregation +#define DSERR_NOAGGREGATION CLASS_E_NOAGGREGATION + +// The buffer memory has been lost, and must be restored +#define DSERR_BUFFERLOST MAKE_DSHRESULT(150) + +// Another app has a higher priority level, preventing this call from +// succeeding +#define DSERR_OTHERAPPHASPRIO MAKE_DSHRESULT(160) + +// This object has not been initialized +#define DSERR_UNINITIALIZED MAKE_DSHRESULT(170) + +// The requested COM interface is not available +#define DSERR_NOINTERFACE E_NOINTERFACE + +// Access is denied +#define DSERR_ACCESSDENIED E_ACCESSDENIED + +// Tried to create a DSBCAPS_CTRLFX buffer shorter than DSBSIZE_FX_MIN milliseconds +#define DSERR_BUFFERTOOSMALL MAKE_DSHRESULT(180) + +// Attempt to use DirectSound 8 functionality on an older DirectSound object +#define DSERR_DS8_REQUIRED MAKE_DSHRESULT(190) + +// A circular loop of send effects was detected +#define DSERR_SENDLOOP MAKE_DSHRESULT(200) + +// The GUID specified in an audiopath file does not match a valid MIXIN buffer +#define DSERR_BADSENDBUFFERGUID MAKE_DSHRESULT(210) + +// The object requested was not found (numerically equal to DMUS_E_NOT_FOUND) +#define DSERR_OBJECTNOTFOUND MAKE_DSHRESULT(4449) + +// The effects requested could not be found on the system, or they were found +// but in the wrong order, or in the wrong hardware/software locations. +#define DSERR_FXUNAVAILABLE MAKE_DSHRESULT(220) + +// +// Flags +// + +#define DSCAPS_PRIMARYMONO 0x00000001 +#define DSCAPS_PRIMARYSTEREO 0x00000002 +#define DSCAPS_PRIMARY8BIT 0x00000004 +#define DSCAPS_PRIMARY16BIT 0x00000008 +#define DSCAPS_CONTINUOUSRATE 0x00000010 +#define DSCAPS_EMULDRIVER 0x00000020 +#define DSCAPS_CERTIFIED 0x00000040 +#define DSCAPS_SECONDARYMONO 0x00000100 +#define DSCAPS_SECONDARYSTEREO 0x00000200 +#define DSCAPS_SECONDARY8BIT 0x00000400 +#define DSCAPS_SECONDARY16BIT 0x00000800 + +#define DSSCL_NORMAL 0x00000001 +#define DSSCL_PRIORITY 0x00000002 +#define DSSCL_EXCLUSIVE 0x00000003 +#define DSSCL_WRITEPRIMARY 0x00000004 + +#define DSSPEAKER_DIRECTOUT 0x00000000 +#define DSSPEAKER_HEADPHONE 0x00000001 +#define DSSPEAKER_MONO 0x00000002 +#define DSSPEAKER_QUAD 0x00000003 +#define DSSPEAKER_STEREO 0x00000004 +#define DSSPEAKER_SURROUND 0x00000005 +#define DSSPEAKER_5POINT1 0x00000006 +#define DSSPEAKER_7POINT1 0x00000007 + +#define DSSPEAKER_GEOMETRY_MIN 0x00000005 // 5 degrees +#define DSSPEAKER_GEOMETRY_NARROW 0x0000000A // 10 degrees +#define DSSPEAKER_GEOMETRY_WIDE 0x00000014 // 20 degrees +#define DSSPEAKER_GEOMETRY_MAX 0x000000B4 // 180 degrees + +#define DSSPEAKER_COMBINED(c, g) ((DWORD)(((BYTE)(c)) | ((DWORD)((BYTE)(g))) << 16)) +#define DSSPEAKER_CONFIG(a) ((BYTE)(a)) +#define DSSPEAKER_GEOMETRY(a) ((BYTE)(((DWORD)(a) >> 16) & 0x00FF)) + +#define DSBCAPS_PRIMARYBUFFER 0x00000001 +#define DSBCAPS_STATIC 0x00000002 +#define DSBCAPS_LOCHARDWARE 0x00000004 +#define DSBCAPS_LOCSOFTWARE 0x00000008 +#define DSBCAPS_CTRL3D 0x00000010 +#define DSBCAPS_CTRLFREQUENCY 0x00000020 +#define DSBCAPS_CTRLPAN 0x00000040 +#define DSBCAPS_CTRLVOLUME 0x00000080 +#define DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100 +#define DSBCAPS_CTRLFX 0x00000200 +#define DSBCAPS_STICKYFOCUS 0x00004000 +#define DSBCAPS_GLOBALFOCUS 0x00008000 +#define DSBCAPS_GETCURRENTPOSITION2 0x00010000 +#define DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000 +#define DSBCAPS_LOCDEFER 0x00040000 + +#define DSBPLAY_LOOPING 0x00000001 +#define DSBPLAY_LOCHARDWARE 0x00000002 +#define DSBPLAY_LOCSOFTWARE 0x00000004 +#define DSBPLAY_TERMINATEBY_TIME 0x00000008 +#define DSBPLAY_TERMINATEBY_DISTANCE 0x000000010 +#define DSBPLAY_TERMINATEBY_PRIORITY 0x000000020 + +#define DSBSTATUS_PLAYING 0x00000001 +#define DSBSTATUS_BUFFERLOST 0x00000002 +#define DSBSTATUS_LOOPING 0x00000004 +#define DSBSTATUS_LOCHARDWARE 0x00000008 +#define DSBSTATUS_LOCSOFTWARE 0x00000010 +#define DSBSTATUS_TERMINATED 0x00000020 + +#define DSBLOCK_FROMWRITECURSOR 0x00000001 +#define DSBLOCK_ENTIREBUFFER 0x00000002 + +#define DSBFREQUENCY_ORIGINAL 0 +#define DSBFREQUENCY_MIN 100 +#if DIRECTSOUND_VERSION >= 0x0900 +#define DSBFREQUENCY_MAX 200000 +#else +#define DSBFREQUENCY_MAX 100000 +#endif + +#define DSBPAN_LEFT -10000 +#define DSBPAN_CENTER 0 +#define DSBPAN_RIGHT 10000 + +#define DSBVOLUME_MIN -10000 +#define DSBVOLUME_MAX 0 + +#define DSBSIZE_MIN 4 +#define DSBSIZE_MAX 0x0FFFFFFF +#define DSBSIZE_FX_MIN 150 // NOTE: Milliseconds, not bytes + +#define DS3DMODE_NORMAL 0x00000000 +#define DS3DMODE_HEADRELATIVE 0x00000001 +#define DS3DMODE_DISABLE 0x00000002 + +#define DS3D_IMMEDIATE 0x00000000 +#define DS3D_DEFERRED 0x00000001 + +#define DS3D_MINDISTANCEFACTOR FLT_MIN +#define DS3D_MAXDISTANCEFACTOR FLT_MAX +#define DS3D_DEFAULTDISTANCEFACTOR 1.0f + +#define DS3D_MINROLLOFFFACTOR 0.0f +#define DS3D_MAXROLLOFFFACTOR 10.0f +#define DS3D_DEFAULTROLLOFFFACTOR 1.0f + +#define DS3D_MINDOPPLERFACTOR 0.0f +#define DS3D_MAXDOPPLERFACTOR 10.0f +#define DS3D_DEFAULTDOPPLERFACTOR 1.0f + +#define DS3D_DEFAULTMINDISTANCE 1.0f +#define DS3D_DEFAULTMAXDISTANCE 1000000000.0f + +#define DS3D_MINCONEANGLE 0 +#define DS3D_MAXCONEANGLE 360 +#define DS3D_DEFAULTCONEANGLE 360 + +#define DS3D_DEFAULTCONEOUTSIDEVOLUME DSBVOLUME_MAX + +// IDirectSoundCapture attributes + +#define DSCCAPS_EMULDRIVER DSCAPS_EMULDRIVER +#define DSCCAPS_CERTIFIED DSCAPS_CERTIFIED +#define DSCCAPS_MULTIPLECAPTURE 0x00000001 + +// IDirectSoundCaptureBuffer attributes + +#define DSCBCAPS_WAVEMAPPED 0x80000000 + +#if DIRECTSOUND_VERSION >= 0x0800 +#define DSCBCAPS_CTRLFX 0x00000200 +#endif + + +#define DSCBLOCK_ENTIREBUFFER 0x00000001 + +#define DSCBSTATUS_CAPTURING 0x00000001 +#define DSCBSTATUS_LOOPING 0x00000002 + +#define DSCBSTART_LOOPING 0x00000001 + +#define DSBPN_OFFSETSTOP 0xFFFFFFFF + +#define DS_CERTIFIED 0x00000000 +#define DS_UNCERTIFIED 0x00000001 + + +// +// Flags for the I3DL2 effects +// + +// +// I3DL2 Material Presets +// + +enum +{ + DSFX_I3DL2_MATERIAL_PRESET_SINGLEWINDOW, + DSFX_I3DL2_MATERIAL_PRESET_DOUBLEWINDOW, + DSFX_I3DL2_MATERIAL_PRESET_THINDOOR, + DSFX_I3DL2_MATERIAL_PRESET_THICKDOOR, + DSFX_I3DL2_MATERIAL_PRESET_WOODWALL, + DSFX_I3DL2_MATERIAL_PRESET_BRICKWALL, + DSFX_I3DL2_MATERIAL_PRESET_STONEWALL, + DSFX_I3DL2_MATERIAL_PRESET_CURTAIN +}; + +#define I3DL2_MATERIAL_PRESET_SINGLEWINDOW -2800,0.71f +#define I3DL2_MATERIAL_PRESET_DOUBLEWINDOW -5000,0.40f +#define I3DL2_MATERIAL_PRESET_THINDOOR -1800,0.66f +#define I3DL2_MATERIAL_PRESET_THICKDOOR -4400,0.64f +#define I3DL2_MATERIAL_PRESET_WOODWALL -4000,0.50f +#define I3DL2_MATERIAL_PRESET_BRICKWALL -5000,0.60f +#define I3DL2_MATERIAL_PRESET_STONEWALL -6000,0.68f +#define I3DL2_MATERIAL_PRESET_CURTAIN -1200,0.15f + +enum +{ + DSFX_I3DL2_ENVIRONMENT_PRESET_DEFAULT, + DSFX_I3DL2_ENVIRONMENT_PRESET_GENERIC, + DSFX_I3DL2_ENVIRONMENT_PRESET_PADDEDCELL, + DSFX_I3DL2_ENVIRONMENT_PRESET_ROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_BATHROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_LIVINGROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_STONEROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_AUDITORIUM, + DSFX_I3DL2_ENVIRONMENT_PRESET_CONCERTHALL, + DSFX_I3DL2_ENVIRONMENT_PRESET_CAVE, + DSFX_I3DL2_ENVIRONMENT_PRESET_ARENA, + DSFX_I3DL2_ENVIRONMENT_PRESET_HANGAR, + DSFX_I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY, + DSFX_I3DL2_ENVIRONMENT_PRESET_HALLWAY, + DSFX_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR, + DSFX_I3DL2_ENVIRONMENT_PRESET_ALLEY, + DSFX_I3DL2_ENVIRONMENT_PRESET_FOREST, + DSFX_I3DL2_ENVIRONMENT_PRESET_CITY, + DSFX_I3DL2_ENVIRONMENT_PRESET_MOUNTAINS, + DSFX_I3DL2_ENVIRONMENT_PRESET_QUARRY, + DSFX_I3DL2_ENVIRONMENT_PRESET_PLAIN, + DSFX_I3DL2_ENVIRONMENT_PRESET_PARKINGLOT, + DSFX_I3DL2_ENVIRONMENT_PRESET_SEWERPIPE, + DSFX_I3DL2_ENVIRONMENT_PRESET_UNDERWATER, + DSFX_I3DL2_ENVIRONMENT_PRESET_SMALLROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEROOM, + DSFX_I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL, + DSFX_I3DL2_ENVIRONMENT_PRESET_LARGEHALL, + DSFX_I3DL2_ENVIRONMENT_PRESET_PLATE +}; + +// +// I3DL2 Reverberation Presets Values +// + +#define I3DL2_ENVIRONMENT_PRESET_DEFAULT -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_GENERIC -1000, -100, 0.0f, 1.49f, 0.83f, -2602, 0.007f, 200, 0.011f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_PADDEDCELL -1000,-6000, 0.0f, 0.17f, 0.10f, -1204, 0.001f, 207, 0.002f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_ROOM -1000, -454, 0.0f, 0.40f, 0.83f, -1646, 0.002f, 53, 0.003f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_BATHROOM -1000,-1200, 0.0f, 1.49f, 0.54f, -370, 0.007f, 1030, 0.011f, 100.0f, 60.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_LIVINGROOM -1000,-6000, 0.0f, 0.50f, 0.10f, -1376, 0.003f, -1104, 0.004f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_STONEROOM -1000, -300, 0.0f, 2.31f, 0.64f, -711, 0.012f, 83, 0.017f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_AUDITORIUM -1000, -476, 0.0f, 4.32f, 0.59f, -789, 0.020f, -289, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_CONCERTHALL -1000, -500, 0.0f, 3.92f, 0.70f, -1230, 0.020f, -2, 0.029f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_CAVE -1000, 0, 0.0f, 2.91f, 1.30f, -602, 0.015f, -302, 0.022f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_ARENA -1000, -698, 0.0f, 7.24f, 0.33f, -1166, 0.020f, 16, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_HANGAR -1000,-1000, 0.0f,10.05f, 0.23f, -602, 0.020f, 198, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY -1000,-4000, 0.0f, 0.30f, 0.10f, -1831, 0.002f, -1630, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_HALLWAY -1000, -300, 0.0f, 1.49f, 0.59f, -1219, 0.007f, 441, 0.011f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR -1000, -237, 0.0f, 2.70f, 0.79f, -1214, 0.013f, 395, 0.020f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_ALLEY -1000, -270, 0.0f, 1.49f, 0.86f, -1204, 0.007f, -4, 0.011f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_FOREST -1000,-3300, 0.0f, 1.49f, 0.54f, -2560, 0.162f, -613, 0.088f, 79.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_CITY -1000, -800, 0.0f, 1.49f, 0.67f, -2273, 0.007f, -2217, 0.011f, 50.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_MOUNTAINS -1000,-2500, 0.0f, 1.49f, 0.21f, -2780, 0.300f, -2014, 0.100f, 27.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_QUARRY -1000,-1000, 0.0f, 1.49f, 0.83f,-10000, 0.061f, 500, 0.025f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_PLAIN -1000,-2000, 0.0f, 1.49f, 0.50f, -2466, 0.179f, -2514, 0.100f, 21.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_PARKINGLOT -1000, 0, 0.0f, 1.65f, 1.50f, -1363, 0.008f, -1153, 0.012f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_SEWERPIPE -1000,-1000, 0.0f, 2.81f, 0.14f, 429, 0.014f, 648, 0.021f, 80.0f, 60.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_UNDERWATER -1000,-4000, 0.0f, 1.49f, 0.10f, -449, 0.007f, 1700, 0.011f, 100.0f, 100.0f, 5000.0f + +// +// Examples simulating 'musical' reverb presets +// +// Name Decay time Description +// Small Room 1.1s A small size room with a length of 5m or so. +// Medium Room 1.3s A medium size room with a length of 10m or so. +// Large Room 1.5s A large size room suitable for live performances. +// Medium Hall 1.8s A medium size concert hall. +// Large Hall 1.8s A large size concert hall suitable for a full orchestra. +// Plate 1.3s A plate reverb simulation. +// + +#define I3DL2_ENVIRONMENT_PRESET_SMALLROOM -1000, -600, 0.0f, 1.10f, 0.83f, -400, 0.005f, 500, 0.010f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM -1000, -600, 0.0f, 1.30f, 0.83f, -1000, 0.010f, -200, 0.020f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_LARGEROOM -1000, -600, 0.0f, 1.50f, 0.83f, -1600, 0.020f, -1000, 0.040f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL -1000, -600, 0.0f, 1.80f, 0.70f, -1300, 0.015f, -800, 0.030f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_LARGEHALL -1000, -600, 0.0f, 1.80f, 0.70f, -2000, 0.030f, -1400, 0.060f, 100.0f, 100.0f, 5000.0f +#define I3DL2_ENVIRONMENT_PRESET_PLATE -1000, -200, 0.0f, 1.30f, 0.90f, 0, 0.002f, 0, 0.010f, 100.0f, 75.0f, 5000.0f + +// +// DirectSound3D Algorithms +// + +// Default DirectSound3D algorithm {00000000-0000-0000-0000-000000000000} +#define DS3DALG_DEFAULT GUID_NULL + +// No virtualization (Pan3D) {C241333F-1C1B-11d2-94F5-00C04FC28ACA} +DEFINE_GUID(DS3DALG_NO_VIRTUALIZATION, 0xc241333f, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); + +// High-quality HRTF algorithm {C2413340-1C1B-11d2-94F5-00C04FC28ACA} +DEFINE_GUID(DS3DALG_HRTF_FULL, 0xc2413340, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); + +// Lower-quality HRTF algorithm {C2413342-1C1B-11d2-94F5-00C04FC28ACA} +DEFINE_GUID(DS3DALG_HRTF_LIGHT, 0xc2413342, 0x1c1b, 0x11d2, 0x94, 0xf5, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca); + + +#if DIRECTSOUND_VERSION >= 0x0800 + +// +// DirectSound Internal Effect Algorithms +// + + +// Gargle {DAFD8210-5711-4B91-9FE3-F75B7AE279BF} +DEFINE_GUID(GUID_DSFX_STANDARD_GARGLE, 0xdafd8210, 0x5711, 0x4b91, 0x9f, 0xe3, 0xf7, 0x5b, 0x7a, 0xe2, 0x79, 0xbf); + +// Chorus {EFE6629C-81F7-4281-BD91-C9D604A95AF6} +DEFINE_GUID(GUID_DSFX_STANDARD_CHORUS, 0xefe6629c, 0x81f7, 0x4281, 0xbd, 0x91, 0xc9, 0xd6, 0x04, 0xa9, 0x5a, 0xf6); + +// Flanger {EFCA3D92-DFD8-4672-A603-7420894BAD98} +DEFINE_GUID(GUID_DSFX_STANDARD_FLANGER, 0xefca3d92, 0xdfd8, 0x4672, 0xa6, 0x03, 0x74, 0x20, 0x89, 0x4b, 0xad, 0x98); + +// Echo/Delay {EF3E932C-D40B-4F51-8CCF-3F98F1B29D5D} +DEFINE_GUID(GUID_DSFX_STANDARD_ECHO, 0xef3e932c, 0xd40b, 0x4f51, 0x8c, 0xcf, 0x3f, 0x98, 0xf1, 0xb2, 0x9d, 0x5d); + +// Distortion {EF114C90-CD1D-484E-96E5-09CFAF912A21} +DEFINE_GUID(GUID_DSFX_STANDARD_DISTORTION, 0xef114c90, 0xcd1d, 0x484e, 0x96, 0xe5, 0x09, 0xcf, 0xaf, 0x91, 0x2a, 0x21); + +// Compressor/Limiter {EF011F79-4000-406D-87AF-BFFB3FC39D57} +DEFINE_GUID(GUID_DSFX_STANDARD_COMPRESSOR, 0xef011f79, 0x4000, 0x406d, 0x87, 0xaf, 0xbf, 0xfb, 0x3f, 0xc3, 0x9d, 0x57); + +// Parametric Equalization {120CED89-3BF4-4173-A132-3CB406CF3231} +DEFINE_GUID(GUID_DSFX_STANDARD_PARAMEQ, 0x120ced89, 0x3bf4, 0x4173, 0xa1, 0x32, 0x3c, 0xb4, 0x06, 0xcf, 0x32, 0x31); + +// I3DL2 Environmental Reverberation: Reverb (Listener) Effect {EF985E71-D5C7-42D4-BA4D-2D073E2E96F4} +DEFINE_GUID(GUID_DSFX_STANDARD_I3DL2REVERB, 0xef985e71, 0xd5c7, 0x42d4, 0xba, 0x4d, 0x2d, 0x07, 0x3e, 0x2e, 0x96, 0xf4); + +// Waves Reverberation {87FC0268-9A55-4360-95AA-004A1D9DE26C} +DEFINE_GUID(GUID_DSFX_WAVES_REVERB, 0x87fc0268, 0x9a55, 0x4360, 0x95, 0xaa, 0x00, 0x4a, 0x1d, 0x9d, 0xe2, 0x6c); + +// +// DirectSound Capture Effect Algorithms +// + + +// Acoustic Echo Canceller {BF963D80-C559-11D0-8A2B-00A0C9255AC1} +// Matches KSNODETYPE_ACOUSTIC_ECHO_CANCEL in ksmedia.h +DEFINE_GUID(GUID_DSCFX_CLASS_AEC, 0xBF963D80L, 0xC559, 0x11D0, 0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1); + +// Microsoft AEC {CDEBB919-379A-488a-8765-F53CFD36DE40} +DEFINE_GUID(GUID_DSCFX_MS_AEC, 0xcdebb919, 0x379a, 0x488a, 0x87, 0x65, 0xf5, 0x3c, 0xfd, 0x36, 0xde, 0x40); + +// System AEC {1C22C56D-9879-4f5b-A389-27996DDC2810} +DEFINE_GUID(GUID_DSCFX_SYSTEM_AEC, 0x1c22c56d, 0x9879, 0x4f5b, 0xa3, 0x89, 0x27, 0x99, 0x6d, 0xdc, 0x28, 0x10); + +// Noise Supression {E07F903F-62FD-4e60-8CDD-DEA7236665B5} +// Matches KSNODETYPE_NOISE_SUPPRESS in post Windows ME DDK's ksmedia.h +DEFINE_GUID(GUID_DSCFX_CLASS_NS, 0xe07f903f, 0x62fd, 0x4e60, 0x8c, 0xdd, 0xde, 0xa7, 0x23, 0x66, 0x65, 0xb5); + +// Microsoft Noise Suppresion {11C5C73B-66E9-4ba1-A0BA-E814C6EED92D} +DEFINE_GUID(GUID_DSCFX_MS_NS, 0x11c5c73b, 0x66e9, 0x4ba1, 0xa0, 0xba, 0xe8, 0x14, 0xc6, 0xee, 0xd9, 0x2d); + +// System Noise Suppresion {5AB0882E-7274-4516-877D-4EEE99BA4FD0} +DEFINE_GUID(GUID_DSCFX_SYSTEM_NS, 0x5ab0882e, 0x7274, 0x4516, 0x87, 0x7d, 0x4e, 0xee, 0x99, 0xba, 0x4f, 0xd0); + +#endif // DIRECTSOUND_VERSION >= 0x0800 + +#endif // __DSOUND_INCLUDED__ + + + +#ifdef __cplusplus +}; +#endif // __cplusplus + + diff --git a/desmume/src/windows/directx/dsound.lib b/src/windows/directx/dsound.lib similarity index 100% rename from desmume/src/windows/directx/dsound.lib rename to src/windows/directx/dsound.lib diff --git a/desmume/src/windows/directx/dxerr8.h b/src/windows/directx/dxerr8.h similarity index 96% rename from desmume/src/windows/directx/dxerr8.h rename to src/windows/directx/dxerr8.h index 4f4d84806..c2744306e 100644 --- a/desmume/src/windows/directx/dxerr8.h +++ b/src/windows/directx/dxerr8.h @@ -1,99 +1,99 @@ -/*==========================================================================; - * - * - * File: dxerr8.h - * Content: DirectX Error Library Include File - * - ****************************************************************************/ - -#ifndef _DXERR8_H_ -#define _DXERR8_H_ - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -// -// DXGetErrorString8 -// -// Desc: Converts a DirectX HRESULT to a string -// -// Args: HRESULT hr Can be any error code from -// D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW -// -// Return: Converted string -// -const char* WINAPI DXGetErrorString8A(HRESULT hr); -const WCHAR* WINAPI DXGetErrorString8W(HRESULT hr); - -#ifdef UNICODE -#define DXGetErrorString8 DXGetErrorString8W -#else -#define DXGetErrorString8 DXGetErrorString8A -#endif - - -// -// DXGetErrorDescription8 -// -// Desc: Returns a string description of a DirectX HRESULT -// -// Args: HRESULT hr Can be any error code from -// D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW -// -// Return: String description -// -const char* WINAPI DXGetErrorDescription8A(HRESULT hr); -const WCHAR* WINAPI DXGetErrorDescription8W(HRESULT hr); - -#ifdef UNICODE - #define DXGetErrorDescription8 DXGetErrorDescription8W -#else - #define DXGetErrorDescription8 DXGetErrorDescription8A -#endif - - -// -// DXTrace -// -// Desc: Outputs a formatted error message to the debug stream -// -// Args: CHAR* strFile The current file, typically passed in using the -// __FILE__ macro. -// DWORD dwLine The current line number, typically passed in using the -// __LINE__ macro. -// HRESULT hr An HRESULT that will be traced to the debug stream. -// CHAR* strMsg A string that will be traced to the debug stream (may be NULL) -// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info. -// -// Return: The hr that was passed in. -// -HRESULT WINAPI DXTraceA( const char* strFile, DWORD dwLine, HRESULT hr, const char* strMsg, BOOL bPopMsgBox ); -HRESULT WINAPI DXTraceW( const char* strFile, DWORD dwLine, HRESULT hr, const WCHAR* strMsg, BOOL bPopMsgBox ); - -#ifdef UNICODE -#define DXTrace DXTraceW -#else -#define DXTrace DXTraceA -#endif - - -// -// Helper macros -// -#if defined(DEBUG) | defined(_DEBUG) -#define DXTRACE_MSG(str) DXTrace( __FILE__, (DWORD)__LINE__, 0, str, FALSE ) -#define DXTRACE_ERR(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, TRUE ) -#define DXTRACE_ERR_NOMSGBOX(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, FALSE ) -#else -#define DXTRACE_MSG(str) (0L) -#define DXTRACE_ERR(str,hr) (hr) -#define DXTRACE_ERR_NOMSGBOX(str,hr) (hr) -#endif - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif // _DXERR8_H_ +/*==========================================================================; + * + * + * File: dxerr8.h + * Content: DirectX Error Library Include File + * + ****************************************************************************/ + +#ifndef _DXERR8_H_ +#define _DXERR8_H_ + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +// +// DXGetErrorString8 +// +// Desc: Converts a DirectX HRESULT to a string +// +// Args: HRESULT hr Can be any error code from +// D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW +// +// Return: Converted string +// +const char* WINAPI DXGetErrorString8A(HRESULT hr); +const WCHAR* WINAPI DXGetErrorString8W(HRESULT hr); + +#ifdef UNICODE +#define DXGetErrorString8 DXGetErrorString8W +#else +#define DXGetErrorString8 DXGetErrorString8A +#endif + + +// +// DXGetErrorDescription8 +// +// Desc: Returns a string description of a DirectX HRESULT +// +// Args: HRESULT hr Can be any error code from +// D3D8 D3DX8 DDRAW DPLAY8 DMUSIC DSOUND DINPUT DSHOW +// +// Return: String description +// +const char* WINAPI DXGetErrorDescription8A(HRESULT hr); +const WCHAR* WINAPI DXGetErrorDescription8W(HRESULT hr); + +#ifdef UNICODE + #define DXGetErrorDescription8 DXGetErrorDescription8W +#else + #define DXGetErrorDescription8 DXGetErrorDescription8A +#endif + + +// +// DXTrace +// +// Desc: Outputs a formatted error message to the debug stream +// +// Args: CHAR* strFile The current file, typically passed in using the +// __FILE__ macro. +// DWORD dwLine The current line number, typically passed in using the +// __LINE__ macro. +// HRESULT hr An HRESULT that will be traced to the debug stream. +// CHAR* strMsg A string that will be traced to the debug stream (may be NULL) +// BOOL bPopMsgBox If TRUE, then a message box will popup also containing the passed info. +// +// Return: The hr that was passed in. +// +HRESULT WINAPI DXTraceA( const char* strFile, DWORD dwLine, HRESULT hr, const char* strMsg, BOOL bPopMsgBox ); +HRESULT WINAPI DXTraceW( const char* strFile, DWORD dwLine, HRESULT hr, const WCHAR* strMsg, BOOL bPopMsgBox ); + +#ifdef UNICODE +#define DXTrace DXTraceW +#else +#define DXTrace DXTraceA +#endif + + +// +// Helper macros +// +#if defined(DEBUG) | defined(_DEBUG) +#define DXTRACE_MSG(str) DXTrace( __FILE__, (DWORD)__LINE__, 0, str, FALSE ) +#define DXTRACE_ERR(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, TRUE ) +#define DXTRACE_ERR_NOMSGBOX(str,hr) DXTrace( __FILE__, (DWORD)__LINE__, hr, str, FALSE ) +#else +#define DXTRACE_MSG(str) (0L) +#define DXTRACE_ERR(str,hr) (hr) +#define DXTRACE_ERR_NOMSGBOX(str,hr) (hr) +#endif + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif // _DXERR8_H_ diff --git a/desmume/src/windows/directx/dxguid.lib b/src/windows/directx/dxguid.lib similarity index 100% rename from desmume/src/windows/directx/dxguid.lib rename to src/windows/directx/dxguid.lib diff --git a/desmume/src/windows/disView.cpp b/src/windows/disView.cpp similarity index 96% rename from desmume/src/windows/disView.cpp rename to src/windows/disView.cpp index 6d7df45a2..6b009f57e 100644 --- a/desmume/src/windows/disView.cpp +++ b/src/windows/disView.cpp @@ -1,733 +1,733 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include -#include "../MMU.h" -#include "../Disassembler.h" -#include "../NDSSystem.h" -#include "../armcpu.h" -#include "disView.h" -#include -#include "resource.h" - -typedef struct -{ - BOOL autogo; - BOOL autoup; - u32 autoup_secs; - u32 curr_ligne; - armcpu_t *cpu; - u16 mode; -} disview_struct; - -disview_struct *DisView7 = NULL; -disview_struct *DisView9 = NULL; - -static HWND DisViewWnd[2] = {NULL, NULL}; - -#define INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF)) - -LRESULT DisViewBox_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - SIZE fontsize; - TCHAR text[100]; - TCHAR txt[100]; - RECT rect; - int lg; - int ht; - HDC mem_dc; - HBITMAP mem_bmp; - u32 nbligne; - - GetClientRect(hwnd, &rect); - lg = rect.right - rect.left; - ht = rect.bottom - rect.top; - - hdc = BeginPaint(hwnd, &ps); - - mem_dc = CreateCompatibleDC(hdc); - mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); - SelectObject(mem_dc, mem_bmp); - - FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT)); - - GetTextExtentPoint32(mem_dc, "0", 1, &fontsize); - - nbligne = ht/fontsize.cy; - - SetTextColor(mem_dc, RGB(0,0,0)); - - if((win->mode==1) || ((win->mode==0) && (win->cpu->CPSR.bits.T == 0))) - { - u32 i; - u32 adr; - - if (win->autoup||win->autogo) - win->curr_ligne = (win->cpu->instruct_adr >> 2) - (win->curr_ligne % nbligne) ; - adr = win->curr_ligne*4; - - for(i = 0; i < nbligne; ++i) - { - u32 ins = MMU_read32(win->cpu->proc_ID, adr); - des_arm_instructions_set[INDEX(ins)](adr, ins, txt); - sprintf(text, "%04X:%04X %08X %s", (int)(adr>>16), (int)(adr&0xFFFF), (int)ins, txt); - DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX); - rect.top+=fontsize.cy; - adr += 4; - } - - - - if(((win->cpu->instruct_adr&0x0FFFFFFF) >= (win->curr_ligne<<2))&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+(nbligne<<2)))) - { - HBRUSH brjaune = CreateSolidBrush(RGB(255, 255, 0)); - SetBkColor(mem_dc, RGB(255, 255, 0)); - rect.top = (((win->cpu->instruct_adr&0x0FFFFFFF)>>2) - win->curr_ligne)*fontsize.cy; - rect.bottom = rect.top + fontsize.cy; - FillRect(mem_dc, &rect, brjaune); - des_arm_instructions_set[INDEX(win->cpu->instruction)](win->cpu->instruct_adr, win->cpu->instruction, txt); - sprintf(text, "%04X:%04X %08X %s", (int)((win->cpu->instruct_adr&0x0FFFFFFF)>>16), (int)(win->cpu->instruct_adr&0xFFFF), (int)win->cpu->instruction, txt); - DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX); - DeleteObject(brjaune); - } - } - else - { /* thumb display */ - u32 i; - u32 adr; - if (win->autoup) - win->curr_ligne = (win->cpu->instruct_adr >> 1) - (win->curr_ligne % nbligne) ; - - adr = win->curr_ligne*2; - - for(i = 0; i < nbligne; ++i) - { - u32 ins = MMU_read16(win->cpu->proc_ID, adr); - des_thumb_instructions_set[ins>>6](adr, ins, txt); - sprintf(text, "%04X:%04X %04X %s", (int)(adr>>16), (int)(adr&0xFFFF), (int)ins, txt); - DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX); - rect.top+=fontsize.cy; - adr += 2; - } - - if(((win->cpu->instruct_adr&0x0FFFFFFF) >= (win->curr_ligne<<1))&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+(nbligne<<1)))) - { - HBRUSH brjaune = CreateSolidBrush(RGB(255, 255, 0)); - SetBkColor(mem_dc, RGB(255, 255, 0)); - - rect.top = (((win->cpu->instruct_adr&0x0FFFFFFF)>>1) - win->curr_ligne)*fontsize.cy; - rect.bottom = rect.top + fontsize.cy; - FillRect(mem_dc, &rect, brjaune); - des_thumb_instructions_set[((win->cpu->instruction)&0xFFFF)>>6](win->cpu->instruct_adr, win->cpu->instruction&0xFFFF, txt); - sprintf(text, "%04X:%04X %04X %s", (int)((win->cpu->instruct_adr&0x0FFFFFFF)>>16), (int)(win->cpu->instruct_adr&0xFFFF), (int)(win->cpu->instruction&0xFFFF), txt); - DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX); - DeleteObject(brjaune); - } - } - - BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); - - DeleteDC(mem_dc); - DeleteObject(mem_bmp); - - EndPaint(hwnd, &ps); - return 1; -} - -LRESULT DisViewDialog_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - TCHAR text[80]; - u32 i; - - hdc = BeginPaint(hwnd, &ps); - - for(i = 0; i < 16; ++i) - { - sprintf(text, "%08X", (int)win->cpu->R[i]); - SetWindowText(GetDlgItem(hwnd, IDC_R0+i), text); - } - - #define OFF 16 - - SetBkMode(hdc, TRANSPARENT); - if(win->cpu->CPSR.bits.N) - SetTextColor(hdc, RGB(255,0,0)); - else - SetTextColor(hdc, RGB(70, 70, 70)); - TextOut(hdc, 452+OFF, 238, "N", 1); - - if(win->cpu->CPSR.bits.Z) - SetTextColor(hdc, RGB(255,0,0)); - else - SetTextColor(hdc, RGB(70, 70, 70)); - TextOut(hdc, 464+OFF, 238, "Z", 1); - - if(win->cpu->CPSR.bits.C) - SetTextColor(hdc, RGB(255,0,0)); - else - SetTextColor(hdc, RGB(70, 70, 70)); - TextOut(hdc, 475+OFF, 238, "C", 1); - - if(win->cpu->CPSR.bits.V) - SetTextColor(hdc, RGB(255,0,0)); - else - SetTextColor(hdc, RGB(70, 70, 70)); - TextOut(hdc, 486+OFF, 238, "V", 1); - - if(win->cpu->CPSR.bits.Q) - SetTextColor(hdc, RGB(255,0,0)); - else - SetTextColor(hdc, RGB(70, 70, 70)); - TextOut(hdc, 497+OFF, 238, "Q", 1); - - if(!win->cpu->CPSR.bits.I) - SetTextColor(hdc, RGB(255,0,0)); - else - SetTextColor(hdc, RGB(70, 70, 70)); - TextOut(hdc, 508+OFF, 238, "I", 1); - - sprintf(text, "%02X", (int)win->cpu->CPSR.bits.mode); - SetWindowText(GetDlgItem(hwnd, IDC_MODE), text); - - sprintf(text, "%08X", MMU.timer[0][0]);//win->cpu->SPSR); - SetWindowText(GetDlgItem(hwnd, IDC_TMP), text); - - EndPaint(hwnd, &ps); - return 1; -} - -// =================================================== ARM7 -LRESULT CALLBACK ViewDisasm_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_NCCREATE: - SetScrollRange(hwnd, SB_VERT, 0, 0x3FFFFF7, TRUE); - SetScrollPos(hwnd, SB_VERT, 10, TRUE); - return 1; - - case WM_NCDESTROY: - //free(win); - return 1; - - case WM_PAINT: - DisViewBox_OnPaint(hwnd, DisView7, wParam, lParam); - return 1; - - case WM_VSCROLL : - { - RECT rect; - SIZE fontsize; - HDC dc; - HFONT old; - int nbligne; - - GetClientRect(hwnd, &rect); - dc = GetDC(hwnd); - old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); - GetTextExtentPoint32(dc, "0", 1, &fontsize); - - nbligne = (rect.bottom - rect.top)/fontsize.cy; - - switch LOWORD(wParam) - { - case SB_LINEDOWN : - DisView7->curr_ligne = std::min(0x3FFFFF7*(1+DisView7->cpu->CPSR.bits.T), DisView7->curr_ligne+1); - break; - case SB_LINEUP : - DisView7->curr_ligne = (u32)std::max(0, (s32)DisView7->curr_ligne-1); - break; - case SB_PAGEDOWN : - DisView7->curr_ligne = std::min(0x3FFFFF7*(1+DisView7->cpu->CPSR.bits.T), DisView7->curr_ligne+nbligne); - break; - case SB_PAGEUP : - DisView7->curr_ligne = (u32)std::max(0, DisView7->curr_ligne-nbligne); - break; - } - - SelectObject(dc, old); - SetScrollPos(hwnd, SB_VERT, DisView7->curr_ligne, TRUE); - InvalidateRect(hwnd, NULL, FALSE); - } - return 1; - - case WM_ERASEBKGND: - return 1; - } - return FALSE; -} - -BOOL CALLBACK ViewDisasm_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - //bail out early if the dialog isnt initialized - if(!DisView7 && message != WM_INITDIALOG) - return false; - - switch (message) - { - case WM_INITDIALOG : - { - SetWindowText(hwnd, "ARM7 Disassembler"); - SetDlgItemInt(hwnd, IDC_SETPNUM, 1, FALSE); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_DES), BM_SETCHECK, TRUE, 0); - DisView7 = new disview_struct; - memset(DisView7, 0, sizeof(disview_struct)); - DisView7->cpu = &NDS_ARM7; - DisView7->autoup_secs = 1; - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETRANGE, 0, MAKELONG(99, 1)); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETPOS32, 0, DisView7->autoup_secs); - DisViewWnd[1] = NULL; - return 1; - } - case WM_CLOSE : - { - if(DisView7->autoup) - { - KillTimer(hwnd, IDT_VIEW_DISASM7); - DisView7->autoup = false; - } - if (DisView7!=NULL) - { - delete DisView7; - DisView7 = NULL; - } - DisViewWnd[1] = NULL; - //INFO("Close ARM7 disassembler\n"); - PostQuitMessage(0); - return 1; - } - case WM_PAINT: - DisViewDialog_OnPaint(hwnd, DisView7, wParam, lParam); - return 1; - case WM_TIMER: - SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); - return 1; - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDC_FERMER : - SendMessage(hwnd, WM_CLOSE, 0, 0); - return 0; - case IDC_AUTO_DES : - /* address to line correction */ - if ((DisView7->cpu->CPSR.bits.T) && (DisView7->mode == 1)) { - /* from arm to thumb, line * 2*/ - DisView7->curr_ligne <<= 1 ; - } else if (!(DisView7->cpu->CPSR.bits.T) && (DisView7->mode == 2)) { - /* from thumb to arm, line / 2 */ - DisView7->curr_ligne >>= 1 ; - } - DisView7->mode = 0; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - return 1; - case IDC_ARM : - /* address to line correction */ - if ((DisView7->mode==2) || ((DisView7->mode==0) && (DisView7->cpu->CPSR.bits.T))) { - DisView7->curr_ligne >>= 1 ; - } ; - DisView7->mode = 1; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - return 1; - case IDC_THUMB : - /* address to line correction */ - if ((DisView7->mode==1) || ((DisView7->mode==0) && !(DisView7->cpu->CPSR.bits.T))) { - DisView7->curr_ligne <<= 1 ; - } ; - DisView7->mode = 2; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - return 1; - case IDC_AUTO_UPDATE : - if(DisView7->autoup) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTOUPDATE_ASM), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); - KillTimer(hwnd, IDT_VIEW_DISASM7); - DisView7->autoup = FALSE; - return 1; - } - EnableWindow(GetDlgItem(hwnd, IDC_AUTOUPDATE_ASM), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); - DisView7->autoup = TRUE; - SetTimer(hwnd, IDT_VIEW_DISASM7, DisView7->autoup_secs*20, (TIMERPROC) NULL); - return 1; - case IDC_STEP : // TODO: draw in DD - { - int ndstep; - ndstep = GetDlgItemInt(hwnd, IDC_SETPNUM, NULL, FALSE); - NDS_exec(ndstep); - } - return 1; - case IDC_GO : - { - u16 i; - char tmp[16]; - int lg = GetDlgItemText(hwnd, IDC_GOTODES, tmp, 16); - u32 adr = 0; - for(i = 0; i='A')&&(tmp[i]<='F')) - { - adr = adr*16 + (tmp[i]-'A'+10); - continue; - } - if((tmp[i]>='0')&&(tmp[i]<='9')) - { - adr = adr*16 + (tmp[i]-'0'); - continue; - } - } - /* address to line correction */ - switch (DisView7->mode) { - case 0: /* auto */ - DisView7->curr_ligne = adr>>2; - if (DisView7->cpu->CPSR.bits.T) { - DisView7->curr_ligne = adr>>1; - } - break ; - case 1: /* arm */ - DisView7->curr_ligne = adr>>2; - break ; - case 2: /* thumb */ - DisView7->curr_ligne = adr>>1; - break ; - } ; - InvalidateRect(hwnd, NULL, FALSE); - } - return 1; - case IDC_REFRESH: - DisView7->autogo=true; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - DisView7->autogo=false; - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_AUTO_UPDATE_SECS: - { - u16 t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); - if (!DisView7) - { - SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - if (t != DisView7->autoup_secs) - { - DisView7->autoup_secs = t; - if (DisView7->autoup) - SetTimer(hwnd, IDT_VIEW_DISASM7, - DisView7->autoup_secs*20, (TIMERPROC) NULL); - } - } - return 1; - case IDC_AUTOUPDATE_ASM: - { - if (DisViewWnd[1] == NULL) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), FALSE); - DisViewWnd[1] = GetDlgItem(hwnd, IDC_DES_BOX); - return 1; - } - DisViewWnd[1] = NULL; - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), TRUE); - } - return 1; - return 1; - } - return 0; - } - - return FALSE; -} - -// =================================================== ARM9 -LRESULT CALLBACK ViewDisasm_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_NCCREATE: - SetScrollRange(hwnd, SB_VERT, 0, 0x3FFFFF7, TRUE); - SetScrollPos(hwnd, SB_VERT, 10, TRUE); - return 1; - - case WM_NCDESTROY: - //free(win); - return 1; - - case WM_PAINT: - DisViewBox_OnPaint(hwnd, DisView9, wParam, lParam); - return 1; - - case WM_VSCROLL : - { - RECT rect; - SIZE fontsize; - HDC dc; - HFONT old; - int nbligne; - - GetClientRect(hwnd, &rect); - dc = GetDC(hwnd); - old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); - GetTextExtentPoint32(dc, "0", 1, &fontsize); - - nbligne = (rect.bottom - rect.top)/fontsize.cy; - - switch LOWORD(wParam) - { - case SB_LINEDOWN : - DisView9->curr_ligne = std::min(0x3FFFFF7*(1+DisView9->cpu->CPSR.bits.T), DisView9->curr_ligne+1); - break; - case SB_LINEUP : - DisView9->curr_ligne = (u32)std::max(0, (s32)DisView9->curr_ligne-1); - break; - case SB_PAGEDOWN : - DisView9->curr_ligne = std::min(0x3FFFFF7*(1+DisView9->cpu->CPSR.bits.T), DisView9->curr_ligne+nbligne); - break; - case SB_PAGEUP : - DisView9->curr_ligne = (u32)std::max(0, DisView9->curr_ligne-nbligne); - break; - } - - SelectObject(dc, old); - SetScrollPos(hwnd, SB_VERT, DisView9->curr_ligne, TRUE); - InvalidateRect(hwnd, NULL, FALSE); - } - return 1; - - case WM_ERASEBKGND: - return 1; - } - return FALSE; -} - -BOOL CALLBACK ViewDisasm_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - //bail out early if the dialog isnt initialized - if(!DisView9 && message != WM_INITDIALOG) - return false; - - switch (message) - { - case WM_INITDIALOG : - { - SetWindowText(hwnd, "ARM9 Disassembler"); - SetDlgItemInt(hwnd, IDC_SETPNUM, 1, FALSE); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_DES), BM_SETCHECK, TRUE, 0); - DisView9 = new disview_struct; - memset(DisView9, 0, sizeof(disview_struct)); - DisView9->cpu = &NDS_ARM9; - DisView9->autoup_secs = 1; - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETRANGE, 0, MAKELONG(99, 1)); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETPOS32, 0, DisView9->autoup_secs); - DisViewWnd[0] = NULL; - return 1; - } - case WM_CLOSE : - { - if(DisView9->autoup) - { - KillTimer(hwnd, IDT_VIEW_DISASM9); - DisView9->autoup = false; - } - if (DisView9!=NULL) - { - delete DisView9; - DisView9 = NULL; - } - DisViewWnd[0] = NULL; - //INFO("Close ARM9 disassembler\n"); - PostQuitMessage(0); - return 1; - } - case WM_PAINT: - DisViewDialog_OnPaint(hwnd, DisView9, wParam, lParam); - return 1; - case WM_TIMER: - SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); - return 1; - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDC_FERMER : - SendMessage(hwnd, WM_CLOSE, 0, 0); - return 0; - case IDC_AUTO_DES : - /* address to line correction */ - if ((DisView9->cpu->CPSR.bits.T) && (DisView9->mode == 1)) { - /* from arm to thumb, line * 2*/ - DisView9->curr_ligne <<= 1 ; - } else if (!(DisView9->cpu->CPSR.bits.T) && (DisView9->mode == 2)) { - /* from thumb to arm, line / 2 */ - DisView9->curr_ligne >>= 2 ; - } - DisView9->mode = 0; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - return 1; - case IDC_ARM : - /* address to line correction */ - if ((DisView9->mode==2) || ((DisView9->mode==0) && (DisView9->cpu->CPSR.bits.T))) { - DisView9->curr_ligne >>= 2 ; - } ; - DisView9->mode = 1; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - return 1; - case IDC_THUMB : - /* address to line correction */ - if ((DisView9->mode==1) || ((DisView9->mode==0) && !(DisView9->cpu->CPSR.bits.T))) { - DisView9->curr_ligne <<= 1 ; - } ; - DisView9->mode = 2; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - return 1; - case IDC_AUTO_UPDATE : - if(DisView9->autoup) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTOUPDATE_ASM), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); - KillTimer(hwnd, IDT_VIEW_DISASM9); - DisView9->autoup = FALSE; - return 1; - } - EnableWindow(GetDlgItem(hwnd, IDC_AUTOUPDATE_ASM), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); - DisView9->autoup = TRUE; - SetTimer(hwnd, IDT_VIEW_DISASM9, DisView9->autoup_secs*20, (TIMERPROC) NULL); - return 1; - case IDC_STEP : // TODO: draw in DD - { - int ndstep; - ndstep = GetDlgItemInt(hwnd, IDC_SETPNUM, NULL, FALSE); - NDS_exec(ndstep); - } - return 1; - case IDC_GO : - { - u16 i; - char tmp[16]; - int lg = GetDlgItemText(hwnd, IDC_GOTODES, tmp, 16); - u32 adr = 0; - for(i = 0; i='A')&&(tmp[i]<='F')) - { - adr = adr*16 + (tmp[i]-'A'+10); - continue; - } - if((tmp[i]>='0')&&(tmp[i]<='9')) - { - adr = adr*16 + (tmp[i]-'0'); - continue; - } - } - /* address to line correction */ - switch (DisView9->mode) { - case 0: /* auto */ - DisView9->curr_ligne = adr>>2; - if (DisView9->cpu->CPSR.bits.T) { - DisView9->curr_ligne = adr>>1; - } - break ; - case 1: /* arm */ - DisView9->curr_ligne = adr>>2; - break ; - case 2: /* thumb */ - DisView9->curr_ligne = adr>>1; - break ; - } ; - InvalidateRect(hwnd, NULL, FALSE); - } - return 1; - case IDC_REFRESH: - DisView9->autogo=true; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - DisView9->autogo=false; - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_AUTO_UPDATE_SECS: - { - u16 t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); - if (!DisView9) - { - SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - if (t != DisView9->autoup_secs) - { - DisView9->autoup_secs = t; - if (DisView9->autoup) - SetTimer(hwnd, IDT_VIEW_DISASM9, - DisView9->autoup_secs*20, (TIMERPROC) NULL); - } - } - return 1; - case IDC_AUTOUPDATE_ASM: - { - if (DisViewWnd[0] == NULL) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), FALSE); - DisViewWnd[0] = GetDlgItem(hwnd, IDC_DES_BOX); - return 1; - } - DisViewWnd[0] = NULL; - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), TRUE); - } - return 1; - return 1; - } - return 0; - } - - return FALSE; -} - -template -FORCEINLINE void DisassemblerTools_Refresh() -{ - if (DisViewWnd[proc] == NULL) return; - if (proc == 0) - { - DisView9->autogo=true; - InvalidateRect(DisViewWnd[proc], NULL, FALSE); - DisView9->autogo=false; - } - else - { - DisView7->autogo=true; - InvalidateRect(DisViewWnd[proc], NULL, FALSE); - DisView7->autogo=false; - } -} - -//these templates needed to be instantiated manually -template void DisassemblerTools_Refresh<0>(); +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include +#include "../MMU.h" +#include "../Disassembler.h" +#include "../NDSSystem.h" +#include "../armcpu.h" +#include "disView.h" +#include +#include "resource.h" + +typedef struct +{ + BOOL autogo; + BOOL autoup; + u32 autoup_secs; + u32 curr_ligne; + armcpu_t *cpu; + u16 mode; +} disview_struct; + +disview_struct *DisView7 = NULL; +disview_struct *DisView9 = NULL; + +static HWND DisViewWnd[2] = {NULL, NULL}; + +#define INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF)) + +LRESULT DisViewBox_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + SIZE fontsize; + TCHAR text[100]; + TCHAR txt[100]; + RECT rect; + int lg; + int ht; + HDC mem_dc; + HBITMAP mem_bmp; + u32 nbligne; + + GetClientRect(hwnd, &rect); + lg = rect.right - rect.left; + ht = rect.bottom - rect.top; + + hdc = BeginPaint(hwnd, &ps); + + mem_dc = CreateCompatibleDC(hdc); + mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); + SelectObject(mem_dc, mem_bmp); + + FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT)); + + GetTextExtentPoint32(mem_dc, "0", 1, &fontsize); + + nbligne = ht/fontsize.cy; + + SetTextColor(mem_dc, RGB(0,0,0)); + + if((win->mode==1) || ((win->mode==0) && (win->cpu->CPSR.bits.T == 0))) + { + u32 i; + u32 adr; + + if (win->autoup||win->autogo) + win->curr_ligne = (win->cpu->instruct_adr >> 2) - (win->curr_ligne % nbligne) ; + adr = win->curr_ligne*4; + + for(i = 0; i < nbligne; ++i) + { + u32 ins = MMU_read32(win->cpu->proc_ID, adr); + des_arm_instructions_set[INDEX(ins)](adr, ins, txt); + sprintf(text, "%04X:%04X %08X %s", (int)(adr>>16), (int)(adr&0xFFFF), (int)ins, txt); + DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX); + rect.top+=fontsize.cy; + adr += 4; + } + + + + if(((win->cpu->instruct_adr&0x0FFFFFFF) >= win->curr_ligne<<2)&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+nbligne<<2))) + { + HBRUSH brjaune = CreateSolidBrush(RGB(255, 255, 0)); + SetBkColor(mem_dc, RGB(255, 255, 0)); + rect.top = (((win->cpu->instruct_adr&0x0FFFFFFF)>>2) - win->curr_ligne)*fontsize.cy; + rect.bottom = rect.top + fontsize.cy; + FillRect(mem_dc, &rect, brjaune); + des_arm_instructions_set[INDEX(win->cpu->instruction)](win->cpu->instruct_adr, win->cpu->instruction, txt); + sprintf(text, "%04X:%04X %08X %s", (int)((win->cpu->instruct_adr&0x0FFFFFFF)>>16), (int)(win->cpu->instruct_adr&0xFFFF), (int)win->cpu->instruction, txt); + DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX); + DeleteObject(brjaune); + } + } + else + { /* thumb display */ + u32 i; + u32 adr; + if (win->autoup) + win->curr_ligne = (win->cpu->instruct_adr >> 1) - (win->curr_ligne % nbligne) ; + + adr = win->curr_ligne*2; + + for(i = 0; i < nbligne; ++i) + { + u32 ins = MMU_read16(win->cpu->proc_ID, adr); + des_thumb_instructions_set[ins>>6](adr, ins, txt); + sprintf(text, "%04X:%04X %04X %s", (int)(adr>>16), (int)(adr&0xFFFF), (int)ins, txt); + DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX); + rect.top+=fontsize.cy; + adr += 2; + } + + if(((win->cpu->instruct_adr&0x0FFFFFFF) >= win->curr_ligne<<1)&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+nbligne<<1))) + { + HBRUSH brjaune = CreateSolidBrush(RGB(255, 255, 0)); + SetBkColor(mem_dc, RGB(255, 255, 0)); + + rect.top = (((win->cpu->instruct_adr&0x0FFFFFFF)>>1) - win->curr_ligne)*fontsize.cy; + rect.bottom = rect.top + fontsize.cy; + FillRect(mem_dc, &rect, brjaune); + des_thumb_instructions_set[((win->cpu->instruction)&0xFFFF)>>6](win->cpu->instruct_adr, win->cpu->instruction&0xFFFF, txt); + sprintf(text, "%04X:%04X %04X %s", (int)((win->cpu->instruct_adr&0x0FFFFFFF)>>16), (int)(win->cpu->instruct_adr&0xFFFF), (int)(win->cpu->instruction&0xFFFF), txt); + DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX); + DeleteObject(brjaune); + } + } + + BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); + + DeleteDC(mem_dc); + DeleteObject(mem_bmp); + + EndPaint(hwnd, &ps); + return 1; +} + +LRESULT DisViewDialog_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + TCHAR text[80]; + u32 i; + + hdc = BeginPaint(hwnd, &ps); + + for(i = 0; i < 16; ++i) + { + sprintf(text, "%08X", (int)win->cpu->R[i]); + SetWindowText(GetDlgItem(hwnd, IDC_R0+i), text); + } + + #define OFF 16 + + SetBkMode(hdc, TRANSPARENT); + if(win->cpu->CPSR.bits.N) + SetTextColor(hdc, RGB(255,0,0)); + else + SetTextColor(hdc, RGB(70, 70, 70)); + TextOut(hdc, 452+OFF, 238, "N", 1); + + if(win->cpu->CPSR.bits.Z) + SetTextColor(hdc, RGB(255,0,0)); + else + SetTextColor(hdc, RGB(70, 70, 70)); + TextOut(hdc, 464+OFF, 238, "Z", 1); + + if(win->cpu->CPSR.bits.C) + SetTextColor(hdc, RGB(255,0,0)); + else + SetTextColor(hdc, RGB(70, 70, 70)); + TextOut(hdc, 475+OFF, 238, "C", 1); + + if(win->cpu->CPSR.bits.V) + SetTextColor(hdc, RGB(255,0,0)); + else + SetTextColor(hdc, RGB(70, 70, 70)); + TextOut(hdc, 486+OFF, 238, "V", 1); + + if(win->cpu->CPSR.bits.Q) + SetTextColor(hdc, RGB(255,0,0)); + else + SetTextColor(hdc, RGB(70, 70, 70)); + TextOut(hdc, 497+OFF, 238, "Q", 1); + + if(!win->cpu->CPSR.bits.I) + SetTextColor(hdc, RGB(255,0,0)); + else + SetTextColor(hdc, RGB(70, 70, 70)); + TextOut(hdc, 508+OFF, 238, "I", 1); + + sprintf(text, "%02X", (int)win->cpu->CPSR.bits.mode); + SetWindowText(GetDlgItem(hwnd, IDC_MODE), text); + + sprintf(text, "%08X", MMU.timer[0][0]);//win->cpu->SPSR); + SetWindowText(GetDlgItem(hwnd, IDC_TMP), text); + + EndPaint(hwnd, &ps); + return 1; +} + +// =================================================== ARM7 +LRESULT CALLBACK ViewDisasm_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_NCCREATE: + SetScrollRange(hwnd, SB_VERT, 0, 0x3FFFFF7, TRUE); + SetScrollPos(hwnd, SB_VERT, 10, TRUE); + return 1; + + case WM_NCDESTROY: + //free(win); + return 1; + + case WM_PAINT: + DisViewBox_OnPaint(hwnd, DisView7, wParam, lParam); + return 1; + + case WM_VSCROLL : + { + RECT rect; + SIZE fontsize; + HDC dc; + HFONT old; + int nbligne; + + GetClientRect(hwnd, &rect); + dc = GetDC(hwnd); + old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); + GetTextExtentPoint32(dc, "0", 1, &fontsize); + + nbligne = (rect.bottom - rect.top)/fontsize.cy; + + switch LOWORD(wParam) + { + case SB_LINEDOWN : + DisView7->curr_ligne = std::min(0x3FFFFF7*(1+DisView7->cpu->CPSR.bits.T), DisView7->curr_ligne+1); + break; + case SB_LINEUP : + DisView7->curr_ligne = (u32)std::max(0, (s32)DisView7->curr_ligne-1); + break; + case SB_PAGEDOWN : + DisView7->curr_ligne = std::min(0x3FFFFF7*(1+DisView7->cpu->CPSR.bits.T), DisView7->curr_ligne+nbligne); + break; + case SB_PAGEUP : + DisView7->curr_ligne = (u32)std::max(0, DisView7->curr_ligne-nbligne); + break; + } + + SelectObject(dc, old); + SetScrollPos(hwnd, SB_VERT, DisView7->curr_ligne, TRUE); + InvalidateRect(hwnd, NULL, FALSE); + } + return 1; + + case WM_ERASEBKGND: + return 1; + } + return FALSE; +} + +BOOL CALLBACK ViewDisasm_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + //bail out early if the dialog isnt initialized + if(!DisView7 && message != WM_INITDIALOG) + return false; + + switch (message) + { + case WM_INITDIALOG : + { + SetWindowText(hwnd, "ARM7 Disassembler"); + SetDlgItemInt(hwnd, IDC_SETPNUM, 1, FALSE); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_DES), BM_SETCHECK, TRUE, 0); + DisView7 = new disview_struct; + memset(DisView7, 0, sizeof(disview_struct)); + DisView7->cpu = &NDS_ARM7; + DisView7->autoup_secs = 1; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, DisView7->autoup_secs); + DisViewWnd[1] = NULL; + return 1; + } + case WM_CLOSE : + { + if(DisView7->autoup) + { + KillTimer(hwnd, IDT_VIEW_DISASM7); + DisView7->autoup = false; + } + if (DisView7!=NULL) + { + delete DisView7; + DisView7 = NULL; + } + DisViewWnd[1] = NULL; + //INFO("Close ARM7 disassembler\n"); + PostQuitMessage(0); + return 1; + } + case WM_PAINT: + DisViewDialog_OnPaint(hwnd, DisView7, wParam, lParam); + return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; + case WM_COMMAND : + switch (LOWORD (wParam)) + { + case IDC_FERMER : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 0; + case IDC_AUTO_DES : + /* address to line correction */ + if ((DisView7->cpu->CPSR.bits.T) && (DisView7->mode == 1)) { + /* from arm to thumb, line * 2*/ + DisView7->curr_ligne <<= 1 ; + } else if (!(DisView7->cpu->CPSR.bits.T) && (DisView7->mode == 2)) { + /* from thumb to arm, line / 2 */ + DisView7->curr_ligne >>= 1 ; + } + DisView7->mode = 0; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + return 1; + case IDC_ARM : + /* address to line correction */ + if ((DisView7->mode==2) || ((DisView7->mode==0) && (DisView7->cpu->CPSR.bits.T))) { + DisView7->curr_ligne >>= 1 ; + } ; + DisView7->mode = 1; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + return 1; + case IDC_THUMB : + /* address to line correction */ + if ((DisView7->mode==1) || ((DisView7->mode==0) && !(DisView7->cpu->CPSR.bits.T))) { + DisView7->curr_ligne <<= 1 ; + } ; + DisView7->mode = 2; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + return 1; + case IDC_AUTO_UPDATE : + if(DisView7->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTOUPDATE_ASM), TRUE); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_DISASM7); + DisView7->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTOUPDATE_ASM), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + DisView7->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_DISASM7, DisView7->autoup_secs*20, (TIMERPROC) NULL); + return 1; + case IDC_STEP : // TODO: draw in DD + { + int ndstep; + ndstep = GetDlgItemInt(hwnd, IDC_SETPNUM, NULL, FALSE); + NDS_exec(ndstep); + } + return 1; + case IDC_GO : + { + u16 i; + char tmp[16]; + int lg = GetDlgItemText(hwnd, IDC_GOTODES, tmp, 16); + u32 adr = 0; + for(i = 0; i='A')&&(tmp[i]<='F')) + { + adr = adr*16 + (tmp[i]-'A'+10); + continue; + } + if((tmp[i]>='0')&&(tmp[i]<='9')) + { + adr = adr*16 + (tmp[i]-'0'); + continue; + } + } + /* address to line correction */ + switch (DisView7->mode) { + case 0: /* auto */ + DisView7->curr_ligne = adr>>2; + if (DisView7->cpu->CPSR.bits.T) { + DisView7->curr_ligne = adr>>1; + } + break ; + case 1: /* arm */ + DisView7->curr_ligne = adr>>2; + break ; + case 2: /* thumb */ + DisView7->curr_ligne = adr>>1; + break ; + } ; + InvalidateRect(hwnd, NULL, FALSE); + } + return 1; + case IDC_REFRESH: + DisView7->autogo=true; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + DisView7->autogo=false; + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + u16 t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (!DisView7) + { + SendMessage(hwnd, WM_INITDIALOG, 0, 0); + } + if (t != DisView7->autoup_secs) + { + DisView7->autoup_secs = t; + if (DisView7->autoup) + SetTimer(hwnd, IDT_VIEW_DISASM7, + DisView7->autoup_secs*20, (TIMERPROC) NULL); + } + } + return 1; + case IDC_AUTOUPDATE_ASM: + { + if (DisViewWnd[1] == NULL) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), FALSE); + DisViewWnd[1] = GetDlgItem(hwnd, IDC_DES_BOX); + return 1; + } + DisViewWnd[1] = NULL; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), TRUE); + } + return 1; + return 1; + } + return 0; + } + + return FALSE; +} + +// =================================================== ARM9 +LRESULT CALLBACK ViewDisasm_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_NCCREATE: + SetScrollRange(hwnd, SB_VERT, 0, 0x3FFFFF7, TRUE); + SetScrollPos(hwnd, SB_VERT, 10, TRUE); + return 1; + + case WM_NCDESTROY: + //free(win); + return 1; + + case WM_PAINT: + DisViewBox_OnPaint(hwnd, DisView9, wParam, lParam); + return 1; + + case WM_VSCROLL : + { + RECT rect; + SIZE fontsize; + HDC dc; + HFONT old; + int nbligne; + + GetClientRect(hwnd, &rect); + dc = GetDC(hwnd); + old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); + GetTextExtentPoint32(dc, "0", 1, &fontsize); + + nbligne = (rect.bottom - rect.top)/fontsize.cy; + + switch LOWORD(wParam) + { + case SB_LINEDOWN : + DisView9->curr_ligne = std::min(0x3FFFFF7*(1+DisView9->cpu->CPSR.bits.T), DisView9->curr_ligne+1); + break; + case SB_LINEUP : + DisView9->curr_ligne = (u32)std::max(0, (s32)DisView9->curr_ligne-1); + break; + case SB_PAGEDOWN : + DisView9->curr_ligne = std::min(0x3FFFFF7*(1+DisView9->cpu->CPSR.bits.T), DisView9->curr_ligne+nbligne); + break; + case SB_PAGEUP : + DisView9->curr_ligne = (u32)std::max(0, DisView9->curr_ligne-nbligne); + break; + } + + SelectObject(dc, old); + SetScrollPos(hwnd, SB_VERT, DisView9->curr_ligne, TRUE); + InvalidateRect(hwnd, NULL, FALSE); + } + return 1; + + case WM_ERASEBKGND: + return 1; + } + return FALSE; +} + +BOOL CALLBACK ViewDisasm_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + //bail out early if the dialog isnt initialized + if(!DisView9 && message != WM_INITDIALOG) + return false; + + switch (message) + { + case WM_INITDIALOG : + { + SetWindowText(hwnd, "ARM9 Disassembler"); + SetDlgItemInt(hwnd, IDC_SETPNUM, 1, FALSE); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_DES), BM_SETCHECK, TRUE, 0); + DisView9 = new disview_struct; + memset(DisView9, 0, sizeof(disview_struct)); + DisView9->cpu = &NDS_ARM9; + DisView9->autoup_secs = 1; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, DisView9->autoup_secs); + DisViewWnd[0] = NULL; + return 1; + } + case WM_CLOSE : + { + if(DisView9->autoup) + { + KillTimer(hwnd, IDT_VIEW_DISASM9); + DisView9->autoup = false; + } + if (DisView9!=NULL) + { + delete DisView9; + DisView9 = NULL; + } + DisViewWnd[0] = NULL; + //INFO("Close ARM9 disassembler\n"); + PostQuitMessage(0); + return 1; + } + case WM_PAINT: + DisViewDialog_OnPaint(hwnd, DisView9, wParam, lParam); + return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; + case WM_COMMAND : + switch (LOWORD (wParam)) + { + case IDC_FERMER : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 0; + case IDC_AUTO_DES : + /* address to line correction */ + if ((DisView9->cpu->CPSR.bits.T) && (DisView9->mode == 1)) { + /* from arm to thumb, line * 2*/ + DisView9->curr_ligne <<= 1 ; + } else if (!(DisView9->cpu->CPSR.bits.T) && (DisView9->mode == 2)) { + /* from thumb to arm, line / 2 */ + DisView9->curr_ligne >>= 2 ; + } + DisView9->mode = 0; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + return 1; + case IDC_ARM : + /* address to line correction */ + if ((DisView9->mode==2) || ((DisView9->mode==0) && (DisView9->cpu->CPSR.bits.T))) { + DisView9->curr_ligne >>= 2 ; + } ; + DisView9->mode = 1; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + return 1; + case IDC_THUMB : + /* address to line correction */ + if ((DisView9->mode==1) || ((DisView9->mode==0) && !(DisView9->cpu->CPSR.bits.T))) { + DisView9->curr_ligne <<= 1 ; + } ; + DisView9->mode = 2; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + return 1; + case IDC_AUTO_UPDATE : + if(DisView9->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTOUPDATE_ASM), TRUE); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_DISASM9); + DisView9->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTOUPDATE_ASM), FALSE); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + DisView9->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_DISASM9, DisView9->autoup_secs*20, (TIMERPROC) NULL); + return 1; + case IDC_STEP : // TODO: draw in DD + { + int ndstep; + ndstep = GetDlgItemInt(hwnd, IDC_SETPNUM, NULL, FALSE); + NDS_exec(ndstep); + } + return 1; + case IDC_GO : + { + u16 i; + char tmp[16]; + int lg = GetDlgItemText(hwnd, IDC_GOTODES, tmp, 16); + u32 adr = 0; + for(i = 0; i='A')&&(tmp[i]<='F')) + { + adr = adr*16 + (tmp[i]-'A'+10); + continue; + } + if((tmp[i]>='0')&&(tmp[i]<='9')) + { + adr = adr*16 + (tmp[i]-'0'); + continue; + } + } + /* address to line correction */ + switch (DisView9->mode) { + case 0: /* auto */ + DisView9->curr_ligne = adr>>2; + if (DisView9->cpu->CPSR.bits.T) { + DisView9->curr_ligne = adr>>1; + } + break ; + case 1: /* arm */ + DisView9->curr_ligne = adr>>2; + break ; + case 2: /* thumb */ + DisView9->curr_ligne = adr>>1; + break ; + } ; + InvalidateRect(hwnd, NULL, FALSE); + } + return 1; + case IDC_REFRESH: + DisView9->autogo=true; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + DisView9->autogo=false; + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + u16 t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (!DisView9) + { + SendMessage(hwnd, WM_INITDIALOG, 0, 0); + } + if (t != DisView9->autoup_secs) + { + DisView9->autoup_secs = t; + if (DisView9->autoup) + SetTimer(hwnd, IDT_VIEW_DISASM9, + DisView9->autoup_secs*20, (TIMERPROC) NULL); + } + } + return 1; + case IDC_AUTOUPDATE_ASM: + { + if (DisViewWnd[0] == NULL) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), FALSE); + DisViewWnd[0] = GetDlgItem(hwnd, IDC_DES_BOX); + return 1; + } + DisViewWnd[0] = NULL; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), TRUE); + } + return 1; + return 1; + } + return 0; + } + + return FALSE; +} + +template +FORCEINLINE void DisassemblerTools_Refresh() +{ + if (DisViewWnd[proc] == NULL) return; + if (proc == 0) + { + DisView9->autogo=true; + InvalidateRect(DisViewWnd[proc], NULL, FALSE); + DisView9->autogo=false; + } + else + { + DisView7->autogo=true; + InvalidateRect(DisViewWnd[proc], NULL, FALSE); + DisView7->autogo=false; + } +} + +//these templates needed to be instantiated manually +template void DisassemblerTools_Refresh<0>(); template void DisassemblerTools_Refresh<1>(); \ No newline at end of file diff --git a/desmume/src/windows/disView.h b/src/windows/disView.h similarity index 97% rename from desmume/src/windows/disView.h rename to src/windows/disView.h index ad2edc913..494cb5689 100644 --- a/desmume/src/windows/disView.h +++ b/src/windows/disView.h @@ -1,35 +1,35 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef DISVIEW_H -#define DISVIEW_H - -#include "../common.h" - -extern BOOL CALLBACK ViewDisasm_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); -extern LRESULT CALLBACK ViewDisasm_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -extern BOOL CALLBACK ViewDisasm_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); -extern LRESULT CALLBACK ViewDisasm_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -template void FORCEINLINE DisassemblerTools_Refresh(); - -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef DISVIEW_H +#define DISVIEW_H + +#include "../common.h" + +extern BOOL CALLBACK ViewDisasm_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +extern LRESULT CALLBACK ViewDisasm_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + +extern BOOL CALLBACK ViewDisasm_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +extern LRESULT CALLBACK ViewDisasm_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + +template void FORCEINLINE DisassemblerTools_Refresh(); + +#endif diff --git a/desmume/src/windows/filter/2xsai.cpp b/src/windows/filter/2xsai.cpp similarity index 100% rename from desmume/src/windows/filter/2xsai.cpp rename to src/windows/filter/2xsai.cpp diff --git a/desmume/src/windows/filter/bilinear.cpp b/src/windows/filter/bilinear.cpp similarity index 100% rename from desmume/src/windows/filter/bilinear.cpp rename to src/windows/filter/bilinear.cpp diff --git a/desmume/src/windows/filter/filter.h b/src/windows/filter/filter.h similarity index 100% rename from desmume/src/windows/filter/filter.h rename to src/windows/filter/filter.h diff --git a/desmume/src/windows/filter/hq2x.cpp b/src/windows/filter/hq2x.cpp similarity index 100% rename from desmume/src/windows/filter/hq2x.cpp rename to src/windows/filter/hq2x.cpp diff --git a/desmume/src/windows/filter/hq2x.h b/src/windows/filter/hq2x.h similarity index 100% rename from desmume/src/windows/filter/hq2x.h rename to src/windows/filter/hq2x.h diff --git a/desmume/src/windows/filter/interp.h b/src/windows/filter/interp.h similarity index 100% rename from desmume/src/windows/filter/interp.h rename to src/windows/filter/interp.h diff --git a/desmume/src/windows/filter/scanline.cpp b/src/windows/filter/scanline.cpp similarity index 100% rename from desmume/src/windows/filter/scanline.cpp rename to src/windows/filter/scanline.cpp diff --git a/desmume/src/windows/gbaslot_config.cpp b/src/windows/gbaslot_config.cpp similarity index 96% rename from desmume/src/windows/gbaslot_config.cpp rename to src/windows/gbaslot_config.cpp index 4f5db81e4..3426a48d2 100644 --- a/desmume/src/windows/gbaslot_config.cpp +++ b/src/windows/gbaslot_config.cpp @@ -1,520 +1,507 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright (C) 2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "gbaslot_config.h" -#include -#include "resource.h" -#include "debug.h" -#include "../addons.h" -#include "../NDSSystem.h" -#include "inputdx.h" -#include - -WNDCLASSEX wc; -HWND wndConfig = NULL; -u8 temp_type = 0; -u8 last_type = 0; -char tmp_cflash_filename[MAX_PATH] = { 0 }; -char tmp_cflash_path[MAX_PATH] = { 0 }; -char tmp_gbagame_filename[MAX_PATH] = { 0 }; -ADDON_CFLASH_MODE tmp_CFlashMode = ADDON_CFLASH_MODE_RomPath; -HWND OKbutton = NULL; -bool _OKbutton = false; -SGuitar tmp_Guitar; -bool needReset = true; - -std::string CFlashPath, CFlashName; - -BOOL CALLBACK GbaSlotNone(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - _OKbutton = TRUE; - return TRUE; - } - } - return FALSE; -} - -BOOL CALLBACK GbaSlotCFlash(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - SetWindowText(GetDlgItem(dialog, IDC_PATHIMG), tmp_cflash_filename); - SetWindowText(GetDlgItem(dialog, IDC_PATH), tmp_cflash_path); - switch (tmp_CFlashMode) - { - case ADDON_CFLASH_MODE_Path: - CheckDlgButton(dialog, IDC_RFOLDER, BST_CHECKED); - EnableWindow(GetDlgItem(dialog, IDC_PATH), TRUE); - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), TRUE); - EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); - if (strlen(tmp_cflash_path)) _OKbutton = TRUE; - break; - - case ADDON_CFLASH_MODE_File: - CheckDlgButton(dialog, IDC_RFILE, BST_CHECKED); - EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), TRUE); - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), TRUE); - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); - if (strlen(tmp_cflash_filename)) _OKbutton = TRUE; - break; - - case ADDON_CFLASH_MODE_RomPath: - CheckDlgButton(dialog, IDC_PATHDESMUME, BST_CHECKED); - EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); - _OKbutton = TRUE; - break; - default: - return FALSE; - - } - return TRUE; - } - - case WM_COMMAND: - { - switch (LOWORD(wparam)) - { - case IDC_BBROWSE: - { - int filterSize = 0, i = 0; - OPENFILENAME ofn; - char filename[MAX_PATH] = "", - fileFilter[512]=""; - - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = dialog; - - strncpy (fileFilter, "Compact Flash image (*.img)|*.img||",512 - strlen(fileFilter)); - strncat (fileFilter, "Any file (*.*)|*.*||",512 - strlen(fileFilter)); - - filterSize = strlen(fileFilter); - for (i = 0; i < filterSize; i++) - if (fileFilter[i] == '|') fileFilter[i] = '\0'; - ofn.lpstrFilter = fileFilter; - ofn.nFilterIndex = 1; - ofn.lpstrFile = filename; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "img"; - ofn.Flags = OFN_NOCHANGEDIR | OFN_CREATEPROMPT | OFN_PATHMUSTEXIST; - - if(!GetOpenFileName(&ofn)) return FALSE; - - SetWindowText(GetDlgItem(dialog, IDC_PATHIMG), filename); - strcpy(tmp_cflash_filename, filename); - if (!strlen(tmp_cflash_filename)) - EnableWindow(OKbutton, FALSE); - else - EnableWindow(OKbutton, TRUE); - return FALSE; - } - - case IDC_BBROWSE2: - { - BROWSEINFO bp={0}; - - bp.hwndOwner=dialog; - bp.pidlRoot=NULL; - bp.pszDisplayName=NULL; - bp.lpszTitle="Select directory for Compact Flash"; - bp.ulFlags=BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; - bp.lpfn=NULL; - - LPITEMIDLIST tmp = SHBrowseForFolder((LPBROWSEINFO)&bp); - if (tmp!=NULL) - { - memset(tmp_cflash_path, 0, sizeof(tmp_cflash_path)); - SHGetPathFromIDList(tmp, tmp_cflash_path); - if (tmp_cflash_path[strlen(tmp_cflash_path)-1] != '\\') - tmp_cflash_path[strlen(tmp_cflash_path)] = '\\'; - SetWindowText(GetDlgItem(dialog, IDC_PATH), tmp_cflash_path); - } - if (strlen(tmp_cflash_path)) - EnableWindow(OKbutton, TRUE); - else - EnableWindow(OKbutton, FALSE); - break; - } - - case IDC_RFILE: - { - if (HIWORD(wparam) == BN_CLICKED) - { - tmp_CFlashMode = ADDON_CFLASH_MODE_File; - EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), TRUE); - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), TRUE); - - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); - - if (!strlen(tmp_cflash_filename)) - EnableWindow(OKbutton, FALSE); - } - break; - } - - case IDC_RFOLDER: - { - if (HIWORD(wparam) == BN_CLICKED) - { - tmp_CFlashMode = ADDON_CFLASH_MODE_Path; - EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); - - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), TRUE); - EnableWindow(GetDlgItem(dialog, IDC_PATH), TRUE); - if (!strlen(tmp_cflash_path)) - EnableWindow(OKbutton, FALSE); - } - break; - } - - case IDC_PATHDESMUME: - { - if (HIWORD(wparam) == BN_CLICKED) - { - tmp_CFlashMode = ADDON_CFLASH_MODE_RomPath; - EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); - - EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); - EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); - EnableWindow(OKbutton, TRUE); - } - break; - } - } - break; - } - } - return FALSE; -} - -BOOL CALLBACK GbaSlotRumblePak(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - _OKbutton = TRUE; - return TRUE; - } - } - return FALSE; -} - -BOOL CALLBACK GbaSlotGBAgame(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - SetWindowText(GetDlgItem(dialog, IDC_PATHGAME), tmp_gbagame_filename); - if (strlen(tmp_gbagame_filename) > 0) _OKbutton = true; - return TRUE; - } - case WM_COMMAND: - { - switch (LOWORD(wparam)) - { - case IDC_BBROWSE: - { - int filterSize = 0, i = 0; - OPENFILENAME ofn; - char filename[MAX_PATH] = "", - fileFilter[512]=""; - - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = dialog; - - // TODO: add another gba file formats and archs - strncpy (fileFilter, "GameBoy Advance ROM (*.gba)|*.gba||",512 - strlen(fileFilter)); - strncat (fileFilter, "Any file (*.*)|*.*||",512 - strlen(fileFilter)); - - filterSize = strlen(fileFilter); - for (i = 0; i < filterSize; i++) - if (fileFilter[i] == '|') fileFilter[i] = '\0'; - ofn.lpstrFilter = fileFilter; - ofn.nFilterIndex = 1; - ofn.lpstrFile = filename; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "gba"; - ofn.Flags = OFN_NOCHANGEDIR | OFN_FILEMUSTEXIST; - - if(!GetOpenFileName(&ofn)) return FALSE; - - SetWindowText(GetDlgItem(dialog, IDC_PATHGAME), filename); - strcpy(tmp_gbagame_filename, filename); - if (!strlen(tmp_gbagame_filename)) - EnableWindow(OKbutton, FALSE); - else - EnableWindow(OKbutton, TRUE); - return FALSE; - } - } - break; - } - } - return FALSE; -} - -BOOL CALLBACK GbaSlotGuitarGrip(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - int which = 0; - - switch(msg) - { - case WM_INITDIALOG: - { - _OKbutton = TRUE; - SendDlgItemMessage(dialog,IDC_GGREEN,WM_USER+44,tmp_Guitar.GREEN,0); - SendDlgItemMessage(dialog,IDC_GRED,WM_USER+44,tmp_Guitar.RED,0); - SendDlgItemMessage(dialog,IDC_GYELLOW,WM_USER+44,tmp_Guitar.YELLOW,0); - SendDlgItemMessage(dialog,IDC_GBLUE,WM_USER+44,tmp_Guitar.BLUE,0); - if (temp_type != addon_type) - needReset = true; - else - needReset = false; - - return TRUE; - } - - case WM_USER+46: - SendDlgItemMessage(dialog,IDC_GGREEN,WM_USER+44,tmp_Guitar.GREEN,0); - SendDlgItemMessage(dialog,IDC_GRED,WM_USER+44,tmp_Guitar.RED,0); - SendDlgItemMessage(dialog,IDC_GYELLOW,WM_USER+44,tmp_Guitar.YELLOW,0); - SendDlgItemMessage(dialog,IDC_GBLUE,WM_USER+44,tmp_Guitar.BLUE,0); - return TRUE; - - case WM_USER+43: - //MessageBox(hDlg,"USER+43 CAUGHT","moo",MB_OK); - which = GetDlgCtrlID((HWND)lparam); - switch(which) - { - case IDC_GGREEN: - tmp_Guitar.GREEN = wparam; - - break; - case IDC_GRED: - tmp_Guitar.RED = wparam; - - break; - case IDC_GYELLOW: - tmp_Guitar.YELLOW = wparam; - - break; - case IDC_GBLUE: - tmp_Guitar.BLUE = wparam; - break; - } - - SendDlgItemMessage(dialog,IDC_GGREEN,WM_USER+44,tmp_Guitar.GREEN,0); - SendDlgItemMessage(dialog,IDC_GRED,WM_USER+44,tmp_Guitar.RED,0); - SendDlgItemMessage(dialog,IDC_GYELLOW,WM_USER+44,tmp_Guitar.YELLOW,0); - SendDlgItemMessage(dialog,IDC_GBLUE,WM_USER+44,tmp_Guitar.BLUE,0); - PostMessage(dialog,WM_NEXTDLGCTL,0,0); - return true; - } - return FALSE; -} - -u32 GBAslot_IDDs[NDS_ADDON_COUNT] = { - IDD_GBASLOT_NONE, - IDD_GBASLOT_CFLASH, - IDD_GBASLOT_RUMBLEPAK, - IDD_GBASLOT_GBAGAME, - IDD_GBASLOT_GUITARGRIP -}; - -DLGPROC GBAslot_Procs[NDS_ADDON_COUNT] = { - GbaSlotNone, - GbaSlotCFlash, - GbaSlotRumblePak, - GbaSlotGBAgame, - GbaSlotGuitarGrip -}; - - -//============================================================================== -BOOL CALLBACK GbaSlotBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) -{ - switch(msg) - { - case WM_INITDIALOG: - { - OKbutton = GetDlgItem(dialog, IDOK); - for(int i = 0; i < NDS_ADDON_COUNT; i++) - ComboBox_AddString(GetDlgItem(dialog, IDC_ADDONS_LIST), addonList[i].name); - ComboBox_SetCurSel(GetDlgItem(dialog, IDC_ADDONS_LIST), temp_type); - u8 tmp_info[512]; - addonList[temp_type].info((char *)tmp_info); - SetWindowText(GetDlgItem(dialog, IDC_ADDONS_INFO), (char *)tmp_info); - - _OKbutton = false; - wndConfig=CreateDialog(hAppInst, MAKEINTRESOURCE(GBAslot_IDDs[temp_type]), - dialog, (DLGPROC)GBAslot_Procs[temp_type]); - if ( (temp_type == 0) || (_OKbutton) ) - EnableWindow(OKbutton, TRUE); - else - EnableWindow(OKbutton, FALSE); - return TRUE; - } - - case WM_COMMAND: - { - switch (LOWORD(wparam)) - { - case IDOK: - { - int Msg = IDYES; - if (romloaded && (needReset || (temp_type!=addon_type)) ) - { - Msg = MessageBox(dialog, - "After change GBA slot pak game will reset!\nAre you sure to continue?", "DeSmuME", - MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2); - } - if (Msg == IDYES) - { - if (wndConfig) DestroyWindow(wndConfig); - EndDialog(dialog, TRUE); - } - } - return TRUE; - case IDCANCEL: - if (wndConfig) DestroyWindow(wndConfig); - EndDialog(dialog, FALSE); - return TRUE; - - case IDC_ADDONS_LIST: - if (HIWORD(wparam) == CBN_SELENDOK) - { - temp_type = ComboBox_GetCurSel(GetDlgItem(dialog, IDC_ADDONS_LIST)); - if (temp_type != last_type) - { - if (wndConfig) DestroyWindow(wndConfig); - _OKbutton = false; - wndConfig=CreateDialog(hAppInst, - MAKEINTRESOURCE(GBAslot_IDDs[temp_type]), dialog, - (DLGPROC)GBAslot_Procs[temp_type]); - if ( (temp_type == 0) || (_OKbutton) ) - EnableWindow(OKbutton, TRUE); - else - EnableWindow(OKbutton, FALSE); - u8 tmp_info[512]; - addonList[temp_type].info((char *)tmp_info); - SetWindowText(GetDlgItem(dialog, IDC_ADDONS_INFO), (char *)tmp_info); - last_type = temp_type; - } - } - return TRUE; - } - break; - } - } - return FALSE; -} - -void GBAslotDialog(HWND hwnd) -{ - temp_type = addon_type; - last_type = temp_type; - strcpy(tmp_cflash_filename, CFlashName.c_str()); - strcpy(tmp_cflash_path, CFlashPath.c_str()); - strcpy(tmp_gbagame_filename, GBAgameName); - memcpy(&tmp_Guitar, &Guitar, sizeof(Guitar)); - tmp_CFlashMode = CFlash_Mode; - _OKbutton = false; - needReset = true; - u32 res=DialogBox(hAppInst, MAKEINTRESOURCE(IDD_GBASLOT), hwnd, (DLGPROC) GbaSlotBox_Proc); - if (res) - { - switch (temp_type) - { - case NDS_ADDON_NONE: - if (temp_type != addon_type) - needReset = true; - else - needReset = false; - break; - case NDS_ADDON_CFLASH: - CFlash_Mode = tmp_CFlashMode; - WritePrivateProfileInt("GBAslot.CFlash","fileMode",CFlash_Mode,IniName); - WritePrivateProfileString("GBAslot.CFlash","path",tmp_cflash_path,IniName); - WritePrivateProfileString("GBAslot.CFlash","filename",tmp_cflash_filename,IniName); - if(CFlash_Mode == ADDON_CFLASH_MODE_Path) - CFlash_Path = tmp_cflash_path; - else if(CFlash_Mode == ADDON_CFLASH_MODE_RomPath) - CFlash_Path = ""; - else - CFlash_Path = tmp_cflash_filename; - needReset = true; - break; - case NDS_ADDON_RUMBLEPAK: - if (temp_type != addon_type) - needReset = true; - else - needReset = false; - break; - case NDS_ADDON_GBAGAME: - strcpy(GBAgameName, tmp_gbagame_filename); - WritePrivateProfileString("GBAslot.GBAgame","filename",GBAgameName,IniName); - needReset = true; - break; - case NDS_ADDON_GUITARGRIP: - memcpy(&Guitar, &tmp_Guitar, sizeof(tmp_Guitar)); - Guitar.Enabled = true; - WritePrivateProfileInt("GBAslot.GuitarGrip","green",Guitar.GREEN,IniName); - WritePrivateProfileInt("GBAslot.GuitarGrip","red",Guitar.RED,IniName); - WritePrivateProfileInt("GBAslot.GuitarGrip","yellow",Guitar.YELLOW,IniName); - WritePrivateProfileInt("GBAslot.GuitarGrip","blue",Guitar.BLUE,IniName); - if (temp_type != addon_type) - needReset = true; - else - needReset = false; - break; - default: - return; - } - if (temp_type!=NDS_ADDON_GUITARGRIP) - Guitar.Enabled = false; - WritePrivateProfileInt("GBAslot","type",temp_type,IniName); - - addon_type = temp_type; - addonsChangePak(addon_type); - if (romloaded && needReset) - NDS_Reset(); - return; - } +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright (C) 2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "gbaslot_config.h" +#include +#include "resource.h" +#include "debug.h" +#include "../addons.h" +#include "../NDSSystem.h" +#include "inputdx.h" +#include + +WNDCLASSEX wc; +HWND wndConfig = NULL; +u8 temp_type = 0; +u8 last_type = 0; +char tmp_cflash_filename[MAX_PATH] = { 0 }; +char tmp_cflash_path[MAX_PATH] = { 0 }; +char tmp_gbagame_filename[MAX_PATH] = { 0 }; +ADDON_CFLASH_MODE tmp_CFlashMode = ADDON_CFLASH_MODE_RomPath; +HWND OKbutton = NULL; +bool _OKbutton = false; +SGuitar tmp_Guitar; +bool needReset = true; + +std::string CFlashPath, CFlashName; + +BOOL CALLBACK GbaSlotNone(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + _OKbutton = TRUE; + return TRUE; + } + } + return FALSE; +} + +BOOL CALLBACK GbaSlotCFlash(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + SetWindowText(GetDlgItem(dialog, IDC_PATHIMG), tmp_cflash_filename); + SetWindowText(GetDlgItem(dialog, IDC_PATH), tmp_cflash_path); + switch (tmp_CFlashMode) + { + case ADDON_CFLASH_MODE_Path: + CheckDlgButton(dialog, IDC_RFOLDER, BST_CHECKED); + EnableWindow(GetDlgItem(dialog, IDC_PATH), TRUE); + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), TRUE); + EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); + if (strlen(tmp_cflash_path)) _OKbutton = TRUE; + break; + + case ADDON_CFLASH_MODE_File: + CheckDlgButton(dialog, IDC_RFILE, BST_CHECKED); + EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), TRUE); + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), TRUE); + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); + if (strlen(tmp_cflash_filename)) _OKbutton = TRUE; + break; + + case ADDON_CFLASH_MODE_RomPath: + CheckDlgButton(dialog, IDC_PATHDESMUME, BST_CHECKED); + EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); + _OKbutton = TRUE; + break; + default: + return FALSE; + + } + return TRUE; + } + + case WM_COMMAND: + { + switch (LOWORD(wparam)) + { + case IDC_BBROWSE: + { + int filterSize = 0, i = 0; + OPENFILENAME ofn; + char filename[MAX_PATH] = "", + fileFilter[512]=""; + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = dialog; + + strncpy (fileFilter, "Compact Flash image (*.img)|*.img||",512 - strlen(fileFilter)); + strncat (fileFilter, "Any file (*.*)|*.*||",512 - strlen(fileFilter)); + + filterSize = strlen(fileFilter); + for (i = 0; i < filterSize; i++) + if (fileFilter[i] == '|') fileFilter[i] = '\0'; + ofn.lpstrFilter = fileFilter; + ofn.nFilterIndex = 1; + ofn.lpstrFile = filename; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "img"; + ofn.Flags = OFN_NOCHANGEDIR | OFN_CREATEPROMPT | OFN_PATHMUSTEXIST; + + if(!GetOpenFileName(&ofn)) return FALSE; + + SetWindowText(GetDlgItem(dialog, IDC_PATHIMG), filename); + strcpy(tmp_cflash_filename, filename); + if (!strlen(tmp_cflash_filename)) + EnableWindow(OKbutton, FALSE); + else + EnableWindow(OKbutton, TRUE); + return FALSE; + } + + case IDC_BBROWSE2: + { + BROWSEINFO bp={0}; + + bp.hwndOwner=dialog; + bp.pidlRoot=NULL; + bp.pszDisplayName=NULL; + bp.lpszTitle="Select directory for Compact Flash"; + bp.ulFlags=BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; + bp.lpfn=NULL; + + LPITEMIDLIST tmp = SHBrowseForFolder((LPBROWSEINFO)&bp); + if (tmp!=NULL) + { + memset(tmp_cflash_path, 0, sizeof(tmp_cflash_path)); + SHGetPathFromIDList(tmp, tmp_cflash_path); + if (tmp_cflash_path[strlen(tmp_cflash_path)-1] != '\\') + tmp_cflash_path[strlen(tmp_cflash_path)] = '\\'; + SetWindowText(GetDlgItem(dialog, IDC_PATH), tmp_cflash_path); + } + if (strlen(tmp_cflash_path)) + EnableWindow(OKbutton, TRUE); + else + EnableWindow(OKbutton, FALSE); + break; + } + + case IDC_RFILE: + { + if (HIWORD(wparam) == BN_CLICKED) + { + tmp_CFlashMode = ADDON_CFLASH_MODE_File; + EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), TRUE); + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), TRUE); + + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); + + if (!strlen(tmp_cflash_filename)) + EnableWindow(OKbutton, FALSE); + } + break; + } + + case IDC_RFOLDER: + { + if (HIWORD(wparam) == BN_CLICKED) + { + tmp_CFlashMode = ADDON_CFLASH_MODE_Path; + EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); + + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), TRUE); + EnableWindow(GetDlgItem(dialog, IDC_PATH), TRUE); + if (!strlen(tmp_cflash_path)) + EnableWindow(OKbutton, FALSE); + } + break; + } + + case IDC_PATHDESMUME: + { + if (HIWORD(wparam) == BN_CLICKED) + { + tmp_CFlashMode = ADDON_CFLASH_MODE_RomPath; + EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); + + EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); + EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); + EnableWindow(OKbutton, TRUE); + } + break; + } + } + break; + } + } + return FALSE; +} + +BOOL CALLBACK GbaSlotRumblePak(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + _OKbutton = TRUE; + return TRUE; + } + } + return FALSE; +} + +BOOL CALLBACK GbaSlotGBAgame(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + SetWindowText(GetDlgItem(dialog, IDC_PATHGAME), tmp_gbagame_filename); + if (strlen(tmp_gbagame_filename) > 0) _OKbutton = true; + return TRUE; + } + case WM_COMMAND: + { + switch (LOWORD(wparam)) + { + case IDC_BBROWSE: + { + int filterSize = 0, i = 0; + OPENFILENAME ofn; + char filename[MAX_PATH] = "", + fileFilter[512]=""; + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = dialog; + + // TODO: add another gba file formats and archs + strncpy (fileFilter, "GameBoy Advance ROM (*.gba)|*.gba||",512 - strlen(fileFilter)); + strncat (fileFilter, "Any file (*.*)|*.*||",512 - strlen(fileFilter)); + + filterSize = strlen(fileFilter); + for (i = 0; i < filterSize; i++) + if (fileFilter[i] == '|') fileFilter[i] = '\0'; + ofn.lpstrFilter = fileFilter; + ofn.nFilterIndex = 1; + ofn.lpstrFile = filename; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "gba"; + ofn.Flags = OFN_NOCHANGEDIR | OFN_FILEMUSTEXIST; + + if(!GetOpenFileName(&ofn)) return FALSE; + + SetWindowText(GetDlgItem(dialog, IDC_PATHGAME), filename); + strcpy(tmp_gbagame_filename, filename); + if (!strlen(tmp_gbagame_filename)) + EnableWindow(OKbutton, FALSE); + else + EnableWindow(OKbutton, TRUE); + return FALSE; + } + } + break; + } + } + return FALSE; +} + +BOOL CALLBACK GbaSlotGuitarGrip(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + int which = 0; + + switch(msg) + { + case WM_INITDIALOG: + { + _OKbutton = TRUE; + SendDlgItemMessage(dialog,IDC_GGREEN,WM_USER+44,tmp_Guitar.GREEN,0); + SendDlgItemMessage(dialog,IDC_GRED,WM_USER+44,tmp_Guitar.RED,0); + SendDlgItemMessage(dialog,IDC_GYELLOW,WM_USER+44,tmp_Guitar.YELLOW,0); + SendDlgItemMessage(dialog,IDC_GBLUE,WM_USER+44,tmp_Guitar.BLUE,0); + if (temp_type != addon_type) + needReset = true; + else + needReset = false; + + return TRUE; + } + + case WM_USER+46: + SendDlgItemMessage(dialog,IDC_GGREEN,WM_USER+44,tmp_Guitar.GREEN,0); + SendDlgItemMessage(dialog,IDC_GRED,WM_USER+44,tmp_Guitar.RED,0); + SendDlgItemMessage(dialog,IDC_GYELLOW,WM_USER+44,tmp_Guitar.YELLOW,0); + SendDlgItemMessage(dialog,IDC_GBLUE,WM_USER+44,tmp_Guitar.BLUE,0); + return TRUE; + + case WM_USER+43: + //MessageBox(hDlg,"USER+43 CAUGHT","moo",MB_OK); + which = GetDlgCtrlID((HWND)lparam); + switch(which) + { + case IDC_GGREEN: + tmp_Guitar.GREEN = wparam; + + break; + case IDC_GRED: + tmp_Guitar.RED = wparam; + + break; + case IDC_GYELLOW: + tmp_Guitar.YELLOW = wparam; + + break; + case IDC_GBLUE: + tmp_Guitar.BLUE = wparam; + break; + } + + SendDlgItemMessage(dialog,IDC_GGREEN,WM_USER+44,tmp_Guitar.GREEN,0); + SendDlgItemMessage(dialog,IDC_GRED,WM_USER+44,tmp_Guitar.RED,0); + SendDlgItemMessage(dialog,IDC_GYELLOW,WM_USER+44,tmp_Guitar.YELLOW,0); + SendDlgItemMessage(dialog,IDC_GBLUE,WM_USER+44,tmp_Guitar.BLUE,0); + PostMessage(dialog,WM_NEXTDLGCTL,0,0); + return true; + } + return FALSE; +} + +u32 GBAslot_IDDs[NDS_ADDON_COUNT] = { + IDD_GBASLOT_NONE, + IDD_GBASLOT_CFLASH, + IDD_GBASLOT_RUMBLEPAK, + IDD_GBASLOT_GBAGAME, + IDD_GBASLOT_GUITARGRIP +}; + +DLGPROC GBAslot_Procs[NDS_ADDON_COUNT] = { + GbaSlotNone, + GbaSlotCFlash, + GbaSlotRumblePak, + GbaSlotGBAgame, + GbaSlotGuitarGrip +}; + + +//============================================================================== +BOOL CALLBACK GbaSlotBox_Proc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam) +{ + switch(msg) + { + case WM_INITDIALOG: + { + OKbutton = GetDlgItem(dialog, IDOK); + for(int i = 0; i < NDS_ADDON_COUNT; i++) + ComboBox_AddString(GetDlgItem(dialog, IDC_ADDONS_LIST), addonList[i].name); + ComboBox_SetCurSel(GetDlgItem(dialog, IDC_ADDONS_LIST), temp_type); + u8 tmp_info[512]; + addonList[temp_type].info((char *)tmp_info); + SetWindowText(GetDlgItem(dialog, IDC_ADDONS_INFO), (char *)tmp_info); + + _OKbutton = false; + wndConfig=CreateDialog(hAppInst, MAKEINTRESOURCE(GBAslot_IDDs[temp_type]), + dialog, (DLGPROC)GBAslot_Procs[temp_type]); + if ( (temp_type == 0) || (_OKbutton) ) + EnableWindow(OKbutton, TRUE); + else + EnableWindow(OKbutton, FALSE); + return TRUE; + } + + case WM_COMMAND: + { + switch (LOWORD(wparam)) + { + case IDOK: + { + int Msg = IDYES; + if (romloaded && (needReset || (temp_type!=addon_type)) ) + { + Msg = MessageBox(dialog, + "After change GBA slot pak game will reset!\nAre you sure to continue?", "DeSmuME", + MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2); + } + if (Msg == IDYES) + { + if (wndConfig) DestroyWindow(wndConfig); + EndDialog(dialog, TRUE); + } + } + return TRUE; + case IDCANCEL: + if (wndConfig) DestroyWindow(wndConfig); + EndDialog(dialog, FALSE); + return TRUE; + + case IDC_ADDONS_LIST: + if (HIWORD(wparam) == CBN_SELENDOK) + { + temp_type = ComboBox_GetCurSel(GetDlgItem(dialog, IDC_ADDONS_LIST)); + if (temp_type != last_type) + { + if (wndConfig) DestroyWindow(wndConfig); + _OKbutton = false; + wndConfig=CreateDialog(hAppInst, + MAKEINTRESOURCE(GBAslot_IDDs[temp_type]), dialog, + (DLGPROC)GBAslot_Procs[temp_type]); + if ( (temp_type == 0) || (_OKbutton) ) + EnableWindow(OKbutton, TRUE); + else + EnableWindow(OKbutton, FALSE); + u8 tmp_info[512]; + addonList[temp_type].info((char *)tmp_info); + SetWindowText(GetDlgItem(dialog, IDC_ADDONS_INFO), (char *)tmp_info); + last_type = temp_type; + } + } + return TRUE; + } + break; + } + } + return FALSE; +} + +void GBAslotDialog(HWND hwnd) +{ + temp_type = addon_type; + last_type = temp_type; + strcpy(tmp_cflash_filename, CFlashName.c_str()); + strcpy(tmp_cflash_path, CFlashPath.c_str()); + strcpy(tmp_gbagame_filename, GBAgameName); + memcpy(&tmp_Guitar, &Guitar, sizeof(Guitar)); + tmp_CFlashMode = CFlash_Mode; + _OKbutton = false; + needReset = true; + u32 res=DialogBox(hAppInst, MAKEINTRESOURCE(IDD_GBASLOT), hwnd, (DLGPROC) GbaSlotBox_Proc); + if (res) + { + switch (temp_type) + { + case NDS_ADDON_NONE: + break; + case NDS_ADDON_CFLASH: + CFlash_Mode = tmp_CFlashMode; + WritePrivateProfileInt("GBAslot.CFlash","fileMode",CFlash_Mode,IniName); + WritePrivateProfileString("GBAslot.CFlash","path",tmp_cflash_path,IniName); + WritePrivateProfileString("GBAslot.CFlash","filename",tmp_cflash_filename,IniName); + if(CFlash_Mode == ADDON_CFLASH_MODE_Path) + CFlash_Path = tmp_cflash_path; + else if(CFlash_Mode == ADDON_CFLASH_MODE_RomPath) + CFlash_Path = ""; + else + CFlash_Path = tmp_cflash_filename; + + break; + case NDS_ADDON_RUMBLEPAK: + break; + case NDS_ADDON_GBAGAME: + strcpy(GBAgameName, tmp_gbagame_filename); + WritePrivateProfileString("GBAslot.GBAgame","filename",GBAgameName,IniName); + break; + case NDS_ADDON_GUITARGRIP: + memcpy(&Guitar, &tmp_Guitar, sizeof(tmp_Guitar)); + Guitar.Enabled = true; + WritePrivateProfileInt("GBAslot.GuitarGrip","green",Guitar.GREEN,IniName); + WritePrivateProfileInt("GBAslot.GuitarGrip","red",Guitar.RED,IniName); + WritePrivateProfileInt("GBAslot.GuitarGrip","yellow",Guitar.YELLOW,IniName); + WritePrivateProfileInt("GBAslot.GuitarGrip","blue",Guitar.BLUE,IniName); + break; + default: + return; + } + if (temp_type!=NDS_ADDON_GUITARGRIP) + Guitar.Enabled = false; + WritePrivateProfileInt("GBAslot","type",temp_type,IniName); + + addon_type = temp_type; + addonsChangePak(addon_type); + if (romloaded && needReset) + NDS_Reset(); + return; + } } \ No newline at end of file diff --git a/desmume/src/windows/gbaslot_config.h b/src/windows/gbaslot_config.h similarity index 96% rename from desmume/src/windows/gbaslot_config.h rename to src/windows/gbaslot_config.h index 59f1092a0..1866a726c 100644 --- a/desmume/src/windows/gbaslot_config.h +++ b/src/windows/gbaslot_config.h @@ -1,30 +1,30 @@ -/* - Copyright (C) 2008 shash - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef __GBASLOT_CONFIG_H_ -#define __GBASLOT_CONFIG_H_ -#include "../common.h" -#include - -extern std::string CFlashPath, CFlashName; - -extern void GBAslotDialog(HWND hwnd); - -#endif +/* + Copyright (C) 2008 shash + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef __GBASLOT_CONFIG_H_ +#define __GBASLOT_CONFIG_H_ +#include "../common.h" +#include + +extern std::string CFlashPath, CFlashName; + +extern void GBAslotDialog(HWND hwnd); + +#endif diff --git a/desmume/src/windows/ginfo.cpp b/src/windows/ginfo.cpp similarity index 96% rename from desmume/src/windows/ginfo.cpp rename to src/windows/ginfo.cpp index 717dc8edc..9d7d98d80 100644 --- a/desmume/src/windows/ginfo.cpp +++ b/src/windows/ginfo.cpp @@ -1,346 +1,346 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "resource.h" -#include "common.h" -#include "../MMU.h" -#include "../NDSSystem.h" -#include "FirmConfig.h" -#include -#include -#include -#include "ginfo.h" - -////////////////////////////////////////////////////////////////////////////// - -BOOL GInfo_Init() -{ - WNDCLASSEX wc; - - wc.cbSize = sizeof(wc); - wc.lpszClassName = "GInfo_IconBox"; - wc.hInstance = hAppInst; - wc.lpfnWndProc = GInfo_IconBoxProc; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); - wc.style = 0; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hIconSm = 0; - - RegisterClassEx(&wc); - - return 1; -} - -void GInfo_DeInit() -{ - UnregisterClass("GInfo_IconBox", hAppInst); -} - -////////////////////////////////////////////////////////////////////////////// - -BOOL GInfo_DlgOpen(HWND hParentWnd) -{ - HWND hDlg; - - hDlg = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_GAME_INFO), hParentWnd, GInfo_DlgProc); - if(hDlg == NULL) - return 0; - - ShowWindow(hDlg, SW_SHOW); - UpdateWindow(hDlg); - - return 1; -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT GInfo_Paint(HWND hDlg, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - char text[80]; - u32 icontitleOffset; - wchar_t *utf16text; - u32 val; - - hdc = BeginPaint(hDlg, &ps); - - icontitleOffset = T1ReadLong(MMU.CART_ROM, 0x68); - - if(icontitleOffset >= 0x8000) - { - utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x240 + (0x100 * win_fw_config.language)); - sprintf(text, "%ws", utf16text); - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLE), text); - - utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x240); - sprintf(text, "%ws", utf16text); - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEJP), text); - - utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x340); - sprintf(text, "%ws", utf16text); - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEEN), text); - - utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x440); - sprintf(text, "%ws", utf16text); - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEFR), text); - - utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x540); - sprintf(text, "%ws", utf16text); - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEGE), text); - - utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x640); - sprintf(text, "%ws", utf16text); - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEIT), text); - - utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x740); - sprintf(text, "%ws", utf16text); - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLESP), text); - } - else - { - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLE), "\nNo title\n"); - - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEJP), "None"); - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEEN), "None"); - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEFR), "None"); - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEGE), "None"); - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEIT), "None"); - SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLESP), "None"); - } - - - memcpy(text, MMU.CART_ROM, 12); - text[12] = '\0'; - SetWindowText(GetDlgItem(hDlg, IDC_GI_GAMETITLE), text); - - memcpy(text, (MMU.CART_ROM+0xC), 4); - text[4] = '\0'; - SetWindowText(GetDlgItem(hDlg, IDC_GI_GAMECODE), text); - - memcpy(text, (MMU.CART_ROM+0x10), 2); - text[2] = '\0'; - SetWindowText(GetDlgItem(hDlg, IDC_GI_MAKERCODE), text); - - val = T1ReadByte(MMU.CART_ROM, 0x14); - sprintf(text, "%i kilobytes", (0x80 << val)); - SetWindowText(GetDlgItem(hDlg, IDC_GI_CHIPSIZE), text); - - - val = T1ReadLong(MMU.CART_ROM, 0x20); - sprintf(text, "0x%08X", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9ROM), text); - - val = T1ReadLong(MMU.CART_ROM, 0x24); - sprintf(text, "0x%08X", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9ENTRY), text); - - val = T1ReadLong(MMU.CART_ROM, 0x28); - sprintf(text, "0x%08X", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9START), text); - - val = T1ReadLong(MMU.CART_ROM, 0x2C); - sprintf(text, "%i bytes", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9SIZE), text); - - val = T1ReadLong(MMU.CART_ROM, 0x30); - sprintf(text, "0x%08X", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7ROM), text); - - val = T1ReadLong(MMU.CART_ROM, 0x34); - sprintf(text, "0x%08X", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7ENTRY), text); - - val = T1ReadLong(MMU.CART_ROM, 0x38); - sprintf(text, "0x%08X", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7START), text); - - val = T1ReadLong(MMU.CART_ROM, 0x3C); - sprintf(text, "%i bytes", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7SIZE), text); - - - val = T1ReadLong(MMU.CART_ROM, 0x40); - sprintf(text, "0x%08X", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_FNTOFS), text); - - val = T1ReadLong(MMU.CART_ROM, 0x44); - sprintf(text, "%i bytes", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_FNTSIZE), text); - - val = T1ReadLong(MMU.CART_ROM, 0x48); - sprintf(text, "0x%08X", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_FATOFS), text); - - val = T1ReadLong(MMU.CART_ROM, 0x4C); - sprintf(text, "%i bytes", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_FATSIZE), text); - - - sprintf(text, "0x%08X", icontitleOffset); - SetWindowText(GetDlgItem(hDlg, IDC_GI_ICONTITLEOFS), text); - - val = T1ReadLong(MMU.CART_ROM, 0x80); - sprintf(text, "0x%08X", val); - SetWindowText(GetDlgItem(hDlg, IDC_GI_USEDROMSIZE), text); - - - EndPaint(hDlg, &ps); - - return 0; -} - -BOOL CALLBACK GInfo_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_INITDIALOG: - return 1; - - case WM_CLOSE: - EndDialog(hDlg, 0); - return 1; - - case WM_PAINT: - GInfo_Paint(hDlg, wParam, lParam); - return 1; - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDCANCEL: - EndDialog(hDlg, 0); - return 1; - } - return 0; - } - - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT GInfo_IconBoxPaint(HWND hCtl, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - RECT rc; - int w, h; - SIZE fontsize; - HDC mem_hdc; - HBITMAP mem_bmp; - BITMAPV4HEADER bmph; - u32 icontitleOffset; - u16 icon[32 * 32]; - int x, y; - - GetClientRect(hCtl, &rc); - w = (rc.right - rc.left); - h = (rc.bottom - rc.top); - - hdc = BeginPaint(hCtl, &ps); - - mem_hdc = CreateCompatibleDC(hdc); - mem_bmp = CreateCompatibleBitmap(hdc, w, h); - SelectObject(mem_hdc, mem_bmp); - - FillRect(mem_hdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - ZeroMemory(&bmph, sizeof(bmph)); - bmph.bV4Size = sizeof(bmph); - bmph.bV4Planes = 1; - bmph.bV4BitCount = 16; - bmph.bV4V4Compression = BI_BITFIELDS; - bmph.bV4RedMask = 0x001F; - bmph.bV4GreenMask = 0x03E0; - bmph.bV4BlueMask = 0x7C00; - bmph.bV4Width = 32; - bmph.bV4Height = -32; - - icontitleOffset = T1ReadLong(MMU.CART_ROM, 0x68); - - if(icontitleOffset >= 0x8000) - { - for(y = 0; y < 32; y++) - { - for(x = 0; x < 32; x++) - { - int tilenum = (((y / 8) * 4) + (x / 8)); - int tilex = (x % 8); - int tiley = (y % 8); - int mapoffset = ((tilenum * 64) + (tiley * 8) + tilex); - - u8 val = T1ReadByte(MMU.CART_ROM, (icontitleOffset + 0x20 + (mapoffset>>1))); - - if(mapoffset & 1) - val = ((val >> 4) & 0xF); - else - val = (val & 0xF); - - icon[(y * 32) + x] = T1ReadWord(MMU.CART_ROM, (icontitleOffset + 0x220 + (val<<1))); - } - } - - SetDIBitsToDevice(mem_hdc, ((w/2) - 16), ((h/2) - 16), 32, 32, 0, 0, 0, 32, icon, (BITMAPINFO*)&bmph, DIB_RGB_COLORS); - } - else - { - char *noicon = "No icon"; - GetTextExtentPoint32(mem_hdc, noicon, strlen(noicon), &fontsize); - TextOut(mem_hdc, ((w/2) - (fontsize.cx/2)), ((h/2) - (fontsize.cy/2)), noicon, strlen(noicon)); - } - - BitBlt(hdc, 0, 0, w, h, mem_hdc, 0, 0, SRCCOPY); - - DeleteDC(mem_hdc); - DeleteObject(mem_bmp); - - EndPaint(hCtl, &ps); - - return 0; -} - -LRESULT CALLBACK GInfo_IconBoxProc(HWND hCtl, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_NCCREATE: - return 1; - - case WM_NCDESTROY: - return 1; - - case WM_ERASEBKGND: - return 1; - - case WM_PAINT: - GInfo_IconBoxPaint(hCtl, wParam, lParam); - return 1; - } - - return DefWindowProc(hCtl, uMsg, wParam, lParam); -} - -////////////////////////////////////////////////////////////////////////////// +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "resource.h" +#include "common.h" +#include "../MMU.h" +#include "../NDSSystem.h" +#include "FirmConfig.h" +#include +#include +#include +#include "ginfo.h" + +////////////////////////////////////////////////////////////////////////////// + +BOOL GInfo_Init() +{ + WNDCLASSEX wc; + + wc.cbSize = sizeof(wc); + wc.lpszClassName = "GInfo_IconBox"; + wc.hInstance = hAppInst; + wc.lpfnWndProc = GInfo_IconBoxProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hIcon = 0; + wc.lpszMenuName = 0; + wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); + wc.style = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hIconSm = 0; + + RegisterClassEx(&wc); + + return 1; +} + +void GInfo_DeInit() +{ + UnregisterClass("GInfo_IconBox", hAppInst); +} + +////////////////////////////////////////////////////////////////////////////// + +BOOL GInfo_DlgOpen(HWND hParentWnd) +{ + HWND hDlg; + + hDlg = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_GAME_INFO), hParentWnd, GInfo_DlgProc); + if(hDlg == NULL) + return 0; + + ShowWindow(hDlg, SW_SHOW); + UpdateWindow(hDlg); + + return 1; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT GInfo_Paint(HWND hDlg, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + char text[80]; + u32 icontitleOffset; + wchar_t *utf16text; + u32 val; + + hdc = BeginPaint(hDlg, &ps); + + icontitleOffset = T1ReadLong(MMU.CART_ROM, 0x68); + + if(icontitleOffset >= 0x8000) + { + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x240 + (0x100 * win_fw_config.language)); + sprintf(text, "%ws", utf16text); + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLE), text); + + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x240); + sprintf(text, "%ws", utf16text); + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEJP), text); + + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x340); + sprintf(text, "%ws", utf16text); + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEEN), text); + + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x440); + sprintf(text, "%ws", utf16text); + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEFR), text); + + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x540); + sprintf(text, "%ws", utf16text); + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEGE), text); + + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x640); + sprintf(text, "%ws", utf16text); + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEIT), text); + + utf16text = (wchar_t*)(MMU.CART_ROM + icontitleOffset + 0x740); + sprintf(text, "%ws", utf16text); + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLESP), text); + } + else + { + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLE), "\nNo title\n"); + + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEJP), "None"); + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEEN), "None"); + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEFR), "None"); + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEGE), "None"); + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLEIT), "None"); + SetWindowText(GetDlgItem(hDlg, IDC_GI_TITLESP), "None"); + } + + + memcpy(text, MMU.CART_ROM, 12); + text[12] = '\0'; + SetWindowText(GetDlgItem(hDlg, IDC_GI_GAMETITLE), text); + + memcpy(text, (MMU.CART_ROM+0xC), 4); + text[4] = '\0'; + SetWindowText(GetDlgItem(hDlg, IDC_GI_GAMECODE), text); + + memcpy(text, (MMU.CART_ROM+0x10), 2); + text[2] = '\0'; + SetWindowText(GetDlgItem(hDlg, IDC_GI_MAKERCODE), text); + + val = T1ReadByte(MMU.CART_ROM, 0x14); + sprintf(text, "%i kilobytes", (0x80 << val)); + SetWindowText(GetDlgItem(hDlg, IDC_GI_CHIPSIZE), text); + + + val = T1ReadLong(MMU.CART_ROM, 0x20); + sprintf(text, "0x%08X", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9ROM), text); + + val = T1ReadLong(MMU.CART_ROM, 0x24); + sprintf(text, "0x%08X", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9ENTRY), text); + + val = T1ReadLong(MMU.CART_ROM, 0x28); + sprintf(text, "0x%08X", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9START), text); + + val = T1ReadLong(MMU.CART_ROM, 0x2C); + sprintf(text, "%i bytes", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM9SIZE), text); + + val = T1ReadLong(MMU.CART_ROM, 0x30); + sprintf(text, "0x%08X", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7ROM), text); + + val = T1ReadLong(MMU.CART_ROM, 0x34); + sprintf(text, "0x%08X", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7ENTRY), text); + + val = T1ReadLong(MMU.CART_ROM, 0x38); + sprintf(text, "0x%08X", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7START), text); + + val = T1ReadLong(MMU.CART_ROM, 0x3C); + sprintf(text, "%i bytes", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_ARM7SIZE), text); + + + val = T1ReadLong(MMU.CART_ROM, 0x40); + sprintf(text, "0x%08X", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_FNTOFS), text); + + val = T1ReadLong(MMU.CART_ROM, 0x44); + sprintf(text, "%i bytes", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_FNTSIZE), text); + + val = T1ReadLong(MMU.CART_ROM, 0x48); + sprintf(text, "0x%08X", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_FATOFS), text); + + val = T1ReadLong(MMU.CART_ROM, 0x4C); + sprintf(text, "%i bytes", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_FATSIZE), text); + + + sprintf(text, "0x%08X", icontitleOffset); + SetWindowText(GetDlgItem(hDlg, IDC_GI_ICONTITLEOFS), text); + + val = T1ReadLong(MMU.CART_ROM, 0x80); + sprintf(text, "0x%08X", val); + SetWindowText(GetDlgItem(hDlg, IDC_GI_USEDROMSIZE), text); + + + EndPaint(hDlg, &ps); + + return 0; +} + +BOOL CALLBACK GInfo_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + return 1; + + case WM_CLOSE: + EndDialog(hDlg, 0); + return 1; + + case WM_PAINT: + GInfo_Paint(hDlg, wParam, lParam); + return 1; + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDCANCEL: + EndDialog(hDlg, 0); + return 1; + } + return 0; + } + + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT GInfo_IconBoxPaint(HWND hCtl, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + RECT rc; + int w, h; + SIZE fontsize; + HDC mem_hdc; + HBITMAP mem_bmp; + BITMAPV4HEADER bmph; + u32 icontitleOffset; + u16 icon[32 * 32]; + int x, y; + + GetClientRect(hCtl, &rc); + w = (rc.right - rc.left); + h = (rc.bottom - rc.top); + + hdc = BeginPaint(hCtl, &ps); + + mem_hdc = CreateCompatibleDC(hdc); + mem_bmp = CreateCompatibleBitmap(hdc, w, h); + SelectObject(mem_hdc, mem_bmp); + + FillRect(mem_hdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + ZeroMemory(&bmph, sizeof(bmph)); + bmph.bV4Size = sizeof(bmph); + bmph.bV4Planes = 1; + bmph.bV4BitCount = 16; + bmph.bV4V4Compression = BI_BITFIELDS; + bmph.bV4RedMask = 0x001F; + bmph.bV4GreenMask = 0x03E0; + bmph.bV4BlueMask = 0x7C00; + bmph.bV4Width = 32; + bmph.bV4Height = -32; + + icontitleOffset = T1ReadLong(MMU.CART_ROM, 0x68); + + if(icontitleOffset >= 0x8000) + { + for(y = 0; y < 32; y++) + { + for(x = 0; x < 32; x++) + { + int tilenum = (((y / 8) * 4) + (x / 8)); + int tilex = (x % 8); + int tiley = (y % 8); + int mapoffset = ((tilenum * 64) + (tiley * 8) + tilex); + + u8 val = T1ReadByte(MMU.CART_ROM, (icontitleOffset + 0x20 + (mapoffset>>1))); + + if(mapoffset & 1) + val = ((val >> 4) & 0xF); + else + val = (val & 0xF); + + icon[(y * 32) + x] = T1ReadWord(MMU.CART_ROM, (icontitleOffset + 0x220 + (val<<1))); + } + } + + SetDIBitsToDevice(mem_hdc, ((w/2) - 16), ((h/2) - 16), 32, 32, 0, 0, 0, 32, icon, (BITMAPINFO*)&bmph, DIB_RGB_COLORS); + } + else + { + char *noicon = "No icon"; + GetTextExtentPoint32(mem_hdc, noicon, strlen(noicon), &fontsize); + TextOut(mem_hdc, ((w/2) - (fontsize.cx/2)), ((h/2) - (fontsize.cy/2)), noicon, strlen(noicon)); + } + + BitBlt(hdc, 0, 0, w, h, mem_hdc, 0, 0, SRCCOPY); + + DeleteDC(mem_hdc); + DeleteObject(mem_bmp); + + EndPaint(hCtl, &ps); + + return 0; +} + +LRESULT CALLBACK GInfo_IconBoxProc(HWND hCtl, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_NCCREATE: + return 1; + + case WM_NCDESTROY: + return 1; + + case WM_ERASEBKGND: + return 1; + + case WM_PAINT: + GInfo_IconBoxPaint(hCtl, wParam, lParam); + return 1; + } + + return DefWindowProc(hCtl, uMsg, wParam, lParam); +} + +////////////////////////////////////////////////////////////////////////////// diff --git a/desmume/src/windows/ginfo.h b/src/windows/ginfo.h similarity index 97% rename from desmume/src/windows/ginfo.h rename to src/windows/ginfo.h index 5b9855f69..09dfa4a9e 100644 --- a/desmume/src/windows/ginfo.h +++ b/src/windows/ginfo.h @@ -1,33 +1,33 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef GINFO_H -#define GINFO_H - -BOOL GInfo_Init(); -void GInfo_DeInit(); - -BOOL GInfo_DlgOpen(HWND hParentWnd); - -BOOL CALLBACK GInfo_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -LRESULT CALLBACK GInfo_IconBoxProc(HWND hCtl, UINT uMsg, WPARAM wParam, LPARAM lParam); - -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef GINFO_H +#define GINFO_H + +BOOL GInfo_Init(); +void GInfo_DeInit(); + +BOOL GInfo_DlgOpen(HWND hParentWnd); + +BOOL CALLBACK GInfo_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK GInfo_IconBoxProc(HWND hCtl, UINT uMsg, WPARAM wParam, LPARAM lParam); + +#endif diff --git a/desmume/src/windows/glib-2.20.1/build/dependencies/proxy-libintl-20080918/include/libintl.h b/src/windows/glib-2.20.1/build/dependencies/proxy-libintl-20080918/include/libintl.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/dependencies/proxy-libintl-20080918/include/libintl.h rename to src/windows/glib-2.20.1/build/dependencies/proxy-libintl-20080918/include/libintl.h diff --git a/desmume/src/windows/glib-2.20.1/build/dirent/README b/src/windows/glib-2.20.1/build/dirent/README similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/dirent/README rename to src/windows/glib-2.20.1/build/dirent/README diff --git a/desmume/src/windows/glib-2.20.1/build/dirent/dirent.c b/src/windows/glib-2.20.1/build/dirent/dirent.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/dirent/dirent.c rename to src/windows/glib-2.20.1/build/dirent/dirent.c diff --git a/desmume/src/windows/glib-2.20.1/build/dirent/dirent.h b/src/windows/glib-2.20.1/build/dirent/dirent.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/dirent/dirent.h rename to src/windows/glib-2.20.1/build/dirent/dirent.h diff --git a/desmume/src/windows/glib-2.20.1/build/dirent/wdirent.c b/src/windows/glib-2.20.1/build/dirent/wdirent.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/dirent/wdirent.c rename to src/windows/glib-2.20.1/build/dirent/wdirent.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/config.h b/src/windows/glib-2.20.1/build/glib/config.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/config.h rename to src/windows/glib-2.20.1/build/glib/config.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/galias.h b/src/windows/glib-2.20.1/build/glib/galias.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/galias.h rename to src/windows/glib-2.20.1/build/glib/galias.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/galiasdef.c b/src/windows/glib-2.20.1/build/glib/galiasdef.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/galiasdef.c rename to src/windows/glib-2.20.1/build/glib/galiasdef.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/galloca.h b/src/windows/glib-2.20.1/build/glib/galloca.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/galloca.h rename to src/windows/glib-2.20.1/build/glib/galloca.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/garray.c b/src/windows/glib-2.20.1/build/glib/garray.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/garray.c rename to src/windows/glib-2.20.1/build/glib/garray.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/garray.h b/src/windows/glib-2.20.1/build/glib/garray.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/garray.h rename to src/windows/glib-2.20.1/build/glib/garray.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gasyncqueue.c b/src/windows/glib-2.20.1/build/glib/gasyncqueue.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gasyncqueue.c rename to src/windows/glib-2.20.1/build/glib/gasyncqueue.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gasyncqueue.h b/src/windows/glib-2.20.1/build/glib/gasyncqueue.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gasyncqueue.h rename to src/windows/glib-2.20.1/build/glib/gasyncqueue.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gatomic.c b/src/windows/glib-2.20.1/build/glib/gatomic.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gatomic.c rename to src/windows/glib-2.20.1/build/glib/gatomic.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gatomic.h b/src/windows/glib-2.20.1/build/glib/gatomic.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gatomic.h rename to src/windows/glib-2.20.1/build/glib/gatomic.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gbacktrace.c b/src/windows/glib-2.20.1/build/glib/gbacktrace.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gbacktrace.c rename to src/windows/glib-2.20.1/build/glib/gbacktrace.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gbacktrace.h b/src/windows/glib-2.20.1/build/glib/gbacktrace.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gbacktrace.h rename to src/windows/glib-2.20.1/build/glib/gbacktrace.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gbase64.c b/src/windows/glib-2.20.1/build/glib/gbase64.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gbase64.c rename to src/windows/glib-2.20.1/build/glib/gbase64.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gbase64.h b/src/windows/glib-2.20.1/build/glib/gbase64.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gbase64.h rename to src/windows/glib-2.20.1/build/glib/gbase64.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gbookmarkfile.c b/src/windows/glib-2.20.1/build/glib/gbookmarkfile.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gbookmarkfile.c rename to src/windows/glib-2.20.1/build/glib/gbookmarkfile.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gbookmarkfile.h b/src/windows/glib-2.20.1/build/glib/gbookmarkfile.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gbookmarkfile.h rename to src/windows/glib-2.20.1/build/glib/gbookmarkfile.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gbsearcharray.h b/src/windows/glib-2.20.1/build/glib/gbsearcharray.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gbsearcharray.h rename to src/windows/glib-2.20.1/build/glib/gbsearcharray.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gcache.c b/src/windows/glib-2.20.1/build/glib/gcache.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gcache.c rename to src/windows/glib-2.20.1/build/glib/gcache.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gcache.h b/src/windows/glib-2.20.1/build/glib/gcache.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gcache.h rename to src/windows/glib-2.20.1/build/glib/gcache.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gchecksum.c b/src/windows/glib-2.20.1/build/glib/gchecksum.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gchecksum.c rename to src/windows/glib-2.20.1/build/glib/gchecksum.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gchecksum.h b/src/windows/glib-2.20.1/build/glib/gchecksum.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gchecksum.h rename to src/windows/glib-2.20.1/build/glib/gchecksum.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gcompletion.c b/src/windows/glib-2.20.1/build/glib/gcompletion.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gcompletion.c rename to src/windows/glib-2.20.1/build/glib/gcompletion.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gcompletion.h b/src/windows/glib-2.20.1/build/glib/gcompletion.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gcompletion.h rename to src/windows/glib-2.20.1/build/glib/gcompletion.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gconvert.c b/src/windows/glib-2.20.1/build/glib/gconvert.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gconvert.c rename to src/windows/glib-2.20.1/build/glib/gconvert.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gconvert.h b/src/windows/glib-2.20.1/build/glib/gconvert.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gconvert.h rename to src/windows/glib-2.20.1/build/glib/gconvert.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gdataset.c b/src/windows/glib-2.20.1/build/glib/gdataset.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gdataset.c rename to src/windows/glib-2.20.1/build/glib/gdataset.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gdataset.h b/src/windows/glib-2.20.1/build/glib/gdataset.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gdataset.h rename to src/windows/glib-2.20.1/build/glib/gdataset.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gdatasetprivate.h b/src/windows/glib-2.20.1/build/glib/gdatasetprivate.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gdatasetprivate.h rename to src/windows/glib-2.20.1/build/glib/gdatasetprivate.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gdate.c b/src/windows/glib-2.20.1/build/glib/gdate.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gdate.c rename to src/windows/glib-2.20.1/build/glib/gdate.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gdate.h b/src/windows/glib-2.20.1/build/glib/gdate.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gdate.h rename to src/windows/glib-2.20.1/build/glib/gdate.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gdebug.h b/src/windows/glib-2.20.1/build/glib/gdebug.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gdebug.h rename to src/windows/glib-2.20.1/build/glib/gdebug.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gdir.c b/src/windows/glib-2.20.1/build/glib/gdir.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gdir.c rename to src/windows/glib-2.20.1/build/glib/gdir.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gdir.h b/src/windows/glib-2.20.1/build/glib/gdir.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gdir.h rename to src/windows/glib-2.20.1/build/glib/gdir.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gerror.c b/src/windows/glib-2.20.1/build/glib/gerror.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gerror.c rename to src/windows/glib-2.20.1/build/glib/gerror.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gerror.h b/src/windows/glib-2.20.1/build/glib/gerror.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gerror.h rename to src/windows/glib-2.20.1/build/glib/gerror.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gfileutils.c b/src/windows/glib-2.20.1/build/glib/gfileutils.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gfileutils.c rename to src/windows/glib-2.20.1/build/glib/gfileutils.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gfileutils.h b/src/windows/glib-2.20.1/build/glib/gfileutils.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gfileutils.h rename to src/windows/glib-2.20.1/build/glib/gfileutils.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/ghash.c b/src/windows/glib-2.20.1/build/glib/ghash.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/ghash.c rename to src/windows/glib-2.20.1/build/glib/ghash.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/ghash.h b/src/windows/glib-2.20.1/build/glib/ghash.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/ghash.h rename to src/windows/glib-2.20.1/build/glib/ghash.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/ghook.c b/src/windows/glib-2.20.1/build/glib/ghook.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/ghook.c rename to src/windows/glib-2.20.1/build/glib/ghook.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/ghook.h b/src/windows/glib-2.20.1/build/glib/ghook.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/ghook.h rename to src/windows/glib-2.20.1/build/glib/ghook.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gi18n-lib.h b/src/windows/glib-2.20.1/build/glib/gi18n-lib.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gi18n-lib.h rename to src/windows/glib-2.20.1/build/glib/gi18n-lib.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gi18n.h b/src/windows/glib-2.20.1/build/glib/gi18n.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gi18n.h rename to src/windows/glib-2.20.1/build/glib/gi18n.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/giochannel.c b/src/windows/glib-2.20.1/build/glib/giochannel.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/giochannel.c rename to src/windows/glib-2.20.1/build/glib/giochannel.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/giochannel.h b/src/windows/glib-2.20.1/build/glib/giochannel.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/giochannel.h rename to src/windows/glib-2.20.1/build/glib/giochannel.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/giounix.c b/src/windows/glib-2.20.1/build/glib/giounix.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/giounix.c rename to src/windows/glib-2.20.1/build/glib/giounix.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/giowin32.c b/src/windows/glib-2.20.1/build/glib/giowin32.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/giowin32.c rename to src/windows/glib-2.20.1/build/glib/giowin32.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gkeyfile.c b/src/windows/glib-2.20.1/build/glib/gkeyfile.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gkeyfile.c rename to src/windows/glib-2.20.1/build/glib/gkeyfile.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gkeyfile.h b/src/windows/glib-2.20.1/build/glib/gkeyfile.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gkeyfile.h rename to src/windows/glib-2.20.1/build/glib/gkeyfile.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/glib-object.h b/src/windows/glib-2.20.1/build/glib/glib-object.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/glib-object.h rename to src/windows/glib-2.20.1/build/glib/glib-object.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/glib.h b/src/windows/glib-2.20.1/build/glib/glib.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/glib.h rename to src/windows/glib-2.20.1/build/glib/glib.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/glibintl.h b/src/windows/glib-2.20.1/build/glib/glibintl.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/glibintl.h rename to src/windows/glib-2.20.1/build/glib/glibintl.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/glist.c b/src/windows/glib-2.20.1/build/glib/glist.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/glist.c rename to src/windows/glib-2.20.1/build/glib/glist.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/glist.h b/src/windows/glib-2.20.1/build/glib/glist.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/glist.h rename to src/windows/glib-2.20.1/build/glib/glist.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gmacros.h b/src/windows/glib-2.20.1/build/glib/gmacros.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gmacros.h rename to src/windows/glib-2.20.1/build/glib/gmacros.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gmain.c b/src/windows/glib-2.20.1/build/glib/gmain.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gmain.c rename to src/windows/glib-2.20.1/build/glib/gmain.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gmain.h b/src/windows/glib-2.20.1/build/glib/gmain.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gmain.h rename to src/windows/glib-2.20.1/build/glib/gmain.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gmappedfile.c b/src/windows/glib-2.20.1/build/glib/gmappedfile.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gmappedfile.c rename to src/windows/glib-2.20.1/build/glib/gmappedfile.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gmappedfile.h b/src/windows/glib-2.20.1/build/glib/gmappedfile.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gmappedfile.h rename to src/windows/glib-2.20.1/build/glib/gmappedfile.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gmarkup.c b/src/windows/glib-2.20.1/build/glib/gmarkup.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gmarkup.c rename to src/windows/glib-2.20.1/build/glib/gmarkup.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gmarkup.h b/src/windows/glib-2.20.1/build/glib/gmarkup.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gmarkup.h rename to src/windows/glib-2.20.1/build/glib/gmarkup.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gmem.c b/src/windows/glib-2.20.1/build/glib/gmem.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gmem.c rename to src/windows/glib-2.20.1/build/glib/gmem.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gmem.h b/src/windows/glib-2.20.1/build/glib/gmem.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gmem.h rename to src/windows/glib-2.20.1/build/glib/gmem.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gmessages.c b/src/windows/glib-2.20.1/build/glib/gmessages.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gmessages.c rename to src/windows/glib-2.20.1/build/glib/gmessages.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gmessages.h b/src/windows/glib-2.20.1/build/glib/gmessages.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gmessages.h rename to src/windows/glib-2.20.1/build/glib/gmessages.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gmirroringtable.h b/src/windows/glib-2.20.1/build/glib/gmirroringtable.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gmirroringtable.h rename to src/windows/glib-2.20.1/build/glib/gmirroringtable.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnode.c b/src/windows/glib-2.20.1/build/glib/gnode.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnode.c rename to src/windows/glib-2.20.1/build/glib/gnode.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnode.h b/src/windows/glib-2.20.1/build/glib/gnode.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnode.h rename to src/windows/glib-2.20.1/build/glib/gnode.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnulib/README b/src/windows/glib-2.20.1/build/glib/gnulib/README similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnulib/README rename to src/windows/glib-2.20.1/build/glib/gnulib/README diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnulib/asnprintf.c b/src/windows/glib-2.20.1/build/glib/gnulib/asnprintf.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnulib/asnprintf.c rename to src/windows/glib-2.20.1/build/glib/gnulib/asnprintf.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnulib/g-gnulib.h b/src/windows/glib-2.20.1/build/glib/gnulib/g-gnulib.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnulib/g-gnulib.h rename to src/windows/glib-2.20.1/build/glib/gnulib/g-gnulib.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnulib/printf-args.c b/src/windows/glib-2.20.1/build/glib/gnulib/printf-args.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnulib/printf-args.c rename to src/windows/glib-2.20.1/build/glib/gnulib/printf-args.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnulib/printf-args.h b/src/windows/glib-2.20.1/build/glib/gnulib/printf-args.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnulib/printf-args.h rename to src/windows/glib-2.20.1/build/glib/gnulib/printf-args.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnulib/printf-parse.c b/src/windows/glib-2.20.1/build/glib/gnulib/printf-parse.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnulib/printf-parse.c rename to src/windows/glib-2.20.1/build/glib/gnulib/printf-parse.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnulib/printf-parse.h b/src/windows/glib-2.20.1/build/glib/gnulib/printf-parse.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnulib/printf-parse.h rename to src/windows/glib-2.20.1/build/glib/gnulib/printf-parse.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnulib/printf.c b/src/windows/glib-2.20.1/build/glib/gnulib/printf.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnulib/printf.c rename to src/windows/glib-2.20.1/build/glib/gnulib/printf.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnulib/printf.h b/src/windows/glib-2.20.1/build/glib/gnulib/printf.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnulib/printf.h rename to src/windows/glib-2.20.1/build/glib/gnulib/printf.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnulib/vasnprintf.c b/src/windows/glib-2.20.1/build/glib/gnulib/vasnprintf.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnulib/vasnprintf.c rename to src/windows/glib-2.20.1/build/glib/gnulib/vasnprintf.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gnulib/vasnprintf.h b/src/windows/glib-2.20.1/build/glib/gnulib/vasnprintf.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gnulib/vasnprintf.h rename to src/windows/glib-2.20.1/build/glib/gnulib/vasnprintf.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/goption.c b/src/windows/glib-2.20.1/build/glib/goption.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/goption.c rename to src/windows/glib-2.20.1/build/glib/goption.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/goption.h b/src/windows/glib-2.20.1/build/glib/goption.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/goption.h rename to src/windows/glib-2.20.1/build/glib/goption.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gpattern.c b/src/windows/glib-2.20.1/build/glib/gpattern.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gpattern.c rename to src/windows/glib-2.20.1/build/glib/gpattern.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gpattern.h b/src/windows/glib-2.20.1/build/glib/gpattern.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gpattern.h rename to src/windows/glib-2.20.1/build/glib/gpattern.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gpoll.c b/src/windows/glib-2.20.1/build/glib/gpoll.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gpoll.c rename to src/windows/glib-2.20.1/build/glib/gpoll.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gpoll.h b/src/windows/glib-2.20.1/build/glib/gpoll.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gpoll.h rename to src/windows/glib-2.20.1/build/glib/gpoll.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gprimes.c b/src/windows/glib-2.20.1/build/glib/gprimes.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gprimes.c rename to src/windows/glib-2.20.1/build/glib/gprimes.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gprimes.h b/src/windows/glib-2.20.1/build/glib/gprimes.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gprimes.h rename to src/windows/glib-2.20.1/build/glib/gprimes.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gprintf.c b/src/windows/glib-2.20.1/build/glib/gprintf.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gprintf.c rename to src/windows/glib-2.20.1/build/glib/gprintf.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gprintf.h b/src/windows/glib-2.20.1/build/glib/gprintf.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gprintf.h rename to src/windows/glib-2.20.1/build/glib/gprintf.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gprintfint.h b/src/windows/glib-2.20.1/build/glib/gprintfint.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gprintfint.h rename to src/windows/glib-2.20.1/build/glib/gprintfint.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gqsort.c b/src/windows/glib-2.20.1/build/glib/gqsort.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gqsort.c rename to src/windows/glib-2.20.1/build/glib/gqsort.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gqsort.h b/src/windows/glib-2.20.1/build/glib/gqsort.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gqsort.h rename to src/windows/glib-2.20.1/build/glib/gqsort.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gquark.h b/src/windows/glib-2.20.1/build/glib/gquark.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gquark.h rename to src/windows/glib-2.20.1/build/glib/gquark.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gqueue.c b/src/windows/glib-2.20.1/build/glib/gqueue.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gqueue.c rename to src/windows/glib-2.20.1/build/glib/gqueue.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gqueue.h b/src/windows/glib-2.20.1/build/glib/gqueue.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gqueue.h rename to src/windows/glib-2.20.1/build/glib/gqueue.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/grand.c b/src/windows/glib-2.20.1/build/glib/grand.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/grand.c rename to src/windows/glib-2.20.1/build/glib/grand.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/grand.h b/src/windows/glib-2.20.1/build/glib/grand.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/grand.h rename to src/windows/glib-2.20.1/build/glib/grand.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gregex.c b/src/windows/glib-2.20.1/build/glib/gregex.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gregex.c rename to src/windows/glib-2.20.1/build/glib/gregex.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gregex.h b/src/windows/glib-2.20.1/build/glib/gregex.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gregex.h rename to src/windows/glib-2.20.1/build/glib/gregex.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/grel.c b/src/windows/glib-2.20.1/build/glib/grel.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/grel.c rename to src/windows/glib-2.20.1/build/glib/grel.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/grel.h b/src/windows/glib-2.20.1/build/glib/grel.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/grel.h rename to src/windows/glib-2.20.1/build/glib/grel.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gscanner.c b/src/windows/glib-2.20.1/build/glib/gscanner.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gscanner.c rename to src/windows/glib-2.20.1/build/glib/gscanner.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gscanner.h b/src/windows/glib-2.20.1/build/glib/gscanner.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gscanner.h rename to src/windows/glib-2.20.1/build/glib/gscanner.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gscripttable.h b/src/windows/glib-2.20.1/build/glib/gscripttable.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gscripttable.h rename to src/windows/glib-2.20.1/build/glib/gscripttable.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gsequence.c b/src/windows/glib-2.20.1/build/glib/gsequence.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gsequence.c rename to src/windows/glib-2.20.1/build/glib/gsequence.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gsequence.h b/src/windows/glib-2.20.1/build/glib/gsequence.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gsequence.h rename to src/windows/glib-2.20.1/build/glib/gsequence.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gshell.c b/src/windows/glib-2.20.1/build/glib/gshell.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gshell.c rename to src/windows/glib-2.20.1/build/glib/gshell.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gshell.h b/src/windows/glib-2.20.1/build/glib/gshell.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gshell.h rename to src/windows/glib-2.20.1/build/glib/gshell.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gslice.c b/src/windows/glib-2.20.1/build/glib/gslice.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gslice.c rename to src/windows/glib-2.20.1/build/glib/gslice.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gslice.h b/src/windows/glib-2.20.1/build/glib/gslice.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gslice.h rename to src/windows/glib-2.20.1/build/glib/gslice.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gslist.c b/src/windows/glib-2.20.1/build/glib/gslist.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gslist.c rename to src/windows/glib-2.20.1/build/glib/gslist.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gslist.h b/src/windows/glib-2.20.1/build/glib/gslist.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gslist.h rename to src/windows/glib-2.20.1/build/glib/gslist.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gspawn-win32-helper-console.c b/src/windows/glib-2.20.1/build/glib/gspawn-win32-helper-console.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gspawn-win32-helper-console.c rename to src/windows/glib-2.20.1/build/glib/gspawn-win32-helper-console.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gspawn-win32-helper.c b/src/windows/glib-2.20.1/build/glib/gspawn-win32-helper.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gspawn-win32-helper.c rename to src/windows/glib-2.20.1/build/glib/gspawn-win32-helper.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gspawn-win32.c b/src/windows/glib-2.20.1/build/glib/gspawn-win32.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gspawn-win32.c rename to src/windows/glib-2.20.1/build/glib/gspawn-win32.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gspawn-win64-helper-console.c b/src/windows/glib-2.20.1/build/glib/gspawn-win64-helper-console.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gspawn-win64-helper-console.c rename to src/windows/glib-2.20.1/build/glib/gspawn-win64-helper-console.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gspawn-win64-helper.c b/src/windows/glib-2.20.1/build/glib/gspawn-win64-helper.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gspawn-win64-helper.c rename to src/windows/glib-2.20.1/build/glib/gspawn-win64-helper.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gspawn.c b/src/windows/glib-2.20.1/build/glib/gspawn.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gspawn.c rename to src/windows/glib-2.20.1/build/glib/gspawn.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gspawn.h b/src/windows/glib-2.20.1/build/glib/gspawn.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gspawn.h rename to src/windows/glib-2.20.1/build/glib/gspawn.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gstdio.c b/src/windows/glib-2.20.1/build/glib/gstdio.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gstdio.c rename to src/windows/glib-2.20.1/build/glib/gstdio.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gstdio.h b/src/windows/glib-2.20.1/build/glib/gstdio.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gstdio.h rename to src/windows/glib-2.20.1/build/glib/gstdio.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gstrfuncs.c b/src/windows/glib-2.20.1/build/glib/gstrfuncs.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gstrfuncs.c rename to src/windows/glib-2.20.1/build/glib/gstrfuncs.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gstrfuncs.h b/src/windows/glib-2.20.1/build/glib/gstrfuncs.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gstrfuncs.h rename to src/windows/glib-2.20.1/build/glib/gstrfuncs.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gstring.c b/src/windows/glib-2.20.1/build/glib/gstring.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gstring.c rename to src/windows/glib-2.20.1/build/glib/gstring.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gstring.h b/src/windows/glib-2.20.1/build/glib/gstring.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gstring.h rename to src/windows/glib-2.20.1/build/glib/gstring.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gtester.c b/src/windows/glib-2.20.1/build/glib/gtester.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gtester.c rename to src/windows/glib-2.20.1/build/glib/gtester.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gtestutils.c b/src/windows/glib-2.20.1/build/glib/gtestutils.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gtestutils.c rename to src/windows/glib-2.20.1/build/glib/gtestutils.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gtestutils.h b/src/windows/glib-2.20.1/build/glib/gtestutils.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gtestutils.h rename to src/windows/glib-2.20.1/build/glib/gtestutils.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gthread.c b/src/windows/glib-2.20.1/build/glib/gthread.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gthread.c rename to src/windows/glib-2.20.1/build/glib/gthread.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gthread.h b/src/windows/glib-2.20.1/build/glib/gthread.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gthread.h rename to src/windows/glib-2.20.1/build/glib/gthread.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gthread/gthread-impl.c b/src/windows/glib-2.20.1/build/glib/gthread/gthread-impl.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gthread/gthread-impl.c rename to src/windows/glib-2.20.1/build/glib/gthread/gthread-impl.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gthread/gthread-none.c b/src/windows/glib-2.20.1/build/glib/gthread/gthread-none.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gthread/gthread-none.c rename to src/windows/glib-2.20.1/build/glib/gthread/gthread-none.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gthread/gthread-posix.c b/src/windows/glib-2.20.1/build/glib/gthread/gthread-posix.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gthread/gthread-posix.c rename to src/windows/glib-2.20.1/build/glib/gthread/gthread-posix.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gthread/gthread-win32.c b/src/windows/glib-2.20.1/build/glib/gthread/gthread-win32.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gthread/gthread-win32.c rename to src/windows/glib-2.20.1/build/glib/gthread/gthread-win32.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gthreadpool.c b/src/windows/glib-2.20.1/build/glib/gthreadpool.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gthreadpool.c rename to src/windows/glib-2.20.1/build/glib/gthreadpool.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gthreadpool.h b/src/windows/glib-2.20.1/build/glib/gthreadpool.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gthreadpool.h rename to src/windows/glib-2.20.1/build/glib/gthreadpool.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gthreadprivate.h b/src/windows/glib-2.20.1/build/glib/gthreadprivate.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gthreadprivate.h rename to src/windows/glib-2.20.1/build/glib/gthreadprivate.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gtimer.c b/src/windows/glib-2.20.1/build/glib/gtimer.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gtimer.c rename to src/windows/glib-2.20.1/build/glib/gtimer.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gtimer.h b/src/windows/glib-2.20.1/build/glib/gtimer.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gtimer.h rename to src/windows/glib-2.20.1/build/glib/gtimer.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gtree.c b/src/windows/glib-2.20.1/build/glib/gtree.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gtree.c rename to src/windows/glib-2.20.1/build/glib/gtree.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gtree.h b/src/windows/glib-2.20.1/build/glib/gtree.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gtree.h rename to src/windows/glib-2.20.1/build/glib/gtree.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gtypes.h b/src/windows/glib-2.20.1/build/glib/gtypes.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gtypes.h rename to src/windows/glib-2.20.1/build/glib/gtypes.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gunibreak.c b/src/windows/glib-2.20.1/build/glib/gunibreak.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gunibreak.c rename to src/windows/glib-2.20.1/build/glib/gunibreak.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gunibreak.h b/src/windows/glib-2.20.1/build/glib/gunibreak.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gunibreak.h rename to src/windows/glib-2.20.1/build/glib/gunibreak.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gunichartables.h b/src/windows/glib-2.20.1/build/glib/gunichartables.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gunichartables.h rename to src/windows/glib-2.20.1/build/glib/gunichartables.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gunicode.h b/src/windows/glib-2.20.1/build/glib/gunicode.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gunicode.h rename to src/windows/glib-2.20.1/build/glib/gunicode.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gunicodeprivate.h b/src/windows/glib-2.20.1/build/glib/gunicodeprivate.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gunicodeprivate.h rename to src/windows/glib-2.20.1/build/glib/gunicodeprivate.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gunicollate.c b/src/windows/glib-2.20.1/build/glib/gunicollate.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gunicollate.c rename to src/windows/glib-2.20.1/build/glib/gunicollate.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gunicomp.h b/src/windows/glib-2.20.1/build/glib/gunicomp.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gunicomp.h rename to src/windows/glib-2.20.1/build/glib/gunicomp.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gunidecomp.c b/src/windows/glib-2.20.1/build/glib/gunidecomp.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gunidecomp.c rename to src/windows/glib-2.20.1/build/glib/gunidecomp.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gunidecomp.h b/src/windows/glib-2.20.1/build/glib/gunidecomp.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gunidecomp.h rename to src/windows/glib-2.20.1/build/glib/gunidecomp.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/guniprop.c b/src/windows/glib-2.20.1/build/glib/guniprop.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/guniprop.c rename to src/windows/glib-2.20.1/build/glib/guniprop.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gurifuncs.c b/src/windows/glib-2.20.1/build/glib/gurifuncs.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gurifuncs.c rename to src/windows/glib-2.20.1/build/glib/gurifuncs.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gurifuncs.h b/src/windows/glib-2.20.1/build/glib/gurifuncs.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gurifuncs.h rename to src/windows/glib-2.20.1/build/glib/gurifuncs.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gutf8.c b/src/windows/glib-2.20.1/build/glib/gutf8.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gutf8.c rename to src/windows/glib-2.20.1/build/glib/gutf8.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gutils.c b/src/windows/glib-2.20.1/build/glib/gutils.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gutils.c rename to src/windows/glib-2.20.1/build/glib/gutils.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gutils.h b/src/windows/glib-2.20.1/build/glib/gutils.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gutils.h rename to src/windows/glib-2.20.1/build/glib/gutils.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gwin32.c b/src/windows/glib-2.20.1/build/glib/gwin32.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gwin32.c rename to src/windows/glib-2.20.1/build/glib/gwin32.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/gwin32.h b/src/windows/glib-2.20.1/build/glib/gwin32.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/gwin32.h rename to src/windows/glib-2.20.1/build/glib/gwin32.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/libcharset/README b/src/windows/glib-2.20.1/build/glib/libcharset/README similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/libcharset/README rename to src/windows/glib-2.20.1/build/glib/libcharset/README diff --git a/desmume/src/windows/glib-2.20.1/build/glib/libcharset/libcharset.h b/src/windows/glib-2.20.1/build/glib/libcharset/libcharset.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/libcharset/libcharset.h rename to src/windows/glib-2.20.1/build/glib/libcharset/libcharset.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/libcharset/localcharset.c b/src/windows/glib-2.20.1/build/glib/libcharset/localcharset.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/libcharset/localcharset.c rename to src/windows/glib-2.20.1/build/glib/libcharset/localcharset.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/libcharset/localcharset.h b/src/windows/glib-2.20.1/build/glib/libcharset/localcharset.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/libcharset/localcharset.h rename to src/windows/glib-2.20.1/build/glib/libcharset/localcharset.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/libintl.h b/src/windows/glib-2.20.1/build/glib/libintl.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/libintl.h rename to src/windows/glib-2.20.1/build/glib/libintl.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/msvc_recommended_pragmas.h b/src/windows/glib-2.20.1/build/glib/msvc_recommended_pragmas.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/msvc_recommended_pragmas.h rename to src/windows/glib-2.20.1/build/glib/msvc_recommended_pragmas.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/COPYING b/src/windows/glib-2.20.1/build/glib/pcre/COPYING similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/COPYING rename to src/windows/glib-2.20.1/build/glib/pcre/COPYING diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre.h b/src/windows/glib-2.20.1/build/glib/pcre/pcre.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre.h rename to src/windows/glib-2.20.1/build/glib/pcre/pcre.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_chartables.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_chartables.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_chartables.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_chartables.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_compile.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_compile.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_compile.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_compile.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_config.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_config.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_config.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_config.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_dfa_exec.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_dfa_exec.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_dfa_exec.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_dfa_exec.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_exec.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_exec.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_exec.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_exec.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_fullinfo.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_fullinfo.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_fullinfo.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_fullinfo.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_get.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_get.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_get.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_get.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_globals.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_globals.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_globals.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_globals.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_info.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_info.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_info.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_info.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_internal.h b/src/windows/glib-2.20.1/build/glib/pcre/pcre_internal.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_internal.h rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_internal.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_maketables.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_maketables.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_maketables.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_maketables.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_newline.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_newline.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_newline.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_newline.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_ord2utf8.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_ord2utf8.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_ord2utf8.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_ord2utf8.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_refcount.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_refcount.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_refcount.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_refcount.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_study.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_study.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_study.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_study.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_tables.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_tables.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_tables.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_tables.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_try_flipped.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_try_flipped.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_try_flipped.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_try_flipped.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_ucp_searchfuncs.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_ucp_searchfuncs.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_ucp_searchfuncs.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_ucp_searchfuncs.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_valid_utf8.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_valid_utf8.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_valid_utf8.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_valid_utf8.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_version.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_version.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_version.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_version.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_xclass.c b/src/windows/glib-2.20.1/build/glib/pcre/pcre_xclass.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/pcre_xclass.c rename to src/windows/glib-2.20.1/build/glib/pcre/pcre_xclass.c diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/ucp.h b/src/windows/glib-2.20.1/build/glib/pcre/ucp.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/ucp.h rename to src/windows/glib-2.20.1/build/glib/pcre/ucp.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/pcre/ucpinternal.h b/src/windows/glib-2.20.1/build/glib/pcre/ucpinternal.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/pcre/ucpinternal.h rename to src/windows/glib-2.20.1/build/glib/pcre/ucpinternal.h diff --git a/desmume/src/windows/glib-2.20.1/build/glib/win_iconv.c b/src/windows/glib-2.20.1/build/glib/win_iconv.c similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glib/win_iconv.c rename to src/windows/glib-2.20.1/build/glib/win_iconv.c diff --git a/desmume/src/windows/glib-2.20.1/build/glibconfig.h b/src/windows/glib-2.20.1/build/glibconfig.h similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/glibconfig.h rename to src/windows/glib-2.20.1/build/glibconfig.h diff --git a/desmume/src/windows/glib-2.20.1/build/vs8/README b/src/windows/glib-2.20.1/build/vs8/README similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/vs8/README rename to src/windows/glib-2.20.1/build/vs8/README diff --git a/desmume/src/windows/glib-2.20.1/build/vs8/gio.vcproj b/src/windows/glib-2.20.1/build/vs8/gio.vcproj similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/vs8/gio.vcproj rename to src/windows/glib-2.20.1/build/vs8/gio.vcproj diff --git a/desmume/src/windows/glib-2.20.1/build/vs8/glib.sln b/src/windows/glib-2.20.1/build/vs8/glib.sln similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/vs8/glib.sln rename to src/windows/glib-2.20.1/build/vs8/glib.sln diff --git a/desmume/src/windows/glib-2.20.1/build/vs8/glib.vcproj b/src/windows/glib-2.20.1/build/vs8/glib.vcproj similarity index 100% rename from desmume/src/windows/glib-2.20.1/build/vs8/glib.vcproj rename to src/windows/glib-2.20.1/build/vs8/glib.vcproj diff --git a/desmume/src/windows/glib-2.20.1/lib/glib-2.20.1-x86.lib b/src/windows/glib-2.20.1/lib/glib-2.20.1-x86.lib similarity index 100% rename from desmume/src/windows/glib-2.20.1/lib/glib-2.20.1-x86.lib rename to src/windows/glib-2.20.1/lib/glib-2.20.1-x86.lib diff --git a/desmume/src/windows/glib-2.20.1/modified_for_desmume.txt b/src/windows/glib-2.20.1/modified_for_desmume.txt similarity index 100% rename from desmume/src/windows/glib-2.20.1/modified_for_desmume.txt rename to src/windows/glib-2.20.1/modified_for_desmume.txt diff --git a/desmume/src/windows/hotkey.cpp b/src/windows/hotkey.cpp similarity index 96% rename from desmume/src/windows/hotkey.cpp rename to src/windows/hotkey.cpp index c20ea5d8d..8530c7b6a 100644 --- a/desmume/src/windows/hotkey.cpp +++ b/src/windows/hotkey.cpp @@ -1,810 +1,810 @@ -///* This file is part of DeSmuME, derived from several files in Snes9x 1.51 which are -// licensed under the terms supplied at the end of this file (for the terms are very long!) -// Differences from that baseline version are: -// -// Copyright (C) 2009 DeSmuME team -// -// DeSmuME is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// DeSmuME is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with DeSmuME; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//*/ - -#include "hotkey.h" -#include "main.h" -#include "NDSSystem.h" -#include "saves.h" -#include "inputdx.h" -#include "render3d.h" -#include "throttle.h" -#include "../mic.h" -#include "../movie.h" -#include "ramwatch.h" //In order to call UpdateRamWatch (for loadstate functions) -#include "ram_search.h" //In order to call UpdateRamSearch (for loadstate functions) -#include "replay.h" -#include "aviout.h" -#include "spu.h" -#include "../GPU.h" -#include "pathsettings.h" -#include "GPU_osd.h" -#include "path.h" - -extern LRESULT OpenFile(); //adelikat: Made this an extern here instead of main.h Seemed icky not to limit the scope of this function - -SCustomKeys CustomKeys; - -bool AutoHoldPressed=false; - -bool IsLastCustomKey (const SCustomKey *key) -{ - return (key->key == 0xFFFF && key->modifiers == 0xFFFF); -} - -void SetLastCustomKey (SCustomKey *key) -{ - key->key = 0xFFFF; - key->modifiers = 0xFFFF; -} - -void ZeroCustomKeys (SCustomKeys *keys) -{ - UINT i = 0; - - SetLastCustomKey(&keys->LastItem); - while (!IsLastCustomKey(&keys->key(i))) { - keys->key(i).key = 0; - keys->key(i).modifiers = 0; - i++; - }; -} - - -void CopyCustomKeys (SCustomKeys *dst, const SCustomKeys *src) -{ - UINT i = 0; - - do { - dst->key(i) = src->key(i); - } while (!IsLastCustomKey(&src->key(i++))); -} - -//====================================================================================== -//=====================================HANDLERS========================================= -//====================================================================================== -void HK_OpenROM(int) {OpenFile();} -void HK_PrintScreen(int param) -{ - char outFilename[MAX_PATH]; - - OPENFILENAME ofn; - ZeroMemory(&ofn,sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = MainWindow->getHWnd(); - ofn.lpstrFilter = "png file (*.png)\0*.png\0Bmp file (*.bmp)\0*.bmp\0Any file (*.*)\0*.*\0\0"; - ofn.lpstrTitle = "Print Screen Save As"; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrFile = outFilename; - ofn.lpstrDefExt = "png"; - ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; - - std::string filename = path.getpath(path.SCREENSHOTS); - - char file[MAX_PATH]; - ZeroMemory(file, sizeof(file)); - path.formatname(file); - filename += file; - - if(path.imageformat() == path.PNG) - { - filename += ".png"; - ofn.lpstrDefExt = "png"; - ofn.nFilterIndex = 1; - } - else if(path.imageformat() == path.BMP) - { - filename += ".bmp"; - ofn.lpstrDefExt = "bmp"; - ofn.nFilterIndex = 2; - } - - strcpy(outFilename,filename.c_str()); - if(!GetSaveFileName(&ofn)) - return; - filename = outFilename; - - if(toupper(strright(filename,4)) == ".PNG") - NDS_WritePNG(filename.c_str()); - else if(toupper(strright(filename,4)) == ".BMP") - NDS_WriteBMP(filename.c_str()); -} - -void HK_StateSaveSlot(int num) -{ - if (romloaded) - { - if (!paused) - { - NDS_Pause(); - savestate_slot(num); //Savestate - NDS_UnPause(); - } - else - savestate_slot(num); //Savestate - - LoadSaveStateInfo(); - } -} - -void HK_StateLoadSlot(int num) -{ - if (romloaded) - { - BOOL wasPaused = paused; - NDS_Pause(); - loadstate_slot(num); //Loadstate - lastSaveState = num; //Set last savestate used - - Update_RAM_Watch(); //adelikat: TODO this should be a single function call in main, that way we can expand as future dialogs need updating - Update_RAM_Search(); //main.cpp - case IDM_STATE_LOAD: also calls these functions - - if(!wasPaused) - NDS_UnPause(); - else - Display(); - } -} - -void HK_StateSetSlot(int num) -{ - if (romloaded) - { - lastSaveState = num; - osd->addLine("State %i selected", num); - } -} - -void HK_StateQuickSaveSlot(int) -{ - HK_StateSaveSlot(lastSaveState); -} - -void HK_StateQuickLoadSlot(int) -{ - HK_StateLoadSlot(lastSaveState); -} - -void HK_MicrophoneKeyDown(int) {MicButtonPressed =1;} -void HK_MicrophoneKeyUp(int) {MicButtonPressed =0;} - -void HK_AutoHoldClearKeyDown(int) { - - ClearAutoHold(); -} - -void HK_Reset(int) {ResetGame();} - -void HK_RecordAVI(int) { if (AVI_IsRecording()) AviEnd(); else AviRecordTo(); } -void HK_RecordWAV(int) { if (WAV_IsRecording()) WavEnd(); else WavRecordTo(); } - -void HK_ToggleFrame(int) {CommonSettings.hud.FrameCounterDisplay ^= true;} -void HK_ToggleFPS(int) {CommonSettings.hud.FpsDisplay ^= true;} -void HK_ToggleInput(int) {CommonSettings.hud.ShowInputDisplay ^= true;} -void HK_ToggleLag(int) {CommonSettings.hud.ShowLagFrameCounter ^= true;} -void HK_ResetLagCounter(int) { - lagframecounter=0; - LagFrameFlag=0; - lastLag=0; - TotalLagFrames=0; -} -void HK_ToggleReadOnly(int) { - movie_readonly ^= true; - if(movie_readonly) - osd->addLine("Read Only"); - else - osd->addLine("Read+Write"); -} - -void HK_PlayMovie(int) -{ - if (romloaded) - { - //NDS_Pause(); - //Replay_LoadMovie(); - //NDS_UnPause(); - } -} - -bool rewinding = false; - -void HK_RewindKeyDown(int) {rewinding = true;} - -void HK_RewindKeyUp(int){rewinding = false;} - -void HK_RecordMovie(int) -{ - if (romloaded) - { - //NDS_Pause(); - //MovieRecordTo(); - //NDS_UnPause(); - } -} - -void HK_StopMovie(int) -{ - FCEUI_StopMovie(); -} - -void HK_AutoHoldKeyDown(int) {AutoHoldPressed = true;} -void HK_AutoHoldKeyUp(int) {AutoHoldPressed = false;} - -void HK_TurboRightKeyDown(int) { Turbo.Right = true; } -void HK_TurboRightKeyUp(int) { Turbo.Right = false; } - -void HK_TurboLeftKeyDown(int) { Turbo.Left = true; } -void HK_TurboLeftKeyUp(int) { Turbo.Left = false; } - -void HK_TurboRKeyDown(int) { Turbo.R = true; } -void HK_TurboRKeyUp(int) { Turbo.R = false; } - -void HK_TurboLKeyDown(int) { Turbo.L = true; } -void HK_TurboLKeyUp(int) { Turbo.L = false; } - -void HK_TurboDownKeyDown(int) { Turbo.Down = true; } -void HK_TurboDownKeyUp(int) { Turbo.Down = false; } - -void HK_TurboUpKeyDown(int) { Turbo.Up = true; } -void HK_TurboUpKeyUp(int) { Turbo.Up = false; } - -void HK_TurboBKeyDown(int) { Turbo.B = true; } -void HK_TurboBKeyUp(int) { Turbo.B = false; } - -void HK_TurboAKeyDown(int) { Turbo.A = true; } -void HK_TurboAKeyUp(int) { Turbo.A = false; } - -void HK_TurboXKeyDown(int) { Turbo.X = true; } -void HK_TurboXKeyUp(int) { Turbo.X = false; } - -void HK_TurboYKeyDown(int) { Turbo.Y = true; } -void HK_TurboYKeyUp(int) { Turbo.Y = false; } - -void HK_TurboStartKeyDown(int) { Turbo.Start = true; } -void HK_TurboStartKeyUp(int) { Turbo.Start = false; } - -void HK_TurboSelectKeyDown(int) { Turbo.Select = true; } -void HK_TurboSelectKeyUp(int) { Turbo.Select = false; } - -void HK_NextSaveSlot(int) { - lastSaveState++; - if(lastSaveState>9) - lastSaveState=0; - osd->addLine("State %i selected", lastSaveState); -} - -void HK_PreviousSaveSlot(int) { - - if(lastSaveState==0) - lastSaveState=9; - else - lastSaveState--; - osd->addLine("State %i selected", lastSaveState); -} - -void HK_Pause(int) { Pause(); } -void HK_FastForwardToggle(int) { FastForward ^=1; } -void HK_FastForwardKeyDown(int) { FastForward = 1; } -void HK_FastForwardKeyUp(int) { FastForward = 0; } -void HK_IncreaseSpeed(int) { IncreaseSpeed(); } -void HK_DecreaseSpeed(int) { DecreaseSpeed(); } -void HK_FrameAdvanceKeyDown(int) { FrameAdvance(true); } -void HK_FrameAdvanceKeyUp(int) { FrameAdvance(false); } - -void HK_ToggleRasterizer(int) { - if(cur3DCore == GPU3D_OPENGL) - cur3DCore = GPU3D_SWRAST; - else cur3DCore = GPU3D_OPENGL; - - NDS_3D_ChangeCore(cur3DCore); - WritePrivateProfileInt("3D", "Renderer", cur3DCore, IniName); -} - -//====================================================================================== -//=====================================DEFINITIONS====================================== -//====================================================================================== - -void InitCustomKeys (SCustomKeys *keys) -{ - UINT i = 0; - - SetLastCustomKey(&keys->LastItem); - while (!IsLastCustomKey(&keys->key(i))) { - SCustomKey &key = keys->key(i); - key.key = 0; - key.modifiers = 0; - key.handleKeyDown = NULL; - key.handleKeyUp = NULL; - key.page = NUM_HOTKEY_PAGE; - key.param = 0; - - //keys->key[i].timing = PROCESS_NOW; - i++; - }; - - //Main Page--------------------------------------- - keys->OpenROM.handleKeyDown = HK_OpenROM; - keys->OpenROM.code = "OpenROM"; - keys->OpenROM.name = L"Open ROM"; - keys->OpenROM.page = HOTKEY_PAGE_MAIN; - keys->OpenROM.key = 'O'; - keys->OpenROM.modifiers = CUSTKEY_CTRL_MASK; - - keys->Reset.handleKeyDown = HK_Reset; - keys->Reset.code = "Reset"; - keys->Reset.name = L"Reset"; - keys->Reset.page = HOTKEY_PAGE_MAIN; - keys->Reset.key = 'R'; - keys->Reset.modifiers = CUSTKEY_CTRL_MASK; - - keys->Pause.handleKeyDown = HK_Pause; - keys->Pause.code = "Pause"; - keys->Pause.name = L"Pause"; - keys->Pause.page = HOTKEY_PAGE_MAIN; - keys->Pause.key = VK_PAUSE; - - keys->FrameAdvance.handleKeyDown = HK_FrameAdvanceKeyDown; - keys->FrameAdvance.handleKeyUp = HK_FrameAdvanceKeyUp; - keys->FrameAdvance.code = "FrameAdvance"; - keys->FrameAdvance.name = L"Frame Advance"; - keys->FrameAdvance.page = HOTKEY_PAGE_MAIN; - keys->FrameAdvance.key = 'N'; - - keys->FastForward.handleKeyDown = HK_FastForwardKeyDown; - keys->FastForward.handleKeyUp = HK_FastForwardKeyUp; - keys->FastForward.code = "FastForward"; - keys->FastForward.name = L"Fast Forward"; - keys->FastForward.page = HOTKEY_PAGE_MAIN; - keys->FastForward.key = VK_TAB; - - keys->FastForwardToggle.handleKeyDown = HK_FastForwardToggle; - keys->FastForwardToggle.code = "FastForwardToggle"; - keys->FastForwardToggle.name = L"Fast Forward Toggle"; - keys->FastForwardToggle.page = HOTKEY_PAGE_MAIN; - keys->FastForwardToggle.key = NULL; - - keys->IncreaseSpeed.handleKeyDown = HK_IncreaseSpeed; - keys->IncreaseSpeed.code = "IncreaseSpeed"; - keys->IncreaseSpeed.name = L"Increase Speed"; - keys->IncreaseSpeed.page = HOTKEY_PAGE_MAIN; - keys->IncreaseSpeed.key = VK_OEM_PLUS; - - keys->DecreaseSpeed.handleKeyDown = HK_DecreaseSpeed; - keys->DecreaseSpeed.code = "DecreaseSpeed"; - keys->DecreaseSpeed.name = L"Decrease Speed"; - keys->DecreaseSpeed.page = HOTKEY_PAGE_MAIN; - keys->DecreaseSpeed.key = VK_OEM_MINUS; - - keys->Microphone.handleKeyDown = HK_MicrophoneKeyDown; - keys->Microphone.handleKeyUp = HK_MicrophoneKeyUp; - keys->Microphone.code = "Microphone"; - keys->Microphone.name = L"Microphone"; - keys->Microphone.page = HOTKEY_PAGE_MAIN; - keys->Microphone.key = NULL; - - keys->AutoHold.handleKeyDown = HK_AutoHoldKeyDown; - keys->AutoHold.handleKeyUp = HK_AutoHoldKeyUp; - keys->AutoHold.code = "AutoHold"; - keys->AutoHold.name = L"Auto-Hold"; - keys->AutoHold.page = HOTKEY_PAGE_MAIN; - keys->AutoHold.key = NULL; - - keys->AutoHoldClear.handleKeyDown = HK_AutoHoldClearKeyDown; - keys->AutoHoldClear.code = "AutoHoldClear"; - keys->AutoHoldClear.name = L"Auto-Hold Clear"; - keys->AutoHoldClear.page = HOTKEY_PAGE_MAIN; - keys->AutoHoldClear.key = NULL; - - keys->ToggleRasterizer.handleKeyDown = HK_ToggleRasterizer; - keys->ToggleRasterizer.code = "ToggleRasterizer"; - keys->ToggleRasterizer.name = L"Toggle Rasterizer"; - keys->ToggleRasterizer.page = HOTKEY_PAGE_MAIN; - keys->ToggleRasterizer.key = VK_SUBTRACT; - - keys->PrintScreen.handleKeyDown = HK_PrintScreen; - keys->PrintScreen.code = "SaveScreenshotas"; - keys->PrintScreen.name = L"Save Screenshot as"; - keys->PrintScreen.page = HOTKEY_PAGE_MAIN; - keys->PrintScreen.key = VK_F12; - - keys->ToggleFrameCounter.handleKeyDown = HK_ToggleFrame; - keys->ToggleFrameCounter.code = "ToggleFrameDisplay"; - keys->ToggleFrameCounter.name = L"Toggle Frame Display"; - keys->ToggleFrameCounter.page = HOTKEY_PAGE_MAIN; - keys->ToggleFrameCounter.key = VK_OEM_PERIOD; - - keys->ToggleFPS.handleKeyDown = HK_ToggleFPS; - keys->ToggleFPS.code = "ToggleFPSDisplay"; - keys->ToggleFPS.name = L"Toggle FPS Display"; - keys->ToggleFPS.page = HOTKEY_PAGE_MAIN; - keys->ToggleFPS.key = NULL; - - keys->ToggleInput.handleKeyDown = HK_ToggleInput; - keys->ToggleInput.code = "ToggleInputDisplay"; - keys->ToggleInput.name = L"Toggle Input Display"; - keys->ToggleInput.page = HOTKEY_PAGE_MAIN; - keys->ToggleInput.key = VK_OEM_COMMA; - - keys->ToggleLag.handleKeyDown = HK_ToggleLag; - keys->ToggleLag.code = "ToggleLagDisplay"; - keys->ToggleLag.name = L"Toggle Lag Display"; - keys->ToggleLag.page = HOTKEY_PAGE_MAIN; - keys->ToggleLag.key = NULL; - - keys->ResetLagCounter.handleKeyDown = HK_ResetLagCounter; - keys->ResetLagCounter.code = "ResetLagCounter"; - keys->ResetLagCounter.name = L"Reset Lag Counter"; - keys->ResetLagCounter.page = HOTKEY_PAGE_MAIN; - keys->ResetLagCounter.key = NULL; - - keys->ToggleReadOnly.handleKeyDown = HK_ToggleReadOnly; - keys->ToggleReadOnly.code = "ToggleReadOnly"; - keys->ToggleReadOnly.name = L"Toggle Read Only"; - keys->ToggleReadOnly.page = HOTKEY_PAGE_MOVIE; - keys->ToggleReadOnly.key = NULL; - - keys->PlayMovie.handleKeyDown = HK_PlayMovie; - keys->PlayMovie.code = "PlayMovie"; - keys->PlayMovie.name = L"Play Movie"; - keys->PlayMovie.page = HOTKEY_PAGE_MOVIE; - keys->PlayMovie.key = NULL; - - keys->RecordMovie.handleKeyDown = HK_RecordMovie; - keys->RecordMovie.code = "RecordMovie"; - keys->RecordMovie.name = L"Record Movie"; - keys->RecordMovie.page = HOTKEY_PAGE_MOVIE; - keys->RecordMovie.key = NULL; - - keys->StopMovie.handleKeyDown = HK_StopMovie; - keys->StopMovie.code = "StopMovie"; - keys->StopMovie.name = L"Stop Movie"; - keys->StopMovie.page = HOTKEY_PAGE_MOVIE; - keys->StopMovie.key = NULL; - - keys->RecordWAV.handleKeyDown = HK_RecordWAV; - keys->RecordWAV.code = "RecordWAV"; - keys->RecordWAV.name = L"Record WAV"; - keys->RecordWAV.page = HOTKEY_PAGE_MAIN; - keys->RecordWAV.key = NULL; - - keys->RecordAVI.handleKeyDown = HK_RecordAVI; - keys->RecordAVI.code = "RecordAVI"; - keys->RecordAVI.name = L"Record AVI"; - keys->RecordAVI.page = HOTKEY_PAGE_MAIN; - keys->RecordAVI.key = NULL; - - //Turbo Page--------------------------------------- - keys->TurboRight.handleKeyDown = HK_TurboRightKeyDown; - keys->TurboRight.handleKeyUp = HK_TurboRightKeyUp; - keys->TurboRight.code = "TurboRight"; - keys->TurboRight.name = L"Turbo Right"; - keys->TurboRight.page = HOTKEY_PAGE_TURBO; - keys->TurboRight.key = NULL; - - keys->TurboLeft.handleKeyDown = HK_TurboLeftKeyDown; - keys->TurboLeft.handleKeyUp = HK_TurboLeftKeyUp; - keys->TurboLeft.code = "TurboLeft"; - keys->TurboLeft.name = L"Turbo Left"; - keys->TurboLeft.page = HOTKEY_PAGE_TURBO; - keys->TurboLeft.key = NULL; - - keys->TurboR.handleKeyDown = HK_TurboRKeyDown; - keys->TurboR.handleKeyUp = HK_TurboRKeyUp; - keys->TurboR.code = "TurboR"; - keys->TurboR.name = L"Turbo R"; - keys->TurboR.page = HOTKEY_PAGE_TURBO; - keys->TurboR.key = NULL; - - keys->TurboL.handleKeyDown = HK_TurboLKeyDown; - keys->TurboL.handleKeyUp = HK_TurboLKeyUp; - keys->TurboL.code = "TurboL"; - keys->TurboL.name = L"Turbo L"; - keys->TurboL.page = HOTKEY_PAGE_TURBO; - keys->TurboL.key = NULL; - - keys->TurboDown.handleKeyDown = HK_TurboDownKeyDown; - keys->TurboDown.handleKeyUp = HK_TurboDownKeyUp; - keys->TurboDown.code = "TurboDown"; - keys->TurboDown.name = L"Turbo Down"; - keys->TurboDown.page = HOTKEY_PAGE_TURBO; - keys->TurboDown.key = NULL; - - keys->TurboUp.handleKeyDown = HK_TurboUpKeyDown; - keys->TurboUp.handleKeyUp = HK_TurboUpKeyUp; - keys->TurboUp.code = "TurboUp"; - keys->TurboUp.name = L"Turbo Up"; - keys->TurboUp.page = HOTKEY_PAGE_TURBO; - keys->TurboUp.key = NULL; - - keys->TurboB.handleKeyDown = HK_TurboBKeyDown; - keys->TurboB.handleKeyUp = HK_TurboBKeyUp; - keys->TurboB.code = "TurboB"; - keys->TurboB.name = L"Turbo B"; - keys->TurboB.page = HOTKEY_PAGE_TURBO; - keys->TurboB.key = NULL; - - keys->TurboA.handleKeyDown = HK_TurboAKeyDown; - keys->TurboA.handleKeyUp = HK_TurboAKeyUp; - keys->TurboA.code = "TurboA"; - keys->TurboA.name = L"Turbo A"; - keys->TurboA.page = HOTKEY_PAGE_TURBO; - keys->TurboA.key = NULL; - - keys->TurboX.handleKeyDown = HK_TurboXKeyDown; - keys->TurboX.handleKeyUp = HK_TurboXKeyUp; - keys->TurboX.code = "TurboX"; - keys->TurboX.name = L"Turbo X"; - keys->TurboX.page = HOTKEY_PAGE_TURBO; - keys->TurboX.key = NULL; - - keys->TurboY.handleKeyDown = HK_TurboYKeyDown; - keys->TurboY.handleKeyUp = HK_TurboYKeyUp; - keys->TurboY.code = "TurboY"; - keys->TurboY.name = L"Turbo Y"; - keys->TurboY.page = HOTKEY_PAGE_TURBO; - keys->TurboY.key = NULL; - - keys->TurboSelect.handleKeyDown = HK_TurboSelectKeyDown; - keys->TurboSelect.handleKeyUp = HK_TurboSelectKeyUp; - keys->TurboSelect.code = "TurboSelect"; - keys->TurboSelect.name = L"Turbo Select"; - keys->TurboSelect.page = HOTKEY_PAGE_TURBO; - keys->TurboSelect.key = NULL; - - keys->TurboStart.handleKeyDown = HK_TurboStartKeyDown; - keys->TurboStart.handleKeyUp = HK_TurboStartKeyUp; - keys->TurboStart.code = "TurboStart"; - keys->TurboStart.name = L"Turbo Start"; - keys->TurboStart.page = HOTKEY_PAGE_TURBO; - keys->TurboStart.key = NULL; - - keys->Rewind.handleKeyDown = HK_RewindKeyDown; - keys->Rewind.handleKeyUp = HK_RewindKeyUp; - keys->Rewind.code = "Rewind"; - keys->Rewind.name = L"Rewind"; - keys->Rewind.page = HOTKEY_PAGE_MOVIE; - keys->Rewind.key = NULL; - - keys->NextSaveSlot.handleKeyDown = HK_NextSaveSlot; - keys->NextSaveSlot.code = "NextSaveSlot"; - keys->NextSaveSlot.name = L"Next Save Slot"; - keys->NextSaveSlot.page = HOTKEY_PAGE_STATE_SLOTS; - keys->NextSaveSlot.key = NULL; - - keys->PreviousSaveSlot.handleKeyDown = HK_PreviousSaveSlot; - keys->PreviousSaveSlot.code = "PreviousSaveSlot"; - keys->PreviousSaveSlot.name = L"Previous Save Slot"; - keys->PreviousSaveSlot.page = HOTKEY_PAGE_STATE_SLOTS; - keys->PreviousSaveSlot.key = NULL; - - keys->QuickSave.handleKeyDown = HK_StateQuickSaveSlot; - keys->QuickSave.code = "QuickSave"; - keys->QuickSave.name = L"Quick Save"; - keys->QuickSave.page = HOTKEY_PAGE_STATE_SLOTS; - keys->QuickSave.key = 'I'; - - keys->QuickLoad.handleKeyDown = HK_StateQuickLoadSlot; - keys->QuickLoad.code = "QuickLoad"; - keys->QuickLoad.name = L"Quick Load"; - keys->QuickLoad.page = HOTKEY_PAGE_STATE_SLOTS; - keys->QuickLoad.key = 'P'; - - for(int i=0;i<10;i++) { - static const char* saveNames[] = {"SaveToSlot0","SaveToSlot1","SaveToSlot2","SaveToSlot3","SaveToSlot4","SaveToSlot5","SaveToSlot6","SaveToSlot7","SaveToSlot8","SaveToSlot9"}; - static const char* loadNames[] = {"LoadFromSlot0","LoadFromSlot1","LoadFromSlot2","LoadFromSlot3","LoadFromSlot4","LoadFromSlot5","LoadFromSlot6","LoadFromSlot7","LoadFromSlot8","LoadFromSlot9"}; - static const char* slotNames[] = {"SelectSlot0","SelectSlot1","SelectSlot2","SelectSlot3","SelectSlot4","SelectSlot5","SelectSlot6","SelectSlot7","SelectSlot8","SelectSlot9"}; - - WORD key = VK_F1 + i - 1; - if(i==0) key = VK_F10; - - SCustomKey & save = keys->Save[i]; - save.handleKeyDown = HK_StateSaveSlot; - save.param = i; - save.page = HOTKEY_PAGE_STATE; - wchar_t tmp[16]; - _itow(i,tmp,10); - save.name = (std::wstring)L"Save To Slot " + (std::wstring)tmp; - save.code = saveNames[i]; - save.key = key; - save.modifiers = CUSTKEY_SHIFT_MASK; - - SCustomKey & load = keys->Load[i]; - load.handleKeyDown = HK_StateLoadSlot; - load.param = i; - load.page = HOTKEY_PAGE_STATE; - _itow(i,tmp,10); - load.name = (std::wstring)L"Load from Slot " + (std::wstring)tmp; - load.code = loadNames[i]; - load.key = key; - - key = '0' + i; - - SCustomKey & slot = keys->Slot[i]; - slot.handleKeyDown = HK_StateSetSlot; - slot.param = i; - slot.page = HOTKEY_PAGE_STATE_SLOTS; - _itow(i,tmp,10); - slot.name = (std::wstring)L"Select Save Slot " + (std::wstring)tmp; - slot.code = slotNames[i]; - slot.key = key; - } -} - - -/********************************************************************************** - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - - (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), - Jerremy Koot (jkoot@snes9x.com) - - (c) Copyright 2002 - 2004 Matthew Kendora - - (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) - - (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) - - (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) - - (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), - Kris Bleakley (codeviolation@hotmail.com) - - (c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net), - Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) - - (c) Copyright 2006 - 2007 nitsuja - - - BS-X C emulator code - (c) Copyright 2005 - 2006 Dreamer Nom, - zones - - C4 x86 assembler and some C emulation code - (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), - Nach, - zsKnight (zsknight@zsnes.com) - - C4 C++ code - (c) Copyright 2003 - 2006 Brad Jorsch, - Nach - - DSP-1 emulator code - (c) Copyright 1998 - 2006 _Demo_, - Andreas Naive (andreasnaive@gmail.com) - Gary Henderson, - Ivar (ivar@snes9x.com), - John Weidman, - Kris Bleakley, - Matthew Kendora, - Nach, - neviksti (neviksti@hotmail.com) - - DSP-2 emulator code - (c) Copyright 2003 John Weidman, - Kris Bleakley, - Lord Nightmare (lord_nightmare@users.sourceforge.net), - Matthew Kendora, - neviksti - - - DSP-3 emulator code - (c) Copyright 2003 - 2006 John Weidman, - Kris Bleakley, - Lancer, - z80 gaiden - - DSP-4 emulator code - (c) Copyright 2004 - 2006 Dreamer Nom, - John Weidman, - Kris Bleakley, - Nach, - z80 gaiden - - OBC1 emulator code - (c) Copyright 2001 - 2004 zsKnight, - pagefault (pagefault@zsnes.com), - Kris Bleakley, - Ported from x86 assembler to C by sanmaiwashi - - SPC7110 and RTC C++ emulator code - (c) Copyright 2002 Matthew Kendora with research by - zsKnight, - John Weidman, - Dark Force - - S-DD1 C emulator code - (c) Copyright 2003 Brad Jorsch with research by - Andreas Naive, - John Weidman - - S-RTC C emulator code - (c) Copyright 2001-2006 byuu, - John Weidman - - ST010 C++ emulator code - (c) Copyright 2003 Feather, - John Weidman, - Kris Bleakley, - Matthew Kendora - - Super FX x86 assembler emulator code - (c) Copyright 1998 - 2003 _Demo_, - pagefault, - zsKnight, - - Super FX C emulator code - (c) Copyright 1997 - 1999 Ivar, - Gary Henderson, - John Weidman - - Sound DSP emulator code is derived from SNEeSe and OpenSPC: - (c) Copyright 1998 - 2003 Brad Martin - (c) Copyright 1998 - 2006 Charles Bilyue' - - SH assembler code partly based on x86 assembler code - (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) - - 2xSaI filter - (c) Copyright 1999 - 2001 Derek Liauw Kie Fa - - HQ2x, HQ3x, HQ4x filters - (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) - - Win32 GUI code - (c) Copyright 2003 - 2006 blip, - funkyass, - Matthew Kendora, - Nach, - nitsuja - - Mac OS GUI code - (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2007 zones - - - Specific ports contains the works of other authors. See headers in - individual files. - - - Snes9x homepage: http://www.snes9x.com - - Permission to use, copy, modify and/or distribute Snes9x in both binary - and source form, for non-commercial purposes, is hereby granted without - fee, providing that this license information and copyright notice appear - with all copies and any derived work. - - This software is provided 'as-is', without any express or implied - warranty. In no event shall the authors be held liable for any damages - arising from the use of this software or it's derivatives. - - Snes9x is freeware for PERSONAL USE only. Commercial users should - seek permission of the copyright holders first. Commercial use includes, - but is not limited to, charging money for Snes9x or software derived from - Snes9x, including Snes9x or derivatives in commercial game bundles, and/or - using Snes9x as a promotion for your commercial product. - - The copyright holders request that bug fixes and improvements to the code - should be forwarded to them so everyone can benefit from the modifications - in future versions. - - Super NES and Super Nintendo Entertainment System are trademarks of - Nintendo Co., Limited and its subsidiary companies. -**********************************************************************************/ - +///* This file is part of DeSmuME, derived from several files in Snes9x 1.51 which are +// licensed under the terms supplied at the end of this file (for the terms are very long!) +// Differences from that baseline version are: +// +// Copyright (C) 2009 DeSmuME team +// +// DeSmuME is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// DeSmuME is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with DeSmuME; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//*/ + +#include "hotkey.h" +#include "main.h" +#include "NDSSystem.h" +#include "saves.h" +#include "inputdx.h" +#include "render3d.h" +#include "throttle.h" +#include "../mic.h" +#include "../movie.h" +#include "ramwatch.h" //In order to call UpdateRamWatch (for loadstate functions) +#include "ram_search.h" //In order to call UpdateRamSearch (for loadstate functions) +#include "replay.h" +#include "aviout.h" +#include "spu.h" +#include "../GPU.h" +#include "pathsettings.h" +#include "GPU_osd.h" +#include "path.h" + +extern LRESULT OpenFile(); //adelikat: Made this an extern here instead of main.h Seemed icky not to limit the scope of this function + +SCustomKeys CustomKeys; + +bool AutoHoldPressed=false; + +bool IsLastCustomKey (const SCustomKey *key) +{ + return (key->key == 0xFFFF && key->modifiers == 0xFFFF); +} + +void SetLastCustomKey (SCustomKey *key) +{ + key->key = 0xFFFF; + key->modifiers = 0xFFFF; +} + +void ZeroCustomKeys (SCustomKeys *keys) +{ + UINT i = 0; + + SetLastCustomKey(&keys->LastItem); + while (!IsLastCustomKey(&keys->key(i))) { + keys->key(i).key = 0; + keys->key(i).modifiers = 0; + i++; + }; +} + + +void CopyCustomKeys (SCustomKeys *dst, const SCustomKeys *src) +{ + UINT i = 0; + + do { + dst->key(i) = src->key(i); + } while (!IsLastCustomKey(&src->key(i++))); +} + +//====================================================================================== +//=====================================HANDLERS========================================= +//====================================================================================== +void HK_OpenROM(int) {OpenFile();} +void HK_PrintScreen(int param) +{ + char outFilename[MAX_PATH]; + + OPENFILENAME ofn; + ZeroMemory(&ofn,sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = MainWindow->getHWnd(); + ofn.lpstrFilter = "png file (*.png)\0*.png\0Bmp file (*.bmp)\0*.bmp\0Any file (*.*)\0*.*\0\0"; + ofn.lpstrTitle = "Print Screen Save As"; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFile = outFilename; + ofn.lpstrDefExt = "png"; + ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; + + std::string filename = path.getpath(path.SCREENSHOTS); + + char file[MAX_PATH]; + ZeroMemory(file, sizeof(file)); + path.formatname(file); + filename += file; + + if(path.imageformat() == path.PNG) + { + filename += ".png"; + ofn.lpstrDefExt = "png"; + ofn.nFilterIndex = 1; + } + else if(path.imageformat() == path.BMP) + { + filename += ".bmp"; + ofn.lpstrDefExt = "bmp"; + ofn.nFilterIndex = 2; + } + + strcpy(outFilename,filename.c_str()); + if(!GetSaveFileName(&ofn)) + return; + filename = outFilename; + + if(toupper(strright(filename,4)) == ".PNG") + NDS_WritePNG(filename.c_str()); + else if(toupper(strright(filename,4)) == ".BMP") + NDS_WriteBMP(filename.c_str()); +} + +void HK_StateSaveSlot(int num) +{ + if (romloaded) + { + if (!paused) + { + NDS_Pause(); + savestate_slot(num); //Savestate + NDS_UnPause(); + } + else + savestate_slot(num); //Savestate + + LoadSaveStateInfo(); + } +} + +void HK_StateLoadSlot(int num) +{ + if (romloaded) + { + BOOL wasPaused = paused; + NDS_Pause(); + loadstate_slot(num); //Loadstate + lastSaveState = num; //Set last savestate used + + Update_RAM_Watch(); //adelikat: TODO this should be a single function call in main, that way we can expand as future dialogs need updating + Update_RAM_Search(); //main.cpp - case IDM_STATE_LOAD: also calls these functions + + if(!wasPaused) + NDS_UnPause(); + else + Display(); + } +} + +void HK_StateSetSlot(int num) +{ + if (romloaded) + { + lastSaveState = num; + osd->addLine("State %i selected", num); + } +} + +void HK_StateQuickSaveSlot(int) +{ + HK_StateSaveSlot(lastSaveState); +} + +void HK_StateQuickLoadSlot(int) +{ + HK_StateLoadSlot(lastSaveState); +} + +void HK_MicrophoneKeyDown(int) {MicButtonPressed =1;} +void HK_MicrophoneKeyUp(int) {MicButtonPressed =0;} + +void HK_AutoHoldClearKeyDown(int) { + + ClearAutoHold(); +} + +void HK_Reset(int) {ResetGame();} + +void HK_RecordAVI(int) { if (AVI_IsRecording()) AviEnd(); else AviRecordTo(); } +void HK_RecordWAV(int) { if (WAV_IsRecording()) WavEnd(); else WavRecordTo(); } + +void HK_ToggleFrame(int) {CommonSettings.hud.FrameCounterDisplay ^= true;} +void HK_ToggleFPS(int) {CommonSettings.hud.FpsDisplay ^= true;} +void HK_ToggleInput(int) {CommonSettings.hud.ShowInputDisplay ^= true;} +void HK_ToggleLag(int) {CommonSettings.hud.ShowLagFrameCounter ^= true;} +void HK_ResetLagCounter(int) { + lagframecounter=0; + LagFrameFlag=0; + lastLag=0; + TotalLagFrames=0; +} +void HK_ToggleReadOnly(int) { + movie_readonly ^= true; + if(movie_readonly) + osd->addLine("Read Only"); + else + osd->addLine("Read+Write"); +} + +void HK_PlayMovie(int) +{ + if (romloaded) + { + //NDS_Pause(); + //Replay_LoadMovie(); + //NDS_UnPause(); + } +} + +bool rewinding = false; + +void HK_RewindKeyDown(int) {rewinding = true;} + +void HK_RewindKeyUp(int){rewinding = false;} + +void HK_RecordMovie(int) +{ + if (romloaded) + { + //NDS_Pause(); + //MovieRecordTo(); + //NDS_UnPause(); + } +} + +void HK_StopMovie(int) +{ + FCEUI_StopMovie(); +} + +void HK_AutoHoldKeyDown(int) {AutoHoldPressed = true;} +void HK_AutoHoldKeyUp(int) {AutoHoldPressed = false;} + +void HK_TurboRightKeyDown(int) { Turbo.Right = true; } +void HK_TurboRightKeyUp(int) { Turbo.Right = false; } + +void HK_TurboLeftKeyDown(int) { Turbo.Left = true; } +void HK_TurboLeftKeyUp(int) { Turbo.Left = false; } + +void HK_TurboRKeyDown(int) { Turbo.R = true; } +void HK_TurboRKeyUp(int) { Turbo.R = false; } + +void HK_TurboLKeyDown(int) { Turbo.L = true; } +void HK_TurboLKeyUp(int) { Turbo.L = false; } + +void HK_TurboDownKeyDown(int) { Turbo.Down = true; } +void HK_TurboDownKeyUp(int) { Turbo.Down = false; } + +void HK_TurboUpKeyDown(int) { Turbo.Up = true; } +void HK_TurboUpKeyUp(int) { Turbo.Up = false; } + +void HK_TurboBKeyDown(int) { Turbo.B = true; } +void HK_TurboBKeyUp(int) { Turbo.B = false; } + +void HK_TurboAKeyDown(int) { Turbo.A = true; } +void HK_TurboAKeyUp(int) { Turbo.A = false; } + +void HK_TurboXKeyDown(int) { Turbo.X = true; } +void HK_TurboXKeyUp(int) { Turbo.X = false; } + +void HK_TurboYKeyDown(int) { Turbo.Y = true; } +void HK_TurboYKeyUp(int) { Turbo.Y = false; } + +void HK_TurboStartKeyDown(int) { Turbo.Start = true; } +void HK_TurboStartKeyUp(int) { Turbo.Start = false; } + +void HK_TurboSelectKeyDown(int) { Turbo.Select = true; } +void HK_TurboSelectKeyUp(int) { Turbo.Select = false; } + +void HK_NextSaveSlot(int) { + lastSaveState++; + if(lastSaveState>9) + lastSaveState=0; + osd->addLine("State %i selected", lastSaveState); +} + +void HK_PreviousSaveSlot(int) { + + if(lastSaveState==0) + lastSaveState=9; + else + lastSaveState--; + osd->addLine("State %i selected", lastSaveState); +} + +void HK_Pause(int) { Pause(); } +void HK_FastForwardToggle(int) { FastForward ^=1; } +void HK_FastForwardKeyDown(int) { FastForward = 1; } +void HK_FastForwardKeyUp(int) { FastForward = 0; } +void HK_IncreaseSpeed(int) { IncreaseSpeed(); } +void HK_DecreaseSpeed(int) { DecreaseSpeed(); } +void HK_FrameAdvanceKeyDown(int) { FrameAdvance(true); } +void HK_FrameAdvanceKeyUp(int) { FrameAdvance(false); } + +void HK_ToggleRasterizer(int) { + if(cur3DCore == GPU3D_OPENGL) + cur3DCore = GPU3D_SWRAST; + else cur3DCore = GPU3D_OPENGL; + + NDS_3D_ChangeCore(cur3DCore); + WritePrivateProfileInt("3D", "Renderer", cur3DCore, IniName); +} + +//====================================================================================== +//=====================================DEFINITIONS====================================== +//====================================================================================== + +void InitCustomKeys (SCustomKeys *keys) +{ + UINT i = 0; + + SetLastCustomKey(&keys->LastItem); + while (!IsLastCustomKey(&keys->key(i))) { + SCustomKey &key = keys->key(i); + key.key = 0; + key.modifiers = 0; + key.handleKeyDown = NULL; + key.handleKeyUp = NULL; + key.page = NUM_HOTKEY_PAGE; + key.param = 0; + + //keys->key[i].timing = PROCESS_NOW; + i++; + }; + + //Main Page--------------------------------------- + keys->OpenROM.handleKeyDown = HK_OpenROM; + keys->OpenROM.code = "OpenROM"; + keys->OpenROM.name = L"Open ROM"; + keys->OpenROM.page = HOTKEY_PAGE_MAIN; + keys->OpenROM.key = 'O'; + keys->OpenROM.modifiers = CUSTKEY_CTRL_MASK; + + keys->Reset.handleKeyDown = HK_Reset; + keys->Reset.code = "Reset"; + keys->Reset.name = L"Reset"; + keys->Reset.page = HOTKEY_PAGE_MAIN; + keys->Reset.key = 'R'; + keys->Reset.modifiers = CUSTKEY_CTRL_MASK; + + keys->Pause.handleKeyDown = HK_Pause; + keys->Pause.code = "Pause"; + keys->Pause.name = L"Pause"; + keys->Pause.page = HOTKEY_PAGE_MAIN; + keys->Pause.key = VK_PAUSE; + + keys->FrameAdvance.handleKeyDown = HK_FrameAdvanceKeyDown; + keys->FrameAdvance.handleKeyUp = HK_FrameAdvanceKeyUp; + keys->FrameAdvance.code = "FrameAdvance"; + keys->FrameAdvance.name = L"Frame Advance"; + keys->FrameAdvance.page = HOTKEY_PAGE_MAIN; + keys->FrameAdvance.key = 'N'; + + keys->FastForward.handleKeyDown = HK_FastForwardKeyDown; + keys->FastForward.handleKeyUp = HK_FastForwardKeyUp; + keys->FastForward.code = "FastForward"; + keys->FastForward.name = L"Fast Forward"; + keys->FastForward.page = HOTKEY_PAGE_MAIN; + keys->FastForward.key = VK_TAB; + + keys->FastForwardToggle.handleKeyDown = HK_FastForwardToggle; + keys->FastForwardToggle.code = "FastForwardToggle"; + keys->FastForwardToggle.name = L"Fast Forward Toggle"; + keys->FastForwardToggle.page = HOTKEY_PAGE_MAIN; + keys->FastForwardToggle.key = NULL; + + keys->IncreaseSpeed.handleKeyDown = HK_IncreaseSpeed; + keys->IncreaseSpeed.code = "IncreaseSpeed"; + keys->IncreaseSpeed.name = L"Increase Speed"; + keys->IncreaseSpeed.page = HOTKEY_PAGE_MAIN; + keys->IncreaseSpeed.key = VK_OEM_PLUS; + + keys->DecreaseSpeed.handleKeyDown = HK_DecreaseSpeed; + keys->DecreaseSpeed.code = "DecreaseSpeed"; + keys->DecreaseSpeed.name = L"Decrease Speed"; + keys->DecreaseSpeed.page = HOTKEY_PAGE_MAIN; + keys->DecreaseSpeed.key = VK_OEM_MINUS; + + keys->Microphone.handleKeyDown = HK_MicrophoneKeyDown; + keys->Microphone.handleKeyUp = HK_MicrophoneKeyUp; + keys->Microphone.code = "Microphone"; + keys->Microphone.name = L"Microphone"; + keys->Microphone.page = HOTKEY_PAGE_MAIN; + keys->Microphone.key = NULL; + + keys->AutoHold.handleKeyDown = HK_AutoHoldKeyDown; + keys->AutoHold.handleKeyUp = HK_AutoHoldKeyUp; + keys->AutoHold.code = "AutoHold"; + keys->AutoHold.name = L"Auto-Hold"; + keys->AutoHold.page = HOTKEY_PAGE_MAIN; + keys->AutoHold.key = NULL; + + keys->AutoHoldClear.handleKeyDown = HK_AutoHoldClearKeyDown; + keys->AutoHoldClear.code = "AutoHoldClear"; + keys->AutoHoldClear.name = L"Auto-Hold Clear"; + keys->AutoHoldClear.page = HOTKEY_PAGE_MAIN; + keys->AutoHoldClear.key = NULL; + + keys->ToggleRasterizer.handleKeyDown = HK_ToggleRasterizer; + keys->ToggleRasterizer.code = "ToggleRasterizer"; + keys->ToggleRasterizer.name = L"Toggle Rasterizer"; + keys->ToggleRasterizer.page = HOTKEY_PAGE_MAIN; + keys->ToggleRasterizer.key = VK_SUBTRACT; + + keys->PrintScreen.handleKeyDown = HK_PrintScreen; + keys->PrintScreen.code = "SaveScreenshotas"; + keys->PrintScreen.name = L"Save Screenshot as"; + keys->PrintScreen.page = HOTKEY_PAGE_MAIN; + keys->PrintScreen.key = VK_F12; + + keys->ToggleFrameCounter.handleKeyDown = HK_ToggleFrame; + keys->ToggleFrameCounter.code = "ToggleFrameDisplay"; + keys->ToggleFrameCounter.name = L"Toggle Frame Display"; + keys->ToggleFrameCounter.page = HOTKEY_PAGE_MAIN; + keys->ToggleFrameCounter.key = VK_OEM_PERIOD; + + keys->ToggleFPS.handleKeyDown = HK_ToggleFPS; + keys->ToggleFPS.code = "ToggleFPSDisplay"; + keys->ToggleFPS.name = L"Toggle FPS Display"; + keys->ToggleFPS.page = HOTKEY_PAGE_MAIN; + keys->ToggleFPS.key = NULL; + + keys->ToggleInput.handleKeyDown = HK_ToggleInput; + keys->ToggleInput.code = "ToggleInputDisplay"; + keys->ToggleInput.name = L"Toggle Input Display"; + keys->ToggleInput.page = HOTKEY_PAGE_MAIN; + keys->ToggleInput.key = VK_OEM_COMMA; + + keys->ToggleLag.handleKeyDown = HK_ToggleLag; + keys->ToggleLag.code = "ToggleLagDisplay"; + keys->ToggleLag.name = L"Toggle Lag Display"; + keys->ToggleLag.page = HOTKEY_PAGE_MAIN; + keys->ToggleLag.key = NULL; + + keys->ResetLagCounter.handleKeyDown = HK_ResetLagCounter; + keys->ResetLagCounter.code = "ResetLagCounter"; + keys->ResetLagCounter.name = L"Reset Lag Counter"; + keys->ResetLagCounter.page = HOTKEY_PAGE_MAIN; + keys->ResetLagCounter.key = NULL; + + keys->ToggleReadOnly.handleKeyDown = HK_ToggleReadOnly; + keys->ToggleReadOnly.code = "ToggleReadOnly"; + keys->ToggleReadOnly.name = L"Toggle Read Only"; + keys->ToggleReadOnly.page = HOTKEY_PAGE_MOVIE; + keys->ToggleReadOnly.key = NULL; + + keys->PlayMovie.handleKeyDown = HK_PlayMovie; + keys->PlayMovie.code = "PlayMovie"; + keys->PlayMovie.name = L"Play Movie"; + keys->PlayMovie.page = HOTKEY_PAGE_MOVIE; + keys->PlayMovie.key = NULL; + + keys->RecordMovie.handleKeyDown = HK_RecordMovie; + keys->RecordMovie.code = "RecordMovie"; + keys->RecordMovie.name = L"Record Movie"; + keys->RecordMovie.page = HOTKEY_PAGE_MOVIE; + keys->RecordMovie.key = NULL; + + keys->StopMovie.handleKeyDown = HK_StopMovie; + keys->StopMovie.code = "StopMovie"; + keys->StopMovie.name = L"Stop Movie"; + keys->StopMovie.page = HOTKEY_PAGE_MOVIE; + keys->StopMovie.key = NULL; + + keys->RecordWAV.handleKeyDown = HK_RecordWAV; + keys->RecordWAV.code = "RecordWAV"; + keys->RecordWAV.name = L"Record WAV"; + keys->RecordWAV.page = HOTKEY_PAGE_MAIN; + keys->RecordWAV.key = NULL; + + keys->RecordAVI.handleKeyDown = HK_RecordAVI; + keys->RecordAVI.code = "RecordAVI"; + keys->RecordAVI.name = L"Record AVI"; + keys->RecordAVI.page = HOTKEY_PAGE_MAIN; + keys->RecordAVI.key = NULL; + + //Turbo Page--------------------------------------- + keys->TurboRight.handleKeyDown = HK_TurboRightKeyDown; + keys->TurboRight.handleKeyUp = HK_TurboRightKeyUp; + keys->TurboRight.code = "TurboRight"; + keys->TurboRight.name = L"Turbo Right"; + keys->TurboRight.page = HOTKEY_PAGE_TURBO; + keys->TurboRight.key = NULL; + + keys->TurboLeft.handleKeyDown = HK_TurboLeftKeyDown; + keys->TurboLeft.handleKeyUp = HK_TurboLeftKeyUp; + keys->TurboLeft.code = "TurboLeft"; + keys->TurboLeft.name = L"Turbo Left"; + keys->TurboLeft.page = HOTKEY_PAGE_TURBO; + keys->TurboLeft.key = NULL; + + keys->TurboR.handleKeyDown = HK_TurboRKeyDown; + keys->TurboR.handleKeyUp = HK_TurboRKeyUp; + keys->TurboR.code = "TurboR"; + keys->TurboR.name = L"Turbo R"; + keys->TurboR.page = HOTKEY_PAGE_TURBO; + keys->TurboR.key = NULL; + + keys->TurboL.handleKeyDown = HK_TurboLKeyDown; + keys->TurboL.handleKeyUp = HK_TurboLKeyUp; + keys->TurboL.code = "TurboL"; + keys->TurboL.name = L"Turbo L"; + keys->TurboL.page = HOTKEY_PAGE_TURBO; + keys->TurboL.key = NULL; + + keys->TurboDown.handleKeyDown = HK_TurboDownKeyDown; + keys->TurboDown.handleKeyUp = HK_TurboDownKeyUp; + keys->TurboDown.code = "TurboDown"; + keys->TurboDown.name = L"Turbo Down"; + keys->TurboDown.page = HOTKEY_PAGE_TURBO; + keys->TurboDown.key = NULL; + + keys->TurboUp.handleKeyDown = HK_TurboUpKeyDown; + keys->TurboUp.handleKeyUp = HK_TurboUpKeyUp; + keys->TurboUp.code = "TurboUp"; + keys->TurboUp.name = L"Turbo Up"; + keys->TurboUp.page = HOTKEY_PAGE_TURBO; + keys->TurboUp.key = NULL; + + keys->TurboB.handleKeyDown = HK_TurboBKeyDown; + keys->TurboB.handleKeyUp = HK_TurboBKeyUp; + keys->TurboB.code = "TurboB"; + keys->TurboB.name = L"Turbo B"; + keys->TurboB.page = HOTKEY_PAGE_TURBO; + keys->TurboB.key = NULL; + + keys->TurboA.handleKeyDown = HK_TurboAKeyDown; + keys->TurboA.handleKeyUp = HK_TurboAKeyUp; + keys->TurboA.code = "TurboA"; + keys->TurboA.name = L"Turbo A"; + keys->TurboA.page = HOTKEY_PAGE_TURBO; + keys->TurboA.key = NULL; + + keys->TurboX.handleKeyDown = HK_TurboXKeyDown; + keys->TurboX.handleKeyUp = HK_TurboXKeyUp; + keys->TurboX.code = "TurboX"; + keys->TurboX.name = L"Turbo X"; + keys->TurboX.page = HOTKEY_PAGE_TURBO; + keys->TurboX.key = NULL; + + keys->TurboY.handleKeyDown = HK_TurboYKeyDown; + keys->TurboY.handleKeyUp = HK_TurboYKeyUp; + keys->TurboY.code = "TurboY"; + keys->TurboY.name = L"Turbo Y"; + keys->TurboY.page = HOTKEY_PAGE_TURBO; + keys->TurboY.key = NULL; + + keys->TurboSelect.handleKeyDown = HK_TurboSelectKeyDown; + keys->TurboSelect.handleKeyUp = HK_TurboSelectKeyUp; + keys->TurboSelect.code = "TurboSelect"; + keys->TurboSelect.name = L"Turbo Select"; + keys->TurboSelect.page = HOTKEY_PAGE_TURBO; + keys->TurboSelect.key = NULL; + + keys->TurboStart.handleKeyDown = HK_TurboStartKeyDown; + keys->TurboStart.handleKeyUp = HK_TurboStartKeyUp; + keys->TurboStart.code = "TurboStart"; + keys->TurboStart.name = L"Turbo Start"; + keys->TurboStart.page = HOTKEY_PAGE_TURBO; + keys->TurboStart.key = NULL; + + keys->Rewind.handleKeyDown = HK_RewindKeyDown; + keys->Rewind.handleKeyUp = HK_RewindKeyUp; + keys->Rewind.code = "Rewind"; + keys->Rewind.name = L"Rewind"; + keys->Rewind.page = HOTKEY_PAGE_MOVIE; + keys->Rewind.key = NULL; + + keys->NextSaveSlot.handleKeyDown = HK_NextSaveSlot; + keys->NextSaveSlot.code = "NextSaveSlot"; + keys->NextSaveSlot.name = L"Next Save Slot"; + keys->NextSaveSlot.page = HOTKEY_PAGE_STATE_SLOTS; + keys->NextSaveSlot.key = NULL; + + keys->PreviousSaveSlot.handleKeyDown = HK_PreviousSaveSlot; + keys->PreviousSaveSlot.code = "PreviousSaveSlot"; + keys->PreviousSaveSlot.name = L"Previous Save Slot"; + keys->PreviousSaveSlot.page = HOTKEY_PAGE_STATE_SLOTS; + keys->PreviousSaveSlot.key = NULL; + + keys->QuickSave.handleKeyDown = HK_StateQuickSaveSlot; + keys->QuickSave.code = "QuickSave"; + keys->QuickSave.name = L"Quick Save"; + keys->QuickSave.page = HOTKEY_PAGE_STATE_SLOTS; + keys->QuickSave.key = 'I'; + + keys->QuickLoad.handleKeyDown = HK_StateQuickLoadSlot; + keys->QuickLoad.code = "QuickLoad"; + keys->QuickLoad.name = L"Quick Load"; + keys->QuickLoad.page = HOTKEY_PAGE_STATE_SLOTS; + keys->QuickLoad.key = 'P'; + + for(int i=0;i<10;i++) { + static const char* saveNames[] = {"SaveToSlot0","SaveToSlot1","SaveToSlot2","SaveToSlot3","SaveToSlot4","SaveToSlot5","SaveToSlot6","SaveToSlot7","SaveToSlot8","SaveToSlot9"}; + static const char* loadNames[] = {"LoadFromSlot0","LoadFromSlot1","LoadFromSlot2","LoadFromSlot3","LoadFromSlot4","LoadFromSlot5","LoadFromSlot6","LoadFromSlot7","LoadFromSlot8","LoadFromSlot9"}; + static const char* slotNames[] = {"SelectSlot0","SelectSlot1","SelectSlot2","SelectSlot3","SelectSlot4","SelectSlot5","SelectSlot6","SelectSlot7","SelectSlot8","SelectSlot9"}; + + WORD key = VK_F1 + i - 1; + if(i==0) key = VK_F10; + + SCustomKey & save = keys->Save[i]; + save.handleKeyDown = HK_StateSaveSlot; + save.param = i; + save.page = HOTKEY_PAGE_STATE; + wchar_t tmp[16]; + _itow(i,tmp,10); + save.name = (std::wstring)L"Save To Slot " + (std::wstring)tmp; + save.code = saveNames[i]; + save.key = key; + save.modifiers = CUSTKEY_SHIFT_MASK; + + SCustomKey & load = keys->Load[i]; + load.handleKeyDown = HK_StateLoadSlot; + load.param = i; + load.page = HOTKEY_PAGE_STATE; + _itow(i,tmp,10); + load.name = (std::wstring)L"Load from Slot " + (std::wstring)tmp; + load.code = loadNames[i]; + load.key = key; + + key = '0' + i; + + SCustomKey & slot = keys->Slot[i]; + slot.handleKeyDown = HK_StateSetSlot; + slot.param = i; + slot.page = HOTKEY_PAGE_STATE_SLOTS; + _itow(i,tmp,10); + slot.name = (std::wstring)L"Select Save Slot " + (std::wstring)tmp; + slot.code = slotNames[i]; + slot.key = key; + } +} + + +/********************************************************************************** + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + + (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), + Jerremy Koot (jkoot@snes9x.com) + + (c) Copyright 2002 - 2004 Matthew Kendora + + (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) + + (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) + + (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) + + (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), + Kris Bleakley (codeviolation@hotmail.com) + + (c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net), + Nach (n-a-c-h@users.sourceforge.net), + zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2006 - 2007 nitsuja + + + BS-X C emulator code + (c) Copyright 2005 - 2006 Dreamer Nom, + zones + + C4 x86 assembler and some C emulation code + (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), + Nach, + zsKnight (zsknight@zsnes.com) + + C4 C++ code + (c) Copyright 2003 - 2006 Brad Jorsch, + Nach + + DSP-1 emulator code + (c) Copyright 1998 - 2006 _Demo_, + Andreas Naive (andreasnaive@gmail.com) + Gary Henderson, + Ivar (ivar@snes9x.com), + John Weidman, + Kris Bleakley, + Matthew Kendora, + Nach, + neviksti (neviksti@hotmail.com) + + DSP-2 emulator code + (c) Copyright 2003 John Weidman, + Kris Bleakley, + Lord Nightmare (lord_nightmare@users.sourceforge.net), + Matthew Kendora, + neviksti + + + DSP-3 emulator code + (c) Copyright 2003 - 2006 John Weidman, + Kris Bleakley, + Lancer, + z80 gaiden + + DSP-4 emulator code + (c) Copyright 2004 - 2006 Dreamer Nom, + John Weidman, + Kris Bleakley, + Nach, + z80 gaiden + + OBC1 emulator code + (c) Copyright 2001 - 2004 zsKnight, + pagefault (pagefault@zsnes.com), + Kris Bleakley, + Ported from x86 assembler to C by sanmaiwashi + + SPC7110 and RTC C++ emulator code + (c) Copyright 2002 Matthew Kendora with research by + zsKnight, + John Weidman, + Dark Force + + S-DD1 C emulator code + (c) Copyright 2003 Brad Jorsch with research by + Andreas Naive, + John Weidman + + S-RTC C emulator code + (c) Copyright 2001-2006 byuu, + John Weidman + + ST010 C++ emulator code + (c) Copyright 2003 Feather, + John Weidman, + Kris Bleakley, + Matthew Kendora + + Super FX x86 assembler emulator code + (c) Copyright 1998 - 2003 _Demo_, + pagefault, + zsKnight, + + Super FX C emulator code + (c) Copyright 1997 - 1999 Ivar, + Gary Henderson, + John Weidman + + Sound DSP emulator code is derived from SNEeSe and OpenSPC: + (c) Copyright 1998 - 2003 Brad Martin + (c) Copyright 1998 - 2006 Charles Bilyue' + + SH assembler code partly based on x86 assembler code + (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) + + 2xSaI filter + (c) Copyright 1999 - 2001 Derek Liauw Kie Fa + + HQ2x, HQ3x, HQ4x filters + (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) + + Win32 GUI code + (c) Copyright 2003 - 2006 blip, + funkyass, + Matthew Kendora, + Nach, + nitsuja + + Mac OS GUI code + (c) Copyright 1998 - 2001 John Stiles + (c) Copyright 2001 - 2007 zones + + + Specific ports contains the works of other authors. See headers in + individual files. + + + Snes9x homepage: http://www.snes9x.com + + Permission to use, copy, modify and/or distribute Snes9x in both binary + and source form, for non-commercial purposes, is hereby granted without + fee, providing that this license information and copyright notice appear + with all copies and any derived work. + + This software is provided 'as-is', without any express or implied + warranty. In no event shall the authors be held liable for any damages + arising from the use of this software or it's derivatives. + + Snes9x is freeware for PERSONAL USE only. Commercial users should + seek permission of the copyright holders first. Commercial use includes, + but is not limited to, charging money for Snes9x or software derived from + Snes9x, including Snes9x or derivatives in commercial game bundles, and/or + using Snes9x as a promotion for your commercial product. + + The copyright holders request that bug fixes and improvements to the code + should be forwarded to them so everyone can benefit from the modifications + in future versions. + + Super NES and Super Nintendo Entertainment System are trademarks of + Nintendo Co., Limited and its subsidiary companies. +**********************************************************************************/ + diff --git a/desmume/src/windows/hotkey.h b/src/windows/hotkey.h similarity index 96% rename from desmume/src/windows/hotkey.h rename to src/windows/hotkey.h index 490c91bc6..a5d7c102a 100644 --- a/desmume/src/windows/hotkey.h +++ b/src/windows/hotkey.h @@ -1,276 +1,276 @@ -///* This file is part of DeSmuME, derived from several files in Snes9x 1.51 which are -// licensed under the terms supplied at the end of this file (for the terms are very long!) -// Differences from that baseline version are: -// -// Copyright (C) 2009 DeSmuME team -// -// DeSmuME is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// DeSmuME is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with DeSmuME; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//*/ - -#ifndef HOTKEY_H_INCLUDED -#define HOTKEY_H_INCLUDED - -#include -#include -#include -#include - -enum HotkeyPage { - HOTKEY_PAGE_MAIN=0, - HOTKEY_PAGE_MOVIE, - HOTKEY_PAGE_STATE, - HOTKEY_PAGE_STATE_SLOTS, - HOTKEY_PAGE_TURBO, - NUM_HOTKEY_PAGE, -}; - -static LPCTSTR hotkeyPageTitle[] = { - _T("Main"), - _T("Movie"), - _T("Savestates"), - _T("Savestate Slots"), - _T("Turbo"), - _T("NUM_HOTKEY_PAGE"), -}; - - -struct SCustomKey -{ - typedef void (*THandler) (int param); - WORD key; - WORD modifiers; - THandler handleKeyDown; - THandler handleKeyUp; - HotkeyPage page; - std::wstring name; - const char* code; - int param; - //HotkeyTiming timing; -}; - -struct SCustomKeys -{ - SCustomKey Save[10]; - SCustomKey Load[10]; - SCustomKey Slot[10]; - SCustomKey QuickSave, QuickLoad, NextSaveSlot, PreviousSaveSlot; - - SCustomKey OpenROM, Reset, Pause, FrameAdvance, FastForward, FastForwardToggle, IncreaseSpeed, DecreaseSpeed, Microphone; - - SCustomKey PlayMovie, RecordMovie, StopMovie, ToggleReadOnly; - - SCustomKey TurboRight, TurboLeft, TurboDown, TurboUp, TurboSelect, TurboStart, TurboB, TurboA, TurboY, TurboX, TurboR, TurboL; - - SCustomKey AutoHold, AutoHoldClear; - - SCustomKey ToggleRasterizer; - SCustomKey PrintScreen; //Screenshot - - SCustomKey RecordWAV, RecordAVI; - - SCustomKey Rewind; - - SCustomKey ToggleFrameCounter; - SCustomKey ToggleFPS; - SCustomKey ToggleInput; - SCustomKey ToggleLag; - SCustomKey ResetLagCounter; - SCustomKey LastItem; // dummy, must be last - - //--methods-- - SCustomKey &key(int i) { return ((SCustomKey*)this)[i]; } - SCustomKey const &key(int i) const { return ((SCustomKey*)this)[i]; } -}; -//SCustomKey key[]; - -extern SCustomKeys CustomKeys; - -bool IsLastCustomKey (const SCustomKey *key); -void CopyCustomKeys (SCustomKeys *dst, const SCustomKeys *src); -void InitCustomKeys (SCustomKeys *keys); -int GetModifiers(int key); - -//HOTKEY HANDLERS -void HK_PrintScreen(int); -void HK_StateSaveSlot(int); -void HK_StateLoadSlot(int); -void HK_StateSetSlot(int); -void HK_Pause(int); -void HK_FastForward(int); - -extern bool AutoHoldPressed; - -#endif //HOTKEY_H_INCLUDED - -/********************************************************************************** - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - - (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), - Jerremy Koot (jkoot@snes9x.com) - - (c) Copyright 2002 - 2004 Matthew Kendora - - (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) - - (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) - - (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) - - (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), - Kris Bleakley (codeviolation@hotmail.com) - - (c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net), - Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) - - (c) Copyright 2006 - 2007 nitsuja - - - BS-X C emulator code - (c) Copyright 2005 - 2006 Dreamer Nom, - zones - - C4 x86 assembler and some C emulation code - (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), - Nach, - zsKnight (zsknight@zsnes.com) - - C4 C++ code - (c) Copyright 2003 - 2006 Brad Jorsch, - Nach - - DSP-1 emulator code - (c) Copyright 1998 - 2006 _Demo_, - Andreas Naive (andreasnaive@gmail.com) - Gary Henderson, - Ivar (ivar@snes9x.com), - John Weidman, - Kris Bleakley, - Matthew Kendora, - Nach, - neviksti (neviksti@hotmail.com) - - DSP-2 emulator code - (c) Copyright 2003 John Weidman, - Kris Bleakley, - Lord Nightmare (lord_nightmare@users.sourceforge.net), - Matthew Kendora, - neviksti - - - DSP-3 emulator code - (c) Copyright 2003 - 2006 John Weidman, - Kris Bleakley, - Lancer, - z80 gaiden - - DSP-4 emulator code - (c) Copyright 2004 - 2006 Dreamer Nom, - John Weidman, - Kris Bleakley, - Nach, - z80 gaiden - - OBC1 emulator code - (c) Copyright 2001 - 2004 zsKnight, - pagefault (pagefault@zsnes.com), - Kris Bleakley, - Ported from x86 assembler to C by sanmaiwashi - - SPC7110 and RTC C++ emulator code - (c) Copyright 2002 Matthew Kendora with research by - zsKnight, - John Weidman, - Dark Force - - S-DD1 C emulator code - (c) Copyright 2003 Brad Jorsch with research by - Andreas Naive, - John Weidman - - S-RTC C emulator code - (c) Copyright 2001-2006 byuu, - John Weidman - - ST010 C++ emulator code - (c) Copyright 2003 Feather, - John Weidman, - Kris Bleakley, - Matthew Kendora - - Super FX x86 assembler emulator code - (c) Copyright 1998 - 2003 _Demo_, - pagefault, - zsKnight, - - Super FX C emulator code - (c) Copyright 1997 - 1999 Ivar, - Gary Henderson, - John Weidman - - Sound DSP emulator code is derived from SNEeSe and OpenSPC: - (c) Copyright 1998 - 2003 Brad Martin - (c) Copyright 1998 - 2006 Charles Bilyue' - - SH assembler code partly based on x86 assembler code - (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) - - 2xSaI filter - (c) Copyright 1999 - 2001 Derek Liauw Kie Fa - - HQ2x, HQ3x, HQ4x filters - (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) - - Win32 GUI code - (c) Copyright 2003 - 2006 blip, - funkyass, - Matthew Kendora, - Nach, - nitsuja - - Mac OS GUI code - (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2007 zones - - - Specific ports contains the works of other authors. See headers in - individual files. - - - Snes9x homepage: http://www.snes9x.com - - Permission to use, copy, modify and/or distribute Snes9x in both binary - and source form, for non-commercial purposes, is hereby granted without - fee, providing that this license information and copyright notice appear - with all copies and any derived work. - - This software is provided 'as-is', without any express or implied - warranty. In no event shall the authors be held liable for any damages - arising from the use of this software or it's derivatives. - - Snes9x is freeware for PERSONAL USE only. Commercial users should - seek permission of the copyright holders first. Commercial use includes, - but is not limited to, charging money for Snes9x or software derived from - Snes9x, including Snes9x or derivatives in commercial game bundles, and/or - using Snes9x as a promotion for your commercial product. - - The copyright holders request that bug fixes and improvements to the code - should be forwarded to them so everyone can benefit from the modifications - in future versions. - - Super NES and Super Nintendo Entertainment System are trademarks of - Nintendo Co., Limited and its subsidiary companies. -**********************************************************************************/ - +///* This file is part of DeSmuME, derived from several files in Snes9x 1.51 which are +// licensed under the terms supplied at the end of this file (for the terms are very long!) +// Differences from that baseline version are: +// +// Copyright (C) 2009 DeSmuME team +// +// DeSmuME is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// DeSmuME is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with DeSmuME; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//*/ + +#ifndef HOTKEY_H_INCLUDED +#define HOTKEY_H_INCLUDED + +#include +#include +#include +#include + +enum HotkeyPage { + HOTKEY_PAGE_MAIN=0, + HOTKEY_PAGE_MOVIE, + HOTKEY_PAGE_STATE, + HOTKEY_PAGE_STATE_SLOTS, + HOTKEY_PAGE_TURBO, + NUM_HOTKEY_PAGE, +}; + +static LPCTSTR hotkeyPageTitle[] = { + _T("Main"), + _T("Movie"), + _T("Savestates"), + _T("Savestate Slots"), + _T("Turbo"), + _T("NUM_HOTKEY_PAGE"), +}; + + +struct SCustomKey +{ + typedef void (*THandler) (int param); + WORD key; + WORD modifiers; + THandler handleKeyDown; + THandler handleKeyUp; + HotkeyPage page; + std::wstring name; + const char* code; + int param; + //HotkeyTiming timing; +}; + +struct SCustomKeys +{ + SCustomKey Save[10]; + SCustomKey Load[10]; + SCustomKey Slot[10]; + SCustomKey QuickSave, QuickLoad, NextSaveSlot, PreviousSaveSlot; + + SCustomKey OpenROM, Reset, Pause, FrameAdvance, FastForward, FastForwardToggle, IncreaseSpeed, DecreaseSpeed, Microphone; + + SCustomKey PlayMovie, RecordMovie, StopMovie, ToggleReadOnly; + + SCustomKey TurboRight, TurboLeft, TurboDown, TurboUp, TurboSelect, TurboStart, TurboB, TurboA, TurboY, TurboX, TurboR, TurboL; + + SCustomKey AutoHold, AutoHoldClear; + + SCustomKey ToggleRasterizer; + SCustomKey PrintScreen; //Screenshot + + SCustomKey RecordWAV, RecordAVI; + + SCustomKey Rewind; + + SCustomKey ToggleFrameCounter; + SCustomKey ToggleFPS; + SCustomKey ToggleInput; + SCustomKey ToggleLag; + SCustomKey ResetLagCounter; + SCustomKey LastItem; // dummy, must be last + + //--methods-- + SCustomKey &key(int i) { return ((SCustomKey*)this)[i]; } + SCustomKey const &key(int i) const { return ((SCustomKey*)this)[i]; } +}; +//SCustomKey key[]; + +extern SCustomKeys CustomKeys; + +bool IsLastCustomKey (const SCustomKey *key); +void CopyCustomKeys (SCustomKeys *dst, const SCustomKeys *src); +void InitCustomKeys (SCustomKeys *keys); +int GetModifiers(int key); + +//HOTKEY HANDLERS +void HK_PrintScreen(int); +void HK_StateSaveSlot(int); +void HK_StateLoadSlot(int); +void HK_StateSetSlot(int); +void HK_Pause(int); +void HK_FastForward(int); + +extern bool AutoHoldPressed; + +#endif //HOTKEY_H_INCLUDED + +/********************************************************************************** + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + + (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), + Jerremy Koot (jkoot@snes9x.com) + + (c) Copyright 2002 - 2004 Matthew Kendora + + (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) + + (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) + + (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) + + (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), + Kris Bleakley (codeviolation@hotmail.com) + + (c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net), + Nach (n-a-c-h@users.sourceforge.net), + zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2006 - 2007 nitsuja + + + BS-X C emulator code + (c) Copyright 2005 - 2006 Dreamer Nom, + zones + + C4 x86 assembler and some C emulation code + (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), + Nach, + zsKnight (zsknight@zsnes.com) + + C4 C++ code + (c) Copyright 2003 - 2006 Brad Jorsch, + Nach + + DSP-1 emulator code + (c) Copyright 1998 - 2006 _Demo_, + Andreas Naive (andreasnaive@gmail.com) + Gary Henderson, + Ivar (ivar@snes9x.com), + John Weidman, + Kris Bleakley, + Matthew Kendora, + Nach, + neviksti (neviksti@hotmail.com) + + DSP-2 emulator code + (c) Copyright 2003 John Weidman, + Kris Bleakley, + Lord Nightmare (lord_nightmare@users.sourceforge.net), + Matthew Kendora, + neviksti + + + DSP-3 emulator code + (c) Copyright 2003 - 2006 John Weidman, + Kris Bleakley, + Lancer, + z80 gaiden + + DSP-4 emulator code + (c) Copyright 2004 - 2006 Dreamer Nom, + John Weidman, + Kris Bleakley, + Nach, + z80 gaiden + + OBC1 emulator code + (c) Copyright 2001 - 2004 zsKnight, + pagefault (pagefault@zsnes.com), + Kris Bleakley, + Ported from x86 assembler to C by sanmaiwashi + + SPC7110 and RTC C++ emulator code + (c) Copyright 2002 Matthew Kendora with research by + zsKnight, + John Weidman, + Dark Force + + S-DD1 C emulator code + (c) Copyright 2003 Brad Jorsch with research by + Andreas Naive, + John Weidman + + S-RTC C emulator code + (c) Copyright 2001-2006 byuu, + John Weidman + + ST010 C++ emulator code + (c) Copyright 2003 Feather, + John Weidman, + Kris Bleakley, + Matthew Kendora + + Super FX x86 assembler emulator code + (c) Copyright 1998 - 2003 _Demo_, + pagefault, + zsKnight, + + Super FX C emulator code + (c) Copyright 1997 - 1999 Ivar, + Gary Henderson, + John Weidman + + Sound DSP emulator code is derived from SNEeSe and OpenSPC: + (c) Copyright 1998 - 2003 Brad Martin + (c) Copyright 1998 - 2006 Charles Bilyue' + + SH assembler code partly based on x86 assembler code + (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) + + 2xSaI filter + (c) Copyright 1999 - 2001 Derek Liauw Kie Fa + + HQ2x, HQ3x, HQ4x filters + (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) + + Win32 GUI code + (c) Copyright 2003 - 2006 blip, + funkyass, + Matthew Kendora, + Nach, + nitsuja + + Mac OS GUI code + (c) Copyright 1998 - 2001 John Stiles + (c) Copyright 2001 - 2007 zones + + + Specific ports contains the works of other authors. See headers in + individual files. + + + Snes9x homepage: http://www.snes9x.com + + Permission to use, copy, modify and/or distribute Snes9x in both binary + and source form, for non-commercial purposes, is hereby granted without + fee, providing that this license information and copyright notice appear + with all copies and any derived work. + + This software is provided 'as-is', without any express or implied + warranty. In no event shall the authors be held liable for any damages + arising from the use of this software or it's derivatives. + + Snes9x is freeware for PERSONAL USE only. Commercial users should + seek permission of the copyright holders first. Commercial use includes, + but is not limited to, charging money for Snes9x or software derived from + Snes9x, including Snes9x or derivatives in commercial game bundles, and/or + using Snes9x as a promotion for your commercial product. + + The copyright holders request that bug fixes and improvements to the code + should be forwarded to them so everyone can benefit from the modifications + in future versions. + + Super NES and Super Nintendo Entertainment System are trademarks of + Nintendo Co., Limited and its subsidiary companies. +**********************************************************************************/ + diff --git a/desmume/src/windows/inputdx.cpp b/src/windows/inputdx.cpp similarity index 95% rename from desmume/src/windows/inputdx.cpp rename to src/windows/inputdx.cpp index fcde5f8cf..971e3e86b 100644 --- a/desmume/src/windows/inputdx.cpp +++ b/src/windows/inputdx.cpp @@ -1,2722 +1,2724 @@ -///* This file is part of DeSmuME, derived from several files in Snes9x 1.51 which are -// licensed under the terms supplied at the end of this file (for the terms are very long!) -// Differences from that baseline version are: -// -// Copyright (C) 2009 DeSmuME team -// -// DeSmuME is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// DeSmuME is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with DeSmuME; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//*/ - - - -#ifdef __MINGW32__ -#define _WIN32_IE 0x0501 -#define _WIN32_WINNT 0x0501 -#endif - -#define STRICT -#include -#include -#include -#include - -#include - -#if (((defined(_MSC_VER) && _MSC_VER >= 1300)) || defined(__MINGW32__)) - // both MINGW and VS.NET use fstream instead of fstream.h which is deprecated - #include - using namespace std; -#else - // for VC++ 6 - #include -#endif - -#include "inputdx.h" -#include "hotkey.h" - -#include "main.h" -#include "resource.h" -#include "common.h" -#include "../addons.h" -#include "../NDSSystem.h" - -#define DIRECTINPUT_VERSION 0x0800 -#include "../common.h" -#include "../types.h" -#include "directx/dinput.h" - -// Gamepad Dialog Strings -#define INPUTCONFIG_TITLE "Input Configuration" -#define INPUTCONFIG_JPTOGGLE "Enabled" -//#define INPUTCONFIG_DIAGTOGGLE "Toggle Diagonals" -//#define INPUTCONFIG_OK "&OK" -//#define INPUTCONFIG_CANCEL "&Cancel" -#define INPUTCONFIG_JPCOMBO "Joypad #%d" -#define INPUTCONFIG_LABEL_UP "Up" -#define INPUTCONFIG_LABEL_DOWN "Down" -#define INPUTCONFIG_LABEL_LEFT "Left" -#define INPUTCONFIG_LABEL_RIGHT "Right" -#define INPUTCONFIG_LABEL_A "A" -#define INPUTCONFIG_LABEL_B "B" -#define INPUTCONFIG_LABEL_X "X" -#define INPUTCONFIG_LABEL_Y "Y" -#define INPUTCONFIG_LABEL_L "L" -#define INPUTCONFIG_LABEL_R "R" -#define INPUTCONFIG_LABEL_START "Start" -#define INPUTCONFIG_LABEL_SELECT "Select" -#define INPUTCONFIG_LABEL_UPLEFT "Up Left" -#define INPUTCONFIG_LABEL_UPRIGHT "Up Right" -#define INPUTCONFIG_LABEL_DOWNRIGHT "Dn Right" -#define INPUTCONFIG_LABEL_DOWNLEFT "Dn Left" -#define INPUTCONFIG_LABEL_BLUE "Blue means the button is already mapped.\nPink means it conflicts with a custom hotkey.\nRed means it's reserved by Windows.\nButtons can be disabled using Escape.\nGrayed buttons arent supported yet (sorry!)" -#define INPUTCONFIG_LABEL_UNUSED "" -#define INPUTCONFIG_LABEL_CLEAR_TOGGLES_AND_TURBO "Clear All" -#define INPUTCONFIG_LABEL_MAKE_TURBO "TempTurbo" -#define INPUTCONFIG_LABEL_MAKE_HELD "Autohold" -#define INPUTCONFIG_LABEL_MAKE_TURBO_HELD "Autofire" -#define INPUTCONFIG_LABEL_CONTROLLER_TURBO_PANEL_MOD " Turbo" - -// Hotkeys Dialog Strings -#define HOTKEYS_TITLE "Hotkey Configuration" -#define HOTKEYS_CONTROL_MOD "Ctrl + " -#define HOTKEYS_SHIFT_MOD "Shift + " -#define HOTKEYS_ALT_MOD "Alt + " -#define HOTKEYS_LABEL_BLUE "Blue means the hotkey is already mapped.\nPink means it conflicts with a game button.\nRed means it's reserved by Windows.\nA hotkey can be disabled using Escape." -#define HOTKEYS_HKCOMBO "Page %d" - -// gaming buttons and axes -#define GAMEDEVICE_JOYNUMPREFIX "(J%x)" // don't change this -#define GAMEDEVICE_JOYBUTPREFIX "#[%d]" // don't change this -#define GAMEDEVICE_XNEG "Left" -#define GAMEDEVICE_XPOS "Right" -#define GAMEDEVICE_YPOS "Up" -#define GAMEDEVICE_YNEG "Down" -#define GAMEDEVICE_POVLEFT "POV Left" -#define GAMEDEVICE_POVRIGHT "POV Right" -#define GAMEDEVICE_POVUP "POV Up" -#define GAMEDEVICE_POVDOWN "POV Down" -#define GAMEDEVICE_POVDNLEFT "POV Dn Left" -#define GAMEDEVICE_POVDNRIGHT "POV Dn Right" -#define GAMEDEVICE_POVUPLEFT "POV Up Left" -#define GAMEDEVICE_POVUPRIGHT "POV Up Right" -#define GAMEDEVICE_ZPOS "Z Up" -#define GAMEDEVICE_ZNEG "Z Down" -#define GAMEDEVICE_RPOS "R Up" -#define GAMEDEVICE_RNEG "R Down" -#define GAMEDEVICE_UPOS "U Up" -#define GAMEDEVICE_UNEG "U Down" -#define GAMEDEVICE_VPOS "V Up" -#define GAMEDEVICE_VNEG "V Down" -#define GAMEDEVICE_BUTTON "Button %d" - -// gaming general -#define GAMEDEVICE_DISABLED "Disabled" - -// gaming keys -#define GAMEDEVICE_KEY "#%d" -#define GAMEDEVICE_NUMPADPREFIX "Numpad-%c" -#define GAMEDEVICE_VK_TAB "Tab" -#define GAMEDEVICE_VK_BACK "Backspace" -#define GAMEDEVICE_VK_CLEAR "Delete" -#define GAMEDEVICE_VK_RETURN "Enter" -#define GAMEDEVICE_VK_LSHIFT "LShift" -#define GAMEDEVICE_VK_RSHIFT "RShift" -#define GAMEDEVICE_VK_LCONTROL "LCtrl" -#define GAMEDEVICE_VK_RCONTROL "RCtrl" -#define GAMEDEVICE_VK_LMENU "LAlt" -#define GAMEDEVICE_VK_RMENU "RAlt" -#define GAMEDEVICE_VK_PAUSE "Pause" -#define GAMEDEVICE_VK_CAPITAL "Capslock" -#define GAMEDEVICE_VK_ESCAPE "Disabled" -#define GAMEDEVICE_VK_SPACE "Space" -#define GAMEDEVICE_VK_PRIOR "PgUp" -#define GAMEDEVICE_VK_NEXT "PgDn" -#define GAMEDEVICE_VK_HOME "Home" -#define GAMEDEVICE_VK_END "End" -#define GAMEDEVICE_VK_LEFT "Left" -#define GAMEDEVICE_VK_RIGHT "Right" -#define GAMEDEVICE_VK_UP "Up" -#define GAMEDEVICE_VK_DOWN "Down" -#define GAMEDEVICE_VK_SELECT "Select" -#define GAMEDEVICE_VK_PRINT "Print" -#define GAMEDEVICE_VK_EXECUTE "Execute" -#define GAMEDEVICE_VK_SNAPSHOT "SnapShot" -#define GAMEDEVICE_VK_INSERT "Insert" -#define GAMEDEVICE_VK_DELETE "Delete" -#define GAMEDEVICE_VK_HELP "Help" -#define GAMEDEVICE_VK_LWIN "LWinKey" -#define GAMEDEVICE_VK_RWIN "RWinKey" -#define GAMEDEVICE_VK_APPS "AppKey" -#define GAMEDEVICE_VK_MULTIPLY "Numpad *" -#define GAMEDEVICE_VK_ADD "Numpad +" -#define GAMEDEVICE_VK_SEPARATOR "Separator" -#define GAMEDEVICE_VK_OEM_1 "Semi-Colon" -#define GAMEDEVICE_VK_OEM_7 "Apostrophe" -#define GAMEDEVICE_VK_OEM_COMMA "Comma" -#define GAMEDEVICE_VK_OEM_PERIOD "Period" -#define GAMEDEVICE_VK_SUBTRACT "Numpad -" -#define GAMEDEVICE_VK_DECIMAL "Numpad ." -#define GAMEDEVICE_VK_DIVIDE "Numpad /" -#define GAMEDEVICE_VK_NUMLOCK "Num-lock" -#define GAMEDEVICE_VK_SCROLL "Scroll-lock" -#define GAMEDEVICE_VK_OEM_MINUS "-" -#define GAMEDEVICE_VK_OEM_PLUS "=" -#define GAMEDEVICE_VK_SHIFT "Shift" -#define GAMEDEVICE_VK_CONTROL "Control" -#define GAMEDEVICE_VK_MENU "Alt" -#define GAMEDEVICE_VK_OEM_4 "[" -#define GAMEDEVICE_VK_OEM_6 "]" -#define GAMEDEVICE_VK_OEM_5 "\\" -#define GAMEDEVICE_VK_OEM_2 "/" -#define GAMEDEVICE_VK_OEM_3 "`" -#define GAMEDEVICE_VK_F1 "F1" -#define GAMEDEVICE_VK_F2 "F2" -#define GAMEDEVICE_VK_F3 "F3" -#define GAMEDEVICE_VK_F4 "F4" -#define GAMEDEVICE_VK_F5 "F5" -#define GAMEDEVICE_VK_F6 "F6" -#define GAMEDEVICE_VK_F7 "F7" -#define GAMEDEVICE_VK_F8 "F8" -#define GAMEDEVICE_VK_F9 "F9" -#define GAMEDEVICE_VK_F10 "F10" -#define GAMEDEVICE_VK_F11 "F11" -#define GAMEDEVICE_VK_F12 "F12" -#define BUTTON_OK "&OK" -#define BUTTON_CANCEL "&Cancel" - -static TCHAR szClassName[] = _T("InputCustom"); -static TCHAR szHotkeysClassName[] = _T("InputCustomHot"); -static TCHAR szGuitarClassName[] = _T("InputCustomGuitar"); - -static LRESULT CALLBACK InputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -static LRESULT CALLBACK HotInputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -static LRESULT CALLBACK GuitarInputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -SJoyState Joystick [16]; -SJoyState JoystickF [16]; -SJoypad ToggleJoypadStorage[8]; -SJoypad TurboToggleJoypadStorage[8]; -u32 joypads [8]; - -//the main input configuration: -SJoypad DefaultJoypad[16] = { - { - true, /* Joypad 1 enabled */ - VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, /* Left, Right, Up, Down */ - 0, 0, 0, 0, /* Left_Up, Left_Down, Right_Up, Right_Down */ - VK_RETURN, VK_RSHIFT, /* Start, Select */ - 0, 0, /* Lid, Debug */ - 'X', 'Z', /* A B */ - 'S', 'A', /* X Y */ - 'Q', 'W' /* L R */ - }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } -}; - -SJoypad Joypad[16]; - -SGuitar DefaultGuitar = { false, 'E', 'R', 'T', 'Y' }; - -SGuitar Guitar; -u8 guitarState = 0; - -extern volatile bool paused; - -#define MAXKEYPAD 15 - -#define WM_CUSTKEYDOWN (WM_USER+50) -#define WM_CUSTKEYUP (WM_USER+51) - -#define NUM_HOTKEY_CONTROLS 20 - -#define COUNT(a) (sizeof (a) / sizeof (a[0])) - -const int IDC_LABEL_HK_Table[NUM_HOTKEY_CONTROLS] = { - IDC_LABEL_HK1 , IDC_LABEL_HK2 , IDC_LABEL_HK3 , IDC_LABEL_HK4 , IDC_LABEL_HK5 , - IDC_LABEL_HK6 , IDC_LABEL_HK7 , IDC_LABEL_HK8 , IDC_LABEL_HK9 , IDC_LABEL_HK10, - IDC_LABEL_HK11, IDC_LABEL_HK12, IDC_LABEL_HK13, IDC_LABEL_HK14, IDC_LABEL_HK15, - IDC_LABEL_HK16, IDC_LABEL_HK17, IDC_LABEL_HK18, IDC_LABEL_HK19, IDC_LABEL_HK20, -}; -const int IDC_HOTKEY_Table[NUM_HOTKEY_CONTROLS] = { - IDC_HOTKEY1 , IDC_HOTKEY2 , IDC_HOTKEY3 , IDC_HOTKEY4 , IDC_HOTKEY5 , - IDC_HOTKEY6 , IDC_HOTKEY7 , IDC_HOTKEY8 , IDC_HOTKEY9 , IDC_HOTKEY10, - IDC_HOTKEY11, IDC_HOTKEY12, IDC_HOTKEY13, IDC_HOTKEY14, IDC_HOTKEY15, - IDC_HOTKEY16, IDC_HOTKEY17, IDC_HOTKEY18, IDC_HOTKEY19, IDC_HOTKEY20, -}; - -typedef char TcDIBuf[512]; - -TcDIBuf cDIBuf; -LPDIRECTINPUT8 pDI; -LPDIRECTINPUTDEVICE8 pJoystick; -DIDEVCAPS DIJoycap; -LPDIRECTINPUTEFFECT pEffect; -char JoystickName[255]; -BOOL Feedback; - - -static LPDIRECTINPUT8 tmp_pDI = NULL; -static BOOL tmp_Feedback = FALSE; -static char tmp_device_name[255] = { 0 }; -static LPDIRECTINPUTDEVICE8 tmp_Device = NULL; -static LPDIRECTINPUTDEVICE8 tmp_Joystick = NULL; - -BOOL CALLBACK EnumCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef) -{ - if ( FAILED( tmp_pDI->CreateDevice(lpddi->guidInstance, &tmp_Device, NULL) ) ) - { - tmp_Device = NULL; - return DIENUM_CONTINUE; - } - - strcpy(tmp_device_name, lpddi->tszProductName); - if (lpddi->guidFFDriver.Data1) tmp_Feedback = TRUE; - return DIENUM_STOP; -} - - -LPDIRECTINPUTDEVICE8 EnumDevices(LPDIRECTINPUT8 pDI) -{ - tmp_pDI = pDI; - tmp_Feedback = FALSE; - memset(tmp_device_name, 0, 255); - if( FAILED( pDI->EnumDevices(DI8DEVCLASS_GAMECTRL, - EnumCallback, - NULL, - DIEDFL_ATTACHEDONLY) ) ) - return NULL; - Feedback = tmp_Feedback; - strcpy(JoystickName, tmp_device_name); - return tmp_Device; -} - -BOOL CALLBACK EnumObjects(const DIDEVICEOBJECTINSTANCE* pdidoi,VOID* pContext) -{ - if( pdidoi->dwType & DIDFT_AXIS ) - { - DIPROPRANGE diprg; - diprg.diph.dwSize = sizeof(DIPROPRANGE); - diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER); - diprg.diph.dwHow = DIPH_BYID; - diprg.diph.dwObj = pdidoi->dwType; - diprg.lMin = -10000; - diprg.lMax = 10000; - - if( FAILED(tmp_Joystick->SetProperty(DIPROP_RANGE, &diprg.diph)) ) - return DIENUM_STOP; - } - return DIENUM_CONTINUE; -} - -static void ReadControl(const char* name, WORD& output) -{ - UINT temp; - temp = GetPrivateProfileInt("Controls",name,-1,IniName); - if(temp != -1) { - output = temp; - } -} - -static void ReadHotkey(const char* name, WORD& output) -{ - UINT temp; - temp = GetPrivateProfileInt("Hotkeys",name,-1,IniName); - if(temp != -1) { - output = temp; - } -} - -static void ReadGuitarControl(const char* name, WORD& output) -{ - UINT temp; - temp = GetPrivateProfileInt("GBAslot.GuitarGrip",name,-1,IniName); - if(temp != -1) { - output = temp; - } -} - -static void LoadHotkeyConfig() -{ - SCustomKey *key = &CustomKeys.key(0); - - while (!IsLastCustomKey(key)) { - ReadHotkey(key->code,key->key); - std::string modname = (std::string)key->code + (std::string)" MOD"; - ReadHotkey(modname.c_str(),key->modifiers); - key++; - } -} - -static void SaveHotkeyConfig() -{ - SCustomKey *key = &CustomKeys.key(0); - - while (!IsLastCustomKey(key)) { - WritePrivateProfileInt("Hotkeys",(char*)key->code,key->key,IniName); - std::string modname = (std::string)key->code + (std::string)" MOD"; - WritePrivateProfileInt("Hotkeys",(char*)modname.c_str(),key->modifiers,IniName); - key++; - } -} - -static void LoadGuitarConfig() -{ - memcpy(&Guitar,&DefaultGuitar,sizeof(Guitar)); - - //Guitar.Enabled = true; -#define DO(X) ReadControl(#X,Guitar.X); - DO(GREEN); - DO(RED); - DO(YELLOW); - DO(BLUE); -#undef DO -} - -static void LoadInputConfig() -{ - memcpy(&Joypad,&DefaultJoypad,sizeof(Joypad)); - - //read from configuration file - Joypad[0].Enabled = true; -#define DO(X) ReadControl(#X,Joypad[0] . X); - DO(Left); DO(Right); DO(Up); DO(Down); - DO(Left_Up); DO(Left_Down); DO(Right_Up); DO(Right_Down); - DO(Start); DO(Select); - DO(Lid); DO(Debug); - DO(A); DO(B); DO(X); DO(Y); - DO(L); DO(R); -#undef DO -} - -static void WriteControl(char* name, WORD val) -{ - WritePrivateProfileInt("Controls",name,val,IniName); -} - -static void SaveInputConfig() -{ -#define DO(X) WriteControl(#X,Joypad[0] . X); - DO(Left); DO(Right); DO(Up); DO(Down); - DO(Left_Up); DO(Left_Down); DO(Right_Up); DO(Right_Down); - DO(Start); DO(Select); - DO(Lid); DO(Debug); - DO(A); DO(B); DO(X); DO(Y); - DO(L); DO(R); -#undef DO -} - -BOOL di_init() -{ - HWND hParentWnd = MainWindow->getHWnd(); - - pDI = NULL; - pJoystick = NULL; - Feedback = FALSE; - memset(cDIBuf, 0, sizeof(cDIBuf)); - memset(JoystickName, 0, sizeof(JoystickName)); - - if(FAILED(DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&pDI,NULL))) - return FALSE; - - - pJoystick = EnumDevices(pDI); - - if (pJoystick) - { - if(!FAILED(pJoystick->SetDataFormat(&c_dfDIJoystick2))) - { - if(FAILED(pJoystick->SetCooperativeLevel(hParentWnd,DISCL_BACKGROUND|DISCL_EXCLUSIVE))) - { - pJoystick->Release(); - pJoystick = NULL; - } - else - { - tmp_Joystick = pJoystick; - pJoystick->EnumObjects(::EnumObjects, (VOID*)hParentWnd, DIDFT_ALL); - memset(&DIJoycap,0,sizeof(DIDEVCAPS)); - DIJoycap.dwSize=sizeof(DIDEVCAPS); - pJoystick->GetCapabilities(&DIJoycap); - } - } - else - { - pJoystick->Release(); - pJoystick = NULL; - } - } - - if (pJoystick) - { - DIPROPDWORD dipdw; - dipdw.diph.dwSize = sizeof(DIPROPDWORD); - dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); - dipdw.diph.dwObj = 0; - dipdw.diph.dwHow = DIPH_DEVICE; - dipdw.dwData = 0; - if ( !FAILED( pJoystick->SetProperty(DIPROP_AUTOCENTER, &dipdw.diph) ) ) - { - DWORD rgdwAxes[1] = { DIJOFS_Y }; - LONG rglDirection[2] = { 0 }; - DICONSTANTFORCE cf = { 0 }; - DIEFFECT eff; - - cf.lMagnitude = (DI_FFNOMINALMAX * 100); - - memset(&eff, 0, sizeof(eff)); - eff.dwSize = sizeof(DIEFFECT); - eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS; - eff.dwDuration = INFINITE; - eff.dwSamplePeriod = 0; - eff.dwGain = DI_FFNOMINALMAX; - eff.dwTriggerButton = DIEB_NOTRIGGER; - eff.dwTriggerRepeatInterval = 0; - eff.cAxes = 1; - eff.rgdwAxes = rgdwAxes; - eff.rglDirection = rglDirection; - eff.lpEnvelope = 0; - eff.cbTypeSpecificParams = sizeof( DICONSTANTFORCE ); - eff.lpvTypeSpecificParams = &cf; - eff.dwStartDelay = 0; - - if( FAILED( pJoystick->CreateEffect(GUID_ConstantForce, &eff, &pEffect, NULL) ) ) - Feedback = FALSE; - } - else - Feedback = FALSE; - } - - INFO("DirectX Input: \n"); - if (pJoystick != NULL) - { - INFO(" - gamecontrol successfully inited: %s\n", JoystickName); - if (Feedback) INFO("\t\t\t\t (with FeedBack support)\n"); - } - - paused = FALSE; - - return TRUE; -} - -BOOL JoystickEnabled() -{ - return (pJoystick==NULL?FALSE:TRUE); -} - - -HWND funky; -//WPARAM tid; - -// -void JoystickChanged( short ID, short Movement) -{ - // don't allow two changes to happen too close together in time - { - static bool first = true; - static DWORD lastTime = 0; - if(first || timeGetTime() - lastTime > 300) // 0.3 seconds - { - first = false; - lastTime = timeGetTime(); - } - else - { - return; // too soon after last change - } - } - - WORD JoyKey; - - JoyKey = 0x8000; - JoyKey |= (WORD)(ID << 8); - JoyKey |= Movement; - SendMessage(funky,WM_USER+45,JoyKey,0); -// KillTimer(funky,tid); -} - -int FunkyNormalize(int cur, int min, int max) -{ - int Result = 0; - - if ((max - min) == 0) - - return (Result); - - Result = cur - min; - Result = (Result * 200) / (max - min); - Result -= 100; - - return Result; -} - - - -#define S9X_JOY_NEUTRAL 60 - -void CheckAxis (short joy, short control, int val, - int min, int max, - bool &first, bool &second) -{ - - - - if (FunkyNormalize (val, min, max) < -S9X_JOY_NEUTRAL) - - { - second = false; - if (!first) - { - JoystickChanged (joy, control); - first = true; - - } - } - else - first = false; - - if (FunkyNormalize (val, min, max) > S9X_JOY_NEUTRAL) - { - first = false; - if (!second) - { - JoystickChanged (joy, (short) (control + 1)); - second = true; - } - } - else - second = false; -} - - -void CheckAxis_game (int val, int min, int max, bool &first, bool &second) -{ - if (FunkyNormalize (val, min, max) < -S9X_JOY_NEUTRAL) - { - second = false; - first = true; - } - else - first = false; - - if (FunkyNormalize (val, min, max) > S9X_JOY_NEUTRAL) - { - first = false; - second = true; - } - else - second = false; -} - -void S9xUpdateJoyState() -{ - memset(&Joystick[0],0,sizeof(Joystick[0])); - - int C = 0; - if (pJoystick) - { - DIJOYSTATE2 JoyStatus; - - HRESULT hr=pJoystick->Poll(); - if (FAILED(hr)) - pJoystick->Acquire(); - else - { - hr=pJoystick->GetDeviceState(sizeof(JoyStatus),&JoyStatus); - if (FAILED(hr)) hr=pJoystick->Acquire(); - else - { - CheckAxis_game(JoyStatus.lX,-10000,10000,Joystick[0].Left,Joystick[0].Right); - CheckAxis_game(JoyStatus.lY,-10000,10000,Joystick[0].Up,Joystick[0].Down); - - switch (JoyStatus.rgdwPOV[0]) - { - case JOY_POVBACKWARD: - Joystick[C].PovDown = true; - break; - case 4500: - //Joystick[C].PovUpRight = true; - Joystick[C].PovUp = true; - Joystick[C].PovRight = true; - break; - case 13500: - //Joystick[C].PovDnRight = true; - Joystick[C].PovDown = true; - Joystick[C].PovRight = true; - break; - case 22500: - //Joystick[C].PovDnLeft = true; - Joystick[C].PovDown = true; - Joystick[C].PovLeft = true; - break; - case 31500: - //Joystick[C].PovUpLeft = true; - Joystick[C].PovUp = true; - Joystick[C].PovLeft = true; - break; - - case JOY_POVFORWARD: - Joystick[C].PovUp = true; - break; - - case JOY_POVLEFT: - Joystick[C].PovLeft = true; - break; - - case JOY_POVRIGHT: - Joystick[C].PovRight = true; - break; - - default: - break; - } - - for(int B=0;B<128;B++) - if( JoyStatus.rgbButtons[B] ) - Joystick[C].Button[B] = true; - - } - } - } -} - -void di_poll_scan() -{ - int C = 0; - if (pJoystick) - { - DIJOYSTATE2 JoyStatus; - - HRESULT hr=pJoystick->Poll(); - if (FAILED(hr)) - pJoystick->Acquire(); - else - { - hr=pJoystick->GetDeviceState(sizeof(JoyStatus),&JoyStatus); - if (FAILED(hr)) hr=pJoystick->Acquire(); - else - { - CheckAxis(0,0,JoyStatus.lX,-10000,10000,Joystick[0].Left,Joystick[0].Right); - CheckAxis(0,2,JoyStatus.lY,-10000,10000,Joystick[0].Down,Joystick[0].Up); - - switch (JoyStatus.rgdwPOV[0]) - { - case JOY_POVBACKWARD: - if( !JoystickF[C].PovDown) - { JoystickChanged( C, 7); } - - JoystickF[C].PovDown = true; - JoystickF[C].PovUp = false; - JoystickF[C].PovLeft = false; - JoystickF[C].PovRight = false; - JoystickF[C].PovDnLeft = false; - JoystickF[C].PovDnRight = false; - JoystickF[C].PovUpLeft = false; - JoystickF[C].PovUpRight = false; - break; - case 4500: - if( !JoystickF[C].PovUpRight) - { JoystickChanged( C, 52); } - JoystickF[C].PovDown = false; - JoystickF[C].PovUp = false; - JoystickF[C].PovLeft = false; - JoystickF[C].PovRight = false; - JoystickF[C].PovDnLeft = false; - JoystickF[C].PovDnRight = false; - JoystickF[C].PovUpLeft = false; - JoystickF[C].PovUpRight = true; - break; - case 13500: - if( !JoystickF[C].PovDnRight) - { JoystickChanged( C, 50); } - JoystickF[C].PovDown = false; - JoystickF[C].PovUp = false; - JoystickF[C].PovLeft = false; - JoystickF[C].PovRight = false; - JoystickF[C].PovDnLeft = false; - JoystickF[C].PovDnRight = true; - JoystickF[C].PovUpLeft = false; - JoystickF[C].PovUpRight = false; - break; - case 22500: - if( !JoystickF[C].PovDnLeft) - { JoystickChanged( C, 49); } - JoystickF[C].PovDown = false; - JoystickF[C].PovUp = false; - JoystickF[C].PovLeft = false; - JoystickF[C].PovRight = false; - JoystickF[C].PovDnLeft = true; - JoystickF[C].PovDnRight = false; - JoystickF[C].PovUpLeft = false; - JoystickF[C].PovUpRight = false; - break; - case 31500: - if( !JoystickF[C].PovUpLeft) - { JoystickChanged( C, 51); } - JoystickF[C].PovDown = false; - JoystickF[C].PovUp = false; - JoystickF[C].PovLeft = false; - JoystickF[C].PovRight = false; - JoystickF[C].PovDnLeft = false; - JoystickF[C].PovDnRight = false; - JoystickF[C].PovUpLeft = true; - JoystickF[C].PovUpRight = false; - break; - - case JOY_POVFORWARD: - if( !JoystickF[C].PovUp) - { JoystickChanged( C, 6); } - - JoystickF[C].PovDown = false; - JoystickF[C].PovUp = true; - JoystickF[C].PovLeft = false; - JoystickF[C].PovRight = false; - JoystickF[C].PovDnLeft = false; - JoystickF[C].PovDnRight = false; - JoystickF[C].PovUpLeft = false; - JoystickF[C].PovUpRight = false; - break; - - case JOY_POVLEFT: - if( !JoystickF[C].PovLeft) - { JoystickChanged( C, 4); } - - JoystickF[C].PovDown = false; - JoystickF[C].PovUp = false; - JoystickF[C].PovLeft = true; - JoystickF[C].PovRight = false; - JoystickF[C].PovDnLeft = false; - JoystickF[C].PovDnRight = false; - JoystickF[C].PovUpLeft = false; - JoystickF[C].PovUpRight = false; - break; - - case JOY_POVRIGHT: - if( !JoystickF[C].PovRight) - { JoystickChanged( C, 5); } - - JoystickF[C].PovDown = false; - JoystickF[C].PovUp = false; - JoystickF[C].PovLeft = false; - JoystickF[C].PovRight = true; - JoystickF[C].PovDnLeft = false; - JoystickF[C].PovDnRight = false; - JoystickF[C].PovUpLeft = false; - JoystickF[C].PovUpRight = false; - break; - - default: - JoystickF[C].PovDown = false; - JoystickF[C].PovUp = false; - JoystickF[C].PovLeft = false; - JoystickF[C].PovRight = false; - JoystickF[C].PovDnLeft = false; - JoystickF[C].PovDnRight = false; - JoystickF[C].PovUpLeft = false; - JoystickF[C].PovUpRight = false; - break; - } - - for(int B=0;B<128;B++) - if( JoyStatus.rgbButtons[B] ) - { - if( !JoystickF[C].Button[B]) - { - JoystickChanged( C, (short)(8+B)); - JoystickF[C].Button[B] = true; - } - } - else - { JoystickF[C].Button[B] = false; } - - - } - } - } - -} - - -void FunkyJoyStickTimer() -{ - di_poll_scan(); -} - -void TranslateKey(WORD keyz,char *out) -{ -// sprintf(out,"%d",keyz); -// return; - - char temp[128]; - if(keyz&0x8000) - { - sprintf(out,GAMEDEVICE_JOYNUMPREFIX,((keyz>>8)&0xF)); - switch(keyz&0xFF) - { - case 0: strcat(out,GAMEDEVICE_XNEG); break; - case 1: strcat(out,GAMEDEVICE_XPOS); break; - case 2: strcat(out,GAMEDEVICE_YPOS); break; - case 3: strcat(out,GAMEDEVICE_YNEG); break; - case 4: strcat(out,GAMEDEVICE_POVLEFT); break; - case 5: strcat(out,GAMEDEVICE_POVRIGHT); break; - case 6: strcat(out,GAMEDEVICE_POVUP); break; - case 7: strcat(out,GAMEDEVICE_POVDOWN); break; - case 49: strcat(out,GAMEDEVICE_POVDNLEFT); break; - case 50: strcat(out,GAMEDEVICE_POVDNRIGHT); break; - case 51: strcat(out,GAMEDEVICE_POVUPLEFT); break; - case 52: strcat(out,GAMEDEVICE_POVUPRIGHT); break; - case 41: strcat(out,GAMEDEVICE_ZPOS); break; - case 42: strcat(out,GAMEDEVICE_ZNEG); break; - case 43: strcat(out,GAMEDEVICE_RPOS); break; - case 44: strcat(out,GAMEDEVICE_RNEG); break; - case 45: strcat(out,GAMEDEVICE_UPOS); break; - case 46: strcat(out,GAMEDEVICE_UNEG); break; - case 47: strcat(out,GAMEDEVICE_VPOS); break; - case 48: strcat(out,GAMEDEVICE_VNEG); break; - default: - if ((keyz & 0xff) > 40) - { - sprintf(temp,GAMEDEVICE_JOYBUTPREFIX,keyz&0xFF); - strcat(out,temp); - break; - } - - sprintf(temp,GAMEDEVICE_BUTTON,(keyz&0xFF)-8); - strcat(out,temp); - break; - - } - return; - } - sprintf(out,GAMEDEVICE_KEY,keyz); - if((keyz>='0' && keyz<='9')||(keyz>='A' &&keyz<='Z')) - { - sprintf(out,"%c",keyz); - return; - } - - if( keyz >= VK_NUMPAD0 && keyz <= VK_NUMPAD9) - { - - sprintf(out,GAMEDEVICE_NUMPADPREFIX,'0'+(keyz-VK_NUMPAD0)); - - return ; - } - switch(keyz) - { - case 0: sprintf(out,GAMEDEVICE_DISABLED); break; - case VK_TAB: sprintf(out,GAMEDEVICE_VK_TAB); break; - case VK_BACK: sprintf(out,GAMEDEVICE_VK_BACK); break; - case VK_CLEAR: sprintf(out,GAMEDEVICE_VK_CLEAR); break; - case VK_RETURN: sprintf(out,GAMEDEVICE_VK_RETURN); break; - case VK_LSHIFT: sprintf(out,GAMEDEVICE_VK_LSHIFT); break; - case VK_RSHIFT: sprintf(out,GAMEDEVICE_VK_RSHIFT); break; - case VK_LCONTROL: sprintf(out,GAMEDEVICE_VK_LCONTROL); break; - case VK_RCONTROL: sprintf(out,GAMEDEVICE_VK_RCONTROL); break; - case VK_LMENU: sprintf(out,GAMEDEVICE_VK_LMENU); break; - case VK_RMENU: sprintf(out,GAMEDEVICE_VK_RMENU); break; - case VK_PAUSE: sprintf(out,GAMEDEVICE_VK_PAUSE); break; - case VK_CANCEL: sprintf(out,GAMEDEVICE_VK_PAUSE); break; // the Pause key can resolve to either "Pause" or "Cancel" depending on when it's pressed - case VK_CAPITAL: sprintf(out,GAMEDEVICE_VK_CAPITAL); break; - case VK_ESCAPE: sprintf(out,GAMEDEVICE_VK_ESCAPE); break; - case VK_SPACE: sprintf(out,GAMEDEVICE_VK_SPACE); break; - case VK_PRIOR: sprintf(out,GAMEDEVICE_VK_PRIOR); break; - case VK_NEXT: sprintf(out,GAMEDEVICE_VK_NEXT); break; - case VK_HOME: sprintf(out,GAMEDEVICE_VK_HOME); break; - case VK_END: sprintf(out,GAMEDEVICE_VK_END); break; - case VK_LEFT: sprintf(out,GAMEDEVICE_VK_LEFT ); break; - case VK_RIGHT: sprintf(out,GAMEDEVICE_VK_RIGHT); break; - case VK_UP: sprintf(out,GAMEDEVICE_VK_UP); break; - case VK_DOWN: sprintf(out,GAMEDEVICE_VK_DOWN); break; - case VK_SELECT: sprintf(out,GAMEDEVICE_VK_SELECT); break; - case VK_PRINT: sprintf(out,GAMEDEVICE_VK_PRINT); break; - case VK_EXECUTE: sprintf(out,GAMEDEVICE_VK_EXECUTE); break; - case VK_SNAPSHOT: sprintf(out,GAMEDEVICE_VK_SNAPSHOT); break; - case VK_INSERT: sprintf(out,GAMEDEVICE_VK_INSERT); break; - case VK_DELETE: sprintf(out,GAMEDEVICE_VK_DELETE); break; - case VK_HELP: sprintf(out,GAMEDEVICE_VK_HELP); break; - case VK_LWIN: sprintf(out,GAMEDEVICE_VK_LWIN); break; - case VK_RWIN: sprintf(out,GAMEDEVICE_VK_RWIN); break; - case VK_APPS: sprintf(out,GAMEDEVICE_VK_APPS); break; - case VK_MULTIPLY: sprintf(out,GAMEDEVICE_VK_MULTIPLY); break; - case VK_ADD: sprintf(out,GAMEDEVICE_VK_ADD); break; - case VK_SEPARATOR: sprintf(out,GAMEDEVICE_VK_SEPARATOR); break; - case /*VK_OEM_1*/0xBA: sprintf(out,GAMEDEVICE_VK_OEM_1); break; - case /*VK_OEM_2*/0xBF: sprintf(out,GAMEDEVICE_VK_OEM_2); break; - case /*VK_OEM_3*/0xC0: sprintf(out,GAMEDEVICE_VK_OEM_3); break; - case /*VK_OEM_4*/0xDB: sprintf(out,GAMEDEVICE_VK_OEM_4); break; - case /*VK_OEM_5*/0xDC: sprintf(out,GAMEDEVICE_VK_OEM_5); break; - case /*VK_OEM_6*/0xDD: sprintf(out,GAMEDEVICE_VK_OEM_6); break; - case /*VK_OEM_7*/0xDE: sprintf(out,GAMEDEVICE_VK_OEM_7); break; - case /*VK_OEM_COMMA*/0xBC: sprintf(out,GAMEDEVICE_VK_OEM_COMMA );break; - case /*VK_OEM_PERIOD*/0xBE: sprintf(out,GAMEDEVICE_VK_OEM_PERIOD);break; - case VK_SUBTRACT: sprintf(out,GAMEDEVICE_VK_SUBTRACT); break; - case VK_DECIMAL: sprintf(out,GAMEDEVICE_VK_DECIMAL); break; - case VK_DIVIDE: sprintf(out,GAMEDEVICE_VK_DIVIDE); break; - case VK_NUMLOCK: sprintf(out,GAMEDEVICE_VK_NUMLOCK); break; - case VK_SCROLL: sprintf(out,GAMEDEVICE_VK_SCROLL); break; - case /*VK_OEM_MINUS*/0xBD: sprintf(out,GAMEDEVICE_VK_OEM_MINUS); break; - case /*VK_OEM_PLUS*/0xBB: sprintf(out,GAMEDEVICE_VK_OEM_PLUS); break; - case VK_SHIFT: sprintf(out,GAMEDEVICE_VK_SHIFT); break; - case VK_CONTROL: sprintf(out,GAMEDEVICE_VK_CONTROL); break; - case VK_MENU: sprintf(out,GAMEDEVICE_VK_MENU); break; - case VK_F1: sprintf(out,GAMEDEVICE_VK_F1); break; - case VK_F2: sprintf(out,GAMEDEVICE_VK_F2); break; - case VK_F3: sprintf(out,GAMEDEVICE_VK_F3); break; - case VK_F4: sprintf(out,GAMEDEVICE_VK_F4); break; - case VK_F5: sprintf(out,GAMEDEVICE_VK_F5); break; - case VK_F6: sprintf(out,GAMEDEVICE_VK_F6); break; - case VK_F7: sprintf(out,GAMEDEVICE_VK_F7); break; - case VK_F8: sprintf(out,GAMEDEVICE_VK_F8); break; - case VK_F9: sprintf(out,GAMEDEVICE_VK_F9); break; - case VK_F10: sprintf(out,GAMEDEVICE_VK_F10); break; - case VK_F11: sprintf(out,GAMEDEVICE_VK_F11); break; - case VK_F12: sprintf(out,GAMEDEVICE_VK_F12); break; - } - - return ; - - - -} - -bool IsReserved (WORD Key, int modifiers) -{ - // keys that do other stuff in Windows - if(Key == VK_CAPITAL || Key == VK_NUMLOCK || Key == VK_SCROLL || Key == VK_SNAPSHOT - || Key == VK_LWIN || Key == VK_RWIN || Key == VK_APPS || Key == /*VK_SLEEP*/0x5F - || (Key == VK_F4 && (modifiers & CUSTKEY_ALT_MASK) != 0)) // alt-f4 (behaves unlike accelerators) - return true; - - // menu shortcuts (accelerators) -- TODO: should somehow parse GUI.Accelerators for this information - if(modifiers == CUSTKEY_CTRL_MASK - && (Key == 'O') - || modifiers == CUSTKEY_ALT_MASK - && (Key == VK_F5 || Key == VK_F7 || Key == VK_F8 || Key == VK_F9 - || Key == 'R' || Key == 'T' || Key == /*VK_OEM_4*/0xDB || Key == /*VK_OEM_6*/0xDD - || Key == 'E' || Key == 'A' || Key == VK_RETURN || Key == VK_DELETE) - || Key == VK_MENU || Key == VK_CONTROL) - return true; - - return false; -} - - -int GetNumHotKeysAssignedTo (WORD Key, int modifiers) -{ - int count = 0; - { - #define MATCHES_KEY(k) \ - (Key != 0 && Key != VK_ESCAPE \ - && ((Key == k->key && modifiers == k->modifiers) \ - || (Key == VK_SHIFT && k->modifiers & CUSTKEY_SHIFT_MASK) \ - || (Key == VK_MENU && k->modifiers & CUSTKEY_ALT_MASK) \ - || (Key == VK_CONTROL && k->modifiers & CUSTKEY_CTRL_MASK) \ - || (k->key == VK_SHIFT && modifiers & CUSTKEY_SHIFT_MASK) \ - || (k->key == VK_MENU && modifiers & CUSTKEY_ALT_MASK) \ - || (k->key == VK_CONTROL && modifiers & CUSTKEY_CTRL_MASK))) - - SCustomKey *key = &CustomKeys.key(0); - while (!IsLastCustomKey(key)) { - if (MATCHES_KEY(key)) { - count++; - } - key++; - } - - - #undef MATCHES_KEY - } - return count; -} - -int GetNumButtonsAssignedTo (WORD Key) -{ - int count = 0; - for(int J = 0; J < 5*2; J++) - { - // don't want to report conflicts with disabled keys - if(!Joypad[J%5].Enabled || Key == 0 || Key == VK_ESCAPE) - continue; - - if(Key == Joypad[J].Left) count++; - if(Key == Joypad[J].Right) count++; - if(Key == Joypad[J].Left_Up) count++; - if(Key == Joypad[J].Left_Down) count++; - if(Key == Joypad[J].Right_Up) count++; - if(Key == Joypad[J].Right_Down) count++; - if(Key == Joypad[J].Up) count++; - if(Key == Joypad[J].Down) count++; - if(Key == Joypad[J].Start) count++; - if(Key == Joypad[J].Select) count++; - if(Key == Joypad[J].A) count++; - if(Key == Joypad[J].B) count++; - if(Key == Joypad[J].X) count++; - if(Key == Joypad[J].Y) count++; - if(Key == Joypad[J].L) count++; - if(Key == Joypad[J].R) count++; - if(Key == Joypad[J].Lid) count++; - if(Key == Joypad[J].Debug) count++; - } - return count; -} - -COLORREF CheckButtonKey( WORD Key) -{ - COLORREF red,magenta,blue,white; - red =RGB(255,0,0); - magenta =RGB(255,0,255); - blue = RGB(0,0,255); - white = RGB(255,255,255); - - // Check for conflict with reserved windows keys - if(IsReserved(Key,0)) - return red; - - // Check for conflict with Snes9X hotkeys - if(GetNumHotKeysAssignedTo(Key,0) > 0) - return magenta; - - // Check for duplicate button keys - if(GetNumButtonsAssignedTo(Key) > 1) - return blue; - - return white; -} - -COLORREF CheckHotKey( WORD Key, int modifiers) -{ - COLORREF red,magenta,blue,white; - red =RGB(255,0,0); - magenta =RGB(255,0,255); - blue = RGB(0,0,255); - white = RGB(255,255,255); - - // Check for conflict with reserved windows keys - if(IsReserved(Key,modifiers)) - return red; - - // Check for conflict with button keys - if(modifiers == 0 && GetNumButtonsAssignedTo(Key) > 0) - return magenta; - - // Check for duplicate Snes9X hotkeys - if(GetNumHotKeysAssignedTo(Key,modifiers) > 1) - return blue; - - return white; -} - -static void InitCustomControls() -{ - - WNDCLASSEX wc; - - wc.cbSize = sizeof(wc); - wc.lpszClassName = szClassName; - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = InputCustomWndProc; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); - wc.style = 0; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(InputCust *); - wc.hIconSm = 0; - - - RegisterClassEx(&wc); - - wc.cbSize = sizeof(wc); - wc.lpszClassName = szHotkeysClassName; - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = HotInputCustomWndProc; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); - wc.style = 0; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(InputCust *); - wc.hIconSm = 0; - - - RegisterClassEx(&wc); - - wc.cbSize = sizeof(wc); - wc.lpszClassName = szGuitarClassName; - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = GuitarInputCustomWndProc; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); - wc.style = 0; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(InputCust *); - wc.hIconSm = 0; - - - RegisterClassEx(&wc); -} - -InputCust * GetInputCustom(HWND hwnd) -{ - return (InputCust *)GetWindowLong(hwnd, 0); -} - -void SetInputCustom(HWND hwnd, InputCust *icp) -{ - SetWindowLong(hwnd, 0, (LONG)icp); -} - -LRESULT InputCustom_OnPaint(InputCust *ccp, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - HANDLE hOldFont; - TCHAR szText[200]; - RECT rect; - SIZE sz; - int x,y; - - // Get a device context for this window - hdc = BeginPaint(ccp->hwnd, &ps); - - // Set the font we are going to use - hOldFont = SelectObject(hdc, ccp->hFont); - - // Set the text colours - SetTextColor(hdc, ccp->crForeGnd); - SetBkColor (hdc, ccp->crBackGnd); - - // Find the text to draw - GetWindowText(ccp->hwnd, szText, sizeof(szText)); - - // Work out where to draw - GetClientRect(ccp->hwnd, &rect); - - - // Find out how big the text will be - GetTextExtentPoint32(hdc, szText, lstrlen(szText), &sz); - - // Center the text - x = (rect.right - sz.cx) / 2; - y = (rect.bottom - sz.cy) / 2; - - // Draw the text - ExtTextOut(hdc, x, y, ETO_OPAQUE, &rect, szText, lstrlen(szText), 0); - - // Restore the old font when we have finished - SelectObject(hdc, hOldFont); - - // Release the device context - EndPaint(ccp->hwnd, &ps); - - return 0; -} - -static LRESULT CALLBACK InputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - // retrieve the custom structure POINTER for THIS window - InputCust *icp = GetInputCustom(hwnd); - HWND pappy = (HWND__ *)GetWindowLongPtr(hwnd,GWL_HWNDPARENT); - funky= hwnd; - - static HWND selectedItem = NULL; - - char temp[100]; - COLORREF col; - switch(msg) - { - - case WM_GETDLGCODE: - return DLGC_WANTARROWS|DLGC_WANTALLKEYS|DLGC_WANTCHARS; - break; - - - case WM_NCCREATE: - - // Allocate a new CustCtrl structure for this window. - icp = (InputCust *) malloc( sizeof(InputCust) ); - - // Failed to allocate, stop window creation. - if(icp == NULL) return FALSE; - - // Initialize the CustCtrl structure. - icp->hwnd = hwnd; - icp->crForeGnd = GetSysColor(COLOR_WINDOWTEXT); - icp->crBackGnd = GetSysColor(COLOR_WINDOW); - icp->hFont = (HFONT__ *) GetStockObject(DEFAULT_GUI_FONT); - - // Assign the window text specified in the call to CreateWindow. - SetWindowText(hwnd, ((CREATESTRUCT *)lParam)->lpszName); - - // Attach custom structure to this window. - SetInputCustom(hwnd, icp); - - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - - selectedItem = NULL; - - SetTimer(hwnd,777,125,NULL); - - // Continue with window creation. - return TRUE; - - // Clean up when the window is destroyed. - case WM_NCDESTROY: - free(icp); - break; - case WM_PAINT: - return InputCustom_OnPaint(icp,wParam,lParam); - break; - case WM_ERASEBKGND: - return 1; - case WM_USER+45: - case WM_KEYDOWN: - TranslateKey(wParam,temp); - col = CheckButtonKey(wParam); - - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - SetWindowText(hwnd,temp); - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - SendMessage(pappy,WM_USER+43,wParam,(LPARAM)hwnd); - - break; - case WM_USER+44: - - TranslateKey(wParam,temp); - if(IsWindowEnabled(hwnd)) - { - col = CheckButtonKey(wParam); - } - else - { - col = RGB( 192,192,192); - } - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - SetWindowText(hwnd,temp); - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - - break; - - case WM_SETFOCUS: - { - selectedItem = hwnd; - col = RGB( 0,255,0); - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); -// tid = wParam; - - break; - } - case WM_KILLFOCUS: - { - selectedItem = NULL; - SendMessage(pappy,WM_USER+46,wParam,(LPARAM)hwnd); // refresh fields on deselect - break; - } - - case WM_TIMER: - if(hwnd == selectedItem) - { - FunkyJoyStickTimer(); - } - SetTimer(hwnd,777,125,NULL); - break; - case WM_LBUTTONDOWN: - SetFocus(hwnd); - break; - case WM_ENABLE: - COLORREF col; - if(wParam) - { - col = RGB( 255,255,255); - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - } - else - { - col = RGB( 192,192,192); - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - } - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - return true; - default: - break; - } - - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -static LRESULT CALLBACK GuitarInputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - // retrieve the custom structure POINTER for THIS window - InputCust *icp = GetInputCustom(hwnd); - HWND pappy = (HWND__ *)GetWindowLongPtr(hwnd,GWL_HWNDPARENT); - funky= hwnd; - - static HWND selectedItem = NULL; - - char temp[100]; - COLORREF col; - switch(msg) - { - - case WM_GETDLGCODE: - return DLGC_WANTARROWS|DLGC_WANTALLKEYS|DLGC_WANTCHARS; - break; - - - case WM_NCCREATE: - - // Allocate a new CustCtrl structure for this window. - icp = (InputCust *) malloc( sizeof(InputCust) ); - - // Failed to allocate, stop window creation. - if(icp == NULL) return FALSE; - - // Initialize the CustCtrl structure. - icp->hwnd = hwnd; - icp->crForeGnd = GetSysColor(COLOR_WINDOWTEXT); - icp->crBackGnd = GetSysColor(COLOR_WINDOW); - icp->hFont = (HFONT__ *) GetStockObject(DEFAULT_GUI_FONT); - - // Assign the window text specified in the call to CreateWindow. - SetWindowText(hwnd, ((CREATESTRUCT *)lParam)->lpszName); - - // Attach custom structure to this window. - SetInputCustom(hwnd, icp); - - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - - selectedItem = NULL; - - SetTimer(hwnd,777,125,NULL); - - // Continue with window creation. - return TRUE; - - // Clean up when the window is destroyed. - case WM_NCDESTROY: - free(icp); - break; - case WM_PAINT: - return InputCustom_OnPaint(icp,wParam,lParam); - break; - case WM_ERASEBKGND: - return 1; - case WM_USER+45: - case WM_KEYDOWN: - TranslateKey(wParam,temp); - col = CheckButtonKey(wParam); - - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - SetWindowText(hwnd,temp); - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - SendMessage(pappy,WM_USER+43,wParam,(LPARAM)hwnd); - - break; - case WM_USER+44: - - TranslateKey(wParam,temp); - if(IsWindowEnabled(hwnd)) - { - col = CheckButtonKey(wParam); - } - else - { - col = RGB( 192,192,192); - } - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - SetWindowText(hwnd,temp); - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - - break; - - case WM_SETFOCUS: - { - selectedItem = hwnd; - col = RGB( 0,255,0); - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); -// tid = wParam; - - break; - } - case WM_KILLFOCUS: - { - selectedItem = NULL; - SendMessage(pappy,WM_USER+46,wParam,(LPARAM)hwnd); // refresh fields on deselect - break; - } - - case WM_TIMER: - if(hwnd == selectedItem) - { - FunkyJoyStickTimer(); - } - SetTimer(hwnd,777,125,NULL); - break; - case WM_LBUTTONDOWN: - SetFocus(hwnd); - break; - case WM_ENABLE: - COLORREF col; - if(wParam) - { - col = RGB( 255,255,255); - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - } - else - { - col = RGB( 192,192,192); - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - } - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - return true; - default: - break; - } - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -static void TranslateKeyWithModifiers(int wParam, int modifiers, char * outStr) -{ - - // if the key itself is a modifier, special case output: - if(wParam == VK_SHIFT) - strcpy(outStr, "Shift"); - else if(wParam == VK_MENU) - strcpy(outStr, "Alt"); - else if(wParam == VK_CONTROL) - strcpy(outStr, "Control"); - else - { - // otherwise, prepend the modifier(s) - if(wParam != VK_ESCAPE && wParam != 0) - { - if((modifiers & CUSTKEY_CTRL_MASK) != 0) - { - sprintf(outStr,HOTKEYS_CONTROL_MOD); - outStr += strlen(HOTKEYS_CONTROL_MOD); - } - if((modifiers & CUSTKEY_ALT_MASK) != 0) - { - sprintf(outStr,HOTKEYS_ALT_MOD); - outStr += strlen(HOTKEYS_ALT_MOD); - } - if((modifiers & CUSTKEY_SHIFT_MASK) != 0) - { - sprintf(outStr,HOTKEYS_SHIFT_MOD); - outStr += strlen(HOTKEYS_SHIFT_MOD); - } - } - - // and append the translated non-modifier key - TranslateKey(wParam,outStr); - } -} - -static bool keyPressLock = false; - -static LRESULT CALLBACK HotInputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - // retrieve the custom structure POINTER for THIS window - InputCust *icp = GetInputCustom(hwnd); - HWND pappy = (HWND__ *)GetWindowLongPtr(hwnd,GWL_HWNDPARENT); - funky= hwnd; - - static HWND selectedItem = NULL; - - char temp[100]; - COLORREF col; - switch(msg) - { - - case WM_GETDLGCODE: - return DLGC_WANTARROWS|DLGC_WANTALLKEYS|DLGC_WANTCHARS; - break; - - - case WM_NCCREATE: - - // Allocate a new CustCtrl structure for this window. - icp = (InputCust *) malloc( sizeof(InputCust) ); - - // Failed to allocate, stop window creation. - if(icp == NULL) return FALSE; - - // Initialize the CustCtrl structure. - icp->hwnd = hwnd; - icp->crForeGnd = GetSysColor(COLOR_WINDOWTEXT); - icp->crBackGnd = GetSysColor(COLOR_WINDOW); - icp->hFont = (HFONT__ *) GetStockObject(DEFAULT_GUI_FONT); - - // Assign the window text specified in the call to CreateWindow. - SetWindowText(hwnd, ((CREATESTRUCT *)lParam)->lpszName); - - // Attach custom structure to this window. - SetInputCustom(hwnd, icp); - - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - - keyPressLock = false; - - selectedItem = NULL; - - SetTimer(hwnd,747,125,NULL); - - // Continue with window creation. - return TRUE; - - // Clean up when the window is destroyed. - case WM_NCDESTROY: - free(icp); - break; - case WM_PAINT: - return InputCustom_OnPaint(icp,wParam,lParam); - break; - case WM_ERASEBKGND: - return 1; -/* - case WM_KEYUP: - { - int count = 0; - for(int i=0;i<256;i++) - if(GetAsyncKeyState(i) & 1) - count++; - - if(count < 2) - { - int p = count; - } - if(count < 1) - { - int p = count; - } - - TranslateKey(wParam,temp); - col = CheckButtonKey(wParam); - - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - SetWindowText(hwnd,temp); - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - SendMessage(pappy,WM_USER+43,wParam,(LPARAM)hwnd); - } - break; -*/ - case WM_SYSKEYDOWN: - case WM_KEYDOWN: - - { - int count = 0; - for(int i=2;i<256;i++) - { - if(i >= VK_LSHIFT && i <= VK_RMENU) - continue; - if(GetAsyncKeyState(i) & 1) - count++; - } - - if(count <= 1) - { - keyPressLock = false; - } - } - - // no break - - case WM_USER+45: - // assign a hotkey: - { - // don't assign pure modifiers on key-down (they're assigned on key-up) - if(wParam == VK_SHIFT || wParam == VK_MENU || wParam == VK_CONTROL) - break; - - int modifiers = 0; - if(GetAsyncKeyState(VK_MENU)) - modifiers |= CUSTKEY_ALT_MASK; - if(GetAsyncKeyState(VK_CONTROL)) - modifiers |= CUSTKEY_CTRL_MASK; - if(GetAsyncKeyState(VK_SHIFT)) - modifiers |= CUSTKEY_SHIFT_MASK; - - TranslateKeyWithModifiers(wParam, modifiers, temp); - - col = CheckHotKey(wParam,modifiers); -/// if(col == RGB(255,0,0)) // un-redify -/// col = RGB(255,255,255); - - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - SetWindowText(hwnd,temp); - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - SendMessage(pappy,WM_USER+43,wParam,(LPARAM)hwnd); - - keyPressLock = true; - - } - break; - case WM_SYSKEYUP: - case WM_KEYUP: - if(!keyPressLock) - { - int count = 0; - for(int i=2;i<256;i++) - { - if(i >= VK_LSHIFT && i <= VK_RMENU) - continue; - if(GetAsyncKeyState(i) & 1) // &1 seems to solve an weird non-zero return problem, don't know why - count++; - } - if(count <= 1) - { - if(wParam == VK_SHIFT || wParam == VK_MENU || wParam == VK_CONTROL) - { - if(wParam == VK_SHIFT) - sprintf(temp, "Shift"); - if(wParam == VK_MENU) - sprintf(temp, "Alt"); - if(wParam == VK_CONTROL) - sprintf(temp, "Control"); - - col = CheckHotKey(wParam,0); - - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - SetWindowText(hwnd,temp); - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - SendMessage(pappy,WM_USER+43,wParam,(LPARAM)hwnd); - } - } - } - break; - case WM_USER+44: - - // set a hotkey field: - { - int modifiers = lParam; - - TranslateKeyWithModifiers(wParam, modifiers, temp); - - if(IsWindowEnabled(hwnd)) - { - col = CheckHotKey(wParam,modifiers); -/// if(col == RGB(255,0,0)) // un-redify -/// col = RGB(255,255,255); - } - else - { - col = RGB( 192,192,192); - } - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - SetWindowText(hwnd,temp); - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - } - break; - - case WM_SETFOCUS: - { - selectedItem = hwnd; - col = RGB( 0,255,0); - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); -// tid = wParam; - - break; - } - case WM_KILLFOCUS: - { - selectedItem = NULL; - SendMessage(pappy,WM_USER+46,wParam,(LPARAM)hwnd); // refresh fields on deselect - break; - } - - case WM_TIMER: - if(hwnd == selectedItem) - { - //FunkyJoyStickTimer(); - } - SetTimer(hwnd,747,125,NULL); - break; - case WM_LBUTTONDOWN: - SetFocus(hwnd); - break; - case WM_ENABLE: - COLORREF col; - if(wParam) - { - col = RGB( 255,255,255); - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - } - else - { - col = RGB( 192,192,192); - icp->crForeGnd = ((~col) & 0x00ffffff); - icp->crBackGnd = col; - } - InvalidateRect(icp->hwnd, NULL, FALSE); - UpdateWindow(icp->hwnd); - return true; - default: - break; - } - - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -static void set_buttoninfo(int index, HWND hDlg) -{ - SendDlgItemMessage(hDlg,IDC_UP,WM_USER+44,Joypad[index].Up,0); - SendDlgItemMessage(hDlg,IDC_LEFT,WM_USER+44,Joypad[index].Left,0); - SendDlgItemMessage(hDlg,IDC_DOWN,WM_USER+44,Joypad[index].Down,0); - SendDlgItemMessage(hDlg,IDC_RIGHT,WM_USER+44,Joypad[index].Right,0); - SendDlgItemMessage(hDlg,IDC_A,WM_USER+44,Joypad[index].A,0); - SendDlgItemMessage(hDlg,IDC_B,WM_USER+44,Joypad[index].B,0); - SendDlgItemMessage(hDlg,IDC_X,WM_USER+44,Joypad[index].X,0); - SendDlgItemMessage(hDlg,IDC_Y,WM_USER+44,Joypad[index].Y,0); - SendDlgItemMessage(hDlg,IDC_L,WM_USER+44,Joypad[index].L,0); - SendDlgItemMessage(hDlg,IDC_R,WM_USER+44,Joypad[index].R,0); - SendDlgItemMessage(hDlg,IDC_START,WM_USER+44,Joypad[index].Start,0); - SendDlgItemMessage(hDlg,IDC_SELECT,WM_USER+44,Joypad[index].Select,0); - SendDlgItemMessage(hDlg,IDC_LID,WM_USER+44,Joypad[index].Lid,0); - SendDlgItemMessage(hDlg,IDC_DEBUG,WM_USER+44,Joypad[index].Debug,0); - if(index < 5) - { - SendDlgItemMessage(hDlg,IDC_UPLEFT,WM_USER+44,Joypad[index].Left_Up,0); - SendDlgItemMessage(hDlg,IDC_UPRIGHT,WM_USER+44,Joypad[index].Right_Up,0); - SendDlgItemMessage(hDlg,IDC_DWNLEFT,WM_USER+44,Joypad[index].Left_Down,0); - SendDlgItemMessage(hDlg,IDC_DWNRIGHT,WM_USER+44,Joypad[index].Right_Down,0); - } -} - -void EnableDisableKeyFields (int index, HWND hDlg) -{ - bool enableUnTurboable; - if(index < 5) - { - SetDlgItemText(hDlg,IDC_LABEL_RIGHT,INPUTCONFIG_LABEL_RIGHT); - SetDlgItemText(hDlg,IDC_LABEL_UPLEFT,INPUTCONFIG_LABEL_UPLEFT); - SetDlgItemText(hDlg,IDC_LABEL_UPRIGHT,INPUTCONFIG_LABEL_UPRIGHT); - SetDlgItemText(hDlg,IDC_LABEL_DOWNRIGHT,INPUTCONFIG_LABEL_DOWNRIGHT); - SetDlgItemText(hDlg,IDC_LABEL_UP,INPUTCONFIG_LABEL_UP); - SetDlgItemText(hDlg,IDC_LABEL_LEFT,INPUTCONFIG_LABEL_LEFT); - SetDlgItemText(hDlg,IDC_LABEL_DOWN,INPUTCONFIG_LABEL_DOWN); - SetDlgItemText(hDlg,IDC_LABEL_DOWNLEFT,INPUTCONFIG_LABEL_DOWNLEFT); - enableUnTurboable = true; - } - else - { - SetDlgItemText(hDlg,IDC_LABEL_UP,INPUTCONFIG_LABEL_MAKE_TURBO); - SetDlgItemText(hDlg,IDC_LABEL_LEFT,INPUTCONFIG_LABEL_MAKE_HELD); - SetDlgItemText(hDlg,IDC_LABEL_DOWN,INPUTCONFIG_LABEL_MAKE_TURBO_HELD); - SetDlgItemText(hDlg,IDC_LABEL_RIGHT,INPUTCONFIG_LABEL_CLEAR_TOGGLES_AND_TURBO); - SetDlgItemText(hDlg,IDC_LABEL_UPLEFT,INPUTCONFIG_LABEL_UNUSED); - SetDlgItemText(hDlg,IDC_LABEL_UPRIGHT,INPUTCONFIG_LABEL_UNUSED); - SetDlgItemText(hDlg,IDC_LABEL_DOWNLEFT,INPUTCONFIG_LABEL_UNUSED); - SetDlgItemText(hDlg,IDC_LABEL_DOWNRIGHT,INPUTCONFIG_LABEL_UNUSED); - SetDlgItemText(hDlg,IDC_UPLEFT,INPUTCONFIG_LABEL_UNUSED); - SetDlgItemText(hDlg,IDC_UPRIGHT,INPUTCONFIG_LABEL_UNUSED); - SetDlgItemText(hDlg,IDC_DWNLEFT,INPUTCONFIG_LABEL_UNUSED); - SetDlgItemText(hDlg,IDC_DWNRIGHT,INPUTCONFIG_LABEL_UNUSED); - enableUnTurboable = false; - } - - EnableWindow(GetDlgItem(hDlg,IDC_UPLEFT), false); - EnableWindow(GetDlgItem(hDlg,IDC_UPRIGHT), false); - EnableWindow(GetDlgItem(hDlg,IDC_DWNRIGHT), false); - EnableWindow(GetDlgItem(hDlg,IDC_DWNLEFT), false); - EnableWindow(GetDlgItem(hDlg,IDC_DEBUG), false); - EnableWindow(GetDlgItem(hDlg,IDC_LID), true); -} - -INT_PTR CALLBACK DlgInputConfig(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - int i, which; - static int index=0; - - - static SJoypad savepad[10]; - - - //HBRUSH g_hbrBackground; - -switch(msg) - { - case WM_INITDIALOG: - //if(DirectX.Clipped) S9xReRefresh(); - SetWindowText(hDlg,INPUTCONFIG_TITLE); - //SetDlgItemText(hDlg,IDC_JPTOGGLE,INPUTCONFIG_JPTOGGLE); - SetDlgItemText(hDlg,IDOK,BUTTON_OK); - SetDlgItemText(hDlg,IDCANCEL,BUTTON_CANCEL); -/// SetDlgItemText(hDlg,IDC_DIAGTOGGLE,INPUTCONFIG_DIAGTOGGLE); - SetDlgItemText(hDlg,IDC_LABEL_UP,INPUTCONFIG_LABEL_UP); - SetDlgItemText(hDlg,IDC_LABEL_DOWN,INPUTCONFIG_LABEL_DOWN); - SetDlgItemText(hDlg,IDC_LABEL_LEFT,INPUTCONFIG_LABEL_LEFT); - SetDlgItemText(hDlg,IDC_LABEL_A,INPUTCONFIG_LABEL_A); - SetDlgItemText(hDlg,IDC_LABEL_B,INPUTCONFIG_LABEL_B); - SetDlgItemText(hDlg,IDC_LABEL_X,INPUTCONFIG_LABEL_X); - SetDlgItemText(hDlg,IDC_LABEL_Y,INPUTCONFIG_LABEL_Y); - SetDlgItemText(hDlg,IDC_LABEL_L,INPUTCONFIG_LABEL_L); - SetDlgItemText(hDlg,IDC_LABEL_R,INPUTCONFIG_LABEL_R); - SetDlgItemText(hDlg,IDC_LABEL_START,INPUTCONFIG_LABEL_START); - SetDlgItemText(hDlg,IDC_LABEL_SELECT,INPUTCONFIG_LABEL_SELECT); - SetDlgItemText(hDlg,IDC_LABEL_UPRIGHT,INPUTCONFIG_LABEL_UPRIGHT); - SetDlgItemText(hDlg,IDC_LABEL_UPLEFT,INPUTCONFIG_LABEL_UPLEFT); - SetDlgItemText(hDlg,IDC_LABEL_DOWNRIGHT,INPUTCONFIG_LABEL_DOWNRIGHT); - SetDlgItemText(hDlg,IDC_LABEL_DOWNLEFT,INPUTCONFIG_LABEL_DOWNLEFT); - SetDlgItemText(hDlg,IDC_LABEL_BLUE,INPUTCONFIG_LABEL_BLUE); - - for(i=5;i<10;i++) - Joypad[i].Left_Up = Joypad[i].Right_Up = Joypad[i].Left_Down = Joypad[i].Right_Down = 0; - - memcpy(savepad, Joypad, 10*sizeof(SJoypad)); - - for( i=0;i<256;i++) - GetAsyncKeyState(i); - - //for( C = 0; C != 16; C ++) - // JoystickF[C].Attached = joyGetDevCaps( JOYSTICKID1+C, &JoystickF[C].Caps, sizeof( JOYCAPS)) == JOYERR_NOERROR; - - memset(&JoystickF[0],0,sizeof(JoystickF[0])); - JoystickF[0].Attached = pJoystick != NULL; - - - //for(i=1;i<6;i++) - //{ - // sprintf(temp,INPUTCONFIG_JPCOMBO,i); - // SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_ADDSTRING,0,(LPARAM)(LPCTSTR)temp); - //} - - //for(i=6;i<11;i++) - //{ - // sprintf(temp,INPUTCONFIG_JPCOMBO INPUTCONFIG_LABEL_CONTROLLER_TURBO_PANEL_MOD,i-5); - // SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_ADDSTRING,0,(LPARAM)(LPCTSTR)temp); - //} - - //SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_SETCURSEL,(WPARAM)0,0); - - //SendDlgItemMessage(hDlg,IDC_JPTOGGLE,BM_SETCHECK, Joypad[index].Enabled ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0); - //SendDlgItemMessage(hDlg,IDC_ALLOWLEFTRIGHT,BM_SETCHECK, Settings.UpAndDown ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0); - - set_buttoninfo(index,hDlg); - - EnableDisableKeyFields(index,hDlg); - - //PostMessage(hDlg,WM_COMMAND, CBN_SELCHANGE<<16, 0); - - //SetFocus(GetDlgItem(hDlg,IDC_JPCOMBO)); - - return true; - break; - case WM_CLOSE: - EndDialog(hDlg, 0); - return TRUE; - case WM_USER+46: - // refresh command, for clicking away from a selected field - //index = SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_GETCURSEL,0,0); - //if(index > 4) index += 3; // skip controllers 6, 7, and 8 in the input dialog - set_buttoninfo(index,hDlg); - return TRUE; - case WM_USER+43: - //MessageBox(hDlg,"USER+43 CAUGHT","moo",MB_OK); - which = GetDlgCtrlID((HWND)lParam); - switch(which) - { - case IDC_UP: - Joypad[index].Up = wParam; - - break; - case IDC_DOWN: - Joypad[index].Down = wParam; - - break; - case IDC_LEFT: - Joypad[index].Left = wParam; - - break; - case IDC_RIGHT: - Joypad[index].Right = wParam; - - break; - case IDC_A: - Joypad[index].A = wParam; - - break; - case IDC_B: - Joypad[index].B = wParam; - - break; - case IDC_X: - Joypad[index].X = wParam; - - break; - case IDC_Y: - Joypad[index].Y = wParam; - - break; - case IDC_L: - Joypad[index].L = wParam; - break; - - case IDC_R: - Joypad[index].R = wParam; - - break; - case IDC_SELECT: - Joypad[index].Select = wParam; - - break; - case IDC_START: - Joypad[index].Start = wParam; - - break; - case IDC_UPLEFT: - Joypad[index].Left_Up = wParam; - - break; - case IDC_UPRIGHT: - Joypad[index].Right_Up = wParam; - - break; - case IDC_DWNLEFT: - Joypad[index].Left_Down = wParam; - - break; - case IDC_DWNRIGHT: - Joypad[index].Right_Down = wParam; - - break; - case IDC_LID: - Joypad[index].Lid = wParam; - - break; - case IDC_DEBUG: - Joypad[index].Debug = wParam; - - break; - - } - - set_buttoninfo(index,hDlg); - - PostMessage(hDlg,WM_NEXTDLGCTL,0,0); - return true; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDCANCEL: - memcpy(Joypad, savepad, 10*sizeof(SJoypad)); - EndDialog(hDlg,0); - break; - - case IDOK: - //Settings.UpAndDown = IsDlgButtonChecked(hDlg, IDC_ALLOWLEFTRIGHT); - SaveInputConfig(); - EndDialog(hDlg,0); - break; - - //case IDC_JPTOGGLE: // joypad Enable toggle - // index = SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_GETCURSEL,0,0); - // if(index > 4) index += 3; // skip controllers 6, 7, and 8 in the input dialog - // Joypad[index].Enabled=IsDlgButtonChecked(hDlg,IDC_JPTOGGLE); - // set_buttoninfo(index, hDlg); // update display of conflicts - // break; - - } - //switch(HIWORD(wParam)) - //{ - // case CBN_SELCHANGE: - // index = SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_GETCURSEL,0,0); - // SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_SETCURSEL,(WPARAM)index,0); - // if(index > 4) index += 3; // skip controllers 6, 7, and 8 in the input dialog - // if(index < 8) - // { - // SendDlgItemMessage(hDlg,IDC_JPTOGGLE,BM_SETCHECK, Joypad[index].Enabled ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0); - // EnableWindow(GetDlgItem(hDlg,IDC_JPTOGGLE),TRUE); - // } - // else - // { - // SendDlgItemMessage(hDlg,IDC_JPTOGGLE,BM_SETCHECK, Joypad[index-8].Enabled ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0); - // EnableWindow(GetDlgItem(hDlg,IDC_JPTOGGLE),FALSE); - // } - - // set_buttoninfo(index,hDlg); - - // EnableDisableKeyFields(index,hDlg); - - // break; - //} - //return FALSE; - - } - - return FALSE; -} - - -bool S9xGetState (WORD KeyIdent) -{ - if(KeyIdent == 0 || KeyIdent == VK_ESCAPE) // if it's the 'disabled' key, it's never pressed - return true; - - //TODO - option for background game keys - if(MainWindow->getHWnd() != GetForegroundWindow()) - return true; - - if (KeyIdent & 0x8000) // if it's a joystick 'key': - { - int j = (KeyIdent >> 8) & 15; - - //S9xUpdateJoyState(); - - switch (KeyIdent & 0xff) - { - case 0: return !Joystick [j].Left; - case 1: return !Joystick [j].Right; - case 2: return !Joystick [j].Up; - case 3: return !Joystick [j].Down; - case 4: return !Joystick [j].PovLeft; - case 5: return !Joystick [j].PovRight; - case 6: return !Joystick [j].PovUp; - case 7: return !Joystick [j].PovDown; - case 49:return !Joystick [j].PovDnLeft; - case 50:return !Joystick [j].PovDnRight; - case 51:return !Joystick [j].PovUpLeft; - case 52:return !Joystick [j].PovUpRight; - case 41:return !Joystick [j].ZUp; - case 42:return !Joystick [j].ZDown; - case 43:return !Joystick [j].RUp; - case 44:return !Joystick [j].RDown; - case 45:return !Joystick [j].UUp; - case 46:return !Joystick [j].UDown; - case 47:return !Joystick [j].VUp; - case 48:return !Joystick [j].VDown; - - default: - if ((KeyIdent & 0xff) > 40) - return true; // not pressed - - return !Joystick [j].Button [(KeyIdent & 0xff) - 8]; - } - } - - // the pause key is special, need this to catch all presses of it - // Both GetKeyState and GetAsyncKeyState cannot catch it anyway, - // so this should be handled in WM_KEYDOWN message. - if(KeyIdent == VK_PAUSE) - { - return true; // not pressed -// if(GetAsyncKeyState(VK_PAUSE)) // not &'ing this with 0x8000 is intentional and necessary -// return false; - } - - SHORT gks = GetKeyState (KeyIdent); - return ((gks & 0x80) == 0); -} - -void S9xWinScanJoypads () -{ - u32 PadState; - - S9xUpdateJoyState(); - - for (int J = 0; J < 8; J++) - { - if (Joypad [J].Enabled) - { - // toggle checks - { - PadState = 0; - PadState |= ToggleJoypadStorage[J].Left||TurboToggleJoypadStorage[J].Left ? LEFT_MASK : 0; - PadState |= ToggleJoypadStorage[J].Right||TurboToggleJoypadStorage[J].Right ? RIGHT_MASK : 0; - PadState |= ToggleJoypadStorage[J].Up||TurboToggleJoypadStorage[J].Up ? UP_MASK : 0; - PadState |= ToggleJoypadStorage[J].Down||TurboToggleJoypadStorage[J].Down ? DOWN_MASK : 0; - PadState |= ToggleJoypadStorage[J].Start||TurboToggleJoypadStorage[J].Start ? START_MASK : 0; - PadState |= ToggleJoypadStorage[J].Select||TurboToggleJoypadStorage[J].Select ? SELECT_MASK : 0; - PadState |= ToggleJoypadStorage[J].Lid||TurboToggleJoypadStorage[J].Lid ? LID_MASK : 0; - PadState |= ToggleJoypadStorage[J].Debug||TurboToggleJoypadStorage[J].Debug ? DEBUG_MASK : 0; - PadState |= ToggleJoypadStorage[J].A||TurboToggleJoypadStorage[J].A ? A_MASK : 0; - PadState |= ToggleJoypadStorage[J].B||TurboToggleJoypadStorage[J].B ? B_MASK : 0; - PadState |= ToggleJoypadStorage[J].X||TurboToggleJoypadStorage[J].X ? X_MASK : 0; - PadState |= ToggleJoypadStorage[J].Y||TurboToggleJoypadStorage[J].Y ? Y_MASK : 0; - PadState |= ToggleJoypadStorage[J].L||TurboToggleJoypadStorage[J].L ? L_MASK : 0; - PadState |= ToggleJoypadStorage[J].R||TurboToggleJoypadStorage[J].R ? R_MASK : 0; - } - // auto-hold AND regular key/joystick presses - if(S9xGetState(Joypad[J+8].Left)) - { - PadState ^= (!S9xGetState(Joypad[J].R)||!S9xGetState(Joypad[J+8].R)) ? R_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].L)||!S9xGetState(Joypad[J+8].L)) ? L_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].X)||!S9xGetState(Joypad[J+8].X)) ? X_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].A)||!S9xGetState(Joypad[J+8].A)) ? A_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Right)) ? RIGHT_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Right_Up)) ? RIGHT_MASK + UP_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Right_Down)) ? RIGHT_MASK + DOWN_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Left)) ? LEFT_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Left_Up)) ? LEFT_MASK + UP_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Left_Down)) ? LEFT_MASK + DOWN_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Down)) ? DOWN_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Up)) ? UP_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Start)||!S9xGetState(Joypad[J+8].Start)) ? START_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Select)||!S9xGetState(Joypad[J+8].Select)) ? SELECT_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Y)||!S9xGetState(Joypad[J+8].Y)) ? Y_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].B)||!S9xGetState(Joypad[J+8].B)) ? B_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Lid)||!S9xGetState(Joypad[J+8].Lid)) ? LID_MASK : 0; - PadState ^= (!S9xGetState(Joypad[J].Debug)||!S9xGetState(Joypad[J+8].Debug)) ? DEBUG_MASK : 0; - } - - bool turbofy = !S9xGetState(Joypad[J+8].Up); // All Mod for turbo - - u32 TurboMask = 0; - - //handle turbo case! (autofire / auto-fire) - if(turbofy || ((TurboMask&A_MASK))&&(PadState&A_MASK) || !S9xGetState(Joypad[J+8].A )) PadState^=(joypads[J]&A_MASK); - if(turbofy || ((TurboMask&B_MASK))&&(PadState&B_MASK) || !S9xGetState(Joypad[J+8].B )) PadState^=(joypads[J]&B_MASK); - if(turbofy || ((TurboMask&Y_MASK))&&(PadState&Y_MASK) || !S9xGetState(Joypad[J+8].Y )) PadState^=(joypads[J]&Y_MASK); - if(turbofy || ((TurboMask&X_MASK))&&(PadState&X_MASK) || !S9xGetState(Joypad[J+8].X )) PadState^=(joypads[J]&X_MASK); - if(turbofy || ((TurboMask&L_MASK))&&(PadState&L_MASK) || !S9xGetState(Joypad[J+8].L )) PadState^=(joypads[J]&L_MASK); - if(turbofy || ((TurboMask&R_MASK))&&(PadState&R_MASK) || !S9xGetState(Joypad[J+8].R )) PadState^=(joypads[J]&R_MASK); - if(turbofy || ((TurboMask&START_MASK))&&(PadState&START_MASK) || !S9xGetState(Joypad[J+8].Start )) PadState^=(joypads[J]&START_MASK); - if(turbofy || ((TurboMask&SELECT_MASK))&&(PadState&SELECT_MASK) || !S9xGetState(Joypad[J+8].Select)) PadState^=(joypads[J]&SELECT_MASK); - if(turbofy || ((TurboMask&DEBUG_MASK))&&(PadState&DEBUG_MASK) || !S9xGetState(Joypad[J+8].Debug)) PadState^=(joypads[J]&DEBUG_MASK); - if( ((TurboMask&LEFT_MASK))&&(PadState&LEFT_MASK) ) PadState^=(joypads[J]&LEFT_MASK); - if( ((TurboMask&UP_MASK))&&(PadState&UP_MASK) ) PadState^=(joypads[J]&UP_MASK); - if( ((TurboMask&RIGHT_MASK))&&(PadState&RIGHT_MASK) ) PadState^=(joypads[J]&RIGHT_MASK); - if( ((TurboMask&DOWN_MASK))&&(PadState&DOWN_MASK) ) PadState^=(joypads[J]&DOWN_MASK); - if( ((TurboMask&LID_MASK))&&(PadState&LID_MASK) ) PadState^=(joypads[J]&LID_MASK); - - if(TurboToggleJoypadStorage[J].A ) PadState^=(joypads[J]&A_MASK); - if(TurboToggleJoypadStorage[J].B ) PadState^=(joypads[J]&B_MASK); - if(TurboToggleJoypadStorage[J].Y ) PadState^=(joypads[J]&Y_MASK); - if(TurboToggleJoypadStorage[J].X ) PadState^=(joypads[J]&X_MASK); - if(TurboToggleJoypadStorage[J].L ) PadState^=(joypads[J]&L_MASK); - if(TurboToggleJoypadStorage[J].R ) PadState^=(joypads[J]&R_MASK); - if(TurboToggleJoypadStorage[J].Start ) PadState^=(joypads[J]&START_MASK); - if(TurboToggleJoypadStorage[J].Select) PadState^=(joypads[J]&SELECT_MASK); - if(TurboToggleJoypadStorage[J].Left ) PadState^=(joypads[J]&LEFT_MASK); - if(TurboToggleJoypadStorage[J].Up ) PadState^=(joypads[J]&UP_MASK); - if(TurboToggleJoypadStorage[J].Right ) PadState^=(joypads[J]&RIGHT_MASK); - if(TurboToggleJoypadStorage[J].Down ) PadState^=(joypads[J]&DOWN_MASK); - if(TurboToggleJoypadStorage[J].Lid ) PadState^=(joypads[J]&LID_MASK); - if(TurboToggleJoypadStorage[J].Debug ) PadState^=(joypads[J]&DEBUG_MASK); - //end turbo case... - - - // enforce left+right/up+down disallowance here to - // avoid recording unused l+r/u+d that will cause desyncs - // when played back with l+r/u+d is allowed - //if(!Settings.UpAndDown) - //{ - // if((PadState[1] & 2) != 0) - // PadState[1] &= ~(1); - // if((PadState[1] & 8) != 0) - // PadState[1] &= ~(4); - //} - - joypads [J] = PadState | 0x80000000; - } - else - joypads [J] = 0; - } - - // input from macro - //for (int J = 0; J < 8; J++) - //{ - // if(MacroIsEnabled(J)) - // { - // uint16 userPadState = joypads[J] & 0xFFFF; - // uint16 macroPadState = MacroInput(J); - // uint16 newPadState; - - // switch(GUI.MacroInputMode) - // { - // case MACRO_INPUT_MOV: - // newPadState = macroPadState; - // break; - // case MACRO_INPUT_OR: - // newPadState = macroPadState | userPadState; - // break; - // case MACRO_INPUT_XOR: - // newPadState = macroPadState ^ userPadState; - // break; - // default: - // newPadState = userPadState; - // break; - // } - - // PadState[0] = (uint8) ( newPadState & 0xFF); - // PadState[1] = (uint8) ((newPadState >> 8) & 0xFF); - - // // enforce left+right/up+down disallowance here to - // // avoid recording unused l+r/u+d that will cause desyncs - // // when played back with l+r/u+d is allowed - // if(!Settings.UpAndDown) - // { - // if((PadState[1] & 2) != 0) - // PadState[1] &= ~(1); - // if((PadState[1] & 8) != 0) - // PadState[1] &= ~(4); - // } - - // joypads [J] = PadState [0] | (PadState [1] << 8) | 0x80000000; - // } - //} - -//#ifdef NETPLAY_SUPPORT -// if (Settings.NetPlay) -// { -// // Send joypad position update to server -// S9xNPSendJoypadUpdate (joypads [GUI.NetplayUseJoypad1 ? 0 : NetPlay.Player-1]); -// -// // set input from network -// for (int J = 0; J < NP_MAX_CLIENTS; J++) -// joypads[J] = S9xNPGetJoypad (J); -// } -//#endif -} - -void input_feedback(BOOL enable) -{ - if (!Feedback) return; - if (!pEffect) return; - - if (enable) - pEffect->Start(2, 0); - else - pEffect->Stop(); -} - - -void input_init() -{ - InitCustomControls(); - - LoadInputConfig(); - LoadHotkeyConfig(); - LoadGuitarConfig(); - - di_init(); - FeedbackON = input_feedback; -} - -void input_process() -{ - S9xWinScanJoypads(); - - //not appropriate right now in desmume - //if (paused) return; - - bool R = (joypads[0] & RIGHT_MASK)!=0; - bool L = (joypads[0] & LEFT_MASK)!=0; - bool D = (joypads[0] & DOWN_MASK)!=0; - bool U = (joypads[0] & UP_MASK)!=0; - bool T = (joypads[0] & START_MASK)!=0; - bool S = (joypads[0] & SELECT_MASK)!=0; - bool B = (joypads[0] & B_MASK)!=0; - bool A = (joypads[0] & A_MASK)!=0; - bool Y = (joypads[0] & Y_MASK)!=0; - bool X = (joypads[0] & X_MASK)!=0; - bool W = (joypads[0] & L_MASK)!=0; - bool E = (joypads[0] & R_MASK)!=0; - bool G = (joypads[0] & DEBUG_MASK)!=0; - bool F = (joypads[0] & LID_MASK)!=0; - - if(AutoHoldPressed && R) AutoHold.Right ^= true; - if(AutoHoldPressed && L) AutoHold.Left ^= true; - if(AutoHoldPressed && D) AutoHold.Down ^= true; - if(AutoHoldPressed && U) AutoHold.Up ^= true; - if(AutoHoldPressed && T) AutoHold.Select ^= true; - if(AutoHoldPressed && S) AutoHold.Start ^= true; - if(AutoHoldPressed && B) AutoHold.B ^= true; - if(AutoHoldPressed && A) AutoHold.A ^= true; - if(AutoHoldPressed && Y) AutoHold.Y ^= true; - if(AutoHoldPressed && X) AutoHold.X ^= true; - if(AutoHoldPressed && W) AutoHold.L ^= true; - if(AutoHoldPressed && E) AutoHold.R ^= true; - - NDS_setPad( R, L, D, U, T, S, B, A, Y, X, W, E, G, F); - - if (Guitar.Enabled) - { - bool gG=!S9xGetState(Guitar.GREEN); - bool gR=!S9xGetState(Guitar.RED); - bool gY=!S9xGetState(Guitar.YELLOW); - bool gB=!S9xGetState(Guitar.BLUE); - guitarGrip_setKey(gG, gR, gY, gB); - } -} - -static void set_hotkeyinfo(HWND hDlg) -{ - HotkeyPage page = (HotkeyPage) SendDlgItemMessage(hDlg,IDC_HKCOMBO,CB_GETCURSEL,0,0); - SCustomKey *key = &CustomKeys.key(0); - int i = 0; - - while (!IsLastCustomKey(key) && i < NUM_HOTKEY_CONTROLS) { - if (page == key->page) { - SendDlgItemMessage(hDlg, IDC_HOTKEY_Table[i], WM_USER+44, key->key, key->modifiers); - SetDlgItemTextW(hDlg, IDC_LABEL_HK_Table[i], key->name.c_str()); - ShowWindow(GetDlgItem(hDlg, IDC_HOTKEY_Table[i]), SW_SHOW); - i++; - } - key++; - } - // disable unused controls - for (; i < NUM_HOTKEY_CONTROLS; i++) { - SendDlgItemMessage(hDlg, IDC_HOTKEY_Table[i], WM_USER+44, 0, 0); - SetDlgItemText(hDlg, IDC_LABEL_HK_Table[i], INPUTCONFIG_LABEL_UNUSED); - ShowWindow(GetDlgItem(hDlg, IDC_HOTKEY_Table[i]), SW_HIDE); - } -} - - -// DlgHotkeyConfig -INT_PTR CALLBACK DlgHotkeyConfig(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - int i, which; - static HotkeyPage page = (HotkeyPage) 0; - - - static SCustomKeys keys; - - //HBRUSH g_hbrBackground; -switch(msg) - { - case WM_PAINT: - { - PAINTSTRUCT ps; - BeginPaint (hDlg, &ps); - - EndPaint (hDlg, &ps); - } - return true; - case WM_INITDIALOG: - //if(DirectX.Clipped) S9xReRefresh(); - SetWindowText(hDlg,HOTKEYS_TITLE); - - // insert hotkey page list items - for(i = 0 ; i < NUM_HOTKEY_PAGE ; i++) - { - SendDlgItemMessage(hDlg, IDC_HKCOMBO, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)hotkeyPageTitle[i]); - } - - SendDlgItemMessage(hDlg,IDC_HKCOMBO,CB_SETCURSEL,(WPARAM)0,0); - - InitCustomKeys(&keys); - CopyCustomKeys(&keys, &CustomKeys); - for( i=0;i<256;i++) - { - GetAsyncKeyState(i); - } - - SetDlgItemText(hDlg,IDC_LABEL_BLUE,HOTKEYS_LABEL_BLUE); - - set_hotkeyinfo(hDlg); - - PostMessage(hDlg,WM_COMMAND, CBN_SELCHANGE<<16, 0); - - SetFocus(GetDlgItem(hDlg,IDC_HKCOMBO)); - - - return true; - break; - case WM_CLOSE: - EndDialog(hDlg, 0); - return TRUE; - case WM_USER+46: - // refresh command, for clicking away from a selected field - page = (HotkeyPage) SendDlgItemMessage(hDlg, IDC_HKCOMBO, CB_GETCURSEL, 0, 0); - set_hotkeyinfo(hDlg); - return TRUE; - case WM_USER+43: - { - //MessageBox(hDlg,"USER+43 CAUGHT","moo",MB_OK); - int modifiers = GetModifiers(wParam); - - page = (HotkeyPage) SendDlgItemMessage(hDlg, IDC_HKCOMBO, CB_GETCURSEL, 0, 0); - wchar_t text[256]; - - which = GetDlgCtrlID((HWND)lParam); - for (i = 0; i < NUM_HOTKEY_CONTROLS; i++) { - if (which == IDC_HOTKEY_Table[i]) - break; - } - GetDlgItemTextW(hDlg, IDC_LABEL_HK_Table[i], text, COUNT(text)); - - SCustomKey *key = &CustomKeys.key(0); - while (!IsLastCustomKey(key)) { - if (page == key->page) { - if(text == key->name) { - key->key = wParam; - key->modifiers = modifiers; - break; - } - } - key++; - } - - set_hotkeyinfo(hDlg); - PostMessage(hDlg,WM_NEXTDLGCTL,0,0); -// PostMessage(hDlg,WM_KILLFOCUS,0,0); - } - return true; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDCANCEL: - CopyCustomKeys(&CustomKeys, &keys); - EndDialog(hDlg,0); - break; - case IDOK: - SaveHotkeyConfig(); - EndDialog(hDlg,0); - break; - } - switch(HIWORD(wParam)) - { - case CBN_SELCHANGE: - page = (HotkeyPage) SendDlgItemMessage(hDlg, IDC_HKCOMBO, CB_GETCURSEL, 0, 0); - SendDlgItemMessage(hDlg, IDC_HKCOMBO, CB_SETCURSEL, (WPARAM)page, 0); - - set_hotkeyinfo(hDlg); - - SetFocus(GetDlgItem(hDlg, IDC_HKCOMBO)); - - break; - } - return FALSE; - - } - - return FALSE; -} - - -void RunInputConfig() -{ - DialogBox(hAppInst, MAKEINTRESOURCE(IDD_INPUTCONFIG), MainWindow->getHWnd(), DlgInputConfig); -} - -void RunHotkeyConfig() -{ - DialogBox(hAppInst, MAKEINTRESOURCE(IDD_KEYCUSTOM), MainWindow->getHWnd(), DlgHotkeyConfig); -} - - -/********************************************************************************** - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - - (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), - Jerremy Koot (jkoot@snes9x.com) - - (c) Copyright 2002 - 2004 Matthew Kendora - - (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) - - (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) - - (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) - - (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), - Kris Bleakley (codeviolation@hotmail.com) - - (c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net), - Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) - - (c) Copyright 2006 - 2007 nitsuja - - - BS-X C emulator code - (c) Copyright 2005 - 2006 Dreamer Nom, - zones - - C4 x86 assembler and some C emulation code - (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), - Nach, - zsKnight (zsknight@zsnes.com) - - C4 C++ code - (c) Copyright 2003 - 2006 Brad Jorsch, - Nach - - DSP-1 emulator code - (c) Copyright 1998 - 2006 _Demo_, - Andreas Naive (andreasnaive@gmail.com) - Gary Henderson, - Ivar (ivar@snes9x.com), - John Weidman, - Kris Bleakley, - Matthew Kendora, - Nach, - neviksti (neviksti@hotmail.com) - - DSP-2 emulator code - (c) Copyright 2003 John Weidman, - Kris Bleakley, - Lord Nightmare (lord_nightmare@users.sourceforge.net), - Matthew Kendora, - neviksti - - - DSP-3 emulator code - (c) Copyright 2003 - 2006 John Weidman, - Kris Bleakley, - Lancer, - z80 gaiden - - DSP-4 emulator code - (c) Copyright 2004 - 2006 Dreamer Nom, - John Weidman, - Kris Bleakley, - Nach, - z80 gaiden - - OBC1 emulator code - (c) Copyright 2001 - 2004 zsKnight, - pagefault (pagefault@zsnes.com), - Kris Bleakley, - Ported from x86 assembler to C by sanmaiwashi - - SPC7110 and RTC C++ emulator code - (c) Copyright 2002 Matthew Kendora with research by - zsKnight, - John Weidman, - Dark Force - - S-DD1 C emulator code - (c) Copyright 2003 Brad Jorsch with research by - Andreas Naive, - John Weidman - - S-RTC C emulator code - (c) Copyright 2001-2006 byuu, - John Weidman - - ST010 C++ emulator code - (c) Copyright 2003 Feather, - John Weidman, - Kris Bleakley, - Matthew Kendora - - Super FX x86 assembler emulator code - (c) Copyright 1998 - 2003 _Demo_, - pagefault, - zsKnight, - - Super FX C emulator code - (c) Copyright 1997 - 1999 Ivar, - Gary Henderson, - John Weidman - - Sound DSP emulator code is derived from SNEeSe and OpenSPC: - (c) Copyright 1998 - 2003 Brad Martin - (c) Copyright 1998 - 2006 Charles Bilyue' - - SH assembler code partly based on x86 assembler code - (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) - - 2xSaI filter - (c) Copyright 1999 - 2001 Derek Liauw Kie Fa - - HQ2x, HQ3x, HQ4x filters - (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) - - Win32 GUI code - (c) Copyright 2003 - 2006 blip, - funkyass, - Matthew Kendora, - Nach, - nitsuja - - Mac OS GUI code - (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2007 zones - - - Specific ports contains the works of other authors. See headers in - individual files. - - - Snes9x homepage: http://www.snes9x.com - - Permission to use, copy, modify and/or distribute Snes9x in both binary - and source form, for non-commercial purposes, is hereby granted without - fee, providing that this license information and copyright notice appear - with all copies and any derived work. - - This software is provided 'as-is', without any express or implied - warranty. In no event shall the authors be held liable for any damages - arising from the use of this software or it's derivatives. - - Snes9x is freeware for PERSONAL USE only. Commercial users should - seek permission of the copyright holders first. Commercial use includes, - but is not limited to, charging money for Snes9x or software derived from - Snes9x, including Snes9x or derivatives in commercial game bundles, and/or - using Snes9x as a promotion for your commercial product. - - The copyright holders request that bug fixes and improvements to the code - should be forwarded to them so everyone can benefit from the modifications - in future versions. - - Super NES and Super Nintendo Entertainment System are trademarks of - Nintendo Co., Limited and its subsidiary companies. -**********************************************************************************/ +///* This file is part of DeSmuME, derived from several files in Snes9x 1.51 which are +// licensed under the terms supplied at the end of this file (for the terms are very long!) +// Differences from that baseline version are: +// +// Copyright (C) 2009 DeSmuME team +// +// DeSmuME is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// DeSmuME is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with DeSmuME; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//*/ + + + +#ifdef __MINGW32__ +#define _WIN32_IE 0x0501 +#define _WIN32_WINNT 0x0501 +#endif + +#define STRICT +#include +#include +#include +#include + +#include + +#if (((defined(_MSC_VER) && _MSC_VER >= 1300)) || defined(__MINGW32__)) + // both MINGW and VS.NET use fstream instead of fstream.h which is deprecated + #include + using namespace std; +#else + // for VC++ 6 + #include +#endif + +#include "inputdx.h" +#include "hotkey.h" + +#include "main.h" +#include "resource.h" +#include "common.h" +#include "../addons.h" +#include "../NDSSystem.h" + +#define DIRECTINPUT_VERSION 0x0800 +#include "../common.h" +#include "../types.h" +#include "directx/dinput.h" + +// Gamepad Dialog Strings +#define INPUTCONFIG_TITLE "Input Configuration" +#define INPUTCONFIG_JPTOGGLE "Enabled" +//#define INPUTCONFIG_DIAGTOGGLE "Toggle Diagonals" +//#define INPUTCONFIG_OK "&OK" +//#define INPUTCONFIG_CANCEL "&Cancel" +#define INPUTCONFIG_JPCOMBO "Joypad #%d" +#define INPUTCONFIG_LABEL_UP "Up" +#define INPUTCONFIG_LABEL_DOWN "Down" +#define INPUTCONFIG_LABEL_LEFT "Left" +#define INPUTCONFIG_LABEL_RIGHT "Right" +#define INPUTCONFIG_LABEL_A "A" +#define INPUTCONFIG_LABEL_B "B" +#define INPUTCONFIG_LABEL_X "X" +#define INPUTCONFIG_LABEL_Y "Y" +#define INPUTCONFIG_LABEL_L "L" +#define INPUTCONFIG_LABEL_R "R" +#define INPUTCONFIG_LABEL_START "Start" +#define INPUTCONFIG_LABEL_SELECT "Select" +#define INPUTCONFIG_LABEL_UPLEFT "Up Left" +#define INPUTCONFIG_LABEL_UPRIGHT "Up Right" +#define INPUTCONFIG_LABEL_DOWNRIGHT "Dn Right" +#define INPUTCONFIG_LABEL_DOWNLEFT "Dn Left" +#define INPUTCONFIG_LABEL_BLUE "Blue means the button is already mapped.\nPink means it conflicts with a custom hotkey.\nRed means it's reserved by Windows.\nButtons can be disabled using Escape.\nGrayed buttons arent supported yet (sorry!)" +#define INPUTCONFIG_LABEL_UNUSED "" +#define INPUTCONFIG_LABEL_CLEAR_TOGGLES_AND_TURBO "Clear All" +#define INPUTCONFIG_LABEL_MAKE_TURBO "TempTurbo" +#define INPUTCONFIG_LABEL_MAKE_HELD "Autohold" +#define INPUTCONFIG_LABEL_MAKE_TURBO_HELD "Autofire" +#define INPUTCONFIG_LABEL_CONTROLLER_TURBO_PANEL_MOD " Turbo" + +// Hotkeys Dialog Strings +#define HOTKEYS_TITLE "Hotkey Configuration" +#define HOTKEYS_CONTROL_MOD "Ctrl + " +#define HOTKEYS_SHIFT_MOD "Shift + " +#define HOTKEYS_ALT_MOD "Alt + " +#define HOTKEYS_LABEL_BLUE "Blue means the hotkey is already mapped.\nPink means it conflicts with a game button.\nRed means it's reserved by Windows.\nA hotkey can be disabled using Escape." +#define HOTKEYS_HKCOMBO "Page %d" + +// gaming buttons and axes +#define GAMEDEVICE_JOYNUMPREFIX "(J%x)" // don't change this +#define GAMEDEVICE_JOYBUTPREFIX "#[%d]" // don't change this +#define GAMEDEVICE_XNEG "Left" +#define GAMEDEVICE_XPOS "Right" +#define GAMEDEVICE_YPOS "Up" +#define GAMEDEVICE_YNEG "Down" +#define GAMEDEVICE_POVLEFT "POV Left" +#define GAMEDEVICE_POVRIGHT "POV Right" +#define GAMEDEVICE_POVUP "POV Up" +#define GAMEDEVICE_POVDOWN "POV Down" +#define GAMEDEVICE_POVDNLEFT "POV Dn Left" +#define GAMEDEVICE_POVDNRIGHT "POV Dn Right" +#define GAMEDEVICE_POVUPLEFT "POV Up Left" +#define GAMEDEVICE_POVUPRIGHT "POV Up Right" +#define GAMEDEVICE_ZPOS "Z Up" +#define GAMEDEVICE_ZNEG "Z Down" +#define GAMEDEVICE_RPOS "R Up" +#define GAMEDEVICE_RNEG "R Down" +#define GAMEDEVICE_UPOS "U Up" +#define GAMEDEVICE_UNEG "U Down" +#define GAMEDEVICE_VPOS "V Up" +#define GAMEDEVICE_VNEG "V Down" +#define GAMEDEVICE_BUTTON "Button %d" + +// gaming general +#define GAMEDEVICE_DISABLED "Disabled" + +// gaming keys +#define GAMEDEVICE_KEY "#%d" +#define GAMEDEVICE_NUMPADPREFIX "Numpad-%c" +#define GAMEDEVICE_VK_TAB "Tab" +#define GAMEDEVICE_VK_BACK "Backspace" +#define GAMEDEVICE_VK_CLEAR "Delete" +#define GAMEDEVICE_VK_RETURN "Enter" +#define GAMEDEVICE_VK_LSHIFT "LShift" +#define GAMEDEVICE_VK_RSHIFT "RShift" +#define GAMEDEVICE_VK_LCONTROL "LCtrl" +#define GAMEDEVICE_VK_RCONTROL "RCtrl" +#define GAMEDEVICE_VK_LMENU "LAlt" +#define GAMEDEVICE_VK_RMENU "RAlt" +#define GAMEDEVICE_VK_PAUSE "Pause" +#define GAMEDEVICE_VK_CAPITAL "Capslock" +#define GAMEDEVICE_VK_ESCAPE "Disabled" +#define GAMEDEVICE_VK_SPACE "Space" +#define GAMEDEVICE_VK_PRIOR "PgUp" +#define GAMEDEVICE_VK_NEXT "PgDn" +#define GAMEDEVICE_VK_HOME "Home" +#define GAMEDEVICE_VK_END "End" +#define GAMEDEVICE_VK_LEFT "Left" +#define GAMEDEVICE_VK_RIGHT "Right" +#define GAMEDEVICE_VK_UP "Up" +#define GAMEDEVICE_VK_DOWN "Down" +#define GAMEDEVICE_VK_SELECT "Select" +#define GAMEDEVICE_VK_PRINT "Print" +#define GAMEDEVICE_VK_EXECUTE "Execute" +#define GAMEDEVICE_VK_SNAPSHOT "SnapShot" +#define GAMEDEVICE_VK_INSERT "Insert" +#define GAMEDEVICE_VK_DELETE "Delete" +#define GAMEDEVICE_VK_HELP "Help" +#define GAMEDEVICE_VK_LWIN "LWinKey" +#define GAMEDEVICE_VK_RWIN "RWinKey" +#define GAMEDEVICE_VK_APPS "AppKey" +#define GAMEDEVICE_VK_MULTIPLY "Numpad *" +#define GAMEDEVICE_VK_ADD "Numpad +" +#define GAMEDEVICE_VK_SEPARATOR "Separator" +#define GAMEDEVICE_VK_OEM_1 "Semi-Colon" +#define GAMEDEVICE_VK_OEM_7 "Apostrophe" +#define GAMEDEVICE_VK_OEM_COMMA "Comma" +#define GAMEDEVICE_VK_OEM_PERIOD "Period" +#define GAMEDEVICE_VK_SUBTRACT "Numpad -" +#define GAMEDEVICE_VK_DECIMAL "Numpad ." +#define GAMEDEVICE_VK_DIVIDE "Numpad /" +#define GAMEDEVICE_VK_NUMLOCK "Num-lock" +#define GAMEDEVICE_VK_SCROLL "Scroll-lock" +#define GAMEDEVICE_VK_OEM_MINUS "-" +#define GAMEDEVICE_VK_OEM_PLUS "=" +#define GAMEDEVICE_VK_SHIFT "Shift" +#define GAMEDEVICE_VK_CONTROL "Control" +#define GAMEDEVICE_VK_MENU "Alt" +#define GAMEDEVICE_VK_OEM_4 "[" +#define GAMEDEVICE_VK_OEM_6 "]" +#define GAMEDEVICE_VK_OEM_5 "\\" +#define GAMEDEVICE_VK_OEM_2 "/" +#define GAMEDEVICE_VK_OEM_3 "`" +#define GAMEDEVICE_VK_F1 "F1" +#define GAMEDEVICE_VK_F2 "F2" +#define GAMEDEVICE_VK_F3 "F3" +#define GAMEDEVICE_VK_F4 "F4" +#define GAMEDEVICE_VK_F5 "F5" +#define GAMEDEVICE_VK_F6 "F6" +#define GAMEDEVICE_VK_F7 "F7" +#define GAMEDEVICE_VK_F8 "F8" +#define GAMEDEVICE_VK_F9 "F9" +#define GAMEDEVICE_VK_F10 "F10" +#define GAMEDEVICE_VK_F11 "F11" +#define GAMEDEVICE_VK_F12 "F12" +#define BUTTON_OK "&OK" +#define BUTTON_CANCEL "&Cancel" + +static TCHAR szClassName[] = _T("InputCustom"); +static TCHAR szHotkeysClassName[] = _T("InputCustomHot"); +static TCHAR szGuitarClassName[] = _T("InputCustomGuitar"); + +static LRESULT CALLBACK InputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +static LRESULT CALLBACK HotInputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +static LRESULT CALLBACK GuitarInputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + +SJoyState Joystick [16]; +SJoyState JoystickF [16]; +SJoypad ToggleJoypadStorage[8]; +SJoypad TurboToggleJoypadStorage[8]; +u32 joypads [8]; + +//the main input configuration: +SJoypad DefaultJoypad[16] = { + { + true, /* Joypad 1 enabled */ + VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, /* Left, Right, Up, Down */ + 0, 0, 0, 0, /* Left_Up, Left_Down, Right_Up, Right_Down */ + VK_RETURN, VK_RSHIFT, /* Start, Select */ + 0, 0, /* Lid, Debug */ + 'X', 'Z', /* A B */ + 'S', 'A', /* X Y */ + 'Q', 'W' /* L R */ + }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +}; + +SJoypad Joypad[16]; + +SGuitar DefaultGuitar = { false, 'E', 'R', 'T', 'Y' }; + +SGuitar Guitar; +u8 guitarState = 0; + +extern volatile BOOL paused; + +#define MAXKEYPAD 15 + +#define WM_CUSTKEYDOWN (WM_USER+50) +#define WM_CUSTKEYUP (WM_USER+51) + +#define NUM_HOTKEY_CONTROLS 20 + +#define COUNT(a) (sizeof (a) / sizeof (a[0])) + +const int IDC_LABEL_HK_Table[NUM_HOTKEY_CONTROLS] = { + IDC_LABEL_HK1 , IDC_LABEL_HK2 , IDC_LABEL_HK3 , IDC_LABEL_HK4 , IDC_LABEL_HK5 , + IDC_LABEL_HK6 , IDC_LABEL_HK7 , IDC_LABEL_HK8 , IDC_LABEL_HK9 , IDC_LABEL_HK10, + IDC_LABEL_HK11, IDC_LABEL_HK12, IDC_LABEL_HK13, IDC_LABEL_HK14, IDC_LABEL_HK15, + IDC_LABEL_HK16, IDC_LABEL_HK17, IDC_LABEL_HK18, IDC_LABEL_HK19, IDC_LABEL_HK20, +}; +const int IDC_HOTKEY_Table[NUM_HOTKEY_CONTROLS] = { + IDC_HOTKEY1 , IDC_HOTKEY2 , IDC_HOTKEY3 , IDC_HOTKEY4 , IDC_HOTKEY5 , + IDC_HOTKEY6 , IDC_HOTKEY7 , IDC_HOTKEY8 , IDC_HOTKEY9 , IDC_HOTKEY10, + IDC_HOTKEY11, IDC_HOTKEY12, IDC_HOTKEY13, IDC_HOTKEY14, IDC_HOTKEY15, + IDC_HOTKEY16, IDC_HOTKEY17, IDC_HOTKEY18, IDC_HOTKEY19, IDC_HOTKEY20, +}; + +typedef char TcDIBuf[512]; + +TcDIBuf cDIBuf; +LPDIRECTINPUT8 pDI; +LPDIRECTINPUTDEVICE8 pJoystick; +DIDEVCAPS DIJoycap; +LPDIRECTINPUTEFFECT pEffect; +char JoystickName[255]; +BOOL Feedback; + + +static LPDIRECTINPUT8 tmp_pDI = NULL; +static BOOL tmp_Feedback = FALSE; +static char tmp_device_name[255] = { 0 }; +static LPDIRECTINPUTDEVICE8 tmp_Device = NULL; +static LPDIRECTINPUTDEVICE8 tmp_Joystick = NULL; + +BOOL CALLBACK EnumCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef) +{ + if ( FAILED( tmp_pDI->CreateDevice(lpddi->guidInstance, &tmp_Device, NULL) ) ) + { + tmp_Device = NULL; + return DIENUM_CONTINUE; + } + + strcpy(tmp_device_name, lpddi->tszProductName); + if (lpddi->guidFFDriver.Data1) tmp_Feedback = TRUE; + return DIENUM_STOP; +} + + +LPDIRECTINPUTDEVICE8 EnumDevices(LPDIRECTINPUT8 pDI) +{ + tmp_pDI = pDI; + tmp_Feedback = FALSE; + memset(tmp_device_name, 0, 255); + if( FAILED( pDI->EnumDevices(DI8DEVCLASS_GAMECTRL, + EnumCallback, + NULL, + DIEDFL_ATTACHEDONLY) ) ) + return NULL; + Feedback = tmp_Feedback; + strcpy(JoystickName, tmp_device_name); + return tmp_Device; +} + +BOOL CALLBACK EnumObjects(const DIDEVICEOBJECTINSTANCE* pdidoi,VOID* pContext) +{ + if( pdidoi->dwType & DIDFT_AXIS ) + { + DIPROPRANGE diprg; + diprg.diph.dwSize = sizeof(DIPROPRANGE); + diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER); + diprg.diph.dwHow = DIPH_BYID; + diprg.diph.dwObj = pdidoi->dwType; + diprg.lMin = -10000; + diprg.lMax = 10000; + + if( FAILED(tmp_Joystick->SetProperty(DIPROP_RANGE, &diprg.diph)) ) + return DIENUM_STOP; + } + return DIENUM_CONTINUE; +} + +static void ReadControl(const char* name, WORD& output) +{ + UINT temp; + temp = GetPrivateProfileInt("Controls",name,-1,IniName); + if(temp != -1) { + output = temp; + } +} + +static void ReadHotkey(const char* name, WORD& output) +{ + UINT temp; + temp = GetPrivateProfileInt("Hotkeys",name,-1,IniName); + if(temp != -1) { + output = temp; + } +} + +static void ReadGuitarControl(const char* name, WORD& output) +{ + UINT temp; + temp = GetPrivateProfileInt("GBAslot.GuitarGrip",name,-1,IniName); + if(temp != -1) { + output = temp; + } +} + +static void LoadHotkeyConfig() +{ + SCustomKey *key = &CustomKeys.key(0); + + while (!IsLastCustomKey(key)) { + ReadHotkey(key->code,key->key); + std::string modname = (std::string)key->code + (std::string)" MOD"; + ReadHotkey(modname.c_str(),key->modifiers); + key++; + } +} + +static void SaveHotkeyConfig() +{ + SCustomKey *key = &CustomKeys.key(0); + + while (!IsLastCustomKey(key)) { + WritePrivateProfileInt("Hotkeys",(char*)key->code,key->key,IniName); + std::string modname = (std::string)key->code + (std::string)" MOD"; + WritePrivateProfileInt("Hotkeys",(char*)modname.c_str(),key->modifiers,IniName); + key++; + } +} + +static void LoadGuitarConfig() +{ + memcpy(&Guitar,&DefaultGuitar,sizeof(Guitar)); + + //Guitar.Enabled = true; +#define DO(X) ReadControl(#X,Guitar.X); + DO(GREEN); + DO(RED); + DO(YELLOW); + DO(BLUE); +#undef DO +} + +static void LoadInputConfig() +{ + memcpy(&Joypad,&DefaultJoypad,sizeof(Joypad)); + + //read from configuration file + Joypad[0].Enabled = true; +#define DO(X) ReadControl(#X,Joypad[0] . X); + DO(Left); DO(Right); DO(Up); DO(Down); + DO(Left_Up); DO(Left_Down); DO(Right_Up); DO(Right_Down); + DO(Start); DO(Select); + DO(Lid); DO(Debug); + DO(A); DO(B); DO(X); DO(Y); + DO(L); DO(R); +#undef DO +} + +static void WriteControl(char* name, WORD val) +{ + WritePrivateProfileInt("Controls",name,val,IniName); +} + +static void SaveInputConfig() +{ +#define DO(X) WriteControl(#X,Joypad[0] . X); + DO(Left); DO(Right); DO(Up); DO(Down); + DO(Left_Up); DO(Left_Down); DO(Right_Up); DO(Right_Down); + DO(Start); DO(Select); + DO(Lid); DO(Debug); + DO(A); DO(B); DO(X); DO(Y); + DO(L); DO(R); +#undef DO +} + +BOOL di_init() +{ + HWND hParentWnd = MainWindow->getHWnd(); + + pDI = NULL; + pJoystick = NULL; + Feedback = FALSE; + memset(cDIBuf, 0, sizeof(cDIBuf)); + memset(JoystickName, 0, sizeof(JoystickName)); + + if(FAILED(DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&pDI,NULL))) + return FALSE; + + + pJoystick = EnumDevices(pDI); + + if (pJoystick) + { + if(!FAILED(pJoystick->SetDataFormat(&c_dfDIJoystick2))) + { + if(FAILED(pJoystick->SetCooperativeLevel(hParentWnd,DISCL_BACKGROUND|DISCL_EXCLUSIVE))) + { + pJoystick->Release(); + pJoystick = NULL; + } + else + { + tmp_Joystick = pJoystick; + pJoystick->EnumObjects(::EnumObjects, (VOID*)hParentWnd, DIDFT_ALL); + memset(&DIJoycap,0,sizeof(DIDEVCAPS)); + DIJoycap.dwSize=sizeof(DIDEVCAPS); + pJoystick->GetCapabilities(&DIJoycap); + } + } + else + { + pJoystick->Release(); + pJoystick = NULL; + } + } + + if (pJoystick) + { + DIPROPDWORD dipdw; + dipdw.diph.dwSize = sizeof(DIPROPDWORD); + dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); + dipdw.diph.dwObj = 0; + dipdw.diph.dwHow = DIPH_DEVICE; + dipdw.dwData = 0; + if ( !FAILED( pJoystick->SetProperty(DIPROP_AUTOCENTER, &dipdw.diph) ) ) + { + DWORD rgdwAxes[1] = { DIJOFS_Y }; + LONG rglDirection[2] = { 0 }; + DICONSTANTFORCE cf = { 0 }; + DIEFFECT eff; + + cf.lMagnitude = (DI_FFNOMINALMAX * 100); + + memset(&eff, 0, sizeof(eff)); + eff.dwSize = sizeof(DIEFFECT); + eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS; + eff.dwDuration = INFINITE; + eff.dwSamplePeriod = 0; + eff.dwGain = DI_FFNOMINALMAX; + eff.dwTriggerButton = DIEB_NOTRIGGER; + eff.dwTriggerRepeatInterval = 0; + eff.cAxes = 1; + eff.rgdwAxes = rgdwAxes; + eff.rglDirection = rglDirection; + eff.lpEnvelope = 0; + eff.cbTypeSpecificParams = sizeof( DICONSTANTFORCE ); + eff.lpvTypeSpecificParams = &cf; + eff.dwStartDelay = 0; + + if( FAILED( pJoystick->CreateEffect(GUID_ConstantForce, &eff, &pEffect, NULL) ) ) + Feedback = FALSE; + } + else + Feedback = FALSE; + } + + INFO("DirectX Input: \n"); + if (pJoystick != NULL) + { + INFO(" - gamecontrol successfully inited: %s\n", JoystickName); + if (Feedback) INFO("\t\t\t\t (with FeedBack support)\n"); + } + + paused = FALSE; + + return TRUE; +} + +BOOL JoystickEnabled() +{ + return (pJoystick==NULL?FALSE:TRUE); +} + + +HWND funky; +//WPARAM tid; + +// +void JoystickChanged( short ID, short Movement) +{ + // don't allow two changes to happen too close together in time + { + static bool first = true; + static DWORD lastTime = 0; + if(first || timeGetTime() - lastTime > 300) // 0.3 seconds + { + first = false; + lastTime = timeGetTime(); + } + else + { + return; // too soon after last change + } + } + + WORD JoyKey; + + JoyKey = 0x8000; + JoyKey |= (WORD)(ID << 8); + JoyKey |= Movement; + SendMessage(funky,WM_USER+45,JoyKey,0); +// KillTimer(funky,tid); +} + +int FunkyNormalize(int cur, int min, int max) +{ + int Result = 0; + + if ((max - min) == 0) + + return (Result); + + Result = cur - min; + Result = (Result * 200) / (max - min); + Result -= 100; + + return Result; +} + + + +#define S9X_JOY_NEUTRAL 60 + +void CheckAxis (short joy, short control, int val, + int min, int max, + bool &first, bool &second) +{ + + + + if (FunkyNormalize (val, min, max) < -S9X_JOY_NEUTRAL) + + { + second = false; + if (!first) + { + JoystickChanged (joy, control); + first = true; + + } + } + else + first = false; + + if (FunkyNormalize (val, min, max) > S9X_JOY_NEUTRAL) + { + first = false; + if (!second) + { + JoystickChanged (joy, (short) (control + 1)); + second = true; + } + } + else + second = false; +} + + +void CheckAxis_game (int val, int min, int max, bool &first, bool &second) +{ + if (FunkyNormalize (val, min, max) < -S9X_JOY_NEUTRAL) + { + second = false; + first = true; + } + else + first = false; + + if (FunkyNormalize (val, min, max) > S9X_JOY_NEUTRAL) + { + first = false; + second = true; + } + else + second = false; +} + +void S9xUpdateJoyState() +{ + memset(&Joystick[0],0,sizeof(Joystick[0])); + + int C = 0; + if (pJoystick) + { + DIJOYSTATE2 JoyStatus; + + HRESULT hr=pJoystick->Poll(); + if (FAILED(hr)) + pJoystick->Acquire(); + else + { + hr=pJoystick->GetDeviceState(sizeof(JoyStatus),&JoyStatus); + if (FAILED(hr)) hr=pJoystick->Acquire(); + else + { + CheckAxis_game(JoyStatus.lX,-10000,10000,Joystick[0].Left,Joystick[0].Right); + CheckAxis_game(JoyStatus.lY,-10000,10000,Joystick[0].Up,Joystick[0].Down); + + switch (JoyStatus.rgdwPOV[0]) + { + case JOY_POVBACKWARD: + Joystick[C].PovDown = true; + break; + case 4500: + //Joystick[C].PovUpRight = true; + Joystick[C].PovUp = true; + Joystick[C].PovRight = true; + break; + case 13500: + //Joystick[C].PovDnRight = true; + Joystick[C].PovDown = true; + Joystick[C].PovRight = true; + break; + case 22500: + //Joystick[C].PovDnLeft = true; + Joystick[C].PovDown = true; + Joystick[C].PovLeft = true; + break; + case 31500: + //Joystick[C].PovUpLeft = true; + Joystick[C].PovUp = true; + Joystick[C].PovLeft = true; + break; + + case JOY_POVFORWARD: + Joystick[C].PovUp = true; + break; + + case JOY_POVLEFT: + Joystick[C].PovLeft = true; + break; + + case JOY_POVRIGHT: + Joystick[C].PovRight = true; + break; + + default: + break; + } + + for(int B=0;B<128;B++) + if( JoyStatus.rgbButtons[B] ) + Joystick[C].Button[B] = true; + + } + } + } +} + +void di_poll_scan() +{ + int C = 0; + if (pJoystick) + { + DIJOYSTATE2 JoyStatus; + + HRESULT hr=pJoystick->Poll(); + if (FAILED(hr)) + pJoystick->Acquire(); + else + { + hr=pJoystick->GetDeviceState(sizeof(JoyStatus),&JoyStatus); + if (FAILED(hr)) hr=pJoystick->Acquire(); + else + { + CheckAxis(0,0,JoyStatus.lX,-10000,10000,Joystick[0].Left,Joystick[0].Right); + CheckAxis(0,2,JoyStatus.lY,-10000,10000,Joystick[0].Down,Joystick[0].Up); + + switch (JoyStatus.rgdwPOV[0]) + { + case JOY_POVBACKWARD: + if( !JoystickF[C].PovDown) + { JoystickChanged( C, 7); } + + JoystickF[C].PovDown = true; + JoystickF[C].PovUp = false; + JoystickF[C].PovLeft = false; + JoystickF[C].PovRight = false; + JoystickF[C].PovDnLeft = false; + JoystickF[C].PovDnRight = false; + JoystickF[C].PovUpLeft = false; + JoystickF[C].PovUpRight = false; + break; + case 4500: + if( !JoystickF[C].PovUpRight) + { JoystickChanged( C, 52); } + JoystickF[C].PovDown = false; + JoystickF[C].PovUp = false; + JoystickF[C].PovLeft = false; + JoystickF[C].PovRight = false; + JoystickF[C].PovDnLeft = false; + JoystickF[C].PovDnRight = false; + JoystickF[C].PovUpLeft = false; + JoystickF[C].PovUpRight = true; + break; + case 13500: + if( !JoystickF[C].PovDnRight) + { JoystickChanged( C, 50); } + JoystickF[C].PovDown = false; + JoystickF[C].PovUp = false; + JoystickF[C].PovLeft = false; + JoystickF[C].PovRight = false; + JoystickF[C].PovDnLeft = false; + JoystickF[C].PovDnRight = true; + JoystickF[C].PovUpLeft = false; + JoystickF[C].PovUpRight = false; + break; + case 22500: + if( !JoystickF[C].PovDnLeft) + { JoystickChanged( C, 49); } + JoystickF[C].PovDown = false; + JoystickF[C].PovUp = false; + JoystickF[C].PovLeft = false; + JoystickF[C].PovRight = false; + JoystickF[C].PovDnLeft = true; + JoystickF[C].PovDnRight = false; + JoystickF[C].PovUpLeft = false; + JoystickF[C].PovUpRight = false; + break; + case 31500: + if( !JoystickF[C].PovUpLeft) + { JoystickChanged( C, 51); } + JoystickF[C].PovDown = false; + JoystickF[C].PovUp = false; + JoystickF[C].PovLeft = false; + JoystickF[C].PovRight = false; + JoystickF[C].PovDnLeft = false; + JoystickF[C].PovDnRight = false; + JoystickF[C].PovUpLeft = true; + JoystickF[C].PovUpRight = false; + break; + + case JOY_POVFORWARD: + if( !JoystickF[C].PovUp) + { JoystickChanged( C, 6); } + + JoystickF[C].PovDown = false; + JoystickF[C].PovUp = true; + JoystickF[C].PovLeft = false; + JoystickF[C].PovRight = false; + JoystickF[C].PovDnLeft = false; + JoystickF[C].PovDnRight = false; + JoystickF[C].PovUpLeft = false; + JoystickF[C].PovUpRight = false; + break; + + case JOY_POVLEFT: + if( !JoystickF[C].PovLeft) + { JoystickChanged( C, 4); } + + JoystickF[C].PovDown = false; + JoystickF[C].PovUp = false; + JoystickF[C].PovLeft = true; + JoystickF[C].PovRight = false; + JoystickF[C].PovDnLeft = false; + JoystickF[C].PovDnRight = false; + JoystickF[C].PovUpLeft = false; + JoystickF[C].PovUpRight = false; + break; + + case JOY_POVRIGHT: + if( !JoystickF[C].PovRight) + { JoystickChanged( C, 5); } + + JoystickF[C].PovDown = false; + JoystickF[C].PovUp = false; + JoystickF[C].PovLeft = false; + JoystickF[C].PovRight = true; + JoystickF[C].PovDnLeft = false; + JoystickF[C].PovDnRight = false; + JoystickF[C].PovUpLeft = false; + JoystickF[C].PovUpRight = false; + break; + + default: + JoystickF[C].PovDown = false; + JoystickF[C].PovUp = false; + JoystickF[C].PovLeft = false; + JoystickF[C].PovRight = false; + JoystickF[C].PovDnLeft = false; + JoystickF[C].PovDnRight = false; + JoystickF[C].PovUpLeft = false; + JoystickF[C].PovUpRight = false; + break; + } + + for(int B=0;B<128;B++) + if( JoyStatus.rgbButtons[B] ) + { + if( !JoystickF[C].Button[B]) + { + JoystickChanged( C, (short)(8+B)); + JoystickF[C].Button[B] = true; + } + } + else + { JoystickF[C].Button[B] = false; } + + + } + } + } + +} + + +void FunkyJoyStickTimer() +{ + di_poll_scan(); +} + +void TranslateKey(WORD keyz,char *out) +{ +// sprintf(out,"%d",keyz); +// return; + + char temp[128]; + if(keyz&0x8000) + { + sprintf(out,GAMEDEVICE_JOYNUMPREFIX,((keyz>>8)&0xF)); + switch(keyz&0xFF) + { + case 0: strcat(out,GAMEDEVICE_XNEG); break; + case 1: strcat(out,GAMEDEVICE_XPOS); break; + case 2: strcat(out,GAMEDEVICE_YPOS); break; + case 3: strcat(out,GAMEDEVICE_YNEG); break; + case 4: strcat(out,GAMEDEVICE_POVLEFT); break; + case 5: strcat(out,GAMEDEVICE_POVRIGHT); break; + case 6: strcat(out,GAMEDEVICE_POVUP); break; + case 7: strcat(out,GAMEDEVICE_POVDOWN); break; + case 49: strcat(out,GAMEDEVICE_POVDNLEFT); break; + case 50: strcat(out,GAMEDEVICE_POVDNRIGHT); break; + case 51: strcat(out,GAMEDEVICE_POVUPLEFT); break; + case 52: strcat(out,GAMEDEVICE_POVUPRIGHT); break; + case 41: strcat(out,GAMEDEVICE_ZPOS); break; + case 42: strcat(out,GAMEDEVICE_ZNEG); break; + case 43: strcat(out,GAMEDEVICE_RPOS); break; + case 44: strcat(out,GAMEDEVICE_RNEG); break; + case 45: strcat(out,GAMEDEVICE_UPOS); break; + case 46: strcat(out,GAMEDEVICE_UNEG); break; + case 47: strcat(out,GAMEDEVICE_VPOS); break; + case 48: strcat(out,GAMEDEVICE_VNEG); break; + default: + if ((keyz & 0xff) > 40) + { + sprintf(temp,GAMEDEVICE_JOYBUTPREFIX,keyz&0xFF); + strcat(out,temp); + break; + } + + sprintf(temp,GAMEDEVICE_BUTTON,(keyz&0xFF)-8); + strcat(out,temp); + break; + + } + return; + } + sprintf(out,GAMEDEVICE_KEY,keyz); + if((keyz>='0' && keyz<='9')||(keyz>='A' &&keyz<='Z')) + { + sprintf(out,"%c",keyz); + return; + } + + if( keyz >= VK_NUMPAD0 && keyz <= VK_NUMPAD9) + { + + sprintf(out,GAMEDEVICE_NUMPADPREFIX,'0'+(keyz-VK_NUMPAD0)); + + return ; + } + switch(keyz) + { + case 0: sprintf(out,GAMEDEVICE_DISABLED); break; + case VK_TAB: sprintf(out,GAMEDEVICE_VK_TAB); break; + case VK_BACK: sprintf(out,GAMEDEVICE_VK_BACK); break; + case VK_CLEAR: sprintf(out,GAMEDEVICE_VK_CLEAR); break; + case VK_RETURN: sprintf(out,GAMEDEVICE_VK_RETURN); break; + case VK_LSHIFT: sprintf(out,GAMEDEVICE_VK_LSHIFT); break; + case VK_RSHIFT: sprintf(out,GAMEDEVICE_VK_RSHIFT); break; + case VK_LCONTROL: sprintf(out,GAMEDEVICE_VK_LCONTROL); break; + case VK_RCONTROL: sprintf(out,GAMEDEVICE_VK_RCONTROL); break; + case VK_LMENU: sprintf(out,GAMEDEVICE_VK_LMENU); break; + case VK_RMENU: sprintf(out,GAMEDEVICE_VK_RMENU); break; + case VK_PAUSE: sprintf(out,GAMEDEVICE_VK_PAUSE); break; + case VK_CANCEL: sprintf(out,GAMEDEVICE_VK_PAUSE); break; // the Pause key can resolve to either "Pause" or "Cancel" depending on when it's pressed + case VK_CAPITAL: sprintf(out,GAMEDEVICE_VK_CAPITAL); break; + case VK_ESCAPE: sprintf(out,GAMEDEVICE_VK_ESCAPE); break; + case VK_SPACE: sprintf(out,GAMEDEVICE_VK_SPACE); break; + case VK_PRIOR: sprintf(out,GAMEDEVICE_VK_PRIOR); break; + case VK_NEXT: sprintf(out,GAMEDEVICE_VK_NEXT); break; + case VK_HOME: sprintf(out,GAMEDEVICE_VK_HOME); break; + case VK_END: sprintf(out,GAMEDEVICE_VK_END); break; + case VK_LEFT: sprintf(out,GAMEDEVICE_VK_LEFT ); break; + case VK_RIGHT: sprintf(out,GAMEDEVICE_VK_RIGHT); break; + case VK_UP: sprintf(out,GAMEDEVICE_VK_UP); break; + case VK_DOWN: sprintf(out,GAMEDEVICE_VK_DOWN); break; + case VK_SELECT: sprintf(out,GAMEDEVICE_VK_SELECT); break; + case VK_PRINT: sprintf(out,GAMEDEVICE_VK_PRINT); break; + case VK_EXECUTE: sprintf(out,GAMEDEVICE_VK_EXECUTE); break; + case VK_SNAPSHOT: sprintf(out,GAMEDEVICE_VK_SNAPSHOT); break; + case VK_INSERT: sprintf(out,GAMEDEVICE_VK_INSERT); break; + case VK_DELETE: sprintf(out,GAMEDEVICE_VK_DELETE); break; + case VK_HELP: sprintf(out,GAMEDEVICE_VK_HELP); break; + case VK_LWIN: sprintf(out,GAMEDEVICE_VK_LWIN); break; + case VK_RWIN: sprintf(out,GAMEDEVICE_VK_RWIN); break; + case VK_APPS: sprintf(out,GAMEDEVICE_VK_APPS); break; + case VK_MULTIPLY: sprintf(out,GAMEDEVICE_VK_MULTIPLY); break; + case VK_ADD: sprintf(out,GAMEDEVICE_VK_ADD); break; + case VK_SEPARATOR: sprintf(out,GAMEDEVICE_VK_SEPARATOR); break; + case /*VK_OEM_1*/0xBA: sprintf(out,GAMEDEVICE_VK_OEM_1); break; + case /*VK_OEM_2*/0xBF: sprintf(out,GAMEDEVICE_VK_OEM_2); break; + case /*VK_OEM_3*/0xC0: sprintf(out,GAMEDEVICE_VK_OEM_3); break; + case /*VK_OEM_4*/0xDB: sprintf(out,GAMEDEVICE_VK_OEM_4); break; + case /*VK_OEM_5*/0xDC: sprintf(out,GAMEDEVICE_VK_OEM_5); break; + case /*VK_OEM_6*/0xDD: sprintf(out,GAMEDEVICE_VK_OEM_6); break; + case /*VK_OEM_7*/0xDE: sprintf(out,GAMEDEVICE_VK_OEM_7); break; + case /*VK_OEM_COMMA*/0xBC: sprintf(out,GAMEDEVICE_VK_OEM_COMMA );break; + case /*VK_OEM_PERIOD*/0xBE: sprintf(out,GAMEDEVICE_VK_OEM_PERIOD);break; + case VK_SUBTRACT: sprintf(out,GAMEDEVICE_VK_SUBTRACT); break; + case VK_DECIMAL: sprintf(out,GAMEDEVICE_VK_DECIMAL); break; + case VK_DIVIDE: sprintf(out,GAMEDEVICE_VK_DIVIDE); break; + case VK_NUMLOCK: sprintf(out,GAMEDEVICE_VK_NUMLOCK); break; + case VK_SCROLL: sprintf(out,GAMEDEVICE_VK_SCROLL); break; + case /*VK_OEM_MINUS*/0xBD: sprintf(out,GAMEDEVICE_VK_OEM_MINUS); break; + case /*VK_OEM_PLUS*/0xBB: sprintf(out,GAMEDEVICE_VK_OEM_PLUS); break; + case VK_SHIFT: sprintf(out,GAMEDEVICE_VK_SHIFT); break; + case VK_CONTROL: sprintf(out,GAMEDEVICE_VK_CONTROL); break; + case VK_MENU: sprintf(out,GAMEDEVICE_VK_MENU); break; + case VK_F1: sprintf(out,GAMEDEVICE_VK_F1); break; + case VK_F2: sprintf(out,GAMEDEVICE_VK_F2); break; + case VK_F3: sprintf(out,GAMEDEVICE_VK_F3); break; + case VK_F4: sprintf(out,GAMEDEVICE_VK_F4); break; + case VK_F5: sprintf(out,GAMEDEVICE_VK_F5); break; + case VK_F6: sprintf(out,GAMEDEVICE_VK_F6); break; + case VK_F7: sprintf(out,GAMEDEVICE_VK_F7); break; + case VK_F8: sprintf(out,GAMEDEVICE_VK_F8); break; + case VK_F9: sprintf(out,GAMEDEVICE_VK_F9); break; + case VK_F10: sprintf(out,GAMEDEVICE_VK_F10); break; + case VK_F11: sprintf(out,GAMEDEVICE_VK_F11); break; + case VK_F12: sprintf(out,GAMEDEVICE_VK_F12); break; + } + + return ; + + + +} + +bool IsReserved (WORD Key, int modifiers) +{ + // keys that do other stuff in Windows + if(Key == VK_CAPITAL || Key == VK_NUMLOCK || Key == VK_SCROLL || Key == VK_SNAPSHOT + || Key == VK_LWIN || Key == VK_RWIN || Key == VK_APPS || Key == /*VK_SLEEP*/0x5F + || (Key == VK_F4 && (modifiers & CUSTKEY_ALT_MASK) != 0)) // alt-f4 (behaves unlike accelerators) + return true; + + // menu shortcuts (accelerators) -- TODO: should somehow parse GUI.Accelerators for this information + if(modifiers == CUSTKEY_CTRL_MASK + && (Key == 'O') + || modifiers == CUSTKEY_ALT_MASK + && (Key == VK_F5 || Key == VK_F7 || Key == VK_F8 || Key == VK_F9 + || Key == 'R' || Key == 'T' || Key == /*VK_OEM_4*/0xDB || Key == /*VK_OEM_6*/0xDD + || Key == 'E' || Key == 'A' || Key == VK_RETURN || Key == VK_DELETE) + || Key == VK_MENU || Key == VK_CONTROL) + return true; + + return false; +} + + +int GetNumHotKeysAssignedTo (WORD Key, int modifiers) +{ + int count = 0; + { + #define MATCHES_KEY(k) \ + (Key != 0 && Key != VK_ESCAPE \ + && ((Key == k->key && modifiers == k->modifiers) \ + || (Key == VK_SHIFT && k->modifiers & CUSTKEY_SHIFT_MASK) \ + || (Key == VK_MENU && k->modifiers & CUSTKEY_ALT_MASK) \ + || (Key == VK_CONTROL && k->modifiers & CUSTKEY_CTRL_MASK) \ + || (k->key == VK_SHIFT && modifiers & CUSTKEY_SHIFT_MASK) \ + || (k->key == VK_MENU && modifiers & CUSTKEY_ALT_MASK) \ + || (k->key == VK_CONTROL && modifiers & CUSTKEY_CTRL_MASK))) + + SCustomKey *key = &CustomKeys.key(0); + while (!IsLastCustomKey(key)) { + if (MATCHES_KEY(key)) { + count++; + } + key++; + } + + + #undef MATCHES_KEY + } + return count; +} + +int GetNumButtonsAssignedTo (WORD Key) +{ + int count = 0; + for(int J = 0; J < 5*2; J++) + { + // don't want to report conflicts with disabled keys + if(!Joypad[J%5].Enabled || Key == 0 || Key == VK_ESCAPE) + continue; + + if(Key == Joypad[J].Left) count++; + if(Key == Joypad[J].Right) count++; + if(Key == Joypad[J].Left_Up) count++; + if(Key == Joypad[J].Left_Down) count++; + if(Key == Joypad[J].Right_Up) count++; + if(Key == Joypad[J].Right_Down) count++; + if(Key == Joypad[J].Up) count++; + if(Key == Joypad[J].Down) count++; + if(Key == Joypad[J].Start) count++; + if(Key == Joypad[J].Select) count++; + if(Key == Joypad[J].A) count++; + if(Key == Joypad[J].B) count++; + if(Key == Joypad[J].X) count++; + if(Key == Joypad[J].Y) count++; + if(Key == Joypad[J].L) count++; + if(Key == Joypad[J].R) count++; + if(Key == Joypad[J].Lid) count++; + if(Key == Joypad[J].Debug) count++; + } + return count; +} + +COLORREF CheckButtonKey( WORD Key) +{ + COLORREF red,magenta,blue,white; + red =RGB(255,0,0); + magenta =RGB(255,0,255); + blue = RGB(0,0,255); + white = RGB(255,255,255); + + // Check for conflict with reserved windows keys + if(IsReserved(Key,0)) + return red; + + // Check for conflict with Snes9X hotkeys + if(GetNumHotKeysAssignedTo(Key,0) > 0) + return magenta; + + // Check for duplicate button keys + if(GetNumButtonsAssignedTo(Key) > 1) + return blue; + + return white; +} + +COLORREF CheckHotKey( WORD Key, int modifiers) +{ + COLORREF red,magenta,blue,white; + red =RGB(255,0,0); + magenta =RGB(255,0,255); + blue = RGB(0,0,255); + white = RGB(255,255,255); + + // Check for conflict with reserved windows keys + if(IsReserved(Key,modifiers)) + return red; + + // Check for conflict with button keys + if(modifiers == 0 && GetNumButtonsAssignedTo(Key) > 0) + return magenta; + + // Check for duplicate Snes9X hotkeys + if(GetNumHotKeysAssignedTo(Key,modifiers) > 1) + return blue; + + return white; +} + +static void InitCustomControls() +{ + + WNDCLASSEX wc; + + wc.cbSize = sizeof(wc); + wc.lpszClassName = szClassName; + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = InputCustomWndProc; + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hIcon = 0; + wc.lpszMenuName = 0; + wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); + wc.style = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = sizeof(InputCust *); + wc.hIconSm = 0; + + + RegisterClassEx(&wc); + + wc.cbSize = sizeof(wc); + wc.lpszClassName = szHotkeysClassName; + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = HotInputCustomWndProc; + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hIcon = 0; + wc.lpszMenuName = 0; + wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); + wc.style = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = sizeof(InputCust *); + wc.hIconSm = 0; + + + RegisterClassEx(&wc); + + wc.cbSize = sizeof(wc); + wc.lpszClassName = szGuitarClassName; + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = GuitarInputCustomWndProc; + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hIcon = 0; + wc.lpszMenuName = 0; + wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); + wc.style = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = sizeof(InputCust *); + wc.hIconSm = 0; + + + RegisterClassEx(&wc); +} + +InputCust * GetInputCustom(HWND hwnd) +{ + return (InputCust *)GetWindowLong(hwnd, 0); +} + +void SetInputCustom(HWND hwnd, InputCust *icp) +{ + SetWindowLong(hwnd, 0, (LONG)icp); +} + +LRESULT InputCustom_OnPaint(InputCust *ccp, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + HANDLE hOldFont; + TCHAR szText[200]; + RECT rect; + SIZE sz; + int x,y; + + // Get a device context for this window + hdc = BeginPaint(ccp->hwnd, &ps); + + // Set the font we are going to use + hOldFont = SelectObject(hdc, ccp->hFont); + + // Set the text colours + SetTextColor(hdc, ccp->crForeGnd); + SetBkColor (hdc, ccp->crBackGnd); + + // Find the text to draw + GetWindowText(ccp->hwnd, szText, sizeof(szText)); + + // Work out where to draw + GetClientRect(ccp->hwnd, &rect); + + + // Find out how big the text will be + GetTextExtentPoint32(hdc, szText, lstrlen(szText), &sz); + + // Center the text + x = (rect.right - sz.cx) / 2; + y = (rect.bottom - sz.cy) / 2; + + // Draw the text + ExtTextOut(hdc, x, y, ETO_OPAQUE, &rect, szText, lstrlen(szText), 0); + + // Restore the old font when we have finished + SelectObject(hdc, hOldFont); + + // Release the device context + EndPaint(ccp->hwnd, &ps); + + return 0; +} + +static LRESULT CALLBACK InputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + // retrieve the custom structure POINTER for THIS window + InputCust *icp = GetInputCustom(hwnd); + HWND pappy = (HWND__ *)GetWindowLongPtr(hwnd,GWL_HWNDPARENT); + funky= hwnd; + + static HWND selectedItem = NULL; + + char temp[100]; + COLORREF col; + switch(msg) + { + + case WM_GETDLGCODE: + return DLGC_WANTARROWS|DLGC_WANTALLKEYS|DLGC_WANTCHARS; + break; + + + case WM_NCCREATE: + + // Allocate a new CustCtrl structure for this window. + icp = (InputCust *) malloc( sizeof(InputCust) ); + + // Failed to allocate, stop window creation. + if(icp == NULL) return FALSE; + + // Initialize the CustCtrl structure. + icp->hwnd = hwnd; + icp->crForeGnd = GetSysColor(COLOR_WINDOWTEXT); + icp->crBackGnd = GetSysColor(COLOR_WINDOW); + icp->hFont = (HFONT__ *) GetStockObject(DEFAULT_GUI_FONT); + + // Assign the window text specified in the call to CreateWindow. + SetWindowText(hwnd, ((CREATESTRUCT *)lParam)->lpszName); + + // Attach custom structure to this window. + SetInputCustom(hwnd, icp); + + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + + selectedItem = NULL; + + SetTimer(hwnd,777,125,NULL); + + // Continue with window creation. + return TRUE; + + // Clean up when the window is destroyed. + case WM_NCDESTROY: + free(icp); + break; + case WM_PAINT: + return InputCustom_OnPaint(icp,wParam,lParam); + break; + case WM_ERASEBKGND: + return 1; + case WM_USER+45: + case WM_KEYDOWN: + TranslateKey(wParam,temp); + col = CheckButtonKey(wParam); + + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + SetWindowText(hwnd,temp); + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + SendMessage(pappy,WM_USER+43,wParam,(LPARAM)hwnd); + + break; + case WM_USER+44: + + TranslateKey(wParam,temp); + if(IsWindowEnabled(hwnd)) + { + col = CheckButtonKey(wParam); + } + else + { + col = RGB( 192,192,192); + } + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + SetWindowText(hwnd,temp); + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + + break; + + case WM_SETFOCUS: + { + selectedItem = hwnd; + col = RGB( 0,255,0); + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); +// tid = wParam; + + break; + } + case WM_KILLFOCUS: + { + selectedItem = NULL; + SendMessage(pappy,WM_USER+46,wParam,(LPARAM)hwnd); // refresh fields on deselect + break; + } + + case WM_TIMER: + if(hwnd == selectedItem) + { + FunkyJoyStickTimer(); + } + SetTimer(hwnd,777,125,NULL); + break; + case WM_LBUTTONDOWN: + SetFocus(hwnd); + break; + case WM_ENABLE: + COLORREF col; + if(wParam) + { + col = RGB( 255,255,255); + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + } + else + { + col = RGB( 192,192,192); + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + } + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + return true; + default: + break; + } + + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +static LRESULT CALLBACK GuitarInputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + // retrieve the custom structure POINTER for THIS window + InputCust *icp = GetInputCustom(hwnd); + HWND pappy = (HWND__ *)GetWindowLongPtr(hwnd,GWL_HWNDPARENT); + funky= hwnd; + + static HWND selectedItem = NULL; + + char temp[100]; + COLORREF col; + switch(msg) + { + + case WM_GETDLGCODE: + return DLGC_WANTARROWS|DLGC_WANTALLKEYS|DLGC_WANTCHARS; + break; + + + case WM_NCCREATE: + + // Allocate a new CustCtrl structure for this window. + icp = (InputCust *) malloc( sizeof(InputCust) ); + + // Failed to allocate, stop window creation. + if(icp == NULL) return FALSE; + + // Initialize the CustCtrl structure. + icp->hwnd = hwnd; + icp->crForeGnd = GetSysColor(COLOR_WINDOWTEXT); + icp->crBackGnd = GetSysColor(COLOR_WINDOW); + icp->hFont = (HFONT__ *) GetStockObject(DEFAULT_GUI_FONT); + + // Assign the window text specified in the call to CreateWindow. + SetWindowText(hwnd, ((CREATESTRUCT *)lParam)->lpszName); + + // Attach custom structure to this window. + SetInputCustom(hwnd, icp); + + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + + selectedItem = NULL; + + SetTimer(hwnd,777,125,NULL); + + // Continue with window creation. + return TRUE; + + // Clean up when the window is destroyed. + case WM_NCDESTROY: + free(icp); + break; + case WM_PAINT: + return InputCustom_OnPaint(icp,wParam,lParam); + break; + case WM_ERASEBKGND: + return 1; + case WM_USER+45: + case WM_KEYDOWN: + TranslateKey(wParam,temp); + col = CheckButtonKey(wParam); + + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + SetWindowText(hwnd,temp); + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + SendMessage(pappy,WM_USER+43,wParam,(LPARAM)hwnd); + + break; + case WM_USER+44: + + TranslateKey(wParam,temp); + if(IsWindowEnabled(hwnd)) + { + col = CheckButtonKey(wParam); + } + else + { + col = RGB( 192,192,192); + } + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + SetWindowText(hwnd,temp); + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + + break; + + case WM_SETFOCUS: + { + selectedItem = hwnd; + col = RGB( 0,255,0); + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); +// tid = wParam; + + break; + } + case WM_KILLFOCUS: + { + selectedItem = NULL; + SendMessage(pappy,WM_USER+46,wParam,(LPARAM)hwnd); // refresh fields on deselect + break; + } + + case WM_TIMER: + if(hwnd == selectedItem) + { + FunkyJoyStickTimer(); + } + SetTimer(hwnd,777,125,NULL); + break; + case WM_LBUTTONDOWN: + SetFocus(hwnd); + break; + case WM_ENABLE: + COLORREF col; + if(wParam) + { + col = RGB( 255,255,255); + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + } + else + { + col = RGB( 192,192,192); + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + } + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + return true; + default: + break; + } + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +static void TranslateKeyWithModifiers(int wParam, int modifiers, char * outStr) +{ + + // if the key itself is a modifier, special case output: + if(wParam == VK_SHIFT) + strcpy(outStr, "Shift"); + else if(wParam == VK_MENU) + strcpy(outStr, "Alt"); + else if(wParam == VK_CONTROL) + strcpy(outStr, "Control"); + else + { + // otherwise, prepend the modifier(s) + if(wParam != VK_ESCAPE && wParam != 0) + { + if((modifiers & CUSTKEY_CTRL_MASK) != 0) + { + sprintf(outStr,HOTKEYS_CONTROL_MOD); + outStr += strlen(HOTKEYS_CONTROL_MOD); + } + if((modifiers & CUSTKEY_ALT_MASK) != 0) + { + sprintf(outStr,HOTKEYS_ALT_MOD); + outStr += strlen(HOTKEYS_ALT_MOD); + } + if((modifiers & CUSTKEY_SHIFT_MASK) != 0) + { + sprintf(outStr,HOTKEYS_SHIFT_MOD); + outStr += strlen(HOTKEYS_SHIFT_MOD); + } + } + + // and append the translated non-modifier key + TranslateKey(wParam,outStr); + } +} + +static bool keyPressLock = false; + +static LRESULT CALLBACK HotInputCustomWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + // retrieve the custom structure POINTER for THIS window + InputCust *icp = GetInputCustom(hwnd); + HWND pappy = (HWND__ *)GetWindowLongPtr(hwnd,GWL_HWNDPARENT); + funky= hwnd; + + static HWND selectedItem = NULL; + + char temp[100]; + COLORREF col; + switch(msg) + { + + case WM_GETDLGCODE: + return DLGC_WANTARROWS|DLGC_WANTALLKEYS|DLGC_WANTCHARS; + break; + + + case WM_NCCREATE: + + // Allocate a new CustCtrl structure for this window. + icp = (InputCust *) malloc( sizeof(InputCust) ); + + // Failed to allocate, stop window creation. + if(icp == NULL) return FALSE; + + // Initialize the CustCtrl structure. + icp->hwnd = hwnd; + icp->crForeGnd = GetSysColor(COLOR_WINDOWTEXT); + icp->crBackGnd = GetSysColor(COLOR_WINDOW); + icp->hFont = (HFONT__ *) GetStockObject(DEFAULT_GUI_FONT); + + // Assign the window text specified in the call to CreateWindow. + SetWindowText(hwnd, ((CREATESTRUCT *)lParam)->lpszName); + + // Attach custom structure to this window. + SetInputCustom(hwnd, icp); + + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + + keyPressLock = false; + + selectedItem = NULL; + + SetTimer(hwnd,747,125,NULL); + + // Continue with window creation. + return TRUE; + + // Clean up when the window is destroyed. + case WM_NCDESTROY: + free(icp); + break; + case WM_PAINT: + return InputCustom_OnPaint(icp,wParam,lParam); + break; + case WM_ERASEBKGND: + return 1; +/* + case WM_KEYUP: + { + int count = 0; + for(int i=0;i<256;i++) + if(GetAsyncKeyState(i) & 1) + count++; + + if(count < 2) + { + int p = count; + } + if(count < 1) + { + int p = count; + } + + TranslateKey(wParam,temp); + col = CheckButtonKey(wParam); + + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + SetWindowText(hwnd,temp); + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + SendMessage(pappy,WM_USER+43,wParam,(LPARAM)hwnd); + } + break; +*/ + case WM_SYSKEYDOWN: + case WM_KEYDOWN: + + { + int count = 0; + for(int i=2;i<256;i++) + { + if(i >= VK_LSHIFT && i <= VK_RMENU) + continue; + if(GetAsyncKeyState(i) & 1) + count++; + } + + if(count <= 1) + { + keyPressLock = false; + } + } + + // no break + + case WM_USER+45: + // assign a hotkey: + { + // don't assign pure modifiers on key-down (they're assigned on key-up) + if(wParam == VK_SHIFT || wParam == VK_MENU || wParam == VK_CONTROL) + break; + + int modifiers = 0; + if(GetAsyncKeyState(VK_MENU)) + modifiers |= CUSTKEY_ALT_MASK; + if(GetAsyncKeyState(VK_CONTROL)) + modifiers |= CUSTKEY_CTRL_MASK; + if(GetAsyncKeyState(VK_SHIFT)) + modifiers |= CUSTKEY_SHIFT_MASK; + + TranslateKeyWithModifiers(wParam, modifiers, temp); + + col = CheckHotKey(wParam,modifiers); +/// if(col == RGB(255,0,0)) // un-redify +/// col = RGB(255,255,255); + + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + SetWindowText(hwnd,temp); + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + SendMessage(pappy,WM_USER+43,wParam,(LPARAM)hwnd); + + keyPressLock = true; + + } + break; + case WM_SYSKEYUP: + case WM_KEYUP: + if(!keyPressLock) + { + int count = 0; + for(int i=2;i<256;i++) + { + if(i >= VK_LSHIFT && i <= VK_RMENU) + continue; + if(GetAsyncKeyState(i) & 1) // &1 seems to solve an weird non-zero return problem, don't know why + count++; + } + if(count <= 1) + { + if(wParam == VK_SHIFT || wParam == VK_MENU || wParam == VK_CONTROL) + { + if(wParam == VK_SHIFT) + sprintf(temp, "Shift"); + if(wParam == VK_MENU) + sprintf(temp, "Alt"); + if(wParam == VK_CONTROL) + sprintf(temp, "Control"); + + col = CheckHotKey(wParam,0); + + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + SetWindowText(hwnd,temp); + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + SendMessage(pappy,WM_USER+43,wParam,(LPARAM)hwnd); + } + } + } + break; + case WM_USER+44: + + // set a hotkey field: + { + int modifiers = lParam; + + TranslateKeyWithModifiers(wParam, modifiers, temp); + + if(IsWindowEnabled(hwnd)) + { + col = CheckHotKey(wParam,modifiers); +/// if(col == RGB(255,0,0)) // un-redify +/// col = RGB(255,255,255); + } + else + { + col = RGB( 192,192,192); + } + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + SetWindowText(hwnd,temp); + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + } + break; + + case WM_SETFOCUS: + { + selectedItem = hwnd; + col = RGB( 0,255,0); + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); +// tid = wParam; + + break; + } + case WM_KILLFOCUS: + { + selectedItem = NULL; + SendMessage(pappy,WM_USER+46,wParam,(LPARAM)hwnd); // refresh fields on deselect + break; + } + + case WM_TIMER: + if(hwnd == selectedItem) + { + //FunkyJoyStickTimer(); + } + SetTimer(hwnd,747,125,NULL); + break; + case WM_LBUTTONDOWN: + SetFocus(hwnd); + break; + case WM_ENABLE: + COLORREF col; + if(wParam) + { + col = RGB( 255,255,255); + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + } + else + { + col = RGB( 192,192,192); + icp->crForeGnd = ((~col) & 0x00ffffff); + icp->crBackGnd = col; + } + InvalidateRect(icp->hwnd, NULL, FALSE); + UpdateWindow(icp->hwnd); + return true; + default: + break; + } + + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +static void set_buttoninfo(int index, HWND hDlg) +{ + SendDlgItemMessage(hDlg,IDC_UP,WM_USER+44,Joypad[index].Up,0); + SendDlgItemMessage(hDlg,IDC_LEFT,WM_USER+44,Joypad[index].Left,0); + SendDlgItemMessage(hDlg,IDC_DOWN,WM_USER+44,Joypad[index].Down,0); + SendDlgItemMessage(hDlg,IDC_RIGHT,WM_USER+44,Joypad[index].Right,0); + SendDlgItemMessage(hDlg,IDC_A,WM_USER+44,Joypad[index].A,0); + SendDlgItemMessage(hDlg,IDC_B,WM_USER+44,Joypad[index].B,0); + SendDlgItemMessage(hDlg,IDC_X,WM_USER+44,Joypad[index].X,0); + SendDlgItemMessage(hDlg,IDC_Y,WM_USER+44,Joypad[index].Y,0); + SendDlgItemMessage(hDlg,IDC_L,WM_USER+44,Joypad[index].L,0); + SendDlgItemMessage(hDlg,IDC_R,WM_USER+44,Joypad[index].R,0); + SendDlgItemMessage(hDlg,IDC_START,WM_USER+44,Joypad[index].Start,0); + SendDlgItemMessage(hDlg,IDC_SELECT,WM_USER+44,Joypad[index].Select,0); + SendDlgItemMessage(hDlg,IDC_LID,WM_USER+44,Joypad[index].Lid,0); + SendDlgItemMessage(hDlg,IDC_DEBUG,WM_USER+44,Joypad[index].Debug,0); + if(index < 5) + { + SendDlgItemMessage(hDlg,IDC_UPLEFT,WM_USER+44,Joypad[index].Left_Up,0); + SendDlgItemMessage(hDlg,IDC_UPRIGHT,WM_USER+44,Joypad[index].Right_Up,0); + SendDlgItemMessage(hDlg,IDC_DWNLEFT,WM_USER+44,Joypad[index].Left_Down,0); + SendDlgItemMessage(hDlg,IDC_DWNRIGHT,WM_USER+44,Joypad[index].Right_Down,0); + } +} + +void EnableDisableKeyFields (int index, HWND hDlg) +{ + bool enableUnTurboable; + if(index < 5) + { + SetDlgItemText(hDlg,IDC_LABEL_RIGHT,INPUTCONFIG_LABEL_RIGHT); + SetDlgItemText(hDlg,IDC_LABEL_UPLEFT,INPUTCONFIG_LABEL_UPLEFT); + SetDlgItemText(hDlg,IDC_LABEL_UPRIGHT,INPUTCONFIG_LABEL_UPRIGHT); + SetDlgItemText(hDlg,IDC_LABEL_DOWNRIGHT,INPUTCONFIG_LABEL_DOWNRIGHT); + SetDlgItemText(hDlg,IDC_LABEL_UP,INPUTCONFIG_LABEL_UP); + SetDlgItemText(hDlg,IDC_LABEL_LEFT,INPUTCONFIG_LABEL_LEFT); + SetDlgItemText(hDlg,IDC_LABEL_DOWN,INPUTCONFIG_LABEL_DOWN); + SetDlgItemText(hDlg,IDC_LABEL_DOWNLEFT,INPUTCONFIG_LABEL_DOWNLEFT); + enableUnTurboable = true; + } + else + { + SetDlgItemText(hDlg,IDC_LABEL_UP,INPUTCONFIG_LABEL_MAKE_TURBO); + SetDlgItemText(hDlg,IDC_LABEL_LEFT,INPUTCONFIG_LABEL_MAKE_HELD); + SetDlgItemText(hDlg,IDC_LABEL_DOWN,INPUTCONFIG_LABEL_MAKE_TURBO_HELD); + SetDlgItemText(hDlg,IDC_LABEL_RIGHT,INPUTCONFIG_LABEL_CLEAR_TOGGLES_AND_TURBO); + SetDlgItemText(hDlg,IDC_LABEL_UPLEFT,INPUTCONFIG_LABEL_UNUSED); + SetDlgItemText(hDlg,IDC_LABEL_UPRIGHT,INPUTCONFIG_LABEL_UNUSED); + SetDlgItemText(hDlg,IDC_LABEL_DOWNLEFT,INPUTCONFIG_LABEL_UNUSED); + SetDlgItemText(hDlg,IDC_LABEL_DOWNRIGHT,INPUTCONFIG_LABEL_UNUSED); + SetDlgItemText(hDlg,IDC_UPLEFT,INPUTCONFIG_LABEL_UNUSED); + SetDlgItemText(hDlg,IDC_UPRIGHT,INPUTCONFIG_LABEL_UNUSED); + SetDlgItemText(hDlg,IDC_DWNLEFT,INPUTCONFIG_LABEL_UNUSED); + SetDlgItemText(hDlg,IDC_DWNRIGHT,INPUTCONFIG_LABEL_UNUSED); + enableUnTurboable = false; + } + + EnableWindow(GetDlgItem(hDlg,IDC_UPLEFT), false); + EnableWindow(GetDlgItem(hDlg,IDC_UPRIGHT), false); + EnableWindow(GetDlgItem(hDlg,IDC_DWNRIGHT), false); + EnableWindow(GetDlgItem(hDlg,IDC_DWNLEFT), false); + EnableWindow(GetDlgItem(hDlg,IDC_DEBUG), false); + EnableWindow(GetDlgItem(hDlg,IDC_LID), true); +} + +INT_PTR CALLBACK DlgInputConfig(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + char temp[256]; + short C; + int i, which; + static int index=0; + + + static SJoypad savepad[10]; + + + //HBRUSH g_hbrBackground; + +switch(msg) + { + case WM_INITDIALOG: + //if(DirectX.Clipped) S9xReRefresh(); + SetWindowText(hDlg,INPUTCONFIG_TITLE); + //SetDlgItemText(hDlg,IDC_JPTOGGLE,INPUTCONFIG_JPTOGGLE); + SetDlgItemText(hDlg,IDOK,BUTTON_OK); + SetDlgItemText(hDlg,IDCANCEL,BUTTON_CANCEL); +/// SetDlgItemText(hDlg,IDC_DIAGTOGGLE,INPUTCONFIG_DIAGTOGGLE); + SetDlgItemText(hDlg,IDC_LABEL_UP,INPUTCONFIG_LABEL_UP); + SetDlgItemText(hDlg,IDC_LABEL_DOWN,INPUTCONFIG_LABEL_DOWN); + SetDlgItemText(hDlg,IDC_LABEL_LEFT,INPUTCONFIG_LABEL_LEFT); + SetDlgItemText(hDlg,IDC_LABEL_A,INPUTCONFIG_LABEL_A); + SetDlgItemText(hDlg,IDC_LABEL_B,INPUTCONFIG_LABEL_B); + SetDlgItemText(hDlg,IDC_LABEL_X,INPUTCONFIG_LABEL_X); + SetDlgItemText(hDlg,IDC_LABEL_Y,INPUTCONFIG_LABEL_Y); + SetDlgItemText(hDlg,IDC_LABEL_L,INPUTCONFIG_LABEL_L); + SetDlgItemText(hDlg,IDC_LABEL_R,INPUTCONFIG_LABEL_R); + SetDlgItemText(hDlg,IDC_LABEL_START,INPUTCONFIG_LABEL_START); + SetDlgItemText(hDlg,IDC_LABEL_SELECT,INPUTCONFIG_LABEL_SELECT); + SetDlgItemText(hDlg,IDC_LABEL_UPRIGHT,INPUTCONFIG_LABEL_UPRIGHT); + SetDlgItemText(hDlg,IDC_LABEL_UPLEFT,INPUTCONFIG_LABEL_UPLEFT); + SetDlgItemText(hDlg,IDC_LABEL_DOWNRIGHT,INPUTCONFIG_LABEL_DOWNRIGHT); + SetDlgItemText(hDlg,IDC_LABEL_DOWNLEFT,INPUTCONFIG_LABEL_DOWNLEFT); + SetDlgItemText(hDlg,IDC_LABEL_BLUE,INPUTCONFIG_LABEL_BLUE); + + for(i=5;i<10;i++) + Joypad[i].Left_Up = Joypad[i].Right_Up = Joypad[i].Left_Down = Joypad[i].Right_Down = 0; + + memcpy(savepad, Joypad, 10*sizeof(SJoypad)); + + for( i=0;i<256;i++) + GetAsyncKeyState(i); + + //for( C = 0; C != 16; C ++) + // JoystickF[C].Attached = joyGetDevCaps( JOYSTICKID1+C, &JoystickF[C].Caps, sizeof( JOYCAPS)) == JOYERR_NOERROR; + + memset(&JoystickF[0],0,sizeof(JoystickF[0])); + JoystickF[0].Attached = pJoystick != NULL; + + + //for(i=1;i<6;i++) + //{ + // sprintf(temp,INPUTCONFIG_JPCOMBO,i); + // SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_ADDSTRING,0,(LPARAM)(LPCTSTR)temp); + //} + + //for(i=6;i<11;i++) + //{ + // sprintf(temp,INPUTCONFIG_JPCOMBO INPUTCONFIG_LABEL_CONTROLLER_TURBO_PANEL_MOD,i-5); + // SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_ADDSTRING,0,(LPARAM)(LPCTSTR)temp); + //} + + //SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_SETCURSEL,(WPARAM)0,0); + + //SendDlgItemMessage(hDlg,IDC_JPTOGGLE,BM_SETCHECK, Joypad[index].Enabled ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0); + //SendDlgItemMessage(hDlg,IDC_ALLOWLEFTRIGHT,BM_SETCHECK, Settings.UpAndDown ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0); + + set_buttoninfo(index,hDlg); + + EnableDisableKeyFields(index,hDlg); + + //PostMessage(hDlg,WM_COMMAND, CBN_SELCHANGE<<16, 0); + + //SetFocus(GetDlgItem(hDlg,IDC_JPCOMBO)); + + return true; + break; + case WM_CLOSE: + EndDialog(hDlg, 0); + return TRUE; + case WM_USER+46: + // refresh command, for clicking away from a selected field + //index = SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_GETCURSEL,0,0); + //if(index > 4) index += 3; // skip controllers 6, 7, and 8 in the input dialog + set_buttoninfo(index,hDlg); + return TRUE; + case WM_USER+43: + //MessageBox(hDlg,"USER+43 CAUGHT","moo",MB_OK); + which = GetDlgCtrlID((HWND)lParam); + switch(which) + { + case IDC_UP: + Joypad[index].Up = wParam; + + break; + case IDC_DOWN: + Joypad[index].Down = wParam; + + break; + case IDC_LEFT: + Joypad[index].Left = wParam; + + break; + case IDC_RIGHT: + Joypad[index].Right = wParam; + + break; + case IDC_A: + Joypad[index].A = wParam; + + break; + case IDC_B: + Joypad[index].B = wParam; + + break; + case IDC_X: + Joypad[index].X = wParam; + + break; + case IDC_Y: + Joypad[index].Y = wParam; + + break; + case IDC_L: + Joypad[index].L = wParam; + break; + + case IDC_R: + Joypad[index].R = wParam; + + break; + case IDC_SELECT: + Joypad[index].Select = wParam; + + break; + case IDC_START: + Joypad[index].Start = wParam; + + break; + case IDC_UPLEFT: + Joypad[index].Left_Up = wParam; + + break; + case IDC_UPRIGHT: + Joypad[index].Right_Up = wParam; + + break; + case IDC_DWNLEFT: + Joypad[index].Left_Down = wParam; + + break; + case IDC_DWNRIGHT: + Joypad[index].Right_Down = wParam; + + break; + case IDC_LID: + Joypad[index].Lid = wParam; + + break; + case IDC_DEBUG: + Joypad[index].Debug = wParam; + + break; + + } + + set_buttoninfo(index,hDlg); + + PostMessage(hDlg,WM_NEXTDLGCTL,0,0); + return true; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDCANCEL: + memcpy(Joypad, savepad, 10*sizeof(SJoypad)); + EndDialog(hDlg,0); + break; + + case IDOK: + //Settings.UpAndDown = IsDlgButtonChecked(hDlg, IDC_ALLOWLEFTRIGHT); + SaveInputConfig(); + EndDialog(hDlg,0); + break; + + //case IDC_JPTOGGLE: // joypad Enable toggle + // index = SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_GETCURSEL,0,0); + // if(index > 4) index += 3; // skip controllers 6, 7, and 8 in the input dialog + // Joypad[index].Enabled=IsDlgButtonChecked(hDlg,IDC_JPTOGGLE); + // set_buttoninfo(index, hDlg); // update display of conflicts + // break; + + } + switch(HIWORD(wParam)) + { + //case CBN_SELCHANGE: + // index = SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_GETCURSEL,0,0); + // SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_SETCURSEL,(WPARAM)index,0); + // if(index > 4) index += 3; // skip controllers 6, 7, and 8 in the input dialog + // if(index < 8) + // { + // SendDlgItemMessage(hDlg,IDC_JPTOGGLE,BM_SETCHECK, Joypad[index].Enabled ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0); + // EnableWindow(GetDlgItem(hDlg,IDC_JPTOGGLE),TRUE); + // } + // else + // { + // SendDlgItemMessage(hDlg,IDC_JPTOGGLE,BM_SETCHECK, Joypad[index-8].Enabled ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0); + // EnableWindow(GetDlgItem(hDlg,IDC_JPTOGGLE),FALSE); + // } + + // set_buttoninfo(index,hDlg); + + // EnableDisableKeyFields(index,hDlg); + + // break; + } + return FALSE; + + } + + return FALSE; +} + + +bool S9xGetState (WORD KeyIdent) +{ + if(KeyIdent == 0 || KeyIdent == VK_ESCAPE) // if it's the 'disabled' key, it's never pressed + return true; + + //TODO - option for background game keys + if(MainWindow->getHWnd() != GetForegroundWindow()) + return true; + + if (KeyIdent & 0x8000) // if it's a joystick 'key': + { + int j = (KeyIdent >> 8) & 15; + + //S9xUpdateJoyState(); + + switch (KeyIdent & 0xff) + { + case 0: return !Joystick [j].Left; + case 1: return !Joystick [j].Right; + case 2: return !Joystick [j].Up; + case 3: return !Joystick [j].Down; + case 4: return !Joystick [j].PovLeft; + case 5: return !Joystick [j].PovRight; + case 6: return !Joystick [j].PovUp; + case 7: return !Joystick [j].PovDown; + case 49:return !Joystick [j].PovDnLeft; + case 50:return !Joystick [j].PovDnRight; + case 51:return !Joystick [j].PovUpLeft; + case 52:return !Joystick [j].PovUpRight; + case 41:return !Joystick [j].ZUp; + case 42:return !Joystick [j].ZDown; + case 43:return !Joystick [j].RUp; + case 44:return !Joystick [j].RDown; + case 45:return !Joystick [j].UUp; + case 46:return !Joystick [j].UDown; + case 47:return !Joystick [j].VUp; + case 48:return !Joystick [j].VDown; + + default: + if ((KeyIdent & 0xff) > 40) + return true; // not pressed + + return !Joystick [j].Button [(KeyIdent & 0xff) - 8]; + } + } + + // the pause key is special, need this to catch all presses of it + // Both GetKeyState and GetAsyncKeyState cannot catch it anyway, + // so this should be handled in WM_KEYDOWN message. + if(KeyIdent == VK_PAUSE) + { + return true; // not pressed +// if(GetAsyncKeyState(VK_PAUSE)) // not &'ing this with 0x8000 is intentional and necessary +// return false; + } + + SHORT gks = GetKeyState (KeyIdent); + return ((gks & 0x80) == 0); +} + +void S9xWinScanJoypads () +{ + u32 PadState; + + S9xUpdateJoyState(); + + for (int J = 0; J < 8; J++) + { + if (Joypad [J].Enabled) + { + // toggle checks + { + PadState = 0; + PadState |= ToggleJoypadStorage[J].Left||TurboToggleJoypadStorage[J].Left ? LEFT_MASK : 0; + PadState |= ToggleJoypadStorage[J].Right||TurboToggleJoypadStorage[J].Right ? RIGHT_MASK : 0; + PadState |= ToggleJoypadStorage[J].Up||TurboToggleJoypadStorage[J].Up ? UP_MASK : 0; + PadState |= ToggleJoypadStorage[J].Down||TurboToggleJoypadStorage[J].Down ? DOWN_MASK : 0; + PadState |= ToggleJoypadStorage[J].Start||TurboToggleJoypadStorage[J].Start ? START_MASK : 0; + PadState |= ToggleJoypadStorage[J].Select||TurboToggleJoypadStorage[J].Select ? SELECT_MASK : 0; + PadState |= ToggleJoypadStorage[J].Lid||TurboToggleJoypadStorage[J].Lid ? LID_MASK : 0; + PadState |= ToggleJoypadStorage[J].Debug||TurboToggleJoypadStorage[J].Debug ? DEBUG_MASK : 0; + PadState |= ToggleJoypadStorage[J].A||TurboToggleJoypadStorage[J].A ? A_MASK : 0; + PadState |= ToggleJoypadStorage[J].B||TurboToggleJoypadStorage[J].B ? B_MASK : 0; + PadState |= ToggleJoypadStorage[J].X||TurboToggleJoypadStorage[J].X ? X_MASK : 0; + PadState |= ToggleJoypadStorage[J].Y||TurboToggleJoypadStorage[J].Y ? Y_MASK : 0; + PadState |= ToggleJoypadStorage[J].L||TurboToggleJoypadStorage[J].L ? L_MASK : 0; + PadState |= ToggleJoypadStorage[J].R||TurboToggleJoypadStorage[J].R ? R_MASK : 0; + } + // auto-hold AND regular key/joystick presses + if(S9xGetState(Joypad[J+8].Left)) + { + PadState ^= (!S9xGetState(Joypad[J].R)||!S9xGetState(Joypad[J+8].R)) ? R_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].L)||!S9xGetState(Joypad[J+8].L)) ? L_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].X)||!S9xGetState(Joypad[J+8].X)) ? X_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].A)||!S9xGetState(Joypad[J+8].A)) ? A_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Right)) ? RIGHT_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Right_Up)) ? RIGHT_MASK + UP_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Right_Down)) ? RIGHT_MASK + DOWN_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Left)) ? LEFT_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Left_Up)) ? LEFT_MASK + UP_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Left_Down)) ? LEFT_MASK + DOWN_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Down)) ? DOWN_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Up)) ? UP_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Start)||!S9xGetState(Joypad[J+8].Start)) ? START_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Select)||!S9xGetState(Joypad[J+8].Select)) ? SELECT_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Y)||!S9xGetState(Joypad[J+8].Y)) ? Y_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].B)||!S9xGetState(Joypad[J+8].B)) ? B_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Lid)||!S9xGetState(Joypad[J+8].Lid)) ? LID_MASK : 0; + PadState ^= (!S9xGetState(Joypad[J].Debug)||!S9xGetState(Joypad[J+8].Debug)) ? DEBUG_MASK : 0; + } + + bool turbofy = !S9xGetState(Joypad[J+8].Up); // All Mod for turbo + + u32 TurboMask = 0; + + //handle turbo case! (autofire / auto-fire) + if(turbofy || ((TurboMask&A_MASK))&&(PadState&A_MASK) || !S9xGetState(Joypad[J+8].A )) PadState^=(joypads[J]&A_MASK); + if(turbofy || ((TurboMask&B_MASK))&&(PadState&B_MASK) || !S9xGetState(Joypad[J+8].B )) PadState^=(joypads[J]&B_MASK); + if(turbofy || ((TurboMask&Y_MASK))&&(PadState&Y_MASK) || !S9xGetState(Joypad[J+8].Y )) PadState^=(joypads[J]&Y_MASK); + if(turbofy || ((TurboMask&X_MASK))&&(PadState&X_MASK) || !S9xGetState(Joypad[J+8].X )) PadState^=(joypads[J]&X_MASK); + if(turbofy || ((TurboMask&L_MASK))&&(PadState&L_MASK) || !S9xGetState(Joypad[J+8].L )) PadState^=(joypads[J]&L_MASK); + if(turbofy || ((TurboMask&R_MASK))&&(PadState&R_MASK) || !S9xGetState(Joypad[J+8].R )) PadState^=(joypads[J]&R_MASK); + if(turbofy || ((TurboMask&START_MASK))&&(PadState&START_MASK) || !S9xGetState(Joypad[J+8].Start )) PadState^=(joypads[J]&START_MASK); + if(turbofy || ((TurboMask&SELECT_MASK))&&(PadState&SELECT_MASK) || !S9xGetState(Joypad[J+8].Select)) PadState^=(joypads[J]&SELECT_MASK); + if(turbofy || ((TurboMask&DEBUG_MASK))&&(PadState&DEBUG_MASK) || !S9xGetState(Joypad[J+8].Debug)) PadState^=(joypads[J]&DEBUG_MASK); + if( ((TurboMask&LEFT_MASK))&&(PadState&LEFT_MASK) ) PadState^=(joypads[J]&LEFT_MASK); + if( ((TurboMask&UP_MASK))&&(PadState&UP_MASK) ) PadState^=(joypads[J]&UP_MASK); + if( ((TurboMask&RIGHT_MASK))&&(PadState&RIGHT_MASK) ) PadState^=(joypads[J]&RIGHT_MASK); + if( ((TurboMask&DOWN_MASK))&&(PadState&DOWN_MASK) ) PadState^=(joypads[J]&DOWN_MASK); + if( ((TurboMask&LID_MASK))&&(PadState&LID_MASK) ) PadState^=(joypads[J]&LID_MASK); + + if(TurboToggleJoypadStorage[J].A ) PadState^=(joypads[J]&A_MASK); + if(TurboToggleJoypadStorage[J].B ) PadState^=(joypads[J]&B_MASK); + if(TurboToggleJoypadStorage[J].Y ) PadState^=(joypads[J]&Y_MASK); + if(TurboToggleJoypadStorage[J].X ) PadState^=(joypads[J]&X_MASK); + if(TurboToggleJoypadStorage[J].L ) PadState^=(joypads[J]&L_MASK); + if(TurboToggleJoypadStorage[J].R ) PadState^=(joypads[J]&R_MASK); + if(TurboToggleJoypadStorage[J].Start ) PadState^=(joypads[J]&START_MASK); + if(TurboToggleJoypadStorage[J].Select) PadState^=(joypads[J]&SELECT_MASK); + if(TurboToggleJoypadStorage[J].Left ) PadState^=(joypads[J]&LEFT_MASK); + if(TurboToggleJoypadStorage[J].Up ) PadState^=(joypads[J]&UP_MASK); + if(TurboToggleJoypadStorage[J].Right ) PadState^=(joypads[J]&RIGHT_MASK); + if(TurboToggleJoypadStorage[J].Down ) PadState^=(joypads[J]&DOWN_MASK); + if(TurboToggleJoypadStorage[J].Lid ) PadState^=(joypads[J]&LID_MASK); + if(TurboToggleJoypadStorage[J].Debug ) PadState^=(joypads[J]&DEBUG_MASK); + //end turbo case... + + + // enforce left+right/up+down disallowance here to + // avoid recording unused l+r/u+d that will cause desyncs + // when played back with l+r/u+d is allowed + //if(!Settings.UpAndDown) + //{ + // if((PadState[1] & 2) != 0) + // PadState[1] &= ~(1); + // if((PadState[1] & 8) != 0) + // PadState[1] &= ~(4); + //} + + joypads [J] = PadState | 0x80000000; + } + else + joypads [J] = 0; + } + + // input from macro + //for (int J = 0; J < 8; J++) + //{ + // if(MacroIsEnabled(J)) + // { + // uint16 userPadState = joypads[J] & 0xFFFF; + // uint16 macroPadState = MacroInput(J); + // uint16 newPadState; + + // switch(GUI.MacroInputMode) + // { + // case MACRO_INPUT_MOV: + // newPadState = macroPadState; + // break; + // case MACRO_INPUT_OR: + // newPadState = macroPadState | userPadState; + // break; + // case MACRO_INPUT_XOR: + // newPadState = macroPadState ^ userPadState; + // break; + // default: + // newPadState = userPadState; + // break; + // } + + // PadState[0] = (uint8) ( newPadState & 0xFF); + // PadState[1] = (uint8) ((newPadState >> 8) & 0xFF); + + // // enforce left+right/up+down disallowance here to + // // avoid recording unused l+r/u+d that will cause desyncs + // // when played back with l+r/u+d is allowed + // if(!Settings.UpAndDown) + // { + // if((PadState[1] & 2) != 0) + // PadState[1] &= ~(1); + // if((PadState[1] & 8) != 0) + // PadState[1] &= ~(4); + // } + + // joypads [J] = PadState [0] | (PadState [1] << 8) | 0x80000000; + // } + //} + +//#ifdef NETPLAY_SUPPORT +// if (Settings.NetPlay) +// { +// // Send joypad position update to server +// S9xNPSendJoypadUpdate (joypads [GUI.NetplayUseJoypad1 ? 0 : NetPlay.Player-1]); +// +// // set input from network +// for (int J = 0; J < NP_MAX_CLIENTS; J++) +// joypads[J] = S9xNPGetJoypad (J); +// } +//#endif +} + +void input_feedback(BOOL enable) +{ + if (!Feedback) return; + if (!pEffect) return; + + if (enable) + pEffect->Start(2, 0); + else + pEffect->Stop(); +} + + +void input_init() +{ + InitCustomControls(); + + LoadInputConfig(); + LoadHotkeyConfig(); + LoadGuitarConfig(); + + di_init(); + FeedbackON = input_feedback; +} + +void input_process() +{ + S9xWinScanJoypads(); + + //not appropriate right now in desmume + //if (paused) return; + + bool R = joypads[0] & RIGHT_MASK; + bool L = joypads[0] & LEFT_MASK; + bool D = joypads[0] & DOWN_MASK; + bool U = joypads[0] & UP_MASK; + bool T = joypads[0] & START_MASK; + bool S = joypads[0] & SELECT_MASK; + bool B = joypads[0] & B_MASK; + bool A = joypads[0] & A_MASK; + bool Y = joypads[0] & Y_MASK; + bool X = joypads[0] & X_MASK; + bool W = joypads[0] & L_MASK; + bool E = joypads[0] & R_MASK; + bool G = joypads[0] & DEBUG_MASK; + bool F = joypads[0] & LID_MASK; + + if(AutoHoldPressed && R) AutoHold.Right ^= true; + if(AutoHoldPressed && L) AutoHold.Left ^= true; + if(AutoHoldPressed && D) AutoHold.Down ^= true; + if(AutoHoldPressed && U) AutoHold.Up ^= true; + if(AutoHoldPressed && T) AutoHold.Select ^= true; + if(AutoHoldPressed && S) AutoHold.Start ^= true; + if(AutoHoldPressed && B) AutoHold.B ^= true; + if(AutoHoldPressed && A) AutoHold.A ^= true; + if(AutoHoldPressed && Y) AutoHold.Y ^= true; + if(AutoHoldPressed && X) AutoHold.X ^= true; + if(AutoHoldPressed && W) AutoHold.L ^= true; + if(AutoHoldPressed && E) AutoHold.R ^= true; + + NDS_setPad( R, L, D, U, T, S, B, A, Y, X, W, E, G, F); + + if (Guitar.Enabled) + { + bool gG=!S9xGetState(Guitar.GREEN); + bool gR=!S9xGetState(Guitar.RED); + bool gY=!S9xGetState(Guitar.YELLOW); + bool gB=!S9xGetState(Guitar.BLUE); + guitarGrip_setKey(gG, gR, gY, gB); + } +} + +static void set_hotkeyinfo(HWND hDlg) +{ + HotkeyPage page = (HotkeyPage) SendDlgItemMessage(hDlg,IDC_HKCOMBO,CB_GETCURSEL,0,0); + SCustomKey *key = &CustomKeys.key(0); + int i = 0; + + while (!IsLastCustomKey(key) && i < NUM_HOTKEY_CONTROLS) { + if (page == key->page) { + SendDlgItemMessage(hDlg, IDC_HOTKEY_Table[i], WM_USER+44, key->key, key->modifiers); + SetDlgItemTextW(hDlg, IDC_LABEL_HK_Table[i], key->name.c_str()); + ShowWindow(GetDlgItem(hDlg, IDC_HOTKEY_Table[i]), SW_SHOW); + i++; + } + key++; + } + // disable unused controls + for (; i < NUM_HOTKEY_CONTROLS; i++) { + SendDlgItemMessage(hDlg, IDC_HOTKEY_Table[i], WM_USER+44, 0, 0); + SetDlgItemText(hDlg, IDC_LABEL_HK_Table[i], INPUTCONFIG_LABEL_UNUSED); + ShowWindow(GetDlgItem(hDlg, IDC_HOTKEY_Table[i]), SW_HIDE); + } +} + + +// DlgHotkeyConfig +INT_PTR CALLBACK DlgHotkeyConfig(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + int i, which; + static HotkeyPage page = (HotkeyPage) 0; + + + static SCustomKeys keys; + + //HBRUSH g_hbrBackground; +switch(msg) + { + case WM_PAINT: + { + PAINTSTRUCT ps; + BeginPaint (hDlg, &ps); + + EndPaint (hDlg, &ps); + } + return true; + case WM_INITDIALOG: + //if(DirectX.Clipped) S9xReRefresh(); + SetWindowText(hDlg,HOTKEYS_TITLE); + + // insert hotkey page list items + for(i = 0 ; i < NUM_HOTKEY_PAGE ; i++) + { + SendDlgItemMessage(hDlg, IDC_HKCOMBO, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)hotkeyPageTitle[i]); + } + + SendDlgItemMessage(hDlg,IDC_HKCOMBO,CB_SETCURSEL,(WPARAM)0,0); + + InitCustomKeys(&keys); + CopyCustomKeys(&keys, &CustomKeys); + for( i=0;i<256;i++) + { + GetAsyncKeyState(i); + } + + SetDlgItemText(hDlg,IDC_LABEL_BLUE,HOTKEYS_LABEL_BLUE); + + set_hotkeyinfo(hDlg); + + PostMessage(hDlg,WM_COMMAND, CBN_SELCHANGE<<16, 0); + + SetFocus(GetDlgItem(hDlg,IDC_HKCOMBO)); + + + return true; + break; + case WM_CLOSE: + EndDialog(hDlg, 0); + return TRUE; + case WM_USER+46: + // refresh command, for clicking away from a selected field + page = (HotkeyPage) SendDlgItemMessage(hDlg, IDC_HKCOMBO, CB_GETCURSEL, 0, 0); + set_hotkeyinfo(hDlg); + return TRUE; + case WM_USER+43: + { + //MessageBox(hDlg,"USER+43 CAUGHT","moo",MB_OK); + int modifiers = GetModifiers(wParam); + + page = (HotkeyPage) SendDlgItemMessage(hDlg, IDC_HKCOMBO, CB_GETCURSEL, 0, 0); + wchar_t text[256]; + + which = GetDlgCtrlID((HWND)lParam); + for (i = 0; i < NUM_HOTKEY_CONTROLS; i++) { + if (which == IDC_HOTKEY_Table[i]) + break; + } + GetDlgItemTextW(hDlg, IDC_LABEL_HK_Table[i], text, COUNT(text)); + + SCustomKey *key = &CustomKeys.key(0); + while (!IsLastCustomKey(key)) { + if (page == key->page) { + if(text == key->name) { + key->key = wParam; + key->modifiers = modifiers; + break; + } + } + key++; + } + + set_hotkeyinfo(hDlg); + PostMessage(hDlg,WM_NEXTDLGCTL,0,0); +// PostMessage(hDlg,WM_KILLFOCUS,0,0); + } + return true; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDCANCEL: + CopyCustomKeys(&CustomKeys, &keys); + EndDialog(hDlg,0); + break; + case IDOK: + SaveHotkeyConfig(); + EndDialog(hDlg,0); + break; + } + switch(HIWORD(wParam)) + { + case CBN_SELCHANGE: + page = (HotkeyPage) SendDlgItemMessage(hDlg, IDC_HKCOMBO, CB_GETCURSEL, 0, 0); + SendDlgItemMessage(hDlg, IDC_HKCOMBO, CB_SETCURSEL, (WPARAM)page, 0); + + set_hotkeyinfo(hDlg); + + SetFocus(GetDlgItem(hDlg, IDC_HKCOMBO)); + + break; + } + return FALSE; + + } + + return FALSE; +} + + +void RunInputConfig() +{ + DialogBox(hAppInst, MAKEINTRESOURCE(IDD_INPUTCONFIG), MainWindow->getHWnd(), DlgInputConfig); +} + +void RunHotkeyConfig() +{ + DialogBox(hAppInst, MAKEINTRESOURCE(IDD_KEYCUSTOM), MainWindow->getHWnd(), DlgHotkeyConfig); +} + + +/********************************************************************************** + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + + (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), + Jerremy Koot (jkoot@snes9x.com) + + (c) Copyright 2002 - 2004 Matthew Kendora + + (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) + + (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) + + (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) + + (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), + Kris Bleakley (codeviolation@hotmail.com) + + (c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net), + Nach (n-a-c-h@users.sourceforge.net), + zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2006 - 2007 nitsuja + + + BS-X C emulator code + (c) Copyright 2005 - 2006 Dreamer Nom, + zones + + C4 x86 assembler and some C emulation code + (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), + Nach, + zsKnight (zsknight@zsnes.com) + + C4 C++ code + (c) Copyright 2003 - 2006 Brad Jorsch, + Nach + + DSP-1 emulator code + (c) Copyright 1998 - 2006 _Demo_, + Andreas Naive (andreasnaive@gmail.com) + Gary Henderson, + Ivar (ivar@snes9x.com), + John Weidman, + Kris Bleakley, + Matthew Kendora, + Nach, + neviksti (neviksti@hotmail.com) + + DSP-2 emulator code + (c) Copyright 2003 John Weidman, + Kris Bleakley, + Lord Nightmare (lord_nightmare@users.sourceforge.net), + Matthew Kendora, + neviksti + + + DSP-3 emulator code + (c) Copyright 2003 - 2006 John Weidman, + Kris Bleakley, + Lancer, + z80 gaiden + + DSP-4 emulator code + (c) Copyright 2004 - 2006 Dreamer Nom, + John Weidman, + Kris Bleakley, + Nach, + z80 gaiden + + OBC1 emulator code + (c) Copyright 2001 - 2004 zsKnight, + pagefault (pagefault@zsnes.com), + Kris Bleakley, + Ported from x86 assembler to C by sanmaiwashi + + SPC7110 and RTC C++ emulator code + (c) Copyright 2002 Matthew Kendora with research by + zsKnight, + John Weidman, + Dark Force + + S-DD1 C emulator code + (c) Copyright 2003 Brad Jorsch with research by + Andreas Naive, + John Weidman + + S-RTC C emulator code + (c) Copyright 2001-2006 byuu, + John Weidman + + ST010 C++ emulator code + (c) Copyright 2003 Feather, + John Weidman, + Kris Bleakley, + Matthew Kendora + + Super FX x86 assembler emulator code + (c) Copyright 1998 - 2003 _Demo_, + pagefault, + zsKnight, + + Super FX C emulator code + (c) Copyright 1997 - 1999 Ivar, + Gary Henderson, + John Weidman + + Sound DSP emulator code is derived from SNEeSe and OpenSPC: + (c) Copyright 1998 - 2003 Brad Martin + (c) Copyright 1998 - 2006 Charles Bilyue' + + SH assembler code partly based on x86 assembler code + (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) + + 2xSaI filter + (c) Copyright 1999 - 2001 Derek Liauw Kie Fa + + HQ2x, HQ3x, HQ4x filters + (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) + + Win32 GUI code + (c) Copyright 2003 - 2006 blip, + funkyass, + Matthew Kendora, + Nach, + nitsuja + + Mac OS GUI code + (c) Copyright 1998 - 2001 John Stiles + (c) Copyright 2001 - 2007 zones + + + Specific ports contains the works of other authors. See headers in + individual files. + + + Snes9x homepage: http://www.snes9x.com + + Permission to use, copy, modify and/or distribute Snes9x in both binary + and source form, for non-commercial purposes, is hereby granted without + fee, providing that this license information and copyright notice appear + with all copies and any derived work. + + This software is provided 'as-is', without any express or implied + warranty. In no event shall the authors be held liable for any damages + arising from the use of this software or it's derivatives. + + Snes9x is freeware for PERSONAL USE only. Commercial users should + seek permission of the copyright holders first. Commercial use includes, + but is not limited to, charging money for Snes9x or software derived from + Snes9x, including Snes9x or derivatives in commercial game bundles, and/or + using Snes9x as a promotion for your commercial product. + + The copyright holders request that bug fixes and improvements to the code + should be forwarded to them so everyone can benefit from the modifications + in future versions. + + Super NES and Super Nintendo Entertainment System are trademarks of + Nintendo Co., Limited and its subsidiary companies. +**********************************************************************************/ diff --git a/desmume/src/windows/inputdx.h b/src/windows/inputdx.h similarity index 96% rename from desmume/src/windows/inputdx.h rename to src/windows/inputdx.h index 2aa559e98..491b06e8b 100644 --- a/desmume/src/windows/inputdx.h +++ b/src/windows/inputdx.h @@ -1,286 +1,286 @@ -///* This file is part of DeSmuME, derived from several files in Snes9x 1.51 which are -// licensed under the terms supplied at the end of this file (for the terms are very long!) -// Differences from that baseline version are: -// -// Copyright (C) 2009 DeSmuME team -// -// DeSmuME is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// DeSmuME is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with DeSmuME; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//*/ - - -#ifndef INPUTDX_INCLUDED -#define INPUTDX_INCLUDED - -typedef struct -{ - COLORREF crForeGnd; // Foreground text colour - COLORREF crBackGnd; // Background text colour - HFONT hFont; // The font - HWND hwnd; // The control's window handle -} InputCust; -COLORREF CheckButtonKey( WORD Key); -COLORREF CheckHotKey( WORD Key, int modifiers); -InputCust * GetInputCustom(HWND hwnd); - -#define CUSTKEY_ALT_MASK 0x01 -#define CUSTKEY_CTRL_MASK 0x02 -#define CUSTKEY_SHIFT_MASK 0x04 - -struct SJoypad { - BOOL Enabled; - WORD Left; - WORD Right; - WORD Up; - WORD Down; - WORD Left_Up; - WORD Left_Down; - WORD Right_Up; - WORD Right_Down; - WORD Start; - WORD Select; - WORD Lid; - WORD Debug; - WORD A; - WORD B; - WORD X; - WORD Y; - WORD L; - WORD R; -}; - -#define LEFT_MASK 0x0001 -#define RIGHT_MASK 0x0002 -#define UP_MASK 0x0004 -#define DOWN_MASK 0x0008 -#define START_MASK 0x0010 -#define SELECT_MASK 0x0020 -#define LID_MASK 0x0040 -#define DEBUG_MASK 0x0080 -#define A_MASK 0x0100 -#define B_MASK 0x0200 -#define X_MASK 0x0400 -#define Y_MASK 0x0800 -#define L_MASK 0x1000 -#define R_MASK 0x2000 - - -struct SJoyState{ - bool Attached; - //JOYCAPS Caps; - int Threshold; - bool Left; - bool Right; - bool Up; - bool Down; - bool PovLeft; - bool PovRight; - bool PovUp; - bool PovDown; - bool PovDnLeft; - bool PovDnRight; - bool PovUpLeft; - bool PovUpRight; - bool RUp; - bool RDown; - bool UUp; - bool UDown; - bool VUp; - bool VDown; - bool ZUp; - bool ZDown; - bool Button[32]; -}; - -extern SJoypad Joypad[16]; -extern SJoypad ToggleJoypadStorage[8]; -//extern SCustomKeys CustomKeys; -extern SJoypad TurboToggleJoypadStorage[8]; - -void RunInputConfig(); -void RunHotkeyConfig(); -void input_process(); - -struct SGuitar { - BOOL Enabled; - WORD GREEN; - WORD RED; - WORD YELLOW; - WORD BLUE; -}; - -extern SGuitar Guitar; - -#endif - - -/********************************************************************************** - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - - (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), - Jerremy Koot (jkoot@snes9x.com) - - (c) Copyright 2002 - 2004 Matthew Kendora - - (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) - - (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) - - (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) - - (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), - Kris Bleakley (codeviolation@hotmail.com) - - (c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net), - Nach (n-a-c-h@users.sourceforge.net), - zones (kasumitokoduck@yahoo.com) - - (c) Copyright 2006 - 2007 nitsuja - - - BS-X C emulator code - (c) Copyright 2005 - 2006 Dreamer Nom, - zones - - C4 x86 assembler and some C emulation code - (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), - Nach, - zsKnight (zsknight@zsnes.com) - - C4 C++ code - (c) Copyright 2003 - 2006 Brad Jorsch, - Nach - - DSP-1 emulator code - (c) Copyright 1998 - 2006 _Demo_, - Andreas Naive (andreasnaive@gmail.com) - Gary Henderson, - Ivar (ivar@snes9x.com), - John Weidman, - Kris Bleakley, - Matthew Kendora, - Nach, - neviksti (neviksti@hotmail.com) - - DSP-2 emulator code - (c) Copyright 2003 John Weidman, - Kris Bleakley, - Lord Nightmare (lord_nightmare@users.sourceforge.net), - Matthew Kendora, - neviksti - - - DSP-3 emulator code - (c) Copyright 2003 - 2006 John Weidman, - Kris Bleakley, - Lancer, - z80 gaiden - - DSP-4 emulator code - (c) Copyright 2004 - 2006 Dreamer Nom, - John Weidman, - Kris Bleakley, - Nach, - z80 gaiden - - OBC1 emulator code - (c) Copyright 2001 - 2004 zsKnight, - pagefault (pagefault@zsnes.com), - Kris Bleakley, - Ported from x86 assembler to C by sanmaiwashi - - SPC7110 and RTC C++ emulator code - (c) Copyright 2002 Matthew Kendora with research by - zsKnight, - John Weidman, - Dark Force - - S-DD1 C emulator code - (c) Copyright 2003 Brad Jorsch with research by - Andreas Naive, - John Weidman - - S-RTC C emulator code - (c) Copyright 2001-2006 byuu, - John Weidman - - ST010 C++ emulator code - (c) Copyright 2003 Feather, - John Weidman, - Kris Bleakley, - Matthew Kendora - - Super FX x86 assembler emulator code - (c) Copyright 1998 - 2003 _Demo_, - pagefault, - zsKnight, - - Super FX C emulator code - (c) Copyright 1997 - 1999 Ivar, - Gary Henderson, - John Weidman - - Sound DSP emulator code is derived from SNEeSe and OpenSPC: - (c) Copyright 1998 - 2003 Brad Martin - (c) Copyright 1998 - 2006 Charles Bilyue' - - SH assembler code partly based on x86 assembler code - (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) - - 2xSaI filter - (c) Copyright 1999 - 2001 Derek Liauw Kie Fa - - HQ2x, HQ3x, HQ4x filters - (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) - - Win32 GUI code - (c) Copyright 2003 - 2006 blip, - funkyass, - Matthew Kendora, - Nach, - nitsuja - - Mac OS GUI code - (c) Copyright 1998 - 2001 John Stiles - (c) Copyright 2001 - 2007 zones - - - Specific ports contains the works of other authors. See headers in - individual files. - - - Snes9x homepage: http://www.snes9x.com - - Permission to use, copy, modify and/or distribute Snes9x in both binary - and source form, for non-commercial purposes, is hereby granted without - fee, providing that this license information and copyright notice appear - with all copies and any derived work. - - This software is provided 'as-is', without any express or implied - warranty. In no event shall the authors be held liable for any damages - arising from the use of this software or it's derivatives. - - Snes9x is freeware for PERSONAL USE only. Commercial users should - seek permission of the copyright holders first. Commercial use includes, - but is not limited to, charging money for Snes9x or software derived from - Snes9x, including Snes9x or derivatives in commercial game bundles, and/or - using Snes9x as a promotion for your commercial product. - - The copyright holders request that bug fixes and improvements to the code - should be forwarded to them so everyone can benefit from the modifications - in future versions. - - Super NES and Super Nintendo Entertainment System are trademarks of - Nintendo Co., Limited and its subsidiary companies. -**********************************************************************************/ +///* This file is part of DeSmuME, derived from several files in Snes9x 1.51 which are +// licensed under the terms supplied at the end of this file (for the terms are very long!) +// Differences from that baseline version are: +// +// Copyright (C) 2009 DeSmuME team +// +// DeSmuME is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// DeSmuME is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with DeSmuME; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//*/ + + +#ifndef INPUTDX_INCLUDED +#define INPUTDX_INCLUDED + +typedef struct +{ + COLORREF crForeGnd; // Foreground text colour + COLORREF crBackGnd; // Background text colour + HFONT hFont; // The font + HWND hwnd; // The control's window handle +} InputCust; +COLORREF CheckButtonKey( WORD Key); +COLORREF CheckHotKey( WORD Key, int modifiers); +InputCust * GetInputCustom(HWND hwnd); + +#define CUSTKEY_ALT_MASK 0x01 +#define CUSTKEY_CTRL_MASK 0x02 +#define CUSTKEY_SHIFT_MASK 0x04 + +struct SJoypad { + BOOL Enabled; + WORD Left; + WORD Right; + WORD Up; + WORD Down; + WORD Left_Up; + WORD Left_Down; + WORD Right_Up; + WORD Right_Down; + WORD Start; + WORD Select; + WORD Lid; + WORD Debug; + WORD A; + WORD B; + WORD X; + WORD Y; + WORD L; + WORD R; +}; + +#define LEFT_MASK 0x0001 +#define RIGHT_MASK 0x0002 +#define UP_MASK 0x0004 +#define DOWN_MASK 0x0008 +#define START_MASK 0x0010 +#define SELECT_MASK 0x0020 +#define LID_MASK 0x0040 +#define DEBUG_MASK 0x0080 +#define A_MASK 0x0100 +#define B_MASK 0x0200 +#define X_MASK 0x0400 +#define Y_MASK 0x0800 +#define L_MASK 0x1000 +#define R_MASK 0x2000 + + +struct SJoyState{ + bool Attached; + //JOYCAPS Caps; + int Threshold; + bool Left; + bool Right; + bool Up; + bool Down; + bool PovLeft; + bool PovRight; + bool PovUp; + bool PovDown; + bool PovDnLeft; + bool PovDnRight; + bool PovUpLeft; + bool PovUpRight; + bool RUp; + bool RDown; + bool UUp; + bool UDown; + bool VUp; + bool VDown; + bool ZUp; + bool ZDown; + bool Button[32]; +}; + +extern SJoypad Joypad[16]; +extern SJoypad ToggleJoypadStorage[8]; +//extern SCustomKeys CustomKeys; +extern SJoypad TurboToggleJoypadStorage[8]; + +void RunInputConfig(); +void RunHotkeyConfig(); +void input_process(); + +struct SGuitar { + BOOL Enabled; + WORD GREEN; + WORD RED; + WORD YELLOW; + WORD BLUE; +}; + +extern SGuitar Guitar; + +#endif + + +/********************************************************************************** + Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + + (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), + Jerremy Koot (jkoot@snes9x.com) + + (c) Copyright 2002 - 2004 Matthew Kendora + + (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) + + (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) + + (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) + + (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), + Kris Bleakley (codeviolation@hotmail.com) + + (c) Copyright 2002 - 2007 Brad Jorsch (anomie@users.sourceforge.net), + Nach (n-a-c-h@users.sourceforge.net), + zones (kasumitokoduck@yahoo.com) + + (c) Copyright 2006 - 2007 nitsuja + + + BS-X C emulator code + (c) Copyright 2005 - 2006 Dreamer Nom, + zones + + C4 x86 assembler and some C emulation code + (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), + Nach, + zsKnight (zsknight@zsnes.com) + + C4 C++ code + (c) Copyright 2003 - 2006 Brad Jorsch, + Nach + + DSP-1 emulator code + (c) Copyright 1998 - 2006 _Demo_, + Andreas Naive (andreasnaive@gmail.com) + Gary Henderson, + Ivar (ivar@snes9x.com), + John Weidman, + Kris Bleakley, + Matthew Kendora, + Nach, + neviksti (neviksti@hotmail.com) + + DSP-2 emulator code + (c) Copyright 2003 John Weidman, + Kris Bleakley, + Lord Nightmare (lord_nightmare@users.sourceforge.net), + Matthew Kendora, + neviksti + + + DSP-3 emulator code + (c) Copyright 2003 - 2006 John Weidman, + Kris Bleakley, + Lancer, + z80 gaiden + + DSP-4 emulator code + (c) Copyright 2004 - 2006 Dreamer Nom, + John Weidman, + Kris Bleakley, + Nach, + z80 gaiden + + OBC1 emulator code + (c) Copyright 2001 - 2004 zsKnight, + pagefault (pagefault@zsnes.com), + Kris Bleakley, + Ported from x86 assembler to C by sanmaiwashi + + SPC7110 and RTC C++ emulator code + (c) Copyright 2002 Matthew Kendora with research by + zsKnight, + John Weidman, + Dark Force + + S-DD1 C emulator code + (c) Copyright 2003 Brad Jorsch with research by + Andreas Naive, + John Weidman + + S-RTC C emulator code + (c) Copyright 2001-2006 byuu, + John Weidman + + ST010 C++ emulator code + (c) Copyright 2003 Feather, + John Weidman, + Kris Bleakley, + Matthew Kendora + + Super FX x86 assembler emulator code + (c) Copyright 1998 - 2003 _Demo_, + pagefault, + zsKnight, + + Super FX C emulator code + (c) Copyright 1997 - 1999 Ivar, + Gary Henderson, + John Weidman + + Sound DSP emulator code is derived from SNEeSe and OpenSPC: + (c) Copyright 1998 - 2003 Brad Martin + (c) Copyright 1998 - 2006 Charles Bilyue' + + SH assembler code partly based on x86 assembler code + (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) + + 2xSaI filter + (c) Copyright 1999 - 2001 Derek Liauw Kie Fa + + HQ2x, HQ3x, HQ4x filters + (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) + + Win32 GUI code + (c) Copyright 2003 - 2006 blip, + funkyass, + Matthew Kendora, + Nach, + nitsuja + + Mac OS GUI code + (c) Copyright 1998 - 2001 John Stiles + (c) Copyright 2001 - 2007 zones + + + Specific ports contains the works of other authors. See headers in + individual files. + + + Snes9x homepage: http://www.snes9x.com + + Permission to use, copy, modify and/or distribute Snes9x in both binary + and source form, for non-commercial purposes, is hereby granted without + fee, providing that this license information and copyright notice appear + with all copies and any derived work. + + This software is provided 'as-is', without any express or implied + warranty. In no event shall the authors be held liable for any damages + arising from the use of this software or it's derivatives. + + Snes9x is freeware for PERSONAL USE only. Commercial users should + seek permission of the copyright holders first. Commercial use includes, + but is not limited to, charging money for Snes9x or software derived from + Snes9x, including Snes9x or derivatives in commercial game bundles, and/or + using Snes9x as a promotion for your commercial product. + + The copyright holders request that bug fixes and improvements to the code + should be forwarded to them so everyone can benefit from the modifications + in future versions. + + Super NES and Super Nintendo Entertainment System are trademarks of + Nintendo Co., Limited and its subsidiary companies. +**********************************************************************************/ diff --git a/desmume/src/windows/langs/build_utils/gettextlib.dll b/src/windows/langs/build_utils/gettextlib.dll similarity index 100% rename from desmume/src/windows/langs/build_utils/gettextlib.dll rename to src/windows/langs/build_utils/gettextlib.dll diff --git a/desmume/src/windows/langs/build_utils/gettextpo.dll b/src/windows/langs/build_utils/gettextpo.dll similarity index 100% rename from desmume/src/windows/langs/build_utils/gettextpo.dll rename to src/windows/langs/build_utils/gettextpo.dll diff --git a/desmume/src/windows/langs/build_utils/gettextsrc.dll b/src/windows/langs/build_utils/gettextsrc.dll similarity index 100% rename from desmume/src/windows/langs/build_utils/gettextsrc.dll rename to src/windows/langs/build_utils/gettextsrc.dll diff --git a/desmume/src/windows/langs/build_utils/iconv.dll b/src/windows/langs/build_utils/iconv.dll similarity index 100% rename from desmume/src/windows/langs/build_utils/iconv.dll rename to src/windows/langs/build_utils/iconv.dll diff --git a/desmume/src/windows/langs/build_utils/intl.dll b/src/windows/langs/build_utils/intl.dll similarity index 100% rename from desmume/src/windows/langs/build_utils/intl.dll rename to src/windows/langs/build_utils/intl.dll diff --git a/desmume/src/windows/langs/build_utils/libiconv-2.dll b/src/windows/langs/build_utils/libiconv-2.dll similarity index 100% rename from desmume/src/windows/langs/build_utils/libiconv-2.dll rename to src/windows/langs/build_utils/libiconv-2.dll diff --git a/desmume/src/windows/langs/build_utils/msgfmt.exe b/src/windows/langs/build_utils/msgfmt.exe similarity index 100% rename from desmume/src/windows/langs/build_utils/msgfmt.exe rename to src/windows/langs/build_utils/msgfmt.exe diff --git a/desmume/src/windows/langs/fr_FR.mo b/src/windows/langs/fr_FR.mo similarity index 100% rename from desmume/src/windows/langs/fr_FR.mo rename to src/windows/langs/fr_FR.mo diff --git a/desmume/src/windows/lightView.cpp b/src/windows/lightView.cpp similarity index 96% rename from desmume/src/windows/lightView.cpp rename to src/windows/lightView.cpp index ca6e778c2..0b6b04a9f 100644 --- a/desmume/src/windows/lightView.cpp +++ b/src/windows/lightView.cpp @@ -1,184 +1,184 @@ -/* Copyright (C) 2007 Acid Burn - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "lightView.h" -#include "commctrl.h" -#include "colorctrl.h" -#include "gfx3d.h" -#include "resource.h" -#include "debug.h" - -// Convert B5G5R5 color format into R8G8B8 color format -unsigned int ColorConv_B5R5R5ToR8G8B8(const unsigned int color) -{ - return (((color&31)<<16)<<3) | // red - ((((color>>5)&31)<<8)<<3) | // green - (((color>>10)&31)<<3); // blue -} - -typedef struct -{ - u32 autoup_secs; - bool autoup; -} lightsview_struct; - -lightsview_struct *LightsView = NULL; - -void LightView_OnPaintLight(HWND hwnd, int index) -{ - const int idcDir[4] = - { - IDC_LIGHT_VIEWER_LIGHT0VECTOR_EDIT, IDC_LIGHT_VIEWER_LIGHT1VECTOR_EDIT, - IDC_LIGHT_VIEWER_LIGHT2VECTOR_EDIT, IDC_LIGHT_VIEWER_LIGHT3VECTOR_EDIT - }; - - const int idcColorEdit[4] = - { - IDC_LIGHT_VIEWER_LIGHT0COLOR_EDIT, IDC_LIGHT_VIEWER_LIGHT1COLOR_EDIT, - IDC_LIGHT_VIEWER_LIGHT2COLOR_EDIT, IDC_LIGHT_VIEWER_LIGHT3COLOR_EDIT - }; - - const int idcColorCtrl[4] = - { - IDC_LIGHT_VIEWER_LIGHT0COLOR_COLORCTRL, IDC_LIGHT_VIEWER_LIGHT1COLOR_COLORCTRL, - IDC_LIGHT_VIEWER_LIGHT2COLOR_COLORCTRL, IDC_LIGHT_VIEWER_LIGHT3COLOR_COLORCTRL - }; - - unsigned int color; - unsigned int direction; - //ColorCtrl* colorCtrl; - char buffer[128]; - - // Get necessary information from gfx3d module - gfx3d_glGetLightColor(index, &color); - gfx3d_glGetLightDirection(index, &direction); - - // Print Light Direction - sprintf(buffer, "%.8x", direction); - SetWindowText(GetDlgItem(hwnd, idcDir[index]), buffer); - - // Print Light Color - sprintf(buffer, "%.4x", color); - SetWindowText(GetDlgItem(hwnd, idcColorEdit[index]), buffer); - - // Set Light Color in ColorDisplay component - ColorCtrl_SetColor(GetDlgItem(hwnd, idcColorCtrl[index]), ColorConv_B5R5R5ToR8G8B8(color)); -} - -////////////////////////////////////////////////////////////////////////////// - -BOOL LightView_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - - hdc = BeginPaint(hwnd, &ps); - - LightView_OnPaintLight(hwnd, 0); - LightView_OnPaintLight(hwnd, 1); - LightView_OnPaintLight(hwnd, 2); - LightView_OnPaintLight(hwnd, 3); - - EndPaint(hwnd, &ps); - - return TRUE; -} - -BOOL CALLBACK ViewLightsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - LightsView = new lightsview_struct; - memset(LightsView, 0, sizeof(lightsview_struct)); - LightsView->autoup_secs = 1; - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETRANGE, 0, MAKELONG(99, 1)); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETPOS32, 0, LightsView->autoup_secs); - break; - - case WM_CLOSE: - if(LightsView->autoup) - { - KillTimer(hwnd, IDT_VIEW_LIGHTS); - LightsView->autoup = false; - } - - if (LightsView!=NULL) - { - delete LightsView; - LightsView = NULL; - } - //INFO("Close lights viewer dialog\n"); - PostQuitMessage(0); - break; - - case WM_PAINT: - LightView_OnPaint(hwnd, wParam, lParam); - break; - - case WM_TIMER: - SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); - return 1; - - case WM_COMMAND: - switch (LOWORD (wParam)) - { - case IDOK: - SendMessage(hwnd, WM_CLOSE, 0, 0); - return 1; - case IDC_AUTO_UPDATE : - if(LightsView->autoup) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); - KillTimer(hwnd, IDT_VIEW_LIGHTS); - LightsView->autoup = FALSE; - return 1; - } - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); - LightsView->autoup = TRUE; - SetTimer(hwnd, IDT_VIEW_LIGHTS, LightsView->autoup_secs*20, (TIMERPROC) NULL); - return 1; - case IDC_AUTO_UPDATE_SECS: - { - int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); - if (!LightsView) - { - SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - if (t != LightsView->autoup_secs) - { - LightsView->autoup_secs = t; - if (LightsView->autoup) - SetTimer(hwnd, IDT_VIEW_LIGHTS, - LightsView->autoup_secs*20, (TIMERPROC) NULL); - } - } - return 1; - case IDC_REFRESH: - InvalidateRect(hwnd, NULL, FALSE); - return 1; - } - return 0; - } - return FALSE; -} +/* Copyright (C) 2007 Acid Burn + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "lightView.h" +#include "commctrl.h" +#include "colorctrl.h" +#include "gfx3d.h" +#include "resource.h" +#include "debug.h" + +// Convert B5G5R5 color format into R8G8B8 color format +unsigned int ColorConv_B5R5R5ToR8G8B8(const unsigned int color) +{ + return (((color&31)<<16)<<3) | // red + ((((color>>5)&31)<<8)<<3) | // green + (((color>>10)&31)<<3); // blue +} + +typedef struct +{ + u32 autoup_secs; + bool autoup; +} lightsview_struct; + +lightsview_struct *LightsView = NULL; + +void LightView_OnPaintLight(HWND hwnd, int index) +{ + const int idcDir[4] = + { + IDC_LIGHT_VIEWER_LIGHT0VECTOR_EDIT, IDC_LIGHT_VIEWER_LIGHT1VECTOR_EDIT, + IDC_LIGHT_VIEWER_LIGHT2VECTOR_EDIT, IDC_LIGHT_VIEWER_LIGHT3VECTOR_EDIT + }; + + const int idcColorEdit[4] = + { + IDC_LIGHT_VIEWER_LIGHT0COLOR_EDIT, IDC_LIGHT_VIEWER_LIGHT1COLOR_EDIT, + IDC_LIGHT_VIEWER_LIGHT2COLOR_EDIT, IDC_LIGHT_VIEWER_LIGHT3COLOR_EDIT + }; + + const int idcColorCtrl[4] = + { + IDC_LIGHT_VIEWER_LIGHT0COLOR_COLORCTRL, IDC_LIGHT_VIEWER_LIGHT1COLOR_COLORCTRL, + IDC_LIGHT_VIEWER_LIGHT2COLOR_COLORCTRL, IDC_LIGHT_VIEWER_LIGHT3COLOR_COLORCTRL + }; + + unsigned int color; + unsigned int direction; + ColorCtrl* colorCtrl; + char buffer[128]; + + // Get necessary information from gfx3d module + gfx3d_glGetLightColor(index, &color); + gfx3d_glGetLightDirection(index, &direction); + + // Print Light Direction + sprintf(buffer, "%.8x", direction); + SetWindowText(GetDlgItem(hwnd, idcDir[index]), buffer); + + // Print Light Color + sprintf(buffer, "%.4x", color); + SetWindowText(GetDlgItem(hwnd, idcColorEdit[index]), buffer); + + // Set Light Color in ColorDisplay component + ColorCtrl_SetColor(GetDlgItem(hwnd, idcColorCtrl[index]), ColorConv_B5R5R5ToR8G8B8(color)); +} + +////////////////////////////////////////////////////////////////////////////// + +BOOL LightView_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + + hdc = BeginPaint(hwnd, &ps); + + LightView_OnPaintLight(hwnd, 0); + LightView_OnPaintLight(hwnd, 1); + LightView_OnPaintLight(hwnd, 2); + LightView_OnPaintLight(hwnd, 3); + + EndPaint(hwnd, &ps); + + return TRUE; +} + +BOOL CALLBACK ViewLightsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG: + LightsView = new lightsview_struct; + memset(LightsView, 0, sizeof(lightsview_struct)); + LightsView->autoup_secs = 1; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, LightsView->autoup_secs); + break; + + case WM_CLOSE: + if(LightsView->autoup) + { + KillTimer(hwnd, IDT_VIEW_LIGHTS); + LightsView->autoup = false; + } + + if (LightsView!=NULL) + { + delete LightsView; + LightsView = NULL; + } + //INFO("Close lights viewer dialog\n"); + PostQuitMessage(0); + break; + + case WM_PAINT: + LightView_OnPaint(hwnd, wParam, lParam); + break; + + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; + + case WM_COMMAND: + switch (LOWORD (wParam)) + { + case IDOK: + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 1; + case IDC_AUTO_UPDATE : + if(LightsView->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_LIGHTS); + LightsView->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + LightsView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_LIGHTS, LightsView->autoup_secs*20, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (!LightsView) + { + SendMessage(hwnd, WM_INITDIALOG, 0, 0); + } + if (t != LightsView->autoup_secs) + { + LightsView->autoup_secs = t; + if (LightsView->autoup) + SetTimer(hwnd, IDT_VIEW_LIGHTS, + LightsView->autoup_secs*20, (TIMERPROC) NULL); + } + } + return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; + } + return 0; + } + return FALSE; +} diff --git a/desmume/src/windows/lightView.h b/src/windows/lightView.h similarity index 96% rename from desmume/src/windows/lightView.h rename to src/windows/lightView.h index 9dd1cf69a..4778b05cd 100644 --- a/desmume/src/windows/lightView.h +++ b/src/windows/lightView.h @@ -1,27 +1,27 @@ -/* Copyright (C) 2007 Acid Burn - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef LIGHTVIEW_H -#define LIGHTVIEW_H - -#include "../common.h" - -extern BOOL CALLBACK ViewLightsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - +/* Copyright (C) 2007 Acid Burn + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef LIGHTVIEW_H +#define LIGHTVIEW_H + +#include "../common.h" + +extern BOOL CALLBACK ViewLightsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + #endif \ No newline at end of file diff --git a/desmume/src/windows/lua/lib/lua-5.1.4-x86.lib b/src/windows/lua/lib/lua-5.1.4-x86.lib similarity index 100% rename from desmume/src/windows/lua/lib/lua-5.1.4-x86.lib rename to src/windows/lua/lib/lua-5.1.4-x86.lib diff --git a/desmume/src/windows/lua/lua-5.1.4/COPYRIGHT b/src/windows/lua/lua-5.1.4/COPYRIGHT similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/COPYRIGHT rename to src/windows/lua/lua-5.1.4/COPYRIGHT diff --git a/desmume/src/windows/lua/lua-5.1.4/src/Makefile b/src/windows/lua/lua-5.1.4/src/Makefile similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/Makefile rename to src/windows/lua/lua-5.1.4/src/Makefile diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lapi.c b/src/windows/lua/lua-5.1.4/src/lapi.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lapi.c rename to src/windows/lua/lua-5.1.4/src/lapi.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lapi.h b/src/windows/lua/lua-5.1.4/src/lapi.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lapi.h rename to src/windows/lua/lua-5.1.4/src/lapi.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lauxlib.c b/src/windows/lua/lua-5.1.4/src/lauxlib.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lauxlib.c rename to src/windows/lua/lua-5.1.4/src/lauxlib.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lauxlib.h b/src/windows/lua/lua-5.1.4/src/lauxlib.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lauxlib.h rename to src/windows/lua/lua-5.1.4/src/lauxlib.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lbaselib.c b/src/windows/lua/lua-5.1.4/src/lbaselib.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lbaselib.c rename to src/windows/lua/lua-5.1.4/src/lbaselib.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lcode.c b/src/windows/lua/lua-5.1.4/src/lcode.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lcode.c rename to src/windows/lua/lua-5.1.4/src/lcode.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lcode.h b/src/windows/lua/lua-5.1.4/src/lcode.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lcode.h rename to src/windows/lua/lua-5.1.4/src/lcode.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/ldblib.c b/src/windows/lua/lua-5.1.4/src/ldblib.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/ldblib.c rename to src/windows/lua/lua-5.1.4/src/ldblib.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/ldebug.c b/src/windows/lua/lua-5.1.4/src/ldebug.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/ldebug.c rename to src/windows/lua/lua-5.1.4/src/ldebug.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/ldebug.h b/src/windows/lua/lua-5.1.4/src/ldebug.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/ldebug.h rename to src/windows/lua/lua-5.1.4/src/ldebug.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/ldo.c b/src/windows/lua/lua-5.1.4/src/ldo.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/ldo.c rename to src/windows/lua/lua-5.1.4/src/ldo.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/ldo.h b/src/windows/lua/lua-5.1.4/src/ldo.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/ldo.h rename to src/windows/lua/lua-5.1.4/src/ldo.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/ldump.c b/src/windows/lua/lua-5.1.4/src/ldump.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/ldump.c rename to src/windows/lua/lua-5.1.4/src/ldump.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lfunc.c b/src/windows/lua/lua-5.1.4/src/lfunc.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lfunc.c rename to src/windows/lua/lua-5.1.4/src/lfunc.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lfunc.h b/src/windows/lua/lua-5.1.4/src/lfunc.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lfunc.h rename to src/windows/lua/lua-5.1.4/src/lfunc.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lgc.c b/src/windows/lua/lua-5.1.4/src/lgc.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lgc.c rename to src/windows/lua/lua-5.1.4/src/lgc.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lgc.h b/src/windows/lua/lua-5.1.4/src/lgc.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lgc.h rename to src/windows/lua/lua-5.1.4/src/lgc.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/linit.c b/src/windows/lua/lua-5.1.4/src/linit.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/linit.c rename to src/windows/lua/lua-5.1.4/src/linit.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/liolib.c b/src/windows/lua/lua-5.1.4/src/liolib.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/liolib.c rename to src/windows/lua/lua-5.1.4/src/liolib.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/llex.c b/src/windows/lua/lua-5.1.4/src/llex.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/llex.c rename to src/windows/lua/lua-5.1.4/src/llex.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/llex.h b/src/windows/lua/lua-5.1.4/src/llex.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/llex.h rename to src/windows/lua/lua-5.1.4/src/llex.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/llimits.h b/src/windows/lua/lua-5.1.4/src/llimits.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/llimits.h rename to src/windows/lua/lua-5.1.4/src/llimits.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lmathlib.c b/src/windows/lua/lua-5.1.4/src/lmathlib.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lmathlib.c rename to src/windows/lua/lua-5.1.4/src/lmathlib.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lmem.c b/src/windows/lua/lua-5.1.4/src/lmem.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lmem.c rename to src/windows/lua/lua-5.1.4/src/lmem.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lmem.h b/src/windows/lua/lua-5.1.4/src/lmem.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lmem.h rename to src/windows/lua/lua-5.1.4/src/lmem.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/loadlib.c b/src/windows/lua/lua-5.1.4/src/loadlib.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/loadlib.c rename to src/windows/lua/lua-5.1.4/src/loadlib.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lobject.c b/src/windows/lua/lua-5.1.4/src/lobject.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lobject.c rename to src/windows/lua/lua-5.1.4/src/lobject.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lobject.h b/src/windows/lua/lua-5.1.4/src/lobject.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lobject.h rename to src/windows/lua/lua-5.1.4/src/lobject.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lopcodes.c b/src/windows/lua/lua-5.1.4/src/lopcodes.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lopcodes.c rename to src/windows/lua/lua-5.1.4/src/lopcodes.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lopcodes.h b/src/windows/lua/lua-5.1.4/src/lopcodes.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lopcodes.h rename to src/windows/lua/lua-5.1.4/src/lopcodes.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/loslib.c b/src/windows/lua/lua-5.1.4/src/loslib.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/loslib.c rename to src/windows/lua/lua-5.1.4/src/loslib.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lparser.c b/src/windows/lua/lua-5.1.4/src/lparser.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lparser.c rename to src/windows/lua/lua-5.1.4/src/lparser.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lparser.h b/src/windows/lua/lua-5.1.4/src/lparser.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lparser.h rename to src/windows/lua/lua-5.1.4/src/lparser.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lstate.c b/src/windows/lua/lua-5.1.4/src/lstate.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lstate.c rename to src/windows/lua/lua-5.1.4/src/lstate.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lstate.h b/src/windows/lua/lua-5.1.4/src/lstate.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lstate.h rename to src/windows/lua/lua-5.1.4/src/lstate.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lstring.c b/src/windows/lua/lua-5.1.4/src/lstring.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lstring.c rename to src/windows/lua/lua-5.1.4/src/lstring.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lstring.h b/src/windows/lua/lua-5.1.4/src/lstring.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lstring.h rename to src/windows/lua/lua-5.1.4/src/lstring.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lstrlib.c b/src/windows/lua/lua-5.1.4/src/lstrlib.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lstrlib.c rename to src/windows/lua/lua-5.1.4/src/lstrlib.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/ltable.c b/src/windows/lua/lua-5.1.4/src/ltable.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/ltable.c rename to src/windows/lua/lua-5.1.4/src/ltable.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/ltable.h b/src/windows/lua/lua-5.1.4/src/ltable.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/ltable.h rename to src/windows/lua/lua-5.1.4/src/ltable.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/ltablib.c b/src/windows/lua/lua-5.1.4/src/ltablib.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/ltablib.c rename to src/windows/lua/lua-5.1.4/src/ltablib.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/ltm.c b/src/windows/lua/lua-5.1.4/src/ltm.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/ltm.c rename to src/windows/lua/lua-5.1.4/src/ltm.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/ltm.h b/src/windows/lua/lua-5.1.4/src/ltm.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/ltm.h rename to src/windows/lua/lua-5.1.4/src/ltm.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lua.c b/src/windows/lua/lua-5.1.4/src/lua.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lua.c rename to src/windows/lua/lua-5.1.4/src/lua.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lua.h b/src/windows/lua/lua-5.1.4/src/lua.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lua.h rename to src/windows/lua/lua-5.1.4/src/lua.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/luac.c b/src/windows/lua/lua-5.1.4/src/luac.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/luac.c rename to src/windows/lua/lua-5.1.4/src/luac.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/luaconf.h b/src/windows/lua/lua-5.1.4/src/luaconf.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/luaconf.h rename to src/windows/lua/lua-5.1.4/src/luaconf.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lualib.h b/src/windows/lua/lua-5.1.4/src/lualib.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lualib.h rename to src/windows/lua/lua-5.1.4/src/lualib.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lundump.c b/src/windows/lua/lua-5.1.4/src/lundump.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lundump.c rename to src/windows/lua/lua-5.1.4/src/lundump.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lundump.h b/src/windows/lua/lua-5.1.4/src/lundump.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lundump.h rename to src/windows/lua/lua-5.1.4/src/lundump.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lvm.c b/src/windows/lua/lua-5.1.4/src/lvm.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lvm.c rename to src/windows/lua/lua-5.1.4/src/lvm.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lvm.h b/src/windows/lua/lua-5.1.4/src/lvm.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lvm.h rename to src/windows/lua/lua-5.1.4/src/lvm.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lzio.c b/src/windows/lua/lua-5.1.4/src/lzio.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lzio.c rename to src/windows/lua/lua-5.1.4/src/lzio.c diff --git a/desmume/src/windows/lua/lua-5.1.4/src/lzio.h b/src/windows/lua/lua-5.1.4/src/lzio.h similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/lzio.h rename to src/windows/lua/lua-5.1.4/src/lzio.h diff --git a/desmume/src/windows/lua/lua-5.1.4/src/print.c b/src/windows/lua/lua-5.1.4/src/print.c similarity index 100% rename from desmume/src/windows/lua/lua-5.1.4/src/print.c rename to src/windows/lua/lua-5.1.4/src/print.c diff --git a/desmume/src/windows/lua/vs8/lua.sln b/src/windows/lua/vs8/lua.sln similarity index 100% rename from desmume/src/windows/lua/vs8/lua.sln rename to src/windows/lua/vs8/lua.sln diff --git a/desmume/src/windows/lua/vs8/lua.vcproj b/src/windows/lua/vs8/lua.vcproj similarity index 100% rename from desmume/src/windows/lua/vs8/lua.vcproj rename to src/windows/lua/vs8/lua.vcproj diff --git a/desmume/src/windows/luaconsole.cpp b/src/windows/luaconsole.cpp similarity index 100% rename from desmume/src/windows/luaconsole.cpp rename to src/windows/luaconsole.cpp diff --git a/desmume/src/windows/main.cpp b/src/windows/main.cpp similarity index 92% rename from desmume/src/windows/main.cpp rename to src/windows/main.cpp index 238d67c5b..dae8202f3 100644 --- a/desmume/src/windows/main.cpp +++ b/src/windows/main.cpp @@ -1,4735 +1,4568 @@ -/* main.cpp - - Copyright 2006 Theo Berkau - Copyright (C) 2006-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "windriver.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "gthread.h" -#include "version.h" -#include "CWindow.h" -#include "../MMU.h" -#include "../armcpu.h" -#include "../NDSSystem.h" -#include "../debug.h" -#include "../saves.h" -#include "../addons.h" -#include "resource.h" -#include "GPU_osd.h" -#include "memView.h" -#include "disView.h" -#include "ginfo.h" -#include "IORegView.h" -#include "palView.h" -#include "tileView.h" -#include "oamView.h" -#include "mapview.h" -#include "matrixview.h" -#include "lightview.h" -#include "inputdx.h" -#include "FirmConfig.h" -#include "AboutBox.h" -#include "OGLRender.h" -#include "rasterize.h" -#include "../gfx3d.h" -#include "../render3D.h" -#include "../gdbstub.h" -#include "colorctrl.h" -#include "console.h" -#include "throttle.h" -#include "gbaslot_config.h" -#include "cheatsWin.h" -#include "Mmsystem.h" -#include "../mic.h" -#include "../common.h" -#include "main.h" -#include "hotkey.h" -#include "../movie.h" -#include "../replay.h" -#include "snddx.h" -#include "ramwatch.h" -#include "ram_search.h" -#include "aviout.h" -#include "soundView.h" -#include "commandline.h" -#include "../lua-engine.h" -#include "7zip.h" -#include "pathsettings.h" -#include "utils/xstring.h" -#include "directx/ddraw.h" -#include "video.h" -#include "path.h" - -#include "aggdraw.h" -#include "agg2d.h" - -using namespace std; - -#define HAVE_REMOTE -#define WPCAP -#define PACKET_SIZE 65535 - -#include -#include //uh? - -VideoInfo video; - -//#define WX_STUB - -#ifdef WX_STUB - -// for compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -class wxDesmumeApp : public wxApp -{ -public: - //call me each frame or something. - //sort of an idle routine - static void frameUpdate() - { - if(!wxTheApp) return; - wxDesmumeApp* self = ((wxDesmumeApp*)wxTheApp); - self->DeletePendingObjects(); - } -}; - -IMPLEMENT_APP_NO_MAIN( wxDesmumeApp ) - -class wxTestModeless : public wxFrame -{ -public: - wxTestModeless(const wxChar *title, int x, int y) - : wxFrame(NULL, wxID_ANY, title, wxPoint(x, y), wxSize(700, 450)) - {} -}; - -void wxTest() { - wxTestModeless *frame = new wxTestModeless(_T("Controls wxWidgets App"), 50, 50); - frame->Show(true); -} - -#endif - -const int kGapNone = 0; -const int kGapBorder = 5; -const int kGapNDS = 64; // extremely tilted (but some games seem to use this value) -const int kGapNDS2 = 90; // more normal viewing angle - -static BOOL OpenCore(const char* filename); - -//----Recent ROMs menu globals---------- -vector RecentRoms; //The list of recent ROM filenames -const unsigned int MAX_RECENT_ROMS = 10; //To change the recent rom max, simply change this number -const unsigned int clearid = IDM_RECENT_RESERVED0; // ID for the Clear recent ROMs item -const unsigned int baseid = IDM_RECENT_RESERVED1; //Base identifier for the recent ROMs items -static HMENU recentromsmenu; //Handle to the recent ROMs submenu -//-------------------------------------- - -void UpdateHotkeyAssignments(); //Appends hotkey mappings to corresponding menu items - -static HMENU mainMenu; //Holds handle to the main DeSmuME menu - -DWORD hKeyInputTimer; - -extern LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -void InitRamSearch(); -void FilterUpdate(HWND hwnd, bool user=true); - -CRITICAL_SECTION win_execute_sync; -volatile int win_sound_samplecounter = 0; - -CRITICAL_SECTION win_backbuffer_sync; - -Lock::Lock() : m_cs(&win_execute_sync) { EnterCriticalSection(m_cs); } -Lock::Lock(CRITICAL_SECTION& cs) : m_cs(&cs) { EnterCriticalSection(m_cs); } -Lock::~Lock() { LeaveCriticalSection(m_cs); } - -//===================== DirectDraw vars -LPDIRECTDRAW7 lpDDraw=NULL; -LPDIRECTDRAWSURFACE7 lpPrimarySurface=NULL; -LPDIRECTDRAWSURFACE7 lpBackSurface=NULL; -DDSURFACEDESC2 ddsd; -LPDIRECTDRAWCLIPPER lpDDClipPrimary=NULL; -LPDIRECTDRAWCLIPPER lpDDClipBack=NULL; - -//===================== Input vars -#define WM_CUSTKEYDOWN (WM_USER+50) -#define WM_CUSTKEYUP (WM_USER+51) - - -inline bool IsDlgCheckboxChecked(HWND hDlg, int id) -{ - return IsDlgButtonChecked(hDlg,id) == BST_CHECKED; -} - -LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); - -char SavName[MAX_PATH] = ""; -char ImportSavName[MAX_PATH] = ""; -char szClassName[ ] = "DeSmuME"; -int romnum = 0; - -DWORD threadID; - -WINCLASS *MainWindow=NULL; - -//HWND hwnd; -//HDC hdc; -HACCEL hAccel; -HINSTANCE hAppInst = NULL; -RECT MainScreenRect, SubScreenRect, GapRect; -RECT MainScreenSrcRect, SubScreenSrcRect; -int WndX = 0; -int WndY = 0; - -extern HWND RamSearchHWnd; -static bool lostFocusPause = true; -static bool lastPauseFromLostFocus = false; -static bool FrameLimit = true; - -std::vector LuaScriptHWnds; -LRESULT CALLBACK LuaScriptProc(HWND, UINT, WPARAM, LPARAM); - -//=========================== view tools -TOOLSCLASS *ViewDisasm_ARM7 = NULL; -TOOLSCLASS *ViewDisasm_ARM9 = NULL; -//TOOLSCLASS *ViewMem_ARM7 = NULL; -//TOOLSCLASS *ViewMem_ARM9 = NULL; -TOOLSCLASS *ViewRegisters = NULL; -TOOLSCLASS *ViewPalette = NULL; -TOOLSCLASS *ViewTiles = NULL; -TOOLSCLASS *ViewMaps = NULL; -TOOLSCLASS *ViewOAM = NULL; -TOOLSCLASS *ViewMatrices = NULL; -TOOLSCLASS *ViewLights = NULL; - -volatile bool execute = false; -volatile bool paused = true; -volatile BOOL pausedByMinimize = FALSE; -u32 glock = 0; - -BOOL finished = FALSE; -bool romloaded = false; - -void SetScreenGap(int gap); - -void SetRotate(HWND hwnd, int rot); - -bool ForceRatio = true; -bool SeparationBorderDrag = true; -float DefaultWidth; -float DefaultHeight; -float widthTradeOff; -float heightTradeOff; - -//static char IniName[MAX_PATH]; -int sndcoretype=SNDCORE_DIRECTX; -int sndbuffersize=735*4; -int sndvolume=100; - -SoundInterface_struct *SNDCoreList[] = { - &SNDDummy, - &SNDDIRECTX, - NULL -}; - -GPU3DInterface *core3DList[] = { - &gpu3DNull, - &gpu3Dgl, - &gpu3DRasterize, - NULL -}; - -bool autoframeskipenab=0; -int frameskiprate=0; -int emu_paused = 0; -bool frameAdvance = false; -bool staterewindingenabled = false; - -bool UseMicSample = false; -unsigned short windowSize = 0; - -/* the firmware settings */ -struct NDS_fw_config_data win_fw_config; - -/*const u32 gapColors[16] = { - Color::Gray, - Color::Brown, - Color::Red, - Color::Pink, - Color::Orange, - Color::Yellow, - Color::LightGreen, - Color::Lime, - Color::Green, - Color::SeaGreen, - Color::SkyBlue, - Color::Blue, - Color::DarkBlue, - Color::DarkViolet, - Color::Purple, - Color::Fuchsia -};*/ - -LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp); -LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -LRESULT CALLBACK MicrophoneSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - -//struct configured_features { -// u16 arm9_gdb_port; -// u16 arm7_gdb_port; -// -// const char *cflash_disk_image_file; -//}; - -int KeyInDelayInCount=30; - -static int lastTime = timeGetTime(); -int repeattime; - -VOID CALLBACK KeyInputTimer( UINT idEvent, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) -{ - // -// if(timeGetTime() - lastTime > 5) -// { - bool S9xGetState (WORD KeyIdent); - - /* if(GUI.JoystickHotkeys) - { - static uint32 joyState [256]; - - for(int i = 0 ; i < 255 ; i++) - { - bool active = !S9xGetState(0x8000|i); - - if(active) - { - if(joyState[i] < ULONG_MAX) // 0xffffffffUL - joyState[i]++; - if(joyState[i] == 1 || joyState[i] >= (unsigned) KeyInDelayInCount) - PostMessage(GUI.hWnd, WM_CUSTKEYDOWN, (WPARAM)(0x8000|i),(LPARAM)(NULL)); - } - else - { - if(joyState[i]) - { - joyState[i] = 0; - PostMessage(GUI.hWnd, WM_CUSTKEYUP, (WPARAM)(0x8000|i),(LPARAM)(NULL)); - } - } - } - }*/ - // if((!GUI.InactivePause || !Settings.ForcedPause) - // || (GUI.BackgroundInput || !(Settings.ForcedPause & (PAUSE_INACTIVE_WINDOW | PAUSE_WINDOW_ICONISED)))) - // { - static u32 joyState [256]; - static bool initialized = false; - if(!initialized) { - memset(joyState,0,sizeof(joyState)); - initialized = true; - } - for(int i = 0 ; i < 256 ; i++) - { - bool active = !S9xGetState(i); - if(active) - { - if(joyState[i] < ULONG_MAX) // 0xffffffffUL - joyState[i]++; - if(joyState[i] == 1 || joyState[i] == (unsigned) KeyInDelayInCount) { - - - //HEY HEY HEY! this only repeats once. this is what it needs to be like for frame advance. - //if anyone wants a different kind of repeat, then the whole setup will need to be redone - - //sort of fix the auto repeating - //TODO find something better - // repeattime++; - // if(repeattime % 10 == 0) { - //printf("trigger %d\n",i); - PostMessage(MainWindow->getHWnd(), WM_CUSTKEYDOWN, (WPARAM)(i),(LPARAM)(NULL)); - repeattime=0; - // } - } - } - else - { - if(joyState[i]) - { - joyState[i] = 0; - PostMessage(MainWindow->getHWnd(), WM_CUSTKEYUP, (WPARAM)(i),(LPARAM)(NULL)); - } - } - } - // } - // lastTime = timeGetTime(); -// } -} - -void ScaleScreen(float factor) -{ - if(windowSize == 0) - { - int defw = GetPrivateProfileInt("Video", "Window width", 256, IniName); - int defh = GetPrivateProfileInt("Video", "Window height", 384, IniName); - - // fix for wrong rotation - int w1x = video.rotatedwidthgap(); - int h1x = video.rotatedheightgap(); - if((defw > defh) != (w1x > h1x)) - { - int temp = defw; - defw = defh; - defh = temp; - } - // fix for wrong gap - if(defh*w1x < h1x*defw) - defh = defw*h1x/w1x; - else if(defw*h1x < w1x*defh) - defw = defh*w1x/h1x; - - MainWindow->setClientSize(defw, defh); - } - else - { - if(factor==65535) - factor = 1.5f; - else if(factor==65534) - factor = 2.5f; - MainWindow->setClientSize((int)(video.rotatedwidthgap() * factor), (int)(video.rotatedheightgap() * factor)); - } -} - -void SetMinWindowSize() -{ - if(ForceRatio) - MainWindow->setMinSize(video.rotatedwidth(), video.rotatedheight()); - else - MainWindow->setMinSize(video.rotatedwidthgap(), video.rotatedheightgap()); -} - -void translateXY(s32& x, s32& y) -{ - s32 tx=x, ty=y; - switch(video.rotation) - { - case 90: - x = ty; - y = 191-tx; - break; - case 180: - x = 255-tx; - y = 383-ty; - y -= 192; - break; - case 270: - x = 255-ty; - y = (tx-192-(video.screengap/video.ratio())); - break; - } -} -// END Rotation definitions - -void UpdateRecentRomsMenu() -{ - //This function will be called to populate the Recent Menu - //The array must be in the proper order ahead of time - - //UpdateRecentRoms will always call this - //This will be always called by GetRecentRoms on DesMume startup - - - //---------------------------------------------------------------------- - //Get Menu item info - - MENUITEMINFO moo; - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_SUBMENU | MIIM_STATE; - - GetMenuItemInfo(GetSubMenu(mainMenu, 0), ID_FILE_RECENTROM, FALSE, &moo); - moo.hSubMenu = GetSubMenu(recentromsmenu, 0); - //moo.fState = RecentRoms[0].c_str() ? MFS_ENABLED : MFS_GRAYED; - moo.fState = MFS_ENABLED; - SetMenuItemInfo(GetSubMenu(mainMenu, 0), ID_FILE_RECENTROM, FALSE, &moo); - - //----------------------------------------------------------------------- - - //----------------------------------------------------------------------- - //Clear the current menu items - for(int x = 0; x < MAX_RECENT_ROMS; x++) - { - DeleteMenu(GetSubMenu(recentromsmenu, 0), baseid + x, MF_BYCOMMAND); - } - - if(RecentRoms.size() == 0) - { - EnableMenuItem(GetSubMenu(recentromsmenu, 0), clearid, MF_GRAYED); - - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_DATA | MIIM_ID | MIIM_STATE | MIIM_TYPE; - - moo.cch = 5; - moo.fType = 0; - moo.wID = baseid; - moo.dwTypeData = "None"; - moo.fState = MF_GRAYED; - - InsertMenuItem(GetSubMenu(recentromsmenu, 0), 0, TRUE, &moo); - - return; - } - - EnableMenuItem(GetSubMenu(recentromsmenu, 0), clearid, MF_ENABLED); - DeleteMenu(GetSubMenu(recentromsmenu, 0), baseid, MF_BYCOMMAND); - - HDC dc = GetDC(MainWindow->getHWnd()); - - //----------------------------------------------------------------------- - //Update the list using RecentRoms vector - for(int x = RecentRoms.size()-1; x >= 0; x--) //Must loop in reverse order since InsertMenuItem will insert as the first on the list - { - string tmp = RecentRoms[x]; - LPSTR tmp2 = (LPSTR)tmp.c_str(); - - PathCompactPath(dc, tmp2, 500); - - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; - - moo.cch = tmp.size(); - moo.fType = 0; - moo.wID = baseid + x; - moo.dwTypeData = tmp2; - //LOG("Inserting: %s\n",tmp.c_str()); //Debug - InsertMenuItem(GetSubMenu(recentromsmenu, 0), 0, 1, &moo); - } - - ReleaseDC(MainWindow->getHWnd(), dc); - //----------------------------------------------------------------------- - - HWND temp = MainWindow->getHWnd(); - DrawMenuBar(temp); -} - -void UpdateRecentRoms(const char* filename) -{ - //This function assumes filename is a ROM filename that was successfully loaded - - string newROM = filename; //Convert to std::string - - //-------------------------------------------------------------- - //Check to see if filename is in list - vector::iterator x; - vector::iterator theMatch; - bool match = false; - for (x = RecentRoms.begin(); x < RecentRoms.end(); ++x) - { - if (newROM == *x) - { - //We have a match - match = true; //Flag that we have a match - theMatch = x; //Hold on to the iterator (Note: the loop continues, so if for some reason we had a duplicate (which wouldn't happen under normal circumstances, it would pick the last one in the list) - } - } - //---------------------------------------------------------------- - //If there was a match, remove it - if (match) - RecentRoms.erase(theMatch); - - RecentRoms.insert(RecentRoms.begin(), newROM); //Add to the array - - //If over the max, we have too many, so remove the last entry - if (RecentRoms.size() > MAX_RECENT_ROMS) - RecentRoms.pop_back(); - - //Debug - //for (int x = 0; x < RecentRoms.size(); x++) - // LOG("Recent ROM: %s\n",RecentRoms[x].c_str()); - - UpdateRecentRomsMenu(); -} - -void RemoveRecentRom(std::string filename) -{ - - vector::iterator x; - vector::iterator theMatch; - bool match = false; - for (x = RecentRoms.begin(); x < RecentRoms.end(); ++x) - { - if (filename == *x) - { - //We have a match - match = true; //Flag that we have a match - theMatch = x; //Hold on to the iterator (Note: the loop continues, so if for some reason we had a duplicate (which wouldn't happen under normal circumstances, it would pick the last one in the list) - } - } - //---------------------------------------------------------------- - //If there was a match, remove it - if (match) - RecentRoms.erase(theMatch); - - UpdateRecentRomsMenu(); -} - -void GetRecentRoms() -{ - //This function retrieves the recent ROMs stored in the .ini file - //Then is populates the RecentRomsMenu array - //Then it calls Update RecentRomsMenu() to populate the menu - - stringstream temp; - char tempstr[256]; - - // Avoids duplicating when changing the language. - RecentRoms.clear(); - - //Loops through all available recent slots - for (int x = 0; x < MAX_RECENT_ROMS; x++) - { - temp.str(""); - temp << "Recent Rom " << (x+1); - - GetPrivateProfileString("General",temp.str().c_str(),"", tempstr, 256, IniName); - if (tempstr[0]) - RecentRoms.push_back(tempstr); - } - UpdateRecentRomsMenu(); -} - -void SaveRecentRoms() -{ - //This function stores the RecentRomsMenu array to the .ini file - - stringstream temp; - - //Loops through all available recent slots - for (int x = 0; x < MAX_RECENT_ROMS; x++) - { - temp.str(""); - temp << "Recent Rom " << (x+1); - if (x < (int)RecentRoms.size()) //If it exists in the array, save it - WritePrivateProfileString("General",temp.str().c_str(),RecentRoms[x].c_str(),IniName); - else //Else, make it empty - WritePrivateProfileString("General",temp.str().c_str(), "",IniName); - } -} - -void ClearRecentRoms() -{ - RecentRoms.clear(); - SaveRecentRoms(); - UpdateRecentRomsMenu(); -} - - - -int CreateDDrawBuffers() -{ - if (lpDDClipPrimary!=NULL) { IDirectDraw7_Release(lpDDClipPrimary); lpDDClipPrimary = NULL; } - if (lpPrimarySurface != NULL) { IDirectDraw7_Release(lpPrimarySurface); lpPrimarySurface = NULL; } - if (lpBackSurface != NULL) { IDirectDraw7_Release(lpBackSurface); lpBackSurface = NULL; } - - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - ddsd.dwFlags = DDSD_CAPS; - if (IDirectDraw7_CreateSurface(lpDDraw, &ddsd, &lpPrimarySurface, NULL) != DD_OK) return -1; - - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; - - ddsd.dwWidth = video.rotatedwidth(); - ddsd.dwHeight = video.rotatedheight(); - - if (IDirectDraw7_CreateSurface(lpDDraw, &ddsd, &lpBackSurface, NULL) != DD_OK) return -2; - - if (IDirectDraw7_CreateClipper(lpDDraw, 0, &lpDDClipPrimary, NULL) != DD_OK) return -3; - - if (IDirectDrawClipper_SetHWnd(lpDDClipPrimary, 0, MainWindow->getHWnd()) != DD_OK) return -4; - if (IDirectDrawSurface7_SetClipper(lpPrimarySurface, lpDDClipPrimary) != DD_OK) return -5; - - return 1; -} - - -template static T realConvert(u16 val) -{ - switch(bpp) - { - case 24: case 32: - return RGB15TO24_REVERSE(val); - case 16: return RGB15TO16_REVERSE(val); - default: - return 0; - } -} - - -template static FORCEINLINE T ddconvert(u32 val) -{ - //not supported yet, needs to drop from 32 to 16 - return val; - //switch(bpp) - //{ - // case 24: case 32: - // return RGB15TO24_REVERSE(val); - // case 16: return RGB15TO16_REVERSE(val); - // default: - // return 0; - //} -} - -template static void doRotate(void* dst) -{ - u8* buffer = (u8*)dst; - int size = video.size(); - u32* src = (u32*)video.finalBuffer(); - switch(video.rotation) - { - case 0: - case 180: - { - if(ddsd.lPitch == 1024) - { - if(video.rotation==180) - for(int i = 0, j=size-1; j>=0; i++,j--) - ((T*)buffer)[i] = ddconvert((src)[j]); - else - for(int i = 0; i < size; i++) - ((T*)buffer)[i] = ddconvert(src[i]); - } - else - { - if(video.rotation==180) - for(int y = 0; y < video.height; y++) - { - for(int x = 0; x < video.width; x++) - ((T*)buffer)[x] = ddconvert(src[video.height*video.width - (y * video.width) - x - 1]); - - buffer += ddsd.lPitch; - } - else - for(int y = 0; y < video.height; y++) - { - for(int x = 0; x < video.width; x++) - ((T*)buffer)[x] = ddconvert(src[(y * video.width) + x]); - - buffer += ddsd.lPitch; - } - } - } - break; - case 90: - case 270: - { - if(video.rotation == 90) - for(int y = 0; y < video.width; y++) - { - for(int x = 0; x < video.height; x++) - ((T*)buffer)[x] = ddconvert(src[(((video.height-1)-x) * video.width) + y]); - - buffer += ddsd.lPitch; - } - else - for(int y = 0; y < video.width; y++) - { - for(int x = 0; x < video.height; x++) - ((T*)buffer)[x] = ddconvert(src[((x) * video.width) + (video.width-1) - y]); - - buffer += ddsd.lPitch; - } - } - break; - } -} - -//the directdraw final presentation portion of display, including rotating -static void DD_DoDisplay() -{ - int res; - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags=DDSD_ALL; - res = lpBackSurface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL); - - if (res==DDERR_SURFACELOST) - { - LOG("DirectDraw buffers is lost\n"); - if (IDirectDrawSurface7_Restore(lpPrimarySurface)==DD_OK) - IDirectDrawSurface7_Restore(lpBackSurface); - } else if(res != DD_OK) - return; - - char* buffer = (char*)ddsd.lpSurface; - - switch(ddsd.ddpfPixelFormat.dwRGBBitCount) - { - case 32: doRotate(ddsd.lpSurface); break; - case 24: doRotate(ddsd.lpSurface); break; - case 16: doRotate(ddsd.lpSurface); break; - default: - { - INFO("Unsupported color depth: %i bpp\n", ddsd.ddpfPixelFormat.dwRGBBitCount); - emu_halt(); - } - break; - } - - - lpBackSurface->Unlock((LPRECT)ddsd.lpSurface); - - // Main screen - if(lpPrimarySurface->Blt(&MainScreenRect, lpBackSurface, &MainScreenSrcRect, DDBLT_WAIT, 0) == DDERR_SURFACELOST) - { - LOG("DirectDraw buffers is lost\n"); - if(IDirectDrawSurface7_Restore(lpPrimarySurface) == DD_OK) - IDirectDrawSurface7_Restore(lpBackSurface); - } - - // Sub screen - if(lpPrimarySurface->Blt(&SubScreenRect, lpBackSurface, &SubScreenSrcRect, DDBLT_WAIT, 0) == DDERR_SURFACELOST) - { - LOG("DirectDraw buffers is lost\n"); - if(IDirectDrawSurface7_Restore(lpPrimarySurface) == DD_OK) - IDirectDrawSurface7_Restore(lpBackSurface); - } - - // Gap - if(video.screengap > 0) - { - //u32 color = gapColors[win_fw_config.fav_colour]; - //u32 color_rev = (((color & 0xFF) << 16) | (color & 0xFF00) | ((color & 0xFF0000) >> 16)); - u32 color_rev = 0xFFFFFF; - - HDC dc; - HBRUSH brush; - - dc = GetDC(MainWindow->getHWnd()); - brush = CreateSolidBrush(color_rev); - - FillRect(dc, &GapRect, brush); - - DeleteObject((HGDIOBJ)brush); - ReleaseDC(MainWindow->getHWnd(), dc); - } -} - -//tripple buffering logic -u16 displayBuffers[3][256*192*4]; -volatile int currDisplayBuffer=-1; -volatile int newestDisplayBuffer=-2; -GMutex *display_mutex = NULL; -GThread *display_thread = NULL; -volatile bool display_die = false; - -static void DoDisplay_DrawHud() -{ - osd->update(); - DrawHUD(); - osd->clear(); -} - -//does a single display work unit. only to be used from the display thread -static void DoDisplay(bool firstTime) -{ - Lock lock (win_backbuffer_sync); - - //convert pixel format to 32bpp for compositing - //why do we do this over and over? well, we are compositing to - //filteredbuffer32bpp, and it needs to get refreshed each frame.. - const int size = video.size(); - u16* src = (u16*)video.srcBuffer; - for(int i=0;iattach((u8*)video.buffer, 256, 384, 1024); - DoDisplay_DrawHud(); - } - } - - //apply user's filter - video.filter(); - - if(!CommonSettings.single_core) - { - //draw and composite the OSD (but not if we are drawing osd straight to screen) - DoDisplay_DrawHud(); - T_AGG_RGBA target((u8*)video.finalBuffer(), video.width,video.height,video.width*4); - target.transformImage(aggDraw.hud->image(), 0,0,video.width-1,video.height-1); - aggDraw.hud->clear(); - } - - DD_DoDisplay(); -} - -void displayProc() -{ - g_mutex_lock(display_mutex); - - //find a buffer to display - int todo = newestDisplayBuffer; - bool alreadyDisplayed = (todo == currDisplayBuffer); - - g_mutex_unlock(display_mutex); - - //something new to display: - if(!alreadyDisplayed) { - //start displaying a new buffer - currDisplayBuffer = todo; - video.srcBuffer = (u8*)displayBuffers[currDisplayBuffer]; - - DoDisplay(true); - } - else - { - DoDisplay(false); - } -} - - -void displayThread(void*) -{ - for(;;) { - if(display_die) return; - displayProc(); - Sleep(10); //don't be greedy and use a whole cpu core, but leave room for 60fps - } -} - -void KillDisplay() -{ - display_die = true; - g_thread_join(display_thread); -} - -void Display() -{ - CallRegisteredLuaFunctions(LUACALL_AFTEREMULATIONGUI); - - if(CommonSettings.single_core) - { - video.srcBuffer = (u8*)GPU_screen; - DoDisplay(true); - } - else - { - if(display_thread == NULL) - { - display_mutex = g_mutex_new(); - display_thread = g_thread_create( (GThreadFunc)displayThread, - NULL, - TRUE, - NULL); - } - - g_mutex_lock(display_mutex); - - if(int diff = (currDisplayBuffer+1)%3 - newestDisplayBuffer) - newestDisplayBuffer += diff; - else newestDisplayBuffer = (currDisplayBuffer+2)%3; - - memcpy(displayBuffers[newestDisplayBuffer],GPU_screen,256*192*4); - - g_mutex_unlock(display_mutex); - } -} - - -void CheckMessages() -{ - MSG msg; - HWND hwnd = MainWindow->getHWnd(); - - #ifdef WX_STUB - wxDesmumeApp::frameUpdate(); - #endif - - while( PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ) ) - { - if( GetMessage( &msg, 0, 0, 0)>0 ) - { - if (RamWatchHWnd && IsDialogMessage(RamWatchHWnd, &msg)) - { - if(msg.message == WM_KEYDOWN) // send keydown messages to the dialog (for accelerators, and also needed for the Alt key to work) - SendMessage(RamWatchHWnd, msg.message, msg.wParam, msg.lParam); - continue; - } - if (SoundView_GetHWnd() && IsDialogMessage(SoundView_GetHWnd(), &msg)) - continue; - - if(!TranslateAccelerator(hwnd,hAccel,&msg)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - } -} - -DWORD WINAPI run() -{ - u32 cycles = 0; - int wait=0; - u64 freq; - u64 OneFrameTime; - int framestoskip=0; - int framesskipped=0; - int skipnextframe=0; - u64 lastticks=0; - u64 curticks=0; - u64 diffticks=0; - u32 framecount=0; - u64 onesecondticks=0; - int fps=0; - int fpsframecount=0; - u64 fpsticks=0; - HWND hwnd = MainWindow->getHWnd(); - - InitSpeedThrottle(); - - osd->setRotate(video.rotation); - - if (DirectDrawCreateEx(NULL, (LPVOID*)&lpDDraw, IID_IDirectDraw7, NULL) != DD_OK) - { - MessageBox(hwnd,"Unable to initialize DirectDraw","Error",MB_OK); - return -1; - } - - if (IDirectDraw7_SetCooperativeLevel(lpDDraw,hwnd, DDSCL_NORMAL) != DD_OK) - { - MessageBox(hwnd,"Unable to set DirectDraw Cooperative Level","Error",MB_OK); - return -1; - } - - if (CreateDDrawBuffers()<1) - { - MessageBox(hwnd,"Unable to set DirectDraw buffers","Error",MB_OK); - return -1; - } - - QueryPerformanceFrequency((LARGE_INTEGER *)&freq); - QueryPerformanceCounter((LARGE_INTEGER *)&lastticks); - OneFrameTime = freq / 60; - - while(!finished) - { - while(execute) - { - input_process(); - CallRegisteredLuaFunctions(LUACALL_BEFOREEMULATION); - FCEUMOV_AddInputState(); - - { - Lock lock; - NDS_exec(); - win_sound_samplecounter = 735; - } - DRV_AviVideoUpdate((u16*)GPU_screen); - - extern bool rewinding; - - if (staterewindingenabled) { - - if(rewinding) - dorewind(); - else - rewindsave(); - } - - CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION); - - static int fps3d = 0; - - Hud.fps = fps; - Hud.fps3d = fps3d; - - Display(); - - gfx3d.frameCtrRaw++; - if(gfx3d.frameCtrRaw == 60) { - fps3d = gfx3d.frameCtr; - gfx3d.frameCtrRaw = 0; - gfx3d.frameCtr = 0; - } - - - // TODO: make that thing properly threaded - static DWORD tools_time_last = 0; - DWORD time_now = timeGetTime(); - if((time_now - tools_time_last) >= 50) - { - if(MemView_IsOpened(ARMCPU_ARM9)) MemView_Refresh(ARMCPU_ARM9); - if(MemView_IsOpened(ARMCPU_ARM7)) MemView_Refresh(ARMCPU_ARM7); - // if(IORegView_IsOpened()) IORegView_Refresh(); - - tools_time_last = time_now; - } - if(SoundView_IsOpened()) SoundView_Refresh(); - - Update_RAM_Watch(); - Update_RAM_Search(); - - fpsframecount++; - QueryPerformanceCounter((LARGE_INTEGER *)&curticks); - bool oneSecond = curticks >= fpsticks + freq; - if(oneSecond) // TODO: print fps on screen in DDraw - { - fps = fpsframecount; - fpsframecount = 0; - QueryPerformanceCounter((LARGE_INTEGER *)&fpsticks); - } - - if(nds.idleFrameCounter==0 || oneSecond) - { - //calculate a 16 frame arm9 load average - int load = 0; - for(int i=0;i<16;i++) - load = load/8 + nds.runCycleCollector[(i+nds.idleFrameCounter)&15]*7/8; - load = std::min(100,std::max(0,(int)(load*100/1120380))); - //sprintf(txt,"(%02d%%) %s", load, DESMUME_NAME_AND_VERSION); - SetWindowText(hwnd, DESMUME_NAME_AND_VERSION); - } - - if(!skipnextframe) - { - framesskipped = 0; - - if (framestoskip > 0) - skipnextframe = 1; - } - else - { - framestoskip--; - - if (framestoskip < 1) - skipnextframe = 0; - else - skipnextframe = 1; - - framesskipped++; - - NDS_SkipNextFrame(); - } - - if(FastForward) { - if(framesskipped < 9) - { - skipnextframe = 1; - framestoskip = 1; - } - if (framestoskip < 1) - framestoskip += 9; - } - - else if(autoframeskipenab || FrameLimit) - while(SpeedThrottle()) - { - } - - if (autoframeskipenab) - { - framecount++; - - if (framecount > 60) - { - framecount = 1; - onesecondticks = 0; - } - - QueryPerformanceCounter((LARGE_INTEGER *)&curticks); - diffticks = curticks-lastticks; - - if(ThrottleIsBehind() && (framesskipped < 9)) - { - skipnextframe = 1; - framestoskip = 1; - } - - onesecondticks += diffticks; - lastticks = curticks; - } - else - { - if (framestoskip < 1) - framestoskip += frameskiprate; - } - if (frameAdvance) - { - frameAdvance = false; - emu_halt(); - SPU_Pause(1); - } -// DisplayMessage(); - CheckMessages(); - - } - - paused = TRUE; - CheckMessages(); - Sleep(100); - } - - return 1; -} - -void NDS_Pause() -{ - if (!paused) - { - emu_halt(); - paused = TRUE; - SPU_Pause(1); - while (!paused) {} - INFO("Emulation paused\n"); - } -} - -void NDS_UnPause() -{ - if (romloaded && paused) - { - paused = FALSE; - pausedByMinimize = FALSE; - execute = TRUE; - SPU_Pause(0); - INFO("Emulation unpaused\n"); - } -} - - -/*** - * Author: Hicoder - * Function: UpdateSaveStateMenu - * Date Added: April 20, 2009 - * Description: Updates the specified savestate menus - * Known Usage: - * ResetSaveStateTimes - * LoadSaveStateInfo - **/ -void UpdateSaveStateMenu(int pos, char* txt) -{ - ModifyMenu(mainMenu,IDM_STATE_SAVE_F1 + pos, MF_BYCOMMAND | MF_STRING, IDM_STATE_SAVE_F1 + pos, txt); - ModifyMenu(mainMenu,IDM_STATE_LOAD_F1 + pos, MF_BYCOMMAND | MF_STRING, IDM_STATE_LOAD_F1 + pos, txt); -} - -/*** - * Author: Hicoder - * Function: ResetSaveStateTime - * Date Added: April 20, 2009 - * Description: Resets the times for save states to blank - * Known Usage: - * LoadRom - **/ -void ResetSaveStateTimes() -{ - char ntxt[64]; - for(int i = 0; i < NB_STATES;i++) - { - sprintf(ntxt,"%d %s", i+1, ""); - UpdateSaveStateMenu(i, ntxt); - } -} - -/*** - * Author: Hicoder - * Function: LoadSaveStateInfo - * Date Added: April 20, 2009 - * Description: Checks The Rom thats opening for save states asscociated with it - * Known Usage: - * LoadRom - **/ -void LoadSaveStateInfo() -{ - scan_savestates(); - char ntxt[128]; - for(int i = 0; i < NB_STATES; i++) - { - if(savestates[i].exists) - { - sprintf(ntxt, "&%d %s", i+1, savestates[i].date); - UpdateSaveStateMenu(i, ntxt); - } - } -} - -static BOOL LoadROM(const char * filename, const char * logicalName) -{ - ResetSaveStateTimes(); - NDS_Pause(); - //if (strcmp(filename,"")!=0) INFO("Attempting to load ROM: %s\n",filename); - - if (NDS_LoadROM(filename, logicalName) > 0) - { - INFO("Loading %s was successful\n",logicalName); - LoadSaveStateInfo(); - lagframecounter=0; - UpdateRecentRoms(logicalName); - osd->setRotate(video.rotation); - if (AutoRWLoad) - { - //Open Ram Watch if its auto-load setting is checked - OpenRWRecentFile(0); - RamWatchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMWATCH), MainWindow->getHWnd(), (DLGPROC) RamWatchProc); - } - - return TRUE; - } - INFO("Loading %s FAILED.\n",logicalName); - return FALSE; -} - -/* -* The thread handling functions needed by the GDB stub code. -*/ -void * -createThread_gdb( void (APIENTRY *thread_function)( void *data), - void *thread_data) { - void *new_thread = CreateThread( NULL, 0, - (LPTHREAD_START_ROUTINE)thread_function, thread_data, - 0, NULL); - - return new_thread; -} - -void -joinThread_gdb( void *thread_handle) { -} - - -int MenuInit() -{ - mainMenu = LoadMenu(hAppInst, "MENU_PRINCIPAL"); //Load Menu, and store handle - if (!MainWindow->setMenu(mainMenu)) return 0; - - recentromsmenu = LoadMenu(hAppInst, "RECENTROMS"); - GetRecentRoms(); - - ResetSaveStateTimes(); - - return 1; -} - -void MenuDeinit() -{ - MainWindow->setMenu(NULL); - DestroyMenu(mainMenu); -} - -typedef int (WINAPI *setLanguageFunc)(LANGID id); - -void SetLanguage(int langid) -{ - - HMODULE kernel32 = LoadLibrary("kernel32.dll"); - FARPROC _setThreadUILanguage = (FARPROC)GetProcAddress(kernel32,"SetThreadUILanguage"); - setLanguageFunc setLanguage = _setThreadUILanguage?(setLanguageFunc)_setThreadUILanguage:(setLanguageFunc)SetThreadLocale; - - switch(langid) - { - case 0: - // English - setLanguage(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); - SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); - break; - case 1: - // French - setLanguage(MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH), SORT_DEFAULT)); - SetThreadLocale(MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH), SORT_DEFAULT)); - break; - case 2: - // Danish - setLanguage(MAKELCID(MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), SORT_DEFAULT)); - SetThreadLocale(MAKELCID(MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), SORT_DEFAULT)); - break; - case 3: - // Chinese - setLanguage(MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT)); - SetThreadLocale(MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT)); - break; - - default: break; - break; - } - - FreeLibrary(kernel32); -} - -void SaveLanguage(int langid) -{ - char text[80]; - - sprintf(text, "%d", langid); - WritePrivateProfileString("General", "Language", text, IniName); -} - -void CheckLanguage(UINT id) -{ - int i; - for (i = IDC_LANGENGLISH; i < IDC_LANG_CHINESE_SIMPLIFIED+1; i++) - MainWindow->checkMenu(i, false); - - MainWindow->checkMenu(id, true); -} - -void ChangeLanguage(int id) -{ - SetLanguage(id); - - MenuDeinit(); - MenuInit(); -} - -int RegClass(WNDPROC Proc, LPCTSTR szName) -{ - WNDCLASS wc; - - wc.style = CS_DBLCLKS; - wc.cbClsExtra = wc.cbWndExtra=0; - wc.lpfnWndProc=Proc; - wc.hInstance=hAppInst; - wc.hIcon=LoadIcon(hAppInst,"ICONDESMUME"); - wc.hCursor=LoadCursor(NULL,IDC_ARROW); - wc.hbrBackground=(HBRUSH)(COLOR_BACKGROUND); - wc.lpszMenuName=(LPCTSTR)NULL; - wc.lpszClassName=szName; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - return RegisterClass(&wc); -} - -static void ExitRunLoop() -{ - finished = TRUE; - emu_halt(); -} - -class WinDriver : public BaseDriver -{ - virtual bool WIFI_Host_InitSystem() { - #ifdef EXPERIMENTAL_WIFI - //require wpcap.dll - HMODULE temp = LoadLibrary("wpcap.dll"); - if(temp == NULL) { - printf("Failed initializing wpcap.dll - softAP support disabled\n"); - return false; - } - FreeLibrary(temp); - return true; - #else - return false ; - #endif - } - virtual void WIFI_Host_ShutdownSystem() { - } - - virtual bool AVI_IsRecording() - { - return ::AVI_IsRecording(); - } - - virtual bool WAV_IsRecording() - { - return ::WAV_IsRecording(); - } - - virtual void USR_InfoMessage(const char *message) - { - LOG("%s\n", message); - osd->addLine(message); - } - - virtual void AVI_SoundUpdate(void* soundData, int soundLen) { - ::DRV_AviSoundUpdate(soundData, soundLen); - } -}; - -std::string GetPrivateProfileStdString(LPCSTR lpAppName,LPCSTR lpKeyName,LPCSTR lpDefault) -{ - static char buf[65536]; - GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, buf, 65536, IniName); - return buf; -} - -int _main() -{ - InitDecoder(); - -#ifdef WX_STUB - wxInitialize(); -#endif - - driver = new WinDriver(); - - InitializeCriticalSection(&win_execute_sync); - InitializeCriticalSection(&win_backbuffer_sync); - -#ifdef GDB_STUB - gdbstub_handle_t arm9_gdb_stub; - gdbstub_handle_t arm7_gdb_stub; - struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; - struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; - struct armcpu_ctrl_iface *arm9_ctrl_iface; - struct armcpu_ctrl_iface *arm7_ctrl_iface; -#endif -// struct configured_features my_config; - - extern bool windows_opengl_init(); - oglrender_init = windows_opengl_init; - - - char text[80]; - - GetINIPath(); - - addon_type = GetPrivateProfileInt("GBAslot", "type", NDS_ADDON_NONE, IniName); - UINT CFlashFileMode = GetPrivateProfileInt("GBAslot.CFlash", "fileMode", 2, IniName); - - CFlashPath = GetPrivateProfileStdString("GBAslot.CFlash", "path", ""); - CFlashName = GetPrivateProfileStdString("GBAslot.CFlash", "filename", ""); - GetPrivateProfileString("GBAslot.GBAgame", "filename", "", GBAgameName, MAX_PATH, IniName); - - if(CFlashFileMode==ADDON_CFLASH_MODE_Path) - { - CFlash_Mode = ADDON_CFLASH_MODE_Path; - } - else - if(CFlashFileMode==ADDON_CFLASH_MODE_File) - { - CFlash_Path = CFlashName; - CFlash_Mode = ADDON_CFLASH_MODE_File; - } - else - { - CFlash_Path = ""; - CFlash_Mode = ADDON_CFLASH_MODE_RomPath; - } - - //init_configured_features( &my_config); - /*if ( !fill_configured_features( &my_config, lpszArgument)) { - MessageBox(NULL,"Unable to parse command line arguments","Error",MB_OK); - return 0; - }*/ - ColorCtrl_Register(); - - if (!RegClass(WindowProcedure, "DeSmuME")) - { - MessageBox(NULL, "Error registering windows class", "DeSmuME", MB_OK); - exit(-1); - } - - windowSize = GetPrivateProfileInt("Video","Window Size", 0, IniName); - video.rotation = GetPrivateProfileInt("Video","Window Rotate", 0, IniName); - ForceRatio = GetPrivateProfileBool("Video","Window Force Ratio", 1, IniName); - WndX = GetPrivateProfileInt("Video","WindowPosX", CW_USEDEFAULT, IniName); - WndY = GetPrivateProfileInt("Video","WindowPosY", CW_USEDEFAULT, IniName); - if(WndX < -10000) WndX = CW_USEDEFAULT; // fix for missing window problem - if(WndY < -10000) WndY = CW_USEDEFAULT; // (happens if you close desmume while it's minimized) - video.width = GetPrivateProfileInt("Video", "Width", 256, IniName); - video.height = GetPrivateProfileInt("Video", "Height", 384, IniName); - - CommonSettings.hud.FpsDisplay = GetPrivateProfileBool("Display","Display Fps", false, IniName); - CommonSettings.hud.FrameCounterDisplay = GetPrivateProfileBool("Display","FrameCounter", false, IniName); - CommonSettings.hud.ShowInputDisplay = GetPrivateProfileBool("Display","Display Input", false, IniName); - CommonSettings.hud.ShowGraphicalInputDisplay = GetPrivateProfileBool("Display","Display Graphical Input", false, IniName); - CommonSettings.hud.ShowLagFrameCounter = GetPrivateProfileBool("Display","Display Lag Counter", false, IniName); - CommonSettings.hud.ShowMicrophone = GetPrivateProfileBool("Display","Display Microphone", false, IniName); - - video.screengap = GetPrivateProfileInt("Display", "ScreenGap", 0, IniName); - SeparationBorderDrag = GetPrivateProfileBool("Display", "Window Split Border Drag", true, IniName); - FrameLimit = GetPrivateProfileBool("FrameLimit", "FrameLimit", true, IniName); - CommonSettings.showGpu.main = GetPrivateProfileInt("Display", "MainGpu", 1, IniName) != 0; - CommonSettings.showGpu.sub = GetPrivateProfileInt("Display", "SubGpu", 1, IniName) != 0; - lostFocusPause = GetPrivateProfileBool("Focus", "BackgroundPause", false, IniName); - - - //Get Ram-Watch values - RWSaveWindowPos = GetPrivateProfileBool("RamWatch", "SaveWindowPos", false, IniName); - ramw_x = GetPrivateProfileInt("RamWatch", "RWWindowPosX", 0, IniName); - ramw_y = GetPrivateProfileInt("RamWatch", "RWWindowPosY", 0, IniName); - AutoRWLoad = GetPrivateProfileBool("RamWatch", "Auto-load", false, IniName); - for(int i = 0; i < MAX_RECENT_WATCHES; i++) - { - char str[256]; - sprintf(str, "Recent Watch %d", i+1); - GetPrivateProfileString("Watches", str, "", &rw_recent_files[i][0], 1024, IniName); - } - - //i think we should override the ini file with anything from the commandline - CommandLine cmdline; - cmdline.loadCommonOptions(); - if(!cmdline.parse(__argc,__argv)) { - cmdline.errorHelp(__argv[0]); - return 1; - } - - //try and detect this for users who didn't specify it on the commandline - //(can't say I really blame them) - //this helps give a substantial speedup for singlecore users - SYSTEM_INFO systemInfo; - GetSystemInfo(&systemInfo); - if(systemInfo.dwNumberOfProcessors==1) - CommonSettings.single_core = true; - - Desmume_InitOnce(); - - //in case this isnt actually a singlecore system, but the user requested it - //then restrict ourselves to one core - if(CommonSettings.single_core) - SetProcessAffinityMask(GetCurrentProcess(),1); - - //sprintf(text, "%s", DESMUME_NAME_AND_VERSION); - MainWindow = new WINCLASS(CLASSNAME, hAppInst); - DWORD dwStyle = WS_CAPTION| WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; - if (!MainWindow->create(DESMUME_NAME_AND_VERSION, WndX/*CW_USEDEFAULT*/, WndY/*CW_USEDEFAULT*/, video.width,video.height+video.screengap, - WS_CAPTION| WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, - NULL)) - { - MessageBox(NULL, "Error creating main window", "DeSmuME", MB_OK); - delete MainWindow; - exit(-1); - } - - gpu_SetRotateScreen(video.rotation); - - /* default the firmware settings, they may get changed later */ - NDS_FillDefaultFirmwareConfigData( &win_fw_config); - - GetPrivateProfileString("General", "Language", "0", text, 80, IniName); - SetLanguage(atoi(text)); - - //hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL)); //Now that we have a hotkey system we down need the Accel table. Not deleting just yet though - - if(MenuInit() == 0) - { - MessageBox(NULL, "Error creating main menu", "DeSmuME", MB_OK); - delete MainWindow; - exit(-1); - } - - SetMinWindowSize(); - - ScaleScreen(windowSize); - - DragAcceptFiles(MainWindow->getHWnd(), TRUE); - -#ifdef EXPERIMENTAL_WIFI - EnableMenuItem(mainMenu, IDM_WIFISETTINGS, MF_ENABLED); -#endif - - - InitCustomKeys(&CustomKeys); - Hud.reset(); - - void input_init(); - input_init(); - - if (addon_type == NDS_ADDON_GUITARGRIP) Guitar.Enabled = true; - - LOG("Init NDS\n"); - - GInfo_Init(); - - MemView_Init(); - SoundView_Init(); - - ViewDisasm_ARM7 = new TOOLSCLASS(hAppInst, IDD_DESASSEMBLEUR_VIEWER7, (DLGPROC) ViewDisasm_ARM7Proc); - ViewDisasm_ARM9 = new TOOLSCLASS(hAppInst, IDD_DESASSEMBLEUR_VIEWER9, (DLGPROC) ViewDisasm_ARM9Proc); - //ViewMem_ARM7 = new TOOLSCLASS(hAppInst, IDD_MEM_VIEWER7, (DLGPROC) ViewMem_ARM7Proc); - //ViewMem_ARM9 = new TOOLSCLASS(hAppInst, IDD_MEM_VIEWER9, (DLGPROC) ViewMem_ARM9Proc); - ViewRegisters = new TOOLSCLASS(hAppInst, IDD_IO_REG, (DLGPROC) IoregView_Proc); - ViewPalette = new TOOLSCLASS(hAppInst, IDD_PAL, (DLGPROC) ViewPalProc); - ViewTiles = new TOOLSCLASS(hAppInst, IDD_TILE, (DLGPROC) ViewTilesProc); - ViewMaps = new TOOLSCLASS(hAppInst, IDD_MAP, (DLGPROC) ViewMapsProc); - ViewOAM = new TOOLSCLASS(hAppInst, IDD_OAM, (DLGPROC) ViewOAMProc); - ViewMatrices = new TOOLSCLASS(hAppInst, IDD_MATRIX_VIEWER, (DLGPROC) ViewMatricesProc); - ViewLights = new TOOLSCLASS(hAppInst, IDD_LIGHT_VIEWER, (DLGPROC) ViewLightsProc); - - - cmdline.process_addonCommands(); - if(cmdline.is_cflash_configured) - { - addon_type = NDS_ADDON_CFLASH; - //push the commandline-provided options into the current config slots - if(CFlash_Mode == ADDON_CFLASH_MODE_Path) - CFlashPath = CFlash_Path; - else - CFlashName = CFlash_Path; - } - - - switch (addon_type) - { - case NDS_ADDON_NONE: - break; - case NDS_ADDON_CFLASH: - break; - case NDS_ADDON_RUMBLEPAK: - break; - case NDS_ADDON_GBAGAME: - if (!strlen(GBAgameName)) - { - addon_type = NDS_ADDON_NONE; - break; - } - // TODO: check for file exist - break; - case NDS_ADDON_GUITARGRIP: - break; - default: - addon_type = NDS_ADDON_NONE; - break; - } - addonsChangePak(addon_type); - -#ifdef GDB_STUB - if ( cmdline.arm9_gdb_port != 0) { - arm9_gdb_stub = createStub_gdb( cmdline.arm9_gdb_port, - &arm9_memio, &arm9_direct_memory_iface); - - if ( arm9_gdb_stub == NULL) { - MessageBox(MainWindow->getHWnd(),"Failed to create ARM9 gdbstub","Error",MB_OK); - return -1; - } - } - if ( cmdline.arm7_gdb_port != 0) { - arm7_gdb_stub = createStub_gdb( cmdline.arm7_gdb_port, - &arm7_memio, - &arm7_base_memory_iface); - - if ( arm7_gdb_stub == NULL) { - MessageBox(MainWindow->getHWnd(),"Failed to create ARM7 gdbstub","Error",MB_OK); - return -1; - } - } - - NDS_Init( arm9_memio, &arm9_ctrl_iface, - arm7_memio, &arm7_ctrl_iface); -#else - NDS_Init (); -#endif - - /* - * Activate the GDB stubs - * This has to come after the NDS_Init where the cpus are set up. - */ -#ifdef GDB_STUB - if ( cmdline.arm9_gdb_port != 0) { - activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); - } - if ( cmdline.arm7_gdb_port != 0) { - activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); - } -#endif - - GetPrivateProfileString("General", "Language", "0", text, 80, IniName); - CheckLanguage(IDC_LANGENGLISH+atoi(text)); - - GetPrivateProfileString("Video", "FrameSkip", "0", text, 80, IniName); - - if (strcmp(text, "AUTO") == 0) - { - autoframeskipenab=1; - frameskiprate=0; - MainWindow->checkMenu(IDC_FRAMESKIPAUTO, true); - } - else - { - autoframeskipenab=0; - frameskiprate=atoi(text); - MainWindow->checkMenu(frameskiprate + IDC_FRAMESKIP0, true); - } - - int KeyInRepeatMSec=20; - - hKeyInputTimer = timeSetEvent (KeyInRepeatMSec, 0, KeyInputTimer, 0, TIME_PERIODIC); - - cur3DCore = GetPrivateProfileInt("3D", "Renderer", GPU3D_OPENGL, IniName); - CommonSettings.HighResolutionInterpolateColor = GetPrivateProfileBool("3D", "HighResolutionInterpolateColor", 1, IniName); - CommonSettings.gfx3d_flushMode = GetPrivateProfileInt("3D", "AlternateFlush", 0, IniName); - NDS_3D_ChangeCore(cur3DCore); - -#ifdef BETA_VERSION - EnableMenuItem (mainMenu, IDM_SUBMITBUGREPORT, MF_GRAYED); -#endif - LOG("Init sound core\n"); - sndcoretype = GetPrivateProfileInt("Sound","SoundCore2", SNDCORE_DIRECTX, IniName); - sndbuffersize = GetPrivateProfileInt("Sound","SoundBufferSize", 735 * 4, IniName); - CommonSettings.spuInterpolationMode = (SPUInterpolationMode)GetPrivateProfileInt("Sound","SPUInterpolation", 1, IniName); - CommonSettings.spuAdpcmCache = GetPrivateProfileInt("Sound","SPUAdpcmCache",0,IniName)!=0; - - EnterCriticalSection(&win_execute_sync); - int spu_ret = SPU_ChangeSoundCore(sndcoretype, sndbuffersize); - LeaveCriticalSection(&win_execute_sync); - if(spu_ret != 0) - { - MessageBox(MainWindow->getHWnd(),"Unable to initialize DirectSound","Error",MB_OK); - return -1; - } - - sndvolume = GetPrivateProfileInt("Sound","Volume",100, IniName); - SPU_SetVolume(sndvolume); - - CommonSettings.DebugConsole = GetPrivateProfileBool("Emulation", "DebugConsole", FALSE, IniName); - CommonSettings.UseExtBIOS = GetPrivateProfileBool("BIOS", "UseExtBIOS", FALSE, IniName); - GetPrivateProfileString("BIOS", "ARM9BIOSFile", "bios9.bin", CommonSettings.ARM9BIOS, 256, IniName); - GetPrivateProfileString("BIOS", "ARM7BIOSFile", "bios7.bin", CommonSettings.ARM7BIOS, 256, IniName); - CommonSettings.SWIFromBIOS = GetPrivateProfileBool("BIOS", "SWIFromBIOS", FALSE, IniName); - - CommonSettings.UseExtFirmware = GetPrivateProfileBool("Firmware", "UseExtFirmware", FALSE, IniName); - GetPrivateProfileString("Firmware", "FirmwareFile", "firmware.bin", CommonSettings.Firmware, 256, IniName); - CommonSettings.BootFromFirmware = GetPrivateProfileBool("Firmware", "BootFromFirmware", FALSE, IniName); - - CommonSettings.wifi.mode = GetPrivateProfileInt("Wifi", "Mode", 0, IniName); - CommonSettings.wifi.adhocMode = GetPrivateProfileInt("Wifi", "AdhocMode", 0, IniName); - GetPrivateProfileString("Wifi", "AdhocServerName", "", CommonSettings.wifi.adhocServerName, 64, IniName); - CommonSettings.wifi.infraBridgeAdapter = GetPrivateProfileInt("Wifi", "BridgeAdapter", 0, IniName); - - video.currentfilter = GetPrivateProfileInt("Video", "Filter", video.NONE, IniName); - FilterUpdate(MainWindow->getHWnd(),false); - - /* Read the firmware settings from the init file */ - win_fw_config.fav_colour = GetPrivateProfileInt("Firmware","favColor", 10, IniName); - win_fw_config.birth_month = GetPrivateProfileInt("Firmware","bMonth", 7, IniName); - win_fw_config.birth_day = GetPrivateProfileInt("Firmware","bDay", 15, IniName); - win_fw_config.language = GetPrivateProfileInt("Firmware","Language", 1, IniName); - - { - /* - * Read in the nickname and message. - * Convert the strings into Unicode UTF-16 characters. - */ - char temp_str[27]; - int char_index; - GetPrivateProfileString("Firmware","nickName", "yopyop", temp_str, 11, IniName); - win_fw_config.nickname_len = strlen( temp_str); - - if ( win_fw_config.nickname_len == 0) { - strcpy( temp_str, "yopyop"); - win_fw_config.nickname_len = strlen( temp_str); - } - - for ( char_index = 0; char_index < win_fw_config.nickname_len; char_index++) { - win_fw_config.nickname[char_index] = temp_str[char_index]; - } - - GetPrivateProfileString("Firmware","Message", "DeSmuME makes you happy!", temp_str, 27, IniName); - win_fw_config.message_len = strlen( temp_str); - for ( char_index = 0; char_index < win_fw_config.message_len; char_index++) { - win_fw_config.message[char_index] = temp_str[char_index]; - } - } - - // Create the dummy firmware - NDS_CreateDummyFirmware( &win_fw_config); - - - if (cmdline.nds_file != "") - { - if(OpenCore(cmdline.nds_file.c_str())) - { - romloaded = TRUE; - if(!cmdline.start_paused) - NDS_UnPause(); - } - } - - cmdline.process_movieCommands(); - - if(cmdline.load_slot != 0) - { - HK_StateLoadSlot(cmdline.load_slot); - } - - MainWindow->Show(SW_NORMAL); - run(); - - KillDisplay(); - - SaveRecentRoms(); - DRV_AviEnd(); - WAV_End(); - - NDS_DeInit(); - - //------SHUTDOWN - -#ifdef DEBUG - //LogStop(); -#endif - - GInfo_DeInit(); - - MemView_DlgClose(ARMCPU_ARM9); - MemView_DlgClose(ARMCPU_ARM7); - SoundView_DlgClose(); - //IORegView_DlgClose(); - - MemView_DeInit(); - SoundView_DeInit(); - - //if (input!=NULL) delete input; - if (ViewLights!=NULL) delete ViewLights; - if (ViewMatrices!=NULL) delete ViewMatrices; - if (ViewOAM!=NULL) delete ViewOAM; - if (ViewMaps!=NULL) delete ViewMaps; - if (ViewTiles!=NULL) delete ViewTiles; - if (ViewPalette!=NULL) delete ViewPalette; - if (ViewRegisters!=NULL) delete ViewRegisters; -// if (ViewMem_ARM9!=NULL) delete ViewMem_ARM9; -// if (ViewMem_ARM7!=NULL) delete ViewMem_ARM7; - if (ViewDisasm_ARM9!=NULL) delete ViewDisasm_ARM9; - if (ViewDisasm_ARM7!=NULL) delete ViewDisasm_ARM7; - - delete MainWindow; - - if (lpDDClipPrimary!=NULL) IDirectDraw7_Release(lpDDClipPrimary); - if (lpPrimarySurface != NULL) IDirectDraw7_Release(lpPrimarySurface); - if (lpBackSurface != NULL) IDirectDraw7_Release(lpBackSurface); - if (lpDDraw != NULL) IDirectDraw7_Release(lpDDraw); - - return 0; -} - -int WINAPI WinMain (HINSTANCE hThisInstance, - HINSTANCE hPrevInstance, - LPSTR lpszArgument, - int nFunsterStil) - -{ - timeBeginPeriod(1); - g_thread_init (NULL); - hAppInst=hThisInstance; - OpenConsole(); // Init debug console - - int ret = _main(); - - CloseConsole(); - - return ret; -} - -void UpdateWndRects(HWND hwnd) -{ - POINT ptClient; - RECT rc; - - int wndWidth, wndHeight; - int defHeight = (video.height + video.screengap); - float ratio; - int oneScreenHeight, gapHeight; - - GetClientRect(hwnd, &rc); - - if((video.rotation == 90) || (video.rotation == 270)) - { - wndWidth = (rc.bottom - rc.top); - wndHeight = (rc.right - rc.left); - } - else - { - wndWidth = (rc.right - rc.left); - wndHeight = (rc.bottom - rc.top); - } - - ratio = ((float)wndHeight / (float)defHeight); - oneScreenHeight = (int)((video.height/2) * ratio); - gapHeight = (wndHeight - (oneScreenHeight * 2)); - - if((video.rotation == 90) || (video.rotation == 270)) - { - // Main screen - ptClient.x = rc.left; - ptClient.y = rc.top; - ClientToScreen(hwnd, &ptClient); - MainScreenRect.left = ptClient.x; - MainScreenRect.top = ptClient.y; - ptClient.x = (rc.left + oneScreenHeight); - ptClient.y = (rc.top + wndWidth); - ClientToScreen(hwnd, &ptClient); - MainScreenRect.right = ptClient.x; - MainScreenRect.bottom = ptClient.y; - - //if there was no specified screen gap, extend the top screen to cover the extra column - if(video.screengap == 0) MainScreenRect.right += gapHeight; - - // Sub screen - ptClient.x = (rc.left + oneScreenHeight + gapHeight); - ptClient.y = rc.top; - ClientToScreen(hwnd, &ptClient); - SubScreenRect.left = ptClient.x; - SubScreenRect.top = ptClient.y; - ptClient.x = (rc.left + oneScreenHeight + gapHeight + oneScreenHeight); - ptClient.y = (rc.top + wndWidth); - ClientToScreen(hwnd, &ptClient); - SubScreenRect.right = ptClient.x; - SubScreenRect.bottom = ptClient.y; - - // Gap - GapRect.left = (rc.left + oneScreenHeight); - GapRect.top = rc.top; - GapRect.right = (rc.left + oneScreenHeight + gapHeight); - GapRect.bottom = (rc.top + wndWidth); - } - else - { - // Main screen - ptClient.x = rc.left; - ptClient.y = rc.top; - ClientToScreen(hwnd, &ptClient); - MainScreenRect.left = ptClient.x; - MainScreenRect.top = ptClient.y; - ptClient.x = (rc.left + wndWidth); - ptClient.y = (rc.top + oneScreenHeight); - ClientToScreen(hwnd, &ptClient); - MainScreenRect.right = ptClient.x; - MainScreenRect.bottom = ptClient.y; - - //if there was no specified screen gap, extend the top screen to cover the extra row - if(video.screengap == 0) MainScreenRect.bottom += gapHeight; - - // Sub screen - ptClient.x = rc.left; - ptClient.y = (rc.top + oneScreenHeight + gapHeight); - ClientToScreen(hwnd, &ptClient); - SubScreenRect.left = ptClient.x; - SubScreenRect.top = ptClient.y; - ptClient.x = (rc.left + wndWidth); - ptClient.y = (rc.top + oneScreenHeight + gapHeight + oneScreenHeight); - ClientToScreen(hwnd, &ptClient); - SubScreenRect.right = ptClient.x; - SubScreenRect.bottom = ptClient.y; - - // Gap - GapRect.left = rc.left; - GapRect.top = (rc.top + oneScreenHeight); - GapRect.right = (rc.left + wndWidth); - GapRect.bottom = (rc.top + oneScreenHeight + gapHeight); - } -} - -void UpdateScreenRects() -{ - if((video.rotation == 90) || (video.rotation == 270)) - { - // Main screen - MainScreenSrcRect.left = 0; - MainScreenSrcRect.top = 0; - MainScreenSrcRect.right = video.height/2; - MainScreenSrcRect.bottom = video.width; - - // Sub screen - SubScreenSrcRect.left = video.height/2; - SubScreenSrcRect.top = 0; - SubScreenSrcRect.right = video.height; - SubScreenSrcRect.bottom = video.width; - } - else - { - // Main screen - MainScreenSrcRect.left = 0; - MainScreenSrcRect.top = 0; - MainScreenSrcRect.right = video.width; - MainScreenSrcRect.bottom = video.height/2; - - // Sub screen - SubScreenSrcRect.left = 0; - SubScreenSrcRect.top = video.height/2; - SubScreenSrcRect.right = video.width; - SubScreenSrcRect.bottom = video.height; - } -} - -// re-run the aspect ratio calculations if enabled -void FixAspectRatio() -{ - if(windowSize != 0) - { - ScaleScreen(windowSize); - } - else if(ForceRatio) - { - RECT rc; - GetWindowRect(MainWindow->getHWnd(), &rc); - SendMessage(MainWindow->getHWnd(), WM_SIZING, WMSZ_BOTTOMRIGHT, (LPARAM)&rc); - MoveWindow(MainWindow->getHWnd(), rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE); - } -} - -void SetScreenGap(int gap) -{ - video.screengap = gap; - SetMinWindowSize(); - FixAspectRatio(); - UpdateWndRects(MainWindow->getHWnd()); -} - -//======================================================================================== -void SetRotate(HWND hwnd, int rot) -{ - Lock lock (win_backbuffer_sync); - - RECT rc; - int oldrot = video.rotation; - int oldheight, oldwidth; - int newheight, newwidth; - - video.rotation = rot; - - GetClientRect(hwnd, &rc); - oldwidth = (rc.right - rc.left); - oldheight = (rc.bottom - rc.top); - newwidth = oldwidth; - newheight = oldheight; - - switch(oldrot) - { - case 0: - case 180: - { - if((rot == 90) || (rot == 270)) - { - newwidth = oldheight; - newheight = oldwidth; - } - } - break; - - case 90: - case 270: - { - if((rot == 0) || (rot == 180)) - { - newwidth = oldheight; - newheight = oldwidth; - } - } - break; - } - - osd->setRotate(rot); - - SetMinWindowSize(); - - MainWindow->setClientSize(newwidth, newheight); - - /* Recreate the DirectDraw back buffer */ - if (lpBackSurface!=NULL) - { - IDirectDrawSurface7_Release(lpBackSurface); - - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; - ddsd.dwWidth = video.rotatedwidth(); - ddsd.dwHeight = video.rotatedheight(); - - IDirectDraw7_CreateSurface(lpDDraw, &ddsd, &lpBackSurface, NULL); - } - - WritePrivateProfileInt("Video","Window Rotate",video.rotation,IniName); - - gpu_SetRotateScreen(video.rotation); - - UpdateScreenRects(); -} - -void AviEnd() -{ - NDS_Pause(); - DRV_AviEnd(); - NDS_UnPause(); -} - -//Shows an Open File menu and starts recording an AVI -void AviRecordTo() -{ - NDS_Pause(); - - OPENFILENAME ofn; - - ////if we are playing a movie, construct the filename from the current movie. - ////else construct it from the filename. - //if(FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD)) - //{ - // extern char curMovieFilename[]; - // strcpy(szChoice, curMovieFilename); - // char* dot = strrchr(szChoice,'.'); - - // if (dot) - // { - // *dot='\0'; - // } - - // strcat(szChoice, ".avi"); - //} - //else - //{ - // extern char FileBase[]; - // sprintf(szChoice, "%s.avi", FileBase); - //} - - // avi record file browser - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = MainWindow->getHWnd(); - ofn.lpstrFilter = "AVI Files (*.avi)\0*.avi\0\0"; - ofn.lpstrDefExt = "avi"; - ofn.lpstrTitle = "Save AVI as"; - - char folder[MAX_PATH]; - ZeroMemory(folder, sizeof(folder)); - path.getpath(path.AVI_FILES, folder); - - char file[MAX_PATH]; - ZeroMemory(file, sizeof(file)); - path.formatname(file); - - strcat(folder, file); - int len = strlen(folder); - if(len > MAX_PATH - 4) - folder[MAX_PATH - 4] = '\0'; - - strcat(folder, ".avi"); - ofn.lpstrFile = folder; - - - ofn.nMaxFile = MAX_PATH; - ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; - - if(GetSaveFileName(&ofn)) - { - DRV_AviBegin(folder); - } - - NDS_UnPause(); -} - -void WavEnd() -{ - NDS_Pause(); - WAV_End(); - NDS_UnPause(); -} - -//Shows an Open File menu and starts recording an WAV -void WavRecordTo() -{ - NDS_Pause(); - - OPENFILENAME ofn; - char szChoice[MAX_PATH] = {0}; - - ////if we are playing a movie, construct the filename from the current movie. - ////else construct it from the filename. - //if(FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD)) - //{ - // extern char curMovieFilename[]; - // strcpy(szChoice, curMovieFilename); - // char* dot = strrchr(szChoice,'.'); - - // if (dot) - // { - // *dot='\0'; - // } - - // strcat(szChoice, ".wav"); - //} - //else - //{ - // extern char FileBase[]; - // sprintf(szChoice, "%s.wav", FileBase); - //} - - // wav record file browser - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = MainWindow->getHWnd(); - ofn.lpstrFilter = "WAV Files (*.wav)\0*.wav\0\0"; - ofn.lpstrFile = szChoice; - ofn.lpstrDefExt = "wav"; - ofn.lpstrTitle = "Save WAV as"; - - ofn.nMaxFile = MAX_PATH; - ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; - - if(GetSaveFileName(&ofn)) - { - WAV_Begin(szChoice); - } - - NDS_UnPause(); -} - -void OpenRecentROM(int listNum) -{ - if (listNum > MAX_RECENT_ROMS) return; //Just in case - char filename[MAX_PATH]; - strcpy(filename, RecentRoms[listNum].c_str()); - //LOG("Attempting to load %s\n",filename); - if(OpenCore(filename)) - { - romloaded = TRUE; - } - else - //Rom failed to load, ask the user how to handle it - { - string str = "Could not open "; - str.append(filename); - str.append("\n\nRemove from list?"); - if (MessageBox(MainWindow->getHWnd(), str.c_str(), "File error", MB_YESNO) == IDYES) - { - RemoveRecentRom(RecentRoms[listNum]); - } - } - - NDS_UnPause(); -} - -#include "OpenArchive.h" -#include "utils/xstring.h" - -static BOOL OpenCore(const char* filename) -{ - char LogicalName[1024], PhysicalName[1024]; - - const char* s_nonRomExtensions [] = {"txt", "nfo", "htm", "html", "jpg", "jpeg", "png", "bmp", "gif", "mp3", "wav", "lnk", "exe", "bat", "gmv", "gm2", "lua", "luasav", "sav", "srm", "brm", "cfg", "wch", "gs*", "dst"}; - - if(!ObtainFile(filename, LogicalName, PhysicalName, "rom", s_nonRomExtensions, ARRAY_SIZE(s_nonRomExtensions))) - return FALSE; - - if(LoadROM(filename, LogicalName)) - { - romloaded = TRUE; - NDS_UnPause(); - return TRUE; - } - else return FALSE; -} - -LRESULT OpenFile() -{ - HWND hwnd = MainWindow->getHWnd(); - - int filterSize = 0, i = 0; - OPENFILENAME ofn; - char filename[MAX_PATH] = "", - fileFilter[512]=""; - NDS_Pause(); //Stop emulation while opening new rom - - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwnd; - - // To avoid #ifdef hell, we'll do a little trick, as lpstrFilter - // needs 0 terminated string, and standard string library, of course, - // can't help us with string creation: just put a '|' were a string end - // should be, and later transform prior assigning to the OPENFILENAME structure - strncpy (fileFilter, "NDS ROM file (*.nds)|*.nds|NDS/GBA ROM File (*.ds.gba)|*.ds.gba|",512); -#ifdef HAVE_LIBZZIP - strncpy (fileFilter, "All Usable Files (*.nds, *.ds.gba, *.zip, *.gz, *.7z, *.rar, *.bz2)|*.nds;*.ds.gba;*.zip;*.gz;*.7z;*.rar;*.bz2|",512); -#endif - -#ifdef HAVE_LIBZZIP - strncat (fileFilter, "Zipped NDS ROM file (*.zip)|*.zip|",512 - strlen(fileFilter)); -#endif -#ifdef HAVE_LIBZ - strncat (fileFilter, "GZipped NDS ROM file (*.gz)|*.gz|",512 - strlen(fileFilter)); -#endif - strncat (fileFilter, "7Zipped NDS ROM file (*.7z)|*.7z|",512 - strlen(fileFilter)); - strncat (fileFilter, "RARed NDS ROM file (*.rar)|*.rar|",512 - strlen(fileFilter)); - strncat (fileFilter, "BZipped NDS ROM file (*.bz2)|*.bz2|",512 - strlen(fileFilter)); - - strncat (fileFilter, "Any file (*.*)|*.*||",512 - strlen(fileFilter)); - - filterSize = strlen(fileFilter); - for (i = 0; i < filterSize; i++) - { - if (fileFilter[i] == '|') fileFilter[i] = '\0'; - } - ofn.lpstrFilter = fileFilter; - ofn.nFilterIndex = 1; - ofn.lpstrFile = filename; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "nds"; - ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; - - char buffer[MAX_PATH]; - ZeroMemory(buffer, sizeof(buffer)); - path.getpath(path.ROMS, buffer); - ofn.lpstrInitialDir = buffer; - - - if (GetOpenFileName(&ofn) == NULL) { - NDS_UnPause(); - return 0; - } - else { - if(path.savelastromvisit) - { - char *lchr, buffer[MAX_PATH]; - ZeroMemory(buffer, sizeof(buffer)); - - lchr = strrchr(filename, '\\'); - strncpy(buffer, filename, strlen(filename) - strlen(lchr)); - - path.setpath(path.ROMS, buffer); - WritePathSettings(); - } - } - - if(!OpenCore(filename)) - return 0; - -// if(!GetOpenFileName(&ofn)) -// { -// if (romloaded) -// { -// CheatsSearchReset(); -// NDS_UnPause(); //Restart emulation if no new rom chosen -// } -// return 0; -// } - - - - return 0; -} - -//TODO - async key state? for real? -int GetModifiers(int key) -{ - int modifiers = 0; - - if (key == VK_MENU || key == VK_CONTROL || key == VK_SHIFT) - return 0; - - if(GetAsyncKeyState(VK_MENU )&0x8000) modifiers |= CUSTKEY_ALT_MASK; - if(GetAsyncKeyState(VK_CONTROL)&0x8000) modifiers |= CUSTKEY_CTRL_MASK; - if(GetAsyncKeyState(VK_SHIFT )&0x8000) modifiers |= CUSTKEY_SHIFT_MASK; - return modifiers; -} - -int HandleKeyUp(WPARAM wParam, LPARAM lParam, int modifiers) -{ - SCustomKey *key = &CustomKeys.key(0); - - while (!IsLastCustomKey(key)) { - if (wParam == key->key && modifiers == key->modifiers && key->handleKeyUp) { - key->handleKeyUp(key->param); - } - key++; - } - - return 1; -} - -int HandleKeyMessage(WPARAM wParam, LPARAM lParam, int modifiers) -{ - //some crap from snes9x I dont understand with toggles and macros... - - bool hitHotKey = false; - - if(!(wParam == 0 || wParam == VK_ESCAPE)) // if it's the 'disabled' key, it's never pressed as a hotkey - { - SCustomKey *key = &CustomKeys.key(0); - while (!IsLastCustomKey(key)) { - if (wParam == key->key && modifiers == key->modifiers && key->handleKeyDown) { - key->handleKeyDown(key->param); - hitHotKey = true; - } - key++; - } - - // don't pull down menu if alt is a hotkey or the menu isn't there, unless no game is running - //if(!Settings.StopEmulation && ((wParam == VK_MENU || wParam == VK_F10) && (hitHotKey || GetMenu (GUI.hWnd) == NULL) && !GetAsyncKeyState(VK_F4))) - /*if(((wParam == VK_MENU || wParam == VK_F10) && (hitHotKey || GetMenu (MainWindow->getHWnd()) == NULL) && !GetAsyncKeyState(VK_F4))) - return 0;*/ - return 1; - } - - return 1; -} - -static void Unpause() -{ - lastPauseFromLostFocus = FALSE; - if (emu_paused) NDS_UnPause(); - emu_paused = 0; -} - -void Pause() -{ - lastPauseFromLostFocus = FALSE; - if (emu_paused) NDS_UnPause(); - else NDS_Pause(); - emu_paused ^= 1; -} - -bool first; - -void FrameAdvance(bool state) -{ - if(state) { - if(first) { - execute = TRUE; - frameAdvance=true; - first=false; - } - else { - execute = TRUE; - } - } - else { - first = true; - if(frameAdvance) - {} - else - { - emu_halt(); - SPU_Pause(1); - emu_paused = 1; - } - } -} - -enum CONFIGSCREEN -{ - CONFIGSCREEN_INPUT, - CONFIGSCREEN_HOTKEY, - CONFIGSCREEN_FIRMWARE, - CONFIGSCREEN_WIFI, - CONFIGSCREEN_SOUND, - CONFIGSCREEN_EMULATION, - CONFIGSCREEN_MICROPHONE, - CONFIGSCREEN_PATHSETTINGS -}; - -void RunConfig(CONFIGSCREEN which) -{ - HWND hwnd = MainWindow->getHWnd(); - bool tpaused=false; - if (execute) - { - tpaused=true; - NDS_Pause(); - } - - switch(which) - { - case CONFIGSCREEN_INPUT: - RunInputConfig(); - break; - case CONFIGSCREEN_HOTKEY: - RunHotkeyConfig(); - break; - case CONFIGSCREEN_FIRMWARE: - DialogBox(hAppInst,MAKEINTRESOURCE(IDD_FIRMSETTINGS), hwnd, (DLGPROC) FirmConfig_Proc); - break; - case CONFIGSCREEN_SOUND: - DialogBox(hAppInst, MAKEINTRESOURCE(IDD_SOUNDSETTINGS), hwnd, (DLGPROC)SoundSettingsDlgProc); - break; - case CONFIGSCREEN_EMULATION: - DialogBox(hAppInst, MAKEINTRESOURCE(IDD_EMULATIONSETTINGS), hwnd, (DLGPROC)EmulationSettingsDlgProc); - break; - case CONFIGSCREEN_MICROPHONE: - DialogBox(hAppInst, MAKEINTRESOURCE(IDD_MICROPHONE), hwnd, (DLGPROC)MicrophoneSettingsDlgProc); - break; - case CONFIGSCREEN_PATHSETTINGS: - DialogBox(hAppInst, MAKEINTRESOURCE(IDD_PATHSETTINGS), hwnd, (DLGPROC)PathSettingsDlgProc); - break; - case CONFIGSCREEN_WIFI: -#ifdef EXPERIMENTAL_WIFI - if(wifi_netEnabled) - { - DialogBox(hAppInst,MAKEINTRESOURCE(IDD_WIFISETTINGS), hwnd, (DLGPROC) WifiSettingsDlgProc); - } - else - { -#endif - MessageBox(MainWindow->getHWnd(),"winpcap failed to initialize, and so wifi cannot be configured.","wifi system failure",0); -#ifdef EXPERIMENTAL_WIFI - } -#endif - break; - } - - if (tpaused) - NDS_UnPause(); -} - -void FilterUpdate (HWND hwnd, bool user) -{ - UpdateScreenRects(); - UpdateWndRects(hwnd); - SetScreenGap(video.screengap); - SetRotate(hwnd, video.rotation); - if(user && windowSize==0) {} - else ScaleScreen(windowSize); - WritePrivateProfileInt("Video", "Filter", video.currentfilter, IniName); - WritePrivateProfileInt("Video", "Width", video.width, IniName); - WritePrivateProfileInt("Video", "Height", video.height, IniName); -} - -void DesEnableMenuItem(HMENU hMenu, UINT uIDEnableItem, bool enable) -{ - EnableMenuItem(hMenu, uIDEnableItem, MF_BYCOMMAND | (enable?MF_ENABLED:MF_GRAYED)); -} - -//======================================================================================== -LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - static int tmp_execute; - switch (message) // handle the messages - { - case WM_ENTERMENULOOP: //Update menu items that needs to be updated dynamically - { - UpdateHotkeyAssignments(); //Add current hotkey mappings to menu item names - - MENUITEMINFO mii; - TCHAR menuItemString[256]; - ZeroMemory(&mii, sizeof(MENUITEMINFO)); - //Check if AVI is recording - mii.cbSize = sizeof(MENUITEMINFO); - mii.fMask = MIIM_STRING; - LoadString(hAppInst, !AVI_IsRecording() ? IDM_FILE_RECORDAVI : IDM_FILE_STOPAVI, menuItemString, 256); - mii.dwTypeData = menuItemString; - SetMenuItemInfo(mainMenu, IDM_FILE_RECORDAVI, FALSE, &mii); - //Check if WAV is recording - LoadString(hAppInst, !WAV_IsRecording() ? IDM_FILE_RECORDWAV : IDM_FILE_STOPWAV, menuItemString, 256); - SetMenuItemInfo(mainMenu, IDM_FILE_RECORDWAV, FALSE, &mii); - - //Menu items dependent on a ROM loaded - DesEnableMenuItem(mainMenu, IDM_GAME_INFO, romloaded); - DesEnableMenuItem(mainMenu, IDM_IMPORTBACKUPMEMORY,romloaded); - DesEnableMenuItem(mainMenu, IDM_EXPORTBACKUPMEMORY,romloaded); - DesEnableMenuItem(mainMenu, IDM_STATE_SAVE, romloaded); - DesEnableMenuItem(mainMenu, IDM_STATE_LOAD, romloaded); - DesEnableMenuItem(mainMenu, IDM_PRINTSCREEN, romloaded); - DesEnableMenuItem(mainMenu, IDM_QUICK_PRINTSCREEN, romloaded); - DesEnableMenuItem(mainMenu, IDM_FILE_RECORDAVI, romloaded); - DesEnableMenuItem(mainMenu, IDM_FILE_RECORDWAV, romloaded); - DesEnableMenuItem(mainMenu, IDM_RESET, romloaded); - DesEnableMenuItem(mainMenu, IDM_SHUT_UP, romloaded); - DesEnableMenuItem(mainMenu, IDM_CHEATS_LIST, romloaded); - DesEnableMenuItem(mainMenu, IDM_CHEATS_SEARCH, romloaded); - //DesEnableMenuItem(mainMenu, IDM_WIFISETTINGS, romloaded); - - DesEnableMenuItem(mainMenu, IDM_RECORD_MOVIE, (romloaded && movieMode == MOVIEMODE_INACTIVE)); - DesEnableMenuItem(mainMenu, IDM_PLAY_MOVIE, (romloaded && movieMode == MOVIEMODE_INACTIVE)); - DesEnableMenuItem(mainMenu, IDM_STOPMOVIE, (romloaded && movieMode != MOVIEMODE_INACTIVE)); - - DesEnableMenuItem(mainMenu, ID_RAM_WATCH, romloaded); - DesEnableMenuItem(mainMenu, ID_RAM_SEARCH, romloaded); - //Update savestate slot items based on ROM loaded - for (int x = 0; x < 10; x++) - { - DesEnableMenuItem(mainMenu, IDM_STATE_SAVE_F1+x, romloaded); - DesEnableMenuItem(mainMenu, IDM_STATE_LOAD_F1+x, romloaded); - } - - //Gray the recent ROM menu item if there are no recent ROMs - DesEnableMenuItem(mainMenu, ID_FILE_RECENTROM, RecentRoms.size()>0); - - //Updated Checked menu items - - //Pause - MainWindow->checkMenu(IDM_PAUSE, ((paused))); - //Force Maintain Ratio - MainWindow->checkMenu(IDC_FORCERATIO, ((ForceRatio))); - //Screen rotation - MainWindow->checkMenu(IDC_ROTATE0, ((video.rotation==0))); - MainWindow->checkMenu(IDC_ROTATE90, ((video.rotation==90))); - MainWindow->checkMenu(IDC_ROTATE180, ((video.rotation==180))); - MainWindow->checkMenu(IDC_ROTATE270, ((video.rotation==270))); - - //Window Size - MainWindow->checkMenu(IDC_WINDOW1X, ((windowSize==1))); - MainWindow->checkMenu(IDC_WINDOW1_5X, ((windowSize==65535))); - MainWindow->checkMenu(IDC_WINDOW2X, ((windowSize==2))); - MainWindow->checkMenu(IDC_WINDOW2_5X, ((windowSize==65534))); - MainWindow->checkMenu(IDC_WINDOW3X, ((windowSize==3))); - MainWindow->checkMenu(IDC_WINDOW4X, ((windowSize==4))); - - //Screen Separation - MainWindow->checkMenu(IDM_SCREENSEP_NONE, ((video.screengap==kGapNone))); - MainWindow->checkMenu(IDM_SCREENSEP_BORDER, ((video.screengap==kGapBorder))); - MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP, ((video.screengap==kGapNDS))); - MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP2, ((video.screengap==kGapNDS2))); - MainWindow->checkMenu(IDM_SCREENSEP_DRAGEDIT, (SeparationBorderDrag)); - - //Counters / Etc. - MainWindow->checkMenu(ID_VIEW_FRAMECOUNTER,CommonSettings.hud.FrameCounterDisplay); - MainWindow->checkMenu(ID_VIEW_DISPLAYFPS,CommonSettings.hud.FpsDisplay); - MainWindow->checkMenu(ID_VIEW_DISPLAYINPUT,CommonSettings.hud.ShowInputDisplay); - MainWindow->checkMenu(ID_VIEW_DISPLAYGRAPHICALINPUT,CommonSettings.hud.ShowGraphicalInputDisplay); - MainWindow->checkMenu(ID_VIEW_DISPLAYLAG,CommonSettings.hud.ShowLagFrameCounter); - MainWindow->checkMenu(ID_VIEW_DISPLAYMICROPHONE,CommonSettings.hud.ShowMicrophone); - MainWindow->checkMenu(ID_VIEW_HUDEDITOR, HudEditorMode); - MainWindow->checkMenu(IDC_FRAMELIMIT, FrameLimit); - - //Frame Skip - MainWindow->checkMenu(IDC_FRAMESKIPAUTO, ((autoframeskipenab))); - - MainWindow->checkMenu(IDC_FRAMESKIP0, (!autoframeskipenab && frameskiprate==0) ); - MainWindow->checkMenu(IDC_FRAMESKIP1, (!autoframeskipenab && frameskiprate==1) ); - MainWindow->checkMenu(IDC_FRAMESKIP2, (!autoframeskipenab && frameskiprate==2) ); - MainWindow->checkMenu(IDC_FRAMESKIP3, (!autoframeskipenab && frameskiprate==3) ); - MainWindow->checkMenu(IDC_FRAMESKIP4, (!autoframeskipenab && frameskiprate==4) ); - MainWindow->checkMenu(IDC_FRAMESKIP5, (!autoframeskipenab && frameskiprate==5) ); - MainWindow->checkMenu(IDC_FRAMESKIP6, (!autoframeskipenab && frameskiprate==6) ); - MainWindow->checkMenu(IDC_FRAMESKIP7, (!autoframeskipenab && frameskiprate==7) ); - MainWindow->checkMenu(IDC_FRAMESKIP8, (!autoframeskipenab && frameskiprate==8) ); - MainWindow->checkMenu(IDC_FRAMESKIP9, (!autoframeskipenab && frameskiprate==9) ); - - //gpu visibility toggles - MainWindow->checkMenu(IDM_MGPU, CommonSettings.showGpu.main ); - MainWindow->checkMenu(IDM_SGPU, CommonSettings.showGpu.sub ); - //TODO - change how the gpu visibility flags work - - //Filters - MainWindow->checkMenu(IDM_RENDER_NORMAL, video.currentfilter == video.NONE ); - MainWindow->checkMenu(IDM_RENDER_HQ2X, video.currentfilter == video.HQ2X ); - MainWindow->checkMenu(IDM_RENDER_2XSAI, video.currentfilter == video._2XSAI ); - MainWindow->checkMenu(IDM_RENDER_SUPER2XSAI, video.currentfilter == video.SUPER2XSAI ); - MainWindow->checkMenu(IDM_RENDER_SUPEREAGLE, video.currentfilter == video.SUPEREAGLE ); - MainWindow->checkMenu(IDM_RENDER_SCANLINE, video.currentfilter == video.SCANLINE ); - MainWindow->checkMenu(IDM_RENDER_BILINEAR, video.currentfilter == video.BILINEAR ); - MainWindow->checkMenu(IDM_RENDER_NEAREST2X, video.currentfilter == video.NEAREST2X ); - - MainWindow->checkMenu(IDC_STATEREWINDING, staterewindingenabled == 1 ); - - //Language selection - MainWindow->checkMenu(IDC_BACKGROUNDPAUSE, lostFocusPause); - - //Save type - const int savelist[] = {IDC_SAVETYPE1,IDC_SAVETYPE2,IDC_SAVETYPE3,IDC_SAVETYPE4,IDC_SAVETYPE5,IDC_SAVETYPE6,IDC_SAVETYPE7}; - for(int i=0;i<7;i++) - MainWindow->checkMenu(savelist[i], false); - MainWindow->checkMenu(savelist[CommonSettings.manualBackupType], true); - - - return 0; - } - /*case WM_EXITMENULOOP: - { - if (tmp_execute==2) NDS_UnPause(); - return 0; - }*/ - - case WM_CREATE: - { - path.ReadPathSettings(); - pausedByMinimize = FALSE; - UpdateScreenRects(); - return 0; - } - case WM_DESTROY: - case WM_CLOSE: - { - NDS_Pause(); - if (true/*AskSave()*/) //Ask Save comes from the Ram Watch dialog. The dialog uses .wch files and this allows asks the user if he wants to save changes first, should he cancel, closing will not happen - { - //Save window size - WritePrivateProfileInt("Video","Window Size",windowSize,IniName); - if (windowSize==0) - { - // WritePrivateProfileInt("Video","Window width",MainWindowRect.right-MainWindowRect.left+widthTradeOff,IniName); - // WritePrivateProfileInt("Video","Window height",MainWindowRect.bottom-MainWindowRect.top+heightTradeOff,IniName); - RECT rc; - GetClientRect(hwnd, &rc); - WritePrivateProfileInt("Video", "Window width", (rc.right - rc.left), IniName); - WritePrivateProfileInt("Video", "Window height", (rc.bottom - rc.top), IniName); - } - - //Save window position - WritePrivateProfileInt("Video", "WindowPosX", WndX/*MainWindowRect.left*/, IniName); - WritePrivateProfileInt("Video", "WindowPosY", WndY/*MainWindowRect.top*/, IniName); - - //Save frame counter status - WritePrivateProfileInt("Display", "FrameCounter", CommonSettings.hud.FrameCounterDisplay, IniName); - WritePrivateProfileInt("Display", "ScreenGap", video.screengap, IniName); - - //Save Ram Watch information - WritePrivateProfileInt("RamWatch", "SaveWindowPos", RWSaveWindowPos, IniName); - WritePrivateProfileInt("RamWatch", "RWWindowPosX", ramw_x, IniName); - WritePrivateProfileInt("RamWatch", "RWWindowPosY", ramw_y, IniName); - WritePrivateProfileInt("RamWatch", "Auto-load", AutoRWLoad, IniName); - - for(int i = 0; i < MAX_RECENT_WATCHES; i++) - { - char str[256]; - sprintf(str, "Recent Watch %d", i+1); - WritePrivateProfileString("Watches", str, &rw_recent_files[i][0], IniName); - } - - ExitRunLoop(); - } - else - NDS_UnPause(); - return 0; - } - case WM_MOVING: - InvalidateRect(hwnd, NULL, FALSE); UpdateWindow(hwnd); - return 0; - case WM_MOVE: { - RECT rect; - GetWindowRect(MainWindow->getHWnd(),&rect); - WndX = rect.left; - WndY = rect.top; - UpdateWndRects(hwnd); - return 0; - } - - case WM_KILLFOCUS: - if(lostFocusPause) { - if(!emu_paused) { - Pause(); - lastPauseFromLostFocus = TRUE; - } - } - return 0; - case WM_SETFOCUS: - if(lostFocusPause) { - if(lastPauseFromLostFocus) { - Unpause(); - } - } - return 0; - - case WM_SIZING: - { - InvalidateRect(hwnd, NULL, FALSE); UpdateWindow(hwnd); - - if(windowSize) - { - windowSize = 0; - MainWindow->checkMenu(IDC_WINDOW1X, false); - MainWindow->checkMenu(IDC_WINDOW1_5X, false); - MainWindow->checkMenu(IDC_WINDOW2X, false); - MainWindow->checkMenu(IDC_WINDOW2_5X, false); - MainWindow->checkMenu(IDC_WINDOW3X, false); - MainWindow->checkMenu(IDC_WINDOW4X, false); - } - - RECT cRect, ncRect; - GetClientRect(MainWindow->getHWnd(), &cRect); - GetWindowRect(MainWindow->getHWnd(), &ncRect); - - LONG forceRatioFlags = WINCLASS::NOKEEP; - bool setGap = false; - bool sideways = (video.rotation == 90) || (video.rotation == 270); - { - bool horizontalDrag = (wParam == WMSZ_LEFT) || (wParam == WMSZ_RIGHT); - bool verticalDrag = (wParam == WMSZ_TOP) || (wParam == WMSZ_BOTTOM); - int minX = video.rotatedwidthgap(); - int minY = video.rotatedheightgap(); - if(verticalDrag && !sideways && SeparationBorderDrag) - { - forceRatioFlags |= WINCLASS::KEEPX; - minY = (MainScreenRect.bottom - MainScreenRect.top) + (SubScreenRect.bottom - SubScreenRect.top); - setGap = true; - } - else if(horizontalDrag && sideways && SeparationBorderDrag) - { - forceRatioFlags |= WINCLASS::KEEPY; - minX = (MainScreenRect.right - MainScreenRect.left) + (SubScreenRect.right - SubScreenRect.left); - setGap = true; - } - else if(ForceRatio) - { - forceRatioFlags |= WINCLASS::KEEPX; - forceRatioFlags |= WINCLASS::KEEPY; - } - MainWindow->setMinSize(minX, minY); - } - - - MainWindow->sizingMsg(wParam, lParam, forceRatioFlags); - - - if(setGap) - { - RECT rc = *(RECT*)lParam; - rc.right += (cRect.right - cRect.left) - (ncRect.right - ncRect.left); - rc.bottom += (cRect.bottom - cRect.top) - (ncRect.bottom - ncRect.top); - int wndWidth, wndHeight, wndHeightGapless; - if(sideways) - { - wndWidth = (rc.bottom - rc.top); - wndHeight = (rc.right - rc.left); - wndHeightGapless = (MainScreenRect.right - MainScreenRect.left) + (SubScreenRect.right - SubScreenRect.left); - } - else - { - wndWidth = (rc.right - rc.left); - wndHeight = (rc.bottom - rc.top); - wndHeightGapless = (MainScreenRect.bottom - MainScreenRect.top) + (SubScreenRect.bottom - SubScreenRect.top); - } - if(ForceRatio) - video.screengap = wndHeight * video.width / wndWidth - video.height; - else - video.screengap = wndHeight * video.height / wndHeightGapless - video.height; - UpdateWndRects(MainWindow->getHWnd()); - } - } - return 1; - //break; - - case WM_GETMINMAXINFO: - if(ForceRatio) - { - // extend the window size limits, otherwise they can make our window get squashed - PMINMAXINFO pmmi = (PMINMAXINFO)lParam; - pmmi->ptMaxTrackSize.x *= 4; - pmmi->ptMaxTrackSize.y *= 4; - return 1; - } - break; - - case WM_KEYDOWN: - if(wParam != VK_PAUSE) - break; - case WM_SYSKEYDOWN: - case WM_CUSTKEYDOWN: - { - int modifiers = GetModifiers(wParam); - if(!HandleKeyMessage(wParam,lParam, modifiers)) - return 0; - break; - } - case WM_KEYUP: - if(wParam != VK_PAUSE) - break; - case WM_SYSKEYUP: - case WM_CUSTKEYUP: - { - int modifiers = GetModifiers(wParam); - HandleKeyUp(wParam, lParam, modifiers); - } - break; - - case WM_SIZE: - switch(wParam) - { - case SIZE_MINIMIZED: - { - if(!paused) - { - pausedByMinimize = TRUE; - NDS_Pause(); - } - } - break; - default: - { - if(pausedByMinimize) - NDS_UnPause(); - - UpdateWndRects(hwnd); - } - break; - } - return 0; - case WM_PAINT: - { - HDC hdc; - PAINTSTRUCT ps; - - hdc = BeginPaint(hwnd, &ps); - - Display(); - - EndPaint(hwnd, &ps); - } - return 0; - case WM_DROPFILES: - { - char filename[MAX_PATH] = ""; - DragQueryFile((HDROP)wParam,0,filename,MAX_PATH); - DragFinish((HDROP)wParam); - - //adelikat: dropping these in from FCEUX, I hope this is the best place for that - std::string fileDropped = filename; - //------------------------------------------------------- - //Check if Movie file - //------------------------------------------------------- - if (!(fileDropped.find(".dsm") == string::npos) && (fileDropped.find(".dsm") == fileDropped.length()-4)) //ROM is already loaded and .dsm in filename - { - if (romloaded && !(fileDropped.find(".dsm") == string::npos)) //.dsm is at the end of the filename so that must be the extension - FCEUI_LoadMovie(fileDropped.c_str(), 1, false, false); //We are convinced it is a movie file, attempt to load it - } - - //------------------------------------------------------- - //Check if Savestate file - //------------------------------------------------------- - else if (!(fileDropped.find(".ds") == string::npos)) - { - size_t extIndex = fileDropped.find(".ds"); - if (extIndex <= fileDropped.length()-4) //Check to see it is both at the end (file extension) and there is on more character - { - if ((fileDropped[extIndex+3] >= '0' && fileDropped[extIndex+3] <= '9') || fileDropped[extIndex+3] == '-' || fileDropped[extIndex+3] == 't') //If last character is 0-9 (making .ds0 - .ds9) or .dst - { - savestate_load(filename); - Update_RAM_Watch(); //adelikat: TODO this should be a single function call in main, that way we can expand as future dialogs need updating - Update_RAM_Search(); //hotkey.cpp - HK_StateLoadSlot & State_Load also call these functions - } - } - } - - //------------------------------------------------------- - //Else load it as a ROM - //------------------------------------------------------- - - else if(OpenCore(filename)) - { - romloaded = TRUE; - } - NDS_UnPause(); - } - return 0; - case WM_MOUSEMOVE: - case WM_LBUTTONDOWN: - case WM_LBUTTONDBLCLK: - if (wParam & MK_LBUTTON) - { - RECT r ; - s32 x = (s32)((s16)LOWORD(lParam)); - s32 y = (s32)((s16)HIWORD(lParam)); - GetClientRect(hwnd,&r); - SetCapture(hwnd); - int defwidth = video.width, defheight = (video.height+video.screengap); - int winwidth = (r.right-r.left), winheight = (r.bottom-r.top); - - // translate from scaling (screen resolution to 256x384 or 512x192) - switch (video.rotation) - { - case 0: - case 180: - x = (x*defwidth) / winwidth; - y = (y*defheight) / winheight; - break ; - case 90: - case 270: - x = (x*defheight) / winwidth; - y = (y*defwidth) / winheight; - break ; - } - - x = x/video.ratio(); - y = y/video.ratio(); - - if(HudEditorMode) { - EditHud(x,y, &Hud); - } - else { - //translate for rotation - if (video.rotation != 0) - translateXY(x,y); - else - y-=192+(video.screengap/video.ratio()); - - if(x<0) x = 0; else if(x>255) x = 255; - if(y<0) y = 0; else if(y>192) y = 192; - NDS_setTouchPos(x, y); - return 0; - } - } - NDS_releaseTouch(); - return 0; - - case WM_LBUTTONUP: - - ReleaseCapture(); - NDS_releaseTouch(); - HudClickRelease(&Hud); - return 0; - -#if 0 - case WM_INITMENU: { - HMENU menu = (HMENU)wParam; - //last minute modification of menu before display - #ifndef DEVELOPER - RemoveMenu(menu,IDM_DISASSEMBLER,MF_BYCOMMAND); - #endif - break; - } -#endif - - case WM_COMMAND: - if(HIWORD(wParam) == 0 || HIWORD(wParam) == 1) - { - //wParam &= 0xFFFF; - - // A menu item from the recent files menu was clicked. - if(wParam >= baseid && wParam <= baseid + MAX_RECENT_ROMS - 1) - { - int x = wParam - baseid; - OpenRecentROM(x); - } - else if(wParam == clearid) - { - /* Clear all the recent ROMs */ - ClearRecentRoms(); - } - - } - switch(LOWORD(wParam)) - { - case IDM_SHUT_UP: - if(SPU_user) SPU_user->ShutUp(); - return 0; - case IDM_QUIT: - if (AskSave()) DestroyWindow(hwnd); - return 0; - case IDM_OPEN: - return OpenFile(); - case IDM_PRINTSCREEN: - HK_PrintScreen(0); - return 0; - case IDM_QUICK_PRINTSCREEN: - { - char buffer[MAX_PATH]; - ZeroMemory(buffer, sizeof(buffer)); - path.getpath(path.SCREENSHOTS, buffer); - - char file[MAX_PATH]; - ZeroMemory(file, sizeof(file)); - path.formatname(file); - - strcat(buffer, file); - if( strlen(buffer) > (MAX_PATH - 4)) - buffer[MAX_PATH - 4] = '\0'; - - switch(path.imageformat()) - { - case path.PNG: - { - strcat(buffer, ".png"); - NDS_WritePNG(buffer); - } - break; - case path.BMP: - { - strcat(buffer, ".bmp"); - NDS_WriteBMP(buffer); - } - break; - } - } - return 0; - case IDM_FILE_RECORDAVI: - if (AVI_IsRecording()) - AviEnd(); - else - AviRecordTo(); - break; - case IDM_FILE_RECORDWAV: - if (WAV_IsRecording()) - WAV_End(); - else - WavRecordTo(); - break; - case IDC_STATEREWINDING: - if(staterewindingenabled) staterewindingenabled = false; - else staterewindingenabled = true; - break; - case IDM_RENDER_NORMAL: - { - Lock lock (win_backbuffer_sync); - video.setfilter(video.NONE); - FilterUpdate(hwnd); - } - break; - case IDM_RENDER_HQ2X: - { - Lock lock (win_backbuffer_sync); - video.setfilter(video.HQ2X); - FilterUpdate(hwnd); - } - break; - case IDM_RENDER_2XSAI: - { - Lock lock (win_backbuffer_sync); - video.setfilter(video._2XSAI); - FilterUpdate(hwnd); - } - break; - case IDM_RENDER_SUPER2XSAI: - { - Lock lock (win_backbuffer_sync); - video.setfilter(video.SUPER2XSAI); - FilterUpdate(hwnd); - } - break; - case IDM_RENDER_SUPEREAGLE: - { - Lock lock (win_backbuffer_sync); - video.setfilter(video.SUPEREAGLE); - FilterUpdate(hwnd); - } - break; - case IDM_RENDER_SCANLINE: - { - Lock lock (win_backbuffer_sync); - video.setfilter(video.SCANLINE); - FilterUpdate(hwnd); - } - break; - case IDM_RENDER_BILINEAR: - { - Lock lock (win_backbuffer_sync); - video.setfilter(video.BILINEAR); - FilterUpdate(hwnd); - } - break; - case IDM_RENDER_NEAREST2X: - { - Lock lock (win_backbuffer_sync); - video.setfilter(video.NEAREST2X); - FilterUpdate(hwnd); - } - break; - case IDM_STATE_LOAD: - { - OPENFILENAME ofn; - NDS_Pause(); - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = "DeSmuME Savestate (*.dst or *.ds#)\0*.dst;*.ds0*;*.ds1*;*.ds2*;*.ds3*;*.ds4*;*.ds5*;*.ds6*;*.ds7*;*.ds8*;*.ds9*;*.ds-*\0DeSmuME Savestate (*.dst only)\0*.dst\0All files (*.*)\0*.*\0\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile = SavName; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "dst"; - ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; - - char buffer[MAX_PATH]; - ZeroMemory(buffer, sizeof(buffer)); - path.getpath(path.STATES, buffer); - ofn.lpstrInitialDir = buffer; - - if(!GetOpenFileName(&ofn)) - { - NDS_UnPause(); - return 0; - } - - savestate_load(SavName); - Update_RAM_Watch(); //adelikat: TODO this should be a single function call in main, that way we can expand as future dialogs need updating - Update_RAM_Search(); //hotkey.cpp - HK_StateLoadSlot also calls these functions - NDS_UnPause(); - } - return 0; - case IDM_STATE_SAVE: - { - OPENFILENAME ofn; - NDS_Pause(); - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = "DeSmuME Savestate (*.dst or *.ds#)\0*.dst;*.ds0*;*.ds1*;*.ds2*;*.ds3*;*.ds4*;*.ds5*;*.ds6*;*.ds7*;*.ds8*;*.ds9*;*.ds-*\0DeSmuME Savestate (*.dst only)\0*.dst\0All files (*.*)\0*.*\0\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile = SavName; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "dst"; - ofn.Flags = OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; - - char buffer[MAX_PATH]; - ZeroMemory(buffer, sizeof(buffer)); - path.getpath(path.STATES, buffer); - ofn.lpstrInitialDir = buffer; - - if(!GetSaveFileName(&ofn)) - { - return 0; - } - - savestate_save(SavName); - LoadSaveStateInfo(); - NDS_UnPause(); - } - return 0; - case IDM_STATE_SAVE_F1: - case IDM_STATE_SAVE_F2: - case IDM_STATE_SAVE_F3: - case IDM_STATE_SAVE_F4: - case IDM_STATE_SAVE_F5: - case IDM_STATE_SAVE_F6: - case IDM_STATE_SAVE_F7: - case IDM_STATE_SAVE_F8: - case IDM_STATE_SAVE_F9: - case IDM_STATE_SAVE_F10: - HK_StateSaveSlot( abs(IDM_STATE_SAVE_F1 - LOWORD(wParam)) +1); - return 0; - - case IDM_STATE_LOAD_F1: - HK_StateLoadSlot(1); - return 0; - case IDM_STATE_LOAD_F2: - HK_StateLoadSlot(2); - return 0; - case IDM_STATE_LOAD_F3: - HK_StateLoadSlot(3); - return 0; - case IDM_STATE_LOAD_F4: - HK_StateLoadSlot(4); - return 0; - case IDM_STATE_LOAD_F5: - HK_StateLoadSlot(5); - return 0; - case IDM_STATE_LOAD_F6: - HK_StateLoadSlot(6); - return 0; - case IDM_STATE_LOAD_F7: - HK_StateLoadSlot(7); - return 0; - case IDM_STATE_LOAD_F8: - HK_StateLoadSlot(8); - return 0; - case IDM_STATE_LOAD_F9: - HK_StateLoadSlot(9); - return 0; - case IDM_STATE_LOAD_F10: - HK_StateLoadSlot(10); - return 0; - case IDM_IMPORTBACKUPMEMORY: - { - OPENFILENAME ofn; - NDS_Pause(); - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = "All supported types\0*.duc;*.sav\0Action Replay DS Save (*.duc)\0*.duc\0Raw Save format (*.sav)\0*.sav\0\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile = ImportSavName; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "duc"; - ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; - - char buffer[MAX_PATH]; - ZeroMemory(buffer, sizeof(buffer)); - path.getpath(path.BATTERY, buffer); - ofn.lpstrInitialDir = buffer; - - if(!GetOpenFileName(&ofn)) - { - NDS_UnPause(); - return 0; - } - - if (!NDS_ImportSave(ImportSavName)) - MessageBox(hwnd,"Save was not successfully imported","Error",MB_OK); - NDS_UnPause(); - return 0; - } - case IDM_EXPORTBACKUPMEMORY: - { - OPENFILENAME ofn; - NDS_Pause(); - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = "Raw Save format (*.sav)\0*.sav\0\0"; - ofn.nFilterIndex = 0; - ofn.lpstrFile = ImportSavName; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "sav"; - ofn.Flags = OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; - - if(!GetSaveFileName(&ofn)) - { - NDS_UnPause(); - return 0; - } - - if (!NDS_ExportSave(ImportSavName)) - MessageBox(hwnd,"Save was not successfully exported","Error",MB_OK); - NDS_UnPause(); - return 0; - } - - - case IDM_CONFIG: - RunConfig(CONFIGSCREEN_INPUT); - return 0; - case IDM_HOTKEY_CONFIG: - RunConfig(CONFIGSCREEN_HOTKEY); - return 0; - case IDM_FIRMSETTINGS: - RunConfig(CONFIGSCREEN_FIRMWARE); - return 0; - case IDM_SOUNDSETTINGS: - RunConfig(CONFIGSCREEN_SOUND); - return 0; - case IDM_WIFISETTINGS: - RunConfig(CONFIGSCREEN_WIFI); - return 0; - case IDM_EMULATIONSETTINGS: - RunConfig(CONFIGSCREEN_EMULATION); - return 0; - case IDM_MICROPHONESETTINGS: - RunConfig(CONFIGSCREEN_MICROPHONE); - return 0; - case IDM_PATHSETTINGS: - RunConfig(CONFIGSCREEN_PATHSETTINGS); - return 0; - - case IDM_GAME_INFO: - { - //CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_GAME_INFO), hwnd, GinfoView_Proc); - GInfo_DlgOpen(hwnd); - } - return 0; - - //========================================================= Tools - case IDM_PAL: - ViewPalette->open(); - return 0; - case IDM_TILE: - { - ViewTiles->regClass("TileViewBox", TileViewBoxProc); - ViewTiles->regClass("MiniTileViewBox", MiniTileViewBoxProc, true); - if (!ViewTiles->open()) - ViewTiles->unregClass(); - } - return 0; - case IDM_IOREG: - ViewRegisters->open(); - //IORegView_DlgOpen(HWND_DESKTOP, "I/O registers"); - return 0; - case IDM_MEMORY: - /* ViewMem_ARM7->regClass("MemViewBox7", ViewMem_ARM7BoxProc); - if (!ViewMem_ARM7->open()) - ViewMem_ARM7->unregClass(); - ViewMem_ARM9->regClass("MemViewBox9", ViewMem_ARM9BoxProc); - if (!ViewMem_ARM9->open()) - ViewMem_ARM9->unregClass();*/ - if(!MemView_IsOpened(ARMCPU_ARM9)) MemView_DlgOpen(HWND_DESKTOP, "ARM9 memory", ARMCPU_ARM9); - if(!MemView_IsOpened(ARMCPU_ARM7)) MemView_DlgOpen(HWND_DESKTOP, "ARM7 memory", ARMCPU_ARM7); - return 0; - case IDM_SOUND_VIEW: - if(!SoundView_IsOpened()) SoundView_DlgOpen(HWND_DESKTOP); - return 0; - case IDM_DISASSEMBLER: - ViewDisasm_ARM7->regClass("DesViewBox7",ViewDisasm_ARM7BoxProc); - if (!ViewDisasm_ARM7->open()) - ViewDisasm_ARM7->unregClass(); - - ViewDisasm_ARM9->regClass("DesViewBox9",ViewDisasm_ARM9BoxProc); - if (!ViewDisasm_ARM9->open()) - ViewDisasm_ARM9->unregClass(); - return 0; - case IDM_MAP: - ViewMaps->open(); - return 0; - case IDM_OAM: - ViewOAM->regClass("OAMViewBox", ViewOAMBoxProc); - if (!ViewOAM->open()) - ViewOAM->unregClass(); - return 0; - - case IDM_MATRIX_VIEWER: - ViewMatrices->open(); - return 0; - - case IDM_LIGHT_VIEWER: - ViewLights->open(); - return 0; - //========================================================== Tools end - - case IDM_MGPU: - CommonSettings.showGpu.main = !CommonSettings.showGpu.main; - WritePrivateProfileInt("Display","MainGpu",CommonSettings.showGpu.main?1:0,IniName); - return 0; - - case IDM_SGPU: - CommonSettings.showGpu.sub = !CommonSettings.showGpu.sub; - WritePrivateProfileInt("Display","SubGpu",CommonSettings.showGpu.sub?1:0,IniName); - return 0; - - case IDM_MBG0 : - if(MainScreen.gpu->dispBG[0]) - { - GPU_remove(MainScreen.gpu, 0); - MainWindow->checkMenu(IDM_MBG0, false); - } - else - { - GPU_addBack(MainScreen.gpu, 0); - MainWindow->checkMenu(IDM_MBG0, true); - } - return 0; - case IDM_MBG1 : - if(MainScreen.gpu->dispBG[1]) - { - GPU_remove(MainScreen.gpu, 1); - MainWindow->checkMenu(IDM_MBG1, false); - } - else - { - GPU_addBack(MainScreen.gpu, 1); - MainWindow->checkMenu(IDM_MBG1, true); - } - return 0; - case IDM_MBG2 : - if(MainScreen.gpu->dispBG[2]) - { - GPU_remove(MainScreen.gpu, 2); - MainWindow->checkMenu(IDM_MBG2, false); - } - else - { - GPU_addBack(MainScreen.gpu, 2); - MainWindow->checkMenu(IDM_MBG2, true); - } - return 0; - case IDM_MBG3 : - if(MainScreen.gpu->dispBG[3]) - { - GPU_remove(MainScreen.gpu, 3); - MainWindow->checkMenu(IDM_MBG3, false); - } - else - { - GPU_addBack(MainScreen.gpu, 3); - MainWindow->checkMenu(IDM_MBG3, true); - } - return 0; - case IDM_SBG0 : - if(SubScreen.gpu->dispBG[0]) - { - GPU_remove(SubScreen.gpu, 0); - MainWindow->checkMenu(IDM_SBG0, false); - } - else - { - GPU_addBack(SubScreen.gpu, 0); - MainWindow->checkMenu(IDM_SBG0, true); - } - return 0; - case IDM_SBG1 : - if(SubScreen.gpu->dispBG[1]) - { - GPU_remove(SubScreen.gpu, 1); - MainWindow->checkMenu(IDM_SBG1, false); - } - else - { - GPU_addBack(SubScreen.gpu, 1); - MainWindow->checkMenu(IDM_SBG1, true); - } - return 0; - case IDM_SBG2 : - if(SubScreen.gpu->dispBG[2]) - { - GPU_remove(SubScreen.gpu, 2); - MainWindow->checkMenu(IDM_SBG2, false); - } - else - { - GPU_addBack(SubScreen.gpu, 2); - MainWindow->checkMenu(IDM_SBG2, true); - } - return 0; - case IDM_SBG3 : - if(SubScreen.gpu->dispBG[3]) - { - GPU_remove(SubScreen.gpu, 3); - MainWindow->checkMenu(IDM_SBG3, false); - } - else - { - GPU_addBack(SubScreen.gpu, 3); - MainWindow->checkMenu(IDM_SBG3, true); - } - return 0; - - case IDM_PAUSE: - Pause(); - return 0; - - case IDM_GBASLOT: - GBAslotDialog(hwnd); - return 0; - - case IDM_CHEATS_LIST: - CheatsListDialog(hwnd); - return 0; - - case IDM_CHEATS_SEARCH: - CheatsSearchDialog(hwnd); - return 0; - case IDM_RECORD_MOVIE: - MovieRecordTo(); - return 0; - case IDM_PLAY_MOVIE: - Replay_LoadMovie(); - return 0; - case IDM_STOPMOVIE: - FCEUI_StopMovie(); - return 0; - case ID_VIEW_FRAMECOUNTER: - CommonSettings.hud.FrameCounterDisplay ^= true; - WritePrivateProfileBool("Display", "Display Fps", CommonSettings.hud.FpsDisplay, IniName); - return 0; - - case ID_VIEW_DISPLAYFPS: - CommonSettings.hud.FpsDisplay ^= true; - WritePrivateProfileBool("Display", "Display Fps", CommonSettings.hud.FpsDisplay, IniName); - osd->clear(); - return 0; - - case ID_VIEW_DISPLAYINPUT: - CommonSettings.hud.ShowInputDisplay ^= true; - WritePrivateProfileBool("Display", "Display Input", CommonSettings.hud.ShowInputDisplay, IniName); - osd->clear(); - return 0; - - case ID_VIEW_DISPLAYGRAPHICALINPUT: - CommonSettings.hud.ShowGraphicalInputDisplay ^= true; - WritePrivateProfileBool("Display", "Display Graphical Input", CommonSettings.hud.ShowGraphicalInputDisplay, IniName); - osd->clear(); - return 0; - - case ID_VIEW_DISPLAYLAG: - CommonSettings.hud.ShowLagFrameCounter ^= true; - WritePrivateProfileBool("Display", "Display Lag Counter", CommonSettings.hud.ShowLagFrameCounter, IniName); - osd->clear(); - return 0; - - case ID_VIEW_HUDEDITOR: - HudEditorMode ^= true; - osd->clear(); - osd->border(HudEditorMode); - return 0; - - case ID_VIEW_DISPLAYMICROPHONE: - CommonSettings.hud.ShowMicrophone ^= true; - WritePrivateProfileBool("Display", "Display Microphone", CommonSettings.hud.ShowMicrophone, IniName); - osd->clear(); - return 0; - - case ID_RAM_SEARCH: - if(!RamSearchHWnd) - { - InitRamSearch(); - RamSearchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMSEARCH), hwnd, (DLGPROC) RamSearchProc); - } - else - SetForegroundWindow(RamSearchHWnd); - break; - - case ID_RAM_WATCH: - if(!RamWatchHWnd) - { - RamWatchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMWATCH), hwnd, (DLGPROC) RamWatchProc); - // DialogsOpen++; - } - else - SetForegroundWindow(RamWatchHWnd); - return 0; - - case IDC_BACKGROUNDPAUSE: - lostFocusPause = !lostFocusPause; - WritePrivateProfileInt("Focus", "BackgroundPause", (int)lostFocusPause, IniName); - return 0; - - case IDC_SAVETYPE1: backup_setManualBackupType(0); return 0; - case IDC_SAVETYPE2: backup_setManualBackupType(1); return 0; - case IDC_SAVETYPE3: backup_setManualBackupType(2); return 0; - case IDC_SAVETYPE4: backup_setManualBackupType(3); return 0; - case IDC_SAVETYPE5: backup_setManualBackupType(4); return 0; - case IDC_SAVETYPE6: backup_setManualBackupType(5); return 0; - case IDC_SAVETYPE7: backup_setManualBackupType(6); return 0; - - case IDM_RESET: - ResetGame(); - return 0; - - case IDM_3DCONFIG: - { - bool tpaused = false; - if(execute) - { - tpaused = true; - NDS_Pause(); - } - - DialogBox(hAppInst, MAKEINTRESOURCE(IDD_3DSETTINGS), hwnd, (DLGPROC)GFX3DSettingsDlgProc); - - if(tpaused) NDS_UnPause(); - } - return 0; - case IDC_FRAMESKIPAUTO: - case IDC_FRAMESKIP0: - case IDC_FRAMESKIP1: - case IDC_FRAMESKIP2: - case IDC_FRAMESKIP3: - case IDC_FRAMESKIP4: - case IDC_FRAMESKIP5: - case IDC_FRAMESKIP6: - case IDC_FRAMESKIP7: - case IDC_FRAMESKIP8: - case IDC_FRAMESKIP9: - { - if(LOWORD(wParam) == IDC_FRAMESKIPAUTO) - { - autoframeskipenab = 1; - WritePrivateProfileString("Video", "FrameSkip", "AUTO", IniName); - } - else - { - char text[80]; - autoframeskipenab = 0; - frameskiprate = LOWORD(wParam) - IDC_FRAMESKIP0; - sprintf(text, "%d", frameskiprate); - WritePrivateProfileString("Video", "FrameSkip", text, IniName); - } - } - return 0; - case IDC_NEW_LUA_SCRIPT: - if(LuaScriptHWnds.size() < 16) - { - CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_LUA), MainWindow->getHWnd(), (DLGPROC) LuaScriptProc); - // DialogsOpen++; - } - break; - case IDC_LANGENGLISH: - SaveLanguage(0); - ChangeLanguage(0); - CheckLanguage(LOWORD(wParam)); - return 0; - case IDC_LANGFRENCH: - SaveLanguage(1); - ChangeLanguage(1); - CheckLanguage(LOWORD(wParam)); - return 0; - case IDC_LANG_CHINESE_SIMPLIFIED: - SaveLanguage(3); - ChangeLanguage(3); - CheckLanguage(LOWORD(wParam)); - return 0; - - case IDC_LANGDANISH: - SaveLanguage(2); - ChangeLanguage(2); - CheckLanguage(LOWORD(wParam)); - return 0; - - case IDC_FRAMELIMIT: - FrameLimit ^= 1; - WritePrivateProfileInt("FrameLimit", "FrameLimit", FrameLimit, IniName); - return 0; - - case IDM_SCREENSEP_NONE: - SetScreenGap(kGapNone); - return 0; - case IDM_SCREENSEP_BORDER: - SetScreenGap(kGapBorder); - return 0; - case IDM_SCREENSEP_NDSGAP: - SetScreenGap(kGapNDS); - return 0; - case IDM_SCREENSEP_NDSGAP2: - SetScreenGap(kGapNDS2); - return 0; - case IDM_SCREENSEP_DRAGEDIT: - SeparationBorderDrag = !SeparationBorderDrag; - WritePrivateProfileInt("Display","Window Split Border Drag",(int)SeparationBorderDrag,IniName); - break; - case IDM_WEBSITE: - ShellExecute(NULL, "open", "http://desmume.sourceforge.net", NULL, NULL, SW_SHOWNORMAL); - return 0; - - case IDM_FORUM: - ShellExecute(NULL, "open", "http://forums.desmume.org/index.php", NULL, NULL, SW_SHOWNORMAL); - return 0; - - case IDM_ABOUT: - { - #ifdef WX_STUB - wxTest(); - return 0; - #endif - bool tpaused=false; - if (execute) - { - tpaused=true; - NDS_Pause(); - } - DialogBox(hAppInst,MAKEINTRESOURCE(IDD_ABOUT_BOX), hwnd, (DLGPROC) AboutBox_Proc); - if (tpaused) - NDS_UnPause(); - - return 0; - } - -#ifndef BETA_VERSION - case IDM_SUBMITBUGREPORT: - ShellExecute(NULL, "open", "http://sourceforge.net/tracker/?func=add&group_id=164579&atid=832291", NULL, NULL, SW_SHOWNORMAL); - return 0; -#endif - - case IDC_ROTATE0: - SetRotate(hwnd, 0); - return 0; - case IDC_ROTATE90: - SetRotate(hwnd, 90); - return 0; - case IDC_ROTATE180: - SetRotate(hwnd, 180); - return 0; - case IDC_ROTATE270: - SetRotate(hwnd, 270); - return 0; - - case IDC_WINDOW1_5X: - windowSize=65535; - ScaleScreen(windowSize); - WritePrivateProfileInt("Video","Window Size",windowSize,IniName); - break; - case IDC_WINDOW2_5X: - windowSize=65534; - ScaleScreen(windowSize); - WritePrivateProfileInt("Video","Window Size",windowSize,IniName); - break; - case IDC_WINDOW1X: - windowSize=1; - ScaleScreen(windowSize); - WritePrivateProfileInt("Video","Window Size",windowSize,IniName); - break; - case IDC_WINDOW2X: - windowSize=2; - ScaleScreen(windowSize); - WritePrivateProfileInt("Video","Window Size",windowSize,IniName); - break; - case IDC_WINDOW3X: - windowSize=3; - ScaleScreen(windowSize); - WritePrivateProfileInt("Video","Window Size",windowSize,IniName); - break; - case IDC_WINDOW4X: - windowSize=4; - ScaleScreen(windowSize); - WritePrivateProfileInt("Video","Window Size",windowSize,IniName); - break; - - case IDC_FORCERATIO: - if (ForceRatio) { - ForceRatio = FALSE; - WritePrivateProfileInt("Video","Window Force Ratio",0,IniName); - } - else { - ForceRatio = TRUE; - FixAspectRatio(); - RECT rc; - GetClientRect(hwnd, &rc); - WritePrivateProfileInt("Video","Window Force Ratio",1,IniName); - WritePrivateProfileInt("Video", "Window width", (rc.right - rc.left), IniName); - WritePrivateProfileInt("Video", "Window height", (rc.bottom - rc.top), IniName); - } - break; - - - case IDM_DEFSIZE: - { - if(windowSize != 1) - windowSize = 0; - - ScaleScreen(1); - } - break; - case IDM_ALWAYS_ON_TOP: - { - LONG exStyle = GetWindowLong(MainWindow->getHWnd(), GWL_EXSTYLE); - UINT menuCheck = MF_BYCOMMAND; - HWND insertAfter = HWND_TOPMOST; - - - if(exStyle & WS_EX_TOPMOST) - { - menuCheck |= MF_UNCHECKED; - insertAfter = HWND_NOTOPMOST; - } - else - menuCheck |= MF_CHECKED; - - CheckMenuItem(mainMenu, IDM_ALWAYS_ON_TOP, menuCheck); - SetWindowPos(MainWindow->getHWnd(), insertAfter, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE); - } - return 0; - - } - } - return DefWindowProc (hwnd, message, wParam, lParam); -} - -LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) -{ - switch(msg) - { - case WM_INITDIALOG: - { - int i; - - CheckDlgButton(hw,IDC_INTERPOLATECOLOR,CommonSettings.HighResolutionInterpolateColor?1:0); - CheckDlgButton(hw,IDC_ALTERNATEFLUSH,CommonSettings.gfx3d_flushMode); - - for(i = 0; core3DList[i] != NULL; i++) - { - ComboBox_AddString(GetDlgItem(hw, IDC_3DCORE), core3DList[i]->name); - } - ComboBox_SetCurSel(GetDlgItem(hw, IDC_3DCORE), cur3DCore); - } - return TRUE; - - case WM_COMMAND: - { - switch(LOWORD(wp)) - { - case IDOK: - { - CommonSettings.HighResolutionInterpolateColor = IsDlgCheckboxChecked(hw,IDC_INTERPOLATECOLOR); - NDS_3D_ChangeCore(ComboBox_GetCurSel(GetDlgItem(hw, IDC_3DCORE))); - WritePrivateProfileInt("3D", "Renderer", cur3DCore, IniName); - WritePrivateProfileInt("3D", "HighResolutionInterpolateColor", CommonSettings.HighResolutionInterpolateColor?1:0, IniName); - CommonSettings.gfx3d_flushMode = (IsDlgButtonChecked(hw,IDC_ALTERNATEFLUSH) == BST_CHECKED)?1:0; - WritePrivateProfileInt("3D", "AlternateFlush", CommonSettings.gfx3d_flushMode, IniName); - } - case IDCANCEL: - { - EndDialog(hw, TRUE); - } - return TRUE; - - case IDC_DEFAULT: - { - NDS_3D_ChangeCore(GPU3D_OPENGL); - ComboBox_SetCurSel(GetDlgItem(hw, IDC_3DCORE), GPU3D_OPENGL); - WritePrivateProfileInt("3D", "Renderer", GPU3D_OPENGL, IniName); - CommonSettings.gfx3d_flushMode = 0; - WritePrivateProfileInt("3D", "AlternateFlush", CommonSettings.gfx3d_flushMode, IniName); - } - return TRUE; - } - - return TRUE; - } - } - - return FALSE; -} - -LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_INITDIALOG: - { - HWND cur; - - CheckDlgButton(hDlg, IDC_CHECKBOX_DEBUGGERMODE, ((CommonSettings.DebugConsole == true) ? BST_CHECKED : BST_UNCHECKED)); - CheckDlgButton(hDlg, IDC_USEEXTBIOS, ((CommonSettings.UseExtBIOS == true) ? BST_CHECKED : BST_UNCHECKED)); - SetDlgItemText(hDlg, IDC_ARM9BIOS, CommonSettings.ARM9BIOS); - SetDlgItemText(hDlg, IDC_ARM7BIOS, CommonSettings.ARM7BIOS); - CheckDlgButton(hDlg, IDC_BIOSSWIS, ((CommonSettings.SWIFromBIOS == true) ? BST_CHECKED : BST_UNCHECKED)); - - if(CommonSettings.UseExtBIOS == false) - { - cur = GetDlgItem(hDlg, IDC_ARM9BIOS); - EnableWindow(cur, FALSE); - cur = GetDlgItem(hDlg, IDC_ARM9BIOSBROWSE); - EnableWindow(cur, FALSE); - cur = GetDlgItem(hDlg, IDC_ARM7BIOS); - EnableWindow(cur, FALSE); - cur = GetDlgItem(hDlg, IDC_ARM7BIOSBROWSE); - EnableWindow(cur, FALSE); - cur = GetDlgItem(hDlg, IDC_BIOSSWIS); - EnableWindow(cur, FALSE); - } - - CheckDlgButton(hDlg, IDC_USEEXTFIRMWARE, ((CommonSettings.UseExtFirmware == true) ? BST_CHECKED : BST_UNCHECKED)); - SetDlgItemText(hDlg, IDC_FIRMWARE, CommonSettings.Firmware); - CheckDlgButton(hDlg, IDC_FIRMWAREBOOT, ((CommonSettings.BootFromFirmware == true) ? BST_CHECKED : BST_UNCHECKED)); - - if(CommonSettings.UseExtFirmware == false) - { - cur = GetDlgItem(hDlg, IDC_FIRMWARE); - EnableWindow(cur, FALSE); - cur = GetDlgItem(hDlg, IDC_FIRMWAREBROWSE); - EnableWindow(cur, FALSE); - } - - if((CommonSettings.UseExtBIOS == false) || (CommonSettings.UseExtFirmware == false)) - { - cur = GetDlgItem(hDlg, IDC_FIRMWAREBOOT); - EnableWindow(cur, FALSE); - } - } - return TRUE; - - case WM_COMMAND: - { - switch(LOWORD(wParam)) - { - case IDOK: - { - int val = 0; - - if(romloaded) - val = MessageBox(hDlg, "The current ROM needs to be reset to apply changes.\nReset now ?", "DeSmuME", (MB_YESNO | MB_ICONQUESTION)); - - HWND cur; - - CommonSettings.UseExtBIOS = IsDlgCheckboxChecked(hDlg, IDC_USEEXTBIOS); - cur = GetDlgItem(hDlg, IDC_ARM9BIOS); - GetWindowText(cur, CommonSettings.ARM9BIOS, 256); - cur = GetDlgItem(hDlg, IDC_ARM7BIOS); - GetWindowText(cur, CommonSettings.ARM7BIOS, 256); - CommonSettings.SWIFromBIOS = IsDlgCheckboxChecked(hDlg, IDC_BIOSSWIS); - - CommonSettings.UseExtFirmware = IsDlgCheckboxChecked(hDlg, IDC_USEEXTFIRMWARE); - cur = GetDlgItem(hDlg, IDC_FIRMWARE); - GetWindowText(cur, CommonSettings.Firmware, 256); - CommonSettings.BootFromFirmware = IsDlgCheckboxChecked(hDlg, IDC_FIRMWAREBOOT); - - CommonSettings.DebugConsole = IsDlgCheckboxChecked(hDlg, IDC_CHECKBOX_DEBUGGERMODE); - - WritePrivateProfileInt("Emulation", "DebugConsole", ((CommonSettings.DebugConsole == true) ? 1 : 0), IniName); - WritePrivateProfileInt("BIOS", "UseExtBIOS", ((CommonSettings.UseExtBIOS == true) ? 1 : 0), IniName); - WritePrivateProfileString("BIOS", "ARM9BIOSFile", CommonSettings.ARM9BIOS, IniName); - WritePrivateProfileString("BIOS", "ARM7BIOSFile", CommonSettings.ARM7BIOS, IniName); - WritePrivateProfileInt("BIOS", "SWIFromBIOS", ((CommonSettings.SWIFromBIOS == true) ? 1 : 0), IniName); - - WritePrivateProfileInt("Firmware", "UseExtFirmware", ((CommonSettings.UseExtFirmware == true) ? 1 : 0), IniName); - WritePrivateProfileString("Firmware", "FirmwareFile", CommonSettings.Firmware, IniName); - WritePrivateProfileInt("Firmware", "BootFromFirmware", ((CommonSettings.BootFromFirmware == true) ? 1 : 0), IniName); - - if(val == IDYES) - { - NDS_Reset(); - } - } - case IDCANCEL: - { - EndDialog(hDlg, TRUE); - } - return TRUE; - - case IDC_USEEXTBIOS: - { - HWND cur; - BOOL enable = IsDlgButtonChecked(hDlg, IDC_USEEXTBIOS); - - cur = GetDlgItem(hDlg, IDC_ARM9BIOS); - EnableWindow(cur, enable); - cur = GetDlgItem(hDlg, IDC_ARM9BIOSBROWSE); - EnableWindow(cur, enable); - cur = GetDlgItem(hDlg, IDC_ARM7BIOS); - EnableWindow(cur, enable); - cur = GetDlgItem(hDlg, IDC_ARM7BIOSBROWSE); - EnableWindow(cur, enable); - cur = GetDlgItem(hDlg, IDC_BIOSSWIS); - EnableWindow(cur, enable); - cur = GetDlgItem(hDlg, IDC_FIRMWAREBOOT); - EnableWindow(cur, (enable && IsDlgButtonChecked(hDlg, IDC_USEEXTFIRMWARE))); - } - return TRUE; - - case IDC_USEEXTFIRMWARE: - { - HWND cur; - BOOL enable = IsDlgButtonChecked(hDlg, IDC_USEEXTFIRMWARE); - - cur = GetDlgItem(hDlg, IDC_FIRMWARE); - EnableWindow(cur, enable); - cur = GetDlgItem(hDlg, IDC_FIRMWAREBROWSE); - EnableWindow(cur, enable); - cur = GetDlgItem(hDlg, IDC_FIRMWAREBOOT); - EnableWindow(cur, (enable && IsDlgButtonChecked(hDlg, IDC_USEEXTBIOS))); - } - return TRUE; - - case IDC_ARM9BIOSBROWSE: - case IDC_ARM7BIOSBROWSE: - case IDC_FIRMWAREBROWSE: - { - char fileName[256] = ""; - OPENFILENAME ofn; - - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hDlg; - ofn.lpstrFilter = "Binary file (*.bin)\0*.bin\0ROM file (*.rom)\0*.rom\0Any file(*.*)\0*.*\0\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile = fileName; - ofn.nMaxFile = 256; - ofn.lpstrDefExt = "bin"; - ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; - - char buffer[MAX_PATH]; - ZeroMemory(buffer, sizeof(buffer)); - path.getpath(path.FIRMWARE, buffer); - ofn.lpstrInitialDir = buffer; - - if(GetOpenFileName(&ofn)) - { - HWND cur; - - switch(LOWORD(wParam)) - { - case IDC_ARM9BIOSBROWSE: cur = GetDlgItem(hDlg, IDC_ARM9BIOS); break; - case IDC_ARM7BIOSBROWSE: cur = GetDlgItem(hDlg, IDC_ARM7BIOS); break; - case IDC_FIRMWAREBROWSE: cur = GetDlgItem(hDlg, IDC_FIRMWARE); break; - } - - SetWindowText(cur, fileName); - } - } - return TRUE; - } - } - return TRUE; - } - - return FALSE; -} - -LRESULT CALLBACK MicrophoneSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch(uMsg) - { - case WM_INITDIALOG: - { - HWND cur; - - UseMicSample = GetPrivateProfileBool("Use Mic Sample", "UseMicSample", false, IniName); - CheckDlgButton(hDlg, IDC_USEMICSAMPLE, ((UseMicSample == true) ? BST_CHECKED : BST_UNCHECKED)); - GetPrivateProfileString("Use Mic Sample", "MicSampleFile", "micsample.raw", MicSampleName, MAX_PATH, IniName); - SetDlgItemText(hDlg, IDC_MICSAMPLE, MicSampleName); - - if(UseMicSample == false) - { - cur = GetDlgItem(hDlg, IDC_MICSAMPLE); - EnableWindow(cur, FALSE); - cur = GetDlgItem(hDlg, IDC_MICSAMPLEBROWSE); - EnableWindow(cur, FALSE); - } - } - return TRUE; - - case WM_COMMAND: - { - switch(LOWORD(wParam)) - { - case IDOK: - { - int val = 0; - - if((romloaded)) //|| (val == IDYES)) - { - HWND cur; - - UseMicSample = IsDlgCheckboxChecked(hDlg, IDC_USEMICSAMPLE); - cur = GetDlgItem(hDlg, IDC_MICSAMPLE); - GetWindowText(cur, MicSampleName, 256); - - WritePrivateProfileInt("Use Mic Sample", "UseMicSample", ((UseMicSample == true) ? 1 : 0), IniName); - WritePrivateProfileString("Use Mic Sample", "MicSampleFile", MicSampleName, IniName); - - if (UseMicSample) - { - if (!LoadSample(MicSampleName)) - { - MessageBox(hDlg, "Unable to read the sample", "DeSmuME", (MB_OK | MB_ICONEXCLAMATION)); - } - } - } - } - case IDCANCEL: - { - EndDialog(hDlg, TRUE); - } - return TRUE; - - case IDC_USEMICSAMPLE: - { - HWND cur; - BOOL enable = IsDlgButtonChecked(hDlg, IDC_USEMICSAMPLE); - - cur = GetDlgItem(hDlg, IDC_MICSAMPLE); - EnableWindow(cur, enable); - cur = GetDlgItem(hDlg, IDC_MICSAMPLEBROWSE); - EnableWindow(cur, enable); - } - return TRUE; - - case IDC_MICSAMPLEBROWSE: - { - char fileName[256] = ""; - OPENFILENAME ofn; - - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hDlg; - ofn.lpstrFilter = "Any file(*.*)\0*.*\0\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile = fileName; - ofn.nMaxFile = 256; - ofn.lpstrDefExt = "bin"; - ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; - - char buffer[MAX_PATH]; - ZeroMemory(buffer, sizeof(buffer)); - path.getpath(path.SOUNDS, buffer); - ofn.lpstrInitialDir = buffer; - - if(GetOpenFileName(&ofn)) - { - HWND cur; - - switch(LOWORD(wParam)) - { - case IDC_MICSAMPLEBROWSE: cur = GetDlgItem(hDlg, IDC_MICSAMPLE); break; - } - - SetWindowText(cur, fileName); - } - } - return TRUE; - } - } - return TRUE; - } - - return FALSE; -} - -LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - #ifdef EXPERIMENTAL_WIFI - switch(uMsg) - { - case WM_INITDIALOG: - { -#if 0 - char errbuf[PCAP_ERRBUF_SIZE]; - pcap_if_t *alldevs; - pcap_if_t *d; - int i; -#endif - HWND cur; - - CheckRadioButton(hDlg, IDC_WIFIMODE0, IDC_WIFIMODE1, IDC_WIFIMODE0 + CommonSettings.wifi.mode); - CheckRadioButton(hDlg, IDC_ADHOC_SERVER, IDC_ADHOC_CLIENT, CommonSettings.wifi.adhocMode ? IDC_ADHOC_CLIENT:IDC_ADHOC_SERVER); - - cur = GetDlgItem(hDlg, IDC_ADHOC_SERVERNAME); - SetWindowText(cur, CommonSettings.wifi.adhocServerName); - EnableWindow(cur, (CommonSettings.wifi.adhocMode == 1) ? TRUE:FALSE); - -#if 0 - if(PCAP::pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) - { - EndDialog(hDlg, TRUE); - return TRUE; - } - - cur = GetDlgItem(hDlg, IDC_BRIDGEADAPTER); - for(i = 0, d = alldevs; d != NULL; i++, d = d->next) - { - ComboBox_AddString(cur, d->description); - } - ComboBox_SetCurSel(cur, CommonSettings.wifi.infraBridgeAdapter); -#endif - } - return TRUE; - - case WM_COMMAND: - { - switch(LOWORD(wParam)) - { - case IDC_ADHOC_SERVER: - case IDC_ADHOC_CLIENT: - { - HWND cur = GetDlgItem(hDlg, IDC_ADHOC_SERVERNAME); - EnableWindow(cur, (LOWORD(wParam) == IDC_ADHOC_CLIENT) ? TRUE:FALSE); - } - return TRUE; - - case IDOK: - { - int val = 0; - - if(romloaded) - val = MessageBox(hDlg, "The current ROM needs to be reset to apply changes.\nReset now ?", "DeSmuME", (MB_YESNO | MB_ICONQUESTION)); - - HWND cur; - -#if 0 - if (IsDlgButtonChecked(hDlg, IDC_WIFIMODE0)) - CommonSettings.wifi.mode = 0; - else - CommonSettings.wifi.mode = 1; - WritePrivateProfileInt("Wifi", "Mode", CommonSettings.wifi.mode, IniName); - - cur = GetDlgItem(hDlg, IDC_BRIDGEADAPTER); - CommonSettings.wifi.infraBridgeAdapter = ComboBox_GetCurSel(cur); - WritePrivateProfileInt("Wifi", "BridgeAdapter", CommonSettings.wifi.infraBridgeAdapter, IniName); -#else - CommonSettings.wifi.mode = 0; - WritePrivateProfileInt("Wifi", "Mode", CommonSettings.wifi.mode, IniName); -#endif - - if (IsDlgButtonChecked(hDlg, IDC_ADHOC_SERVER)) - CommonSettings.wifi.adhocMode = 0; - else - CommonSettings.wifi.adhocMode = 1; - WritePrivateProfileInt("Wifi", "AdhocMode", CommonSettings.wifi.adhocMode, IniName); - - cur = GetDlgItem(hDlg, IDC_ADHOC_SERVERNAME); - GetWindowText(cur, CommonSettings.wifi.adhocServerName, 64); - WritePrivateProfileString("Wifi", "AdhocServerName", CommonSettings.wifi.adhocServerName, IniName); - - if(val == IDYES) - { - NDS_Reset(); - } - } - case IDCANCEL: - { - EndDialog(hDlg, TRUE); - } - return TRUE; - } - } - return TRUE; - } -#endif - return FALSE; -} - -LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static UINT_PTR timerid=0; - switch (uMsg) - { - case WM_INITDIALOG: - { - int i; - char tempstr[MAX_PATH]; - // Setup Sound Core Combo box - SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_RESETCONTENT, 0, 0); - SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (LPARAM)"None"); - - for (i = 1; SNDCoreList[i] != NULL; i++) - SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (LPARAM)SNDCoreList[i]->Name); - - // Set Selected Sound Core - for (i = 0; SNDCoreList[i] != NULL; i++) - { - if (sndcoretype == SNDCoreList[i]->id) - SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_SETCURSEL, i, 0); - } - - //setup interpolation combobox - SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_RESETCONTENT, 0, 0); - SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_ADDSTRING, 0, (LPARAM)"None (fastest, sounds bad)"); - SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_ADDSTRING, 0, (LPARAM)"Linear (typical, sounds good)"); - SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_ADDSTRING, 0, (LPARAM)"Cosine (slowest, sounds best)"); - SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_SETCURSEL, (int)CommonSettings.spuInterpolationMode, 0); - - //setup cache setting - CheckDlgButton(hDlg, IDC_SPU_CACHE, CommonSettings.spuAdpcmCache?BST_CHECKED:BST_UNCHECKED ); - - // Setup Sound Buffer Size Edit Text - sprintf(tempstr, "%d", sndbuffersize); - SetDlgItemText(hDlg, IDC_SOUNDBUFFERET, tempstr); - - // Setup Volume Slider - SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_SETRANGE, 0, MAKELONG(0, 100)); - - // Set Selected Volume - SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_SETPOS, TRUE, sndvolume); - - timerid = SetTimer(hDlg, 1, 500, NULL); - return TRUE; - } - case WM_TIMER: - { - if (timerid == wParam) - { - int setting; - setting = SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_GETPOS, 0, 0); - SPU_SetVolume(setting); - break; - } - break; - } - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDOK: - { - char tempstr[MAX_PATH]; - - EndDialog(hDlg, TRUE); - - // Write Sound core type - sndcoretype = SNDCoreList[SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_GETCURSEL, 0, 0)]->id; - sprintf(tempstr, "%d", sndcoretype); - WritePrivateProfileString("Sound", "SoundCore2", tempstr, IniName); - - // Write Sound Buffer size - GetDlgItemText(hDlg, IDC_SOUNDBUFFERET, tempstr, 6); - sscanf(tempstr, "%d", &sndbuffersize); - WritePrivateProfileString("Sound", "SoundBufferSize", tempstr, IniName); - - if(sndcoretype != SPU_currentCoreNum) - { - Lock lock; - SPU_ChangeSoundCore(sndcoretype, sndbuffersize); - } - - // Write Volume - sndvolume = SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_GETPOS, 0, 0); - sprintf(tempstr, "%d", sndvolume); - WritePrivateProfileString("Sound", "Volume", tempstr, IniName); - SPU_SetVolume(sndvolume); - - //write interpolation type - CommonSettings.spuInterpolationMode = (SPUInterpolationMode)SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_GETCURSEL, 0, 0); - WritePrivateProfileInt("Sound","SPUInterpolation",(int)CommonSettings.spuInterpolationMode, IniName); - - //write cache setting - CommonSettings.spuAdpcmCache = IsDlgButtonChecked(hDlg, IDC_SPU_CACHE) != 0; - WritePrivateProfileInt("Sound","SPUAdpcmCache",CommonSettings.spuAdpcmCache?1:0, IniName); - - return TRUE; - } - case IDCANCEL: - { - EndDialog(hDlg, FALSE); - return TRUE; - } - default: break; - } - - break; - } - case WM_DESTROY: - { - if (timerid != 0) - KillTimer(hDlg, timerid); - break; - } - } - - return FALSE; -} - -void ResetGame() -{ - NDS_Reset(); -} - -//adelikat: This function changes a menu item's text -void ChangeMenuItemText(int menuitem, string text) -{ - MENUITEMINFO moo; - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_TYPE; - moo.cch = NULL; - GetMenuItemInfo(mainMenu, menuitem, FALSE, &moo); - moo.dwTypeData = (LPSTR)text.c_str(); - SetMenuItemInfo(mainMenu, menuitem, FALSE, &moo); -} - -const char* GetModifierString(int num) -{ - switch (num) - { - case 0: - return ""; - case 1: - return "Alt+"; - case 2: - return "Ctrl+"; - case 3: - return "Ctrl+Alt+"; - case 4: - return "Shift+"; - case 5: - return "Alt+Shift+"; - case 6: - return "Ctrl+Shift+"; - case 7: - return "Ctrl+Alt+Shift+"; - default: - return ""; - } -} - -//adelikat: This function find the current hotkey assignments for corresponding menu items -// and appends it to the menu item. This function works correctly for all language menus -// However, a Menu item in the Resource file must NOT have a /t (tab) in its caption. -void UpdateHotkeyAssignments() -{ - extern void TranslateKey(WORD keyz,char *out); //adelikat: Yeah hackey - //Update all menu items that can be called from a hotkey to include the current hotkey assignment - char str[255]; //Temp string - string text; //Used to manipulate menu item text - string keyname; //Used to hold the name of the hotkey - int truncate; //Used to truncate the hotkey config from the menu item - //-------------------------------FILE--------------------------------------- - - - //Open ROM - GetMenuString(mainMenu,IDM_OPEN, str, 255, IDM_OPEN); //Get menu item text - text = str; //Store in string object - truncate = text.find("\t"); //Find the tab - if (truncate >= 1) //Truncate if it exists - text = text.substr(0,truncate); - TranslateKey(CustomKeys.OpenROM.key, str); - keyname = str; - keyname.insert(0,GetModifierString(CustomKeys.OpenROM.modifiers)); - text.append("\t" + keyname); - ChangeMenuItemText(IDM_OPEN, text); - - //Save Screenshot As... - GetMenuString(mainMenu,IDM_PRINTSCREEN, str, 255, IDM_PRINTSCREEN); - text = str; - truncate = text.find("\t"); - if (truncate >= 1) - text = text.substr(0,truncate); - TranslateKey(CustomKeys.PrintScreen.key, str); - keyname = str; - keyname.insert(0,GetModifierString(CustomKeys.PrintScreen.modifiers)); - text.append("\t" + keyname); - ChangeMenuItemText(IDM_PRINTSCREEN, text); - - //adelikat: Why don't these work? GetMenuString returns null for these IDs yet those are the valid ID numbers - /* - //Record AVI - GetMenuString(mainMenu,IDM_FILE_RECORDAVI, str, 255, IDM_FILE_RECORDAVI); - text = str; - truncate = text.find("\t"); - if (truncate >= 1) - text = text.substr(0,truncate); - TranslateKey(CustomKeys.RecordAVI.key, str); - keyname = str; - keyname.insert(0,GetModifierString(CustomKeys.RecordAVI.modifiers)); - text.append("\t" + keyname); - ChangeMenuItemText(IDM_FILE_RECORDAVI, text); - - //Stop AVI - GetMenuString(mainMenu,IDM_FILE_STOPAVI, str, 255, IDM_FILE_STOPAVI); - text = str; - truncate = text.find("\t"); - if (truncate >= 1) - text = text.substr(0,truncate); - TranslateKey(CustomKeys.StopAVI.key, str); - keyname = str; - keyname.insert(0,GetModifierString(CustomKeys.StopAVI.modifiers)); - text.append("\t" + keyname); - ChangeMenuItemText(IDM_FILE_STOPAVI, text); -*/ - - //-------------------------------EMULATION---------------------------------- - - //Pause - GetMenuString(mainMenu,IDM_PAUSE, str, 255, IDM_PAUSE); - text = str; - truncate = text.find("\t"); - if (truncate >= 1) - text = text.substr(0,truncate); - TranslateKey(CustomKeys.Pause.key, str); - keyname = str; - keyname.insert(0,GetModifierString(CustomKeys.Pause.modifiers)); - text.append("\t" + keyname); - ChangeMenuItemText(IDM_PAUSE, text); - - //Reset - GetMenuString(mainMenu,IDM_RESET, str, 255, IDM_RESET); - text = str; - truncate = text.find("\t"); - if (truncate >= 1) - text = text.substr(0,truncate); - TranslateKey(CustomKeys.Reset.key, str); - keyname = str; - keyname.insert(0,GetModifierString(CustomKeys.Reset.modifiers)); - text.append("\t" + keyname); - ChangeMenuItemText(IDM_RESET, text); - - //-------------------------------EMULATION---------------------------------- -/* - //Display Frame Counter - GetMenuString(mainMenu,ID_VIEW_FRAMECOUNTER, str, 255, ID_VIEW_FRAMECOUNTER); - text = str; - truncate = text.find("\t"); - if (truncate >= 1) - text = text.substr(0,truncate); - TranslateKey(CustomKeys.ToggleFrameCounter.key, str); - keyname = str; - keyname.insert(0,GetModifierString(CustomKeys.ToggleFrameCounter.modifiers)); - text.append("\t" + keyname); - ChangeMenuItemText(ID_VIEW_FRAMECOUNTER, text); - - //Display FPS - GetMenuString(mainMenu,ID_VIEW_DISPLAYFPS, str, 255, ID_VIEW_DISPLAYFPS); - text = str; - truncate = text.find("\t"); - if (truncate >= 1) - text = text.substr(0,truncate); - TranslateKey(CustomKeys.ToggleFPS.key, str); - keyname = str; - keyname.insert(0,GetModifierString(CustomKeys.ToggleFPS.modifiers)); - text.append("\t" + keyname); - ChangeMenuItemText(ID_VIEW_DISPLAYFPS, text); - - //Display Input - GetMenuString(mainMenu,ID_VIEW_DISPLAYINPUT, str, 255, ID_VIEW_DISPLAYINPUT); - text = str; - truncate = text.find("\t"); - if (truncate >= 1) - text = text.substr(0,truncate); - TranslateKey(CustomKeys.ToggleInput.key, str); - keyname = str; - keyname.insert(0,GetModifierString(CustomKeys.ToggleInput.modifiers)); - text.append("\t" + keyname); - ChangeMenuItemText(ID_VIEW_DISPLAYINPUT, text); - - //Display Lag Counter - GetMenuString(mainMenu,ID_VIEW_DISPLAYLAG, str, 255, ID_VIEW_DISPLAYLAG); - text = str; - truncate = text.find("\t"); - if (truncate >= 1) - text = text.substr(0,truncate); - TranslateKey(CustomKeys.ToggleLag.key, str); - keyname = str; - keyname.insert(0,GetModifierString(CustomKeys.ToggleLag.modifiers)); - text.append("\t" + keyname); - ChangeMenuItemText(ID_VIEW_DISPLAYLAG, text); -*/ -} - - -static char Lua_Dir [1024]; -char Desmume_Path [1024]; - -static const char* PathWithoutPrefixDotOrSlash(const char* path) -{ - while(*path && - ((*path == '.' && (path[1] == '\\' || path[1] == '/')) || - *path == '\\' || *path == '/' || *path == ' ')) - path++; - return path; -} - -const char* MakeScriptPathAbsolute(const char* filename, const char* extraDirToCheck) -{ - static char filename2 [1024]; - if(filename[0] && filename[1] != ':') - { - char tempFile [1024], curDir [1024]; - strncpy(tempFile, filename, 1024); - tempFile[1023] = 0; - const char* tempFilePtr = PathWithoutPrefixDotOrSlash(tempFile); - for(int i=0; i<=4; i++) - { - if((!*tempFilePtr || tempFilePtr[1] != ':') && i != 2) - strcpy(curDir, i!=1 ? ((i!=3||!extraDirToCheck) ? Lua_Dir : extraDirToCheck) : Desmume_Path); - else - curDir[0] = 0; - _snprintf(filename2, 1024, "%s%s", curDir, tempFilePtr); - char* bar = strchr(filename2, '|'); - if(bar) *bar = 0; - FILE* file = fopen(filename2, "rb"); - if(bar) *bar = '|'; - if(file || i==4) - filename = filename2; - if(file) - { - fclose(file); - break; - } - } - } - return filename; -} - -extern void RequestAbortLuaScript(int uid, const char* message); - -const char* OpenLuaScript(const char* filename, const char* extraDirToCheck, bool makeSubservient) -{ - if(LuaScriptHWnds.size() < 16) - { - // make the filename absolute before loading - filename = MakeScriptPathAbsolute(filename, extraDirToCheck); - - // now check if it's already open and load it if it isn't - HWND IsScriptFileOpen(const char* Path); - HWND scriptHWnd = IsScriptFileOpen(filename); - if(!scriptHWnd) - { - HWND prevWindow = GetActiveWindow(); - - HWND hDlg = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_LUA), MainWindow->getHWnd(), (DLGPROC) LuaScriptProc); - SendMessage(hDlg,WM_COMMAND,IDC_NOTIFY_SUBSERVIENT,TRUE); - SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)filename); -// DialogsOpen++; - - SetActiveWindow(prevWindow); - } - else - { - RequestAbortLuaScript((int)scriptHWnd, "terminated to restart because of a call to emu.openscript"); - SendMessage(scriptHWnd, WM_COMMAND, IDC_BUTTON_LUARUN, 0); - } - } - else return "Too many script windows are already open."; - - return NULL; -} +/* main.cpp + + Copyright 2006 Theo Berkau + Copyright (C) 2006-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "windriver.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "gthread.h" +#include "version.h" +#include "CWindow.h" +#include "../MMU.h" +#include "../armcpu.h" +#include "../NDSSystem.h" +#include "../debug.h" +#include "../saves.h" +#include "../addons.h" +#include "resource.h" +#include "GPU_osd.h" +#include "memView.h" +#include "disView.h" +#include "ginfo.h" +#include "IORegView.h" +#include "palView.h" +#include "tileView.h" +#include "oamView.h" +#include "mapview.h" +#include "matrixview.h" +#include "lightview.h" +#include "inputdx.h" +#include "FirmConfig.h" +#include "AboutBox.h" +#include "OGLRender.h" +#include "rasterize.h" +#include "../gfx3d.h" +#include "../render3D.h" +#include "../gdbstub.h" +#include "colorctrl.h" +#include "console.h" +#include "throttle.h" +#include "gbaslot_config.h" +#include "cheatsWin.h" +#include "Mmsystem.h" +#include "../mic.h" +#include "../common.h" +#include "main.h" +#include "hotkey.h" +#include "../movie.h" +#include "../replay.h" +#include "snddx.h" +#include "ramwatch.h" +#include "ram_search.h" +#include "aviout.h" +#include "soundView.h" +#include "commandline.h" +#include "../lua-engine.h" +#include "7zip.h" +#include "pathsettings.h" +#include "utils/xstring.h" +#include "directx/ddraw.h" +#include "video.h" +#include "path.h" + +#include "aggdraw.h" +#include "agg2d.h" + +using namespace std; + +#define HAVE_REMOTE +#define WPCAP +#define PACKET_SIZE 65535 + +#include +#include //uh? + +VideoInfo video; + +//#define WX_STUB + +#ifdef WX_STUB + +// for compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +class wxDesmumeApp : public wxApp +{ +public: + //call me each frame or something. + //sort of an idle routine + static void frameUpdate() + { + if(!wxTheApp) return; + wxDesmumeApp* self = ((wxDesmumeApp*)wxTheApp); + self->DeletePendingObjects(); + } +}; + +IMPLEMENT_APP_NO_MAIN( wxDesmumeApp ) + +class wxTestModeless : public wxFrame +{ +public: + wxTestModeless(const wxChar *title, int x, int y) + : wxFrame(NULL, wxID_ANY, title, wxPoint(x, y), wxSize(700, 450)) + {} +}; + +void wxTest() { + wxTestModeless *frame = new wxTestModeless(_T("Controls wxWidgets App"), 50, 50); + frame->Show(true); +} + +#endif + +const int kGapNone = 0; +const int kGapBorder = 5; +const int kGapNDS = 64; // extremely tilted (but some games seem to use this value) +const int kGapNDS2 = 90; // more normal viewing angle + +static BOOL OpenCore(const char* filename); + +//----Recent ROMs menu globals---------- +vector RecentRoms; //The list of recent ROM filenames +const unsigned int MAX_RECENT_ROMS = 10; //To change the recent rom max, simply change this number +const unsigned int clearid = IDM_RECENT_RESERVED0; // ID for the Clear recent ROMs item +const unsigned int baseid = IDM_RECENT_RESERVED1; //Base identifier for the recent ROMs items +static HMENU recentromsmenu; //Handle to the recent ROMs submenu +//-------------------------------------- + +void UpdateHotkeyAssignments(); //Appends hotkey mappings to corresponding menu items + +static HMENU mainMenu; //Holds handle to the main DeSmuME menu + +DWORD hKeyInputTimer; + +extern LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +void InitRamSearch(); + + +CRITICAL_SECTION win_sync; +volatile int win_sound_samplecounter = 0; + +Lock::Lock() { EnterCriticalSection(&win_sync); } +Lock::~Lock() { LeaveCriticalSection(&win_sync); } + +//===================== DirectDraw vars +LPDIRECTDRAW7 lpDDraw=NULL; +LPDIRECTDRAWSURFACE7 lpPrimarySurface=NULL; +LPDIRECTDRAWSURFACE7 lpBackSurface=NULL; +DDSURFACEDESC2 ddsd; +LPDIRECTDRAWCLIPPER lpDDClipPrimary=NULL; +LPDIRECTDRAWCLIPPER lpDDClipBack=NULL; + +//===================== Input vars +#define WM_CUSTKEYDOWN (WM_USER+50) +#define WM_CUSTKEYUP (WM_USER+51) + +/* Declare Windows procedure */ +LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); + +/* Make the class name into a global variable */ +char SavName[MAX_PATH] = ""; +char ImportSavName[MAX_PATH] = ""; +char szClassName[ ] = "DeSmuME"; +int romnum = 0; + +DWORD threadID; + +WINCLASS *MainWindow=NULL; + +//HWND hwnd; +//HDC hdc; +HACCEL hAccel; +HINSTANCE hAppInst = NULL; +RECT MainScreenRect, SubScreenRect, GapRect; +RECT MainScreenSrcRect, SubScreenSrcRect; +int WndX = 0; +int WndY = 0; + +extern HWND RamSearchHWnd; +static BOOL lostFocusPause = TRUE; +static BOOL lastPauseFromLostFocus = FALSE; +static int FrameLimit = 1; + +std::vector LuaScriptHWnds; +LRESULT CALLBACK LuaScriptProc(HWND, UINT, WPARAM, LPARAM); + +//=========================== view tools +TOOLSCLASS *ViewDisasm_ARM7 = NULL; +TOOLSCLASS *ViewDisasm_ARM9 = NULL; +//TOOLSCLASS *ViewMem_ARM7 = NULL; +//TOOLSCLASS *ViewMem_ARM9 = NULL; +TOOLSCLASS *ViewRegisters = NULL; +TOOLSCLASS *ViewPalette = NULL; +TOOLSCLASS *ViewTiles = NULL; +TOOLSCLASS *ViewMaps = NULL; +TOOLSCLASS *ViewOAM = NULL; +TOOLSCLASS *ViewMatrices = NULL; +TOOLSCLASS *ViewLights = NULL; + +volatile BOOL execute = FALSE; +volatile BOOL paused = TRUE; +volatile BOOL pausedByMinimize = FALSE; +u32 glock = 0; + +BOOL finished = FALSE; +BOOL romloaded = FALSE; + +void SetScreenGap(int gap); + +void SetRotate(HWND hwnd, int rot); + +bool ForceRatio = true; +bool SeparationBorderDrag = true; +float DefaultWidth; +float DefaultHeight; +float widthTradeOff; +float heightTradeOff; + +//static char IniName[MAX_PATH]; +int sndcoretype=SNDCORE_DIRECTX; +int sndbuffersize=735*4; +int sndvolume=100; + +SoundInterface_struct *SNDCoreList[] = { + &SNDDummy, + &SNDDIRECTX, + NULL +}; + +GPU3DInterface *core3DList[] = { + &gpu3DNull, + &gpu3Dgl, + &gpu3DRasterize, + NULL +}; + +int autoframeskipenab=0; +int frameskiprate=0; +int emu_paused = 0; +bool frameAdvance = false; +bool staterewindingenabled = false; + +bool UseMicSample = false; +unsigned short windowSize = 0; + +/* the firmware settings */ +struct NDS_fw_config_data win_fw_config; + +/*const u32 gapColors[16] = { + Color::Gray, + Color::Brown, + Color::Red, + Color::Pink, + Color::Orange, + Color::Yellow, + Color::LightGreen, + Color::Lime, + Color::Green, + Color::SeaGreen, + Color::SkyBlue, + Color::Blue, + Color::DarkBlue, + Color::DarkViolet, + Color::Purple, + Color::Fuchsia +};*/ + +LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp); +LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK MicrophoneSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); + +//struct configured_features { +// u16 arm9_gdb_port; +// u16 arm7_gdb_port; +// +// const char *cflash_disk_image_file; +//}; + +int KeyInDelayInCount=30; + +static int lastTime = timeGetTime(); +int repeattime; + +VOID CALLBACK KeyInputTimer( UINT idEvent, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) +{ + // +// if(timeGetTime() - lastTime > 5) +// { + bool S9xGetState (WORD KeyIdent); + + /* if(GUI.JoystickHotkeys) + { + static uint32 joyState [256]; + + for(int i = 0 ; i < 255 ; i++) + { + bool active = !S9xGetState(0x8000|i); + + if(active) + { + if(joyState[i] < ULONG_MAX) // 0xffffffffUL + joyState[i]++; + if(joyState[i] == 1 || joyState[i] >= (unsigned) KeyInDelayInCount) + PostMessage(GUI.hWnd, WM_CUSTKEYDOWN, (WPARAM)(0x8000|i),(LPARAM)(NULL)); + } + else + { + if(joyState[i]) + { + joyState[i] = 0; + PostMessage(GUI.hWnd, WM_CUSTKEYUP, (WPARAM)(0x8000|i),(LPARAM)(NULL)); + } + } + } + }*/ + // if((!GUI.InactivePause || !Settings.ForcedPause) + // || (GUI.BackgroundInput || !(Settings.ForcedPause & (PAUSE_INACTIVE_WINDOW | PAUSE_WINDOW_ICONISED)))) + // { + static u32 joyState [256]; + static bool initialized = false; + if(!initialized) { + memset(joyState,0,sizeof(joyState)); + initialized = true; + } + for(int i = 0 ; i < 256 ; i++) + { + bool active = !S9xGetState(i); + if(active) + { + if(joyState[i] < ULONG_MAX) // 0xffffffffUL + joyState[i]++; + if(joyState[i] == 1 || joyState[i] == (unsigned) KeyInDelayInCount) { + + + //HEY HEY HEY! this only repeats once. this is what it needs to be like for frame advance. + //if anyone wants a different kind of repeat, then the whole setup will need to be redone + + //sort of fix the auto repeating + //TODO find something better + // repeattime++; + // if(repeattime % 10 == 0) { + //printf("trigger %d\n",i); + PostMessage(MainWindow->getHWnd(), WM_CUSTKEYDOWN, (WPARAM)(i),(LPARAM)(NULL)); + repeattime=0; + // } + } + } + else + { + if(joyState[i]) + { + joyState[i] = 0; + PostMessage(MainWindow->getHWnd(), WM_CUSTKEYUP, (WPARAM)(i),(LPARAM)(NULL)); + } + } + } + // } + // lastTime = timeGetTime(); +// } +} + +void ScaleScreen(float factor) +{ + if(windowSize == 0) + { + int defw = GetPrivateProfileInt("Video", "Window width", 256, IniName); + int defh = GetPrivateProfileInt("Video", "Window height", 384, IniName); + + // fix for wrong rotation + int w1x = video.rotatedwidthgap(); + int h1x = video.rotatedheightgap(); + if((defw > defh) != (w1x > h1x)) + { + int temp = defw; + defw = defh; + defh = temp; + } + // fix for wrong gap + if(defh*w1x < h1x*defw) + defh = defw*h1x/w1x; + else if(defw*h1x < w1x*defh) + defw = defh*w1x/h1x; + + MainWindow->setClientSize(defw, defh); + } + else + { + if(factor==65535) + factor = 1.5f; + else if(factor==65534) + factor = 2.5f; + MainWindow->setClientSize((video.rotatedwidthgap() * factor), (video.rotatedheightgap() * factor)); + } +} + +void SetMinWindowSize() +{ + if(ForceRatio) + MainWindow->setMinSize(video.rotatedwidth(), video.rotatedheight()); + else + MainWindow->setMinSize(video.rotatedwidthgap(), video.rotatedheightgap()); +} + +void translateXY(s32& x, s32& y) +{ + s32 tx=x, ty=y; + switch(video.rotation) + { + case 90: + x = ty; + y = 191-tx; + break; + case 180: + x = 255-tx; + y = 383-ty; + y -= 192; + break; + case 270: + x = 255-ty; + y = (tx-192-(video.screengap/video.ratio())); + break; + } +} +// END Rotation definitions + +void UpdateRecentRomsMenu() +{ + //This function will be called to populate the Recent Menu + //The array must be in the proper order ahead of time + + //UpdateRecentRoms will always call this + //This will be always called by GetRecentRoms on DesMume startup + + + //---------------------------------------------------------------------- + //Get Menu item info + + MENUITEMINFO moo; + moo.cbSize = sizeof(moo); + moo.fMask = MIIM_SUBMENU | MIIM_STATE; + + GetMenuItemInfo(GetSubMenu(mainMenu, 0), ID_FILE_RECENTROM, FALSE, &moo); + moo.hSubMenu = GetSubMenu(recentromsmenu, 0); + //moo.fState = RecentRoms[0].c_str() ? MFS_ENABLED : MFS_GRAYED; + moo.fState = MFS_ENABLED; + SetMenuItemInfo(GetSubMenu(mainMenu, 0), ID_FILE_RECENTROM, FALSE, &moo); + + //----------------------------------------------------------------------- + + //----------------------------------------------------------------------- + //Clear the current menu items + for(int x = 0; x < MAX_RECENT_ROMS; x++) + { + DeleteMenu(GetSubMenu(recentromsmenu, 0), baseid + x, MF_BYCOMMAND); + } + + if(RecentRoms.size() == 0) + { + EnableMenuItem(GetSubMenu(recentromsmenu, 0), clearid, MF_GRAYED); + + moo.cbSize = sizeof(moo); + moo.fMask = MIIM_DATA | MIIM_ID | MIIM_STATE | MIIM_TYPE; + + moo.cch = 5; + moo.fType = 0; + moo.wID = baseid; + moo.dwTypeData = "None"; + moo.fState = MF_GRAYED; + + InsertMenuItem(GetSubMenu(recentromsmenu, 0), 0, TRUE, &moo); + + return; + } + + EnableMenuItem(GetSubMenu(recentromsmenu, 0), clearid, MF_ENABLED); + DeleteMenu(GetSubMenu(recentromsmenu, 0), baseid, MF_BYCOMMAND); + + HDC dc = GetDC(MainWindow->getHWnd()); + + //----------------------------------------------------------------------- + //Update the list using RecentRoms vector + for(int x = RecentRoms.size()-1; x >= 0; x--) //Must loop in reverse order since InsertMenuItem will insert as the first on the list + { + string tmp = RecentRoms[x]; + LPSTR tmp2 = (LPSTR)tmp.c_str(); + + PathCompactPath(dc, tmp2, 500); + + moo.cbSize = sizeof(moo); + moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; + + moo.cch = tmp.size(); + moo.fType = 0; + moo.wID = baseid + x; + moo.dwTypeData = tmp2; + //LOG("Inserting: %s\n",tmp.c_str()); //Debug + InsertMenuItem(GetSubMenu(recentromsmenu, 0), 0, 1, &moo); + } + + ReleaseDC(MainWindow->getHWnd(), dc); + //----------------------------------------------------------------------- + + HWND temp = MainWindow->getHWnd(); + DrawMenuBar(temp); +} + +void UpdateRecentRoms(const char* filename) +{ + //This function assumes filename is a ROM filename that was successfully loaded + + string newROM = filename; //Convert to std::string + + //-------------------------------------------------------------- + //Check to see if filename is in list + vector::iterator x; + vector::iterator theMatch; + bool match = false; + for (x = RecentRoms.begin(); x < RecentRoms.end(); ++x) + { + if (newROM == *x) + { + //We have a match + match = true; //Flag that we have a match + theMatch = x; //Hold on to the iterator (Note: the loop continues, so if for some reason we had a duplicate (which wouldn't happen under normal circumstances, it would pick the last one in the list) + } + } + //---------------------------------------------------------------- + //If there was a match, remove it + if (match) + RecentRoms.erase(theMatch); + + RecentRoms.insert(RecentRoms.begin(), newROM); //Add to the array + + //If over the max, we have too many, so remove the last entry + if (RecentRoms.size() > MAX_RECENT_ROMS) + RecentRoms.pop_back(); + + //Debug + //for (int x = 0; x < RecentRoms.size(); x++) + // LOG("Recent ROM: %s\n",RecentRoms[x].c_str()); + + UpdateRecentRomsMenu(); +} + +void RemoveRecentRom(std::string filename) +{ + + vector::iterator x; + vector::iterator theMatch; + bool match = false; + for (x = RecentRoms.begin(); x < RecentRoms.end(); ++x) + { + if (filename == *x) + { + //We have a match + match = true; //Flag that we have a match + theMatch = x; //Hold on to the iterator (Note: the loop continues, so if for some reason we had a duplicate (which wouldn't happen under normal circumstances, it would pick the last one in the list) + } + } + //---------------------------------------------------------------- + //If there was a match, remove it + if (match) + RecentRoms.erase(theMatch); + + UpdateRecentRomsMenu(); +} + +void GetRecentRoms() +{ + //This function retrieves the recent ROMs stored in the .ini file + //Then is populates the RecentRomsMenu array + //Then it calls Update RecentRomsMenu() to populate the menu + + stringstream temp; + char tempstr[256]; + + // Avoids duplicating when changing the language. + RecentRoms.clear(); + + //Loops through all available recent slots + for (int x = 0; x < MAX_RECENT_ROMS; x++) + { + temp.str(""); + temp << "Recent Rom " << (x+1); + + GetPrivateProfileString("General",temp.str().c_str(),"", tempstr, 256, IniName); + if (tempstr[0]) + RecentRoms.push_back(tempstr); + } + UpdateRecentRomsMenu(); +} + +void SaveRecentRoms() +{ + //This function stores the RecentRomsMenu array to the .ini file + + stringstream temp; + + //Loops through all available recent slots + for (int x = 0; x < MAX_RECENT_ROMS; x++) + { + temp.str(""); + temp << "Recent Rom " << (x+1); + if (x < RecentRoms.size()) //If it exists in the array, save it + WritePrivateProfileString("General",temp.str().c_str(),RecentRoms[x].c_str(),IniName); + else //Else, make it empty + WritePrivateProfileString("General",temp.str().c_str(), "",IniName); + } +} + +void ClearRecentRoms() +{ + RecentRoms.clear(); + SaveRecentRoms(); + UpdateRecentRomsMenu(); +} + + + +int CreateDDrawBuffers() +{ + if (lpDDClipPrimary!=NULL) { IDirectDraw7_Release(lpDDClipPrimary); lpDDClipPrimary = NULL; } + if (lpPrimarySurface != NULL) { IDirectDraw7_Release(lpPrimarySurface); lpPrimarySurface = NULL; } + if (lpBackSurface != NULL) { IDirectDraw7_Release(lpBackSurface); lpBackSurface = NULL; } + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + ddsd.dwFlags = DDSD_CAPS; + if (IDirectDraw7_CreateSurface(lpDDraw, &ddsd, &lpPrimarySurface, NULL) != DD_OK) return -1; + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + + ddsd.dwWidth = video.rotatedwidth(); + ddsd.dwHeight = video.rotatedheight(); + + if (IDirectDraw7_CreateSurface(lpDDraw, &ddsd, &lpBackSurface, NULL) != DD_OK) return -2; + + if (IDirectDraw7_CreateClipper(lpDDraw, 0, &lpDDClipPrimary, NULL) != DD_OK) return -3; + + if (IDirectDrawClipper_SetHWnd(lpDDClipPrimary, 0, MainWindow->getHWnd()) != DD_OK) return -4; + if (IDirectDrawSurface7_SetClipper(lpPrimarySurface, lpDDClipPrimary) != DD_OK) return -5; + + return 1; +} + + +template static T realConvert(u16 val) +{ + switch(bpp) + { + case 24: case 32: + return RGB15TO24_REVERSE(val); + case 16: return RGB15TO16_REVERSE(val); + default: + return 0; + } +} + + +template static FORCEINLINE T ddconvert(u32 val) +{ + //not supported yet, needs to drop from 32 to 16 + return val; + //switch(bpp) + //{ + // case 24: case 32: + // return RGB15TO24_REVERSE(val); + // case 16: return RGB15TO16_REVERSE(val); + // default: + // return 0; + //} +} + +template static void doRotate(void* dst) +{ + u8* buffer = (u8*)dst; + int size = video.size(); + u32* src = (u32*)video.finalBuffer(); + switch(video.rotation) + { + case 0: + case 180: + { + if(ddsd.lPitch == 1024) + { + if(video.rotation==180) + for(int i = 0, j=size-1; j>=0; i++,j--) + ((T*)buffer)[i] = ddconvert((src)[j]); + else + for(int i = 0; i < size; i++) + ((T*)buffer)[i] = ddconvert(src[i]); + } + else + { + if(video.rotation==180) + for(int y = 0; y < video.height; y++) + { + for(int x = 0; x < video.width; x++) + ((T*)buffer)[x] = ddconvert(src[video.height*video.width - (y * video.width) - x - 1]); + + buffer += ddsd.lPitch; + } + else + for(int y = 0; y < video.height; y++) + { + for(int x = 0; x < video.width; x++) + ((T*)buffer)[x] = ddconvert(src[(y * video.width) + x]); + + buffer += ddsd.lPitch; + } + } + } + break; + case 90: + case 270: + { + if(video.rotation == 90) + for(int y = 0; y < video.width; y++) + { + for(int x = 0; x < video.height; x++) + ((T*)buffer)[x] = ddconvert(src[(((video.height-1)-x) * video.width) + y]); + + buffer += ddsd.lPitch; + } + else + for(int y = 0; y < video.width; y++) + { + for(int x = 0; x < video.height; x++) + ((T*)buffer)[x] = ddconvert(src[((x) * video.width) + (video.width-1) - y]); + + buffer += ddsd.lPitch; + } + } + break; + } +} + +//the directdraw final presentation portion of display, including rotating +static void DD_DoDisplay() +{ + int res; + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags=DDSD_ALL; + res = lpBackSurface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL); + + if (res==DDERR_SURFACELOST) + { + LOG("DirectDraw buffers is lost\n"); + if (IDirectDrawSurface7_Restore(lpPrimarySurface)==DD_OK) + IDirectDrawSurface7_Restore(lpBackSurface); + } else if(res != DD_OK) + return; + + char* buffer = (char*)ddsd.lpSurface; + + switch(ddsd.ddpfPixelFormat.dwRGBBitCount) + { + case 32: doRotate(ddsd.lpSurface); break; + case 24: doRotate(ddsd.lpSurface); break; + case 16: doRotate(ddsd.lpSurface); break; + default: + { + INFO("Unsupported color depth: %i bpp\n", ddsd.ddpfPixelFormat.dwRGBBitCount); + emu_halt(); + } + break; + } + + + lpBackSurface->Unlock((LPRECT)ddsd.lpSurface); + + // Main screen + if(lpPrimarySurface->Blt(&MainScreenRect, lpBackSurface, &MainScreenSrcRect, DDBLT_WAIT, 0) == DDERR_SURFACELOST) + { + LOG("DirectDraw buffers is lost\n"); + if(IDirectDrawSurface7_Restore(lpPrimarySurface) == DD_OK) + IDirectDrawSurface7_Restore(lpBackSurface); + } + + // Sub screen + if(lpPrimarySurface->Blt(&SubScreenRect, lpBackSurface, &SubScreenSrcRect, DDBLT_WAIT, 0) == DDERR_SURFACELOST) + { + LOG("DirectDraw buffers is lost\n"); + if(IDirectDrawSurface7_Restore(lpPrimarySurface) == DD_OK) + IDirectDrawSurface7_Restore(lpBackSurface); + } + + // Gap + if(video.screengap > 0) + { + //u32 color = gapColors[win_fw_config.fav_colour]; + //u32 color_rev = (((color & 0xFF) << 16) | (color & 0xFF00) | ((color & 0xFF0000) >> 16)); + u32 color_rev = 0xFFFFFF; + + HDC dc; + HBRUSH brush; + + dc = GetDC(MainWindow->getHWnd()); + brush = CreateSolidBrush(color_rev); + + FillRect(dc, &GapRect, brush); + + DeleteObject((HGDIOBJ)brush); + ReleaseDC(MainWindow->getHWnd(), dc); + } +} + +static void DoDisplay_DrawHud() +{ + osd->update(); + DrawHUD(); + osd->clear(); +} + +static void DoDisplay(bool firstTime) +{ + //convert pixel format to 32bpp for compositing + //why do we do this over and over? well, we are compositing to + //filteredbuffer32bpp, and it needs to get refreshed each frame.. + const int size = video.size(); + u16* src = (u16*)video.srcBuffer; + for(int i=0;iattach((u8*)video.buffer, 256, 384, 1024); + DoDisplay_DrawHud(); + } + + //apply user's filter + video.filter(); + + DD_DoDisplay(); +} + +void Display() +{ + CallRegisteredLuaFunctions(LUACALL_AFTEREMULATIONGUI); + + video.srcBuffer = (u8*)GPU_screen; + DoDisplay(true); +} + +void CheckMessages() +{ + MSG msg; + HWND hwnd = MainWindow->getHWnd(); + + #ifdef WX_STUB + wxDesmumeApp::frameUpdate(); + #endif + + while( PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ) ) + { + if( GetMessage( &msg, 0, 0, 0)>0 ) + { + if (RamWatchHWnd && IsDialogMessage(RamWatchHWnd, &msg)) + { + if(msg.message == WM_KEYDOWN) // send keydown messages to the dialog (for accelerators, and also needed for the Alt key to work) + SendMessage(RamWatchHWnd, msg.message, msg.wParam, msg.lParam); + continue; + } + if (SoundView_GetHWnd() && IsDialogMessage(SoundView_GetHWnd(), &msg)) + continue; + + if(!TranslateAccelerator(hwnd,hAccel,&msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + } +} +int fps; +DWORD WINAPI run() +{ + char txt[80]; + u32 cycles = 0; + int wait=0; + u64 freq; + u64 OneFrameTime; + int framestoskip=0; + int framesskipped=0; + int skipnextframe=0; + u64 lastticks=0; + u64 curticks=0; + u64 diffticks=0; + u32 framecount=0; + u64 onesecondticks=0; + int fps=0; + int fpsframecount=0; + u64 fpsticks=0; + int res; + HWND hwnd = MainWindow->getHWnd(); + + DDCAPS hw_caps, sw_caps; + + InitSpeedThrottle(); + + osd->setRotate(video.rotation); + + if (DirectDrawCreateEx(NULL, (LPVOID*)&lpDDraw, IID_IDirectDraw7, NULL) != DD_OK) + { + MessageBox(hwnd,"Unable to initialize DirectDraw","Error",MB_OK); + return -1; + } + + if (IDirectDraw7_SetCooperativeLevel(lpDDraw,hwnd, DDSCL_NORMAL) != DD_OK) + { + MessageBox(hwnd,"Unable to set DirectDraw Cooperative Level","Error",MB_OK); + return -1; + } + + if (CreateDDrawBuffers()<1) + { + MessageBox(hwnd,"Unable to set DirectDraw buffers","Error",MB_OK); + return -1; + } + + QueryPerformanceFrequency((LARGE_INTEGER *)&freq); + QueryPerformanceCounter((LARGE_INTEGER *)&lastticks); + OneFrameTime = freq / 60; + + while(!finished) + { + while(execute) + { + input_process(); + CallRegisteredLuaFunctions(LUACALL_BEFOREEMULATION); + FCEUMOV_AddInputState(); + + { + Lock lock; + NDS_exec(); + win_sound_samplecounter = 735; + } + DRV_AviVideoUpdate((u16*)GPU_screen); + + extern void rewindsave(); + extern bool rewinding; + extern void dorewind(); + + if (staterewindingenabled) { + + if(rewinding) + dorewind(); + else + rewindsave(); + } + + CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION); + + static int fps3d = 0; + + Hud.fps = fps; + Hud.fps3d = fps3d; + + Display(); + + gfx3d.frameCtrRaw++; + if(gfx3d.frameCtrRaw == 60) { + fps3d = gfx3d.frameCtr; + gfx3d.frameCtrRaw = 0; + gfx3d.frameCtr = 0; + } + + + // TODO: make that thing properly threaded + static DWORD tools_time_last = 0; + DWORD time_now = timeGetTime(); + if((time_now - tools_time_last) >= 50) + { + if(MemView_IsOpened(ARMCPU_ARM9)) MemView_Refresh(ARMCPU_ARM9); + if(MemView_IsOpened(ARMCPU_ARM7)) MemView_Refresh(ARMCPU_ARM7); + // if(IORegView_IsOpened()) IORegView_Refresh(); + + tools_time_last = time_now; + } + if(SoundView_IsOpened()) SoundView_Refresh(); + + Update_RAM_Watch(); + Update_RAM_Search(); + + fpsframecount++; + QueryPerformanceCounter((LARGE_INTEGER *)&curticks); + bool oneSecond = curticks >= fpsticks + freq; + if(oneSecond) // TODO: print fps on screen in DDraw + { + fps = fpsframecount; + fpsframecount = 0; + QueryPerformanceCounter((LARGE_INTEGER *)&fpsticks); + } + + if(nds.idleFrameCounter==0 || oneSecond) + { + //calculate a 16 frame arm9 load average + int load = 0; + for(int i=0;i<16;i++) + load = load/8 + nds.runCycleCollector[(i+nds.idleFrameCounter)&15]*7/8; + load = std::min(100,std::max(0,(int)(load*100/1120380))); + //sprintf(txt,"(%02d%%) %s", load, DESMUME_NAME_AND_VERSION); + SetWindowText(hwnd, DESMUME_NAME_AND_VERSION); + } + + if(!skipnextframe) + { + + framesskipped = 0; + + if (framestoskip > 0) + skipnextframe = 1; + } + else + { + framestoskip--; + + if (framestoskip < 1) + skipnextframe = 0; + else + skipnextframe = 1; + + framesskipped++; + + NDS_SkipNextFrame(); + } + + if(FastForward) { + if(framesskipped < 9) + { + skipnextframe = 1; + framestoskip = 1; + } + if (framestoskip < 1) + framestoskip += 9; + } + + else if(autoframeskipenab || FrameLimit) + while(SpeedThrottle()) + { + } + + if (autoframeskipenab) + { + framecount++; + + if (framecount > 60) + { + framecount = 1; + onesecondticks = 0; + } + + QueryPerformanceCounter((LARGE_INTEGER *)&curticks); + diffticks = curticks-lastticks; + + if(ThrottleIsBehind() && (framesskipped < 9)) + { + skipnextframe = 1; + framestoskip = 1; + } + + onesecondticks += diffticks; + lastticks = curticks; + } + else + { + if (framestoskip < 1) + framestoskip += frameskiprate; + } + if (frameAdvance) + { + frameAdvance = false; + emu_halt(); + SPU_Pause(1); + } +// DisplayMessage(); + CheckMessages(); + + } + + paused = TRUE; + CheckMessages(); + Sleep(100); + } + + if (lpDDClipPrimary!=NULL) IDirectDraw7_Release(lpDDClipPrimary); + if (lpPrimarySurface != NULL) IDirectDraw7_Release(lpPrimarySurface); + if (lpBackSurface != NULL) IDirectDraw7_Release(lpBackSurface); + if (lpDDraw != NULL) IDirectDraw7_Release(lpDDraw); + return 1; +} + +void NDS_Pause() +{ + if (!paused) + { + emu_halt(); + paused = TRUE; + SPU_Pause(1); + while (!paused) {} + INFO("Emulation paused\n"); + } +} + +void NDS_UnPause() +{ + if (romloaded && paused) + { + paused = FALSE; + pausedByMinimize = FALSE; + execute = TRUE; + SPU_Pause(0); + INFO("Emulation unpaused\n"); + } +} + + +/*** + * Author: Hicoder + * Function: UpdateSaveStateMenu + * Date Added: April 20, 2009 + * Description: Updates the specified savestate menus + * Known Usage: + * ResetSaveStateTimes + * LoadSaveStateInfo + **/ +void UpdateSaveStateMenu(int pos, char* txt) +{ + ModifyMenu(mainMenu,IDM_STATE_SAVE_F1 + pos, MF_BYCOMMAND | MF_STRING, IDM_STATE_SAVE_F1 + pos, txt); + ModifyMenu(mainMenu,IDM_STATE_LOAD_F1 + pos, MF_BYCOMMAND | MF_STRING, IDM_STATE_LOAD_F1 + pos, txt); +} + +/*** + * Author: Hicoder + * Function: ResetSaveStateTime + * Date Added: April 20, 2009 + * Description: Resets the times for save states to blank + * Known Usage: + * LoadRom + **/ +void ResetSaveStateTimes() +{ + char ntxt[64]; + for(int i = 0; i < NB_STATES;i++) + { + sprintf(ntxt,"%d %s", i+1, ""); + UpdateSaveStateMenu(i, ntxt); + } +} + +/*** + * Author: Hicoder + * Function: LoadSaveStateInfo + * Date Added: April 20, 2009 + * Description: Checks The Rom thats opening for save states asscociated with it + * Known Usage: + * LoadRom + **/ +void LoadSaveStateInfo() +{ + scan_savestates(); + char ntxt[128]; + for(int i = 0; i < NB_STATES; i++) + { + if(savestates[i].exists) + { + sprintf(ntxt, "&%d %s", i+1, savestates[i].date); + UpdateSaveStateMenu(i, ntxt); + } + } +} + +static BOOL LoadROM(const char * filename, const char * logicalName) +{ + ResetSaveStateTimes(); + NDS_Pause(); + //if (strcmp(filename,"")!=0) INFO("Attempting to load ROM: %s\n",filename); + + if (NDS_LoadROM(filename, logicalName) > 0) + { + INFO("Loading %s was successful\n",logicalName); + LoadSaveStateInfo(); + lagframecounter=0; + UpdateRecentRoms(logicalName); + osd->setRotate(video.rotation); + if (AutoRWLoad) + { + //Open Ram Watch if its auto-load setting is checked + OpenRWRecentFile(0); + RamWatchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMWATCH), MainWindow->getHWnd(), (DLGPROC) RamWatchProc); + } + + return TRUE; + } + INFO("Loading %s FAILED.\n",logicalName); + return FALSE; +} + +/* +* The thread handling functions needed by the GDB stub code. +*/ +void * +createThread_gdb( void (APIENTRY *thread_function)( void *data), + void *thread_data) { + void *new_thread = CreateThread( NULL, 0, + (LPTHREAD_START_ROUTINE)thread_function, thread_data, + 0, NULL); + + return new_thread; +} + +void +joinThread_gdb( void *thread_handle) { +} + + +int MenuInit() +{ + mainMenu = LoadMenu(hAppInst, "MENU_PRINCIPAL"); //Load Menu, and store handle + if (!MainWindow->setMenu(mainMenu)) return 0; + + recentromsmenu = LoadMenu(hAppInst, "RECENTROMS"); + GetRecentRoms(); + + ResetSaveStateTimes(); + + return 1; +} + +void MenuDeinit() +{ + MainWindow->setMenu(NULL); + DestroyMenu(mainMenu); +} + +typedef int (WINAPI *setLanguageFunc)(LANGID id); + +void SetLanguage(int langid) +{ + + HMODULE kernel32 = LoadLibrary("kernel32.dll"); + FARPROC _setThreadUILanguage = (FARPROC)GetProcAddress(kernel32,"SetThreadUILanguage"); + setLanguageFunc setLanguage = _setThreadUILanguage?(setLanguageFunc)_setThreadUILanguage:(setLanguageFunc)SetThreadLocale; + + switch(langid) + { + case 0: + // English + setLanguage(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); + SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)); + break; + case 1: + // French + setLanguage(MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH), SORT_DEFAULT)); + SetThreadLocale(MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH), SORT_DEFAULT)); + break; + case 2: + // Danish + setLanguage(MAKELCID(MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), SORT_DEFAULT)); + SetThreadLocale(MAKELCID(MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), SORT_DEFAULT)); + break; + case 3: + // Chinese + setLanguage(MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT)); + SetThreadLocale(MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED), SORT_DEFAULT)); + break; + + default: break; + break; + } + + FreeLibrary(kernel32); +} + +void SaveLanguage(int langid) +{ + char text[80]; + + sprintf(text, "%d", langid); + WritePrivateProfileString("General", "Language", text, IniName); +} + +void CheckLanguage(UINT id) +{ + int i; + for (i = IDC_LANGENGLISH; i < IDC_LANG_CHINESE_SIMPLIFIED+1; i++) + MainWindow->checkMenu(i, false); + + MainWindow->checkMenu(id, true); +} + +void ChangeLanguage(int id) +{ + SetLanguage(id); + + MenuDeinit(); + MenuInit(); +} + +int RegClass(WNDPROC Proc, LPCTSTR szName) +{ + WNDCLASS wc; + + wc.style = CS_DBLCLKS; + wc.cbClsExtra = wc.cbWndExtra=0; + wc.lpfnWndProc=Proc; + wc.hInstance=hAppInst; + wc.hIcon=LoadIcon(hAppInst,"ICONDESMUME"); + wc.hCursor=LoadCursor(NULL,IDC_ARROW); + wc.hbrBackground=(HBRUSH)(COLOR_BACKGROUND); + wc.lpszMenuName=(LPCTSTR)NULL; + wc.lpszClassName=szName; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + return RegisterClass(&wc); +} + +static void ExitRunLoop() +{ + finished = TRUE; + emu_halt(); +} + +class WinDriver : public BaseDriver +{ + virtual bool WIFI_Host_InitSystem() { + #ifdef EXPERIMENTAL_WIFI + //require wpcap.dll + HMODULE temp = LoadLibrary("wpcap.dll"); + if(temp == NULL) { + printf("Failed initializing wpcap.dll - softAP support disabled\n"); + return false; + } + FreeLibrary(temp); + return true; + #else + return false ; + #endif + } + virtual void WIFI_Host_ShutdownSystem() { + } + + virtual bool AVI_IsRecording() + { + return ::AVI_IsRecording(); + } + + virtual bool WAV_IsRecording() + { + return ::WAV_IsRecording(); + } + + virtual void USR_InfoMessage(const char *message) + { + LOG("%s\n", message); + osd->addLine(message); + } + + virtual void AVI_SoundUpdate(void* soundData, int soundLen) { + ::DRV_AviSoundUpdate(soundData, soundLen); + } +}; + +std::string GetPrivateProfileStdString(LPCSTR lpAppName,LPCSTR lpKeyName,LPCSTR lpDefault) +{ + static char buf[65536]; + GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, buf, 65536, IniName); + return buf; +} + +int _main() +{ + Desmume_InitOnce(); + InitDecoder(); + +#ifdef WX_STUB + wxInitialize(); +#endif + + driver = new WinDriver(); + + InitializeCriticalSection(&win_sync); + +#ifdef GDB_STUB + gdbstub_handle_t arm9_gdb_stub; + gdbstub_handle_t arm7_gdb_stub; + struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; + struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; + struct armcpu_ctrl_iface *arm9_ctrl_iface; + struct armcpu_ctrl_iface *arm7_ctrl_iface; +#endif +// struct configured_features my_config; + + extern bool windows_opengl_init(); + oglrender_init = windows_opengl_init; + + + char text[80]; + + GetINIPath(); + + addon_type = GetPrivateProfileInt("GBAslot", "type", NDS_ADDON_NONE, IniName); + UINT CFlashFileMode = GetPrivateProfileInt("GBAslot.CFlash", "fileMode", 2, IniName); + + CFlashPath = GetPrivateProfileStdString("GBAslot.CFlash", "path", ""); + CFlashName = GetPrivateProfileStdString("GBAslot.CFlash", "filename", ""); + GetPrivateProfileString("GBAslot.GBAgame", "filename", "", GBAgameName, MAX_PATH, IniName); + + if(CFlashFileMode==ADDON_CFLASH_MODE_Path) + { + CFlash_Mode = ADDON_CFLASH_MODE_Path; + } + else + if(CFlashFileMode==ADDON_CFLASH_MODE_File) + { + CFlash_Path = CFlashName; + CFlash_Mode = ADDON_CFLASH_MODE_File; + } + else + { + CFlash_Path = ""; + CFlash_Mode = ADDON_CFLASH_MODE_RomPath; + } + + //init_configured_features( &my_config); + /*if ( !fill_configured_features( &my_config, lpszArgument)) { + MessageBox(NULL,"Unable to parse command line arguments","Error",MB_OK); + return 0; + }*/ + ColorCtrl_Register(); + + if (!RegClass(WindowProcedure, "DeSmuME")) + { + MessageBox(NULL, "Error registering windows class", "DeSmuME", MB_OK); + exit(-1); + } + + windowSize = GetPrivateProfileInt("Video","Window Size", 0, IniName); + video.rotation = GetPrivateProfileInt("Video","Window Rotate", 0, IniName); + ForceRatio = GetPrivateProfileInt("Video","Window Force Ratio", 1, IniName); + WndX = GetPrivateProfileInt("Video","WindowPosX", CW_USEDEFAULT, IniName); + WndY = GetPrivateProfileInt("Video","WindowPosY", CW_USEDEFAULT, IniName); + if(WndX < -10000) WndX = CW_USEDEFAULT; // fix for missing window problem + if(WndY < -10000) WndY = CW_USEDEFAULT; // (happens if you close desmume while it's minimized) + video.width = GetPrivateProfileInt("Video", "Width", 256, IniName); + video.height = GetPrivateProfileInt("Video", "Height", 384, IniName); + + CommonSettings.hud.FpsDisplay = GetPrivateProfileBool("Display","Display Fps", 0, IniName); + CommonSettings.hud.FrameCounterDisplay = GetPrivateProfileBool("Display","FrameCounter", 0, IniName); + CommonSettings.hud.ShowInputDisplay = GetPrivateProfileBool("Display","Display Input", 0, IniName); + CommonSettings.hud.ShowLagFrameCounter = GetPrivateProfileBool("Display","Display Lag Counter", 0, IniName); + CommonSettings.hud.ShowMicrophone = GetPrivateProfileBool("Display","Display Microphone", 0, IniName); + + video.screengap = GetPrivateProfileInt("Display", "ScreenGap", 0, IniName); + SeparationBorderDrag = GetPrivateProfileBool("Display", "Window Split Border Drag", true, IniName); + FrameLimit = GetPrivateProfileInt("FrameLimit", "FrameLimit", 1, IniName); + CommonSettings.showGpu.main = GetPrivateProfileInt("Display", "MainGpu", 1, IniName) != 0; + CommonSettings.showGpu.sub = GetPrivateProfileInt("Display", "SubGpu", 1, IniName) != 0; + lostFocusPause = GetPrivateProfileInt("Focus", "BackgroundPause", 0, IniName); + + + //Get Ram-Watch values + RWSaveWindowPos = GetPrivateProfileInt("RamWatch", "SaveWindowPos", 0, IniName); + ramw_x = GetPrivateProfileInt("RamWatch", "RWWindowPosX", 0, IniName); + ramw_y = GetPrivateProfileInt("RamWatch", "RWWindowPosY", 0, IniName); + AutoRWLoad = GetPrivateProfileInt("RamWatch", "Auto-load", 0, IniName); + for(int i = 0; i < MAX_RECENT_WATCHES; i++) + { + char str[256]; + sprintf(str, "Recent Watch %d", i+1); + GetPrivateProfileString("Watches", str, "", &rw_recent_files[i][0], 1024, IniName); + } + + //i think we should override the ini file with anything from the commandline + CommandLine cmdline; + cmdline.loadCommonOptions(); + if(!cmdline.parse(__argc,__argv)) { + cmdline.errorHelp(__argv[0]); + return 1; + } + + //sprintf(text, "%s", DESMUME_NAME_AND_VERSION); + MainWindow = new WINCLASS(CLASSNAME, hAppInst); + DWORD dwStyle = WS_CAPTION| WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; + if (!MainWindow->create(DESMUME_NAME_AND_VERSION, WndX/*CW_USEDEFAULT*/, WndY/*CW_USEDEFAULT*/, video.width,video.height+video.screengap, + WS_CAPTION| WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + NULL)) + { + MessageBox(NULL, "Error creating main window", "DeSmuME", MB_OK); + delete MainWindow; + exit(-1); + } + + gpu_SetRotateScreen(video.rotation); + + /* default the firmware settings, they may get changed later */ + NDS_FillDefaultFirmwareConfigData( &win_fw_config); + + GetPrivateProfileString("General", "Language", "0", text, 80, IniName); + SetLanguage(atoi(text)); + + //hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL)); //Now that we have a hotkey system we down need the Accel table. Not deleting just yet though + + if(MenuInit() == 0) + { + MessageBox(NULL, "Error creating main menu", "DeSmuME", MB_OK); + delete MainWindow; + exit(-1); + } + + SetMinWindowSize(); + + ScaleScreen(windowSize); + + DragAcceptFiles(MainWindow->getHWnd(), TRUE); + +#ifdef EXPERIMENTAL_WIFI + EnableMenuItem(mainMenu, IDM_WIFISETTINGS, MF_ENABLED); +#endif + + + InitCustomKeys(&CustomKeys); + Hud.reset(); + + void input_init(); + input_init(); + + if (addon_type == NDS_ADDON_GUITARGRIP) Guitar.Enabled = true; + + LOG("Init NDS\n"); + + GInfo_Init(); + + MemView_Init(); + SoundView_Init(); + + ViewDisasm_ARM7 = new TOOLSCLASS(hAppInst, IDD_DESASSEMBLEUR_VIEWER7, (DLGPROC) ViewDisasm_ARM7Proc); + ViewDisasm_ARM9 = new TOOLSCLASS(hAppInst, IDD_DESASSEMBLEUR_VIEWER9, (DLGPROC) ViewDisasm_ARM9Proc); + //ViewMem_ARM7 = new TOOLSCLASS(hAppInst, IDD_MEM_VIEWER7, (DLGPROC) ViewMem_ARM7Proc); + //ViewMem_ARM9 = new TOOLSCLASS(hAppInst, IDD_MEM_VIEWER9, (DLGPROC) ViewMem_ARM9Proc); + ViewRegisters = new TOOLSCLASS(hAppInst, IDD_IO_REG, (DLGPROC) IoregView_Proc); + ViewPalette = new TOOLSCLASS(hAppInst, IDD_PAL, (DLGPROC) ViewPalProc); + ViewTiles = new TOOLSCLASS(hAppInst, IDD_TILE, (DLGPROC) ViewTilesProc); + ViewMaps = new TOOLSCLASS(hAppInst, IDD_MAP, (DLGPROC) ViewMapsProc); + ViewOAM = new TOOLSCLASS(hAppInst, IDD_OAM, (DLGPROC) ViewOAMProc); + ViewMatrices = new TOOLSCLASS(hAppInst, IDD_MATRIX_VIEWER, (DLGPROC) ViewMatricesProc); + ViewLights = new TOOLSCLASS(hAppInst, IDD_LIGHT_VIEWER, (DLGPROC) ViewLightsProc); + + + cmdline.process_addonCommands(); + if(cmdline.is_cflash_configured) + { + addon_type = NDS_ADDON_CFLASH; + //push the commandline-provided options into the current config slots + if(CFlash_Mode == ADDON_CFLASH_MODE_Path) + CFlashPath = CFlash_Path; + else + CFlashName = CFlash_Path; + } + + + switch (addon_type) + { + case NDS_ADDON_NONE: + break; + case NDS_ADDON_CFLASH: + break; + case NDS_ADDON_RUMBLEPAK: + break; + case NDS_ADDON_GBAGAME: + if (!strlen(GBAgameName)) + { + addon_type = NDS_ADDON_NONE; + break; + } + // TODO: check for file exist + break; + case NDS_ADDON_GUITARGRIP: + break; + default: + addon_type = NDS_ADDON_NONE; + break; + } + addonsChangePak(addon_type); + +#ifdef GDB_STUB + if ( cmdline.arm9_gdb_port != 0) { + arm9_gdb_stub = createStub_gdb( cmdline.arm9_gdb_port, + &arm9_memio, &arm9_direct_memory_iface); + + if ( arm9_gdb_stub == NULL) { + MessageBox(MainWindow->getHWnd(),"Failed to create ARM9 gdbstub","Error",MB_OK); + return -1; + } + } + if ( cmdline.arm7_gdb_port != 0) { + arm7_gdb_stub = createStub_gdb( cmdline.arm7_gdb_port, + &arm7_memio, + &arm7_base_memory_iface); + + if ( arm7_gdb_stub == NULL) { + MessageBox(MainWindow->getHWnd(),"Failed to create ARM7 gdbstub","Error",MB_OK); + return -1; + } + } + + NDS_Init( arm9_memio, &arm9_ctrl_iface, + arm7_memio, &arm7_ctrl_iface); +#else + NDS_Init (); +#endif + + /* + * Activate the GDB stubs + * This has to come after the NDS_Init where the cpus are set up. + */ +#ifdef GDB_STUB + if ( cmdline.arm9_gdb_port != 0) { + activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); + } + if ( cmdline.arm7_gdb_port != 0) { + activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); + } +#endif + + GetPrivateProfileString("General", "Language", "0", text, 80, IniName); + CheckLanguage(IDC_LANGENGLISH+atoi(text)); + + GetPrivateProfileString("Video", "FrameSkip", "0", text, 80, IniName); + + if (strcmp(text, "AUTO") == 0) + { + autoframeskipenab=1; + frameskiprate=0; + MainWindow->checkMenu(IDC_FRAMESKIPAUTO, true); + } + else + { + autoframeskipenab=0; + frameskiprate=atoi(text); + MainWindow->checkMenu(frameskiprate + IDC_FRAMESKIP0, true); + } + + int KeyInRepeatMSec=20; + + hKeyInputTimer = timeSetEvent (KeyInRepeatMSec, 0, KeyInputTimer, 0, TIME_PERIODIC); + + cur3DCore = GetPrivateProfileInt("3D", "Renderer", GPU3D_OPENGL, IniName); + CommonSettings.HighResolutionInterpolateColor = GetPrivateProfileInt("3D", "HighResolutionInterpolateColor", 1, IniName); + CommonSettings.gfx3d_flushMode = GetPrivateProfileInt("3D", "AlternateFlush", 0, IniName); + NDS_3D_ChangeCore(cur3DCore); + +#ifdef BETA_VERSION + EnableMenuItem (mainMenu, IDM_SUBMITBUGREPORT, MF_GRAYED); +#endif + LOG("Init sound core\n"); + sndcoretype = GetPrivateProfileInt("Sound","SoundCore2", SNDCORE_DIRECTX, IniName); + sndbuffersize = GetPrivateProfileInt("Sound","SoundBufferSize", 735 * 4, IniName); + CommonSettings.spuInterpolationMode = (SPUInterpolationMode)GetPrivateProfileInt("Sound","SPUInterpolation", 1, IniName); + CommonSettings.spuAdpcmCache = GetPrivateProfileInt("Sound","SPUAdpcmCache",0,IniName)!=0; + + EnterCriticalSection(&win_sync); + int spu_ret = SPU_ChangeSoundCore(sndcoretype, sndbuffersize); + LeaveCriticalSection(&win_sync); + if(spu_ret != 0) + { + MessageBox(MainWindow->getHWnd(),"Unable to initialize DirectSound","Error",MB_OK); + return -1; + } + + sndvolume = GetPrivateProfileInt("Sound","Volume",100, IniName); + SPU_SetVolume(sndvolume); + + CommonSettings.DebugConsole = GetPrivateProfileInt("Emulation", "DebugConsole", FALSE, IniName); + CommonSettings.UseExtBIOS = GetPrivateProfileInt("BIOS", "UseExtBIOS", FALSE, IniName); + GetPrivateProfileString("BIOS", "ARM9BIOSFile", "bios9.bin", CommonSettings.ARM9BIOS, 256, IniName); + GetPrivateProfileString("BIOS", "ARM7BIOSFile", "bios7.bin", CommonSettings.ARM7BIOS, 256, IniName); + CommonSettings.SWIFromBIOS = GetPrivateProfileInt("BIOS", "SWIFromBIOS", FALSE, IniName); + + CommonSettings.UseExtFirmware = GetPrivateProfileInt("Firmware", "UseExtFirmware", FALSE, IniName); + GetPrivateProfileString("Firmware", "FirmwareFile", "firmware.bin", CommonSettings.Firmware, 256, IniName); + CommonSettings.BootFromFirmware = GetPrivateProfileInt("Firmware", "BootFromFirmware", FALSE, IniName); + + CommonSettings.wifiBridgeAdapterNum = GetPrivateProfileInt("Wifi", "BridgeAdapter", 0, IniName); + + video.currentfilter = GetPrivateProfileInt("Video", "Filter", video.NONE, IniName); + void FilterUpdate(HWND hwnd); + FilterUpdate(MainWindow->getHWnd()); + + /* Read the firmware settings from the init file */ + win_fw_config.fav_colour = GetPrivateProfileInt("Firmware","favColor", 10, IniName); + win_fw_config.birth_month = GetPrivateProfileInt("Firmware","bMonth", 7, IniName); + win_fw_config.birth_day = GetPrivateProfileInt("Firmware","bDay", 15, IniName); + win_fw_config.language = GetPrivateProfileInt("Firmware","Language", 1, IniName); + + { + /* + * Read in the nickname and message. + * Convert the strings into Unicode UTF-16 characters. + */ + char temp_str[27]; + int char_index; + GetPrivateProfileString("Firmware","nickName", "yopyop", temp_str, 11, IniName); + win_fw_config.nickname_len = strlen( temp_str); + + if ( win_fw_config.nickname_len == 0) { + strcpy( temp_str, "yopyop"); + win_fw_config.nickname_len = strlen( temp_str); + } + + for ( char_index = 0; char_index < win_fw_config.nickname_len; char_index++) { + win_fw_config.nickname[char_index] = temp_str[char_index]; + } + + GetPrivateProfileString("Firmware","Message", "DeSmuME makes you happy!", temp_str, 27, IniName); + win_fw_config.message_len = strlen( temp_str); + for ( char_index = 0; char_index < win_fw_config.message_len; char_index++) { + win_fw_config.message[char_index] = temp_str[char_index]; + } + } + + // Create the dummy firmware + NDS_CreateDummyFirmware( &win_fw_config); + + + if (cmdline.nds_file != "") + { + if(OpenCore(cmdline.nds_file.c_str())) + { + romloaded = TRUE; + if(!cmdline.start_paused) + NDS_UnPause(); + } + } + + cmdline.process_movieCommands(); + + if(cmdline.load_slot != 0) + { + HK_StateLoadSlot(cmdline.load_slot); + } + + MainWindow->Show(SW_NORMAL); + run(); + SaveRecentRoms(); + DRV_AviEnd(); + WAV_End(); + + NDS_DeInit(); + + //------SHUTDOWN + +#ifdef DEBUG + //LogStop(); +#endif + + GInfo_DeInit(); + + MemView_DlgClose(ARMCPU_ARM9); + MemView_DlgClose(ARMCPU_ARM7); + SoundView_DlgClose(); + //IORegView_DlgClose(); + + MemView_DeInit(); + SoundView_DeInit(); + + //if (input!=NULL) delete input; + if (ViewLights!=NULL) delete ViewLights; + if (ViewMatrices!=NULL) delete ViewMatrices; + if (ViewOAM!=NULL) delete ViewOAM; + if (ViewMaps!=NULL) delete ViewMaps; + if (ViewTiles!=NULL) delete ViewTiles; + if (ViewPalette!=NULL) delete ViewPalette; + if (ViewRegisters!=NULL) delete ViewRegisters; +// if (ViewMem_ARM9!=NULL) delete ViewMem_ARM9; +// if (ViewMem_ARM7!=NULL) delete ViewMem_ARM7; + if (ViewDisasm_ARM9!=NULL) delete ViewDisasm_ARM9; + if (ViewDisasm_ARM7!=NULL) delete ViewDisasm_ARM7; + + delete MainWindow; + + return 0; +} + +int WINAPI WinMain (HINSTANCE hThisInstance, + HINSTANCE hPrevInstance, + LPSTR lpszArgument, + int nFunsterStil) + +{ + timeBeginPeriod(1); + g_thread_init (NULL); + hAppInst=hThisInstance; + OpenConsole(); // Init debug console + + int ret = _main(); + + CloseConsole(); + + return ret; +} + +void UpdateWndRects(HWND hwnd) +{ + POINT ptClient; + RECT rc; + + int wndWidth, wndHeight; + int defHeight = (video.height + video.screengap); + float ratio; + int oneScreenHeight, gapHeight; + + GetClientRect(hwnd, &rc); + + if((video.rotation == 90) || (video.rotation == 270)) + { + wndWidth = (rc.bottom - rc.top); + wndHeight = (rc.right - rc.left); + } + else + { + wndWidth = (rc.right - rc.left); + wndHeight = (rc.bottom - rc.top); + } + + ratio = ((float)wndHeight / (float)defHeight); + oneScreenHeight = ((video.height/2) * ratio); + gapHeight = (wndHeight - (oneScreenHeight * 2)); + + if((video.rotation == 90) || (video.rotation == 270)) + { + // Main screen + ptClient.x = rc.left; + ptClient.y = rc.top; + ClientToScreen(hwnd, &ptClient); + MainScreenRect.left = ptClient.x; + MainScreenRect.top = ptClient.y; + ptClient.x = (rc.left + oneScreenHeight); + ptClient.y = (rc.top + wndWidth); + ClientToScreen(hwnd, &ptClient); + MainScreenRect.right = ptClient.x; + MainScreenRect.bottom = ptClient.y; + + //if there was no specified screen gap, extend the top screen to cover the extra column + if(video.screengap == 0) MainScreenRect.right += gapHeight; + + // Sub screen + ptClient.x = (rc.left + oneScreenHeight + gapHeight); + ptClient.y = rc.top; + ClientToScreen(hwnd, &ptClient); + SubScreenRect.left = ptClient.x; + SubScreenRect.top = ptClient.y; + ptClient.x = (rc.left + oneScreenHeight + gapHeight + oneScreenHeight); + ptClient.y = (rc.top + wndWidth); + ClientToScreen(hwnd, &ptClient); + SubScreenRect.right = ptClient.x; + SubScreenRect.bottom = ptClient.y; + + // Gap + GapRect.left = (rc.left + oneScreenHeight); + GapRect.top = rc.top; + GapRect.right = (rc.left + oneScreenHeight + gapHeight); + GapRect.bottom = (rc.top + wndWidth); + } + else + { + // Main screen + ptClient.x = rc.left; + ptClient.y = rc.top; + ClientToScreen(hwnd, &ptClient); + MainScreenRect.left = ptClient.x; + MainScreenRect.top = ptClient.y; + ptClient.x = (rc.left + wndWidth); + ptClient.y = (rc.top + oneScreenHeight); + ClientToScreen(hwnd, &ptClient); + MainScreenRect.right = ptClient.x; + MainScreenRect.bottom = ptClient.y; + + //if there was no specified screen gap, extend the top screen to cover the extra row + if(video.screengap == 0) MainScreenRect.bottom += gapHeight; + + // Sub screen + ptClient.x = rc.left; + ptClient.y = (rc.top + oneScreenHeight + gapHeight); + ClientToScreen(hwnd, &ptClient); + SubScreenRect.left = ptClient.x; + SubScreenRect.top = ptClient.y; + ptClient.x = (rc.left + wndWidth); + ptClient.y = (rc.top + oneScreenHeight + gapHeight + oneScreenHeight); + ClientToScreen(hwnd, &ptClient); + SubScreenRect.right = ptClient.x; + SubScreenRect.bottom = ptClient.y; + + // Gap + GapRect.left = rc.left; + GapRect.top = (rc.top + oneScreenHeight); + GapRect.right = (rc.left + wndWidth); + GapRect.bottom = (rc.top + oneScreenHeight + gapHeight); + } +} + +void UpdateScreenRects() +{ + if((video.rotation == 90) || (video.rotation == 270)) + { + // Main screen + MainScreenSrcRect.left = 0; + MainScreenSrcRect.top = 0; + MainScreenSrcRect.right = video.height/2; + MainScreenSrcRect.bottom = video.width; + + // Sub screen + SubScreenSrcRect.left = video.height/2; + SubScreenSrcRect.top = 0; + SubScreenSrcRect.right = video.height; + SubScreenSrcRect.bottom = video.width; + } + else + { + // Main screen + MainScreenSrcRect.left = 0; + MainScreenSrcRect.top = 0; + MainScreenSrcRect.right = video.width; + MainScreenSrcRect.bottom = video.height/2; + + // Sub screen + SubScreenSrcRect.left = 0; + SubScreenSrcRect.top = video.height/2; + SubScreenSrcRect.right = video.width; + SubScreenSrcRect.bottom = video.height; + } +} + +// re-run the aspect ratio calculations if enabled +void FixAspectRatio() +{ + if(windowSize != 0) + { + ScaleScreen(windowSize); + } + else if(ForceRatio) + { + RECT rc; + GetWindowRect(MainWindow->getHWnd(), &rc); + SendMessage(MainWindow->getHWnd(), WM_SIZING, WMSZ_BOTTOMRIGHT, (LPARAM)&rc); + MoveWindow(MainWindow->getHWnd(), rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE); + } +} + +void SetScreenGap(int gap) +{ + video.screengap = gap; + SetMinWindowSize(); + FixAspectRatio(); + UpdateWndRects(MainWindow->getHWnd()); +} + +//======================================================================================== +void SetRotate(HWND hwnd, int rot) +{ + RECT rc; + int oldrot = video.rotation; + int oldheight, oldwidth; + int newheight, newwidth; + + video.rotation = rot; + + GetClientRect(hwnd, &rc); + oldwidth = (rc.right - rc.left); + oldheight = (rc.bottom - rc.top); + newwidth = oldwidth; + newheight = oldheight; + + switch(oldrot) + { + case 0: + case 180: + { + if((rot == 90) || (rot == 270)) + { + newwidth = oldheight; + newheight = oldwidth; + } + } + break; + + case 90: + case 270: + { + if((rot == 0) || (rot == 180)) + { + newwidth = oldheight; + newheight = oldwidth; + } + } + break; + } + + osd->setRotate(rot); + + SetMinWindowSize(); + + MainWindow->setClientSize(newwidth, newheight); + + /* Recreate the DirectDraw back buffer */ + if (lpBackSurface!=NULL) + { + IDirectDrawSurface7_Release(lpBackSurface); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + ddsd.dwWidth = video.rotatedwidth(); + ddsd.dwHeight = video.rotatedheight(); + + IDirectDraw7_CreateSurface(lpDDraw, &ddsd, &lpBackSurface, NULL); + } + + WritePrivateProfileInt("Video","Window Rotate",video.rotation,IniName); + + gpu_SetRotateScreen(video.rotation); + + UpdateScreenRects(); +} + +void AviEnd() +{ + NDS_Pause(); + DRV_AviEnd(); + NDS_UnPause(); +} + +//Shows an Open File menu and starts recording an AVI +void AviRecordTo() +{ + NDS_Pause(); + + OPENFILENAME ofn; + + ////if we are playing a movie, construct the filename from the current movie. + ////else construct it from the filename. + //if(FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD)) + //{ + // extern char curMovieFilename[]; + // strcpy(szChoice, curMovieFilename); + // char* dot = strrchr(szChoice,'.'); + + // if (dot) + // { + // *dot='\0'; + // } + + // strcat(szChoice, ".avi"); + //} + //else + //{ + // extern char FileBase[]; + // sprintf(szChoice, "%s.avi", FileBase); + //} + + // avi record file browser + memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = MainWindow->getHWnd(); + ofn.lpstrFilter = "AVI Files (*.avi)\0*.avi\0\0"; + ofn.lpstrDefExt = "avi"; + ofn.lpstrTitle = "Save AVI as"; + + char folder[MAX_PATH]; + ZeroMemory(folder, sizeof(folder)); + path.getpath(path.AVI_FILES, folder); + + char file[MAX_PATH]; + ZeroMemory(file, sizeof(file)); + path.formatname(file); + + strcat(folder, file); + int len = strlen(folder); + if(len > MAX_PATH - 4) + folder[MAX_PATH - 4] = '\0'; + + strcat(folder, ".avi"); + ofn.lpstrFile = folder; + + + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; + + if(GetSaveFileName(&ofn)) + { + DRV_AviBegin(folder); + } + + NDS_UnPause(); +} + +void WavEnd() +{ + NDS_Pause(); + WAV_End(); + NDS_UnPause(); +} + +//Shows an Open File menu and starts recording an WAV +void WavRecordTo() +{ + NDS_Pause(); + + OPENFILENAME ofn; + char szChoice[MAX_PATH] = {0}; + + ////if we are playing a movie, construct the filename from the current movie. + ////else construct it from the filename. + //if(FCEUMOV_Mode(MOVIEMODE_PLAY|MOVIEMODE_RECORD)) + //{ + // extern char curMovieFilename[]; + // strcpy(szChoice, curMovieFilename); + // char* dot = strrchr(szChoice,'.'); + + // if (dot) + // { + // *dot='\0'; + // } + + // strcat(szChoice, ".wav"); + //} + //else + //{ + // extern char FileBase[]; + // sprintf(szChoice, "%s.wav", FileBase); + //} + + // wav record file browser + memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = MainWindow->getHWnd(); + ofn.lpstrFilter = "WAV Files (*.wav)\0*.wav\0\0"; + ofn.lpstrFile = szChoice; + ofn.lpstrDefExt = "wav"; + ofn.lpstrTitle = "Save WAV as"; + + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; + + if(GetSaveFileName(&ofn)) + { + WAV_Begin(szChoice); + } + + NDS_UnPause(); +} + +void OpenRecentROM(int listNum) +{ + if (listNum > MAX_RECENT_ROMS) return; //Just in case + char filename[MAX_PATH]; + strcpy(filename, RecentRoms[listNum].c_str()); + //LOG("Attempting to load %s\n",filename); + if(OpenCore(filename)) + { + romloaded = TRUE; + } + else + //Rom failed to load, ask the user how to handle it + { + string str = "Could not open "; + str.append(filename); + str.append("\n\nRemove from list?"); + if (MessageBox(MainWindow->getHWnd(), str.c_str(), "File error", MB_YESNO) == IDYES) + { + RemoveRecentRom(RecentRoms[listNum]); + } + } + + NDS_UnPause(); +} + +#include "OpenArchive.h" +#include "utils/xstring.h" + +static BOOL OpenCore(const char* filename) +{ + char LogicalName[1024], PhysicalName[1024]; + + const char* s_nonRomExtensions [] = {"txt", "nfo", "htm", "html", "jpg", "jpeg", "png", "bmp", "gif", "mp3", "wav", "lnk", "exe", "bat", "gmv", "gm2", "lua", "luasav", "sav", "srm", "brm", "cfg", "wch", "gs*", "dst"}; + + if(!ObtainFile(filename, LogicalName, PhysicalName, "rom", s_nonRomExtensions, ARRAY_SIZE(s_nonRomExtensions))) + return FALSE; + + if(LoadROM(filename, LogicalName)) + { + romloaded = TRUE; + NDS_UnPause(); + return TRUE; + } + else return FALSE; +} + +LRESULT OpenFile() +{ + HWND hwnd = MainWindow->getHWnd(); + + int filterSize = 0, i = 0; + OPENFILENAME ofn; + char filename[MAX_PATH] = "", + fileFilter[512]=""; + NDS_Pause(); //Stop emulation while opening new rom + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + + // To avoid #ifdef hell, we'll do a little trick, as lpstrFilter + // needs 0 terminated string, and standard string library, of course, + // can't help us with string creation: just put a '|' were a string end + // should be, and later transform prior assigning to the OPENFILENAME structure + strncpy (fileFilter, "NDS ROM file (*.nds)|*.nds|NDS/GBA ROM File (*.ds.gba)|*.ds.gba|",512); +#ifdef HAVE_LIBZZIP + strncpy (fileFilter, "All Usable Files (*.nds, *.ds.gba, *.zip, *.gz, *.7z, *.rar, *.bz2)|*.nds;*.ds.gba;*.zip;*.gz;*.7z;*.rar;*.bz2|",512); +#endif + +#ifdef HAVE_LIBZZIP + strncat (fileFilter, "Zipped NDS ROM file (*.zip)|*.zip|",512 - strlen(fileFilter)); +#endif +#ifdef HAVE_LIBZ + strncat (fileFilter, "GZipped NDS ROM file (*.gz)|*.gz|",512 - strlen(fileFilter)); +#endif + strncat (fileFilter, "7Zipped NDS ROM file (*.7z)|*.7z|",512 - strlen(fileFilter)); + strncat (fileFilter, "RARed NDS ROM file (*.rar)|*.rar|",512 - strlen(fileFilter)); + strncat (fileFilter, "BZipped NDS ROM file (*.bz2)|*.bz2|",512 - strlen(fileFilter)); + + strncat (fileFilter, "Any file (*.*)|*.*||",512 - strlen(fileFilter)); + + filterSize = strlen(fileFilter); + for (i = 0; i < filterSize; i++) + { + if (fileFilter[i] == '|') fileFilter[i] = '\0'; + } + ofn.lpstrFilter = fileFilter; + ofn.nFilterIndex = 1; + ofn.lpstrFile = filename; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "nds"; + ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; + + char buffer[MAX_PATH]; + ZeroMemory(buffer, sizeof(buffer)); + path.getpath(path.ROMS, buffer); + ofn.lpstrInitialDir = buffer; + + + if (GetOpenFileName(&ofn) == NULL) { + NDS_UnPause(); + return 0; + } + else { + if(path.savelastromvisit) + { + char *lchr, buffer[MAX_PATH]; + ZeroMemory(buffer, sizeof(buffer)); + + lchr = strrchr(filename, '\\'); + strncpy(buffer, filename, strlen(filename) - strlen(lchr)); + + path.setpath(path.ROMS, buffer); + WritePathSettings(); + } + } + + if(!OpenCore(filename)) + return 0; + +// if(!GetOpenFileName(&ofn)) +// { +// if (romloaded) +// { +// CheatsSearchReset(); +// NDS_UnPause(); //Restart emulation if no new rom chosen +// } +// return 0; +// } + + + + return 0; +} + +//TODO - async key state? for real? +int GetModifiers(int key) +{ + int modifiers = 0; + + if (key == VK_MENU || key == VK_CONTROL || key == VK_SHIFT) + return 0; + + if(GetAsyncKeyState(VK_MENU )&0x8000) modifiers |= CUSTKEY_ALT_MASK; + if(GetAsyncKeyState(VK_CONTROL)&0x8000) modifiers |= CUSTKEY_CTRL_MASK; + if(GetAsyncKeyState(VK_SHIFT )&0x8000) modifiers |= CUSTKEY_SHIFT_MASK; + return modifiers; +} + +int HandleKeyUp(WPARAM wParam, LPARAM lParam, int modifiers) +{ + SCustomKey *key = &CustomKeys.key(0); + + while (!IsLastCustomKey(key)) { + if (wParam == key->key && modifiers == key->modifiers && key->handleKeyUp) { + key->handleKeyUp(key->param); + } + key++; + } + + return 1; +} + +int HandleKeyMessage(WPARAM wParam, LPARAM lParam, int modifiers) +{ + //some crap from snes9x I dont understand with toggles and macros... + + bool hitHotKey = false; + + if(!(wParam == 0 || wParam == VK_ESCAPE)) // if it's the 'disabled' key, it's never pressed as a hotkey + { + SCustomKey *key = &CustomKeys.key(0); + while (!IsLastCustomKey(key)) { + if (wParam == key->key && modifiers == key->modifiers && key->handleKeyDown) { + key->handleKeyDown(key->param); + hitHotKey = true; + } + key++; + } + + // don't pull down menu if alt is a hotkey or the menu isn't there, unless no game is running + //if(!Settings.StopEmulation && ((wParam == VK_MENU || wParam == VK_F10) && (hitHotKey || GetMenu (GUI.hWnd) == NULL) && !GetAsyncKeyState(VK_F4))) + /*if(((wParam == VK_MENU || wParam == VK_F10) && (hitHotKey || GetMenu (MainWindow->getHWnd()) == NULL) && !GetAsyncKeyState(VK_F4))) + return 0;*/ + return 1; + } + + return 1; +} + +static void Unpause() +{ + lastPauseFromLostFocus = FALSE; + if (emu_paused) NDS_UnPause(); + emu_paused = 0; +} + +void Pause() +{ + lastPauseFromLostFocus = FALSE; + if (emu_paused) NDS_UnPause(); + else NDS_Pause(); + emu_paused ^= 1; +} + +bool first; + +void FrameAdvance(bool state) +{ + if(state) { + if(first) { + execute = TRUE; + frameAdvance=true; + first=false; + } + else { + execute = TRUE; + } + } + else { + first = true; + if(frameAdvance) + {} + else + { + emu_halt(); + SPU_Pause(1); + emu_paused = 1; + } + } +} + +enum CONFIGSCREEN +{ + CONFIGSCREEN_INPUT, + CONFIGSCREEN_HOTKEY, + CONFIGSCREEN_FIRMWARE, + CONFIGSCREEN_WIFI, + CONFIGSCREEN_SOUND, + CONFIGSCREEN_EMULATION, + CONFIGSCREEN_MICROPHONE, + CONFIGSCREEN_PATHSETTINGS +}; + +void RunConfig(CONFIGSCREEN which) +{ + HWND hwnd = MainWindow->getHWnd(); + bool tpaused=false; + if (execute) + { + tpaused=true; + NDS_Pause(); + } + + switch(which) + { + case CONFIGSCREEN_INPUT: + RunInputConfig(); + break; + case CONFIGSCREEN_HOTKEY: + RunHotkeyConfig(); + break; + case CONFIGSCREEN_FIRMWARE: + DialogBox(hAppInst,MAKEINTRESOURCE(IDD_FIRMSETTINGS), hwnd, (DLGPROC) FirmConfig_Proc); + break; + case CONFIGSCREEN_SOUND: + DialogBox(hAppInst, MAKEINTRESOURCE(IDD_SOUNDSETTINGS), hwnd, (DLGPROC)SoundSettingsDlgProc); + break; + case CONFIGSCREEN_EMULATION: + DialogBox(hAppInst, MAKEINTRESOURCE(IDD_EMULATIONSETTINGS), hwnd, (DLGPROC)EmulationSettingsDlgProc); + break; + case CONFIGSCREEN_MICROPHONE: + DialogBox(hAppInst, MAKEINTRESOURCE(IDD_MICROPHONE), hwnd, (DLGPROC)MicrophoneSettingsDlgProc); + break; + case CONFIGSCREEN_PATHSETTINGS: + DialogBox(hAppInst, MAKEINTRESOURCE(IDD_PATHSETTINGS), hwnd, (DLGPROC)PathSettingsDlgProc); + break; + case CONFIGSCREEN_WIFI: +#ifdef EXPERIMENTAL_WIFI + if(wifi_netEnabled) + { + DialogBox(hAppInst,MAKEINTRESOURCE(IDD_WIFISETTINGS), hwnd, (DLGPROC) WifiSettingsDlgProc); + } + else + { +#endif + MessageBox(MainWindow->getHWnd(),"winpcap failed to initialize, and so wifi cannot be configured.","wifi system failure",0); +#ifdef EXPERIMENTAL_WIFI + } +#endif + break; + } + + if (tpaused) + NDS_UnPause(); +} + +void FilterUpdate (HWND hwnd){ + UpdateScreenRects(); + UpdateWndRects(hwnd); + SetScreenGap(video.screengap); + SetRotate(hwnd, video.rotation); + ScaleScreen(windowSize); + WritePrivateProfileInt("Video", "Filter", video.currentfilter, IniName); + WritePrivateProfileInt("Video", "Width", video.width, IniName); + WritePrivateProfileInt("Video", "Height", video.height, IniName); +} + +void DesEnableMenuItem(HMENU hMenu, UINT uIDEnableItem, bool enable) +{ + EnableMenuItem(hMenu, uIDEnableItem, MF_BYCOMMAND | (enable?MF_ENABLED:MF_GRAYED)); +} + +//======================================================================================== +LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + static int tmp_execute; + switch (message) // handle the messages + { + case WM_ENTERMENULOOP: //Update menu items that needs to be updated dynamically + { + UpdateHotkeyAssignments(); //Add current hotkey mappings to menu item names + + MENUITEMINFO mii; + TCHAR menuItemString[256]; + ZeroMemory(&mii, sizeof(MENUITEMINFO)); + //Check if AVI is recording + mii.cbSize = sizeof(MENUITEMINFO); + mii.fMask = MIIM_STRING; + LoadString(hAppInst, !AVI_IsRecording() ? IDM_FILE_RECORDAVI : IDM_FILE_STOPAVI, menuItemString, 256); + mii.dwTypeData = menuItemString; + SetMenuItemInfo(mainMenu, IDM_FILE_RECORDAVI, FALSE, &mii); + //Check if WAV is recording + LoadString(hAppInst, !WAV_IsRecording() ? IDM_FILE_RECORDWAV : IDM_FILE_STOPWAV, menuItemString, 256); + SetMenuItemInfo(mainMenu, IDM_FILE_RECORDWAV, FALSE, &mii); + + //Menu items dependent on a ROM loaded + DesEnableMenuItem(mainMenu, IDM_GAME_INFO, romloaded); + DesEnableMenuItem(mainMenu, IDM_IMPORTBACKUPMEMORY,romloaded); + DesEnableMenuItem(mainMenu, IDM_EXPORTBACKUPMEMORY,romloaded); + DesEnableMenuItem(mainMenu, IDM_STATE_SAVE, romloaded); + DesEnableMenuItem(mainMenu, IDM_STATE_LOAD, romloaded); + DesEnableMenuItem(mainMenu, IDM_PRINTSCREEN, romloaded); + DesEnableMenuItem(mainMenu, IDM_QUICK_PRINTSCREEN, romloaded); + DesEnableMenuItem(mainMenu, IDM_FILE_RECORDAVI, romloaded); + DesEnableMenuItem(mainMenu, IDM_FILE_RECORDWAV, romloaded); + DesEnableMenuItem(mainMenu, IDM_RESET, romloaded); + DesEnableMenuItem(mainMenu, IDM_SHUT_UP, romloaded); + DesEnableMenuItem(mainMenu, IDM_CHEATS_LIST, romloaded); + DesEnableMenuItem(mainMenu, IDM_CHEATS_SEARCH, romloaded); + DesEnableMenuItem(mainMenu, IDM_WIFISETTINGS, romloaded); + + DesEnableMenuItem(mainMenu, IDM_RECORD_MOVIE, (romloaded && movieMode == MOVIEMODE_INACTIVE)); + DesEnableMenuItem(mainMenu, IDM_PLAY_MOVIE, (romloaded && movieMode == MOVIEMODE_INACTIVE)); + DesEnableMenuItem(mainMenu, IDM_STOPMOVIE, (romloaded && movieMode != MOVIEMODE_INACTIVE)); + + DesEnableMenuItem(mainMenu, ID_RAM_WATCH, romloaded); + DesEnableMenuItem(mainMenu, ID_RAM_SEARCH, romloaded); + //Update savestate slot items based on ROM loaded + for (int x = 0; x < 10; x++) + { + DesEnableMenuItem(mainMenu, IDM_STATE_SAVE_F1+x, romloaded); + DesEnableMenuItem(mainMenu, IDM_STATE_LOAD_F1+x, romloaded); + } + + //Gray the recent ROM menu item if there are no recent ROMs + DesEnableMenuItem(mainMenu, ID_FILE_RECENTROM, RecentRoms.size()>0); + + //Updated Checked menu items + + //Pause + MainWindow->checkMenu(IDM_PAUSE, paused); + //Force Maintain Ratio + MainWindow->checkMenu(IDC_FORCERATIO, ForceRatio); + //Screen rotation + MainWindow->checkMenu(IDC_ROTATE0, ((video.rotation==0))); + MainWindow->checkMenu(IDC_ROTATE90, ((video.rotation==90))); + MainWindow->checkMenu(IDC_ROTATE180, ((video.rotation==180))); + MainWindow->checkMenu(IDC_ROTATE270, ((video.rotation==270))); + + //Window Size + MainWindow->checkMenu(IDC_WINDOW1X, ((windowSize==1))); + MainWindow->checkMenu(IDC_WINDOW1_5X, ((windowSize==65535))); + MainWindow->checkMenu(IDC_WINDOW2X, ((windowSize==2))); + MainWindow->checkMenu(IDC_WINDOW2_5X, ((windowSize==65534))); + MainWindow->checkMenu(IDC_WINDOW3X, ((windowSize==3))); + MainWindow->checkMenu(IDC_WINDOW4X, ((windowSize==4))); + + //Screen Separation + MainWindow->checkMenu(IDM_SCREENSEP_NONE, ((video.screengap==kGapNone))); + MainWindow->checkMenu(IDM_SCREENSEP_BORDER, ((video.screengap==kGapBorder))); + MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP, ((video.screengap==kGapNDS))); + MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP2, ((video.screengap==kGapNDS2))); + MainWindow->checkMenu(IDM_SCREENSEP_DRAGEDIT, (SeparationBorderDrag)); + + //Counters / Etc. + MainWindow->checkMenu(ID_VIEW_FRAMECOUNTER,CommonSettings.hud.FrameCounterDisplay); + MainWindow->checkMenu(ID_VIEW_DISPLAYFPS,CommonSettings.hud.FpsDisplay); + MainWindow->checkMenu(ID_VIEW_DISPLAYINPUT,CommonSettings.hud.ShowInputDisplay); + MainWindow->checkMenu(ID_VIEW_DISPLAYLAG,CommonSettings.hud.ShowLagFrameCounter); + MainWindow->checkMenu(ID_VIEW_DISPLAYMICROPHONE,CommonSettings.hud.ShowMicrophone); + MainWindow->checkMenu(ID_VIEW_HUDEDITOR, HudEditorMode); + MainWindow->checkMenu(IDC_FRAMELIMIT, FrameLimit); + + //Frame Skip + MainWindow->checkMenu(IDC_FRAMESKIPAUTO, ((autoframeskipenab))); + + MainWindow->checkMenu(IDC_FRAMESKIP0, (!autoframeskipenab && frameskiprate==0) ); + MainWindow->checkMenu(IDC_FRAMESKIP1, (!autoframeskipenab && frameskiprate==1) ); + MainWindow->checkMenu(IDC_FRAMESKIP2, (!autoframeskipenab && frameskiprate==2) ); + MainWindow->checkMenu(IDC_FRAMESKIP3, (!autoframeskipenab && frameskiprate==3) ); + MainWindow->checkMenu(IDC_FRAMESKIP4, (!autoframeskipenab && frameskiprate==4) ); + MainWindow->checkMenu(IDC_FRAMESKIP5, (!autoframeskipenab && frameskiprate==5) ); + MainWindow->checkMenu(IDC_FRAMESKIP6, (!autoframeskipenab && frameskiprate==6) ); + MainWindow->checkMenu(IDC_FRAMESKIP7, (!autoframeskipenab && frameskiprate==7) ); + MainWindow->checkMenu(IDC_FRAMESKIP8, (!autoframeskipenab && frameskiprate==8) ); + MainWindow->checkMenu(IDC_FRAMESKIP9, (!autoframeskipenab && frameskiprate==9) ); + + //gpu visibility toggles + MainWindow->checkMenu(IDM_MGPU, CommonSettings.showGpu.main ); + MainWindow->checkMenu(IDM_SGPU, CommonSettings.showGpu.sub ); + + //Filters + MainWindow->checkMenu(IDM_RENDER_NORMAL, video.currentfilter == video.NONE ); + MainWindow->checkMenu(IDM_RENDER_HQ2X, video.currentfilter == video.HQ2X ); + MainWindow->checkMenu(IDM_RENDER_2XSAI, video.currentfilter == video._2XSAI ); + MainWindow->checkMenu(IDM_RENDER_SUPER2XSAI, video.currentfilter == video.SUPER2XSAI ); + MainWindow->checkMenu(IDM_RENDER_SUPEREAGLE, video.currentfilter == video.SUPEREAGLE ); + MainWindow->checkMenu(IDM_RENDER_SCANLINE, video.currentfilter == video.SCANLINE ); + MainWindow->checkMenu(IDM_RENDER_BILINEAR, video.currentfilter == video.BILINEAR ); + MainWindow->checkMenu(IDM_RENDER_NEAREST2X, video.currentfilter == video.NEAREST2X ); + + MainWindow->checkMenu(IDC_STATEREWINDING, staterewindingenabled == 1 ); + + //Language selection + MainWindow->checkMenu(IDC_BACKGROUNDPAUSE, lostFocusPause); + + //Save type + const int savelist[] = {IDC_SAVETYPE1,IDC_SAVETYPE2,IDC_SAVETYPE3,IDC_SAVETYPE4,IDC_SAVETYPE5,IDC_SAVETYPE6,IDC_SAVETYPE7}; + for(int i=0;i<7;i++) MainWindow->checkMenu(savelist[i], false); + MainWindow->checkMenu(savelist[CommonSettings.manualBackupType], true); + + + return 0; + } + /*case WM_EXITMENULOOP: + { + if (tmp_execute==2) NDS_UnPause(); + return 0; + }*/ + + case WM_CREATE: + { + path.ReadPathSettings(); + pausedByMinimize = FALSE; + UpdateScreenRects(); + return 0; + } + case WM_DESTROY: + case WM_CLOSE: + { + NDS_Pause(); + if (true/*AskSave()*/) //Ask Save comes from the Ram Watch dialog. The dialog uses .wch files and this allows asks the user if he wants to save changes first, should he cancel, closing will not happen + { + //Save window size + WritePrivateProfileInt("Video","Window Size",windowSize,IniName); + if (windowSize==0) + { + // WritePrivateProfileInt("Video","Window width",MainWindowRect.right-MainWindowRect.left+widthTradeOff,IniName); + // WritePrivateProfileInt("Video","Window height",MainWindowRect.bottom-MainWindowRect.top+heightTradeOff,IniName); + RECT rc; + GetClientRect(hwnd, &rc); + WritePrivateProfileInt("Video", "Window width", (rc.right - rc.left), IniName); + WritePrivateProfileInt("Video", "Window height", (rc.bottom - rc.top), IniName); + } + + //Save window position + WritePrivateProfileInt("Video", "WindowPosX", WndX/*MainWindowRect.left*/, IniName); + WritePrivateProfileInt("Video", "WindowPosY", WndY/*MainWindowRect.top*/, IniName); + + //Save frame counter status + WritePrivateProfileInt("Display", "FrameCounter", CommonSettings.hud.FrameCounterDisplay, IniName); + WritePrivateProfileInt("Display", "ScreenGap", video.screengap, IniName); + + //Save Ram Watch information + WritePrivateProfileInt("RamWatch", "SaveWindowPos", RWSaveWindowPos, IniName); + WritePrivateProfileInt("RamWatch", "RWWindowPosX", ramw_x, IniName); + WritePrivateProfileInt("RamWatch", "RWWindowPosY", ramw_y, IniName); + WritePrivateProfileInt("RamWatch", "Auto-load", AutoRWLoad, IniName); + + for(int i = 0; i < MAX_RECENT_WATCHES; i++) + { + char str[256]; + sprintf(str, "Recent Watch %d", i+1); + WritePrivateProfileString("Watches", str, &rw_recent_files[i][0], IniName); + } + + ExitRunLoop(); + } + else + NDS_UnPause(); + return 0; + } + case WM_MOVING: + InvalidateRect(hwnd, NULL, FALSE); UpdateWindow(hwnd); + return 0; + case WM_MOVE: { + RECT rect; + GetWindowRect(MainWindow->getHWnd(),&rect); + WndX = rect.left; + WndY = rect.top; + UpdateWndRects(hwnd); + return 0; + } + + case WM_KILLFOCUS: + if(lostFocusPause) { + if(!emu_paused) { + Pause(); + lastPauseFromLostFocus = TRUE; + } + } + return 0; + case WM_SETFOCUS: + if(lostFocusPause) { + if(lastPauseFromLostFocus) { + Unpause(); + } + } + return 0; + + case WM_SIZING: + { + InvalidateRect(hwnd, NULL, FALSE); UpdateWindow(hwnd); + + if(windowSize) + { + windowSize = 0; + MainWindow->checkMenu(IDC_WINDOW1X, false); + MainWindow->checkMenu(IDC_WINDOW1_5X, false); + MainWindow->checkMenu(IDC_WINDOW2X, false); + MainWindow->checkMenu(IDC_WINDOW2_5X, false); + MainWindow->checkMenu(IDC_WINDOW3X, false); + MainWindow->checkMenu(IDC_WINDOW4X, false); + } + + RECT cRect, ncRect; + GetClientRect(MainWindow->getHWnd(), &cRect); + GetWindowRect(MainWindow->getHWnd(), &ncRect); + + LONG forceRatioFlags = WINCLASS::NOKEEP; + bool setGap = false; + bool sideways = (video.rotation == 90) || (video.rotation == 270); + { + bool horizontalDrag = (wParam == WMSZ_LEFT) || (wParam == WMSZ_RIGHT); + bool verticalDrag = (wParam == WMSZ_TOP) || (wParam == WMSZ_BOTTOM); + int minX = video.rotatedwidthgap(); + int minY = video.rotatedheightgap(); + if(verticalDrag && !sideways && SeparationBorderDrag) + { + forceRatioFlags |= WINCLASS::KEEPX; + minY = (MainScreenRect.bottom - MainScreenRect.top) + (SubScreenRect.bottom - SubScreenRect.top); + setGap = true; + } + else if(horizontalDrag && sideways && SeparationBorderDrag) + { + forceRatioFlags |= WINCLASS::KEEPY; + minX = (MainScreenRect.right - MainScreenRect.left) + (SubScreenRect.right - SubScreenRect.left); + setGap = true; + } + else if(ForceRatio) + { + forceRatioFlags |= WINCLASS::KEEPX; + forceRatioFlags |= WINCLASS::KEEPY; + } + MainWindow->setMinSize(minX, minY); + } + + + MainWindow->sizingMsg(wParam, lParam, forceRatioFlags); + + + if(setGap) + { + RECT rc = *(RECT*)lParam; + rc.right += (cRect.right - cRect.left) - (ncRect.right - ncRect.left); + rc.bottom += (cRect.bottom - cRect.top) - (ncRect.bottom - ncRect.top); + int wndWidth, wndHeight, wndHeightGapless; + if(sideways) + { + wndWidth = (rc.bottom - rc.top); + wndHeight = (rc.right - rc.left); + wndHeightGapless = (MainScreenRect.right - MainScreenRect.left) + (SubScreenRect.right - SubScreenRect.left); + } + else + { + wndWidth = (rc.right - rc.left); + wndHeight = (rc.bottom - rc.top); + wndHeightGapless = (MainScreenRect.bottom - MainScreenRect.top) + (SubScreenRect.bottom - SubScreenRect.top); + } + if(ForceRatio) + video.screengap = wndHeight * video.width / wndWidth - video.height; + else + video.screengap = wndHeight * video.height / wndHeightGapless - video.height; + UpdateWndRects(MainWindow->getHWnd()); + } + } + return 1; + //break; + + case WM_GETMINMAXINFO: + if(ForceRatio) + { + // extend the window size limits, otherwise they can make our window get squashed + PMINMAXINFO pmmi = (PMINMAXINFO)lParam; + pmmi->ptMaxTrackSize.x *= 4; + pmmi->ptMaxTrackSize.y *= 4; + return 1; + } + break; + + case WM_KEYDOWN: + if(wParam != VK_PAUSE) + break; + case WM_SYSKEYDOWN: + case WM_CUSTKEYDOWN: + { + int modifiers = GetModifiers(wParam); + if(!HandleKeyMessage(wParam,lParam, modifiers)) + return 0; + break; + } + case WM_KEYUP: + if(wParam != VK_PAUSE) + break; + case WM_SYSKEYUP: + case WM_CUSTKEYUP: + { + int modifiers = GetModifiers(wParam); + HandleKeyUp(wParam, lParam, modifiers); + } + break; + + case WM_SIZE: + switch(wParam) + { + case SIZE_MINIMIZED: + { + if(!paused) + { + pausedByMinimize = TRUE; + NDS_Pause(); + } + } + break; + default: + { + if(pausedByMinimize) + NDS_UnPause(); + + UpdateWndRects(hwnd); + } + break; + } + return 0; + case WM_PAINT: + { + HDC hdc; + PAINTSTRUCT ps; + + hdc = BeginPaint(hwnd, &ps); + + Display(); + + EndPaint(hwnd, &ps); + } + return 0; + case WM_DROPFILES: + { + char filename[MAX_PATH] = ""; + DragQueryFile((HDROP)wParam,0,filename,MAX_PATH); + DragFinish((HDROP)wParam); + + //adelikat: dropping these in from FCEUX, I hope this is the best place for that + std::string fileDropped = filename; + //------------------------------------------------------- + //Check if Movie file + //------------------------------------------------------- + if (!(fileDropped.find(".dsm") == string::npos) && (fileDropped.find(".dsm") == fileDropped.length()-4)) //ROM is already loaded and .dsm in filename + { + if (romloaded && !(fileDropped.find(".dsm") == string::npos)) //.dsm is at the end of the filename so that must be the extension + FCEUI_LoadMovie(fileDropped.c_str(), 1, false, false); //We are convinced it is a movie file, attempt to load it + } + + //------------------------------------------------------- + //Check if Savestate file + //------------------------------------------------------- + else if (!(fileDropped.find(".ds") == string::npos)) + { + size_t extIndex = fileDropped.find(".ds"); + if (extIndex <= fileDropped.length()-4) //Check to see it is both at the end (file extension) and there is on more character + { + if ((fileDropped[extIndex+3] >= '0' && fileDropped[extIndex+3] <= '9') || fileDropped[extIndex+3] == '-' || fileDropped[extIndex+3] == 't') //If last character is 0-9 (making .ds0 - .ds9) or .dst + { + savestate_load(filename); + Update_RAM_Watch(); //adelikat: TODO this should be a single function call in main, that way we can expand as future dialogs need updating + Update_RAM_Search(); //hotkey.cpp - HK_StateLoadSlot & State_Load also call these functions + } + } + } + + //------------------------------------------------------- + //Else load it as a ROM + //------------------------------------------------------- + + else if(OpenCore(filename)) + { + romloaded = TRUE; + } + NDS_UnPause(); + } + return 0; + case WM_MOUSEMOVE: + case WM_LBUTTONDOWN: + case WM_LBUTTONDBLCLK: + if (wParam & MK_LBUTTON) + { + RECT r ; + s32 x = (s32)((s16)LOWORD(lParam)); + s32 y = (s32)((s16)HIWORD(lParam)); + GetClientRect(hwnd,&r); + SetCapture(hwnd); + int defwidth = video.width, defheight = (video.height+video.screengap); + int winwidth = (r.right-r.left), winheight = (r.bottom-r.top); + + // translate from scaling (screen resolution to 256x384 or 512x192) + switch (video.rotation) + { + case 0: + case 180: + x = (x*defwidth) / winwidth; + y = (y*defheight) / winheight; + break ; + case 90: + case 270: + x = (x*defheight) / winwidth; + y = (y*defwidth) / winheight; + break ; + } + + x = x/video.ratio(); + y = y/video.ratio(); + + if(HudEditorMode) { + EditHud(x,y, &Hud); + } + else { + //translate for rotation + if (video.rotation != 0) + translateXY(x,y); + else + y-=192+(video.screengap/video.ratio()); + + if(x<0) x = 0; else if(x>255) x = 255; + if(y<0) y = 0; else if(y>192) y = 192; + NDS_setTouchPos(x, y); + return 0; + } + } + NDS_releaseTouch(); + return 0; + + case WM_LBUTTONUP: + + ReleaseCapture(); + NDS_releaseTouch(); + HudClickRelease(&Hud); + return 0; + +#if 0 + case WM_INITMENU: { + HMENU menu = (HMENU)wParam; + //last minute modification of menu before display + #ifndef DEVELOPER + RemoveMenu(menu,IDM_DISASSEMBLER,MF_BYCOMMAND); + #endif + break; + } +#endif + + case WM_COMMAND: + if(HIWORD(wParam) == 0 || HIWORD(wParam) == 1) + { + //wParam &= 0xFFFF; + + // A menu item from the recent files menu was clicked. + if(wParam >= baseid && wParam <= baseid + MAX_RECENT_ROMS - 1) + { + int x = wParam - baseid; + OpenRecentROM(x); + } + else if(wParam == clearid) + { + /* Clear all the recent ROMs */ + ClearRecentRoms(); + } + + } + switch(LOWORD(wParam)) + { + case IDM_SHUT_UP: + if(SPU_user) SPU_user->ShutUp(); + return 0; + case IDM_QUIT: + if (AskSave()) DestroyWindow(hwnd); + return 0; + case IDM_OPEN: + return OpenFile(); + case IDM_PRINTSCREEN: + HK_PrintScreen(0); + return 0; + case IDM_QUICK_PRINTSCREEN: + { + char buffer[MAX_PATH]; + ZeroMemory(buffer, sizeof(buffer)); + path.getpath(path.SCREENSHOTS, buffer); + + char file[MAX_PATH]; + ZeroMemory(file, sizeof(file)); + path.formatname(file); + + strcat(buffer, file); + if( strlen(buffer) > (MAX_PATH - 4)) + buffer[MAX_PATH - 4] = '\0'; + + switch(path.imageformat()) + { + case path.PNG: + { + strcat(buffer, ".png"); + NDS_WritePNG(buffer); + } + break; + case path.BMP: + { + strcat(buffer, ".bmp"); + NDS_WriteBMP(buffer); + } + break; + } + } + return 0; + case IDM_FILE_RECORDAVI: + if (AVI_IsRecording()) + AviEnd(); + else + AviRecordTo(); + break; + case IDM_FILE_RECORDWAV: + if (WAV_IsRecording()) + WAV_End(); + else + WavRecordTo(); + break; + case IDC_STATEREWINDING: + if(staterewindingenabled) staterewindingenabled = false; + else staterewindingenabled = true; + break; + case IDM_RENDER_NORMAL: + video.setfilter(video.NONE); + FilterUpdate(hwnd); + break; + case IDM_RENDER_HQ2X: + video.setfilter(video.HQ2X); + FilterUpdate(hwnd); + break; + case IDM_RENDER_2XSAI: + video.setfilter(video._2XSAI); + FilterUpdate(hwnd); + break; + case IDM_RENDER_SUPER2XSAI: + video.setfilter(video.SUPER2XSAI); + FilterUpdate(hwnd); + break; + case IDM_RENDER_SUPEREAGLE: + video.setfilter(video.SUPEREAGLE); + FilterUpdate(hwnd); + break; + case IDM_RENDER_SCANLINE: + video.setfilter(video.SCANLINE); + FilterUpdate(hwnd); + break; + case IDM_RENDER_BILINEAR: + video.setfilter(video.BILINEAR); + FilterUpdate(hwnd); + break; + case IDM_RENDER_NEAREST2X: + video.setfilter(video.NEAREST2X); + FilterUpdate(hwnd); + break; + case IDM_STATE_LOAD: + { + OPENFILENAME ofn; + NDS_Pause(); + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "DeSmuME Savestate (*.dst or *.ds#)\0*.dst;*.ds0*;*.ds1*;*.ds2*;*.ds3*;*.ds4*;*.ds5*;*.ds6*;*.ds7*;*.ds8*;*.ds9*;*.ds-*\0DeSmuME Savestate (*.dst only)\0*.dst\0All files (*.*)\0*.*\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = SavName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "dst"; + ofn.Flags = OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; + + char buffer[MAX_PATH]; + ZeroMemory(buffer, sizeof(buffer)); + path.getpath(path.STATES, buffer); + ofn.lpstrInitialDir = buffer; + + if(!GetOpenFileName(&ofn)) + { + NDS_UnPause(); + return 0; + } + + savestate_load(SavName); + Update_RAM_Watch(); //adelikat: TODO this should be a single function call in main, that way we can expand as future dialogs need updating + Update_RAM_Search(); //hotkey.cpp - HK_StateLoadSlot also calls these functions + NDS_UnPause(); + } + return 0; + case IDM_STATE_SAVE: + { + OPENFILENAME ofn; + NDS_Pause(); + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "DeSmuME Savestate (*.dst or *.ds#)\0*.dst;*.ds0*;*.ds1*;*.ds2*;*.ds3*;*.ds4*;*.ds5*;*.ds6*;*.ds7*;*.ds8*;*.ds9*;*.ds-*\0DeSmuME Savestate (*.dst only)\0*.dst\0All files (*.*)\0*.*\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = SavName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "dst"; + ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; + + char buffer[MAX_PATH]; + ZeroMemory(buffer, sizeof(buffer)); + path.getpath(path.STATES, buffer); + ofn.lpstrInitialDir = buffer; + + if(!GetSaveFileName(&ofn)) + { + return 0; + } + + savestate_save(SavName); + LoadSaveStateInfo(); + NDS_UnPause(); + } + return 0; + case IDM_STATE_SAVE_F1: + case IDM_STATE_SAVE_F2: + case IDM_STATE_SAVE_F3: + case IDM_STATE_SAVE_F4: + case IDM_STATE_SAVE_F5: + case IDM_STATE_SAVE_F6: + case IDM_STATE_SAVE_F7: + case IDM_STATE_SAVE_F8: + case IDM_STATE_SAVE_F9: + case IDM_STATE_SAVE_F10: + HK_StateSaveSlot( abs(IDM_STATE_SAVE_F1 - LOWORD(wParam)) +1); + return 0; + + case IDM_STATE_LOAD_F1: + HK_StateLoadSlot(1); + return 0; + case IDM_STATE_LOAD_F2: + HK_StateLoadSlot(2); + return 0; + case IDM_STATE_LOAD_F3: + HK_StateLoadSlot(3); + return 0; + case IDM_STATE_LOAD_F4: + HK_StateLoadSlot(4); + return 0; + case IDM_STATE_LOAD_F5: + HK_StateLoadSlot(5); + return 0; + case IDM_STATE_LOAD_F6: + HK_StateLoadSlot(6); + return 0; + case IDM_STATE_LOAD_F7: + HK_StateLoadSlot(7); + return 0; + case IDM_STATE_LOAD_F8: + HK_StateLoadSlot(8); + return 0; + case IDM_STATE_LOAD_F9: + HK_StateLoadSlot(9); + return 0; + case IDM_STATE_LOAD_F10: + HK_StateLoadSlot(10); + return 0; + case IDM_IMPORTBACKUPMEMORY: + { + OPENFILENAME ofn; + NDS_Pause(); + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "All supported types\0*.duc;*.sav\0Action Replay DS Save (*.duc)\0*.duc\0Raw Save format (*.sav)\0*.sav\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = ImportSavName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "duc"; + ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; + + char buffer[MAX_PATH]; + ZeroMemory(buffer, sizeof(buffer)); + path.getpath(path.BATTERY, buffer); + ofn.lpstrInitialDir = buffer; + + if(!GetOpenFileName(&ofn)) + { + NDS_UnPause(); + return 0; + } + + if (!NDS_ImportSave(ImportSavName)) + MessageBox(hwnd,"Save was not successfully imported","Error",MB_OK); + NDS_UnPause(); + return 0; + } + case IDM_EXPORTBACKUPMEMORY: + { + OPENFILENAME ofn; + NDS_Pause(); + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "Raw Save format (*.sav)\0*.sav\0\0"; + ofn.nFilterIndex = 0; + ofn.lpstrFile = ImportSavName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "sav"; + ofn.Flags = OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; + + if(!GetSaveFileName(&ofn)) + { + NDS_UnPause(); + return 0; + } + + if (!NDS_ExportSave(ImportSavName)) + MessageBox(hwnd,"Save was not successfully exported","Error",MB_OK); + NDS_UnPause(); + return 0; + } + + + case IDM_CONFIG: + RunConfig(CONFIGSCREEN_INPUT); + return 0; + case IDM_HOTKEY_CONFIG: + RunConfig(CONFIGSCREEN_HOTKEY); + return 0; + case IDM_FIRMSETTINGS: + RunConfig(CONFIGSCREEN_FIRMWARE); + return 0; + case IDM_SOUNDSETTINGS: + RunConfig(CONFIGSCREEN_SOUND); + return 0; + case IDM_WIFISETTINGS: + RunConfig(CONFIGSCREEN_WIFI); + return 0; + case IDM_EMULATIONSETTINGS: + RunConfig(CONFIGSCREEN_EMULATION); + return 0; + case IDM_MICROPHONESETTINGS: + RunConfig(CONFIGSCREEN_MICROPHONE); + return 0; + case IDM_PATHSETTINGS: + RunConfig(CONFIGSCREEN_PATHSETTINGS); + return 0; + + case IDM_GAME_INFO: + { + //CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_GAME_INFO), hwnd, GinfoView_Proc); + GInfo_DlgOpen(hwnd); + } + return 0; + + //========================================================= Tools + case IDM_PAL: + ViewPalette->open(); + return 0; + case IDM_TILE: + { + ViewTiles->regClass("TileViewBox", TileViewBoxProc); + ViewTiles->regClass("MiniTileViewBox", MiniTileViewBoxProc, true); + if (!ViewTiles->open()) + ViewTiles->unregClass(); + } + return 0; + case IDM_IOREG: + ViewRegisters->open(); + //IORegView_DlgOpen(HWND_DESKTOP, "I/O registers"); + return 0; + case IDM_MEMORY: + /* ViewMem_ARM7->regClass("MemViewBox7", ViewMem_ARM7BoxProc); + if (!ViewMem_ARM7->open()) + ViewMem_ARM7->unregClass(); + ViewMem_ARM9->regClass("MemViewBox9", ViewMem_ARM9BoxProc); + if (!ViewMem_ARM9->open()) + ViewMem_ARM9->unregClass();*/ + if(!MemView_IsOpened(ARMCPU_ARM9)) MemView_DlgOpen(HWND_DESKTOP, "ARM9 memory", ARMCPU_ARM9); + if(!MemView_IsOpened(ARMCPU_ARM7)) MemView_DlgOpen(HWND_DESKTOP, "ARM7 memory", ARMCPU_ARM7); + return 0; + case IDM_SOUND_VIEW: + if(!SoundView_IsOpened()) SoundView_DlgOpen(HWND_DESKTOP); + return 0; + case IDM_DISASSEMBLER: + ViewDisasm_ARM7->regClass("DesViewBox7",ViewDisasm_ARM7BoxProc); + if (!ViewDisasm_ARM7->open()) + ViewDisasm_ARM7->unregClass(); + + ViewDisasm_ARM9->regClass("DesViewBox9",ViewDisasm_ARM9BoxProc); + if (!ViewDisasm_ARM9->open()) + ViewDisasm_ARM9->unregClass(); + return 0; + case IDM_MAP: + ViewMaps->open(); + return 0; + case IDM_OAM: + ViewOAM->regClass("OAMViewBox", ViewOAMBoxProc); + if (!ViewOAM->open()) + ViewOAM->unregClass(); + return 0; + + case IDM_MATRIX_VIEWER: + ViewMatrices->open(); + return 0; + + case IDM_LIGHT_VIEWER: + ViewLights->open(); + return 0; + //========================================================== Tools end + + case IDM_MGPU: + CommonSettings.showGpu.main = !CommonSettings.showGpu.main; + WritePrivateProfileInt("Display","MainGpu",CommonSettings.showGpu.main?1:0,IniName); + return 0; + + case IDM_SGPU: + CommonSettings.showGpu.sub = !CommonSettings.showGpu.sub; + WritePrivateProfileInt("Display","SubGpu",CommonSettings.showGpu.sub?1:0,IniName); + return 0; + + case IDM_MBG0 : + if(MainScreen.gpu->dispBG[0]) + { + GPU_remove(MainScreen.gpu, 0); + MainWindow->checkMenu(IDM_MBG0, false); + } + else + { + GPU_addBack(MainScreen.gpu, 0); + MainWindow->checkMenu(IDM_MBG0, true); + } + return 0; + case IDM_MBG1 : + if(MainScreen.gpu->dispBG[1]) + { + GPU_remove(MainScreen.gpu, 1); + MainWindow->checkMenu(IDM_MBG1, false); + } + else + { + GPU_addBack(MainScreen.gpu, 1); + MainWindow->checkMenu(IDM_MBG1, true); + } + return 0; + case IDM_MBG2 : + if(MainScreen.gpu->dispBG[2]) + { + GPU_remove(MainScreen.gpu, 2); + MainWindow->checkMenu(IDM_MBG2, false); + } + else + { + GPU_addBack(MainScreen.gpu, 2); + MainWindow->checkMenu(IDM_MBG2, true); + } + return 0; + case IDM_MBG3 : + if(MainScreen.gpu->dispBG[3]) + { + GPU_remove(MainScreen.gpu, 3); + MainWindow->checkMenu(IDM_MBG3, false); + } + else + { + GPU_addBack(MainScreen.gpu, 3); + MainWindow->checkMenu(IDM_MBG3, true); + } + return 0; + case IDM_SBG0 : + if(SubScreen.gpu->dispBG[0]) + { + GPU_remove(SubScreen.gpu, 0); + MainWindow->checkMenu(IDM_SBG0, false); + } + else + { + GPU_addBack(SubScreen.gpu, 0); + MainWindow->checkMenu(IDM_SBG0, true); + } + return 0; + case IDM_SBG1 : + if(SubScreen.gpu->dispBG[1]) + { + GPU_remove(SubScreen.gpu, 1); + MainWindow->checkMenu(IDM_SBG1, false); + } + else + { + GPU_addBack(SubScreen.gpu, 1); + MainWindow->checkMenu(IDM_SBG1, true); + } + return 0; + case IDM_SBG2 : + if(SubScreen.gpu->dispBG[2]) + { + GPU_remove(SubScreen.gpu, 2); + MainWindow->checkMenu(IDM_SBG2, false); + } + else + { + GPU_addBack(SubScreen.gpu, 2); + MainWindow->checkMenu(IDM_SBG2, true); + } + return 0; + case IDM_SBG3 : + if(SubScreen.gpu->dispBG[3]) + { + GPU_remove(SubScreen.gpu, 3); + MainWindow->checkMenu(IDM_SBG3, false); + } + else + { + GPU_addBack(SubScreen.gpu, 3); + MainWindow->checkMenu(IDM_SBG3, true); + } + return 0; + + case IDM_PAUSE: + Pause(); + return 0; + + case IDM_GBASLOT: + GBAslotDialog(hwnd); + return 0; + + case IDM_CHEATS_LIST: + CheatsListDialog(hwnd); + return 0; + + case IDM_CHEATS_SEARCH: + CheatsSearchDialog(hwnd); + return 0; + case IDM_RECORD_MOVIE: + MovieRecordTo(); + return 0; + case IDM_PLAY_MOVIE: + Replay_LoadMovie(); + return 0; + case IDM_STOPMOVIE: + FCEUI_StopMovie(); + return 0; + case ID_VIEW_FRAMECOUNTER: + CommonSettings.hud.FrameCounterDisplay ^= true; + WritePrivateProfileBool("Display", "Display Fps", CommonSettings.hud.FpsDisplay, IniName); + return 0; + + case ID_VIEW_DISPLAYFPS: + CommonSettings.hud.FpsDisplay ^= true; + WritePrivateProfileBool("Display", "Display Fps", CommonSettings.hud.FpsDisplay, IniName); + osd->clear(); + return 0; + + case ID_VIEW_DISPLAYINPUT: + CommonSettings.hud.ShowInputDisplay ^= true; + WritePrivateProfileBool("Display", "Display Input", CommonSettings.hud.ShowInputDisplay, IniName); + osd->clear(); + return 0; + + case ID_VIEW_DISPLAYLAG: + CommonSettings.hud.ShowLagFrameCounter ^= true; + WritePrivateProfileBool("Display", "Display Lag Counter", CommonSettings.hud.ShowLagFrameCounter, IniName); + osd->clear(); + return 0; + + case ID_VIEW_HUDEDITOR: + HudEditorMode ^= true; + osd->clear(); + osd->border(HudEditorMode); + return 0; + + case ID_VIEW_DISPLAYMICROPHONE: + CommonSettings.hud.ShowMicrophone ^= true; + WritePrivateProfileBool("Display", "Display Microphone", CommonSettings.hud.ShowMicrophone, IniName); + osd->clear(); + return 0; + + case ID_RAM_SEARCH: + if(!RamSearchHWnd) + { + InitRamSearch(); + RamSearchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMSEARCH), hwnd, (DLGPROC) RamSearchProc); + } + else + SetForegroundWindow(RamSearchHWnd); + break; + + case ID_RAM_WATCH: + if(!RamWatchHWnd) + { + RamWatchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMWATCH), hwnd, (DLGPROC) RamWatchProc); + // DialogsOpen++; + } + else + SetForegroundWindow(RamWatchHWnd); + return 0; + + case IDC_BACKGROUNDPAUSE: + lostFocusPause = !lostFocusPause; + WritePrivateProfileInt("Focus", "BackgroundPause", (int)lostFocusPause, IniName); + return 0; + + case IDC_SAVETYPE1: backup_setManualBackupType(0); return 0; + case IDC_SAVETYPE2: backup_setManualBackupType(1); return 0; + case IDC_SAVETYPE3: backup_setManualBackupType(2); return 0; + case IDC_SAVETYPE4: backup_setManualBackupType(3); return 0; + case IDC_SAVETYPE5: backup_setManualBackupType(4); return 0; + case IDC_SAVETYPE6: backup_setManualBackupType(5); return 0; + case IDC_SAVETYPE7: backup_setManualBackupType(6); return 0; + + case IDM_RESET: + ResetGame(); + return 0; + + case IDM_3DCONFIG: + { + bool tpaused = false; + if(execute) + { + tpaused = true; + NDS_Pause(); + } + + DialogBox(hAppInst, MAKEINTRESOURCE(IDD_3DSETTINGS), hwnd, (DLGPROC)GFX3DSettingsDlgProc); + + if(tpaused) NDS_UnPause(); + } + return 0; + case IDC_FRAMESKIPAUTO: + case IDC_FRAMESKIP0: + case IDC_FRAMESKIP1: + case IDC_FRAMESKIP2: + case IDC_FRAMESKIP3: + case IDC_FRAMESKIP4: + case IDC_FRAMESKIP5: + case IDC_FRAMESKIP6: + case IDC_FRAMESKIP7: + case IDC_FRAMESKIP8: + case IDC_FRAMESKIP9: + { + if(LOWORD(wParam) == IDC_FRAMESKIPAUTO) + { + autoframeskipenab = 1; + WritePrivateProfileString("Video", "FrameSkip", "AUTO", IniName); + } + else + { + char text[80]; + autoframeskipenab = 0; + frameskiprate = LOWORD(wParam) - IDC_FRAMESKIP0; + sprintf(text, "%d", frameskiprate); + WritePrivateProfileString("Video", "FrameSkip", text, IniName); + } + } + return 0; + case IDC_NEW_LUA_SCRIPT: + if(LuaScriptHWnds.size() < 16) + { + CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_LUA), MainWindow->getHWnd(), (DLGPROC) LuaScriptProc); + // DialogsOpen++; + } + break; + case IDC_LANGENGLISH: + SaveLanguage(0); + ChangeLanguage(0); + CheckLanguage(LOWORD(wParam)); + return 0; + case IDC_LANGFRENCH: + SaveLanguage(1); + ChangeLanguage(1); + CheckLanguage(LOWORD(wParam)); + return 0; + case IDC_LANG_CHINESE_SIMPLIFIED: + SaveLanguage(3); + ChangeLanguage(3); + CheckLanguage(LOWORD(wParam)); + return 0; + + case IDC_LANGDANISH: + SaveLanguage(2); + ChangeLanguage(2); + CheckLanguage(LOWORD(wParam)); + return 0; + + case IDC_FRAMELIMIT: + FrameLimit ^= 1; + WritePrivateProfileInt("FrameLimit", "FrameLimit", FrameLimit, IniName); + return 0; + case IDM_SCREENSEP_NONE: + { + SetScreenGap(0); + MainWindow->checkMenu(IDM_SCREENSEP_NONE, true); + MainWindow->checkMenu(IDM_SCREENSEP_BORDER, false); + MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP, false); + UpdateWndRects(hwnd); + } + return 0; + case IDM_SCREENSEP_BORDER: + { + SetScreenGap(5); + MainWindow->checkMenu(IDM_SCREENSEP_NONE, false); + MainWindow->checkMenu(IDM_SCREENSEP_BORDER, true); + MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP, false); + UpdateWndRects(hwnd); + } + return 0; + case IDM_SCREENSEP_NDSGAP: + { + SetScreenGap(64); + MainWindow->checkMenu(IDM_SCREENSEP_NONE, false); + MainWindow->checkMenu(IDM_SCREENSEP_BORDER, false); + MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP, true); + UpdateWndRects(hwnd); + } + return 0; + case IDM_SCREENSEP_NDSGAP2: + SetScreenGap(kGapNDS2); + return 0; + case IDM_SCREENSEP_DRAGEDIT: + SeparationBorderDrag = !SeparationBorderDrag; + WritePrivateProfileInt("Display","Window Split Border Drag",(int)SeparationBorderDrag,IniName); + break; + case IDM_WEBSITE: + ShellExecute(NULL, "open", "http://desmume.sourceforge.net", NULL, NULL, SW_SHOWNORMAL); + return 0; + + case IDM_FORUM: + ShellExecute(NULL, "open", "http://forums.desmume.org/index.php", NULL, NULL, SW_SHOWNORMAL); + return 0; + + case IDM_ABOUT: + { + #ifdef WX_STUB + wxTest(); + return 0; + #endif + bool tpaused=false; + if (execute) + { + tpaused=true; + NDS_Pause(); + } + DialogBox(hAppInst,MAKEINTRESOURCE(IDD_ABOUT_BOX), hwnd, (DLGPROC) AboutBox_Proc); + if (tpaused) + NDS_UnPause(); + + return 0; + } + +#ifndef BETA_VERSION + case IDM_SUBMITBUGREPORT: + ShellExecute(NULL, "open", "http://sourceforge.net/tracker/?func=add&group_id=164579&atid=832291", NULL, NULL, SW_SHOWNORMAL); + return 0; +#endif + + case IDC_ROTATE0: + SetRotate(hwnd, 0); + return 0; + case IDC_ROTATE90: + SetRotate(hwnd, 90); + return 0; + case IDC_ROTATE180: + SetRotate(hwnd, 180); + return 0; + case IDC_ROTATE270: + SetRotate(hwnd, 270); + return 0; + + case IDC_WINDOW1_5X: + windowSize=65535; + ScaleScreen(windowSize); + WritePrivateProfileInt("Video","Window Size",windowSize,IniName); + break; + case IDC_WINDOW2_5X: + windowSize=65534; + ScaleScreen(windowSize); + WritePrivateProfileInt("Video","Window Size",windowSize,IniName); + break; + case IDC_WINDOW1X: + windowSize=1; + ScaleScreen(windowSize); + WritePrivateProfileInt("Video","Window Size",windowSize,IniName); + break; + case IDC_WINDOW2X: + windowSize=2; + ScaleScreen(windowSize); + WritePrivateProfileInt("Video","Window Size",windowSize,IniName); + break; + case IDC_WINDOW3X: + windowSize=3; + ScaleScreen(windowSize); + WritePrivateProfileInt("Video","Window Size",windowSize,IniName); + break; + case IDC_WINDOW4X: + windowSize=4; + ScaleScreen(windowSize); + WritePrivateProfileInt("Video","Window Size",windowSize,IniName); + break; + + case IDC_FORCERATIO: + if (ForceRatio) { + ForceRatio = false; + WritePrivateProfileInt("Video","Window Force Ratio",0,IniName); + } + else { + ForceRatio = true; + FixAspectRatio(); + RECT rc; + GetClientRect(hwnd, &rc); + WritePrivateProfileInt("Video","Window Force Ratio",1,IniName); + WritePrivateProfileInt("Video", "Window width", (rc.right - rc.left), IniName); + WritePrivateProfileInt("Video", "Window height", (rc.bottom - rc.top), IniName); + } + break; + + + case IDM_DEFSIZE: + { + if(windowSize != 1) + windowSize = 0; + + ScaleScreen(1); + } + break; + case IDM_ALWAYS_ON_TOP: + { + LONG exStyle = GetWindowLong(MainWindow->getHWnd(), GWL_EXSTYLE); + UINT menuCheck = MF_BYCOMMAND; + HWND insertAfter = HWND_TOPMOST; + + + if(exStyle & WS_EX_TOPMOST) + { + menuCheck |= MF_UNCHECKED; + insertAfter = HWND_NOTOPMOST; + } + else + menuCheck |= MF_CHECKED; + + CheckMenuItem(mainMenu, IDM_ALWAYS_ON_TOP, menuCheck); + SetWindowPos(MainWindow->getHWnd(), insertAfter, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE); + } + return 0; + + } + } + return DefWindowProc (hwnd, message, wParam, lParam); +} + +LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) +{ + switch(msg) + { + case WM_INITDIALOG: + { + int i; + + CheckDlgButton(hw,IDC_INTERPOLATECOLOR,CommonSettings.HighResolutionInterpolateColor?1:0); + CheckDlgButton(hw,IDC_ALTERNATEFLUSH,CommonSettings.gfx3d_flushMode); + + for(i = 0; core3DList[i] != NULL; i++) + { + ComboBox_AddString(GetDlgItem(hw, IDC_3DCORE), core3DList[i]->name); + } + ComboBox_SetCurSel(GetDlgItem(hw, IDC_3DCORE), cur3DCore); + } + return TRUE; + + case WM_COMMAND: + { + switch(LOWORD(wp)) + { + case IDOK: + { + CommonSettings.HighResolutionInterpolateColor = IsDlgButtonChecked(hw,IDC_INTERPOLATECOLOR); + NDS_3D_ChangeCore(ComboBox_GetCurSel(GetDlgItem(hw, IDC_3DCORE))); + WritePrivateProfileInt("3D", "Renderer", cur3DCore, IniName); + WritePrivateProfileInt("3D", "HighResolutionInterpolateColor", CommonSettings.HighResolutionInterpolateColor?1:0, IniName); + CommonSettings.gfx3d_flushMode = (IsDlgButtonChecked(hw,IDC_ALTERNATEFLUSH) == BST_CHECKED)?1:0; + WritePrivateProfileInt("3D", "AlternateFlush", CommonSettings.gfx3d_flushMode, IniName); + } + case IDCANCEL: + { + EndDialog(hw, TRUE); + } + return TRUE; + + case IDC_DEFAULT: + { + NDS_3D_ChangeCore(GPU3D_OPENGL); + ComboBox_SetCurSel(GetDlgItem(hw, IDC_3DCORE), GPU3D_OPENGL); + WritePrivateProfileInt("3D", "Renderer", GPU3D_OPENGL, IniName); + CommonSettings.gfx3d_flushMode = 0; + WritePrivateProfileInt("3D", "AlternateFlush", CommonSettings.gfx3d_flushMode, IniName); + } + return TRUE; + } + + return TRUE; + } + } + + return FALSE; +} + +LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + { + HWND cur; + + CheckDlgButton(hDlg, IDC_CHECKBOX_DEBUGGERMODE, ((CommonSettings.DebugConsole == true) ? BST_CHECKED : BST_UNCHECKED)); + CheckDlgButton(hDlg, IDC_USEEXTBIOS, ((CommonSettings.UseExtBIOS == true) ? BST_CHECKED : BST_UNCHECKED)); + SetDlgItemText(hDlg, IDC_ARM9BIOS, CommonSettings.ARM9BIOS); + SetDlgItemText(hDlg, IDC_ARM7BIOS, CommonSettings.ARM7BIOS); + CheckDlgButton(hDlg, IDC_BIOSSWIS, ((CommonSettings.SWIFromBIOS == true) ? BST_CHECKED : BST_UNCHECKED)); + + if(CommonSettings.UseExtBIOS == false) + { + cur = GetDlgItem(hDlg, IDC_ARM9BIOS); + EnableWindow(cur, FALSE); + cur = GetDlgItem(hDlg, IDC_ARM9BIOSBROWSE); + EnableWindow(cur, FALSE); + cur = GetDlgItem(hDlg, IDC_ARM7BIOS); + EnableWindow(cur, FALSE); + cur = GetDlgItem(hDlg, IDC_ARM7BIOSBROWSE); + EnableWindow(cur, FALSE); + cur = GetDlgItem(hDlg, IDC_BIOSSWIS); + EnableWindow(cur, FALSE); + } + + CheckDlgButton(hDlg, IDC_USEEXTFIRMWARE, ((CommonSettings.UseExtFirmware == true) ? BST_CHECKED : BST_UNCHECKED)); + SetDlgItemText(hDlg, IDC_FIRMWARE, CommonSettings.Firmware); + CheckDlgButton(hDlg, IDC_FIRMWAREBOOT, ((CommonSettings.BootFromFirmware == true) ? BST_CHECKED : BST_UNCHECKED)); + + if(CommonSettings.UseExtFirmware == false) + { + cur = GetDlgItem(hDlg, IDC_FIRMWARE); + EnableWindow(cur, FALSE); + cur = GetDlgItem(hDlg, IDC_FIRMWAREBROWSE); + EnableWindow(cur, FALSE); + } + + if((CommonSettings.UseExtBIOS == false) || (CommonSettings.UseExtFirmware == false)) + { + cur = GetDlgItem(hDlg, IDC_FIRMWAREBOOT); + EnableWindow(cur, FALSE); + } + } + return TRUE; + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDOK: + { + int val = 0; + + if(romloaded) + val = MessageBox(hDlg, "The current ROM needs to be reset to apply changes.\nReset now ?", "DeSmuME", (MB_YESNO | MB_ICONQUESTION)); + + HWND cur; + + CommonSettings.UseExtBIOS = IsDlgButtonChecked(hDlg, IDC_USEEXTBIOS); + cur = GetDlgItem(hDlg, IDC_ARM9BIOS); + GetWindowText(cur, CommonSettings.ARM9BIOS, 256); + cur = GetDlgItem(hDlg, IDC_ARM7BIOS); + GetWindowText(cur, CommonSettings.ARM7BIOS, 256); + CommonSettings.SWIFromBIOS = IsDlgButtonChecked(hDlg, IDC_BIOSSWIS); + + CommonSettings.UseExtFirmware = IsDlgButtonChecked(hDlg, IDC_USEEXTFIRMWARE); + cur = GetDlgItem(hDlg, IDC_FIRMWARE); + GetWindowText(cur, CommonSettings.Firmware, 256); + CommonSettings.BootFromFirmware = IsDlgButtonChecked(hDlg, IDC_FIRMWAREBOOT); + + CommonSettings.DebugConsole = IsDlgButtonChecked(hDlg, IDC_CHECKBOX_DEBUGGERMODE); + + WritePrivateProfileInt("Emulation", "DebugConsole", ((CommonSettings.DebugConsole == true) ? 1 : 0), IniName); + WritePrivateProfileInt("BIOS", "UseExtBIOS", ((CommonSettings.UseExtBIOS == true) ? 1 : 0), IniName); + WritePrivateProfileString("BIOS", "ARM9BIOSFile", CommonSettings.ARM9BIOS, IniName); + WritePrivateProfileString("BIOS", "ARM7BIOSFile", CommonSettings.ARM7BIOS, IniName); + WritePrivateProfileInt("BIOS", "SWIFromBIOS", ((CommonSettings.SWIFromBIOS == true) ? 1 : 0), IniName); + + WritePrivateProfileInt("Firmware", "UseExtFirmware", ((CommonSettings.UseExtFirmware == true) ? 1 : 0), IniName); + WritePrivateProfileString("Firmware", "FirmwareFile", CommonSettings.Firmware, IniName); + WritePrivateProfileInt("Firmware", "BootFromFirmware", ((CommonSettings.BootFromFirmware == true) ? 1 : 0), IniName); + + if(val == IDYES) + { + NDS_Reset(); + } + } + case IDCANCEL: + { + EndDialog(hDlg, TRUE); + } + return TRUE; + + case IDC_USEEXTBIOS: + { + HWND cur; + BOOL enable = IsDlgButtonChecked(hDlg, IDC_USEEXTBIOS); + + cur = GetDlgItem(hDlg, IDC_ARM9BIOS); + EnableWindow(cur, enable); + cur = GetDlgItem(hDlg, IDC_ARM9BIOSBROWSE); + EnableWindow(cur, enable); + cur = GetDlgItem(hDlg, IDC_ARM7BIOS); + EnableWindow(cur, enable); + cur = GetDlgItem(hDlg, IDC_ARM7BIOSBROWSE); + EnableWindow(cur, enable); + cur = GetDlgItem(hDlg, IDC_BIOSSWIS); + EnableWindow(cur, enable); + cur = GetDlgItem(hDlg, IDC_FIRMWAREBOOT); + EnableWindow(cur, (enable && IsDlgButtonChecked(hDlg, IDC_USEEXTFIRMWARE))); + } + return TRUE; + + case IDC_USEEXTFIRMWARE: + { + HWND cur; + BOOL enable = IsDlgButtonChecked(hDlg, IDC_USEEXTFIRMWARE); + + cur = GetDlgItem(hDlg, IDC_FIRMWARE); + EnableWindow(cur, enable); + cur = GetDlgItem(hDlg, IDC_FIRMWAREBROWSE); + EnableWindow(cur, enable); + cur = GetDlgItem(hDlg, IDC_FIRMWAREBOOT); + EnableWindow(cur, (enable && IsDlgButtonChecked(hDlg, IDC_USEEXTBIOS))); + } + return TRUE; + + case IDC_ARM9BIOSBROWSE: + case IDC_ARM7BIOSBROWSE: + case IDC_FIRMWAREBROWSE: + { + char fileName[256] = ""; + OPENFILENAME ofn; + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hDlg; + ofn.lpstrFilter = "Binary file (*.bin)\0*.bin\0ROM file (*.rom)\0*.rom\0Any file(*.*)\0*.*\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = fileName; + ofn.nMaxFile = 256; + ofn.lpstrDefExt = "bin"; + ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; + + char buffer[MAX_PATH]; + ZeroMemory(buffer, sizeof(buffer)); + path.getpath(path.FIRMWARE, buffer); + ofn.lpstrInitialDir = buffer; + + if(GetOpenFileName(&ofn)) + { + HWND cur; + + switch(LOWORD(wParam)) + { + case IDC_ARM9BIOSBROWSE: cur = GetDlgItem(hDlg, IDC_ARM9BIOS); break; + case IDC_ARM7BIOSBROWSE: cur = GetDlgItem(hDlg, IDC_ARM7BIOS); break; + case IDC_FIRMWAREBROWSE: cur = GetDlgItem(hDlg, IDC_FIRMWARE); break; + } + + SetWindowText(cur, fileName); + } + } + return TRUE; + } + } + return TRUE; + } + + return FALSE; +} + +LRESULT CALLBACK MicrophoneSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch(uMsg) + { + case WM_INITDIALOG: + { + HWND cur; + + UseMicSample = GetPrivateProfileInt("Use Mic Sample", "UseMicSample", FALSE, IniName); + CheckDlgButton(hDlg, IDC_USEMICSAMPLE, ((UseMicSample == true) ? BST_CHECKED : BST_UNCHECKED)); + GetPrivateProfileString("Use Mic Sample", "MicSampleFile", "micsample.raw", MicSampleName, MAX_PATH, IniName); + SetDlgItemText(hDlg, IDC_MICSAMPLE, MicSampleName); + + if(UseMicSample == false) + { + cur = GetDlgItem(hDlg, IDC_MICSAMPLE); + EnableWindow(cur, FALSE); + cur = GetDlgItem(hDlg, IDC_MICSAMPLEBROWSE); + EnableWindow(cur, FALSE); + } + } + return TRUE; + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDOK: + { + int val = 0; + + if((romloaded)) //|| (val == IDYES)) + { + HWND cur; + + UseMicSample = IsDlgButtonChecked(hDlg, IDC_USEMICSAMPLE); + cur = GetDlgItem(hDlg, IDC_MICSAMPLE); + GetWindowText(cur, MicSampleName, 256); + + WritePrivateProfileInt("Use Mic Sample", "UseMicSample", ((UseMicSample == true) ? 1 : 0), IniName); + WritePrivateProfileString("Use Mic Sample", "MicSampleFile", MicSampleName, IniName); + + if (UseMicSample) + { + if (!LoadSample(MicSampleName)) + { + MessageBox(hDlg, "Unable to read the sample", "DeSmuME", (MB_OK | MB_ICONEXCLAMATION)); + } + } + } + } + case IDCANCEL: + { + EndDialog(hDlg, TRUE); + } + return TRUE; + + case IDC_USEMICSAMPLE: + { + HWND cur; + BOOL enable = IsDlgButtonChecked(hDlg, IDC_USEMICSAMPLE); + + cur = GetDlgItem(hDlg, IDC_MICSAMPLE); + EnableWindow(cur, enable); + cur = GetDlgItem(hDlg, IDC_MICSAMPLEBROWSE); + EnableWindow(cur, enable); + } + return TRUE; + + case IDC_MICSAMPLEBROWSE: + { + char fileName[256] = ""; + OPENFILENAME ofn; + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hDlg; + ofn.lpstrFilter = "Any file(*.*)\0*.*\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = fileName; + ofn.nMaxFile = 256; + ofn.lpstrDefExt = "bin"; + ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; + + char buffer[MAX_PATH]; + ZeroMemory(buffer, sizeof(buffer)); + path.getpath(path.SOUNDS, buffer); + ofn.lpstrInitialDir = buffer; + + if(GetOpenFileName(&ofn)) + { + HWND cur; + + switch(LOWORD(wParam)) + { + case IDC_MICSAMPLEBROWSE: cur = GetDlgItem(hDlg, IDC_MICSAMPLE); break; + } + + SetWindowText(cur, fileName); + } + } + return TRUE; + } + } + return TRUE; + } + + return FALSE; +} + +LRESULT CALLBACK WifiSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + #ifdef EXPERIMENTAL_WIFI + switch(uMsg) + { + case WM_INITDIALOG: + { + char errbuf[PCAP_ERRBUF_SIZE]; + pcap_if_t *alldevs; + pcap_if_t *d; + int i; + HWND cur; + + if(PCAP::pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) + { + EndDialog(hDlg, TRUE); + return TRUE; + } + + cur = GetDlgItem(hDlg, IDC_BRIDGEADAPTER); + for(i = 0, d = alldevs; d != NULL; i++, d = d->next) + { + ComboBox_AddString(cur, d->description); + } + ComboBox_SetCurSel(cur, CommonSettings.wifiBridgeAdapterNum); + } + return TRUE; + + case WM_COMMAND: + { + switch(LOWORD(wParam)) + { + case IDOK: + { + int val = 0; + + if(romloaded) + val = MessageBox(hDlg, "The current ROM needs to be reset to apply changes.\nReset now ?", "DeSmuME", (MB_YESNO | MB_ICONQUESTION)); + + if((!romloaded) || (val == IDYES)) + { + HWND cur; + + cur = GetDlgItem(hDlg, IDC_BRIDGEADAPTER); + CommonSettings.wifiBridgeAdapterNum = ComboBox_GetCurSel(cur); + + WritePrivateProfileInt("Wifi", "BridgeAdapter", CommonSettings.wifiBridgeAdapterNum, IniName); + + if(romloaded) + { + NDS_Reset(); + } + } + } + case IDCANCEL: + { + EndDialog(hDlg, TRUE); + } + return TRUE; + } + } + return TRUE; + } +#endif + return FALSE; +} + +LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + static UINT_PTR timerid=0; + switch (uMsg) + { + case WM_INITDIALOG: + { + int i; + char tempstr[MAX_PATH]; + // Setup Sound Core Combo box + SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_RESETCONTENT, 0, 0); + SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (LPARAM)"None"); + + for (i = 1; SNDCoreList[i] != NULL; i++) + SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (LPARAM)SNDCoreList[i]->Name); + + // Set Selected Sound Core + for (i = 0; SNDCoreList[i] != NULL; i++) + { + if (sndcoretype == SNDCoreList[i]->id) + SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_SETCURSEL, i, 0); + } + + //setup interpolation combobox + SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_RESETCONTENT, 0, 0); + SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_ADDSTRING, 0, (LPARAM)"None (fastest, sounds bad)"); + SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_ADDSTRING, 0, (LPARAM)"Linear (typical, sounds good)"); + SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_ADDSTRING, 0, (LPARAM)"Cosine (slowest, sounds best)"); + SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_SETCURSEL, (int)CommonSettings.spuInterpolationMode, 0); + + //setup cache setting + CheckDlgButton(hDlg, IDC_SPU_CACHE, CommonSettings.spuAdpcmCache?BST_CHECKED:BST_UNCHECKED ); + + // Setup Sound Buffer Size Edit Text + sprintf(tempstr, "%d", sndbuffersize); + SetDlgItemText(hDlg, IDC_SOUNDBUFFERET, tempstr); + + // Setup Volume Slider + SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_SETRANGE, 0, MAKELONG(0, 100)); + + // Set Selected Volume + SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_SETPOS, TRUE, sndvolume); + + timerid = SetTimer(hDlg, 1, 500, NULL); + return TRUE; + } + case WM_TIMER: + { + if (timerid == wParam) + { + int setting; + setting = SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_GETPOS, 0, 0); + SPU_SetVolume(setting); + break; + } + break; + } + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDOK: + { + char tempstr[MAX_PATH]; + + EndDialog(hDlg, TRUE); + + // Write Sound core type + sndcoretype = SNDCoreList[SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_GETCURSEL, 0, 0)]->id; + sprintf(tempstr, "%d", sndcoretype); + WritePrivateProfileString("Sound", "SoundCore2", tempstr, IniName); + + // Write Sound Buffer size + GetDlgItemText(hDlg, IDC_SOUNDBUFFERET, tempstr, 6); + sscanf(tempstr, "%d", &sndbuffersize); + WritePrivateProfileString("Sound", "SoundBufferSize", tempstr, IniName); + + if(sndcoretype != SPU_currentCoreNum) + { + Lock lock; + SPU_ChangeSoundCore(sndcoretype, sndbuffersize); + } + + // Write Volume + sndvolume = SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_GETPOS, 0, 0); + sprintf(tempstr, "%d", sndvolume); + WritePrivateProfileString("Sound", "Volume", tempstr, IniName); + SPU_SetVolume(sndvolume); + + //write interpolation type + CommonSettings.spuInterpolationMode = (SPUInterpolationMode)SendDlgItemMessage(hDlg, IDC_SPU_INTERPOLATION_CB, CB_GETCURSEL, 0, 0); + WritePrivateProfileInt("Sound","SPUInterpolation",(int)CommonSettings.spuInterpolationMode, IniName); + + //write cache setting + CommonSettings.spuAdpcmCache = IsDlgButtonChecked(hDlg, IDC_SPU_CACHE) != 0; + WritePrivateProfileInt("Sound","SPUAdpcmCache",CommonSettings.spuAdpcmCache?1:0, IniName); + + return TRUE; + } + case IDCANCEL: + { + EndDialog(hDlg, FALSE); + return TRUE; + } + default: break; + } + + break; + } + case WM_DESTROY: + { + if (timerid != 0) + KillTimer(hDlg, timerid); + break; + } + } + + return FALSE; +} + +void ResetGame() +{ + NDS_Reset(); +} + +//adelikat: This function changes a menu item's text +void ChangeMenuItemText(int menuitem, string text) +{ + MENUITEMINFO moo; + moo.cbSize = sizeof(moo); + moo.fMask = MIIM_TYPE; + moo.cch = NULL; + GetMenuItemInfo(mainMenu, menuitem, FALSE, &moo); + moo.dwTypeData = (LPSTR)text.c_str(); + SetMenuItemInfo(mainMenu, menuitem, FALSE, &moo); +} + +const char* GetModifierString(int num) +{ + switch (num) + { + case 0: + return ""; + case 1: + return "Alt+"; + case 2: + return "Ctrl+"; + case 3: + return "Ctrl+Alt+"; + case 4: + return "Shift+"; + case 5: + return "Alt+Shift+"; + case 6: + return "Ctrl+Shift+"; + case 7: + return "Ctrl+Alt+Shift+"; + default: + return ""; + } +} + +//adelikat: This function find the current hotkey assignments for corresponding menu items +// and appends it to the menu item. This function works correctly for all language menus +// However, a Menu item in the Resource file must NOT have a /t (tab) in its caption. +void UpdateHotkeyAssignments() +{ + extern void TranslateKey(WORD keyz,char *out); //adelikat: Yeah hackey + //Update all menu items that can be called from a hotkey to include the current hotkey assignment + char str[255]; //Temp string + string text; //Used to manipulate menu item text + string keyname; //Used to hold the name of the hotkey + int truncate; //Used to truncate the hotkey config from the menu item + //-------------------------------FILE--------------------------------------- + + + //Open ROM + GetMenuString(mainMenu,IDM_OPEN, str, 255, IDM_OPEN); //Get menu item text + text = str; //Store in string object + truncate = text.find("\t"); //Find the tab + if (truncate >= 1) //Truncate if it exists + text = text.substr(0,truncate); + TranslateKey(CustomKeys.OpenROM.key, str); + keyname = str; + keyname.insert(0,GetModifierString(CustomKeys.OpenROM.modifiers)); + text.append("\t" + keyname); + ChangeMenuItemText(IDM_OPEN, text); + + //Save Screenshot As... + GetMenuString(mainMenu,IDM_PRINTSCREEN, str, 255, IDM_PRINTSCREEN); + text = str; + truncate = text.find("\t"); + if (truncate >= 1) + text = text.substr(0,truncate); + TranslateKey(CustomKeys.PrintScreen.key, str); + keyname = str; + keyname.insert(0,GetModifierString(CustomKeys.PrintScreen.modifiers)); + text.append("\t" + keyname); + ChangeMenuItemText(IDM_PRINTSCREEN, text); + + //adelikat: Why don't these work? GetMenuString returns null for these IDs yet those are the valid ID numbers + /* + //Record AVI + GetMenuString(mainMenu,IDM_FILE_RECORDAVI, str, 255, IDM_FILE_RECORDAVI); + text = str; + truncate = text.find("\t"); + if (truncate >= 1) + text = text.substr(0,truncate); + TranslateKey(CustomKeys.RecordAVI.key, str); + keyname = str; + keyname.insert(0,GetModifierString(CustomKeys.RecordAVI.modifiers)); + text.append("\t" + keyname); + ChangeMenuItemText(IDM_FILE_RECORDAVI, text); + + //Stop AVI + GetMenuString(mainMenu,IDM_FILE_STOPAVI, str, 255, IDM_FILE_STOPAVI); + text = str; + truncate = text.find("\t"); + if (truncate >= 1) + text = text.substr(0,truncate); + TranslateKey(CustomKeys.StopAVI.key, str); + keyname = str; + keyname.insert(0,GetModifierString(CustomKeys.StopAVI.modifiers)); + text.append("\t" + keyname); + ChangeMenuItemText(IDM_FILE_STOPAVI, text); +*/ + + //-------------------------------EMULATION---------------------------------- + + //Pause + GetMenuString(mainMenu,IDM_PAUSE, str, 255, IDM_PAUSE); + text = str; + truncate = text.find("\t"); + if (truncate >= 1) + text = text.substr(0,truncate); + TranslateKey(CustomKeys.Pause.key, str); + keyname = str; + keyname.insert(0,GetModifierString(CustomKeys.Pause.modifiers)); + text.append("\t" + keyname); + ChangeMenuItemText(IDM_PAUSE, text); + + //Reset + GetMenuString(mainMenu,IDM_RESET, str, 255, IDM_RESET); + text = str; + truncate = text.find("\t"); + if (truncate >= 1) + text = text.substr(0,truncate); + TranslateKey(CustomKeys.Reset.key, str); + keyname = str; + keyname.insert(0,GetModifierString(CustomKeys.Reset.modifiers)); + text.append("\t" + keyname); + ChangeMenuItemText(IDM_RESET, text); + + //-------------------------------EMULATION---------------------------------- +/* + //Display Frame Counter + GetMenuString(mainMenu,ID_VIEW_FRAMECOUNTER, str, 255, ID_VIEW_FRAMECOUNTER); + text = str; + truncate = text.find("\t"); + if (truncate >= 1) + text = text.substr(0,truncate); + TranslateKey(CustomKeys.ToggleFrameCounter.key, str); + keyname = str; + keyname.insert(0,GetModifierString(CustomKeys.ToggleFrameCounter.modifiers)); + text.append("\t" + keyname); + ChangeMenuItemText(ID_VIEW_FRAMECOUNTER, text); + + //Display FPS + GetMenuString(mainMenu,ID_VIEW_DISPLAYFPS, str, 255, ID_VIEW_DISPLAYFPS); + text = str; + truncate = text.find("\t"); + if (truncate >= 1) + text = text.substr(0,truncate); + TranslateKey(CustomKeys.ToggleFPS.key, str); + keyname = str; + keyname.insert(0,GetModifierString(CustomKeys.ToggleFPS.modifiers)); + text.append("\t" + keyname); + ChangeMenuItemText(ID_VIEW_DISPLAYFPS, text); + + //Display Input + GetMenuString(mainMenu,ID_VIEW_DISPLAYINPUT, str, 255, ID_VIEW_DISPLAYINPUT); + text = str; + truncate = text.find("\t"); + if (truncate >= 1) + text = text.substr(0,truncate); + TranslateKey(CustomKeys.ToggleInput.key, str); + keyname = str; + keyname.insert(0,GetModifierString(CustomKeys.ToggleInput.modifiers)); + text.append("\t" + keyname); + ChangeMenuItemText(ID_VIEW_DISPLAYINPUT, text); + + //Display Lag Counter + GetMenuString(mainMenu,ID_VIEW_DISPLAYLAG, str, 255, ID_VIEW_DISPLAYLAG); + text = str; + truncate = text.find("\t"); + if (truncate >= 1) + text = text.substr(0,truncate); + TranslateKey(CustomKeys.ToggleLag.key, str); + keyname = str; + keyname.insert(0,GetModifierString(CustomKeys.ToggleLag.modifiers)); + text.append("\t" + keyname); + ChangeMenuItemText(ID_VIEW_DISPLAYLAG, text); +*/ +} + + +static char Lua_Dir [1024]; +char Desmume_Path [1024]; + +static const char* PathWithoutPrefixDotOrSlash(const char* path) +{ + while(*path && + ((*path == '.' && (path[1] == '\\' || path[1] == '/')) || + *path == '\\' || *path == '/' || *path == ' ')) + path++; + return path; +} + +const char* MakeScriptPathAbsolute(const char* filename, const char* extraDirToCheck) +{ + static char filename2 [1024]; + if(filename[0] && filename[1] != ':') + { + char tempFile [1024], curDir [1024]; + strncpy(tempFile, filename, 1024); + tempFile[1023] = 0; + const char* tempFilePtr = PathWithoutPrefixDotOrSlash(tempFile); + for(int i=0; i<=4; i++) + { + if((!*tempFilePtr || tempFilePtr[1] != ':') && i != 2) + strcpy(curDir, i!=1 ? ((i!=3||!extraDirToCheck) ? Lua_Dir : extraDirToCheck) : Desmume_Path); + else + curDir[0] = 0; + _snprintf(filename2, 1024, "%s%s", curDir, tempFilePtr); + char* bar = strchr(filename2, '|'); + if(bar) *bar = 0; + FILE* file = fopen(filename2, "rb"); + if(bar) *bar = '|'; + if(file || i==4) + filename = filename2; + if(file) + { + fclose(file); + break; + } + } + } + return filename; +} + +extern void RequestAbortLuaScript(int uid, const char* message); + +const char* OpenLuaScript(const char* filename, const char* extraDirToCheck, bool makeSubservient) +{ + if(LuaScriptHWnds.size() < 16) + { + // make the filename absolute before loading + filename = MakeScriptPathAbsolute(filename, extraDirToCheck); + + // now check if it's already open and load it if it isn't + HWND IsScriptFileOpen(const char* Path); + HWND scriptHWnd = IsScriptFileOpen(filename); + if(!scriptHWnd) + { + HWND prevWindow = GetActiveWindow(); + + HWND hDlg = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_LUA), MainWindow->getHWnd(), (DLGPROC) LuaScriptProc); + SendMessage(hDlg,WM_COMMAND,IDC_NOTIFY_SUBSERVIENT,TRUE); + SendDlgItemMessage(hDlg,IDC_EDIT_LUAPATH,WM_SETTEXT,0,(LPARAM)filename); +// DialogsOpen++; + + SetActiveWindow(prevWindow); + } + else + { + RequestAbortLuaScript((int)scriptHWnd, "terminated to restart because of a call to gens.openscript"); + SendMessage(scriptHWnd, WM_COMMAND, IDC_BUTTON_LUARUN, 0); + } + } + else return "Too many script windows are already open."; + + return NULL; +} diff --git a/desmume/src/windows/main.h b/src/windows/main.h similarity index 89% rename from desmume/src/windows/main.h rename to src/windows/main.h index b4772cb00..76d9c4903 100644 --- a/desmume/src/windows/main.h +++ b/src/windows/main.h @@ -1,32 +1,32 @@ -#ifndef _MAIN_H_ -#define _MAIN_H_ - -#include "CWindow.h" -extern WINCLASS *MainWindow; - -extern volatile bool execute, paused; -void NDS_Pause(); -void NDS_UnPause(); -void LoadSaveStateInfo(); -void Display(); -void Pause(); -void FrameAdvance(bool state); -void ResetGame(); //Resets game (for the menu item & hotkey -void AviRecordTo(); -void AviEnd(); -void WavRecordTo(); -void WavEnd(); - -extern bool frameCounterDisplay; -extern bool FpsDisplay; -extern bool ShowLagFrameCounter; - -#define GPU3D_NULL 0 -#define GPU3D_OPENGL 1 -#define GPU3D_SWRAST 2 - -extern int backupmemorytype; -extern u32 backupmemorysize; - - -#endif +#ifndef _MAIN_H_ +#define _MAIN_H_ + +#include "CWindow.h" +extern WINCLASS *MainWindow; + +extern volatile BOOL execute, paused; +void NDS_Pause(); +void NDS_UnPause(); +void LoadSaveStateInfo(); +void Display(); +void Pause(); +void FrameAdvance(bool state); +void ResetGame(); //Resets game (for the menu item & hotkey +void AviRecordTo(); +void AviEnd(); +void WavRecordTo(); +void WavEnd(); + +extern bool frameCounterDisplay; +extern bool FpsDisplay; +extern bool ShowLagFrameCounter; + +#define GPU3D_NULL 0 +#define GPU3D_OPENGL 1 +#define GPU3D_SWRAST 2 + +extern int backupmemorytype; +extern u32 backupmemorysize; + + +#endif diff --git a/src/windows/mapView.cpp b/src/windows/mapView.cpp new file mode 100644 index 000000000..8d1cba31b --- /dev/null +++ b/src/windows/mapView.cpp @@ -0,0 +1,298 @@ +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "mapView.h" +#include "resource.h" + +#include +#include "../MMU.h" +#include "../NDSSystem.h" +#include "debug.h" +#include "windriver.h" + +using namespace GPU_EXT; + +struct mapview_struct +{ + u32 autoup_secs; + bool autoup; + + u16 map; + u16 lcd; + u16 bitmap[1024*1024]; + + void render() + { + //we're going to make a copy of the gpu so that we don't wreck affine scroll params + //hopefully we won't mess up anything else + GPU *realGpu; + if(lcd) realGpu = SubScreen.gpu; + else realGpu = MainScreen.gpu; + GPU &gpu = *realGpu; + + //forgive the gyrations, some of this junk in here is to remind us of gyrations we might have to go + //through to avoid breaking the gpu struct + + gpu.currBgNum = map; + gpu.debug = true; + + for(u32 i = 0; i < gpu.BGSize[map][1]; ++i) + { + gpu.currDst = (u8 *)bitmap + i*gpu.BGSize[map][0]*2; + gpu.currLine = i; + gpu.modeRender(map); + } + gpu.debug = false; + + } +}; + +mapview_struct *MapView = NULL; + + +LRESULT MapView_OnPaint(mapview_struct * win, HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + Lock lock; + + HDC hdc; + PAINTSTRUCT ps; + char text[80]; + u32 dispcnt = ((volatile u32 *)ARM9Mem.ARM9_REG)[(win->lcd*0x400)]; + u32 bgcnt = ((volatile u16 *)ARM9Mem.ARM9_REG)[(8 + (win->map<<1) + (win->lcd*0x1000))>>1]; + BITMAPV4HEADER bmi; + u16 lg; + u16 ht; + BGxPARMS * parms; + + //CreateBitmapIndirect(&bmi); + memset(&bmi, 0, sizeof(bmi)); + bmi.bV4Size = sizeof(bmi); + bmi.bV4Planes = 1; + bmi.bV4BitCount = 16; + bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS; + bmi.bV4RedMask = 0x001F; + bmi.bV4GreenMask = 0x03E0; + bmi.bV4BlueMask = 0x7C00; + + if(win->lcd) + { + lg = SubScreen.gpu->BGSize[win->map][0]; + ht = SubScreen.gpu->BGSize[win->map][1]; + } + else + { + lg = MainScreen.gpu->BGSize[win->map][0]; + ht = MainScreen.gpu->BGSize[win->map][1]; + } + bmi.bV4Width = lg; + bmi.bV4Height = -ht; + + hdc = BeginPaint(hwnd, &ps); + + sprintf(text, "%d %08X, %08X", (int)(dispcnt&7), (int)dispcnt, (int)bgcnt); + SetWindowText(GetDlgItem(hwnd, IDC_MODE), text); + + if(!(bgcnt&(1<<7))) + sprintf(text, "normal 16"); + else + { + if(!(dispcnt&(1<<30))) + sprintf(text, "normal 256"); + else + { + switch(win->map) + { + case 0 : + sprintf(text, "extended slot %d", (bgcnt&(1<<13))?2:0); + break; + case 1 : + sprintf(text, "extended slot %d", (bgcnt&(1<<13))?3:1); + break; + default : + sprintf(text, "extended slot %d", MainScreen.gpu->BGExtPalSlot[win->map]); + break; + } + } + } + SetWindowText(GetDlgItem(hwnd, IDC_PAL), text); + + sprintf(text, "%d", (int)(bgcnt&3)); + SetWindowText(GetDlgItem(hwnd, IDC_PRIO), text); + + + if((dispcnt>>8>>win->map)&1) + SetWindowText(GetDlgItem(hwnd, IDC_VISIBLE), "true"); + else + SetWindowText(GetDlgItem(hwnd, IDC_VISIBLE), "false"); + + sprintf(text, "0x%08X", (int)(0x6000000 + ((bgcnt>>2)&0xF)*0x4000 + win->lcd*0x200000 +((dispcnt>>24)&7)*0x10000)); + SetWindowText(GetDlgItem(hwnd, IDC_CHAR), text); + + sprintf(text, "0x%08X", (int)(0x6000000 + 0x800*((bgcnt>>8)&0x1F) + win->lcd*0x200000 + ((dispcnt>>27)&7)*0x10000)); + SetWindowText(GetDlgItem(hwnd, IDC_SCR), text); + + //sprintf(text, "%d x %d", MainScreen.gpu->BGPA[win->map], MainScreen.gpu->BGPB[win->map]); + sprintf(text, "%d x %d", (int)MainScreen.gpu->BGSize[win->map][0], (int)MainScreen.gpu->BGSize[win->map][1]); + SetWindowText(GetDlgItem(hwnd, IDC_MSIZE), text); + + if (win->map==2) { + parms = &(MainScreen.gpu->dispx_st)->dispx_BG2PARMS; + } else { + parms = &(MainScreen.gpu->dispx_st)->dispx_BG3PARMS; + } + sprintf(text, "%d x %d", parms->BGxPC, parms->BGxPD); + SetWindowText(GetDlgItem(hwnd, IDC_SCROLL), text); + + for(int i = 0; i < (1024*1024); i++) + win->bitmap[i] = 0x7C1F; + + win->render(); + + SetDIBitsToDevice(hdc, 200, 4, lg, ht, 0, 0, 0, ht, win->bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + + EndPaint(hwnd, &ps); + + return 0; +} + +BOOL CALLBACK ViewMapsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + //bail out early if the dialog isnt initialized + if(!MapView && message != WM_INITDIALOG) + return false; + + switch (message) + { + case WM_INITDIALOG : + { + MapView = new mapview_struct; + memset(MapView, 0, sizeof(MapView)); + MapView->autoup_secs = 1; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, MapView->autoup_secs); + HWND combo = GetDlgItem(hwnd, IDC_BG_SELECT); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 3"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub BackGround 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub BackGround 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub BackGround 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub BackGround 3"); + SendMessage(combo, CB_SETCURSEL, 0, 0); + } + return 1; + case WM_CLOSE : + { + if(MapView->autoup) + { + KillTimer(hwnd, IDT_VIEW_MAP); + MapView->autoup = false; + } + if (MapView!=NULL) + { + delete MapView; + MapView = NULL; + } + //INFO("Close Map view dialog\n"); + PostQuitMessage(0); + return 0; + } + case WM_PAINT: + MapView_OnPaint(MapView, hwnd, wParam, lParam); + return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; + case WM_COMMAND : + switch (LOWORD (wParam)) + { + case IDC_FERMER : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 1; + case IDC_AUTO_UPDATE : + if(MapView->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_MAP); + MapView->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + MapView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_MAP, MapView->autoup_secs*20, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (!MapView) + { + SendMessage(hwnd, WM_INITDIALOG, 0, 0); + } + if (t != MapView->autoup_secs) + { + MapView->autoup_secs = t; + if (MapView->autoup) + SetTimer(hwnd, IDT_VIEW_MAP, + MapView->autoup_secs*20, (TIMERPROC) NULL); + } + } + return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_BG_SELECT : + switch(HIWORD(wParam)) + { + case CBN_SELCHANGE : + case CBN_CLOSEUP : + { + u32 sel= SendMessage(GetDlgItem(hwnd, IDC_BG_SELECT), CB_GETCURSEL, 0, 0); + switch(sel) + { + case 0 : + case 1 : + case 2 : + case 3 : + MapView->map = sel; + MapView->lcd = 0; + break; + case 4 : + case 5 : + case 6 : + case 7 : + MapView->map = sel-4; + MapView->lcd = 1; + break; + } + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + }//switch et case + }//switch + return 1; + } + return false; +} diff --git a/desmume/src/windows/mapView.h b/src/windows/mapView.h similarity index 96% rename from desmume/src/windows/mapView.h rename to src/windows/mapView.h index ca12ed9cf..124dae2f9 100644 --- a/desmume/src/windows/mapView.h +++ b/src/windows/mapView.h @@ -1,29 +1,29 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef MAPVIEW_H -#define MAPVIEW_H - -#include "../common.h" - -extern BOOL CALLBACK ViewMapsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef MAPVIEW_H +#define MAPVIEW_H + +#include "../common.h" + +extern BOOL CALLBACK ViewMapsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + #endif \ No newline at end of file diff --git a/desmume/src/windows/matrixView.cpp b/src/windows/matrixView.cpp similarity index 97% rename from desmume/src/windows/matrixView.cpp rename to src/windows/matrixView.cpp index 47893fd65..12ee73150 100644 --- a/desmume/src/windows/matrixView.cpp +++ b/src/windows/matrixView.cpp @@ -1,256 +1,256 @@ -/* Copyright (C) 2007 Acid Burn - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "matrixView.h" -#include -#include "debug.h" -#include "resource.h" -#include "gfx3d.h" - -typedef struct -{ - u32 autoup_secs; - bool autoup; -} matrixview_struct; - -matrixview_struct *MatrixView = NULL; - -void MatrixView_SetMatrix(HWND hwnd, const int* idcs, float* matrix) -{ - int n; - char buffer[64]; - - for(n = 0; n < 16; n++) - { - sprintf(buffer, "%.4f", matrix[n]); - //sprintf(buffer, "%.8x", (int)(matrix[n]*4096)); - SetWindowText(GetDlgItem(hwnd, idcs[n]), buffer); - } -} - -void MatrixView_OnPaintPositionMatrix(HWND hwnd) -{ - // IDC for each matrix coefficient - const int idcGroup[16] = - { - IDC_MATRIX_VIEWER_COORD_11_EDIT, IDC_MATRIX_VIEWER_COORD_12_EDIT, IDC_MATRIX_VIEWER_COORD_13_EDIT, IDC_MATRIX_VIEWER_COORD_14_EDIT, - IDC_MATRIX_VIEWER_COORD_21_EDIT, IDC_MATRIX_VIEWER_COORD_22_EDIT, IDC_MATRIX_VIEWER_COORD_23_EDIT, IDC_MATRIX_VIEWER_COORD_24_EDIT, - IDC_MATRIX_VIEWER_COORD_31_EDIT, IDC_MATRIX_VIEWER_COORD_32_EDIT, IDC_MATRIX_VIEWER_COORD_33_EDIT, IDC_MATRIX_VIEWER_COORD_34_EDIT, - IDC_MATRIX_VIEWER_COORD_41_EDIT, IDC_MATRIX_VIEWER_COORD_42_EDIT, IDC_MATRIX_VIEWER_COORD_43_EDIT, IDC_MATRIX_VIEWER_COORD_44_EDIT - }; - - float matrix[16]; - HWND hStackCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_COORD_COMBO); - int stackIndex; - - stackIndex = SendMessage(hStackCombo, CB_GETCURSEL, 0, 0) - 1; - - gfx3d_glGetMatrix(1, stackIndex, matrix); - MatrixView_SetMatrix(hwnd, idcGroup, matrix); -} - -////////////////////////////////////////////////////////////////////////////// - -void MatrixView_OnPaintDirectionMatrix(HWND hwnd) -{ - // IDC for each matrix coefficient - const int idcGroup[16] = - { - IDC_MATRIX_VIEWER_DIR_11_EDIT, IDC_MATRIX_VIEWER_DIR_12_EDIT, IDC_MATRIX_VIEWER_DIR_13_EDIT, IDC_MATRIX_VIEWER_DIR_14_EDIT, - IDC_MATRIX_VIEWER_DIR_21_EDIT, IDC_MATRIX_VIEWER_DIR_22_EDIT, IDC_MATRIX_VIEWER_DIR_23_EDIT, IDC_MATRIX_VIEWER_DIR_24_EDIT, - IDC_MATRIX_VIEWER_DIR_31_EDIT, IDC_MATRIX_VIEWER_DIR_32_EDIT, IDC_MATRIX_VIEWER_DIR_33_EDIT, IDC_MATRIX_VIEWER_DIR_34_EDIT, - IDC_MATRIX_VIEWER_DIR_41_EDIT, IDC_MATRIX_VIEWER_DIR_42_EDIT, IDC_MATRIX_VIEWER_DIR_43_EDIT, IDC_MATRIX_VIEWER_DIR_44_EDIT - }; - - float matrix[16]; - HWND hStackCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_DIR_COMBO); - int stackIndex; - - stackIndex = SendMessage(hStackCombo, CB_GETCURSEL, 0, 0) - 1; - - gfx3d_glGetMatrix(2, stackIndex, matrix); - MatrixView_SetMatrix(hwnd, idcGroup, matrix); -} - -////////////////////////////////////////////////////////////////////////////// - -void MatrixView_OnPaintProjectionMatrix(HWND hwnd) -{ - // IDC for each matrix coefficient - const int idcGroup[16] = - { - IDC_MATRIX_VIEWER_PROJ_11_EDIT, IDC_MATRIX_VIEWER_PROJ_12_EDIT, IDC_MATRIX_VIEWER_PROJ_13_EDIT, IDC_MATRIX_VIEWER_PROJ_14_EDIT, - IDC_MATRIX_VIEWER_PROJ_21_EDIT, IDC_MATRIX_VIEWER_PROJ_22_EDIT, IDC_MATRIX_VIEWER_PROJ_23_EDIT, IDC_MATRIX_VIEWER_PROJ_24_EDIT, - IDC_MATRIX_VIEWER_PROJ_31_EDIT, IDC_MATRIX_VIEWER_PROJ_32_EDIT, IDC_MATRIX_VIEWER_PROJ_33_EDIT, IDC_MATRIX_VIEWER_PROJ_34_EDIT, - IDC_MATRIX_VIEWER_PROJ_41_EDIT, IDC_MATRIX_VIEWER_PROJ_42_EDIT, IDC_MATRIX_VIEWER_PROJ_43_EDIT, IDC_MATRIX_VIEWER_PROJ_44_EDIT - }; - - float mat[16]; - - gfx3d_glGetMatrix(0, -1, mat); - MatrixView_SetMatrix(hwnd, idcGroup, mat); -} - -////////////////////////////////////////////////////////////////////////////// - -void MatrixView_OnPaintTextureMatrix(HWND hwnd) -{ - // IDC for each matrix coefficient - const int idcGroup[16] = - { - IDC_MATRIX_VIEWER_TEX_11_EDIT, IDC_MATRIX_VIEWER_TEX_12_EDIT, IDC_MATRIX_VIEWER_TEX_13_EDIT, IDC_MATRIX_VIEWER_TEX_14_EDIT, - IDC_MATRIX_VIEWER_TEX_21_EDIT, IDC_MATRIX_VIEWER_TEX_22_EDIT, IDC_MATRIX_VIEWER_TEX_23_EDIT, IDC_MATRIX_VIEWER_TEX_24_EDIT, - IDC_MATRIX_VIEWER_TEX_31_EDIT, IDC_MATRIX_VIEWER_TEX_32_EDIT, IDC_MATRIX_VIEWER_TEX_33_EDIT, IDC_MATRIX_VIEWER_TEX_34_EDIT, - IDC_MATRIX_VIEWER_TEX_41_EDIT, IDC_MATRIX_VIEWER_TEX_42_EDIT, IDC_MATRIX_VIEWER_TEX_43_EDIT, IDC_MATRIX_VIEWER_TEX_44_EDIT - }; - - float mat[16]; - - gfx3d_glGetMatrix(3, -1, mat); - MatrixView_SetMatrix(hwnd, idcGroup, mat); -} - -BOOL MatrixView_OnPaint( HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - - hdc = BeginPaint(hwnd, &ps); - - MatrixView_OnPaintProjectionMatrix(hwnd); - MatrixView_OnPaintPositionMatrix(hwnd); - MatrixView_OnPaintDirectionMatrix(hwnd); - MatrixView_OnPaintTextureMatrix(hwnd); - - EndPaint(hwnd, &ps); - - return TRUE; -} - -BOOL CALLBACK ViewMatricesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_INITDIALOG: - { - MatrixView = new matrixview_struct; - memset(MatrixView, 0, sizeof(matrixview_struct)); - MatrixView->autoup_secs = 1; - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETRANGE, 0, MAKELONG(99, 1)); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETPOS32, 0, MatrixView->autoup_secs); - int n; - HWND hPosCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_COORD_COMBO); - HWND hDirCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_DIR_COMBO); - - // Setup position and direction matrix comboboxes with stack indices - SendMessage(hPosCombo, CB_ADDSTRING, 0,(LPARAM)"Current"); - SendMessage(hDirCombo, CB_ADDSTRING, 0,(LPARAM)"Current"); - - for(n = 0; n < 32; n++) - { - char buffer[4]; - - sprintf(buffer, "%d", n); - SendMessage(hPosCombo, CB_ADDSTRING, 0,(LPARAM)buffer); - SendMessage(hDirCombo, CB_ADDSTRING, 0,(LPARAM)buffer); - } - - SendMessage(hPosCombo, CB_SETCURSEL, 0, 0); - SendMessage(hDirCombo, CB_SETCURSEL, 0, 0); - return 1; - } - - case WM_CLOSE: - { - if(MatrixView->autoup) - { - KillTimer(hwnd, IDT_VIEW_MATRIX); - MatrixView->autoup = false; - } - - if (MatrixView!=NULL) - { - delete MatrixView; - MatrixView = NULL; - } - //INFO("Close Matrix view dialog\n"); - PostQuitMessage(0); - return 0; - } - - case WM_PAINT: - MatrixView_OnPaint(hwnd, wParam, lParam); - return 1; - case WM_TIMER: - SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); - return 1; - - case WM_COMMAND: - switch (LOWORD (wParam)) - { - case IDOK: - SendMessage(hwnd, WM_CLOSE, 0, 0); - return 1; - - case IDC_AUTO_UPDATE : - if(MatrixView->autoup) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); - KillTimer(hwnd, IDT_VIEW_MATRIX); - MatrixView->autoup = FALSE; - return 1; - } - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); - MatrixView->autoup = TRUE; - SetTimer(hwnd, IDT_VIEW_MATRIX, MatrixView->autoup_secs*20, (TIMERPROC) NULL); - return 1; - case IDC_AUTO_UPDATE_SECS: - { - int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); - if (!MatrixView) - { - SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - if (t != MatrixView->autoup_secs) - { - MatrixView->autoup_secs = t; - if (MatrixView->autoup) - SetTimer(hwnd, IDT_VIEW_MATRIX, - MatrixView->autoup_secs*20, (TIMERPROC) NULL); - } - } - return 1; - case IDC_REFRESH: - InvalidateRect(hwnd, NULL, FALSE); - return 1; - - case IDC_MATRIX_VIEWER_DIR_COMBO: - case IDC_MATRIX_VIEWER_COORD_COMBO: - InvalidateRect(hwnd, NULL, FALSE); - return 1; - } - return 0; - } - - return false; -} +/* Copyright (C) 2007 Acid Burn + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "matrixView.h" +#include +#include "debug.h" +#include "resource.h" +#include "gfx3d.h" + +typedef struct +{ + u32 autoup_secs; + bool autoup; +} matrixview_struct; + +matrixview_struct *MatrixView = NULL; + +void MatrixView_SetMatrix(HWND hwnd, const int* idcs, float* matrix) +{ + int n; + char buffer[64]; + + for(n = 0; n < 16; n++) + { + sprintf(buffer, "%.4f", matrix[n]); + //sprintf(buffer, "%.8x", (int)(matrix[n]*4096)); + SetWindowText(GetDlgItem(hwnd, idcs[n]), buffer); + } +} + +void MatrixView_OnPaintPositionMatrix(HWND hwnd) +{ + // IDC for each matrix coefficient + const int idcGroup[16] = + { + IDC_MATRIX_VIEWER_COORD_11_EDIT, IDC_MATRIX_VIEWER_COORD_12_EDIT, IDC_MATRIX_VIEWER_COORD_13_EDIT, IDC_MATRIX_VIEWER_COORD_14_EDIT, + IDC_MATRIX_VIEWER_COORD_21_EDIT, IDC_MATRIX_VIEWER_COORD_22_EDIT, IDC_MATRIX_VIEWER_COORD_23_EDIT, IDC_MATRIX_VIEWER_COORD_24_EDIT, + IDC_MATRIX_VIEWER_COORD_31_EDIT, IDC_MATRIX_VIEWER_COORD_32_EDIT, IDC_MATRIX_VIEWER_COORD_33_EDIT, IDC_MATRIX_VIEWER_COORD_34_EDIT, + IDC_MATRIX_VIEWER_COORD_41_EDIT, IDC_MATRIX_VIEWER_COORD_42_EDIT, IDC_MATRIX_VIEWER_COORD_43_EDIT, IDC_MATRIX_VIEWER_COORD_44_EDIT + }; + + float matrix[16]; + HWND hStackCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_COORD_COMBO); + int stackIndex; + + stackIndex = SendMessage(hStackCombo, CB_GETCURSEL, 0, 0) - 1; + + gfx3d_glGetMatrix(1, stackIndex, matrix); + MatrixView_SetMatrix(hwnd, idcGroup, matrix); +} + +////////////////////////////////////////////////////////////////////////////// + +void MatrixView_OnPaintDirectionMatrix(HWND hwnd) +{ + // IDC for each matrix coefficient + const int idcGroup[16] = + { + IDC_MATRIX_VIEWER_DIR_11_EDIT, IDC_MATRIX_VIEWER_DIR_12_EDIT, IDC_MATRIX_VIEWER_DIR_13_EDIT, IDC_MATRIX_VIEWER_DIR_14_EDIT, + IDC_MATRIX_VIEWER_DIR_21_EDIT, IDC_MATRIX_VIEWER_DIR_22_EDIT, IDC_MATRIX_VIEWER_DIR_23_EDIT, IDC_MATRIX_VIEWER_DIR_24_EDIT, + IDC_MATRIX_VIEWER_DIR_31_EDIT, IDC_MATRIX_VIEWER_DIR_32_EDIT, IDC_MATRIX_VIEWER_DIR_33_EDIT, IDC_MATRIX_VIEWER_DIR_34_EDIT, + IDC_MATRIX_VIEWER_DIR_41_EDIT, IDC_MATRIX_VIEWER_DIR_42_EDIT, IDC_MATRIX_VIEWER_DIR_43_EDIT, IDC_MATRIX_VIEWER_DIR_44_EDIT + }; + + float matrix[16]; + HWND hStackCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_DIR_COMBO); + int stackIndex; + + stackIndex = SendMessage(hStackCombo, CB_GETCURSEL, 0, 0) - 1; + + gfx3d_glGetMatrix(2, stackIndex, matrix); + MatrixView_SetMatrix(hwnd, idcGroup, matrix); +} + +////////////////////////////////////////////////////////////////////////////// + +void MatrixView_OnPaintProjectionMatrix(HWND hwnd) +{ + // IDC for each matrix coefficient + const int idcGroup[16] = + { + IDC_MATRIX_VIEWER_PROJ_11_EDIT, IDC_MATRIX_VIEWER_PROJ_12_EDIT, IDC_MATRIX_VIEWER_PROJ_13_EDIT, IDC_MATRIX_VIEWER_PROJ_14_EDIT, + IDC_MATRIX_VIEWER_PROJ_21_EDIT, IDC_MATRIX_VIEWER_PROJ_22_EDIT, IDC_MATRIX_VIEWER_PROJ_23_EDIT, IDC_MATRIX_VIEWER_PROJ_24_EDIT, + IDC_MATRIX_VIEWER_PROJ_31_EDIT, IDC_MATRIX_VIEWER_PROJ_32_EDIT, IDC_MATRIX_VIEWER_PROJ_33_EDIT, IDC_MATRIX_VIEWER_PROJ_34_EDIT, + IDC_MATRIX_VIEWER_PROJ_41_EDIT, IDC_MATRIX_VIEWER_PROJ_42_EDIT, IDC_MATRIX_VIEWER_PROJ_43_EDIT, IDC_MATRIX_VIEWER_PROJ_44_EDIT + }; + + float mat[16]; + + gfx3d_glGetMatrix(0, -1, mat); + MatrixView_SetMatrix(hwnd, idcGroup, mat); +} + +////////////////////////////////////////////////////////////////////////////// + +void MatrixView_OnPaintTextureMatrix(HWND hwnd) +{ + // IDC for each matrix coefficient + const int idcGroup[16] = + { + IDC_MATRIX_VIEWER_TEX_11_EDIT, IDC_MATRIX_VIEWER_TEX_12_EDIT, IDC_MATRIX_VIEWER_TEX_13_EDIT, IDC_MATRIX_VIEWER_TEX_14_EDIT, + IDC_MATRIX_VIEWER_TEX_21_EDIT, IDC_MATRIX_VIEWER_TEX_22_EDIT, IDC_MATRIX_VIEWER_TEX_23_EDIT, IDC_MATRIX_VIEWER_TEX_24_EDIT, + IDC_MATRIX_VIEWER_TEX_31_EDIT, IDC_MATRIX_VIEWER_TEX_32_EDIT, IDC_MATRIX_VIEWER_TEX_33_EDIT, IDC_MATRIX_VIEWER_TEX_34_EDIT, + IDC_MATRIX_VIEWER_TEX_41_EDIT, IDC_MATRIX_VIEWER_TEX_42_EDIT, IDC_MATRIX_VIEWER_TEX_43_EDIT, IDC_MATRIX_VIEWER_TEX_44_EDIT + }; + + float mat[16]; + + gfx3d_glGetMatrix(3, -1, mat); + MatrixView_SetMatrix(hwnd, idcGroup, mat); +} + +BOOL MatrixView_OnPaint( HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + + hdc = BeginPaint(hwnd, &ps); + + MatrixView_OnPaintProjectionMatrix(hwnd); + MatrixView_OnPaintPositionMatrix(hwnd); + MatrixView_OnPaintDirectionMatrix(hwnd); + MatrixView_OnPaintTextureMatrix(hwnd); + + EndPaint(hwnd, &ps); + + return TRUE; +} + +BOOL CALLBACK ViewMatricesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG: + { + MatrixView = new matrixview_struct; + memset(MatrixView, 0, sizeof(matrixview_struct)); + MatrixView->autoup_secs = 1; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, MatrixView->autoup_secs); + int n; + HWND hPosCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_COORD_COMBO); + HWND hDirCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_DIR_COMBO); + + // Setup position and direction matrix comboboxes with stack indices + SendMessage(hPosCombo, CB_ADDSTRING, 0,(LPARAM)"Current"); + SendMessage(hDirCombo, CB_ADDSTRING, 0,(LPARAM)"Current"); + + for(n = 0; n < 32; n++) + { + char buffer[4]; + + sprintf(buffer, "%d", n); + SendMessage(hPosCombo, CB_ADDSTRING, 0,(LPARAM)buffer); + SendMessage(hDirCombo, CB_ADDSTRING, 0,(LPARAM)buffer); + } + + SendMessage(hPosCombo, CB_SETCURSEL, 0, 0); + SendMessage(hDirCombo, CB_SETCURSEL, 0, 0); + return 1; + } + + case WM_CLOSE: + { + if(MatrixView->autoup) + { + KillTimer(hwnd, IDT_VIEW_MATRIX); + MatrixView->autoup = false; + } + + if (MatrixView!=NULL) + { + delete MatrixView; + MatrixView = NULL; + } + //INFO("Close Matrix view dialog\n"); + PostQuitMessage(0); + return 0; + } + + case WM_PAINT: + MatrixView_OnPaint(hwnd, wParam, lParam); + return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; + + case WM_COMMAND: + switch (LOWORD (wParam)) + { + case IDOK: + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 1; + + case IDC_AUTO_UPDATE : + if(MatrixView->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_MATRIX); + MatrixView->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + MatrixView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_MATRIX, MatrixView->autoup_secs*20, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (!MatrixView) + { + SendMessage(hwnd, WM_INITDIALOG, 0, 0); + } + if (t != MatrixView->autoup_secs) + { + MatrixView->autoup_secs = t; + if (MatrixView->autoup) + SetTimer(hwnd, IDT_VIEW_MATRIX, + MatrixView->autoup_secs*20, (TIMERPROC) NULL); + } + } + return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; + + case IDC_MATRIX_VIEWER_DIR_COMBO: + case IDC_MATRIX_VIEWER_COORD_COMBO: + InvalidateRect(hwnd, NULL, FALSE); + return 1; + } + return 0; + } + + return false; +} diff --git a/desmume/src/windows/matrixView.h b/src/windows/matrixView.h similarity index 96% rename from desmume/src/windows/matrixView.h rename to src/windows/matrixView.h index fb3480061..6f5f16c91 100644 --- a/desmume/src/windows/matrixView.h +++ b/src/windows/matrixView.h @@ -1,27 +1,27 @@ -/* Copyright (C) 2007 Acid Burn - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef MATRIXVIEW_H -#define MATRIXVIEW_H - -#include "../common.h" - -extern BOOL CALLBACK ViewMatricesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - +/* Copyright (C) 2007 Acid Burn + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef MATRIXVIEW_H +#define MATRIXVIEW_H + +#include "../common.h" + +extern BOOL CALLBACK ViewMatricesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + #endif \ No newline at end of file diff --git a/desmume/src/windows/memView.cpp b/src/windows/memView.cpp similarity index 95% rename from desmume/src/windows/memView.cpp rename to src/windows/memView.cpp index d4100f9fe..b7c989d15 100644 --- a/desmume/src/windows/memView.cpp +++ b/src/windows/memView.cpp @@ -1,812 +1,813 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - - -#include "../MMU.h" -#include "debug.h" -#include "resource.h" -#include "common.h" -#include -#include -#include -#include -#include "memView.h" - -using namespace std; - -////////////////////////////////////////////////////////////////////////////// - -typedef struct MemView_DataStruct -{ - MemView_DataStruct(u8 CPU) : cpu(CPU), address(0x02000000), viewMode(0), sel(FALSE), selPart(0), selAddress(0x00000000), selNewVal(0x000000000) - { - } - - HWND hDlg; - - u8 cpu; - u32 address; - u8 viewMode; - - BOOL sel; - u8 selPart; - u32 selAddress; - u32 selNewVal; -} MemView_DataStruct; - -MemView_DataStruct * MemView_Data[2] = {NULL, NULL}; - -////////////////////////////////////////////////////////////////////////////// - -BOOL MemView_Init() -{ - WNDCLASSEX wc; - - wc.cbSize = sizeof(wc); - wc.lpszClassName = "MemView_ViewBox"; - wc.hInstance = hAppInst; - wc.lpfnWndProc = MemView_ViewBoxProc; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); - wc.style = 0; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(MemView_DataStruct); - wc.hIconSm = 0; - - RegisterClassEx(&wc); - - return 1; -} - -void MemView_DeInit() -{ - UnregisterClass("MemView_ViewBox", hAppInst); -} - -////////////////////////////////////////////////////////////////////////////// - -BOOL MemView_DlgOpen(HWND hParentWnd, char *Title, u8 CPU) -{ - HWND hDlg; - - MemView_Data[CPU] = new MemView_DataStruct(CPU); - if(MemView_Data[CPU] == NULL) - return 0; - - hDlg = CreateDialogParam(hAppInst, MAKEINTRESOURCE(IDD_MEM_VIEW), hParentWnd, MemView_DlgProc, (LPARAM)MemView_Data[CPU]); - if(hDlg == NULL) - { - delete MemView_Data[CPU]; - MemView_Data[CPU] = NULL; - return 0; - } - - MemView_Data[CPU]->hDlg = hDlg; - - SetWindowText(hDlg, Title); - - ShowWindow(hDlg, SW_SHOW); - UpdateWindow(hDlg); - - return 1; -} - -void MemView_DlgClose(u8 CPU) -{ - if(MemView_Data[CPU] != NULL) - { - DestroyWindow(MemView_Data[CPU]->hDlg); - delete MemView_Data[CPU]; - MemView_Data[CPU] = NULL; - } -} - -BOOL MemView_IsOpened(u8 CPU) -{ - return (MemView_Data[CPU] != NULL); -} - -void MemView_Refresh(u8 CPU) -{ - InvalidateRect(MemView_Data[CPU]->hDlg, NULL, FALSE); - UpdateWindow(MemView_Data[CPU]->hDlg); -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT MemView_DlgPaint(HWND hDlg, MemView_DataStruct *data, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - - hdc = BeginPaint(hDlg, &ps); - - EndPaint(hDlg, &ps); - - return 0; -} - -BOOL CALLBACK MemView_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - MemView_DataStruct *data = (MemView_DataStruct*)GetWindowLong(hDlg, DWL_USER); - if((data == NULL) && (uMsg != WM_INITDIALOG)) - return 0; - - switch(uMsg) - { - case WM_INITDIALOG: - { - if(data == NULL) - { - data = (MemView_DataStruct*)lParam; - SetWindowLong(hDlg, DWL_USER, (LONG)data); - } - - CheckRadioButton(hDlg, IDC_8_BIT, IDC_32_BIT, IDC_8_BIT); - - SendMessage(GetDlgItem(hDlg, IDC_ADDRESS), EM_SETLIMITTEXT, 8, 0); - SetWindowText(GetDlgItem(hDlg, IDC_ADDRESS), "02000000"); - - SetWindowLong(GetDlgItem(hDlg, IDC_MEMVIEWBOX), DWL_USER, (LONG)data); - - InvalidateRect(hDlg, NULL, FALSE); UpdateWindow(hDlg); - } - return 1; - - case WM_CLOSE: - case WM_DESTROY: - MemView_DlgClose(data->cpu); - return 1; - - case WM_PAINT: - MemView_DlgPaint(hDlg, data, wParam, lParam); - return 1; - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDCANCEL: - MemView_DlgClose(data->cpu); - return 1; - - case IDC_8_BIT: - case IDC_16_BIT: - case IDC_32_BIT: - data->sel = FALSE; - data->selAddress = 0x00000000; - data->selPart = 0; - data->selNewVal = 0x00000000; - CheckRadioButton(hDlg, IDC_8_BIT, IDC_32_BIT, LOWORD(wParam)); - data->viewMode = (LOWORD(wParam) - IDC_8_BIT); - InvalidateRect(hDlg, NULL, FALSE); UpdateWindow(hDlg); - return 1; - - case IDC_GO: - { - char addrstr[9]; - int len; - int i; - int shift; - BOOL error = FALSE; - u32 address = 0x00000000; - - len = GetWindowText(GetDlgItem(hDlg, IDC_ADDRESS), addrstr, 9); - - for(i = 0; i < len; i++) - { - char ch = addrstr[i]; - - if((ch >= '0') && (ch <= '9')) - continue; - - if((ch >= 'A') && (ch <= 'F')) - continue; - - if((ch >= 'a') && (ch <= 'f')) - continue; - - if(ch == '\0') - break; - - error = TRUE; - break; - } - - if(error) - { - MessageBox(hDlg, "Error:\nInvalid address specified.\nThe address must be an hexadecimal value.", "DeSmuME", (MB_OK | MB_ICONERROR)); - SetWindowText(GetDlgItem(hDlg, IDC_ADDRESS), ""); - return 1; - } - - for(i = (len-1), shift = 0; i >= 0; i--, shift += 4) - { - char ch = addrstr[i]; - - if((ch >= '0') && (ch <= '9')) - address |= ((ch - '0') << shift); - else if((ch >= 'A') && (ch <= 'F')) - address |= ((ch - 'A' + 0xA) << shift); - else if((ch >= 'a') && (ch <= 'f')) - address |= ((ch - 'a' + 0xA) << shift); - } - - data->sel = FALSE; - data->selAddress = 0x00000000; - data->selPart = 0; - data->selNewVal = 0x00000000; - - data->address = min((u32)0xFFFFFF00, (address & 0xFFFFFFF0)); - SetScrollPos(GetDlgItem(hDlg, IDC_MEMVIEWBOX), SB_VERT, ((data->address >> 4) & 0x000FFFFF), TRUE); - InvalidateRect(hDlg, NULL, FALSE); UpdateWindow(hDlg); - } - return 1; - - case IDC_TEXTDUMP: - { - char fileName[256] = ""; - OPENFILENAME ofn; - - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hDlg; - ofn.lpstrFilter = "Text file (*.txt)\0*.txt\0Any file (*.*)\0*.*\0\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile = fileName; - ofn.nMaxFile = 256; - ofn.lpstrDefExt = "txt"; - ofn.Flags = OFN_NOCHANGEDIR | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; - - if(GetSaveFileName(&ofn)) - { - FILE *f; - u8 memory[0x100]; - int line; - - MMU_DumpMemBlock(data->cpu, data->address, 0x100, memory); - - f = fopen(fileName, "a"); - - for(line = 0; line < 16; line++) - { - int i; - - fprintf(f, "%08X\t\t", (data->address + (line << 4))); - - switch(data->viewMode) - { - case 0: - { - for(i = 0; i < 16; i++) - { - fprintf(f, "%02X ", T1ReadByte(memory, ((line << 4) + i))); - } - fprintf(f, "\t"); - } - break; - - case 1: - { - for(i = 0; i < 16; i += 2) - { - fprintf(f, "%04X ", T1ReadWord(memory, ((line << 4) + i))); - } - fprintf(f, "\t\t"); - } - break; - - case 2: - { - for(i = 0; i < 16; i += 4) - { - fprintf(f, "%08X ", T1ReadLong(memory, ((line << 4) + i))); - } - fprintf(f, "\t\t\t"); - } - break; - } - - for(i = 0; i < 16; i++) - { - u8 val = T1ReadByte(memory, ((line << 4) + i)); - - if((val >= 32) && (val <= 127)) - fprintf(f, "%c", (char)val); - else - fprintf(f, "."); - } - fprintf(f, "\n"); - } - - fclose(f); - } - } - return 1; - - case IDC_RAWDUMP: - { - char fileName[256] = ""; - OPENFILENAME ofn; - - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hDlg; - ofn.lpstrFilter = "Binary file (*.bin)\0*.bin\0Any file (*.*)\0*.*\0\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile = fileName; - ofn.nMaxFile = 256; - ofn.lpstrDefExt = "bin"; - ofn.Flags = OFN_NOCHANGEDIR | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; - - if(GetSaveFileName(&ofn)) - { - FILE *f; - u8 memory[0x100]; - - MMU_DumpMemBlock(data->cpu, data->address, 0x100, memory); - - f = fopen(fileName, "ab"); - - fwrite(memory, 0x100, 1, f); - - fclose(f); - } - } - return 1; - } - return 0; - } - - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT MemView_ViewBoxPaint(HWND hCtl, MemView_DataStruct *data, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - RECT rc; - int w, h; - SIZE fontsize; - int fontwidth, fontheight; - HDC mem_hdc; - HBITMAP mem_bmp; - - GetClientRect(hCtl, &rc); - w = (rc.right - rc.left); - h = (rc.bottom - rc.top); - - hdc = BeginPaint(hCtl, &ps); - - mem_hdc = CreateCompatibleDC(hdc); - mem_bmp = CreateCompatibleBitmap(hdc, w, h); - SelectObject(mem_hdc, mem_bmp); - - SelectObject(mem_hdc, GetStockObject(SYSTEM_FIXED_FONT)); - - SetBkMode(mem_hdc, OPAQUE); - SetBkColor(mem_hdc, RGB(255, 255, 255)); - SetTextColor(mem_hdc, RGB(0, 0, 0)); - - GetTextExtentPoint32(mem_hdc, " ", 1, &fontsize); - fontwidth = fontsize.cx; - fontheight = fontsize.cy; - - FillRect(mem_hdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - if(data != NULL) - { - u32 addr = data->address; - u8 memory[0x100]; - char text[80]; - int startx; - int curx, cury; - int line; - - startx = 0; - curx = 0; - cury = 0; - - startx = ((fontwidth * 8) + 5); - cury = (fontheight + 3); - - MoveToEx(mem_hdc, ((fontwidth * 8) + 2), 0, NULL); - LineTo(mem_hdc, ((fontwidth * 8) + 2), h); - - MoveToEx(mem_hdc, 0, (fontheight + 1), NULL); - LineTo(mem_hdc, w, (fontheight + 1)); - - switch(data->viewMode) - { - case 0: - { - sprintf(text, " 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"); - TextOut(mem_hdc, startx, 0, text, strlen(text)); - } - break; - - case 1: - { - sprintf(text, " 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"); - TextOut(mem_hdc, startx, 0, text, strlen(text)); - } - break; - - case 2: - { - sprintf(text, " 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"); - TextOut(mem_hdc, startx, 0, text, strlen(text)); - } - break; - } - - MMU_DumpMemBlock(data->cpu, data->address, 0x100, memory); - - for(line = 0; line < 16; line++, addr += 0x10) - { - int i; - - sprintf(text, "%08X", addr); - TextOut(mem_hdc, 0, cury, text, strlen(text)); - - curx = startx; - - switch(data->viewMode) - { - case 0: - { - curx += (fontwidth * 2); - for(i = 0; i < 16; i++) - { - u8 val = T1ReadByte(memory, ((line << 4) + i)); - if(data->sel && (data->selAddress == (addr + i))) - { - SetBkColor(mem_hdc, GetSysColor(COLOR_HIGHLIGHT)); - SetTextColor(mem_hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); - - switch(data->selPart) - { - case 0: sprintf(text, "%02X", val); break; - case 1: sprintf(text, "%01X.", data->selNewVal); break; - } - } - else - { - SetBkColor(mem_hdc, RGB(255, 255, 255)); - SetTextColor(mem_hdc, RGB(0, 0, 0)); - - sprintf(text, "%02X", val); - } - - TextOut(mem_hdc, curx, cury, text, strlen(text)); - curx += (fontwidth * (2+1)); - } - curx += (fontwidth * 2); - } - break; - - case 1: - { - curx += (fontwidth * 6); - for(i = 0; i < 16; i += 2) - { - u16 val = T1ReadWord(memory, ((line << 4) + i)); - if(data->sel && (data->selAddress == (addr + i))) - { - SetBkColor(mem_hdc, GetSysColor(COLOR_HIGHLIGHT)); - SetTextColor(mem_hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); - - switch(data->selPart) - { - case 0: sprintf(text, "%04X", val); break; - case 1: sprintf(text, "%01X...", data->selNewVal); break; - case 2: sprintf(text, "%02X..", data->selNewVal); break; - case 3: sprintf(text, "%03X.", data->selNewVal); break; - } - } - else - { - SetBkColor(mem_hdc, RGB(255, 255, 255)); - SetTextColor(mem_hdc, RGB(0, 0, 0)); - - sprintf(text, "%04X", val); - } - - TextOut(mem_hdc, curx, cury, text, strlen(text)); - curx += (fontwidth * (4+1)); - } - curx += (fontwidth * 6); - } - break; - - case 2: - { - curx += (fontwidth * 8); - for(i = 0; i < 16; i += 4) - { - u32 val = T1ReadLong(memory, ((line << 4) + i)); - if(data->sel && (data->selAddress == (addr + i))) - { - SetBkColor(mem_hdc, GetSysColor(COLOR_HIGHLIGHT)); - SetTextColor(mem_hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); - - switch(data->selPart) - { - case 0: sprintf(text, "%08X", val); break; - case 1: sprintf(text, "%01X.......", data->selNewVal); break; - case 2: sprintf(text, "%02X......", data->selNewVal); break; - case 3: sprintf(text, "%03X.....", data->selNewVal); break; - case 4: sprintf(text, "%04X....", data->selNewVal); break; - case 5: sprintf(text, "%05X...", data->selNewVal); break; - case 6: sprintf(text, "%06X..", data->selNewVal); break; - case 7: sprintf(text, "%07X.", data->selNewVal); break; - } - } - else - { - SetBkColor(mem_hdc, RGB(255, 255, 255)); - SetTextColor(mem_hdc, RGB(0, 0, 0)); - - sprintf(text, "%08X", val); - } - - TextOut(mem_hdc, curx, cury, text, strlen(text)); - curx += (fontwidth * (8+1)); - } - curx += (fontwidth * 8); - } - break; - } - - SetBkColor(mem_hdc, RGB(255, 255, 255)); - SetTextColor(mem_hdc, RGB(0, 0, 0)); - - for(i = 0; i < 16; i++) - { - u8 val = T1ReadByte(memory, ((line << 4) + i)); - - if((val >= 32) && (val <= 127)) - text[i] = (char)val; - else - text[i] = '.'; - } - text[16] = '\0'; - TextOut(mem_hdc, curx, cury, text, strlen(text)); - - cury += fontheight; - } - } - - BitBlt(hdc, 0, 0, w, h, mem_hdc, 0, 0, SRCCOPY); - - DeleteDC(mem_hdc); - DeleteObject(mem_bmp); - - EndPaint(hCtl, &ps); - - return 0; -} - -LRESULT CALLBACK MemView_ViewBoxProc(HWND hCtl, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - MemView_DataStruct *data = (MemView_DataStruct*)GetWindowLong(hCtl, DWL_USER); - - switch(uMsg) - { - case WM_NCCREATE: - SetScrollRange(hCtl, SB_VERT, 0x00000000, 0x000FFFF0, TRUE); - SetScrollPos(hCtl, SB_VERT, 0x00000000, TRUE); - return 1; - - case WM_NCDESTROY: - return 1; - - case WM_ERASEBKGND: - return 1; - - case WM_PAINT: - MemView_ViewBoxPaint(hCtl, data, wParam, lParam); - return 1; - - case WM_LBUTTONDOWN: - { - HDC hdc; - HFONT font; - SIZE fontsize; - int x, y; - - data->sel = FALSE; - data->selAddress = 0x00000000; - data->selPart = 0; - data->selNewVal = 0x00000000; - - hdc = GetDC(hCtl); - font = (HFONT)SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT)); - GetTextExtentPoint32(hdc, " ", 1, &fontsize); - - x = LOWORD(lParam); - y = HIWORD(lParam); - - if((x >= ((fontsize.cx * 8) + 5)) && (y >= (fontsize.cy + 3))) - { - int line, col; - - x -= ((fontsize.cx * 8) + 5); - y -= (fontsize.cy + 3); - - line = (y / fontsize.cy); - - switch(data->viewMode) - { - case 0: - { - if((x < (fontsize.cx * 2)) || (x >= (fontsize.cx * (2 + ((2+1) * 16))))) - break; - - col = ((x - (fontsize.cx * 2)) / (fontsize.cx * (2+1))); - - data->sel = TRUE; - - } - break; - - case 1: - { - if((x < (fontsize.cx * 6)) || (x >= (fontsize.cx * (6 + ((4+1) * 8))))) - break; - - col = ((x - (fontsize.cx * 6)) / (fontsize.cx * (4+1)) * 2); - - data->sel = TRUE; - - } - break; - - case 2: - { - if((x < (fontsize.cx * 8)) || (x >= (fontsize.cx * (8 + ((8+1) * 4))))) - break; - - col = ((x - (fontsize.cx * 8)) / (fontsize.cx * (8+1)) * 4); - - data->sel = TRUE; - - } - break; - } - - data->selAddress = (data->address + (line << 4) + col); - data->selPart = 0; - data->selNewVal = 0x00000000; - } - - SelectObject(hdc, font); - ReleaseDC(hCtl, hdc); - - SetFocus(hCtl); /* Required to receive keyboard messages */ - InvalidateRect(hCtl, NULL, FALSE); UpdateWindow(hCtl); - } - return 1; - - case WM_CHAR: - { - char ch = (char)wParam; - - if(((ch >= '0') && (ch <= '9')) || ((ch >= 'A') && (ch <= 'F')) || ((ch >= 'a') && (ch <= 'f'))) - { - u8 maxSelPart[3] = {2, 4, 8}; - - data->selNewVal <<= 4; - data->selPart++; - - if((ch >= '0') && (ch <= '9')) - data->selNewVal |= (ch - '0'); - else if((ch >= 'A') && (ch <= 'F')) - data->selNewVal |= (ch - 'A' + 0xA); - else if((ch >= 'a') && (ch <= 'f')) - data->selNewVal |= (ch - 'a' + 0xA); - - if(data->selPart >= maxSelPart[data->viewMode]) - { - switch(data->viewMode) - { - case 0: MMU_write8(data->cpu, data->selAddress, (u8)data->selNewVal); data->selAddress++; break; - case 1: MMU_write16(data->cpu, data->selAddress, (u16)data->selNewVal); data->selAddress += 2; break; - case 2: MMU_write32(data->cpu, data->selAddress, data->selNewVal); data->selAddress += 4; break; - } - data->selPart = 0; - data->selNewVal = 0x00000000; - - if(data->selAddress == 0x00000000) - { - data->sel = FALSE; - } - else if(data->selAddress >= (data->address + 0x100)) - { - data->address = min((u32)0xFFFFFF00, (data->address + 0x10)); - SetScrollPos(hCtl, SB_VERT, ((data->address >> 4) & 0x000FFFFF), TRUE); - } - } - } - - InvalidateRect(hCtl, NULL, FALSE); UpdateWindow(hCtl); - } - return 1; - - case WM_VSCROLL: - { - int firstpos = GetScrollPos(hCtl, SB_VERT); - - switch(LOWORD(wParam)) - { - case SB_LINEUP: - data->address = (u32)max(0x00000000, ((int)data->address - 0x10)); - break; - - case SB_LINEDOWN: - data->address = min((u32)0xFFFFFF00, (data->address + 0x10)); - break; - - case SB_PAGEUP: - data->address = (u32)max(0x00000000, ((int)data->address - 0x100)); - break; - - case SB_PAGEDOWN: - data->address = min((u32)0xFFFFFF00, (data->address + 0x100)); - break; - - case SB_THUMBTRACK: - case SB_THUMBPOSITION: - { - SCROLLINFO si; - - ZeroMemory(&si, sizeof(si)); - si.cbSize = sizeof(si); - si.fMask = SIF_TRACKPOS; - - GetScrollInfo(hCtl, SB_VERT, &si); - - data->address = min((u32)0xFFFFFF00, (data->address + ((si.nTrackPos - firstpos) * 16))); - } - break; - } - - if((data->selAddress < data->address) || (data->selAddress >= (data->address + 0x100))) - { - data->sel = FALSE; - data->selAddress = 0x00000000; - data->selPart = 0; - data->selNewVal = 0x00000000; - } - - SetScrollPos(hCtl, SB_VERT, ((data->address >> 4) & 0x000FFFFF), TRUE); - InvalidateRect(hCtl, NULL, FALSE); UpdateWindow(hCtl); - } - return 1; - } - - return DefWindowProc(hCtl, uMsg, wParam, lParam); -} - -////////////////////////////////////////////////////////////////////////////// +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + + +#include "../MMU.h" +#include "debug.h" +#include "resource.h" +#include "common.h" +#include +#include +#include +#include +#include "memView.h" + +using namespace std; + +////////////////////////////////////////////////////////////////////////////// + +typedef struct MemView_DataStruct +{ + MemView_DataStruct(u8 CPU) : cpu(CPU), address(0x02000000), viewMode(0), sel(FALSE), selPart(0), selAddress(0x00000000), selNewVal(0x000000000) + { + } + + HWND hDlg; + + u8 cpu; + u32 address; + u8 viewMode; + + BOOL sel; + u8 selPart; + u32 selAddress; + u32 selNewVal; +} MemView_DataStruct; + +MemView_DataStruct * MemView_Data[2] = {NULL, NULL}; + +////////////////////////////////////////////////////////////////////////////// + +BOOL MemView_Init() +{ + WNDCLASSEX wc; + + wc.cbSize = sizeof(wc); + wc.lpszClassName = "MemView_ViewBox"; + wc.hInstance = hAppInst; + wc.lpfnWndProc = MemView_ViewBoxProc; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hIcon = 0; + wc.lpszMenuName = 0; + wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE); + wc.style = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = sizeof(MemView_DataStruct); + wc.hIconSm = 0; + + RegisterClassEx(&wc); + + return 1; +} + +void MemView_DeInit() +{ + UnregisterClass("MemView_ViewBox", hAppInst); +} + +////////////////////////////////////////////////////////////////////////////// + +BOOL MemView_DlgOpen(HWND hParentWnd, char *Title, u8 CPU) +{ + HWND hDlg; + + MemView_Data[CPU] = new MemView_DataStruct(CPU); + if(MemView_Data[CPU] == NULL) + return 0; + + hDlg = CreateDialogParam(hAppInst, MAKEINTRESOURCE(IDD_MEM_VIEW), hParentWnd, MemView_DlgProc, (LPARAM)MemView_Data[CPU]); + if(hDlg == NULL) + { + delete MemView_Data[CPU]; + MemView_Data[CPU] = NULL; + return 0; + } + + MemView_Data[CPU]->hDlg = hDlg; + + SetWindowText(hDlg, Title); + + ShowWindow(hDlg, SW_SHOW); + UpdateWindow(hDlg); + + return 1; +} + +void MemView_DlgClose(u8 CPU) +{ + if(MemView_Data[CPU] != NULL) + { + DestroyWindow(MemView_Data[CPU]->hDlg); + delete MemView_Data[CPU]; + MemView_Data[CPU] = NULL; + } +} + +BOOL MemView_IsOpened(u8 CPU) +{ + return (MemView_Data[CPU] != NULL); +} + +void MemView_Refresh(u8 CPU) +{ + InvalidateRect(MemView_Data[CPU]->hDlg, NULL, FALSE); + UpdateWindow(MemView_Data[CPU]->hDlg); +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT MemView_DlgPaint(HWND hDlg, MemView_DataStruct *data, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + + hdc = BeginPaint(hDlg, &ps); + + EndPaint(hDlg, &ps); + + return 0; +} + +BOOL CALLBACK MemView_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + MemView_DataStruct *data = (MemView_DataStruct*)GetWindowLong(hDlg, DWL_USER); + if((data == NULL) && (uMsg != WM_INITDIALOG)) + return 0; + + switch(uMsg) + { + case WM_INITDIALOG: + { + if(data == NULL) + { + data = (MemView_DataStruct*)lParam; + SetWindowLong(hDlg, DWL_USER, (LONG)data); + } + + CheckRadioButton(hDlg, IDC_8_BIT, IDC_32_BIT, IDC_8_BIT); + + SendMessage(GetDlgItem(hDlg, IDC_ADDRESS), EM_SETLIMITTEXT, 8, 0); + SetWindowText(GetDlgItem(hDlg, IDC_ADDRESS), "02000000"); + + SetWindowLong(GetDlgItem(hDlg, IDC_MEMVIEWBOX), DWL_USER, (LONG)data); + + InvalidateRect(hDlg, NULL, FALSE); UpdateWindow(hDlg); + } + return 1; + + case WM_CLOSE: + case WM_DESTROY: + MemView_DlgClose(data->cpu); + return 1; + + case WM_PAINT: + MemView_DlgPaint(hDlg, data, wParam, lParam); + return 1; + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDCANCEL: + MemView_DlgClose(data->cpu); + return 1; + + case IDC_8_BIT: + case IDC_16_BIT: + case IDC_32_BIT: + data->sel = FALSE; + data->selAddress = 0x00000000; + data->selPart = 0; + data->selNewVal = 0x00000000; + CheckRadioButton(hDlg, IDC_8_BIT, IDC_32_BIT, LOWORD(wParam)); + data->viewMode = (LOWORD(wParam) - IDC_8_BIT); + InvalidateRect(hDlg, NULL, FALSE); UpdateWindow(hDlg); + return 1; + + case IDC_GO: + { + char addrstr[9]; + int len; + int i; + int shift; + BOOL error = FALSE; + u32 address = 0x00000000; + + len = GetWindowText(GetDlgItem(hDlg, IDC_ADDRESS), addrstr, 9); + + for(i = 0; i < len; i++) + { + char ch = addrstr[i]; + + if((ch >= '0') && (ch <= '9')) + continue; + + if((ch >= 'A') && (ch <= 'F')) + continue; + + if((ch >= 'a') && (ch <= 'f')) + continue; + + if(ch == '\0') + break; + + error = TRUE; + break; + } + + if(error) + { + MessageBox(hDlg, "Error:\nInvalid address specified.\nThe address must be an hexadecimal value.", "DeSmuME", (MB_OK | MB_ICONERROR)); + SetWindowText(GetDlgItem(hDlg, IDC_ADDRESS), ""); + return 1; + } + + for(i = (len-1), shift = 0; i >= 0; i--, shift += 4) + { + char ch = addrstr[i]; + + if((ch >= '0') && (ch <= '9')) + address |= ((ch - '0') << shift); + else if((ch >= 'A') && (ch <= 'F')) + address |= ((ch - 'A' + 0xA) << shift); + else if((ch >= 'a') && (ch <= 'f')) + address |= ((ch - 'a' + 0xA) << shift); + } + + data->sel = FALSE; + data->selAddress = 0x00000000; + data->selPart = 0; + data->selNewVal = 0x00000000; + + data->address = min((u32)0xFFFFFF00, (address & 0xFFFFFFF0)); + SetScrollPos(GetDlgItem(hDlg, IDC_MEMVIEWBOX), SB_VERT, ((data->address >> 4) & 0x000FFFFF), TRUE); + InvalidateRect(hDlg, NULL, FALSE); UpdateWindow(hDlg); + } + return 1; + + case IDC_TEXTDUMP: + { + char fileName[256] = ""; + OPENFILENAME ofn; + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hDlg; + ofn.lpstrFilter = "Text file (*.txt)\0*.txt\0Any file (*.*)\0*.*\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = fileName; + ofn.nMaxFile = 256; + ofn.lpstrDefExt = "txt"; + ofn.Flags = OFN_NOCHANGEDIR | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; + + if(GetSaveFileName(&ofn)) + { + FILE *f; + u8 memory[0x100]; + int line; + + MMU_DumpMemBlock(data->cpu, data->address, 0x100, memory); + + f = fopen(fileName, "a"); + + for(line = 0; line < 16; line++) + { + int i; + + fprintf(f, "%08X\t\t", (data->address + (line << 4))); + + switch(data->viewMode) + { + case 0: + { + for(i = 0; i < 16; i++) + { + fprintf(f, "%02X ", T1ReadByte(memory, ((line << 4) + i))); + } + fprintf(f, "\t"); + } + break; + + case 1: + { + for(i = 0; i < 16; i += 2) + { + fprintf(f, "%04X ", T1ReadWord(memory, ((line << 4) + i))); + } + fprintf(f, "\t\t"); + } + break; + + case 2: + { + for(i = 0; i < 16; i += 4) + { + fprintf(f, "%08X ", T1ReadLong(memory, ((line << 4) + i))); + } + fprintf(f, "\t\t\t"); + } + break; + } + + for(i = 0; i < 16; i++) + { + u8 val = T1ReadByte(memory, ((line << 4) + i)); + + if((val >= 32) && (val <= 127)) + fprintf(f, "%c", (char)val); + else + fprintf(f, "."); + } + fprintf(f, "\n"); + } + + fclose(f); + } + } + return 1; + + case IDC_RAWDUMP: + { + char fileName[256] = ""; + OPENFILENAME ofn; + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hDlg; + ofn.lpstrFilter = "Binary file (*.bin)\0*.bin\0Any file (*.*)\0*.*\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = fileName; + ofn.nMaxFile = 256; + ofn.lpstrDefExt = "bin"; + ofn.Flags = OFN_NOCHANGEDIR | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; + + if(GetSaveFileName(&ofn)) + { + FILE *f; + u8 memory[0x100]; + int line; + + MMU_DumpMemBlock(data->cpu, data->address, 0x100, memory); + + f = fopen(fileName, "ab"); + + fwrite(memory, 0x100, 1, f); + + fclose(f); + } + } + return 1; + } + return 0; + } + + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT MemView_ViewBoxPaint(HWND hCtl, MemView_DataStruct *data, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + RECT rc; + int w, h; + SIZE fontsize; + int fontwidth, fontheight; + HDC mem_hdc; + HBITMAP mem_bmp; + + GetClientRect(hCtl, &rc); + w = (rc.right - rc.left); + h = (rc.bottom - rc.top); + + hdc = BeginPaint(hCtl, &ps); + + mem_hdc = CreateCompatibleDC(hdc); + mem_bmp = CreateCompatibleBitmap(hdc, w, h); + SelectObject(mem_hdc, mem_bmp); + + SelectObject(mem_hdc, GetStockObject(SYSTEM_FIXED_FONT)); + + SetBkMode(mem_hdc, OPAQUE); + SetBkColor(mem_hdc, RGB(255, 255, 255)); + SetTextColor(mem_hdc, RGB(0, 0, 0)); + + GetTextExtentPoint32(mem_hdc, " ", 1, &fontsize); + fontwidth = fontsize.cx; + fontheight = fontsize.cy; + + FillRect(mem_hdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + if(data != NULL) + { + u32 addr = data->address; + u8 memory[0x100]; + char text[80]; + int startx; + int curx, cury; + int line; + + startx = 0; + curx = 0; + cury = 0; + + startx = ((fontwidth * 8) + 5); + cury = (fontheight + 3); + + MoveToEx(mem_hdc, ((fontwidth * 8) + 2), 0, NULL); + LineTo(mem_hdc, ((fontwidth * 8) + 2), h); + + MoveToEx(mem_hdc, 0, (fontheight + 1), NULL); + LineTo(mem_hdc, w, (fontheight + 1)); + + switch(data->viewMode) + { + case 0: + { + sprintf(text, " 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"); + TextOut(mem_hdc, startx, 0, text, strlen(text)); + } + break; + + case 1: + { + sprintf(text, " 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"); + TextOut(mem_hdc, startx, 0, text, strlen(text)); + } + break; + + case 2: + { + sprintf(text, " 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF"); + TextOut(mem_hdc, startx, 0, text, strlen(text)); + } + break; + } + + MMU_DumpMemBlock(data->cpu, data->address, 0x100, memory); + + for(line = 0; line < 16; line++, addr += 0x10) + { + int i; + + sprintf(text, "%08X", addr); + TextOut(mem_hdc, 0, cury, text, strlen(text)); + + curx = startx; + + switch(data->viewMode) + { + case 0: + { + curx += (fontwidth * 2); + for(i = 0; i < 16; i++) + { + u8 val = T1ReadByte(memory, ((line << 4) + i)); + if(data->sel && (data->selAddress == (addr + i))) + { + SetBkColor(mem_hdc, GetSysColor(COLOR_HIGHLIGHT)); + SetTextColor(mem_hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); + + switch(data->selPart) + { + case 0: sprintf(text, "%02X", val); break; + case 1: sprintf(text, "%01X.", data->selNewVal); break; + } + } + else + { + SetBkColor(mem_hdc, RGB(255, 255, 255)); + SetTextColor(mem_hdc, RGB(0, 0, 0)); + + sprintf(text, "%02X", val); + } + + TextOut(mem_hdc, curx, cury, text, strlen(text)); + curx += (fontwidth * (2+1)); + } + curx += (fontwidth * 2); + } + break; + + case 1: + { + curx += (fontwidth * 6); + for(i = 0; i < 16; i += 2) + { + u16 val = T1ReadWord(memory, ((line << 4) + i)); + if(data->sel && (data->selAddress == (addr + i))) + { + SetBkColor(mem_hdc, GetSysColor(COLOR_HIGHLIGHT)); + SetTextColor(mem_hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); + + switch(data->selPart) + { + case 0: sprintf(text, "%04X", val); break; + case 1: sprintf(text, "%01X...", data->selNewVal); break; + case 2: sprintf(text, "%02X..", data->selNewVal); break; + case 3: sprintf(text, "%03X.", data->selNewVal); break; + } + } + else + { + SetBkColor(mem_hdc, RGB(255, 255, 255)); + SetTextColor(mem_hdc, RGB(0, 0, 0)); + + sprintf(text, "%04X", val); + } + + TextOut(mem_hdc, curx, cury, text, strlen(text)); + curx += (fontwidth * (4+1)); + } + curx += (fontwidth * 6); + } + break; + + case 2: + { + curx += (fontwidth * 8); + for(i = 0; i < 16; i += 4) + { + u32 val = T1ReadLong(memory, ((line << 4) + i)); + if(data->sel && (data->selAddress == (addr + i))) + { + SetBkColor(mem_hdc, GetSysColor(COLOR_HIGHLIGHT)); + SetTextColor(mem_hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); + + switch(data->selPart) + { + case 0: sprintf(text, "%08X", val); break; + case 1: sprintf(text, "%01X.......", data->selNewVal); break; + case 2: sprintf(text, "%02X......", data->selNewVal); break; + case 3: sprintf(text, "%03X.....", data->selNewVal); break; + case 4: sprintf(text, "%04X....", data->selNewVal); break; + case 5: sprintf(text, "%05X...", data->selNewVal); break; + case 6: sprintf(text, "%06X..", data->selNewVal); break; + case 7: sprintf(text, "%07X.", data->selNewVal); break; + } + } + else + { + SetBkColor(mem_hdc, RGB(255, 255, 255)); + SetTextColor(mem_hdc, RGB(0, 0, 0)); + + sprintf(text, "%08X", val); + } + + TextOut(mem_hdc, curx, cury, text, strlen(text)); + curx += (fontwidth * (8+1)); + } + curx += (fontwidth * 8); + } + break; + } + + SetBkColor(mem_hdc, RGB(255, 255, 255)); + SetTextColor(mem_hdc, RGB(0, 0, 0)); + + for(i = 0; i < 16; i++) + { + u8 val = T1ReadByte(memory, ((line << 4) + i)); + + if((val >= 32) && (val <= 127)) + text[i] = (char)val; + else + text[i] = '.'; + } + text[16] = '\0'; + TextOut(mem_hdc, curx, cury, text, strlen(text)); + + cury += fontheight; + } + } + + BitBlt(hdc, 0, 0, w, h, mem_hdc, 0, 0, SRCCOPY); + + DeleteDC(mem_hdc); + DeleteObject(mem_bmp); + + EndPaint(hCtl, &ps); + + return 0; +} + +LRESULT CALLBACK MemView_ViewBoxProc(HWND hCtl, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + MemView_DataStruct *data = (MemView_DataStruct*)GetWindowLong(hCtl, DWL_USER); + + switch(uMsg) + { + case WM_NCCREATE: + SetScrollRange(hCtl, SB_VERT, 0x00000000, 0x000FFFF0, TRUE); + SetScrollPos(hCtl, SB_VERT, 0x00000000, TRUE); + return 1; + + case WM_NCDESTROY: + return 1; + + case WM_ERASEBKGND: + return 1; + + case WM_PAINT: + MemView_ViewBoxPaint(hCtl, data, wParam, lParam); + return 1; + + case WM_LBUTTONDOWN: + { + HDC hdc; + HFONT font; + SIZE fontsize; + int x, y; + + data->sel = FALSE; + data->selAddress = 0x00000000; + data->selPart = 0; + data->selNewVal = 0x00000000; + + hdc = GetDC(hCtl); + font = (HFONT)SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT)); + GetTextExtentPoint32(hdc, " ", 1, &fontsize); + + x = LOWORD(lParam); + y = HIWORD(lParam); + + if((x >= ((fontsize.cx * 8) + 5)) && (y >= (fontsize.cy + 3))) + { + int line, col; + + x -= ((fontsize.cx * 8) + 5); + y -= (fontsize.cy + 3); + + line = (y / fontsize.cy); + + switch(data->viewMode) + { + case 0: + { + if((x < (fontsize.cx * 2)) || (x >= (fontsize.cx * (2 + ((2+1) * 16))))) + break; + + col = ((x - (fontsize.cx * 2)) / (fontsize.cx * (2+1))); + + data->sel = TRUE; + + } + break; + + case 1: + { + if((x < (fontsize.cx * 6)) || (x >= (fontsize.cx * (6 + ((4+1) * 8))))) + break; + + col = ((x - (fontsize.cx * 6)) / (fontsize.cx * (4+1)) * 2); + + data->sel = TRUE; + + } + break; + + case 2: + { + if((x < (fontsize.cx * 8)) || (x >= (fontsize.cx * (8 + ((8+1) * 4))))) + break; + + col = ((x - (fontsize.cx * 8)) / (fontsize.cx * (8+1)) * 4); + + data->sel = TRUE; + + } + break; + } + + data->selAddress = (data->address + (line << 4) + col); + data->selPart = 0; + data->selNewVal = 0x00000000; + } + + SelectObject(hdc, font); + ReleaseDC(hCtl, hdc); + + SetFocus(hCtl); /* Required to receive keyboard messages */ + InvalidateRect(hCtl, NULL, FALSE); UpdateWindow(hCtl); + } + return 1; + + case WM_CHAR: + { + char ch = (char)wParam; + + if(((ch >= '0') && (ch <= '9')) || ((ch >= 'A') && (ch <= 'F')) || ((ch >= 'a') && (ch <= 'f'))) + { + u8 maxSelPart[3] = {2, 4, 8}; + + data->selNewVal <<= 4; + data->selPart++; + + if((ch >= '0') && (ch <= '9')) + data->selNewVal |= (ch - '0'); + else if((ch >= 'A') && (ch <= 'F')) + data->selNewVal |= (ch - 'A' + 0xA); + else if((ch >= 'a') && (ch <= 'f')) + data->selNewVal |= (ch - 'a' + 0xA); + + if(data->selPart >= maxSelPart[data->viewMode]) + { + switch(data->viewMode) + { + case 0: MMU_write8(data->cpu, data->selAddress, (u8)data->selNewVal); data->selAddress++; break; + case 1: MMU_write16(data->cpu, data->selAddress, (u16)data->selNewVal); data->selAddress += 2; break; + case 2: MMU_write32(data->cpu, data->selAddress, data->selNewVal); data->selAddress += 4; break; + } + data->selPart = 0; + data->selNewVal = 0x00000000; + + if(data->selAddress == 0x00000000) + { + data->sel = FALSE; + } + else if(data->selAddress >= (data->address + 0x100)) + { + data->address = min((u32)0xFFFFFF00, (data->address + 0x10)); + SetScrollPos(hCtl, SB_VERT, ((data->address >> 4) & 0x000FFFFF), TRUE); + } + } + } + + InvalidateRect(hCtl, NULL, FALSE); UpdateWindow(hCtl); + } + return 1; + + case WM_VSCROLL: + { + int firstpos = GetScrollPos(hCtl, SB_VERT); + + switch(LOWORD(wParam)) + { + case SB_LINEUP: + data->address = (u32)max(0x00000000, ((int)data->address - 0x10)); + break; + + case SB_LINEDOWN: + data->address = min((u32)0xFFFFFF00, (data->address + 0x10)); + break; + + case SB_PAGEUP: + data->address = (u32)max(0x00000000, ((int)data->address - 0x100)); + break; + + case SB_PAGEDOWN: + data->address = min((u32)0xFFFFFF00, (data->address + 0x100)); + break; + + case SB_THUMBTRACK: + case SB_THUMBPOSITION: + { + SCROLLINFO si; + + ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SIF_TRACKPOS; + + GetScrollInfo(hCtl, SB_VERT, &si); + + data->address = min((u32)0xFFFFFF00, (data->address + ((si.nTrackPos - firstpos) * 16))); + } + break; + } + + if((data->selAddress < data->address) || (data->selAddress >= (data->address + 0x100))) + { + data->sel = FALSE; + data->selAddress = 0x00000000; + data->selPart = 0; + data->selNewVal = 0x00000000; + } + + SetScrollPos(hCtl, SB_VERT, ((data->address >> 4) & 0x000FFFFF), TRUE); + InvalidateRect(hCtl, NULL, FALSE); UpdateWindow(hCtl); + } + return 1; + } + + return DefWindowProc(hCtl, uMsg, wParam, lParam); +} + +////////////////////////////////////////////////////////////////////////////// diff --git a/desmume/src/windows/memView.h b/src/windows/memView.h similarity index 96% rename from desmume/src/windows/memView.h rename to src/windows/memView.h index d324dc05b..97e61bcc0 100644 --- a/desmume/src/windows/memView.h +++ b/src/windows/memView.h @@ -1,36 +1,36 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef MEM_VIEW_H -#define MEM_VIEW_H - -BOOL MemView_Init(); -void MemView_DeInit(); - -BOOL MemView_DlgOpen(HWND hParentWnd, char *Title, u8 CPU); -void MemView_DlgClose(u8 CPU); -BOOL MemView_IsOpened(u8 CPU); -void MemView_Refresh(u8 CPU); - -BOOL CALLBACK MemView_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -LRESULT CALLBACK MemView_ViewBoxProc(HWND hCtl, UINT uMsg, WPARAM wParam, LPARAM lParam); - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef MEM_VIEW_H +#define MEM_VIEW_H + +BOOL MemView_Init(); +void MemView_DeInit(); + +BOOL MemView_DlgOpen(HWND hParentWnd, char *Title, u8 CPU); +void MemView_DlgClose(u8 CPU); +BOOL MemView_IsOpened(u8 CPU); +void MemView_Refresh(u8 CPU); + +BOOL CALLBACK MemView_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK MemView_ViewBoxProc(HWND hCtl, UINT uMsg, WPARAM wParam, LPARAM lParam); + #endif \ No newline at end of file diff --git a/desmume/src/windows/mic.cpp b/src/windows/mic.cpp similarity index 94% rename from desmume/src/windows/mic.cpp rename to src/windows/mic.cpp index 319583293..33c2ae32f 100644 --- a/desmume/src/windows/mic.cpp +++ b/src/windows/mic.cpp @@ -1,221 +1,221 @@ -/* - Microphone emulation for Win32 - - The NDS microphone produces 8-bit sound sampled at 16khz. - The sound data must be read sample-by-sample through the - ARM7 SPI device (touchscreen controller, channel 6). - - Note : I added these notes because the microphone isn't - documented on GBATek. -*/ -#include -#include "../types.h" -#include "../debug.h" -#include "../mic.h" -#include -#include - -int MicDisplay; -int MicButtonPressed=0; -int SampleLoaded=0; - -#define MIC_CHECKERR(hr) if(hr != MMSYSERR_NOERROR) return FALSE; - -#define MIC_BUFSIZE 4096 - -static BOOL Mic_Inited = FALSE; - -static u8 Mic_TempBuf[MIC_BUFSIZE]; -static u8 Mic_Buffer[2][MIC_BUFSIZE]; -static u16 Mic_BufPos; -static u8 Mic_WriteBuf; -static u8 Mic_PlayBuf; - -static HWAVEIN waveIn; -static WAVEHDR waveHdr; - -static int CALLBACK waveInProc(HWAVEIN wavein, UINT msg, DWORD instance, DWORD param1, DWORD param2) -{ - LPWAVEHDR lpWaveHdr; - HRESULT hr; - - if(!Mic_Inited) - return 1; - - if(msg == WIM_DATA) - { - lpWaveHdr = (LPWAVEHDR)param1; - - memcpy(Mic_Buffer[Mic_WriteBuf], lpWaveHdr->lpData, MIC_BUFSIZE); - Mic_WriteBuf ^= 1; - - hr = waveInAddBuffer(waveIn, lpWaveHdr, sizeof(WAVEHDR)); - if(hr != MMSYSERR_NOERROR) - return 1; - } - - return 0; -} - -static char* samplebuffer = NULL; -static int samplebuffersize = 0; -static FILE* fp = NULL; - -bool LoadSample(const char *name) -{ - std::ifstream fl(name); - - if (!fl.is_open()) - { - return false; - } - - fl.seekg( 0, std::ios::end ); - size_t len = fl.tellg(); - - // Avoid mem leaks - if (samplebuffer != NULL) - delete[] samplebuffer; - - samplebuffersize = len; - samplebuffer = new char[len]; - - fl.seekg(0, std::ios::beg); - fl.read (samplebuffer, len); - fl.close(); - - SampleLoaded=1; - - return true; -} - -BOOL Mic_Init() { - - if(Mic_Inited) - return TRUE; - - Mic_Inited = FALSE; - - HRESULT hr; - WAVEFORMATEX wfx; - - memset(Mic_TempBuf, 0, MIC_BUFSIZE); - memset(Mic_Buffer[0], 0, MIC_BUFSIZE); - memset(Mic_Buffer[1], 0, MIC_BUFSIZE); - Mic_BufPos = 0; - - Mic_WriteBuf = 0; - Mic_PlayBuf = 1; - - memset(&wfx, 0, sizeof(wfx)); - wfx.cbSize = 0; - wfx.wFormatTag = WAVE_FORMAT_PCM; - wfx.nChannels = 1; - wfx.nSamplesPerSec = 16000; - wfx.nBlockAlign = 1; - wfx.nAvgBytesPerSec = 16000; - wfx.wBitsPerSample = 8; - - hr = waveInOpen(&waveIn, WAVE_MAPPER, &wfx, (DWORD_PTR)waveInProc, 0, CALLBACK_FUNCTION); - MIC_CHECKERR(hr) - - memset(&waveHdr, 0, sizeof(waveHdr)); - waveHdr.lpData = (LPSTR)Mic_TempBuf; - waveHdr.dwBufferLength = MIC_BUFSIZE; - - hr = waveInPrepareHeader(waveIn, &waveHdr, sizeof(WAVEHDR)); - MIC_CHECKERR(hr) - - hr = waveInAddBuffer(waveIn, &waveHdr, sizeof(WAVEHDR)); - MIC_CHECKERR(hr) - - hr = waveInStart(waveIn); - MIC_CHECKERR(hr) - - Mic_Inited = TRUE; - return TRUE; -} - -void Mic_Reset() -{ - if(!Mic_Inited) - return; - - memset(Mic_TempBuf, 0, MIC_BUFSIZE); - memset(Mic_Buffer[0], 0, MIC_BUFSIZE); - memset(Mic_Buffer[1], 0, MIC_BUFSIZE); - Mic_BufPos = 0; - - Mic_WriteBuf = 0; - Mic_PlayBuf = 1; -} - -void Mic_DeInit() -{ - if(!Mic_Inited) - return; - - Mic_Inited = FALSE; - - waveInReset(waveIn); - waveInClose(waveIn); -} - -static const int random[32] = {0xB1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE9, 0x70, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x28, 0x00, 0x00, 0x00, -0x00, 0x00, 0x20, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE9}; - -static int x=0; - -u8 Mic_ReadSample() -{ - - if(!Mic_Inited) - return 0; - - u8 ret; - u8 tmp; - if(MicButtonPressed) { - if(SampleLoaded) { - //use a sample - tmp = samplebuffer[x >> 1]; - x++; - if(x == samplebuffersize*2) - x=0; - } else { - //use the "random" values - tmp = random[x >> 1]; - //tmp = rand()&0xFF; - x++; - if(x == ARRAY_SIZE(random)*2) - x=0; - } - } - else { - //normal mic behavior - tmp = (u8)Mic_Buffer[Mic_PlayBuf][Mic_BufPos >> 1]; - - //reset mic button buffer pos if not pressed - x=0; - } - - if(Mic_BufPos & 0x1) - { - ret = ((tmp & 0x1) << 7); - } - else - { - ret = ((tmp & 0xFE) >> 1); - } - - MicDisplay = tmp; - - Mic_BufPos++; - if(Mic_BufPos >= (MIC_BUFSIZE << 1)) - { - Mic_BufPos = 0; - Mic_PlayBuf ^= 1; - } - - return ret; +/* + Microphone emulation for Win32 + + The NDS microphone produces 8-bit sound sampled at 16khz. + The sound data must be read sample-by-sample through the + ARM7 SPI device (touchscreen controller, channel 6). + + Note : I added these notes because the microphone isn't + documented on GBATek. +*/ +#include +#include "../types.h" +#include "../debug.h" +#include "../mic.h" +#include +#include + +int MicDisplay; +int MicButtonPressed=0; +int SampleLoaded=0; + +#define MIC_CHECKERR(hr) if(hr != MMSYSERR_NOERROR) return FALSE; + +#define MIC_BUFSIZE 4096 + +static BOOL Mic_Inited = FALSE; + +static u8 Mic_TempBuf[MIC_BUFSIZE]; +static u8 Mic_Buffer[2][MIC_BUFSIZE]; +static u16 Mic_BufPos; +static u8 Mic_WriteBuf; +static u8 Mic_PlayBuf; + +static HWAVEIN waveIn; +static WAVEHDR waveHdr; + +static int CALLBACK waveInProc(HWAVEIN wavein, UINT msg, DWORD instance, DWORD param1, DWORD param2) +{ + LPWAVEHDR lpWaveHdr; + HRESULT hr; + + if(!Mic_Inited) + return 1; + + if(msg == WIM_DATA) + { + lpWaveHdr = (LPWAVEHDR)param1; + + memcpy(Mic_Buffer[Mic_WriteBuf], lpWaveHdr->lpData, MIC_BUFSIZE); + Mic_WriteBuf ^= 1; + + hr = waveInAddBuffer(waveIn, lpWaveHdr, sizeof(WAVEHDR)); + if(hr != MMSYSERR_NOERROR) + return 1; + } + + return 0; +} + +static char* samplebuffer = NULL; +static int samplebuffersize = 0; +static FILE* fp = NULL; + +bool LoadSample(const char *name) +{ + std::ifstream fl(name); + + if (!fl.is_open()) + { + return false; + } + + fl.seekg( 0, std::ios::end ); + size_t len = fl.tellg(); + + // Avoid mem leaks + if (samplebuffer != NULL) + delete[] samplebuffer; + + samplebuffersize = len; + samplebuffer = new char[len]; + + fl.seekg(0, std::ios::beg); + fl.read (samplebuffer, len); + fl.close(); + + SampleLoaded=1; + + return true; +} + +BOOL Mic_Init() { + + if(Mic_Inited) + return TRUE; + + Mic_Inited = FALSE; + + HRESULT hr; + WAVEFORMATEX wfx; + + memset(Mic_TempBuf, 0, MIC_BUFSIZE); + memset(Mic_Buffer[0], 0, MIC_BUFSIZE); + memset(Mic_Buffer[1], 0, MIC_BUFSIZE); + Mic_BufPos = 0; + + Mic_WriteBuf = 0; + Mic_PlayBuf = 1; + + memset(&wfx, 0, sizeof(wfx)); + wfx.cbSize = 0; + wfx.wFormatTag = WAVE_FORMAT_PCM; + wfx.nChannels = 1; + wfx.nSamplesPerSec = 16000; + wfx.nBlockAlign = 1; + wfx.nAvgBytesPerSec = 16000; + wfx.wBitsPerSample = 8; + + hr = waveInOpen(&waveIn, WAVE_MAPPER, &wfx, (DWORD_PTR)waveInProc, 0, CALLBACK_FUNCTION); + MIC_CHECKERR(hr) + + memset(&waveHdr, 0, sizeof(waveHdr)); + waveHdr.lpData = (LPSTR)Mic_TempBuf; + waveHdr.dwBufferLength = MIC_BUFSIZE; + + hr = waveInPrepareHeader(waveIn, &waveHdr, sizeof(WAVEHDR)); + MIC_CHECKERR(hr) + + hr = waveInAddBuffer(waveIn, &waveHdr, sizeof(WAVEHDR)); + MIC_CHECKERR(hr) + + hr = waveInStart(waveIn); + MIC_CHECKERR(hr) + + Mic_Inited = TRUE; + return TRUE; +} + +void Mic_Reset() +{ + if(!Mic_Inited) + return; + + memset(Mic_TempBuf, 0, MIC_BUFSIZE); + memset(Mic_Buffer[0], 0, MIC_BUFSIZE); + memset(Mic_Buffer[1], 0, MIC_BUFSIZE); + Mic_BufPos = 0; + + Mic_WriteBuf = 0; + Mic_PlayBuf = 1; +} + +void Mic_DeInit() +{ + if(!Mic_Inited) + return; + + Mic_Inited = FALSE; + + waveInReset(waveIn); + waveInClose(waveIn); +} + +static const int random[32] = {0xB1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE9, 0x70, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x28, 0x00, 0x00, 0x00, +0x00, 0x00, 0x20, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE9}; + +static int x=0; + +u8 Mic_ReadSample() +{ + + if(!Mic_Inited) + return 0; + + u8 ret; + u8 tmp; + if(MicButtonPressed) { + if(SampleLoaded) { + //use a sample + tmp = samplebuffer[x >> 1]; + x++; + if(x == samplebuffersize*2) + x=0; + } else { + //use the "random" values + tmp = random[x >> 1]; + //tmp = rand()&0xFF; + x++; + if(x == ARRAY_SIZE(random)*2) + x=0; + } + } + else { + //normal mic behavior + tmp = (u8)Mic_Buffer[Mic_PlayBuf][Mic_BufPos >> 1]; + + //reset mic button buffer pos if not pressed + x=0; + } + + if(Mic_BufPos & 0x1) + { + ret = ((tmp & 0x1) << 7); + } + else + { + ret = ((tmp & 0xFE) >> 1); + } + + MicDisplay = tmp; + + Mic_BufPos++; + if(Mic_BufPos >= (MIC_BUFSIZE << 1)) + { + Mic_BufPos = 0; + Mic_PlayBuf ^= 1; + } + + return ret; } \ No newline at end of file diff --git a/desmume/src/windows/oamView.cpp b/src/windows/oamView.cpp similarity index 96% rename from desmume/src/windows/oamView.cpp rename to src/windows/oamView.cpp index 1d592d35a..9603d1d18 100644 --- a/desmume/src/windows/oamView.cpp +++ b/src/windows/oamView.cpp @@ -1,348 +1,348 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "oamView.h" -#include -#include "debug.h" -#include "resource.h" -#include "../MMU.h" -#include "../GPU.h" -#include "../NDSSystem.h" -#include "windriver.h" - -typedef struct -{ - u32 autoup_secs; - bool autoup; - - s16 num; - OAM *oam; - GPU *gpu; -} oamview_struct; - -oamview_struct *OAMView = NULL; - -const char dimm[4][4][8] = -{ - {"8 x 8", "16 x 8", "8 x 16", "- x -"}, - {"16 x 16", "32 x 8", "8 x 32", "- x -"}, - {"32 x 32", "32 x 16", "16 x 32", "- x -"}, - {"64 x 64", "64 x 32", "32 x 64", "- x -"}, -}; - -LRESULT OAMViewBox_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - Lock lock; - - //HWND hwnd = GetDlgItem(win->hwnd, IDC_OAM_BOX); - HDC hdc; - PAINTSTRUCT ps; -// TCHAR text[80]; - RECT rect; - int lg; - int ht; - HDC mem_dc; - HBITMAP mem_bmp; - - GetClientRect(hwnd, &rect); - lg = rect.right - rect.left; - ht = rect.bottom - rect.top; - - hdc = BeginPaint(hwnd, &ps); - - mem_dc = CreateCompatibleDC(hdc); - mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); - SelectObject(mem_dc, mem_bmp); - - FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); - - DeleteDC(mem_dc); - DeleteObject(mem_bmp); - - EndPaint(hwnd, &ps); - - return 0; -} - -LRESULT OamView_OnPaint(HWND hwnd, oamview_struct *win, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - OAM * oam = &win->oam[win->num]; - char text[80]; - u16 bitmap[256*192]; - u8 bitmap_alpha[256*192]; - u8 type[256*192]; - u8 prio[256*192]; - BITMAPV4HEADER bmi; - u16 i; - s16 x; - - //CreateBitmapIndirect(&bmi); - memset(&bmi, 0, sizeof(bmi)); - bmi.bV4Size = sizeof(bmi); - bmi.bV4Planes = 1; - bmi.bV4BitCount = 16; - bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS; - bmi.bV4RedMask = 0x001F; - bmi.bV4GreenMask = 0x03E0; - bmi.bV4BlueMask = 0x7C00; - bmi.bV4Width = 256; - bmi.bV4Height = -192; - - for(i = 0; i < 256*192; ++i) - { - bitmap[i] = 0x7F0F; - bitmap_alpha[i] = 0; - type[i] = 0; - prio[i] = 4; - } - - hdc = BeginPaint(hwnd, &ps); - - sprintf(text, "OAM : %d", win->num); - SetWindowText(GetDlgItem(hwnd, IDC_OAMNUM), text); - - switch(oam->attr0&(3<<10)) - { - case 0 : - SetWindowText(GetDlgItem(hwnd, IDC_MODE), "Normal"); - break; - case (1<<10) : - SetWindowText(GetDlgItem(hwnd, IDC_MODE), "Smi-transp"); - break; - case (2<<10) : - SetWindowText(GetDlgItem(hwnd, IDC_MODE), "OBJ Window"); - break; - case (3<<10) : - SetWindowText(GetDlgItem(hwnd, IDC_MODE), "Bitmap"); - } - - sprintf(text, "0x%08X", oam->attr0/*oam->attr2&0x3FF*/); - SetWindowText(GetDlgItem(hwnd, IDC_TILE), text); - - sprintf(text, "0x%08X", oam->attr1/*oam->attr2&0x3FF*/); - SetWindowText(GetDlgItem(hwnd, IDC_PAL), text); - - //SetWindowText(GetDlgItem(hwnd, IDC_PAL), (oam->attr0&(1<<13))?"256 couleurs": "16 couleurs"); - - sprintf(text, "%d 0x%08X", (oam->attr2>>10)&3, oam->attr2); - SetWindowText(GetDlgItem(hwnd, IDC_PRIO), text); - - x = oam->attr1&0x1FF; - x = ((s16)(x<<7)>>7); - sprintf(text, "%d x %d", x, oam->attr0&0xFF); - SetWindowText(GetDlgItem(hwnd, IDC_COOR), text); - - SetWindowText(GetDlgItem(hwnd, IDC_DIM), dimm[oam->attr1>>14][oam->attr0>>14]); - - SetWindowText(GetDlgItem(hwnd, IDC_ROT), oam->attr0&(1<<8)?"ON" : "OFF"); - - SetWindowText(GetDlgItem(hwnd, IDC_MOS), oam->attr0&(1<<12)?"ON" : "OFF"); - - if(oam->attr0&(1<<8)) - { - sprintf(text, "Rot param : %d", (oam->attr1>>9)&0x1F); - SetWindowText(GetDlgItem(hwnd, IDC_PROP0), text); - - SetWindowText(GetDlgItem(hwnd, IDC_PROP1), (oam->attr0&(1<<9))?"Double size": ""); - } - else - { - if(oam->attr0&(1<<9)) - sprintf(text, "INVISIBLE"); - else - sprintf(text, "%s %s", oam->attr0&(1<<12)?"H FLIP":"", oam->attr0&(1<<13)?"V FLIP":""); - - SetWindowText(GetDlgItem(hwnd, IDC_PROP0), text); - - SetWindowText(GetDlgItem(hwnd, IDC_PROP1), ""); - } - - GPU copy = *win->gpu; - for(i = 0; i < 192; ++i) - { - copy.currLine = i; - copy.spriteRender((u8*)(bitmap + i*256), bitmap_alpha + i*256, type + i*256, prio + i*256); - } - - SetDIBitsToDevice(hdc, 180, 4, 256, 192, 0, 0, 0, 192, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); - - EndPaint(hwnd, &ps); - - return 0; -} - -LRESULT CALLBACK ViewOAMBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_NCCREATE: - return 1; - case WM_NCDESTROY: - return 1; - case WM_PAINT: - OAMViewBox_OnPaint(hwnd, wParam, lParam); - return 1; - case WM_ERASEBKGND: - return 1; - default: - break; - } - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -BOOL CALLBACK ViewOAMProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - //bail out early if the dialog isnt initialized - if(!OAMView && message != WM_INITDIALOG) - return false; - - switch (message) - { - case WM_INITDIALOG : - { - OAMView = new oamview_struct; - memset(OAMView, 0, sizeof(oamview_struct)); - OAMView->oam = (OAM *)(MMU.ARM9_OAM); - OAMView->gpu = MainScreen.gpu; - - OAMView->autoup_secs = 1; - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETRANGE, 0, MAKELONG(99, 1)); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETPOS32, 0, OAMView->autoup_secs); - - HWND combo = GetDlgItem(hwnd, IDC_SCR_SELECT); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen sprite"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen sprite"); - SendMessage(combo, CB_SETCURSEL, 0, 0); - } - return 1; - case WM_CLOSE : - { - if(OAMView->autoup) - { - KillTimer(hwnd, IDT_VIEW_OAM); - OAMView->autoup = false; - } - - if (OAMView!=NULL) - { - delete OAMView; - OAMView = NULL; - } - //INFO("Close OAM viewer dialog\n"); - PostQuitMessage(0); - return 0; - } - case WM_PAINT: - OamView_OnPaint(hwnd, OAMView, wParam, lParam); - return 1; - case WM_TIMER: - SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); - return 1; - case WM_HSCROLL : - switch LOWORD(wParam) - { - case SB_LINERIGHT : - ++(OAMView->num); - if(OAMView->num>127) - OAMView->num = 127; - break; - case SB_LINELEFT : - --(OAMView->num); - if(OAMView->num<0) - OAMView->num = 0; - break; - } - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDC_FERMER : - SendMessage(hwnd, WM_CLOSE, 0, 0); - return 1; - case IDC_AUTO_UPDATE : - if(OAMView->autoup) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); - KillTimer(hwnd, IDT_VIEW_OAM); - OAMView->autoup = FALSE; - return 1; - } - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); - OAMView->autoup = TRUE; - SetTimer(hwnd, IDT_VIEW_OAM, OAMView->autoup_secs*20, (TIMERPROC) NULL); - return 1; - case IDC_AUTO_UPDATE_SECS: - { - int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); - if (!OAMView) - { - SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - if (t != OAMView->autoup_secs) - { - OAMView->autoup_secs = t; - if (OAMView->autoup) - SetTimer(hwnd, IDT_VIEW_OAM, - OAMView->autoup_secs*20, (TIMERPROC) NULL); - } - } - return 1; - case IDC_REFRESH: - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_SCR_SELECT : - switch(HIWORD(wParam)) - { - case CBN_SELCHANGE : - { - u32 sel = SendMessage(GetDlgItem(hwnd, IDC_SCR_SELECT), CB_GETCURSEL, 0, 0); - switch(sel) - { - case 0 : - OAMView->oam = (OAM *)MMU.ARM9_OAM; - OAMView->num = 0; - OAMView->gpu = MainScreen.gpu; - break; - case 1 : - OAMView->oam = (OAM *)(MMU.ARM9_OAM+0x400); - OAMView->num = 0; - OAMView->gpu = SubScreen.gpu; - break; - } - } - InvalidateRect(hwnd, NULL, FALSE); - return 1; - } - return 1; - } - return 0; - } - return FALSE; -} +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "oamView.h" +#include +#include "debug.h" +#include "resource.h" +#include "../MMU.h" +#include "../GPU.h" +#include "../NDSSystem.h" +#include "windriver.h" + +typedef struct +{ + u32 autoup_secs; + bool autoup; + + s16 num; + OAM *oam; + GPU *gpu; +} oamview_struct; + +oamview_struct *OAMView = NULL; + +const char dimm[4][4][8] = +{ + {"8 x 8", "16 x 8", "8 x 16", "- x -"}, + {"16 x 16", "32 x 8", "8 x 32", "- x -"}, + {"32 x 32", "32 x 16", "16 x 32", "- x -"}, + {"64 x 64", "64 x 32", "32 x 64", "- x -"}, +}; + +LRESULT OAMViewBox_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + Lock lock; + + //HWND hwnd = GetDlgItem(win->hwnd, IDC_OAM_BOX); + HDC hdc; + PAINTSTRUCT ps; +// TCHAR text[80]; + RECT rect; + int lg; + int ht; + HDC mem_dc; + HBITMAP mem_bmp; + + GetClientRect(hwnd, &rect); + lg = rect.right - rect.left; + ht = rect.bottom - rect.top; + + hdc = BeginPaint(hwnd, &ps); + + mem_dc = CreateCompatibleDC(hdc); + mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); + SelectObject(mem_dc, mem_bmp); + + FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); + + DeleteDC(mem_dc); + DeleteObject(mem_bmp); + + EndPaint(hwnd, &ps); + + return 0; +} + +LRESULT OamView_OnPaint(HWND hwnd, oamview_struct *win, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + OAM * oam = &win->oam[win->num]; + char text[80]; + u16 bitmap[256*192]; + u8 bitmap_alpha[256*192]; + u8 type[256*192]; + u8 prio[256*192]; + BITMAPV4HEADER bmi; + u16 i; + s16 x; + + //CreateBitmapIndirect(&bmi); + memset(&bmi, 0, sizeof(bmi)); + bmi.bV4Size = sizeof(bmi); + bmi.bV4Planes = 1; + bmi.bV4BitCount = 16; + bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS; + bmi.bV4RedMask = 0x001F; + bmi.bV4GreenMask = 0x03E0; + bmi.bV4BlueMask = 0x7C00; + bmi.bV4Width = 256; + bmi.bV4Height = -192; + + for(i = 0; i < 256*192; ++i) + { + bitmap[i] = 0x7F0F; + bitmap_alpha[i] = 0; + type[i] = 0; + prio[i] = 4; + } + + hdc = BeginPaint(hwnd, &ps); + + sprintf(text, "OAM : %d", win->num); + SetWindowText(GetDlgItem(hwnd, IDC_OAMNUM), text); + + switch(oam->attr0&(3<<10)) + { + case 0 : + SetWindowText(GetDlgItem(hwnd, IDC_MODE), "Normal"); + break; + case (1<<10) : + SetWindowText(GetDlgItem(hwnd, IDC_MODE), "Smi-transp"); + break; + case (2<<10) : + SetWindowText(GetDlgItem(hwnd, IDC_MODE), "OBJ Window"); + break; + case (3<<10) : + SetWindowText(GetDlgItem(hwnd, IDC_MODE), "Bitmap"); + } + + sprintf(text, "0x%08X", oam->attr0/*oam->attr2&0x3FF*/); + SetWindowText(GetDlgItem(hwnd, IDC_TILE), text); + + sprintf(text, "0x%08X", oam->attr1/*oam->attr2&0x3FF*/); + SetWindowText(GetDlgItem(hwnd, IDC_PAL), text); + + //SetWindowText(GetDlgItem(hwnd, IDC_PAL), (oam->attr0&(1<<13))?"256 couleurs": "16 couleurs"); + + sprintf(text, "%d 0x%08X", (oam->attr2>>10)&3, oam->attr2); + SetWindowText(GetDlgItem(hwnd, IDC_PRIO), text); + + x = oam->attr1&0x1FF; + x = ((s16)(x<<7)>>7); + sprintf(text, "%d x %d", x, oam->attr0&0xFF); + SetWindowText(GetDlgItem(hwnd, IDC_COOR), text); + + SetWindowText(GetDlgItem(hwnd, IDC_DIM), dimm[oam->attr1>>14][oam->attr0>>14]); + + SetWindowText(GetDlgItem(hwnd, IDC_ROT), oam->attr0&(1<<8)?"ON" : "OFF"); + + SetWindowText(GetDlgItem(hwnd, IDC_MOS), oam->attr0&(1<<12)?"ON" : "OFF"); + + if(oam->attr0&(1<<8)) + { + sprintf(text, "Rot param : %d", (oam->attr1>>9)&0x1F); + SetWindowText(GetDlgItem(hwnd, IDC_PROP0), text); + + SetWindowText(GetDlgItem(hwnd, IDC_PROP1), (oam->attr0&(1<<9))?"Double size": ""); + } + else + { + if(oam->attr0&(1<<9)) + sprintf(text, "INVISIBLE"); + else + sprintf(text, "%s %s", oam->attr0&(1<<12)?"H FLIP":"", oam->attr0&(1<<13)?"V FLIP":""); + + SetWindowText(GetDlgItem(hwnd, IDC_PROP0), text); + + SetWindowText(GetDlgItem(hwnd, IDC_PROP1), ""); + } + + GPU copy = *win->gpu; + for(i = 0; i < 192; ++i) + { + copy.currLine = i; + copy.spriteRender((u8*)(bitmap + i*256), bitmap_alpha + i*256, type + i*256, prio + i*256); + } + + SetDIBitsToDevice(hdc, 180, 4, 256, 192, 0, 0, 0, 192, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + + EndPaint(hwnd, &ps); + + return 0; +} + +LRESULT CALLBACK ViewOAMBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_NCCREATE: + return 1; + case WM_NCDESTROY: + return 1; + case WM_PAINT: + OAMViewBox_OnPaint(hwnd, wParam, lParam); + return 1; + case WM_ERASEBKGND: + return 1; + default: + break; + } + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +BOOL CALLBACK ViewOAMProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + //bail out early if the dialog isnt initialized + if(!OAMView && message != WM_INITDIALOG) + return false; + + switch (message) + { + case WM_INITDIALOG : + { + OAMView = new oamview_struct; + memset(OAMView, 0, sizeof(oamview_struct)); + OAMView->oam = (OAM *)(ARM9Mem.ARM9_OAM); + OAMView->gpu = MainScreen.gpu; + + OAMView->autoup_secs = 1; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, OAMView->autoup_secs); + + HWND combo = GetDlgItem(hwnd, IDC_SCR_SELECT); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen sprite"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen sprite"); + SendMessage(combo, CB_SETCURSEL, 0, 0); + } + return 1; + case WM_CLOSE : + { + if(OAMView->autoup) + { + KillTimer(hwnd, IDT_VIEW_OAM); + OAMView->autoup = false; + } + + if (OAMView!=NULL) + { + delete OAMView; + OAMView = NULL; + } + //INFO("Close OAM viewer dialog\n"); + PostQuitMessage(0); + return 0; + } + case WM_PAINT: + OamView_OnPaint(hwnd, OAMView, wParam, lParam); + return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; + case WM_HSCROLL : + switch LOWORD(wParam) + { + case SB_LINERIGHT : + ++(OAMView->num); + if(OAMView->num>127) + OAMView->num = 127; + break; + case SB_LINELEFT : + --(OAMView->num); + if(OAMView->num<0) + OAMView->num = 0; + break; + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case WM_COMMAND : + switch (LOWORD (wParam)) + { + case IDC_FERMER : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 1; + case IDC_AUTO_UPDATE : + if(OAMView->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_OAM); + OAMView->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + OAMView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_OAM, OAMView->autoup_secs*20, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (!OAMView) + { + SendMessage(hwnd, WM_INITDIALOG, 0, 0); + } + if (t != OAMView->autoup_secs) + { + OAMView->autoup_secs = t; + if (OAMView->autoup) + SetTimer(hwnd, IDT_VIEW_OAM, + OAMView->autoup_secs*20, (TIMERPROC) NULL); + } + } + return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_SCR_SELECT : + switch(HIWORD(wParam)) + { + case CBN_SELCHANGE : + { + u32 sel = SendMessage(GetDlgItem(hwnd, IDC_SCR_SELECT), CB_GETCURSEL, 0, 0); + switch(sel) + { + case 0 : + OAMView->oam = (OAM *)ARM9Mem.ARM9_OAM; + OAMView->num = 0; + OAMView->gpu = MainScreen.gpu; + break; + case 1 : + OAMView->oam = (OAM *)(ARM9Mem.ARM9_OAM+0x400); + OAMView->num = 0; + OAMView->gpu = SubScreen.gpu; + break; + } + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + } + return 1; + } + return 0; + } + return FALSE; +} diff --git a/desmume/src/windows/oamView.h b/src/windows/oamView.h similarity index 97% rename from desmume/src/windows/oamView.h rename to src/windows/oamView.h index ac5d3ba6a..dbb4eab60 100644 --- a/desmume/src/windows/oamView.h +++ b/src/windows/oamView.h @@ -1,30 +1,30 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef OAMVIEW_H -#define OAMVIEW_H - -#include "../common.h" - -extern LRESULT CALLBACK ViewOAMBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -extern BOOL CALLBACK ViewOAMProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef OAMVIEW_H +#define OAMVIEW_H + +#include "../common.h" + +extern LRESULT CALLBACK ViewOAMBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +extern BOOL CALLBACK ViewOAMProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + +#endif diff --git a/desmume/src/windows/ogl.cpp b/src/windows/ogl.cpp similarity index 96% rename from desmume/src/windows/ogl.cpp rename to src/windows/ogl.cpp index 0449997f0..1ee76469a 100644 --- a/desmume/src/windows/ogl.cpp +++ b/src/windows/ogl.cpp @@ -1,98 +1,98 @@ -/* ogl.cpp - - Copyright (C) 2006-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#define WIN32_LEAN_AND_MEAN -#include "../common.h" -#include "../debug.h" -#include -#include -#include "console.h" -#include "CWindow.h" - -extern WINCLASS *MainWindow; - -static bool oglAlreadyInit = false; - -int CheckHardwareSupport(HDC hdc) -{ - int PixelFormat = GetPixelFormat(hdc); - PIXELFORMATDESCRIPTOR pfd; - - DescribePixelFormat(hdc,PixelFormat,sizeof(PIXELFORMATDESCRIPTOR),&pfd); - if ((pfd.dwFlags & PFD_GENERIC_FORMAT) && !(pfd.dwFlags & PFD_GENERIC_ACCELERATED)) - return 0; // Software acceleration OpenGL - - else if ((pfd.dwFlags & PFD_GENERIC_FORMAT) && (pfd.dwFlags & PFD_GENERIC_ACCELERATED)) - return 1; // Half hardware acceleration OpenGL (MCD driver) - - else if ( !(pfd.dwFlags & PFD_GENERIC_FORMAT) && !(pfd.dwFlags & PFD_GENERIC_ACCELERATED)) - return 2; // Full hardware acceleration OpenGL - return -1; // check error -} - -bool windows_opengl_init() -{ - HDC oglDC = NULL; - HGLRC hRC = NULL; - int pixelFormat; - PIXELFORMATDESCRIPTOR pfd; - int res; - char *opengl_modes[3]={"software","half hardware (MCD driver)","hardware"}; - - if(oglAlreadyInit == true) return true; - - oglDC = GetDC (MainWindow->getHWnd()); - - memset(&pfd,0, sizeof(PIXELFORMATDESCRIPTOR)); - pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.cColorBits = 24; - pfd.cDepthBits = 24; - pfd.cAlphaBits = 8; - pfd.cStencilBits = 8; - pfd.iLayerType = PFD_MAIN_PLANE ; - - pixelFormat = ChoosePixelFormat(oglDC, &pfd); - if (pixelFormat == 0) - return false; - - if(!SetPixelFormat(oglDC, pixelFormat, &pfd)) - return false; - - hRC = wglCreateContext(oglDC); - if (!hRC) - return false; - - if(!wglMakeCurrent(oglDC, hRC)) - return false; - - res=CheckHardwareSupport(oglDC); - if (res>=0&&res<=2) - INFO("OpenGL mode: %s\n",opengl_modes[res]); - else - INFO("OpenGL mode: uknown\n"); - - oglAlreadyInit = true; - - return true; -} +/* ogl.cpp + + Copyright (C) 2006-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#define WIN32_LEAN_AND_MEAN +#include "../common.h" +#include "../debug.h" +#include +#include +#include "console.h" +#include "CWindow.h" + +extern WINCLASS *MainWindow; + +static bool oglAlreadyInit = false; + +int CheckHardwareSupport(HDC hdc) +{ + int PixelFormat = GetPixelFormat(hdc); + PIXELFORMATDESCRIPTOR pfd; + + DescribePixelFormat(hdc,PixelFormat,sizeof(PIXELFORMATDESCRIPTOR),&pfd); + if ((pfd.dwFlags & PFD_GENERIC_FORMAT) && !(pfd.dwFlags & PFD_GENERIC_ACCELERATED)) + return 0; // Software acceleration OpenGL + + else if ((pfd.dwFlags & PFD_GENERIC_FORMAT) && (pfd.dwFlags & PFD_GENERIC_ACCELERATED)) + return 1; // Half hardware acceleration OpenGL (MCD driver) + + else if ( !(pfd.dwFlags & PFD_GENERIC_FORMAT) && !(pfd.dwFlags & PFD_GENERIC_ACCELERATED)) + return 2; // Full hardware acceleration OpenGL + return -1; // check error +} + +bool windows_opengl_init() +{ + HDC oglDC = NULL; + HGLRC hRC = NULL; + int pixelFormat; + PIXELFORMATDESCRIPTOR pfd; + int res; + char *opengl_modes[3]={"software","half hardware (MCD driver)","hardware"}; + + if(oglAlreadyInit == true) return true; + + oglDC = GetDC (MainWindow->getHWnd()); + + memset(&pfd,0, sizeof(PIXELFORMATDESCRIPTOR)); + pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = 24; + pfd.cDepthBits = 24; + pfd.cAlphaBits = 8; + pfd.cStencilBits = 8; + pfd.iLayerType = PFD_MAIN_PLANE ; + + pixelFormat = ChoosePixelFormat(oglDC, &pfd); + if (pixelFormat == 0) + return false; + + if(!SetPixelFormat(oglDC, pixelFormat, &pfd)) + return false; + + hRC = wglCreateContext(oglDC); + if (!hRC) + return false; + + if(!wglMakeCurrent(oglDC, hRC)) + return false; + + res=CheckHardwareSupport(oglDC); + if (res>=0&&res<=2) + INFO("OpenGL mode: %s\n",opengl_modes[res]); + else + INFO("OpenGL mode: uknown\n"); + + oglAlreadyInit = true; + + return true; +} diff --git a/desmume/src/windows/palView.cpp b/src/windows/palView.cpp similarity index 94% rename from desmume/src/windows/palView.cpp rename to src/windows/palView.cpp index e9dd6f889..0e2dcf2ae 100644 --- a/desmume/src/windows/palView.cpp +++ b/src/windows/palView.cpp @@ -1,295 +1,295 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "palView.h" -#include -#include "debug.h" -#include "resource.h" -#include "../MMU.h" - -typedef struct -{ - u32 autoup_secs; - bool autoup; - - u16 *adr; - s16 palnum; -} palview_struct; - -palview_struct *PalView = NULL; - -LRESULT PalView_OnPaint(const u16 * adr, u16 num, HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - RECT rect; - HBRUSH brush; - u16 c; - char tmp[80]; - - rect.left = 3; - rect.top = 55; - rect.right = 13; - rect.bottom = 65; - hdc = BeginPaint(hwnd, &ps); - - if(adr) - { - u32 y; - - for(y = 0; y < 16; ++y) - { - u32 x; - - for(x = 0; x < 16; ++x) - { - c = adr[(y<<4)+x+0x100*num]; - brush = CreateSolidBrush(RGB((c&0x1F)<<3, (c&0x3E0)>>2, (c&0x7C00)>>7)); - FillRect(hdc, &rect, brush); - DeleteObject(brush); - rect.left += 11; - rect.right += 11; - } - rect.top += 11; - rect.bottom += 11; - rect.left = 3; - rect.right = 13; - } - sprintf(tmp, "Pal : %d", num); - SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), tmp); - } - else - TextOut(hdc, 3, 55, "Pas de palette", 14); - EndPaint(hwnd, &ps); - - return 0; -} - -BOOL CALLBACK ViewPalProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - //bail out early if the dialog isnt initialized - if(!PalView && message != WM_INITDIALOG) - return false; - - switch (message) - { - case WM_INITDIALOG : - { - PalView = new palview_struct; - memset(PalView, 0, sizeof(palview_struct)); - PalView->adr = (u16 *)MMU.ARM9_VMEM; - PalView->autoup_secs = 1; - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETRANGE, 0, MAKELONG(99, 1)); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETPOS32, 0, PalView->autoup_secs); - - HWND combo = GetDlgItem(hwnd, IDC_PAL_SELECT); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen BG PAL"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen BG PAL"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen SPR PAL"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen SPR PAL"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 3"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 3"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 3"); - SendMessage(combo, CB_SETCURSEL, 0, 0); - ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); - EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); - } - return 1; - case WM_CLOSE : - { - if(PalView->autoup) - { - KillTimer(hwnd, IDT_VIEW_DISASM7); - PalView->autoup = false; - } - - if (PalView!=NULL) - { - delete PalView; - PalView = NULL; - } - //INFO("Close Palette view dialog\n"); - PostQuitMessage(0); - return 0; - } - case WM_PAINT: - PalView_OnPaint(PalView->adr, PalView->palnum, hwnd, wParam, lParam); - return 1; - case WM_TIMER: - SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); - return 1; - case WM_HSCROLL : - switch LOWORD(wParam) - { - case SB_LINERIGHT : - ++(PalView->palnum); - if(PalView->palnum>15) - PalView->palnum = 15; - break; - case SB_LINELEFT : - --(PalView->palnum); - if(PalView->palnum<0) - PalView->palnum = 0; - break; - } - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDC_FERMER : - SendMessage(hwnd, WM_CLOSE, 0, 0); - return 1; - case IDC_AUTO_UPDATE : - if(PalView->autoup) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); - KillTimer(hwnd, IDT_VIEW_PAL); - PalView->autoup = FALSE; - return 1; - } - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); - PalView->autoup = TRUE; - SetTimer(hwnd, IDT_VIEW_PAL, PalView->autoup_secs*20, (TIMERPROC) NULL); - return 1; - case IDC_AUTO_UPDATE_SECS: - { - int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); - if (!PalView) - { - SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - if (t != PalView->autoup_secs) - { - PalView->autoup_secs = t; - if (PalView->autoup) - SetTimer(hwnd, IDT_VIEW_PAL, - PalView->autoup_secs*20, (TIMERPROC) NULL); - } - } - return 1; - case IDC_REFRESH: - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_PAL_SELECT : - switch(HIWORD(wParam)) - { - case CBN_SELCHANGE : - case CBN_CLOSEUP : - { - u32 sel = SendMessage(GetDlgItem(hwnd, IDC_PAL_SELECT), CB_GETCURSEL, 0, 0); - switch(sel) - { - case 0 : - PalView->adr = (u16 *)MMU.ARM9_VMEM; - PalView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); - EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); - break; - case 1 : - PalView->adr = ((u16 *)MMU.ARM9_VMEM) + 0x200; - PalView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); - EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); - break; - case 2 : - PalView->adr = (u16 *)MMU.ARM9_VMEM + 0x100; - PalView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); - EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); - break; - case 3 : - PalView->adr = ((u16 *)MMU.ARM9_VMEM) + 0x300; - PalView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); - EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); - break; - case 4 : - case 5 : - case 6 : - case 7 : - PalView->adr = ((u16 *)(MMU.ExtPal[0][sel-4])); - PalView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); - EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); - break; - case 8 : - case 9 : - case 10 : - case 11 : - PalView->adr = ((u16 *)(MMU.ExtPal[1][sel-8])); - PalView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); - EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); - break; - case 12 : - case 13 : - PalView->adr = ((u16 *)(MMU.ObjExtPal[0][sel-12])); - PalView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); - EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); - break; - case 14 : - case 15 : - PalView->adr = ((u16 *)(MMU.ObjExtPal[1][sel-14])); - PalView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); - EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); - break; - case 16 : - case 17 : - case 18 : - case 19 : - PalView->adr = ((u16 *)(MMU.texInfo.texPalSlot[sel-16])); - PalView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); - EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); - break; - default : - return 1; - } - InvalidateRect(hwnd, NULL, FALSE); - return 1; - } - } - return 1; - } - return 0; - } - return false; -} +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "palView.h" +#include +#include "debug.h" +#include "resource.h" +#include "../MMU.h" + +typedef struct +{ + u32 autoup_secs; + bool autoup; + + u16 *adr; + s16 palnum; +} palview_struct; + +palview_struct *PalView = NULL; + +LRESULT PalView_OnPaint(const u16 * adr, u16 num, HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + RECT rect; + HBRUSH brush; + u16 c; + char tmp[80]; + + rect.left = 3; + rect.top = 55; + rect.right = 13; + rect.bottom = 65; + hdc = BeginPaint(hwnd, &ps); + + if(adr) + { + u32 y; + + for(y = 0; y < 16; ++y) + { + u32 x; + + for(x = 0; x < 16; ++x) + { + c = adr[(y<<4)+x+0x100*num]; + brush = CreateSolidBrush(RGB((c&0x1F)<<3, (c&0x3E0)>>2, (c&0x7C00)>>7)); + FillRect(hdc, &rect, brush); + DeleteObject(brush); + rect.left += 11; + rect.right += 11; + } + rect.top += 11; + rect.bottom += 11; + rect.left = 3; + rect.right = 13; + } + sprintf(tmp, "Pal : %d", num); + SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), tmp); + } + else + TextOut(hdc, 3, 55, "Pas de palette", 14); + EndPaint(hwnd, &ps); + + return 0; +} + +BOOL CALLBACK ViewPalProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + //bail out early if the dialog isnt initialized + if(!PalView && message != WM_INITDIALOG) + return false; + + switch (message) + { + case WM_INITDIALOG : + { + PalView = new palview_struct; + memset(PalView, 0, sizeof(palview_struct)); + PalView->adr = (u16 *)ARM9Mem.ARM9_VMEM; + PalView->autoup_secs = 1; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, PalView->autoup_secs); + + HWND combo = GetDlgItem(hwnd, IDC_PAL_SELECT); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen BG PAL"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen BG PAL"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen SPR PAL"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen SPR PAL"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 3"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 3"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 3"); + SendMessage(combo, CB_SETCURSEL, 0, 0); + ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); + EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); + } + return 1; + case WM_CLOSE : + { + if(PalView->autoup) + { + KillTimer(hwnd, IDT_VIEW_DISASM7); + PalView->autoup = false; + } + + if (PalView!=NULL) + { + delete PalView; + PalView = NULL; + } + //INFO("Close Palette view dialog\n"); + PostQuitMessage(0); + return 0; + } + case WM_PAINT: + PalView_OnPaint(PalView->adr, PalView->palnum, hwnd, wParam, lParam); + return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; + case WM_HSCROLL : + switch LOWORD(wParam) + { + case SB_LINERIGHT : + ++(PalView->palnum); + if(PalView->palnum>15) + PalView->palnum = 15; + break; + case SB_LINELEFT : + --(PalView->palnum); + if(PalView->palnum<0) + PalView->palnum = 0; + break; + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case WM_COMMAND : + switch (LOWORD (wParam)) + { + case IDC_FERMER : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 1; + case IDC_AUTO_UPDATE : + if(PalView->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_PAL); + PalView->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + PalView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_PAL, PalView->autoup_secs*20, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (!PalView) + { + SendMessage(hwnd, WM_INITDIALOG, 0, 0); + } + if (t != PalView->autoup_secs) + { + PalView->autoup_secs = t; + if (PalView->autoup) + SetTimer(hwnd, IDT_VIEW_PAL, + PalView->autoup_secs*20, (TIMERPROC) NULL); + } + } + return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_PAL_SELECT : + switch(HIWORD(wParam)) + { + case CBN_SELCHANGE : + case CBN_CLOSEUP : + { + u32 sel = SendMessage(GetDlgItem(hwnd, IDC_PAL_SELECT), CB_GETCURSEL, 0, 0); + switch(sel) + { + case 0 : + PalView->adr = (u16 *)ARM9Mem.ARM9_VMEM; + PalView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); + EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); + break; + case 1 : + PalView->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x200; + PalView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); + EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); + break; + case 2 : + PalView->adr = (u16 *)ARM9Mem.ARM9_VMEM + 0x100; + PalView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); + EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); + break; + case 3 : + PalView->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300; + PalView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); + EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); + break; + case 4 : + case 5 : + case 6 : + case 7 : + PalView->adr = ((u16 *)(ARM9Mem.ExtPal[0][sel-4])); + PalView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); + break; + case 8 : + case 9 : + case 10 : + case 11 : + PalView->adr = ((u16 *)(ARM9Mem.ExtPal[1][sel-8])); + PalView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); + break; + case 12 : + case 13 : + PalView->adr = ((u16 *)(ARM9Mem.ObjExtPal[0][sel-12])); + PalView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); + break; + case 14 : + case 15 : + PalView->adr = ((u16 *)(ARM9Mem.ObjExtPal[1][sel-14])); + PalView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); + break; + case 16 : + case 17 : + case 18 : + case 19 : + PalView->adr = ((u16 *)(ARM9Mem.texInfo.texPalSlot[sel-16])); + PalView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); + break; + default : + return 1; + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + } + } + return 1; + } + return 0; + } + return false; +} diff --git a/desmume/src/windows/palView.h b/src/windows/palView.h similarity index 96% rename from desmume/src/windows/palView.h rename to src/windows/palView.h index faef7d93c..6a8193bb7 100644 --- a/desmume/src/windows/palView.h +++ b/src/windows/palView.h @@ -1,30 +1,30 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef PALVIEW_H -#define PALVIEW_H - -#include "../common.h" -#include - -extern BOOL CALLBACK ViewPalProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef PALVIEW_H +#define PALVIEW_H + +#include "../common.h" +#include + +extern BOOL CALLBACK ViewPalProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + #endif \ No newline at end of file diff --git a/desmume/src/windows/pathsettings.cpp b/src/windows/pathsettings.cpp similarity index 100% rename from desmume/src/windows/pathsettings.cpp rename to src/windows/pathsettings.cpp diff --git a/desmume/src/windows/pathsettings.h b/src/windows/pathsettings.h similarity index 100% rename from desmume/src/windows/pathsettings.h rename to src/windows/pathsettings.h diff --git a/desmume/src/windows/ram_search.cpp b/src/windows/ram_search.cpp similarity index 97% rename from desmume/src/windows/ram_search.cpp rename to src/windows/ram_search.cpp index 884aafda6..98e4c2e2c 100644 --- a/desmume/src/windows/ram_search.cpp +++ b/src/windows/ram_search.cpp @@ -1,1947 +1,1947 @@ -//RamSearch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/ -//Authors: Upthorn, Nitsuja, adelikat - -// A few notes about this implementation of a RAM search window: -// -// Speed of update was one of the highest priories. -// This is because I wanted the RAM search window to be able to -// update every single value in RAM every single frame, and -// keep track of the exact number of frames across which each value has changed, -// without causing the emulation to run noticeably slower than normal. -// -// The data representation was changed from one entry per valid address -// to one entry per contiguous range of uneliminated addresses -// which references uniform pools of per-address properties. -// - This saves time when there are many items because -// it minimizes the amount of data that needs to be stored and processed per address. -// - It also saves time when there are few items because -// it ensures that no time is wasted in iterating through -// addresses that have already been eliminated from the search. -// -// The worst-case scenario is when every other item has been -// eliminated from the search, maximizing the number of regions. -// This implementation manages to handle even that pathological case -// acceptably well. In fact, it still updates faster than the previous implementation. -// The time spent setting up or clearing such a large number of regions -// is somewhat horrendous, but it seems reasonable to have poor worst-case speed -// during these sporadic "setup" steps to achieve an all-around faster per-update speed. -// (You can test this case by performing the search: Modulo 2 Is Specific Address 0) - -#include "resource.h" - -#include "common.h" -#include "main.h" -#include "NDSSystem.h" -#include "ramwatch.h" - -#include "ram_search.h" -#include -#include -#include "ramwatch.h" -#include -#include -#ifdef _WIN32 - #include "BaseTsd.h" - typedef INT_PTR intptr_t; -#else - #include "stdint.h" -#endif - -HWND RamSearchHWnd = NULL; - -extern HWND RamWatchHWnd; - -static char Str_Tmp[1024]; - -int Rom_Size; //TODO -unsigned char* Rom_Data; //TODO - -struct MemoryRegion -{ - unsigned int hardwareAddress; // hardware address of the start of this region - unsigned int size; // number of bytes to the end of this region - unsigned char* softwareAddress; // pointer to the start of the live emulator source values for this region - BOOL byteSwapped; // true if this is a byte-swapped region of memory - - unsigned int virtualIndex; // index into s_prevValues, s_curValues, and s_numChanges, valid after being initialized in ResetMemoryRegions() - unsigned int itemIndex; // index into listbox items, valid when s_itemIndicesInvalid is false -}; - -static struct Buffers { - unsigned char s_prevValues [MAX_RAM_SIZE+4]; // values at last search or reset - unsigned char s_curValues [MAX_RAM_SIZE+4]; // values at last frame update - unsigned short s_numChanges [MAX_RAM_SIZE+4]; // number of changes of the item starting at this virtual index address - MemoryRegion* s_itemIndexToRegionPointer [MAX_RAM_SIZE+4]; // used for random access into the memory list (trading memory size to get speed here, too bad it's so much memory), only valid when s_itemIndicesInvalid is false -} *buffers = NULL; -static BOOL s_itemIndicesInvalid = true; // if true, the link from listbox items to memory regions (s_itemIndexToRegionPointer) and the link from memory regions to list box items (MemoryRegion::itemIndex) both need to be recalculated -static BOOL s_prevValuesNeedUpdate = true; // if true, the "prev" values should be updated using the "cur" values on the next frame update signaled -static unsigned int s_maxItemIndex = 0; // max currently valid item index, the listbox sometimes tries to update things past the end of the list so we need to know this to ignore those attempts - -static const MemoryRegion s_prgRegion = { 0x02000000, 0x400000, (unsigned char*)MMU.MAIN_MEM, false}; - -/* -static const MemoryRegion s_prgRegion = { 0x020000, SEGACD_RAM_PRG_SIZE, (unsigned char*)Ram_Prg, true}; -static const MemoryRegion s_word1MRegion = { 0x200000, SEGACD_1M_RAM_SIZE, (unsigned char*)Ram_Word_1M, true}; -static const MemoryRegion s_word2MRegion = { 0x200000, SEGACD_2M_RAM_SIZE, (unsigned char*)Ram_Word_2M, true}; -static const MemoryRegion s_z80Region = { 0xA00000, Z80_RAM_SIZE, (unsigned char*)Ram_Z80, true}; -static const MemoryRegion s_68kRegion = { 0xFF0000, _68K_RAM_SIZE, (unsigned char*)Ram_68k, true}; -static const MemoryRegion s_32xRegion = {0x06000000, _32X_RAM_SIZE, (unsigned char*)_32X_Ram, false}; -*/ -// list of contiguous uneliminated memory regions -typedef std::list MemoryList; -static MemoryList s_activeMemoryRegions; - -// for undo support (could be better, but this way was really easy) -static MemoryList s_activeMemoryRegionsBackup; -static int s_undoType = 0; // 0 means can't undo, 1 means can undo, 2 means can redo - -void RamSearchSaveUndoStateIfNotTooBig(HWND hDlg); -static const int tooManyRegionsForUndo = 10000; - -void InitRamSearch() -{ - if(buffers == NULL) - { - buffers = new Buffers; - memset(buffers,0,sizeof(Buffers)); - } -} - -void ResetMemoryRegions() -{ -// Clear_Sound_Buffer(); - - s_activeMemoryRegions.clear(); - - s_activeMemoryRegions.push_back(s_prgRegion); - - /*if(Genesis_Started || _32X_Started || SegaCD_Started) - { - s_activeMemoryRegions.push_back(s_68kRegion); - s_activeMemoryRegions.push_back(s_z80Region); - if(SegaCD_Started) - { - s_activeMemoryRegions.push_back(s_prgRegion); - s_activeMemoryRegions.push_back((Ram_Word_State & 0x2) ? s_word1MRegion : s_word2MRegion); - } - if(_32X_Started) - { - s_activeMemoryRegions.push_back(s_32xRegion); - } - }*/ - - int nextVirtualIndex = 0; - for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter) - { - MemoryRegion& region = *iter; - region.virtualIndex = nextVirtualIndex; - assert(((intptr_t)region.softwareAddress & 1) == 0 && "somebody need to reimplement ReadValueAtSoftwareAddress()"); - nextVirtualIndex = region.virtualIndex + region.size; - } -// assert(nextVirtualIndex <= MAX_RAM_SIZE); TODO -} - -// eliminates a range of hardware addresses from the search results -// returns 2 if it changed the region and moved the iterator to another region -// returns 1 if it changed the region but didn't move the iterator -// returns 0 if it had no effect -// warning: don't call anything that takes an itemIndex in a loop that calls DeactivateRegion... -// doing so would be tremendously slow because DeactivateRegion invalidates the index cache -int DeactivateRegion(MemoryRegion& region, MemoryList::iterator& iter, unsigned int hardwareAddress, unsigned int size) -{ - if(hardwareAddress + size <= region.hardwareAddress || hardwareAddress >= region.hardwareAddress + region.size) - { - // region is unaffected - return 0; - } - else if(hardwareAddress > region.hardwareAddress && hardwareAddress + size >= region.hardwareAddress + region.size) - { - // erase end of region - region.size = hardwareAddress - region.hardwareAddress; - return 1; - } - else if(hardwareAddress <= region.hardwareAddress && hardwareAddress + size < region.hardwareAddress + region.size) - { - // erase start of region - int eraseSize = (hardwareAddress + size) - region.hardwareAddress; - region.hardwareAddress += eraseSize; - region.size -= eraseSize; - region.softwareAddress += eraseSize; - region.virtualIndex += eraseSize; - return 1; - } - else if(hardwareAddress <= region.hardwareAddress && hardwareAddress + size >= region.hardwareAddress + region.size) - { - // erase entire region - iter = s_activeMemoryRegions.erase(iter); - s_itemIndicesInvalid = TRUE; - return 2; - } - else //if(hardwareAddress > region.hardwareAddress && hardwareAddress + size < region.hardwareAddress + region.size) - { - // split region - int eraseSize = (hardwareAddress + size) - region.hardwareAddress; - MemoryRegion region2 = {region.hardwareAddress + eraseSize, region.size - eraseSize, region.softwareAddress + eraseSize, region.byteSwapped, region.virtualIndex + eraseSize}; - region.size = hardwareAddress - region.hardwareAddress; - iter = s_activeMemoryRegions.insert(++iter, region2); - s_itemIndicesInvalid = TRUE; - return 2; - } -} - -/* -// eliminates a range of hardware addresses from the search results -// this is a simpler but usually slower interface for the above function -void DeactivateRegion(unsigned int hardwareAddress, unsigned int size) -{ - for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ) - { - MemoryRegion& region = *iter; - if(2 != DeactivateRegion(region, iter, hardwareAddress, size)) - ++iter; - } -} -*/ - -// warning: can be slow -void CalculateItemIndices(int itemSize) -{ - unsigned int itemIndex = 0; - for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter) - { - MemoryRegion& region = *iter; - region.itemIndex = itemIndex; - int startSkipSize = ((unsigned int)(itemSize - region.hardwareAddress)) % itemSize; - unsigned int start = startSkipSize; - unsigned int end = region.size; - for(unsigned int i = start; i < end; i += itemSize) - buffers->s_itemIndexToRegionPointer[itemIndex++] = ®ion; - } - s_maxItemIndex = itemIndex; - s_itemIndicesInvalid = FALSE; -} - -template -void UpdateRegionT(const MemoryRegion& region, const MemoryRegion* nextRegionPtr) -{ - if(s_prevValuesNeedUpdate) - memcpy(buffers->s_prevValues + region.virtualIndex, buffers->s_curValues + region.virtualIndex, region.size + sizeof(compareType) - sizeof(stepType)); - - unsigned int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); - - unsigned char* sourceAddr = region.softwareAddress - region.virtualIndex; - unsigned int indexStart = region.virtualIndex + startSkipSize; - unsigned int indexEnd = region.virtualIndex + region.size; - - if(sizeof(compareType) == 1) - { - for(unsigned int i = indexStart; i < indexEnd; i++) - { - if(buffers->s_curValues[i] != sourceAddr[i^swapXOR]) // if value changed - { - buffers->s_curValues[i] = sourceAddr[i^swapXOR]; // update value - //if(s_numChanges[i] != 0xFFFF) - buffers->s_numChanges[i]++; // increase change count - } - } - } - else // it's more complicated for non-byte sizes because: - { // - more than one byte can affect a given change count entry - // - when more than one of those bytes changes simultaneously the entry's change count should only increase by 1 - // - a few of those bytes can be outside the region - - unsigned int endSkipSize = ((unsigned int)(startSkipSize - region.size)) % sizeof(stepType); - unsigned int lastIndexToRead = indexEnd + endSkipSize + sizeof(compareType) - sizeof(stepType); - unsigned int lastIndexToCopy = lastIndexToRead; - if(nextRegionPtr) - { - const MemoryRegion& nextRegion = *nextRegionPtr; - int nextStartSkipSize = ((unsigned int)(sizeof(stepType) - nextRegion.hardwareAddress)) % sizeof(stepType); - unsigned int nextIndexStart = nextRegion.virtualIndex + nextStartSkipSize; - if(lastIndexToCopy > nextIndexStart) - lastIndexToCopy = nextIndexStart; - } - - unsigned int nextValidChange [sizeof(compareType)]; - for(unsigned int i = 0; i < sizeof(compareType); i++) - nextValidChange[i] = indexStart + i; - - for(unsigned int i = indexStart, j = 0; i < lastIndexToRead; i++, j++) - { - if(buffers->s_curValues[i] != sourceAddr[i^swapXOR]) // if value of this byte changed - { - if(i < lastIndexToCopy) - buffers->s_curValues[i] = sourceAddr[i^swapXOR]; // update value - for(int k = 0; k < sizeof(compareType); k++) // loop through the previous entries that contain this byte - { - if(i >= indexEnd+k) - continue; - int m = (j-k+sizeof(compareType)) & (sizeof(compareType)-1); - if(nextValidChange[m]+sizeof(compareType) <= i+sizeof(compareType)) // if we didn't already increase the change count for this entry - { - //if(s_numChanges[i-k] != 0xFFFF) - buffers->s_numChanges[i-k]++; // increase the change count for this entry - nextValidChange[m] = i+sizeof(compareType); // and remember not to increase it again - } - } - } - } - } -} - -template -void UpdateRegionsT() -{ - for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end();) - { - const MemoryRegion& region = *iter; - ++iter; - const MemoryRegion* nextRegion = (iter == s_activeMemoryRegions.end()) ? NULL : &*iter; - - if(region.byteSwapped) - UpdateRegionT(region, nextRegion); - else - UpdateRegionT(region, nextRegion); - } - - s_prevValuesNeedUpdate = false; -} - -template -int CountRegionItemsT() -{ - if(sizeof(stepType) == 1) - { - if(s_activeMemoryRegions.empty()) - return 0; - - if(s_itemIndicesInvalid) - CalculateItemIndices(sizeof(stepType)); - - MemoryRegion& lastRegion = s_activeMemoryRegions.back(); - return lastRegion.itemIndex + lastRegion.size; - } - else // the branch above is faster but won't work if the step size isn't 1 - { - int total = 0; - for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter) - { - MemoryRegion& region = *iter; - int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); - total += (region.size - startSkipSize + (sizeof(stepType)-1)) / sizeof(stepType); - } - return total; - } -} - -// returns information about the item in the form of a "fake" region -// that has the item in it and nothing else -template -void ItemIndexToVirtualRegion(unsigned int itemIndex, MemoryRegion& virtualRegion) -{ - if(s_itemIndicesInvalid) - CalculateItemIndices(sizeof(stepType)); - - if(itemIndex >= s_maxItemIndex) - { - memset(&virtualRegion, 0, sizeof(MemoryRegion)); - return; - } - - const MemoryRegion* regionPtr = buffers->s_itemIndexToRegionPointer[itemIndex]; - const MemoryRegion& region = *regionPtr; - - int bytesWithinRegion = (itemIndex - region.itemIndex) * sizeof(stepType); - int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); - bytesWithinRegion += startSkipSize; - - virtualRegion.size = sizeof(compareType); - virtualRegion.hardwareAddress = region.hardwareAddress + bytesWithinRegion; - virtualRegion.softwareAddress = region.softwareAddress + bytesWithinRegion; - virtualRegion.virtualIndex = region.virtualIndex + bytesWithinRegion; - virtualRegion.byteSwapped = region.byteSwapped; - virtualRegion.itemIndex = itemIndex; - return; -} - -template -unsigned int ItemIndexToVirtualIndex(unsigned int itemIndex) -{ - MemoryRegion virtualRegion; - ItemIndexToVirtualRegion(itemIndex, virtualRegion); - return virtualRegion.virtualIndex; -} - -template -T ReadBigEndian(const unsigned char* data) -{ - T rv = 0; - for(int i = 0; i < sizeof(T); i++) - { - rv <<= 8; - rv |= *data++; - } - return rv; -} -template<> signed char ReadBigEndian(const unsigned char* data) { return *data; } -template<> unsigned char ReadBigEndian(const unsigned char* data) { return *data; } - - -template -compareType GetPrevValueFromVirtualIndex(unsigned int virtualIndex) -{ -// return ReadBigEndian(buffers->s_prevValues + virtualIndex); - return *(compareType*)(buffers->s_prevValues+virtualIndex); -} -template -compareType GetCurValueFromVirtualIndex(unsigned int virtualIndex) -{ -// return ReadBigEndian(buffers->s_curValues + virtualIndex); - return *(compareType*)(buffers->s_curValues+virtualIndex); -} -template -unsigned short GetNumChangesFromVirtualIndex(unsigned int virtualIndex) -{ - unsigned short num = buffers->s_numChanges[virtualIndex]; - //for(unsigned int i = 1; i < sizeof(stepType); i++) - // if(num < s_numChanges[virtualIndex+i]) - // num = s_numChanges[virtualIndex+i]; - return num; -} - -template -compareType GetPrevValueFromItemIndex(unsigned int itemIndex) -{ - int virtualIndex = ItemIndexToVirtualIndex(itemIndex); - return GetPrevValueFromVirtualIndex(virtualIndex); -} -template -compareType GetCurValueFromItemIndex(unsigned int itemIndex) -{ - int virtualIndex = ItemIndexToVirtualIndex(itemIndex); - return GetCurValueFromVirtualIndex(virtualIndex); -} -template -unsigned short GetNumChangesFromItemIndex(unsigned int itemIndex) -{ - int virtualIndex = ItemIndexToVirtualIndex(itemIndex); - return GetNumChangesFromVirtualIndex(virtualIndex); -} -template -unsigned int GetHardwareAddressFromItemIndex(unsigned int itemIndex) -{ - MemoryRegion virtualRegion; - ItemIndexToVirtualRegion(itemIndex, virtualRegion); - return virtualRegion.hardwareAddress; -} - -// this one might be unreliable, haven't used it much -template -unsigned int HardwareAddressToItemIndex(unsigned int hardwareAddress) -{ - if(s_itemIndicesInvalid) - CalculateItemIndices(sizeof(stepType)); - - for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter) - { - MemoryRegion& region = *iter; - if(hardwareAddress >= region.hardwareAddress && hardwareAddress < region.hardwareAddress + region.size) - { - int indexWithinRegion = (hardwareAddress - region.hardwareAddress) / sizeof(stepType); - return region.itemIndex + indexWithinRegion; - } - } - - return -1; -} - - - - -// workaround for a parser error in MSVC that sometimes deletes a comma preceeding a macro -// this macro takes a type and a signed/unsigned modifier, and returns the same type with that modifier whether or not the compiler decides to delete the comma between them -template -struct DummyType { typedef T t; }; -#define COMMAHACK(sign, type) DummyType::t -#ifdef _MSC_VER -#pragma warning(disable : 4114) // disable "same modifier used twice" warning that otherwise would get issued when the compiler bug happens -#endif - -// it's ugly but I can't think of a better way to call these functions that isn't also slower, since -// I need the current values of these arguments to determine which primitive types are used within the function -#define CALL_WITH_T_SIZE_TYPES(functionName, sizeTypeID, isSigned, requireAligned, ...) \ - (sizeTypeID == 'b' \ - ? (isSigned \ - ? functionName(__VA_ARGS__) \ - : functionName(__VA_ARGS__)) \ - : sizeTypeID == 'w' \ - ? (isSigned \ - ? (requireAligned \ - ? functionName(__VA_ARGS__) \ - : functionName(__VA_ARGS__)) \ - : (requireAligned \ - ? functionName(__VA_ARGS__) \ - : functionName(__VA_ARGS__))) \ - : sizeTypeID == 'd' \ - ? (isSigned \ - ? (requireAligned \ - ? functionName(__VA_ARGS__) \ - : functionName(__VA_ARGS__)) \ - : (requireAligned \ - ? functionName(__VA_ARGS__) \ - : functionName(__VA_ARGS__))) \ - : functionName(__VA_ARGS__)) - -// version that takes a forced comparison type -#define CALL_WITH_T_STEP(functionName, sizeTypeID, sign,type, requireAligned, ...) \ - (sizeTypeID == 'b' \ - ? functionName(__VA_ARGS__) \ - : sizeTypeID == 'w' \ - ? (requireAligned \ - ? functionName(__VA_ARGS__) \ - : functionName(__VA_ARGS__)) \ - : sizeTypeID == 'd' \ - ? (requireAligned \ - ? functionName(__VA_ARGS__) \ - : functionName(__VA_ARGS__)) \ - : functionName(__VA_ARGS__)) - - -// basic comparison functions: -template inline bool LessCmp (T x, T y, T i) { return x < y; } -template inline bool MoreCmp (T x, T y, T i) { return x > y; } -template inline bool LessEqualCmp (T x, T y, T i) { return x <= y; } -template inline bool MoreEqualCmp (T x, T y, T i) { return x >= y; } -template inline bool EqualCmp (T x, T y, T i) { return x == y; } -template inline bool UnequalCmp (T x, T y, T i) { return x != y; } -template inline bool DiffByCmp (T x, T y, T p) { return x - y == p || y - x == p; } -template inline bool ModIsCmp (T x, T y, T p) { return p && x % p == y; } - -// compare-to type functions: -template -void SearchRelative (bool(*cmpFun)(T,T,T), T ignored, T param) -{ - for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ) - { - MemoryRegion& region = *iter; - int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); - unsigned int start = region.virtualIndex + startSkipSize; - unsigned int end = region.virtualIndex + region.size; - for(unsigned int i = start, hwaddr = region.hardwareAddress; i < end; i += sizeof(stepType), hwaddr += sizeof(stepType)) - if(!cmpFun(GetCurValueFromVirtualIndex(i), GetPrevValueFromVirtualIndex(i), param)) - if(2 == DeactivateRegion(region, iter, hwaddr, sizeof(stepType))) - goto outerContinue; - ++iter; -outerContinue: - continue; - } -} -template -void SearchSpecific (bool(*cmpFun)(T,T,T), T value, T param) -{ - for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ) - { - MemoryRegion& region = *iter; - int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); - unsigned int start = region.virtualIndex + startSkipSize; - unsigned int end = region.virtualIndex + region.size; - for(unsigned int i = start, hwaddr = region.hardwareAddress; i < end; i += sizeof(stepType), hwaddr += sizeof(stepType)) - if(!cmpFun(GetCurValueFromVirtualIndex(i), value, param)) - if(2 == DeactivateRegion(region, iter, hwaddr, sizeof(stepType))) - goto outerContinue; - ++iter; -outerContinue: - continue; - } -} -template -void SearchAddress (bool(*cmpFun)(T,T,T), T address, T param) -{ - for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ) - { - MemoryRegion& region = *iter; - int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); - unsigned int start = region.virtualIndex + startSkipSize; - unsigned int end = region.virtualIndex + region.size; - for(unsigned int i = start, hwaddr = region.hardwareAddress; i < end; i += sizeof(stepType), hwaddr += sizeof(stepType)) - if(!cmpFun(hwaddr, address, param)) - if(2 == DeactivateRegion(region, iter, hwaddr, sizeof(stepType))) - goto outerContinue; - ++iter; -outerContinue: - continue; - } -} -template -void SearchChanges (bool(*cmpFun)(T,T,T), T changes, T param) -{ - for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ) - { - MemoryRegion& region = *iter; - int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); - unsigned int start = region.virtualIndex + startSkipSize; - unsigned int end = region.virtualIndex + region.size; - for(unsigned int i = start, hwaddr = region.hardwareAddress; i < end; i += sizeof(stepType), hwaddr += sizeof(stepType)) - if(!cmpFun(GetNumChangesFromVirtualIndex(i), changes, param)) - if(2 == DeactivateRegion(region, iter, hwaddr, sizeof(stepType))) - goto outerContinue; - ++iter; -outerContinue: - continue; - } -} - -char rs_c='s'; -char rs_o='='; -char rs_t='s'; -int rs_param=0, rs_val=0, rs_val_valid=0; -char rs_type_size = 'b', rs_last_type_size = rs_type_size; -bool noMisalign = true, rs_last_no_misalign = noMisalign; -bool littleEndian = false; -int last_rs_possible = -1; -int last_rs_regions = -1; - -void prune(char c,char o,char t,int v,int p) -{ - // repetition-reducing macros - #define DO_SEARCH(sf) \ - switch (o) \ - { \ - case '<': DO_SEARCH_2(LessCmp,sf); break; \ - case '>': DO_SEARCH_2(MoreCmp,sf); break; \ - case '=': DO_SEARCH_2(EqualCmp,sf); break; \ - case '!': DO_SEARCH_2(UnequalCmp,sf); break; \ - case 'l': DO_SEARCH_2(LessEqualCmp,sf); break; \ - case 'm': DO_SEARCH_2(MoreEqualCmp,sf); break; \ - case 'd': DO_SEARCH_2(DiffByCmp,sf); break; \ - case '%': DO_SEARCH_2(ModIsCmp,sf); break; \ - default: assert(!"Invalid operator for this search type."); break; \ - } - - // perform the search, eliminating nonmatching values - switch (c) - { - #define DO_SEARCH_2(CmpFun,sf) CALL_WITH_T_SIZE_TYPES(sf, rs_type_size, t, noMisalign, CmpFun,v,p) - case 'r': DO_SEARCH(SearchRelative); break; - case 's': DO_SEARCH(SearchSpecific); break; - - #undef DO_SEARCH_2 - #define DO_SEARCH_2(CmpFun,sf) CALL_WITH_T_STEP(sf, rs_type_size, unsigned,int, noMisalign, CmpFun,v,p); - case 'a': DO_SEARCH(SearchAddress); break; - - #undef DO_SEARCH_2 - #define DO_SEARCH_2(CmpFun,sf) CALL_WITH_T_STEP(sf, rs_type_size, unsigned,short, noMisalign, CmpFun,v,p); - case 'n': DO_SEARCH(SearchChanges); break; - - default: assert(!"Invalid search comparison type."); break; - } - - s_prevValuesNeedUpdate = true; - - int prevNumItems = last_rs_possible; - - CompactAddrs(); - - if(prevNumItems == last_rs_possible) - { - SetRamSearchUndoType(RamSearchHWnd, 0); // nothing to undo - } -} - - - - -template -bool CompareRelativeAtItem (bool(*cmpFun)(T,T,T), int itemIndex, T ignored, T param) -{ - return cmpFun(GetCurValueFromItemIndex(itemIndex), GetPrevValueFromItemIndex(itemIndex), param); -} -template -bool CompareSpecificAtItem (bool(*cmpFun)(T,T,T), int itemIndex, T value, T param) -{ - return cmpFun(GetCurValueFromItemIndex(itemIndex), value, param); -} -template -bool CompareAddressAtItem (bool(*cmpFun)(T,T,T), int itemIndex, T address, T param) -{ - return cmpFun(GetHardwareAddressFromItemIndex(itemIndex), address, param); -} -template -bool CompareChangesAtItem (bool(*cmpFun)(T,T,T), int itemIndex, T changes, T param) -{ - return cmpFun(GetNumChangesFromItemIndex(itemIndex), changes, param); -} - -int ReadControlInt(int controlID, bool forceHex, BOOL& success) -{ - int rv = 0; - BOOL ok = false; - - if(!forceHex) - { - rv = GetDlgItemInt(RamSearchHWnd,controlID,&ok,(rs_t == 's')); - } - - if(!ok) - { - if(GetDlgItemText(RamSearchHWnd,controlID,Str_Tmp,16)) - { - for(int i = 0; Str_Tmp[i]; i++) {if(toupper(Str_Tmp[i]) == 'O') Str_Tmp[i] = '0';} - const char* strPtr = Str_Tmp; - bool negate = false; - while(strPtr[0] == '-') - strPtr++, negate = !negate; - if(strPtr[0] == '+') - strPtr++; - if(strPtr[0] == '0' && tolower(strPtr[1]) == 'x') - strPtr += 2, forceHex = true; - if(strPtr[0] == '$') - strPtr++, forceHex = true; - if(!forceHex) - { - const char* strSearchPtr = strPtr; - while(*strSearchPtr) - { - int c = tolower(*strSearchPtr++); - if(c >= 'a' && c <= 'f') - forceHex = true; - } - } - const char* formatString = forceHex ? "%X" : ((rs_t=='s') ? "%d" : "%u"); - if(sscanf(strPtr, formatString, &rv) > 0) - ok = true; - if(negate) - rv = -rv; - } - } - - success = ok; - return rv; -} - - -bool Set_RS_Val() -{ - BOOL success; - - // update rs_val - switch(rs_c) - { - case 'r': - default: - rs_val = 0; - break; - case 's': - rs_val = ReadControlInt(IDC_EDIT_COMPAREVALUE, rs_t == 'h', success); - if(!success) - return false; - if((rs_type_size == 'b' && rs_t == 's' && (rs_val < -128 || rs_val > 127)) || - (rs_type_size == 'b' && rs_t != 's' && (rs_val < 0 || rs_val > 255)) || - (rs_type_size == 'w' && rs_t == 's' && (rs_val < -32768 || rs_val > 32767)) || - (rs_type_size == 'w' && rs_t != 's' && (rs_val < 0 || rs_val > 65535))) - return false; - break; - case 'a': - rs_val = ReadControlInt(IDC_EDIT_COMPAREADDRESS, true, success); - if(!success || rs_val < 0 || rs_val > 0x06040000) - return false; - break; - case 'n': { - rs_val = ReadControlInt(IDC_EDIT_COMPARECHANGES, false, success); - if(!success || rs_val < 0 || rs_val > 0xFFFF) - return false; - } break; - } - - // also update rs_param - switch(rs_o) - { - default: - rs_param = 0; - break; - case 'd': - rs_param = ReadControlInt(IDC_EDIT_DIFFBY, false, success); - if(!success) - return false; - if(rs_param < 0) - rs_param = -rs_param; - break; - case '%': - rs_param = ReadControlInt(IDC_EDIT_MODBY, false, success); - if(!success || rs_param == 0) - return false; - break; - } - - // validate that rs_param fits in the comparison data type - { - int appliedSize = rs_type_size; - int appliedSign = rs_t; - if(rs_c == 'n') - appliedSize = 'w', appliedSign = 'u'; - if(rs_c == 'a') - appliedSize = 'd', appliedSign = 'u'; - if((appliedSize == 'b' && appliedSize == 's' && (rs_param < -128 || rs_param > 127)) || - (appliedSize == 'b' && appliedSize != 's' && (rs_param < 0 || rs_param > 255)) || - (appliedSize == 'w' && appliedSize == 's' && (rs_param < -32768 || rs_param > 32767)) || - (appliedSize == 'w' && appliedSize != 's' && (rs_param < 0 || rs_param > 65535))) - return false; - } - - return true; -} - -bool IsSatisfied(int itemIndex) -{ - if(!rs_val_valid) - return true; - int o = rs_o; - switch (rs_c) - { - #undef DO_SEARCH_2 - #define DO_SEARCH_2(CmpFun,sf) return CALL_WITH_T_SIZE_TYPES(sf, rs_type_size,(rs_t=='s'),noMisalign, CmpFun,itemIndex,rs_val,rs_param); - case 'r': DO_SEARCH(CompareRelativeAtItem); break; - case 's': DO_SEARCH(CompareSpecificAtItem); break; - - #undef DO_SEARCH_2 - #define DO_SEARCH_2(CmpFun,sf) return CALL_WITH_T_STEP(sf, rs_type_size, unsigned,int, noMisalign, CmpFun,itemIndex,rs_val,rs_param); - case 'a': DO_SEARCH(CompareAddressAtItem); break; - - #undef DO_SEARCH_2 - #define DO_SEARCH_2(CmpFun,sf) return CALL_WITH_T_STEP(sf, rs_type_size, unsigned,short, noMisalign, CmpFun,itemIndex,rs_val,rs_param); - case 'n': DO_SEARCH(CompareChangesAtItem); break; - } - return false; -} - - - -// this is mainly for the RAM watch window -unsigned int ReadValueAtSoftwareAddress(const unsigned char* address, unsigned int size, int byteSwapped = false) -{ - unsigned int value = 0; - if(!byteSwapped) - { - // convert to current endianness - for(unsigned int i = 0; i < size; i++) - { - value <<= 8; - value |= *address++; - } - } - else - { - // byte-swap and convert to current endianness at the same time - for(unsigned int i = 0; i < size; i++) - { - value <<= 8; - value |= *((unsigned char*)((intptr_t)address++^1)); - } - } - return value; -} -void WriteValueAtSoftwareAddress(unsigned char* address, unsigned int value, unsigned int size, int byteSwapped = false) -{ - if(!byteSwapped) - { - // write as big endian - for(int i = size-1; i >= 0; i--) - { - address[i] = value & 0xFF; - value >>= 8; - } - } - else - { - // byte-swap and write as big endian at the same time - for(int i = size-1; i >= 0; i--) - { - *((unsigned char*)((intptr_t)(address+i)^1)) = value & 0xFF; - value >>= 8; - } - } -} -inline bool IsInRange(unsigned int x, unsigned int min, unsigned int size) -{ - x -= min; - return x < size; -} -unsigned int ReadValueAtHardwareAddress(unsigned int address, unsigned int size) -{ - if((address & ~0xFFFFFF) == ~0xFFFFFF) - address &= 0xFFFFFF; - - - char buf[4]; - MMU_DumpMemBlock(0, address, 4, (u8*)buf); - - u32 val_u32 = *(u32*)buf; - u16 val_u16 = *(u16*)buf; - u8 val_u8 = *(u8*)buf; - - switch (size) - { - case 1: return val_u8; - case 2: return val_u16; - case 4: return val_u32; - } -// if(IsInRange(address, 0xFF0000, _68K_RAM_SIZE)) -// return ReadValueAtSoftwareAddress(Ram_68k + address - 0xFF0000, size, true); -/* if(IsInRange(address, 0xFF0000, _68K_RAM_SIZE)) TODO - return ReadValueAtSoftwareAddress(Ram_68k + address - 0xFF0000, size, true); - if(IsInRange(address, 0xA00000, Z80_RAM_SIZE)) - return ReadValueAtSoftwareAddress(Ram_Z80 + address - 0xA00000, size, true); - if(SegaCD_Started && IsInRange(address, 0x020000, SEGACD_RAM_PRG_SIZE)) - return ReadValueAtSoftwareAddress(Ram_Prg + address - 0x020000, size, true); - if(SegaCD_Started && IsInRange(address, 0x200000, SEGACD_1M_RAM_SIZE)) - return ReadValueAtSoftwareAddress(((Ram_Word_State & 0x2) ? Ram_Word_1M : Ram_Word_2M) + address - 0x200000, size, true); - if(IsInRange(address, 0x0, Rom_Size)) - return ReadValueAtSoftwareAddress(Rom_Data + address, size, true); - if(_32X_Started && IsInRange(address, 0x06000000, _32X_RAM_SIZE)) - return ReadValueAtSoftwareAddress(_32X_Ram + address - 0x06000000, size, false);*/ - return 0; -} -bool WriteValueAtHardwareRAMAddress(unsigned int address, unsigned int value, unsigned int size, bool hookless) -{ - if((address & ~0xFFFFFF) == ~0xFFFFFF) - address &= 0xFFFFFF; -/* if(IsInRange(address, 0xFF0000, _68K_RAM_SIZE)) TODO - WriteValueAtSoftwareAddress(Ram_68k + address - 0xFF0000, value, size, true); - else if(IsInRange(address, 0xA00000, Z80_RAM_SIZE)) - WriteValueAtSoftwareAddress(Ram_Z80 + address - 0xA00000, value, size, true); - else if(SegaCD_Started && IsInRange(address, 0x020000, SEGACD_RAM_PRG_SIZE)) - WriteValueAtSoftwareAddress(Ram_Prg + address - 0x020000, value, size, true); - else if(SegaCD_Started && IsInRange(address, 0x200000, SEGACD_1M_RAM_SIZE)) - WriteValueAtSoftwareAddress(((Ram_Word_State & 0x2) ? Ram_Word_1M : Ram_Word_2M) + address - 0x200000, value, size, true); - else if(_32X_Started && IsInRange(address, 0x06000000, _32X_RAM_SIZE)) - WriteValueAtSoftwareAddress(_32X_Ram + address - 0x06000000, value, size, false);*/ -// else return false; -// if(!hookless) // a script that calls e.g. memory.writebyte() should trigger write hooks -// CallRegisteredLuaMemHook(address, size, value, LUAMEMHOOK_WRITE); - return true; -} -bool WriteValueAtHardwareROMAddress(unsigned int address, unsigned int value, unsigned int size) -{ - if(IsInRange(address, 0x0, Rom_Size)) - WriteValueAtSoftwareAddress(Rom_Data + address, value, size, true); - else return false; - return true; -} -bool WriteValueAtHardwareAddress(unsigned int address, unsigned int value, unsigned int size, bool hookless=false) -{ - return WriteValueAtHardwareRAMAddress(address, value, size, hookless) || - WriteValueAtHardwareROMAddress(address, value, size); -} -bool IsHardwareRAMAddressValid(unsigned int address) -{ - if((address & ~0xFFFFFF) == ~0xFFFFFF) - address &= 0xFFFFFF; -// if(IsInRange(address, 0xFF0000, _68K_RAM_SIZE)) -// return true; -// if(IsInRange(address, 0xA00000, Z80_RAM_SIZE)) -// return true; - - return true; //TODO -/* if(SegaCD_Started && IsInRange(address, 0x020000, SEGACD_RAM_PRG_SIZE)) TODO - return true; - if(SegaCD_Started && IsInRange(address, 0x200000, SEGACD_1M_RAM_SIZE)) - return true; - if(_32X_Started && IsInRange(address, 0x06000000, _32X_RAM_SIZE)) - return true;*/ - return false; -} -bool IsHardwareROMAddressValid(unsigned int address) -{ - return IsInRange(address, 0x0, Rom_Size); -} -bool IsHardwareAddressValid(unsigned int address) -{ - return IsHardwareROMAddressValid(address) || IsHardwareRAMAddressValid(address); -} - - - -int ResultCount=0; -bool AutoSearch=false; -bool AutoSearchAutoRetry=false; -LRESULT CALLBACK PromptWatchNameProc(HWND, UINT, WPARAM, LPARAM); -void UpdatePossibilities(int rs_possible, int regions); - - -void CompactAddrs() -{ - int size = (rs_type_size=='b' || !noMisalign) ? 1 : 2; - int prevResultCount = ResultCount; - - CalculateItemIndices(size); - - ResultCount = CALL_WITH_T_SIZE_TYPES(CountRegionItemsT, rs_type_size,rs_t=='s',noMisalign); - UpdatePossibilities(ResultCount, (int)s_activeMemoryRegions.size()); - - if(ResultCount != prevResultCount) - ListView_SetItemCount(GetDlgItem(RamSearchHWnd,IDC_RAMLIST),ResultCount); -} - -void soft_reset_address_info () -{ - ResetMemoryRegions(); - memset(buffers->s_numChanges, 0, sizeof(buffers->s_numChanges)); - CompactAddrs(); -} -void reset_address_info () -{ - SetRamSearchUndoType(RamSearchHWnd, 0); - s_activeMemoryRegionsBackup.clear(); // not necessary, but we'll take the time hit here instead of at the next thing that sets up an undo - memcpy(buffers->s_prevValues, buffers->s_curValues, sizeof(buffers->s_prevValues)); - s_prevValuesNeedUpdate = false; - ResetMemoryRegions(); - if(!RamSearchHWnd) - { - s_activeMemoryRegions.clear(); - ResultCount = 0; - } - else - { - // force s_prevValues to be valid - signal_new_frame(); - s_prevValuesNeedUpdate = true; - signal_new_frame(); - } - memset(buffers->s_numChanges, 0, sizeof(buffers->s_numChanges)); - CompactAddrs(); -} - -void signal_new_frame () -{ - CALL_WITH_T_SIZE_TYPES(UpdateRegionsT, rs_type_size,rs_t=='s',noMisalign); -} - - - - - - - -void RefreshRamListSelectedCountControlStatus(HWND hDlg) -{ - static int prevSelCount=-1; - int selCount = ListView_GetSelectedCount(GetDlgItem(hDlg,IDC_RAMLIST)); - if(selCount != prevSelCount) - { - if(selCount < 2 || prevSelCount < 2) - { - EnableWindow(GetDlgItem(hDlg, IDC_C_WATCH), (selCount == 1 && WatchCount < MAX_WATCH_COUNT) ? TRUE : FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_C_ADDCHEAT), (selCount == 1) ? /*TRUE*/FALSE : FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_C_ELIMINATE), (selCount >= 1) ? TRUE : FALSE); - } - prevSelCount = selCount; - } -} - - - - -struct AddrRange -{ - unsigned int addr; - unsigned int size; - unsigned int End() const { return addr + size; } - AddrRange(unsigned int a, unsigned int s) : addr(a),size(s){} -}; - -void signal_new_size () -{ - HWND lv = GetDlgItem(RamSearchHWnd,IDC_RAMLIST); - - int oldSize = (rs_last_type_size=='b' || !rs_last_no_misalign) ? 1 : 2; - int newSize = (rs_type_size=='b' || !noMisalign) ? 1 : 2; - bool numberOfItemsChanged = (oldSize != newSize); - - unsigned int itemsPerPage = ListView_GetCountPerPage(lv); - unsigned int oldTopIndex = ListView_GetTopIndex(lv); - unsigned int oldSelectionIndex = ListView_GetSelectionMark(lv); - unsigned int oldTopAddr = CALL_WITH_T_SIZE_TYPES(GetHardwareAddressFromItemIndex, rs_last_type_size,rs_t=='s',rs_last_no_misalign, oldTopIndex); - unsigned int oldSelectionAddr = CALL_WITH_T_SIZE_TYPES(GetHardwareAddressFromItemIndex, rs_last_type_size,rs_t=='s',rs_last_no_misalign, oldSelectionIndex); - - std::vector selHardwareAddrs; - if(numberOfItemsChanged) - { - // store selection ranges - // unfortunately this can take a while if the user has a huge range of items selected -// Clear_Sound_Buffer(); - int selCount = ListView_GetSelectedCount(lv); - int size = (rs_last_type_size=='b' || !rs_last_no_misalign) ? 1 : 2; - int watchIndex = -1; - for(int i = 0; i < selCount; ++i) - { - watchIndex = ListView_GetNextItem(lv, watchIndex, LVNI_SELECTED); - int addr = CALL_WITH_T_SIZE_TYPES(GetHardwareAddressFromItemIndex, rs_last_type_size,rs_t=='s',rs_last_no_misalign, watchIndex); - if(!selHardwareAddrs.empty() && addr == selHardwareAddrs.back().End()) - selHardwareAddrs.back().size += size; - else - selHardwareAddrs.push_back(AddrRange(addr,size)); - } - } - - CompactAddrs(); - - rs_last_type_size = rs_type_size; - rs_last_no_misalign = noMisalign; - - if(numberOfItemsChanged) - { - // restore selection ranges - unsigned int newTopIndex = CALL_WITH_T_SIZE_TYPES(HardwareAddressToItemIndex, rs_type_size,rs_t=='s',noMisalign, oldTopAddr); - unsigned int newBottomIndex = newTopIndex + itemsPerPage - 1; - SendMessage(lv, WM_SETREDRAW, FALSE, 0); - ListView_SetItemState(lv, -1, 0, LVIS_SELECTED|LVIS_FOCUSED); // deselect all - for(unsigned int i = 0; i < selHardwareAddrs.size(); i++) - { - // calculate index ranges of this selection - const AddrRange& range = selHardwareAddrs[i]; - int selRangeTop = CALL_WITH_T_SIZE_TYPES(HardwareAddressToItemIndex, rs_type_size,rs_t=='s',noMisalign, range.addr); - int selRangeBottom = -1; - for(int endAddr = range.End()-1; endAddr >= selRangeTop && selRangeBottom == -1; endAddr--) - selRangeBottom = CALL_WITH_T_SIZE_TYPES(HardwareAddressToItemIndex, rs_type_size,rs_t=='s',noMisalign, endAddr); - if(selRangeBottom == -1) - selRangeBottom = selRangeTop; - if(selRangeTop == -1) - continue; - - // select the entire range at once without deselecting the other ranges - // looks hacky but it works, and the only documentation I found on how to do this was blatantly false and equally hacky anyway - POINT pos; - ListView_EnsureVisible(lv, selRangeTop, 0); - ListView_GetItemPosition(lv, selRangeTop, &pos); - SendMessage(lv, WM_LBUTTONDOWN, MK_LBUTTON|MK_CONTROL, MAKELONG(pos.x,pos.y)); - ListView_EnsureVisible(lv, selRangeBottom, 0); - ListView_GetItemPosition(lv, selRangeBottom, &pos); - SendMessage(lv, WM_LBUTTONDOWN, MK_LBUTTON|MK_CONTROL|MK_SHIFT, MAKELONG(pos.x,pos.y)); - } - - // restore previous scroll position - if(newBottomIndex != -1) - ListView_EnsureVisible(lv, newBottomIndex, 0); - if(newTopIndex != -1) - ListView_EnsureVisible(lv, newTopIndex, 0); - - SendMessage(lv, WM_SETREDRAW, TRUE, 0); - - RefreshRamListSelectedCountControlStatus(RamSearchHWnd); - - EnableWindow(GetDlgItem(RamSearchHWnd,IDC_MISALIGN), rs_type_size != 'b'); - } - else - { - ListView_Update(lv, -1); - } -} - - - - -LRESULT CustomDraw (LPARAM lParam) -{ - LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam; - - switch(lplvcd->nmcd.dwDrawStage) - { - case CDDS_PREPAINT : - return CDRF_NOTIFYITEMDRAW; - - case CDDS_ITEMPREPAINT: - { - int rv = CDRF_DODEFAULT; - - if(lplvcd->nmcd.dwItemSpec % 2) - { - // alternate the background color slightly - lplvcd->clrTextBk = RGB(248,248,255); - rv = CDRF_NEWFONT; - } - - if(!IsSatisfied(lplvcd->nmcd.dwItemSpec)) - { - // tint red any items that would be eliminated if a search were to run now - lplvcd->clrText = RGB(192,64,64); - rv = CDRF_NEWFONT; - } - - return rv; - } break; - } - return CDRF_DODEFAULT; -} - -//extern "C" int disableRamSearchUpdate; -void Update_RAM_Search() //keeps RAM values up to date in the search and watch windows -{ - if (!RamSearchHWnd) return; -// if(disableRamSearchUpdate) -// return; - - if (AutoSearch && !ResultCount) - { - if(!AutoSearchAutoRetry) - { -// Clear_Sound_Buffer(); - int answer = MessageBox(RamSearchHWnd,"Choosing Retry will reset the search once and continue autosearching.\nChoose Ignore will reset the search whenever necessary and continue autosearching.\nChoosing Abort will reset the search once and stop autosearching.","Autosearch - out of results.",MB_ABORTRETRYIGNORE|MB_DEFBUTTON2|MB_ICONINFORMATION); - if(answer == IDABORT) - { - SendDlgItemMessage(RamSearchHWnd, IDC_C_AUTOSEARCH, BM_SETCHECK, BST_UNCHECKED, 0); - SendMessage(RamSearchHWnd, WM_COMMAND, IDC_C_AUTOSEARCH, 0); - } - if(answer == IDIGNORE) - AutoSearchAutoRetry = true; - } - reset_address_info(); - } - - int prevValuesNeededUpdate = s_prevValuesNeedUpdate; - if (RamSearchHWnd) - { - // update active RAM values - signal_new_frame(); - } - - if (AutoSearch && ResultCount) - { - //Clear_Sound_Buffer(); - if(!rs_val_valid) - rs_val_valid = Set_RS_Val(); - if(rs_val_valid) - prune(rs_c,rs_o,rs_t=='s',rs_val,rs_param); - } - - if(RamSearchHWnd) - { - HWND lv = GetDlgItem(RamSearchHWnd,IDC_RAMLIST); - if(prevValuesNeededUpdate != s_prevValuesNeedUpdate) - { - // previous values got updated, refresh everything visible - ListView_Update(lv, -1); - } - else - { - // refresh any visible parts of the listview box that changed - static int changes[128]; - int top = ListView_GetTopIndex(lv); - int count = ListView_GetCountPerPage(lv); - int start = -1; - for(int i = top; i <= top+count; i++) - { - int changeNum = CALL_WITH_T_SIZE_TYPES(GetNumChangesFromItemIndex, rs_type_size,rs_t=='s',noMisalign, i); //s_numChanges[i]; - int changed = changeNum != changes[i-top]; - if(changed) - changes[i-top] = changeNum; - - if(start == -1) - { - if(i != top+count && changed) - { - start = i; - //somethingChanged = true; - } - } - else - { - if(i == top+count || !changed) - { - ListView_RedrawItems(lv, start, i-1); - start = -1; - } - } - } - } - } - - if(RamWatchHWnd) - { - Update_RAM_Watch(); - } -} - -static int rs_lastPercent = -1; -inline void UpdateRamSearchProgressBar(int percent) -{ - if(rs_lastPercent != percent) - { - rs_lastPercent = percent; - UpdateRamSearchTitleBar(percent); - } -} - -static void SelectEditControl(int controlID) -{ - HWND hEdit = GetDlgItem(RamSearchHWnd,controlID); - SetFocus(hEdit); - SendMessage(hEdit, EM_SETSEL, 0, -1); -} - -static BOOL SelectingByKeyboard() -{ - int a = GetKeyState(VK_LEFT); - int b = GetKeyState(VK_RIGHT); - int c = GetKeyState(VK_UP); - int d = GetKeyState(VK_DOWN); // space and tab are intentionally omitted - return (a | b | c | d) & 0x80; -} - -extern void init_list_box(HWND Box, const char* Strs[], int numColumns, int *columnWidths); - -LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - RECT r; - RECT r2; - int dx1, dy1, dx2, dy2; - static int watchIndex=0; - - switch(uMsg) - { - case WM_INITDIALOG: { - RamSearchHWnd = hDlg; -/* if (Full_Screen) - { - while (ShowCursor(false) >= 0); - while (ShowCursor(true) < 0); - }*/ - - GetWindowRect(MainWindow->getHWnd(), &r); - dx1 = (r.right - r.left) / 2; - dy1 = (r.bottom - r.top) / 2; - - GetWindowRect(hDlg, &r2); - dx2 = (r2.right - r2.left) / 2; - dy2 = (r2.bottom - r2.top) / 2; - - // push it away from the main window if we can - const int width = (r.right-r.left); - const int width2 = (r2.right-r2.left); - if(r.left+width2 + width < GetSystemMetrics(SM_CXSCREEN)) - { - r.right += width; - r.left += width; - } - else if((int)r.left - (int)width2 > 0) - { - r.right -= width2; - r.left -= width2; - } - - SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); - switch(rs_o) - { - case '<': - SendDlgItemMessage(hDlg, IDC_LESSTHAN, BM_SETCHECK, BST_CHECKED, 0); - break; - case '>': - SendDlgItemMessage(hDlg, IDC_MORETHAN, BM_SETCHECK, BST_CHECKED, 0); - break; - case 'l': - SendDlgItemMessage(hDlg, IDC_NOMORETHAN, BM_SETCHECK, BST_CHECKED, 0); - break; - case 'm': - SendDlgItemMessage(hDlg, IDC_NOLESSTHAN, BM_SETCHECK, BST_CHECKED, 0); - break; - case '=': - SendDlgItemMessage(hDlg, IDC_EQUALTO, BM_SETCHECK, BST_CHECKED, 0); - break; - case '!': - SendDlgItemMessage(hDlg, IDC_DIFFERENTFROM, BM_SETCHECK, BST_CHECKED, 0); - break; - case 'd': - SendDlgItemMessage(hDlg, IDC_DIFFERENTBY, BM_SETCHECK, BST_CHECKED, 0); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),true); - break; - case '%': - SendDlgItemMessage(hDlg, IDC_MODULO, BM_SETCHECK, BST_CHECKED, 0); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),true); - break; - } - switch (rs_c) - { - case 'r': - SendDlgItemMessage(hDlg, IDC_PREVIOUSVALUE, BM_SETCHECK, BST_CHECKED, 0); - break; - case 's': - SendDlgItemMessage(hDlg, IDC_SPECIFICVALUE, BM_SETCHECK, BST_CHECKED, 0); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),true); - break; - case 'a': - SendDlgItemMessage(hDlg, IDC_SPECIFICADDRESS, BM_SETCHECK, BST_CHECKED, 0); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),true); - break; - case 'n': - SendDlgItemMessage(hDlg, IDC_NUMBEROFCHANGES, BM_SETCHECK, BST_CHECKED, 0); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),true); - break; - } - switch (rs_t) - { - case 's': - SendDlgItemMessage(hDlg, IDC_SIGNED, BM_SETCHECK, BST_CHECKED, 0); - break; - case 'u': - SendDlgItemMessage(hDlg, IDC_UNSIGNED, BM_SETCHECK, BST_CHECKED, 0); - break; - case 'h': - SendDlgItemMessage(hDlg, IDC_HEX, BM_SETCHECK, BST_CHECKED, 0); - break; - } - switch (rs_type_size) - { - case 'b': - SendDlgItemMessage(hDlg, IDC_1_BYTE, BM_SETCHECK, BST_CHECKED, 0); - break; - case 'w': - SendDlgItemMessage(hDlg, IDC_2_BYTES, BM_SETCHECK, BST_CHECKED, 0); - break; - case 'd': - SendDlgItemMessage(hDlg, IDC_4_BYTES, BM_SETCHECK, BST_CHECKED, 0); - break; - } - - s_prevValuesNeedUpdate = true; - - SendDlgItemMessage(hDlg,IDC_C_AUTOSEARCH,BM_SETCHECK,AutoSearch?BST_CHECKED:BST_UNCHECKED,0); - //const char* names[5] = {"Address","Value","Previous","Changes","Notes"}; - //int widths[5] = {62,64,64,55,55}; - const char* names[] = {"Address","Value","Previous","Changes"}; - int widths[4] = {68,76,76,68}; - if (!ResultCount) - reset_address_info(); - else - { - signal_new_frame(); - CompactAddrs(); - } - init_list_box(GetDlgItem(hDlg,IDC_RAMLIST),names,4,widths); - //ListView_SetItemCount(GetDlgItem(hDlg,IDC_RAMLIST),ResultCount); - if (!noMisalign) SendDlgItemMessage(hDlg, IDC_MISALIGN, BM_SETCHECK, BST_CHECKED, 0); -// if (littleEndian) SendDlgItemMessage(hDlg, IDC_ENDIAN, BM_SETCHECK, BST_CHECKED, 0); - last_rs_possible = -1; - RefreshRamListSelectedCountControlStatus(hDlg); - - // force misalign checkbox to refresh - signal_new_size(); - - // force undo button to refresh - int undoType = s_undoType; - SetRamSearchUndoType(hDlg, -2); - SetRamSearchUndoType(hDlg, undoType); - - // force possibility count to refresh - last_rs_possible--; - UpdatePossibilities(ResultCount, (int)s_activeMemoryRegions.size()); - - rs_val_valid = Set_RS_Val(); - - ListView_SetCallbackMask(GetDlgItem(hDlg,IDC_RAMLIST), LVIS_FOCUSED|LVIS_SELECTED); - - return true; - } break; - - case WM_NOTIFY: - { - LPNMHDR lP = (LPNMHDR) lParam; - switch (lP->code) - { - case LVN_ITEMCHANGED: // selection changed event - { - NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lP; - if(pNMListView->uNewState & LVIS_FOCUSED) - { - // disable buttons that we don't have the right number of selected items for - RefreshRamListSelectedCountControlStatus(hDlg); - } - } break; - - case LVN_GETDISPINFO: - { - LV_DISPINFO *Item = (LV_DISPINFO *)lParam; - Item->item.mask = LVIF_TEXT; - Item->item.state = 0; - Item->item.iImage = 0; - const unsigned int iNum = Item->item.iItem; - static char num[11]; - switch (Item->item.iSubItem) - { - case 0: - { - int addr = CALL_WITH_T_SIZE_TYPES(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum); - sprintf(num,"%08X",addr); - Item->item.pszText = num; - } return true; - case 1: - { - int i = CALL_WITH_T_SIZE_TYPES(GetCurValueFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum); - const char* formatString = ((rs_t=='s') ? "%d" : (rs_t=='u') ? "%u" : (rs_type_size=='d' ? "%08X" : rs_type_size=='w' ? "%04X" : "%02X")); - switch (rs_type_size) - { - case 'b': - default: sprintf(num, formatString, rs_t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break; - case 'w': sprintf(num, formatString, rs_t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break; - case 'd': sprintf(num, formatString, rs_t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break; - } - Item->item.pszText = num; - } return true; - case 2: - { - int i = CALL_WITH_T_SIZE_TYPES(GetPrevValueFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum); - const char* formatString = ((rs_t=='s') ? "%d" : (rs_t=='u') ? "%u" : (rs_type_size=='d' ? "%08X" : rs_type_size=='w' ? "%04X" : "%02X")); - switch (rs_type_size) - { - case 'b': - default: sprintf(num, formatString, rs_t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break; - case 'w': sprintf(num, formatString, rs_t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break; - case 'd': sprintf(num, formatString, rs_t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break; - } - Item->item.pszText = num; - } return true; - case 3: - { - int i = CALL_WITH_T_SIZE_TYPES(GetNumChangesFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum); - sprintf(num,"%d",i); - - Item->item.pszText = num; - } return true; - //case 4: - // Item->item.pszText = rsaddrs[rsresults[iNum].Index].comment ? rsaddrs[rsresults[iNum].Index].comment : ""; - // return true; - default: - return false; - } - } - - case NM_CUSTOMDRAW: - { - SetWindowLong(hDlg, DWL_MSGRESULT, CustomDraw(lParam)); - return TRUE; - } break; - - //case LVN_ODCACHEHINT: //Copied this bit from the MSDN virtual listbox code sample. Eventually it should probably do something. - //{ - // LPNMLVCACHEHINT lpCacheHint = (LPNMLVCACHEHINT)lParam; - // return 0; - //} - //case LVN_ODFINDITEM: //Copied this bit from the MSDN virtual listbox code sample. Eventually it should probably do something. - //{ - // LPNMLVFINDITEM lpFindItem = (LPNMLVFINDITEM)lParam; - // return 0; - //} - } - } break; - - case WM_COMMAND: - { - int rv = false; - switch(LOWORD(wParam)) - { - case IDC_SIGNED: - rs_t='s'; - signal_new_size(); - {rv = true; break;} - case IDC_UNSIGNED: - rs_t='u'; - signal_new_size(); - {rv = true; break;} - case IDC_HEX: - rs_t='h'; - signal_new_size(); - {rv = true; break;} - case IDC_1_BYTE: - rs_type_size = 'b'; - signal_new_size(); - {rv = true; break;} - case IDC_2_BYTES: - rs_type_size = 'w'; - signal_new_size(); - {rv = true; break;} - case IDC_4_BYTES: - rs_type_size = 'd'; - signal_new_size(); - {rv = true; break;} - case IDC_MISALIGN: - noMisalign = !noMisalign; - //CompactAddrs(); - signal_new_size(); - {rv = true; break;} -// case IDC_ENDIAN: -// littleEndian = !littleEndian; -// signal_new_size(); - {rv = true; break;} - case IDC_LESSTHAN: - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); - rs_o = '<'; - {rv = true; break;} - case IDC_MORETHAN: - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); - rs_o = '>'; - {rv = true; break;} - case IDC_NOMORETHAN: - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); - rs_o = 'l'; - {rv = true; break;} - case IDC_NOLESSTHAN: - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); - rs_o = 'm'; - {rv = true; break;} - case IDC_EQUALTO: - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); - rs_o = '='; - {rv = true; break;} - case IDC_DIFFERENTFROM: - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); - rs_o = '!'; - {rv = true; break;} - case IDC_DIFFERENTBY: - { - rs_o = 'd'; - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),true); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); - if(!SelectingByKeyboard()) - SelectEditControl(IDC_EDIT_DIFFBY); - } {rv = true; break;} - case IDC_MODULO: - { - rs_o = '%'; - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),true); - if(!SelectingByKeyboard()) - SelectEditControl(IDC_EDIT_MODBY); - } {rv = true; break;} - case IDC_PREVIOUSVALUE: - rs_c='r'; - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),false); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),false); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),false); - {rv = true; break;} - case IDC_SPECIFICVALUE: - { - rs_c = 's'; - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),true); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),false); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),false); - if(!SelectingByKeyboard()) - SelectEditControl(IDC_EDIT_COMPAREVALUE); - {rv = true; break;} - } - case IDC_SPECIFICADDRESS: - { - rs_c = 'a'; - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),true); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),false); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),false); - if(!SelectingByKeyboard()) - SelectEditControl(IDC_EDIT_COMPAREADDRESS); - } {rv = true; break;} - case IDC_NUMBEROFCHANGES: - { - rs_c = 'n'; - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),true); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),false); - EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),false); - if(!SelectingByKeyboard()) - SelectEditControl(IDC_EDIT_COMPARECHANGES); - } {rv = true; break;} - case IDC_C_ADDCHEAT: - { -// watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST)); -// Liste_GG[CheatCount].restore = Liste_GG[CheatCount].data = rsresults[watchIndex].cur; -// Liste_GG[CheatCount].addr = rsresults[watchIndex].Address; -// Liste_GG[CheatCount].size = rs_type_size; -// Liste_GG[CheatCount].Type = rs_t; -// Liste_GG[CheatCount].oper = '='; -// Liste_GG[CheatCount].mode = 0; -// DialogBoxParam(ghInstance, MAKEINTRESOURCE(IDD_EDITCHEAT), hDlg, (DLGPROC) EditCheatProc,(LPARAM) 0); - } - case IDC_C_RESET: - { - RamSearchSaveUndoStateIfNotTooBig(RamSearchHWnd); - int prevNumItems = last_rs_possible; - - soft_reset_address_info(); - - if(prevNumItems == last_rs_possible) - SetRamSearchUndoType(RamSearchHWnd, 0); // nothing to undo - - ListView_SetItemState(GetDlgItem(hDlg,IDC_RAMLIST), -1, 0, LVIS_SELECTED); // deselect all - //ListView_SetItemCount(GetDlgItem(hDlg,IDC_RAMLIST),ResultCount); - ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST), 0); - RefreshRamListSelectedCountControlStatus(hDlg); - {rv = true; break;} - } - case IDC_C_RESET_CHANGES: - memset(buffers->s_numChanges, 0, sizeof(buffers->s_numChanges)); - ListView_Update(GetDlgItem(hDlg,IDC_RAMLIST), -1); - //SetRamSearchUndoType(hDlg, 0); - {rv = true; break;} - case IDC_C_UNDO: - if(s_undoType>0) - { -// Clear_Sound_Buffer(); - if(s_activeMemoryRegions.size() < tooManyRegionsForUndo) - { - MemoryList tempMemoryList = s_activeMemoryRegions; - s_activeMemoryRegions = s_activeMemoryRegionsBackup; - s_activeMemoryRegionsBackup = tempMemoryList; - SetRamSearchUndoType(hDlg, 3 - s_undoType); - } - else - { - s_activeMemoryRegions = s_activeMemoryRegionsBackup; - SetRamSearchUndoType(hDlg, -1); - } - CompactAddrs(); - ListView_SetItemState(GetDlgItem(hDlg,IDC_RAMLIST), -1, 0, LVIS_SELECTED); // deselect all - ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST), 0); - RefreshRamListSelectedCountControlStatus(hDlg); - } - {rv = true; break;} - case IDC_C_AUTOSEARCH: - AutoSearch = SendDlgItemMessage(hDlg, IDC_C_AUTOSEARCH, BM_GETCHECK, 0, 0) != 0; - AutoSearchAutoRetry = false; - if (!AutoSearch) {rv = true; break;} - case IDC_C_SEARCH: - { -// Clear_Sound_Buffer(); - - if(!rs_val_valid && !(rs_val_valid = Set_RS_Val())) - goto invalid_field; - - if(ResultCount) - { - RamSearchSaveUndoStateIfNotTooBig(hDlg); - - prune(rs_c,rs_o,rs_t=='s',rs_val,rs_param); - - RefreshRamListSelectedCountControlStatus(hDlg); - } - - if(!ResultCount) - { - - MessageBox(RamSearchHWnd,"Resetting search.","Out of results.",MB_OK|MB_ICONINFORMATION); - soft_reset_address_info(); - } - - {rv = true; break;} - -invalid_field: - MessageBox(RamSearchHWnd,"Invalid or out-of-bound entered value.","Error",MB_OK|MB_ICONSTOP); - if(AutoSearch) // stop autosearch if it just started - { - SendDlgItemMessage(hDlg, IDC_C_AUTOSEARCH, BM_SETCHECK, BST_UNCHECKED, 0); - SendMessage(hDlg, WM_COMMAND, IDC_C_AUTOSEARCH, 0); - } - {rv = true; break;} - } - case IDC_C_WATCH: - { - int watchItemIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST)); - if(watchItemIndex >= 0) - { - AddressWatcher tempWatch; - tempWatch.Address = CALL_WITH_T_SIZE_TYPES(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchItemIndex); - tempWatch.Size = rs_type_size; - tempWatch.Type = rs_t; - tempWatch.WrongEndian = 0; //Replace when I get little endian working - tempWatch.comment = NULL; - - bool inserted = InsertWatch(tempWatch, hDlg); - //ListView_Update(GetDlgItem(hDlg,IDC_RAMLIST), -1); - - // bring up the ram watch window if it's not already showing so the user knows where the watch went - if(inserted && !RamWatchHWnd) - SendMessage(MainWindow->getHWnd(), WM_COMMAND, ID_RAM_WATCH, 0); - SetForegroundWindow(RamSearchHWnd); - } - {rv = true; break;} - } - - // eliminate all selected items - case IDC_C_ELIMINATE: - { - RamSearchSaveUndoStateIfNotTooBig(hDlg); - - HWND ramListControl = GetDlgItem(hDlg,IDC_RAMLIST); - int size = (rs_type_size=='b' || !noMisalign) ? 1 : 2; - int selCount = ListView_GetSelectedCount(ramListControl); - int watchIndex = -1; - - // time-saving trick #1: - // condense the selected items into an array of address ranges - std::vector selHardwareAddrs; - for(int i = 0, j = 1024; i < selCount; ++i, --j) - { - watchIndex = ListView_GetNextItem(ramListControl, watchIndex, LVNI_SELECTED); - int addr = CALL_WITH_T_SIZE_TYPES(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchIndex); - if(!selHardwareAddrs.empty() && addr == selHardwareAddrs.back().End()) - selHardwareAddrs.back().size += size; - else - selHardwareAddrs.push_back(AddrRange(addr,size)); - - if(!j) UpdateRamSearchProgressBar(i * 50 / selCount), j = 1024; - } - - // now deactivate the ranges - - // time-saving trick #2: - // take advantage of the fact that the listbox items must be in the same order as the regions - MemoryList::iterator iter = s_activeMemoryRegions.begin(); - int numHardwareAddrRanges = selHardwareAddrs.size(); - for(int i = 0, j = 16; i < numHardwareAddrRanges; ++i, --j) - { - int addr = selHardwareAddrs[i].addr; - int size = selHardwareAddrs[i].size; - bool affected = false; - while(iter != s_activeMemoryRegions.end()) - { - MemoryRegion& region = *iter; - int affNow = DeactivateRegion(region, iter, addr, size); - if(affNow) - affected = true; - else if(affected) - break; - if(affNow != 2) - ++iter; - } - - if(!j) UpdateRamSearchProgressBar(50 + (i * 50 / selCount)), j = 16; - } - UpdateRamSearchTitleBar(); - - // careful -- if the above two time-saving tricks aren't working, - // the runtime can absolutely explode (seconds -> hours) when there are lots of regions - - ListView_SetItemState(ramListControl, -1, 0, LVIS_SELECTED); // deselect all - signal_new_size(); - {rv = true; break;} - } - //case IDOK: - case IDCANCEL: -/* if (Full_Screen) - { - while (ShowCursor(true) < 0); - while (ShowCursor(false) >= 0); - }*/ -// DialogsOpen--; - RamSearchHWnd = NULL; - EndDialog(hDlg, true); - {rv = true; break;} - } - - // check refresh for comparison preview color update - // also, update rs_val if needed - bool needRefresh = false; - switch(LOWORD(wParam)) - { - case IDC_LESSTHAN: - case IDC_MORETHAN: - case IDC_NOMORETHAN: - case IDC_NOLESSTHAN: - case IDC_EQUALTO: - case IDC_DIFFERENTFROM: - case IDC_DIFFERENTBY: - case IDC_MODULO: - case IDC_PREVIOUSVALUE: - case IDC_SPECIFICVALUE: - case IDC_SPECIFICADDRESS: - case IDC_NUMBEROFCHANGES: - case IDC_SIGNED: - case IDC_UNSIGNED: - case IDC_HEX: - rs_val_valid = Set_RS_Val(); - needRefresh = true; - break; - case IDC_EDIT_COMPAREVALUE: - case IDC_EDIT_COMPAREADDRESS: - case IDC_EDIT_COMPARECHANGES: - case IDC_EDIT_DIFFBY: - case IDC_EDIT_MODBY: - if(HIWORD(wParam) == EN_CHANGE) - { - rs_val_valid = Set_RS_Val(); - needRefresh = true; - } - break; - } - if(needRefresh) - ListView_Update(GetDlgItem(hDlg,IDC_RAMLIST), -1); - - - return rv; - } break; - - case WM_CLOSE: -/* if (Full_Screen) - { - while (ShowCursor(true) < 0); - while (ShowCursor(false) >= 0); - } - DialogsOpen--;*/ - RamSearchHWnd = NULL; - EndDialog(hDlg, true); - return true; - } - - return false; -} - -void UpdateRamSearchTitleBar(int percent) -{ -#define HEADER_STR " RAM Search - " -#define PROGRESS_STR " %d%% ... " -#define STATUS_STR "%d Possibilit%s (%d Region%s)" - - int poss = last_rs_possible; - int regions = last_rs_regions; - if(poss <= 0) - strcpy(Str_Tmp," RAM Search"); - else if(percent <= 0) - sprintf(Str_Tmp, HEADER_STR STATUS_STR, poss, poss==1?"y":"ies", regions, regions==1?"":"s"); - else - sprintf(Str_Tmp, PROGRESS_STR STATUS_STR, percent, poss, poss==1?"y":"ies", regions, regions==1?"":"s"); - SetWindowText(RamSearchHWnd, Str_Tmp); -} - -void UpdatePossibilities(int rs_possible, int regions) -{ - if(rs_possible != last_rs_possible) - { - last_rs_possible = rs_possible; - last_rs_regions = regions; - UpdateRamSearchTitleBar(); - } -} - -void SetRamSearchUndoType(HWND hDlg, int type) -{ - if(s_undoType != type) - { - if((s_undoType!=2 && s_undoType!=-1)!=(type!=2 && type!=-1)) - SendDlgItemMessage(hDlg,IDC_C_UNDO,WM_SETTEXT,0,(LPARAM)((type == 2 || type == -1) ? "Redo" : "Undo")); - if((s_undoType>0)!=(type>0)) - EnableWindow(GetDlgItem(hDlg,IDC_C_UNDO),type>0); - s_undoType = type; - } -} - -void RamSearchSaveUndoStateIfNotTooBig(HWND hDlg) -{ - if(s_activeMemoryRegions.size() < tooManyRegionsForUndo) - { - s_activeMemoryRegionsBackup = s_activeMemoryRegions; - SetRamSearchUndoType(hDlg, 1); - } - else - { - SetRamSearchUndoType(hDlg, 0); - } -} +//RamSearch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/ +//Authors: Upthorn, Nitsuja, adelikat + +// A few notes about this implementation of a RAM search window: +// +// Speed of update was one of the highest priories. +// This is because I wanted the RAM search window to be able to +// update every single value in RAM every single frame, and +// keep track of the exact number of frames across which each value has changed, +// without causing the emulation to run noticeably slower than normal. +// +// The data representation was changed from one entry per valid address +// to one entry per contiguous range of uneliminated addresses +// which references uniform pools of per-address properties. +// - This saves time when there are many items because +// it minimizes the amount of data that needs to be stored and processed per address. +// - It also saves time when there are few items because +// it ensures that no time is wasted in iterating through +// addresses that have already been eliminated from the search. +// +// The worst-case scenario is when every other item has been +// eliminated from the search, maximizing the number of regions. +// This implementation manages to handle even that pathological case +// acceptably well. In fact, it still updates faster than the previous implementation. +// The time spent setting up or clearing such a large number of regions +// is somewhat horrendous, but it seems reasonable to have poor worst-case speed +// during these sporadic "setup" steps to achieve an all-around faster per-update speed. +// (You can test this case by performing the search: Modulo 2 Is Specific Address 0) + +#include "resource.h" + +#include "common.h" +#include "main.h" +#include "NDSSystem.h" +#include "ramwatch.h" + +#include "ram_search.h" +#include +#include +#include "ramwatch.h" +#include +#include +#ifdef _WIN32 + #include "BaseTsd.h" + typedef INT_PTR intptr_t; +#else + #include "stdint.h" +#endif + +HWND RamSearchHWnd = NULL; + +extern HWND RamWatchHWnd; + +static char Str_Tmp[1024]; + +int Rom_Size; //TODO +unsigned char* Rom_Data; //TODO + +struct MemoryRegion +{ + unsigned int hardwareAddress; // hardware address of the start of this region + unsigned int size; // number of bytes to the end of this region + unsigned char* softwareAddress; // pointer to the start of the live emulator source values for this region + BOOL byteSwapped; // true if this is a byte-swapped region of memory + + unsigned int virtualIndex; // index into s_prevValues, s_curValues, and s_numChanges, valid after being initialized in ResetMemoryRegions() + unsigned int itemIndex; // index into listbox items, valid when s_itemIndicesInvalid is false +}; + +static struct Buffers { + unsigned char s_prevValues [MAX_RAM_SIZE+4]; // values at last search or reset + unsigned char s_curValues [MAX_RAM_SIZE+4]; // values at last frame update + unsigned short s_numChanges [MAX_RAM_SIZE+4]; // number of changes of the item starting at this virtual index address + MemoryRegion* s_itemIndexToRegionPointer [MAX_RAM_SIZE+4]; // used for random access into the memory list (trading memory size to get speed here, too bad it's so much memory), only valid when s_itemIndicesInvalid is false +} *buffers = NULL; +static BOOL s_itemIndicesInvalid = true; // if true, the link from listbox items to memory regions (s_itemIndexToRegionPointer) and the link from memory regions to list box items (MemoryRegion::itemIndex) both need to be recalculated +static BOOL s_prevValuesNeedUpdate = true; // if true, the "prev" values should be updated using the "cur" values on the next frame update signaled +static unsigned int s_maxItemIndex = 0; // max currently valid item index, the listbox sometimes tries to update things past the end of the list so we need to know this to ignore those attempts + +static const MemoryRegion s_prgRegion = { 0x02000000, 0x400000, (unsigned char*)ARM9Mem.MAIN_MEM, false}; + +/* +static const MemoryRegion s_prgRegion = { 0x020000, SEGACD_RAM_PRG_SIZE, (unsigned char*)Ram_Prg, true}; +static const MemoryRegion s_word1MRegion = { 0x200000, SEGACD_1M_RAM_SIZE, (unsigned char*)Ram_Word_1M, true}; +static const MemoryRegion s_word2MRegion = { 0x200000, SEGACD_2M_RAM_SIZE, (unsigned char*)Ram_Word_2M, true}; +static const MemoryRegion s_z80Region = { 0xA00000, Z80_RAM_SIZE, (unsigned char*)Ram_Z80, true}; +static const MemoryRegion s_68kRegion = { 0xFF0000, _68K_RAM_SIZE, (unsigned char*)Ram_68k, true}; +static const MemoryRegion s_32xRegion = {0x06000000, _32X_RAM_SIZE, (unsigned char*)_32X_Ram, false}; +*/ +// list of contiguous uneliminated memory regions +typedef std::list MemoryList; +static MemoryList s_activeMemoryRegions; + +// for undo support (could be better, but this way was really easy) +static MemoryList s_activeMemoryRegionsBackup; +static int s_undoType = 0; // 0 means can't undo, 1 means can undo, 2 means can redo + +void RamSearchSaveUndoStateIfNotTooBig(HWND hDlg); +static const int tooManyRegionsForUndo = 10000; + +void InitRamSearch() +{ + if(buffers == NULL) + { + buffers = new Buffers; + memset(buffers,0,sizeof(Buffers)); + } +} + +void ResetMemoryRegions() +{ +// Clear_Sound_Buffer(); + + s_activeMemoryRegions.clear(); + + s_activeMemoryRegions.push_back(s_prgRegion); + + /*if(Genesis_Started || _32X_Started || SegaCD_Started) + { + s_activeMemoryRegions.push_back(s_68kRegion); + s_activeMemoryRegions.push_back(s_z80Region); + if(SegaCD_Started) + { + s_activeMemoryRegions.push_back(s_prgRegion); + s_activeMemoryRegions.push_back((Ram_Word_State & 0x2) ? s_word1MRegion : s_word2MRegion); + } + if(_32X_Started) + { + s_activeMemoryRegions.push_back(s_32xRegion); + } + }*/ + + int nextVirtualIndex = 0; + for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter) + { + MemoryRegion& region = *iter; + region.virtualIndex = nextVirtualIndex; + assert(((intptr_t)region.softwareAddress & 1) == 0 && "somebody need to reimplement ReadValueAtSoftwareAddress()"); + nextVirtualIndex = region.virtualIndex + region.size; + } +// assert(nextVirtualIndex <= MAX_RAM_SIZE); TODO +} + +// eliminates a range of hardware addresses from the search results +// returns 2 if it changed the region and moved the iterator to another region +// returns 1 if it changed the region but didn't move the iterator +// returns 0 if it had no effect +// warning: don't call anything that takes an itemIndex in a loop that calls DeactivateRegion... +// doing so would be tremendously slow because DeactivateRegion invalidates the index cache +int DeactivateRegion(MemoryRegion& region, MemoryList::iterator& iter, unsigned int hardwareAddress, unsigned int size) +{ + if(hardwareAddress + size <= region.hardwareAddress || hardwareAddress >= region.hardwareAddress + region.size) + { + // region is unaffected + return 0; + } + else if(hardwareAddress > region.hardwareAddress && hardwareAddress + size >= region.hardwareAddress + region.size) + { + // erase end of region + region.size = hardwareAddress - region.hardwareAddress; + return 1; + } + else if(hardwareAddress <= region.hardwareAddress && hardwareAddress + size < region.hardwareAddress + region.size) + { + // erase start of region + int eraseSize = (hardwareAddress + size) - region.hardwareAddress; + region.hardwareAddress += eraseSize; + region.size -= eraseSize; + region.softwareAddress += eraseSize; + region.virtualIndex += eraseSize; + return 1; + } + else if(hardwareAddress <= region.hardwareAddress && hardwareAddress + size >= region.hardwareAddress + region.size) + { + // erase entire region + iter = s_activeMemoryRegions.erase(iter); + s_itemIndicesInvalid = TRUE; + return 2; + } + else //if(hardwareAddress > region.hardwareAddress && hardwareAddress + size < region.hardwareAddress + region.size) + { + // split region + int eraseSize = (hardwareAddress + size) - region.hardwareAddress; + MemoryRegion region2 = {region.hardwareAddress + eraseSize, region.size - eraseSize, region.softwareAddress + eraseSize, region.byteSwapped, region.virtualIndex + eraseSize}; + region.size = hardwareAddress - region.hardwareAddress; + iter = s_activeMemoryRegions.insert(++iter, region2); + s_itemIndicesInvalid = TRUE; + return 2; + } +} + +/* +// eliminates a range of hardware addresses from the search results +// this is a simpler but usually slower interface for the above function +void DeactivateRegion(unsigned int hardwareAddress, unsigned int size) +{ + for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ) + { + MemoryRegion& region = *iter; + if(2 != DeactivateRegion(region, iter, hardwareAddress, size)) + ++iter; + } +} +*/ + +// warning: can be slow +void CalculateItemIndices(int itemSize) +{ + unsigned int itemIndex = 0; + for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter) + { + MemoryRegion& region = *iter; + region.itemIndex = itemIndex; + int startSkipSize = ((unsigned int)(itemSize - region.hardwareAddress)) % itemSize; + unsigned int start = startSkipSize; + unsigned int end = region.size; + for(unsigned int i = start; i < end; i += itemSize) + buffers->s_itemIndexToRegionPointer[itemIndex++] = ®ion; + } + s_maxItemIndex = itemIndex; + s_itemIndicesInvalid = FALSE; +} + +template +void UpdateRegionT(const MemoryRegion& region, const MemoryRegion* nextRegionPtr) +{ + if(s_prevValuesNeedUpdate) + memcpy(buffers->s_prevValues + region.virtualIndex, buffers->s_curValues + region.virtualIndex, region.size + sizeof(compareType) - sizeof(stepType)); + + unsigned int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); + + unsigned char* sourceAddr = region.softwareAddress - region.virtualIndex; + unsigned int indexStart = region.virtualIndex + startSkipSize; + unsigned int indexEnd = region.virtualIndex + region.size; + + if(sizeof(compareType) == 1) + { + for(unsigned int i = indexStart; i < indexEnd; i++) + { + if(buffers->s_curValues[i] != sourceAddr[i^swapXOR]) // if value changed + { + buffers->s_curValues[i] = sourceAddr[i^swapXOR]; // update value + //if(s_numChanges[i] != 0xFFFF) + buffers->s_numChanges[i]++; // increase change count + } + } + } + else // it's more complicated for non-byte sizes because: + { // - more than one byte can affect a given change count entry + // - when more than one of those bytes changes simultaneously the entry's change count should only increase by 1 + // - a few of those bytes can be outside the region + + unsigned int endSkipSize = ((unsigned int)(startSkipSize - region.size)) % sizeof(stepType); + unsigned int lastIndexToRead = indexEnd + endSkipSize + sizeof(compareType) - sizeof(stepType); + unsigned int lastIndexToCopy = lastIndexToRead; + if(nextRegionPtr) + { + const MemoryRegion& nextRegion = *nextRegionPtr; + int nextStartSkipSize = ((unsigned int)(sizeof(stepType) - nextRegion.hardwareAddress)) % sizeof(stepType); + unsigned int nextIndexStart = nextRegion.virtualIndex + nextStartSkipSize; + if(lastIndexToCopy > nextIndexStart) + lastIndexToCopy = nextIndexStart; + } + + unsigned int nextValidChange [sizeof(compareType)]; + for(unsigned int i = 0; i < sizeof(compareType); i++) + nextValidChange[i] = indexStart + i; + + for(unsigned int i = indexStart, j = 0; i < lastIndexToRead; i++, j++) + { + if(buffers->s_curValues[i] != sourceAddr[i^swapXOR]) // if value of this byte changed + { + if(i < lastIndexToCopy) + buffers->s_curValues[i] = sourceAddr[i^swapXOR]; // update value + for(int k = 0; k < sizeof(compareType); k++) // loop through the previous entries that contain this byte + { + if(i >= indexEnd+k) + continue; + int m = (j-k+sizeof(compareType)) & (sizeof(compareType)-1); + if(nextValidChange[m]+sizeof(compareType) <= i+sizeof(compareType)) // if we didn't already increase the change count for this entry + { + //if(s_numChanges[i-k] != 0xFFFF) + buffers->s_numChanges[i-k]++; // increase the change count for this entry + nextValidChange[m] = i+sizeof(compareType); // and remember not to increase it again + } + } + } + } + } +} + +template +void UpdateRegionsT() +{ + for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end();) + { + const MemoryRegion& region = *iter; + ++iter; + const MemoryRegion* nextRegion = (iter == s_activeMemoryRegions.end()) ? NULL : &*iter; + + if(region.byteSwapped) + UpdateRegionT(region, nextRegion); + else + UpdateRegionT(region, nextRegion); + } + + s_prevValuesNeedUpdate = false; +} + +template +int CountRegionItemsT() +{ + if(sizeof(stepType) == 1) + { + if(s_activeMemoryRegions.empty()) + return 0; + + if(s_itemIndicesInvalid) + CalculateItemIndices(sizeof(stepType)); + + MemoryRegion& lastRegion = s_activeMemoryRegions.back(); + return lastRegion.itemIndex + lastRegion.size; + } + else // the branch above is faster but won't work if the step size isn't 1 + { + int total = 0; + for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter) + { + MemoryRegion& region = *iter; + int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); + total += (region.size - startSkipSize + (sizeof(stepType)-1)) / sizeof(stepType); + } + return total; + } +} + +// returns information about the item in the form of a "fake" region +// that has the item in it and nothing else +template +void ItemIndexToVirtualRegion(unsigned int itemIndex, MemoryRegion& virtualRegion) +{ + if(s_itemIndicesInvalid) + CalculateItemIndices(sizeof(stepType)); + + if(itemIndex >= s_maxItemIndex) + { + memset(&virtualRegion, 0, sizeof(MemoryRegion)); + return; + } + + const MemoryRegion* regionPtr = buffers->s_itemIndexToRegionPointer[itemIndex]; + const MemoryRegion& region = *regionPtr; + + int bytesWithinRegion = (itemIndex - region.itemIndex) * sizeof(stepType); + int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); + bytesWithinRegion += startSkipSize; + + virtualRegion.size = sizeof(compareType); + virtualRegion.hardwareAddress = region.hardwareAddress + bytesWithinRegion; + virtualRegion.softwareAddress = region.softwareAddress + bytesWithinRegion; + virtualRegion.virtualIndex = region.virtualIndex + bytesWithinRegion; + virtualRegion.byteSwapped = region.byteSwapped; + virtualRegion.itemIndex = itemIndex; + return; +} + +template +unsigned int ItemIndexToVirtualIndex(unsigned int itemIndex) +{ + MemoryRegion virtualRegion; + ItemIndexToVirtualRegion(itemIndex, virtualRegion); + return virtualRegion.virtualIndex; +} + +template +T ReadBigEndian(const unsigned char* data) +{ + T rv = 0; + for(int i = 0; i < sizeof(T); i++) + { + rv <<= 8; + rv |= *data++; + } + return rv; +} +template<> signed char ReadBigEndian(const unsigned char* data) { return *data; } +template<> unsigned char ReadBigEndian(const unsigned char* data) { return *data; } + + +template +compareType GetPrevValueFromVirtualIndex(unsigned int virtualIndex) +{ +// return ReadBigEndian(buffers->s_prevValues + virtualIndex); + return *(compareType*)(buffers->s_prevValues+virtualIndex); +} +template +compareType GetCurValueFromVirtualIndex(unsigned int virtualIndex) +{ +// return ReadBigEndian(buffers->s_curValues + virtualIndex); + return *(compareType*)(buffers->s_curValues+virtualIndex); +} +template +unsigned short GetNumChangesFromVirtualIndex(unsigned int virtualIndex) +{ + unsigned short num = buffers->s_numChanges[virtualIndex]; + //for(unsigned int i = 1; i < sizeof(stepType); i++) + // if(num < s_numChanges[virtualIndex+i]) + // num = s_numChanges[virtualIndex+i]; + return num; +} + +template +compareType GetPrevValueFromItemIndex(unsigned int itemIndex) +{ + int virtualIndex = ItemIndexToVirtualIndex(itemIndex); + return GetPrevValueFromVirtualIndex(virtualIndex); +} +template +compareType GetCurValueFromItemIndex(unsigned int itemIndex) +{ + int virtualIndex = ItemIndexToVirtualIndex(itemIndex); + return GetCurValueFromVirtualIndex(virtualIndex); +} +template +unsigned short GetNumChangesFromItemIndex(unsigned int itemIndex) +{ + int virtualIndex = ItemIndexToVirtualIndex(itemIndex); + return GetNumChangesFromVirtualIndex(virtualIndex); +} +template +unsigned int GetHardwareAddressFromItemIndex(unsigned int itemIndex) +{ + MemoryRegion virtualRegion; + ItemIndexToVirtualRegion(itemIndex, virtualRegion); + return virtualRegion.hardwareAddress; +} + +// this one might be unreliable, haven't used it much +template +unsigned int HardwareAddressToItemIndex(unsigned int hardwareAddress) +{ + if(s_itemIndicesInvalid) + CalculateItemIndices(sizeof(stepType)); + + for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter) + { + MemoryRegion& region = *iter; + if(hardwareAddress >= region.hardwareAddress && hardwareAddress < region.hardwareAddress + region.size) + { + int indexWithinRegion = (hardwareAddress - region.hardwareAddress) / sizeof(stepType); + return region.itemIndex + indexWithinRegion; + } + } + + return -1; +} + + + + +// workaround for a parser error in MSVC that sometimes deletes a comma preceeding a macro +// this macro takes a type and a signed/unsigned modifier, and returns the same type with that modifier whether or not the compiler decides to delete the comma between them +template +struct DummyType { typedef T t; }; +#define COMMAHACK(sign, type) DummyType::t +#ifdef _MSC_VER +#pragma warning(disable : 4114) // disable "same modifier used twice" warning that otherwise would get issued when the compiler bug happens +#endif + +// it's ugly but I can't think of a better way to call these functions that isn't also slower, since +// I need the current values of these arguments to determine which primitive types are used within the function +#define CALL_WITH_T_SIZE_TYPES(functionName, sizeTypeID, isSigned, requireAligned, ...) \ + (sizeTypeID == 'b' \ + ? (isSigned \ + ? functionName(__VA_ARGS__) \ + : functionName(__VA_ARGS__)) \ + : sizeTypeID == 'w' \ + ? (isSigned \ + ? (requireAligned \ + ? functionName(__VA_ARGS__) \ + : functionName(__VA_ARGS__)) \ + : (requireAligned \ + ? functionName(__VA_ARGS__) \ + : functionName(__VA_ARGS__))) \ + : sizeTypeID == 'd' \ + ? (isSigned \ + ? (requireAligned \ + ? functionName(__VA_ARGS__) \ + : functionName(__VA_ARGS__)) \ + : (requireAligned \ + ? functionName(__VA_ARGS__) \ + : functionName(__VA_ARGS__))) \ + : functionName(__VA_ARGS__)) + +// version that takes a forced comparison type +#define CALL_WITH_T_STEP(functionName, sizeTypeID, sign,type, requireAligned, ...) \ + (sizeTypeID == 'b' \ + ? functionName(__VA_ARGS__) \ + : sizeTypeID == 'w' \ + ? (requireAligned \ + ? functionName(__VA_ARGS__) \ + : functionName(__VA_ARGS__)) \ + : sizeTypeID == 'd' \ + ? (requireAligned \ + ? functionName(__VA_ARGS__) \ + : functionName(__VA_ARGS__)) \ + : functionName(__VA_ARGS__)) + + +// basic comparison functions: +template inline bool LessCmp (T x, T y, T i) { return x < y; } +template inline bool MoreCmp (T x, T y, T i) { return x > y; } +template inline bool LessEqualCmp (T x, T y, T i) { return x <= y; } +template inline bool MoreEqualCmp (T x, T y, T i) { return x >= y; } +template inline bool EqualCmp (T x, T y, T i) { return x == y; } +template inline bool UnequalCmp (T x, T y, T i) { return x != y; } +template inline bool DiffByCmp (T x, T y, T p) { return x - y == p || y - x == p; } +template inline bool ModIsCmp (T x, T y, T p) { return p && x % p == y; } + +// compare-to type functions: +template +void SearchRelative (bool(*cmpFun)(T,T,T), T ignored, T param) +{ + for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ) + { + MemoryRegion& region = *iter; + int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); + unsigned int start = region.virtualIndex + startSkipSize; + unsigned int end = region.virtualIndex + region.size; + for(unsigned int i = start, hwaddr = region.hardwareAddress; i < end; i += sizeof(stepType), hwaddr += sizeof(stepType)) + if(!cmpFun(GetCurValueFromVirtualIndex(i), GetPrevValueFromVirtualIndex(i), param)) + if(2 == DeactivateRegion(region, iter, hwaddr, sizeof(stepType))) + goto outerContinue; + ++iter; +outerContinue: + continue; + } +} +template +void SearchSpecific (bool(*cmpFun)(T,T,T), T value, T param) +{ + for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ) + { + MemoryRegion& region = *iter; + int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); + unsigned int start = region.virtualIndex + startSkipSize; + unsigned int end = region.virtualIndex + region.size; + for(unsigned int i = start, hwaddr = region.hardwareAddress; i < end; i += sizeof(stepType), hwaddr += sizeof(stepType)) + if(!cmpFun(GetCurValueFromVirtualIndex(i), value, param)) + if(2 == DeactivateRegion(region, iter, hwaddr, sizeof(stepType))) + goto outerContinue; + ++iter; +outerContinue: + continue; + } +} +template +void SearchAddress (bool(*cmpFun)(T,T,T), T address, T param) +{ + for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ) + { + MemoryRegion& region = *iter; + int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); + unsigned int start = region.virtualIndex + startSkipSize; + unsigned int end = region.virtualIndex + region.size; + for(unsigned int i = start, hwaddr = region.hardwareAddress; i < end; i += sizeof(stepType), hwaddr += sizeof(stepType)) + if(!cmpFun(hwaddr, address, param)) + if(2 == DeactivateRegion(region, iter, hwaddr, sizeof(stepType))) + goto outerContinue; + ++iter; +outerContinue: + continue; + } +} +template +void SearchChanges (bool(*cmpFun)(T,T,T), T changes, T param) +{ + for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ) + { + MemoryRegion& region = *iter; + int startSkipSize = ((unsigned int)(sizeof(stepType) - region.hardwareAddress)) % sizeof(stepType); + unsigned int start = region.virtualIndex + startSkipSize; + unsigned int end = region.virtualIndex + region.size; + for(unsigned int i = start, hwaddr = region.hardwareAddress; i < end; i += sizeof(stepType), hwaddr += sizeof(stepType)) + if(!cmpFun(GetNumChangesFromVirtualIndex(i), changes, param)) + if(2 == DeactivateRegion(region, iter, hwaddr, sizeof(stepType))) + goto outerContinue; + ++iter; +outerContinue: + continue; + } +} + +char rs_c='s'; +char rs_o='='; +char rs_t='s'; +int rs_param=0, rs_val=0, rs_val_valid=0; +char rs_type_size = 'b', rs_last_type_size = rs_type_size; +bool noMisalign = true, rs_last_no_misalign = noMisalign; +bool littleEndian = false; +int last_rs_possible = -1; +int last_rs_regions = -1; + +void prune(char c,char o,char t,int v,int p) +{ + // repetition-reducing macros + #define DO_SEARCH(sf) \ + switch (o) \ + { \ + case '<': DO_SEARCH_2(LessCmp,sf); break; \ + case '>': DO_SEARCH_2(MoreCmp,sf); break; \ + case '=': DO_SEARCH_2(EqualCmp,sf); break; \ + case '!': DO_SEARCH_2(UnequalCmp,sf); break; \ + case 'l': DO_SEARCH_2(LessEqualCmp,sf); break; \ + case 'm': DO_SEARCH_2(MoreEqualCmp,sf); break; \ + case 'd': DO_SEARCH_2(DiffByCmp,sf); break; \ + case '%': DO_SEARCH_2(ModIsCmp,sf); break; \ + default: assert(!"Invalid operator for this search type."); break; \ + } + + // perform the search, eliminating nonmatching values + switch (c) + { + #define DO_SEARCH_2(CmpFun,sf) CALL_WITH_T_SIZE_TYPES(sf, rs_type_size, t, noMisalign, CmpFun,v,p) + case 'r': DO_SEARCH(SearchRelative); break; + case 's': DO_SEARCH(SearchSpecific); break; + + #undef DO_SEARCH_2 + #define DO_SEARCH_2(CmpFun,sf) CALL_WITH_T_STEP(sf, rs_type_size, unsigned,int, noMisalign, CmpFun,v,p); + case 'a': DO_SEARCH(SearchAddress); break; + + #undef DO_SEARCH_2 + #define DO_SEARCH_2(CmpFun,sf) CALL_WITH_T_STEP(sf, rs_type_size, unsigned,short, noMisalign, CmpFun,v,p); + case 'n': DO_SEARCH(SearchChanges); break; + + default: assert(!"Invalid search comparison type."); break; + } + + s_prevValuesNeedUpdate = true; + + int prevNumItems = last_rs_possible; + + CompactAddrs(); + + if(prevNumItems == last_rs_possible) + { + SetRamSearchUndoType(RamSearchHWnd, 0); // nothing to undo + } +} + + + + +template +bool CompareRelativeAtItem (bool(*cmpFun)(T,T,T), int itemIndex, T ignored, T param) +{ + return cmpFun(GetCurValueFromItemIndex(itemIndex), GetPrevValueFromItemIndex(itemIndex), param); +} +template +bool CompareSpecificAtItem (bool(*cmpFun)(T,T,T), int itemIndex, T value, T param) +{ + return cmpFun(GetCurValueFromItemIndex(itemIndex), value, param); +} +template +bool CompareAddressAtItem (bool(*cmpFun)(T,T,T), int itemIndex, T address, T param) +{ + return cmpFun(GetHardwareAddressFromItemIndex(itemIndex), address, param); +} +template +bool CompareChangesAtItem (bool(*cmpFun)(T,T,T), int itemIndex, T changes, T param) +{ + return cmpFun(GetNumChangesFromItemIndex(itemIndex), changes, param); +} + +int ReadControlInt(int controlID, bool forceHex, BOOL& success) +{ + int rv = 0; + BOOL ok = false; + + if(!forceHex) + { + rv = GetDlgItemInt(RamSearchHWnd,controlID,&ok,(rs_t == 's')); + } + + if(!ok) + { + if(GetDlgItemText(RamSearchHWnd,controlID,Str_Tmp,16)) + { + for(int i = 0; Str_Tmp[i]; i++) {if(toupper(Str_Tmp[i]) == 'O') Str_Tmp[i] = '0';} + const char* strPtr = Str_Tmp; + bool negate = false; + while(strPtr[0] == '-') + strPtr++, negate = !negate; + if(strPtr[0] == '+') + strPtr++; + if(strPtr[0] == '0' && tolower(strPtr[1]) == 'x') + strPtr += 2, forceHex = true; + if(strPtr[0] == '$') + strPtr++, forceHex = true; + if(!forceHex) + { + const char* strSearchPtr = strPtr; + while(*strSearchPtr) + { + int c = tolower(*strSearchPtr++); + if(c >= 'a' && c <= 'f') + forceHex = true; + } + } + const char* formatString = forceHex ? "%X" : ((rs_t=='s') ? "%d" : "%u"); + if(sscanf(strPtr, formatString, &rv) > 0) + ok = true; + if(negate) + rv = -rv; + } + } + + success = ok; + return rv; +} + + +bool Set_RS_Val() +{ + BOOL success; + + // update rs_val + switch(rs_c) + { + case 'r': + default: + rs_val = 0; + break; + case 's': + rs_val = ReadControlInt(IDC_EDIT_COMPAREVALUE, rs_t == 'h', success); + if(!success) + return false; + if((rs_type_size == 'b' && rs_t == 's' && (rs_val < -128 || rs_val > 127)) || + (rs_type_size == 'b' && rs_t != 's' && (rs_val < 0 || rs_val > 255)) || + (rs_type_size == 'w' && rs_t == 's' && (rs_val < -32768 || rs_val > 32767)) || + (rs_type_size == 'w' && rs_t != 's' && (rs_val < 0 || rs_val > 65535))) + return false; + break; + case 'a': + rs_val = ReadControlInt(IDC_EDIT_COMPAREADDRESS, true, success); + if(!success || rs_val < 0 || rs_val > 0x06040000) + return false; + break; + case 'n': { + rs_val = ReadControlInt(IDC_EDIT_COMPARECHANGES, false, success); + if(!success || rs_val < 0 || rs_val > 0xFFFF) + return false; + } break; + } + + // also update rs_param + switch(rs_o) + { + default: + rs_param = 0; + break; + case 'd': + rs_param = ReadControlInt(IDC_EDIT_DIFFBY, false, success); + if(!success) + return false; + if(rs_param < 0) + rs_param = -rs_param; + break; + case '%': + rs_param = ReadControlInt(IDC_EDIT_MODBY, false, success); + if(!success || rs_param == 0) + return false; + break; + } + + // validate that rs_param fits in the comparison data type + { + int appliedSize = rs_type_size; + int appliedSign = rs_t; + if(rs_c == 'n') + appliedSize = 'w', appliedSign = 'u'; + if(rs_c == 'a') + appliedSize = 'd', appliedSign = 'u'; + if((appliedSize == 'b' && appliedSize == 's' && (rs_param < -128 || rs_param > 127)) || + (appliedSize == 'b' && appliedSize != 's' && (rs_param < 0 || rs_param > 255)) || + (appliedSize == 'w' && appliedSize == 's' && (rs_param < -32768 || rs_param > 32767)) || + (appliedSize == 'w' && appliedSize != 's' && (rs_param < 0 || rs_param > 65535))) + return false; + } + + return true; +} + +bool IsSatisfied(int itemIndex) +{ + if(!rs_val_valid) + return true; + int o = rs_o; + switch (rs_c) + { + #undef DO_SEARCH_2 + #define DO_SEARCH_2(CmpFun,sf) return CALL_WITH_T_SIZE_TYPES(sf, rs_type_size,(rs_t=='s'),noMisalign, CmpFun,itemIndex,rs_val,rs_param); + case 'r': DO_SEARCH(CompareRelativeAtItem); break; + case 's': DO_SEARCH(CompareSpecificAtItem); break; + + #undef DO_SEARCH_2 + #define DO_SEARCH_2(CmpFun,sf) return CALL_WITH_T_STEP(sf, rs_type_size, unsigned,int, noMisalign, CmpFun,itemIndex,rs_val,rs_param); + case 'a': DO_SEARCH(CompareAddressAtItem); break; + + #undef DO_SEARCH_2 + #define DO_SEARCH_2(CmpFun,sf) return CALL_WITH_T_STEP(sf, rs_type_size, unsigned,short, noMisalign, CmpFun,itemIndex,rs_val,rs_param); + case 'n': DO_SEARCH(CompareChangesAtItem); break; + } + return false; +} + + + +// this is mainly for the RAM watch window +unsigned int ReadValueAtSoftwareAddress(const unsigned char* address, unsigned int size, int byteSwapped = false) +{ + unsigned int value = 0; + if(!byteSwapped) + { + // convert to current endianness + for(unsigned int i = 0; i < size; i++) + { + value <<= 8; + value |= *address++; + } + } + else + { + // byte-swap and convert to current endianness at the same time + for(unsigned int i = 0; i < size; i++) + { + value <<= 8; + value |= *((unsigned char*)((intptr_t)address++^1)); + } + } + return value; +} +void WriteValueAtSoftwareAddress(unsigned char* address, unsigned int value, unsigned int size, int byteSwapped = false) +{ + if(!byteSwapped) + { + // write as big endian + for(int i = size-1; i >= 0; i--) + { + address[i] = value & 0xFF; + value >>= 8; + } + } + else + { + // byte-swap and write as big endian at the same time + for(int i = size-1; i >= 0; i--) + { + *((unsigned char*)((intptr_t)(address+i)^1)) = value & 0xFF; + value >>= 8; + } + } +} +inline bool IsInRange(unsigned int x, unsigned int min, unsigned int size) +{ + x -= min; + return x < size; +} +unsigned int ReadValueAtHardwareAddress(unsigned int address, unsigned int size) +{ + if((address & ~0xFFFFFF) == ~0xFFFFFF) + address &= 0xFFFFFF; + + + char buf[4]; + MMU_DumpMemBlock(0, address, 4, (u8*)buf); + + u32 val_u32 = *(u32*)buf; + u16 val_u16 = *(u16*)buf; + u8 val_u8 = *(u8*)buf; + + switch (size) + { + case 1: return val_u8; + case 2: return val_u16; + case 4: return val_u32; + } +// if(IsInRange(address, 0xFF0000, _68K_RAM_SIZE)) +// return ReadValueAtSoftwareAddress(Ram_68k + address - 0xFF0000, size, true); +/* if(IsInRange(address, 0xFF0000, _68K_RAM_SIZE)) TODO + return ReadValueAtSoftwareAddress(Ram_68k + address - 0xFF0000, size, true); + if(IsInRange(address, 0xA00000, Z80_RAM_SIZE)) + return ReadValueAtSoftwareAddress(Ram_Z80 + address - 0xA00000, size, true); + if(SegaCD_Started && IsInRange(address, 0x020000, SEGACD_RAM_PRG_SIZE)) + return ReadValueAtSoftwareAddress(Ram_Prg + address - 0x020000, size, true); + if(SegaCD_Started && IsInRange(address, 0x200000, SEGACD_1M_RAM_SIZE)) + return ReadValueAtSoftwareAddress(((Ram_Word_State & 0x2) ? Ram_Word_1M : Ram_Word_2M) + address - 0x200000, size, true); + if(IsInRange(address, 0x0, Rom_Size)) + return ReadValueAtSoftwareAddress(Rom_Data + address, size, true); + if(_32X_Started && IsInRange(address, 0x06000000, _32X_RAM_SIZE)) + return ReadValueAtSoftwareAddress(_32X_Ram + address - 0x06000000, size, false);*/ + return 0; +} +bool WriteValueAtHardwareRAMAddress(unsigned int address, unsigned int value, unsigned int size, bool hookless) +{ + if((address & ~0xFFFFFF) == ~0xFFFFFF) + address &= 0xFFFFFF; +/* if(IsInRange(address, 0xFF0000, _68K_RAM_SIZE)) TODO + WriteValueAtSoftwareAddress(Ram_68k + address - 0xFF0000, value, size, true); + else if(IsInRange(address, 0xA00000, Z80_RAM_SIZE)) + WriteValueAtSoftwareAddress(Ram_Z80 + address - 0xA00000, value, size, true); + else if(SegaCD_Started && IsInRange(address, 0x020000, SEGACD_RAM_PRG_SIZE)) + WriteValueAtSoftwareAddress(Ram_Prg + address - 0x020000, value, size, true); + else if(SegaCD_Started && IsInRange(address, 0x200000, SEGACD_1M_RAM_SIZE)) + WriteValueAtSoftwareAddress(((Ram_Word_State & 0x2) ? Ram_Word_1M : Ram_Word_2M) + address - 0x200000, value, size, true); + else if(_32X_Started && IsInRange(address, 0x06000000, _32X_RAM_SIZE)) + WriteValueAtSoftwareAddress(_32X_Ram + address - 0x06000000, value, size, false);*/ +// else return false; +// if(!hookless) // a script that calls e.g. memory.writebyte() should trigger write hooks +// CallRegisteredLuaMemHook(address, size, value, LUAMEMHOOK_WRITE); + return true; +} +bool WriteValueAtHardwareROMAddress(unsigned int address, unsigned int value, unsigned int size) +{ + if(IsInRange(address, 0x0, Rom_Size)) + WriteValueAtSoftwareAddress(Rom_Data + address, value, size, true); + else return false; + return true; +} +bool WriteValueAtHardwareAddress(unsigned int address, unsigned int value, unsigned int size, bool hookless=false) +{ + return WriteValueAtHardwareRAMAddress(address, value, size, hookless) || + WriteValueAtHardwareROMAddress(address, value, size); +} +bool IsHardwareRAMAddressValid(unsigned int address) +{ + if((address & ~0xFFFFFF) == ~0xFFFFFF) + address &= 0xFFFFFF; +// if(IsInRange(address, 0xFF0000, _68K_RAM_SIZE)) +// return true; +// if(IsInRange(address, 0xA00000, Z80_RAM_SIZE)) +// return true; + + return true; //TODO +/* if(SegaCD_Started && IsInRange(address, 0x020000, SEGACD_RAM_PRG_SIZE)) TODO + return true; + if(SegaCD_Started && IsInRange(address, 0x200000, SEGACD_1M_RAM_SIZE)) + return true; + if(_32X_Started && IsInRange(address, 0x06000000, _32X_RAM_SIZE)) + return true;*/ + return false; +} +bool IsHardwareROMAddressValid(unsigned int address) +{ + return IsInRange(address, 0x0, Rom_Size); +} +bool IsHardwareAddressValid(unsigned int address) +{ + return IsHardwareROMAddressValid(address) || IsHardwareRAMAddressValid(address); +} + + + +int ResultCount=0; +bool AutoSearch=false; +bool AutoSearchAutoRetry=false; +LRESULT CALLBACK PromptWatchNameProc(HWND, UINT, WPARAM, LPARAM); +void UpdatePossibilities(int rs_possible, int regions); + + +void CompactAddrs() +{ + int size = (rs_type_size=='b' || !noMisalign) ? 1 : 2; + int prevResultCount = ResultCount; + + CalculateItemIndices(size); + + ResultCount = CALL_WITH_T_SIZE_TYPES(CountRegionItemsT, rs_type_size,rs_t=='s',noMisalign); + UpdatePossibilities(ResultCount, (int)s_activeMemoryRegions.size()); + + if(ResultCount != prevResultCount) + ListView_SetItemCount(GetDlgItem(RamSearchHWnd,IDC_RAMLIST),ResultCount); +} + +void soft_reset_address_info () +{ + ResetMemoryRegions(); + memset(buffers->s_numChanges, 0, sizeof(buffers->s_numChanges)); + CompactAddrs(); +} +void reset_address_info () +{ + SetRamSearchUndoType(RamSearchHWnd, 0); + s_activeMemoryRegionsBackup.clear(); // not necessary, but we'll take the time hit here instead of at the next thing that sets up an undo + memcpy(buffers->s_prevValues, buffers->s_curValues, sizeof(buffers->s_prevValues)); + s_prevValuesNeedUpdate = false; + ResetMemoryRegions(); + if(!RamSearchHWnd) + { + s_activeMemoryRegions.clear(); + ResultCount = 0; + } + else + { + // force s_prevValues to be valid + signal_new_frame(); + s_prevValuesNeedUpdate = true; + signal_new_frame(); + } + memset(buffers->s_numChanges, 0, sizeof(buffers->s_numChanges)); + CompactAddrs(); +} + +void signal_new_frame () +{ + CALL_WITH_T_SIZE_TYPES(UpdateRegionsT, rs_type_size,rs_t=='s',noMisalign); +} + + + + + + + +void RefreshRamListSelectedCountControlStatus(HWND hDlg) +{ + static int prevSelCount=-1; + int selCount = ListView_GetSelectedCount(GetDlgItem(hDlg,IDC_RAMLIST)); + if(selCount != prevSelCount) + { + if(selCount < 2 || prevSelCount < 2) + { + EnableWindow(GetDlgItem(hDlg, IDC_C_WATCH), (selCount == 1 && WatchCount < MAX_WATCH_COUNT) ? TRUE : FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_C_ADDCHEAT), (selCount == 1) ? /*TRUE*/FALSE : FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_C_ELIMINATE), (selCount >= 1) ? TRUE : FALSE); + } + prevSelCount = selCount; + } +} + + + + +struct AddrRange +{ + unsigned int addr; + unsigned int size; + unsigned int End() const { return addr + size; } + AddrRange(unsigned int a, unsigned int s) : addr(a),size(s){} +}; + +void signal_new_size () +{ + HWND lv = GetDlgItem(RamSearchHWnd,IDC_RAMLIST); + + int oldSize = (rs_last_type_size=='b' || !rs_last_no_misalign) ? 1 : 2; + int newSize = (rs_type_size=='b' || !noMisalign) ? 1 : 2; + bool numberOfItemsChanged = (oldSize != newSize); + + unsigned int itemsPerPage = ListView_GetCountPerPage(lv); + unsigned int oldTopIndex = ListView_GetTopIndex(lv); + unsigned int oldSelectionIndex = ListView_GetSelectionMark(lv); + unsigned int oldTopAddr = CALL_WITH_T_SIZE_TYPES(GetHardwareAddressFromItemIndex, rs_last_type_size,rs_t=='s',rs_last_no_misalign, oldTopIndex); + unsigned int oldSelectionAddr = CALL_WITH_T_SIZE_TYPES(GetHardwareAddressFromItemIndex, rs_last_type_size,rs_t=='s',rs_last_no_misalign, oldSelectionIndex); + + std::vector selHardwareAddrs; + if(numberOfItemsChanged) + { + // store selection ranges + // unfortunately this can take a while if the user has a huge range of items selected +// Clear_Sound_Buffer(); + int selCount = ListView_GetSelectedCount(lv); + int size = (rs_last_type_size=='b' || !rs_last_no_misalign) ? 1 : 2; + int watchIndex = -1; + for(int i = 0; i < selCount; ++i) + { + watchIndex = ListView_GetNextItem(lv, watchIndex, LVNI_SELECTED); + int addr = CALL_WITH_T_SIZE_TYPES(GetHardwareAddressFromItemIndex, rs_last_type_size,rs_t=='s',rs_last_no_misalign, watchIndex); + if(!selHardwareAddrs.empty() && addr == selHardwareAddrs.back().End()) + selHardwareAddrs.back().size += size; + else + selHardwareAddrs.push_back(AddrRange(addr,size)); + } + } + + CompactAddrs(); + + rs_last_type_size = rs_type_size; + rs_last_no_misalign = noMisalign; + + if(numberOfItemsChanged) + { + // restore selection ranges + unsigned int newTopIndex = CALL_WITH_T_SIZE_TYPES(HardwareAddressToItemIndex, rs_type_size,rs_t=='s',noMisalign, oldTopAddr); + unsigned int newBottomIndex = newTopIndex + itemsPerPage - 1; + SendMessage(lv, WM_SETREDRAW, FALSE, 0); + ListView_SetItemState(lv, -1, 0, LVIS_SELECTED|LVIS_FOCUSED); // deselect all + for(unsigned int i = 0; i < selHardwareAddrs.size(); i++) + { + // calculate index ranges of this selection + const AddrRange& range = selHardwareAddrs[i]; + int selRangeTop = CALL_WITH_T_SIZE_TYPES(HardwareAddressToItemIndex, rs_type_size,rs_t=='s',noMisalign, range.addr); + int selRangeBottom = -1; + for(int endAddr = range.End()-1; endAddr >= selRangeTop && selRangeBottom == -1; endAddr--) + selRangeBottom = CALL_WITH_T_SIZE_TYPES(HardwareAddressToItemIndex, rs_type_size,rs_t=='s',noMisalign, endAddr); + if(selRangeBottom == -1) + selRangeBottom = selRangeTop; + if(selRangeTop == -1) + continue; + + // select the entire range at once without deselecting the other ranges + // looks hacky but it works, and the only documentation I found on how to do this was blatantly false and equally hacky anyway + POINT pos; + ListView_EnsureVisible(lv, selRangeTop, 0); + ListView_GetItemPosition(lv, selRangeTop, &pos); + SendMessage(lv, WM_LBUTTONDOWN, MK_LBUTTON|MK_CONTROL, MAKELONG(pos.x,pos.y)); + ListView_EnsureVisible(lv, selRangeBottom, 0); + ListView_GetItemPosition(lv, selRangeBottom, &pos); + SendMessage(lv, WM_LBUTTONDOWN, MK_LBUTTON|MK_CONTROL|MK_SHIFT, MAKELONG(pos.x,pos.y)); + } + + // restore previous scroll position + if(newBottomIndex != -1) + ListView_EnsureVisible(lv, newBottomIndex, 0); + if(newTopIndex != -1) + ListView_EnsureVisible(lv, newTopIndex, 0); + + SendMessage(lv, WM_SETREDRAW, TRUE, 0); + + RefreshRamListSelectedCountControlStatus(RamSearchHWnd); + + EnableWindow(GetDlgItem(RamSearchHWnd,IDC_MISALIGN), rs_type_size != 'b'); + } + else + { + ListView_Update(lv, -1); + } +} + + + + +LRESULT CustomDraw (LPARAM lParam) +{ + LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam; + + switch(lplvcd->nmcd.dwDrawStage) + { + case CDDS_PREPAINT : + return CDRF_NOTIFYITEMDRAW; + + case CDDS_ITEMPREPAINT: + { + int rv = CDRF_DODEFAULT; + + if(lplvcd->nmcd.dwItemSpec % 2) + { + // alternate the background color slightly + lplvcd->clrTextBk = RGB(248,248,255); + rv = CDRF_NEWFONT; + } + + if(!IsSatisfied(lplvcd->nmcd.dwItemSpec)) + { + // tint red any items that would be eliminated if a search were to run now + lplvcd->clrText = RGB(192,64,64); + rv = CDRF_NEWFONT; + } + + return rv; + } break; + } + return CDRF_DODEFAULT; +} + +//extern "C" int disableRamSearchUpdate; +void Update_RAM_Search() //keeps RAM values up to date in the search and watch windows +{ + if (!RamSearchHWnd) return; +// if(disableRamSearchUpdate) +// return; + + if (AutoSearch && !ResultCount) + { + if(!AutoSearchAutoRetry) + { +// Clear_Sound_Buffer(); + int answer = MessageBox(RamSearchHWnd,"Choosing Retry will reset the search once and continue autosearching.\nChoose Ignore will reset the search whenever necessary and continue autosearching.\nChoosing Abort will reset the search once and stop autosearching.","Autosearch - out of results.",MB_ABORTRETRYIGNORE|MB_DEFBUTTON2|MB_ICONINFORMATION); + if(answer == IDABORT) + { + SendDlgItemMessage(RamSearchHWnd, IDC_C_AUTOSEARCH, BM_SETCHECK, BST_UNCHECKED, 0); + SendMessage(RamSearchHWnd, WM_COMMAND, IDC_C_AUTOSEARCH, 0); + } + if(answer == IDIGNORE) + AutoSearchAutoRetry = true; + } + reset_address_info(); + } + + int prevValuesNeededUpdate = s_prevValuesNeedUpdate; + if (RamSearchHWnd) + { + // update active RAM values + signal_new_frame(); + } + + if (AutoSearch && ResultCount) + { + //Clear_Sound_Buffer(); + if(!rs_val_valid) + rs_val_valid = Set_RS_Val(); + if(rs_val_valid) + prune(rs_c,rs_o,rs_t=='s',rs_val,rs_param); + } + + if(RamSearchHWnd) + { + HWND lv = GetDlgItem(RamSearchHWnd,IDC_RAMLIST); + if(prevValuesNeededUpdate != s_prevValuesNeedUpdate) + { + // previous values got updated, refresh everything visible + ListView_Update(lv, -1); + } + else + { + // refresh any visible parts of the listview box that changed + static int changes[128]; + int top = ListView_GetTopIndex(lv); + int count = ListView_GetCountPerPage(lv); + int start = -1; + for(int i = top; i <= top+count; i++) + { + int changeNum = CALL_WITH_T_SIZE_TYPES(GetNumChangesFromItemIndex, rs_type_size,rs_t=='s',noMisalign, i); //s_numChanges[i]; + int changed = changeNum != changes[i-top]; + if(changed) + changes[i-top] = changeNum; + + if(start == -1) + { + if(i != top+count && changed) + { + start = i; + //somethingChanged = true; + } + } + else + { + if(i == top+count || !changed) + { + ListView_RedrawItems(lv, start, i-1); + start = -1; + } + } + } + } + } + + if(RamWatchHWnd) + { + Update_RAM_Watch(); + } +} + +static int rs_lastPercent = -1; +inline void UpdateRamSearchProgressBar(int percent) +{ + if(rs_lastPercent != percent) + { + rs_lastPercent = percent; + UpdateRamSearchTitleBar(percent); + } +} + +static void SelectEditControl(int controlID) +{ + HWND hEdit = GetDlgItem(RamSearchHWnd,controlID); + SetFocus(hEdit); + SendMessage(hEdit, EM_SETSEL, 0, -1); +} + +static BOOL SelectingByKeyboard() +{ + int a = GetKeyState(VK_LEFT); + int b = GetKeyState(VK_RIGHT); + int c = GetKeyState(VK_UP); + int d = GetKeyState(VK_DOWN); // space and tab are intentionally omitted + return (a | b | c | d) & 0x80; +} + +extern void init_list_box(HWND Box, const char* Strs[], int numColumns, int *columnWidths); + +LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + RECT r; + RECT r2; + int dx1, dy1, dx2, dy2; + static int watchIndex=0; + + switch(uMsg) + { + case WM_INITDIALOG: { + RamSearchHWnd = hDlg; +/* if (Full_Screen) + { + while (ShowCursor(false) >= 0); + while (ShowCursor(true) < 0); + }*/ + + GetWindowRect(MainWindow->getHWnd(), &r); + dx1 = (r.right - r.left) / 2; + dy1 = (r.bottom - r.top) / 2; + + GetWindowRect(hDlg, &r2); + dx2 = (r2.right - r2.left) / 2; + dy2 = (r2.bottom - r2.top) / 2; + + // push it away from the main window if we can + const int width = (r.right-r.left); + const int width2 = (r2.right-r2.left); + if(r.left+width2 + width < GetSystemMetrics(SM_CXSCREEN)) + { + r.right += width; + r.left += width; + } + else if((int)r.left - (int)width2 > 0) + { + r.right -= width2; + r.left -= width2; + } + + SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); + switch(rs_o) + { + case '<': + SendDlgItemMessage(hDlg, IDC_LESSTHAN, BM_SETCHECK, BST_CHECKED, 0); + break; + case '>': + SendDlgItemMessage(hDlg, IDC_MORETHAN, BM_SETCHECK, BST_CHECKED, 0); + break; + case 'l': + SendDlgItemMessage(hDlg, IDC_NOMORETHAN, BM_SETCHECK, BST_CHECKED, 0); + break; + case 'm': + SendDlgItemMessage(hDlg, IDC_NOLESSTHAN, BM_SETCHECK, BST_CHECKED, 0); + break; + case '=': + SendDlgItemMessage(hDlg, IDC_EQUALTO, BM_SETCHECK, BST_CHECKED, 0); + break; + case '!': + SendDlgItemMessage(hDlg, IDC_DIFFERENTFROM, BM_SETCHECK, BST_CHECKED, 0); + break; + case 'd': + SendDlgItemMessage(hDlg, IDC_DIFFERENTBY, BM_SETCHECK, BST_CHECKED, 0); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),true); + break; + case '%': + SendDlgItemMessage(hDlg, IDC_MODULO, BM_SETCHECK, BST_CHECKED, 0); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),true); + break; + } + switch (rs_c) + { + case 'r': + SendDlgItemMessage(hDlg, IDC_PREVIOUSVALUE, BM_SETCHECK, BST_CHECKED, 0); + break; + case 's': + SendDlgItemMessage(hDlg, IDC_SPECIFICVALUE, BM_SETCHECK, BST_CHECKED, 0); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),true); + break; + case 'a': + SendDlgItemMessage(hDlg, IDC_SPECIFICADDRESS, BM_SETCHECK, BST_CHECKED, 0); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),true); + break; + case 'n': + SendDlgItemMessage(hDlg, IDC_NUMBEROFCHANGES, BM_SETCHECK, BST_CHECKED, 0); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),true); + break; + } + switch (rs_t) + { + case 's': + SendDlgItemMessage(hDlg, IDC_SIGNED, BM_SETCHECK, BST_CHECKED, 0); + break; + case 'u': + SendDlgItemMessage(hDlg, IDC_UNSIGNED, BM_SETCHECK, BST_CHECKED, 0); + break; + case 'h': + SendDlgItemMessage(hDlg, IDC_HEX, BM_SETCHECK, BST_CHECKED, 0); + break; + } + switch (rs_type_size) + { + case 'b': + SendDlgItemMessage(hDlg, IDC_1_BYTE, BM_SETCHECK, BST_CHECKED, 0); + break; + case 'w': + SendDlgItemMessage(hDlg, IDC_2_BYTES, BM_SETCHECK, BST_CHECKED, 0); + break; + case 'd': + SendDlgItemMessage(hDlg, IDC_4_BYTES, BM_SETCHECK, BST_CHECKED, 0); + break; + } + + s_prevValuesNeedUpdate = true; + + SendDlgItemMessage(hDlg,IDC_C_AUTOSEARCH,BM_SETCHECK,AutoSearch?BST_CHECKED:BST_UNCHECKED,0); + //const char* names[5] = {"Address","Value","Previous","Changes","Notes"}; + //int widths[5] = {62,64,64,55,55}; + const char* names[] = {"Address","Value","Previous","Changes"}; + int widths[4] = {68,76,76,68}; + if (!ResultCount) + reset_address_info(); + else + { + signal_new_frame(); + CompactAddrs(); + } + init_list_box(GetDlgItem(hDlg,IDC_RAMLIST),names,4,widths); + //ListView_SetItemCount(GetDlgItem(hDlg,IDC_RAMLIST),ResultCount); + if (!noMisalign) SendDlgItemMessage(hDlg, IDC_MISALIGN, BM_SETCHECK, BST_CHECKED, 0); +// if (littleEndian) SendDlgItemMessage(hDlg, IDC_ENDIAN, BM_SETCHECK, BST_CHECKED, 0); + last_rs_possible = -1; + RefreshRamListSelectedCountControlStatus(hDlg); + + // force misalign checkbox to refresh + signal_new_size(); + + // force undo button to refresh + int undoType = s_undoType; + SetRamSearchUndoType(hDlg, -2); + SetRamSearchUndoType(hDlg, undoType); + + // force possibility count to refresh + last_rs_possible--; + UpdatePossibilities(ResultCount, (int)s_activeMemoryRegions.size()); + + rs_val_valid = Set_RS_Val(); + + ListView_SetCallbackMask(GetDlgItem(hDlg,IDC_RAMLIST), LVIS_FOCUSED|LVIS_SELECTED); + + return true; + } break; + + case WM_NOTIFY: + { + LPNMHDR lP = (LPNMHDR) lParam; + switch (lP->code) + { + case LVN_ITEMCHANGED: // selection changed event + { + NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)lP; + if(pNMListView->uNewState & LVIS_FOCUSED) + { + // disable buttons that we don't have the right number of selected items for + RefreshRamListSelectedCountControlStatus(hDlg); + } + } break; + + case LVN_GETDISPINFO: + { + LV_DISPINFO *Item = (LV_DISPINFO *)lParam; + Item->item.mask = LVIF_TEXT; + Item->item.state = 0; + Item->item.iImage = 0; + const unsigned int iNum = Item->item.iItem; + static char num[11]; + switch (Item->item.iSubItem) + { + case 0: + { + int addr = CALL_WITH_T_SIZE_TYPES(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum); + sprintf(num,"%08X",addr); + Item->item.pszText = num; + } return true; + case 1: + { + int i = CALL_WITH_T_SIZE_TYPES(GetCurValueFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum); + const char* formatString = ((rs_t=='s') ? "%d" : (rs_t=='u') ? "%u" : (rs_type_size=='d' ? "%08X" : rs_type_size=='w' ? "%04X" : "%02X")); + switch (rs_type_size) + { + case 'b': + default: sprintf(num, formatString, rs_t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break; + case 'w': sprintf(num, formatString, rs_t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break; + case 'd': sprintf(num, formatString, rs_t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break; + } + Item->item.pszText = num; + } return true; + case 2: + { + int i = CALL_WITH_T_SIZE_TYPES(GetPrevValueFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum); + const char* formatString = ((rs_t=='s') ? "%d" : (rs_t=='u') ? "%u" : (rs_type_size=='d' ? "%08X" : rs_type_size=='w' ? "%04X" : "%02X")); + switch (rs_type_size) + { + case 'b': + default: sprintf(num, formatString, rs_t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break; + case 'w': sprintf(num, formatString, rs_t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break; + case 'd': sprintf(num, formatString, rs_t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break; + } + Item->item.pszText = num; + } return true; + case 3: + { + int i = CALL_WITH_T_SIZE_TYPES(GetNumChangesFromItemIndex, rs_type_size,rs_t=='s',noMisalign, iNum); + sprintf(num,"%d",i); + + Item->item.pszText = num; + } return true; + //case 4: + // Item->item.pszText = rsaddrs[rsresults[iNum].Index].comment ? rsaddrs[rsresults[iNum].Index].comment : ""; + // return true; + default: + return false; + } + } + + case NM_CUSTOMDRAW: + { + SetWindowLong(hDlg, DWL_MSGRESULT, CustomDraw(lParam)); + return TRUE; + } break; + + //case LVN_ODCACHEHINT: //Copied this bit from the MSDN virtual listbox code sample. Eventually it should probably do something. + //{ + // LPNMLVCACHEHINT lpCacheHint = (LPNMLVCACHEHINT)lParam; + // return 0; + //} + //case LVN_ODFINDITEM: //Copied this bit from the MSDN virtual listbox code sample. Eventually it should probably do something. + //{ + // LPNMLVFINDITEM lpFindItem = (LPNMLVFINDITEM)lParam; + // return 0; + //} + } + } break; + + case WM_COMMAND: + { + int rv = false; + switch(LOWORD(wParam)) + { + case IDC_SIGNED: + rs_t='s'; + signal_new_size(); + {rv = true; break;} + case IDC_UNSIGNED: + rs_t='u'; + signal_new_size(); + {rv = true; break;} + case IDC_HEX: + rs_t='h'; + signal_new_size(); + {rv = true; break;} + case IDC_1_BYTE: + rs_type_size = 'b'; + signal_new_size(); + {rv = true; break;} + case IDC_2_BYTES: + rs_type_size = 'w'; + signal_new_size(); + {rv = true; break;} + case IDC_4_BYTES: + rs_type_size = 'd'; + signal_new_size(); + {rv = true; break;} + case IDC_MISALIGN: + noMisalign = !noMisalign; + //CompactAddrs(); + signal_new_size(); + {rv = true; break;} +// case IDC_ENDIAN: +// littleEndian = !littleEndian; +// signal_new_size(); + {rv = true; break;} + case IDC_LESSTHAN: + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); + rs_o = '<'; + {rv = true; break;} + case IDC_MORETHAN: + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); + rs_o = '>'; + {rv = true; break;} + case IDC_NOMORETHAN: + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); + rs_o = 'l'; + {rv = true; break;} + case IDC_NOLESSTHAN: + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); + rs_o = 'm'; + {rv = true; break;} + case IDC_EQUALTO: + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); + rs_o = '='; + {rv = true; break;} + case IDC_DIFFERENTFROM: + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); + rs_o = '!'; + {rv = true; break;} + case IDC_DIFFERENTBY: + { + rs_o = 'd'; + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),true); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),false); + if(!SelectingByKeyboard()) + SelectEditControl(IDC_EDIT_DIFFBY); + } {rv = true; break;} + case IDC_MODULO: + { + rs_o = '%'; + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_DIFFBY),false); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_MODBY),true); + if(!SelectingByKeyboard()) + SelectEditControl(IDC_EDIT_MODBY); + } {rv = true; break;} + case IDC_PREVIOUSVALUE: + rs_c='r'; + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),false); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),false); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),false); + {rv = true; break;} + case IDC_SPECIFICVALUE: + { + rs_c = 's'; + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),true); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),false); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),false); + if(!SelectingByKeyboard()) + SelectEditControl(IDC_EDIT_COMPAREVALUE); + {rv = true; break;} + } + case IDC_SPECIFICADDRESS: + { + rs_c = 'a'; + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),true); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),false); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),false); + if(!SelectingByKeyboard()) + SelectEditControl(IDC_EDIT_COMPAREADDRESS); + } {rv = true; break;} + case IDC_NUMBEROFCHANGES: + { + rs_c = 'n'; + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPARECHANGES),true); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREVALUE),false); + EnableWindow(GetDlgItem(hDlg,IDC_EDIT_COMPAREADDRESS),false); + if(!SelectingByKeyboard()) + SelectEditControl(IDC_EDIT_COMPARECHANGES); + } {rv = true; break;} + case IDC_C_ADDCHEAT: + { +// watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST)); +// Liste_GG[CheatCount].restore = Liste_GG[CheatCount].data = rsresults[watchIndex].cur; +// Liste_GG[CheatCount].addr = rsresults[watchIndex].Address; +// Liste_GG[CheatCount].size = rs_type_size; +// Liste_GG[CheatCount].Type = rs_t; +// Liste_GG[CheatCount].oper = '='; +// Liste_GG[CheatCount].mode = 0; +// DialogBoxParam(ghInstance, MAKEINTRESOURCE(IDD_EDITCHEAT), hDlg, (DLGPROC) EditCheatProc,(LPARAM) 0); + } + case IDC_C_RESET: + { + RamSearchSaveUndoStateIfNotTooBig(RamSearchHWnd); + int prevNumItems = last_rs_possible; + + soft_reset_address_info(); + + if(prevNumItems == last_rs_possible) + SetRamSearchUndoType(RamSearchHWnd, 0); // nothing to undo + + ListView_SetItemState(GetDlgItem(hDlg,IDC_RAMLIST), -1, 0, LVIS_SELECTED); // deselect all + //ListView_SetItemCount(GetDlgItem(hDlg,IDC_RAMLIST),ResultCount); + ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST), 0); + RefreshRamListSelectedCountControlStatus(hDlg); + {rv = true; break;} + } + case IDC_C_RESET_CHANGES: + memset(buffers->s_numChanges, 0, sizeof(buffers->s_numChanges)); + ListView_Update(GetDlgItem(hDlg,IDC_RAMLIST), -1); + //SetRamSearchUndoType(hDlg, 0); + {rv = true; break;} + case IDC_C_UNDO: + if(s_undoType>0) + { +// Clear_Sound_Buffer(); + if(s_activeMemoryRegions.size() < tooManyRegionsForUndo) + { + MemoryList tempMemoryList = s_activeMemoryRegions; + s_activeMemoryRegions = s_activeMemoryRegionsBackup; + s_activeMemoryRegionsBackup = tempMemoryList; + SetRamSearchUndoType(hDlg, 3 - s_undoType); + } + else + { + s_activeMemoryRegions = s_activeMemoryRegionsBackup; + SetRamSearchUndoType(hDlg, -1); + } + CompactAddrs(); + ListView_SetItemState(GetDlgItem(hDlg,IDC_RAMLIST), -1, 0, LVIS_SELECTED); // deselect all + ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST), 0); + RefreshRamListSelectedCountControlStatus(hDlg); + } + {rv = true; break;} + case IDC_C_AUTOSEARCH: + AutoSearch = SendDlgItemMessage(hDlg, IDC_C_AUTOSEARCH, BM_GETCHECK, 0, 0) != 0; + AutoSearchAutoRetry = false; + if (!AutoSearch) {rv = true; break;} + case IDC_C_SEARCH: + { +// Clear_Sound_Buffer(); + + if(!rs_val_valid && !(rs_val_valid = Set_RS_Val())) + goto invalid_field; + + if(ResultCount) + { + RamSearchSaveUndoStateIfNotTooBig(hDlg); + + prune(rs_c,rs_o,rs_t=='s',rs_val,rs_param); + + RefreshRamListSelectedCountControlStatus(hDlg); + } + + if(!ResultCount) + { + + MessageBox(RamSearchHWnd,"Resetting search.","Out of results.",MB_OK|MB_ICONINFORMATION); + soft_reset_address_info(); + } + + {rv = true; break;} + +invalid_field: + MessageBox(RamSearchHWnd,"Invalid or out-of-bound entered value.","Error",MB_OK|MB_ICONSTOP); + if(AutoSearch) // stop autosearch if it just started + { + SendDlgItemMessage(hDlg, IDC_C_AUTOSEARCH, BM_SETCHECK, BST_UNCHECKED, 0); + SendMessage(hDlg, WM_COMMAND, IDC_C_AUTOSEARCH, 0); + } + {rv = true; break;} + } + case IDC_C_WATCH: + { + int watchItemIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_RAMLIST)); + if(watchItemIndex >= 0) + { + AddressWatcher tempWatch; + tempWatch.Address = CALL_WITH_T_SIZE_TYPES(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchItemIndex); + tempWatch.Size = rs_type_size; + tempWatch.Type = rs_t; + tempWatch.WrongEndian = 0; //Replace when I get little endian working + tempWatch.comment = NULL; + + bool inserted = InsertWatch(tempWatch, hDlg); + //ListView_Update(GetDlgItem(hDlg,IDC_RAMLIST), -1); + + // bring up the ram watch window if it's not already showing so the user knows where the watch went + if(inserted && !RamWatchHWnd) + SendMessage(MainWindow->getHWnd(), WM_COMMAND, ID_RAM_WATCH, 0); + SetForegroundWindow(RamSearchHWnd); + } + {rv = true; break;} + } + + // eliminate all selected items + case IDC_C_ELIMINATE: + { + RamSearchSaveUndoStateIfNotTooBig(hDlg); + + HWND ramListControl = GetDlgItem(hDlg,IDC_RAMLIST); + int size = (rs_type_size=='b' || !noMisalign) ? 1 : 2; + int selCount = ListView_GetSelectedCount(ramListControl); + int watchIndex = -1; + + // time-saving trick #1: + // condense the selected items into an array of address ranges + std::vector selHardwareAddrs; + for(int i = 0, j = 1024; i < selCount; ++i, --j) + { + watchIndex = ListView_GetNextItem(ramListControl, watchIndex, LVNI_SELECTED); + int addr = CALL_WITH_T_SIZE_TYPES(GetHardwareAddressFromItemIndex, rs_type_size,rs_t=='s',noMisalign, watchIndex); + if(!selHardwareAddrs.empty() && addr == selHardwareAddrs.back().End()) + selHardwareAddrs.back().size += size; + else + selHardwareAddrs.push_back(AddrRange(addr,size)); + + if(!j) UpdateRamSearchProgressBar(i * 50 / selCount), j = 1024; + } + + // now deactivate the ranges + + // time-saving trick #2: + // take advantage of the fact that the listbox items must be in the same order as the regions + MemoryList::iterator iter = s_activeMemoryRegions.begin(); + int numHardwareAddrRanges = selHardwareAddrs.size(); + for(int i = 0, j = 16; i < numHardwareAddrRanges; ++i, --j) + { + int addr = selHardwareAddrs[i].addr; + int size = selHardwareAddrs[i].size; + bool affected = false; + while(iter != s_activeMemoryRegions.end()) + { + MemoryRegion& region = *iter; + int affNow = DeactivateRegion(region, iter, addr, size); + if(affNow) + affected = true; + else if(affected) + break; + if(affNow != 2) + ++iter; + } + + if(!j) UpdateRamSearchProgressBar(50 + (i * 50 / selCount)), j = 16; + } + UpdateRamSearchTitleBar(); + + // careful -- if the above two time-saving tricks aren't working, + // the runtime can absolutely explode (seconds -> hours) when there are lots of regions + + ListView_SetItemState(ramListControl, -1, 0, LVIS_SELECTED); // deselect all + signal_new_size(); + {rv = true; break;} + } + //case IDOK: + case IDCANCEL: +/* if (Full_Screen) + { + while (ShowCursor(true) < 0); + while (ShowCursor(false) >= 0); + }*/ +// DialogsOpen--; + RamSearchHWnd = NULL; + EndDialog(hDlg, true); + {rv = true; break;} + } + + // check refresh for comparison preview color update + // also, update rs_val if needed + bool needRefresh = false; + switch(LOWORD(wParam)) + { + case IDC_LESSTHAN: + case IDC_MORETHAN: + case IDC_NOMORETHAN: + case IDC_NOLESSTHAN: + case IDC_EQUALTO: + case IDC_DIFFERENTFROM: + case IDC_DIFFERENTBY: + case IDC_MODULO: + case IDC_PREVIOUSVALUE: + case IDC_SPECIFICVALUE: + case IDC_SPECIFICADDRESS: + case IDC_NUMBEROFCHANGES: + case IDC_SIGNED: + case IDC_UNSIGNED: + case IDC_HEX: + rs_val_valid = Set_RS_Val(); + needRefresh = true; + break; + case IDC_EDIT_COMPAREVALUE: + case IDC_EDIT_COMPAREADDRESS: + case IDC_EDIT_COMPARECHANGES: + case IDC_EDIT_DIFFBY: + case IDC_EDIT_MODBY: + if(HIWORD(wParam) == EN_CHANGE) + { + rs_val_valid = Set_RS_Val(); + needRefresh = true; + } + break; + } + if(needRefresh) + ListView_Update(GetDlgItem(hDlg,IDC_RAMLIST), -1); + + + return rv; + } break; + + case WM_CLOSE: +/* if (Full_Screen) + { + while (ShowCursor(true) < 0); + while (ShowCursor(false) >= 0); + } + DialogsOpen--;*/ + RamSearchHWnd = NULL; + EndDialog(hDlg, true); + return true; + } + + return false; +} + +void UpdateRamSearchTitleBar(int percent) +{ +#define HEADER_STR " RAM Search - " +#define PROGRESS_STR " %d%% ... " +#define STATUS_STR "%d Possibilit%s (%d Region%s)" + + int poss = last_rs_possible; + int regions = last_rs_regions; + if(poss <= 0) + strcpy(Str_Tmp," RAM Search"); + else if(percent <= 0) + sprintf(Str_Tmp, HEADER_STR STATUS_STR, poss, poss==1?"y":"ies", regions, regions==1?"":"s"); + else + sprintf(Str_Tmp, PROGRESS_STR STATUS_STR, percent, poss, poss==1?"y":"ies", regions, regions==1?"":"s"); + SetWindowText(RamSearchHWnd, Str_Tmp); +} + +void UpdatePossibilities(int rs_possible, int regions) +{ + if(rs_possible != last_rs_possible) + { + last_rs_possible = rs_possible; + last_rs_regions = regions; + UpdateRamSearchTitleBar(); + } +} + +void SetRamSearchUndoType(HWND hDlg, int type) +{ + if(s_undoType != type) + { + if((s_undoType!=2 && s_undoType!=-1)!=(type!=2 && type!=-1)) + SendDlgItemMessage(hDlg,IDC_C_UNDO,WM_SETTEXT,0,(LPARAM)((type == 2 || type == -1) ? "Redo" : "Undo")); + if((s_undoType>0)!=(type>0)) + EnableWindow(GetDlgItem(hDlg,IDC_C_UNDO),type>0); + s_undoType = type; + } +} + +void RamSearchSaveUndoStateIfNotTooBig(HWND hDlg) +{ + if(s_activeMemoryRegions.size() < tooManyRegionsForUndo) + { + s_activeMemoryRegionsBackup = s_activeMemoryRegions; + SetRamSearchUndoType(hDlg, 1); + } + else + { + SetRamSearchUndoType(hDlg, 0); + } +} diff --git a/desmume/src/windows/ram_search.h b/src/windows/ram_search.h similarity index 97% rename from desmume/src/windows/ram_search.h rename to src/windows/ram_search.h index e349b34dc..7d1cd6091 100644 --- a/desmume/src/windows/ram_search.h +++ b/src/windows/ram_search.h @@ -1,52 +1,52 @@ -//RamSearch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/ -//Authors: Upthorn, Nitsuja, adelikat - -#ifndef RAM_SEARCH_H -#define RAM_SEARCH_H - - -//64k in Ram_68k[], 8k in Ram_Z80[] -//#define _68K_RAM_SIZE 64*1024 -//#define Z80_RAM_SIZE 8*1024 -/*#define SRAM_SIZE (((SRAM_End - SRAM_Start) > 2) ? SRAM_End - SRAM_Start : 0) -#define BRAM_SIZE ((8 << BRAM_Ex_Size) * 1024)*/ -//#define GENESIS_RAM_SIZE (_68K_RAM_SIZE + Z80_RAM_SIZE) - -//_32X_Ram[] -//#define _32X_RAM_SIZE 256*1024 - -//512k in Ram_Prg, 256k in Ram_Word_1M and Ram_Word_2M -//(docs say 6Mbit of ram, but I'm not sure what's used when) -//#define SEGACD_RAM_PRG_SIZE 512*1024 -//#define SEGACD_1M_RAM_SIZE 256*1024 -//#define SEGACD_2M_RAM_SIZE 256*1024 -//#define SEGACD_RAM_SIZE (SEGACD_RAM_PRG_SIZE + SEGACD_2M_RAM_SIZE) - - -//#define MAX_RAM_SIZE (0x112000) -//#define MAX_RAM_SIZE (0xD2000) -#define MAX_RAM_SIZE (0x400000) - -extern char rs_type_size; -extern int ResultCount; - -unsigned int sizeConv(unsigned int index,char size, char *prevSize = &rs_type_size, bool usePrev = false); -unsigned int GetRamValue(unsigned int Addr,char Size); -void prune(char Search, char Operater, char Type, int Value, int OperatorParameter); -void CompactAddrs(); -void reset_address_info(); -void signal_new_frame(); -void signal_new_size(); -void UpdateRamSearchTitleBar(int percent = 0); -void Update_RAM_Search(); -void SetRamSearchUndoType(HWND hDlg, int type); -unsigned int ReadValueAtHardwareAddress(unsigned int address, unsigned int size); -bool WriteValueAtHardwareRAMAddress(unsigned int address, unsigned int value, unsigned int size, bool hookless=false); -bool IsHardwareRAMAddressValid(unsigned int address); -extern int curr_ram_size; -extern bool noMisalign; -extern bool littleEndian; - - -#endif - +//RamSearch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/ +//Authors: Upthorn, Nitsuja, adelikat + +#ifndef RAM_SEARCH_H +#define RAM_SEARCH_H + + +//64k in Ram_68k[], 8k in Ram_Z80[] +//#define _68K_RAM_SIZE 64*1024 +//#define Z80_RAM_SIZE 8*1024 +/*#define SRAM_SIZE (((SRAM_End - SRAM_Start) > 2) ? SRAM_End - SRAM_Start : 0) +#define BRAM_SIZE ((8 << BRAM_Ex_Size) * 1024)*/ +//#define GENESIS_RAM_SIZE (_68K_RAM_SIZE + Z80_RAM_SIZE) + +//_32X_Ram[] +//#define _32X_RAM_SIZE 256*1024 + +//512k in Ram_Prg, 256k in Ram_Word_1M and Ram_Word_2M +//(docs say 6Mbit of ram, but I'm not sure what's used when) +//#define SEGACD_RAM_PRG_SIZE 512*1024 +//#define SEGACD_1M_RAM_SIZE 256*1024 +//#define SEGACD_2M_RAM_SIZE 256*1024 +//#define SEGACD_RAM_SIZE (SEGACD_RAM_PRG_SIZE + SEGACD_2M_RAM_SIZE) + + +//#define MAX_RAM_SIZE (0x112000) +//#define MAX_RAM_SIZE (0xD2000) +#define MAX_RAM_SIZE (0x400000) + +extern char rs_type_size; +extern int ResultCount; + +unsigned int sizeConv(unsigned int index,char size, char *prevSize = &rs_type_size, bool usePrev = false); +unsigned int GetRamValue(unsigned int Addr,char Size); +void prune(char Search, char Operater, char Type, int Value, int OperatorParameter); +void CompactAddrs(); +void reset_address_info(); +void signal_new_frame(); +void signal_new_size(); +void UpdateRamSearchTitleBar(int percent = 0); +void Update_RAM_Search(); +void SetRamSearchUndoType(HWND hDlg, int type); +unsigned int ReadValueAtHardwareAddress(unsigned int address, unsigned int size); +bool WriteValueAtHardwareRAMAddress(unsigned int address, unsigned int value, unsigned int size, bool hookless=false); +bool IsHardwareRAMAddressValid(unsigned int address); +extern int curr_ram_size; +extern bool noMisalign; +extern bool littleEndian; + + +#endif + diff --git a/desmume/src/windows/ramwatch.cpp b/src/windows/ramwatch.cpp similarity index 96% rename from desmume/src/windows/ramwatch.cpp rename to src/windows/ramwatch.cpp index 89e1390a6..e5e631dd8 100644 --- a/desmume/src/windows/ramwatch.cpp +++ b/src/windows/ramwatch.cpp @@ -1,1084 +1,1084 @@ -//RamWatch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/ -//Authors: Upthorn, Nitsuja, adelikat - -#include "main.h" -#include "resource.h" -#include "common.h" -#include "NDSSystem.h" -#include "ramwatch.h" -#include "ram_search.h" -#include -#include -#include -#include -#include "path.h" - -HWND RamWatchHWnd = NULL; - -#define MESSAGEBOXPARENT (RamWatchHWnd ? RamWatchHWnd : MainWindow->getHWnd()) - -static char Str_Tmp[1024]; -std::string Rom_Name; - -static HMENU ramwatchmenu; -static HMENU rwrecentmenu; -static HACCEL RamWatchAccels = NULL; -char rw_recent_files[MAX_RECENT_WATCHES][1024]; -char Watch_Dir[1024]=""; -const unsigned int RW_MENU_FIRST_RECENT_FILE = 600; -bool RWfileChanged = false; //Keeps track of whether the current watch file has been changed, if so, ramwatch will prompt to save changes -bool AutoRWLoad = false; //Keeps track of whether Auto-load is checked -bool RWSaveWindowPos = false; //Keeps track of whether Save Window position is checked -char currentWatch[1024]; -int ramw_x, ramw_y; //Used to store ramwatch dialog window positions -AddressWatcher rswatches[MAX_WATCH_COUNT]; -int WatchCount=0; - -bool QuickSaveWatches(); -bool ResetWatches(); - -unsigned int GetCurrentValue(AddressWatcher& watch) -{ - char buf[4]; - MMU_DumpMemBlock(0, watch.Address, 4, (u8*)buf); - - u32 val_u32 = *(u32*)buf; - u16 val_u16 = *(u16*)buf; - u8 val_u8 = *(u8*)buf; - - switch (watch.Size) - { - case 0x62: return val_u8; - case 0x77: return val_u16; - case 0x64: return val_u32; - default: return 0; - } -// return ReadValueAtHardwareAddress(watch.Address, watch.Size == 'd' ? 4 : watch.Size == 'w' ? 2 : 1); -} - -bool IsSameWatch(const AddressWatcher& l, const AddressWatcher& r) -{ - return ((l.Address == r.Address) && (l.Size == r.Size) && (l.Type == r.Type)/* && (l.WrongEndian == r.WrongEndian)*/); -} - -bool VerifyWatchNotAlreadyAdded(const AddressWatcher& watch) -{ - for (int j = 0; j < WatchCount; j++) - { - if (IsSameWatch(rswatches[j], watch)) - { - if(RamWatchHWnd) - SetForegroundWindow(RamWatchHWnd); - return false; - } - } - return true; -} - - -bool InsertWatch(const AddressWatcher& Watch, char *Comment) -{ - if(!VerifyWatchNotAlreadyAdded(Watch)) - return false; - - if(WatchCount >= MAX_WATCH_COUNT) - return false; - - int i = WatchCount++; - AddressWatcher& NewWatch = rswatches[i]; - NewWatch = Watch; - //if (NewWatch.comment) free(NewWatch.comment); - NewWatch.comment = (char *) malloc(strlen(Comment)+2); - NewWatch.CurValue = GetCurrentValue(NewWatch); - strcpy(NewWatch.comment, Comment); - ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); - RWfileChanged=true; - - return true; -} - -LRESULT CALLBACK PromptWatchNameProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) //Gets the description of a watched address -{ - RECT r; - RECT r2; - int dx1, dy1, dx2, dy2; - - switch(uMsg) - { - case WM_INITDIALOG: - GetWindowRect(MainWindow->getHWnd(), &r); - dx1 = (r.right - r.left) / 2; - dy1 = (r.bottom - r.top) / 2; - - GetWindowRect(hDlg, &r2); - dx2 = (r2.right - r2.left) / 2; - dy2 = (r2.bottom - r2.top) / 2; - - SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); - strcpy(Str_Tmp,"Enter a name for this RAM address."); - //SendDlgItemMessage(hDlg,IDC_PROMPT_TEXT,WM_SETTEXT,0,(LPARAM)Str_Tmp); - strcpy(Str_Tmp,""); - //SendDlgItemMessage(hDlg,IDC_PROMPT_TEXT2,WM_SETTEXT,0,(LPARAM)Str_Tmp); - return true; - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: - { - GetDlgItemText(hDlg,IDC_PROMPT_EDIT,Str_Tmp,80); - InsertWatch(rswatches[WatchCount],Str_Tmp); - EndDialog(hDlg, true); - return true; - break; - } - case IDCANCEL: - - EndDialog(hDlg, false); - return false; - break; - } - break; - - case WM_CLOSE: - EndDialog(hDlg, false); - return false; - break; - } - - return false; -} - -bool InsertWatch(const AddressWatcher& Watch, HWND parent) -{ - if(!VerifyWatchNotAlreadyAdded(Watch)) - return false; - - if(!parent) - parent = RamWatchHWnd; - if(!parent) - parent = MainWindow->getHWnd(); - - int prevWatchCount = WatchCount; - - rswatches[WatchCount] = Watch; - rswatches[WatchCount].CurValue = GetCurrentValue(rswatches[WatchCount]); - DialogBox(hAppInst, MAKEINTRESOURCE(IDD_PROMPT), parent, (DLGPROC) PromptWatchNameProc); - - return WatchCount > prevWatchCount; -} - -void Update_RAM_Watch() -{ - if (!RamWatchHWnd) return; - - // update cached values and detect changes to displayed listview items - BOOL watchChanged[MAX_WATCH_COUNT] = {0}; - for(int i = 0; i < WatchCount; i++) - { - unsigned int prevCurValue = rswatches[i].CurValue; - unsigned int newCurValue = GetCurrentValue(rswatches[i]); - if(prevCurValue != newCurValue) - { - rswatches[i].CurValue = newCurValue; - watchChanged[i] = TRUE; - } - } - - // refresh any visible parts of the listview box that changed - HWND lv = GetDlgItem(RamWatchHWnd,IDC_WATCHLIST); - int top = ListView_GetTopIndex(lv); - int bottom = top + ListView_GetCountPerPage(lv) + 1; // +1 is so we will update a partially-displayed last item - if(top < 0) top = 0; - if(bottom > WatchCount) bottom = WatchCount; - int start = -1; - for(int i = top; i <= bottom; i++) - { - if(start == -1) - { - if(i != bottom && watchChanged[i]) - { - start = i; - //somethingChanged = true; - } - } - else - { - if(i == bottom || !watchChanged[i]) - { - ListView_RedrawItems(lv, start, i-1); - start = -1; - } - } - } -} - -bool AskSave() -{ - //This function asks to save changes if the watch file contents have changed - //returns false only if a save was attempted but failed or was cancelled - if (RWfileChanged) - { - HWND Hwnd = MainWindow->getHWnd(); - int answer = MessageBox(Hwnd, "Save Changes?", "Ram Watch", MB_YESNOCANCEL); - if(answer == IDYES) - if(!QuickSaveWatches()) - return false; - return (answer != IDCANCEL); - } - return true; -} - - -void UpdateRW_RMenu(HMENU menu, unsigned int mitem, unsigned int baseid) -{ - MENUITEMINFO moo; - int x; - - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_SUBMENU | MIIM_STATE; - - GetMenuItemInfo(GetSubMenu(ramwatchmenu, 0), mitem, FALSE, &moo); - moo.hSubMenu = menu; - moo.fState = strlen(rw_recent_files[0]) ? MFS_ENABLED : MFS_GRAYED; - - SetMenuItemInfo(GetSubMenu(ramwatchmenu, 0), mitem, FALSE, &moo); - - // Remove all recent files submenus - for(x = 0; x < MAX_RECENT_WATCHES; x++) - { - RemoveMenu(menu, baseid + x, MF_BYCOMMAND); - } - - // Recreate the menus - for(x = MAX_RECENT_WATCHES - 1; x >= 0; x--) - { - char tmp[128 + 5]; - - // Skip empty strings - if(!strlen(rw_recent_files[x])) - { - continue; - } - - moo.cbSize = sizeof(moo); - moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; - - // Fill in the menu text. - if(strlen(rw_recent_files[x]) < 128) - { - sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, rw_recent_files[x]); - } - else - { - sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, rw_recent_files[x] + strlen( rw_recent_files[x] ) - 127); - } - - // Insert the menu item - moo.cch = strlen(tmp); - moo.fType = 0; - moo.wID = baseid + x; - moo.dwTypeData = tmp; - InsertMenuItem(menu, 0, 1, &moo); - } -} - -void UpdateRWRecentArray(const char* addString, unsigned int arrayLen, HMENU menu, unsigned int menuItem, unsigned int baseId) -{ - // Try to find out if the filename is already in the recent files list. - for(unsigned int x = 0; x < arrayLen; x++) - { - if(strlen(rw_recent_files[x])) - { - if(!strcmp(rw_recent_files[x], addString)) // Item is already in list. - { - // If the filename is in the file list don't add it again. - // Move it up in the list instead. - - int y; - char tmp[1024]; - - // Save pointer. - strcpy(tmp,rw_recent_files[x]); - - for(y = x; y; y--) - { - // Move items down. - strcpy(rw_recent_files[y],rw_recent_files[y - 1]); - } - - // Put item on top. - strcpy(rw_recent_files[0],tmp); - - // Update the recent files menu - UpdateRW_RMenu(menu, menuItem, baseId); - - return; - } - } - } - - // The filename wasn't found in the list. That means we need to add it. - - // Move the other items down. - for(unsigned int x = arrayLen - 1; x; x--) - { - strcpy(rw_recent_files[x],rw_recent_files[x - 1]); - } - - // Add the new item. - strcpy(rw_recent_files[0], addString); - - // Update the recent files menu - UpdateRW_RMenu(menu, menuItem, baseId); -} - - -void RWAddRecentFile(const char *filename) -{ - UpdateRWRecentArray(filename, MAX_RECENT_WATCHES, rwrecentmenu, RAMMENU_FILE_RECENT, RW_MENU_FIRST_RECENT_FILE); -} - -void OpenRWRecentFile(int memwRFileNumber) -{ - if(!ResetWatches()) - return; - - int rnum = memwRFileNumber; - if ((unsigned int)rnum >= MAX_RECENT_WATCHES) - return; //just in case - - char* x; - - while(true) - { - x = rw_recent_files[rnum]; - if (!*x) - return; //If no recent files exist just return. Useful for Load last file on startup (or if something goes screwy) - - if (rnum) //Change order of recent files if not most recent - { - RWAddRecentFile(x); - rnum = 0; - } - else - { - break; - } - } - - strcpy(currentWatch,x); - strcpy(Str_Tmp,currentWatch); - - //loadwatches here - FILE *WatchFile = fopen(Str_Tmp,"rb"); - if (!WatchFile) - { - int answer = MessageBox(MESSAGEBOXPARENT,"Error opening file.","ERROR",MB_OKCANCEL); - if (answer == IDOK) - { - rw_recent_files[rnum][0] = '\0'; //Clear file from list - if (rnum) //Update the ramwatch list - RWAddRecentFile(rw_recent_files[0]); - else - RWAddRecentFile(rw_recent_files[1]); - } - return; - } - const char DELIM = '\t'; - AddressWatcher Temp; - char mode; - fgets(Str_Tmp,1024,WatchFile); - sscanf(Str_Tmp,"%c%*s",&mode); - int WatchAdd; - fgets(Str_Tmp,1024,WatchFile); - sscanf(Str_Tmp,"%d%*s",&WatchAdd); - WatchAdd+=WatchCount; - for (int i = WatchCount; i < WatchAdd; i++) - { - while (i < 0) - i++; - do { - fgets(Str_Tmp,1024,WatchFile); - } while (Str_Tmp[0] == '\n'); - sscanf(Str_Tmp,"%*05X%*c%08X%*c%c%*c%c%*c%d",&(Temp.Address),&(Temp.Size),&(Temp.Type),&(Temp.WrongEndian)); - Temp.WrongEndian = 0; - char *Comment = strrchr(Str_Tmp,DELIM) + 1; - *strrchr(Comment,'\n') = '\0'; - InsertWatch(Temp,Comment); - } - - fclose(WatchFile); - if (RamWatchHWnd) - ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); - RWfileChanged=false; - return; -} - -char Gens_Path[64]= "M:\\"; //TODO - -int Change_File_S(char *Dest, char *Dir, char *Titre, char *Filter, char *Ext, HWND hwnd) -{ - OPENFILENAME ofn; - - SetCurrentDirectory(Gens_Path); - - if (!strcmp(Dest, "")) - { - strcpy(Dest, "default."); - strcat(Dest, Ext); - } - - memset(&ofn, 0, sizeof(OPENFILENAME)); - - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = hwnd; - ofn.hInstance = hAppInst; - ofn.lpstrFile = Dest; - ofn.nMaxFile = 2047; - ofn.lpstrFilter = Filter; - ofn.nFilterIndex = 1; - ofn.lpstrInitialDir = Dir; - ofn.lpstrTitle = Titre; - ofn.lpstrDefExt = Ext; - ofn.Flags = OFN_PATHMUSTEXIST | OFN_NOREADONLYRETURN; - - if (GetSaveFileName(&ofn)) return 1; - - return 0; -} - - -bool Save_Watches() -{ - Rom_Name = path.GetRomName(); - strncpy(Str_Tmp,Rom_Name.c_str(),512); - strcat(Str_Tmp,".wch"); - if(Change_File_S(Str_Tmp, Gens_Path, "Save Watches", "DeSmuME Watchlist\0*.wch\0All Files\0*.*\0\0", "wch", RamWatchHWnd)) - { - FILE *WatchFile = fopen(Str_Tmp,"r+b"); - if (!WatchFile) WatchFile = fopen(Str_Tmp,"w+b"); - fputc('\n',WatchFile); - strcpy(currentWatch,Str_Tmp); - RWAddRecentFile(currentWatch); - sprintf(Str_Tmp,"%d\n",WatchCount); - fputs(Str_Tmp,WatchFile); - const char DELIM = '\t'; - for (int i = 0; i < WatchCount; i++) - { - sprintf(Str_Tmp,"%05X%c%08X%c%c%c%c%c%d%c%s\n",i,DELIM,rswatches[i].Address,DELIM,rswatches[i].Size,DELIM,rswatches[i].Type,DELIM,rswatches[i].WrongEndian,DELIM,rswatches[i].comment); - fputs(Str_Tmp,WatchFile); - } - - fclose(WatchFile); - RWfileChanged=false; - return true; - } - return false; -} - -bool QuickSaveWatches() -{ -if (RWfileChanged==false) return true; //If file has not changed, no need to save changes -if (currentWatch[0] == NULL) //If there is no currently loaded file, run to Save as and then return - { - return Save_Watches(); - } - - strcpy(Str_Tmp,currentWatch); - FILE *WatchFile = fopen(Str_Tmp,"r+b"); - if (!WatchFile) WatchFile = fopen(Str_Tmp,"w+b"); - fputc('\n',WatchFile); - sprintf(Str_Tmp,"%d\n",WatchCount); - fputs(Str_Tmp,WatchFile); - const char DELIM = '\t'; - for (int i = 0; i < WatchCount; i++) - { - sprintf(Str_Tmp,"%05X%c%08X%c%c%c%c%c%d%c%s\n",i,DELIM,rswatches[i].Address,DELIM,rswatches[i].Size,DELIM,rswatches[i].Type,DELIM,rswatches[i].WrongEndian,DELIM,rswatches[i].comment); - fputs(Str_Tmp,WatchFile); - } - fclose(WatchFile); - RWfileChanged=false; - return true; -} - -bool Load_Watches(bool clear, const char* filename) -{ - const char DELIM = '\t'; - FILE* WatchFile = fopen(filename,"rb"); - if (!WatchFile) - { - MessageBox(MESSAGEBOXPARENT,"Error opening file.","ERROR",MB_OK); - return false; - } - if(clear) - { - if(!ResetWatches()) - { - fclose(WatchFile); - return false; - } - } - strcpy(currentWatch,filename); - RWAddRecentFile(currentWatch); - AddressWatcher Temp; - char mode; - fgets(Str_Tmp,1024,WatchFile); - sscanf(Str_Tmp,"%c%*s",&mode); - int WatchAdd; - fgets(Str_Tmp,1024,WatchFile); - sscanf(Str_Tmp,"%d%*s",&WatchAdd); - WatchAdd+=WatchCount; - for (int i = WatchCount; i < WatchAdd; i++) - { - while (i < 0) - i++; - do { - fgets(Str_Tmp,1024,WatchFile); - } while (Str_Tmp[0] == '\n'); - sscanf(Str_Tmp,"%*05X%*c%08X%*c%c%*c%c%*c%d",&(Temp.Address),&(Temp.Size),&(Temp.Type),&(Temp.WrongEndian)); - Temp.WrongEndian = 0; - char *Comment = strrchr(Str_Tmp,DELIM) + 1; - *strrchr(Comment,'\n') = '\0'; - InsertWatch(Temp,Comment); - } - - fclose(WatchFile); - if (RamWatchHWnd) - ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); - RWfileChanged=false; - return true; -} - - - -static int Change_File_L(char *Dest, char *Dir, char *Titre, char *Filter, char *Ext, HWND hwnd) -{ - OPENFILENAME ofn; - - SetCurrentDirectory(Gens_Path); - - if (!strcmp(Dest, "")) - { - strcpy(Dest, "default."); - strcat(Dest, Ext); - } - - memset(&ofn, 0, sizeof(OPENFILENAME)); - - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = hwnd; - ofn.hInstance = hAppInst; - ofn.lpstrFile = Dest; - ofn.nMaxFile = 2047; - ofn.lpstrFilter = Filter; - ofn.nFilterIndex = 1; - ofn.lpstrInitialDir = Dir; - ofn.lpstrTitle = Titre; - ofn.lpstrDefExt = Ext; - ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - - if (GetOpenFileName(&ofn)) return 1; - - return 0; -} - -bool Load_Watches(bool clear) -{ - Rom_Name = path.GetRomName(); - strncpy(Str_Tmp,Rom_Name.c_str(),512); - strcat(Str_Tmp,".wch"); - if(Change_File_L(Str_Tmp, Watch_Dir, "Load Watches", "DeSmuME Watchlist\0*.wch\0All Files\0*.*\0\0", "wch", RamWatchHWnd)) - { - return Load_Watches(clear, Str_Tmp); - } - return false; -} - -bool ResetWatches() -{ - if(!AskSave()) - return false; - for (;WatchCount>=0;WatchCount--) - { - free(rswatches[WatchCount].comment); - rswatches[WatchCount].comment = NULL; - } - WatchCount++; - if (RamWatchHWnd) - ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); - RWfileChanged = false; - currentWatch[0] = NULL; - return true; -} - -void RemoveWatch(int watchIndex) -{ - free(rswatches[watchIndex].comment); - rswatches[watchIndex].comment = NULL; - for (int i = watchIndex; i <= WatchCount; i++) - rswatches[i] = rswatches[i+1]; - WatchCount--; -} - -LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) //Gets info for a RAM Watch, and then inserts it into the Watch List -{ - RECT r; - RECT r2; - int dx1, dy1, dx2, dy2; - static int index; - static char s,t = s = 0; - - switch(uMsg) - { - case WM_INITDIALOG: - GetWindowRect(MainWindow->getHWnd(), &r); - dx1 = (r.right - r.left) / 2; - dy1 = (r.bottom - r.top) / 2; - - GetWindowRect(hDlg, &r2); - dx2 = (r2.right - r2.left) / 2; - dy2 = (r2.bottom - r2.top) / 2; - - SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); - index = (int)lParam; - sprintf(Str_Tmp,"%08X",rswatches[index].Address); - SetDlgItemText(hDlg,IDC_EDIT_COMPAREADDRESS,Str_Tmp); - if (rswatches[index].comment != NULL) - SetDlgItemText(hDlg,IDC_PROMPT_EDIT,rswatches[index].comment); - s = rswatches[index].Size; - t = rswatches[index].Type; - switch (s) - { - case 'b': - SendDlgItemMessage(hDlg, IDC_1_BYTE, BM_SETCHECK, BST_CHECKED, 0); - break; - case 'w': - SendDlgItemMessage(hDlg, IDC_2_BYTES, BM_SETCHECK, BST_CHECKED, 0); - break; - case 'd': - SendDlgItemMessage(hDlg, IDC_4_BYTES, BM_SETCHECK, BST_CHECKED, 0); - break; - default: - s = 0; - break; - } - switch (t) - { - case 's': - SendDlgItemMessage(hDlg, IDC_SIGNED, BM_SETCHECK, BST_CHECKED, 0); - break; - case 'u': - SendDlgItemMessage(hDlg, IDC_UNSIGNED, BM_SETCHECK, BST_CHECKED, 0); - break; - case 'h': - SendDlgItemMessage(hDlg, IDC_HEX, BM_SETCHECK, BST_CHECKED, 0); - break; - default: - t = 0; - break; - } - - return true; - break; - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDC_SIGNED: - t='s'; - return true; - case IDC_UNSIGNED: - t='u'; - return true; - case IDC_HEX: - t='h'; - return true; - case IDC_1_BYTE: - s = 'b'; - return true; - case IDC_2_BYTES: - s = 'w'; - return true; - case IDC_4_BYTES: - s = 'd'; - return true; - case IDOK: - { - if (s && t) - { - AddressWatcher Temp; - Temp.Size = s; - Temp.Type = t; - Temp.WrongEndian = false; //replace this when I get little endian working properly - GetDlgItemText(hDlg,IDC_EDIT_COMPAREADDRESS,Str_Tmp,1024); - char *addrstr = Str_Tmp; - if (strlen(Str_Tmp) > 8) addrstr = &(Str_Tmp[strlen(Str_Tmp) - 9]); - for(int i = 0; addrstr[i]; i++) {if(toupper(addrstr[i]) == 'O') addrstr[i] = '0';} - sscanf(addrstr,"%08X",&(Temp.Address)); - - if((Temp.Address & ~0xFFFFFF) == ~0xFFFFFF) - Temp.Address &= 0xFFFFFF; - - if(IsHardwareRAMAddressValid(Temp.Address)) - { - GetDlgItemText(hDlg,IDC_PROMPT_EDIT,Str_Tmp,80); - if (index < WatchCount) RemoveWatch(index); - InsertWatch(Temp,Str_Tmp); - if(RamWatchHWnd) - { - ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); - } - EndDialog(hDlg, true); - } - else - { - MessageBox(hDlg,"Invalid Address","ERROR",MB_OK); - } - } - else - { - strcpy(Str_Tmp,"Error:"); - if (!s) - strcat(Str_Tmp," Size must be specified."); - if (!t) - strcat(Str_Tmp," Type must be specified."); - MessageBox(hDlg,Str_Tmp,"ERROR",MB_OK); - } - RWfileChanged=true; - return true; - break; - } - case IDCANCEL: - EndDialog(hDlg, false); - return false; - break; - } - break; - - case WM_CLOSE: - EndDialog(hDlg, false); - return false; - break; - } - - return false; -} - -void init_list_box(HWND Box, const char* Strs[], int numColumns, int *columnWidths) //initializes the ram search and/or ram watch listbox -{ - LVCOLUMN Col; - Col.mask = LVCF_FMT | LVCF_ORDER | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; - Col.fmt = LVCFMT_CENTER; - for (int i = 0; i < numColumns; i++) - { - Col.iOrder = i; - Col.iSubItem = i; - Col.pszText = (LPSTR)(Strs[i]); - Col.cx = columnWidths[i]; - ListView_InsertColumn(Box,i,&Col); - } - - ListView_SetExtendedListViewStyle(Box, LVS_EX_FULLROWSELECT); -} - -LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - RECT r; - RECT r2; - int dx1, dy1, dx2, dy2; - static int watchIndex=0; - - Update_RAM_Watch(); - - switch(uMsg) - { - case WM_MOVE: { - RECT wrect; - GetWindowRect(hDlg,&wrect); - ramw_x = wrect.left; - ramw_y = wrect.top; - break; - }; - - case WM_INITDIALOG: { - GetWindowRect(MainWindow->getHWnd(), &r); //Ramwatch window - dx1 = (r.right - r.left) / 2; - dy1 = (r.bottom - r.top) / 2; - - GetWindowRect(hDlg, &r2); // Gens window - dx2 = (r2.right - r2.left) / 2; - dy2 = (r2.bottom - r2.top) / 2; - - - // push it away from the main window if we can - const int width = (r.right-r.left); - const int height = (r.bottom - r.top); - const int width2 = (r2.right-r2.left); - if(r.left+width2 + width < GetSystemMetrics(SM_CXSCREEN)) - { - r.right += width; - r.left += width; - } - else if((int)r.left - (int)width2 > 0) - { - r.right -= width2; - r.left -= width2; - } - - //----------------------------------------------------------------------------------- - //If user has Save Window Pos selected, override default positioning - if (RWSaveWindowPos) - { - //If ramwindow is for some reason completely off screen, use default instead - if (ramw_x > (-width*2) || ramw_x < (width*2 + GetSystemMetrics(SM_CYSCREEN)) ) - r.left = ramw_x; //This also ignores cases of windows -32000 error codes - //If ramwindow is for some reason completely off screen, use default instead - if (ramw_y > (0-height*2) ||ramw_y < (height*2 + GetSystemMetrics(SM_CYSCREEN)) ) - r.top = ramw_y; //This also ignores cases of windows -32000 error codes - } - //------------------------------------------------------------------------------------- - SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); - - ramwatchmenu=GetMenu(hDlg); - rwrecentmenu=CreateMenu(); - UpdateRW_RMenu(rwrecentmenu, RAMMENU_FILE_RECENT, RW_MENU_FIRST_RECENT_FILE); - - const char* names[3] = {"Address","Value","Notes"}; - int widths[3] = {62,64,64+51+53}; - init_list_box(GetDlgItem(hDlg,IDC_WATCHLIST),names,3,widths); -/* if (!ResultCount) //TODO what do these do - reset_address_info(); - else - signal_new_frame();*/ - ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); -// if (!noMisalign) SendDlgItemMessage(hDlg, IDC_MISALIGN, BM_SETCHECK, BST_CHECKED, 0); -// if (littleEndian) SendDlgItemMessage(hDlg, IDC_ENDIAN, BM_SETCHECK, BST_CHECKED, 0); - - RamWatchAccels = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_ACCELERATOR1)); - - // due to some bug in windows, the arrow button width from the resource gets ignored, so we have to set it here - SetWindowPos(GetDlgItem(hDlg,ID_WATCHES_UPDOWN), 0,0,0, 30,60, SWP_NOMOVE); - Update_RAM_Watch(); - DragAcceptFiles(hDlg, TRUE); - - return true; - break; - } - - case WM_INITMENU: - CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED); - break; - - case WM_MENUSELECT: - case WM_ENTERSIZEMOVE: - break; - - case WM_NOTIFY: - { - switch(wParam) - { - case ID_WATCHES_UPDOWN: - { - switch(((LPNMUPDOWN)lParam)->hdr.code) - { - case UDN_DELTAPOS: - int delta = ((LPNMUPDOWN)lParam)->iDelta; - SendMessage(hDlg, WM_COMMAND, delta<0 ? IDC_C_WATCH_UP : IDC_C_WATCH_DOWN,0); - break; - } - } - - default: - { - LPNMHDR lP = (LPNMHDR) lParam; - switch (lP->code) - { - case LVN_GETDISPINFO: - { - LV_DISPINFO *Item = (LV_DISPINFO *)lParam; - Item->item.mask = LVIF_TEXT; - Item->item.state = 0; - Item->item.iImage = 0; - const unsigned int iNum = Item->item.iItem; - static char num[11]; - switch (Item->item.iSubItem) - { - case 0: - sprintf(num,"%08X",rswatches[iNum].Address); - Item->item.pszText = num; - return true; - case 1: { - int i = rswatches[iNum].CurValue; - int t = rswatches[iNum].Type; - int size = rswatches[iNum].Size; - const char* formatString = ((t=='s') ? "%d" : (t=='u') ? "%u" : (size=='d' ? "%08X" : size=='w' ? "%04X" : "%02X")); - switch (size) - { - case 'b': - default: sprintf(num, formatString, t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break; - case 'w': sprintf(num, formatString, t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break; - case 'd': sprintf(num, formatString, t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break; - } - - Item->item.pszText = num; - } return true; - case 2: - Item->item.pszText = rswatches[iNum].comment ? rswatches[iNum].comment : ""; - return true; - - default: - return false; - } - } - case LVN_ODFINDITEM: - { - // disable search by keyboard typing, - // because it interferes with some of the accelerators - // and it isn't very useful here anyway - SetWindowLong(hDlg, DWL_MSGRESULT, ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST))); - return 1; - } - } - } - } - break; - } - - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case RAMMENU_FILE_SAVE: - QuickSaveWatches(); - break; - - case RAMMENU_FILE_SAVEAS: - return Save_Watches(); - case RAMMENU_FILE_OPEN: - return Load_Watches(true); - case RAMMENU_FILE_APPEND: - return Load_Watches(false); - case RAMMENU_FILE_NEW: - ResetWatches(); - return true; - case IDC_C_WATCH_REMOVE: - watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); - RemoveWatch(watchIndex); - ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); - RWfileChanged=true; - SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); - return true; - case IDC_C_WATCH_EDIT: - watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); - DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) watchIndex); - SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); - return true; - case IDC_C_WATCH: - rswatches[WatchCount].Address = rswatches[WatchCount].WrongEndian = 0; - rswatches[WatchCount].Size = 'b'; - rswatches[WatchCount].Type = 's'; - DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount); - SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); - return true; - case IDC_C_WATCH_DUPLICATE: - watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); - rswatches[WatchCount].Address = rswatches[watchIndex].Address; - rswatches[WatchCount].WrongEndian = rswatches[watchIndex].WrongEndian; - rswatches[WatchCount].Size = rswatches[watchIndex].Size; - rswatches[WatchCount].Type = rswatches[watchIndex].Type; - DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount); - SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); - return true; - case IDC_C_WATCH_UP: - { - watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); - if (watchIndex == 0 || watchIndex == -1) - return true; - void *tmp = malloc(sizeof(AddressWatcher)); - memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher)); - memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex - 1]),sizeof(AddressWatcher)); - memcpy(&(rswatches[watchIndex - 1]),tmp,sizeof(AddressWatcher)); - free(tmp); - ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1); - ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); - ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); - RWfileChanged=true; - return true; - } - case IDC_C_WATCH_DOWN: - { - watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); - if (watchIndex >= WatchCount - 1 || watchIndex == -1) - return true; - void *tmp = malloc(sizeof(AddressWatcher)); - memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher)); - memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex + 1]),sizeof(AddressWatcher)); - memcpy(&(rswatches[watchIndex + 1]),tmp,sizeof(AddressWatcher)); - free(tmp); - ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1); - ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); - ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); - RWfileChanged=true; - return true; - } - case RAMMENU_FILE_AUTOLOAD: - { - AutoRWLoad ^= 1; - CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED); - break; - } - case RAMMENU_FILE_SAVEWINDOW: - { - RWSaveWindowPos ^=1; - CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED); - break; - } - case IDC_C_ADDCHEAT: - { - watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)) | (1 << 24); -// DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITCHEAT), hDlg, (DLGPROC) EditCheatProc,(LPARAM) searchIndex); //TODO: made a IDD_EDITCHEAT dialog, and EditCheatProc (are they in GENS?) and integrate into cheats system - break; - } - case IDCANCEL: - RamWatchHWnd = NULL; - DragAcceptFiles(hDlg, FALSE); - EndDialog(hDlg, true); - return true; - default: - if (LOWORD(wParam) >= RW_MENU_FIRST_RECENT_FILE && LOWORD(wParam) < RW_MENU_FIRST_RECENT_FILE+MAX_RECENT_WATCHES) - OpenRWRecentFile(LOWORD(wParam) - RW_MENU_FIRST_RECENT_FILE); - } - break; - - case WM_KEYDOWN: // handle accelerator keys - { - SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); - MSG msg; - msg.hwnd = hDlg; - msg.message = uMsg; - msg.wParam = wParam; - msg.lParam = lParam; - if(RamWatchAccels && TranslateAccelerator(hDlg, RamWatchAccels, &msg)) - return true; - } break; - - case WM_CLOSE: - RamWatchHWnd = NULL; - DragAcceptFiles(hDlg, FALSE); - EndDialog(hDlg, true); - return true; - - case WM_DROPFILES: - { - HDROP hDrop = (HDROP)wParam; - DragQueryFile(hDrop, 0, Str_Tmp, 1024); - DragFinish(hDrop); - return Load_Watches(true, Str_Tmp); - } break; - } - - return false; -} - +//RamWatch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/ +//Authors: Upthorn, Nitsuja, adelikat + +#include "main.h" +#include "resource.h" +#include "common.h" +#include "NDSSystem.h" +#include "ramwatch.h" +#include "ram_search.h" +#include +#include +#include +#include +#include "path.h" + +HWND RamWatchHWnd = NULL; + +#define MESSAGEBOXPARENT (RamWatchHWnd ? RamWatchHWnd : MainWindow->getHWnd()) + +static char Str_Tmp[1024]; +std::string Rom_Name; + +static HMENU ramwatchmenu; +static HMENU rwrecentmenu; +static HACCEL RamWatchAccels = NULL; +char rw_recent_files[MAX_RECENT_WATCHES][1024]; +char Watch_Dir[1024]=""; +const unsigned int RW_MENU_FIRST_RECENT_FILE = 600; +bool RWfileChanged = false; //Keeps track of whether the current watch file has been changed, if so, ramwatch will prompt to save changes +bool AutoRWLoad = false; //Keeps track of whether Auto-load is checked +bool RWSaveWindowPos = false; //Keeps track of whether Save Window position is checked +char currentWatch[1024]; +int ramw_x, ramw_y; //Used to store ramwatch dialog window positions +AddressWatcher rswatches[MAX_WATCH_COUNT]; +int WatchCount=0; + +bool QuickSaveWatches(); +bool ResetWatches(); + +unsigned int GetCurrentValue(AddressWatcher& watch) +{ + char buf[4]; + MMU_DumpMemBlock(0, watch.Address, 4, (u8*)buf); + + u32 val_u32 = *(u32*)buf; + u16 val_u16 = *(u16*)buf; + u8 val_u8 = *(u8*)buf; + + switch (watch.Size) + { + case 0x62: return val_u8; + case 0x77: return val_u16; + case 0x64: return val_u32; + default: return 0; + } +// return ReadValueAtHardwareAddress(watch.Address, watch.Size == 'd' ? 4 : watch.Size == 'w' ? 2 : 1); +} + +bool IsSameWatch(const AddressWatcher& l, const AddressWatcher& r) +{ + return ((l.Address == r.Address) && (l.Size == r.Size) && (l.Type == r.Type)/* && (l.WrongEndian == r.WrongEndian)*/); +} + +bool VerifyWatchNotAlreadyAdded(const AddressWatcher& watch) +{ + for (int j = 0; j < WatchCount; j++) + { + if (IsSameWatch(rswatches[j], watch)) + { + if(RamWatchHWnd) + SetForegroundWindow(RamWatchHWnd); + return false; + } + } + return true; +} + + +bool InsertWatch(const AddressWatcher& Watch, char *Comment) +{ + if(!VerifyWatchNotAlreadyAdded(Watch)) + return false; + + if(WatchCount >= MAX_WATCH_COUNT) + return false; + + int i = WatchCount++; + AddressWatcher& NewWatch = rswatches[i]; + NewWatch = Watch; + //if (NewWatch.comment) free(NewWatch.comment); + NewWatch.comment = (char *) malloc(strlen(Comment)+2); + NewWatch.CurValue = GetCurrentValue(NewWatch); + strcpy(NewWatch.comment, Comment); + ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); + RWfileChanged=true; + + return true; +} + +LRESULT CALLBACK PromptWatchNameProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) //Gets the description of a watched address +{ + RECT r; + RECT r2; + int dx1, dy1, dx2, dy2; + + switch(uMsg) + { + case WM_INITDIALOG: + GetWindowRect(MainWindow->getHWnd(), &r); + dx1 = (r.right - r.left) / 2; + dy1 = (r.bottom - r.top) / 2; + + GetWindowRect(hDlg, &r2); + dx2 = (r2.right - r2.left) / 2; + dy2 = (r2.bottom - r2.top) / 2; + + SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); + strcpy(Str_Tmp,"Enter a name for this RAM address."); + //SendDlgItemMessage(hDlg,IDC_PROMPT_TEXT,WM_SETTEXT,0,(LPARAM)Str_Tmp); + strcpy(Str_Tmp,""); + //SendDlgItemMessage(hDlg,IDC_PROMPT_TEXT2,WM_SETTEXT,0,(LPARAM)Str_Tmp); + return true; + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDOK: + { + GetDlgItemText(hDlg,IDC_PROMPT_EDIT,Str_Tmp,80); + InsertWatch(rswatches[WatchCount],Str_Tmp); + EndDialog(hDlg, true); + return true; + break; + } + case IDCANCEL: + + EndDialog(hDlg, false); + return false; + break; + } + break; + + case WM_CLOSE: + EndDialog(hDlg, false); + return false; + break; + } + + return false; +} + +bool InsertWatch(const AddressWatcher& Watch, HWND parent) +{ + if(!VerifyWatchNotAlreadyAdded(Watch)) + return false; + + if(!parent) + parent = RamWatchHWnd; + if(!parent) + parent = MainWindow->getHWnd(); + + int prevWatchCount = WatchCount; + + rswatches[WatchCount] = Watch; + rswatches[WatchCount].CurValue = GetCurrentValue(rswatches[WatchCount]); + DialogBox(hAppInst, MAKEINTRESOURCE(IDD_PROMPT), parent, (DLGPROC) PromptWatchNameProc); + + return WatchCount > prevWatchCount; +} + +void Update_RAM_Watch() +{ + if (!RamWatchHWnd) return; + + // update cached values and detect changes to displayed listview items + BOOL watchChanged[MAX_WATCH_COUNT] = {0}; + for(int i = 0; i < WatchCount; i++) + { + unsigned int prevCurValue = rswatches[i].CurValue; + unsigned int newCurValue = GetCurrentValue(rswatches[i]); + if(prevCurValue != newCurValue) + { + rswatches[i].CurValue = newCurValue; + watchChanged[i] = TRUE; + } + } + + // refresh any visible parts of the listview box that changed + HWND lv = GetDlgItem(RamWatchHWnd,IDC_WATCHLIST); + int top = ListView_GetTopIndex(lv); + int bottom = top + ListView_GetCountPerPage(lv) + 1; // +1 is so we will update a partially-displayed last item + if(top < 0) top = 0; + if(bottom > WatchCount) bottom = WatchCount; + int start = -1; + for(int i = top; i <= bottom; i++) + { + if(start == -1) + { + if(i != bottom && watchChanged[i]) + { + start = i; + //somethingChanged = true; + } + } + else + { + if(i == bottom || !watchChanged[i]) + { + ListView_RedrawItems(lv, start, i-1); + start = -1; + } + } + } +} + +bool AskSave() +{ + //This function asks to save changes if the watch file contents have changed + //returns false only if a save was attempted but failed or was cancelled + if (RWfileChanged) + { + HWND Hwnd = MainWindow->getHWnd(); + int answer = MessageBox(Hwnd, "Save Changes?", "Ram Watch", MB_YESNOCANCEL); + if(answer == IDYES) + if(!QuickSaveWatches()) + return false; + return (answer != IDCANCEL); + } + return true; +} + + +void UpdateRW_RMenu(HMENU menu, unsigned int mitem, unsigned int baseid) +{ + MENUITEMINFO moo; + int x; + + moo.cbSize = sizeof(moo); + moo.fMask = MIIM_SUBMENU | MIIM_STATE; + + GetMenuItemInfo(GetSubMenu(ramwatchmenu, 0), mitem, FALSE, &moo); + moo.hSubMenu = menu; + moo.fState = strlen(rw_recent_files[0]) ? MFS_ENABLED : MFS_GRAYED; + + SetMenuItemInfo(GetSubMenu(ramwatchmenu, 0), mitem, FALSE, &moo); + + // Remove all recent files submenus + for(x = 0; x < MAX_RECENT_WATCHES; x++) + { + RemoveMenu(menu, baseid + x, MF_BYCOMMAND); + } + + // Recreate the menus + for(x = MAX_RECENT_WATCHES - 1; x >= 0; x--) + { + char tmp[128 + 5]; + + // Skip empty strings + if(!strlen(rw_recent_files[x])) + { + continue; + } + + moo.cbSize = sizeof(moo); + moo.fMask = MIIM_DATA | MIIM_ID | MIIM_TYPE; + + // Fill in the menu text. + if(strlen(rw_recent_files[x]) < 128) + { + sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, rw_recent_files[x]); + } + else + { + sprintf(tmp, "&%d. %s", ( x + 1 ) % 10, rw_recent_files[x] + strlen( rw_recent_files[x] ) - 127); + } + + // Insert the menu item + moo.cch = strlen(tmp); + moo.fType = 0; + moo.wID = baseid + x; + moo.dwTypeData = tmp; + InsertMenuItem(menu, 0, 1, &moo); + } +} + +void UpdateRWRecentArray(const char* addString, unsigned int arrayLen, HMENU menu, unsigned int menuItem, unsigned int baseId) +{ + // Try to find out if the filename is already in the recent files list. + for(unsigned int x = 0; x < arrayLen; x++) + { + if(strlen(rw_recent_files[x])) + { + if(!strcmp(rw_recent_files[x], addString)) // Item is already in list. + { + // If the filename is in the file list don't add it again. + // Move it up in the list instead. + + int y; + char tmp[1024]; + + // Save pointer. + strcpy(tmp,rw_recent_files[x]); + + for(y = x; y; y--) + { + // Move items down. + strcpy(rw_recent_files[y],rw_recent_files[y - 1]); + } + + // Put item on top. + strcpy(rw_recent_files[0],tmp); + + // Update the recent files menu + UpdateRW_RMenu(menu, menuItem, baseId); + + return; + } + } + } + + // The filename wasn't found in the list. That means we need to add it. + + // Move the other items down. + for(unsigned int x = arrayLen - 1; x; x--) + { + strcpy(rw_recent_files[x],rw_recent_files[x - 1]); + } + + // Add the new item. + strcpy(rw_recent_files[0], addString); + + // Update the recent files menu + UpdateRW_RMenu(menu, menuItem, baseId); +} + + +void RWAddRecentFile(const char *filename) +{ + UpdateRWRecentArray(filename, MAX_RECENT_WATCHES, rwrecentmenu, RAMMENU_FILE_RECENT, RW_MENU_FIRST_RECENT_FILE); +} + +void OpenRWRecentFile(int memwRFileNumber) +{ + if(!ResetWatches()) + return; + + int rnum = memwRFileNumber; + if ((unsigned int)rnum >= MAX_RECENT_WATCHES) + return; //just in case + + char* x; + + while(true) + { + x = rw_recent_files[rnum]; + if (!*x) + return; //If no recent files exist just return. Useful for Load last file on startup (or if something goes screwy) + + if (rnum) //Change order of recent files if not most recent + { + RWAddRecentFile(x); + rnum = 0; + } + else + { + break; + } + } + + strcpy(currentWatch,x); + strcpy(Str_Tmp,currentWatch); + + //loadwatches here + FILE *WatchFile = fopen(Str_Tmp,"rb"); + if (!WatchFile) + { + int answer = MessageBox(MESSAGEBOXPARENT,"Error opening file.","ERROR",MB_OKCANCEL); + if (answer == IDOK) + { + rw_recent_files[rnum][0] = '\0'; //Clear file from list + if (rnum) //Update the ramwatch list + RWAddRecentFile(rw_recent_files[0]); + else + RWAddRecentFile(rw_recent_files[1]); + } + return; + } + const char DELIM = '\t'; + AddressWatcher Temp; + char mode; + fgets(Str_Tmp,1024,WatchFile); + sscanf(Str_Tmp,"%c%*s",&mode); + int WatchAdd; + fgets(Str_Tmp,1024,WatchFile); + sscanf(Str_Tmp,"%d%*s",&WatchAdd); + WatchAdd+=WatchCount; + for (int i = WatchCount; i < WatchAdd; i++) + { + while (i < 0) + i++; + do { + fgets(Str_Tmp,1024,WatchFile); + } while (Str_Tmp[0] == '\n'); + sscanf(Str_Tmp,"%*05X%*c%08X%*c%c%*c%c%*c%d",&(Temp.Address),&(Temp.Size),&(Temp.Type),&(Temp.WrongEndian)); + Temp.WrongEndian = 0; + char *Comment = strrchr(Str_Tmp,DELIM) + 1; + *strrchr(Comment,'\n') = '\0'; + InsertWatch(Temp,Comment); + } + + fclose(WatchFile); + if (RamWatchHWnd) + ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); + RWfileChanged=false; + return; +} + +char Gens_Path[64]= "M:\\"; //TODO + +int Change_File_S(char *Dest, char *Dir, char *Titre, char *Filter, char *Ext, HWND hwnd) +{ + OPENFILENAME ofn; + + SetCurrentDirectory(Gens_Path); + + if (!strcmp(Dest, "")) + { + strcpy(Dest, "default."); + strcat(Dest, Ext); + } + + memset(&ofn, 0, sizeof(OPENFILENAME)); + + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = hwnd; + ofn.hInstance = hAppInst; + ofn.lpstrFile = Dest; + ofn.nMaxFile = 2047; + ofn.lpstrFilter = Filter; + ofn.nFilterIndex = 1; + ofn.lpstrInitialDir = Dir; + ofn.lpstrTitle = Titre; + ofn.lpstrDefExt = Ext; + ofn.Flags = OFN_PATHMUSTEXIST | OFN_NOREADONLYRETURN; + + if (GetSaveFileName(&ofn)) return 1; + + return 0; +} + + +bool Save_Watches() +{ + Rom_Name = path.GetRomName(); + strncpy(Str_Tmp,Rom_Name.c_str(),512); + strcat(Str_Tmp,".wch"); + if(Change_File_S(Str_Tmp, Gens_Path, "Save Watches", "DeSmuME Watchlist\0*.wch\0All Files\0*.*\0\0", "wch", RamWatchHWnd)) + { + FILE *WatchFile = fopen(Str_Tmp,"r+b"); + if (!WatchFile) WatchFile = fopen(Str_Tmp,"w+b"); + fputc('\n',WatchFile); + strcpy(currentWatch,Str_Tmp); + RWAddRecentFile(currentWatch); + sprintf(Str_Tmp,"%d\n",WatchCount); + fputs(Str_Tmp,WatchFile); + const char DELIM = '\t'; + for (int i = 0; i < WatchCount; i++) + { + sprintf(Str_Tmp,"%05X%c%08X%c%c%c%c%c%d%c%s\n",i,DELIM,rswatches[i].Address,DELIM,rswatches[i].Size,DELIM,rswatches[i].Type,DELIM,rswatches[i].WrongEndian,DELIM,rswatches[i].comment); + fputs(Str_Tmp,WatchFile); + } + + fclose(WatchFile); + RWfileChanged=false; + return true; + } + return false; +} + +bool QuickSaveWatches() +{ +if (RWfileChanged==false) return true; //If file has not changed, no need to save changes +if (currentWatch[0] == NULL) //If there is no currently loaded file, run to Save as and then return + { + return Save_Watches(); + } + + strcpy(Str_Tmp,currentWatch); + FILE *WatchFile = fopen(Str_Tmp,"r+b"); + if (!WatchFile) WatchFile = fopen(Str_Tmp,"w+b"); + fputc('\n',WatchFile); + sprintf(Str_Tmp,"%d\n",WatchCount); + fputs(Str_Tmp,WatchFile); + const char DELIM = '\t'; + for (int i = 0; i < WatchCount; i++) + { + sprintf(Str_Tmp,"%05X%c%08X%c%c%c%c%c%d%c%s\n",i,DELIM,rswatches[i].Address,DELIM,rswatches[i].Size,DELIM,rswatches[i].Type,DELIM,rswatches[i].WrongEndian,DELIM,rswatches[i].comment); + fputs(Str_Tmp,WatchFile); + } + fclose(WatchFile); + RWfileChanged=false; + return true; +} + +bool Load_Watches(bool clear, const char* filename) +{ + const char DELIM = '\t'; + FILE* WatchFile = fopen(filename,"rb"); + if (!WatchFile) + { + MessageBox(MESSAGEBOXPARENT,"Error opening file.","ERROR",MB_OK); + return false; + } + if(clear) + { + if(!ResetWatches()) + { + fclose(WatchFile); + return false; + } + } + strcpy(currentWatch,filename); + RWAddRecentFile(currentWatch); + AddressWatcher Temp; + char mode; + fgets(Str_Tmp,1024,WatchFile); + sscanf(Str_Tmp,"%c%*s",&mode); + int WatchAdd; + fgets(Str_Tmp,1024,WatchFile); + sscanf(Str_Tmp,"%d%*s",&WatchAdd); + WatchAdd+=WatchCount; + for (int i = WatchCount; i < WatchAdd; i++) + { + while (i < 0) + i++; + do { + fgets(Str_Tmp,1024,WatchFile); + } while (Str_Tmp[0] == '\n'); + sscanf(Str_Tmp,"%*05X%*c%08X%*c%c%*c%c%*c%d",&(Temp.Address),&(Temp.Size),&(Temp.Type),&(Temp.WrongEndian)); + Temp.WrongEndian = 0; + char *Comment = strrchr(Str_Tmp,DELIM) + 1; + *strrchr(Comment,'\n') = '\0'; + InsertWatch(Temp,Comment); + } + + fclose(WatchFile); + if (RamWatchHWnd) + ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); + RWfileChanged=false; + return true; +} + + + +static int Change_File_L(char *Dest, char *Dir, char *Titre, char *Filter, char *Ext, HWND hwnd) +{ + OPENFILENAME ofn; + + SetCurrentDirectory(Gens_Path); + + if (!strcmp(Dest, "")) + { + strcpy(Dest, "default."); + strcat(Dest, Ext); + } + + memset(&ofn, 0, sizeof(OPENFILENAME)); + + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = hwnd; + ofn.hInstance = hAppInst; + ofn.lpstrFile = Dest; + ofn.nMaxFile = 2047; + ofn.lpstrFilter = Filter; + ofn.nFilterIndex = 1; + ofn.lpstrInitialDir = Dir; + ofn.lpstrTitle = Titre; + ofn.lpstrDefExt = Ext; + ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + + if (GetOpenFileName(&ofn)) return 1; + + return 0; +} + +bool Load_Watches(bool clear) +{ + Rom_Name = path.GetRomName(); + strncpy(Str_Tmp,Rom_Name.c_str(),512); + strcat(Str_Tmp,".wch"); + if(Change_File_L(Str_Tmp, Watch_Dir, "Load Watches", "DeSmuME Watchlist\0*.wch\0All Files\0*.*\0\0", "wch", RamWatchHWnd)) + { + return Load_Watches(clear, Str_Tmp); + } + return false; +} + +bool ResetWatches() +{ + if(!AskSave()) + return false; + for (;WatchCount>=0;WatchCount--) + { + free(rswatches[WatchCount].comment); + rswatches[WatchCount].comment = NULL; + } + WatchCount++; + if (RamWatchHWnd) + ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); + RWfileChanged = false; + currentWatch[0] = NULL; + return true; +} + +void RemoveWatch(int watchIndex) +{ + free(rswatches[watchIndex].comment); + rswatches[watchIndex].comment = NULL; + for (int i = watchIndex; i <= WatchCount; i++) + rswatches[i] = rswatches[i+1]; + WatchCount--; +} + +LRESULT CALLBACK EditWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) //Gets info for a RAM Watch, and then inserts it into the Watch List +{ + RECT r; + RECT r2; + int dx1, dy1, dx2, dy2; + static int index; + static char s,t = s = 0; + + switch(uMsg) + { + case WM_INITDIALOG: + GetWindowRect(MainWindow->getHWnd(), &r); + dx1 = (r.right - r.left) / 2; + dy1 = (r.bottom - r.top) / 2; + + GetWindowRect(hDlg, &r2); + dx2 = (r2.right - r2.left) / 2; + dy2 = (r2.bottom - r2.top) / 2; + + SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); + index = (int)lParam; + sprintf(Str_Tmp,"%08X",rswatches[index].Address); + SetDlgItemText(hDlg,IDC_EDIT_COMPAREADDRESS,Str_Tmp); + if (rswatches[index].comment != NULL) + SetDlgItemText(hDlg,IDC_PROMPT_EDIT,rswatches[index].comment); + s = rswatches[index].Size; + t = rswatches[index].Type; + switch (s) + { + case 'b': + SendDlgItemMessage(hDlg, IDC_1_BYTE, BM_SETCHECK, BST_CHECKED, 0); + break; + case 'w': + SendDlgItemMessage(hDlg, IDC_2_BYTES, BM_SETCHECK, BST_CHECKED, 0); + break; + case 'd': + SendDlgItemMessage(hDlg, IDC_4_BYTES, BM_SETCHECK, BST_CHECKED, 0); + break; + default: + s = 0; + break; + } + switch (t) + { + case 's': + SendDlgItemMessage(hDlg, IDC_SIGNED, BM_SETCHECK, BST_CHECKED, 0); + break; + case 'u': + SendDlgItemMessage(hDlg, IDC_UNSIGNED, BM_SETCHECK, BST_CHECKED, 0); + break; + case 'h': + SendDlgItemMessage(hDlg, IDC_HEX, BM_SETCHECK, BST_CHECKED, 0); + break; + default: + t = 0; + break; + } + + return true; + break; + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDC_SIGNED: + t='s'; + return true; + case IDC_UNSIGNED: + t='u'; + return true; + case IDC_HEX: + t='h'; + return true; + case IDC_1_BYTE: + s = 'b'; + return true; + case IDC_2_BYTES: + s = 'w'; + return true; + case IDC_4_BYTES: + s = 'd'; + return true; + case IDOK: + { + if (s && t) + { + AddressWatcher Temp; + Temp.Size = s; + Temp.Type = t; + Temp.WrongEndian = false; //replace this when I get little endian working properly + GetDlgItemText(hDlg,IDC_EDIT_COMPAREADDRESS,Str_Tmp,1024); + char *addrstr = Str_Tmp; + if (strlen(Str_Tmp) > 8) addrstr = &(Str_Tmp[strlen(Str_Tmp) - 9]); + for(int i = 0; addrstr[i]; i++) {if(toupper(addrstr[i]) == 'O') addrstr[i] = '0';} + sscanf(addrstr,"%08X",&(Temp.Address)); + + if((Temp.Address & ~0xFFFFFF) == ~0xFFFFFF) + Temp.Address &= 0xFFFFFF; + + if(IsHardwareRAMAddressValid(Temp.Address)) + { + GetDlgItemText(hDlg,IDC_PROMPT_EDIT,Str_Tmp,80); + if (index < WatchCount) RemoveWatch(index); + InsertWatch(Temp,Str_Tmp); + if(RamWatchHWnd) + { + ListView_SetItemCount(GetDlgItem(RamWatchHWnd,IDC_WATCHLIST),WatchCount); + } + EndDialog(hDlg, true); + } + else + { + MessageBox(hDlg,"Invalid Address","ERROR",MB_OK); + } + } + else + { + strcpy(Str_Tmp,"Error:"); + if (!s) + strcat(Str_Tmp," Size must be specified."); + if (!t) + strcat(Str_Tmp," Type must be specified."); + MessageBox(hDlg,Str_Tmp,"ERROR",MB_OK); + } + RWfileChanged=true; + return true; + break; + } + case IDCANCEL: + EndDialog(hDlg, false); + return false; + break; + } + break; + + case WM_CLOSE: + EndDialog(hDlg, false); + return false; + break; + } + + return false; +} + +void init_list_box(HWND Box, const char* Strs[], int numColumns, int *columnWidths) //initializes the ram search and/or ram watch listbox +{ + LVCOLUMN Col; + Col.mask = LVCF_FMT | LVCF_ORDER | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH; + Col.fmt = LVCFMT_CENTER; + for (int i = 0; i < numColumns; i++) + { + Col.iOrder = i; + Col.iSubItem = i; + Col.pszText = (LPSTR)(Strs[i]); + Col.cx = columnWidths[i]; + ListView_InsertColumn(Box,i,&Col); + } + + ListView_SetExtendedListViewStyle(Box, LVS_EX_FULLROWSELECT); +} + +LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + RECT r; + RECT r2; + int dx1, dy1, dx2, dy2; + static int watchIndex=0; + + Update_RAM_Watch(); + + switch(uMsg) + { + case WM_MOVE: { + RECT wrect; + GetWindowRect(hDlg,&wrect); + ramw_x = wrect.left; + ramw_y = wrect.top; + break; + }; + + case WM_INITDIALOG: { + GetWindowRect(MainWindow->getHWnd(), &r); //Ramwatch window + dx1 = (r.right - r.left) / 2; + dy1 = (r.bottom - r.top) / 2; + + GetWindowRect(hDlg, &r2); // Gens window + dx2 = (r2.right - r2.left) / 2; + dy2 = (r2.bottom - r2.top) / 2; + + + // push it away from the main window if we can + const int width = (r.right-r.left); + const int height = (r.bottom - r.top); + const int width2 = (r2.right-r2.left); + if(r.left+width2 + width < GetSystemMetrics(SM_CXSCREEN)) + { + r.right += width; + r.left += width; + } + else if((int)r.left - (int)width2 > 0) + { + r.right -= width2; + r.left -= width2; + } + + //----------------------------------------------------------------------------------- + //If user has Save Window Pos selected, override default positioning + if (RWSaveWindowPos) + { + //If ramwindow is for some reason completely off screen, use default instead + if (ramw_x > (-width*2) || ramw_x < (width*2 + GetSystemMetrics(SM_CYSCREEN)) ) + r.left = ramw_x; //This also ignores cases of windows -32000 error codes + //If ramwindow is for some reason completely off screen, use default instead + if (ramw_y > (0-height*2) ||ramw_y < (height*2 + GetSystemMetrics(SM_CYSCREEN)) ) + r.top = ramw_y; //This also ignores cases of windows -32000 error codes + } + //------------------------------------------------------------------------------------- + SetWindowPos(hDlg, NULL, r.left, r.top, NULL, NULL, SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW); + + ramwatchmenu=GetMenu(hDlg); + rwrecentmenu=CreateMenu(); + UpdateRW_RMenu(rwrecentmenu, RAMMENU_FILE_RECENT, RW_MENU_FIRST_RECENT_FILE); + + const char* names[3] = {"Address","Value","Notes"}; + int widths[3] = {62,64,64+51+53}; + init_list_box(GetDlgItem(hDlg,IDC_WATCHLIST),names,3,widths); +/* if (!ResultCount) //TODO what do these do + reset_address_info(); + else + signal_new_frame();*/ + ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); +// if (!noMisalign) SendDlgItemMessage(hDlg, IDC_MISALIGN, BM_SETCHECK, BST_CHECKED, 0); +// if (littleEndian) SendDlgItemMessage(hDlg, IDC_ENDIAN, BM_SETCHECK, BST_CHECKED, 0); + + RamWatchAccels = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_ACCELERATOR1)); + + // due to some bug in windows, the arrow button width from the resource gets ignored, so we have to set it here + SetWindowPos(GetDlgItem(hDlg,ID_WATCHES_UPDOWN), 0,0,0, 30,60, SWP_NOMOVE); + Update_RAM_Watch(); + DragAcceptFiles(hDlg, TRUE); + + return true; + break; + } + + case WM_INITMENU: + CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED); + break; + + case WM_MENUSELECT: + case WM_ENTERSIZEMOVE: + break; + + case WM_NOTIFY: + { + switch(wParam) + { + case ID_WATCHES_UPDOWN: + { + switch(((LPNMUPDOWN)lParam)->hdr.code) + { + case UDN_DELTAPOS: + int delta = ((LPNMUPDOWN)lParam)->iDelta; + SendMessage(hDlg, WM_COMMAND, delta<0 ? IDC_C_WATCH_UP : IDC_C_WATCH_DOWN,0); + break; + } + } + + default: + { + LPNMHDR lP = (LPNMHDR) lParam; + switch (lP->code) + { + case LVN_GETDISPINFO: + { + LV_DISPINFO *Item = (LV_DISPINFO *)lParam; + Item->item.mask = LVIF_TEXT; + Item->item.state = 0; + Item->item.iImage = 0; + const unsigned int iNum = Item->item.iItem; + static char num[11]; + switch (Item->item.iSubItem) + { + case 0: + sprintf(num,"%08X",rswatches[iNum].Address); + Item->item.pszText = num; + return true; + case 1: { + int i = rswatches[iNum].CurValue; + int t = rswatches[iNum].Type; + int size = rswatches[iNum].Size; + const char* formatString = ((t=='s') ? "%d" : (t=='u') ? "%u" : (size=='d' ? "%08X" : size=='w' ? "%04X" : "%02X")); + switch (size) + { + case 'b': + default: sprintf(num, formatString, t=='s' ? (char)(i&0xff) : (unsigned char)(i&0xff)); break; + case 'w': sprintf(num, formatString, t=='s' ? (short)(i&0xffff) : (unsigned short)(i&0xffff)); break; + case 'd': sprintf(num, formatString, t=='s' ? (long)(i&0xffffffff) : (unsigned long)(i&0xffffffff)); break; + } + + Item->item.pszText = num; + } return true; + case 2: + Item->item.pszText = rswatches[iNum].comment ? rswatches[iNum].comment : ""; + return true; + + default: + return false; + } + } + case LVN_ODFINDITEM: + { + // disable search by keyboard typing, + // because it interferes with some of the accelerators + // and it isn't very useful here anyway + SetWindowLong(hDlg, DWL_MSGRESULT, ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST))); + return 1; + } + } + } + } + break; + } + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case RAMMENU_FILE_SAVE: + QuickSaveWatches(); + break; + + case RAMMENU_FILE_SAVEAS: + return Save_Watches(); + case RAMMENU_FILE_OPEN: + return Load_Watches(true); + case RAMMENU_FILE_APPEND: + return Load_Watches(false); + case RAMMENU_FILE_NEW: + ResetWatches(); + return true; + case IDC_C_WATCH_REMOVE: + watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); + RemoveWatch(watchIndex); + ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); + RWfileChanged=true; + SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); + return true; + case IDC_C_WATCH_EDIT: + watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); + DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) watchIndex); + SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); + return true; + case IDC_C_WATCH: + rswatches[WatchCount].Address = rswatches[WatchCount].WrongEndian = 0; + rswatches[WatchCount].Size = 'b'; + rswatches[WatchCount].Type = 's'; + DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount); + SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); + return true; + case IDC_C_WATCH_DUPLICATE: + watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); + rswatches[WatchCount].Address = rswatches[watchIndex].Address; + rswatches[WatchCount].WrongEndian = rswatches[watchIndex].WrongEndian; + rswatches[WatchCount].Size = rswatches[watchIndex].Size; + rswatches[WatchCount].Type = rswatches[watchIndex].Type; + DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITWATCH), hDlg, (DLGPROC) EditWatchProc,(LPARAM) WatchCount); + SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); + return true; + case IDC_C_WATCH_UP: + { + watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); + if (watchIndex == 0 || watchIndex == -1) + return true; + void *tmp = malloc(sizeof(AddressWatcher)); + memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher)); + memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex - 1]),sizeof(AddressWatcher)); + memcpy(&(rswatches[watchIndex - 1]),tmp,sizeof(AddressWatcher)); + free(tmp); + ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1); + ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex-1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); + ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); + RWfileChanged=true; + return true; + } + case IDC_C_WATCH_DOWN: + { + watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)); + if (watchIndex >= WatchCount - 1 || watchIndex == -1) + return true; + void *tmp = malloc(sizeof(AddressWatcher)); + memcpy(tmp,&(rswatches[watchIndex]),sizeof(AddressWatcher)); + memcpy(&(rswatches[watchIndex]),&(rswatches[watchIndex + 1]),sizeof(AddressWatcher)); + memcpy(&(rswatches[watchIndex + 1]),tmp,sizeof(AddressWatcher)); + free(tmp); + ListView_SetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1); + ListView_SetItemState(GetDlgItem(hDlg,IDC_WATCHLIST),watchIndex+1,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED); + ListView_SetItemCount(GetDlgItem(hDlg,IDC_WATCHLIST),WatchCount); + RWfileChanged=true; + return true; + } + case RAMMENU_FILE_AUTOLOAD: + { + AutoRWLoad ^= 1; + CheckMenuItem(ramwatchmenu, RAMMENU_FILE_AUTOLOAD, AutoRWLoad ? MF_CHECKED : MF_UNCHECKED); + break; + } + case RAMMENU_FILE_SAVEWINDOW: + { + RWSaveWindowPos ^=1; + CheckMenuItem(ramwatchmenu, RAMMENU_FILE_SAVEWINDOW, RWSaveWindowPos ? MF_CHECKED : MF_UNCHECKED); + break; + } + case IDC_C_ADDCHEAT: + { + watchIndex = ListView_GetSelectionMark(GetDlgItem(hDlg,IDC_WATCHLIST)) | (1 << 24); +// DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_EDITCHEAT), hDlg, (DLGPROC) EditCheatProc,(LPARAM) searchIndex); //TODO: made a IDD_EDITCHEAT dialog, and EditCheatProc (are they in GENS?) and integrate into cheats system + break; + } + case IDCANCEL: + RamWatchHWnd = NULL; + DragAcceptFiles(hDlg, FALSE); + EndDialog(hDlg, true); + return true; + default: + if (LOWORD(wParam) >= RW_MENU_FIRST_RECENT_FILE && LOWORD(wParam) < RW_MENU_FIRST_RECENT_FILE+MAX_RECENT_WATCHES) + OpenRWRecentFile(LOWORD(wParam) - RW_MENU_FIRST_RECENT_FILE); + } + break; + + case WM_KEYDOWN: // handle accelerator keys + { + SetFocus(GetDlgItem(hDlg,IDC_WATCHLIST)); + MSG msg; + msg.hwnd = hDlg; + msg.message = uMsg; + msg.wParam = wParam; + msg.lParam = lParam; + if(RamWatchAccels && TranslateAccelerator(hDlg, RamWatchAccels, &msg)) + return true; + } break; + + case WM_CLOSE: + RamWatchHWnd = NULL; + DragAcceptFiles(hDlg, FALSE); + EndDialog(hDlg, true); + return true; + + case WM_DROPFILES: + { + HDROP hDrop = (HDROP)wParam; + DragQueryFile(hDrop, 0, Str_Tmp, 1024); + DragFinish(hDrop); + return Load_Watches(true, Str_Tmp); + } break; + } + + return false; +} + diff --git a/desmume/src/windows/ramwatch.h b/src/windows/ramwatch.h similarity index 96% rename from desmume/src/windows/ramwatch.h rename to src/windows/ramwatch.h index 385223b6b..0272b8ebb 100644 --- a/desmume/src/windows/ramwatch.h +++ b/src/windows/ramwatch.h @@ -1,42 +1,42 @@ -//RamWatch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/ -//Authors: Upthorn, Nitsuja, adelikat - -#ifndef RAMWATCH_H -#define RAMWATCH_H -#include "windows.h" -bool ResetWatches(); -void OpenRWRecentFile(int memwRFileNumber); -extern bool AutoRWLoad; -extern bool RWSaveWindowPos; -#define MAX_RECENT_WATCHES 5 -extern char rw_recent_files[MAX_RECENT_WATCHES][1024]; -extern bool AskSave(); -extern int ramw_x; -extern int ramw_y; -extern bool RWfileChanged; - -// AddressWatcher is self-contained now -struct AddressWatcher -{ - unsigned int Address; // hardware address - char Size; - char Type; - char* comment; // NULL means no comment, non-NULL means allocated comment - bool WrongEndian; - unsigned int CurValue; -}; -#define MAX_WATCH_COUNT 256 -extern AddressWatcher rswatches[MAX_WATCH_COUNT]; -extern int WatchCount; // number of valid items in rswatches - -extern char Watch_Dir[1024]; - -bool InsertWatch(const AddressWatcher& Watch, char *Comment); -bool InsertWatch(const AddressWatcher& Watch, HWND parent=NULL); // asks user for comment -void Update_RAM_Watch(); -bool Load_Watches(bool clear, const char* filename); - -LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -extern HWND RamWatchHWnd; - -#endif +//RamWatch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/ +//Authors: Upthorn, Nitsuja, adelikat + +#ifndef RAMWATCH_H +#define RAMWATCH_H +#include "windows.h" +bool ResetWatches(); +void OpenRWRecentFile(int memwRFileNumber); +extern bool AutoRWLoad; +extern bool RWSaveWindowPos; +#define MAX_RECENT_WATCHES 5 +extern char rw_recent_files[MAX_RECENT_WATCHES][1024]; +extern bool AskSave(); +extern int ramw_x; +extern int ramw_y; +extern bool RWfileChanged; + +// AddressWatcher is self-contained now +struct AddressWatcher +{ + unsigned int Address; // hardware address + char Size; + char Type; + char* comment; // NULL means no comment, non-NULL means allocated comment + bool WrongEndian; + unsigned int CurValue; +}; +#define MAX_WATCH_COUNT 256 +extern AddressWatcher rswatches[MAX_WATCH_COUNT]; +extern int WatchCount; // number of valid items in rswatches + +extern char Watch_Dir[1024]; + +bool InsertWatch(const AddressWatcher& Watch, char *Comment); +bool InsertWatch(const AddressWatcher& Watch, HWND parent=NULL); // asks user for comment +void Update_RAM_Watch(); +bool Load_Watches(bool clear, const char* filename); + +LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +extern HWND RamWatchHWnd; + +#endif diff --git a/desmume/src/windows/replay.cpp b/src/windows/replay.cpp similarity index 95% rename from desmume/src/windows/replay.cpp rename to src/windows/replay.cpp index 0ecb871cc..f319f0b3e 100644 --- a/desmume/src/windows/replay.cpp +++ b/src/windows/replay.cpp @@ -1,239 +1,239 @@ -#include -#include -#include "resource.h" -#include "replay.h" -#include "common.h" -#include "main.h" -#include "movie.h" -#include "utils/xstring.h" - -bool replayreadonly=1; - -//adelikat: TODO: put this in one of the header files -template -inline std::wstring GetDlgItemTextW(HWND hDlg, int nIDDlgItem) { - wchar_t buf[BUFSIZE]; - GetDlgItemTextW(hDlg, nIDDlgItem, buf, BUFSIZE); - return buf; -} - -template -inline std::string GetDlgItemText(HWND hDlg, int nIDDlgItem) { - char buf[BUFSIZE]; - GetDlgItemText(hDlg, nIDDlgItem, buf, BUFSIZE); - return buf; -} - - -static char playfilename[MAX_PATH] = ""; - -void Describe(HWND hwndDlg) -{ - std::fstream fs (playfilename); - MovieData md; - LoadFM2(md, &fs, INT_MAX, false); - fs.close(); - - u32 num_frames = md.records.size(); - - double tempCount = num_frames / (33513982.0/6/355/263); - int num_seconds = (int)tempCount; - int fraction = ((int)tempCount - num_seconds) * 100; - int seconds = num_seconds % 60; - int minutes = (num_seconds / 60) % 60; - int hours = (num_seconds / 60 / 60) % 60; - char tmp[256]; - sprintf(tmp, "%02d:%02d:%02d.%02d", hours, minutes, seconds, fraction); - - SetDlgItemText(hwndDlg,IDC_MLENGTH,tmp); - SetDlgItemInt(hwndDlg,IDC_MFRAMES,num_frames,FALSE); - SetDlgItemText(hwndDlg, PM_FILENAME, playfilename); - SetDlgItemInt(hwndDlg,IDC_MRERECORDCOUNT,md.rerecordCount,FALSE); - SetDlgItemText(hwndDlg,IDC_MROM,md.romSerial.c_str()); -} - -//Replay movie dialog -BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - OPENFILENAME ofn; - char szChoice[MAX_PATH]={0}; - char filename[MAX_PATH] = ""; - - switch(uMsg) - { - case WM_INITDIALOG: - SendDlgItemMessage(hwndDlg, IDC_CHECK_READONLY, BM_SETCHECK, replayreadonly?BST_CHECKED:BST_UNCHECKED, 0); - - //Clear fields - SetWindowText(GetDlgItem(hwndDlg, IDC_MLENGTH), ""); - SetWindowText(GetDlgItem(hwndDlg, IDC_MFRAMES), ""); - SetWindowText(GetDlgItem(hwndDlg, IDC_MRERECORDCOUNT), ""); - SetWindowText(GetDlgItem(hwndDlg, IDC_MROM), ""); - return FALSE; - - case WM_COMMAND: - int wID = LOWORD(wParam); - switch(wID) - { - case ID_BROWSE: - - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = MainWindow->getHWnd(); - ofn.lpstrFilter = "Desmume Movie File (*.dsm)\0*.dsm\0All files(*.*)\0*.*\0\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile = filename; - ofn.lpstrTitle = "Replay Movie from File"; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "dsm"; - ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; - GetOpenFileName(&ofn); - strcpy(playfilename, filename); - Describe(hwndDlg); - return true; - - case IDC_CHECK_READONLY: - replayreadonly ^= 1; - return true; - - case IDOK: - FCEUI_LoadMovie(playfilename, replayreadonly, false, 80000); - ZeroMemory(&playfilename, sizeof(playfilename)); - EndDialog(hwndDlg, 0); - return true; - - case IDCANCEL: - ZeroMemory(&playfilename, sizeof(playfilename)); - EndDialog(hwndDlg, 0); - return true; - } - } - - return false; -} -int flag=0; -std::string sramfname; - -//Record movie dialog -static BOOL CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - static struct CreateMovieParameters* p = NULL; - std::wstring author = L""; - std::string fname; - int x; //temp vairable - switch(uMsg) - { - case WM_INITDIALOG: - CheckDlgButton(hwndDlg, IDC_START_FROM_SRAM, ((flag == 1) ? BST_CHECKED : BST_UNCHECKED)); - - return false; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDOK: { - author = GetDlgItemTextW<500>(hwndDlg,IDC_EDIT_AUTHOR); - fname = GetDlgItemText(hwndDlg,IDC_EDIT_FILENAME); - if (fname.length()) - { - FCEUI_SaveMovie(fname.c_str(), author, flag, sramfname); - EndDialog(hwndDlg, 0); - } - return true; - } - - case IDCANCEL: - EndDialog(hwndDlg, 0); - return true; - - case IDC_BUTTON_BROWSEFILE: - { - OPENFILENAME ofn; - char szChoice[MAX_PATH]={0}; - - // browse button - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = MainWindow->getHWnd(); - ofn.lpstrFilter = "Desmume Movie File (*.dsm)\0*.dsm\0All files(*.*)\0*.*\0\0"; - ofn.lpstrFile = szChoice; - ofn.lpstrTitle = "Record a new movie"; - ofn.lpstrDefExt = "dsm"; - ofn.nMaxFile = MAX_PATH; - ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; - GetSaveFileName(&ofn); - - //If user did not specify an extension, add .dsm for them - fname = szChoice; - x = fname.find_last_of("."); - if (x < 0) - fname.append(".dsm"); - - SetDlgItemText(hwndDlg, IDC_EDIT_FILENAME, fname.c_str()); - //if(GetSaveFileName(&ofn)) - // UpdateRecordDialogPath(hwndDlg,szChoice); - - return true; - } - case IDC_BUTTON_BROWSESRAM: - { - OPENFILENAME ofn; - char szChoice[MAX_PATH]={0}; - - // browse button - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = MainWindow->getHWnd(); - ofn.lpstrFilter = "Desmume SRAM File (*.dsv)\0*.dsv\0All files(*.*)\0*.*\0\0"; - ofn.lpstrFile = szChoice; - ofn.lpstrTitle = "Choose SRAM"; - ofn.lpstrDefExt = "dsv"; - ofn.nMaxFile = MAX_PATH; - ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - GetOpenFileName(&ofn); - - //If user did not specify an extension, add .dsm for them - fname = szChoice; - x = fname.find_last_of("."); - if (x < 0) - fname.append(".dsv"); - - SetDlgItemText(hwndDlg, IDC_EDIT_SRAMFILENAME, fname.c_str()); - sramfname=(std::string)fname; - //if(GetSaveFileName(&ofn)) - // UpdateRecordDialogPath(hwndDlg,szChoice); - - return true; - } - } - } - - HWND cur = GetDlgItem(hwndDlg, IDC_EDIT_SRAMFILENAME); - - IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? flag=1 : flag=0; - IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? EnableWindow(cur, TRUE) : EnableWindow(cur, FALSE); - - cur = GetDlgItem(hwndDlg, IDC_BUTTON_BROWSESRAM); - IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? EnableWindow(cur, TRUE) : EnableWindow(cur, FALSE); - - return false; -} - - -//Show the play movie dialog and play a movie -void Replay_LoadMovie() -{ - char* fn = (char*)DialogBoxParam(hAppInst, "IDD_REPLAYINP", MainWindow->getHWnd(), ReplayDialogProc, false); - - if(fn) - { - FCEUI_LoadMovie(fn, movie_readonly, false, -1); - - free(fn); - } -} - -//Show the record movie dialog and record a movie. -void MovieRecordTo() -{ - DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_RECORDMOVIE), MainWindow->getHWnd(), RecordDialogProc, (LPARAM)0); -} +#include +#include +#include "resource.h" +#include "replay.h" +#include "common.h" +#include "main.h" +#include "movie.h" +#include "utils/xstring.h" + +bool replayreadonly=1; + +//adelikat: TODO: put this in one of the header files +template +inline std::wstring GetDlgItemTextW(HWND hDlg, int nIDDlgItem) { + wchar_t buf[BUFSIZE]; + GetDlgItemTextW(hDlg, nIDDlgItem, buf, BUFSIZE); + return buf; +} + +template +inline std::string GetDlgItemText(HWND hDlg, int nIDDlgItem) { + char buf[BUFSIZE]; + GetDlgItemText(hDlg, nIDDlgItem, buf, BUFSIZE); + return buf; +} + + +static char playfilename[MAX_PATH] = ""; + +void Describe(HWND hwndDlg) +{ + std::fstream fs (playfilename); + MovieData md; + LoadFM2(md, &fs, INT_MAX, false); + fs.close(); + + u32 num_frames = md.records.size(); + + double tempCount = num_frames / (33513982.0/6/355/263); + int num_seconds = tempCount; + int fraction = (tempCount - num_seconds) * 100; + int seconds = num_seconds % 60; + int minutes = (num_seconds / 60) % 60; + int hours = (num_seconds / 60 / 60) % 60; + char tmp[256]; + sprintf(tmp, "%02d:%02d:%02d.%02d", hours, minutes, seconds, fraction); + + SetDlgItemText(hwndDlg,IDC_MLENGTH,tmp); + SetDlgItemInt(hwndDlg,IDC_MFRAMES,num_frames,FALSE); + SetDlgItemText(hwndDlg, PM_FILENAME, playfilename); + SetDlgItemInt(hwndDlg,IDC_MRERECORDCOUNT,md.rerecordCount,FALSE); + SetDlgItemText(hwndDlg,IDC_MROM,md.romSerial.c_str()); +} + +//Replay movie dialog +BOOL CALLBACK ReplayDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + OPENFILENAME ofn; + char szChoice[MAX_PATH]={0}; + char filename[MAX_PATH] = ""; + + switch(uMsg) + { + case WM_INITDIALOG: + SendDlgItemMessage(hwndDlg, IDC_CHECK_READONLY, BM_SETCHECK, replayreadonly?BST_CHECKED:BST_UNCHECKED, 0); + + //Clear fields + SetWindowText(GetDlgItem(hwndDlg, IDC_MLENGTH), ""); + SetWindowText(GetDlgItem(hwndDlg, IDC_MFRAMES), ""); + SetWindowText(GetDlgItem(hwndDlg, IDC_MRERECORDCOUNT), ""); + SetWindowText(GetDlgItem(hwndDlg, IDC_MROM), ""); + return FALSE; + + case WM_COMMAND: + int wID = LOWORD(wParam); + switch(wID) + { + case ID_BROWSE: + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = MainWindow->getHWnd(); + ofn.lpstrFilter = "Desmume Movie File (*.dsm)\0*.dsm\0All files(*.*)\0*.*\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = filename; + ofn.lpstrTitle = "Replay Movie from File"; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "dsm"; + ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; + GetOpenFileName(&ofn); + strcpy(playfilename, filename); + Describe(hwndDlg); + return true; + + case IDC_CHECK_READONLY: + replayreadonly ^= 1; + return true; + + case IDOK: + FCEUI_LoadMovie(playfilename, replayreadonly, false, 80000); + ZeroMemory(&playfilename, sizeof(playfilename)); + EndDialog(hwndDlg, 0); + return true; + + case IDCANCEL: + ZeroMemory(&playfilename, sizeof(playfilename)); + EndDialog(hwndDlg, 0); + return true; + } + } + + return false; +} +int flag=0; +std::string sramfname; + +//Record movie dialog +static BOOL CALLBACK RecordDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + static struct CreateMovieParameters* p = NULL; + std::wstring author = L""; + std::string fname; + int x; //temp vairable + switch(uMsg) + { + case WM_INITDIALOG: + CheckDlgButton(hwndDlg, IDC_START_FROM_SRAM, ((flag == 1) ? BST_CHECKED : BST_UNCHECKED)); + + return false; + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDOK: { + author = GetDlgItemTextW<500>(hwndDlg,IDC_EDIT_AUTHOR); + fname = GetDlgItemText(hwndDlg,IDC_EDIT_FILENAME); + if (fname.length()) + { + FCEUI_SaveMovie(fname.c_str(), author, flag, sramfname); + EndDialog(hwndDlg, 0); + } + return true; + } + + case IDCANCEL: + EndDialog(hwndDlg, 0); + return true; + + case IDC_BUTTON_BROWSEFILE: + { + OPENFILENAME ofn; + char szChoice[MAX_PATH]={0}; + + // browse button + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = MainWindow->getHWnd(); + ofn.lpstrFilter = "Desmume Movie File (*.dsm)\0*.dsm\0All files(*.*)\0*.*\0\0"; + ofn.lpstrFile = szChoice; + ofn.lpstrTitle = "Record a new movie"; + ofn.lpstrDefExt = "dsm"; + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOREADONLYRETURN | OFN_PATHMUSTEXIST; + GetSaveFileName(&ofn); + + //If user did not specify an extension, add .dsm for them + fname = szChoice; + x = fname.find_last_of("."); + if (x < 0) + fname.append(".dsm"); + + SetDlgItemText(hwndDlg, IDC_EDIT_FILENAME, fname.c_str()); + //if(GetSaveFileName(&ofn)) + // UpdateRecordDialogPath(hwndDlg,szChoice); + + return true; + } + case IDC_BUTTON_BROWSESRAM: + { + OPENFILENAME ofn; + char szChoice[MAX_PATH]={0}; + + // browse button + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = MainWindow->getHWnd(); + ofn.lpstrFilter = "Desmume SRAM File (*.dsv)\0*.dsv\0All files(*.*)\0*.*\0\0"; + ofn.lpstrFile = szChoice; + ofn.lpstrTitle = "Choose SRAM"; + ofn.lpstrDefExt = "dsv"; + ofn.nMaxFile = MAX_PATH; + ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; + GetOpenFileName(&ofn); + + //If user did not specify an extension, add .dsm for them + fname = szChoice; + x = fname.find_last_of("."); + if (x < 0) + fname.append(".dsv"); + + SetDlgItemText(hwndDlg, IDC_EDIT_SRAMFILENAME, fname.c_str()); + sramfname=(std::string)fname; + //if(GetSaveFileName(&ofn)) + // UpdateRecordDialogPath(hwndDlg,szChoice); + + return true; + } + } + } + + HWND cur = GetDlgItem(hwndDlg, IDC_EDIT_SRAMFILENAME); + + IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? flag=1 : flag=0; + IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? EnableWindow(cur, TRUE) : EnableWindow(cur, FALSE); + + cur = GetDlgItem(hwndDlg, IDC_BUTTON_BROWSESRAM); + IsDlgButtonChecked(hwndDlg, IDC_START_FROM_SRAM) ? EnableWindow(cur, TRUE) : EnableWindow(cur, FALSE); + + return false; +} + + +//Show the play movie dialog and play a movie +void Replay_LoadMovie() +{ + char* fn = (char*)DialogBoxParam(hAppInst, "IDD_REPLAYINP", MainWindow->getHWnd(), ReplayDialogProc, false); + + if(fn) + { + FCEUI_LoadMovie(fn, movie_readonly, false, -1); + + free(fn); + } +} + +//Show the record movie dialog and record a movie. +void MovieRecordTo() +{ + DialogBoxParam(hAppInst, MAKEINTRESOURCE(IDD_RECORDMOVIE), MainWindow->getHWnd(), RecordDialogProc, (LPARAM)0); +} diff --git a/desmume/src/windows/replay.h b/src/windows/replay.h similarity index 95% rename from desmume/src/windows/replay.h rename to src/windows/replay.h index d721b31b5..6a0880b94 100644 --- a/desmume/src/windows/replay.h +++ b/src/windows/replay.h @@ -1,2 +1,2 @@ -void Replay_LoadMovie(); -void MovieRecordTo(); +void Replay_LoadMovie(); +void MovieRecordTo(); diff --git a/desmume/src/windows/resource.h b/src/windows/resource.h similarity index 97% rename from desmume/src/windows/resource.h rename to src/windows/resource.h index f45064860..b3a9c97f8 100644 --- a/desmume/src/windows/resource.h +++ b/src/windows/resource.h @@ -1,813 +1,807 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by resources.rc -// -#define IDD_RECORDMOVIE 101 -#define IDM_OPEN 101 -#define IDM_QUIT 102 -#define IDC_FERMER 103 -#define IDD_DESASSEMBLEUR_VIEWER7 103 -#define IDC_STEP 104 -#define IDC_SETPNUM 105 -#define IDC_SCROLLER 106 -#define IDD_SOUNDSETTINGS 106 -#define IDC_GO 107 -#define IDC_AUTO_UPDATE 108 -#define IDM_MEMORY 109 -#define IDM_DISASSEMBLER 110 -#define IDD_3DSETTINGS 111 -#define IDM_GAME_INFO 111 -#define IDD_GBASLOT 113 -#define IDM_PAUSE 113 -#define IDD_GBASLOT_CFLASH 114 -#define IDM_RESET 114 -#define IDD_CHEAT_SEARCH_VIEW 115 -#define IDM_IOREG 115 -#define IDD_CHEAT_LIST 116 -#define IDD_CHEAT_ADD 117 -#define IDM_PAL 117 -#define IDM_TILE 118 -#define IDM_MAP 119 -#define IDM_MBG0 120 -#define IDM_MBG1 121 -#define IDM_MBG2 122 -#define IDM_MBG3 123 -#define IDM_SBG0 124 -#define IDM_SBG1 125 -#define IDM_SBG2 126 -#define IDM_SBG3 127 -#define IDM_OAM 128 -#define IDM_PRINTSCREEN 129 -#define IDM_QUICK_PRINTSCREEN 130 -#define IDM_SOUNDSETTINGS 131 -#define IDM_WEBSITE 132 -#define IDM_FORUM 133 -#define IDM_SUBMITBUGREPORT 134 -#define IDM_STATE_LOAD 135 -#define IDM_STATE_SAVE 136 -#define IDM_STATE_SAVE_F1 140 -#define IDM_STATE_SAVE_F2 141 -#define IDM_STATE_SAVE_F3 142 -#define IDM_STATE_SAVE_F4 143 -#define IDM_STATE_SAVE_F5 144 -#define IDM_STATE_SAVE_F6 145 -#define IDM_STATE_SAVE_F7 146 -#define IDM_STATE_SAVE_F8 147 -#define IDM_STATE_SAVE_F9 148 -#define IDM_STATE_SAVE_F10 149 -#define IDM_STATE_LOAD_F1 150 -#define IDM_STATE_LOAD_F2 151 -#define IDM_STATE_LOAD_F3 152 -#define IDM_STATE_LOAD_F4 153 -#define IDM_STATE_LOAD_F5 154 -#define IDM_STATE_LOAD_F6 155 -#define IDM_STATE_LOAD_F7 156 -#define IDM_STATE_LOAD_F8 157 -#define IDM_STATE_LOAD_F9 158 -#define IDM_STATE_LOAD_F10 159 -#define IDC_COMBO1 160 -#define IDC_COMBO2 161 -#define IDC_COMBO3 162 -#define IDC_COMBO4 163 -#define IDM_CONFIG 180 -#define IDD_INPUT 181 -#define IDC_SAVETYPE1 182 -#define IDC_SAVETYPE2 183 -#define IDC_SAVETYPE3 184 -#define IDC_SAVETYPE4 185 -#define IDC_SAVETYPE5 186 -#define IDC_SAVETYPE6 187 -#define IDC_FRAMESKIPAUTO 190 -#define IDC_FRAMESKIP0 191 -#define IDC_FRAMESKIP1 192 -#define IDC_FRAMESKIP2 193 -#define IDC_FRAMESKIP3 194 -#define IDC_FRAMESKIP4 195 -#define IDC_FRAMESKIP5 196 -#define IDC_FRAMESKIP6 197 -#define IDC_FRAMESKIP7 198 -#define IDC_FRAMESKIP8 199 -#define IDC_EDIT_FILENAME 200 -#define IDC_FRAMESKIP9 200 -#define IDC_BUTTON_BROWSEFILE 201 -#define IDC_CHECK_READONLY 201 -#define IDM_IMPORTBACKUPMEMORY 201 -#define IDC_LANGENGLISH 210 -#define IDC_LANGFRENCH 211 -#define IDC_LANGDANISH 212 -#define IDM_MGPU 213 -#define IDM_SGPU 214 -#define IDC_8_BIT 302 -#define IDC_16_BIT 303 -#define IDC_32_BIT 304 -#define IDC_BACKGROUNDPAUSE 305 -#define IDC_LUACONSOLE 309 -#define IDC_EDIT_LUAPATH 310 -#define IDC_BUTTON_LUARUN 311 -#define IDC_BUTTON_LUASTOP 312 -#define IDC_BUTTON_LUABROWSE 313 -#define IDC_BUTTON_LUAEDIT 314 -#define IDC_NOTIFY_SUBSERVIENT 315 -#define IDD_ARCHIVEFILECHOOSER 316 -#define IDD_LUA 317 -#define IDC_NEW_LUA_SCRIPT 318 -#define IDC_PATHEDIT 319 -#define IDC_BROWSE 320 -#define IDC_USELASTVISIT 321 -#define IDC_FORMATEDIT 322 -#define IDC_PATHLIST 323 -#define IDC_SAVEAS 324 -#define IDC_PNG 325 -#define IDC_BMP 326 -#define IDC_FORMATSTATIC 327 -#define IDM_PATHSETTINGS 350 -#define IDC_ROMPATHEDIT 351 -#define IDC_BROWSEROMS 352 -#define IDC_PATHDEFAULTS 353 -#define IDC_SAVERAMPATHEDIT 354 -#define IDC_BROWSESRAM 355 -#define IDC_STATEPATHEDIT 356 -#define IDC_BROWSESTATES 357 -#define IDC_SCREENSHOTPATHEDIT 358 -#define IDC_BROWSESCREENSHOTS 359 -#define IDC_AVIPATHEDIT 360 -#define IDC_BROWSEAVI 361 -#define IDC_CHEATPATHEDIT 362 -#define IDC_BROWSECHEATS 363 -#define IDC_LUAPATHEDIT 364 -#define IDC_BROWSELUA 365 -#define IDD_PATHSETTINGS 366 -#define IDC_STATEREWINDING 367 -#define IDC_DES_BOX 402 -#define IDC_R0 403 -#define IDC_R1 404 -#define IDC_R2 405 -#define IDC_R3 406 -#define IDC_R4 407 -#define IDC_R5 408 -#define IDC_R6 409 -#define IDC_R7 410 -#define IDC_R8 411 -#define IDC_R9 412 -#define IDC_R10 413 -#define IDC_R11 414 -#define IDC_R12 415 -#define IDC_R13 416 -#define IDC_R14 417 -#define IDC_R15 418 -#define IDC_MODE 419 -#define IDC_AUTO_DES 420 -#define IDC_ARM 421 -#define IDC_THUMB 422 -#define IDC_GOTODES 423 -#define IDC_TMP 424 -#define IDD_GAME_INFO 501 -#define ID_RAM_WATCH 550 -#define IDM_RENDER_NORMAL 551 -#define IDM_RENDER_HQ2X 552 -#define IDM_RENDER_2XSAI 553 -#define IDM_RENDER_SUPER2XSAI 554 -#define IDM_RENDER_SUPEREAGLE 555 -#define IDM_RENDER_SCANLINE 556 -#define IDM_RENDER_BILINEAR 557 -#define IDM_RENDER_NEAREST2X 558 -#define IDD_IO_REG 601 -#define IDM_RECORD_MOVIE 602 -#define IDM_PLAY_MOVIE 603 -#define IDD_PAL 703 -#define IDD_TILE 704 -#define IDC_PAL_SELECT 705 -#define IDC_PALNUM 706 -#define IDC_MEM_SELECT 707 -#define IDC_Tile_BOX 708 -#define IDC_BITMAP 709 -#define IDC_256COUL 710 -#define IDC_16COUL 711 -#define IDC_MINI_TILE 712 -#define IDC_TILENUM 713 -#define IDD_MAP 800 -#define IDC_BG_SELECT 801 -#define IDC_PAL 803 -#define IDC_PRIO 804 -#define IDC_CHAR 805 -#define IDC_SCR 806 -#define IDC_MSIZE 807 -#define IDC_SCROLL 808 -#define IDD_OAM 900 -#define IDC_SCR_SELECT 901 -#define IDC_TILE 902 -#define IDC_OAMNUM 903 -#define IDC_COOR 904 -#define IDC_DIM 905 -#define IDC_ROT 906 -#define IDC_MOS 907 -#define IDC_PROP0 908 -#define IDC_PROP1 909 -#define IDD_BGMAP_VIEWER 911 -#define IDB_BGTILES 913 -#define IDD_EMULATIONSETTINGS 916 -#define IDD_WIFISETTINGS 918 -#define IDD_MEM_VIEW 920 -#define IDC_DIFFERENTFROM 921 -#define IDC_DIFFERENTBY 922 -#define IDC_MODULO 923 -#define IDC_EDIT_DIFFBY 924 -#define IDC_EDIT_MODBY 925 -#define IDC_PREVIOUSVALUE 926 -#define IDC_SPECIFICVALUE 927 -#define IDC_NUMBEROFCHANGES 928 -#define IDC_EDIT_COMPAREVALUE 929 -#define IDC_EDIT_COMPARECHANGES 930 -#define IDC_C_AUTOSEARCH 931 -#define IDC_MISALIGN 932 -#define IDC_C_RESET_CHANGES 933 -#define IDC_C_UNDO 934 -#define ID_RAM_SEARCH 935 -#define IDD_RAMSEARCH 945 -#define IDC_SPECIFICADDRESS 950 -#define IDC_EDIT_COMPAREADDRESS 951 -#define IDC_PROMPT_TEXT 952 -#define IDC_PROMPT_EDIT 953 -#define IDC_SIGNED 954 -#define IDC_UNSIGNED 955 -#define IDC_HEX 956 -#define IDC_1_BYTE 957 -#define IDC_2_BYTES 958 -#define IDC_4_BYTES 959 -#define IDC_WATCHLIST 960 -#define IDC_C_WATCH_EDIT 961 -#define IDC_C_WATCH_REMOVE 962 -#define IDC_C_WATCH 963 -#define IDC_C_WATCH_DUPLICATE 964 -#define IDC_C_ADDCHEAT 965 -#define ID_WATCHES_UPDOWN 966 -#define IDD_RAMWATCH 967 -#define IDR_ACCELERATOR1 968 -#define IDD_PROMPT 969 -#define IDD_IOREG_VIEW_MEM_IRQ 970 -#define ID_VIEW_DISPLAYGRAPHICALINPUT 971 -#define IDD_IOREG_VIEW_SPI 973 -#define IDD_IOREG_VIEW_CP15 975 -#define IDD_SOUND_VIEW 977 -#define IDC_START_FROM_SRAM 978 -#define IDC_EDIT_SRAMFILENAME 979 -#define IDC_BUTTON_BROWSESRAM 980 -#define IDC_C_WATCH_UP 980 -#define IDD_EDITWATCH 980 -#define IDC_C_WATCH_DOWN 981 -#define RAMMENU_FILE_AUTOLOAD 982 -#define RAMMENU_FILE_SAVEWINDOW 983 -#define RAMMENU_FILE_SAVE 984 -#define RAMMENU_FILE_SAVEAS 985 -#define RAMMENU_FILE_OPEN 986 -#define RAMMENU_FILE_APPEND 987 -#define RAMMENU_FILE_NEW 988 -#define RAMMENU_FILE_RECENT 990 -#define IDC_RAMLIST 991 -#define IDC_C_SEARCH 992 -#define IDC_C_RESET 993 -#define IDC_C_ELIMINATE 994 -#define IDC_LESSTHAN 995 -#define IDC_MORETHAN 996 -#define IDC_NOMORETHAN 997 -#define IDC_NOLESSTHAN 998 -#define IDC_EQUALTO 999 -#define IDC_BGMAP_SEL 1000 -#define IDC_BRIDGEADAPTER 1000 -#define IDC_EDIT03 1000 -#define IDC_SOUNDCORECB 1000 -#define IDC_USEEXTBIOS 1000 -#define ID_BROWSE 1000 -#define IDC_ALTERNATEFLUSH 1001 -#define IDC_BGMAP_BGXCNT 1001 -#define IDC_CHECKBOX_DEBUGGERMODE 1001 -#define IDC_EDIT01 1001 -#define IDC_IOREG_TAB 1001 -#define IDC_SOUNDBUFFERET 1001 -#define IDC_SOUNDVIEW_CHANSWITCH 1001 -#define PM_FILENAME 1001 -#define IDC_ARM9BIOS 1002 -#define IDC_EDIT05 1002 -#define IDC_MLENGTH 1002 -#define IDC_SLVOLUME 1002 -#define IDC_BGMAP_TYPE 1003 -#define IDC_EDIT08 1003 -#define IDC_GI_GAMETITLE 1003 -#define IDC_MFRAMES 1003 -#define IDC_ROTATE0 1003 -#define IDC_BUTTON2 1003 -#define IDC_ARM9BIOSBROWSE 1004 -#define IDC_EDIT11 1004 -#define IDC_GI_GAMECODE 1004 -#define IDC_MRERECORDCOUNT 1004 -#define IDC_ROTATE90 1004 -#define IDC_SPU_INTERPOLATION_CB 1004 -#define IDC_BUTTON_VOLMODE 1004 -#define IDC_ARM7BIOS 1005 -#define IDC_EDIT07 1005 -#define IDC_MROM 1005 -#define IDC_ROTATE180 1005 -#define IDC_GGREEN 1005 -#define IDC_EDIT12 1006 -#define IDC_ROTATE270 1006 -#define IDC_SPU_CACHE 1006 -#define IDC_GRED 1006 -#define IDC_WIFIMODE0 1006 -#define IDC_ARM7BIOSBROWSE 1007 -#define IDC_EDIT06 1007 -#define IDC_GYELLOW 1007 -#define IDC_WIFIMODE1 1007 -#define IDC_EDIT09 1008 -#define IDC_MEMVIEWBOX 1008 -#define IDC_GBLUE 1008 -#define IDC_ADHOC_SERVER 1008 -#define IDC_ADDRESS 1009 -#define IDC_BIOSSWIS 1009 -#define IDC_EDIT10 1009 -#define IDC_FORCERATIO 1009 -#define IDC_ADHOC_CLIENT 1009 -#define IDC_AUTO_UPDATE_SPIN 1010 -#define IDC_EDIT15 1010 -#define IDC_TEXTDUMP 1010 -#define IDC_WINDOW1X 1010 -#define IDC_ADHOC_SERVERNAME 1010 -#define IDC_AUTO_UPDATE_SECS 1011 -#define IDC_USEEXTFIRMWARE 1011 -#define IDC_WINDOW2X 1011 -#define IDC_FIRMWARE 1012 -#define IDC_RAWDUMP 1012 -#define IDC_REFRESH 1012 -#define IDC_WINDOW3X 1012 -#define IDC_EDIT02 1013 -#define IDC_WINDOW4X 1013 -#define IDC_EDIT04 1014 -#define IDC_FIRMWAREBROWSE 1014 -#define IDC_BGMAP_CHARBASE 1016 -#define IDC_FIRMWAREBOOT 1016 -#define IDC_BGMAP_SCRBASE 1017 -#define IDC_AUTOUPDATE_ASM 1018 -#define IDC_BGMAP_PRIO 1018 -#define IDC_BGMAP_PAL 1019 -#define IDC_VISIBLE 1019 -#define IDC_BGMAP_SIZE 1020 -#define IDC_IPCFIFO9 1020 -#define IDC_BGMAP_SCROLL 1021 -#define IDC_IPCSYNC9 1021 -#define IDC_IF9 1022 -#define IDC_INTHAND9 1023 -#define IDC_IE9 1024 -#define IDC_BGMAP_MOSAIC 1025 -#define IDC_DISPCNTA9 1025 -#define IDC_BGMAP_SPECEFF 1026 -#define IDC_DISPSTATA9 1026 -#define IDC_BGMAP_WINDOWS 1027 -#define IDC_DEFAULT 1027 -#define IDC_DISPCNTB9 1027 -#define IDC_3DCORE 1028 -#define IDC_DISPSTATB9 1028 -#define IDC_IME9 1029 -#define IDC_TXT_COMPILED 1029 -#define IDC_GXSTAT9 1030 -#define IDC_TXT_VERSION 1030 -#define IDC_IE7 1032 -#define IDC_ADDONS_LIST 1033 -#define IDC_IF7 1033 -#define IDC_ADDONS_INFO 1034 -#define IDC_IME7 1034 -#define IDC_BBROWSE 1035 -#define IDC_IPCSYNC7 1035 -#define IDC_IPCFIFO7 1036 -#define IDC_PATHIMG 1036 -#define IDC_PATH 1037 -#define IDC_PATHGAME 1037 -#define IDC_RFILE 1038 -#define IDC_RFOLDER 1039 -#define IDC_BBROWSE2 1040 -#define IDC_PATHDESMUME 1041 -#define IDC_BRESTART 1042 -#define IDC_BVIEW 1043 -#define IDC_BSEARCH 1044 -#define IDC_RADIO1 1045 -#define IDC_RADIO2 1046 -#define IDC_RADIO3 1047 -#define IDC_RADIO4 1048 -#define IDC_RADIO5 1049 -#define IDC_RADIO6 1050 -#define IDC_RADIO7 1051 -#define IDC_RADIO8 1052 -#define IDC_LIST1 1056 -#define IDC_BADD_AR 1057 -#define IDC_BADD_CB 1058 -#define IDC_BREMOVE 1060 -#define IDC_BEDIT 1061 -#define IDC_STATIC_S1 1061 -#define IDC_STATIC_S2 1062 -#define IDC_STATIC_S3 1063 -#define IDC_STATIC_S4 1064 -#define IDC_EVALUE 1065 -#define IDC_STATIC_RANGE 1066 -#define IDC_BADD 1068 -#define IDC_LIST 1069 -#define IDC_SNUMBER 1071 -#define IDC_CHECK1 1074 -#define IDC_CHECK2 1075 - -#define IDC_CHECK3 1076 - -#define IDC_CHECK4 1077 -#define IDC_CHECK6 1080 -#define IDC_CHECK7 1082 -#define IDC_CHECK8 1083 -#define IDC_CHECK9 1088 -#define IDM_FIRMSETTINGS 1100 -#define IDD_FIRMSETTINGS 1101 -#define IDC_EDIT1 1102 -#define IDC_EDIT2 1103 -#define IDC_EDIT13 1104 -#define IDC_EDIT3 1104 -#define IDC_EDIT14 1105 -#define IDC_EDIT_AUTHOR 1180 -#define IDD_MATRIX_VIEWER 1200 -#define IDM_MATRIX_VIEWER 1200 -#define IDC_MATRIX_VIEWER_COORD_GROUP 1201 -#define IDC_MATRIX_VIEWER_COORD_COMBO 1202 -#define IDC_MATRIX_VIEWER_COORD_11_EDIT 1203 -#define IDC_MATRIX_VIEWER_COORD_12_EDIT 1204 -#define IDC_MATRIX_VIEWER_COORD_13_EDIT 1205 -#define IDC_MATRIX_VIEWER_COORD_14_EDIT 1206 -#define IDC_MATRIX_VIEWER_COORD_21_EDIT 1207 -#define IDC_MATRIX_VIEWER_COORD_22_EDIT 1208 -#define IDC_MATRIX_VIEWER_COORD_23_EDIT 1209 -#define IDC_MATRIX_VIEWER_COORD_24_EDIT 1210 -#define IDC_MATRIX_VIEWER_COORD_31_EDIT 1211 -#define IDC_MATRIX_VIEWER_COORD_32_EDIT 1212 -#define IDC_MATRIX_VIEWER_COORD_33_EDIT 1213 -#define IDC_MATRIX_VIEWER_COORD_34_EDIT 1214 -#define IDC_MATRIX_VIEWER_COORD_41_EDIT 1215 -#define IDC_MATRIX_VIEWER_COORD_42_EDIT 1216 -#define IDC_MATRIX_VIEWER_COORD_43_EDIT 1217 -#define IDC_MATRIX_VIEWER_COORD_44_EDIT 1218 -#define IDC_MATRIX_VIEWER_DIR_GROUP 1221 -#define IDC_MATRIX_VIEWER_DIR_COMBO 1222 -#define IDC_MATRIX_VIEWER_DIR_11_EDIT 1223 -#define IDC_MATRIX_VIEWER_DIR_12_EDIT 1224 -#define IDC_MATRIX_VIEWER_DIR_13_EDIT 1225 -#define IDC_MATRIX_VIEWER_DIR_14_EDIT 1226 -#define IDC_MATRIX_VIEWER_DIR_21_EDIT 1227 -#define IDC_MATRIX_VIEWER_DIR_22_EDIT 1228 -#define IDC_MATRIX_VIEWER_DIR_23_EDIT 1229 -#define IDC_MATRIX_VIEWER_DIR_24_EDIT 1230 -#define IDC_MATRIX_VIEWER_DIR_31_EDIT 1231 -#define IDC_MATRIX_VIEWER_DIR_32_EDIT 1232 -#define IDC_MATRIX_VIEWER_DIR_33_EDIT 1233 -#define IDC_MATRIX_VIEWER_DIR_34_EDIT 1234 -#define IDC_MATRIX_VIEWER_DIR_41_EDIT 1235 -#define IDC_MATRIX_VIEWER_DIR_42_EDIT 1236 -#define IDC_MATRIX_VIEWER_DIR_43_EDIT 1237 -#define IDC_MATRIX_VIEWER_DIR_44_EDIT 1238 -#define IDC_MATRIX_VIEWER_PROJ_GROUP 1241 -#define IDC_MATRIX_VIEWER_PROJ_11_EDIT 1243 -#define IDC_MATRIX_VIEWER_PROJ_12_EDIT 1244 -#define IDC_MATRIX_VIEWER_PROJ_13_EDIT 1245 -#define IDC_MATRIX_VIEWER_PROJ_14_EDIT 1246 -#define IDC_MATRIX_VIEWER_PROJ_21_EDIT 1247 -#define IDC_MATRIX_VIEWER_PROJ_22_EDIT 1248 -#define IDC_MATRIX_VIEWER_PROJ_23_EDIT 1249 -#define IDC_MATRIX_VIEWER_PROJ_24_EDIT 1250 -#define IDC_MATRIX_VIEWER_PROJ_31_EDIT 1251 -#define IDC_MATRIX_VIEWER_PROJ_32_EDIT 1252 -#define IDC_MATRIX_VIEWER_PROJ_33_EDIT 1253 -#define IDC_MATRIX_VIEWER_PROJ_34_EDIT 1254 -#define IDC_MATRIX_VIEWER_PROJ_41_EDIT 1255 -#define IDC_MATRIX_VIEWER_PROJ_42_EDIT 1256 -#define IDC_MATRIX_VIEWER_PROJ_43_EDIT 1257 -#define IDC_MATRIX_VIEWER_PROJ_44_EDIT 1258 -#define IDC_MATRIX_VIEWER_TEX_GROUP 1261 -#define IDC_MATRIX_VIEWER_TEX_11_EDIT 1263 -#define IDC_MATRIX_VIEWER_TEX_12_EDIT 1264 -#define IDC_MATRIX_VIEWER_TEX_13_EDIT 1265 -#define IDC_MATRIX_VIEWER_TEX_14_EDIT 1266 -#define IDC_MATRIX_VIEWER_TEX_21_EDIT 1267 -#define IDC_MATRIX_VIEWER_TEX_22_EDIT 1268 -#define IDC_MATRIX_VIEWER_TEX_23_EDIT 1269 -#define IDC_MATRIX_VIEWER_TEX_24_EDIT 1270 -#define IDC_MATRIX_VIEWER_TEX_31_EDIT 1271 -#define IDC_MATRIX_VIEWER_TEX_32_EDIT 1272 -#define IDC_MATRIX_VIEWER_TEX_33_EDIT 1273 -#define IDC_MATRIX_VIEWER_TEX_34_EDIT 1274 -#define IDC_MATRIX_VIEWER_TEX_41_EDIT 1275 -#define IDC_MATRIX_VIEWER_TEX_42_EDIT 1276 -#define IDC_MATRIX_VIEWER_TEX_43_EDIT 1277 -#define IDC_MATRIX_VIEWER_TEX_44_EDIT 1278 -#define IDD_LIGHT_VIEWER 1300 -#define IDM_LIGHT_VIEWER 1300 -#define IDC_LIGHT_VIWER_LIGHT0_GROUP 1301 -#define IDD_ABOUT_BOX 1301 -#define IDC_AUTHORS_LIST 1302 -#define IDC_LIGHT_VIEWER_LIGHT0COLOR_COLORCTRL 1302 -#define IDD_DESASSEMBLEUR_VIEWER9 1302 -#define IDC_LIGHT_VIEWER_LIGHT0COLOR_EDIT 1303 -#define IDC_LIGHT_VIEWER_LIGHT0VECTOR_EDIT 1304 -#define IDD_GBASLOT_NONE 1304 -#define IDD_GBASLOT_RUMBLEPAK 1305 -#define IDD_GBASLOT_GBAGAME 1306 -#define IDD_CHEAT_SEARCH_COMP 1307 -#define IDD_CHEAT_SEARCH_MAIN 1308 -#define IDD_CHEAT_SEARCH_RESULT 1310 -#define IDC_LIGHT_VIWER_LIGHT1_GROUP 1311 -#define IDD_CHEAT_SEARCH_EXACT 1311 -#define IDC_LIGHT_VIEWER_LIGHT1COLOR_COLORCTRL 1312 -#define IDD_CHEAT_SEARCH 1312 -#define IDC_LIGHT_VIEWER_LIGHT1COLOR_EDIT 1313 -#define IDC_LIGHT_VIEWER_LIGHT1VECTOR_EDIT 1314 -#define IDC_LIGHT_VIWER_LIGHT2_GROUP 1321 -#define IDC_LIGHT_VIEWER_LIGHT2COLOR_COLORCTRL 1322 -#define IDC_LIGHT_VIEWER_LIGHT2COLOR_EDIT 1323 -#define IDC_LIGHT_VIEWER_LIGHT2VECTOR_EDIT 1324 -#define IDC_LIGHT_VIWER_LIGHT3_GROUP 1331 -#define IDC_LIGHT_VIEWER_LIGHT3COLOR_COLORCTRL 1332 -#define IDC_LIGHT_VIEWER_LIGHT3COLOR_EDIT 1333 -#define IDC_LIGHT_VIEWER_LIGHT3VECTOR_EDIT 1334 -#define IDC_SOUND0ID 1350 -#define IDC_SOUND1ID 1351 -#define IDC_SOUND2ID 1352 -#define IDC_SOUND3ID 1353 -#define IDC_SOUND4ID 1354 -#define IDC_SOUND5ID 1355 -#define IDC_SOUND6ID 1356 -#define IDC_SOUND7ID 1357 -#define IDC_SOUND0VOL 1358 -#define IDC_SOUND1VOL 1359 -#define IDC_SOUND2VOL 1360 -#define IDC_SOUND3VOL 1361 -#define IDC_SOUND4VOL 1362 -#define IDC_SOUND5VOL 1363 -#define IDC_SOUND6VOL 1364 -#define IDC_SOUND7VOL 1365 -#define IDC_SOUND0VOLBAR 1366 -#define IDC_SOUND1VOLBAR 1367 -#define IDC_SOUND2VOLBAR 1368 -#define IDC_SOUND3VOLBAR 1369 -#define IDC_SOUND4VOLBAR 1370 -#define IDC_SOUND5VOLBAR 1371 -#define IDC_SOUND6VOLBAR 1372 -#define IDC_SOUND7VOLBAR 1373 -#define IDC_SOUND0PAN 1374 -#define IDC_SOUND1PAN 1375 -#define IDC_SOUND2PAN 1376 -#define IDC_SOUND3PAN 1377 -#define IDC_SOUND4PAN 1378 -#define IDC_SOUND5PAN 1379 -#define IDC_SOUND6PAN 1380 -#define IDC_SOUND7PAN 1381 -#define IDC_SOUND0PANBAR 1382 -#define IDC_SOUND1PANBAR 1383 -#define IDC_SOUND2PANBAR 1384 -#define IDC_SOUND3PANBAR 1385 -#define IDC_SOUND4PANBAR 1386 -#define IDC_SOUND5PANBAR 1387 -#define IDC_SOUND6PANBAR 1388 -#define IDC_SOUND7PANBAR 1389 -#define IDC_SOUND0HOLD 1390 -#define IDC_SOUND1HOLD 1391 -#define IDC_SOUND2HOLD 1392 -#define IDC_SOUND3HOLD 1393 -#define IDC_SOUND4HOLD 1394 -#define IDC_SOUND5HOLD 1395 -#define IDC_SOUND6HOLD 1396 -#define IDC_SOUND7HOLD 1397 -#define IDC_SOUND0BUSY 1398 -#define IDC_SOUND1BUSY 1399 -#define IDC_SOUND2BUSY 1400 -#define IDC_SOUND3BUSY 1401 -#define IDC_SOUND4BUSY 1402 -#define IDC_SOUND5BUSY 1403 -#define IDC_SOUND6BUSY 1404 -#define IDC_SOUND7BUSY 1405 -#define IDC_SOUND0REPEATMODE 1406 -#define IDC_SOUND1REPEATMODE 1407 -#define IDC_SOUND2REPEATMODE 1408 -#define IDC_SOUND3REPEATMODE 1409 -#define IDC_SOUND4REPEATMODE 1410 -#define IDC_SOUND5REPEATMODE 1411 -#define IDC_SOUND6REPEATMODE 1412 -#define IDC_SOUND7REPEATMODE 1413 -#define IDC_SOUND0FORMAT 1414 -#define IDC_SOUND1FORMAT 1415 -#define IDC_SOUND2FORMAT 1416 -#define IDC_SOUND3FORMAT 1417 -#define IDC_SOUND4FORMAT 1418 -#define IDC_SOUND5FORMAT 1419 -#define IDC_SOUND6FORMAT 1420 -#define IDC_SOUND7FORMAT 1421 -#define IDC_SOUND0SAD 1422 -#define IDC_SOUND1SAD 1423 -#define IDC_SOUND2SAD 1424 -#define IDC_SOUND3SAD 1425 -#define IDC_SOUND4SAD 1426 -#define IDC_SOUND5SAD 1427 -#define IDC_SOUND6SAD 1428 -#define IDC_SOUND7SAD 1429 -#define IDC_SOUND0PNT 1430 -#define IDC_SOUND1PNT 1431 -#define IDC_SOUND2PNT 1432 -#define IDC_SOUND3PNT 1433 -#define IDC_SOUND4PNT 1434 -#define IDC_SOUND5PNT 1435 -#define IDC_SOUND6PNT 1436 -#define IDC_SOUND7PNT 1437 -#define IDC_SOUND0TMR 1438 -#define IDC_SOUND1TMR 1439 -#define IDC_SOUND2TMR 1440 -#define IDC_SOUND3TMR 1441 -#define IDC_SOUND4TMR 1442 -#define IDC_SOUND5TMR 1443 -#define IDC_SOUND6TMR 1444 -#define IDC_SOUND7TMR 1445 -#define IDC_SOUND0POSLEN 1446 -#define IDC_SOUND1POSLEN 1447 -#define IDC_SOUND2POSLEN 1448 -#define IDC_SOUND3POSLEN 1449 -#define IDC_SOUND4POSLEN 1450 -#define IDC_SOUND5POSLEN 1451 -#define IDC_SOUND6POSLEN 1452 -#define IDC_SOUND7POSLEN 1453 -#define IDC_SOUND0MUTE 2001 -#define IDC_SOUND1MUTE 2002 -#define IDC_SOUND2MUTE 2003 -#define IDC_SOUND3MUTE 2004 -#define IDC_SOUND4MUTE 2005 -#define IDC_SOUND5MUTE 2006 -#define IDC_SOUND6MUTE 2007 -#define IDC_SOUND7MUTE 2008 -#define IDC_GI_FATOFS 4464 -#define IDC_INTERPOLATECOLOR 4464 -#define IDC_GI_FATSIZE 4465 -#define IDC_GI_ICONTITLEOFS 4466 -#define IDC_CLOSE 4467 -#define IDC_GI_USEDROMSIZE 4467 -#define IDC_GI_ICON 4469 -#define IDC_GI_TITLE 4470 -#define IDC_GI_TITLEEN 4471 -#define IDC_GI_TITLEFR 4472 -#define IDC_GI_TITLEGE 4473 -#define IDC_GI_TITLEIT 4474 -#define IDC_GI_TITLESP 4475 -#define IDC_GI_MAKERCODE 4476 -#define IDC_GI_TITLEJP 4477 -#define IDC_GI_CHIPSIZE 4478 -#define IDC_GI_ARM9START 4479 -#define IDC_GI_ARM9ENTRY 4480 -#define IDC_GI_ARM9ROM 4481 -#define IDC_GI_ARM9SIZE 4482 -#define IDC_GI_ARM7ROM 4483 -#define IDC_GI_ARM7ENTRY 4484 -#define IDC_GI_ARM7START 4485 -#define IDC_GI_ARM7SIZE 4486 -#define IDC_GI_FNTOFS 4487 -#define IDC_GI_FNTSIZE 4488 -#define IDD_MICROPHONE 5000 -#define IDM_MICROPHONESETTINGS 5001 -#define IDC_MICSAMPLEBROWSE 5003 -#define IDC_MICSAMPLE 5004 -#define IDC_USEMICSAMPLE 5005 -#define IDD_IOREG_VIEW 10000 -#define IDD_IOREG_VIEW_GPU_A 10001 -#define IDD_IOREG_VIEW_GPU_B 10002 -#define IDD_IOREG_VIEW_GPU_3D 10003 -#define IDD_IOREG_VIEW_GPU_MISC 10004 -#define IDD_CHEAT_ADD_XX_CODE 10005 -#define IDD_IOREG_VIEW_DMA 10006 -#define IDD_IOREG_VIEW_TIMERS 10007 -#define IDD_IOREG_VIEW_IPC_ROM 10008 -#define IDD_GBASLOT_GUITARGRIP 10009 -#define IDM_FILE_STOPAVI 40000 -#define IDM_SCREENSEP_NONE 40000 -#define IDM_FILE_STOPWAV 40001 -#define IDM_SCREENSEP_BORDER 40001 -#define IDM_SCREENSEP_NDSGAP 40002 -#define IDM_ABOUT 40003 -#define IDM_EMULATIONSETTINGS 40004 -#define IDC_FRAMELIMIT 40005 -#define ID_CONFIG_PAUSEWHENFOCUSLOST 40005 -#define IDC_WINDOW1_5X 40006 -#define IDM_WIFISETTINGS 40007 -#define IDM_ALWAYS_ON_TOP 40008 -#define ID_VIEW_FRAMECOUNTER 40009 -#define ID_VIEW_DISPLAYFPS 40010 -#define ID_VIEW_DISPLAYINPUT 40011 -#define ID_VIEW_DISPLAYLAG 40012 -#define ID_VIEW_HUDEDITOR 40013 -#define ID_VIEW_DISPLAYMICROPHONE 40014 -#define IDM_FILE_RECORDAVI 40015 -#define IDM_SOUND_VIEW 40016 -#define IDM_FILE_RECORDWAV 40017 -#define IDM_EXPORTBACKUPMEMORY 40018 -#define IDM_STOPMOVIE 40019 -#define IDC_LANG_CHINESE_SIMPLIFIED 40020 -#define IDM_SCREENSEP_NDSGAP2 40021 -#define IDM_SCREENSEP_DRAGEDIT 40022 -#define ID_FILE_RECENTROM 40034 -#define IDC_SAVETYPE7 40037 -#define IDM_DEFSIZE 40038 -#define IDM_3DCONFIG 40040 -#define IDM_GBASLOT 40042 -#define IDM_CHEATS_LIST 40050 -#define IDC_BGMAP_ROTSCALEPARAMS 40051 -#define IDM_CHEATS_SEARCH 40051 -#define IDC_BGMAP_ROTSCALE 40052 -#define IDM_SHUT_UP 40053 -#define IDC_WINDOW2_5X 40054 -#define IDC_LABEL_UP 50000 -#define IDC_LABEL_RIGHT 50001 -#define IDC_LABEL_LEFT 50002 -#define IDC_LABEL_DOWN 50003 -#define IDC_LABEL_A 50004 -#define IDC_LABEL_X 50005 -#define IDC_LABEL_B 50006 -#define IDC_LABEL_Y 50007 -#define IDC_LABEL_L 50008 -#define IDC_LABEL_START 50009 -#define IDC_LABEL_R 50010 -#define IDC_LABEL_SELECT 50011 -#define IDC_LABEL_UPLEFT 50012 -#define IDC_LABEL_DOWNRIGHT 50013 -#define IDC_LABEL_UPRIGHT 50014 -#define IDC_LABEL_DOWNLEFT 50015 -#define IDC_ALLOWLEFTRIGHT 50016 -#define IDC_LABEL_X3 50017 -#define IDC_LABEL_X2 50018 -#define IDC_DEBUG 50019 -#define IDC_UP 50020 -#define IDC_LEFT 50021 -#define IDC_DOWN 50022 -#define IDC_RIGHT 50023 -#define IDC_B 50024 -#define IDC_A 50025 -#define IDC_Y 50026 -#define IDC_X 50027 -#define IDC_START 50028 -#define IDC_SELECT 50029 -#define IDC_L 50030 -#define IDC_R 50031 -#define IDC_UPLEFT 50032 -#define IDC_UPRIGHT 50033 -#define IDC_DWNRIGHT 50034 -#define IDC_DWNLEFT 50035 -#define IDC_LABEL_BLUE 50036 -#define IDC_LID 50037 -#define IDD_INPUTCONFIG 50038 -#define IDC_LABEL_HK1 60001 -#define IDC_LABEL_HK2 60002 -#define IDC_LABEL_HK3 60003 -#define IDC_LABEL_HK4 60004 -#define IDC_LABEL_HK5 60005 -#define IDC_LABEL_HK6 60006 -#define IDC_LABEL_HK7 60007 -#define IDC_LABEL_HK8 60008 -#define IDC_LABEL_HK9 60009 -#define IDC_HOTKEY1 60011 -#define IDC_HOTKEY2 60012 -#define IDC_HOTKEY3 60013 -#define IDC_HOTKEY4 60014 -#define IDC_HOTKEY5 60015 -#define IDC_HOTKEY6 60016 -#define IDC_HOTKEY7 60017 -#define IDC_HOTKEY8 60018 -#define IDC_HOTKEY9 60019 -#define IDC_HOTKEY10 60020 -#define IDC_HOTKEY11 60021 -#define IDC_HOTKEY12 60022 -#define IDC_HOTKEY13 60023 -#define IDC_HOTKEY14 60024 -#define IDC_HOTKEY15 60025 -#define IDC_HOTKEY16 60026 -#define IDC_HOTKEY17 60027 -#define IDC_HOTKEY18 60028 -#define IDC_HOTKEY19 60029 -#define IDC_HOTKEY20 60030 -#define IDC_LABEL_HK10 60031 -#define IDC_LABEL_HK11 60032 -#define IDC_LABEL_HK12 60033 -#define IDC_LABEL_HK13 60034 -#define IDC_LABEL_HK14 60035 -#define IDC_LABEL_HK15 60036 -#define IDC_LABEL_HK16 60037 -#define IDC_LABEL_HK17 60038 -#define IDC_LABEL_HK19 60040 -#define IDC_LABEL_HK20 60041 -#define IDC_LABEL_HK18 60049 -#define IDC_HKCOMBO 60077 -#define IDD_KEYCUSTOM 60078 -#define IDM_HOTKEY_CONFIG 60079 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 105 -#define _APS_NEXT_COMMAND_VALUE 40008 -#define _APS_NEXT_CONTROL_VALUE 1011 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by resources.rc +// +#define IDD_RECORDMOVIE 101 +#define IDM_OPEN 101 +#define IDM_QUIT 102 +#define IDC_FERMER 103 +#define IDD_DESASSEMBLEUR_VIEWER7 103 +#define IDC_STEP 104 +#define IDC_SETPNUM 105 +#define IDC_SCROLLER 106 +#define IDD_SOUNDSETTINGS 106 +#define IDC_GO 107 +#define IDC_AUTO_UPDATE 108 +#define IDM_MEMORY 109 +#define IDM_DISASSEMBLER 110 +#define IDD_3DSETTINGS 111 +#define IDM_GAME_INFO 111 +#define IDD_GBASLOT 113 +#define IDM_PAUSE 113 +#define IDD_GBASLOT_CFLASH 114 +#define IDM_RESET 114 +#define IDD_CHEAT_SEARCH_VIEW 115 +#define IDM_IOREG 115 +#define IDD_CHEAT_LIST 116 +#define IDD_CHEAT_ADD 117 +#define IDM_PAL 117 +#define IDM_TILE 118 +#define IDM_MAP 119 +#define IDM_MBG0 120 +#define IDM_MBG1 121 +#define IDM_MBG2 122 +#define IDM_MBG3 123 +#define IDM_SBG0 124 +#define IDM_SBG1 125 +#define IDM_SBG2 126 +#define IDM_SBG3 127 +#define IDM_OAM 128 +#define IDM_PRINTSCREEN 129 +#define IDM_QUICK_PRINTSCREEN 130 +#define IDM_SOUNDSETTINGS 131 +#define IDM_WEBSITE 132 +#define IDM_FORUM 133 +#define IDM_SUBMITBUGREPORT 134 +#define IDM_STATE_LOAD 135 +#define IDM_STATE_SAVE 136 +#define IDM_STATE_SAVE_F1 140 +#define IDM_STATE_SAVE_F2 141 +#define IDM_STATE_SAVE_F3 142 +#define IDM_STATE_SAVE_F4 143 +#define IDM_STATE_SAVE_F5 144 +#define IDM_STATE_SAVE_F6 145 +#define IDM_STATE_SAVE_F7 146 +#define IDM_STATE_SAVE_F8 147 +#define IDM_STATE_SAVE_F9 148 +#define IDM_STATE_SAVE_F10 149 +#define IDM_STATE_LOAD_F1 150 +#define IDM_STATE_LOAD_F2 151 +#define IDM_STATE_LOAD_F3 152 +#define IDM_STATE_LOAD_F4 153 +#define IDM_STATE_LOAD_F5 154 +#define IDM_STATE_LOAD_F6 155 +#define IDM_STATE_LOAD_F7 156 +#define IDM_STATE_LOAD_F8 157 +#define IDM_STATE_LOAD_F9 158 +#define IDM_STATE_LOAD_F10 159 +#define IDC_COMBO1 160 +#define IDC_COMBO2 161 +#define IDC_COMBO3 162 +#define IDC_COMBO4 163 +#define IDM_CONFIG 180 +#define IDD_INPUT 181 +#define IDC_SAVETYPE1 182 +#define IDC_SAVETYPE2 183 +#define IDC_SAVETYPE3 184 +#define IDC_SAVETYPE4 185 +#define IDC_SAVETYPE5 186 +#define IDC_SAVETYPE6 187 +#define IDC_FRAMESKIPAUTO 190 +#define IDC_FRAMESKIP0 191 +#define IDC_FRAMESKIP1 192 +#define IDC_FRAMESKIP2 193 +#define IDC_FRAMESKIP3 194 +#define IDC_FRAMESKIP4 195 +#define IDC_FRAMESKIP5 196 +#define IDC_FRAMESKIP6 197 +#define IDC_FRAMESKIP7 198 +#define IDC_FRAMESKIP8 199 +#define IDC_EDIT_FILENAME 200 +#define IDC_FRAMESKIP9 200 +#define IDC_BUTTON_BROWSEFILE 201 +#define IDC_CHECK_READONLY 201 +#define IDM_IMPORTBACKUPMEMORY 201 +#define IDC_LANGENGLISH 210 +#define IDC_LANGFRENCH 211 +#define IDC_LANGDANISH 212 +#define IDM_MGPU 213 +#define IDM_SGPU 214 +#define IDC_8_BIT 302 +#define IDC_16_BIT 303 +#define IDC_32_BIT 304 +#define IDC_BACKGROUNDPAUSE 305 +#define IDC_LUACONSOLE 309 +#define IDC_EDIT_LUAPATH 310 +#define IDC_BUTTON_LUARUN 311 +#define IDC_BUTTON_LUASTOP 312 +#define IDC_BUTTON_LUABROWSE 313 +#define IDC_BUTTON_LUAEDIT 314 +#define IDC_NOTIFY_SUBSERVIENT 315 +#define IDD_ARCHIVEFILECHOOSER 316 +#define IDD_LUA 317 +#define IDC_NEW_LUA_SCRIPT 318 +#define IDC_PATHEDIT 319 +#define IDC_BROWSE 320 +#define IDC_USELASTVISIT 321 +#define IDC_FORMATEDIT 322 +#define IDC_PATHLIST 323 +#define IDC_SAVEAS 324 +#define IDC_PNG 325 +#define IDC_BMP 326 +#define IDC_FORMATSTATIC 327 +#define IDM_PATHSETTINGS 350 +#define IDC_ROMPATHEDIT 351 +#define IDC_BROWSEROMS 352 +#define IDC_PATHDEFAULTS 353 +#define IDC_SAVERAMPATHEDIT 354 +#define IDC_BROWSESRAM 355 +#define IDC_STATEPATHEDIT 356 +#define IDC_BROWSESTATES 357 +#define IDC_SCREENSHOTPATHEDIT 358 +#define IDC_BROWSESCREENSHOTS 359 +#define IDC_AVIPATHEDIT 360 +#define IDC_BROWSEAVI 361 +#define IDC_CHEATPATHEDIT 362 +#define IDC_BROWSECHEATS 363 +#define IDC_LUAPATHEDIT 364 +#define IDC_BROWSELUA 365 +#define IDD_PATHSETTINGS 366 +#define IDC_STATEREWINDING 367 +#define IDC_DES_BOX 402 +#define IDC_R0 403 +#define IDC_R1 404 +#define IDC_R2 405 +#define IDC_R3 406 +#define IDC_R4 407 +#define IDC_R5 408 +#define IDC_R6 409 +#define IDC_R7 410 +#define IDC_R8 411 +#define IDC_R9 412 +#define IDC_R10 413 +#define IDC_R11 414 +#define IDC_R12 415 +#define IDC_R13 416 +#define IDC_R14 417 +#define IDC_R15 418 +#define IDC_MODE 419 +#define IDC_AUTO_DES 420 +#define IDC_ARM 421 +#define IDC_THUMB 422 +#define IDC_GOTODES 423 +#define IDC_TMP 424 +#define IDD_GAME_INFO 501 +#define ID_RAM_WATCH 550 +#define IDM_RENDER_NORMAL 551 +#define IDM_RENDER_HQ2X 552 +#define IDM_RENDER_2XSAI 553 +#define IDM_RENDER_SUPER2XSAI 554 +#define IDM_RENDER_SUPEREAGLE 555 +#define IDM_RENDER_SCANLINE 556 +#define IDM_RENDER_BILINEAR 557 +#define IDM_RENDER_NEAREST2X 558 +#define IDD_IO_REG 601 +#define IDM_RECORD_MOVIE 602 +#define IDM_PLAY_MOVIE 603 +#define IDD_PAL 703 +#define IDD_TILE 704 +#define IDC_PAL_SELECT 705 +#define IDC_PALNUM 706 +#define IDC_MEM_SELECT 707 +#define IDC_Tile_BOX 708 +#define IDC_BITMAP 709 +#define IDC_256COUL 710 +#define IDC_16COUL 711 +#define IDC_MINI_TILE 712 +#define IDC_TILENUM 713 +#define IDD_MAP 800 +#define IDC_BG_SELECT 801 +#define IDC_PAL 803 +#define IDC_PRIO 804 +#define IDC_CHAR 805 +#define IDC_SCR 806 +#define IDC_MSIZE 807 +#define IDC_SCROLL 808 +#define IDD_OAM 900 +#define IDC_SCR_SELECT 901 +#define IDC_TILE 902 +#define IDC_OAMNUM 903 +#define IDC_COOR 904 +#define IDC_DIM 905 +#define IDC_ROT 906 +#define IDC_MOS 907 +#define IDC_PROP0 908 +#define IDC_PROP1 909 +#define IDD_BGMAP_VIEWER 911 +#define IDB_BGTILES 913 +#define IDD_EMULATIONSETTINGS 916 +#define IDD_WIFISETTINGS 918 +#define IDD_MEM_VIEW 920 +#define IDC_DIFFERENTFROM 921 +#define IDC_DIFFERENTBY 922 +#define IDC_MODULO 923 +#define IDC_EDIT_DIFFBY 924 +#define IDC_EDIT_MODBY 925 +#define IDC_PREVIOUSVALUE 926 +#define IDC_SPECIFICVALUE 927 +#define IDC_NUMBEROFCHANGES 928 +#define IDC_EDIT_COMPAREVALUE 929 +#define IDC_EDIT_COMPARECHANGES 930 +#define IDC_C_AUTOSEARCH 931 +#define IDC_MISALIGN 932 +#define IDC_C_RESET_CHANGES 933 +#define IDC_C_UNDO 934 +#define ID_RAM_SEARCH 935 +#define IDD_RAMSEARCH 945 +#define IDC_SPECIFICADDRESS 950 +#define IDC_EDIT_COMPAREADDRESS 951 +#define IDC_PROMPT_TEXT 952 +#define IDC_PROMPT_EDIT 953 +#define IDC_SIGNED 954 +#define IDC_UNSIGNED 955 +#define IDC_HEX 956 +#define IDC_1_BYTE 957 +#define IDC_2_BYTES 958 +#define IDC_4_BYTES 959 +#define IDC_WATCHLIST 960 +#define IDC_C_WATCH_EDIT 961 +#define IDC_C_WATCH_REMOVE 962 +#define IDC_C_WATCH 963 +#define IDC_C_WATCH_DUPLICATE 964 +#define IDC_C_ADDCHEAT 965 +#define ID_WATCHES_UPDOWN 966 +#define IDD_RAMWATCH 967 +#define IDR_ACCELERATOR1 968 +#define IDD_PROMPT 969 +#define IDD_IOREG_VIEW_MEM_IRQ 970 +#define IDD_IOREG_VIEW_SPI 973 +#define IDD_IOREG_VIEW_CP15 975 +#define IDD_SOUND_VIEW 977 +#define IDC_START_FROM_SRAM 978 +#define IDC_EDIT_SRAMFILENAME 979 +#define IDC_BUTTON_BROWSESRAM 980 +#define IDC_C_WATCH_UP 980 +#define IDD_EDITWATCH 980 +#define IDC_C_WATCH_DOWN 981 +#define RAMMENU_FILE_AUTOLOAD 982 +#define RAMMENU_FILE_SAVEWINDOW 983 +#define RAMMENU_FILE_SAVE 984 +#define RAMMENU_FILE_SAVEAS 985 +#define RAMMENU_FILE_OPEN 986 +#define RAMMENU_FILE_APPEND 987 +#define RAMMENU_FILE_NEW 988 +#define RAMMENU_FILE_RECENT 990 +#define IDC_RAMLIST 991 +#define IDC_C_SEARCH 992 +#define IDC_C_RESET 993 +#define IDC_C_ELIMINATE 994 +#define IDC_LESSTHAN 995 +#define IDC_MORETHAN 996 +#define IDC_NOMORETHAN 997 +#define IDC_NOLESSTHAN 998 +#define IDC_EQUALTO 999 +#define IDC_BGMAP_SEL 1000 +#define IDC_BRIDGEADAPTER 1000 +#define IDC_EDIT03 1000 +#define IDC_SOUNDCORECB 1000 +#define IDC_USEEXTBIOS 1000 +#define ID_BROWSE 1000 +#define IDC_ALTERNATEFLUSH 1001 +#define IDC_BGMAP_BGXCNT 1001 +#define IDC_CHECKBOX_DEBUGGERMODE 1001 +#define IDC_EDIT01 1001 +#define IDC_IOREG_TAB 1001 +#define IDC_SOUNDBUFFERET 1001 +#define IDC_SOUNDVIEW_CHANSWITCH 1001 +#define PM_FILENAME 1001 +#define IDC_ARM9BIOS 1002 +#define IDC_EDIT05 1002 +#define IDC_MLENGTH 1002 +#define IDC_SLVOLUME 1002 +#define IDC_BGMAP_TYPE 1003 +#define IDC_EDIT08 1003 +#define IDC_GI_GAMETITLE 1003 +#define IDC_MFRAMES 1003 +#define IDC_ROTATE0 1003 +#define IDC_BUTTON2 1003 +#define IDC_ARM9BIOSBROWSE 1004 +#define IDC_EDIT11 1004 +#define IDC_GI_GAMECODE 1004 +#define IDC_MRERECORDCOUNT 1004 +#define IDC_ROTATE90 1004 +#define IDC_SPU_INTERPOLATION_CB 1004 +#define IDC_BUTTON_VOLMODE 1004 +#define IDC_ARM7BIOS 1005 +#define IDC_EDIT07 1005 +#define IDC_MROM 1005 +#define IDC_ROTATE180 1005 +#define IDC_GGREEN 1005 +#define IDC_EDIT12 1006 +#define IDC_ROTATE270 1006 +#define IDC_SPU_CACHE 1006 +#define IDC_GRED 1006 +#define IDC_ARM7BIOSBROWSE 1007 +#define IDC_EDIT06 1007 +#define IDC_GYELLOW 1007 +#define IDC_EDIT09 1008 +#define IDC_MEMVIEWBOX 1008 +#define IDC_GBLUE 1008 +#define IDC_ADDRESS 1009 +#define IDC_BIOSSWIS 1009 +#define IDC_EDIT10 1009 +#define IDC_FORCERATIO 1009 +#define IDC_AUTO_UPDATE_SPIN 1010 +#define IDC_EDIT15 1010 +#define IDC_TEXTDUMP 1010 +#define IDC_WINDOW1X 1010 +#define IDC_AUTO_UPDATE_SECS 1011 +#define IDC_USEEXTFIRMWARE 1011 +#define IDC_WINDOW2X 1011 +#define IDC_FIRMWARE 1012 +#define IDC_RAWDUMP 1012 +#define IDC_REFRESH 1012 +#define IDC_WINDOW3X 1012 +#define IDC_EDIT02 1013 +#define IDC_WINDOW4X 1013 +#define IDC_EDIT04 1014 +#define IDC_FIRMWAREBROWSE 1014 +#define IDC_BGMAP_CHARBASE 1016 +#define IDC_FIRMWAREBOOT 1016 +#define IDC_BGMAP_SCRBASE 1017 +#define IDC_AUTOUPDATE_ASM 1018 +#define IDC_BGMAP_PRIO 1018 +#define IDC_BGMAP_PAL 1019 +#define IDC_VISIBLE 1019 +#define IDC_BGMAP_SIZE 1020 +#define IDC_IPCFIFO9 1020 +#define IDC_BGMAP_SCROLL 1021 +#define IDC_IPCSYNC9 1021 +#define IDC_IF9 1022 +#define IDC_INTHAND9 1023 +#define IDC_IE9 1024 +#define IDC_BGMAP_MOSAIC 1025 +#define IDC_DISPCNTA9 1025 +#define IDC_BGMAP_SPECEFF 1026 +#define IDC_DISPSTATA9 1026 +#define IDC_BGMAP_WINDOWS 1027 +#define IDC_DEFAULT 1027 +#define IDC_DISPCNTB9 1027 +#define IDC_3DCORE 1028 +#define IDC_DISPSTATB9 1028 +#define IDC_IME9 1029 +#define IDC_TXT_COMPILED 1029 +#define IDC_GXSTAT9 1030 +#define IDC_TXT_VERSION 1030 +#define IDC_IE7 1032 +#define IDC_ADDONS_LIST 1033 +#define IDC_IF7 1033 +#define IDC_ADDONS_INFO 1034 +#define IDC_IME7 1034 +#define IDC_BBROWSE 1035 +#define IDC_IPCSYNC7 1035 +#define IDC_IPCFIFO7 1036 +#define IDC_PATHIMG 1036 +#define IDC_PATH 1037 +#define IDC_PATHGAME 1037 +#define IDC_RFILE 1038 +#define IDC_RFOLDER 1039 +#define IDC_BBROWSE2 1040 +#define IDC_PATHDESMUME 1041 +#define IDC_BRESTART 1042 +#define IDC_BVIEW 1043 +#define IDC_BSEARCH 1044 +#define IDC_RADIO1 1045 +#define IDC_RADIO2 1046 +#define IDC_RADIO3 1047 +#define IDC_RADIO4 1048 +#define IDC_RADIO5 1049 +#define IDC_RADIO6 1050 +#define IDC_RADIO7 1051 +#define IDC_RADIO8 1052 +#define IDC_LIST1 1056 +#define IDC_BADD_AR 1057 +#define IDC_BADD_CB 1058 +#define IDC_BREMOVE 1060 +#define IDC_BEDIT 1061 +#define IDC_STATIC_S1 1061 +#define IDC_STATIC_S2 1062 +#define IDC_STATIC_S3 1063 +#define IDC_STATIC_S4 1064 +#define IDC_EVALUE 1065 +#define IDC_STATIC_RANGE 1066 +#define IDC_BADD 1068 +#define IDC_LIST 1069 +#define IDC_SNUMBER 1071 +#define IDC_CHECK1 1074 +#define IDC_CHECK2 1075 + +#define IDC_CHECK3 1076 + +#define IDC_CHECK4 1077 +#define IDC_CHECK6 1080 +#define IDC_CHECK7 1082 +#define IDC_CHECK8 1083 +#define IDC_CHECK9 1088 +#define IDM_FIRMSETTINGS 1100 +#define IDD_FIRMSETTINGS 1101 +#define IDC_EDIT1 1102 +#define IDC_EDIT2 1103 +#define IDC_EDIT13 1104 +#define IDC_EDIT3 1104 +#define IDC_EDIT14 1105 +#define IDC_EDIT_AUTHOR 1180 +#define IDD_MATRIX_VIEWER 1200 +#define IDM_MATRIX_VIEWER 1200 +#define IDC_MATRIX_VIEWER_COORD_GROUP 1201 +#define IDC_MATRIX_VIEWER_COORD_COMBO 1202 +#define IDC_MATRIX_VIEWER_COORD_11_EDIT 1203 +#define IDC_MATRIX_VIEWER_COORD_12_EDIT 1204 +#define IDC_MATRIX_VIEWER_COORD_13_EDIT 1205 +#define IDC_MATRIX_VIEWER_COORD_14_EDIT 1206 +#define IDC_MATRIX_VIEWER_COORD_21_EDIT 1207 +#define IDC_MATRIX_VIEWER_COORD_22_EDIT 1208 +#define IDC_MATRIX_VIEWER_COORD_23_EDIT 1209 +#define IDC_MATRIX_VIEWER_COORD_24_EDIT 1210 +#define IDC_MATRIX_VIEWER_COORD_31_EDIT 1211 +#define IDC_MATRIX_VIEWER_COORD_32_EDIT 1212 +#define IDC_MATRIX_VIEWER_COORD_33_EDIT 1213 +#define IDC_MATRIX_VIEWER_COORD_34_EDIT 1214 +#define IDC_MATRIX_VIEWER_COORD_41_EDIT 1215 +#define IDC_MATRIX_VIEWER_COORD_42_EDIT 1216 +#define IDC_MATRIX_VIEWER_COORD_43_EDIT 1217 +#define IDC_MATRIX_VIEWER_COORD_44_EDIT 1218 +#define IDC_MATRIX_VIEWER_DIR_GROUP 1221 +#define IDC_MATRIX_VIEWER_DIR_COMBO 1222 +#define IDC_MATRIX_VIEWER_DIR_11_EDIT 1223 +#define IDC_MATRIX_VIEWER_DIR_12_EDIT 1224 +#define IDC_MATRIX_VIEWER_DIR_13_EDIT 1225 +#define IDC_MATRIX_VIEWER_DIR_14_EDIT 1226 +#define IDC_MATRIX_VIEWER_DIR_21_EDIT 1227 +#define IDC_MATRIX_VIEWER_DIR_22_EDIT 1228 +#define IDC_MATRIX_VIEWER_DIR_23_EDIT 1229 +#define IDC_MATRIX_VIEWER_DIR_24_EDIT 1230 +#define IDC_MATRIX_VIEWER_DIR_31_EDIT 1231 +#define IDC_MATRIX_VIEWER_DIR_32_EDIT 1232 +#define IDC_MATRIX_VIEWER_DIR_33_EDIT 1233 +#define IDC_MATRIX_VIEWER_DIR_34_EDIT 1234 +#define IDC_MATRIX_VIEWER_DIR_41_EDIT 1235 +#define IDC_MATRIX_VIEWER_DIR_42_EDIT 1236 +#define IDC_MATRIX_VIEWER_DIR_43_EDIT 1237 +#define IDC_MATRIX_VIEWER_DIR_44_EDIT 1238 +#define IDC_MATRIX_VIEWER_PROJ_GROUP 1241 +#define IDC_MATRIX_VIEWER_PROJ_11_EDIT 1243 +#define IDC_MATRIX_VIEWER_PROJ_12_EDIT 1244 +#define IDC_MATRIX_VIEWER_PROJ_13_EDIT 1245 +#define IDC_MATRIX_VIEWER_PROJ_14_EDIT 1246 +#define IDC_MATRIX_VIEWER_PROJ_21_EDIT 1247 +#define IDC_MATRIX_VIEWER_PROJ_22_EDIT 1248 +#define IDC_MATRIX_VIEWER_PROJ_23_EDIT 1249 +#define IDC_MATRIX_VIEWER_PROJ_24_EDIT 1250 +#define IDC_MATRIX_VIEWER_PROJ_31_EDIT 1251 +#define IDC_MATRIX_VIEWER_PROJ_32_EDIT 1252 +#define IDC_MATRIX_VIEWER_PROJ_33_EDIT 1253 +#define IDC_MATRIX_VIEWER_PROJ_34_EDIT 1254 +#define IDC_MATRIX_VIEWER_PROJ_41_EDIT 1255 +#define IDC_MATRIX_VIEWER_PROJ_42_EDIT 1256 +#define IDC_MATRIX_VIEWER_PROJ_43_EDIT 1257 +#define IDC_MATRIX_VIEWER_PROJ_44_EDIT 1258 +#define IDC_MATRIX_VIEWER_TEX_GROUP 1261 +#define IDC_MATRIX_VIEWER_TEX_11_EDIT 1263 +#define IDC_MATRIX_VIEWER_TEX_12_EDIT 1264 +#define IDC_MATRIX_VIEWER_TEX_13_EDIT 1265 +#define IDC_MATRIX_VIEWER_TEX_14_EDIT 1266 +#define IDC_MATRIX_VIEWER_TEX_21_EDIT 1267 +#define IDC_MATRIX_VIEWER_TEX_22_EDIT 1268 +#define IDC_MATRIX_VIEWER_TEX_23_EDIT 1269 +#define IDC_MATRIX_VIEWER_TEX_24_EDIT 1270 +#define IDC_MATRIX_VIEWER_TEX_31_EDIT 1271 +#define IDC_MATRIX_VIEWER_TEX_32_EDIT 1272 +#define IDC_MATRIX_VIEWER_TEX_33_EDIT 1273 +#define IDC_MATRIX_VIEWER_TEX_34_EDIT 1274 +#define IDC_MATRIX_VIEWER_TEX_41_EDIT 1275 +#define IDC_MATRIX_VIEWER_TEX_42_EDIT 1276 +#define IDC_MATRIX_VIEWER_TEX_43_EDIT 1277 +#define IDC_MATRIX_VIEWER_TEX_44_EDIT 1278 +#define IDD_LIGHT_VIEWER 1300 +#define IDM_LIGHT_VIEWER 1300 +#define IDC_LIGHT_VIWER_LIGHT0_GROUP 1301 +#define IDD_ABOUT_BOX 1301 +#define IDC_AUTHORS_LIST 1302 +#define IDC_LIGHT_VIEWER_LIGHT0COLOR_COLORCTRL 1302 +#define IDD_DESASSEMBLEUR_VIEWER9 1302 +#define IDC_LIGHT_VIEWER_LIGHT0COLOR_EDIT 1303 +#define IDC_LIGHT_VIEWER_LIGHT0VECTOR_EDIT 1304 +#define IDD_GBASLOT_NONE 1304 +#define IDD_GBASLOT_RUMBLEPAK 1305 +#define IDD_GBASLOT_GBAGAME 1306 +#define IDD_CHEAT_SEARCH_COMP 1307 +#define IDD_CHEAT_SEARCH_MAIN 1308 +#define IDD_CHEAT_SEARCH_RESULT 1310 +#define IDC_LIGHT_VIWER_LIGHT1_GROUP 1311 +#define IDD_CHEAT_SEARCH_EXACT 1311 +#define IDC_LIGHT_VIEWER_LIGHT1COLOR_COLORCTRL 1312 +#define IDD_CHEAT_SEARCH 1312 +#define IDC_LIGHT_VIEWER_LIGHT1COLOR_EDIT 1313 +#define IDC_LIGHT_VIEWER_LIGHT1VECTOR_EDIT 1314 +#define IDC_LIGHT_VIWER_LIGHT2_GROUP 1321 +#define IDC_LIGHT_VIEWER_LIGHT2COLOR_COLORCTRL 1322 +#define IDC_LIGHT_VIEWER_LIGHT2COLOR_EDIT 1323 +#define IDC_LIGHT_VIEWER_LIGHT2VECTOR_EDIT 1324 +#define IDC_LIGHT_VIWER_LIGHT3_GROUP 1331 +#define IDC_LIGHT_VIEWER_LIGHT3COLOR_COLORCTRL 1332 +#define IDC_LIGHT_VIEWER_LIGHT3COLOR_EDIT 1333 +#define IDC_LIGHT_VIEWER_LIGHT3VECTOR_EDIT 1334 +#define IDC_SOUND0ID 1350 +#define IDC_SOUND1ID 1351 +#define IDC_SOUND2ID 1352 +#define IDC_SOUND3ID 1353 +#define IDC_SOUND4ID 1354 +#define IDC_SOUND5ID 1355 +#define IDC_SOUND6ID 1356 +#define IDC_SOUND7ID 1357 +#define IDC_SOUND0VOL 1358 +#define IDC_SOUND1VOL 1359 +#define IDC_SOUND2VOL 1360 +#define IDC_SOUND3VOL 1361 +#define IDC_SOUND4VOL 1362 +#define IDC_SOUND5VOL 1363 +#define IDC_SOUND6VOL 1364 +#define IDC_SOUND7VOL 1365 +#define IDC_SOUND0VOLBAR 1366 +#define IDC_SOUND1VOLBAR 1367 +#define IDC_SOUND2VOLBAR 1368 +#define IDC_SOUND3VOLBAR 1369 +#define IDC_SOUND4VOLBAR 1370 +#define IDC_SOUND5VOLBAR 1371 +#define IDC_SOUND6VOLBAR 1372 +#define IDC_SOUND7VOLBAR 1373 +#define IDC_SOUND0PAN 1374 +#define IDC_SOUND1PAN 1375 +#define IDC_SOUND2PAN 1376 +#define IDC_SOUND3PAN 1377 +#define IDC_SOUND4PAN 1378 +#define IDC_SOUND5PAN 1379 +#define IDC_SOUND6PAN 1380 +#define IDC_SOUND7PAN 1381 +#define IDC_SOUND0PANBAR 1382 +#define IDC_SOUND1PANBAR 1383 +#define IDC_SOUND2PANBAR 1384 +#define IDC_SOUND3PANBAR 1385 +#define IDC_SOUND4PANBAR 1386 +#define IDC_SOUND5PANBAR 1387 +#define IDC_SOUND6PANBAR 1388 +#define IDC_SOUND7PANBAR 1389 +#define IDC_SOUND0HOLD 1390 +#define IDC_SOUND1HOLD 1391 +#define IDC_SOUND2HOLD 1392 +#define IDC_SOUND3HOLD 1393 +#define IDC_SOUND4HOLD 1394 +#define IDC_SOUND5HOLD 1395 +#define IDC_SOUND6HOLD 1396 +#define IDC_SOUND7HOLD 1397 +#define IDC_SOUND0BUSY 1398 +#define IDC_SOUND1BUSY 1399 +#define IDC_SOUND2BUSY 1400 +#define IDC_SOUND3BUSY 1401 +#define IDC_SOUND4BUSY 1402 +#define IDC_SOUND5BUSY 1403 +#define IDC_SOUND6BUSY 1404 +#define IDC_SOUND7BUSY 1405 +#define IDC_SOUND0REPEATMODE 1406 +#define IDC_SOUND1REPEATMODE 1407 +#define IDC_SOUND2REPEATMODE 1408 +#define IDC_SOUND3REPEATMODE 1409 +#define IDC_SOUND4REPEATMODE 1410 +#define IDC_SOUND5REPEATMODE 1411 +#define IDC_SOUND6REPEATMODE 1412 +#define IDC_SOUND7REPEATMODE 1413 +#define IDC_SOUND0FORMAT 1414 +#define IDC_SOUND1FORMAT 1415 +#define IDC_SOUND2FORMAT 1416 +#define IDC_SOUND3FORMAT 1417 +#define IDC_SOUND4FORMAT 1418 +#define IDC_SOUND5FORMAT 1419 +#define IDC_SOUND6FORMAT 1420 +#define IDC_SOUND7FORMAT 1421 +#define IDC_SOUND0SAD 1422 +#define IDC_SOUND1SAD 1423 +#define IDC_SOUND2SAD 1424 +#define IDC_SOUND3SAD 1425 +#define IDC_SOUND4SAD 1426 +#define IDC_SOUND5SAD 1427 +#define IDC_SOUND6SAD 1428 +#define IDC_SOUND7SAD 1429 +#define IDC_SOUND0PNT 1430 +#define IDC_SOUND1PNT 1431 +#define IDC_SOUND2PNT 1432 +#define IDC_SOUND3PNT 1433 +#define IDC_SOUND4PNT 1434 +#define IDC_SOUND5PNT 1435 +#define IDC_SOUND6PNT 1436 +#define IDC_SOUND7PNT 1437 +#define IDC_SOUND0TMR 1438 +#define IDC_SOUND1TMR 1439 +#define IDC_SOUND2TMR 1440 +#define IDC_SOUND3TMR 1441 +#define IDC_SOUND4TMR 1442 +#define IDC_SOUND5TMR 1443 +#define IDC_SOUND6TMR 1444 +#define IDC_SOUND7TMR 1445 +#define IDC_SOUND0POSLEN 1446 +#define IDC_SOUND1POSLEN 1447 +#define IDC_SOUND2POSLEN 1448 +#define IDC_SOUND3POSLEN 1449 +#define IDC_SOUND4POSLEN 1450 +#define IDC_SOUND5POSLEN 1451 +#define IDC_SOUND6POSLEN 1452 +#define IDC_SOUND7POSLEN 1453 +#define IDC_SOUND0MUTE 2001 +#define IDC_SOUND1MUTE 2002 +#define IDC_SOUND2MUTE 2003 +#define IDC_SOUND3MUTE 2004 +#define IDC_SOUND4MUTE 2005 +#define IDC_SOUND5MUTE 2006 +#define IDC_SOUND6MUTE 2007 +#define IDC_SOUND7MUTE 2008 +#define IDC_GI_FATOFS 4464 +#define IDC_INTERPOLATECOLOR 4464 +#define IDC_GI_FATSIZE 4465 +#define IDC_GI_ICONTITLEOFS 4466 +#define IDC_CLOSE 4467 +#define IDC_GI_USEDROMSIZE 4467 +#define IDC_GI_ICON 4469 +#define IDC_GI_TITLE 4470 +#define IDC_GI_TITLEEN 4471 +#define IDC_GI_TITLEFR 4472 +#define IDC_GI_TITLEGE 4473 +#define IDC_GI_TITLEIT 4474 +#define IDC_GI_TITLESP 4475 +#define IDC_GI_MAKERCODE 4476 +#define IDC_GI_TITLEJP 4477 +#define IDC_GI_CHIPSIZE 4478 +#define IDC_GI_ARM9START 4479 +#define IDC_GI_ARM9ENTRY 4480 +#define IDC_GI_ARM9ROM 4481 +#define IDC_GI_ARM9SIZE 4482 +#define IDC_GI_ARM7ROM 4483 +#define IDC_GI_ARM7ENTRY 4484 +#define IDC_GI_ARM7START 4485 +#define IDC_GI_ARM7SIZE 4486 +#define IDC_GI_FNTOFS 4487 +#define IDC_GI_FNTSIZE 4488 +#define IDD_MICROPHONE 5000 +#define IDM_MICROPHONESETTINGS 5001 +#define IDC_MICSAMPLEBROWSE 5003 +#define IDC_MICSAMPLE 5004 +#define IDC_USEMICSAMPLE 5005 +#define IDD_IOREG_VIEW 10000 +#define IDD_IOREG_VIEW_GPU_A 10001 +#define IDD_IOREG_VIEW_GPU_B 10002 +#define IDD_IOREG_VIEW_GPU_3D 10003 +#define IDD_IOREG_VIEW_GPU_MISC 10004 +#define IDD_CHEAT_ADD_XX_CODE 10005 +#define IDD_IOREG_VIEW_DMA 10006 +#define IDD_IOREG_VIEW_TIMERS 10007 +#define IDD_IOREG_VIEW_IPC_ROM 10008 +#define IDD_GBASLOT_GUITARGRIP 10009 +#define IDM_FILE_STOPAVI 40000 +#define IDM_SCREENSEP_NONE 40000 +#define IDM_FILE_STOPWAV 40001 +#define IDM_SCREENSEP_BORDER 40001 +#define IDM_SCREENSEP_NDSGAP 40002 +#define IDM_ABOUT 40003 +#define IDM_EMULATIONSETTINGS 40004 +#define IDC_FRAMELIMIT 40005 +#define ID_CONFIG_PAUSEWHENFOCUSLOST 40005 +#define IDC_WINDOW1_5X 40006 +#define IDM_WIFISETTINGS 40007 +#define IDM_ALWAYS_ON_TOP 40008 +#define ID_VIEW_FRAMECOUNTER 40009 +#define ID_VIEW_DISPLAYFPS 40010 +#define ID_VIEW_DISPLAYINPUT 40011 +#define ID_VIEW_DISPLAYLAG 40012 +#define ID_VIEW_HUDEDITOR 40013 +#define ID_VIEW_DISPLAYMICROPHONE 40014 +#define IDM_FILE_RECORDAVI 40015 +#define IDM_SOUND_VIEW 40016 +#define IDM_FILE_RECORDWAV 40017 +#define IDM_EXPORTBACKUPMEMORY 40018 +#define IDM_STOPMOVIE 40019 +#define IDC_LANG_CHINESE_SIMPLIFIED 40020 +#define IDM_SCREENSEP_NDSGAP2 40021 +#define IDM_SCREENSEP_DRAGEDIT 40022 +#define ID_FILE_RECENTROM 40034 +#define IDC_SAVETYPE7 40037 +#define IDM_DEFSIZE 40038 +#define IDM_3DCONFIG 40040 +#define IDM_GBASLOT 40042 +#define IDM_CHEATS_LIST 40050 +#define IDC_BGMAP_ROTSCALEPARAMS 40051 +#define IDM_CHEATS_SEARCH 40051 +#define IDC_BGMAP_ROTSCALE 40052 +#define IDM_SHUT_UP 40053 +#define IDC_WINDOW2_5X 40054 +#define IDC_LABEL_UP 50000 +#define IDC_LABEL_RIGHT 50001 +#define IDC_LABEL_LEFT 50002 +#define IDC_LABEL_DOWN 50003 +#define IDC_LABEL_A 50004 +#define IDC_LABEL_X 50005 +#define IDC_LABEL_B 50006 +#define IDC_LABEL_Y 50007 +#define IDC_LABEL_L 50008 +#define IDC_LABEL_START 50009 +#define IDC_LABEL_R 50010 +#define IDC_LABEL_SELECT 50011 +#define IDC_LABEL_UPLEFT 50012 +#define IDC_LABEL_DOWNRIGHT 50013 +#define IDC_LABEL_UPRIGHT 50014 +#define IDC_LABEL_DOWNLEFT 50015 +#define IDC_ALLOWLEFTRIGHT 50016 +#define IDC_LABEL_X3 50017 +#define IDC_LABEL_X2 50018 +#define IDC_DEBUG 50019 +#define IDC_UP 50020 +#define IDC_LEFT 50021 +#define IDC_DOWN 50022 +#define IDC_RIGHT 50023 +#define IDC_B 50024 +#define IDC_A 50025 +#define IDC_Y 50026 +#define IDC_X 50027 +#define IDC_START 50028 +#define IDC_SELECT 50029 +#define IDC_L 50030 +#define IDC_R 50031 +#define IDC_UPLEFT 50032 +#define IDC_UPRIGHT 50033 +#define IDC_DWNRIGHT 50034 +#define IDC_DWNLEFT 50035 +#define IDC_LABEL_BLUE 50036 +#define IDC_LID 50037 +#define IDD_INPUTCONFIG 50038 +#define IDC_LABEL_HK1 60001 +#define IDC_LABEL_HK2 60002 +#define IDC_LABEL_HK3 60003 +#define IDC_LABEL_HK4 60004 +#define IDC_LABEL_HK5 60005 +#define IDC_LABEL_HK6 60006 +#define IDC_LABEL_HK7 60007 +#define IDC_LABEL_HK8 60008 +#define IDC_LABEL_HK9 60009 +#define IDC_HOTKEY1 60011 +#define IDC_HOTKEY2 60012 +#define IDC_HOTKEY3 60013 +#define IDC_HOTKEY4 60014 +#define IDC_HOTKEY5 60015 +#define IDC_HOTKEY6 60016 +#define IDC_HOTKEY7 60017 +#define IDC_HOTKEY8 60018 +#define IDC_HOTKEY9 60019 +#define IDC_HOTKEY10 60020 +#define IDC_HOTKEY11 60021 +#define IDC_HOTKEY12 60022 +#define IDC_HOTKEY13 60023 +#define IDC_HOTKEY14 60024 +#define IDC_HOTKEY15 60025 +#define IDC_HOTKEY16 60026 +#define IDC_HOTKEY17 60027 +#define IDC_HOTKEY18 60028 +#define IDC_HOTKEY19 60029 +#define IDC_HOTKEY20 60030 +#define IDC_LABEL_HK10 60031 +#define IDC_LABEL_HK11 60032 +#define IDC_LABEL_HK12 60033 +#define IDC_LABEL_HK13 60034 +#define IDC_LABEL_HK14 60035 +#define IDC_LABEL_HK15 60036 +#define IDC_LABEL_HK16 60037 +#define IDC_LABEL_HK17 60038 +#define IDC_LABEL_HK19 60040 +#define IDC_LABEL_HK20 60041 +#define IDC_LABEL_HK18 60049 +#define IDC_HKCOMBO 60077 +#define IDD_KEYCUSTOM 60078 +#define IDM_HOTKEY_CONFIG 60079 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 105 +#define _APS_NEXT_COMMAND_VALUE 40008 +#define _APS_NEXT_CONTROL_VALUE 1006 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/desmume/src/windows/resources.rc b/src/windows/resources.rc similarity index 98% rename from desmume/src/windows/resources.rc rename to src/windows/resources.rc index 9fa633f14..7b284be14 100644 Binary files a/desmume/src/windows/resources.rc and b/src/windows/resources.rc differ diff --git a/desmume/src/windows/snddx.cpp b/src/windows/snddx.cpp old mode 100755 new mode 100644 similarity index 95% rename from desmume/src/windows/snddx.cpp rename to src/windows/snddx.cpp index 889ad8ac7..6d91925d6 --- a/desmume/src/windows/snddx.cpp +++ b/src/windows/snddx.cpp @@ -1,321 +1,322 @@ -/* snddx.cpp - - Copyright (C) 2005-2007 Theo Berkau - Copyright (C) 2008-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include -#include -#include "directx/dsound.h" -#ifdef __MINGW32__ -// I have to do this because for some reason because the dxerr8.h header is fubared -const char* __stdcall DXGetErrorString8A(HRESULT hr); -#define DXGetErrorString8 DXGetErrorString8A -const char* __stdcall DXGetErrorDescription8A(HRESULT hr); -#define DXGetErrorDescription8 DXGetErrorDescription8A -#else -#include "directx/dxerr8.h" -#endif -#include "SPU.h" -#include "snddx.h" -#include "CWindow.h" -#include "windriver.h" - -int SNDDXInit(int buffersize); -void SNDDXDeInit(); -void SNDDXUpdateAudio(s16 *buffer, u32 num_samples); -u32 SNDDXGetAudioSpace(); -void SNDDXMuteAudio(); -void SNDDXUnMuteAudio(); -void SNDDXSetVolume(int volume); - -SoundInterface_struct SNDDIRECTX = { - SNDCORE_DIRECTX, - "Direct Sound Interface", - SNDDXInit, - SNDDXDeInit, - SNDDXUpdateAudio, - SNDDXGetAudioSpace, - SNDDXMuteAudio, - SNDDXUnMuteAudio, - SNDDXSetVolume -}; - -LPDIRECTSOUND8 lpDS8; -LPDIRECTSOUNDBUFFER lpDSB, lpDSB2; - -extern WINCLASS *MainWindow; - -static s16 *stereodata16; -static u32 soundoffset=0; -static u32 soundbufsize; -static LONG soundvolume; -static int issoundmuted; - -////////////////////////////////////////////////////////////////////////////// - -static volatile bool doterminate; -static volatile bool terminated; - -extern volatile int win_sound_samplecounter; - -DWORD WINAPI SNDDXThread( LPVOID ) -{ - for(;;) { - if(doterminate) break; - { - Lock lock; - SPU_Emulate_user(); - } - Sleep(10); - } - terminated = true; - return 0; -} - -int SNDDXInit(int buffersize) -{ - DSBUFFERDESC dsbdesc; - WAVEFORMATEX wfx; - HRESULT ret; - char tempstr[512]; - - if ((ret = DirectSoundCreate8(NULL, &lpDS8, NULL)) != DS_OK) - { - sprintf(tempstr, "DirectSound8Create error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); - MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); - return -1; - } - - if ((ret = IDirectSound8_SetCooperativeLevel(lpDS8, MainWindow->getHWnd(), DSSCL_PRIORITY)) != DS_OK) - { - sprintf(tempstr, "IDirectSound8_SetCooperativeLevel error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); - MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); - return -1; - } - - memset(&dsbdesc, 0, sizeof(dsbdesc)); - dsbdesc.dwSize = sizeof(DSBUFFERDESC); - dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER; - dsbdesc.dwBufferBytes = 0; - dsbdesc.lpwfxFormat = NULL; - - if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB, NULL)) != DS_OK) - { - sprintf(tempstr, "Error when creating primary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); - MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); - return -1; - } - - soundbufsize = buffersize * 2 * 2; - - memset(&wfx, 0, sizeof(wfx)); - wfx.wFormatTag = WAVE_FORMAT_PCM; - wfx.nChannels = 2; - wfx.nSamplesPerSec = 44100; - wfx.wBitsPerSample = 16; - wfx.nBlockAlign = (wfx.wBitsPerSample / 8) * wfx.nChannels; - wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; - - if ((ret = IDirectSoundBuffer8_SetFormat(lpDSB, &wfx)) != DS_OK) - { - sprintf(tempstr, "IDirectSoundBuffer8_SetFormat error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); - MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); - return -1; - } - - memset(&dsbdesc, 0, sizeof(dsbdesc)); - dsbdesc.dwSize = sizeof(DSBUFFERDESC); - dsbdesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_STICKYFOCUS | - DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | - DSBCAPS_LOCHARDWARE; - dsbdesc.dwBufferBytes = soundbufsize; - dsbdesc.lpwfxFormat = &wfx; - - if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB2, NULL)) != DS_OK) - { - if (ret == DSERR_CONTROLUNAVAIL || - ret == DSERR_INVALIDCALL || - ret == E_FAIL || - ret == E_NOTIMPL) - { - // Try using a software buffer instead - dsbdesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_STICKYFOCUS | - DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | - DSBCAPS_LOCSOFTWARE; - - if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB2, NULL)) != DS_OK) - { - sprintf(tempstr, "Error when creating secondary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); - MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); - return -1; - } - } - else - { - sprintf(tempstr, "Error when creating secondary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); - MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); - return -1; - } - } - - IDirectSoundBuffer8_Play(lpDSB2, 0, 0, DSBPLAY_LOOPING); - - if ((stereodata16 = (s16 *)malloc(soundbufsize)) == NULL) - return -1; - - memset(stereodata16, 0, soundbufsize); - - soundvolume = DSBVOLUME_MAX; - issoundmuted = 0; - - doterminate = false; - terminated = false; - CreateThread(0,0,SNDDXThread,0,0,0); - - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDXDeInit() -{ - DWORD status=0; - - doterminate = true; - while(!terminated) { - Sleep(1); - } - - if (lpDSB2) - { - IDirectSoundBuffer8_GetStatus(lpDSB2, &status); - - if(status == DSBSTATUS_PLAYING) - IDirectSoundBuffer8_Stop(lpDSB2); - - IDirectSoundBuffer8_Release(lpDSB2); - lpDSB2 = NULL; - } - - if (lpDSB) - { - IDirectSoundBuffer8_Release(lpDSB); - lpDSB = NULL; - } - - if (lpDS8) - { - IDirectSound8_Release(lpDS8); - lpDS8 = NULL; - } -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDXUpdateAudio(s16 *buffer, u32 num_samples) -{ - LPVOID buffer1; - LPVOID buffer2; - DWORD buffer1_size, buffer2_size; - DWORD status; - - int samplecounter; - { - Lock lock; - samplecounter = win_sound_samplecounter -= num_samples; - } - - bool silence = (samplecounter<-44100*15/60); //behind by more than a quarter second -> silence - - IDirectSoundBuffer8_GetStatus(lpDSB2, &status); - - if (status & DSBSTATUS_BUFFERLOST) - return; // fix me - - IDirectSoundBuffer8_Lock(lpDSB2, soundoffset, num_samples * sizeof(s16) * 2, &buffer1, &buffer1_size, &buffer2, &buffer2_size, 0); - - if(silence) { - memset(buffer1, 0, buffer1_size); - if(buffer2) - memset(buffer2, 0, buffer2_size); - } - else - { - memcpy(buffer1, buffer, buffer1_size); - if (buffer2) - memcpy(buffer2, ((u8 *)buffer)+buffer1_size, buffer2_size); - } - - soundoffset += buffer1_size + buffer2_size; - soundoffset %= soundbufsize; - - IDirectSoundBuffer8_Unlock(lpDSB2, buffer1, buffer1_size, buffer2, buffer2_size); -} - -////////////////////////////////////////////////////////////////////////////// - -u32 SNDDXGetAudioSpace() -{ - DWORD playcursor, writecursor; - u32 freespace=0; - - if (IDirectSoundBuffer8_GetCurrentPosition (lpDSB2, &playcursor, &writecursor) != DS_OK) - return 0; - - if (soundoffset > playcursor) - freespace = soundbufsize - soundoffset + playcursor; - else - freespace = playcursor - soundoffset; - - // if (freespace > 512) - return (freespace / 2 / 2); - // else - // return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDXMuteAudio() -{ - issoundmuted = 1; - IDirectSoundBuffer8_SetVolume (lpDSB2, DSBVOLUME_MIN); -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDXUnMuteAudio() -{ - issoundmuted = 0; - IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume); -} - -////////////////////////////////////////////////////////////////////////////// - -void SNDDXSetVolume(int volume) -{ - if (!lpDSB2) return ; /* might happen when changing sounddevice on the fly, caused a gpf */ - soundvolume = (((LONG)volume) - 100) * 100; - if (!issoundmuted) - IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume); -} - -////////////////////////////////////////////////////////////////////////////// - - +/* snddx.cpp + + Copyright (C) 2005-2007 Theo Berkau + Copyright (C) 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include +#include +#include "directx/dsound.h" +#ifdef __MINGW32__ +// I have to do this because for some reason because the dxerr8.h header is fubared +const char* __stdcall DXGetErrorString8A(HRESULT hr); +#define DXGetErrorString8 DXGetErrorString8A +const char* __stdcall DXGetErrorDescription8A(HRESULT hr); +#define DXGetErrorDescription8 DXGetErrorDescription8A +#else +#include "directx/dxerr8.h" +#endif +#include "SPU.h" +#include "snddx.h" +#include "CWindow.h" +#include "windriver.h" + +int SNDDXInit(int buffersize); +void SNDDXDeInit(); +void SNDDXUpdateAudio(s16 *buffer, u32 num_samples); +u32 SNDDXGetAudioSpace(); +void SNDDXMuteAudio(); +void SNDDXUnMuteAudio(); +void SNDDXSetVolume(int volume); + +SoundInterface_struct SNDDIRECTX = { + SNDCORE_DIRECTX, + "Direct Sound Interface", + SNDDXInit, + SNDDXDeInit, + SNDDXUpdateAudio, + SNDDXGetAudioSpace, + SNDDXMuteAudio, + SNDDXUnMuteAudio, + SNDDXSetVolume +}; + +LPDIRECTSOUND8 lpDS8; +LPDIRECTSOUNDBUFFER lpDSB, lpDSB2; + +extern WINCLASS *MainWindow; + +static s16 *stereodata16; +static u32 soundoffset=0; +static u32 soundbufsize; +static LONG soundvolume; +static int issoundmuted; + +////////////////////////////////////////////////////////////////////////////// + +static volatile bool doterminate; +static volatile bool terminated; + +extern CRITICAL_SECTION win_sync; +extern volatile int win_sound_samplecounter; + +DWORD WINAPI SNDDXThread( LPVOID ) +{ + for(;;) { + if(doterminate) break; + { + Lock lock; + SPU_Emulate_user(); + } + Sleep(10); + } + terminated = true; + return 0; +} + +int SNDDXInit(int buffersize) +{ + DSBUFFERDESC dsbdesc; + WAVEFORMATEX wfx; + HRESULT ret; + char tempstr[512]; + + if ((ret = DirectSoundCreate8(NULL, &lpDS8, NULL)) != DS_OK) + { + sprintf(tempstr, "DirectSound8Create error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); + MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); + return -1; + } + + if ((ret = IDirectSound8_SetCooperativeLevel(lpDS8, MainWindow->getHWnd(), DSSCL_PRIORITY)) != DS_OK) + { + sprintf(tempstr, "IDirectSound8_SetCooperativeLevel error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); + MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); + return -1; + } + + memset(&dsbdesc, 0, sizeof(dsbdesc)); + dsbdesc.dwSize = sizeof(DSBUFFERDESC); + dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER; + dsbdesc.dwBufferBytes = 0; + dsbdesc.lpwfxFormat = NULL; + + if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB, NULL)) != DS_OK) + { + sprintf(tempstr, "Error when creating primary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); + MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); + return -1; + } + + soundbufsize = buffersize * 2 * 2; + + memset(&wfx, 0, sizeof(wfx)); + wfx.wFormatTag = WAVE_FORMAT_PCM; + wfx.nChannels = 2; + wfx.nSamplesPerSec = 44100; + wfx.wBitsPerSample = 16; + wfx.nBlockAlign = (wfx.wBitsPerSample / 8) * wfx.nChannels; + wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; + + if ((ret = IDirectSoundBuffer8_SetFormat(lpDSB, &wfx)) != DS_OK) + { + sprintf(tempstr, "IDirectSoundBuffer8_SetFormat error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); + MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); + return -1; + } + + memset(&dsbdesc, 0, sizeof(dsbdesc)); + dsbdesc.dwSize = sizeof(DSBUFFERDESC); + dsbdesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_STICKYFOCUS | + DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | + DSBCAPS_LOCHARDWARE; + dsbdesc.dwBufferBytes = soundbufsize; + dsbdesc.lpwfxFormat = &wfx; + + if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB2, NULL)) != DS_OK) + { + if (ret == DSERR_CONTROLUNAVAIL || + ret == DSERR_INVALIDCALL || + ret == E_FAIL || + ret == E_NOTIMPL) + { + // Try using a software buffer instead + dsbdesc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_STICKYFOCUS | + DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2 | + DSBCAPS_LOCSOFTWARE; + + if ((ret = IDirectSound8_CreateSoundBuffer(lpDS8, &dsbdesc, &lpDSB2, NULL)) != DS_OK) + { + sprintf(tempstr, "Error when creating secondary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); + MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); + return -1; + } + } + else + { + sprintf(tempstr, "Error when creating secondary sound buffer: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); + MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); + return -1; + } + } + + IDirectSoundBuffer8_Play(lpDSB2, 0, 0, DSBPLAY_LOOPING); + + if ((stereodata16 = (s16 *)malloc(soundbufsize)) == NULL) + return -1; + + memset(stereodata16, 0, soundbufsize); + + soundvolume = DSBVOLUME_MAX; + issoundmuted = 0; + + doterminate = false; + terminated = false; + CreateThread(0,0,SNDDXThread,0,0,0); + + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDXDeInit() +{ + DWORD status=0; + + doterminate = true; + while(!terminated) { + Sleep(1); + } + + if (lpDSB2) + { + IDirectSoundBuffer8_GetStatus(lpDSB2, &status); + + if(status == DSBSTATUS_PLAYING) + IDirectSoundBuffer8_Stop(lpDSB2); + + IDirectSoundBuffer8_Release(lpDSB2); + lpDSB2 = NULL; + } + + if (lpDSB) + { + IDirectSoundBuffer8_Release(lpDSB); + lpDSB = NULL; + } + + if (lpDS8) + { + IDirectSound8_Release(lpDS8); + lpDS8 = NULL; + } +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDXUpdateAudio(s16 *buffer, u32 num_samples) +{ + LPVOID buffer1; + LPVOID buffer2; + DWORD buffer1_size, buffer2_size; + DWORD status; + + int samplecounter; + { + Lock lock; + samplecounter = win_sound_samplecounter -= num_samples; + } + + bool silence = (samplecounter<-44100*15/60); //behind by more than a quarter second -> silence + + IDirectSoundBuffer8_GetStatus(lpDSB2, &status); + + if (status & DSBSTATUS_BUFFERLOST) + return; // fix me + + IDirectSoundBuffer8_Lock(lpDSB2, soundoffset, num_samples * sizeof(s16) * 2, &buffer1, &buffer1_size, &buffer2, &buffer2_size, 0); + + if(silence) { + memset(buffer1, 0, buffer1_size); + if(buffer2) + memset(buffer2, 0, buffer2_size); + } + else + { + memcpy(buffer1, buffer, buffer1_size); + if (buffer2) + memcpy(buffer2, ((u8 *)buffer)+buffer1_size, buffer2_size); + } + + soundoffset += buffer1_size + buffer2_size; + soundoffset %= soundbufsize; + + IDirectSoundBuffer8_Unlock(lpDSB2, buffer1, buffer1_size, buffer2, buffer2_size); +} + +////////////////////////////////////////////////////////////////////////////// + +u32 SNDDXGetAudioSpace() +{ + DWORD playcursor, writecursor; + u32 freespace=0; + + if (IDirectSoundBuffer8_GetCurrentPosition (lpDSB2, &playcursor, &writecursor) != DS_OK) + return 0; + + if (soundoffset > playcursor) + freespace = soundbufsize - soundoffset + playcursor; + else + freespace = playcursor - soundoffset; + + // if (freespace > 512) + return (freespace / 2 / 2); + // else + // return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDXMuteAudio() +{ + issoundmuted = 1; + IDirectSoundBuffer8_SetVolume (lpDSB2, DSBVOLUME_MIN); +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDXUnMuteAudio() +{ + issoundmuted = 0; + IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume); +} + +////////////////////////////////////////////////////////////////////////////// + +void SNDDXSetVolume(int volume) +{ + if (!lpDSB2) return ; /* might happen when changing sounddevice on the fly, caused a gpf */ + soundvolume = (((LONG)volume) - 100) * 100; + if (!issoundmuted) + IDirectSoundBuffer8_SetVolume (lpDSB2, soundvolume); +} + +////////////////////////////////////////////////////////////////////////////// + + diff --git a/desmume/src/windows/snddx.h b/src/windows/snddx.h old mode 100755 new mode 100644 similarity index 97% rename from desmume/src/windows/snddx.h rename to src/windows/snddx.h index bb75bc086..245411751 --- a/desmume/src/windows/snddx.h +++ b/src/windows/snddx.h @@ -1,25 +1,25 @@ -/* Copyright (C) 2006 Theo Berkau - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef SNDDX_H -#define SNDDX_H -#define SNDCORE_DIRECTX 2 - -extern SoundInterface_struct SNDDIRECTX; -#endif +/* Copyright (C) 2006 Theo Berkau + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef SNDDX_H +#define SNDDX_H +#define SNDCORE_DIRECTX 2 + +extern SoundInterface_struct SNDDIRECTX; +#endif diff --git a/desmume/src/windows/soundView.cpp b/src/windows/soundView.cpp similarity index 100% rename from desmume/src/windows/soundView.cpp rename to src/windows/soundView.cpp diff --git a/desmume/src/windows/soundView.h b/src/windows/soundView.h similarity index 100% rename from desmume/src/windows/soundView.h rename to src/windows/soundView.h diff --git a/desmume/src/windows/throttle.cpp b/src/windows/throttle.cpp similarity index 93% rename from desmume/src/windows/throttle.cpp rename to src/windows/throttle.cpp index 6986f61ee..81ac96c6a 100644 --- a/desmume/src/windows/throttle.cpp +++ b/src/windows/throttle.cpp @@ -1,109 +1,109 @@ -//THIS SPEED THROTTLE IS TAKEN FROM FCEUX. -//Copyright (C) 2002 Xodnizel - -#include "../common.h" -#include "../types.h" -#include "../debug.h" -#include "../console.h" -#include - -int FastForward=0; -static u64 tmethod,tfreq; -static const u64 core_desiredfps = 3920763; //59.8261 -static u64 desiredfps = core_desiredfps; -static u64 desiredFpsScaler = 256; - -void IncreaseSpeed(void) { - - desiredFpsScaler*=2; - desiredfps = core_desiredfps * desiredFpsScaler / 256; - printf("Throttle fps scaling increased to: %f\n",desiredFpsScaler/256.0); -} - -void DecreaseSpeed(void) { - - desiredFpsScaler/=2; - desiredfps = core_desiredfps * desiredFpsScaler / 256; - printf("Throttle fps scaling decreased to: %f\n",desiredFpsScaler/256.0); -} - -static u64 GetCurTime(void) -{ - if(tmethod) - { - u64 tmp; - - /* Practically, LARGE_INTEGER and u64 differ only by signness and name. */ - QueryPerformanceCounter((LARGE_INTEGER*)&tmp); - - return(tmp); - } - else - return((u64)GetTickCount()); - -} - -void InitSpeedThrottle(void) -{ - tmethod=0; - if(QueryPerformanceFrequency((LARGE_INTEGER*)&tfreq)) - { - tmethod=1; - } - else - tfreq=1000; - tfreq<<=16; /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */ -} - -static bool behind=false; -bool ThrottleIsBehind() { - return behind; -} - -int SpeedThrottle(void) -{ - static u64 ttime,ltime; - - if(FastForward) - return (0); - - behind = false; - -waiter: - - ttime=GetCurTime(); - - - if( (ttime-ltime) < (tfreq/desiredfps) ) - { - u64 sleepy; - sleepy=(tfreq/desiredfps)-(ttime-ltime); - sleepy*=1000; - if(tfreq>=65536) - sleepy/=tfreq>>16; - else - sleepy=0; - if(sleepy>100) - { - // block for a max of 100ms to - // keep the gui responsive - Sleep(100); - return 1; - } - Sleep((DWORD)sleepy); - goto waiter; - } - if( (ttime-ltime) >= (tfreq*4/desiredfps)) - ltime=ttime; - else - { - ltime+=tfreq/desiredfps; - - if( (ttime-ltime) >= (tfreq/desiredfps) ) // Oops, we're behind! - { - behind = true; - return 0; - } - } - return(0); -} +//THIS SPEED THROTTLE IS TAKEN FROM FCEUX. +//Copyright (C) 2002 Xodnizel + +#include "../common.h" +#include "../types.h" +#include "../debug.h" +#include "../console.h" +#include + +int FastForward=0; +static u64 tmethod,tfreq; +static const u64 core_desiredfps = 3920763; //59.8261 +static u64 desiredfps = core_desiredfps; +static u64 desiredFpsScaler = 256; + +void IncreaseSpeed(void) { + + desiredFpsScaler*=2; + desiredfps = core_desiredfps * desiredFpsScaler / 256; + printf("Throttle fps scaling increased to: %f\n",desiredFpsScaler/256.0); +} + +void DecreaseSpeed(void) { + + desiredFpsScaler/=2; + desiredfps = core_desiredfps * desiredFpsScaler / 256; + printf("Throttle fps scaling decreased to: %f\n",desiredFpsScaler/256.0); +} + +static u64 GetCurTime(void) +{ + if(tmethod) + { + u64 tmp; + + /* Practically, LARGE_INTEGER and u64 differ only by signness and name. */ + QueryPerformanceCounter((LARGE_INTEGER*)&tmp); + + return(tmp); + } + else + return((u64)GetTickCount()); + +} + +void InitSpeedThrottle(void) +{ + tmethod=0; + if(QueryPerformanceFrequency((LARGE_INTEGER*)&tfreq)) + { + tmethod=1; + } + else + tfreq=1000; + tfreq<<=16; /* Adjustment for fps returned from FCEUI_GetDesiredFPS(). */ +} + +static bool behind=false; +bool ThrottleIsBehind() { + return behind; +} + +int SpeedThrottle(void) +{ + static u64 ttime,ltime; + + if(FastForward) + return (0); + + behind = false; + +waiter: + + ttime=GetCurTime(); + + + if( (ttime-ltime) < (tfreq/desiredfps) ) + { + u64 sleepy; + sleepy=(tfreq/desiredfps)-(ttime-ltime); + sleepy*=1000; + if(tfreq>=65536) + sleepy/=tfreq>>16; + else + sleepy=0; + if(sleepy>100) + { + // block for a max of 100ms to + // keep the gui responsive + Sleep(100); + return 1; + } + Sleep(sleepy); + goto waiter; + } + if( (ttime-ltime) >= (tfreq*4/desiredfps)) + ltime=ttime; + else + { + ltime+=tfreq/desiredfps; + + if( (ttime-ltime) >= (tfreq/desiredfps) ) // Oops, we're behind! + { + behind = true; + return 0; + } + } + return(0); +} diff --git a/desmume/src/windows/throttle.h b/src/windows/throttle.h similarity index 94% rename from desmume/src/windows/throttle.h rename to src/windows/throttle.h index b2d3103e3..c30e8f07f 100644 --- a/desmume/src/windows/throttle.h +++ b/src/windows/throttle.h @@ -1,11 +1,11 @@ -#ifndef _THROTTLE_H_ -#define _THROTTLE_H_ - -void InitSpeedThrottle(); -int SpeedThrottle(); -bool ThrottleIsBehind(); -extern int FastForward; -void IncreaseSpeed(); -void DecreaseSpeed(); - -#endif +#ifndef _THROTTLE_H_ +#define _THROTTLE_H_ + +void InitSpeedThrottle(); +int SpeedThrottle(); +bool ThrottleIsBehind(); +extern int FastForward; +void IncreaseSpeed(); +void DecreaseSpeed(); + +#endif diff --git a/desmume/src/windows/tileView.cpp b/src/windows/tileView.cpp similarity index 93% rename from desmume/src/windows/tileView.cpp rename to src/windows/tileView.cpp index d12415463..93152dad7 100644 --- a/desmume/src/windows/tileView.cpp +++ b/src/windows/tileView.cpp @@ -1,658 +1,658 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "tileView.h" -#include "commctrl.h" -#include "resource.h" -#include "debug.h" -#include "../MMU.h" -#include "../gpu.h" - -typedef struct -{ - u32 autoup_secs; - bool autoup; - - HWND hwnd; - u32 target; - u16 * pal; - s16 palnum; - u16 tilenum; - u8 coul; - u32 x; - u32 y; -} tileview_struct; - -tileview_struct *TileView = NULL; - -LRESULT TileViewBox_Direct(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; -// SIZE fontsize; -// TCHAR text[80]; - BITMAPV4HEADER bmi; - RECT rect; - HDC mem_dc; - HBITMAP mem_bmp; - int lg; - int ht; - - memset(&bmi, 0, sizeof(bmi)); - bmi.bV4Size = sizeof(bmi); - bmi.bV4Planes = 1; - bmi.bV4BitCount = 16; - bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS; - bmi.bV4RedMask = 0x001F; - bmi.bV4GreenMask = 0x03E0; - bmi.bV4BlueMask = 0x7C00; - bmi.bV4Width = 256; - bmi.bV4Height = -256; - - GetClientRect(hwnd, &rect); - lg = rect.right - rect.left; - ht = rect.bottom - rect.top; - - hdc = BeginPaint(hwnd, &ps); - - mem_dc = CreateCompatibleDC(hdc); - mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); - SelectObject(mem_dc, mem_bmp); - - FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - u8* mem; - if(win->target >= MMU_LCDC) - mem = MMU.ARM9_LCD + win->target - MMU_LCDC; - else - mem = (u8*)MMU_gpu_map(win->target); - if(mem) - SetDIBitsToDevice(mem_dc, 0, 0, 256, 256, 0, 0, 0, 256, mem, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); - - BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); - - DeleteDC(mem_dc); - DeleteObject(mem_bmp); - - EndPaint(hwnd, &ps); - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT TileViewBox_Pal256(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; -// SIZE fontsize; - TCHAR text[80]; - u16 bitmap[256*256]; - u16 * pal = ((u16 *)win->pal) + win->palnum*256; - BITMAPV4HEADER bmi; - RECT rect; - int lg; - int ht; - HDC mem_dc; - HBITMAP mem_bmp; - - memset(&bmi, 0, sizeof(bmi)); - bmi.bV4Size = sizeof(bmi); - bmi.bV4Planes = 1; - bmi.bV4BitCount = 16; - bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS; - bmi.bV4RedMask = 0x001F; - bmi.bV4GreenMask = 0x03E0; - bmi.bV4BlueMask = 0x7C00; - bmi.bV4Width = 256; - bmi.bV4Height = -256; - - GetClientRect(hwnd, &rect); - lg = rect.right - rect.left; - ht = rect.bottom - rect.top; - - hdc = BeginPaint(hwnd, &ps); - - mem_dc = CreateCompatibleDC(hdc); - mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); - SelectObject(mem_dc, mem_bmp); - - FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - if(win->pal) - { - u32 num2, num, y, x; - - u8* mem; - if(win->target >= MMU_LCDC) - mem = MMU.ARM9_LCD + win->target - MMU_LCDC; - else - mem = (u8*)MMU_gpu_map(win->target); - if(mem) - { - for(num2 = 0; num2<32; ++num2) - for(num = 0; num<32; ++num) - for(y = 0; y<8; ++y) - for(x = 0; x<8; ++x) - bitmap[x + (y*256) + (num*8) +(num2*256*8)] = pal[mem[x + (y*8) + (num*64) +(num2*2048)]]; - SetDIBitsToDevice(mem_dc, 0, 0, 256, 256, 0, 0, 0, 256, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); - } - sprintf(text, "Pal : %d", win->palnum); - SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), text); - } - else - TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23); - - BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); - - DeleteDC(mem_dc); - DeleteObject(mem_bmp); - - EndPaint(hwnd, &ps); - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT TileViewBox_Pal16(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; -// SIZE fontsize; - TCHAR text[80]; - u16 bitmap[512*512]; - u16 * pal = ((u16 *)win->pal) + win->palnum*16; - BITMAPV4HEADER bmi; - RECT rect; - int lg; - int ht; - HDC mem_dc; - HBITMAP mem_bmp; - - memset(&bmi, 0, sizeof(bmi)); - bmi.bV4Size = sizeof(bmi); - bmi.bV4Planes = 1; - bmi.bV4BitCount = 16; - bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS; - bmi.bV4RedMask = 0x001F; - bmi.bV4GreenMask = 0x03E0; - bmi.bV4BlueMask = 0x7C00; - bmi.bV4Width = 512; - bmi.bV4Height = -256; - - GetClientRect(hwnd, &rect); - lg = rect.right - rect.left; - ht = rect.bottom - rect.top; - - hdc = BeginPaint(hwnd, &ps); - - mem_dc = CreateCompatibleDC(hdc); - mem_bmp = CreateCompatibleBitmap(hdc, 512, 256); - SelectObject(mem_dc, mem_bmp); - - FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - if(win->pal) - { - u8* mem; - if(win->target >= MMU_LCDC) - mem = MMU.ARM9_LCD + win->target - MMU_LCDC; - else - mem = (u8*)MMU_gpu_map(win->target); - - if(mem) - { - u32 num2, num, y, x; - for(num2 = 0; num2<32; ++num2) - for(num = 0; num<64; ++num) - for(y = 0; y<8; ++y) - for(x = 0; x<4; ++x) - { - bitmap[(x<<1) + (y*512) + (num*8) +(num2*512*8)] = pal[mem[x + (y*4) + (num*32) +(num2*2048)]&0xF]; - bitmap[(x<<1)+1 + (y*512) + (num*8) +(num2*512*8)] = pal[mem[x + (y*4) + (num*32) +(num2*2048)]>>4]; - } - SetDIBitsToDevice(mem_dc, 0, 0, 512, 256, 0, 0, 0, 256, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); - } - sprintf(text, "Pal : %d", win->palnum); - SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), text); - } - else - TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23); - - BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); - - DeleteDC(mem_dc); - DeleteObject(mem_bmp); - - EndPaint(hwnd, &ps); - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT CALLBACK TileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_INITDIALOG: - return 1; - case WM_NCCREATE: - return 1; - case WM_NCDESTROY: - return 1; - case WM_PAINT: - switch(TileView->coul) - { - case 0 : - TileViewBox_Direct(hwnd, TileView, wParam, lParam); - break; - case 1 : - TileViewBox_Pal256(hwnd, TileView, wParam, lParam); - break; - case 2 : - TileViewBox_Pal16(hwnd, TileView, wParam, lParam); - break; - } - break; - case WM_LBUTTONDOWN : - switch(TileView->coul) - { - case 0 : - case 1 : - if(LOWORD(lParam)<(32*8)) - { - TileView->x = ((LOWORD(lParam)>>3)<<3); - TileView->y = (HIWORD(lParam)>>3)<<3; - TileView->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*32; - } - break; - case 2 : - TileView->x = ((LOWORD(lParam)>>3)<<3); - TileView->y = (HIWORD(lParam)>>3)<<3; - TileView->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*64; - break; - } - InvalidateRect(GetDlgItem(hwnd, IDC_MINI_TILE), NULL, FALSE); - return 1; - case WM_ERASEBKGND: - return 1; - } - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -LRESULT MiniTileViewBox_Paint(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) -{ - HWND hwnd_src = GetDlgItem(GetParent(hwnd), IDC_Tile_BOX); - HDC hdc_src; - HDC hdc_dst; - char txt[80]; - - PAINTSTRUCT ps; - - hdc_dst = BeginPaint(hwnd, &ps); - hdc_src = GetDC(hwnd_src); - StretchBlt(hdc_dst, 0, 0, 80, 80, hdc_src, win->x, win->y, 8, 8, SRCCOPY); - sprintf(txt, "Tile num : 0x%X", win->tilenum); - SetWindowText(GetDlgItem(win->hwnd, IDC_TILENUM), txt); - EndPaint(hwnd, &ps); - return 0; -} - -LRESULT CALLBACK MiniTileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) - { - case WM_NCCREATE: - return 1; - case WM_NCDESTROY: - return 1; - case WM_PAINT : - MiniTileViewBox_Paint(hwnd, TileView, wParam, lParam); - break; - case WM_ERASEBKGND: - return 1; - default: - break; - } - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -BOOL CALLBACK ViewTilesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - //bail out early if the dialog isnt initialized - if(!TileView && message != WM_INITDIALOG) - return false; - - switch (message) - { - case WM_INITDIALOG : - { - TileView = new tileview_struct; - memset(TileView, 0, sizeof(tileview_struct)); - TileView->hwnd = hwnd; - TileView->target = MMU_ABG; - TileView->pal = ((u16 *)MMU.ARM9_VMEM); - TileView->autoup_secs = 1; - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETRANGE, 0, MAKELONG(99, 1)); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), - UDM_SETPOS32, 0, TileView->autoup_secs); - - HWND combo = GetDlgItem(hwnd, IDC_PAL_SELECT); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen BG PAL"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen BG PAL"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen SPR PAL"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen SPR PAL"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 3"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 3"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 3"); - SendMessage(combo, CB_SETCURSEL, 0, 0); - - combo = GetDlgItem(hwnd, IDC_MEM_SELECT); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6000000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6010000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6020000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6030000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6040000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6050000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6060000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6070000"); - - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-BG - 0x6200000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-BG - 0x6210000"); - - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6400000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6410000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6420000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6430000"); - - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-OBJ- 0x6600000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-OBJ- 0x6610000"); - - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6800000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6810000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6820000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6830000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6840000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6850000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6860000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6870000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6880000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6890000"); - SendMessage(combo, CB_SETCURSEL, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_BITMAP), BM_SETCHECK, TRUE, 0); - } - return 1; - case WM_CLOSE : - if(TileView->autoup) - { - KillTimer(hwnd, IDT_VIEW_TILE); - TileView->autoup = false; - } - if (TileView!=NULL) - { - delete TileView; - TileView = NULL; - } - //INFO("Close Tile view dialog\n"); - PostQuitMessage(0); - return 1; - case WM_TIMER: - SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); - return 1; - case WM_HSCROLL : - switch LOWORD(wParam) - { - case SB_LINERIGHT : - ++(TileView->palnum); - if(TileView->palnum>15) - TileView->palnum = 15; - break; - case SB_LINELEFT : - --(TileView->palnum); - if(TileView->palnum<0) - TileView->palnum = 0; - break; - } - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDC_FERMER : - SendMessage(hwnd, WM_CLOSE, 0, 0); - return 1; - case IDC_AUTO_UPDATE : - if(TileView->autoup) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); - KillTimer(hwnd, IDT_VIEW_TILE); - TileView->autoup = FALSE; - return 1; - } - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); - TileView->autoup = TRUE; - SetTimer(hwnd, IDT_VIEW_TILE, TileView->autoup_secs*20, (TIMERPROC) NULL); - return 1; - case IDC_AUTO_UPDATE_SECS: - { - int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); - if (!TileView) - { - SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - if (t != TileView->autoup_secs) - { - TileView->autoup_secs = t; - if (TileView->autoup) - SetTimer(hwnd, IDT_VIEW_TILE, - TileView->autoup_secs*20, (TIMERPROC) NULL); - } - } - return 1; - case IDC_REFRESH: - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_BITMAP : - TileView->coul = 0; - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_256COUL : - TileView->coul = 1; - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_16COUL : - TileView->coul = 2; - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_MEM_SELECT : - switch(HIWORD(wParam)) - { - case CBN_SELCHANGE : - case CBN_CLOSEUP : - { - u32 sel = SendMessage(GetDlgItem(hwnd, IDC_MEM_SELECT), CB_GETCURSEL, 0, 0); - switch(sel) - { - case 0 : - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 6 : - case 7 : - TileView->target = MMU_ABG + 0x10000*sel; - break; - case 8 : - case 9 : - TileView->target = MMU_BBG + 0x10000*(sel-8); - break; - case 10 : - case 11 : - case 12 : - case 13 : - TileView->target = MMU_AOBJ + 0x10000*(sel-10); - break; - case 14 : - case 15 : - TileView->target = MMU_BOBJ + 0x10000*(sel-14); - break; - case 16 : - case 17 : - case 18 : - case 19 : - case 20 : - case 21 : - case 22 : - case 23 : - case 24 : - case 25 : - TileView->target = MMU_LCDC + 0x10000*(sel-16); - break; - default : - return 1; - } - InvalidateRect(hwnd, NULL, FALSE); - return 1; - } - } - return 1; - case IDC_PAL_SELECT : - switch(HIWORD(wParam)) - { - case CBN_SELCHANGE : - case CBN_CLOSEUP : - { - u32 sel = SendMessage(GetDlgItem(hwnd, IDC_PAL_SELECT), CB_GETCURSEL, 0, 0); - switch(sel) - { - case 0 : - TileView->pal = (u16 *)MMU.ARM9_VMEM; - TileView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); - EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); - break; - case 1 : - TileView->pal = ((u16 *)MMU.ARM9_VMEM) + 0x200; - TileView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); - EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); - break; - case 2 : - TileView->pal = (u16 *)MMU.ARM9_VMEM + 0x100; - TileView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); - EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); - break; - case 3 : - TileView->pal = ((u16 *)MMU.ARM9_VMEM) + 0x300; - TileView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); - EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); - break; - case 4 : - case 5 : - case 6 : - case 7 : - TileView->pal = ((u16 *)(MMU.ExtPal[0][sel-4])); - TileView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_HIDE); - EnableWindow(GetDlgItem(hwnd, IDC_16COUL), FALSE); - if(TileView->coul == 2) - { - SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); - SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); - TileView->coul = 1; - } - break; - case 8 : - case 9 : - case 10 : - case 11 : - TileView->pal = ((u16 *)(MMU.ExtPal[1][sel-8])); - TileView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_HIDE); - EnableWindow(GetDlgItem(hwnd, IDC_16COUL), FALSE); - if(TileView->coul == 2) - { - SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); - SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); - TileView->coul = 1; - } - break; - case 12 : - case 13 : - TileView->pal = ((u16 *)(MMU.ObjExtPal[0][sel-12])); - TileView->palnum = 0; - if(TileView->coul == 2) - { - SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); - SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); - TileView->coul = 1; - } - break; - case 14 : - case 15 : - TileView->pal = ((u16 *)(MMU.ObjExtPal[1][sel-14])); - TileView->palnum = 0; - if(TileView->coul == 2) - { - SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); - SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); - TileView->coul = 1; - } - break; - case 16 : - case 17 : - case 18 : - case 19 : - TileView->pal = ((u16 *)(MMU.texInfo.texPalSlot[sel-16])); - TileView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); - EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); - break; - default : - return 1; - } - InvalidateRect(hwnd, NULL, FALSE); - return 1; - } - } - } - return 0; - } - return FALSE; -} +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "tileView.h" +#include "commctrl.h" +#include "resource.h" +#include "debug.h" +#include "../MMU.h" +#include "../gpu.h" + +typedef struct +{ + u32 autoup_secs; + bool autoup; + + HWND hwnd; + u32 target; + u16 * pal; + s16 palnum; + u16 tilenum; + u8 coul; + u32 x; + u32 y; +} tileview_struct; + +tileview_struct *TileView = NULL; + +LRESULT TileViewBox_Direct(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; +// SIZE fontsize; +// TCHAR text[80]; + BITMAPV4HEADER bmi; + RECT rect; + HDC mem_dc; + HBITMAP mem_bmp; + int lg; + int ht; + + memset(&bmi, 0, sizeof(bmi)); + bmi.bV4Size = sizeof(bmi); + bmi.bV4Planes = 1; + bmi.bV4BitCount = 16; + bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS; + bmi.bV4RedMask = 0x001F; + bmi.bV4GreenMask = 0x03E0; + bmi.bV4BlueMask = 0x7C00; + bmi.bV4Width = 256; + bmi.bV4Height = -256; + + GetClientRect(hwnd, &rect); + lg = rect.right - rect.left; + ht = rect.bottom - rect.top; + + hdc = BeginPaint(hwnd, &ps); + + mem_dc = CreateCompatibleDC(hdc); + mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); + SelectObject(mem_dc, mem_bmp); + + FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + u8* mem; + if(win->target >= ARM9MEM_LCDC) + mem = ARM9Mem.ARM9_LCD + win->target - ARM9MEM_LCDC; + else + mem = MMU_RenderMapToLCD(win->target); + if(mem) + SetDIBitsToDevice(mem_dc, 0, 0, 256, 256, 0, 0, 0, 256, mem, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + + BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); + + DeleteDC(mem_dc); + DeleteObject(mem_bmp); + + EndPaint(hwnd, &ps); + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT TileViewBox_Pal256(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; +// SIZE fontsize; + TCHAR text[80]; + u16 bitmap[256*256]; + u16 * pal = ((u16 *)win->pal) + win->palnum*256; + BITMAPV4HEADER bmi; + RECT rect; + int lg; + int ht; + HDC mem_dc; + HBITMAP mem_bmp; + + memset(&bmi, 0, sizeof(bmi)); + bmi.bV4Size = sizeof(bmi); + bmi.bV4Planes = 1; + bmi.bV4BitCount = 16; + bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS; + bmi.bV4RedMask = 0x001F; + bmi.bV4GreenMask = 0x03E0; + bmi.bV4BlueMask = 0x7C00; + bmi.bV4Width = 256; + bmi.bV4Height = -256; + + GetClientRect(hwnd, &rect); + lg = rect.right - rect.left; + ht = rect.bottom - rect.top; + + hdc = BeginPaint(hwnd, &ps); + + mem_dc = CreateCompatibleDC(hdc); + mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); + SelectObject(mem_dc, mem_bmp); + + FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + if(win->pal) + { + u32 i, num2, num, y, x; + + u8* mem; + if(win->target >= ARM9MEM_LCDC) + mem = ARM9Mem.ARM9_LCD + win->target - ARM9MEM_LCDC; + else + mem = MMU_RenderMapToLCD(win->target); + if(mem) + { + for(num2 = 0; num2<32; ++num2) + for(num = 0; num<32; ++num) + for(y = 0; y<8; ++y) + for(x = 0; x<8; ++x) + bitmap[x + (y*256) + (num*8) +(num2*256*8)] = pal[mem[x + (y*8) + (num*64) +(num2*2048)]]; + SetDIBitsToDevice(mem_dc, 0, 0, 256, 256, 0, 0, 0, 256, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + } + sprintf(text, "Pal : %d", win->palnum); + SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), text); + } + else + TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23); + + BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); + + DeleteDC(mem_dc); + DeleteObject(mem_bmp); + + EndPaint(hwnd, &ps); + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT TileViewBox_Pal16(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; +// SIZE fontsize; + TCHAR text[80]; + u16 bitmap[512*512]; + u16 * pal = ((u16 *)win->pal) + win->palnum*16; + BITMAPV4HEADER bmi; + RECT rect; + int lg; + int ht; + HDC mem_dc; + HBITMAP mem_bmp; + + memset(&bmi, 0, sizeof(bmi)); + bmi.bV4Size = sizeof(bmi); + bmi.bV4Planes = 1; + bmi.bV4BitCount = 16; + bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS; + bmi.bV4RedMask = 0x001F; + bmi.bV4GreenMask = 0x03E0; + bmi.bV4BlueMask = 0x7C00; + bmi.bV4Width = 512; + bmi.bV4Height = -256; + + GetClientRect(hwnd, &rect); + lg = rect.right - rect.left; + ht = rect.bottom - rect.top; + + hdc = BeginPaint(hwnd, &ps); + + mem_dc = CreateCompatibleDC(hdc); + mem_bmp = CreateCompatibleBitmap(hdc, 512, 256); + SelectObject(mem_dc, mem_bmp); + + FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + if(win->pal) + { + u8* mem; + if(win->target >= ARM9MEM_LCDC) + mem = ARM9Mem.ARM9_LCD + win->target - ARM9MEM_LCDC; + else + mem = MMU_RenderMapToLCD(win->target); + + if(mem) + { + u32 num2, num, y, x; + for(num2 = 0; num2<32; ++num2) + for(num = 0; num<64; ++num) + for(y = 0; y<8; ++y) + for(x = 0; x<4; ++x) + { + bitmap[(x<<1) + (y*512) + (num*8) +(num2*512*8)] = pal[mem[x + (y*4) + (num*32) +(num2*2048)]&0xF]; + bitmap[(x<<1)+1 + (y*512) + (num*8) +(num2*512*8)] = pal[mem[x + (y*4) + (num*32) +(num2*2048)]>>4]; + } + SetDIBitsToDevice(mem_dc, 0, 0, 512, 256, 0, 0, 0, 256, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + } + sprintf(text, "Pal : %d", win->palnum); + SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), text); + } + else + TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23); + + BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); + + DeleteDC(mem_dc); + DeleteObject(mem_bmp); + + EndPaint(hwnd, &ps); + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT CALLBACK TileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_INITDIALOG: + return 1; + case WM_NCCREATE: + return 1; + case WM_NCDESTROY: + return 1; + case WM_PAINT: + switch(TileView->coul) + { + case 0 : + TileViewBox_Direct(hwnd, TileView, wParam, lParam); + break; + case 1 : + TileViewBox_Pal256(hwnd, TileView, wParam, lParam); + break; + case 2 : + TileViewBox_Pal16(hwnd, TileView, wParam, lParam); + break; + } + break; + case WM_LBUTTONDOWN : + switch(TileView->coul) + { + case 0 : + case 1 : + if(LOWORD(lParam)<(32*8)) + { + TileView->x = ((LOWORD(lParam)>>3)<<3); + TileView->y = (HIWORD(lParam)>>3)<<3; + TileView->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*32; + } + break; + case 2 : + TileView->x = ((LOWORD(lParam)>>3)<<3); + TileView->y = (HIWORD(lParam)>>3)<<3; + TileView->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*64; + break; + } + InvalidateRect(GetDlgItem(hwnd, IDC_MINI_TILE), NULL, FALSE); + return 1; + case WM_ERASEBKGND: + return 1; + } + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +LRESULT MiniTileViewBox_Paint(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) +{ + HWND hwnd_src = GetDlgItem(GetParent(hwnd), IDC_Tile_BOX); + HDC hdc_src; + HDC hdc_dst; + char txt[80]; + + PAINTSTRUCT ps; + + hdc_dst = BeginPaint(hwnd, &ps); + hdc_src = GetDC(hwnd_src); + StretchBlt(hdc_dst, 0, 0, 80, 80, hdc_src, win->x, win->y, 8, 8, SRCCOPY); + sprintf(txt, "Tile num : 0x%X", win->tilenum); + SetWindowText(GetDlgItem(win->hwnd, IDC_TILENUM), txt); + EndPaint(hwnd, &ps); + return 0; +} + +LRESULT CALLBACK MiniTileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_NCCREATE: + return 1; + case WM_NCDESTROY: + return 1; + case WM_PAINT : + MiniTileViewBox_Paint(hwnd, TileView, wParam, lParam); + break; + case WM_ERASEBKGND: + return 1; + default: + break; + } + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +BOOL CALLBACK ViewTilesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + //bail out early if the dialog isnt initialized + if(!TileView && message != WM_INITDIALOG) + return false; + + switch (message) + { + case WM_INITDIALOG : + { + TileView = new tileview_struct; + memset(TileView, 0, sizeof(tileview_struct)); + TileView->hwnd = hwnd; + TileView->target = ARM9MEM_ABG; + TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM); + TileView->autoup_secs = 1; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, TileView->autoup_secs); + + HWND combo = GetDlgItem(hwnd, IDC_PAL_SELECT); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen BG PAL"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen BG PAL"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen SPR PAL"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen SPR PAL"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 3"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 3"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 3"); + SendMessage(combo, CB_SETCURSEL, 0, 0); + + combo = GetDlgItem(hwnd, IDC_MEM_SELECT); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6000000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6010000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6020000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6030000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6040000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6050000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6060000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6070000"); + + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-BG - 0x6200000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-BG - 0x6210000"); + + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6400000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6410000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6420000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6430000"); + + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-OBJ- 0x6600000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-OBJ- 0x6610000"); + + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6800000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6810000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6820000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6830000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6840000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6850000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6860000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6870000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6880000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6890000"); + SendMessage(combo, CB_SETCURSEL, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_BITMAP), BM_SETCHECK, TRUE, 0); + } + return 1; + case WM_CLOSE : + if(TileView->autoup) + { + KillTimer(hwnd, IDT_VIEW_TILE); + TileView->autoup = false; + } + if (TileView!=NULL) + { + delete TileView; + TileView = NULL; + } + //INFO("Close Tile view dialog\n"); + PostQuitMessage(0); + return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; + case WM_HSCROLL : + switch LOWORD(wParam) + { + case SB_LINERIGHT : + ++(TileView->palnum); + if(TileView->palnum>15) + TileView->palnum = 15; + break; + case SB_LINELEFT : + --(TileView->palnum); + if(TileView->palnum<0) + TileView->palnum = 0; + break; + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case WM_COMMAND : + switch (LOWORD (wParam)) + { + case IDC_FERMER : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 1; + case IDC_AUTO_UPDATE : + if(TileView->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_TILE); + TileView->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + TileView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_TILE, TileView->autoup_secs*20, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (!TileView) + { + SendMessage(hwnd, WM_INITDIALOG, 0, 0); + } + if (t != TileView->autoup_secs) + { + TileView->autoup_secs = t; + if (TileView->autoup) + SetTimer(hwnd, IDT_VIEW_TILE, + TileView->autoup_secs*20, (TIMERPROC) NULL); + } + } + return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_BITMAP : + TileView->coul = 0; + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_256COUL : + TileView->coul = 1; + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_16COUL : + TileView->coul = 2; + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_MEM_SELECT : + switch(HIWORD(wParam)) + { + case CBN_SELCHANGE : + case CBN_CLOSEUP : + { + u32 sel = SendMessage(GetDlgItem(hwnd, IDC_MEM_SELECT), CB_GETCURSEL, 0, 0); + switch(sel) + { + case 0 : + case 1 : + case 2 : + case 3 : + case 4 : + case 5 : + case 6 : + case 7 : + TileView->target = ARM9MEM_ABG + 0x10000*sel; + break; + case 8 : + case 9 : + TileView->target = ARM9MEM_BBG + 0x10000*(sel-8); + break; + case 10 : + case 11 : + case 12 : + case 13 : + TileView->target = ARM9MEM_AOBJ + 0x10000*(sel-10); + break; + case 14 : + case 15 : + TileView->target = ARM9MEM_BOBJ + 0x10000*(sel-14); + break; + case 16 : + case 17 : + case 18 : + case 19 : + case 20 : + case 21 : + case 22 : + case 23 : + case 24 : + case 25 : + TileView->target = ARM9MEM_LCDC + 0x10000*(sel-16); + break; + default : + return 1; + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + } + } + return 1; + case IDC_PAL_SELECT : + switch(HIWORD(wParam)) + { + case CBN_SELCHANGE : + case CBN_CLOSEUP : + { + u32 sel = SendMessage(GetDlgItem(hwnd, IDC_PAL_SELECT), CB_GETCURSEL, 0, 0); + switch(sel) + { + case 0 : + TileView->pal = (u16 *)ARM9Mem.ARM9_VMEM; + TileView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); + break; + case 1 : + TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x200; + TileView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); + break; + case 2 : + TileView->pal = (u16 *)ARM9Mem.ARM9_VMEM + 0x100; + TileView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); + break; + case 3 : + TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300; + TileView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); + break; + case 4 : + case 5 : + case 6 : + case 7 : + TileView->pal = ((u16 *)(ARM9Mem.ExtPal[0][sel-4])); + TileView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_HIDE); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), FALSE); + if(TileView->coul == 2) + { + SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); + SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); + TileView->coul = 1; + } + break; + case 8 : + case 9 : + case 10 : + case 11 : + TileView->pal = ((u16 *)(ARM9Mem.ExtPal[1][sel-8])); + TileView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_HIDE); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), FALSE); + if(TileView->coul == 2) + { + SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); + SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); + TileView->coul = 1; + } + break; + case 12 : + case 13 : + TileView->pal = ((u16 *)(ARM9Mem.ObjExtPal[0][sel-12])); + TileView->palnum = 0; + if(TileView->coul == 2) + { + SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); + SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); + TileView->coul = 1; + } + break; + case 14 : + case 15 : + TileView->pal = ((u16 *)(ARM9Mem.ObjExtPal[1][sel-14])); + TileView->palnum = 0; + if(TileView->coul == 2) + { + SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); + SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); + TileView->coul = 1; + } + break; + case 16 : + case 17 : + case 18 : + case 19 : + TileView->pal = ((u16 *)(ARM9Mem.texInfo.texPalSlot[sel-16])); + TileView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); + break; + default : + return 1; + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + } + } + } + return 0; + } + return FALSE; +} diff --git a/desmume/src/windows/tileView.h b/src/windows/tileView.h similarity index 97% rename from desmume/src/windows/tileView.h rename to src/windows/tileView.h index 2a53ba6eb..f8be7e555 100644 --- a/desmume/src/windows/tileView.h +++ b/src/windows/tileView.h @@ -1,32 +1,32 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#ifndef TILEVIEW_H -#define TILEVIEW_H - -#include "../common.h" -#include - -extern LRESULT CALLBACK TileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -extern LRESULT CALLBACK MiniTileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -extern BOOL CALLBACK ViewTilesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - -#endif +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef TILEVIEW_H +#define TILEVIEW_H + +#include "../common.h" +#include + +extern LRESULT CALLBACK TileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +extern LRESULT CALLBACK MiniTileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +extern BOOL CALLBACK ViewTilesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); + +#endif diff --git a/desmume/src/windows/userconfig/readme.txt b/src/windows/userconfig/readme.txt similarity index 100% rename from desmume/src/windows/userconfig/readme.txt rename to src/windows/userconfig/readme.txt diff --git a/desmume/src/windows/video.h b/src/windows/video.h similarity index 100% rename from desmume/src/windows/video.h rename to src/windows/video.h diff --git a/desmume/src/windows/windriver.h b/src/windows/windriver.h similarity index 93% rename from desmume/src/windows/windriver.h rename to src/windows/windriver.h index ffa427029..3299f2d84 100644 --- a/desmume/src/windows/windriver.h +++ b/src/windows/windriver.h @@ -1,58 +1,55 @@ -/* windriver.h - - Copyright (C) 2008-2009 DeSmuME team - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef _WINDRIVER_H_ -#define _WINDRIVER_H_ - -#define WIN32_LEAN_AND_MEAN -#include "../common.h" -#include "CWindow.h" - -#ifdef EXPERIMENTAL_WIFI -#include -#include //uh? - -//because the pcap headers are written poorly, we need to declare these as cdecl -//this may cause the code to fail to compile on non-windows platforms; -//we may have to use a macro to call these functions which chooses whether to call them -//through the namespace -namespace PCAP { - extern "C" __declspec(dllexport) int __cdecl pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf); - extern "C" __declspec(dllexport) int __cdecl pcap_sendpacket(pcap_t *, const u_char *, int); - extern "C" __declspec(dllexport) void __cdecl pcap_close(pcap_t *); - extern "C" __declspec(dllexport) pcap_t* __cdecl pcap_open(const char *source, int snaplen, int flags, int read_timeout, struct pcap_rmtauth *auth, char *errbuf); - extern "C" __declspec(dllexport) void __cdecl pcap_freealldevs(pcap_if_t *); -} - -#endif - -extern WINCLASS *MainWindow; - -class Lock { -public: - Lock(); // defaults to the critical section around NDS_exec - Lock(CRITICAL_SECTION& cs); - ~Lock(); -private: - CRITICAL_SECTION* m_cs; -}; - +/* windriver.h + + Copyright (C) 2008-2009 DeSmuME team + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _WINDRIVER_H_ +#define _WINDRIVER_H_ + +#define WIN32_LEAN_AND_MEAN +#include "../common.h" +#include "CWindow.h" + +#ifdef EXPERIMENTAL_WIFI +#include +#include //uh? + +//because the pcap headers are written poorly, we need to declare these as cdecl +//this may cause the code to fail to compile on non-windows platforms; +//we may have to use a macro to call these functions which chooses whether to call them +//through the namespace +namespace PCAP { + extern "C" __declspec(dllexport) int __cdecl pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf); + extern "C" __declspec(dllexport) int __cdecl pcap_sendpacket(pcap_t *, const u_char *, int); + extern "C" __declspec(dllexport) void __cdecl pcap_close(pcap_t *); + extern "C" __declspec(dllexport) pcap_t* __cdecl pcap_open(const char *source, int snaplen, int flags, int read_timeout, struct pcap_rmtauth *auth, char *errbuf); + extern "C" __declspec(dllexport) void __cdecl pcap_freealldevs(pcap_if_t *); +} + +#endif + +extern WINCLASS *MainWindow; + +class Lock { +public: + Lock(); + ~Lock(); +}; + #endif \ No newline at end of file diff --git a/desmume/src/windows/winpcap/Devioctl.h b/src/windows/winpcap/Devioctl.h similarity index 97% rename from desmume/src/windows/winpcap/Devioctl.h rename to src/windows/winpcap/Devioctl.h index 661fda029..af8784bfd 100644 --- a/desmume/src/windows/winpcap/Devioctl.h +++ b/src/windows/winpcap/Devioctl.h @@ -1,90 +1,90 @@ -/*++ BUILD Version: 0004 // Increment this if a change has global effects - Copyright (c) 1992-1993 Microsoft Corporation - Module Name: - devioctl.h - Revision History: - -- */ -// begin_winioctl -#ifndef _DEVIOCTL_ -#define _DEVIOCTL_ -// begin_ntddk begin_nthal begin_ntifs -// -// Define the various device type values. Note that values used by Microsoft -// Corporation are in the range 0-32767, and 32768-65535 are reserved for use -// by customers. -// -#define DEVICE_TYPE ULONG -#define FILE_DEVICE_BEEP 0x00000001 -#define FILE_DEVICE_CD_ROM 0x00000002 -#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 -#define FILE_DEVICE_CONTROLLER 0x00000004 -#define FILE_DEVICE_DATALINK 0x00000005 -#define FILE_DEVICE_DFS 0x00000006 -#define FILE_DEVICE_DISK 0x00000007 -#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 -#define FILE_DEVICE_FILE_SYSTEM 0x00000009 -#define FILE_DEVICE_INPORT_PORT 0x0000000a -#define FILE_DEVICE_KEYBOARD 0x0000000b -#define FILE_DEVICE_MAILSLOT 0x0000000c -#define FILE_DEVICE_MIDI_IN 0x0000000d -#define FILE_DEVICE_MIDI_OUT 0x0000000e -#define FILE_DEVICE_MOUSE 0x0000000f -#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010 -#define FILE_DEVICE_NAMED_PIPE 0x00000011 -#define FILE_DEVICE_NETWORK 0x00000012 -#define FILE_DEVICE_NETWORK_BROWSER 0x00000013 -#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 -#define FILE_DEVICE_NULL 0x00000015 -#define FILE_DEVICE_PARALLEL_PORT 0x00000016 -#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017 -#define FILE_DEVICE_PRINTER 0x00000018 -#define FILE_DEVICE_SCANNER 0x00000019 -#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a -#define FILE_DEVICE_SERIAL_PORT 0x0000001b -#define FILE_DEVICE_SCREEN 0x0000001c -#define FILE_DEVICE_SOUND 0x0000001d -#define FILE_DEVICE_STREAMS 0x0000001e -#define FILE_DEVICE_TAPE 0x0000001f -#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 -#define FILE_DEVICE_TRANSPORT 0x00000021 -#define FILE_DEVICE_UNKNOWN 0x00000022 -#define FILE_DEVICE_VIDEO 0x00000023 -#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 -#define FILE_DEVICE_WAVE_IN 0x00000025 -#define FILE_DEVICE_WAVE_OUT 0x00000026 -#define FILE_DEVICE_8042_PORT 0x00000027 -#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 -#define FILE_DEVICE_BATTERY 0x00000029 -#define FILE_DEVICE_BUS_EXTENDER 0x0000002a -#define FILE_DEVICE_MODEM 0x0000002b -#define FILE_DEVICE_VDM 0x0000002c -#define FILE_DEVICE_MASS_STORAGE 0x0000002d -// -// Macro definition for defining IOCTL and FSCTL function control codes. Note -// that function codes 0-2047 are reserved for Microsoft Corporation, and -// 2048-4095 are reserved for customers. -// -#define CTL_CODE( DeviceType, Function, Method, Access ) ( \ - ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \ -) -// -// Define the method codes for how buffers are passed for I/O and FS controls -// -#define METHOD_BUFFERED 0 -#define METHOD_IN_DIRECT 1 -#define METHOD_OUT_DIRECT 2 -#define METHOD_NEITHER 3 -// -// Define the access check value for any access -// -// -// The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in -// ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these -// constants *MUST* always be in sync. -// -#define FILE_ANY_ACCESS 0 -#define FILE_READ_ACCESS ( 0x0001 ) // file & pipe -#define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe -// end_ntddk end_nthal end_ntifs -#endif // _DEVIOCTL_ -// end_winioctl +/*++ BUILD Version: 0004 // Increment this if a change has global effects + Copyright (c) 1992-1993 Microsoft Corporation + Module Name: + devioctl.h + Revision History: + -- */ +// begin_winioctl +#ifndef _DEVIOCTL_ +#define _DEVIOCTL_ +// begin_ntddk begin_nthal begin_ntifs +// +// Define the various device type values. Note that values used by Microsoft +// Corporation are in the range 0-32767, and 32768-65535 are reserved for use +// by customers. +// +#define DEVICE_TYPE ULONG +#define FILE_DEVICE_BEEP 0x00000001 +#define FILE_DEVICE_CD_ROM 0x00000002 +#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 +#define FILE_DEVICE_CONTROLLER 0x00000004 +#define FILE_DEVICE_DATALINK 0x00000005 +#define FILE_DEVICE_DFS 0x00000006 +#define FILE_DEVICE_DISK 0x00000007 +#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 +#define FILE_DEVICE_FILE_SYSTEM 0x00000009 +#define FILE_DEVICE_INPORT_PORT 0x0000000a +#define FILE_DEVICE_KEYBOARD 0x0000000b +#define FILE_DEVICE_MAILSLOT 0x0000000c +#define FILE_DEVICE_MIDI_IN 0x0000000d +#define FILE_DEVICE_MIDI_OUT 0x0000000e +#define FILE_DEVICE_MOUSE 0x0000000f +#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010 +#define FILE_DEVICE_NAMED_PIPE 0x00000011 +#define FILE_DEVICE_NETWORK 0x00000012 +#define FILE_DEVICE_NETWORK_BROWSER 0x00000013 +#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 +#define FILE_DEVICE_NULL 0x00000015 +#define FILE_DEVICE_PARALLEL_PORT 0x00000016 +#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017 +#define FILE_DEVICE_PRINTER 0x00000018 +#define FILE_DEVICE_SCANNER 0x00000019 +#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a +#define FILE_DEVICE_SERIAL_PORT 0x0000001b +#define FILE_DEVICE_SCREEN 0x0000001c +#define FILE_DEVICE_SOUND 0x0000001d +#define FILE_DEVICE_STREAMS 0x0000001e +#define FILE_DEVICE_TAPE 0x0000001f +#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 +#define FILE_DEVICE_TRANSPORT 0x00000021 +#define FILE_DEVICE_UNKNOWN 0x00000022 +#define FILE_DEVICE_VIDEO 0x00000023 +#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 +#define FILE_DEVICE_WAVE_IN 0x00000025 +#define FILE_DEVICE_WAVE_OUT 0x00000026 +#define FILE_DEVICE_8042_PORT 0x00000027 +#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 +#define FILE_DEVICE_BATTERY 0x00000029 +#define FILE_DEVICE_BUS_EXTENDER 0x0000002a +#define FILE_DEVICE_MODEM 0x0000002b +#define FILE_DEVICE_VDM 0x0000002c +#define FILE_DEVICE_MASS_STORAGE 0x0000002d +// +// Macro definition for defining IOCTL and FSCTL function control codes. Note +// that function codes 0-2047 are reserved for Microsoft Corporation, and +// 2048-4095 are reserved for customers. +// +#define CTL_CODE( DeviceType, Function, Method, Access ) ( \ + ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \ +) +// +// Define the method codes for how buffers are passed for I/O and FS controls +// +#define METHOD_BUFFERED 0 +#define METHOD_IN_DIRECT 1 +#define METHOD_OUT_DIRECT 2 +#define METHOD_NEITHER 3 +// +// Define the access check value for any access +// +// +// The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in +// ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these +// constants *MUST* always be in sync. +// +#define FILE_ANY_ACCESS 0 +#define FILE_READ_ACCESS ( 0x0001 ) // file & pipe +#define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe +// end_ntddk end_nthal end_ntifs +#endif // _DEVIOCTL_ +// end_winioctl diff --git a/desmume/src/windows/winpcap/Gnuc.h b/src/windows/winpcap/Gnuc.h similarity index 94% rename from desmume/src/windows/winpcap/Gnuc.h rename to src/windows/winpcap/Gnuc.h index b05890f9e..b7cfb59c7 100644 --- a/desmume/src/windows/winpcap/Gnuc.h +++ b/src/windows/winpcap/Gnuc.h @@ -1,46 +1,46 @@ -/* @(#) $Header: /tcpdump/master/libpcap/Win32/Include/Gnuc.h,v 1.1 2002/08/01 08:33:05 risso Exp $ (LBL) */ - -/* Define __P() macro, if necessary */ - -#ifndef __P -#if __STDC__ -#define __P(protos) protos -#else -#define __P(protos) () -#endif -#endif - -/* inline foo */ -#ifndef __cplusplus -#ifdef __GNUC__ -#define inline __inline -#else -#define inline -#endif -#endif - -/* - * Handle new and old "dead" routine prototypes - * - * For example: - * - * __dead void foo(void) __attribute__((volatile)); - * - */ -#ifdef __GNUC__ -#ifndef __dead -#define __dead volatile -#endif -#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) -#ifndef __attribute__ -#define __attribute__(args) -#endif -#endif -#else -#ifndef __dead -#define __dead -#endif -#ifndef __attribute__ -#define __attribute__(args) -#endif -#endif +/* @(#) $Header: /tcpdump/master/libpcap/Win32/Include/Gnuc.h,v 1.1 2002/08/01 08:33:05 risso Exp $ (LBL) */ + +/* Define __P() macro, if necessary */ + +#ifndef __P +#if __STDC__ +#define __P(protos) protos +#else +#define __P(protos) () +#endif +#endif + +/* inline foo */ +#ifndef __cplusplus +#ifdef __GNUC__ +#define inline __inline +#else +#define inline +#endif +#endif + +/* + * Handle new and old "dead" routine prototypes + * + * For example: + * + * __dead void foo(void) __attribute__((volatile)); + * + */ +#ifdef __GNUC__ +#ifndef __dead +#define __dead volatile +#endif +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +#ifndef __attribute__ +#define __attribute__(args) +#endif +#endif +#else +#ifndef __dead +#define __dead +#endif +#ifndef __attribute__ +#define __attribute__(args) +#endif +#endif diff --git a/desmume/src/windows/winpcap/Ntddndis.h b/src/windows/winpcap/Ntddndis.h similarity index 97% rename from desmume/src/windows/winpcap/Ntddndis.h rename to src/windows/winpcap/Ntddndis.h index 77a53d7af..0b6298069 100644 --- a/desmume/src/windows/winpcap/Ntddndis.h +++ b/src/windows/winpcap/Ntddndis.h @@ -1,1400 +1,1400 @@ -/*++ BUILD Version: 0001 // Increment this if a change has global effects - Copyright (c) 1990-1993 Microsoft Corporation - Module Name: - ntddndis.h - Abstract: - This is the include file that defines all constants and types for - accessing the Network driver interface device. - Author: - Steve Wood (stevewo) 27-May-1990 - Revision History: - Adam Barr (adamba) 04-Nov-1992 added the correct values for NDIS 3.0. - Jameel Hyder (jameelh) 01-Aug-95 added Pnp IoCTLs and structures - Kyle Brandon (kyleb) 09/24/96 added general co ndis oids. - -- */ -#ifndef _NTDDNDIS_ -#define _NTDDNDIS_ -// -// Device Name - this string is the name of the device. It is the name -// that should be passed to NtOpenFile when accessing the device. -// -// Note: For devices that support multiple units, it should be suffixed -// with the Ascii representation of the unit number. -// -#define DD_NDIS_DEVICE_NAME "\\Device\\UNKNOWN" -// -// NtDeviceIoControlFile IoControlCode values for this device. -// -// Warning: Remember that the low two bits of the code specify how the -// buffers are passed to the driver! -// -#define _NDIS_CONTROL_CODE(request,method) \ - CTL_CODE(FILE_DEVICE_PHYSICAL_NETCARD, request, method, FILE_ANY_ACCESS) -#define IOCTL_NDIS_QUERY_GLOBAL_STATS _NDIS_CONTROL_CODE( 0, METHOD_OUT_DIRECT ) -#define IOCTL_NDIS_QUERY_ALL_STATS _NDIS_CONTROL_CODE( 1, METHOD_OUT_DIRECT ) -#define IOCTL_NDIS_ADD_DEVICE _NDIS_CONTROL_CODE( 2, METHOD_BUFFERED ) -#define IOCTL_NDIS_DELETE_DEVICE _NDIS_CONTROL_CODE( 3, METHOD_BUFFERED ) -#define IOCTL_NDIS_TRANSLATE_NAME _NDIS_CONTROL_CODE( 4, METHOD_BUFFERED ) -#define IOCTL_NDIS_ADD_TDI_DEVICE _NDIS_CONTROL_CODE( 5, METHOD_BUFFERED ) -#define IOCTL_NDIS_NOTIFY_PROTOCOL _NDIS_CONTROL_CODE( 6, METHOD_BUFFERED ) -#define IOCTL_NDIS_GET_LOG_DATA _NDIS_CONTROL_CODE( 7, METHOD_OUT_DIRECT ) -// -// NtDeviceIoControlFile InputBuffer/OutputBuffer record structures for -// this device. -// -// -// This is the type of an NDIS OID value. -// -typedef ULONG NDIS_OID, *PNDIS_OID; -// -// IOCTL_NDIS_QUERY_ALL_STATS returns a sequence of these, packed -// together (no padding is required since statistics all have -// four or eight bytes of data). -// -typedef struct _NDIS_STATISTICS_VALUE { - NDIS_OID Oid; - ULONG DataLength; - UCHAR Data[1]; // variable length - -} NDIS_STATISTICS_VALUE, *PNDIS_STATISTICS_VALUE; - -// -// Structure used by TRANSLATE_NAME IOCTL -// -typedef struct _NET_PNP_ID { - ULONG ClassId; - ULONG Token; -} NET_PNP_ID, *PNET_PNP_ID; - -typedef struct _NET_PNP_TRANSLATE_LIST { - ULONG BytesNeeded; - NET_PNP_ID IdArray[ANYSIZE_ARRAY]; -} NET_PNP_TRANSLATE_LIST, *PNET_PNP_TRANSLATE_LIST; - -// -// Structure used to define a self-contained variable data structure -// -typedef struct _NDIS_VAR_DATA_DESC { - USHORT Length; // # of octects of data - - USHORT MaximumLength; // # of octects available - - LONG Offset; // Offset of data relative to the descriptor - -} NDIS_VAR_DATA_DESC, *PNDIS_VAR_DATA_DESC; - -// -// Object Identifiers used by NdisRequest Query/Set Information -// -// -// General Objects -// -#define OID_GEN_SUPPORTED_LIST 0x00010101 -#define OID_GEN_HARDWARE_STATUS 0x00010102 -#define OID_GEN_MEDIA_SUPPORTED 0x00010103 -#define OID_GEN_MEDIA_IN_USE 0x00010104 -#define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105 -#define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106 -#define OID_GEN_LINK_SPEED 0x00010107 -#define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108 -#define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109 -#define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A -#define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B -#define OID_GEN_VENDOR_ID 0x0001010C -#define OID_GEN_VENDOR_DESCRIPTION 0x0001010D -#define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E -#define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F -#define OID_GEN_DRIVER_VERSION 0x00010110 -#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111 -#define OID_GEN_PROTOCOL_OPTIONS 0x00010112 -#define OID_GEN_MAC_OPTIONS 0x00010113 -#define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114 -#define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115 -#define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116 -#define OID_GEN_XMIT_OK 0x00020101 -#define OID_GEN_RCV_OK 0x00020102 -#define OID_GEN_XMIT_ERROR 0x00020103 -#define OID_GEN_RCV_ERROR 0x00020104 -#define OID_GEN_RCV_NO_BUFFER 0x00020105 -#define OID_GEN_DIRECTED_BYTES_XMIT 0x00020201 -#define OID_GEN_DIRECTED_FRAMES_XMIT 0x00020202 -#define OID_GEN_MULTICAST_BYTES_XMIT 0x00020203 -#define OID_GEN_MULTICAST_FRAMES_XMIT 0x00020204 -#define OID_GEN_BROADCAST_BYTES_XMIT 0x00020205 -#define OID_GEN_BROADCAST_FRAMES_XMIT 0x00020206 -#define OID_GEN_DIRECTED_BYTES_RCV 0x00020207 -#define OID_GEN_DIRECTED_FRAMES_RCV 0x00020208 -#define OID_GEN_MULTICAST_BYTES_RCV 0x00020209 -#define OID_GEN_MULTICAST_FRAMES_RCV 0x0002020A -#define OID_GEN_BROADCAST_BYTES_RCV 0x0002020B -#define OID_GEN_BROADCAST_FRAMES_RCV 0x0002020C -#define OID_GEN_RCV_CRC_ERROR 0x0002020D -#define OID_GEN_TRANSMIT_QUEUE_LENGTH 0x0002020E -#define OID_GEN_GET_TIME_CAPS 0x0002020F -#define OID_GEN_GET_NETCARD_TIME 0x00020210 -// -// These are connection-oriented general OIDs. -// These replace the above OIDs for connection-oriented media. -// -#define OID_GEN_CO_SUPPORTED_LIST 0x00010101 -#define OID_GEN_CO_HARDWARE_STATUS 0x00010102 -#define OID_GEN_CO_MEDIA_SUPPORTED 0x00010103 -#define OID_GEN_CO_MEDIA_IN_USE 0x00010104 -#define OID_GEN_CO_LINK_SPEED 0x00010105 -#define OID_GEN_CO_VENDOR_ID 0x00010106 -#define OID_GEN_CO_VENDOR_DESCRIPTION 0x00010107 -#define OID_GEN_CO_DRIVER_VERSION 0x00010108 -#define OID_GEN_CO_PROTOCOL_OPTIONS 0x00010109 -#define OID_GEN_CO_MAC_OPTIONS 0x0001010A -#define OID_GEN_CO_MEDIA_CONNECT_STATUS 0x0001010B -#define OID_GEN_CO_VENDOR_DRIVER_VERSION 0x0001010C -#define OID_GEN_CO_MINIMUM_LINK_SPEED 0x0001010D -#define OID_GEN_CO_GET_TIME_CAPS 0x00010201 -#define OID_GEN_CO_GET_NETCARD_TIME 0x00010202 -// -// These are connection-oriented statistics OIDs. -// -#define OID_GEN_CO_XMIT_PDUS_OK 0x00020101 -#define OID_GEN_CO_RCV_PDUS_OK 0x00020102 -#define OID_GEN_CO_XMIT_PDUS_ERROR 0x00020103 -#define OID_GEN_CO_RCV_PDUS_ERROR 0x00020104 -#define OID_GEN_CO_RCV_PDUS_NO_BUFFER 0x00020105 -#define OID_GEN_CO_RCV_CRC_ERROR 0x00020201 -#define OID_GEN_CO_TRANSMIT_QUEUE_LENGTH 0x00020202 -#define OID_GEN_CO_BYTES_XMIT 0x00020203 -#define OID_GEN_CO_BYTES_RCV 0x00020204 -#define OID_GEN_CO_BYTES_XMIT_OUTSTANDING 0x00020205 -#define OID_GEN_CO_NETCARD_LOAD 0x00020206 -// -// These are objects for Connection-oriented media call-managers and are not -// valid for ndis drivers. Under construction. -// -#define OID_CO_ADD_PVC 0xFF000001 -#define OID_CO_DELETE_PVC 0xFF000002 -#define OID_CO_GET_CALL_INFORMATION 0xFF000003 -#define OID_CO_ADD_ADDRESS 0xFF000004 -#define OID_CO_DELETE_ADDRESS 0xFF000005 -#define OID_CO_GET_ADDRESSES 0xFF000006 -#define OID_CO_ADDRESS_CHANGE 0xFF000007 -#define OID_CO_SIGNALING_ENABLED 0xFF000008 -#define OID_CO_SIGNALING_DISABLED 0xFF000009 -// -// 802.3 Objects (Ethernet) -// -#define OID_802_3_PERMANENT_ADDRESS 0x01010101 -#define OID_802_3_CURRENT_ADDRESS 0x01010102 -#define OID_802_3_MULTICAST_LIST 0x01010103 -#define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104 -#define OID_802_3_MAC_OPTIONS 0x01010105 -// -// -#define NDIS_802_3_MAC_OPTION_PRIORITY 0x00000001 -#define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101 -#define OID_802_3_XMIT_ONE_COLLISION 0x01020102 -#define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103 -#define OID_802_3_XMIT_DEFERRED 0x01020201 -#define OID_802_3_XMIT_MAX_COLLISIONS 0x01020202 -#define OID_802_3_RCV_OVERRUN 0x01020203 -#define OID_802_3_XMIT_UNDERRUN 0x01020204 -#define OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205 -#define OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206 -#define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 -// -// 802.5 Objects (Token-Ring) -// -#define OID_802_5_PERMANENT_ADDRESS 0x02010101 -#define OID_802_5_CURRENT_ADDRESS 0x02010102 -#define OID_802_5_CURRENT_FUNCTIONAL 0x02010103 -#define OID_802_5_CURRENT_GROUP 0x02010104 -#define OID_802_5_LAST_OPEN_STATUS 0x02010105 -#define OID_802_5_CURRENT_RING_STATUS 0x02010106 -#define OID_802_5_CURRENT_RING_STATE 0x02010107 -#define OID_802_5_LINE_ERRORS 0x02020101 -#define OID_802_5_LOST_FRAMES 0x02020102 -#define OID_802_5_BURST_ERRORS 0x02020201 -#define OID_802_5_AC_ERRORS 0x02020202 -#define OID_802_5_ABORT_DELIMETERS 0x02020203 -#define OID_802_5_FRAME_COPIED_ERRORS 0x02020204 -#define OID_802_5_FREQUENCY_ERRORS 0x02020205 -#define OID_802_5_TOKEN_ERRORS 0x02020206 -#define OID_802_5_INTERNAL_ERRORS 0x02020207 -// -// FDDI Objects -// -#define OID_FDDI_LONG_PERMANENT_ADDR 0x03010101 -#define OID_FDDI_LONG_CURRENT_ADDR 0x03010102 -#define OID_FDDI_LONG_MULTICAST_LIST 0x03010103 -#define OID_FDDI_LONG_MAX_LIST_SIZE 0x03010104 -#define OID_FDDI_SHORT_PERMANENT_ADDR 0x03010105 -#define OID_FDDI_SHORT_CURRENT_ADDR 0x03010106 -#define OID_FDDI_SHORT_MULTICAST_LIST 0x03010107 -#define OID_FDDI_SHORT_MAX_LIST_SIZE 0x03010108 -#define OID_FDDI_ATTACHMENT_TYPE 0x03020101 -#define OID_FDDI_UPSTREAM_NODE_LONG 0x03020102 -#define OID_FDDI_DOWNSTREAM_NODE_LONG 0x03020103 -#define OID_FDDI_FRAME_ERRORS 0x03020104 -#define OID_FDDI_FRAMES_LOST 0x03020105 -#define OID_FDDI_RING_MGT_STATE 0x03020106 -#define OID_FDDI_LCT_FAILURES 0x03020107 -#define OID_FDDI_LEM_REJECTS 0x03020108 -#define OID_FDDI_LCONNECTION_STATE 0x03020109 -#define OID_FDDI_SMT_STATION_ID 0x03030201 -#define OID_FDDI_SMT_OP_VERSION_ID 0x03030202 -#define OID_FDDI_SMT_HI_VERSION_ID 0x03030203 -#define OID_FDDI_SMT_LO_VERSION_ID 0x03030204 -#define OID_FDDI_SMT_MANUFACTURER_DATA 0x03030205 -#define OID_FDDI_SMT_USER_DATA 0x03030206 -#define OID_FDDI_SMT_MIB_VERSION_ID 0x03030207 -#define OID_FDDI_SMT_MAC_CT 0x03030208 -#define OID_FDDI_SMT_NON_MASTER_CT 0x03030209 -#define OID_FDDI_SMT_MASTER_CT 0x0303020A -#define OID_FDDI_SMT_AVAILABLE_PATHS 0x0303020B -#define OID_FDDI_SMT_CONFIG_CAPABILITIES 0x0303020C -#define OID_FDDI_SMT_CONFIG_POLICY 0x0303020D -#define OID_FDDI_SMT_CONNECTION_POLICY 0x0303020E -#define OID_FDDI_SMT_T_NOTIFY 0x0303020F -#define OID_FDDI_SMT_STAT_RPT_POLICY 0x03030210 -#define OID_FDDI_SMT_TRACE_MAX_EXPIRATION 0x03030211 -#define OID_FDDI_SMT_PORT_INDEXES 0x03030212 -#define OID_FDDI_SMT_MAC_INDEXES 0x03030213 -#define OID_FDDI_SMT_BYPASS_PRESENT 0x03030214 -#define OID_FDDI_SMT_ECM_STATE 0x03030215 -#define OID_FDDI_SMT_CF_STATE 0x03030216 -#define OID_FDDI_SMT_HOLD_STATE 0x03030217 -#define OID_FDDI_SMT_REMOTE_DISCONNECT_FLAG 0x03030218 -#define OID_FDDI_SMT_STATION_STATUS 0x03030219 -#define OID_FDDI_SMT_PEER_WRAP_FLAG 0x0303021A -#define OID_FDDI_SMT_MSG_TIME_STAMP 0x0303021B -#define OID_FDDI_SMT_TRANSITION_TIME_STAMP 0x0303021C -#define OID_FDDI_SMT_SET_COUNT 0x0303021D -#define OID_FDDI_SMT_LAST_SET_STATION_ID 0x0303021E -#define OID_FDDI_MAC_FRAME_STATUS_FUNCTIONS 0x0303021F -#define OID_FDDI_MAC_BRIDGE_FUNCTIONS 0x03030220 -#define OID_FDDI_MAC_T_MAX_CAPABILITY 0x03030221 -#define OID_FDDI_MAC_TVX_CAPABILITY 0x03030222 -#define OID_FDDI_MAC_AVAILABLE_PATHS 0x03030223 -#define OID_FDDI_MAC_CURRENT_PATH 0x03030224 -#define OID_FDDI_MAC_UPSTREAM_NBR 0x03030225 -#define OID_FDDI_MAC_DOWNSTREAM_NBR 0x03030226 -#define OID_FDDI_MAC_OLD_UPSTREAM_NBR 0x03030227 -#define OID_FDDI_MAC_OLD_DOWNSTREAM_NBR 0x03030228 -#define OID_FDDI_MAC_DUP_ADDRESS_TEST 0x03030229 -#define OID_FDDI_MAC_REQUESTED_PATHS 0x0303022A -#define OID_FDDI_MAC_DOWNSTREAM_PORT_TYPE 0x0303022B -#define OID_FDDI_MAC_INDEX 0x0303022C -#define OID_FDDI_MAC_SMT_ADDRESS 0x0303022D -#define OID_FDDI_MAC_LONG_GRP_ADDRESS 0x0303022E -#define OID_FDDI_MAC_SHORT_GRP_ADDRESS 0x0303022F -#define OID_FDDI_MAC_T_REQ 0x03030230 -#define OID_FDDI_MAC_T_NEG 0x03030231 -#define OID_FDDI_MAC_T_MAX 0x03030232 -#define OID_FDDI_MAC_TVX_VALUE 0x03030233 -#define OID_FDDI_MAC_T_PRI0 0x03030234 -#define OID_FDDI_MAC_T_PRI1 0x03030235 -#define OID_FDDI_MAC_T_PRI2 0x03030236 -#define OID_FDDI_MAC_T_PRI3 0x03030237 -#define OID_FDDI_MAC_T_PRI4 0x03030238 -#define OID_FDDI_MAC_T_PRI5 0x03030239 -#define OID_FDDI_MAC_T_PRI6 0x0303023A -#define OID_FDDI_MAC_FRAME_CT 0x0303023B -#define OID_FDDI_MAC_COPIED_CT 0x0303023C -#define OID_FDDI_MAC_TRANSMIT_CT 0x0303023D -#define OID_FDDI_MAC_TOKEN_CT 0x0303023E -#define OID_FDDI_MAC_ERROR_CT 0x0303023F -#define OID_FDDI_MAC_LOST_CT 0x03030240 -#define OID_FDDI_MAC_TVX_EXPIRED_CT 0x03030241 -#define OID_FDDI_MAC_NOT_COPIED_CT 0x03030242 -#define OID_FDDI_MAC_LATE_CT 0x03030243 -#define OID_FDDI_MAC_RING_OP_CT 0x03030244 -#define OID_FDDI_MAC_FRAME_ERROR_THRESHOLD 0x03030245 -#define OID_FDDI_MAC_FRAME_ERROR_RATIO 0x03030246 -#define OID_FDDI_MAC_NOT_COPIED_THRESHOLD 0x03030247 -#define OID_FDDI_MAC_NOT_COPIED_RATIO 0x03030248 -#define OID_FDDI_MAC_RMT_STATE 0x03030249 -#define OID_FDDI_MAC_DA_FLAG 0x0303024A -#define OID_FDDI_MAC_UNDA_FLAG 0x0303024B -#define OID_FDDI_MAC_FRAME_ERROR_FLAG 0x0303024C -#define OID_FDDI_MAC_NOT_COPIED_FLAG 0x0303024D -#define OID_FDDI_MAC_MA_UNITDATA_AVAILABLE 0x0303024E -#define OID_FDDI_MAC_HARDWARE_PRESENT 0x0303024F -#define OID_FDDI_MAC_MA_UNITDATA_ENABLE 0x03030250 -#define OID_FDDI_PATH_INDEX 0x03030251 -#define OID_FDDI_PATH_RING_LATENCY 0x03030252 -#define OID_FDDI_PATH_TRACE_STATUS 0x03030253 -#define OID_FDDI_PATH_SBA_PAYLOAD 0x03030254 -#define OID_FDDI_PATH_SBA_OVERHEAD 0x03030255 -#define OID_FDDI_PATH_CONFIGURATION 0x03030256 -#define OID_FDDI_PATH_T_R_MODE 0x03030257 -#define OID_FDDI_PATH_SBA_AVAILABLE 0x03030258 -#define OID_FDDI_PATH_TVX_LOWER_BOUND 0x03030259 -#define OID_FDDI_PATH_T_MAX_LOWER_BOUND 0x0303025A -#define OID_FDDI_PATH_MAX_T_REQ 0x0303025B -#define OID_FDDI_PORT_MY_TYPE 0x0303025C -#define OID_FDDI_PORT_NEIGHBOR_TYPE 0x0303025D -#define OID_FDDI_PORT_CONNECTION_POLICIES 0x0303025E -#define OID_FDDI_PORT_MAC_INDICATED 0x0303025F -#define OID_FDDI_PORT_CURRENT_PATH 0x03030260 -#define OID_FDDI_PORT_REQUESTED_PATHS 0x03030261 -#define OID_FDDI_PORT_MAC_PLACEMENT 0x03030262 -#define OID_FDDI_PORT_AVAILABLE_PATHS 0x03030263 -#define OID_FDDI_PORT_MAC_LOOP_TIME 0x03030264 -#define OID_FDDI_PORT_PMD_CLASS 0x03030265 -#define OID_FDDI_PORT_CONNECTION_CAPABILITIES 0x03030266 -#define OID_FDDI_PORT_INDEX 0x03030267 -#define OID_FDDI_PORT_MAINT_LS 0x03030268 -#define OID_FDDI_PORT_BS_FLAG 0x03030269 -#define OID_FDDI_PORT_PC_LS 0x0303026A -#define OID_FDDI_PORT_EB_ERROR_CT 0x0303026B -#define OID_FDDI_PORT_LCT_FAIL_CT 0x0303026C -#define OID_FDDI_PORT_LER_ESTIMATE 0x0303026D -#define OID_FDDI_PORT_LEM_REJECT_CT 0x0303026E -#define OID_FDDI_PORT_LEM_CT 0x0303026F -#define OID_FDDI_PORT_LER_CUTOFF 0x03030270 -#define OID_FDDI_PORT_LER_ALARM 0x03030271 -#define OID_FDDI_PORT_CONNNECT_STATE 0x03030272 -#define OID_FDDI_PORT_PCM_STATE 0x03030273 -#define OID_FDDI_PORT_PC_WITHHOLD 0x03030274 -#define OID_FDDI_PORT_LER_FLAG 0x03030275 -#define OID_FDDI_PORT_HARDWARE_PRESENT 0x03030276 -#define OID_FDDI_SMT_STATION_ACTION 0x03030277 -#define OID_FDDI_PORT_ACTION 0x03030278 -#define OID_FDDI_IF_DESCR 0x03030279 -#define OID_FDDI_IF_TYPE 0x0303027A -#define OID_FDDI_IF_MTU 0x0303027B -#define OID_FDDI_IF_SPEED 0x0303027C -#define OID_FDDI_IF_PHYS_ADDRESS 0x0303027D -#define OID_FDDI_IF_ADMIN_STATUS 0x0303027E -#define OID_FDDI_IF_OPER_STATUS 0x0303027F -#define OID_FDDI_IF_LAST_CHANGE 0x03030280 -#define OID_FDDI_IF_IN_OCTETS 0x03030281 -#define OID_FDDI_IF_IN_UCAST_PKTS 0x03030282 -#define OID_FDDI_IF_IN_NUCAST_PKTS 0x03030283 -#define OID_FDDI_IF_IN_DISCARDS 0x03030284 -#define OID_FDDI_IF_IN_ERRORS 0x03030285 -#define OID_FDDI_IF_IN_UNKNOWN_PROTOS 0x03030286 -#define OID_FDDI_IF_OUT_OCTETS 0x03030287 -#define OID_FDDI_IF_OUT_UCAST_PKTS 0x03030288 -#define OID_FDDI_IF_OUT_NUCAST_PKTS 0x03030289 -#define OID_FDDI_IF_OUT_DISCARDS 0x0303028A -#define OID_FDDI_IF_OUT_ERRORS 0x0303028B -#define OID_FDDI_IF_OUT_QLEN 0x0303028C -#define OID_FDDI_IF_SPECIFIC 0x0303028D -// -// WAN objects -// -#define OID_WAN_PERMANENT_ADDRESS 0x04010101 -#define OID_WAN_CURRENT_ADDRESS 0x04010102 -#define OID_WAN_QUALITY_OF_SERVICE 0x04010103 -#define OID_WAN_PROTOCOL_TYPE 0x04010104 -#define OID_WAN_MEDIUM_SUBTYPE 0x04010105 -#define OID_WAN_HEADER_FORMAT 0x04010106 -#define OID_WAN_GET_INFO 0x04010107 -#define OID_WAN_SET_LINK_INFO 0x04010108 -#define OID_WAN_GET_LINK_INFO 0x04010109 -#define OID_WAN_LINE_COUNT 0x0401010A -#define OID_WAN_GET_BRIDGE_INFO 0x0401020A -#define OID_WAN_SET_BRIDGE_INFO 0x0401020B -#define OID_WAN_GET_COMP_INFO 0x0401020C -#define OID_WAN_SET_COMP_INFO 0x0401020D -#define OID_WAN_GET_STATS_INFO 0x0401020E -// -// LocalTalk objects -// -#define OID_LTALK_CURRENT_NODE_ID 0x05010102 -#define OID_LTALK_IN_BROADCASTS 0x05020101 -#define OID_LTALK_IN_LENGTH_ERRORS 0x05020102 -#define OID_LTALK_OUT_NO_HANDLERS 0x05020201 -#define OID_LTALK_COLLISIONS 0x05020202 -#define OID_LTALK_DEFERS 0x05020203 -#define OID_LTALK_NO_DATA_ERRORS 0x05020204 -#define OID_LTALK_RANDOM_CTS_ERRORS 0x05020205 -#define OID_LTALK_FCS_ERRORS 0x05020206 -// -// Arcnet objects -// -#define OID_ARCNET_PERMANENT_ADDRESS 0x06010101 -#define OID_ARCNET_CURRENT_ADDRESS 0x06010102 -#define OID_ARCNET_RECONFIGURATIONS 0x06020201 -// -// TAPI objects -// -#define OID_TAPI_ACCEPT 0x07030101 -#define OID_TAPI_ANSWER 0x07030102 -#define OID_TAPI_CLOSE 0x07030103 -#define OID_TAPI_CLOSE_CALL 0x07030104 -#define OID_TAPI_CONDITIONAL_MEDIA_DETECTION 0x07030105 -#define OID_TAPI_CONFIG_DIALOG 0x07030106 -#define OID_TAPI_DEV_SPECIFIC 0x07030107 -#define OID_TAPI_DIAL 0x07030108 -#define OID_TAPI_DROP 0x07030109 -#define OID_TAPI_GET_ADDRESS_CAPS 0x0703010A -#define OID_TAPI_GET_ADDRESS_ID 0x0703010B -#define OID_TAPI_GET_ADDRESS_STATUS 0x0703010C -#define OID_TAPI_GET_CALL_ADDRESS_ID 0x0703010D -#define OID_TAPI_GET_CALL_INFO 0x0703010E -#define OID_TAPI_GET_CALL_STATUS 0x0703010F -#define OID_TAPI_GET_DEV_CAPS 0x07030110 -#define OID_TAPI_GET_DEV_CONFIG 0x07030111 -#define OID_TAPI_GET_EXTENSION_ID 0x07030112 -#define OID_TAPI_GET_ID 0x07030113 -#define OID_TAPI_GET_LINE_DEV_STATUS 0x07030114 -#define OID_TAPI_MAKE_CALL 0x07030115 -#define OID_TAPI_NEGOTIATE_EXT_VERSION 0x07030116 -#define OID_TAPI_OPEN 0x07030117 -#define OID_TAPI_PROVIDER_INITIALIZE 0x07030118 -#define OID_TAPI_PROVIDER_SHUTDOWN 0x07030119 -#define OID_TAPI_SECURE_CALL 0x0703011A -#define OID_TAPI_SELECT_EXT_VERSION 0x0703011B -#define OID_TAPI_SEND_USER_USER_INFO 0x0703011C -#define OID_TAPI_SET_APP_SPECIFIC 0x0703011D -#define OID_TAPI_SET_CALL_PARAMS 0x0703011E -#define OID_TAPI_SET_DEFAULT_MEDIA_DETECTION 0x0703011F -#define OID_TAPI_SET_DEV_CONFIG 0x07030120 -#define OID_TAPI_SET_MEDIA_MODE 0x07030121 -#define OID_TAPI_SET_STATUS_MESSAGES 0x07030122 -// -// ATM Connection Oriented Ndis -// -#define OID_ATM_SUPPORTED_VC_RATES 0x08010101 -#define OID_ATM_SUPPORTED_SERVICE_CATEGORY 0x08010102 -#define OID_ATM_SUPPORTED_AAL_TYPES 0x08010103 -#define OID_ATM_HW_CURRENT_ADDRESS 0x08010104 -#define OID_ATM_MAX_ACTIVE_VCS 0x08010105 -#define OID_ATM_MAX_ACTIVE_VCI_BITS 0x08010106 -#define OID_ATM_MAX_ACTIVE_VPI_BITS 0x08010107 -#define OID_ATM_MAX_AAL0_PACKET_SIZE 0x08010108 -#define OID_ATM_MAX_AAL1_PACKET_SIZE 0x08010109 -#define OID_ATM_MAX_AAL34_PACKET_SIZE 0x0801010A -#define OID_ATM_MAX_AAL5_PACKET_SIZE 0x0801010B -#define OID_ATM_SIGNALING_VPIVCI 0x08010201 -#define OID_ATM_ASSIGNED_VPI 0x08010202 -#define OID_ATM_ACQUIRE_ACCESS_NET_RESOURCES 0x08010203 -#define OID_ATM_RELEASE_ACCESS_NET_RESOURCES 0x08010204 -#define OID_ATM_ILMI_VPIVCI 0x08010205 -#define OID_ATM_DIGITAL_BROADCAST_VPIVCI 0x08010206 -#define OID_ATM_GET_NEAREST_FLOW 0x08010207 -#define OID_ATM_ALIGNMENT_REQUIRED 0x08010208 -// -// ATM specific statistics OIDs. -// -#define OID_ATM_RCV_CELLS_OK 0x08020101 -#define OID_ATM_XMIT_CELLS_OK 0x08020102 -#define OID_ATM_RCV_CELLS_DROPPED 0x08020103 -#define OID_ATM_RCV_INVALID_VPI_VCI 0x08020201 -#define OID_ATM_CELLS_HEC_ERROR 0x08020202 -#define OID_ATM_RCV_REASSEMBLY_ERROR 0x08020203 -// -// PCCA (Wireless) object -// -// -// All WirelessWAN devices must support the following OIDs -// -#define OID_WW_GEN_NETWORK_TYPES_SUPPORTED 0x09010101 -#define OID_WW_GEN_NETWORK_TYPE_IN_USE 0x09010102 -#define OID_WW_GEN_HEADER_FORMATS_SUPPORTED 0x09010103 -#define OID_WW_GEN_HEADER_FORMAT_IN_USE 0x09010104 -#define OID_WW_GEN_INDICATION_REQUEST 0x09010105 -#define OID_WW_GEN_DEVICE_INFO 0x09010106 -#define OID_WW_GEN_OPERATION_MODE 0x09010107 -#define OID_WW_GEN_LOCK_STATUS 0x09010108 -#define OID_WW_GEN_DISABLE_TRANSMITTER 0x09010109 -#define OID_WW_GEN_NETWORK_ID 0x0901010A -#define OID_WW_GEN_PERMANENT_ADDRESS 0x0901010B -#define OID_WW_GEN_CURRENT_ADDRESS 0x0901010C -#define OID_WW_GEN_SUSPEND_DRIVER 0x0901010D -#define OID_WW_GEN_BASESTATION_ID 0x0901010E -#define OID_WW_GEN_CHANNEL_ID 0x0901010F -#define OID_WW_GEN_ENCRYPTION_SUPPORTED 0x09010110 -#define OID_WW_GEN_ENCRYPTION_IN_USE 0x09010111 -#define OID_WW_GEN_ENCRYPTION_STATE 0x09010112 -#define OID_WW_GEN_CHANNEL_QUALITY 0x09010113 -#define OID_WW_GEN_REGISTRATION_STATUS 0x09010114 -#define OID_WW_GEN_RADIO_LINK_SPEED 0x09010115 -#define OID_WW_GEN_LATENCY 0x09010116 -#define OID_WW_GEN_BATTERY_LEVEL 0x09010117 -#define OID_WW_GEN_EXTERNAL_POWER 0x09010118 -// -// Network Dependent OIDs - Mobitex: -// -#define OID_WW_MBX_SUBADDR 0x09050101 -// OID 0x09050102 is reserved and may not be used -#define OID_WW_MBX_FLEXLIST 0x09050103 -#define OID_WW_MBX_GROUPLIST 0x09050104 -#define OID_WW_MBX_TRAFFIC_AREA 0x09050105 -#define OID_WW_MBX_LIVE_DIE 0x09050106 -#define OID_WW_MBX_TEMP_DEFAULTLIST 0x09050107 -// -// Network Dependent OIDs - Pinpoint: -// -#define OID_WW_PIN_LOC_AUTHORIZE 0x09090101 -#define OID_WW_PIN_LAST_LOCATION 0x09090102 -#define OID_WW_PIN_LOC_FIX 0x09090103 -// -// Network Dependent - CDPD: -// -#define OID_WW_CDPD_SPNI 0x090D0101 -#define OID_WW_CDPD_WASI 0x090D0102 -#define OID_WW_CDPD_AREA_COLOR 0x090D0103 -#define OID_WW_CDPD_TX_POWER_LEVEL 0x090D0104 -#define OID_WW_CDPD_EID 0x090D0105 -#define OID_WW_CDPD_HEADER_COMPRESSION 0x090D0106 -#define OID_WW_CDPD_DATA_COMPRESSION 0x090D0107 -#define OID_WW_CDPD_CHANNEL_SELECT 0x090D0108 -#define OID_WW_CDPD_CHANNEL_STATE 0x090D0109 -#define OID_WW_CDPD_NEI 0x090D010A -#define OID_WW_CDPD_NEI_STATE 0x090D010B -#define OID_WW_CDPD_SERVICE_PROVIDER_IDENTIFIER 0x090D010C -#define OID_WW_CDPD_SLEEP_MODE 0x090D010D -#define OID_WW_CDPD_CIRCUIT_SWITCHED 0x090D010E -#define OID_WW_CDPD_TEI 0x090D010F -#define OID_WW_CDPD_RSSI 0x090D0110 -// -// Network Dependent - Ardis: -// -#define OID_WW_ARD_SNDCP 0x09110101 -#define OID_WW_ARD_TMLY_MSG 0x09110102 -#define OID_WW_ARD_DATAGRAM 0x09110103 -// -// Network Dependent - DataTac: -// -#define OID_WW_TAC_COMPRESSION 0x09150101 -#define OID_WW_TAC_SET_CONFIG 0x09150102 -#define OID_WW_TAC_GET_STATUS 0x09150103 -#define OID_WW_TAC_USER_HEADER 0x09150104 -// -// Network Dependent - Metricom: -// -#define OID_WW_MET_FUNCTION 0x09190101 -// -// IRDA objects -// -#define OID_IRDA_RECEIVING 0x0A010100 -#define OID_IRDA_TURNAROUND_TIME 0x0A010101 -#define OID_IRDA_SUPPORTED_SPEEDS 0x0A010102 -#define OID_IRDA_LINK_SPEED 0x0A010103 -#define OID_IRDA_MEDIA_BUSY 0x0A010104 -#define OID_IRDA_EXTRA_RCV_BOFS 0x0A010200 -#define OID_IRDA_RATE_SNIFF 0x0A010201 -#define OID_IRDA_UNICAST_LIST 0x0A010202 -#define OID_IRDA_MAX_UNICAST_LIST_SIZE 0x0A010203 -#define OID_IRDA_MAX_RECEIVE_WINDOW_SIZE 0x0A010204 -#define OID_IRDA_MAX_SEND_WINDOW_SIZE 0x0A010205 -// -// Medium the Ndis Driver is running on (OID_GEN_MEDIA_SUPPORTED/ -// OID_GEN_MEDIA_IN_USE). -// -typedef enum _NDIS_MEDIUM { - NdisMedium802_3, - NdisMedium802_5, - NdisMediumFddi, - NdisMediumWan, - NdisMediumLocalTalk, - NdisMediumDix, // defined for convenience, not a real medium - NdisMediumArcnetRaw, - NdisMediumArcnet878_2, - NdisMediumAtm, - NdisMediumWirelessWan, - NdisMediumIrda, - NdisMediumMax // Not a real medium, defined as an upper-bound -} NDIS_MEDIUM, *PNDIS_MEDIUM; - -// -// Hardware status codes (OID_GEN_HARDWARE_STATUS). -// -typedef enum _NDIS_HARDWARE_STATUS { - NdisHardwareStatusReady, - NdisHardwareStatusInitializing, - NdisHardwareStatusReset, - NdisHardwareStatusClosing, - NdisHardwareStatusNotReady -} NDIS_HARDWARE_STATUS, *PNDIS_HARDWARE_STATUS; - -// -// this is the type passed in the OID_GEN_GET_TIME_CAPS request -// -typedef struct _GEN_GET_TIME_CAPS { - ULONG Flags; // Bits defined below - - ULONG ClockPrecision; -} GEN_GET_TIME_CAPS, *PGEN_GET_TIME_CAPS; - -#define READABLE_LOCAL_CLOCK 0x000000001 -#define CLOCK_NETWORK_DERIVED 0x000000002 -#define CLOCK_PRECISION 0x000000004 -#define RECEIVE_TIME_INDICATION_CAPABLE 0x000000008 -#define TIMED_SEND_CAPABLE 0x000000010 -#define TIME_STAMP_CAPABLE 0x000000020 -// -// -// this is the type passed in the OID_GEN_GET_NETCARD_TIME request -// -typedef struct _GEN_GET_NETCARD_TIME { - ULONG ReadTime; -} GEN_GET_NETCARD_TIME, *PGEN_GET_NETCARD_TIME; - -// -// Defines the attachment types for FDDI (OID_FDDI_ATTACHMENT_TYPE). -// -typedef enum _NDIS_FDDI_ATTACHMENT_TYPE { - NdisFddiTypeIsolated = 1, - NdisFddiTypeLocalA, - NdisFddiTypeLocalB, - NdisFddiTypeLocalAB, - NdisFddiTypeLocalS, - NdisFddiTypeWrapA, - NdisFddiTypeWrapB, - NdisFddiTypeWrapAB, - NdisFddiTypeWrapS, - NdisFddiTypeCWrapA, - NdisFddiTypeCWrapB, - NdisFddiTypeCWrapS, - NdisFddiTypeThrough -} NDIS_FDDI_ATTACHMENT_TYPE, *PNDIS_FDDI_ATTACHMENT_TYPE; - -// -// Defines the ring management states for FDDI (OID_FDDI_RING_MGT_STATE). -// -typedef enum _NDIS_FDDI_RING_MGT_STATE { - NdisFddiRingIsolated = 1, - NdisFddiRingNonOperational, - NdisFddiRingOperational, - NdisFddiRingDetect, - NdisFddiRingNonOperationalDup, - NdisFddiRingOperationalDup, - NdisFddiRingDirected, - NdisFddiRingTrace -} NDIS_FDDI_RING_MGT_STATE, *PNDIS_FDDI_RING_MGT_STATE; - -// -// Defines the Lconnection state for FDDI (OID_FDDI_LCONNECTION_STATE). -// -typedef enum _NDIS_FDDI_LCONNECTION_STATE { - NdisFddiStateOff = 1, - NdisFddiStateBreak, - NdisFddiStateTrace, - NdisFddiStateConnect, - NdisFddiStateNext, - NdisFddiStateSignal, - NdisFddiStateJoin, - NdisFddiStateVerify, - NdisFddiStateActive, - NdisFddiStateMaintenance -} NDIS_FDDI_LCONNECTION_STATE, *PNDIS_FDDI_LCONNECTION_STATE; - -// -// Defines the medium subtypes for WAN medium (OID_WAN_MEDIUM_SUBTYPE). -// -typedef enum _NDIS_WAN_MEDIUM_SUBTYPE { - NdisWanMediumHub, - NdisWanMediumX_25, - NdisWanMediumIsdn, - NdisWanMediumSerial, - NdisWanMediumFrameRelay, - NdisWanMediumAtm, - NdisWanMediumSonet, - NdisWanMediumSW56K -} NDIS_WAN_MEDIUM_SUBTYPE, *PNDIS_WAN_MEDIUM_SUBTYPE; - -// -// Defines the header format for WAN medium (OID_WAN_HEADER_FORMAT). -// -typedef enum _NDIS_WAN_HEADER_FORMAT { - NdisWanHeaderNative, // src/dest based on subtype, followed by NLPID - NdisWanHeaderEthernet // emulation of ethernet header -} NDIS_WAN_HEADER_FORMAT, *PNDIS_WAN_HEADER_FORMAT; - -// -// Defines the line quality on a WAN line (OID_WAN_QUALITY_OF_SERVICE). -// -typedef enum _NDIS_WAN_QUALITY { - NdisWanRaw, - NdisWanErrorControl, - NdisWanReliable -} NDIS_WAN_QUALITY, *PNDIS_WAN_QUALITY; - -// -// Defines the state of a token-ring adapter (OID_802_5_CURRENT_RING_STATE). -// -typedef enum _NDIS_802_5_RING_STATE { - NdisRingStateOpened = 1, - NdisRingStateClosed, - NdisRingStateOpening, - NdisRingStateClosing, - NdisRingStateOpenFailure, - NdisRingStateRingFailure -} NDIS_802_5_RING_STATE, *PNDIS_802_5_RING_STATE; - -// -// Defines the state of the LAN media -// -typedef enum _NDIS_MEDIA_STATE { - NdisMediaStateConnected, - NdisMediaStateDisconnected -} NDIS_MEDIA_STATE, *PNDIS_MEDIA_STATE; - -// -// The following is set on a per-packet basis as OOB data with NdisClass802_3Priority -// -typedef ULONG Priority_802_3; // 0-7 priority levels -// -// The following structure is used to query OID_GEN_CO_LINK_SPEED and -// OID_GEN_CO_MINIMUM_LINK_SPEED. The first OID will return the current -// link speed of the adapter. The second will return the minimum link speed -// the adapter is capable of. -// - -typedef struct _NDIS_CO_LINK_SPEED { - ULONG Outbound; - ULONG Inbound; -} NDIS_CO_LINK_SPEED, - -*PNDIS_CO_LINK_SPEED; -// -// Ndis Packet Filter Bits (OID_GEN_CURRENT_PACKET_FILTER). -// -#define NDIS_PACKET_TYPE_DIRECTED 0x0001 -#define NDIS_PACKET_TYPE_MULTICAST 0x0002 -#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x0004 -#define NDIS_PACKET_TYPE_BROADCAST 0x0008 -#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x0010 -#define NDIS_PACKET_TYPE_PROMISCUOUS 0x0020 -#define NDIS_PACKET_TYPE_SMT 0x0040 -#define NDIS_PACKET_TYPE_ALL_LOCAL 0x0080 -#define NDIS_PACKET_TYPE_MAC_FRAME 0x8000 -#define NDIS_PACKET_TYPE_FUNCTIONAL 0x4000 -#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x2000 -#define NDIS_PACKET_TYPE_GROUP 0x1000 -// -// Ndis Token-Ring Ring Status Codes (OID_802_5_CURRENT_RING_STATUS). -// -#define NDIS_RING_SIGNAL_LOSS 0x00008000 -#define NDIS_RING_HARD_ERROR 0x00004000 -#define NDIS_RING_SOFT_ERROR 0x00002000 -#define NDIS_RING_TRANSMIT_BEACON 0x00001000 -#define NDIS_RING_LOBE_WIRE_FAULT 0x00000800 -#define NDIS_RING_AUTO_REMOVAL_ERROR 0x00000400 -#define NDIS_RING_REMOVE_RECEIVED 0x00000200 -#define NDIS_RING_COUNTER_OVERFLOW 0x00000100 -#define NDIS_RING_SINGLE_STATION 0x00000080 -#define NDIS_RING_RING_RECOVERY 0x00000040 -// -// Ndis protocol option bits (OID_GEN_PROTOCOL_OPTIONS). -// -#define NDIS_PROT_OPTION_ESTIMATED_LENGTH 0x00000001 -#define NDIS_PROT_OPTION_NO_LOOPBACK 0x00000002 -#define NDIS_PROT_OPTION_NO_RSVD_ON_RCVPKT 0x00000004 -// -// Ndis MAC option bits (OID_GEN_MAC_OPTIONS). -// -#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA 0x00000001 -#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED 0x00000002 -#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND 0x00000004 -#define NDIS_MAC_OPTION_NO_LOOPBACK 0x00000008 -#define NDIS_MAC_OPTION_FULL_DUPLEX 0x00000010 -#define NDIS_MAC_OPTION_EOTX_INDICATION 0x00000020 -#define NDIS_MAC_OPTION_RESERVED 0x80000000 -// -// NDIS MAC option bits for OID_GEN_CO_MAC_OPTIONS. -// -#define NDIS_CO_MAC_OPTION_DYNAMIC_LINK_SPEED 0x00000001 -#ifdef IRDA -// -// The following is set on a per-packet basis as OOB data with NdisClassIrdaPacketInfo -// This is the per-packet info specified on a per-packet basis -// -typedef struct _NDIS_IRDA_PACKET_INFO { - UINT ExtraBOFs; - UINT MinTurnAroundTime; -} NDIS_IRDA_PACKET_INFO, *PNDIS_IRDA_PACKET_INFO; - -#endif -#ifdef WIRELESS_WAN -// -// Wireless WAN structure definitions -// -// -// currently defined Wireless network subtypes -// -typedef enum _NDIS_WW_NETWORK_TYPE { - NdisWWGeneric, - NdisWWMobitex, - NdisWWPinpoint, - NdisWWCDPD, - NdisWWArdis, - NdisWWDataTAC, - NdisWWMetricom, - NdisWWGSM, - NdisWWCDMA, - NdisWWTDMA, - NdisWWAMPS, - NdisWWInmarsat, - NdisWWpACT -} NDIS_WW_NETWORK_TYPE; - -// -// currently defined header formats -// -typedef enum _NDIS_WW_HEADER_FORMAT { - NdisWWDIXEthernetFrames, - NdisWWMPAKFrames, - NdisWWRDLAPFrames, - NdisWWMDC4800Frames -} NDIS_WW_HEADER_FORMAT; - -// -// currently defined encryption types -// -typedef enum _NDIS_WW_ENCRYPTION_TYPE { - NdisWWUnknownEncryption = -1, - NdisWWNoEncryption, - NdisWWDefaultEncryption -} NDIS_WW_ENCRYPTION_TYPE, *PNDIS_WW_ENCRYPTION_TYPE; - -// -// OID_WW_GEN_INDICATION_REQUEST -// -typedef struct _NDIS_WW_INDICATION_REQUEST { - NDIS_OID Oid; // IN - - UINT uIndicationFlag; // IN - - UINT uApplicationToken; // IN OUT - - HANDLE hIndicationHandle; // IN OUT - - INT iPollingInterval; // IN OUT - - NDIS_VAR_DATA_DESC InitialValue; // IN OUT - - NDIS_VAR_DATA_DESC OIDIndicationValue; // OUT - only valid after indication - - NDIS_VAR_DATA_DESC TriggerValue; // IN - -} NDIS_WW_INDICATION_REQUEST, *PNDIS_WW_INDICATION_REQUEST; - -#define OID_INDICATION_REQUEST_ENABLE 0x0000 -#define OID_INDICATION_REQUEST_CANCEL 0x0001 -// -// OID_WW_GEN_DEVICE_INFO -// -typedef struct _WW_DEVICE_INFO { - NDIS_VAR_DATA_DESC Manufacturer; - NDIS_VAR_DATA_DESC ModelNum; - NDIS_VAR_DATA_DESC SWVersionNum; - NDIS_VAR_DATA_DESC SerialNum; -} WW_DEVICE_INFO, *PWW_DEVICE_INFO; - -// -// OID_WW_GEN_OPERATION_MODE -// -typedef INT WW_OPERATION_MODE; // 0 = Normal mode - // 1 = Power saving mode - // -1 = mode unknown -// -// OID_WW_GEN_LOCK_STATUS -// - -typedef INT WW_LOCK_STATUS; // 0 = unlocked - // 1 = locked - // -1 = unknown lock status -// -// OID_WW_GEN_DISABLE_TRANSMITTER -// - -typedef INT WW_DISABLE_TRANSMITTER; // 0 = transmitter enabled - // 1 = transmitter disabled - // -1 = unknown value -// -// OID_WW_GEN_NETWORK_ID -// - -typedef NDIS_VAR_DATA_DESC WW_NETWORK_ID; -// -// OID_WW_GEN_PERMANENT_ADDRESS -// -typedef NDIS_VAR_DATA_DESC WW_PERMANENT_ADDRESS; -// -// OID_WW_GEN_CURRENT_ADDRESS -// -typedef struct _WW_CURRENT_ADDRESS { - NDIS_WW_HEADER_FORMAT Format; - NDIS_VAR_DATA_DESC Address; -} WW_CURRENT_ADDRESS, *PWW_CURRENT_ADDRESS; - -// -// OID_WW_GEN_SUSPEND_DRIVER -// -typedef BOOLEAN WW_SUSPEND_DRIVER; // 0 = driver operational - // 1 = driver suspended -// -// OID_WW_GEN_BASESTATION_ID -// - -typedef NDIS_VAR_DATA_DESC WW_BASESTATION_ID; -// -// OID_WW_GEN_CHANNEL_ID -// -typedef NDIS_VAR_DATA_DESC WW_CHANNEL_ID; -// -// OID_WW_GEN_ENCRYPTION_STATE -// -typedef BOOLEAN WW_ENCRYPTION_STATE; // 0 = if encryption is disabled - // 1 = if encryption is enabled -// -// OID_WW_GEN_CHANNEL_QUALITY -// - -typedef INT WW_CHANNEL_QUALITY; // 0 = Not in network contact, - // 1-100 = Quality of Channel (100 is highest quality). - // -1 = channel quality is unknown -// -// OID_WW_GEN_REGISTRATION_STATUS -// - -typedef INT WW_REGISTRATION_STATUS; // 0 = Registration denied - // 1 = Registration pending - // 2 = Registered - // -1 = unknown registration status -// -// OID_WW_GEN_RADIO_LINK_SPEED -// - -typedef UINT WW_RADIO_LINK_SPEED; // Bits per second. -// -// OID_WW_GEN_LATENCY -// - -typedef UINT WW_LATENCY; // milliseconds -// -// OID_WW_GEN_BATTERY_LEVEL -// - -typedef INT WW_BATTERY_LEVEL; // 0-100 = battery level in percentage - // (100=fully charged) - // -1 = unknown battery level. -// -// OID_WW_GEN_EXTERNAL_POWER -// - -typedef INT WW_EXTERNAL_POWER; // 0 = no external power connected - // 1 = external power connected - // -1 = unknown -// -// OID_WW_MET_FUNCTION -// - -typedef NDIS_VAR_DATA_DESC WW_MET_FUNCTION; -// -// OID_WW_TAC_COMPRESSION -// -typedef BOOLEAN WW_TAC_COMPRESSION; // Determines whether or not network level compression - // is being used. -// -// OID_WW_TAC_SET_CONFIG -// - -typedef struct _WW_TAC_SETCONFIG { - NDIS_VAR_DATA_DESC RCV_MODE; - NDIS_VAR_DATA_DESC TX_CONTROL; - NDIS_VAR_DATA_DESC RX_CONTROL; - NDIS_VAR_DATA_DESC FLOW_CONTROL; - NDIS_VAR_DATA_DESC RESET_CNF; - NDIS_VAR_DATA_DESC READ_CNF; -} WW_TAC_SETCONFIG, *PWW_TAC_SETCONFIG; - -// -// OID_WW_TAC_GET_STATUS -// -typedef struct _WW_TAC_GETSTATUS { - BOOLEAN Action; // Set = Execute command. - - NDIS_VAR_DATA_DESC Command; - NDIS_VAR_DATA_DESC Option; - NDIS_VAR_DATA_DESC Response; // The response to the requested command - // - max. length of string is 256 octets. - -} WW_TAC_GETSTATUS, *PWW_TAC_GETSTATUS; - -// -// OID_WW_TAC_USER_HEADER -// -typedef NDIS_VAR_DATA_DESC WW_TAC_USERHEADER; // This will hold the user header - Max. 64 octets. -// -// OID_WW_ARD_SNDCP -// - -typedef struct _WW_ARD_SNDCP { - NDIS_VAR_DATA_DESC Version; // The version of SNDCP protocol supported. - - INT BlockSize; // The block size used for SNDCP - - INT Window; // The window size used in SNDCP - -} WW_ARD_SNDCP, *PWW_ARD_SNDCP; - -// -// OID_WW_ARD_TMLY_MSG -// -typedef BOOLEAN WW_ARD_CHANNEL_STATUS; // The current status of the inbound RF Channel. -// -// OID_WW_ARD_DATAGRAM -// - -typedef struct _WW_ARD_DATAGRAM { - BOOLEAN LoadLevel; // Byte that contains the load level info. - - INT SessionTime; // Datagram session time remaining. - - NDIS_VAR_DATA_DESC HostAddr; // Host address. - - NDIS_VAR_DATA_DESC THostAddr; // Test host address. - -} WW_ARD_DATAGRAM, *PWW_ARD_DATAGRAM; - -// -// OID_WW_CDPD_SPNI -// -typedef struct _WW_CDPD_SPNI { - UINT SPNI[10]; //10 16-bit service provider network IDs - - INT OperatingMode; // 0 = ignore SPNI, - // 1 = require SPNI from list, - // 2 = prefer SPNI from list. - // 3 = exclude SPNI from list. - -} WW_CDPD_SPNI, *PWW_CDPD_SPNI; - -// -// OID_WW_CDPD_WASI -// -typedef struct _WW_CDPD_WIDE_AREA_SERVICE_ID { - UINT WASI[10]; //10 16-bit wide area service IDs - - INT OperatingMode; // 0 = ignore WASI, - // 1 = Require WASI from list, - // 2 = prefer WASI from list - // 3 = exclude WASI from list. - -} WW_CDPD_WIDE_AREA_SERVICE_ID, *PWW_CDPD_WIDE_AREA_SERVICE_ID; - -// -// OID_WW_CDPD_AREA_COLOR -// -typedef INT WW_CDPD_AREA_COLOR; -// -// OID_WW_CDPD_TX_POWER_LEVEL -// -typedef UINT WW_CDPD_TX_POWER_LEVEL; -// -// OID_WW_CDPD_EID -// -typedef NDIS_VAR_DATA_DESC WW_CDPD_EID; -// -// OID_WW_CDPD_HEADER_COMPRESSION -// -typedef INT WW_CDPD_HEADER_COMPRESSION; // 0 = no header compression, - // 1 = always compress headers, - // 2 = compress headers if MD-IS does - // -1 = unknown -// -// OID_WW_CDPD_DATA_COMPRESSION -// - -typedef INT WW_CDPD_DATA_COMPRESSION; // 0 = no data compression, - // 1 = data compression enabled - // -1 = unknown -// -// OID_WW_CDPD_CHANNEL_SELECT -// - -typedef struct _WW_CDPD_CHANNEL_SELECT { - UINT ChannelID; // channel number - - UINT fixedDuration; // duration in seconds - -} WW_CDPD_CHANNEL_SELECT, *PWW_CDPD_CHANNEL_SELECT; - -// -// OID_WW_CDPD_CHANNEL_STATE -// -typedef enum _WW_CDPD_CHANNEL_STATE { - CDPDChannelNotAvail, - CDPDChannelScanning, - CDPDChannelInitAcquired, - CDPDChannelAcquired, - CDPDChannelSleeping, - CDPDChannelWaking, - CDPDChannelCSDialing, - CDPDChannelCSRedial, - CDPDChannelCSAnswering, - CDPDChannelCSConnected, - CDPDChannelCSSuspended -} WW_CDPD_CHANNEL_STATE, *PWW_CDPD_CHANNEL_STATE; - -// -// OID_WW_CDPD_NEI -// -typedef enum _WW_CDPD_NEI_FORMAT { - CDPDNeiIPv4, - CDPDNeiCLNP, - CDPDNeiIPv6 -} WW_CDPD_NEI_FORMAT, *PWW_CDPD_NEI_FORMAT; -typedef enum _WW_CDPD_NEI_TYPE { - CDPDNeiIndividual, - CDPDNeiMulticast, - CDPDNeiBroadcast -} WW_CDPD_NEI_TYPE; -typedef struct _WW_CDPD_NEI { - UINT uNeiIndex; - WW_CDPD_NEI_FORMAT NeiFormat; - WW_CDPD_NEI_TYPE NeiType; - WORD NeiGmid; // group member identifier, only - // meaningful if NeiType == - // CDPDNeiMulticast - - NDIS_VAR_DATA_DESC NeiAddress; -} WW_CDPD_NEI; - -// -// OID_WW_CDPD_NEI_STATE -// -typedef enum _WW_CDPD_NEI_STATE { - CDPDUnknown, - CDPDRegistered, - CDPDDeregistered -} WW_CDPD_NEI_STATE, *PWW_CDPD_NEI_STATE; -typedef enum _WW_CDPD_NEI_SUB_STATE { - CDPDPending, // Registration pending - CDPDNoReason, // Registration denied - no reason given - CDPDMDISNotCapable, // Registration denied - MD-IS not capable of - // handling M-ES at this time - CDPDNEINotAuthorized, // Registration denied - NEI is not authorized to - // use this subnetwork - CDPDInsufficientAuth, // Registration denied - M-ES gave insufficient - // authentication credentials - CDPDUnsupportedAuth, // Registration denied - M-ES gave unsupported - // authentication credentials - CDPDUsageExceeded, // Registration denied - NEI has exceeded usage - // limitations - CDPDDeniedThisNetwork // Registration denied on this network, service - // may be obtained on alternate Service Provider - // network -} WW_CDPD_NEI_SUB_STATE; -typedef struct _WW_CDPD_NEI_REG_STATE { - UINT uNeiIndex; - WW_CDPD_NEI_STATE NeiState; - WW_CDPD_NEI_SUB_STATE NeiSubState; -} WW_CDPD_NEI_REG_STATE, *PWW_CDPD_NEI_REG_STATE; - -// -// OID_WW_CDPD_SERVICE_PROVIDER_IDENTIFIER -// -typedef struct _WW_CDPD_SERVICE_PROVIDER_ID { - UINT SPI[10]; //10 16-bit service provider IDs - - INT OperatingMode; // 0 = ignore SPI, - // 1 = require SPI from list, - // 2 = prefer SPI from list. - // 3 = exclude SPI from list. - -} WW_CDPD_SERVICE_PROVIDER_ID, *PWW_CDPD_SERVICE_PROVIDER_ID; - -// -// OID_WW_CDPD_SLEEP_MODE -// -typedef INT WW_CDPD_SLEEP_MODE; -// -// OID_WW_CDPD_TEI -// -typedef ULONG WW_CDPD_TEI; -// -// OID_WW_CDPD_CIRCUIT_SWITCHED -// -typedef struct _WW_CDPD_CIRCUIT_SWITCHED { - INT service_preference; // -1 = unknown, - // 0 = always use packet switched CDPD, - // 1 = always use CS CDPD via AMPS, - // 2 = always use CS CDPD via PSTN, - // 3 = use circuit switched via AMPS only - // when packet switched is not available. - // 4 = use packet switched only when circuit - // switched via AMPS is not available. - // 5 = device manuf. defined service - // preference. - // 6 = device manuf. defined service - // preference. - - INT service_status; // -1 = unknown, - // 0 = packet switched CDPD, - // 1 = circuit switched CDPD via AMPS, - // 2 = circuit switched CDPD via PSTN. - - INT connect_rate; // CS connection bit rate (bits per second). - // 0 = no active connection, - // -1 = unknown - // Dial code last used to dial. - - NDIS_VAR_DATA_DESC dial_code[20]; - - UINT sid; // Current AMPS system ID - - INT a_b_side_selection; // -1 = unknown, - // 0 = no AMPS service - // 1 = AMPS "A" side channels selected - // 2 = AMPS "B" side channels selected - - INT AMPS_channel; // -1= unknown - // 0 = no AMPS service. - // 1-1023 = AMPS channel number in use - - UINT action; // 0 = no action - // 1 = suspend (hangup) - // 2 = dial - - // Default dial code for CS CDPD service - // encoded as specified in the CS CDPD - // implementor guidelines. - NDIS_VAR_DATA_DESC default_dial[20]; - - // Number for the CS CDPD network to call - // back the mobile, encoded as specified in - // the CS CDPD implementor guidelines. - NDIS_VAR_DATA_DESC call_back[20]; - - UINT sid_list[10]; // List of 10 16-bit preferred AMPS - // system IDs for CS CDPD. - - UINT inactivity_timer; // Wait time after last data before dropping - // call. - // 0-65535 = inactivity time limit (seconds). - - UINT receive_timer; // secs. per CS-CDPD Implementor Guidelines. - - UINT conn_resp_timer; // secs. per CS-CDPD Implementor Guidelines. - - UINT reconn_resp_timer; // secs. per CS-CDPD Implementor Guidelines. - - UINT disconn_timer; // secs. per CS-CDPD Implementor Guidelines. - - UINT NEI_reg_timer; // secs. per CS-CDPD Implementor Guidelines. - - UINT reconn_retry_timer; // secs. per CS-CDPD Implementor Guidelines. - - UINT link_reset_timer; // secs. per CS-CDPD Implementor Guidelines. - - UINT link_reset_ack_timer; // secs. per CS-CDPD Implementor Guidelines. - - UINT n401_retry_limit; // per CS-CDPD Implementor Guidelines. - - UINT n402_retry_limit; // per CS-CDPD Implementor Guidelines. - - UINT n404_retry_limit; // per CS-CDPD Implementor Guidelines. - - UINT n405_retry_limit; // per CS-CDPD Implementor Guidelines. - -} WW_CDPD_CIRCUIT_SWITCHED, *WW_PCDPD_CIRCUIT_SWITCHED; -typedef UINT WW_CDPD_RSSI; -// -// OID_WW_PIN_LOC_AUTHORIZE -// -typedef INT WW_PIN_AUTHORIZED; // 0 = unauthorized - // 1 = authorized - // -1 = unknown -// -// OID_WW_PIN_LAST_LOCATION -// OID_WW_PIN_LOC_FIX -// - -typedef struct _WW_PIN_LOCATION { - INT Latitude; // Latitude in hundredths of a second - - INT Longitude; // Longitude in hundredths of a second - - INT Altitude; // Altitude in feet - - INT FixTime; // Time of the location fix, since midnight, local time (of the - // current day), in tenths of a second - - INT NetTime; // Current local network time of the current day, since midnight, - // in tenths of a second - - INT LocQuality; // 0-100 = location quality - - INT LatReg; // Latitude registration offset, in hundredths of a second - - INT LongReg; // Longitude registration offset, in hundredths of a second - - INT GMTOffset; // Offset in minutes of the local time zone from GMT - -} WW_PIN_LOCATION, *PWW_PIN_LOCATION; - -// -// The following is set on a per-packet basis as OOB data with NdisClassWirelessWanMbxMailbox -// -typedef ULONG WW_MBX_MAILBOX_FLAG; // 1 = set mailbox flag, 0 = do not set mailbox flag -// -// OID_WW_MBX_SUBADDR -// - -typedef struct _WW_MBX_PMAN { - BOOLEAN ACTION; // 0 = Login PMAN, 1 = Logout PMAN - - UINT MAN; - UCHAR PASSWORD[8]; // Password should be null for Logout and indications. - // Maximum length of password is 8 chars. - -} WW_MBX_PMAN, *PWW_MBX_PMAN; - -// -// OID_WW_MBX_FLEXLIST -// -typedef struct _WW_MBX_FLEXLIST { - INT count; // Number of MAN entries used. - // -1=unknown. - - UINT MAN[7]; // List of MANs. - -} WW_MBX_FLEXLIST; - -// -// OID_WW_MBX_GROUPLIST -// -typedef struct _WW_MBX_GROUPLIST { - INT count; // Number of MAN entries used. - // -1=unknown. - - UINT MAN[15]; // List of MANs. - -} WW_MBX_GROUPLIST; - -// -// OID_WW_MBX_TRAFFIC_AREA -// -typedef enum _WW_MBX_TRAFFIC_AREA { - unknown_traffic_area, // The driver has no information about the current traffic area. - in_traffic_area, // Mobile unit has entered a subscribed traffic area. - in_auth_traffic_area, // Mobile unit is outside traffic area but is authorized. - unauth_traffic_area // Mobile unit is outside traffic area but is un-authorized. -} WW_MBX_TRAFFIC_AREA; - -// -// OID_WW_MBX_LIVE_DIE -// -typedef INT WW_MBX_LIVE_DIE; // 0 = DIE last received - // 1 = LIVE last received - // -1 = unknown -// -// OID_WW_MBX_TEMP_DEFAULTLIST -// - -typedef struct _WW_MBX_CHANNEL_PAIR { - UINT Mobile_Tx; - UINT Mobile_Rx; -} WW_MBX_CHANNEL_PAIR, *PWW_MBX_CHANNEL_PAIR; -typedef struct _WW_MBX_TEMPDEFAULTLIST { - UINT Length; - WW_MBX_CHANNEL_PAIR ChannelPair[1]; -} WW_MBX_TEMPDEFAULTLIST, *WW_PMBX_TEMPDEFAULTLIST; - -#endif // WIRELESS_WAN -#endif // _NTDDNDIS_ +/*++ BUILD Version: 0001 // Increment this if a change has global effects + Copyright (c) 1990-1993 Microsoft Corporation + Module Name: + ntddndis.h + Abstract: + This is the include file that defines all constants and types for + accessing the Network driver interface device. + Author: + Steve Wood (stevewo) 27-May-1990 + Revision History: + Adam Barr (adamba) 04-Nov-1992 added the correct values for NDIS 3.0. + Jameel Hyder (jameelh) 01-Aug-95 added Pnp IoCTLs and structures + Kyle Brandon (kyleb) 09/24/96 added general co ndis oids. + -- */ +#ifndef _NTDDNDIS_ +#define _NTDDNDIS_ +// +// Device Name - this string is the name of the device. It is the name +// that should be passed to NtOpenFile when accessing the device. +// +// Note: For devices that support multiple units, it should be suffixed +// with the Ascii representation of the unit number. +// +#define DD_NDIS_DEVICE_NAME "\\Device\\UNKNOWN" +// +// NtDeviceIoControlFile IoControlCode values for this device. +// +// Warning: Remember that the low two bits of the code specify how the +// buffers are passed to the driver! +// +#define _NDIS_CONTROL_CODE(request,method) \ + CTL_CODE(FILE_DEVICE_PHYSICAL_NETCARD, request, method, FILE_ANY_ACCESS) +#define IOCTL_NDIS_QUERY_GLOBAL_STATS _NDIS_CONTROL_CODE( 0, METHOD_OUT_DIRECT ) +#define IOCTL_NDIS_QUERY_ALL_STATS _NDIS_CONTROL_CODE( 1, METHOD_OUT_DIRECT ) +#define IOCTL_NDIS_ADD_DEVICE _NDIS_CONTROL_CODE( 2, METHOD_BUFFERED ) +#define IOCTL_NDIS_DELETE_DEVICE _NDIS_CONTROL_CODE( 3, METHOD_BUFFERED ) +#define IOCTL_NDIS_TRANSLATE_NAME _NDIS_CONTROL_CODE( 4, METHOD_BUFFERED ) +#define IOCTL_NDIS_ADD_TDI_DEVICE _NDIS_CONTROL_CODE( 5, METHOD_BUFFERED ) +#define IOCTL_NDIS_NOTIFY_PROTOCOL _NDIS_CONTROL_CODE( 6, METHOD_BUFFERED ) +#define IOCTL_NDIS_GET_LOG_DATA _NDIS_CONTROL_CODE( 7, METHOD_OUT_DIRECT ) +// +// NtDeviceIoControlFile InputBuffer/OutputBuffer record structures for +// this device. +// +// +// This is the type of an NDIS OID value. +// +typedef ULONG NDIS_OID, *PNDIS_OID; +// +// IOCTL_NDIS_QUERY_ALL_STATS returns a sequence of these, packed +// together (no padding is required since statistics all have +// four or eight bytes of data). +// +typedef struct _NDIS_STATISTICS_VALUE { + NDIS_OID Oid; + ULONG DataLength; + UCHAR Data[1]; // variable length + +} NDIS_STATISTICS_VALUE, *PNDIS_STATISTICS_VALUE; + +// +// Structure used by TRANSLATE_NAME IOCTL +// +typedef struct _NET_PNP_ID { + ULONG ClassId; + ULONG Token; +} NET_PNP_ID, *PNET_PNP_ID; + +typedef struct _NET_PNP_TRANSLATE_LIST { + ULONG BytesNeeded; + NET_PNP_ID IdArray[ANYSIZE_ARRAY]; +} NET_PNP_TRANSLATE_LIST, *PNET_PNP_TRANSLATE_LIST; + +// +// Structure used to define a self-contained variable data structure +// +typedef struct _NDIS_VAR_DATA_DESC { + USHORT Length; // # of octects of data + + USHORT MaximumLength; // # of octects available + + LONG Offset; // Offset of data relative to the descriptor + +} NDIS_VAR_DATA_DESC, *PNDIS_VAR_DATA_DESC; + +// +// Object Identifiers used by NdisRequest Query/Set Information +// +// +// General Objects +// +#define OID_GEN_SUPPORTED_LIST 0x00010101 +#define OID_GEN_HARDWARE_STATUS 0x00010102 +#define OID_GEN_MEDIA_SUPPORTED 0x00010103 +#define OID_GEN_MEDIA_IN_USE 0x00010104 +#define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105 +#define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106 +#define OID_GEN_LINK_SPEED 0x00010107 +#define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108 +#define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109 +#define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A +#define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B +#define OID_GEN_VENDOR_ID 0x0001010C +#define OID_GEN_VENDOR_DESCRIPTION 0x0001010D +#define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E +#define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F +#define OID_GEN_DRIVER_VERSION 0x00010110 +#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111 +#define OID_GEN_PROTOCOL_OPTIONS 0x00010112 +#define OID_GEN_MAC_OPTIONS 0x00010113 +#define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114 +#define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115 +#define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116 +#define OID_GEN_XMIT_OK 0x00020101 +#define OID_GEN_RCV_OK 0x00020102 +#define OID_GEN_XMIT_ERROR 0x00020103 +#define OID_GEN_RCV_ERROR 0x00020104 +#define OID_GEN_RCV_NO_BUFFER 0x00020105 +#define OID_GEN_DIRECTED_BYTES_XMIT 0x00020201 +#define OID_GEN_DIRECTED_FRAMES_XMIT 0x00020202 +#define OID_GEN_MULTICAST_BYTES_XMIT 0x00020203 +#define OID_GEN_MULTICAST_FRAMES_XMIT 0x00020204 +#define OID_GEN_BROADCAST_BYTES_XMIT 0x00020205 +#define OID_GEN_BROADCAST_FRAMES_XMIT 0x00020206 +#define OID_GEN_DIRECTED_BYTES_RCV 0x00020207 +#define OID_GEN_DIRECTED_FRAMES_RCV 0x00020208 +#define OID_GEN_MULTICAST_BYTES_RCV 0x00020209 +#define OID_GEN_MULTICAST_FRAMES_RCV 0x0002020A +#define OID_GEN_BROADCAST_BYTES_RCV 0x0002020B +#define OID_GEN_BROADCAST_FRAMES_RCV 0x0002020C +#define OID_GEN_RCV_CRC_ERROR 0x0002020D +#define OID_GEN_TRANSMIT_QUEUE_LENGTH 0x0002020E +#define OID_GEN_GET_TIME_CAPS 0x0002020F +#define OID_GEN_GET_NETCARD_TIME 0x00020210 +// +// These are connection-oriented general OIDs. +// These replace the above OIDs for connection-oriented media. +// +#define OID_GEN_CO_SUPPORTED_LIST 0x00010101 +#define OID_GEN_CO_HARDWARE_STATUS 0x00010102 +#define OID_GEN_CO_MEDIA_SUPPORTED 0x00010103 +#define OID_GEN_CO_MEDIA_IN_USE 0x00010104 +#define OID_GEN_CO_LINK_SPEED 0x00010105 +#define OID_GEN_CO_VENDOR_ID 0x00010106 +#define OID_GEN_CO_VENDOR_DESCRIPTION 0x00010107 +#define OID_GEN_CO_DRIVER_VERSION 0x00010108 +#define OID_GEN_CO_PROTOCOL_OPTIONS 0x00010109 +#define OID_GEN_CO_MAC_OPTIONS 0x0001010A +#define OID_GEN_CO_MEDIA_CONNECT_STATUS 0x0001010B +#define OID_GEN_CO_VENDOR_DRIVER_VERSION 0x0001010C +#define OID_GEN_CO_MINIMUM_LINK_SPEED 0x0001010D +#define OID_GEN_CO_GET_TIME_CAPS 0x00010201 +#define OID_GEN_CO_GET_NETCARD_TIME 0x00010202 +// +// These are connection-oriented statistics OIDs. +// +#define OID_GEN_CO_XMIT_PDUS_OK 0x00020101 +#define OID_GEN_CO_RCV_PDUS_OK 0x00020102 +#define OID_GEN_CO_XMIT_PDUS_ERROR 0x00020103 +#define OID_GEN_CO_RCV_PDUS_ERROR 0x00020104 +#define OID_GEN_CO_RCV_PDUS_NO_BUFFER 0x00020105 +#define OID_GEN_CO_RCV_CRC_ERROR 0x00020201 +#define OID_GEN_CO_TRANSMIT_QUEUE_LENGTH 0x00020202 +#define OID_GEN_CO_BYTES_XMIT 0x00020203 +#define OID_GEN_CO_BYTES_RCV 0x00020204 +#define OID_GEN_CO_BYTES_XMIT_OUTSTANDING 0x00020205 +#define OID_GEN_CO_NETCARD_LOAD 0x00020206 +// +// These are objects for Connection-oriented media call-managers and are not +// valid for ndis drivers. Under construction. +// +#define OID_CO_ADD_PVC 0xFF000001 +#define OID_CO_DELETE_PVC 0xFF000002 +#define OID_CO_GET_CALL_INFORMATION 0xFF000003 +#define OID_CO_ADD_ADDRESS 0xFF000004 +#define OID_CO_DELETE_ADDRESS 0xFF000005 +#define OID_CO_GET_ADDRESSES 0xFF000006 +#define OID_CO_ADDRESS_CHANGE 0xFF000007 +#define OID_CO_SIGNALING_ENABLED 0xFF000008 +#define OID_CO_SIGNALING_DISABLED 0xFF000009 +// +// 802.3 Objects (Ethernet) +// +#define OID_802_3_PERMANENT_ADDRESS 0x01010101 +#define OID_802_3_CURRENT_ADDRESS 0x01010102 +#define OID_802_3_MULTICAST_LIST 0x01010103 +#define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104 +#define OID_802_3_MAC_OPTIONS 0x01010105 +// +// +#define NDIS_802_3_MAC_OPTION_PRIORITY 0x00000001 +#define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101 +#define OID_802_3_XMIT_ONE_COLLISION 0x01020102 +#define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103 +#define OID_802_3_XMIT_DEFERRED 0x01020201 +#define OID_802_3_XMIT_MAX_COLLISIONS 0x01020202 +#define OID_802_3_RCV_OVERRUN 0x01020203 +#define OID_802_3_XMIT_UNDERRUN 0x01020204 +#define OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205 +#define OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206 +#define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 +// +// 802.5 Objects (Token-Ring) +// +#define OID_802_5_PERMANENT_ADDRESS 0x02010101 +#define OID_802_5_CURRENT_ADDRESS 0x02010102 +#define OID_802_5_CURRENT_FUNCTIONAL 0x02010103 +#define OID_802_5_CURRENT_GROUP 0x02010104 +#define OID_802_5_LAST_OPEN_STATUS 0x02010105 +#define OID_802_5_CURRENT_RING_STATUS 0x02010106 +#define OID_802_5_CURRENT_RING_STATE 0x02010107 +#define OID_802_5_LINE_ERRORS 0x02020101 +#define OID_802_5_LOST_FRAMES 0x02020102 +#define OID_802_5_BURST_ERRORS 0x02020201 +#define OID_802_5_AC_ERRORS 0x02020202 +#define OID_802_5_ABORT_DELIMETERS 0x02020203 +#define OID_802_5_FRAME_COPIED_ERRORS 0x02020204 +#define OID_802_5_FREQUENCY_ERRORS 0x02020205 +#define OID_802_5_TOKEN_ERRORS 0x02020206 +#define OID_802_5_INTERNAL_ERRORS 0x02020207 +// +// FDDI Objects +// +#define OID_FDDI_LONG_PERMANENT_ADDR 0x03010101 +#define OID_FDDI_LONG_CURRENT_ADDR 0x03010102 +#define OID_FDDI_LONG_MULTICAST_LIST 0x03010103 +#define OID_FDDI_LONG_MAX_LIST_SIZE 0x03010104 +#define OID_FDDI_SHORT_PERMANENT_ADDR 0x03010105 +#define OID_FDDI_SHORT_CURRENT_ADDR 0x03010106 +#define OID_FDDI_SHORT_MULTICAST_LIST 0x03010107 +#define OID_FDDI_SHORT_MAX_LIST_SIZE 0x03010108 +#define OID_FDDI_ATTACHMENT_TYPE 0x03020101 +#define OID_FDDI_UPSTREAM_NODE_LONG 0x03020102 +#define OID_FDDI_DOWNSTREAM_NODE_LONG 0x03020103 +#define OID_FDDI_FRAME_ERRORS 0x03020104 +#define OID_FDDI_FRAMES_LOST 0x03020105 +#define OID_FDDI_RING_MGT_STATE 0x03020106 +#define OID_FDDI_LCT_FAILURES 0x03020107 +#define OID_FDDI_LEM_REJECTS 0x03020108 +#define OID_FDDI_LCONNECTION_STATE 0x03020109 +#define OID_FDDI_SMT_STATION_ID 0x03030201 +#define OID_FDDI_SMT_OP_VERSION_ID 0x03030202 +#define OID_FDDI_SMT_HI_VERSION_ID 0x03030203 +#define OID_FDDI_SMT_LO_VERSION_ID 0x03030204 +#define OID_FDDI_SMT_MANUFACTURER_DATA 0x03030205 +#define OID_FDDI_SMT_USER_DATA 0x03030206 +#define OID_FDDI_SMT_MIB_VERSION_ID 0x03030207 +#define OID_FDDI_SMT_MAC_CT 0x03030208 +#define OID_FDDI_SMT_NON_MASTER_CT 0x03030209 +#define OID_FDDI_SMT_MASTER_CT 0x0303020A +#define OID_FDDI_SMT_AVAILABLE_PATHS 0x0303020B +#define OID_FDDI_SMT_CONFIG_CAPABILITIES 0x0303020C +#define OID_FDDI_SMT_CONFIG_POLICY 0x0303020D +#define OID_FDDI_SMT_CONNECTION_POLICY 0x0303020E +#define OID_FDDI_SMT_T_NOTIFY 0x0303020F +#define OID_FDDI_SMT_STAT_RPT_POLICY 0x03030210 +#define OID_FDDI_SMT_TRACE_MAX_EXPIRATION 0x03030211 +#define OID_FDDI_SMT_PORT_INDEXES 0x03030212 +#define OID_FDDI_SMT_MAC_INDEXES 0x03030213 +#define OID_FDDI_SMT_BYPASS_PRESENT 0x03030214 +#define OID_FDDI_SMT_ECM_STATE 0x03030215 +#define OID_FDDI_SMT_CF_STATE 0x03030216 +#define OID_FDDI_SMT_HOLD_STATE 0x03030217 +#define OID_FDDI_SMT_REMOTE_DISCONNECT_FLAG 0x03030218 +#define OID_FDDI_SMT_STATION_STATUS 0x03030219 +#define OID_FDDI_SMT_PEER_WRAP_FLAG 0x0303021A +#define OID_FDDI_SMT_MSG_TIME_STAMP 0x0303021B +#define OID_FDDI_SMT_TRANSITION_TIME_STAMP 0x0303021C +#define OID_FDDI_SMT_SET_COUNT 0x0303021D +#define OID_FDDI_SMT_LAST_SET_STATION_ID 0x0303021E +#define OID_FDDI_MAC_FRAME_STATUS_FUNCTIONS 0x0303021F +#define OID_FDDI_MAC_BRIDGE_FUNCTIONS 0x03030220 +#define OID_FDDI_MAC_T_MAX_CAPABILITY 0x03030221 +#define OID_FDDI_MAC_TVX_CAPABILITY 0x03030222 +#define OID_FDDI_MAC_AVAILABLE_PATHS 0x03030223 +#define OID_FDDI_MAC_CURRENT_PATH 0x03030224 +#define OID_FDDI_MAC_UPSTREAM_NBR 0x03030225 +#define OID_FDDI_MAC_DOWNSTREAM_NBR 0x03030226 +#define OID_FDDI_MAC_OLD_UPSTREAM_NBR 0x03030227 +#define OID_FDDI_MAC_OLD_DOWNSTREAM_NBR 0x03030228 +#define OID_FDDI_MAC_DUP_ADDRESS_TEST 0x03030229 +#define OID_FDDI_MAC_REQUESTED_PATHS 0x0303022A +#define OID_FDDI_MAC_DOWNSTREAM_PORT_TYPE 0x0303022B +#define OID_FDDI_MAC_INDEX 0x0303022C +#define OID_FDDI_MAC_SMT_ADDRESS 0x0303022D +#define OID_FDDI_MAC_LONG_GRP_ADDRESS 0x0303022E +#define OID_FDDI_MAC_SHORT_GRP_ADDRESS 0x0303022F +#define OID_FDDI_MAC_T_REQ 0x03030230 +#define OID_FDDI_MAC_T_NEG 0x03030231 +#define OID_FDDI_MAC_T_MAX 0x03030232 +#define OID_FDDI_MAC_TVX_VALUE 0x03030233 +#define OID_FDDI_MAC_T_PRI0 0x03030234 +#define OID_FDDI_MAC_T_PRI1 0x03030235 +#define OID_FDDI_MAC_T_PRI2 0x03030236 +#define OID_FDDI_MAC_T_PRI3 0x03030237 +#define OID_FDDI_MAC_T_PRI4 0x03030238 +#define OID_FDDI_MAC_T_PRI5 0x03030239 +#define OID_FDDI_MAC_T_PRI6 0x0303023A +#define OID_FDDI_MAC_FRAME_CT 0x0303023B +#define OID_FDDI_MAC_COPIED_CT 0x0303023C +#define OID_FDDI_MAC_TRANSMIT_CT 0x0303023D +#define OID_FDDI_MAC_TOKEN_CT 0x0303023E +#define OID_FDDI_MAC_ERROR_CT 0x0303023F +#define OID_FDDI_MAC_LOST_CT 0x03030240 +#define OID_FDDI_MAC_TVX_EXPIRED_CT 0x03030241 +#define OID_FDDI_MAC_NOT_COPIED_CT 0x03030242 +#define OID_FDDI_MAC_LATE_CT 0x03030243 +#define OID_FDDI_MAC_RING_OP_CT 0x03030244 +#define OID_FDDI_MAC_FRAME_ERROR_THRESHOLD 0x03030245 +#define OID_FDDI_MAC_FRAME_ERROR_RATIO 0x03030246 +#define OID_FDDI_MAC_NOT_COPIED_THRESHOLD 0x03030247 +#define OID_FDDI_MAC_NOT_COPIED_RATIO 0x03030248 +#define OID_FDDI_MAC_RMT_STATE 0x03030249 +#define OID_FDDI_MAC_DA_FLAG 0x0303024A +#define OID_FDDI_MAC_UNDA_FLAG 0x0303024B +#define OID_FDDI_MAC_FRAME_ERROR_FLAG 0x0303024C +#define OID_FDDI_MAC_NOT_COPIED_FLAG 0x0303024D +#define OID_FDDI_MAC_MA_UNITDATA_AVAILABLE 0x0303024E +#define OID_FDDI_MAC_HARDWARE_PRESENT 0x0303024F +#define OID_FDDI_MAC_MA_UNITDATA_ENABLE 0x03030250 +#define OID_FDDI_PATH_INDEX 0x03030251 +#define OID_FDDI_PATH_RING_LATENCY 0x03030252 +#define OID_FDDI_PATH_TRACE_STATUS 0x03030253 +#define OID_FDDI_PATH_SBA_PAYLOAD 0x03030254 +#define OID_FDDI_PATH_SBA_OVERHEAD 0x03030255 +#define OID_FDDI_PATH_CONFIGURATION 0x03030256 +#define OID_FDDI_PATH_T_R_MODE 0x03030257 +#define OID_FDDI_PATH_SBA_AVAILABLE 0x03030258 +#define OID_FDDI_PATH_TVX_LOWER_BOUND 0x03030259 +#define OID_FDDI_PATH_T_MAX_LOWER_BOUND 0x0303025A +#define OID_FDDI_PATH_MAX_T_REQ 0x0303025B +#define OID_FDDI_PORT_MY_TYPE 0x0303025C +#define OID_FDDI_PORT_NEIGHBOR_TYPE 0x0303025D +#define OID_FDDI_PORT_CONNECTION_POLICIES 0x0303025E +#define OID_FDDI_PORT_MAC_INDICATED 0x0303025F +#define OID_FDDI_PORT_CURRENT_PATH 0x03030260 +#define OID_FDDI_PORT_REQUESTED_PATHS 0x03030261 +#define OID_FDDI_PORT_MAC_PLACEMENT 0x03030262 +#define OID_FDDI_PORT_AVAILABLE_PATHS 0x03030263 +#define OID_FDDI_PORT_MAC_LOOP_TIME 0x03030264 +#define OID_FDDI_PORT_PMD_CLASS 0x03030265 +#define OID_FDDI_PORT_CONNECTION_CAPABILITIES 0x03030266 +#define OID_FDDI_PORT_INDEX 0x03030267 +#define OID_FDDI_PORT_MAINT_LS 0x03030268 +#define OID_FDDI_PORT_BS_FLAG 0x03030269 +#define OID_FDDI_PORT_PC_LS 0x0303026A +#define OID_FDDI_PORT_EB_ERROR_CT 0x0303026B +#define OID_FDDI_PORT_LCT_FAIL_CT 0x0303026C +#define OID_FDDI_PORT_LER_ESTIMATE 0x0303026D +#define OID_FDDI_PORT_LEM_REJECT_CT 0x0303026E +#define OID_FDDI_PORT_LEM_CT 0x0303026F +#define OID_FDDI_PORT_LER_CUTOFF 0x03030270 +#define OID_FDDI_PORT_LER_ALARM 0x03030271 +#define OID_FDDI_PORT_CONNNECT_STATE 0x03030272 +#define OID_FDDI_PORT_PCM_STATE 0x03030273 +#define OID_FDDI_PORT_PC_WITHHOLD 0x03030274 +#define OID_FDDI_PORT_LER_FLAG 0x03030275 +#define OID_FDDI_PORT_HARDWARE_PRESENT 0x03030276 +#define OID_FDDI_SMT_STATION_ACTION 0x03030277 +#define OID_FDDI_PORT_ACTION 0x03030278 +#define OID_FDDI_IF_DESCR 0x03030279 +#define OID_FDDI_IF_TYPE 0x0303027A +#define OID_FDDI_IF_MTU 0x0303027B +#define OID_FDDI_IF_SPEED 0x0303027C +#define OID_FDDI_IF_PHYS_ADDRESS 0x0303027D +#define OID_FDDI_IF_ADMIN_STATUS 0x0303027E +#define OID_FDDI_IF_OPER_STATUS 0x0303027F +#define OID_FDDI_IF_LAST_CHANGE 0x03030280 +#define OID_FDDI_IF_IN_OCTETS 0x03030281 +#define OID_FDDI_IF_IN_UCAST_PKTS 0x03030282 +#define OID_FDDI_IF_IN_NUCAST_PKTS 0x03030283 +#define OID_FDDI_IF_IN_DISCARDS 0x03030284 +#define OID_FDDI_IF_IN_ERRORS 0x03030285 +#define OID_FDDI_IF_IN_UNKNOWN_PROTOS 0x03030286 +#define OID_FDDI_IF_OUT_OCTETS 0x03030287 +#define OID_FDDI_IF_OUT_UCAST_PKTS 0x03030288 +#define OID_FDDI_IF_OUT_NUCAST_PKTS 0x03030289 +#define OID_FDDI_IF_OUT_DISCARDS 0x0303028A +#define OID_FDDI_IF_OUT_ERRORS 0x0303028B +#define OID_FDDI_IF_OUT_QLEN 0x0303028C +#define OID_FDDI_IF_SPECIFIC 0x0303028D +// +// WAN objects +// +#define OID_WAN_PERMANENT_ADDRESS 0x04010101 +#define OID_WAN_CURRENT_ADDRESS 0x04010102 +#define OID_WAN_QUALITY_OF_SERVICE 0x04010103 +#define OID_WAN_PROTOCOL_TYPE 0x04010104 +#define OID_WAN_MEDIUM_SUBTYPE 0x04010105 +#define OID_WAN_HEADER_FORMAT 0x04010106 +#define OID_WAN_GET_INFO 0x04010107 +#define OID_WAN_SET_LINK_INFO 0x04010108 +#define OID_WAN_GET_LINK_INFO 0x04010109 +#define OID_WAN_LINE_COUNT 0x0401010A +#define OID_WAN_GET_BRIDGE_INFO 0x0401020A +#define OID_WAN_SET_BRIDGE_INFO 0x0401020B +#define OID_WAN_GET_COMP_INFO 0x0401020C +#define OID_WAN_SET_COMP_INFO 0x0401020D +#define OID_WAN_GET_STATS_INFO 0x0401020E +// +// LocalTalk objects +// +#define OID_LTALK_CURRENT_NODE_ID 0x05010102 +#define OID_LTALK_IN_BROADCASTS 0x05020101 +#define OID_LTALK_IN_LENGTH_ERRORS 0x05020102 +#define OID_LTALK_OUT_NO_HANDLERS 0x05020201 +#define OID_LTALK_COLLISIONS 0x05020202 +#define OID_LTALK_DEFERS 0x05020203 +#define OID_LTALK_NO_DATA_ERRORS 0x05020204 +#define OID_LTALK_RANDOM_CTS_ERRORS 0x05020205 +#define OID_LTALK_FCS_ERRORS 0x05020206 +// +// Arcnet objects +// +#define OID_ARCNET_PERMANENT_ADDRESS 0x06010101 +#define OID_ARCNET_CURRENT_ADDRESS 0x06010102 +#define OID_ARCNET_RECONFIGURATIONS 0x06020201 +// +// TAPI objects +// +#define OID_TAPI_ACCEPT 0x07030101 +#define OID_TAPI_ANSWER 0x07030102 +#define OID_TAPI_CLOSE 0x07030103 +#define OID_TAPI_CLOSE_CALL 0x07030104 +#define OID_TAPI_CONDITIONAL_MEDIA_DETECTION 0x07030105 +#define OID_TAPI_CONFIG_DIALOG 0x07030106 +#define OID_TAPI_DEV_SPECIFIC 0x07030107 +#define OID_TAPI_DIAL 0x07030108 +#define OID_TAPI_DROP 0x07030109 +#define OID_TAPI_GET_ADDRESS_CAPS 0x0703010A +#define OID_TAPI_GET_ADDRESS_ID 0x0703010B +#define OID_TAPI_GET_ADDRESS_STATUS 0x0703010C +#define OID_TAPI_GET_CALL_ADDRESS_ID 0x0703010D +#define OID_TAPI_GET_CALL_INFO 0x0703010E +#define OID_TAPI_GET_CALL_STATUS 0x0703010F +#define OID_TAPI_GET_DEV_CAPS 0x07030110 +#define OID_TAPI_GET_DEV_CONFIG 0x07030111 +#define OID_TAPI_GET_EXTENSION_ID 0x07030112 +#define OID_TAPI_GET_ID 0x07030113 +#define OID_TAPI_GET_LINE_DEV_STATUS 0x07030114 +#define OID_TAPI_MAKE_CALL 0x07030115 +#define OID_TAPI_NEGOTIATE_EXT_VERSION 0x07030116 +#define OID_TAPI_OPEN 0x07030117 +#define OID_TAPI_PROVIDER_INITIALIZE 0x07030118 +#define OID_TAPI_PROVIDER_SHUTDOWN 0x07030119 +#define OID_TAPI_SECURE_CALL 0x0703011A +#define OID_TAPI_SELECT_EXT_VERSION 0x0703011B +#define OID_TAPI_SEND_USER_USER_INFO 0x0703011C +#define OID_TAPI_SET_APP_SPECIFIC 0x0703011D +#define OID_TAPI_SET_CALL_PARAMS 0x0703011E +#define OID_TAPI_SET_DEFAULT_MEDIA_DETECTION 0x0703011F +#define OID_TAPI_SET_DEV_CONFIG 0x07030120 +#define OID_TAPI_SET_MEDIA_MODE 0x07030121 +#define OID_TAPI_SET_STATUS_MESSAGES 0x07030122 +// +// ATM Connection Oriented Ndis +// +#define OID_ATM_SUPPORTED_VC_RATES 0x08010101 +#define OID_ATM_SUPPORTED_SERVICE_CATEGORY 0x08010102 +#define OID_ATM_SUPPORTED_AAL_TYPES 0x08010103 +#define OID_ATM_HW_CURRENT_ADDRESS 0x08010104 +#define OID_ATM_MAX_ACTIVE_VCS 0x08010105 +#define OID_ATM_MAX_ACTIVE_VCI_BITS 0x08010106 +#define OID_ATM_MAX_ACTIVE_VPI_BITS 0x08010107 +#define OID_ATM_MAX_AAL0_PACKET_SIZE 0x08010108 +#define OID_ATM_MAX_AAL1_PACKET_SIZE 0x08010109 +#define OID_ATM_MAX_AAL34_PACKET_SIZE 0x0801010A +#define OID_ATM_MAX_AAL5_PACKET_SIZE 0x0801010B +#define OID_ATM_SIGNALING_VPIVCI 0x08010201 +#define OID_ATM_ASSIGNED_VPI 0x08010202 +#define OID_ATM_ACQUIRE_ACCESS_NET_RESOURCES 0x08010203 +#define OID_ATM_RELEASE_ACCESS_NET_RESOURCES 0x08010204 +#define OID_ATM_ILMI_VPIVCI 0x08010205 +#define OID_ATM_DIGITAL_BROADCAST_VPIVCI 0x08010206 +#define OID_ATM_GET_NEAREST_FLOW 0x08010207 +#define OID_ATM_ALIGNMENT_REQUIRED 0x08010208 +// +// ATM specific statistics OIDs. +// +#define OID_ATM_RCV_CELLS_OK 0x08020101 +#define OID_ATM_XMIT_CELLS_OK 0x08020102 +#define OID_ATM_RCV_CELLS_DROPPED 0x08020103 +#define OID_ATM_RCV_INVALID_VPI_VCI 0x08020201 +#define OID_ATM_CELLS_HEC_ERROR 0x08020202 +#define OID_ATM_RCV_REASSEMBLY_ERROR 0x08020203 +// +// PCCA (Wireless) object +// +// +// All WirelessWAN devices must support the following OIDs +// +#define OID_WW_GEN_NETWORK_TYPES_SUPPORTED 0x09010101 +#define OID_WW_GEN_NETWORK_TYPE_IN_USE 0x09010102 +#define OID_WW_GEN_HEADER_FORMATS_SUPPORTED 0x09010103 +#define OID_WW_GEN_HEADER_FORMAT_IN_USE 0x09010104 +#define OID_WW_GEN_INDICATION_REQUEST 0x09010105 +#define OID_WW_GEN_DEVICE_INFO 0x09010106 +#define OID_WW_GEN_OPERATION_MODE 0x09010107 +#define OID_WW_GEN_LOCK_STATUS 0x09010108 +#define OID_WW_GEN_DISABLE_TRANSMITTER 0x09010109 +#define OID_WW_GEN_NETWORK_ID 0x0901010A +#define OID_WW_GEN_PERMANENT_ADDRESS 0x0901010B +#define OID_WW_GEN_CURRENT_ADDRESS 0x0901010C +#define OID_WW_GEN_SUSPEND_DRIVER 0x0901010D +#define OID_WW_GEN_BASESTATION_ID 0x0901010E +#define OID_WW_GEN_CHANNEL_ID 0x0901010F +#define OID_WW_GEN_ENCRYPTION_SUPPORTED 0x09010110 +#define OID_WW_GEN_ENCRYPTION_IN_USE 0x09010111 +#define OID_WW_GEN_ENCRYPTION_STATE 0x09010112 +#define OID_WW_GEN_CHANNEL_QUALITY 0x09010113 +#define OID_WW_GEN_REGISTRATION_STATUS 0x09010114 +#define OID_WW_GEN_RADIO_LINK_SPEED 0x09010115 +#define OID_WW_GEN_LATENCY 0x09010116 +#define OID_WW_GEN_BATTERY_LEVEL 0x09010117 +#define OID_WW_GEN_EXTERNAL_POWER 0x09010118 +// +// Network Dependent OIDs - Mobitex: +// +#define OID_WW_MBX_SUBADDR 0x09050101 +// OID 0x09050102 is reserved and may not be used +#define OID_WW_MBX_FLEXLIST 0x09050103 +#define OID_WW_MBX_GROUPLIST 0x09050104 +#define OID_WW_MBX_TRAFFIC_AREA 0x09050105 +#define OID_WW_MBX_LIVE_DIE 0x09050106 +#define OID_WW_MBX_TEMP_DEFAULTLIST 0x09050107 +// +// Network Dependent OIDs - Pinpoint: +// +#define OID_WW_PIN_LOC_AUTHORIZE 0x09090101 +#define OID_WW_PIN_LAST_LOCATION 0x09090102 +#define OID_WW_PIN_LOC_FIX 0x09090103 +// +// Network Dependent - CDPD: +// +#define OID_WW_CDPD_SPNI 0x090D0101 +#define OID_WW_CDPD_WASI 0x090D0102 +#define OID_WW_CDPD_AREA_COLOR 0x090D0103 +#define OID_WW_CDPD_TX_POWER_LEVEL 0x090D0104 +#define OID_WW_CDPD_EID 0x090D0105 +#define OID_WW_CDPD_HEADER_COMPRESSION 0x090D0106 +#define OID_WW_CDPD_DATA_COMPRESSION 0x090D0107 +#define OID_WW_CDPD_CHANNEL_SELECT 0x090D0108 +#define OID_WW_CDPD_CHANNEL_STATE 0x090D0109 +#define OID_WW_CDPD_NEI 0x090D010A +#define OID_WW_CDPD_NEI_STATE 0x090D010B +#define OID_WW_CDPD_SERVICE_PROVIDER_IDENTIFIER 0x090D010C +#define OID_WW_CDPD_SLEEP_MODE 0x090D010D +#define OID_WW_CDPD_CIRCUIT_SWITCHED 0x090D010E +#define OID_WW_CDPD_TEI 0x090D010F +#define OID_WW_CDPD_RSSI 0x090D0110 +// +// Network Dependent - Ardis: +// +#define OID_WW_ARD_SNDCP 0x09110101 +#define OID_WW_ARD_TMLY_MSG 0x09110102 +#define OID_WW_ARD_DATAGRAM 0x09110103 +// +// Network Dependent - DataTac: +// +#define OID_WW_TAC_COMPRESSION 0x09150101 +#define OID_WW_TAC_SET_CONFIG 0x09150102 +#define OID_WW_TAC_GET_STATUS 0x09150103 +#define OID_WW_TAC_USER_HEADER 0x09150104 +// +// Network Dependent - Metricom: +// +#define OID_WW_MET_FUNCTION 0x09190101 +// +// IRDA objects +// +#define OID_IRDA_RECEIVING 0x0A010100 +#define OID_IRDA_TURNAROUND_TIME 0x0A010101 +#define OID_IRDA_SUPPORTED_SPEEDS 0x0A010102 +#define OID_IRDA_LINK_SPEED 0x0A010103 +#define OID_IRDA_MEDIA_BUSY 0x0A010104 +#define OID_IRDA_EXTRA_RCV_BOFS 0x0A010200 +#define OID_IRDA_RATE_SNIFF 0x0A010201 +#define OID_IRDA_UNICAST_LIST 0x0A010202 +#define OID_IRDA_MAX_UNICAST_LIST_SIZE 0x0A010203 +#define OID_IRDA_MAX_RECEIVE_WINDOW_SIZE 0x0A010204 +#define OID_IRDA_MAX_SEND_WINDOW_SIZE 0x0A010205 +// +// Medium the Ndis Driver is running on (OID_GEN_MEDIA_SUPPORTED/ +// OID_GEN_MEDIA_IN_USE). +// +typedef enum _NDIS_MEDIUM { + NdisMedium802_3, + NdisMedium802_5, + NdisMediumFddi, + NdisMediumWan, + NdisMediumLocalTalk, + NdisMediumDix, // defined for convenience, not a real medium + NdisMediumArcnetRaw, + NdisMediumArcnet878_2, + NdisMediumAtm, + NdisMediumWirelessWan, + NdisMediumIrda, + NdisMediumMax // Not a real medium, defined as an upper-bound +} NDIS_MEDIUM, *PNDIS_MEDIUM; + +// +// Hardware status codes (OID_GEN_HARDWARE_STATUS). +// +typedef enum _NDIS_HARDWARE_STATUS { + NdisHardwareStatusReady, + NdisHardwareStatusInitializing, + NdisHardwareStatusReset, + NdisHardwareStatusClosing, + NdisHardwareStatusNotReady +} NDIS_HARDWARE_STATUS, *PNDIS_HARDWARE_STATUS; + +// +// this is the type passed in the OID_GEN_GET_TIME_CAPS request +// +typedef struct _GEN_GET_TIME_CAPS { + ULONG Flags; // Bits defined below + + ULONG ClockPrecision; +} GEN_GET_TIME_CAPS, *PGEN_GET_TIME_CAPS; + +#define READABLE_LOCAL_CLOCK 0x000000001 +#define CLOCK_NETWORK_DERIVED 0x000000002 +#define CLOCK_PRECISION 0x000000004 +#define RECEIVE_TIME_INDICATION_CAPABLE 0x000000008 +#define TIMED_SEND_CAPABLE 0x000000010 +#define TIME_STAMP_CAPABLE 0x000000020 +// +// +// this is the type passed in the OID_GEN_GET_NETCARD_TIME request +// +typedef struct _GEN_GET_NETCARD_TIME { + ULONG ReadTime; +} GEN_GET_NETCARD_TIME, *PGEN_GET_NETCARD_TIME; + +// +// Defines the attachment types for FDDI (OID_FDDI_ATTACHMENT_TYPE). +// +typedef enum _NDIS_FDDI_ATTACHMENT_TYPE { + NdisFddiTypeIsolated = 1, + NdisFddiTypeLocalA, + NdisFddiTypeLocalB, + NdisFddiTypeLocalAB, + NdisFddiTypeLocalS, + NdisFddiTypeWrapA, + NdisFddiTypeWrapB, + NdisFddiTypeWrapAB, + NdisFddiTypeWrapS, + NdisFddiTypeCWrapA, + NdisFddiTypeCWrapB, + NdisFddiTypeCWrapS, + NdisFddiTypeThrough +} NDIS_FDDI_ATTACHMENT_TYPE, *PNDIS_FDDI_ATTACHMENT_TYPE; + +// +// Defines the ring management states for FDDI (OID_FDDI_RING_MGT_STATE). +// +typedef enum _NDIS_FDDI_RING_MGT_STATE { + NdisFddiRingIsolated = 1, + NdisFddiRingNonOperational, + NdisFddiRingOperational, + NdisFddiRingDetect, + NdisFddiRingNonOperationalDup, + NdisFddiRingOperationalDup, + NdisFddiRingDirected, + NdisFddiRingTrace +} NDIS_FDDI_RING_MGT_STATE, *PNDIS_FDDI_RING_MGT_STATE; + +// +// Defines the Lconnection state for FDDI (OID_FDDI_LCONNECTION_STATE). +// +typedef enum _NDIS_FDDI_LCONNECTION_STATE { + NdisFddiStateOff = 1, + NdisFddiStateBreak, + NdisFddiStateTrace, + NdisFddiStateConnect, + NdisFddiStateNext, + NdisFddiStateSignal, + NdisFddiStateJoin, + NdisFddiStateVerify, + NdisFddiStateActive, + NdisFddiStateMaintenance +} NDIS_FDDI_LCONNECTION_STATE, *PNDIS_FDDI_LCONNECTION_STATE; + +// +// Defines the medium subtypes for WAN medium (OID_WAN_MEDIUM_SUBTYPE). +// +typedef enum _NDIS_WAN_MEDIUM_SUBTYPE { + NdisWanMediumHub, + NdisWanMediumX_25, + NdisWanMediumIsdn, + NdisWanMediumSerial, + NdisWanMediumFrameRelay, + NdisWanMediumAtm, + NdisWanMediumSonet, + NdisWanMediumSW56K +} NDIS_WAN_MEDIUM_SUBTYPE, *PNDIS_WAN_MEDIUM_SUBTYPE; + +// +// Defines the header format for WAN medium (OID_WAN_HEADER_FORMAT). +// +typedef enum _NDIS_WAN_HEADER_FORMAT { + NdisWanHeaderNative, // src/dest based on subtype, followed by NLPID + NdisWanHeaderEthernet // emulation of ethernet header +} NDIS_WAN_HEADER_FORMAT, *PNDIS_WAN_HEADER_FORMAT; + +// +// Defines the line quality on a WAN line (OID_WAN_QUALITY_OF_SERVICE). +// +typedef enum _NDIS_WAN_QUALITY { + NdisWanRaw, + NdisWanErrorControl, + NdisWanReliable +} NDIS_WAN_QUALITY, *PNDIS_WAN_QUALITY; + +// +// Defines the state of a token-ring adapter (OID_802_5_CURRENT_RING_STATE). +// +typedef enum _NDIS_802_5_RING_STATE { + NdisRingStateOpened = 1, + NdisRingStateClosed, + NdisRingStateOpening, + NdisRingStateClosing, + NdisRingStateOpenFailure, + NdisRingStateRingFailure +} NDIS_802_5_RING_STATE, *PNDIS_802_5_RING_STATE; + +// +// Defines the state of the LAN media +// +typedef enum _NDIS_MEDIA_STATE { + NdisMediaStateConnected, + NdisMediaStateDisconnected +} NDIS_MEDIA_STATE, *PNDIS_MEDIA_STATE; + +// +// The following is set on a per-packet basis as OOB data with NdisClass802_3Priority +// +typedef ULONG Priority_802_3; // 0-7 priority levels +// +// The following structure is used to query OID_GEN_CO_LINK_SPEED and +// OID_GEN_CO_MINIMUM_LINK_SPEED. The first OID will return the current +// link speed of the adapter. The second will return the minimum link speed +// the adapter is capable of. +// + +typedef struct _NDIS_CO_LINK_SPEED { + ULONG Outbound; + ULONG Inbound; +} NDIS_CO_LINK_SPEED, + +*PNDIS_CO_LINK_SPEED; +// +// Ndis Packet Filter Bits (OID_GEN_CURRENT_PACKET_FILTER). +// +#define NDIS_PACKET_TYPE_DIRECTED 0x0001 +#define NDIS_PACKET_TYPE_MULTICAST 0x0002 +#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x0004 +#define NDIS_PACKET_TYPE_BROADCAST 0x0008 +#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x0010 +#define NDIS_PACKET_TYPE_PROMISCUOUS 0x0020 +#define NDIS_PACKET_TYPE_SMT 0x0040 +#define NDIS_PACKET_TYPE_ALL_LOCAL 0x0080 +#define NDIS_PACKET_TYPE_MAC_FRAME 0x8000 +#define NDIS_PACKET_TYPE_FUNCTIONAL 0x4000 +#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x2000 +#define NDIS_PACKET_TYPE_GROUP 0x1000 +// +// Ndis Token-Ring Ring Status Codes (OID_802_5_CURRENT_RING_STATUS). +// +#define NDIS_RING_SIGNAL_LOSS 0x00008000 +#define NDIS_RING_HARD_ERROR 0x00004000 +#define NDIS_RING_SOFT_ERROR 0x00002000 +#define NDIS_RING_TRANSMIT_BEACON 0x00001000 +#define NDIS_RING_LOBE_WIRE_FAULT 0x00000800 +#define NDIS_RING_AUTO_REMOVAL_ERROR 0x00000400 +#define NDIS_RING_REMOVE_RECEIVED 0x00000200 +#define NDIS_RING_COUNTER_OVERFLOW 0x00000100 +#define NDIS_RING_SINGLE_STATION 0x00000080 +#define NDIS_RING_RING_RECOVERY 0x00000040 +// +// Ndis protocol option bits (OID_GEN_PROTOCOL_OPTIONS). +// +#define NDIS_PROT_OPTION_ESTIMATED_LENGTH 0x00000001 +#define NDIS_PROT_OPTION_NO_LOOPBACK 0x00000002 +#define NDIS_PROT_OPTION_NO_RSVD_ON_RCVPKT 0x00000004 +// +// Ndis MAC option bits (OID_GEN_MAC_OPTIONS). +// +#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA 0x00000001 +#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED 0x00000002 +#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND 0x00000004 +#define NDIS_MAC_OPTION_NO_LOOPBACK 0x00000008 +#define NDIS_MAC_OPTION_FULL_DUPLEX 0x00000010 +#define NDIS_MAC_OPTION_EOTX_INDICATION 0x00000020 +#define NDIS_MAC_OPTION_RESERVED 0x80000000 +// +// NDIS MAC option bits for OID_GEN_CO_MAC_OPTIONS. +// +#define NDIS_CO_MAC_OPTION_DYNAMIC_LINK_SPEED 0x00000001 +#ifdef IRDA +// +// The following is set on a per-packet basis as OOB data with NdisClassIrdaPacketInfo +// This is the per-packet info specified on a per-packet basis +// +typedef struct _NDIS_IRDA_PACKET_INFO { + UINT ExtraBOFs; + UINT MinTurnAroundTime; +} NDIS_IRDA_PACKET_INFO, *PNDIS_IRDA_PACKET_INFO; + +#endif +#ifdef WIRELESS_WAN +// +// Wireless WAN structure definitions +// +// +// currently defined Wireless network subtypes +// +typedef enum _NDIS_WW_NETWORK_TYPE { + NdisWWGeneric, + NdisWWMobitex, + NdisWWPinpoint, + NdisWWCDPD, + NdisWWArdis, + NdisWWDataTAC, + NdisWWMetricom, + NdisWWGSM, + NdisWWCDMA, + NdisWWTDMA, + NdisWWAMPS, + NdisWWInmarsat, + NdisWWpACT +} NDIS_WW_NETWORK_TYPE; + +// +// currently defined header formats +// +typedef enum _NDIS_WW_HEADER_FORMAT { + NdisWWDIXEthernetFrames, + NdisWWMPAKFrames, + NdisWWRDLAPFrames, + NdisWWMDC4800Frames +} NDIS_WW_HEADER_FORMAT; + +// +// currently defined encryption types +// +typedef enum _NDIS_WW_ENCRYPTION_TYPE { + NdisWWUnknownEncryption = -1, + NdisWWNoEncryption, + NdisWWDefaultEncryption +} NDIS_WW_ENCRYPTION_TYPE, *PNDIS_WW_ENCRYPTION_TYPE; + +// +// OID_WW_GEN_INDICATION_REQUEST +// +typedef struct _NDIS_WW_INDICATION_REQUEST { + NDIS_OID Oid; // IN + + UINT uIndicationFlag; // IN + + UINT uApplicationToken; // IN OUT + + HANDLE hIndicationHandle; // IN OUT + + INT iPollingInterval; // IN OUT + + NDIS_VAR_DATA_DESC InitialValue; // IN OUT + + NDIS_VAR_DATA_DESC OIDIndicationValue; // OUT - only valid after indication + + NDIS_VAR_DATA_DESC TriggerValue; // IN + +} NDIS_WW_INDICATION_REQUEST, *PNDIS_WW_INDICATION_REQUEST; + +#define OID_INDICATION_REQUEST_ENABLE 0x0000 +#define OID_INDICATION_REQUEST_CANCEL 0x0001 +// +// OID_WW_GEN_DEVICE_INFO +// +typedef struct _WW_DEVICE_INFO { + NDIS_VAR_DATA_DESC Manufacturer; + NDIS_VAR_DATA_DESC ModelNum; + NDIS_VAR_DATA_DESC SWVersionNum; + NDIS_VAR_DATA_DESC SerialNum; +} WW_DEVICE_INFO, *PWW_DEVICE_INFO; + +// +// OID_WW_GEN_OPERATION_MODE +// +typedef INT WW_OPERATION_MODE; // 0 = Normal mode + // 1 = Power saving mode + // -1 = mode unknown +// +// OID_WW_GEN_LOCK_STATUS +// + +typedef INT WW_LOCK_STATUS; // 0 = unlocked + // 1 = locked + // -1 = unknown lock status +// +// OID_WW_GEN_DISABLE_TRANSMITTER +// + +typedef INT WW_DISABLE_TRANSMITTER; // 0 = transmitter enabled + // 1 = transmitter disabled + // -1 = unknown value +// +// OID_WW_GEN_NETWORK_ID +// + +typedef NDIS_VAR_DATA_DESC WW_NETWORK_ID; +// +// OID_WW_GEN_PERMANENT_ADDRESS +// +typedef NDIS_VAR_DATA_DESC WW_PERMANENT_ADDRESS; +// +// OID_WW_GEN_CURRENT_ADDRESS +// +typedef struct _WW_CURRENT_ADDRESS { + NDIS_WW_HEADER_FORMAT Format; + NDIS_VAR_DATA_DESC Address; +} WW_CURRENT_ADDRESS, *PWW_CURRENT_ADDRESS; + +// +// OID_WW_GEN_SUSPEND_DRIVER +// +typedef BOOLEAN WW_SUSPEND_DRIVER; // 0 = driver operational + // 1 = driver suspended +// +// OID_WW_GEN_BASESTATION_ID +// + +typedef NDIS_VAR_DATA_DESC WW_BASESTATION_ID; +// +// OID_WW_GEN_CHANNEL_ID +// +typedef NDIS_VAR_DATA_DESC WW_CHANNEL_ID; +// +// OID_WW_GEN_ENCRYPTION_STATE +// +typedef BOOLEAN WW_ENCRYPTION_STATE; // 0 = if encryption is disabled + // 1 = if encryption is enabled +// +// OID_WW_GEN_CHANNEL_QUALITY +// + +typedef INT WW_CHANNEL_QUALITY; // 0 = Not in network contact, + // 1-100 = Quality of Channel (100 is highest quality). + // -1 = channel quality is unknown +// +// OID_WW_GEN_REGISTRATION_STATUS +// + +typedef INT WW_REGISTRATION_STATUS; // 0 = Registration denied + // 1 = Registration pending + // 2 = Registered + // -1 = unknown registration status +// +// OID_WW_GEN_RADIO_LINK_SPEED +// + +typedef UINT WW_RADIO_LINK_SPEED; // Bits per second. +// +// OID_WW_GEN_LATENCY +// + +typedef UINT WW_LATENCY; // milliseconds +// +// OID_WW_GEN_BATTERY_LEVEL +// + +typedef INT WW_BATTERY_LEVEL; // 0-100 = battery level in percentage + // (100=fully charged) + // -1 = unknown battery level. +// +// OID_WW_GEN_EXTERNAL_POWER +// + +typedef INT WW_EXTERNAL_POWER; // 0 = no external power connected + // 1 = external power connected + // -1 = unknown +// +// OID_WW_MET_FUNCTION +// + +typedef NDIS_VAR_DATA_DESC WW_MET_FUNCTION; +// +// OID_WW_TAC_COMPRESSION +// +typedef BOOLEAN WW_TAC_COMPRESSION; // Determines whether or not network level compression + // is being used. +// +// OID_WW_TAC_SET_CONFIG +// + +typedef struct _WW_TAC_SETCONFIG { + NDIS_VAR_DATA_DESC RCV_MODE; + NDIS_VAR_DATA_DESC TX_CONTROL; + NDIS_VAR_DATA_DESC RX_CONTROL; + NDIS_VAR_DATA_DESC FLOW_CONTROL; + NDIS_VAR_DATA_DESC RESET_CNF; + NDIS_VAR_DATA_DESC READ_CNF; +} WW_TAC_SETCONFIG, *PWW_TAC_SETCONFIG; + +// +// OID_WW_TAC_GET_STATUS +// +typedef struct _WW_TAC_GETSTATUS { + BOOLEAN Action; // Set = Execute command. + + NDIS_VAR_DATA_DESC Command; + NDIS_VAR_DATA_DESC Option; + NDIS_VAR_DATA_DESC Response; // The response to the requested command + // - max. length of string is 256 octets. + +} WW_TAC_GETSTATUS, *PWW_TAC_GETSTATUS; + +// +// OID_WW_TAC_USER_HEADER +// +typedef NDIS_VAR_DATA_DESC WW_TAC_USERHEADER; // This will hold the user header - Max. 64 octets. +// +// OID_WW_ARD_SNDCP +// + +typedef struct _WW_ARD_SNDCP { + NDIS_VAR_DATA_DESC Version; // The version of SNDCP protocol supported. + + INT BlockSize; // The block size used for SNDCP + + INT Window; // The window size used in SNDCP + +} WW_ARD_SNDCP, *PWW_ARD_SNDCP; + +// +// OID_WW_ARD_TMLY_MSG +// +typedef BOOLEAN WW_ARD_CHANNEL_STATUS; // The current status of the inbound RF Channel. +// +// OID_WW_ARD_DATAGRAM +// + +typedef struct _WW_ARD_DATAGRAM { + BOOLEAN LoadLevel; // Byte that contains the load level info. + + INT SessionTime; // Datagram session time remaining. + + NDIS_VAR_DATA_DESC HostAddr; // Host address. + + NDIS_VAR_DATA_DESC THostAddr; // Test host address. + +} WW_ARD_DATAGRAM, *PWW_ARD_DATAGRAM; + +// +// OID_WW_CDPD_SPNI +// +typedef struct _WW_CDPD_SPNI { + UINT SPNI[10]; //10 16-bit service provider network IDs + + INT OperatingMode; // 0 = ignore SPNI, + // 1 = require SPNI from list, + // 2 = prefer SPNI from list. + // 3 = exclude SPNI from list. + +} WW_CDPD_SPNI, *PWW_CDPD_SPNI; + +// +// OID_WW_CDPD_WASI +// +typedef struct _WW_CDPD_WIDE_AREA_SERVICE_ID { + UINT WASI[10]; //10 16-bit wide area service IDs + + INT OperatingMode; // 0 = ignore WASI, + // 1 = Require WASI from list, + // 2 = prefer WASI from list + // 3 = exclude WASI from list. + +} WW_CDPD_WIDE_AREA_SERVICE_ID, *PWW_CDPD_WIDE_AREA_SERVICE_ID; + +// +// OID_WW_CDPD_AREA_COLOR +// +typedef INT WW_CDPD_AREA_COLOR; +// +// OID_WW_CDPD_TX_POWER_LEVEL +// +typedef UINT WW_CDPD_TX_POWER_LEVEL; +// +// OID_WW_CDPD_EID +// +typedef NDIS_VAR_DATA_DESC WW_CDPD_EID; +// +// OID_WW_CDPD_HEADER_COMPRESSION +// +typedef INT WW_CDPD_HEADER_COMPRESSION; // 0 = no header compression, + // 1 = always compress headers, + // 2 = compress headers if MD-IS does + // -1 = unknown +// +// OID_WW_CDPD_DATA_COMPRESSION +// + +typedef INT WW_CDPD_DATA_COMPRESSION; // 0 = no data compression, + // 1 = data compression enabled + // -1 = unknown +// +// OID_WW_CDPD_CHANNEL_SELECT +// + +typedef struct _WW_CDPD_CHANNEL_SELECT { + UINT ChannelID; // channel number + + UINT fixedDuration; // duration in seconds + +} WW_CDPD_CHANNEL_SELECT, *PWW_CDPD_CHANNEL_SELECT; + +// +// OID_WW_CDPD_CHANNEL_STATE +// +typedef enum _WW_CDPD_CHANNEL_STATE { + CDPDChannelNotAvail, + CDPDChannelScanning, + CDPDChannelInitAcquired, + CDPDChannelAcquired, + CDPDChannelSleeping, + CDPDChannelWaking, + CDPDChannelCSDialing, + CDPDChannelCSRedial, + CDPDChannelCSAnswering, + CDPDChannelCSConnected, + CDPDChannelCSSuspended +} WW_CDPD_CHANNEL_STATE, *PWW_CDPD_CHANNEL_STATE; + +// +// OID_WW_CDPD_NEI +// +typedef enum _WW_CDPD_NEI_FORMAT { + CDPDNeiIPv4, + CDPDNeiCLNP, + CDPDNeiIPv6 +} WW_CDPD_NEI_FORMAT, *PWW_CDPD_NEI_FORMAT; +typedef enum _WW_CDPD_NEI_TYPE { + CDPDNeiIndividual, + CDPDNeiMulticast, + CDPDNeiBroadcast +} WW_CDPD_NEI_TYPE; +typedef struct _WW_CDPD_NEI { + UINT uNeiIndex; + WW_CDPD_NEI_FORMAT NeiFormat; + WW_CDPD_NEI_TYPE NeiType; + WORD NeiGmid; // group member identifier, only + // meaningful if NeiType == + // CDPDNeiMulticast + + NDIS_VAR_DATA_DESC NeiAddress; +} WW_CDPD_NEI; + +// +// OID_WW_CDPD_NEI_STATE +// +typedef enum _WW_CDPD_NEI_STATE { + CDPDUnknown, + CDPDRegistered, + CDPDDeregistered +} WW_CDPD_NEI_STATE, *PWW_CDPD_NEI_STATE; +typedef enum _WW_CDPD_NEI_SUB_STATE { + CDPDPending, // Registration pending + CDPDNoReason, // Registration denied - no reason given + CDPDMDISNotCapable, // Registration denied - MD-IS not capable of + // handling M-ES at this time + CDPDNEINotAuthorized, // Registration denied - NEI is not authorized to + // use this subnetwork + CDPDInsufficientAuth, // Registration denied - M-ES gave insufficient + // authentication credentials + CDPDUnsupportedAuth, // Registration denied - M-ES gave unsupported + // authentication credentials + CDPDUsageExceeded, // Registration denied - NEI has exceeded usage + // limitations + CDPDDeniedThisNetwork // Registration denied on this network, service + // may be obtained on alternate Service Provider + // network +} WW_CDPD_NEI_SUB_STATE; +typedef struct _WW_CDPD_NEI_REG_STATE { + UINT uNeiIndex; + WW_CDPD_NEI_STATE NeiState; + WW_CDPD_NEI_SUB_STATE NeiSubState; +} WW_CDPD_NEI_REG_STATE, *PWW_CDPD_NEI_REG_STATE; + +// +// OID_WW_CDPD_SERVICE_PROVIDER_IDENTIFIER +// +typedef struct _WW_CDPD_SERVICE_PROVIDER_ID { + UINT SPI[10]; //10 16-bit service provider IDs + + INT OperatingMode; // 0 = ignore SPI, + // 1 = require SPI from list, + // 2 = prefer SPI from list. + // 3 = exclude SPI from list. + +} WW_CDPD_SERVICE_PROVIDER_ID, *PWW_CDPD_SERVICE_PROVIDER_ID; + +// +// OID_WW_CDPD_SLEEP_MODE +// +typedef INT WW_CDPD_SLEEP_MODE; +// +// OID_WW_CDPD_TEI +// +typedef ULONG WW_CDPD_TEI; +// +// OID_WW_CDPD_CIRCUIT_SWITCHED +// +typedef struct _WW_CDPD_CIRCUIT_SWITCHED { + INT service_preference; // -1 = unknown, + // 0 = always use packet switched CDPD, + // 1 = always use CS CDPD via AMPS, + // 2 = always use CS CDPD via PSTN, + // 3 = use circuit switched via AMPS only + // when packet switched is not available. + // 4 = use packet switched only when circuit + // switched via AMPS is not available. + // 5 = device manuf. defined service + // preference. + // 6 = device manuf. defined service + // preference. + + INT service_status; // -1 = unknown, + // 0 = packet switched CDPD, + // 1 = circuit switched CDPD via AMPS, + // 2 = circuit switched CDPD via PSTN. + + INT connect_rate; // CS connection bit rate (bits per second). + // 0 = no active connection, + // -1 = unknown + // Dial code last used to dial. + + NDIS_VAR_DATA_DESC dial_code[20]; + + UINT sid; // Current AMPS system ID + + INT a_b_side_selection; // -1 = unknown, + // 0 = no AMPS service + // 1 = AMPS "A" side channels selected + // 2 = AMPS "B" side channels selected + + INT AMPS_channel; // -1= unknown + // 0 = no AMPS service. + // 1-1023 = AMPS channel number in use + + UINT action; // 0 = no action + // 1 = suspend (hangup) + // 2 = dial + + // Default dial code for CS CDPD service + // encoded as specified in the CS CDPD + // implementor guidelines. + NDIS_VAR_DATA_DESC default_dial[20]; + + // Number for the CS CDPD network to call + // back the mobile, encoded as specified in + // the CS CDPD implementor guidelines. + NDIS_VAR_DATA_DESC call_back[20]; + + UINT sid_list[10]; // List of 10 16-bit preferred AMPS + // system IDs for CS CDPD. + + UINT inactivity_timer; // Wait time after last data before dropping + // call. + // 0-65535 = inactivity time limit (seconds). + + UINT receive_timer; // secs. per CS-CDPD Implementor Guidelines. + + UINT conn_resp_timer; // secs. per CS-CDPD Implementor Guidelines. + + UINT reconn_resp_timer; // secs. per CS-CDPD Implementor Guidelines. + + UINT disconn_timer; // secs. per CS-CDPD Implementor Guidelines. + + UINT NEI_reg_timer; // secs. per CS-CDPD Implementor Guidelines. + + UINT reconn_retry_timer; // secs. per CS-CDPD Implementor Guidelines. + + UINT link_reset_timer; // secs. per CS-CDPD Implementor Guidelines. + + UINT link_reset_ack_timer; // secs. per CS-CDPD Implementor Guidelines. + + UINT n401_retry_limit; // per CS-CDPD Implementor Guidelines. + + UINT n402_retry_limit; // per CS-CDPD Implementor Guidelines. + + UINT n404_retry_limit; // per CS-CDPD Implementor Guidelines. + + UINT n405_retry_limit; // per CS-CDPD Implementor Guidelines. + +} WW_CDPD_CIRCUIT_SWITCHED, *WW_PCDPD_CIRCUIT_SWITCHED; +typedef UINT WW_CDPD_RSSI; +// +// OID_WW_PIN_LOC_AUTHORIZE +// +typedef INT WW_PIN_AUTHORIZED; // 0 = unauthorized + // 1 = authorized + // -1 = unknown +// +// OID_WW_PIN_LAST_LOCATION +// OID_WW_PIN_LOC_FIX +// + +typedef struct _WW_PIN_LOCATION { + INT Latitude; // Latitude in hundredths of a second + + INT Longitude; // Longitude in hundredths of a second + + INT Altitude; // Altitude in feet + + INT FixTime; // Time of the location fix, since midnight, local time (of the + // current day), in tenths of a second + + INT NetTime; // Current local network time of the current day, since midnight, + // in tenths of a second + + INT LocQuality; // 0-100 = location quality + + INT LatReg; // Latitude registration offset, in hundredths of a second + + INT LongReg; // Longitude registration offset, in hundredths of a second + + INT GMTOffset; // Offset in minutes of the local time zone from GMT + +} WW_PIN_LOCATION, *PWW_PIN_LOCATION; + +// +// The following is set on a per-packet basis as OOB data with NdisClassWirelessWanMbxMailbox +// +typedef ULONG WW_MBX_MAILBOX_FLAG; // 1 = set mailbox flag, 0 = do not set mailbox flag +// +// OID_WW_MBX_SUBADDR +// + +typedef struct _WW_MBX_PMAN { + BOOLEAN ACTION; // 0 = Login PMAN, 1 = Logout PMAN + + UINT MAN; + UCHAR PASSWORD[8]; // Password should be null for Logout and indications. + // Maximum length of password is 8 chars. + +} WW_MBX_PMAN, *PWW_MBX_PMAN; + +// +// OID_WW_MBX_FLEXLIST +// +typedef struct _WW_MBX_FLEXLIST { + INT count; // Number of MAN entries used. + // -1=unknown. + + UINT MAN[7]; // List of MANs. + +} WW_MBX_FLEXLIST; + +// +// OID_WW_MBX_GROUPLIST +// +typedef struct _WW_MBX_GROUPLIST { + INT count; // Number of MAN entries used. + // -1=unknown. + + UINT MAN[15]; // List of MANs. + +} WW_MBX_GROUPLIST; + +// +// OID_WW_MBX_TRAFFIC_AREA +// +typedef enum _WW_MBX_TRAFFIC_AREA { + unknown_traffic_area, // The driver has no information about the current traffic area. + in_traffic_area, // Mobile unit has entered a subscribed traffic area. + in_auth_traffic_area, // Mobile unit is outside traffic area but is authorized. + unauth_traffic_area // Mobile unit is outside traffic area but is un-authorized. +} WW_MBX_TRAFFIC_AREA; + +// +// OID_WW_MBX_LIVE_DIE +// +typedef INT WW_MBX_LIVE_DIE; // 0 = DIE last received + // 1 = LIVE last received + // -1 = unknown +// +// OID_WW_MBX_TEMP_DEFAULTLIST +// + +typedef struct _WW_MBX_CHANNEL_PAIR { + UINT Mobile_Tx; + UINT Mobile_Rx; +} WW_MBX_CHANNEL_PAIR, *PWW_MBX_CHANNEL_PAIR; +typedef struct _WW_MBX_TEMPDEFAULTLIST { + UINT Length; + WW_MBX_CHANNEL_PAIR ChannelPair[1]; +} WW_MBX_TEMPDEFAULTLIST, *WW_PMBX_TEMPDEFAULTLIST; + +#endif // WIRELESS_WAN +#endif // _NTDDNDIS_ diff --git a/desmume/src/windows/winpcap/Ntddpack.h b/src/windows/winpcap/Ntddpack.h similarity index 97% rename from desmume/src/windows/winpcap/Ntddpack.h rename to src/windows/winpcap/Ntddpack.h index 87eac60ed..30945c1ef 100644 --- a/desmume/src/windows/winpcap/Ntddpack.h +++ b/src/windows/winpcap/Ntddpack.h @@ -1,26 +1,26 @@ - -#ifndef __NTDDPACKET -#define __NTDDPACKET 1 -#include "devioctl.h" -/*#include */ -struct _PACKET_OID_DATA { - ULONG Oid; - ULONG Length; - UCHAR Data[1]; -}; - -typedef struct _PACKET_OID_DATA PACKET_OID_DATA, *PPACKET_OID_DATA; - -/*#include */ -#define FILE_DEVICE_PROTOCOL 0x8000 -#define IOCTL_PROTOCOL_QUERY_OID CTL_CODE(FILE_DEVICE_PROTOCOL, 0 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_PROTOCOL_SET_OID CTL_CODE(FILE_DEVICE_PROTOCOL, 1 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_PROTOCOL_STATISTICS CTL_CODE(FILE_DEVICE_PROTOCOL, 2 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_PROTOCOL_RESET CTL_CODE(FILE_DEVICE_PROTOCOL, 3 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_PROTOCOL_READ CTL_CODE(FILE_DEVICE_PROTOCOL, 4 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_PROTOCOL_WRITE CTL_CODE(FILE_DEVICE_PROTOCOL, 5 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_PROTOCOL_MACNAME CTL_CODE(FILE_DEVICE_PROTOCOL, 6 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_OPEN CTL_CODE(FILE_DEVICE_PROTOCOL, 7 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_CLOSE CTL_CODE(FILE_DEVICE_PROTOCOL, 8 , METHOD_BUFFERED, FILE_ANY_ACCESS) - -#endif + +#ifndef __NTDDPACKET +#define __NTDDPACKET 1 +#include "devioctl.h" +/*#include */ +struct _PACKET_OID_DATA { + ULONG Oid; + ULONG Length; + UCHAR Data[1]; +}; + +typedef struct _PACKET_OID_DATA PACKET_OID_DATA, *PPACKET_OID_DATA; + +/*#include */ +#define FILE_DEVICE_PROTOCOL 0x8000 +#define IOCTL_PROTOCOL_QUERY_OID CTL_CODE(FILE_DEVICE_PROTOCOL, 0 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_PROTOCOL_SET_OID CTL_CODE(FILE_DEVICE_PROTOCOL, 1 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_PROTOCOL_STATISTICS CTL_CODE(FILE_DEVICE_PROTOCOL, 2 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_PROTOCOL_RESET CTL_CODE(FILE_DEVICE_PROTOCOL, 3 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_PROTOCOL_READ CTL_CODE(FILE_DEVICE_PROTOCOL, 4 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_PROTOCOL_WRITE CTL_CODE(FILE_DEVICE_PROTOCOL, 5 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_PROTOCOL_MACNAME CTL_CODE(FILE_DEVICE_PROTOCOL, 6 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_OPEN CTL_CODE(FILE_DEVICE_PROTOCOL, 7 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_CLOSE CTL_CODE(FILE_DEVICE_PROTOCOL, 8 , METHOD_BUFFERED, FILE_ANY_ACCESS) + +#endif diff --git a/desmume/src/windows/winpcap/Packet.lib b/src/windows/winpcap/Packet.lib similarity index 100% rename from desmume/src/windows/winpcap/Packet.lib rename to src/windows/winpcap/Packet.lib diff --git a/desmume/src/windows/winpcap/Packet32.h b/src/windows/winpcap/Packet32.h similarity index 98% rename from desmume/src/windows/winpcap/Packet32.h rename to src/windows/winpcap/Packet32.h index 2d989b99f..04630a0ee 100644 --- a/desmume/src/windows/winpcap/Packet32.h +++ b/src/windows/winpcap/Packet32.h @@ -1,405 +1,405 @@ -/* - * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) - * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Politecnico di Torino, CACE Technologies - * nor the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/** @ingroup packetapi - * @{ - */ - -/** @defgroup packet32h Packet.dll definitions and data structures - * Packet32.h contains the data structures and the definitions used by packet.dll. - * The file is used both by the Win9x and the WinNTx versions of packet.dll, and can be included - * by the applications that use the functions of this library - * @{ - */ - -#ifndef __PACKET32 -#define __PACKET32 - -#include - -#include "devioctl.h" - -#ifdef HAVE_AIRPCAP_API -#include -#else -#if !defined(AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_) -#define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_ -typedef struct _AirpcapHandle *PAirpcapHandle; -#endif /* AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_ */ -#endif /* HAVE_AIRPCAP_API */ - -#ifdef HAVE_DAG_API -#include -#endif /* HAVE_DAG_API */ - -// Working modes -#define PACKET_MODE_CAPT 0x0 ///< Capture mode -#define PACKET_MODE_STAT 0x1 ///< Statistical mode -#define PACKET_MODE_MON 0x2 ///< Monitoring mode -#define PACKET_MODE_DUMP 0x10 ///< Dump mode -#define PACKET_MODE_STAT_DUMP MODE_DUMP | MODE_STAT ///< Statistical dump Mode - -// ioctls -#define FILE_DEVICE_PROTOCOL 0x8000 - -#define IOCTL_PROTOCOL_STATISTICS CTL_CODE(FILE_DEVICE_PROTOCOL, 2 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_PROTOCOL_RESET CTL_CODE(FILE_DEVICE_PROTOCOL, 3 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_PROTOCOL_READ CTL_CODE(FILE_DEVICE_PROTOCOL, 4 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_PROTOCOL_WRITE CTL_CODE(FILE_DEVICE_PROTOCOL, 5 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_PROTOCOL_MACNAME CTL_CODE(FILE_DEVICE_PROTOCOL, 6 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_OPEN CTL_CODE(FILE_DEVICE_PROTOCOL, 7 , METHOD_BUFFERED, FILE_ANY_ACCESS) -#define IOCTL_CLOSE CTL_CODE(FILE_DEVICE_PROTOCOL, 8 , METHOD_BUFFERED, FILE_ANY_ACCESS) - -#define pBIOCSETBUFFERSIZE 9592 ///< IOCTL code: set kernel buffer size. -#define pBIOCSETF 9030 ///< IOCTL code: set packet filtering program. -#define pBIOCGSTATS 9031 ///< IOCTL code: get the capture stats. -#define pBIOCSRTIMEOUT 7416 ///< IOCTL code: set the read timeout. -#define pBIOCSMODE 7412 ///< IOCTL code: set working mode. -#define pBIOCSWRITEREP 7413 ///< IOCTL code: set number of physical repetions of every packet written by the app. -#define pBIOCSMINTOCOPY 7414 ///< IOCTL code: set minimum amount of data in the kernel buffer that unlocks a read call. -#define pBIOCSETOID 2147483648U ///< IOCTL code: set an OID value. -#define pBIOCQUERYOID 2147483652U ///< IOCTL code: get an OID value. -#define pATTACHPROCESS 7117 ///< IOCTL code: attach a process to the driver. Used in Win9x only. -#define pDETACHPROCESS 7118 ///< IOCTL code: detach a process from the driver. Used in Win9x only. -#define pBIOCSETDUMPFILENAME 9029 ///< IOCTL code: set the name of a the file used by kernel dump mode. -#define pBIOCEVNAME 7415 ///< IOCTL code: get the name of the event that the driver signals when some data is present in the buffer. -#define pBIOCSENDPACKETSNOSYNC 9032 ///< IOCTL code: Send a buffer containing multiple packets to the network, ignoring the timestamps associated with the packets. -#define pBIOCSENDPACKETSSYNC 9033 ///< IOCTL code: Send a buffer containing multiple packets to the network, respecting the timestamps associated with the packets. -#define pBIOCSETDUMPLIMITS 9034 ///< IOCTL code: Set the dump file limits. See the PacketSetDumpLimits() function. -#define pBIOCISDUMPENDED 7411 ///< IOCTL code: Get the status of the kernel dump process. See the PacketIsDumpEnded() function. -#define pBIOCISETLOBBEH 7410 ///< IOCTL code: Set the loopback behavior of the driver with packets sent by itself: capture or drop. -#define pBIOCSETEVENTHANDLE 7920 ///< IOCTL code: Passes the read event HANDLE allocated by the user (packet.dll) to the kernel level driver. - -#define pBIOCSTIMEZONE 7471 ///< IOCTL code: set time zone. Used in Win9x only. - - -/// Alignment macro. Defines the alignment size. -#define Packet_ALIGNMENT sizeof(int) -/// Alignment macro. Rounds up to the next even multiple of Packet_ALIGNMENT. -#define Packet_WORDALIGN(x) (((x)+(Packet_ALIGNMENT-1))&~(Packet_ALIGNMENT-1)) - -#define NdisMediumNull -1 ///< Custom linktype: NDIS doesn't provide an equivalent -#define NdisMediumCHDLC -2 ///< Custom linktype: NDIS doesn't provide an equivalent -#define NdisMediumPPPSerial -3 ///< Custom linktype: NDIS doesn't provide an equivalent -#define NdisMediumBare80211 -4 ///< Custom linktype: NDIS doesn't provide an equivalent -#define NdisMediumRadio80211 -5 ///< Custom linktype: NDIS doesn't provide an equivalent - -// Loopback behaviour definitions -#define NPF_DISABLE_LOOPBACK 1 ///< Drop the packets sent by the NPF driver -#define NPF_ENABLE_LOOPBACK 2 ///< Capture the packets sent by the NPF driver - -/*! - \brief Network type structure. - - This structure is used by the PacketGetNetType() function to return information on the current adapter's type and speed. -*/ -typedef struct NetType -{ - UINT LinkType; ///< The MAC of the current network adapter (see function PacketGetNetType() for more information) - ULONGLONG LinkSpeed; ///< The speed of the network in bits per second -}NetType; - - -//some definitions stolen from libpcap - -#ifndef BPF_MAJOR_VERSION - -/*! - \brief A BPF pseudo-assembly program. - - The program will be injected in the kernel by the PacketSetBPF() function and applied to every incoming packet. -*/ -struct bpf_program -{ - UINT bf_len; ///< Indicates the number of instructions of the program, i.e. the number of struct bpf_insn that will follow. - struct bpf_insn *bf_insns; ///< A pointer to the first instruction of the program. -}; - -/*! - \brief A single BPF pseudo-instruction. - - bpf_insn contains a single instruction for the BPF register-machine. It is used to send a filter program to the driver. -*/ -struct bpf_insn -{ - USHORT code; ///< Instruction type and addressing mode. - UCHAR jt; ///< Jump if true - UCHAR jf; ///< Jump if false - int k; ///< Generic field used for various purposes. -}; - -/*! - \brief Structure that contains a couple of statistics values on the current capture. - - It is used by packet.dll to return statistics about a capture session. -*/ -struct bpf_stat -{ - UINT bs_recv; ///< Number of packets that the driver received from the network adapter - ///< from the beginning of the current capture. This value includes the packets - ///< lost by the driver. - UINT bs_drop; ///< number of packets that the driver lost from the beginning of a capture. - ///< Basically, a packet is lost when the the buffer of the driver is full. - ///< In this situation the packet cannot be stored and the driver rejects it. - UINT ps_ifdrop; ///< drops by interface. XXX not yet supported - UINT bs_capt; ///< number of packets that pass the filter, find place in the kernel buffer and - ///< thus reach the application. -}; - -/*! - \brief Packet header. - - This structure defines the header associated with every packet delivered to the application. -*/ -struct bpf_hdr -{ - struct timeval bh_tstamp; ///< The timestamp associated with the captured packet. - ///< It is stored in a TimeVal structure. - UINT bh_caplen; ///< Length of captured portion. The captured portion can be different - ///< from the original packet, because it is possible (with a proper filter) - ///< to instruct the driver to capture only a portion of the packets. - UINT bh_datalen; ///< Original length of packet - USHORT bh_hdrlen; ///< Length of bpf header (this struct plus alignment padding). In some cases, - ///< a padding could be added between the end of this structure and the packet - ///< data for performance reasons. This filed can be used to retrieve the actual data - ///< of the packet. -}; - -/*! - \brief Dump packet header. - - This structure defines the header associated with the packets in a buffer to be used with PacketSendPackets(). - It is simpler than the bpf_hdr, because it corresponds to the header associated by WinPcap and libpcap to a - packet in a dump file. This makes straightforward sending WinPcap dump files to the network. -*/ -struct dump_bpf_hdr{ - struct timeval ts; ///< Time stamp of the packet - UINT caplen; ///< Length of captured portion. The captured portion can smaller than the - ///< the original packet, because it is possible (with a proper filter) to - ///< instruct the driver to capture only a portion of the packets. - UINT len; ///< Length of the original packet (off wire). -}; - - -#endif - -struct bpf_stat; - -#define DOSNAMEPREFIX TEXT("Packet_") ///< Prefix added to the adapters device names to create the WinPcap devices -#define MAX_LINK_NAME_LENGTH 64 //< Maximum length of the devices symbolic links -#define NMAX_PACKET 65535 - -/*! - \brief Addresses of a network adapter. - - This structure is used by the PacketGetNetInfoEx() function to return the IP addresses associated with - an adapter. -*/ -typedef struct npf_if_addr { - struct sockaddr_storage IPAddress; ///< IP address. - struct sockaddr_storage SubnetMask; ///< Netmask for that address. - struct sockaddr_storage Broadcast; ///< Broadcast address. -}npf_if_addr; - - -#define ADAPTER_NAME_LENGTH 256 + 12 ///< Maximum length for the name of an adapter. The value is the same used by the IP Helper API. -#define ADAPTER_DESC_LENGTH 128 ///< Maximum length for the description of an adapter. The value is the same used by the IP Helper API. -#define MAX_MAC_ADDR_LENGTH 8 ///< Maximum length for the link layer address of an adapter. The value is the same used by the IP Helper API. -#define MAX_NETWORK_ADDRESSES 16 ///< Maximum length for the link layer address of an adapter. The value is the same used by the IP Helper API. - - -typedef struct WAN_ADAPTER_INT WAN_ADAPTER; ///< Describes an opened wan (dialup, VPN...) network adapter using the NetMon API -typedef WAN_ADAPTER *PWAN_ADAPTER; ///< Describes an opened wan (dialup, VPN...) network adapter using the NetMon API - -#define INFO_FLAG_NDIS_ADAPTER 0 ///< Flag for ADAPTER_INFO: this is a traditional ndis adapter -#define INFO_FLAG_NDISWAN_ADAPTER 1 ///< Flag for ADAPTER_INFO: this is a NdisWan adapter, and it's managed by WANPACKET -#define INFO_FLAG_DAG_CARD 2 ///< Flag for ADAPTER_INFO: this is a DAG card -#define INFO_FLAG_DAG_FILE 6 ///< Flag for ADAPTER_INFO: this is a DAG file -#define INFO_FLAG_DONT_EXPORT 8 ///< Flag for ADAPTER_INFO: when this flag is set, the adapter will not be listed or openend by winpcap. This allows to prevent exporting broken network adapters, like for example FireWire ones. -#define INFO_FLAG_AIRPCAP_CARD 16 ///< Flag for ADAPTER_INFO: this is an airpcap card -#define INFO_FLAG_NPFIM_DEVICE 32 -/*! - \brief Contains comprehensive information about a network adapter. - - This structure is filled with all the accessory information that the user can need about an adapter installed - on his system. -*/ -typedef struct _ADAPTER_INFO -{ - struct _ADAPTER_INFO *Next; ///< Pointer to the next adapter in the list. - CHAR Name[ADAPTER_NAME_LENGTH + 1]; ///< Name of the device representing the adapter. - CHAR Description[ADAPTER_DESC_LENGTH + 1]; ///< Human understandable description of the adapter - UINT MacAddressLen; ///< Length of the link layer address. - UCHAR MacAddress[MAX_MAC_ADDR_LENGTH]; ///< Link layer address. - NetType LinkLayer; ///< Physical characteristics of this adapter. This NetType structure contains the link type and the speed of the adapter. - INT NNetworkAddresses; ///< Number of network layer addresses of this adapter. - npf_if_addr *NetworkAddresses; ///< Pointer to an array of npf_if_addr, each of which specifies a network address of this adapter. - UINT Flags; ///< Adapter's flags. Tell if this adapter must be treated in a different way, using the Netmon API or the dagc API. -} -ADAPTER_INFO, *PADAPTER_INFO; - -/*! - \brief Describes an opened network adapter. - - This structure is the most important for the functioning of packet.dll, but the great part of its fields - should be ignored by the user, since the library offers functions that avoid to cope with low-level parameters -*/ -typedef struct _ADAPTER { - HANDLE hFile; ///< \internal Handle to an open instance of the NPF driver. - CHAR SymbolicLink[MAX_LINK_NAME_LENGTH]; ///< \internal A string containing the name of the network adapter currently opened. - int NumWrites; ///< \internal Number of times a packets written on this adapter will be repeated - ///< on the wire. - HANDLE ReadEvent; ///< A notification event associated with the read calls on the adapter. - ///< It can be passed to standard Win32 functions (like WaitForSingleObject - ///< or WaitForMultipleObjects) to wait until the driver's buffer contains some - ///< data. It is particularly useful in GUI applications that need to wait - ///< concurrently on several events. In Windows NT/2000 the PacketSetMinToCopy() - ///< function can be used to define the minimum amount of data in the kernel buffer - ///< that will cause the event to be signalled. - - UINT ReadTimeOut; ///< \internal The amount of time after which a read on the driver will be released and - ///< ReadEvent will be signaled, also if no packets were captured - CHAR Name[ADAPTER_NAME_LENGTH]; - PWAN_ADAPTER pWanAdapter; - UINT Flags; ///< Adapter's flags. Tell if this adapter must be treated in a different way, using the Netmon API or the dagc API. - -#ifdef HAVE_AIRPCAP_API - PAirpcapHandle AirpcapAd; -#endif // HAVE_AIRPCAP_API - -#ifdef HAVE_NPFIM_API - void* NpfImHandle; -#endif // HAVE_NPFIM_API - -#ifdef HAVE_DAG_API - dagc_t *pDagCard; ///< Pointer to the dagc API adapter descriptor for this adapter - PCHAR DagBuffer; ///< Pointer to the buffer with the packets that is received from the DAG card - struct timeval DagReadTimeout; ///< Read timeout. The dagc API requires a timeval structure - unsigned DagFcsLen; ///< Length of the frame check sequence attached to any packet by the card. Obtained from the registry - DWORD DagFastProcess; ///< True if the user requests fast capture processing on this card. Higher level applications can use this value to provide a faster but possibly unprecise capture (for example, libpcap doesn't convert the timestamps). -#endif // HAVE_DAG_API -} ADAPTER, *LPADAPTER; - -/*! - \brief Structure that contains a group of packets coming from the driver. - - This structure defines the header associated with every packet delivered to the application. -*/ -typedef struct _PACKET { - HANDLE hEvent; ///< \deprecated Still present for compatibility with old applications. - OVERLAPPED OverLapped; ///< \deprecated Still present for compatibility with old applications. - PVOID Buffer; ///< Buffer with containing the packets. See the PacketReceivePacket() for - ///< details about the organization of the data in this buffer - UINT Length; ///< Length of the buffer - DWORD ulBytesReceived; ///< Number of valid bytes present in the buffer, i.e. amount of data - ///< received by the last call to PacketReceivePacket() - BOOLEAN bIoComplete; ///< \deprecated Still present for compatibility with old applications. -} PACKET, *LPPACKET; - -/*! - \brief Structure containing an OID request. - - It is used by the PacketRequest() function to send an OID to the interface card driver. - It can be used, for example, to retrieve the status of the error counters on the adapter, its MAC address, - the list of the multicast groups defined on it, and so on. -*/ -struct _PACKET_OID_DATA { - ULONG Oid; ///< OID code. See the Microsoft DDK documentation or the file ntddndis.h - ///< for a complete list of valid codes. - ULONG Length; ///< Length of the data field - UCHAR Data[1]; ///< variable-lenght field that contains the information passed to or received - ///< from the adapter. -}; -typedef struct _PACKET_OID_DATA PACKET_OID_DATA, *PPACKET_OID_DATA; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @} - */ - -/* -BOOLEAN QueryWinPcapRegistryStringA(CHAR *SubKeyName, - CHAR *Value, - UINT *pValueLen, - CHAR *DefaultVal); - -BOOLEAN QueryWinPcapRegistryStringW(WCHAR *SubKeyName, - WCHAR *Value, - UINT *pValueLen, - WCHAR *DefaultVal); -*/ - -//--------------------------------------------------------------------------- -// EXPORTED FUNCTIONS -//--------------------------------------------------------------------------- - -PCHAR PacketGetVersion(); -PCHAR PacketGetDriverVersion(); -BOOLEAN PacketSetMinToCopy(LPADAPTER AdapterObject,int nbytes); -BOOLEAN PacketSetNumWrites(LPADAPTER AdapterObject,int nwrites); -BOOLEAN PacketSetMode(LPADAPTER AdapterObject,int mode); -BOOLEAN PacketSetReadTimeout(LPADAPTER AdapterObject,int timeout); -BOOLEAN PacketSetBpf(LPADAPTER AdapterObject,struct bpf_program *fp); -BOOLEAN PacketSetLoopbackBehavior(LPADAPTER AdapterObject, UINT LoopbackBehavior); -INT PacketSetSnapLen(LPADAPTER AdapterObject,int snaplen); -BOOLEAN PacketGetStats(LPADAPTER AdapterObject,struct bpf_stat *s); -BOOLEAN PacketGetStatsEx(LPADAPTER AdapterObject,struct bpf_stat *s); -BOOLEAN PacketSetBuff(LPADAPTER AdapterObject,int dim); -BOOLEAN PacketGetNetType (LPADAPTER AdapterObject,NetType *type); -LPADAPTER PacketOpenAdapter(PCHAR AdapterName); -BOOLEAN PacketSendPacket(LPADAPTER AdapterObject,LPPACKET pPacket,BOOLEAN Sync); -INT PacketSendPackets(LPADAPTER AdapterObject,PVOID PacketBuff,ULONG Size, BOOLEAN Sync); -LPPACKET PacketAllocatePacket(void); -VOID PacketInitPacket(LPPACKET lpPacket,PVOID Buffer,UINT Length); -VOID PacketFreePacket(LPPACKET lpPacket); -BOOLEAN PacketReceivePacket(LPADAPTER AdapterObject,LPPACKET lpPacket,BOOLEAN Sync); -BOOLEAN PacketSetHwFilter(LPADAPTER AdapterObject,ULONG Filter); -BOOLEAN PacketGetAdapterNames(PTSTR pStr,PULONG BufferSize); -BOOLEAN PacketGetNetInfoEx(PCHAR AdapterName, npf_if_addr* buffer, PLONG NEntries); -BOOLEAN PacketRequest(LPADAPTER AdapterObject,BOOLEAN Set,PPACKET_OID_DATA OidData); -HANDLE PacketGetReadEvent(LPADAPTER AdapterObject); -BOOLEAN PacketSetDumpName(LPADAPTER AdapterObject, void *name, int len); -BOOLEAN PacketSetDumpLimits(LPADAPTER AdapterObject, UINT maxfilesize, UINT maxnpacks); -BOOLEAN PacketIsDumpEnded(LPADAPTER AdapterObject, BOOLEAN sync); -BOOL PacketStopDriver(); -VOID PacketCloseAdapter(LPADAPTER lpAdapter); -BOOLEAN PacketStartOem(PCHAR errorString, UINT errorStringLength); -PAirpcapHandle PacketGetAirPcapHandle(LPADAPTER AdapterObject); -#ifdef __cplusplus -} -#endif - -#endif //__PACKET32 +/* + * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) + * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino, CACE Technologies + * nor the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/** @ingroup packetapi + * @{ + */ + +/** @defgroup packet32h Packet.dll definitions and data structures + * Packet32.h contains the data structures and the definitions used by packet.dll. + * The file is used both by the Win9x and the WinNTx versions of packet.dll, and can be included + * by the applications that use the functions of this library + * @{ + */ + +#ifndef __PACKET32 +#define __PACKET32 + +#include + +#include "devioctl.h" + +#ifdef HAVE_AIRPCAP_API +#include +#else +#if !defined(AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_) +#define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_ +typedef struct _AirpcapHandle *PAirpcapHandle; +#endif /* AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_ */ +#endif /* HAVE_AIRPCAP_API */ + +#ifdef HAVE_DAG_API +#include +#endif /* HAVE_DAG_API */ + +// Working modes +#define PACKET_MODE_CAPT 0x0 ///< Capture mode +#define PACKET_MODE_STAT 0x1 ///< Statistical mode +#define PACKET_MODE_MON 0x2 ///< Monitoring mode +#define PACKET_MODE_DUMP 0x10 ///< Dump mode +#define PACKET_MODE_STAT_DUMP MODE_DUMP | MODE_STAT ///< Statistical dump Mode + +// ioctls +#define FILE_DEVICE_PROTOCOL 0x8000 + +#define IOCTL_PROTOCOL_STATISTICS CTL_CODE(FILE_DEVICE_PROTOCOL, 2 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_PROTOCOL_RESET CTL_CODE(FILE_DEVICE_PROTOCOL, 3 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_PROTOCOL_READ CTL_CODE(FILE_DEVICE_PROTOCOL, 4 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_PROTOCOL_WRITE CTL_CODE(FILE_DEVICE_PROTOCOL, 5 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_PROTOCOL_MACNAME CTL_CODE(FILE_DEVICE_PROTOCOL, 6 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_OPEN CTL_CODE(FILE_DEVICE_PROTOCOL, 7 , METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_CLOSE CTL_CODE(FILE_DEVICE_PROTOCOL, 8 , METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define pBIOCSETBUFFERSIZE 9592 ///< IOCTL code: set kernel buffer size. +#define pBIOCSETF 9030 ///< IOCTL code: set packet filtering program. +#define pBIOCGSTATS 9031 ///< IOCTL code: get the capture stats. +#define pBIOCSRTIMEOUT 7416 ///< IOCTL code: set the read timeout. +#define pBIOCSMODE 7412 ///< IOCTL code: set working mode. +#define pBIOCSWRITEREP 7413 ///< IOCTL code: set number of physical repetions of every packet written by the app. +#define pBIOCSMINTOCOPY 7414 ///< IOCTL code: set minimum amount of data in the kernel buffer that unlocks a read call. +#define pBIOCSETOID 2147483648U ///< IOCTL code: set an OID value. +#define pBIOCQUERYOID 2147483652U ///< IOCTL code: get an OID value. +#define pATTACHPROCESS 7117 ///< IOCTL code: attach a process to the driver. Used in Win9x only. +#define pDETACHPROCESS 7118 ///< IOCTL code: detach a process from the driver. Used in Win9x only. +#define pBIOCSETDUMPFILENAME 9029 ///< IOCTL code: set the name of a the file used by kernel dump mode. +#define pBIOCEVNAME 7415 ///< IOCTL code: get the name of the event that the driver signals when some data is present in the buffer. +#define pBIOCSENDPACKETSNOSYNC 9032 ///< IOCTL code: Send a buffer containing multiple packets to the network, ignoring the timestamps associated with the packets. +#define pBIOCSENDPACKETSSYNC 9033 ///< IOCTL code: Send a buffer containing multiple packets to the network, respecting the timestamps associated with the packets. +#define pBIOCSETDUMPLIMITS 9034 ///< IOCTL code: Set the dump file limits. See the PacketSetDumpLimits() function. +#define pBIOCISDUMPENDED 7411 ///< IOCTL code: Get the status of the kernel dump process. See the PacketIsDumpEnded() function. +#define pBIOCISETLOBBEH 7410 ///< IOCTL code: Set the loopback behavior of the driver with packets sent by itself: capture or drop. +#define pBIOCSETEVENTHANDLE 7920 ///< IOCTL code: Passes the read event HANDLE allocated by the user (packet.dll) to the kernel level driver. + +#define pBIOCSTIMEZONE 7471 ///< IOCTL code: set time zone. Used in Win9x only. + + +/// Alignment macro. Defines the alignment size. +#define Packet_ALIGNMENT sizeof(int) +/// Alignment macro. Rounds up to the next even multiple of Packet_ALIGNMENT. +#define Packet_WORDALIGN(x) (((x)+(Packet_ALIGNMENT-1))&~(Packet_ALIGNMENT-1)) + +#define NdisMediumNull -1 ///< Custom linktype: NDIS doesn't provide an equivalent +#define NdisMediumCHDLC -2 ///< Custom linktype: NDIS doesn't provide an equivalent +#define NdisMediumPPPSerial -3 ///< Custom linktype: NDIS doesn't provide an equivalent +#define NdisMediumBare80211 -4 ///< Custom linktype: NDIS doesn't provide an equivalent +#define NdisMediumRadio80211 -5 ///< Custom linktype: NDIS doesn't provide an equivalent + +// Loopback behaviour definitions +#define NPF_DISABLE_LOOPBACK 1 ///< Drop the packets sent by the NPF driver +#define NPF_ENABLE_LOOPBACK 2 ///< Capture the packets sent by the NPF driver + +/*! + \brief Network type structure. + + This structure is used by the PacketGetNetType() function to return information on the current adapter's type and speed. +*/ +typedef struct NetType +{ + UINT LinkType; ///< The MAC of the current network adapter (see function PacketGetNetType() for more information) + ULONGLONG LinkSpeed; ///< The speed of the network in bits per second +}NetType; + + +//some definitions stolen from libpcap + +#ifndef BPF_MAJOR_VERSION + +/*! + \brief A BPF pseudo-assembly program. + + The program will be injected in the kernel by the PacketSetBPF() function and applied to every incoming packet. +*/ +struct bpf_program +{ + UINT bf_len; ///< Indicates the number of instructions of the program, i.e. the number of struct bpf_insn that will follow. + struct bpf_insn *bf_insns; ///< A pointer to the first instruction of the program. +}; + +/*! + \brief A single BPF pseudo-instruction. + + bpf_insn contains a single instruction for the BPF register-machine. It is used to send a filter program to the driver. +*/ +struct bpf_insn +{ + USHORT code; ///< Instruction type and addressing mode. + UCHAR jt; ///< Jump if true + UCHAR jf; ///< Jump if false + int k; ///< Generic field used for various purposes. +}; + +/*! + \brief Structure that contains a couple of statistics values on the current capture. + + It is used by packet.dll to return statistics about a capture session. +*/ +struct bpf_stat +{ + UINT bs_recv; ///< Number of packets that the driver received from the network adapter + ///< from the beginning of the current capture. This value includes the packets + ///< lost by the driver. + UINT bs_drop; ///< number of packets that the driver lost from the beginning of a capture. + ///< Basically, a packet is lost when the the buffer of the driver is full. + ///< In this situation the packet cannot be stored and the driver rejects it. + UINT ps_ifdrop; ///< drops by interface. XXX not yet supported + UINT bs_capt; ///< number of packets that pass the filter, find place in the kernel buffer and + ///< thus reach the application. +}; + +/*! + \brief Packet header. + + This structure defines the header associated with every packet delivered to the application. +*/ +struct bpf_hdr +{ + struct timeval bh_tstamp; ///< The timestamp associated with the captured packet. + ///< It is stored in a TimeVal structure. + UINT bh_caplen; ///< Length of captured portion. The captured portion can be different + ///< from the original packet, because it is possible (with a proper filter) + ///< to instruct the driver to capture only a portion of the packets. + UINT bh_datalen; ///< Original length of packet + USHORT bh_hdrlen; ///< Length of bpf header (this struct plus alignment padding). In some cases, + ///< a padding could be added between the end of this structure and the packet + ///< data for performance reasons. This filed can be used to retrieve the actual data + ///< of the packet. +}; + +/*! + \brief Dump packet header. + + This structure defines the header associated with the packets in a buffer to be used with PacketSendPackets(). + It is simpler than the bpf_hdr, because it corresponds to the header associated by WinPcap and libpcap to a + packet in a dump file. This makes straightforward sending WinPcap dump files to the network. +*/ +struct dump_bpf_hdr{ + struct timeval ts; ///< Time stamp of the packet + UINT caplen; ///< Length of captured portion. The captured portion can smaller than the + ///< the original packet, because it is possible (with a proper filter) to + ///< instruct the driver to capture only a portion of the packets. + UINT len; ///< Length of the original packet (off wire). +}; + + +#endif + +struct bpf_stat; + +#define DOSNAMEPREFIX TEXT("Packet_") ///< Prefix added to the adapters device names to create the WinPcap devices +#define MAX_LINK_NAME_LENGTH 64 //< Maximum length of the devices symbolic links +#define NMAX_PACKET 65535 + +/*! + \brief Addresses of a network adapter. + + This structure is used by the PacketGetNetInfoEx() function to return the IP addresses associated with + an adapter. +*/ +typedef struct npf_if_addr { + struct sockaddr_storage IPAddress; ///< IP address. + struct sockaddr_storage SubnetMask; ///< Netmask for that address. + struct sockaddr_storage Broadcast; ///< Broadcast address. +}npf_if_addr; + + +#define ADAPTER_NAME_LENGTH 256 + 12 ///< Maximum length for the name of an adapter. The value is the same used by the IP Helper API. +#define ADAPTER_DESC_LENGTH 128 ///< Maximum length for the description of an adapter. The value is the same used by the IP Helper API. +#define MAX_MAC_ADDR_LENGTH 8 ///< Maximum length for the link layer address of an adapter. The value is the same used by the IP Helper API. +#define MAX_NETWORK_ADDRESSES 16 ///< Maximum length for the link layer address of an adapter. The value is the same used by the IP Helper API. + + +typedef struct WAN_ADAPTER_INT WAN_ADAPTER; ///< Describes an opened wan (dialup, VPN...) network adapter using the NetMon API +typedef WAN_ADAPTER *PWAN_ADAPTER; ///< Describes an opened wan (dialup, VPN...) network adapter using the NetMon API + +#define INFO_FLAG_NDIS_ADAPTER 0 ///< Flag for ADAPTER_INFO: this is a traditional ndis adapter +#define INFO_FLAG_NDISWAN_ADAPTER 1 ///< Flag for ADAPTER_INFO: this is a NdisWan adapter, and it's managed by WANPACKET +#define INFO_FLAG_DAG_CARD 2 ///< Flag for ADAPTER_INFO: this is a DAG card +#define INFO_FLAG_DAG_FILE 6 ///< Flag for ADAPTER_INFO: this is a DAG file +#define INFO_FLAG_DONT_EXPORT 8 ///< Flag for ADAPTER_INFO: when this flag is set, the adapter will not be listed or openend by winpcap. This allows to prevent exporting broken network adapters, like for example FireWire ones. +#define INFO_FLAG_AIRPCAP_CARD 16 ///< Flag for ADAPTER_INFO: this is an airpcap card +#define INFO_FLAG_NPFIM_DEVICE 32 +/*! + \brief Contains comprehensive information about a network adapter. + + This structure is filled with all the accessory information that the user can need about an adapter installed + on his system. +*/ +typedef struct _ADAPTER_INFO +{ + struct _ADAPTER_INFO *Next; ///< Pointer to the next adapter in the list. + CHAR Name[ADAPTER_NAME_LENGTH + 1]; ///< Name of the device representing the adapter. + CHAR Description[ADAPTER_DESC_LENGTH + 1]; ///< Human understandable description of the adapter + UINT MacAddressLen; ///< Length of the link layer address. + UCHAR MacAddress[MAX_MAC_ADDR_LENGTH]; ///< Link layer address. + NetType LinkLayer; ///< Physical characteristics of this adapter. This NetType structure contains the link type and the speed of the adapter. + INT NNetworkAddresses; ///< Number of network layer addresses of this adapter. + npf_if_addr *NetworkAddresses; ///< Pointer to an array of npf_if_addr, each of which specifies a network address of this adapter. + UINT Flags; ///< Adapter's flags. Tell if this adapter must be treated in a different way, using the Netmon API or the dagc API. +} +ADAPTER_INFO, *PADAPTER_INFO; + +/*! + \brief Describes an opened network adapter. + + This structure is the most important for the functioning of packet.dll, but the great part of its fields + should be ignored by the user, since the library offers functions that avoid to cope with low-level parameters +*/ +typedef struct _ADAPTER { + HANDLE hFile; ///< \internal Handle to an open instance of the NPF driver. + CHAR SymbolicLink[MAX_LINK_NAME_LENGTH]; ///< \internal A string containing the name of the network adapter currently opened. + int NumWrites; ///< \internal Number of times a packets written on this adapter will be repeated + ///< on the wire. + HANDLE ReadEvent; ///< A notification event associated with the read calls on the adapter. + ///< It can be passed to standard Win32 functions (like WaitForSingleObject + ///< or WaitForMultipleObjects) to wait until the driver's buffer contains some + ///< data. It is particularly useful in GUI applications that need to wait + ///< concurrently on several events. In Windows NT/2000 the PacketSetMinToCopy() + ///< function can be used to define the minimum amount of data in the kernel buffer + ///< that will cause the event to be signalled. + + UINT ReadTimeOut; ///< \internal The amount of time after which a read on the driver will be released and + ///< ReadEvent will be signaled, also if no packets were captured + CHAR Name[ADAPTER_NAME_LENGTH]; + PWAN_ADAPTER pWanAdapter; + UINT Flags; ///< Adapter's flags. Tell if this adapter must be treated in a different way, using the Netmon API or the dagc API. + +#ifdef HAVE_AIRPCAP_API + PAirpcapHandle AirpcapAd; +#endif // HAVE_AIRPCAP_API + +#ifdef HAVE_NPFIM_API + void* NpfImHandle; +#endif // HAVE_NPFIM_API + +#ifdef HAVE_DAG_API + dagc_t *pDagCard; ///< Pointer to the dagc API adapter descriptor for this adapter + PCHAR DagBuffer; ///< Pointer to the buffer with the packets that is received from the DAG card + struct timeval DagReadTimeout; ///< Read timeout. The dagc API requires a timeval structure + unsigned DagFcsLen; ///< Length of the frame check sequence attached to any packet by the card. Obtained from the registry + DWORD DagFastProcess; ///< True if the user requests fast capture processing on this card. Higher level applications can use this value to provide a faster but possibly unprecise capture (for example, libpcap doesn't convert the timestamps). +#endif // HAVE_DAG_API +} ADAPTER, *LPADAPTER; + +/*! + \brief Structure that contains a group of packets coming from the driver. + + This structure defines the header associated with every packet delivered to the application. +*/ +typedef struct _PACKET { + HANDLE hEvent; ///< \deprecated Still present for compatibility with old applications. + OVERLAPPED OverLapped; ///< \deprecated Still present for compatibility with old applications. + PVOID Buffer; ///< Buffer with containing the packets. See the PacketReceivePacket() for + ///< details about the organization of the data in this buffer + UINT Length; ///< Length of the buffer + DWORD ulBytesReceived; ///< Number of valid bytes present in the buffer, i.e. amount of data + ///< received by the last call to PacketReceivePacket() + BOOLEAN bIoComplete; ///< \deprecated Still present for compatibility with old applications. +} PACKET, *LPPACKET; + +/*! + \brief Structure containing an OID request. + + It is used by the PacketRequest() function to send an OID to the interface card driver. + It can be used, for example, to retrieve the status of the error counters on the adapter, its MAC address, + the list of the multicast groups defined on it, and so on. +*/ +struct _PACKET_OID_DATA { + ULONG Oid; ///< OID code. See the Microsoft DDK documentation or the file ntddndis.h + ///< for a complete list of valid codes. + ULONG Length; ///< Length of the data field + UCHAR Data[1]; ///< variable-lenght field that contains the information passed to or received + ///< from the adapter. +}; +typedef struct _PACKET_OID_DATA PACKET_OID_DATA, *PPACKET_OID_DATA; + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @} + */ + +/* +BOOLEAN QueryWinPcapRegistryStringA(CHAR *SubKeyName, + CHAR *Value, + UINT *pValueLen, + CHAR *DefaultVal); + +BOOLEAN QueryWinPcapRegistryStringW(WCHAR *SubKeyName, + WCHAR *Value, + UINT *pValueLen, + WCHAR *DefaultVal); +*/ + +//--------------------------------------------------------------------------- +// EXPORTED FUNCTIONS +//--------------------------------------------------------------------------- + +PCHAR PacketGetVersion(); +PCHAR PacketGetDriverVersion(); +BOOLEAN PacketSetMinToCopy(LPADAPTER AdapterObject,int nbytes); +BOOLEAN PacketSetNumWrites(LPADAPTER AdapterObject,int nwrites); +BOOLEAN PacketSetMode(LPADAPTER AdapterObject,int mode); +BOOLEAN PacketSetReadTimeout(LPADAPTER AdapterObject,int timeout); +BOOLEAN PacketSetBpf(LPADAPTER AdapterObject,struct bpf_program *fp); +BOOLEAN PacketSetLoopbackBehavior(LPADAPTER AdapterObject, UINT LoopbackBehavior); +INT PacketSetSnapLen(LPADAPTER AdapterObject,int snaplen); +BOOLEAN PacketGetStats(LPADAPTER AdapterObject,struct bpf_stat *s); +BOOLEAN PacketGetStatsEx(LPADAPTER AdapterObject,struct bpf_stat *s); +BOOLEAN PacketSetBuff(LPADAPTER AdapterObject,int dim); +BOOLEAN PacketGetNetType (LPADAPTER AdapterObject,NetType *type); +LPADAPTER PacketOpenAdapter(PCHAR AdapterName); +BOOLEAN PacketSendPacket(LPADAPTER AdapterObject,LPPACKET pPacket,BOOLEAN Sync); +INT PacketSendPackets(LPADAPTER AdapterObject,PVOID PacketBuff,ULONG Size, BOOLEAN Sync); +LPPACKET PacketAllocatePacket(void); +VOID PacketInitPacket(LPPACKET lpPacket,PVOID Buffer,UINT Length); +VOID PacketFreePacket(LPPACKET lpPacket); +BOOLEAN PacketReceivePacket(LPADAPTER AdapterObject,LPPACKET lpPacket,BOOLEAN Sync); +BOOLEAN PacketSetHwFilter(LPADAPTER AdapterObject,ULONG Filter); +BOOLEAN PacketGetAdapterNames(PTSTR pStr,PULONG BufferSize); +BOOLEAN PacketGetNetInfoEx(PCHAR AdapterName, npf_if_addr* buffer, PLONG NEntries); +BOOLEAN PacketRequest(LPADAPTER AdapterObject,BOOLEAN Set,PPACKET_OID_DATA OidData); +HANDLE PacketGetReadEvent(LPADAPTER AdapterObject); +BOOLEAN PacketSetDumpName(LPADAPTER AdapterObject, void *name, int len); +BOOLEAN PacketSetDumpLimits(LPADAPTER AdapterObject, UINT maxfilesize, UINT maxnpacks); +BOOLEAN PacketIsDumpEnded(LPADAPTER AdapterObject, BOOLEAN sync); +BOOL PacketStopDriver(); +VOID PacketCloseAdapter(LPADAPTER lpAdapter); +BOOLEAN PacketStartOem(PCHAR errorString, UINT errorStringLength); +PAirpcapHandle PacketGetAirPcapHandle(LPADAPTER AdapterObject); +#ifdef __cplusplus +} +#endif + +#endif //__PACKET32 diff --git a/desmume/src/windows/winpcap/Win32-Extensions.h b/src/windows/winpcap/Win32-Extensions.h similarity index 97% rename from desmume/src/windows/winpcap/Win32-Extensions.h rename to src/windows/winpcap/Win32-Extensions.h index ad3be25cf..d3b063b0f 100644 --- a/desmume/src/windows/winpcap/Win32-Extensions.h +++ b/src/windows/winpcap/Win32-Extensions.h @@ -1,113 +1,113 @@ -/* - * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) - * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Politecnico di Torino, CACE Technologies - * nor the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __WIN32_EXTENSIONS_H__ -#define __WIN32_EXTENSIONS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Definitions */ - -/*! - \brief A queue of raw packets that will be sent to the network with pcap_sendqueue_transmit(). -*/ -struct pcap_send_queue -{ - u_int maxlen; ///< Maximum size of the the queue, in bytes. This variable contains the size of the buffer field. - u_int len; ///< Current size of the queue, in bytes. - char *buffer; ///< Buffer containing the packets to be sent. -}; - -typedef struct pcap_send_queue pcap_send_queue; - -/*! - \brief This typedef is a support for the pcap_get_airpcap_handle() function -*/ -#if !defined(AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_) -#define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_ -typedef struct _AirpcapHandle *PAirpcapHandle; -#endif - -#define BPF_MEM_EX_IMM 0xc0 -#define BPF_MEM_EX_IND 0xe0 - -/*used for ST*/ -#define BPF_MEM_EX 0xc0 -#define BPF_TME 0x08 - -#define BPF_LOOKUP 0x90 -#define BPF_EXECUTE 0xa0 -#define BPF_INIT 0xb0 -#define BPF_VALIDATE 0xc0 -#define BPF_SET_ACTIVE 0xd0 -#define BPF_RESET 0xe0 -#define BPF_SET_MEMORY 0x80 -#define BPF_GET_REGISTER_VALUE 0x70 -#define BPF_SET_REGISTER_VALUE 0x60 -#define BPF_SET_WORKING 0x50 -#define BPF_SET_ACTIVE_READ 0x40 -#define BPF_SET_AUTODELETION 0x30 -#define BPF_SEPARATION 0xff - -/* Prototypes */ -pcap_send_queue* pcap_sendqueue_alloc(u_int memsize); - -void pcap_sendqueue_destroy(pcap_send_queue* queue); - -int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data); - -u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync); - -HANDLE pcap_getevent(pcap_t *p); - -struct pcap_stat *pcap_stats_ex(pcap_t *p, int *pcap_stat_size); - -int pcap_setuserbuffer(pcap_t *p, int size); - -int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks); - -int pcap_live_dump_ended(pcap_t *p, int sync); - -int pcap_offline_filter(struct bpf_program *prog, const struct pcap_pkthdr *header, const u_char *pkt_data); - -int pcap_start_oem(char* err_str, int flags); - -PAirpcapHandle pcap_get_airpcap_handle(pcap_t *p); - -#ifdef __cplusplus -} -#endif - -#endif //__WIN32_EXTENSIONS_H__ +/* + * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) + * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino, CACE Technologies + * nor the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __WIN32_EXTENSIONS_H__ +#define __WIN32_EXTENSIONS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Definitions */ + +/*! + \brief A queue of raw packets that will be sent to the network with pcap_sendqueue_transmit(). +*/ +struct pcap_send_queue +{ + u_int maxlen; ///< Maximum size of the the queue, in bytes. This variable contains the size of the buffer field. + u_int len; ///< Current size of the queue, in bytes. + char *buffer; ///< Buffer containing the packets to be sent. +}; + +typedef struct pcap_send_queue pcap_send_queue; + +/*! + \brief This typedef is a support for the pcap_get_airpcap_handle() function +*/ +#if !defined(AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_) +#define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_ +typedef struct _AirpcapHandle *PAirpcapHandle; +#endif + +#define BPF_MEM_EX_IMM 0xc0 +#define BPF_MEM_EX_IND 0xe0 + +/*used for ST*/ +#define BPF_MEM_EX 0xc0 +#define BPF_TME 0x08 + +#define BPF_LOOKUP 0x90 +#define BPF_EXECUTE 0xa0 +#define BPF_INIT 0xb0 +#define BPF_VALIDATE 0xc0 +#define BPF_SET_ACTIVE 0xd0 +#define BPF_RESET 0xe0 +#define BPF_SET_MEMORY 0x80 +#define BPF_GET_REGISTER_VALUE 0x70 +#define BPF_SET_REGISTER_VALUE 0x60 +#define BPF_SET_WORKING 0x50 +#define BPF_SET_ACTIVE_READ 0x40 +#define BPF_SET_AUTODELETION 0x30 +#define BPF_SEPARATION 0xff + +/* Prototypes */ +pcap_send_queue* pcap_sendqueue_alloc(u_int memsize); + +void pcap_sendqueue_destroy(pcap_send_queue* queue); + +int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data); + +u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync); + +HANDLE pcap_getevent(pcap_t *p); + +struct pcap_stat *pcap_stats_ex(pcap_t *p, int *pcap_stat_size); + +int pcap_setuserbuffer(pcap_t *p, int size); + +int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks); + +int pcap_live_dump_ended(pcap_t *p, int sync); + +int pcap_offline_filter(struct bpf_program *prog, const struct pcap_pkthdr *header, const u_char *pkt_data); + +int pcap_start_oem(char* err_str, int flags); + +PAirpcapHandle pcap_get_airpcap_handle(pcap_t *p); + +#ifdef __cplusplus +} +#endif + +#endif //__WIN32_EXTENSIONS_H__ diff --git a/desmume/src/windows/winpcap/bittypes.h b/src/windows/winpcap/bittypes.h similarity index 96% rename from desmume/src/windows/winpcap/bittypes.h rename to src/windows/winpcap/bittypes.h index c84077af3..1a2611d84 100644 --- a/desmume/src/windows/winpcap/bittypes.h +++ b/src/windows/winpcap/bittypes.h @@ -1,135 +1,135 @@ -/* - * Copyright (C) 1999 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#ifndef _BITTYPES_H -#define _BITTYPES_H - -#ifndef HAVE_U_INT8_T - -#if SIZEOF_CHAR == 1 -typedef unsigned char u_int8_t; -typedef signed char int8_t; -#elif SIZEOF_INT == 1 -typedef unsigned int u_int8_t; -typedef signed int int8_t; -#else /* XXX */ -#error "there's no appropriate type for u_int8_t" -#endif -#define HAVE_U_INT8_T 1 -#define HAVE_INT8_T 1 - -#endif /* HAVE_U_INT8_T */ - -#ifndef HAVE_U_INT16_T - -#if SIZEOF_SHORT == 2 -typedef unsigned short u_int16_t; -typedef signed short int16_t; -#elif SIZEOF_INT == 2 -typedef unsigned int u_int16_t; -typedef signed int int16_t; -#elif SIZEOF_CHAR == 2 -typedef unsigned char u_int16_t; -typedef signed char int16_t; -#else /* XXX */ -#error "there's no appropriate type for u_int16_t" -#endif -#define HAVE_U_INT16_T 1 -#define HAVE_INT16_T 1 - -#endif /* HAVE_U_INT16_T */ - -#ifndef HAVE_U_INT32_T - -#if SIZEOF_INT == 4 -typedef unsigned int u_int32_t; -typedef signed int int32_t; -#elif SIZEOF_LONG == 4 -typedef unsigned long u_int32_t; -typedef signed long int32_t; -#elif SIZEOF_SHORT == 4 -typedef unsigned short u_int32_t; -typedef signed short int32_t; -#else /* XXX */ -#error "there's no appropriate type for u_int32_t" -#endif -#define HAVE_U_INT32_T 1 -#define HAVE_INT32_T 1 - -#endif /* HAVE_U_INT32_T */ - -#ifndef HAVE_U_INT64_T -#if SIZEOF_LONG_LONG == 8 -typedef unsigned long long u_int64_t; -#elif defined(_MSC_EXTENSIONS) -typedef unsigned _int64 u_int64_t; -#elif SIZEOF_INT == 8 -typedef unsigned int u_int64_t; -#elif SIZEOF_LONG == 8 -typedef unsigned long u_int64_t; -#elif SIZEOF_SHORT == 8 -typedef unsigned short u_int64_t; -#else /* XXX */ -#error "there's no appropriate type for u_int64_t" -#endif - -#endif /* HAVE_U_INT64_T */ - -#ifndef PRId64 -#ifdef _MSC_EXTENSIONS -#define PRId64 "I64d" -#else /* _MSC_EXTENSIONS */ -#define PRId64 "lld" -#endif /* _MSC_EXTENSIONS */ -#endif /* PRId64 */ - -#ifndef PRIo64 -#ifdef _MSC_EXTENSIONS -#define PRIo64 "I64o" -#else /* _MSC_EXTENSIONS */ -#define PRIo64 "llo" -#endif /* _MSC_EXTENSIONS */ -#endif /* PRIo64 */ - -#ifndef PRIx64 -#ifdef _MSC_EXTENSIONS -#define PRIx64 "I64x" -#else /* _MSC_EXTENSIONS */ -#define PRIx64 "llx" -#endif /* _MSC_EXTENSIONS */ -#endif /* PRIx64 */ - -#ifndef PRIu64 -#ifdef _MSC_EXTENSIONS -#define PRIu64 "I64u" -#else /* _MSC_EXTENSIONS */ -#define PRIu64 "llu" -#endif /* _MSC_EXTENSIONS */ -#endif /* PRIu64 */ - -#endif /* _BITTYPES_H */ +/* + * Copyright (C) 1999 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef _BITTYPES_H +#define _BITTYPES_H + +#ifndef HAVE_U_INT8_T + +#if SIZEOF_CHAR == 1 +typedef unsigned char u_int8_t; +typedef signed char int8_t; +#elif SIZEOF_INT == 1 +typedef unsigned int u_int8_t; +typedef signed int int8_t; +#else /* XXX */ +#error "there's no appropriate type for u_int8_t" +#endif +#define HAVE_U_INT8_T 1 +#define HAVE_INT8_T 1 + +#endif /* HAVE_U_INT8_T */ + +#ifndef HAVE_U_INT16_T + +#if SIZEOF_SHORT == 2 +typedef unsigned short u_int16_t; +typedef signed short int16_t; +#elif SIZEOF_INT == 2 +typedef unsigned int u_int16_t; +typedef signed int int16_t; +#elif SIZEOF_CHAR == 2 +typedef unsigned char u_int16_t; +typedef signed char int16_t; +#else /* XXX */ +#error "there's no appropriate type for u_int16_t" +#endif +#define HAVE_U_INT16_T 1 +#define HAVE_INT16_T 1 + +#endif /* HAVE_U_INT16_T */ + +#ifndef HAVE_U_INT32_T + +#if SIZEOF_INT == 4 +typedef unsigned int u_int32_t; +typedef signed int int32_t; +#elif SIZEOF_LONG == 4 +typedef unsigned long u_int32_t; +typedef signed long int32_t; +#elif SIZEOF_SHORT == 4 +typedef unsigned short u_int32_t; +typedef signed short int32_t; +#else /* XXX */ +#error "there's no appropriate type for u_int32_t" +#endif +#define HAVE_U_INT32_T 1 +#define HAVE_INT32_T 1 + +#endif /* HAVE_U_INT32_T */ + +#ifndef HAVE_U_INT64_T +#if SIZEOF_LONG_LONG == 8 +typedef unsigned long long u_int64_t; +#elif defined(_MSC_EXTENSIONS) +typedef unsigned _int64 u_int64_t; +#elif SIZEOF_INT == 8 +typedef unsigned int u_int64_t; +#elif SIZEOF_LONG == 8 +typedef unsigned long u_int64_t; +#elif SIZEOF_SHORT == 8 +typedef unsigned short u_int64_t; +#else /* XXX */ +#error "there's no appropriate type for u_int64_t" +#endif + +#endif /* HAVE_U_INT64_T */ + +#ifndef PRId64 +#ifdef _MSC_EXTENSIONS +#define PRId64 "I64d" +#else /* _MSC_EXTENSIONS */ +#define PRId64 "lld" +#endif /* _MSC_EXTENSIONS */ +#endif /* PRId64 */ + +#ifndef PRIo64 +#ifdef _MSC_EXTENSIONS +#define PRIo64 "I64o" +#else /* _MSC_EXTENSIONS */ +#define PRIo64 "llo" +#endif /* _MSC_EXTENSIONS */ +#endif /* PRIo64 */ + +#ifndef PRIx64 +#ifdef _MSC_EXTENSIONS +#define PRIx64 "I64x" +#else /* _MSC_EXTENSIONS */ +#define PRIx64 "llx" +#endif /* _MSC_EXTENSIONS */ +#endif /* PRIx64 */ + +#ifndef PRIu64 +#ifdef _MSC_EXTENSIONS +#define PRIu64 "I64u" +#else /* _MSC_EXTENSIONS */ +#define PRIu64 "llu" +#endif /* _MSC_EXTENSIONS */ +#endif /* PRIu64 */ + +#endif /* _BITTYPES_H */ diff --git a/desmume/src/windows/winpcap/bucket_lookup.h b/src/windows/winpcap/bucket_lookup.h similarity index 97% rename from desmume/src/windows/winpcap/bucket_lookup.h rename to src/windows/winpcap/bucket_lookup.h index e614e45d9..b17843694 100644 --- a/desmume/src/windows/winpcap/bucket_lookup.h +++ b/src/windows/winpcap/bucket_lookup.h @@ -1,54 +1,54 @@ -/* - * Copyright (c) 2001 - 2003 - * NetGroup, Politecnico di Torino (Italy) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Politecnico di Torino nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __bucket_lookup -#define __bucket_lookup -#ifdef WIN32 -#include "tme.h" -#endif - -#ifdef __FreeBSD__ - -#ifdef _KERNEL -#include -#else -#include -#endif - -#endif - -#define BUCKET_LOOKUP_INSERT 0x00000011 -uint32 bucket_lookup_insert(uint8 *key, TME_DATA *data, MEM_TYPE *mem_ex, struct time_conv *time_ref); -#define BUCKET_LOOKUP 0x00000010 -uint32 bucket_lookup(uint8 *key, TME_DATA *data, MEM_TYPE *mem_ex, struct time_conv *time_ref); - +/* + * Copyright (c) 2001 - 2003 + * NetGroup, Politecnico di Torino (Italy) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __bucket_lookup +#define __bucket_lookup +#ifdef WIN32 +#include "tme.h" +#endif + +#ifdef __FreeBSD__ + +#ifdef _KERNEL +#include +#else +#include +#endif + +#endif + +#define BUCKET_LOOKUP_INSERT 0x00000011 +uint32 bucket_lookup_insert(uint8 *key, TME_DATA *data, MEM_TYPE *mem_ex, struct time_conv *time_ref); +#define BUCKET_LOOKUP 0x00000010 +uint32 bucket_lookup(uint8 *key, TME_DATA *data, MEM_TYPE *mem_ex, struct time_conv *time_ref); + #endif \ No newline at end of file diff --git a/desmume/src/windows/winpcap/count_packets.h b/src/windows/winpcap/count_packets.h similarity index 97% rename from desmume/src/windows/winpcap/count_packets.h rename to src/windows/winpcap/count_packets.h index 2cd1af597..9853bda34 100644 --- a/desmume/src/windows/winpcap/count_packets.h +++ b/src/windows/winpcap/count_packets.h @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2001 - 2003 - * NetGroup, Politecnico di Torino (Italy) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Politecnico di Torino nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __count_packets -#define __count_packets - -#ifdef WIN32 -#include "tme.h" -#endif - -#ifdef __FreeBSD__ - -#ifdef _KERNEL -#include -#else -#include -#endif - -#endif - -typedef struct __c_p_data -{ - struct timeval timestamp; - uint64 packets; - uint64 bytes; -} - c_p_data; - -#define COUNT_PACKETS 0x00000000 -uint32 count_packets(uint8 *block, uint32 pkt_size, TME_DATA *data, MEM_TYPE *mem_ex, uint8 *mem_data); - -#endif - +/* + * Copyright (c) 2001 - 2003 + * NetGroup, Politecnico di Torino (Italy) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __count_packets +#define __count_packets + +#ifdef WIN32 +#include "tme.h" +#endif + +#ifdef __FreeBSD__ + +#ifdef _KERNEL +#include +#else +#include +#endif + +#endif + +typedef struct __c_p_data +{ + struct timeval timestamp; + uint64 packets; + uint64 bytes; +} + c_p_data; + +#define COUNT_PACKETS 0x00000000 +uint32 count_packets(uint8 *block, uint32 pkt_size, TME_DATA *data, MEM_TYPE *mem_ex, uint8 *mem_data); + +#endif + diff --git a/desmume/src/windows/winpcap/ip6_misc.h b/src/windows/winpcap/ip6_misc.h similarity index 97% rename from desmume/src/windows/winpcap/ip6_misc.h rename to src/windows/winpcap/ip6_misc.h index 6ff3dd548..fb02e40a6 100644 --- a/desmume/src/windows/winpcap/ip6_misc.h +++ b/src/windows/winpcap/ip6_misc.h @@ -1,165 +1,165 @@ -/* - * Copyright (c) 1993, 1994, 1997 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * @(#) $Header: /tcpdump/master/libpcap/Win32/Include/ip6_misc.h,v 1.4.2.1 2006/01/22 18:13:47 gianluca Exp $ (LBL) - */ - -/* - * This file contains a collage of declarations for IPv6 from FreeBSD not present in Windows - */ - -#include - -#ifndef __MINGW32__ -#include -#endif /* __MINGW32__ */ - -#ifndef __MINGW32__ -#define IN_MULTICAST(a) IN_CLASSD(a) -#endif - -#define IN_EXPERIMENTAL(a) ((((u_int32_t) (a)) & 0xf0000000) == 0xf0000000) - -#define IN_LOOPBACKNET 127 - -#ifdef __MINGW32__ -/* IPv6 address */ -struct in6_addr - { - union - { - u_int8_t u6_addr8[16]; - u_int16_t u6_addr16[8]; - u_int32_t u6_addr32[4]; - } in6_u; -#define s6_addr in6_u.u6_addr8 -#define s6_addr16 in6_u.u6_addr16 -#define s6_addr32 in6_u.u6_addr32 -#define s6_addr64 in6_u.u6_addr64 - }; - -#define IN6ADDR_ANY_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } -#define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } -#endif /* __MINGW32__ */ - - -#if (defined WIN32) || (defined __MINGW32__) -typedef unsigned short sa_family_t; -#endif - - -#ifdef __MINGW32__ - -#define __SOCKADDR_COMMON(sa_prefix) \ - sa_family_t sa_prefix##family - -/* Ditto, for IPv6. */ -struct sockaddr_in6 - { - __SOCKADDR_COMMON (sin6_); - u_int16_t sin6_port; /* Transport layer port # */ - u_int32_t sin6_flowinfo; /* IPv6 flow information */ - struct in6_addr sin6_addr; /* IPv6 address */ - }; - -#define IN6_IS_ADDR_V4MAPPED(a) \ - ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \ - (((u_int32_t *) (a))[2] == htonl (0xffff))) - -#define IN6_IS_ADDR_MULTICAST(a) (((u_int8_t *) (a))[0] == 0xff) - -#define IN6_IS_ADDR_LINKLOCAL(a) \ - ((((u_int32_t *) (a))[0] & htonl (0xffc00000)) == htonl (0xfe800000)) - -#define IN6_IS_ADDR_LOOPBACK(a) \ - (((u_int32_t *) (a))[0] == 0 && ((u_int32_t *) (a))[1] == 0 && \ - ((u_int32_t *) (a))[2] == 0 && ((u_int32_t *) (a))[3] == htonl (1)) -#endif /* __MINGW32__ */ - -#define ip6_vfc ip6_ctlun.ip6_un2_vfc -#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow -#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen -#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt -#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim -#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim - -#define nd_rd_type nd_rd_hdr.icmp6_type -#define nd_rd_code nd_rd_hdr.icmp6_code -#define nd_rd_cksum nd_rd_hdr.icmp6_cksum -#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] - -/* - * IPV6 extension headers - */ -#define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */ -#define IPPROTO_IPV6 41 /* IPv6 header. */ -#define IPPROTO_ROUTING 43 /* IPv6 routing header */ -#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */ -#define IPPROTO_ESP 50 /* encapsulating security payload */ -#define IPPROTO_AH 51 /* authentication header */ -#define IPPROTO_ICMPV6 58 /* ICMPv6 */ -#define IPPROTO_NONE 59 /* IPv6 no next header */ -#define IPPROTO_DSTOPTS 60 /* IPv6 destination options */ -#define IPPROTO_PIM 103 /* Protocol Independent Multicast. */ - -#define IPV6_RTHDR_TYPE_0 0 - -/* Option types and related macros */ -#define IP6OPT_PAD1 0x00 /* 00 0 00000 */ -#define IP6OPT_PADN 0x01 /* 00 0 00001 */ -#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */ -#define IP6OPT_JUMBO_LEN 6 -#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */ - -#define IP6OPT_RTALERT_LEN 4 -#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */ -#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */ -#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */ -#define IP6OPT_MINLEN 2 - -#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */ -#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */ -#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */ -#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */ -#define IP6OPT_EID 0x8a /* 10 0 01010 */ - -#define IP6OPT_TYPE(o) ((o) & 0xC0) -#define IP6OPT_TYPE_SKIP 0x00 -#define IP6OPT_TYPE_DISCARD 0x40 -#define IP6OPT_TYPE_FORCEICMP 0x80 -#define IP6OPT_TYPE_ICMP 0xC0 - -#define IP6OPT_MUTABLE 0x20 - - -#ifdef __MINGW32__ -#ifndef EAI_ADDRFAMILY -struct addrinfo { - int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ - int ai_family; /* PF_xxx */ - int ai_socktype; /* SOCK_xxx */ - int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ - size_t ai_addrlen; /* length of ai_addr */ - char *ai_canonname; /* canonical name for hostname */ - struct sockaddr *ai_addr; /* binary address */ - struct addrinfo *ai_next; /* next structure in linked list */ -}; -#endif -#endif /* __MINGW32__ */ +/* + * Copyright (c) 1993, 1994, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that: (1) source code distributions + * retain the above copyright notice and this paragraph in its entirety, (2) + * distributions including binary code include the above copyright notice and + * this paragraph in its entirety in the documentation or other materials + * provided with the distribution, and (3) all advertising materials mentioning + * features or use of this software display the following acknowledgement: + * ``This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of + * the University nor the names of its contributors may be used to endorse + * or promote products derived from this software without specific prior + * written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#) $Header: /tcpdump/master/libpcap/Win32/Include/ip6_misc.h,v 1.4.2.1 2006/01/22 18:13:47 gianluca Exp $ (LBL) + */ + +/* + * This file contains a collage of declarations for IPv6 from FreeBSD not present in Windows + */ + +#include + +#ifndef __MINGW32__ +#include +#endif /* __MINGW32__ */ + +#ifndef __MINGW32__ +#define IN_MULTICAST(a) IN_CLASSD(a) +#endif + +#define IN_EXPERIMENTAL(a) ((((u_int32_t) (a)) & 0xf0000000) == 0xf0000000) + +#define IN_LOOPBACKNET 127 + +#ifdef __MINGW32__ +/* IPv6 address */ +struct in6_addr + { + union + { + u_int8_t u6_addr8[16]; + u_int16_t u6_addr16[8]; + u_int32_t u6_addr32[4]; + } in6_u; +#define s6_addr in6_u.u6_addr8 +#define s6_addr16 in6_u.u6_addr16 +#define s6_addr32 in6_u.u6_addr32 +#define s6_addr64 in6_u.u6_addr64 + }; + +#define IN6ADDR_ANY_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } +#define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } +#endif /* __MINGW32__ */ + + +#if (defined WIN32) || (defined __MINGW32__) +typedef unsigned short sa_family_t; +#endif + + +#ifdef __MINGW32__ + +#define __SOCKADDR_COMMON(sa_prefix) \ + sa_family_t sa_prefix##family + +/* Ditto, for IPv6. */ +struct sockaddr_in6 + { + __SOCKADDR_COMMON (sin6_); + u_int16_t sin6_port; /* Transport layer port # */ + u_int32_t sin6_flowinfo; /* IPv6 flow information */ + struct in6_addr sin6_addr; /* IPv6 address */ + }; + +#define IN6_IS_ADDR_V4MAPPED(a) \ + ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \ + (((u_int32_t *) (a))[2] == htonl (0xffff))) + +#define IN6_IS_ADDR_MULTICAST(a) (((u_int8_t *) (a))[0] == 0xff) + +#define IN6_IS_ADDR_LINKLOCAL(a) \ + ((((u_int32_t *) (a))[0] & htonl (0xffc00000)) == htonl (0xfe800000)) + +#define IN6_IS_ADDR_LOOPBACK(a) \ + (((u_int32_t *) (a))[0] == 0 && ((u_int32_t *) (a))[1] == 0 && \ + ((u_int32_t *) (a))[2] == 0 && ((u_int32_t *) (a))[3] == htonl (1)) +#endif /* __MINGW32__ */ + +#define ip6_vfc ip6_ctlun.ip6_un2_vfc +#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow +#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen +#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt +#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim +#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim + +#define nd_rd_type nd_rd_hdr.icmp6_type +#define nd_rd_code nd_rd_hdr.icmp6_code +#define nd_rd_cksum nd_rd_hdr.icmp6_cksum +#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] + +/* + * IPV6 extension headers + */ +#define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */ +#define IPPROTO_IPV6 41 /* IPv6 header. */ +#define IPPROTO_ROUTING 43 /* IPv6 routing header */ +#define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */ +#define IPPROTO_ESP 50 /* encapsulating security payload */ +#define IPPROTO_AH 51 /* authentication header */ +#define IPPROTO_ICMPV6 58 /* ICMPv6 */ +#define IPPROTO_NONE 59 /* IPv6 no next header */ +#define IPPROTO_DSTOPTS 60 /* IPv6 destination options */ +#define IPPROTO_PIM 103 /* Protocol Independent Multicast. */ + +#define IPV6_RTHDR_TYPE_0 0 + +/* Option types and related macros */ +#define IP6OPT_PAD1 0x00 /* 00 0 00000 */ +#define IP6OPT_PADN 0x01 /* 00 0 00001 */ +#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */ +#define IP6OPT_JUMBO_LEN 6 +#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */ + +#define IP6OPT_RTALERT_LEN 4 +#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */ +#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */ +#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */ +#define IP6OPT_MINLEN 2 + +#define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */ +#define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */ +#define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */ +#define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */ +#define IP6OPT_EID 0x8a /* 10 0 01010 */ + +#define IP6OPT_TYPE(o) ((o) & 0xC0) +#define IP6OPT_TYPE_SKIP 0x00 +#define IP6OPT_TYPE_DISCARD 0x40 +#define IP6OPT_TYPE_FORCEICMP 0x80 +#define IP6OPT_TYPE_ICMP 0xC0 + +#define IP6OPT_MUTABLE 0x20 + + +#ifdef __MINGW32__ +#ifndef EAI_ADDRFAMILY +struct addrinfo { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + size_t ai_addrlen; /* length of ai_addr */ + char *ai_canonname; /* canonical name for hostname */ + struct sockaddr *ai_addr; /* binary address */ + struct addrinfo *ai_next; /* next structure in linked list */ +}; +#endif +#endif /* __MINGW32__ */ diff --git a/desmume/src/windows/winpcap/memory_t.h b/src/windows/winpcap/memory_t.h similarity index 96% rename from desmume/src/windows/winpcap/memory_t.h rename to src/windows/winpcap/memory_t.h index b4200168a..3f3fb526b 100644 --- a/desmume/src/windows/winpcap/memory_t.h +++ b/src/windows/winpcap/memory_t.h @@ -1,133 +1,133 @@ -/* - * Copyright (c) 2001 - 2005 NetGroup, Politecnico di Torino (Italy) - * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Politecnico di Torino, CACE Technologies - * nor the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __memory_t -#define __memory_t - -#define uint8 UCHAR -#define int8 CHAR -#define uint16 USHORT -#define int16 SHORT -#define uint32 ULONG -#define int32 LONG -#define uint64 ULONGLONG -#define int64 LONGLONG - -/*memory type*/ -typedef struct __MEM_TYPE -{ - uint8 *buffer; - uint32 size; -} MEM_TYPE, *PMEM_TYPE; - -#define LONG_AT(base,offset) (*(int32*)((uint8*)base+(uint32)offset)) - -#define ULONG_AT(base,offset) (*(uint32*)((uint8*)base+(uint32)offset)) - -#define SHORT_AT(base,offset) (*(int16*)((uint8*)base+(uint32)offset)) - -#define USHORT_AT(base,offset) (*(uint16*)((uint8*)base+(uint32)offset)) - -__inline int32 SW_LONG_AT(void *b, uint32 c) -{ - return ((int32)*((uint8 *)b+c)<<24| - (int32)*((uint8 *)b+c+1)<<16| - (int32)*((uint8 *)b+c+2)<<8| - (int32)*((uint8 *)b+c+3)<<0); -} - - -__inline uint32 SW_ULONG_AT(void *b, uint32 c) -{ - return ((uint32)*((uint8 *)b+c)<<24| - (uint32)*((uint8 *)b+c+1)<<16| - (uint32)*((uint8 *)b+c+2)<<8| - (uint32)*((uint8 *)b+c+3)<<0); -} - -__inline int16 SW_SHORT_AT(void *b, uint32 os) -{ - return ((int16) - ((int16)*((uint8 *)b+os+0)<<8| - (int16)*((uint8 *)b+os+1)<<0)); -} - -__inline uint16 SW_USHORT_AT(void *b, uint32 os) -{ - return ((uint16) - ((uint16)*((uint8 *)b+os+0)<<8| - (uint16)*((uint8 *)b+os+1)<<0)); -} - -__inline VOID SW_ULONG_ASSIGN(void *dst, uint32 src) -{ - *((uint8*)dst+0)=*((uint8*)&src+3); - *((uint8*)dst+1)=*((uint8*)&src+2); - *((uint8*)dst+2)=*((uint8*)&src+1); - *((uint8*)dst+3)=*((uint8*)&src+0); - -} - -#ifdef WIN_NT_DRIVER - -#define ALLOCATE_MEMORY(dest,type,amount) \ - (dest)=ExAllocatePoolWithTag(NonPagedPool,sizeof(type)*(amount), '0TWA'); -#define ALLOCATE_ZERO_MEMORY(dest,type,amount) \ - { \ - (dest)=ExAllocatePoolWithTag(NonPagedPool,sizeof(type)*(amount), '1TWA'); \ - if ((dest)!=NULL) \ - RtlZeroMemory((dest),sizeof(type)*(amount)); \ - } - -#define FREE_MEMORY(dest) ExFreePool(dest); -#define ZERO_MEMORY(dest,amount) RtlZeroMemory(dest,amount); -#define COPY_MEMORY(dest,src,amount) RtlCopyMemory(dest,src,amount); - -#else - -#define ALLOCATE_MEMORY(dest,type,amount) \ - (dest)=(type*)GlobalAlloc(GPTR, sizeof(type)*(amount)); -#define ALLOCATE_ZERO_MEMORY(dest,type,amount) \ - (dest)=(type*)GlobalAlloc(GPTR, sizeof(type)*(amount)); - -#define FREE_MEMORY(dest) GlobalFree(dest); -#define ZERO_MEMORY(dest,amount) RtlZeroMemory(dest,amount); -#define COPY_MEMORY(dest,src,amount) RtlCopyMemory(dest,src,amount); - - -#endif /*WIN_NT_DRIVER*/ - - - -#endif - +/* + * Copyright (c) 2001 - 2005 NetGroup, Politecnico di Torino (Italy) + * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino, CACE Technologies + * nor the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __memory_t +#define __memory_t + +#define uint8 UCHAR +#define int8 CHAR +#define uint16 USHORT +#define int16 SHORT +#define uint32 ULONG +#define int32 LONG +#define uint64 ULONGLONG +#define int64 LONGLONG + +/*memory type*/ +typedef struct __MEM_TYPE +{ + uint8 *buffer; + uint32 size; +} MEM_TYPE, *PMEM_TYPE; + +#define LONG_AT(base,offset) (*(int32*)((uint8*)base+(uint32)offset)) + +#define ULONG_AT(base,offset) (*(uint32*)((uint8*)base+(uint32)offset)) + +#define SHORT_AT(base,offset) (*(int16*)((uint8*)base+(uint32)offset)) + +#define USHORT_AT(base,offset) (*(uint16*)((uint8*)base+(uint32)offset)) + +__inline int32 SW_LONG_AT(void *b, uint32 c) +{ + return ((int32)*((uint8 *)b+c)<<24| + (int32)*((uint8 *)b+c+1)<<16| + (int32)*((uint8 *)b+c+2)<<8| + (int32)*((uint8 *)b+c+3)<<0); +} + + +__inline uint32 SW_ULONG_AT(void *b, uint32 c) +{ + return ((uint32)*((uint8 *)b+c)<<24| + (uint32)*((uint8 *)b+c+1)<<16| + (uint32)*((uint8 *)b+c+2)<<8| + (uint32)*((uint8 *)b+c+3)<<0); +} + +__inline int16 SW_SHORT_AT(void *b, uint32 os) +{ + return ((int16) + ((int16)*((uint8 *)b+os+0)<<8| + (int16)*((uint8 *)b+os+1)<<0)); +} + +__inline uint16 SW_USHORT_AT(void *b, uint32 os) +{ + return ((uint16) + ((uint16)*((uint8 *)b+os+0)<<8| + (uint16)*((uint8 *)b+os+1)<<0)); +} + +__inline VOID SW_ULONG_ASSIGN(void *dst, uint32 src) +{ + *((uint8*)dst+0)=*((uint8*)&src+3); + *((uint8*)dst+1)=*((uint8*)&src+2); + *((uint8*)dst+2)=*((uint8*)&src+1); + *((uint8*)dst+3)=*((uint8*)&src+0); + +} + +#ifdef WIN_NT_DRIVER + +#define ALLOCATE_MEMORY(dest,type,amount) \ + (dest)=ExAllocatePoolWithTag(NonPagedPool,sizeof(type)*(amount), '0TWA'); +#define ALLOCATE_ZERO_MEMORY(dest,type,amount) \ + { \ + (dest)=ExAllocatePoolWithTag(NonPagedPool,sizeof(type)*(amount), '1TWA'); \ + if ((dest)!=NULL) \ + RtlZeroMemory((dest),sizeof(type)*(amount)); \ + } + +#define FREE_MEMORY(dest) ExFreePool(dest); +#define ZERO_MEMORY(dest,amount) RtlZeroMemory(dest,amount); +#define COPY_MEMORY(dest,src,amount) RtlCopyMemory(dest,src,amount); + +#else + +#define ALLOCATE_MEMORY(dest,type,amount) \ + (dest)=(type*)GlobalAlloc(GPTR, sizeof(type)*(amount)); +#define ALLOCATE_ZERO_MEMORY(dest,type,amount) \ + (dest)=(type*)GlobalAlloc(GPTR, sizeof(type)*(amount)); + +#define FREE_MEMORY(dest) GlobalFree(dest); +#define ZERO_MEMORY(dest,amount) RtlZeroMemory(dest,amount); +#define COPY_MEMORY(dest,src,amount) RtlCopyMemory(dest,src,amount); + + +#endif /*WIN_NT_DRIVER*/ + + + +#endif + diff --git a/desmume/src/windows/winpcap/normal_lookup.h b/src/windows/winpcap/normal_lookup.h similarity index 97% rename from desmume/src/windows/winpcap/normal_lookup.h rename to src/windows/winpcap/normal_lookup.h index 62e75f467..f9fb00bf9 100644 --- a/desmume/src/windows/winpcap/normal_lookup.h +++ b/src/windows/winpcap/normal_lookup.h @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2001 - 2003 - * NetGroup, Politecnico di Torino (Italy) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Politecnico di Torino nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __normal_lookup -#define __normal_lookup - -#ifdef WIN32 -#include "tme.h" -#endif - -#ifdef __FreeBSD__ - -#ifdef _KERNEL -#include -#else -#include -#endif - -#endif - -#define NORMAL_LUT_W_INSERT 0x00000000 -uint32 normal_lut_w_insert(uint8 *key, TME_DATA *data, MEM_TYPE *mem_ex, struct time_conv *time_ref); -#define NORMAL_LUT_WO_INSERT 0x00000001 -uint32 normal_lut_wo_insert(uint8 *key, TME_DATA *data, MEM_TYPE *mem_ex, struct time_conv *time_ref); -#define DUMMY_INSERT 1234 - +/* + * Copyright (c) 2001 - 2003 + * NetGroup, Politecnico di Torino (Italy) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __normal_lookup +#define __normal_lookup + +#ifdef WIN32 +#include "tme.h" +#endif + +#ifdef __FreeBSD__ + +#ifdef _KERNEL +#include +#else +#include +#endif + +#endif + +#define NORMAL_LUT_W_INSERT 0x00000000 +uint32 normal_lut_w_insert(uint8 *key, TME_DATA *data, MEM_TYPE *mem_ex, struct time_conv *time_ref); +#define NORMAL_LUT_WO_INSERT 0x00000001 +uint32 normal_lut_wo_insert(uint8 *key, TME_DATA *data, MEM_TYPE *mem_ex, struct time_conv *time_ref); +#define DUMMY_INSERT 1234 + #endif \ No newline at end of file diff --git a/desmume/src/windows/winpcap/pcap-bpf.h b/src/windows/winpcap/pcap-bpf.h similarity index 96% rename from desmume/src/windows/winpcap/pcap-bpf.h rename to src/windows/winpcap/pcap-bpf.h index 542976701..175fa73df 100644 --- a/desmume/src/windows/winpcap/pcap-bpf.h +++ b/src/windows/winpcap/pcap-bpf.h @@ -1,736 +1,736 @@ -/*- - * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from the Stanford/CMU enet packet filter, - * (net/enet.c) distributed as part of 4.3BSD, and code contributed - * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence - * Berkeley Laboratory. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)bpf.h 7.1 (Berkeley) 5/7/91 - * - * @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.34.2.11 2006/07/27 21:06:17 gianluca Exp $ (LBL) - */ - -/* - * This is libpcap's cut-down version of bpf.h; it includes only - * the stuff needed for the code generator and the userland BPF - * interpreter, and the libpcap APIs for setting filters, etc.. - * - * "pcap-bpf.c" will include the native OS version, as it deals with - * the OS's BPF implementation. - * - * XXX - should this all just be moved to "pcap.h"? - */ - -#ifndef BPF_MAJOR_VERSION - -#ifdef __cplusplus -extern "C" { -#endif - -/* BSD style release date */ -#define BPF_RELEASE 199606 - -#ifdef MSDOS /* must be 32-bit */ -typedef long bpf_int32; -typedef unsigned long bpf_u_int32; -#else -typedef int bpf_int32; -typedef u_int bpf_u_int32; -#endif - -/* - * Alignment macros. BPF_WORDALIGN rounds up to the next - * even multiple of BPF_ALIGNMENT. - */ -#ifndef __NetBSD__ -#define BPF_ALIGNMENT sizeof(bpf_int32) -#else -#define BPF_ALIGNMENT sizeof(long) -#endif -#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1)) - -#define BPF_MAXINSNS 512 -#define BPF_MAXBUFSIZE 0x8000 -#define BPF_MINBUFSIZE 32 - -/* - * Structure for "pcap_compile()", "pcap_setfilter()", etc.. - */ -struct bpf_program { - u_int bf_len; - struct bpf_insn *bf_insns; -}; - -/* - * Struct return by BIOCVERSION. This represents the version number of - * the filter language described by the instruction encodings below. - * bpf understands a program iff kernel_major == filter_major && - * kernel_minor >= filter_minor, that is, if the value returned by the - * running kernel has the same major number and a minor number equal - * equal to or less than the filter being downloaded. Otherwise, the - * results are undefined, meaning an error may be returned or packets - * may be accepted haphazardly. - * It has nothing to do with the source code version. - */ -struct bpf_version { - u_short bv_major; - u_short bv_minor; -}; -/* Current version number of filter architecture. */ -#define BPF_MAJOR_VERSION 1 -#define BPF_MINOR_VERSION 1 - -/* - * Data-link level type codes. - * - * Do *NOT* add new values to this list without asking - * "tcpdump-workers@tcpdump.org" for a value. Otherwise, you run the - * risk of using a value that's already being used for some other purpose, - * and of having tools that read libpcap-format captures not being able - * to handle captures with your new DLT_ value, with no hope that they - * will ever be changed to do so (as that would destroy their ability - * to read captures using that value for that other purpose). - */ - -/* - * These are the types that are the same on all platforms, and that - * have been defined by for ages. - */ -#define DLT_NULL 0 /* BSD loopback encapsulation */ -#define DLT_EN10MB 1 /* Ethernet (10Mb) */ -#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */ -#define DLT_AX25 3 /* Amateur Radio AX.25 */ -#define DLT_PRONET 4 /* Proteon ProNET Token Ring */ -#define DLT_CHAOS 5 /* Chaos */ -#define DLT_IEEE802 6 /* IEEE 802 Networks */ -#define DLT_ARCNET 7 /* ARCNET, with BSD-style header */ -#define DLT_SLIP 8 /* Serial Line IP */ -#define DLT_PPP 9 /* Point-to-point Protocol */ -#define DLT_FDDI 10 /* FDDI */ - -/* - * These are types that are different on some platforms, and that - * have been defined by for ages. We use #ifdefs to - * detect the BSDs that define them differently from the traditional - * libpcap - * - * XXX - DLT_ATM_RFC1483 is 13 in BSD/OS, and DLT_RAW is 14 in BSD/OS, - * but I don't know what the right #define is for BSD/OS. - */ -#define DLT_ATM_RFC1483 11 /* LLC-encapsulated ATM */ - -#ifdef __OpenBSD__ -#define DLT_RAW 14 /* raw IP */ -#else -#define DLT_RAW 12 /* raw IP */ -#endif - -/* - * Given that the only OS that currently generates BSD/OS SLIP or PPP - * is, well, BSD/OS, arguably everybody should have chosen its values - * for DLT_SLIP_BSDOS and DLT_PPP_BSDOS, which are 15 and 16, but they - * didn't. So it goes. - */ -#if defined(__NetBSD__) || defined(__FreeBSD__) -#ifndef DLT_SLIP_BSDOS -#define DLT_SLIP_BSDOS 13 /* BSD/OS Serial Line IP */ -#define DLT_PPP_BSDOS 14 /* BSD/OS Point-to-point Protocol */ -#endif -#else -#define DLT_SLIP_BSDOS 15 /* BSD/OS Serial Line IP */ -#define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */ -#endif - -/* - * 17 is used for DLT_OLD_PFLOG in OpenBSD; - * OBSOLETE: DLT_PFLOG is 117 in OpenBSD now as well. See below. - * 18 is used for DLT_PFSYNC in OpenBSD; don't use it for anything else. - */ - -#define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */ - -/* - * Apparently Redback uses this for its SmartEdge 400/800. I hope - * nobody else decided to use it, too. - */ -#define DLT_REDBACK_SMARTEDGE 32 - -/* - * These values are defined by NetBSD; other platforms should refrain from - * using them for other purposes, so that NetBSD savefiles with link - * types of 50 or 51 can be read as this type on all platforms. - */ -#define DLT_PPP_SERIAL 50 /* PPP over serial with HDLC encapsulation */ -#define DLT_PPP_ETHER 51 /* PPP over Ethernet */ - -/* - * The Axent Raptor firewall - now the Symantec Enterprise Firewall - uses - * a link-layer type of 99 for the tcpdump it supplies. The link-layer - * header has 6 bytes of unknown data, something that appears to be an - * Ethernet type, and 36 bytes that appear to be 0 in at least one capture - * I've seen. - */ -#define DLT_SYMANTEC_FIREWALL 99 - -/* - * Values between 100 and 103 are used in capture file headers as - * link-layer types corresponding to DLT_ types that differ - * between platforms; don't use those values for new DLT_ new types. - */ - -/* - * This value was defined by libpcap 0.5; platforms that have defined - * it with a different value should define it here with that value - - * a link type of 104 in a save file will be mapped to DLT_C_HDLC, - * whatever value that happens to be, so programs will correctly - * handle files with that link type regardless of the value of - * DLT_C_HDLC. - * - * The name DLT_C_HDLC was used by BSD/OS; we use that name for source - * compatibility with programs written for BSD/OS. - * - * libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well, - * for source compatibility with programs written for libpcap 0.5. - */ -#define DLT_C_HDLC 104 /* Cisco HDLC */ -#define DLT_CHDLC DLT_C_HDLC - -#define DLT_IEEE802_11 105 /* IEEE 802.11 wireless */ - -/* - * 106 is reserved for Linux Classical IP over ATM; it's like DLT_RAW, - * except when it isn't. (I.e., sometimes it's just raw IP, and - * sometimes it isn't.) We currently handle it as DLT_LINUX_SLL, - * so that we don't have to worry about the link-layer header.) - */ - -/* - * Frame Relay; BSD/OS has a DLT_FR with a value of 11, but that collides - * with other values. - * DLT_FR and DLT_FRELAY packets start with the Q.922 Frame Relay header - * (DLCI, etc.). - */ -#define DLT_FRELAY 107 - -/* - * OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except - * that the AF_ type in the link-layer header is in network byte order. - * - * OpenBSD defines it as 12, but that collides with DLT_RAW, so we - * define it as 108 here. If OpenBSD picks up this file, it should - * define DLT_LOOP as 12 in its version, as per the comment above - - * and should not use 108 as a DLT_ value. - */ -#define DLT_LOOP 108 - -/* - * Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's - * DLT_SLIP_BSDOS in NetBSD, so we don't use 13 for it in OSes other - * than OpenBSD. - */ -#ifdef __OpenBSD__ -#define DLT_ENC 13 -#else -#define DLT_ENC 109 -#endif - -/* - * Values between 110 and 112 are reserved for use in capture file headers - * as link-layer types corresponding to DLT_ types that might differ - * between platforms; don't use those values for new DLT_ types - * other than the corresponding DLT_ types. - */ - -/* - * This is for Linux cooked sockets. - */ -#define DLT_LINUX_SLL 113 - -/* - * Apple LocalTalk hardware. - */ -#define DLT_LTALK 114 - -/* - * Acorn Econet. - */ -#define DLT_ECONET 115 - -/* - * Reserved for use with OpenBSD ipfilter. - */ -#define DLT_IPFILTER 116 - -/* - * OpenBSD DLT_PFLOG; DLT_PFLOG is 17 in OpenBSD, but that's DLT_LANE8023 - * in SuSE 6.3, so we can't use 17 for it in capture-file headers. - * - * XXX: is there a conflict with DLT_PFSYNC 18 as well? - */ -#ifdef __OpenBSD__ -#define DLT_OLD_PFLOG 17 -#define DLT_PFSYNC 18 -#endif -#define DLT_PFLOG 117 - -/* - * Registered for Cisco-internal use. - */ -#define DLT_CISCO_IOS 118 - -/* - * For 802.11 cards using the Prism II chips, with a link-layer - * header including Prism monitor mode information plus an 802.11 - * header. - */ -#define DLT_PRISM_HEADER 119 - -/* - * Reserved for Aironet 802.11 cards, with an Aironet link-layer header - * (see Doug Ambrisko's FreeBSD patches). - */ -#define DLT_AIRONET_HEADER 120 - -/* - * Reserved for Siemens HiPath HDLC. - */ -#define DLT_HHDLC 121 - -/* - * This is for RFC 2625 IP-over-Fibre Channel. - * - * This is not for use with raw Fibre Channel, where the link-layer - * header starts with a Fibre Channel frame header; it's for IP-over-FC, - * where the link-layer header starts with an RFC 2625 Network_Header - * field. - */ -#define DLT_IP_OVER_FC 122 - -/* - * This is for Full Frontal ATM on Solaris with SunATM, with a - * pseudo-header followed by an AALn PDU. - * - * There may be other forms of Full Frontal ATM on other OSes, - * with different pseudo-headers. - * - * If ATM software returns a pseudo-header with VPI/VCI information - * (and, ideally, packet type information, e.g. signalling, ILMI, - * LANE, LLC-multiplexed traffic, etc.), it should not use - * DLT_ATM_RFC1483, but should get a new DLT_ value, so tcpdump - * and the like don't have to infer the presence or absence of a - * pseudo-header and the form of the pseudo-header. - */ -#define DLT_SUNATM 123 /* Solaris+SunATM */ - -/* - * Reserved as per request from Kent Dahlgren - * for private use. - */ -#define DLT_RIO 124 /* RapidIO */ -#define DLT_PCI_EXP 125 /* PCI Express */ -#define DLT_AURORA 126 /* Xilinx Aurora link layer */ - -/* - * Header for 802.11 plus a number of bits of link-layer information - * including radio information, used by some recent BSD drivers as - * well as the madwifi Atheros driver for Linux. - */ -#define DLT_IEEE802_11_RADIO 127 /* 802.11 plus radiotap radio header */ - -/* - * Reserved for the TZSP encapsulation, as per request from - * Chris Waters - * TZSP is a generic encapsulation for any other link type, - * which includes a means to include meta-information - * with the packet, e.g. signal strength and channel - * for 802.11 packets. - */ -#define DLT_TZSP 128 /* Tazmen Sniffer Protocol */ - -/* - * BSD's ARCNET headers have the source host, destination host, - * and type at the beginning of the packet; that's what's handed - * up to userland via BPF. - * - * Linux's ARCNET headers, however, have a 2-byte offset field - * between the host IDs and the type; that's what's handed up - * to userland via PF_PACKET sockets. - * - * We therefore have to have separate DLT_ values for them. - */ -#define DLT_ARCNET_LINUX 129 /* ARCNET */ - -/* - * Juniper-private data link types, as per request from - * Hannes Gredler . The DLT_s are used - * for passing on chassis-internal metainformation such as - * QOS profiles, etc.. - */ -#define DLT_JUNIPER_MLPPP 130 -#define DLT_JUNIPER_MLFR 131 -#define DLT_JUNIPER_ES 132 -#define DLT_JUNIPER_GGSN 133 -#define DLT_JUNIPER_MFR 134 -#define DLT_JUNIPER_ATM2 135 -#define DLT_JUNIPER_SERVICES 136 -#define DLT_JUNIPER_ATM1 137 - -/* - * Apple IP-over-IEEE 1394, as per a request from Dieter Siegmund - * . The header that's presented is an Ethernet-like - * header: - * - * #define FIREWIRE_EUI64_LEN 8 - * struct firewire_header { - * u_char firewire_dhost[FIREWIRE_EUI64_LEN]; - * u_char firewire_shost[FIREWIRE_EUI64_LEN]; - * u_short firewire_type; - * }; - * - * with "firewire_type" being an Ethernet type value, rather than, - * for example, raw GASP frames being handed up. - */ -#define DLT_APPLE_IP_OVER_IEEE1394 138 - -/* - * Various SS7 encapsulations, as per a request from Jeff Morriss - * and subsequent discussions. - */ -#define DLT_MTP2_WITH_PHDR 139 /* pseudo-header with various info, followed by MTP2 */ -#define DLT_MTP2 140 /* MTP2, without pseudo-header */ -#define DLT_MTP3 141 /* MTP3, without pseudo-header or MTP2 */ -#define DLT_SCCP 142 /* SCCP, without pseudo-header or MTP2 or MTP3 */ - -/* - * DOCSIS MAC frames. - */ -#define DLT_DOCSIS 143 - -/* - * Linux-IrDA packets. Protocol defined at http://www.irda.org. - * Those packets include IrLAP headers and above (IrLMP...), but - * don't include Phy framing (SOF/EOF/CRC & byte stuffing), because Phy - * framing can be handled by the hardware and depend on the bitrate. - * This is exactly the format you would get capturing on a Linux-IrDA - * interface (irdaX), but not on a raw serial port. - * Note the capture is done in "Linux-cooked" mode, so each packet include - * a fake packet header (struct sll_header). This is because IrDA packet - * decoding is dependant on the direction of the packet (incomming or - * outgoing). - * When/if other platform implement IrDA capture, we may revisit the - * issue and define a real DLT_IRDA... - * Jean II - */ -#define DLT_LINUX_IRDA 144 - -/* - * Reserved for IBM SP switch and IBM Next Federation switch. - */ -#define DLT_IBM_SP 145 -#define DLT_IBM_SN 146 - -/* - * Reserved for private use. If you have some link-layer header type - * that you want to use within your organization, with the capture files - * using that link-layer header type not ever be sent outside your - * organization, you can use these values. - * - * No libpcap release will use these for any purpose, nor will any - * tcpdump release use them, either. - * - * Do *NOT* use these in capture files that you expect anybody not using - * your private versions of capture-file-reading tools to read; in - * particular, do *NOT* use them in products, otherwise you may find that - * people won't be able to use tcpdump, or snort, or Ethereal, or... to - * read capture files from your firewall/intrusion detection/traffic - * monitoring/etc. appliance, or whatever product uses that DLT_ value, - * and you may also find that the developers of those applications will - * not accept patches to let them read those files. - * - * Also, do not use them if somebody might send you a capture using them - * for *their* private type and tools using them for *your* private type - * would have to read them. - * - * Instead, ask "tcpdump-workers@tcpdump.org" for a new DLT_ value, - * as per the comment above, and use the type you're given. - */ -#define DLT_USER0 147 -#define DLT_USER1 148 -#define DLT_USER2 149 -#define DLT_USER3 150 -#define DLT_USER4 151 -#define DLT_USER5 152 -#define DLT_USER6 153 -#define DLT_USER7 154 -#define DLT_USER8 155 -#define DLT_USER9 156 -#define DLT_USER10 157 -#define DLT_USER11 158 -#define DLT_USER12 159 -#define DLT_USER13 160 -#define DLT_USER14 161 -#define DLT_USER15 162 - -/* - * For future use with 802.11 captures - defined by AbsoluteValue - * Systems to store a number of bits of link-layer information - * including radio information: - * - * http://www.shaftnet.org/~pizza/software/capturefrm.txt - * - * but it might be used by some non-AVS drivers now or in the - * future. - */ -#define DLT_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */ - -/* - * Juniper-private data link type, as per request from - * Hannes Gredler . The DLT_s are used - * for passing on chassis-internal metainformation such as - * QOS profiles, etc.. - */ -#define DLT_JUNIPER_MONITOR 164 - -/* - * Reserved for BACnet MS/TP. - */ -#define DLT_BACNET_MS_TP 165 - -/* - * Another PPP variant as per request from Karsten Keil . - * - * This is used in some OSes to allow a kernel socket filter to distinguish - * between incoming and outgoing packets, on a socket intended to - * supply pppd with outgoing packets so it can do dial-on-demand and - * hangup-on-lack-of-demand; incoming packets are filtered out so they - * don't cause pppd to hold the connection up (you don't want random - * input packets such as port scans, packets from old lost connections, - * etc. to force the connection to stay up). - * - * The first byte of the PPP header (0xff03) is modified to accomodate - * the direction - 0x00 = IN, 0x01 = OUT. - */ -#define DLT_PPP_PPPD 166 - -/* - * Names for backwards compatibility with older versions of some PPP - * software; new software should use DLT_PPP_PPPD. - */ -#define DLT_PPP_WITH_DIRECTION DLT_PPP_PPPD -#define DLT_LINUX_PPP_WITHDIRECTION DLT_PPP_PPPD - -/* - * Juniper-private data link type, as per request from - * Hannes Gredler . The DLT_s are used - * for passing on chassis-internal metainformation such as - * QOS profiles, cookies, etc.. - */ -#define DLT_JUNIPER_PPPOE 167 -#define DLT_JUNIPER_PPPOE_ATM 168 - -#define DLT_GPRS_LLC 169 /* GPRS LLC */ -#define DLT_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */ -#define DLT_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */ - -/* - * Requested by Oolan Zimmer for use in Gcom's T1/E1 line - * monitoring equipment. - */ -#define DLT_GCOM_T1E1 172 -#define DLT_GCOM_SERIAL 173 - -/* - * Juniper-private data link type, as per request from - * Hannes Gredler . The DLT_ is used - * for internal communication to Physical Interface Cards (PIC) - */ -#define DLT_JUNIPER_PIC_PEER 174 - -/* - * Link types requested by Gregor Maier of Endace - * Measurement Systems. They add an ERF header (see - * http://www.endace.com/support/EndaceRecordFormat.pdf) in front of - * the link-layer header. - */ -#define DLT_ERF_ETH 175 /* Ethernet */ -#define DLT_ERF_POS 176 /* Packet-over-SONET */ - -/* - * Requested by Daniele Orlandi for raw LAPD - * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header - * includes additional information before the LAPD header, so it's - * not necessarily a generic LAPD header. - */ -#define DLT_LINUX_LAPD 177 - -/* - * Juniper-private data link type, as per request from - * Hannes Gredler . - * The DLT_ are used for prepending meta-information - * like interface index, interface name - * before standard Ethernet, PPP, Frelay & C-HDLC Frames - */ -#define DLT_JUNIPER_ETHER 178 -#define DLT_JUNIPER_PPP 179 -#define DLT_JUNIPER_FRELAY 180 -#define DLT_JUNIPER_CHDLC 181 - -/* - * Multi Link Frame Relay (FRF.16) - */ -#define DLT_MFR 182 - -/* - * Juniper-private data link type, as per request from - * Hannes Gredler . - * The DLT_ is used for internal communication with a - * voice Adapter Card (PIC) - */ -#define DLT_JUNIPER_VP 183 - -/* - * Arinc 429 frames. - * DLT_ requested by Gianluca Varenni . - * Every frame contains a 32bit A429 label. - * More documentation on Arinc 429 can be found at - * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf - */ -#define DLT_A429 184 - -/* - * Arinc 653 Interpartition Communication messages. - * DLT_ requested by Gianluca Varenni . - * Please refer to the A653-1 standard for more information. - */ -#define DLT_A653_ICM 185 - -/* - * Controller Area Network (CAN) v. 2.0B packets. - * DLT_ requested by Gianluca Varenni . - * Used to dump CAN packets coming from a CAN Vector board. - * More documentation on the CAN v2.0B frames can be found at - * http://www.can-cia.org/downloads/?269 - */ -#define DLT_CAN20B 190 - - -/* - * The instruction encodings. - */ -/* instruction classes */ -#define BPF_CLASS(code) ((code) & 0x07) -#define BPF_LD 0x00 -#define BPF_LDX 0x01 -#define BPF_ST 0x02 -#define BPF_STX 0x03 -#define BPF_ALU 0x04 -#define BPF_JMP 0x05 -#define BPF_RET 0x06 -#define BPF_MISC 0x07 - -/* ld/ldx fields */ -#define BPF_SIZE(code) ((code) & 0x18) -#define BPF_W 0x00 -#define BPF_H 0x08 -#define BPF_B 0x10 -#define BPF_MODE(code) ((code) & 0xe0) -#define BPF_IMM 0x00 -#define BPF_ABS 0x20 -#define BPF_IND 0x40 -#define BPF_MEM 0x60 -#define BPF_LEN 0x80 -#define BPF_MSH 0xa0 - -/* alu/jmp fields */ -#define BPF_OP(code) ((code) & 0xf0) -#define BPF_ADD 0x00 -#define BPF_SUB 0x10 -#define BPF_MUL 0x20 -#define BPF_DIV 0x30 -#define BPF_OR 0x40 -#define BPF_AND 0x50 -#define BPF_LSH 0x60 -#define BPF_RSH 0x70 -#define BPF_NEG 0x80 -#define BPF_JA 0x00 -#define BPF_JEQ 0x10 -#define BPF_JGT 0x20 -#define BPF_JGE 0x30 -#define BPF_JSET 0x40 -#define BPF_SRC(code) ((code) & 0x08) -#define BPF_K 0x00 -#define BPF_X 0x08 - -/* ret - BPF_K and BPF_X also apply */ -#define BPF_RVAL(code) ((code) & 0x18) -#define BPF_A 0x10 - -/* misc */ -#define BPF_MISCOP(code) ((code) & 0xf8) -#define BPF_TAX 0x00 -#define BPF_TXA 0x80 - -/* - * The instruction data structure. - */ -struct bpf_insn { - u_short code; - u_char jt; - u_char jf; - bpf_int32 k; -}; - -/* - * Macros for insn array initializers. - */ -#define BPF_STMT(code, k) { (u_short)(code), 0, 0, k } -#define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k } - -#if __STDC__ || defined(__cplusplus) -extern int bpf_validate(struct bpf_insn *, int); -extern u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int); -#else -extern int bpf_validate(); -extern u_int bpf_filter(); -#endif - -/* - * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST). - */ -#define BPF_MEMWORDS 16 - -#ifdef __cplusplus -} -#endif - -#endif +/*- + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)bpf.h 7.1 (Berkeley) 5/7/91 + * + * @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.34.2.11 2006/07/27 21:06:17 gianluca Exp $ (LBL) + */ + +/* + * This is libpcap's cut-down version of bpf.h; it includes only + * the stuff needed for the code generator and the userland BPF + * interpreter, and the libpcap APIs for setting filters, etc.. + * + * "pcap-bpf.c" will include the native OS version, as it deals with + * the OS's BPF implementation. + * + * XXX - should this all just be moved to "pcap.h"? + */ + +#ifndef BPF_MAJOR_VERSION + +#ifdef __cplusplus +extern "C" { +#endif + +/* BSD style release date */ +#define BPF_RELEASE 199606 + +#ifdef MSDOS /* must be 32-bit */ +typedef long bpf_int32; +typedef unsigned long bpf_u_int32; +#else +typedef int bpf_int32; +typedef u_int bpf_u_int32; +#endif + +/* + * Alignment macros. BPF_WORDALIGN rounds up to the next + * even multiple of BPF_ALIGNMENT. + */ +#ifndef __NetBSD__ +#define BPF_ALIGNMENT sizeof(bpf_int32) +#else +#define BPF_ALIGNMENT sizeof(long) +#endif +#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1)) + +#define BPF_MAXINSNS 512 +#define BPF_MAXBUFSIZE 0x8000 +#define BPF_MINBUFSIZE 32 + +/* + * Structure for "pcap_compile()", "pcap_setfilter()", etc.. + */ +struct bpf_program { + u_int bf_len; + struct bpf_insn *bf_insns; +}; + +/* + * Struct return by BIOCVERSION. This represents the version number of + * the filter language described by the instruction encodings below. + * bpf understands a program iff kernel_major == filter_major && + * kernel_minor >= filter_minor, that is, if the value returned by the + * running kernel has the same major number and a minor number equal + * equal to or less than the filter being downloaded. Otherwise, the + * results are undefined, meaning an error may be returned or packets + * may be accepted haphazardly. + * It has nothing to do with the source code version. + */ +struct bpf_version { + u_short bv_major; + u_short bv_minor; +}; +/* Current version number of filter architecture. */ +#define BPF_MAJOR_VERSION 1 +#define BPF_MINOR_VERSION 1 + +/* + * Data-link level type codes. + * + * Do *NOT* add new values to this list without asking + * "tcpdump-workers@tcpdump.org" for a value. Otherwise, you run the + * risk of using a value that's already being used for some other purpose, + * and of having tools that read libpcap-format captures not being able + * to handle captures with your new DLT_ value, with no hope that they + * will ever be changed to do so (as that would destroy their ability + * to read captures using that value for that other purpose). + */ + +/* + * These are the types that are the same on all platforms, and that + * have been defined by for ages. + */ +#define DLT_NULL 0 /* BSD loopback encapsulation */ +#define DLT_EN10MB 1 /* Ethernet (10Mb) */ +#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */ +#define DLT_AX25 3 /* Amateur Radio AX.25 */ +#define DLT_PRONET 4 /* Proteon ProNET Token Ring */ +#define DLT_CHAOS 5 /* Chaos */ +#define DLT_IEEE802 6 /* IEEE 802 Networks */ +#define DLT_ARCNET 7 /* ARCNET, with BSD-style header */ +#define DLT_SLIP 8 /* Serial Line IP */ +#define DLT_PPP 9 /* Point-to-point Protocol */ +#define DLT_FDDI 10 /* FDDI */ + +/* + * These are types that are different on some platforms, and that + * have been defined by for ages. We use #ifdefs to + * detect the BSDs that define them differently from the traditional + * libpcap + * + * XXX - DLT_ATM_RFC1483 is 13 in BSD/OS, and DLT_RAW is 14 in BSD/OS, + * but I don't know what the right #define is for BSD/OS. + */ +#define DLT_ATM_RFC1483 11 /* LLC-encapsulated ATM */ + +#ifdef __OpenBSD__ +#define DLT_RAW 14 /* raw IP */ +#else +#define DLT_RAW 12 /* raw IP */ +#endif + +/* + * Given that the only OS that currently generates BSD/OS SLIP or PPP + * is, well, BSD/OS, arguably everybody should have chosen its values + * for DLT_SLIP_BSDOS and DLT_PPP_BSDOS, which are 15 and 16, but they + * didn't. So it goes. + */ +#if defined(__NetBSD__) || defined(__FreeBSD__) +#ifndef DLT_SLIP_BSDOS +#define DLT_SLIP_BSDOS 13 /* BSD/OS Serial Line IP */ +#define DLT_PPP_BSDOS 14 /* BSD/OS Point-to-point Protocol */ +#endif +#else +#define DLT_SLIP_BSDOS 15 /* BSD/OS Serial Line IP */ +#define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */ +#endif + +/* + * 17 is used for DLT_OLD_PFLOG in OpenBSD; + * OBSOLETE: DLT_PFLOG is 117 in OpenBSD now as well. See below. + * 18 is used for DLT_PFSYNC in OpenBSD; don't use it for anything else. + */ + +#define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */ + +/* + * Apparently Redback uses this for its SmartEdge 400/800. I hope + * nobody else decided to use it, too. + */ +#define DLT_REDBACK_SMARTEDGE 32 + +/* + * These values are defined by NetBSD; other platforms should refrain from + * using them for other purposes, so that NetBSD savefiles with link + * types of 50 or 51 can be read as this type on all platforms. + */ +#define DLT_PPP_SERIAL 50 /* PPP over serial with HDLC encapsulation */ +#define DLT_PPP_ETHER 51 /* PPP over Ethernet */ + +/* + * The Axent Raptor firewall - now the Symantec Enterprise Firewall - uses + * a link-layer type of 99 for the tcpdump it supplies. The link-layer + * header has 6 bytes of unknown data, something that appears to be an + * Ethernet type, and 36 bytes that appear to be 0 in at least one capture + * I've seen. + */ +#define DLT_SYMANTEC_FIREWALL 99 + +/* + * Values between 100 and 103 are used in capture file headers as + * link-layer types corresponding to DLT_ types that differ + * between platforms; don't use those values for new DLT_ new types. + */ + +/* + * This value was defined by libpcap 0.5; platforms that have defined + * it with a different value should define it here with that value - + * a link type of 104 in a save file will be mapped to DLT_C_HDLC, + * whatever value that happens to be, so programs will correctly + * handle files with that link type regardless of the value of + * DLT_C_HDLC. + * + * The name DLT_C_HDLC was used by BSD/OS; we use that name for source + * compatibility with programs written for BSD/OS. + * + * libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well, + * for source compatibility with programs written for libpcap 0.5. + */ +#define DLT_C_HDLC 104 /* Cisco HDLC */ +#define DLT_CHDLC DLT_C_HDLC + +#define DLT_IEEE802_11 105 /* IEEE 802.11 wireless */ + +/* + * 106 is reserved for Linux Classical IP over ATM; it's like DLT_RAW, + * except when it isn't. (I.e., sometimes it's just raw IP, and + * sometimes it isn't.) We currently handle it as DLT_LINUX_SLL, + * so that we don't have to worry about the link-layer header.) + */ + +/* + * Frame Relay; BSD/OS has a DLT_FR with a value of 11, but that collides + * with other values. + * DLT_FR and DLT_FRELAY packets start with the Q.922 Frame Relay header + * (DLCI, etc.). + */ +#define DLT_FRELAY 107 + +/* + * OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except + * that the AF_ type in the link-layer header is in network byte order. + * + * OpenBSD defines it as 12, but that collides with DLT_RAW, so we + * define it as 108 here. If OpenBSD picks up this file, it should + * define DLT_LOOP as 12 in its version, as per the comment above - + * and should not use 108 as a DLT_ value. + */ +#define DLT_LOOP 108 + +/* + * Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's + * DLT_SLIP_BSDOS in NetBSD, so we don't use 13 for it in OSes other + * than OpenBSD. + */ +#ifdef __OpenBSD__ +#define DLT_ENC 13 +#else +#define DLT_ENC 109 +#endif + +/* + * Values between 110 and 112 are reserved for use in capture file headers + * as link-layer types corresponding to DLT_ types that might differ + * between platforms; don't use those values for new DLT_ types + * other than the corresponding DLT_ types. + */ + +/* + * This is for Linux cooked sockets. + */ +#define DLT_LINUX_SLL 113 + +/* + * Apple LocalTalk hardware. + */ +#define DLT_LTALK 114 + +/* + * Acorn Econet. + */ +#define DLT_ECONET 115 + +/* + * Reserved for use with OpenBSD ipfilter. + */ +#define DLT_IPFILTER 116 + +/* + * OpenBSD DLT_PFLOG; DLT_PFLOG is 17 in OpenBSD, but that's DLT_LANE8023 + * in SuSE 6.3, so we can't use 17 for it in capture-file headers. + * + * XXX: is there a conflict with DLT_PFSYNC 18 as well? + */ +#ifdef __OpenBSD__ +#define DLT_OLD_PFLOG 17 +#define DLT_PFSYNC 18 +#endif +#define DLT_PFLOG 117 + +/* + * Registered for Cisco-internal use. + */ +#define DLT_CISCO_IOS 118 + +/* + * For 802.11 cards using the Prism II chips, with a link-layer + * header including Prism monitor mode information plus an 802.11 + * header. + */ +#define DLT_PRISM_HEADER 119 + +/* + * Reserved for Aironet 802.11 cards, with an Aironet link-layer header + * (see Doug Ambrisko's FreeBSD patches). + */ +#define DLT_AIRONET_HEADER 120 + +/* + * Reserved for Siemens HiPath HDLC. + */ +#define DLT_HHDLC 121 + +/* + * This is for RFC 2625 IP-over-Fibre Channel. + * + * This is not for use with raw Fibre Channel, where the link-layer + * header starts with a Fibre Channel frame header; it's for IP-over-FC, + * where the link-layer header starts with an RFC 2625 Network_Header + * field. + */ +#define DLT_IP_OVER_FC 122 + +/* + * This is for Full Frontal ATM on Solaris with SunATM, with a + * pseudo-header followed by an AALn PDU. + * + * There may be other forms of Full Frontal ATM on other OSes, + * with different pseudo-headers. + * + * If ATM software returns a pseudo-header with VPI/VCI information + * (and, ideally, packet type information, e.g. signalling, ILMI, + * LANE, LLC-multiplexed traffic, etc.), it should not use + * DLT_ATM_RFC1483, but should get a new DLT_ value, so tcpdump + * and the like don't have to infer the presence or absence of a + * pseudo-header and the form of the pseudo-header. + */ +#define DLT_SUNATM 123 /* Solaris+SunATM */ + +/* + * Reserved as per request from Kent Dahlgren + * for private use. + */ +#define DLT_RIO 124 /* RapidIO */ +#define DLT_PCI_EXP 125 /* PCI Express */ +#define DLT_AURORA 126 /* Xilinx Aurora link layer */ + +/* + * Header for 802.11 plus a number of bits of link-layer information + * including radio information, used by some recent BSD drivers as + * well as the madwifi Atheros driver for Linux. + */ +#define DLT_IEEE802_11_RADIO 127 /* 802.11 plus radiotap radio header */ + +/* + * Reserved for the TZSP encapsulation, as per request from + * Chris Waters + * TZSP is a generic encapsulation for any other link type, + * which includes a means to include meta-information + * with the packet, e.g. signal strength and channel + * for 802.11 packets. + */ +#define DLT_TZSP 128 /* Tazmen Sniffer Protocol */ + +/* + * BSD's ARCNET headers have the source host, destination host, + * and type at the beginning of the packet; that's what's handed + * up to userland via BPF. + * + * Linux's ARCNET headers, however, have a 2-byte offset field + * between the host IDs and the type; that's what's handed up + * to userland via PF_PACKET sockets. + * + * We therefore have to have separate DLT_ values for them. + */ +#define DLT_ARCNET_LINUX 129 /* ARCNET */ + +/* + * Juniper-private data link types, as per request from + * Hannes Gredler . The DLT_s are used + * for passing on chassis-internal metainformation such as + * QOS profiles, etc.. + */ +#define DLT_JUNIPER_MLPPP 130 +#define DLT_JUNIPER_MLFR 131 +#define DLT_JUNIPER_ES 132 +#define DLT_JUNIPER_GGSN 133 +#define DLT_JUNIPER_MFR 134 +#define DLT_JUNIPER_ATM2 135 +#define DLT_JUNIPER_SERVICES 136 +#define DLT_JUNIPER_ATM1 137 + +/* + * Apple IP-over-IEEE 1394, as per a request from Dieter Siegmund + * . The header that's presented is an Ethernet-like + * header: + * + * #define FIREWIRE_EUI64_LEN 8 + * struct firewire_header { + * u_char firewire_dhost[FIREWIRE_EUI64_LEN]; + * u_char firewire_shost[FIREWIRE_EUI64_LEN]; + * u_short firewire_type; + * }; + * + * with "firewire_type" being an Ethernet type value, rather than, + * for example, raw GASP frames being handed up. + */ +#define DLT_APPLE_IP_OVER_IEEE1394 138 + +/* + * Various SS7 encapsulations, as per a request from Jeff Morriss + * and subsequent discussions. + */ +#define DLT_MTP2_WITH_PHDR 139 /* pseudo-header with various info, followed by MTP2 */ +#define DLT_MTP2 140 /* MTP2, without pseudo-header */ +#define DLT_MTP3 141 /* MTP3, without pseudo-header or MTP2 */ +#define DLT_SCCP 142 /* SCCP, without pseudo-header or MTP2 or MTP3 */ + +/* + * DOCSIS MAC frames. + */ +#define DLT_DOCSIS 143 + +/* + * Linux-IrDA packets. Protocol defined at http://www.irda.org. + * Those packets include IrLAP headers and above (IrLMP...), but + * don't include Phy framing (SOF/EOF/CRC & byte stuffing), because Phy + * framing can be handled by the hardware and depend on the bitrate. + * This is exactly the format you would get capturing on a Linux-IrDA + * interface (irdaX), but not on a raw serial port. + * Note the capture is done in "Linux-cooked" mode, so each packet include + * a fake packet header (struct sll_header). This is because IrDA packet + * decoding is dependant on the direction of the packet (incomming or + * outgoing). + * When/if other platform implement IrDA capture, we may revisit the + * issue and define a real DLT_IRDA... + * Jean II + */ +#define DLT_LINUX_IRDA 144 + +/* + * Reserved for IBM SP switch and IBM Next Federation switch. + */ +#define DLT_IBM_SP 145 +#define DLT_IBM_SN 146 + +/* + * Reserved for private use. If you have some link-layer header type + * that you want to use within your organization, with the capture files + * using that link-layer header type not ever be sent outside your + * organization, you can use these values. + * + * No libpcap release will use these for any purpose, nor will any + * tcpdump release use them, either. + * + * Do *NOT* use these in capture files that you expect anybody not using + * your private versions of capture-file-reading tools to read; in + * particular, do *NOT* use them in products, otherwise you may find that + * people won't be able to use tcpdump, or snort, or Ethereal, or... to + * read capture files from your firewall/intrusion detection/traffic + * monitoring/etc. appliance, or whatever product uses that DLT_ value, + * and you may also find that the developers of those applications will + * not accept patches to let them read those files. + * + * Also, do not use them if somebody might send you a capture using them + * for *their* private type and tools using them for *your* private type + * would have to read them. + * + * Instead, ask "tcpdump-workers@tcpdump.org" for a new DLT_ value, + * as per the comment above, and use the type you're given. + */ +#define DLT_USER0 147 +#define DLT_USER1 148 +#define DLT_USER2 149 +#define DLT_USER3 150 +#define DLT_USER4 151 +#define DLT_USER5 152 +#define DLT_USER6 153 +#define DLT_USER7 154 +#define DLT_USER8 155 +#define DLT_USER9 156 +#define DLT_USER10 157 +#define DLT_USER11 158 +#define DLT_USER12 159 +#define DLT_USER13 160 +#define DLT_USER14 161 +#define DLT_USER15 162 + +/* + * For future use with 802.11 captures - defined by AbsoluteValue + * Systems to store a number of bits of link-layer information + * including radio information: + * + * http://www.shaftnet.org/~pizza/software/capturefrm.txt + * + * but it might be used by some non-AVS drivers now or in the + * future. + */ +#define DLT_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */ + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . The DLT_s are used + * for passing on chassis-internal metainformation such as + * QOS profiles, etc.. + */ +#define DLT_JUNIPER_MONITOR 164 + +/* + * Reserved for BACnet MS/TP. + */ +#define DLT_BACNET_MS_TP 165 + +/* + * Another PPP variant as per request from Karsten Keil . + * + * This is used in some OSes to allow a kernel socket filter to distinguish + * between incoming and outgoing packets, on a socket intended to + * supply pppd with outgoing packets so it can do dial-on-demand and + * hangup-on-lack-of-demand; incoming packets are filtered out so they + * don't cause pppd to hold the connection up (you don't want random + * input packets such as port scans, packets from old lost connections, + * etc. to force the connection to stay up). + * + * The first byte of the PPP header (0xff03) is modified to accomodate + * the direction - 0x00 = IN, 0x01 = OUT. + */ +#define DLT_PPP_PPPD 166 + +/* + * Names for backwards compatibility with older versions of some PPP + * software; new software should use DLT_PPP_PPPD. + */ +#define DLT_PPP_WITH_DIRECTION DLT_PPP_PPPD +#define DLT_LINUX_PPP_WITHDIRECTION DLT_PPP_PPPD + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . The DLT_s are used + * for passing on chassis-internal metainformation such as + * QOS profiles, cookies, etc.. + */ +#define DLT_JUNIPER_PPPOE 167 +#define DLT_JUNIPER_PPPOE_ATM 168 + +#define DLT_GPRS_LLC 169 /* GPRS LLC */ +#define DLT_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */ +#define DLT_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */ + +/* + * Requested by Oolan Zimmer for use in Gcom's T1/E1 line + * monitoring equipment. + */ +#define DLT_GCOM_T1E1 172 +#define DLT_GCOM_SERIAL 173 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . The DLT_ is used + * for internal communication to Physical Interface Cards (PIC) + */ +#define DLT_JUNIPER_PIC_PEER 174 + +/* + * Link types requested by Gregor Maier of Endace + * Measurement Systems. They add an ERF header (see + * http://www.endace.com/support/EndaceRecordFormat.pdf) in front of + * the link-layer header. + */ +#define DLT_ERF_ETH 175 /* Ethernet */ +#define DLT_ERF_POS 176 /* Packet-over-SONET */ + +/* + * Requested by Daniele Orlandi for raw LAPD + * for vISDN (http://www.orlandi.com/visdn/). Its link-layer header + * includes additional information before the LAPD header, so it's + * not necessarily a generic LAPD header. + */ +#define DLT_LINUX_LAPD 177 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ are used for prepending meta-information + * like interface index, interface name + * before standard Ethernet, PPP, Frelay & C-HDLC Frames + */ +#define DLT_JUNIPER_ETHER 178 +#define DLT_JUNIPER_PPP 179 +#define DLT_JUNIPER_FRELAY 180 +#define DLT_JUNIPER_CHDLC 181 + +/* + * Multi Link Frame Relay (FRF.16) + */ +#define DLT_MFR 182 + +/* + * Juniper-private data link type, as per request from + * Hannes Gredler . + * The DLT_ is used for internal communication with a + * voice Adapter Card (PIC) + */ +#define DLT_JUNIPER_VP 183 + +/* + * Arinc 429 frames. + * DLT_ requested by Gianluca Varenni . + * Every frame contains a 32bit A429 label. + * More documentation on Arinc 429 can be found at + * http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf + */ +#define DLT_A429 184 + +/* + * Arinc 653 Interpartition Communication messages. + * DLT_ requested by Gianluca Varenni . + * Please refer to the A653-1 standard for more information. + */ +#define DLT_A653_ICM 185 + +/* + * Controller Area Network (CAN) v. 2.0B packets. + * DLT_ requested by Gianluca Varenni . + * Used to dump CAN packets coming from a CAN Vector board. + * More documentation on the CAN v2.0B frames can be found at + * http://www.can-cia.org/downloads/?269 + */ +#define DLT_CAN20B 190 + + +/* + * The instruction encodings. + */ +/* instruction classes */ +#define BPF_CLASS(code) ((code) & 0x07) +#define BPF_LD 0x00 +#define BPF_LDX 0x01 +#define BPF_ST 0x02 +#define BPF_STX 0x03 +#define BPF_ALU 0x04 +#define BPF_JMP 0x05 +#define BPF_RET 0x06 +#define BPF_MISC 0x07 + +/* ld/ldx fields */ +#define BPF_SIZE(code) ((code) & 0x18) +#define BPF_W 0x00 +#define BPF_H 0x08 +#define BPF_B 0x10 +#define BPF_MODE(code) ((code) & 0xe0) +#define BPF_IMM 0x00 +#define BPF_ABS 0x20 +#define BPF_IND 0x40 +#define BPF_MEM 0x60 +#define BPF_LEN 0x80 +#define BPF_MSH 0xa0 + +/* alu/jmp fields */ +#define BPF_OP(code) ((code) & 0xf0) +#define BPF_ADD 0x00 +#define BPF_SUB 0x10 +#define BPF_MUL 0x20 +#define BPF_DIV 0x30 +#define BPF_OR 0x40 +#define BPF_AND 0x50 +#define BPF_LSH 0x60 +#define BPF_RSH 0x70 +#define BPF_NEG 0x80 +#define BPF_JA 0x00 +#define BPF_JEQ 0x10 +#define BPF_JGT 0x20 +#define BPF_JGE 0x30 +#define BPF_JSET 0x40 +#define BPF_SRC(code) ((code) & 0x08) +#define BPF_K 0x00 +#define BPF_X 0x08 + +/* ret - BPF_K and BPF_X also apply */ +#define BPF_RVAL(code) ((code) & 0x18) +#define BPF_A 0x10 + +/* misc */ +#define BPF_MISCOP(code) ((code) & 0xf8) +#define BPF_TAX 0x00 +#define BPF_TXA 0x80 + +/* + * The instruction data structure. + */ +struct bpf_insn { + u_short code; + u_char jt; + u_char jf; + bpf_int32 k; +}; + +/* + * Macros for insn array initializers. + */ +#define BPF_STMT(code, k) { (u_short)(code), 0, 0, k } +#define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k } + +#if __STDC__ || defined(__cplusplus) +extern int bpf_validate(struct bpf_insn *, int); +extern u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int); +#else +extern int bpf_validate(); +extern u_int bpf_filter(); +#endif + +/* + * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST). + */ +#define BPF_MEMWORDS 16 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/desmume/src/windows/winpcap/pcap-int.h b/src/windows/winpcap/pcap-int.h similarity index 97% rename from desmume/src/windows/winpcap/pcap-int.h rename to src/windows/winpcap/pcap-int.h index 7aefa191f..784797046 100644 --- a/desmume/src/windows/winpcap/pcap-int.h +++ b/src/windows/winpcap/pcap-int.h @@ -1,373 +1,373 @@ -/* - * Copyright (c) 1994, 1995, 1996 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Computer Systems - * Engineering Group at Lawrence Berkeley Laboratory. - * 4. Neither the name of the University nor of the Laboratory may be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.68.2.9 2006/02/22 17:09:54 gianluca Exp $ (LBL) - */ - -#ifndef pcap_int_h -#define pcap_int_h - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#ifdef WIN32 -#include -#endif /* WIN32 */ - -#ifdef MSDOS -#include -#include -#endif - -/* - * Savefile - */ -typedef enum { - NOT_SWAPPED, - SWAPPED, - MAYBE_SWAPPED -} swapped_type_t; - -struct pcap_sf { - FILE *rfile; - int swapped; - int hdrsize; - swapped_type_t lengths_swapped; - int version_major; - int version_minor; - u_char *base; -}; - -struct pcap_md { - struct pcap_stat stat; - /*XXX*/ - int use_bpf; /* using kernel filter */ - u_long TotPkts; /* can't oflow for 79 hrs on ether */ - u_long TotAccepted; /* count accepted by filter */ - u_long TotDrops; /* count of dropped packets */ - long TotMissed; /* missed by i/f during this run */ - long OrigMissed; /* missed by i/f before this run */ - char *device; /* device name */ -#ifdef linux - int sock_packet; /* using Linux 2.0 compatible interface */ - int timeout; /* timeout specified to pcap_open_live */ - int clear_promisc; /* must clear promiscuous mode when we close */ - int cooked; /* using SOCK_DGRAM rather than SOCK_RAW */ - int ifindex; /* interface index of device we're bound to */ - int lo_ifindex; /* interface index of the loopback device */ - struct pcap *next; /* list of open promiscuous sock_packet pcaps */ - u_int packets_read; /* count of packets read with recvfrom() */ -#endif - -#ifdef HAVE_DAG_API -#ifdef HAVE_DAG_STREAMS_API - u_char *dag_mem_bottom; /* DAG card current memory bottom pointer */ - u_char *dag_mem_top; /* DAG card current memory top pointer */ -#else - void *dag_mem_base; /* DAG card memory base address */ - u_int dag_mem_bottom; /* DAG card current memory bottom offset */ - u_int dag_mem_top; /* DAG card current memory top offset */ -#endif /* HAVE_DAG_STREAMS_API */ - int dag_fcs_bits; /* Number of checksum bits from link layer */ - int dag_offset_flags; /* Flags to pass to dag_offset(). */ - int dag_stream; /* DAG stream number */ - int dag_timeout; /* timeout specified to pcap_open_live. - * Same as in linux above, introduce - * generally? */ -#endif /* HAVE_DAG_API */ - -#ifdef HAVE_REMOTE -/*! - There is really a mess with previous variables, and it seems to me that they are not used - (they are used in pcap_pf.c only). I think we have to start using them. - The meaning is the following: - - - TotPkts: the amount of packets received by the bpf filter, *before* applying the filter - - TotAccepted: the amount of packets that satisfies the filter - - TotDrops: the amount of packet that were dropped into the kernel buffer because of lack of space - - TotMissed: the amount of packets that were dropped by the physical interface; it is basically - the value of the hardware counter into the card. This number is never put to zero, so this number - takes into account the *total* number of interface drops starting from the interface power-on. - - OrigMissed: the amount of packets that were dropped by the interface *when the capture begins*. - This value is used to detect the number of packets dropped by the interface *during the present - capture*, so that (ps_ifdrops= TotMissed - OrigMissed). -*/ - unsigned int TotNetDrops; //!< keeps the number of packets that have been dropped by the network -/*! - \brief It keeps the number of packets that have been received by the application. - - Packets dropped by the kernel buffer are not counted in this variable. The variable is always - equal to (TotAccepted - TotDrops), exept for the case of remote capture, in which we have also - packets in fligh, i.e. that have been transmitted by the remote host, but that have not been - received (yet) from the client. In this case, (TotAccepted - TotDrops - TotNetDrops) gives a - wrong result, since this number does not corresponds always to the number of packet received by - the application. For this reason, in the remote capture we need another variable that takes - into account of the number of packets actually received by the application. -*/ - unsigned int TotCapt; -#endif /* HAVE_REMOTE */ -}; - -/* - * Ultrix, DEC OSF/1^H^H^H^H^H^H^H^H^HDigital UNIX^H^H^H^H^H^H^H^H^H^H^H^H - * Tru64 UNIX, and NetBSD pad to make everything line up on a nice boundary. - */ -#if defined(ultrix) || defined(__osf__) || (defined(__NetBSD__) && __NetBSD_Version__ > 106000000) -#define PCAP_FDDIPAD 3 -#endif - -struct pcap { -#ifdef WIN32 - ADAPTER *adapter; - LPPACKET Packet; - int timeout; - int nonblock; -#else - int fd; - int selectable_fd; - int send_fd; -#endif /* WIN32 */ - int snapshot; - int linktype; - int tzoff; /* timezone offset */ - int offset; /* offset for proper alignment */ - - int break_loop; /* flag set to force break from packet-reading loop */ - -#ifdef PCAP_FDDIPAD - int fddipad; -#endif - -#ifdef MSDOS - int inter_packet_wait; /* offline: wait between packets */ - void (*wait_proc)(void); /* call proc while waiting */ -#endif - - struct pcap_sf sf; - struct pcap_md md; - - /* - * Read buffer. - */ - int bufsize; - u_char *buffer; - u_char *bp; - int cc; - - /* - * Place holder for pcap_next(). - */ - u_char *pkt; - - /* We're accepting only packets in this direction/these directions. */ - pcap_direction_t direction; - - /* - * Methods. - */ - int (*read_op)(pcap_t *, int cnt, pcap_handler, u_char *); - int (*inject_op)(pcap_t *, const void *, size_t); - int (*setfilter_op)(pcap_t *, struct bpf_program *); - int (*setdirection_op)(pcap_t *, pcap_direction_t); - int (*set_datalink_op)(pcap_t *, int); - int (*getnonblock_op)(pcap_t *, char *); - int (*setnonblock_op)(pcap_t *, int, char *); - int (*stats_op)(pcap_t *, struct pcap_stat *); - void (*close_op)(pcap_t *); - - /* - * Placeholder for filter code if bpf not in kernel. - */ - struct bpf_program fcode; - - char errbuf[PCAP_ERRBUF_SIZE + 1]; - int dlt_count; - u_int *dlt_list; - - struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */ - -#ifdef HAVE_REMOTE -#ifndef WIN32 // Win32 already defines 'timeout' - int timeout; //!< timeout to be used in the pcap_open() -#endif - /*! \brief '1' if we're the network client; needed by several functions (like pcap_setfilter() ) to know if - they have to use the socket or they have to open the local adapter. */ - int rmt_clientside; - - SOCKET rmt_sockctrl; //!< socket ID of the socket used for the control connection - SOCKET rmt_sockdata; //!< socket ID of the socket used for the data connection - int rmt_flags; //!< we have to save flags, since they are passed by the pcap_open_live(), but they are used by the pcap_startcapture() - int rmt_capstarted; //!< 'true' if the capture is already started (needed to knoe if we have to call the pcap_startcapture() - struct pcap_samp rmt_samp; //!< Keeps the parameters related to the sampling process. - char *currentfilter; //!< Pointer to a buffer (allocated at run-time) that stores the current filter. Needed when flag PCAP_OPENFLAG_NOCAPTURE_RPCAP is turned on. -#endif /* HAVE_REMOTE */ -}; - -/* - * This is a timeval as stored in a savefile. - * It has to use the same types everywhere, independent of the actual - * `struct timeval'; `struct timeval' has 32-bit tv_sec values on some - * platforms and 64-bit tv_sec values on other platforms, and writing - * out native `struct timeval' values would mean files could only be - * read on systems with the same tv_sec size as the system on which - * the file was written. - */ - -struct pcap_timeval { - bpf_int32 tv_sec; /* seconds */ - bpf_int32 tv_usec; /* microseconds */ -}; - -/* - * This is a `pcap_pkthdr' as actually stored in a savefile. - * - * Do not change the format of this structure, in any way (this includes - * changes that only affect the length of fields in this structure), - * and do not make the time stamp anything other than seconds and - * microseconds (e.g., seconds and nanoseconds). Instead: - * - * introduce a new structure for the new format; - * - * send mail to "tcpdump-workers@tcpdump.org", requesting a new - * magic number for your new capture file format, and, when - * you get the new magic number, put it in "savefile.c"; - * - * use that magic number for save files with the changed record - * header; - * - * make the code in "savefile.c" capable of reading files with - * the old record header as well as files with the new record header - * (using the magic number to determine the header format). - * - * Then supply the changes to "patches@tcpdump.org", so that future - * versions of libpcap and programs that use it (such as tcpdump) will - * be able to read your new capture file format. - */ - -struct pcap_sf_pkthdr { - struct pcap_timeval ts; /* time stamp */ - bpf_u_int32 caplen; /* length of portion present */ - bpf_u_int32 len; /* length this packet (off wire) */ -}; - -/* - * How a `pcap_pkthdr' is actually stored in savefiles written - * by some patched versions of libpcap (e.g. the ones in Red - * Hat Linux 6.1 and 6.2). - * - * Do not change the format of this structure, in any way (this includes - * changes that only affect the length of fields in this structure). - * Instead, introduce a new structure, as per the above. - */ - -struct pcap_sf_patched_pkthdr { - struct pcap_timeval ts; /* time stamp */ - bpf_u_int32 caplen; /* length of portion present */ - bpf_u_int32 len; /* length this packet (off wire) */ - int index; - unsigned short protocol; - unsigned char pkt_type; -}; - -int yylex(void); - -#ifndef min -#define min(a, b) ((a) > (b) ? (b) : (a)) -#endif - -/* XXX should these be in pcap.h? */ -int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *); -int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *); - -#ifndef HAVE_STRLCPY -#define strlcpy(x, y, z) \ - (strncpy((x), (y), (z)), \ - ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \ - strlen((y))) -#endif - -#include - -#if !defined(HAVE_SNPRINTF) -#define snprintf pcap_snprintf -extern int snprintf (char *, size_t, const char *, ...); -#endif - -#if !defined(HAVE_VSNPRINTF) -#define vsnprintf pcap_vsnprintf -extern int vsnprintf (char *, size_t, const char *, va_list ap); -#endif - -/* - * Routines that most pcap implementations can use for non-blocking mode. - */ -#if !defined(WIN32) && !defined(MSDOS) -int pcap_getnonblock_fd(pcap_t *, char *); -int pcap_setnonblock_fd(pcap_t *p, int, char *); -#endif - -void pcap_close_common(pcap_t *); - -/* - * Internal interfaces for "pcap_findalldevs()". - * - * "pcap_platform_finddevs()" is a platform-dependent routine to - * add devices not found by the "standard" mechanisms (SIOCGIFCONF, - * "getifaddrs()", etc.. - * - * "pcap_add_if()" adds an interface to the list of interfaces. - */ -int pcap_platform_finddevs(pcap_if_t **, char *); -int add_addr_to_iflist(pcap_if_t **, const char *, u_int, struct sockaddr *, - size_t, struct sockaddr *, size_t, struct sockaddr *, size_t, - struct sockaddr *, size_t, char *); -int pcap_add_if(pcap_if_t **, const char *, u_int, const char *, char *); -struct sockaddr *dup_sockaddr(struct sockaddr *, size_t); -int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int, - const char *, char *); - -#ifdef WIN32 -char *pcap_win32strerror(void); -#endif - -int install_bpf_program(pcap_t *, struct bpf_program *); - -int pcap_strcasecmp(const char *, const char *); - -#ifdef __cplusplus -} -#endif - -#endif +/* + * Copyright (c) 1994, 1995, 1996 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.68.2.9 2006/02/22 17:09:54 gianluca Exp $ (LBL) + */ + +#ifndef pcap_int_h +#define pcap_int_h + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef WIN32 +#include +#endif /* WIN32 */ + +#ifdef MSDOS +#include +#include +#endif + +/* + * Savefile + */ +typedef enum { + NOT_SWAPPED, + SWAPPED, + MAYBE_SWAPPED +} swapped_type_t; + +struct pcap_sf { + FILE *rfile; + int swapped; + int hdrsize; + swapped_type_t lengths_swapped; + int version_major; + int version_minor; + u_char *base; +}; + +struct pcap_md { + struct pcap_stat stat; + /*XXX*/ + int use_bpf; /* using kernel filter */ + u_long TotPkts; /* can't oflow for 79 hrs on ether */ + u_long TotAccepted; /* count accepted by filter */ + u_long TotDrops; /* count of dropped packets */ + long TotMissed; /* missed by i/f during this run */ + long OrigMissed; /* missed by i/f before this run */ + char *device; /* device name */ +#ifdef linux + int sock_packet; /* using Linux 2.0 compatible interface */ + int timeout; /* timeout specified to pcap_open_live */ + int clear_promisc; /* must clear promiscuous mode when we close */ + int cooked; /* using SOCK_DGRAM rather than SOCK_RAW */ + int ifindex; /* interface index of device we're bound to */ + int lo_ifindex; /* interface index of the loopback device */ + struct pcap *next; /* list of open promiscuous sock_packet pcaps */ + u_int packets_read; /* count of packets read with recvfrom() */ +#endif + +#ifdef HAVE_DAG_API +#ifdef HAVE_DAG_STREAMS_API + u_char *dag_mem_bottom; /* DAG card current memory bottom pointer */ + u_char *dag_mem_top; /* DAG card current memory top pointer */ +#else + void *dag_mem_base; /* DAG card memory base address */ + u_int dag_mem_bottom; /* DAG card current memory bottom offset */ + u_int dag_mem_top; /* DAG card current memory top offset */ +#endif /* HAVE_DAG_STREAMS_API */ + int dag_fcs_bits; /* Number of checksum bits from link layer */ + int dag_offset_flags; /* Flags to pass to dag_offset(). */ + int dag_stream; /* DAG stream number */ + int dag_timeout; /* timeout specified to pcap_open_live. + * Same as in linux above, introduce + * generally? */ +#endif /* HAVE_DAG_API */ + +#ifdef HAVE_REMOTE +/*! + There is really a mess with previous variables, and it seems to me that they are not used + (they are used in pcap_pf.c only). I think we have to start using them. + The meaning is the following: + + - TotPkts: the amount of packets received by the bpf filter, *before* applying the filter + - TotAccepted: the amount of packets that satisfies the filter + - TotDrops: the amount of packet that were dropped into the kernel buffer because of lack of space + - TotMissed: the amount of packets that were dropped by the physical interface; it is basically + the value of the hardware counter into the card. This number is never put to zero, so this number + takes into account the *total* number of interface drops starting from the interface power-on. + - OrigMissed: the amount of packets that were dropped by the interface *when the capture begins*. + This value is used to detect the number of packets dropped by the interface *during the present + capture*, so that (ps_ifdrops= TotMissed - OrigMissed). +*/ + unsigned int TotNetDrops; //!< keeps the number of packets that have been dropped by the network +/*! + \brief It keeps the number of packets that have been received by the application. + + Packets dropped by the kernel buffer are not counted in this variable. The variable is always + equal to (TotAccepted - TotDrops), exept for the case of remote capture, in which we have also + packets in fligh, i.e. that have been transmitted by the remote host, but that have not been + received (yet) from the client. In this case, (TotAccepted - TotDrops - TotNetDrops) gives a + wrong result, since this number does not corresponds always to the number of packet received by + the application. For this reason, in the remote capture we need another variable that takes + into account of the number of packets actually received by the application. +*/ + unsigned int TotCapt; +#endif /* HAVE_REMOTE */ +}; + +/* + * Ultrix, DEC OSF/1^H^H^H^H^H^H^H^H^HDigital UNIX^H^H^H^H^H^H^H^H^H^H^H^H + * Tru64 UNIX, and NetBSD pad to make everything line up on a nice boundary. + */ +#if defined(ultrix) || defined(__osf__) || (defined(__NetBSD__) && __NetBSD_Version__ > 106000000) +#define PCAP_FDDIPAD 3 +#endif + +struct pcap { +#ifdef WIN32 + ADAPTER *adapter; + LPPACKET Packet; + int timeout; + int nonblock; +#else + int fd; + int selectable_fd; + int send_fd; +#endif /* WIN32 */ + int snapshot; + int linktype; + int tzoff; /* timezone offset */ + int offset; /* offset for proper alignment */ + + int break_loop; /* flag set to force break from packet-reading loop */ + +#ifdef PCAP_FDDIPAD + int fddipad; +#endif + +#ifdef MSDOS + int inter_packet_wait; /* offline: wait between packets */ + void (*wait_proc)(void); /* call proc while waiting */ +#endif + + struct pcap_sf sf; + struct pcap_md md; + + /* + * Read buffer. + */ + int bufsize; + u_char *buffer; + u_char *bp; + int cc; + + /* + * Place holder for pcap_next(). + */ + u_char *pkt; + + /* We're accepting only packets in this direction/these directions. */ + pcap_direction_t direction; + + /* + * Methods. + */ + int (*read_op)(pcap_t *, int cnt, pcap_handler, u_char *); + int (*inject_op)(pcap_t *, const void *, size_t); + int (*setfilter_op)(pcap_t *, struct bpf_program *); + int (*setdirection_op)(pcap_t *, pcap_direction_t); + int (*set_datalink_op)(pcap_t *, int); + int (*getnonblock_op)(pcap_t *, char *); + int (*setnonblock_op)(pcap_t *, int, char *); + int (*stats_op)(pcap_t *, struct pcap_stat *); + void (*close_op)(pcap_t *); + + /* + * Placeholder for filter code if bpf not in kernel. + */ + struct bpf_program fcode; + + char errbuf[PCAP_ERRBUF_SIZE + 1]; + int dlt_count; + u_int *dlt_list; + + struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */ + +#ifdef HAVE_REMOTE +#ifndef WIN32 // Win32 already defines 'timeout' + int timeout; //!< timeout to be used in the pcap_open() +#endif + /*! \brief '1' if we're the network client; needed by several functions (like pcap_setfilter() ) to know if + they have to use the socket or they have to open the local adapter. */ + int rmt_clientside; + + SOCKET rmt_sockctrl; //!< socket ID of the socket used for the control connection + SOCKET rmt_sockdata; //!< socket ID of the socket used for the data connection + int rmt_flags; //!< we have to save flags, since they are passed by the pcap_open_live(), but they are used by the pcap_startcapture() + int rmt_capstarted; //!< 'true' if the capture is already started (needed to knoe if we have to call the pcap_startcapture() + struct pcap_samp rmt_samp; //!< Keeps the parameters related to the sampling process. + char *currentfilter; //!< Pointer to a buffer (allocated at run-time) that stores the current filter. Needed when flag PCAP_OPENFLAG_NOCAPTURE_RPCAP is turned on. +#endif /* HAVE_REMOTE */ +}; + +/* + * This is a timeval as stored in a savefile. + * It has to use the same types everywhere, independent of the actual + * `struct timeval'; `struct timeval' has 32-bit tv_sec values on some + * platforms and 64-bit tv_sec values on other platforms, and writing + * out native `struct timeval' values would mean files could only be + * read on systems with the same tv_sec size as the system on which + * the file was written. + */ + +struct pcap_timeval { + bpf_int32 tv_sec; /* seconds */ + bpf_int32 tv_usec; /* microseconds */ +}; + +/* + * This is a `pcap_pkthdr' as actually stored in a savefile. + * + * Do not change the format of this structure, in any way (this includes + * changes that only affect the length of fields in this structure), + * and do not make the time stamp anything other than seconds and + * microseconds (e.g., seconds and nanoseconds). Instead: + * + * introduce a new structure for the new format; + * + * send mail to "tcpdump-workers@tcpdump.org", requesting a new + * magic number for your new capture file format, and, when + * you get the new magic number, put it in "savefile.c"; + * + * use that magic number for save files with the changed record + * header; + * + * make the code in "savefile.c" capable of reading files with + * the old record header as well as files with the new record header + * (using the magic number to determine the header format). + * + * Then supply the changes to "patches@tcpdump.org", so that future + * versions of libpcap and programs that use it (such as tcpdump) will + * be able to read your new capture file format. + */ + +struct pcap_sf_pkthdr { + struct pcap_timeval ts; /* time stamp */ + bpf_u_int32 caplen; /* length of portion present */ + bpf_u_int32 len; /* length this packet (off wire) */ +}; + +/* + * How a `pcap_pkthdr' is actually stored in savefiles written + * by some patched versions of libpcap (e.g. the ones in Red + * Hat Linux 6.1 and 6.2). + * + * Do not change the format of this structure, in any way (this includes + * changes that only affect the length of fields in this structure). + * Instead, introduce a new structure, as per the above. + */ + +struct pcap_sf_patched_pkthdr { + struct pcap_timeval ts; /* time stamp */ + bpf_u_int32 caplen; /* length of portion present */ + bpf_u_int32 len; /* length this packet (off wire) */ + int index; + unsigned short protocol; + unsigned char pkt_type; +}; + +int yylex(void); + +#ifndef min +#define min(a, b) ((a) > (b) ? (b) : (a)) +#endif + +/* XXX should these be in pcap.h? */ +int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *); +int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *); + +#ifndef HAVE_STRLCPY +#define strlcpy(x, y, z) \ + (strncpy((x), (y), (z)), \ + ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \ + strlen((y))) +#endif + +#include + +#if !defined(HAVE_SNPRINTF) +#define snprintf pcap_snprintf +extern int snprintf (char *, size_t, const char *, ...); +#endif + +#if !defined(HAVE_VSNPRINTF) +#define vsnprintf pcap_vsnprintf +extern int vsnprintf (char *, size_t, const char *, va_list ap); +#endif + +/* + * Routines that most pcap implementations can use for non-blocking mode. + */ +#if !defined(WIN32) && !defined(MSDOS) +int pcap_getnonblock_fd(pcap_t *, char *); +int pcap_setnonblock_fd(pcap_t *p, int, char *); +#endif + +void pcap_close_common(pcap_t *); + +/* + * Internal interfaces for "pcap_findalldevs()". + * + * "pcap_platform_finddevs()" is a platform-dependent routine to + * add devices not found by the "standard" mechanisms (SIOCGIFCONF, + * "getifaddrs()", etc.. + * + * "pcap_add_if()" adds an interface to the list of interfaces. + */ +int pcap_platform_finddevs(pcap_if_t **, char *); +int add_addr_to_iflist(pcap_if_t **, const char *, u_int, struct sockaddr *, + size_t, struct sockaddr *, size_t, struct sockaddr *, size_t, + struct sockaddr *, size_t, char *); +int pcap_add_if(pcap_if_t **, const char *, u_int, const char *, char *); +struct sockaddr *dup_sockaddr(struct sockaddr *, size_t); +int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int, + const char *, char *); + +#ifdef WIN32 +char *pcap_win32strerror(void); +#endif + +int install_bpf_program(pcap_t *, struct bpf_program *); + +int pcap_strcasecmp(const char *, const char *); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/desmume/src/windows/winpcap/pcap-stdinc.h b/src/windows/winpcap/pcap-stdinc.h similarity index 97% rename from desmume/src/windows/winpcap/pcap-stdinc.h rename to src/windows/winpcap/pcap-stdinc.h index 12810247e..0d8bd6d4b 100644 --- a/desmume/src/windows/winpcap/pcap-stdinc.h +++ b/src/windows/winpcap/pcap-stdinc.h @@ -1,64 +1,64 @@ -/* - * Copyright (c) 2002 - 2003 - * NetGroup, Politecnico di Torino (Italy) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Politecnico di Torino nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#define SIZEOF_CHAR 1 -#define SIZEOF_SHORT 2 -#define SIZEOF_INT 4 -#ifndef _MSC_EXTENSIONS -#define SIZEOF_LONG_LONG 8 -#endif - -/* - * Avoids a compiler warning in case this was already defined - * (someone defined _WINSOCKAPI_ when including 'windows.h', in order - * to prevent it from including 'winsock.h') - */ -#ifdef _WINSOCKAPI_ -#undef _WINSOCKAPI_ -#endif -#include - -#include - -#include "bittypes.h" -#include -#include - -#ifndef __MINGW32__ -#include "IP6_misc.h" -#endif - -#define caddr_t char* - -#define snprintf _snprintf -#define vsnprintf _vsnprintf -#define inline __inline +/* + * Copyright (c) 2002 - 2003 + * NetGroup, Politecnico di Torino (Italy) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#define SIZEOF_CHAR 1 +#define SIZEOF_SHORT 2 +#define SIZEOF_INT 4 +#ifndef _MSC_EXTENSIONS +#define SIZEOF_LONG_LONG 8 +#endif + +/* + * Avoids a compiler warning in case this was already defined + * (someone defined _WINSOCKAPI_ when including 'windows.h', in order + * to prevent it from including 'winsock.h') + */ +#ifdef _WINSOCKAPI_ +#undef _WINSOCKAPI_ +#endif +#include + +#include + +#include "bittypes.h" +#include +#include + +#ifndef __MINGW32__ +#include "IP6_misc.h" +#endif + +#define caddr_t char* + +#define snprintf _snprintf +#define vsnprintf _vsnprintf +#define inline __inline diff --git a/desmume/src/windows/winpcap/pcap.h b/src/windows/winpcap/pcap.h similarity index 97% rename from desmume/src/windows/winpcap/pcap.h rename to src/windows/winpcap/pcap.h index c8a57119c..cbb0f06f6 100644 --- a/desmume/src/windows/winpcap/pcap.h +++ b/src/windows/winpcap/pcap.h @@ -1,344 +1,344 @@ -/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ -/* - * Copyright (c) 1993, 1994, 1995, 1996, 1997 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Computer Systems - * Engineering Group at Lawrence Berkeley Laboratory. - * 4. Neither the name of the University nor of the Laboratory may be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.52.2.6 2006/02/09 22:26:49 guy Exp $ (LBL) - */ - -#ifndef lib_pcap_h -#define lib_pcap_h - -#if defined(WIN32) - #include -#elif defined(MSDOS) - #include - #include /* u_int, u_char etc. */ -#else /* UN*X */ - #include - #include -#endif /* WIN32/MSDOS/UN*X */ - -#ifndef PCAP_DONT_INCLUDE_PCAP_BPF_H -#include -#endif - -#include - -#ifdef HAVE_REMOTE - // We have to define the SOCKET here, although it has been defined in sockutils.h - // This is to avoid the distribution of the 'sockutils.h' file around - // (for example in the WinPcap developer's pack) - #ifndef SOCKET - #ifdef WIN32 - #define SOCKET unsigned int - #else - #define SOCKET int - #endif - #endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define PCAP_VERSION_MAJOR 2 -#define PCAP_VERSION_MINOR 4 - -#define PCAP_ERRBUF_SIZE 256 - -/* - * Compatibility for systems that have a bpf.h that - * predates the bpf typedefs for 64-bit support. - */ -#if BPF_RELEASE - 0 < 199406 -typedef int bpf_int32; -typedef u_int bpf_u_int32; -#endif - -typedef struct pcap pcap_t; -typedef struct pcap_dumper pcap_dumper_t; -typedef struct pcap_if pcap_if_t; -typedef struct pcap_addr pcap_addr_t; - -/* - * The first record in the file contains saved values for some - * of the flags used in the printout phases of tcpdump. - * Many fields here are 32 bit ints so compilers won't insert unwanted - * padding; these files need to be interchangeable across architectures. - * - * Do not change the layout of this structure, in any way (this includes - * changes that only affect the length of fields in this structure). - * - * Also, do not change the interpretation of any of the members of this - * structure, in any way (this includes using values other than - * LINKTYPE_ values, as defined in "savefile.c", in the "linktype" - * field). - * - * Instead: - * - * introduce a new structure for the new format, if the layout - * of the structure changed; - * - * send mail to "tcpdump-workers@tcpdump.org", requesting a new - * magic number for your new capture file format, and, when - * you get the new magic number, put it in "savefile.c"; - * - * use that magic number for save files with the changed file - * header; - * - * make the code in "savefile.c" capable of reading files with - * the old file header as well as files with the new file header - * (using the magic number to determine the header format). - * - * Then supply the changes to "patches@tcpdump.org", so that future - * versions of libpcap and programs that use it (such as tcpdump) will - * be able to read your new capture file format. - */ -struct pcap_file_header { - bpf_u_int32 magic; - u_short version_major; - u_short version_minor; - bpf_int32 thiszone; /* gmt to local correction */ - bpf_u_int32 sigfigs; /* accuracy of timestamps */ - bpf_u_int32 snaplen; /* max length saved portion of each pkt */ - bpf_u_int32 linktype; /* data link type (LINKTYPE_*) */ -}; - -typedef enum { - PCAP_D_INOUT = 0, - PCAP_D_IN, - PCAP_D_OUT -} pcap_direction_t; - -/* - * Generic per-packet information, as supplied by libpcap. - * - * The time stamp can and should be a "struct timeval", regardless of - * whether your system supports 32-bit tv_sec in "struct timeval", - * 64-bit tv_sec in "struct timeval", or both if it supports both 32-bit - * and 64-bit applications. The on-disk format of savefiles uses 32-bit - * tv_sec (and tv_usec); this structure is irrelevant to that. 32-bit - * and 64-bit versions of libpcap, even if they're on the same platform, - * should supply the appropriate version of "struct timeval", even if - * that's not what the underlying packet capture mechanism supplies. - */ -struct pcap_pkthdr { - struct timeval ts; /* time stamp */ - bpf_u_int32 caplen; /* length of portion present */ - bpf_u_int32 len; /* length this packet (off wire) */ -}; - -/* - * As returned by the pcap_stats() - */ -struct pcap_stat { - u_int ps_recv; /* number of packets received */ - u_int ps_drop; /* number of packets dropped */ - u_int ps_ifdrop; /* drops by interface XXX not yet supported */ -#ifdef HAVE_REMOTE - u_int ps_capt; /* number of packets that are received by the application; please get rid off the Win32 ifdef */ - u_int ps_sent; /* number of packets sent by the server on the network */ - u_int ps_netdrop; /* number of packets lost on the network */ -#endif /* HAVE_REMOTE */ -}; - -#ifdef MSDOS -/* - * As returned by the pcap_stats_ex() - */ -struct pcap_stat_ex { - u_long rx_packets; /* total packets received */ - u_long tx_packets; /* total packets transmitted */ - u_long rx_bytes; /* total bytes received */ - u_long tx_bytes; /* total bytes transmitted */ - u_long rx_errors; /* bad packets received */ - u_long tx_errors; /* packet transmit problems */ - u_long rx_dropped; /* no space in Rx buffers */ - u_long tx_dropped; /* no space available for Tx */ - u_long multicast; /* multicast packets received */ - u_long collisions; - - /* detailed rx_errors: */ - u_long rx_length_errors; - u_long rx_over_errors; /* receiver ring buff overflow */ - u_long rx_crc_errors; /* recv'd pkt with crc error */ - u_long rx_frame_errors; /* recv'd frame alignment error */ - u_long rx_fifo_errors; /* recv'r fifo overrun */ - u_long rx_missed_errors; /* recv'r missed packet */ - - /* detailed tx_errors */ - u_long tx_aborted_errors; - u_long tx_carrier_errors; - u_long tx_fifo_errors; - u_long tx_heartbeat_errors; - u_long tx_window_errors; - }; -#endif - -/* - * Item in a list of interfaces. - */ -struct pcap_if { - struct pcap_if *next; - char *name; /* name to hand to "pcap_open_live()" */ - char *description; /* textual description of interface, or NULL */ - struct pcap_addr *addresses; - bpf_u_int32 flags; /* PCAP_IF_ interface flags */ -}; - -#define PCAP_IF_LOOPBACK 0x00000001 /* interface is loopback */ - -/* - * Representation of an interface address. - */ -struct pcap_addr { - struct pcap_addr *next; - struct sockaddr *addr; /* address */ - struct sockaddr *netmask; /* netmask for that address */ - struct sockaddr *broadaddr; /* broadcast address for that address */ - struct sockaddr *dstaddr; /* P2P destination address for that address */ -}; - -typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *, - const u_char *); - -char *pcap_lookupdev(char *); -int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *); -pcap_t *pcap_open_live(const char *, int, int, int, char *); -pcap_t *pcap_open_dead(int, int); -pcap_t *pcap_open_offline(const char *, char *); -pcap_t *pcap_fopen_offline(FILE *, char *); -void pcap_close(pcap_t *); -int pcap_loop(pcap_t *, int, pcap_handler, u_char *); -int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *); -const u_char* - pcap_next(pcap_t *, struct pcap_pkthdr *); -int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **); -void pcap_breakloop(pcap_t *); -int pcap_stats(pcap_t *, struct pcap_stat *); -int pcap_setfilter(pcap_t *, struct bpf_program *); -int pcap_setdirection(pcap_t *, pcap_direction_t); -int pcap_getnonblock(pcap_t *, char *); -int pcap_setnonblock(pcap_t *, int, char *); -void pcap_perror(pcap_t *, char *); -int pcap_inject(pcap_t *, const void *, size_t); -int pcap_sendpacket(pcap_t *, const u_char *, int); -char *pcap_strerror(int); -char *pcap_geterr(pcap_t *); -int pcap_compile(pcap_t *, struct bpf_program *, char *, int, - bpf_u_int32); -int pcap_compile_nopcap(int, int, struct bpf_program *, - char *, int, bpf_u_int32); -void pcap_freecode(struct bpf_program *); -int pcap_datalink(pcap_t *); -int pcap_list_datalinks(pcap_t *, int **); -int pcap_set_datalink(pcap_t *, int); -int pcap_datalink_name_to_val(const char *); -const char *pcap_datalink_val_to_name(int); -const char *pcap_datalink_val_to_description(int); -int pcap_snapshot(pcap_t *); -int pcap_is_swapped(pcap_t *); -int pcap_major_version(pcap_t *); -int pcap_minor_version(pcap_t *); - -/* XXX */ -FILE *pcap_file(pcap_t *); -int pcap_fileno(pcap_t *); - -pcap_dumper_t *pcap_dump_open(pcap_t *, const char *); -pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp); -FILE *pcap_dump_file(pcap_dumper_t *); -long pcap_dump_ftell(pcap_dumper_t *); -int pcap_dump_flush(pcap_dumper_t *); -void pcap_dump_close(pcap_dumper_t *); -void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *); - -int pcap_findalldevs(pcap_if_t **, char *); -void pcap_freealldevs(pcap_if_t *); - -const char *pcap_lib_version(void); - -/* XXX this guy lives in the bpf tree */ -u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int); -int bpf_validate(struct bpf_insn *f, int len); -char *bpf_image(struct bpf_insn *, int); -void bpf_dump(struct bpf_program *, int); - -#if defined(WIN32) - -/* - * Win32 definitions - */ - -int pcap_setbuff(pcap_t *p, int dim); -int pcap_setmode(pcap_t *p, int mode); -int pcap_setmintocopy(pcap_t *p, int size); - -#ifdef WPCAP -/* Include file with the wpcap-specific extensions */ -#include -#endif /* WPCAP */ - -#define MODE_CAPT 0 -#define MODE_STAT 1 -#define MODE_MON 2 - -#elif defined(MSDOS) - -/* - * MS-DOS definitions - */ - -int pcap_stats_ex (pcap_t *, struct pcap_stat_ex *); -void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait); -u_long pcap_mac_packets (void); - -#else /* UN*X */ - -/* - * UN*X definitions - */ - -int pcap_get_selectable_fd(pcap_t *); - -#endif /* WIN32/MSDOS/UN*X */ - -#ifdef HAVE_REMOTE -/* Includes most of the public stuff that is needed for the remote capture */ -#include "remote-ext.h" -#endif /* HAVE_REMOTE */ - -#ifdef __cplusplus -} -#endif - -#endif +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.52.2.6 2006/02/09 22:26:49 guy Exp $ (LBL) + */ + +#ifndef lib_pcap_h +#define lib_pcap_h + +#if defined(WIN32) + #include +#elif defined(MSDOS) + #include + #include /* u_int, u_char etc. */ +#else /* UN*X */ + #include + #include +#endif /* WIN32/MSDOS/UN*X */ + +#ifndef PCAP_DONT_INCLUDE_PCAP_BPF_H +#include +#endif + +#include + +#ifdef HAVE_REMOTE + // We have to define the SOCKET here, although it has been defined in sockutils.h + // This is to avoid the distribution of the 'sockutils.h' file around + // (for example in the WinPcap developer's pack) + #ifndef SOCKET + #ifdef WIN32 + #define SOCKET unsigned int + #else + #define SOCKET int + #endif + #endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define PCAP_VERSION_MAJOR 2 +#define PCAP_VERSION_MINOR 4 + +#define PCAP_ERRBUF_SIZE 256 + +/* + * Compatibility for systems that have a bpf.h that + * predates the bpf typedefs for 64-bit support. + */ +#if BPF_RELEASE - 0 < 199406 +typedef int bpf_int32; +typedef u_int bpf_u_int32; +#endif + +typedef struct pcap pcap_t; +typedef struct pcap_dumper pcap_dumper_t; +typedef struct pcap_if pcap_if_t; +typedef struct pcap_addr pcap_addr_t; + +/* + * The first record in the file contains saved values for some + * of the flags used in the printout phases of tcpdump. + * Many fields here are 32 bit ints so compilers won't insert unwanted + * padding; these files need to be interchangeable across architectures. + * + * Do not change the layout of this structure, in any way (this includes + * changes that only affect the length of fields in this structure). + * + * Also, do not change the interpretation of any of the members of this + * structure, in any way (this includes using values other than + * LINKTYPE_ values, as defined in "savefile.c", in the "linktype" + * field). + * + * Instead: + * + * introduce a new structure for the new format, if the layout + * of the structure changed; + * + * send mail to "tcpdump-workers@tcpdump.org", requesting a new + * magic number for your new capture file format, and, when + * you get the new magic number, put it in "savefile.c"; + * + * use that magic number for save files with the changed file + * header; + * + * make the code in "savefile.c" capable of reading files with + * the old file header as well as files with the new file header + * (using the magic number to determine the header format). + * + * Then supply the changes to "patches@tcpdump.org", so that future + * versions of libpcap and programs that use it (such as tcpdump) will + * be able to read your new capture file format. + */ +struct pcap_file_header { + bpf_u_int32 magic; + u_short version_major; + u_short version_minor; + bpf_int32 thiszone; /* gmt to local correction */ + bpf_u_int32 sigfigs; /* accuracy of timestamps */ + bpf_u_int32 snaplen; /* max length saved portion of each pkt */ + bpf_u_int32 linktype; /* data link type (LINKTYPE_*) */ +}; + +typedef enum { + PCAP_D_INOUT = 0, + PCAP_D_IN, + PCAP_D_OUT +} pcap_direction_t; + +/* + * Generic per-packet information, as supplied by libpcap. + * + * The time stamp can and should be a "struct timeval", regardless of + * whether your system supports 32-bit tv_sec in "struct timeval", + * 64-bit tv_sec in "struct timeval", or both if it supports both 32-bit + * and 64-bit applications. The on-disk format of savefiles uses 32-bit + * tv_sec (and tv_usec); this structure is irrelevant to that. 32-bit + * and 64-bit versions of libpcap, even if they're on the same platform, + * should supply the appropriate version of "struct timeval", even if + * that's not what the underlying packet capture mechanism supplies. + */ +struct pcap_pkthdr { + struct timeval ts; /* time stamp */ + bpf_u_int32 caplen; /* length of portion present */ + bpf_u_int32 len; /* length this packet (off wire) */ +}; + +/* + * As returned by the pcap_stats() + */ +struct pcap_stat { + u_int ps_recv; /* number of packets received */ + u_int ps_drop; /* number of packets dropped */ + u_int ps_ifdrop; /* drops by interface XXX not yet supported */ +#ifdef HAVE_REMOTE + u_int ps_capt; /* number of packets that are received by the application; please get rid off the Win32 ifdef */ + u_int ps_sent; /* number of packets sent by the server on the network */ + u_int ps_netdrop; /* number of packets lost on the network */ +#endif /* HAVE_REMOTE */ +}; + +#ifdef MSDOS +/* + * As returned by the pcap_stats_ex() + */ +struct pcap_stat_ex { + u_long rx_packets; /* total packets received */ + u_long tx_packets; /* total packets transmitted */ + u_long rx_bytes; /* total bytes received */ + u_long tx_bytes; /* total bytes transmitted */ + u_long rx_errors; /* bad packets received */ + u_long tx_errors; /* packet transmit problems */ + u_long rx_dropped; /* no space in Rx buffers */ + u_long tx_dropped; /* no space available for Tx */ + u_long multicast; /* multicast packets received */ + u_long collisions; + + /* detailed rx_errors: */ + u_long rx_length_errors; + u_long rx_over_errors; /* receiver ring buff overflow */ + u_long rx_crc_errors; /* recv'd pkt with crc error */ + u_long rx_frame_errors; /* recv'd frame alignment error */ + u_long rx_fifo_errors; /* recv'r fifo overrun */ + u_long rx_missed_errors; /* recv'r missed packet */ + + /* detailed tx_errors */ + u_long tx_aborted_errors; + u_long tx_carrier_errors; + u_long tx_fifo_errors; + u_long tx_heartbeat_errors; + u_long tx_window_errors; + }; +#endif + +/* + * Item in a list of interfaces. + */ +struct pcap_if { + struct pcap_if *next; + char *name; /* name to hand to "pcap_open_live()" */ + char *description; /* textual description of interface, or NULL */ + struct pcap_addr *addresses; + bpf_u_int32 flags; /* PCAP_IF_ interface flags */ +}; + +#define PCAP_IF_LOOPBACK 0x00000001 /* interface is loopback */ + +/* + * Representation of an interface address. + */ +struct pcap_addr { + struct pcap_addr *next; + struct sockaddr *addr; /* address */ + struct sockaddr *netmask; /* netmask for that address */ + struct sockaddr *broadaddr; /* broadcast address for that address */ + struct sockaddr *dstaddr; /* P2P destination address for that address */ +}; + +typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *, + const u_char *); + +char *pcap_lookupdev(char *); +int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *); +pcap_t *pcap_open_live(const char *, int, int, int, char *); +pcap_t *pcap_open_dead(int, int); +pcap_t *pcap_open_offline(const char *, char *); +pcap_t *pcap_fopen_offline(FILE *, char *); +void pcap_close(pcap_t *); +int pcap_loop(pcap_t *, int, pcap_handler, u_char *); +int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *); +const u_char* + pcap_next(pcap_t *, struct pcap_pkthdr *); +int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **); +void pcap_breakloop(pcap_t *); +int pcap_stats(pcap_t *, struct pcap_stat *); +int pcap_setfilter(pcap_t *, struct bpf_program *); +int pcap_setdirection(pcap_t *, pcap_direction_t); +int pcap_getnonblock(pcap_t *, char *); +int pcap_setnonblock(pcap_t *, int, char *); +void pcap_perror(pcap_t *, char *); +int pcap_inject(pcap_t *, const void *, size_t); +int pcap_sendpacket(pcap_t *, const u_char *, int); +char *pcap_strerror(int); +char *pcap_geterr(pcap_t *); +int pcap_compile(pcap_t *, struct bpf_program *, char *, int, + bpf_u_int32); +int pcap_compile_nopcap(int, int, struct bpf_program *, + char *, int, bpf_u_int32); +void pcap_freecode(struct bpf_program *); +int pcap_datalink(pcap_t *); +int pcap_list_datalinks(pcap_t *, int **); +int pcap_set_datalink(pcap_t *, int); +int pcap_datalink_name_to_val(const char *); +const char *pcap_datalink_val_to_name(int); +const char *pcap_datalink_val_to_description(int); +int pcap_snapshot(pcap_t *); +int pcap_is_swapped(pcap_t *); +int pcap_major_version(pcap_t *); +int pcap_minor_version(pcap_t *); + +/* XXX */ +FILE *pcap_file(pcap_t *); +int pcap_fileno(pcap_t *); + +pcap_dumper_t *pcap_dump_open(pcap_t *, const char *); +pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp); +FILE *pcap_dump_file(pcap_dumper_t *); +long pcap_dump_ftell(pcap_dumper_t *); +int pcap_dump_flush(pcap_dumper_t *); +void pcap_dump_close(pcap_dumper_t *); +void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *); + +int pcap_findalldevs(pcap_if_t **, char *); +void pcap_freealldevs(pcap_if_t *); + +const char *pcap_lib_version(void); + +/* XXX this guy lives in the bpf tree */ +u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int); +int bpf_validate(struct bpf_insn *f, int len); +char *bpf_image(struct bpf_insn *, int); +void bpf_dump(struct bpf_program *, int); + +#if defined(WIN32) + +/* + * Win32 definitions + */ + +int pcap_setbuff(pcap_t *p, int dim); +int pcap_setmode(pcap_t *p, int mode); +int pcap_setmintocopy(pcap_t *p, int size); + +#ifdef WPCAP +/* Include file with the wpcap-specific extensions */ +#include +#endif /* WPCAP */ + +#define MODE_CAPT 0 +#define MODE_STAT 1 +#define MODE_MON 2 + +#elif defined(MSDOS) + +/* + * MS-DOS definitions + */ + +int pcap_stats_ex (pcap_t *, struct pcap_stat_ex *); +void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait); +u_long pcap_mac_packets (void); + +#else /* UN*X */ + +/* + * UN*X definitions + */ + +int pcap_get_selectable_fd(pcap_t *); + +#endif /* WIN32/MSDOS/UN*X */ + +#ifdef HAVE_REMOTE +/* Includes most of the public stuff that is needed for the remote capture */ +#include "remote-ext.h" +#endif /* HAVE_REMOTE */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/desmume/src/windows/winpcap/remote-ext.h b/src/windows/winpcap/remote-ext.h similarity index 97% rename from desmume/src/windows/winpcap/remote-ext.h rename to src/windows/winpcap/remote-ext.h index b3884c9c8..9db8055f9 100644 --- a/desmume/src/windows/winpcap/remote-ext.h +++ b/src/windows/winpcap/remote-ext.h @@ -1,441 +1,441 @@ -/* - * Copyright (c) 2002 - 2003 - * NetGroup, Politecnico di Torino (Italy) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Politecnico di Torino nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#ifndef __REMOTE_EXT_H__ -#define __REMOTE_EXT_H__ - - - -// Definition for Microsoft Visual Studio -#if _MSC_VER > 1000 -#pragma once -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/*! - \file remote-ext.h - - The goal of this file it to include most of the new definitions that should be - placed into the pcap.h file. - - It includes all new definitions (structures and functions like pcap_open(). - Some of the functions are not really a remote feature, but, right now, - they are placed here. -*/ - - - -// All this stuff is public -/*! \addtogroup remote_struct - \{ -*/ - - - - -/*! - \brief Defines the maximum buffer size in which address, port, interface names are kept. - - In case the adapter name or such is larger than this value, it is truncated. - This is not used by the user; however it must be aware that an hostname / interface - name longer than this value will be truncated. -*/ -#define PCAP_BUF_SIZE 1024 - - -/*! \addtogroup remote_source_ID - \{ -*/ - - -/*! - \brief Internal representation of the type of source in use (file, - remote/local interface). - - This indicates a file, i.e. the user want to open a capture from a local file. -*/ -#define PCAP_SRC_FILE 2 -/*! - \brief Internal representation of the type of source in use (file, - remote/local interface). - - This indicates a local interface, i.e. the user want to open a capture from - a local interface. This does not involve the RPCAP protocol. -*/ -#define PCAP_SRC_IFLOCAL 3 -/*! - \brief Internal representation of the type of source in use (file, - remote/local interface). - - This indicates a remote interface, i.e. the user want to open a capture from - an interface on a remote host. This does involve the RPCAP protocol. -*/ -#define PCAP_SRC_IFREMOTE 4 - -/*! - \} -*/ - - - -/*! \addtogroup remote_source_string - - The formats allowed by the pcap_open() are the following: - - file://path_and_filename [opens a local file] - - rpcap://devicename [opens the selected device devices available on the local host, without using the RPCAP protocol] - - rpcap://host/devicename [opens the selected device available on a remote host] - - rpcap://host:port/devicename [opens the selected device available on a remote host, using a non-standard port for RPCAP] - - adaptername [to open a local adapter; kept for compability, but it is strongly discouraged] - - (NULL) [to open the first local adapter; kept for compability, but it is strongly discouraged] - - The formats allowed by the pcap_findalldevs_ex() are the following: - - file://folder/ [lists all the files in the given folder] - - rpcap:// [lists all local adapters] - - rpcap://host:port/ [lists the devices available on a remote host] - - Referring to the 'host' and 'port' paramters, they can be either numeric or literal. Since - IPv6 is fully supported, these are the allowed formats: - - - host (literal): e.g. host.foo.bar - - host (numeric IPv4): e.g. 10.11.12.13 - - host (numeric IPv4, IPv6 style): e.g. [10.11.12.13] - - host (numeric IPv6): e.g. [1:2:3::4] - - port: can be either numeric (e.g. '80') or literal (e.g. 'http') - - Here you find some allowed examples: - - rpcap://host.foo.bar/devicename [everything literal, no port number] - - rpcap://host.foo.bar:1234/devicename [everything literal, with port number] - - rpcap://10.11.12.13/devicename [IPv4 numeric, no port number] - - rpcap://10.11.12.13:1234/devicename [IPv4 numeric, with port number] - - rpcap://[10.11.12.13]:1234/devicename [IPv4 numeric with IPv6 format, with port number] - - rpcap://[1:2:3::4]/devicename [IPv6 numeric, no port number] - - rpcap://[1:2:3::4]:1234/devicename [IPv6 numeric, with port number] - - rpcap://[1:2:3::4]:http/devicename [IPv6 numeric, with literal port number] - - \{ -*/ - - -/*! - \brief String that will be used to determine the type of source in use (file, - remote/local interface). - - This string will be prepended to the interface name in order to create a string - that contains all the information required to open the source. - - This string indicates that the user wants to open a capture from a local file. -*/ -#define PCAP_SRC_FILE_STRING "file://" -/*! - \brief String that will be used to determine the type of source in use (file, - remote/local interface). - - This string will be prepended to the interface name in order to create a string - that contains all the information required to open the source. - - This string indicates that the user wants to open a capture from a network interface. - This string does not necessarily involve the use of the RPCAP protocol. If the - interface required resides on the local host, the RPCAP protocol is not involved - and the local functions are used. -*/ -#define PCAP_SRC_IF_STRING "rpcap://" - -/*! - \} -*/ - - - - - -/*! - \addtogroup remote_open_flags - \{ -*/ - -/*! - \brief Defines if the adapter has to go in promiscuous mode. - - It is '1' if you have to open the adapter in promiscuous mode, '0' otherwise. - Note that even if this parameter is false, the interface could well be in promiscuous - mode for some other reason (for example because another capture process with - promiscuous mode enabled is currently using that interface). - On on Linux systems with 2.2 or later kernels (that have the "any" device), this - flag does not work on the "any" device; if an argument of "any" is supplied, - the 'promisc' flag is ignored. -*/ -#define PCAP_OPENFLAG_PROMISCUOUS 1 - -/*! - \brief Defines if the data trasfer (in case of a remote - capture) has to be done with UDP protocol. - - If it is '1' if you want a UDP data connection, '0' if you want - a TCP data connection; control connection is always TCP-based. - A UDP connection is much lighter, but it does not guarantee that all - the captured packets arrive to the client workstation. Moreover, - it could be harmful in case of network congestion. - This flag is meaningless if the source is not a remote interface. - In that case, it is simply ignored. -*/ -#define PCAP_OPENFLAG_DATATX_UDP 2 - - -/*! - \brief Defines if the remote probe will capture its own generated traffic. - - In case the remote probe uses the same interface to capture traffic and to send - data back to the caller, the captured traffic includes the RPCAP traffic as well. - If this flag is turned on, the RPCAP traffic is excluded from the capture, so that - the trace returned back to the collector is does not include this traffic. -*/ -#define PCAP_OPENFLAG_NOCAPTURE_RPCAP 4 - -/*! - \brief Defines if the local adapter will capture its own generated traffic. - - This flag tells the underlying capture driver to drop the packets that were sent by itself. - This is usefult when building applications like bridges, that should ignore the traffic - they just sent. -*/ -#define PCAP_OPENFLAG_NOCAPTURE_LOCAL 8 - -/*! - \brief This flag configures the adapter for maximum responsiveness. - - In presence of a large value for nbytes, WinPcap waits for the arrival of several packets before - copying the data to the user. This guarantees a low number of system calls, i.e. lower processor usage, - i.e. better performance, which is good for applications like sniffers. If the user sets the - PCAP_OPENFLAG_MAX_RESPONSIVENESS flag, the capture driver will copy the packets as soon as the application - is ready to receive them. This is suggested for real time applications (like, for example, a bridge) - that need the best responsiveness.*/ -#define PCAP_OPENFLAG_MAX_RESPONSIVENESS 16 - -/*! - \} -*/ - - -/*! - \addtogroup remote_samp_methods - \{ -*/ - -/*! - \brief No sampling has to be done on the current capture. - - In this case, no sampling algorithms are applied to the current capture. -*/ -#define PCAP_SAMP_NOSAMP 0 - -/*! - \brief It defines that only 1 out of N packets must be returned to the user. - - In this case, the 'value' field of the 'pcap_samp' structure indicates the - number of packets (minus 1) that must be discarded before one packet got accepted. - In other words, if 'value = 10', the first packet is returned to the caller, while - the following 9 are discarded. -*/ -#define PCAP_SAMP_1_EVERY_N 1 - -/*! - \brief It defines that we have to return 1 packet every N milliseconds. - - In this case, the 'value' field of the 'pcap_samp' structure indicates the 'waiting - time' in milliseconds before one packet got accepted. - In other words, if 'value = 10', the first packet is returned to the caller; the next - returned one will be the first packet that arrives when 10ms have elapsed. -*/ -#define PCAP_SAMP_FIRST_AFTER_N_MS 2 - -/*! - \} -*/ - - -/*! - \addtogroup remote_auth_methods - \{ -*/ - -/*! - \brief It defines the NULL authentication. - - This value has to be used within the 'type' member of the pcap_rmtauth structure. - The 'NULL' authentication has to be equal to 'zero', so that old applications - can just put every field of struct pcap_rmtauth to zero, and it does work. -*/ -#define RPCAP_RMTAUTH_NULL 0 -/*! - \brief It defines the username/password authentication. - - With this type of authentication, the RPCAP protocol will use the username/ - password provided to authenticate the user on the remote machine. If the - authentication is successful (and the user has the right to open network devices) - the RPCAP connection will continue; otherwise it will be dropped. - - This value has to be used within the 'type' member of the pcap_rmtauth structure. -*/ -#define RPCAP_RMTAUTH_PWD 1 - -/*! - \} -*/ - - - - -/*! - - \brief This structure keeps the information needed to autheticate - the user on a remote machine. - - The remote machine can either grant or refuse the access according - to the information provided. - In case the NULL authentication is required, both 'username' and - 'password' can be NULL pointers. - - This structure is meaningless if the source is not a remote interface; - in that case, the functions which requires such a structure can accept - a NULL pointer as well. -*/ -struct pcap_rmtauth -{ - /*! - \brief Type of the authentication required. - - In order to provide maximum flexibility, we can support different types - of authentication based on the value of this 'type' variable. The currently - supported authentication methods are defined into the - \link remote_auth_methods Remote Authentication Methods Section\endlink. - - */ - int type; - /*! - \brief Zero-terminated string containing the username that has to be - used on the remote machine for authentication. - - This field is meaningless in case of the RPCAP_RMTAUTH_NULL authentication - and it can be NULL. - */ - char *username; - /*! - \brief Zero-terminated string containing the password that has to be - used on the remote machine for authentication. - - This field is meaningless in case of the RPCAP_RMTAUTH_NULL authentication - and it can be NULL. - */ - char *password; -}; - - -/*! - \brief This structure defines the information related to sampling. - - In case the sampling is requested, the capturing device should read - only a subset of the packets coming from the source. The returned packets depend - on the sampling parameters. - - \warning The sampling process is applied after the filtering process. - In other words, packets are filtered first, then the sampling process selects a - subset of the 'filtered' packets and it returns them to the caller. -*/ -struct pcap_samp -{ - /*! - Method used for sampling. Currently, the supported methods are listed in the - \link remote_samp_methods Sampling Methods Section\endlink. - */ - int method; - - /*! - This value depends on the sampling method defined. For its meaning, please check - at the \link remote_samp_methods Sampling Methods Section\endlink. - */ - int value; -}; - - - - -//! Maximum lenght of an host name (needed for the RPCAP active mode) -#define RPCAP_HOSTLIST_SIZE 1024 - - -/*! - \} -*/ // end of public documentation - - -// Exported functions - - - -/** \name New WinPcap functions - - This section lists the new functions that are able to help considerably in writing - WinPcap programs because of their easiness of use. - */ -//\{ -pcap_t *pcap_open(const char *source, int snaplen, int flags, int read_timeout, struct pcap_rmtauth *auth, char *errbuf); -int pcap_createsrcstr(char *source, int type, const char *host, const char *port, const char *name, char *errbuf); -int pcap_parsesrcstr(const char *source, int *type, char *host, char *port, char *name, char *errbuf); -int pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf); -struct pcap_samp *pcap_setsampling(pcap_t *p); - -//\} -// End of new winpcap functions - - - -/** \name Remote Capture functions - */ -//\{ -SOCKET pcap_remoteact_accept(const char *address, const char *port, const char *hostlist, char *connectinghost, struct pcap_rmtauth *auth, char *errbuf); -int pcap_remoteact_list(char *hostlist, char sep, int size, char *errbuf); -int pcap_remoteact_close(const char *host, char *errbuf); -void pcap_remoteact_cleanup(); -//\} -// End of remote capture functions - -#ifdef __cplusplus -} -#endif - - -#endif - +/* + * Copyright (c) 2002 - 2003 + * NetGroup, Politecnico di Torino (Italy) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + + +#ifndef __REMOTE_EXT_H__ +#define __REMOTE_EXT_H__ + + + +// Definition for Microsoft Visual Studio +#if _MSC_VER > 1000 +#pragma once +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + \file remote-ext.h + + The goal of this file it to include most of the new definitions that should be + placed into the pcap.h file. + + It includes all new definitions (structures and functions like pcap_open(). + Some of the functions are not really a remote feature, but, right now, + they are placed here. +*/ + + + +// All this stuff is public +/*! \addtogroup remote_struct + \{ +*/ + + + + +/*! + \brief Defines the maximum buffer size in which address, port, interface names are kept. + + In case the adapter name or such is larger than this value, it is truncated. + This is not used by the user; however it must be aware that an hostname / interface + name longer than this value will be truncated. +*/ +#define PCAP_BUF_SIZE 1024 + + +/*! \addtogroup remote_source_ID + \{ +*/ + + +/*! + \brief Internal representation of the type of source in use (file, + remote/local interface). + + This indicates a file, i.e. the user want to open a capture from a local file. +*/ +#define PCAP_SRC_FILE 2 +/*! + \brief Internal representation of the type of source in use (file, + remote/local interface). + + This indicates a local interface, i.e. the user want to open a capture from + a local interface. This does not involve the RPCAP protocol. +*/ +#define PCAP_SRC_IFLOCAL 3 +/*! + \brief Internal representation of the type of source in use (file, + remote/local interface). + + This indicates a remote interface, i.e. the user want to open a capture from + an interface on a remote host. This does involve the RPCAP protocol. +*/ +#define PCAP_SRC_IFREMOTE 4 + +/*! + \} +*/ + + + +/*! \addtogroup remote_source_string + + The formats allowed by the pcap_open() are the following: + - file://path_and_filename [opens a local file] + - rpcap://devicename [opens the selected device devices available on the local host, without using the RPCAP protocol] + - rpcap://host/devicename [opens the selected device available on a remote host] + - rpcap://host:port/devicename [opens the selected device available on a remote host, using a non-standard port for RPCAP] + - adaptername [to open a local adapter; kept for compability, but it is strongly discouraged] + - (NULL) [to open the first local adapter; kept for compability, but it is strongly discouraged] + + The formats allowed by the pcap_findalldevs_ex() are the following: + - file://folder/ [lists all the files in the given folder] + - rpcap:// [lists all local adapters] + - rpcap://host:port/ [lists the devices available on a remote host] + + Referring to the 'host' and 'port' paramters, they can be either numeric or literal. Since + IPv6 is fully supported, these are the allowed formats: + + - host (literal): e.g. host.foo.bar + - host (numeric IPv4): e.g. 10.11.12.13 + - host (numeric IPv4, IPv6 style): e.g. [10.11.12.13] + - host (numeric IPv6): e.g. [1:2:3::4] + - port: can be either numeric (e.g. '80') or literal (e.g. 'http') + + Here you find some allowed examples: + - rpcap://host.foo.bar/devicename [everything literal, no port number] + - rpcap://host.foo.bar:1234/devicename [everything literal, with port number] + - rpcap://10.11.12.13/devicename [IPv4 numeric, no port number] + - rpcap://10.11.12.13:1234/devicename [IPv4 numeric, with port number] + - rpcap://[10.11.12.13]:1234/devicename [IPv4 numeric with IPv6 format, with port number] + - rpcap://[1:2:3::4]/devicename [IPv6 numeric, no port number] + - rpcap://[1:2:3::4]:1234/devicename [IPv6 numeric, with port number] + - rpcap://[1:2:3::4]:http/devicename [IPv6 numeric, with literal port number] + + \{ +*/ + + +/*! + \brief String that will be used to determine the type of source in use (file, + remote/local interface). + + This string will be prepended to the interface name in order to create a string + that contains all the information required to open the source. + + This string indicates that the user wants to open a capture from a local file. +*/ +#define PCAP_SRC_FILE_STRING "file://" +/*! + \brief String that will be used to determine the type of source in use (file, + remote/local interface). + + This string will be prepended to the interface name in order to create a string + that contains all the information required to open the source. + + This string indicates that the user wants to open a capture from a network interface. + This string does not necessarily involve the use of the RPCAP protocol. If the + interface required resides on the local host, the RPCAP protocol is not involved + and the local functions are used. +*/ +#define PCAP_SRC_IF_STRING "rpcap://" + +/*! + \} +*/ + + + + + +/*! + \addtogroup remote_open_flags + \{ +*/ + +/*! + \brief Defines if the adapter has to go in promiscuous mode. + + It is '1' if you have to open the adapter in promiscuous mode, '0' otherwise. + Note that even if this parameter is false, the interface could well be in promiscuous + mode for some other reason (for example because another capture process with + promiscuous mode enabled is currently using that interface). + On on Linux systems with 2.2 or later kernels (that have the "any" device), this + flag does not work on the "any" device; if an argument of "any" is supplied, + the 'promisc' flag is ignored. +*/ +#define PCAP_OPENFLAG_PROMISCUOUS 1 + +/*! + \brief Defines if the data trasfer (in case of a remote + capture) has to be done with UDP protocol. + + If it is '1' if you want a UDP data connection, '0' if you want + a TCP data connection; control connection is always TCP-based. + A UDP connection is much lighter, but it does not guarantee that all + the captured packets arrive to the client workstation. Moreover, + it could be harmful in case of network congestion. + This flag is meaningless if the source is not a remote interface. + In that case, it is simply ignored. +*/ +#define PCAP_OPENFLAG_DATATX_UDP 2 + + +/*! + \brief Defines if the remote probe will capture its own generated traffic. + + In case the remote probe uses the same interface to capture traffic and to send + data back to the caller, the captured traffic includes the RPCAP traffic as well. + If this flag is turned on, the RPCAP traffic is excluded from the capture, so that + the trace returned back to the collector is does not include this traffic. +*/ +#define PCAP_OPENFLAG_NOCAPTURE_RPCAP 4 + +/*! + \brief Defines if the local adapter will capture its own generated traffic. + + This flag tells the underlying capture driver to drop the packets that were sent by itself. + This is usefult when building applications like bridges, that should ignore the traffic + they just sent. +*/ +#define PCAP_OPENFLAG_NOCAPTURE_LOCAL 8 + +/*! + \brief This flag configures the adapter for maximum responsiveness. + + In presence of a large value for nbytes, WinPcap waits for the arrival of several packets before + copying the data to the user. This guarantees a low number of system calls, i.e. lower processor usage, + i.e. better performance, which is good for applications like sniffers. If the user sets the + PCAP_OPENFLAG_MAX_RESPONSIVENESS flag, the capture driver will copy the packets as soon as the application + is ready to receive them. This is suggested for real time applications (like, for example, a bridge) + that need the best responsiveness.*/ +#define PCAP_OPENFLAG_MAX_RESPONSIVENESS 16 + +/*! + \} +*/ + + +/*! + \addtogroup remote_samp_methods + \{ +*/ + +/*! + \brief No sampling has to be done on the current capture. + + In this case, no sampling algorithms are applied to the current capture. +*/ +#define PCAP_SAMP_NOSAMP 0 + +/*! + \brief It defines that only 1 out of N packets must be returned to the user. + + In this case, the 'value' field of the 'pcap_samp' structure indicates the + number of packets (minus 1) that must be discarded before one packet got accepted. + In other words, if 'value = 10', the first packet is returned to the caller, while + the following 9 are discarded. +*/ +#define PCAP_SAMP_1_EVERY_N 1 + +/*! + \brief It defines that we have to return 1 packet every N milliseconds. + + In this case, the 'value' field of the 'pcap_samp' structure indicates the 'waiting + time' in milliseconds before one packet got accepted. + In other words, if 'value = 10', the first packet is returned to the caller; the next + returned one will be the first packet that arrives when 10ms have elapsed. +*/ +#define PCAP_SAMP_FIRST_AFTER_N_MS 2 + +/*! + \} +*/ + + +/*! + \addtogroup remote_auth_methods + \{ +*/ + +/*! + \brief It defines the NULL authentication. + + This value has to be used within the 'type' member of the pcap_rmtauth structure. + The 'NULL' authentication has to be equal to 'zero', so that old applications + can just put every field of struct pcap_rmtauth to zero, and it does work. +*/ +#define RPCAP_RMTAUTH_NULL 0 +/*! + \brief It defines the username/password authentication. + + With this type of authentication, the RPCAP protocol will use the username/ + password provided to authenticate the user on the remote machine. If the + authentication is successful (and the user has the right to open network devices) + the RPCAP connection will continue; otherwise it will be dropped. + + This value has to be used within the 'type' member of the pcap_rmtauth structure. +*/ +#define RPCAP_RMTAUTH_PWD 1 + +/*! + \} +*/ + + + + +/*! + + \brief This structure keeps the information needed to autheticate + the user on a remote machine. + + The remote machine can either grant or refuse the access according + to the information provided. + In case the NULL authentication is required, both 'username' and + 'password' can be NULL pointers. + + This structure is meaningless if the source is not a remote interface; + in that case, the functions which requires such a structure can accept + a NULL pointer as well. +*/ +struct pcap_rmtauth +{ + /*! + \brief Type of the authentication required. + + In order to provide maximum flexibility, we can support different types + of authentication based on the value of this 'type' variable. The currently + supported authentication methods are defined into the + \link remote_auth_methods Remote Authentication Methods Section\endlink. + + */ + int type; + /*! + \brief Zero-terminated string containing the username that has to be + used on the remote machine for authentication. + + This field is meaningless in case of the RPCAP_RMTAUTH_NULL authentication + and it can be NULL. + */ + char *username; + /*! + \brief Zero-terminated string containing the password that has to be + used on the remote machine for authentication. + + This field is meaningless in case of the RPCAP_RMTAUTH_NULL authentication + and it can be NULL. + */ + char *password; +}; + + +/*! + \brief This structure defines the information related to sampling. + + In case the sampling is requested, the capturing device should read + only a subset of the packets coming from the source. The returned packets depend + on the sampling parameters. + + \warning The sampling process is applied after the filtering process. + In other words, packets are filtered first, then the sampling process selects a + subset of the 'filtered' packets and it returns them to the caller. +*/ +struct pcap_samp +{ + /*! + Method used for sampling. Currently, the supported methods are listed in the + \link remote_samp_methods Sampling Methods Section\endlink. + */ + int method; + + /*! + This value depends on the sampling method defined. For its meaning, please check + at the \link remote_samp_methods Sampling Methods Section\endlink. + */ + int value; +}; + + + + +//! Maximum lenght of an host name (needed for the RPCAP active mode) +#define RPCAP_HOSTLIST_SIZE 1024 + + +/*! + \} +*/ // end of public documentation + + +// Exported functions + + + +/** \name New WinPcap functions + + This section lists the new functions that are able to help considerably in writing + WinPcap programs because of their easiness of use. + */ +//\{ +pcap_t *pcap_open(const char *source, int snaplen, int flags, int read_timeout, struct pcap_rmtauth *auth, char *errbuf); +int pcap_createsrcstr(char *source, int type, const char *host, const char *port, const char *name, char *errbuf); +int pcap_parsesrcstr(const char *source, int *type, char *host, char *port, char *name, char *errbuf); +int pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf); +struct pcap_samp *pcap_setsampling(pcap_t *p); + +//\} +// End of new winpcap functions + + + +/** \name Remote Capture functions + */ +//\{ +SOCKET pcap_remoteact_accept(const char *address, const char *port, const char *hostlist, char *connectinghost, struct pcap_rmtauth *auth, char *errbuf); +int pcap_remoteact_list(char *hostlist, char sep, int size, char *errbuf); +int pcap_remoteact_close(const char *host, char *errbuf); +void pcap_remoteact_cleanup(); +//\} +// End of remote capture functions + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/desmume/src/windows/winpcap/tcp_session.h b/src/windows/winpcap/tcp_session.h similarity index 96% rename from desmume/src/windows/winpcap/tcp_session.h rename to src/windows/winpcap/tcp_session.h index 73d6bc357..c7fb69a6b 100644 --- a/desmume/src/windows/winpcap/tcp_session.h +++ b/src/windows/winpcap/tcp_session.h @@ -1,96 +1,96 @@ -/* - * Copyright (c) 2001 - 2003 - * NetGroup, Politecnico di Torino (Italy) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Politecnico di Torino nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __tcp_session -#define __tcp_session - -#ifdef WIN32 -#include "tme.h" -#endif - -#ifdef __FreeBSD__ - -#ifdef _KERNEL -#include -#else -#include -#endif - -#endif - -#define UNKNOWN 0 -#define SYN_RCV 1 -#define SYN_ACK_RCV 2 -#define ESTABLISHED 3 -#define CLOSED_RST 4 -#define FIN_CLN_RCV 5 -#define FIN_SRV_RCV 6 -#define CLOSED_FIN 7 -#define ERROR_TCP 8 -#define FIRST_IS_CLN 0 -#define FIRST_IS_SRV 0xffffffff -#define FIN_CLN 1 -#define FIN_SRV 2 - -#define MAX_WINDOW 65536 - -typedef struct __tcp_data -{ - struct timeval timestamp_block; /*DO NOT MOVE THIS VALUE*/ - struct timeval syn_timestamp; - struct timeval last_timestamp; - struct timeval syn_ack_timestamp; - uint32 direction; - uint32 seq_n_0_srv; - uint32 seq_n_0_cln; - uint32 ack_srv; /* acknowledge of (data sent by server) */ - uint32 ack_cln; /* acknowledge of (data sent by client) */ - uint32 status; - uint32 pkts_cln_to_srv; - uint32 pkts_srv_to_cln; - uint32 bytes_srv_to_cln; - uint32 bytes_cln_to_srv; - uint32 close_state; -} - tcp_data; - -#define FIN 1 -#define SYN 2 -#define RST 4 -#define PSH 8 -#define ACK 16 -#define URG 32 - -#define TCP_SESSION 0x00000800 -uint32 tcp_session(uint8 *block, uint32 pkt_size, TME_DATA *data, MEM_TYPE *mem_ex, uint8 *mem_data); - +/* + * Copyright (c) 2001 - 2003 + * NetGroup, Politecnico di Torino (Italy) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __tcp_session +#define __tcp_session + +#ifdef WIN32 +#include "tme.h" +#endif + +#ifdef __FreeBSD__ + +#ifdef _KERNEL +#include +#else +#include +#endif + +#endif + +#define UNKNOWN 0 +#define SYN_RCV 1 +#define SYN_ACK_RCV 2 +#define ESTABLISHED 3 +#define CLOSED_RST 4 +#define FIN_CLN_RCV 5 +#define FIN_SRV_RCV 6 +#define CLOSED_FIN 7 +#define ERROR_TCP 8 +#define FIRST_IS_CLN 0 +#define FIRST_IS_SRV 0xffffffff +#define FIN_CLN 1 +#define FIN_SRV 2 + +#define MAX_WINDOW 65536 + +typedef struct __tcp_data +{ + struct timeval timestamp_block; /*DO NOT MOVE THIS VALUE*/ + struct timeval syn_timestamp; + struct timeval last_timestamp; + struct timeval syn_ack_timestamp; + uint32 direction; + uint32 seq_n_0_srv; + uint32 seq_n_0_cln; + uint32 ack_srv; /* acknowledge of (data sent by server) */ + uint32 ack_cln; /* acknowledge of (data sent by client) */ + uint32 status; + uint32 pkts_cln_to_srv; + uint32 pkts_srv_to_cln; + uint32 bytes_srv_to_cln; + uint32 bytes_cln_to_srv; + uint32 close_state; +} + tcp_data; + +#define FIN 1 +#define SYN 2 +#define RST 4 +#define PSH 8 +#define ACK 16 +#define URG 32 + +#define TCP_SESSION 0x00000800 +uint32 tcp_session(uint8 *block, uint32 pkt_size, TME_DATA *data, MEM_TYPE *mem_ex, uint8 *mem_data); + #endif \ No newline at end of file diff --git a/desmume/src/windows/winpcap/time_calls.h b/src/windows/winpcap/time_calls.h similarity index 96% rename from desmume/src/windows/winpcap/time_calls.h rename to src/windows/winpcap/time_calls.h index 11aab8529..09a6d6959 100644 --- a/desmume/src/windows/winpcap/time_calls.h +++ b/src/windows/winpcap/time_calls.h @@ -1,485 +1,485 @@ -/* - * Copyright (c) 2001 - 2005 NetGroup, Politecnico di Torino (Italy) - * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Politecnico di Torino, CACE Technologies - * nor the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef _time_calls -#define _time_calls - -#ifdef WIN_NT_DRIVER - -#include "debug.h" -#include "ndis.h" - -#define DEFAULT_TIMESTAMPMODE 0 - -#define TIMESTAMPMODE_SINGLE_SYNCHRONIZATION 0 -#define TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_WITH_FIXUP 1 -#define TIMESTAMPMODE_QUERYSYSTEMTIME 2 -#define TIMESTAMPMODE_RDTSC 3 - -#define TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_NO_FIXUP 99 - -#define TIMESTAMPMODE_REGKEY L"TimestampMode" - -extern ULONG TimestampMode; - -/*! - \brief A microsecond precise timestamp. - - included in the sf_pkthdr or the bpf_hdr that NPF associates with every packet. -*/ - -struct timeval { - long tv_sec; ///< seconds - long tv_usec; ///< microseconds -}; - -#endif /*WIN_NT_DRIVER*/ - -struct time_conv -{ - ULONGLONG reference; - struct timeval start[32]; -}; - -#ifdef WIN_NT_DRIVER - -__inline void TIME_DESYNCHRONIZE(struct time_conv *data) -{ - data->reference = 0; -// data->start.tv_sec = 0; -// data->start.tv_usec = 0; -} - - -__inline void ReadTimeStampModeFromRegistry(PUNICODE_STRING RegistryPath) -{ - ULONG NewLength; - PWSTR NullTerminatedString; - RTL_QUERY_REGISTRY_TABLE Queries[2]; - ULONG DefaultTimestampMode = DEFAULT_TIMESTAMPMODE; - - NewLength = RegistryPath->Length/2; - - NullTerminatedString = ExAllocatePoolWithTag(PagedPool, (NewLength+1) *sizeof(WCHAR), '2TWA'); - - if (NullTerminatedString != NULL) - { - RtlCopyMemory(NullTerminatedString, RegistryPath->Buffer, RegistryPath->Length); - - NullTerminatedString[NewLength]=0; - - RtlZeroMemory(Queries, sizeof(Queries)); - - Queries[0].Flags = RTL_QUERY_REGISTRY_DIRECT; - Queries[0].Name = TIMESTAMPMODE_REGKEY; - Queries[0].EntryContext = &TimestampMode; - Queries[0].DefaultType = REG_DWORD; - Queries[0].DefaultData = &DefaultTimestampMode; - Queries[0].DefaultLength = sizeof(ULONG); - - if(RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, NullTerminatedString, Queries, NULL, NULL) != STATUS_SUCCESS) - { - TimestampMode = DEFAULT_TIMESTAMPMODE; - } - - RtlWriteRegistryValue( RTL_REGISTRY_ABSOLUTE, NullTerminatedString, TIMESTAMPMODE_REGKEY, REG_DWORD, &TimestampMode,sizeof(ULONG)); - ExFreePool(NullTerminatedString); - } - else - TimestampMode = DEFAULT_TIMESTAMPMODE; -} - -#pragma optimize ("g",off) //Due to some weird behaviour of the optimizer of DDK build 2600 - -/* KeQueryPerformanceCounter TimeStamps */ -__inline void SynchronizeOnCpu(struct timeval *start) -{ -// struct timeval *start = (struct timeval*)Data; - - struct timeval tmp; - LARGE_INTEGER SystemTime; - LARGE_INTEGER i; - ULONG tmp2; - LARGE_INTEGER TimeFreq,PTime; - - // get the absolute value of the system boot time. - - PTime = KeQueryPerformanceCounter(&TimeFreq); - KeQuerySystemTime(&SystemTime); - - start->tv_sec = (LONG)(SystemTime.QuadPart/10000000-11644473600); - - start->tv_usec = (LONG)((SystemTime.QuadPart%10000000)/10); - - start->tv_sec -= (ULONG)(PTime.QuadPart/TimeFreq.QuadPart); - - start->tv_usec -= (LONG)((PTime.QuadPart%TimeFreq.QuadPart)*1000000/TimeFreq.QuadPart); - - if (start->tv_usec < 0) - { - start->tv_sec --; - start->tv_usec += 1000000; - } -} - -// -// inline assembler is not supported with the current AMD64 compilers -// At the moment we simply disable this timestamping mode on AMD64. -// A solution would be to allocate a small memory from the non-paged -// pool, dump the instructions on that buffer, and then execute them. -// The non paged pool is needed since it's the only area of kernel -// data memory that is not subject to the NX protection. -// Or use some lower level trick, like using an assembler to assemble -// a small function for this. -// - -#ifdef _X86_ -/*RDTSC timestamps */ -/* callers must be at IRQL=PASSIVE_LEVEL*/ -__inline VOID TimeSynchronizeRDTSC(struct time_conv *data) -{ - struct timeval tmp; - LARGE_INTEGER system_time; - ULONGLONG curr_ticks; - KIRQL old; - LARGE_INTEGER start_kqpc,stop_kqpc,start_freq,stop_freq; - ULONGLONG start_ticks,stop_ticks; - ULONGLONG delta,delta2; - KEVENT event; - LARGE_INTEGER i; - ULONGLONG reference; - - if (data->reference!=0) - return; - - KeInitializeEvent(&event,NotificationEvent,FALSE); - - i.QuadPart=-3500000; - - KeRaiseIrql(HIGH_LEVEL,&old); - start_kqpc=KeQueryPerformanceCounter(&start_freq); - __asm - { - push eax - push edx - push ecx - rdtsc - lea ecx, start_ticks - mov [ecx+4], edx - mov [ecx], eax - pop ecx - pop edx - pop eax - } - - KeLowerIrql(old); - - KeWaitForSingleObject(&event,UserRequest,KernelMode,TRUE ,&i); - - KeRaiseIrql(HIGH_LEVEL,&old); - stop_kqpc=KeQueryPerformanceCounter(&stop_freq); - __asm - { - push eax - push edx - push ecx - rdtsc - lea ecx, stop_ticks - mov [ecx+4], edx - mov [ecx], eax - pop ecx - pop edx - pop eax - } - KeLowerIrql(old); - - delta=stop_ticks-start_ticks; - delta2=stop_kqpc.QuadPart-start_kqpc.QuadPart; - if (delta>10000000000) - { - delta/=16; - delta2/=16; - } - - reference=delta*(start_freq.QuadPart)/delta2; - - data->reference=reference/1000; - - if (reference%1000>500) - data->reference++; - - data->reference*=1000; - - reference=data->reference; - - KeQuerySystemTime(&system_time); - - __asm - { - push eax - push edx - push ecx - rdtsc - lea ecx, curr_ticks - mov [ecx+4], edx - mov [ecx], eax - pop ecx - pop edx - pop eax - } - - tmp.tv_sec=-(LONG)(curr_ticks/reference); - - tmp.tv_usec=-(LONG)((curr_ticks%reference)*1000000/reference); - - system_time.QuadPart-=116444736000000000; - - tmp.tv_sec+=(LONG)(system_time.QuadPart/10000000); - tmp.tv_usec+=(LONG)((system_time.QuadPart%10000000)/10); - - if (tmp.tv_usec<0) - { - tmp.tv_sec--; - tmp.tv_usec+=1000000; - } - - data->start[0] = tmp; - - IF_LOUD(DbgPrint("Frequency %I64u MHz\n",data->reference);) -} -#endif //_X86_ - -#pragma optimize ("g",on) //Due to some weird behaviour of the optimizer of DDK build 2600 - -__inline VOID TIME_SYNCHRONIZE(struct time_conv *data) -{ - ULONG NumberOfCpus, i; - KAFFINITY AffinityMask; - - if (data->reference != 0) - return; - - NumberOfCpus = NdisSystemProcessorCount(); - - if ( TimestampMode == TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_WITH_FIXUP || TimestampMode == TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_NO_FIXUP) - { - for (i = 0 ; i < NumberOfCpus ; i++ ) - { - AffinityMask = (1 << i); - ZwSetInformationThread(NtCurrentThread(), ThreadAffinityMask, &AffinityMask, sizeof(KAFFINITY)); - SynchronizeOnCpu(&(data->start[i])); - } - AffinityMask = 0xFFFFFFFF; - ZwSetInformationThread(NtCurrentThread(), ThreadAffinityMask, &AffinityMask, sizeof(KAFFINITY)); - data->reference = 1; - } - else - if ( TimestampMode == TIMESTAMPMODE_QUERYSYSTEMTIME ) - { - //do nothing - data->reference = 1; - } - else -// -// This timestamp mode is supported on x86 (32 bit) only -// -#ifdef _X86_ - if ( TimestampMode == TIMESTAMPMODE_RDTSC ) - { - TimeSynchronizeRDTSC(data); - } - else -#endif // _X86_ - { //it should be only the normal case i.e. TIMESTAMPMODE_SINGLESYNCHRONIZATION - SynchronizeOnCpu(data->start); - data->reference = 1; - } - return; -} - - -#pragma optimize ("g",off) //Due to some weird behaviour of the optimizer of DDK build 2600 - -__inline void GetTimeKQPC(struct timeval *dst, struct time_conv *data) -{ - LARGE_INTEGER PTime, TimeFreq; - LONG tmp; - ULONG CurrentCpu; - static struct timeval old_ts={0,0}; - - - PTime = KeQueryPerformanceCounter(&TimeFreq); - tmp = (LONG)(PTime.QuadPart/TimeFreq.QuadPart); - - if (TimestampMode == TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_WITH_FIXUP || TimestampMode == TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_NO_FIXUP) - { - //actually this code is ok only if we are guaranteed that no thread scheduling will take place. - CurrentCpu = KeGetCurrentProcessorNumber(); - - dst->tv_sec = data->start[CurrentCpu].tv_sec + tmp; - dst->tv_usec = data->start[CurrentCpu].tv_usec + (LONG)((PTime.QuadPart%TimeFreq.QuadPart)*1000000/TimeFreq.QuadPart); - - if (dst->tv_usec >= 1000000) - { - dst->tv_sec ++; - dst->tv_usec -= 1000000; - } - - if (TimestampMode == TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_WITH_FIXUP) - { - if (old_ts.tv_sec > dst->tv_sec || (old_ts.tv_sec == dst->tv_sec && old_ts.tv_usec > dst->tv_usec) ) - *dst = old_ts; - - else - old_ts = *dst; - } - } - else - { //it should be only the normal case i.e. TIMESTAMPMODE_SINGLESYNCHRONIZATION - dst->tv_sec = data->start[0].tv_sec + tmp; - dst->tv_usec = data->start[0].tv_usec + (LONG)((PTime.QuadPart%TimeFreq.QuadPart)*1000000/TimeFreq.QuadPart); - - if (dst->tv_usec >= 1000000) - { - dst->tv_sec ++; - dst->tv_usec -= 1000000; - } - } -} - -// -// inline assembler is not supported with the current AMD64 compilers -// At the moment we simply disable this timestamping mode on AMD64. -// A solution would be to allocate a small memory from the non-paged -// pool, dump the instructions on that buffer, and then execute them. -// The non paged pool is needed since it's the only area of kernel -// data memory that is not subject to the NX protection. -// Or use some lower level trick, like using an assembler to assemble -// a small function for this. -// - -#ifdef _X86_ -__inline void GetTimeRDTSC(struct timeval *dst, struct time_conv *data) -{ - - ULONGLONG tmp = 0; - __asm - { - push eax - push edx - push ecx - rdtsc - lea ecx, tmp - mov [ecx+4], edx - mov [ecx], eax - pop ecx - pop edx - pop eax - } - - if (data->reference==0) - { - return; - } - dst->tv_sec=(LONG)(tmp/data->reference); - - dst->tv_usec=(LONG)((tmp-dst->tv_sec*data->reference)*1000000/data->reference); - - dst->tv_sec+=data->start[0].tv_sec; - - dst->tv_usec+=data->start[0].tv_usec; - - if (dst->tv_usec>=1000000) - { - dst->tv_sec++; - dst->tv_usec-=1000000; - } - - -} -#endif //_X86_ - -__inline void GetTimeQST(struct timeval *dst, struct time_conv *data) -{ - LARGE_INTEGER SystemTime; - - KeQuerySystemTime(&SystemTime); - - dst->tv_sec = (LONG)(SystemTime.QuadPart/10000000-11644473600); - dst->tv_usec = (LONG)((SystemTime.QuadPart%10000000)/10); - -} - -#pragma optimize ("g",on) //Due to some weird behaviour of the optimizer of DDK build 2600 - - -__inline void GET_TIME(struct timeval *dst, struct time_conv *data) -{ - -// -// This timestamp mode is supported on x86 (32 bit) only -// -#ifdef _X86_ - if ( TimestampMode == TIMESTAMPMODE_RDTSC ) - { - GetTimeRDTSC(dst,data); - } - else -#endif // _X86_ - if ( TimestampMode == TIMESTAMPMODE_QUERYSYSTEMTIME ) - { - GetTimeQST(dst,data); - } - else - { - GetTimeKQPC(dst,data); - } -} - - -#else /*WIN_NT_DRIVER*/ - -__inline void FORCE_TIME(struct timeval *src, struct time_conv *dest) -{ - dest->start[0]=*src; -} - -__inline void GET_TIME(struct timeval *dst, struct time_conv *data) -{ - *dst=data->start[0]; -} - -#endif /*WIN_NT_DRIVER*/ - - -#endif /*_time_calls*/ +/* + * Copyright (c) 2001 - 2005 NetGroup, Politecnico di Torino (Italy) + * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino, CACE Technologies + * nor the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef _time_calls +#define _time_calls + +#ifdef WIN_NT_DRIVER + +#include "debug.h" +#include "ndis.h" + +#define DEFAULT_TIMESTAMPMODE 0 + +#define TIMESTAMPMODE_SINGLE_SYNCHRONIZATION 0 +#define TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_WITH_FIXUP 1 +#define TIMESTAMPMODE_QUERYSYSTEMTIME 2 +#define TIMESTAMPMODE_RDTSC 3 + +#define TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_NO_FIXUP 99 + +#define TIMESTAMPMODE_REGKEY L"TimestampMode" + +extern ULONG TimestampMode; + +/*! + \brief A microsecond precise timestamp. + + included in the sf_pkthdr or the bpf_hdr that NPF associates with every packet. +*/ + +struct timeval { + long tv_sec; ///< seconds + long tv_usec; ///< microseconds +}; + +#endif /*WIN_NT_DRIVER*/ + +struct time_conv +{ + ULONGLONG reference; + struct timeval start[32]; +}; + +#ifdef WIN_NT_DRIVER + +__inline void TIME_DESYNCHRONIZE(struct time_conv *data) +{ + data->reference = 0; +// data->start.tv_sec = 0; +// data->start.tv_usec = 0; +} + + +__inline void ReadTimeStampModeFromRegistry(PUNICODE_STRING RegistryPath) +{ + ULONG NewLength; + PWSTR NullTerminatedString; + RTL_QUERY_REGISTRY_TABLE Queries[2]; + ULONG DefaultTimestampMode = DEFAULT_TIMESTAMPMODE; + + NewLength = RegistryPath->Length/2; + + NullTerminatedString = ExAllocatePoolWithTag(PagedPool, (NewLength+1) *sizeof(WCHAR), '2TWA'); + + if (NullTerminatedString != NULL) + { + RtlCopyMemory(NullTerminatedString, RegistryPath->Buffer, RegistryPath->Length); + + NullTerminatedString[NewLength]=0; + + RtlZeroMemory(Queries, sizeof(Queries)); + + Queries[0].Flags = RTL_QUERY_REGISTRY_DIRECT; + Queries[0].Name = TIMESTAMPMODE_REGKEY; + Queries[0].EntryContext = &TimestampMode; + Queries[0].DefaultType = REG_DWORD; + Queries[0].DefaultData = &DefaultTimestampMode; + Queries[0].DefaultLength = sizeof(ULONG); + + if(RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, NullTerminatedString, Queries, NULL, NULL) != STATUS_SUCCESS) + { + TimestampMode = DEFAULT_TIMESTAMPMODE; + } + + RtlWriteRegistryValue( RTL_REGISTRY_ABSOLUTE, NullTerminatedString, TIMESTAMPMODE_REGKEY, REG_DWORD, &TimestampMode,sizeof(ULONG)); + ExFreePool(NullTerminatedString); + } + else + TimestampMode = DEFAULT_TIMESTAMPMODE; +} + +#pragma optimize ("g",off) //Due to some weird behaviour of the optimizer of DDK build 2600 + +/* KeQueryPerformanceCounter TimeStamps */ +__inline void SynchronizeOnCpu(struct timeval *start) +{ +// struct timeval *start = (struct timeval*)Data; + + struct timeval tmp; + LARGE_INTEGER SystemTime; + LARGE_INTEGER i; + ULONG tmp2; + LARGE_INTEGER TimeFreq,PTime; + + // get the absolute value of the system boot time. + + PTime = KeQueryPerformanceCounter(&TimeFreq); + KeQuerySystemTime(&SystemTime); + + start->tv_sec = (LONG)(SystemTime.QuadPart/10000000-11644473600); + + start->tv_usec = (LONG)((SystemTime.QuadPart%10000000)/10); + + start->tv_sec -= (ULONG)(PTime.QuadPart/TimeFreq.QuadPart); + + start->tv_usec -= (LONG)((PTime.QuadPart%TimeFreq.QuadPart)*1000000/TimeFreq.QuadPart); + + if (start->tv_usec < 0) + { + start->tv_sec --; + start->tv_usec += 1000000; + } +} + +// +// inline assembler is not supported with the current AMD64 compilers +// At the moment we simply disable this timestamping mode on AMD64. +// A solution would be to allocate a small memory from the non-paged +// pool, dump the instructions on that buffer, and then execute them. +// The non paged pool is needed since it's the only area of kernel +// data memory that is not subject to the NX protection. +// Or use some lower level trick, like using an assembler to assemble +// a small function for this. +// + +#ifdef _X86_ +/*RDTSC timestamps */ +/* callers must be at IRQL=PASSIVE_LEVEL*/ +__inline VOID TimeSynchronizeRDTSC(struct time_conv *data) +{ + struct timeval tmp; + LARGE_INTEGER system_time; + ULONGLONG curr_ticks; + KIRQL old; + LARGE_INTEGER start_kqpc,stop_kqpc,start_freq,stop_freq; + ULONGLONG start_ticks,stop_ticks; + ULONGLONG delta,delta2; + KEVENT event; + LARGE_INTEGER i; + ULONGLONG reference; + + if (data->reference!=0) + return; + + KeInitializeEvent(&event,NotificationEvent,FALSE); + + i.QuadPart=-3500000; + + KeRaiseIrql(HIGH_LEVEL,&old); + start_kqpc=KeQueryPerformanceCounter(&start_freq); + __asm + { + push eax + push edx + push ecx + rdtsc + lea ecx, start_ticks + mov [ecx+4], edx + mov [ecx], eax + pop ecx + pop edx + pop eax + } + + KeLowerIrql(old); + + KeWaitForSingleObject(&event,UserRequest,KernelMode,TRUE ,&i); + + KeRaiseIrql(HIGH_LEVEL,&old); + stop_kqpc=KeQueryPerformanceCounter(&stop_freq); + __asm + { + push eax + push edx + push ecx + rdtsc + lea ecx, stop_ticks + mov [ecx+4], edx + mov [ecx], eax + pop ecx + pop edx + pop eax + } + KeLowerIrql(old); + + delta=stop_ticks-start_ticks; + delta2=stop_kqpc.QuadPart-start_kqpc.QuadPart; + if (delta>10000000000) + { + delta/=16; + delta2/=16; + } + + reference=delta*(start_freq.QuadPart)/delta2; + + data->reference=reference/1000; + + if (reference%1000>500) + data->reference++; + + data->reference*=1000; + + reference=data->reference; + + KeQuerySystemTime(&system_time); + + __asm + { + push eax + push edx + push ecx + rdtsc + lea ecx, curr_ticks + mov [ecx+4], edx + mov [ecx], eax + pop ecx + pop edx + pop eax + } + + tmp.tv_sec=-(LONG)(curr_ticks/reference); + + tmp.tv_usec=-(LONG)((curr_ticks%reference)*1000000/reference); + + system_time.QuadPart-=116444736000000000; + + tmp.tv_sec+=(LONG)(system_time.QuadPart/10000000); + tmp.tv_usec+=(LONG)((system_time.QuadPart%10000000)/10); + + if (tmp.tv_usec<0) + { + tmp.tv_sec--; + tmp.tv_usec+=1000000; + } + + data->start[0] = tmp; + + IF_LOUD(DbgPrint("Frequency %I64u MHz\n",data->reference);) +} +#endif //_X86_ + +#pragma optimize ("g",on) //Due to some weird behaviour of the optimizer of DDK build 2600 + +__inline VOID TIME_SYNCHRONIZE(struct time_conv *data) +{ + ULONG NumberOfCpus, i; + KAFFINITY AffinityMask; + + if (data->reference != 0) + return; + + NumberOfCpus = NdisSystemProcessorCount(); + + if ( TimestampMode == TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_WITH_FIXUP || TimestampMode == TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_NO_FIXUP) + { + for (i = 0 ; i < NumberOfCpus ; i++ ) + { + AffinityMask = (1 << i); + ZwSetInformationThread(NtCurrentThread(), ThreadAffinityMask, &AffinityMask, sizeof(KAFFINITY)); + SynchronizeOnCpu(&(data->start[i])); + } + AffinityMask = 0xFFFFFFFF; + ZwSetInformationThread(NtCurrentThread(), ThreadAffinityMask, &AffinityMask, sizeof(KAFFINITY)); + data->reference = 1; + } + else + if ( TimestampMode == TIMESTAMPMODE_QUERYSYSTEMTIME ) + { + //do nothing + data->reference = 1; + } + else +// +// This timestamp mode is supported on x86 (32 bit) only +// +#ifdef _X86_ + if ( TimestampMode == TIMESTAMPMODE_RDTSC ) + { + TimeSynchronizeRDTSC(data); + } + else +#endif // _X86_ + { //it should be only the normal case i.e. TIMESTAMPMODE_SINGLESYNCHRONIZATION + SynchronizeOnCpu(data->start); + data->reference = 1; + } + return; +} + + +#pragma optimize ("g",off) //Due to some weird behaviour of the optimizer of DDK build 2600 + +__inline void GetTimeKQPC(struct timeval *dst, struct time_conv *data) +{ + LARGE_INTEGER PTime, TimeFreq; + LONG tmp; + ULONG CurrentCpu; + static struct timeval old_ts={0,0}; + + + PTime = KeQueryPerformanceCounter(&TimeFreq); + tmp = (LONG)(PTime.QuadPart/TimeFreq.QuadPart); + + if (TimestampMode == TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_WITH_FIXUP || TimestampMode == TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_NO_FIXUP) + { + //actually this code is ok only if we are guaranteed that no thread scheduling will take place. + CurrentCpu = KeGetCurrentProcessorNumber(); + + dst->tv_sec = data->start[CurrentCpu].tv_sec + tmp; + dst->tv_usec = data->start[CurrentCpu].tv_usec + (LONG)((PTime.QuadPart%TimeFreq.QuadPart)*1000000/TimeFreq.QuadPart); + + if (dst->tv_usec >= 1000000) + { + dst->tv_sec ++; + dst->tv_usec -= 1000000; + } + + if (TimestampMode == TIMESTAMPMODE_SYNCHRONIZATION_ON_CPU_WITH_FIXUP) + { + if (old_ts.tv_sec > dst->tv_sec || (old_ts.tv_sec == dst->tv_sec && old_ts.tv_usec > dst->tv_usec) ) + *dst = old_ts; + + else + old_ts = *dst; + } + } + else + { //it should be only the normal case i.e. TIMESTAMPMODE_SINGLESYNCHRONIZATION + dst->tv_sec = data->start[0].tv_sec + tmp; + dst->tv_usec = data->start[0].tv_usec + (LONG)((PTime.QuadPart%TimeFreq.QuadPart)*1000000/TimeFreq.QuadPart); + + if (dst->tv_usec >= 1000000) + { + dst->tv_sec ++; + dst->tv_usec -= 1000000; + } + } +} + +// +// inline assembler is not supported with the current AMD64 compilers +// At the moment we simply disable this timestamping mode on AMD64. +// A solution would be to allocate a small memory from the non-paged +// pool, dump the instructions on that buffer, and then execute them. +// The non paged pool is needed since it's the only area of kernel +// data memory that is not subject to the NX protection. +// Or use some lower level trick, like using an assembler to assemble +// a small function for this. +// + +#ifdef _X86_ +__inline void GetTimeRDTSC(struct timeval *dst, struct time_conv *data) +{ + + ULONGLONG tmp = 0; + __asm + { + push eax + push edx + push ecx + rdtsc + lea ecx, tmp + mov [ecx+4], edx + mov [ecx], eax + pop ecx + pop edx + pop eax + } + + if (data->reference==0) + { + return; + } + dst->tv_sec=(LONG)(tmp/data->reference); + + dst->tv_usec=(LONG)((tmp-dst->tv_sec*data->reference)*1000000/data->reference); + + dst->tv_sec+=data->start[0].tv_sec; + + dst->tv_usec+=data->start[0].tv_usec; + + if (dst->tv_usec>=1000000) + { + dst->tv_sec++; + dst->tv_usec-=1000000; + } + + +} +#endif //_X86_ + +__inline void GetTimeQST(struct timeval *dst, struct time_conv *data) +{ + LARGE_INTEGER SystemTime; + + KeQuerySystemTime(&SystemTime); + + dst->tv_sec = (LONG)(SystemTime.QuadPart/10000000-11644473600); + dst->tv_usec = (LONG)((SystemTime.QuadPart%10000000)/10); + +} + +#pragma optimize ("g",on) //Due to some weird behaviour of the optimizer of DDK build 2600 + + +__inline void GET_TIME(struct timeval *dst, struct time_conv *data) +{ + +// +// This timestamp mode is supported on x86 (32 bit) only +// +#ifdef _X86_ + if ( TimestampMode == TIMESTAMPMODE_RDTSC ) + { + GetTimeRDTSC(dst,data); + } + else +#endif // _X86_ + if ( TimestampMode == TIMESTAMPMODE_QUERYSYSTEMTIME ) + { + GetTimeQST(dst,data); + } + else + { + GetTimeKQPC(dst,data); + } +} + + +#else /*WIN_NT_DRIVER*/ + +__inline void FORCE_TIME(struct timeval *src, struct time_conv *dest) +{ + dest->start[0]=*src; +} + +__inline void GET_TIME(struct timeval *dst, struct time_conv *data) +{ + *dst=data->start[0]; +} + +#endif /*WIN_NT_DRIVER*/ + + +#endif /*_time_calls*/ diff --git a/desmume/src/windows/winpcap/tme.h b/src/windows/winpcap/tme.h similarity index 97% rename from desmume/src/windows/winpcap/tme.h rename to src/windows/winpcap/tme.h index 41e46326b..446903c5d 100644 --- a/desmume/src/windows/winpcap/tme.h +++ b/src/windows/winpcap/tme.h @@ -1,176 +1,176 @@ -/* - * Copyright (c) 2001 - 2003 - * NetGroup, Politecnico di Torino (Italy) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Politecnico di Torino nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __tme_include_ -#define __tme_include_ - -#ifdef WIN_NT_DRIVER -#include "ndis.h" -#else -#include -#endif /*WIN_NT_DRIVER*/ - -#include "memory_t.h" -#include "time_calls.h" - - -/* error codes */ -#define TME_ERROR 0 -#define TME_SUCCESS 1 -#define TME_TRUE 2 -#define TME_FALSE 3 - -/* some constants */ -#define DEFAULT_MEM_EX_SIZE 65536 -#define MAX_TME_DATA_BLOCKS 4 -#define TME_NONE_ACTIVE 0xffffffff -#define DELTA_READ 2 /* secs */ - -#define TME_LUT_ENTRIES 0x00000000 -#define TME_MAX_FILL_STATE 0x00000001 /*potrebbe servire per un thread a passive level!?!?! */ -#define TME_REHASHING_VALUE 0x00000002 -#define TME_KEY_LEN 0x00000003 -#define TME_SHARED_MEMORY_BLOCKS 0x00000004 -#define TME_FILLED_ENTRIES 0x00000005 -#define TME_BLOCK_SIZE 0x00000006 -#define TME_EXTRA_SEGMENT_SIZE 0x00000007 -#define TME_LOOKUP_CODE 0x00000008 -#define TME_OUT_LUT_EXEC 0x00000009 -#define TME_FILLED_BLOCKS 0x0000000a -#define TME_DEFAULT_EXEC 0x0000000b -#define TME_LUT_BASE_ADDRESS 0x0000000c -#define TME_SHARED_MEMORY_BASE_ADDRESS 0x0000000d -#define TME_EXTRA_SEGMENT_BASE_ADDRESS 0x0000000e -#define TME_LAST_FOUND 0x0000000f /* contains the offset of the last found entry */ -#define TME_LAST_FOUND_BLOCK 0x00000010 -/* TME default values */ -#define TME_LUT_ENTRIES_DEFAULT 32007 -#define TME_REHASHING_VALUE_DEFAULT 1 -#define TME_SHARED_MEMORY_BLOCKS_DEFAULT 16000 -#define TME_BLOCK_SIZE_DEFAULT 64 -#define TME_EXTRA_SEGMENT_SIZE_DEFAULT 0 -#define TME_LOOKUP_CODE_DEFAULT 0 -#define TME_OUT_LUT_EXEC_DEFAULT 0 -#define TME_DEFAULT_EXEC_DEFAULT 0 -#define TME_MAX_FILL_STATE_DEFAULT 15000 - -#define IS_VALIDATED(src,index) (src&(1<tv_sec=0x7fffffff; - -struct __TME_DATA; - -/* TME callback prototypes */ -typedef uint32 (*lut_fcn)(uint8 *key, struct __TME_DATA *data,MEM_TYPE *mem_ex, struct time_conv *time_ref ); -typedef uint32 (*exec_fcn)(uint8 *block, uint32 pkt_size, struct __TME_DATA *data, MEM_TYPE *mem_ex, uint8 *mem_data); - -/* DO NOT MODIFY THIS STRUCTURE!!!! GV */ -typedef struct __RECORD - -{ - uint32 block; - uint32 exec_fcn; -} - RECORD, *PRECORD; - -/* TME data registers */ -struct __TME_DATA -{ - uint32 lut_entries; - uint32 max_fill_state; - uint32 rehashing_value; - uint32 key_len; - uint32 shared_memory_blocks; - uint32 filled_entries; - uint32 block_size; - uint32 extra_segment_size; - uint32 filled_blocks; - lut_fcn lookup_code; - uint32 default_exec; - uint32 out_lut_exec; - uint8 *lut_base_address; - uint8 *shared_memory_base_address; - uint8 *extra_segment_base_address; - struct timeval last_read; - uint32 enable_deletion; - uint8 *last_found; -}; - -typedef struct __TME_DATA TME_DATA,*PTME_DATA; - - - -/* TME core */ -typedef struct __TME_CORE -{ - uint32 working; - uint32 active; - uint32 validated_blocks; - TME_DATA block_data[MAX_TME_DATA_BLOCKS]; - uint32 active_read; - -} TME_CORE, *PTME_CORE; - -static __inline int32 IS_DELETABLE(void *timestamp, TME_DATA *data) -{ - struct timeval *ts=(struct timeval*)timestamp; - - if (data->enable_deletion==FALSE) - return FALSE; - if (data->filled_entriesmax_fill_state) - return FALSE; - if ((ts->tv_sec+DELTA_READ)last_read.tv_sec) - return TRUE; - return FALSE; -} - -/* functions to manage TME */ -uint32 init_tme_block(TME_CORE *tme, uint32 block); -uint32 validate_tme_block(MEM_TYPE *mem_ex, TME_CORE *tme, uint32 block, uint32 mem_ex_offset); -uint32 lookup_frontend(MEM_TYPE *mem_ex, TME_CORE *tme,uint32 mem_ex_offset, struct time_conv *time_ref); -uint32 execute_frontend(MEM_TYPE *mem_ex, TME_CORE *tme, uint32 pkt_size,uint32 offset); -uint32 set_active_tme_block(TME_CORE *tme, uint32 block); -uint32 init_extended_memory(uint32 size, MEM_TYPE *mem_ex); -uint32 reset_tme(TME_CORE *tme); -uint32 get_tme_block_register(TME_DATA *data,MEM_TYPE *mem_ex,uint32 rgstr,uint32 *rval); -uint32 set_tme_block_register(TME_DATA *data,MEM_TYPE *mem_ex,uint32 rgstr,uint32 value, int32 init); -uint32 set_active_read_tme_block(TME_CORE *tme, uint32 block); -uint32 set_autodeletion(TME_DATA *data, uint32 value); - -/* function mappers */ -lut_fcn lut_fcn_mapper(uint32 index); -exec_fcn exec_fcn_mapper(uint32 index); - +/* + * Copyright (c) 2001 - 2003 + * NetGroup, Politecnico di Torino (Italy) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __tme_include_ +#define __tme_include_ + +#ifdef WIN_NT_DRIVER +#include "ndis.h" +#else +#include +#endif /*WIN_NT_DRIVER*/ + +#include "memory_t.h" +#include "time_calls.h" + + +/* error codes */ +#define TME_ERROR 0 +#define TME_SUCCESS 1 +#define TME_TRUE 2 +#define TME_FALSE 3 + +/* some constants */ +#define DEFAULT_MEM_EX_SIZE 65536 +#define MAX_TME_DATA_BLOCKS 4 +#define TME_NONE_ACTIVE 0xffffffff +#define DELTA_READ 2 /* secs */ + +#define TME_LUT_ENTRIES 0x00000000 +#define TME_MAX_FILL_STATE 0x00000001 /*potrebbe servire per un thread a passive level!?!?! */ +#define TME_REHASHING_VALUE 0x00000002 +#define TME_KEY_LEN 0x00000003 +#define TME_SHARED_MEMORY_BLOCKS 0x00000004 +#define TME_FILLED_ENTRIES 0x00000005 +#define TME_BLOCK_SIZE 0x00000006 +#define TME_EXTRA_SEGMENT_SIZE 0x00000007 +#define TME_LOOKUP_CODE 0x00000008 +#define TME_OUT_LUT_EXEC 0x00000009 +#define TME_FILLED_BLOCKS 0x0000000a +#define TME_DEFAULT_EXEC 0x0000000b +#define TME_LUT_BASE_ADDRESS 0x0000000c +#define TME_SHARED_MEMORY_BASE_ADDRESS 0x0000000d +#define TME_EXTRA_SEGMENT_BASE_ADDRESS 0x0000000e +#define TME_LAST_FOUND 0x0000000f /* contains the offset of the last found entry */ +#define TME_LAST_FOUND_BLOCK 0x00000010 +/* TME default values */ +#define TME_LUT_ENTRIES_DEFAULT 32007 +#define TME_REHASHING_VALUE_DEFAULT 1 +#define TME_SHARED_MEMORY_BLOCKS_DEFAULT 16000 +#define TME_BLOCK_SIZE_DEFAULT 64 +#define TME_EXTRA_SEGMENT_SIZE_DEFAULT 0 +#define TME_LOOKUP_CODE_DEFAULT 0 +#define TME_OUT_LUT_EXEC_DEFAULT 0 +#define TME_DEFAULT_EXEC_DEFAULT 0 +#define TME_MAX_FILL_STATE_DEFAULT 15000 + +#define IS_VALIDATED(src,index) (src&(1<tv_sec=0x7fffffff; + +struct __TME_DATA; + +/* TME callback prototypes */ +typedef uint32 (*lut_fcn)(uint8 *key, struct __TME_DATA *data,MEM_TYPE *mem_ex, struct time_conv *time_ref ); +typedef uint32 (*exec_fcn)(uint8 *block, uint32 pkt_size, struct __TME_DATA *data, MEM_TYPE *mem_ex, uint8 *mem_data); + +/* DO NOT MODIFY THIS STRUCTURE!!!! GV */ +typedef struct __RECORD + +{ + uint32 block; + uint32 exec_fcn; +} + RECORD, *PRECORD; + +/* TME data registers */ +struct __TME_DATA +{ + uint32 lut_entries; + uint32 max_fill_state; + uint32 rehashing_value; + uint32 key_len; + uint32 shared_memory_blocks; + uint32 filled_entries; + uint32 block_size; + uint32 extra_segment_size; + uint32 filled_blocks; + lut_fcn lookup_code; + uint32 default_exec; + uint32 out_lut_exec; + uint8 *lut_base_address; + uint8 *shared_memory_base_address; + uint8 *extra_segment_base_address; + struct timeval last_read; + uint32 enable_deletion; + uint8 *last_found; +}; + +typedef struct __TME_DATA TME_DATA,*PTME_DATA; + + + +/* TME core */ +typedef struct __TME_CORE +{ + uint32 working; + uint32 active; + uint32 validated_blocks; + TME_DATA block_data[MAX_TME_DATA_BLOCKS]; + uint32 active_read; + +} TME_CORE, *PTME_CORE; + +static __inline int32 IS_DELETABLE(void *timestamp, TME_DATA *data) +{ + struct timeval *ts=(struct timeval*)timestamp; + + if (data->enable_deletion==FALSE) + return FALSE; + if (data->filled_entriesmax_fill_state) + return FALSE; + if ((ts->tv_sec+DELTA_READ)last_read.tv_sec) + return TRUE; + return FALSE; +} + +/* functions to manage TME */ +uint32 init_tme_block(TME_CORE *tme, uint32 block); +uint32 validate_tme_block(MEM_TYPE *mem_ex, TME_CORE *tme, uint32 block, uint32 mem_ex_offset); +uint32 lookup_frontend(MEM_TYPE *mem_ex, TME_CORE *tme,uint32 mem_ex_offset, struct time_conv *time_ref); +uint32 execute_frontend(MEM_TYPE *mem_ex, TME_CORE *tme, uint32 pkt_size,uint32 offset); +uint32 set_active_tme_block(TME_CORE *tme, uint32 block); +uint32 init_extended_memory(uint32 size, MEM_TYPE *mem_ex); +uint32 reset_tme(TME_CORE *tme); +uint32 get_tme_block_register(TME_DATA *data,MEM_TYPE *mem_ex,uint32 rgstr,uint32 *rval); +uint32 set_tme_block_register(TME_DATA *data,MEM_TYPE *mem_ex,uint32 rgstr,uint32 value, int32 init); +uint32 set_active_read_tme_block(TME_CORE *tme, uint32 block); +uint32 set_autodeletion(TME_DATA *data, uint32 value); + +/* function mappers */ +lut_fcn lut_fcn_mapper(uint32 index); +exec_fcn exec_fcn_mapper(uint32 index); + #endif \ No newline at end of file diff --git a/desmume/src/windows/winpcap/wpcap.lib b/src/windows/winpcap/wpcap.lib similarity index 100% rename from desmume/src/windows/winpcap/wpcap.lib rename to src/windows/winpcap/wpcap.lib diff --git a/desmume/src/windows/winres.h b/src/windows/winres.h similarity index 100% rename from desmume/src/windows/winres.h rename to src/windows/winres.h diff --git a/desmume/src/windows/zlib123/README b/src/windows/zlib123/README similarity index 100% rename from desmume/src/windows/zlib123/README rename to src/windows/zlib123/README diff --git a/desmume/src/windows/zlib123/zconf.h b/src/windows/zlib123/zconf.h similarity index 96% rename from desmume/src/windows/zlib123/zconf.h rename to src/windows/zlib123/zconf.h index ec69ca940..ff5e7481b 100644 --- a/desmume/src/windows/zlib123/zconf.h +++ b/src/windows/zlib123/zconf.h @@ -1,332 +1,332 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: zconf.h,v 1.1 2008-08-03 18:36:12 mtabachenko Exp $ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - */ -#ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ -# define deflate z_deflate -# define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset -# define deflateParams z_deflateParams -# define deflateBound z_deflateBound -# define deflatePrime z_deflatePrime -# define inflateInit2_ z_inflateInit2_ -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateCopy z_inflateCopy -# define inflateReset z_inflateReset -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# define uncompress z_uncompress -# define adler32 z_adler32 -# define crc32 z_crc32 -# define get_crc_table z_get_crc_table -# define zError z_zError - -# define alloc_func z_alloc_func -# define free_func z_free_func -# define in_func z_in_func -# define out_func z_out_func -# define Byte z_Byte -# define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf -# define uIntf z_uIntf -# define uLongf z_uLongf -# define voidpf z_voidpf -# define voidp z_voidp -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT __cdecl -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ -# include /* for off_t */ -# include /* for SEEK_* and off_t */ -# ifdef VMS -# include /* for off_t */ -# endif -# define z_off_t off_t -#endif -#ifndef SEEK_SET -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif -#ifndef z_off_t -# define z_off_t long -#endif - -#if defined(__OS400__) -# define NO_vsnprintf -#endif - -#if defined(__MVS__) -# define NO_vsnprintf -# ifdef FAR -# undef FAR -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) -# pragma map(deflateInit_,"DEIN") -# pragma map(deflateInit2_,"DEIN2") -# pragma map(deflateEnd,"DEEND") -# pragma map(deflateBound,"DEBND") -# pragma map(inflateInit_,"ININ") -# pragma map(inflateInit2_,"ININ2") -# pragma map(inflateEnd,"INEND") -# pragma map(inflateSync,"INSY") -# pragma map(inflateSetDictionary,"INSEDI") -# pragma map(compressBound,"CMBND") -# pragma map(inflate_table,"INTABL") -# pragma map(inflate_fast,"INFA") -# pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id: zconf.h,v 1.1 2008-08-03 18:36:12 mtabachenko Exp $ */ + +#ifndef ZCONF_H +#define ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define deflateBound z_deflateBound +# define deflatePrime z_deflatePrime +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateCopy z_inflateCopy +# define inflateReset z_inflateReset +# define inflateBack z_inflateBack +# define inflateBackEnd z_inflateBackEnd +# define compress z_compress +# define compress2 z_compress2 +# define compressBound z_compressBound +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table +# define zError z_zError + +# define alloc_func z_alloc_func +# define free_func z_free_func +# define in_func z_in_func +# define out_func z_out_func +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif +#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) +# define OS2 +#endif +#if defined(_WINDOWS) && !defined(WINDOWS) +# define WINDOWS +#endif +#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) +# ifndef WIN32 +# define WIN32 +# endif +#endif +#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) +# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) +# ifndef SYS16BIT +# define SYS16BIT +# endif +# endif +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#ifdef SYS16BIT +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#ifdef __STDC_VERSION__ +# ifndef STDC +# define STDC +# endif +# if __STDC_VERSION__ >= 199901L +# ifndef STDC99 +# define STDC99 +# endif +# endif +#endif +#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) +# define STDC +#endif +#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) +# define STDC +#endif +#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) +# define STDC +#endif +#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) +# define STDC +#endif + +#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ +# define STDC +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const /* note: need a more gentle solution here */ +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#ifdef SYS16BIT +# if defined(M_I86SM) || defined(M_I86MM) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR _far +# else +# define FAR far +# endif +# endif +# if (defined(__SMALL__) || defined(__MEDIUM__)) + /* Turbo C small or medium model */ +# define SMALL_MEDIUM +# ifdef __BORLANDC__ +# define FAR _far +# else +# define FAR far +# endif +# endif +#endif + +#if defined(WINDOWS) || defined(WIN32) + /* If building or using zlib as a DLL, define ZLIB_DLL. + * This is not mandatory, but it offers a little performance increase. + */ +# ifdef ZLIB_DLL +# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) +# ifdef ZLIB_INTERNAL +# define ZEXTERN extern __declspec(dllexport) +# else +# define ZEXTERN extern __declspec(dllimport) +# endif +# endif +# endif /* ZLIB_DLL */ + /* If building or using zlib with the WINAPI/WINAPIV calling convention, + * define ZLIB_WINAPI. + * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. + */ +# ifdef ZLIB_WINAPI +# ifdef FAR +# undef FAR +# endif +# include + /* No need for _export, use ZLIB.DEF instead. */ + /* For complete Windows compatibility, use WINAPI, not __stdcall. */ +# define ZEXPORT WINAPI +# ifdef WIN32 +# define ZEXPORTVA WINAPIV +# else +# define ZEXPORTVA FAR CDECL +# endif +# endif +#endif + +#if defined (__BEOS__) +# ifdef ZLIB_DLL +# ifdef ZLIB_INTERNAL +# define ZEXPORT __declspec(dllexport) +# define ZEXPORTVA __declspec(dllexport) +# else +# define ZEXPORT __declspec(dllimport) +# define ZEXPORTVA __declspec(dllimport) +# endif +# endif +#endif + +#ifndef ZEXTERN +# define ZEXTERN extern +#endif +#ifndef ZEXPORT +# define ZEXPORT __cdecl +#endif +#ifndef ZEXPORTVA +# define ZEXPORTVA +#endif + +#ifndef FAR +# define FAR +#endif + +#if !defined(__MACTYPES__) +typedef unsigned char Byte; /* 8 bits */ +#endif +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#ifdef SMALL_MEDIUM + /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void const *voidpc; + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte const *voidpc; + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# ifdef VMS +# include /* for off_t */ +# endif +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +#if defined(__OS400__) +# define NO_vsnprintf +#endif + +#if defined(__MVS__) +# define NO_vsnprintf +# ifdef FAR +# undef FAR +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(deflateBound,"DEBND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(compressBound,"CMBND") +# pragma map(inflate_table,"INTABL") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_copyright,"INCOPY") +#endif + +#endif /* ZCONF_H */ diff --git a/desmume/src/windows/zlib123/zlib-2005-x32.lib b/src/windows/zlib123/zlib-2005-x32.lib similarity index 100% rename from desmume/src/windows/zlib123/zlib-2005-x32.lib rename to src/windows/zlib123/zlib-2005-x32.lib diff --git a/desmume/src/windows/zlib123/zlib-2005-x64.lib b/src/windows/zlib123/zlib-2005-x64.lib similarity index 100% rename from desmume/src/windows/zlib123/zlib-2005-x64.lib rename to src/windows/zlib123/zlib-2005-x64.lib diff --git a/desmume/src/windows/zlib123/zlib-2008-x32.lib b/src/windows/zlib123/zlib-2008-x32.lib similarity index 100% rename from desmume/src/windows/zlib123/zlib-2008-x32.lib rename to src/windows/zlib123/zlib-2008-x32.lib diff --git a/desmume/src/windows/zlib123/zlib-2008-x64.lib b/src/windows/zlib123/zlib-2008-x64.lib similarity index 100% rename from desmume/src/windows/zlib123/zlib-2008-x64.lib rename to src/windows/zlib123/zlib-2008-x64.lib diff --git a/desmume/src/windows/zlib123/zlib.h b/src/windows/zlib123/zlib.h similarity index 97% rename from desmume/src/windows/zlib123/zlib.h rename to src/windows/zlib123/zlib.h index 022817927..62d0e4675 100644 --- a/desmume/src/windows/zlib123/zlib.h +++ b/src/windows/zlib123/zlib.h @@ -1,1357 +1,1357 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.3, July 18th, 2005 - - Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.3" -#define ZLIB_VERNUM 0x1230 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed - data. This version of the library supports only one compression method - (deflation) but other algorithms will be added later and will have the same - stream interface. - - Compression can be done in a single step if the buffers are large - enough (for example if an input file is mmap'ed), or can be done by - repeated calls of the compression function. In the latter case, the - application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never - crash even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has - dropped to zero. It must update next_out and avail_out when avail_out - has dropped to zero. The application must initialize zalloc, zfree and - opaque before calling the init function. All other fields are set by the - compression library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, - pointers returned by zalloc for objects of exactly 65536 bytes *must* - have their offset normalized to zero. The default allocation function - provided by this library ensures this (see zutil.c). To reduce memory - requirements and avoid any allocation of 64K objects, at the expense of - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or - progress reports. After compression, total_in holds the total size of - the uncompressed data and may be saved for use in the decompressor - (particularly if the decompressor wants to decompress everything in - a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative - * values are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is - not compatible with the zlib.h header file used by the application. - This check is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. - If zalloc and zfree are set to Z_NULL, deflateInit updates them to - use default allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at - all (the input data is simply copied a block at a time). - Z_DEFAULT_COMPRESSION requests a default compromise between speed and - compression (currently equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if level is not a valid compression level, - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). - msg is set to null if there is no error message. deflateInit does not - perform any compression: this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce some - output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). - Some output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating avail_in or avail_out accordingly; avail_out - should never be zero before the call. The application can consume the - compressed output when it wants, for example when the output buffer is full - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK - and with zero avail_out, it must be called again after making room in the - output buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumualte before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In particular - avail_in is zero after the call if enough output space has been provided - before the call.) Flushing may degrade compression for some compression - algorithms and so it should be used only when necessary. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there - was enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the - stream are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least - the value returned by deflateBound (see below). If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect - the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, - msg may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the exact - value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing - will resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there - is no more input data or no more space in the output buffer (see below - about the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating the next_* and avail_* values accordingly. - The application can consume the uncompressed output when it wants, for - example when the output buffer is full (avail_out == 0), or after each - call of inflate(). If inflate returns Z_OK and with zero avail_out, it - must be called again after making room in the output buffer because there - might be more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, - Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() stop - if and when it gets to the next deflate block boundary. When decoding the - zlib or gzip format, this will cause inflate() to return immediately after - the header and before the first block. When doing a raw inflate, inflate() - will go ahead and process the first block, and will return when it gets to - the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 - if inflate() is currently decoding the last block in the deflate stream, - plus 128 if inflate() returned immediately after decoding an end-of-block - code or decoding the complete header up to just before the first byte of the - deflate stream. The end-of-block will not be indicated until all of the - uncompressed data from that block has been written to strm->next_out. The - number of unused bits may in general be greater than seven, except when - bit 7 of data_type is set, in which case the number of unused bits will be - less than eight. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step - (a single call of inflate), the parameter flush should be set to - Z_FINISH. In this case all pending input is processed and all pending - output is flushed; avail_out must be large enough to hold all the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster approach - may be used for the single inflate() call. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the only effect of the flush parameter in this implementation - is on the return value of inflate(), as noted below, or when it returns early - because Z_BLOCK is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the adler32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the adler32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() will decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically. Any information - contained in the gzip header is not retained, so applications that need that - information should instead use raw inflate, see inflateInit2() below, or - inflateBack() and perform their own processing of the gzip header and - trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may then - call inflateSync() to look for a good compression block if a partial recovery - of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by - the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), - no header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but - is slow and reduces compression ratio; memLevel=9 uses maximum memory - for optimal speed. The default value is 8. See zconf.h for total memory - usage as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as - Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy - parameter only affects the compression ratio but not the correctness of the - compressed output even if it is not set appropriately. Z_FIXED prevents the - use of dynamic Huffman codes, allowing for a simpler decoder for special - applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). msg is set to null if there is no error message. deflateInit2 does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. In addition, the - current implementation of deflate will use at most the window size minus - 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and - can consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. - The stream will keep the same compression level and any other attributes - that may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different - strategy. If the compression level is changed, the input available so far - is compressed with the old level (and may be flushed); the new level will - take effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to - be compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR - if strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() - or deflateInit2(). This would be used to allocate an output buffer - for deflation in a single pass, and so would be called before deflate(). -*/ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the - bits leftover from a previous deflate stream when appending to it. As such, - this function can only be used for raw deflate, and must be used before the - first deflate() call after a deflateInit2() or deflateReset(). bits must be - less than or equal to 16, and that many of the least significant bits of - value will be inserted in the output. - - deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is - a crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg - is set to null if there is no error message. inflateInit2 does not perform - any decompression apart from reading the zlib header if present: this will - be done by inflate(). (So next_in and avail_in may be modified, but next_out - and avail_out are unchanged.) -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called - immediately after inflateInit2() or inflateReset() and before any call of - inflate() to set the dictionary. The application must insure that the - dictionary that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been found, - or Z_STREAM_ERROR if the stream structure was inconsistent. In the success - case, the application may save the current current value of total_in which - indicates where valid compressed data was found. In the error case, the - application may repeatedly call inflateSync, providing more input each time, - until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. - The stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK can be used to - force inflate() to return immediately after header processing is complete - and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When - any of extra, name, or comment are not Z_NULL and the respective field is - not present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the paramaters are invalid, Z_MEM_ERROR if the internal state could not - be allocated, or Z_VERSION_ERROR if the version of the library does not - match the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is more efficient than inflate() for - file i/o applications in that it avoids copying between the output and the - sliding window by simply making the window itself the output buffer. This - function trusts the application to not change the output buffer passed by - the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free - the allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects - only the raw deflate stream to decompress. This is different from the - normal behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format - error in the deflate stream (in which case strm->msg is set to indicate the - nature of the error), or Z_STREAM_ERROR if the stream was not properly - initialized. In the case of Z_BUF_ERROR, an input or output error can be - distinguished using strm->next_in which will be Z_NULL only if in() returned - an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to - out() returning non-zero. (in() will always be called before out(), so - strm->next_in is assured to be defined if out() returns non-zero.) Note - that inflateBack() cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - - - /* utility functions */ - -/* - The following utility functions are implemented on top of the - basic stream-oriented functions. To simplify the interface, some - default options are assumed (compression level and memory usage, - standard memory allocation functions). The source code of these - utility functions can easily be modified if you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be at least the value returned - by compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before - a compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. -*/ - - -typedef voidp gzFile; - -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); -/* - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb") but can also include a compression level - ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for - Huffman only compression as in "wb1h", or 'R' for run-length encoding - as in "wb1R". (See the description of deflateInit2 for more information - about the strategy parameter.) - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. - - gzopen returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). */ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen() associates a gzFile with the file descriptor fd. File - descriptors are obtained from calls like open, dup, creat, pipe or - fileno (in the file has been previously opened with fopen). - The mode parameter is as in gzopen. - The next call of gzclose on the returned gzFile will also close the - file descriptor fd, just like fclose(fdopen(fd), mode) closes the file - descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). - gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. - If the input file was not in gzip format, gzread copies the given number - of bytes into the buffer. - gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). */ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). The number of - uncompressed bytes written is limited to 4095. The caller should assure that - this limit is not exceeded. If it is exceeded, then gzprintf() will return - return an error (0) with nothing written. In this case, there may also be a - buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf() - because the secure snprintf() or vsnprintf() functions were not available. -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or - a newline character is read and transferred to buf, or an end-of-file - condition is encountered. The string is then terminated with a null - character. - gzgets returns buf, or Z_NULL in case of error. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read again later. - Only one character of push-back is allowed. gzungetc() returns the - character pushed, or -1 on failure. gzungetc() will fail if a - character has been pushed but not read yet, or if c is -1. The pushed - character will be discarded if the stream is repositioned with gzseek() - or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. The return value is the zlib - error number (see function gzerror below). gzflush returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. - gzflush should be called only when strictly necessary because it can - degrade compression. -*/ - -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); -/* - Sets the starting position for the next gzread or gzwrite on the - given compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); -/* - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns 1 if file is being read directly without decompression, otherwise - zero. -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the - compression library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is NULL, this function returns - the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); -/* - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is NULL, this function returns the required initial - value for the for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - -/* - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, sizeof(z_stream)) - - -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; /* hack for buggy compilers */ -#endif - -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.3, July 18th, 2005 + + Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef ZLIB_H +#define ZLIB_H + +#include "zconf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZLIB_VERSION "1.2.3" +#define ZLIB_VERNUM 0x1230 + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The compressed data format used by default by the in-memory functions is + the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped + around a deflate stream, which is itself documented in RFC 1951. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio using the functions that start + with "gz". The gzip format is different from the zlib format. gzip is a + gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. + + This library can optionally read and write gzip streams in memory as well. + + The zlib format was designed to be compact and fast for use in memory + and on communications channels. The gzip format was designed for single- + file compression on file systems, has a larger header than zlib to maintain + directory information, and uses a different, slower check method than zlib. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: binary or text */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + gzip header information passed to and from zlib routines. See RFC 1952 + for more details on the meanings of these fields. +*/ +typedef struct gz_header_s { + int text; /* true if compressed data believed to be text */ + uLong time; /* modification time */ + int xflags; /* extra flags (not used when writing a gzip file) */ + int os; /* operating system */ + Bytef *extra; /* pointer to extra field or Z_NULL if none */ + uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ + uInt extra_max; /* space at extra (only when reading header) */ + Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ + uInt name_max; /* space at name (only when reading header) */ + Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ + uInt comm_max; /* space at comment (only when reading header) */ + int hcrc; /* true if there was or will be a header crc */ + int done; /* true when done reading gzip header (not used + when writing a gzip file) */ +} gz_header; + +typedef gz_header FAR *gz_headerp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + If zlib is used in a multi-threaded application, zalloc and zfree must be + thread safe. + + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +#define Z_BLOCK 5 +/* Allowed flush values; see deflate() and inflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_RLE 3 +#define Z_FIXED 4 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_TEXT 1 +#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ +#define Z_UNKNOWN 2 +/* Possible values of the data_type field (though see inflate()) */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to + decide how much data to accumualte before producing output, in order to + maximize compression. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that + avail_out is greater than six to avoid repeated flush markers due to + avail_out == 0 on return. + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + the value returned by deflateBound (see below). If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update strm->data_type if it can make a good guess about + the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible + (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not + fatal, and deflate() can be called again with more input and more output + space to continue compressing. +*/ + + +ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce + some output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, + Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much + output as possible to the output buffer. Z_BLOCK requests that inflate() stop + if and when it gets to the next deflate block boundary. When decoding the + zlib or gzip format, this will cause inflate() to return immediately after + the header and before the first block. When doing a raw inflate, inflate() + will go ahead and process the first block, and will return when it gets to + the end of that block, or when it runs out of data. + + The Z_BLOCK option assists in appending to or combining deflate streams. + Also to assist in this, on return inflate() will set strm->data_type to the + number of unused bits in the last byte taken from strm->next_in, plus 64 + if inflate() is currently decoding the last block in the deflate stream, + plus 128 if inflate() returned immediately after decoding an end-of-block + code or decoding the complete header up to just before the first byte of the + deflate stream. The end-of-block will not be indicated until all of the + uncompressed data from that block has been written to strm->next_out. The + number of unused bits may in general be greater than seven, except when + bit 7 of data_type is set, in which case the number of unused bits will be + less than eight. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster approach + may be used for the single inflate() call. + + In this implementation, inflate() always flushes as much output as + possible to the output buffer, and always uses the faster approach on the + first call. So the only effect of the flush parameter in this implementation + is on the return value of inflate(), as noted below, or when it returns early + because Z_BLOCK is used. + + If a preset dictionary is needed after this call (see inflateSetDictionary + below), inflate sets strm->adler to the adler32 checksum of the dictionary + chosen by the compressor and returns Z_NEED_DICT; otherwise it sets + strm->adler to the adler32 checksum of all output produced so far (that is, + total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described + below. At the end of the stream, inflate() checks that its computed adler32 + checksum is equal to that saved by the compressor and returns Z_STREAM_END + only if the checksum is correct. + + inflate() will decompress and check either zlib-wrapped or gzip-wrapped + deflate data. The header type is detected automatically. Any information + contained in the gzip header is not retained, so applications that need that + information should instead use raw inflate, see inflateInit2() below, or + inflateBack() and perform their own processing of the gzip header and + trailer. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect check + value), Z_STREAM_ERROR if the stream structure was inconsistent (for example + if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, + Z_BUF_ERROR if no progress is possible or if there was not enough room in the + output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and + inflate() can be called again with more input and more output space to + continue decompressing. If Z_DATA_ERROR is returned, the application may then + call inflateSync() to look for a good compression block if a partial recovery + of the data is desired. +*/ + + +ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + windowBits can also be -8..-15 for raw deflate. In this case, -windowBits + determines the window size. deflate() will then generate raw deflate data + with no zlib header or trailer, and will not compute an adler32 check value. + + windowBits can also be greater than 15 for optional gzip encoding. Add + 16 to windowBits to write a simple gzip header and trailer around the + compressed data instead of a zlib wrapper. The gzip header will have no + file name, no extra data, no comment, no modification time (set to zero), + no header crc, and the operating system will be set to 255 (unknown). If a + gzip stream is being written, strm->adler is a crc32 instead of an adler32. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match), or Z_RLE to limit match distances to one (run-length + encoding). Filtered data consists mostly of small values with a somewhat + random distribution. In this case, the compression algorithm is tuned to + compress them better. The effect of Z_FILTERED is to force more Huffman + coding and less string matching; it is somewhat intermediate between + Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as + Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy + parameter only affects the compression ratio but not the correctness of the + compressed output even if it is not set appropriately. Z_FIXED prevents the + use of dynamic Huffman codes, allowing for a simpler decoder for special + applications. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit, deflateInit2 or deflateReset, before any + call of deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. In addition, the + current implementation of deflate will use at most the window size minus + 262 bytes of the provided dictionary. + + Upon return of this function, strm->adler is set to the adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) If a raw deflate was requested, then the + adler32 value is not computed and strm->adler is not set. + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, + int level, + int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain)); +/* + Fine tune deflate's internal compression parameters. This should only be + used by someone who understands the algorithm used by zlib's deflate for + searching for the best matching string, and even then only by the most + fanatic optimizer trying to squeeze out the last compressed bit for their + specific input data. Read the deflate.c source code for the meaning of the + max_lazy, good_length, nice_length, and max_chain parameters. + + deflateTune() can be called after deflateInit() or deflateInit2(), and + returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. + */ + +ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, + uLong sourceLen)); +/* + deflateBound() returns an upper bound on the compressed size after + deflation of sourceLen bytes. It must be called after deflateInit() + or deflateInit2(). This would be used to allocate an output buffer + for deflation in a single pass, and so would be called before deflate(). +*/ + +ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + deflatePrime() inserts bits in the deflate output stream. The intent + is that this function is used to start off the deflate output with the + bits leftover from a previous deflate stream when appending to it. As such, + this function can only be used for raw deflate, and must be used before the + first deflate() call after a deflateInit2() or deflateReset(). bits must be + less than or equal to 16, and that many of the least significant bits of + value will be inserted in the output. + + deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, + gz_headerp head)); +/* + deflateSetHeader() provides gzip header information for when a gzip + stream is requested by deflateInit2(). deflateSetHeader() may be called + after deflateInit2() or deflateReset() and before the first call of + deflate(). The text, time, os, extra field, name, and comment information + in the provided gz_header structure are written to the gzip header (xflag is + ignored -- the extra flags are set according to the compression level). The + caller must assure that, if not Z_NULL, name and comment are terminated with + a zero byte, and that if extra is not Z_NULL, that extra_len bytes are + available there. If hcrc is true, a gzip header crc is included. Note that + the current versions of the command-line version of gzip (up through version + 1.3.x) do not support header crc's, and will report that it is a "multi-part + gzip file" and give up. + + If deflateSetHeader is not used, the default gzip header has text false, + the time set to zero, and os set to 255, with no extra, name, or comment + fields. The gzip header is returned to the default state by deflateReset(). + + deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. windowBits must be greater than or equal to the windowBits value + provided to deflateInit2() while compressing, or it must be equal to 15 if + deflateInit2() was not used. If a compressed stream with a larger window + size is given as input, inflate() will return with the error code + Z_DATA_ERROR instead of trying to allocate a larger window. + + windowBits can also be -8..-15 for raw inflate. In this case, -windowBits + determines the window size. inflate() will then process raw deflate data, + not looking for a zlib or gzip header, not generating a check value, and not + looking for any check values for comparison at the end of the stream. This + is for use with other formats that use the deflate compressed data format + such as zip. Those formats provide their own check values. If a custom + format is developed using the raw deflate format for compressed data, it is + recommended that a check value such as an adler32 or a crc32 be applied to + the uncompressed data as is done in the zlib, gzip, and zip formats. For + most applications, the zlib format should be used as is. Note that comments + above on the use in deflateInit2() applies to the magnitude of windowBits. + + windowBits can also be greater than 15 for optional gzip decoding. Add + 32 to windowBits to enable zlib and gzip decoding with automatic header + detection, or add 16 to decode only the gzip format (the zlib format will + return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is + a crc32 instead of an adler32. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg + is set to null if there is no error message. inflateInit2 does not perform + any decompression apart from reading the zlib header if present: this will + be done by inflate(). (So next_in and avail_in may be modified, but next_out + and avail_out are unchanged.) +*/ + +ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate, + if that call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the adler32 value returned by that call of inflate. + The compressor and decompressor must use exactly the same dictionary (see + deflateSetDictionary). For raw inflate, this function can be called + immediately after inflateInit2() or inflateReset() and before any call of + inflate() to set the dictionary. The application must insure that the + dictionary that was used for compression is provided. + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when randomly accessing a large stream. The + first pass through the stream can periodically record the inflate state, + allowing restarting inflate at those points when randomly accessing the + stream. + + inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, + int bits, + int value)); +/* + This function inserts bits in the inflate input stream. The intent is + that this function is used to start inflating at a bit position in the + middle of a byte. The provided bits will be used before any bytes are used + from next_in. This function should only be used with raw inflate, and + should be used before the first inflate() call after inflateInit2() or + inflateReset(). bits must be less than or equal to 16, and that many of the + least significant bits of value will be inserted in the input. + + inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, + gz_headerp head)); +/* + inflateGetHeader() requests that gzip header information be stored in the + provided gz_header structure. inflateGetHeader() may be called after + inflateInit2() or inflateReset(), and before the first call of inflate(). + As inflate() processes the gzip stream, head->done is zero until the header + is completed, at which time head->done is set to one. If a zlib stream is + being decoded, then head->done is set to -1 to indicate that there will be + no gzip header information forthcoming. Note that Z_BLOCK can be used to + force inflate() to return immediately after header processing is complete + and before any actual data is decompressed. + + The text, time, xflags, and os fields are filled in with the gzip header + contents. hcrc is set to true if there is a header CRC. (The header CRC + was valid if done is set to one.) If extra is not Z_NULL, then extra_max + contains the maximum number of bytes to write to extra. Once done is true, + extra_len contains the actual extra field length, and extra contains the + extra field, or that field truncated if extra_max is less than extra_len. + If name is not Z_NULL, then up to name_max characters are written there, + terminated with a zero unless the length is greater than name_max. If + comment is not Z_NULL, then up to comm_max characters are written there, + terminated with a zero unless the length is greater than comm_max. When + any of extra, name, or comment are not Z_NULL and the respective field is + not present in the header, then that field is set to Z_NULL to signal its + absence. This allows the use of deflateSetHeader() with the returned + structure to duplicate the header. However if those fields are set to + allocated memory, then the application will need to save those pointers + elsewhere so that they can be eventually freed. + + If inflateGetHeader is not used, then the header information is simply + discarded. The header is always checked for validity, including the header + CRC if present. inflateReset() will reset the process to discard the header + information. The application would need to call inflateGetHeader() again to + retrieve the header from the next gzip stream. + + inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent. +*/ + +/* +ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, + unsigned char FAR *window)); + + Initialize the internal stream state for decompression using inflateBack() + calls. The fields zalloc, zfree and opaque in strm must be initialized + before the call. If zalloc and zfree are Z_NULL, then the default library- + derived memory allocation routines are used. windowBits is the base two + logarithm of the window size, in the range 8..15. window is a caller + supplied buffer of that size. Except for special applications where it is + assured that deflate was used with small window sizes, windowBits must be 15 + and a 32K byte window must be supplied to be able to decompress general + deflate streams. + + See inflateBack() for the usage of these routines. + + inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of + the paramaters are invalid, Z_MEM_ERROR if the internal state could not + be allocated, or Z_VERSION_ERROR if the version of the library does not + match the version of the header file. +*/ + +typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); +typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); + +ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc)); +/* + inflateBack() does a raw inflate with a single call using a call-back + interface for input and output. This is more efficient than inflate() for + file i/o applications in that it avoids copying between the output and the + sliding window by simply making the window itself the output buffer. This + function trusts the application to not change the output buffer passed by + the output function, at least until inflateBack() returns. + + inflateBackInit() must be called first to allocate the internal state + and to initialize the state with the user-provided window buffer. + inflateBack() may then be used multiple times to inflate a complete, raw + deflate stream with each call. inflateBackEnd() is then called to free + the allocated state. + + A raw deflate stream is one with no zlib or gzip header or trailer. + This routine would normally be used in a utility that reads zip or gzip + files and writes out uncompressed files. The utility would decode the + header and process the trailer on its own, hence this routine expects + only the raw deflate stream to decompress. This is different from the + normal behavior of inflate(), which expects either a zlib or gzip header and + trailer around the deflate stream. + + inflateBack() uses two subroutines supplied by the caller that are then + called by inflateBack() for input and output. inflateBack() calls those + routines until it reads a complete deflate stream and writes out all of the + uncompressed data, or until it encounters an error. The function's + parameters and return types are defined above in the in_func and out_func + typedefs. inflateBack() will call in(in_desc, &buf) which should return the + number of bytes of provided input, and a pointer to that input in buf. If + there is no input available, in() must return zero--buf is ignored in that + case--and inflateBack() will return a buffer error. inflateBack() will call + out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() + should return zero on success, or non-zero on failure. If out() returns + non-zero, inflateBack() will return with an error. Neither in() nor out() + are permitted to change the contents of the window provided to + inflateBackInit(), which is also the buffer that out() uses to write from. + The length written by out() will be at most the window size. Any non-zero + amount of input may be provided by in(). + + For convenience, inflateBack() can be provided input on the first call by + setting strm->next_in and strm->avail_in. If that input is exhausted, then + in() will be called. Therefore strm->next_in must be initialized before + calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called + immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in + must also be initialized, and then if strm->avail_in is not zero, input will + initially be taken from strm->next_in[0 .. strm->avail_in - 1]. + + The in_desc and out_desc parameters of inflateBack() is passed as the + first parameter of in() and out() respectively when they are called. These + descriptors can be optionally used to pass any information that the caller- + supplied in() and out() functions need to do their job. + + On return, inflateBack() will set strm->next_in and strm->avail_in to + pass back any unused input that was provided by the last in() call. The + return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR + if in() or out() returned an error, Z_DATA_ERROR if there was a format + error in the deflate stream (in which case strm->msg is set to indicate the + nature of the error), or Z_STREAM_ERROR if the stream was not properly + initialized. In the case of Z_BUF_ERROR, an input or output error can be + distinguished using strm->next_in which will be Z_NULL only if in() returned + an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to + out() returning non-zero. (in() will always be called before out(), so + strm->next_in is assured to be defined if out() returns non-zero.) Note + that inflateBack() cannot return Z_OK. +*/ + +ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +/* + All memory allocated by inflateBackInit() is freed. + + inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream + state was inconsistent. +*/ + +ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +/* Return flags indicating compile-time options. + + Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: + 1.0: size of uInt + 3.2: size of uLong + 5.4: size of voidpf (pointer) + 7.6: size of z_off_t + + Compiler, assembler, and debug options: + 8: DEBUG + 9: ASMV or ASMINF -- use ASM code + 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention + 11: 0 (reserved) + + One-time table building (smaller code, but not thread-safe if true): + 12: BUILDFIXED -- build static block decoding tables when needed + 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed + 14,15: 0 (reserved) + + Library content (indicates missing functionality): + 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking + deflate code when not needed) + 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect + and decode gzip streams (to avoid linking crc code) + 18-19: 0 (reserved) + + Operation variations (changes in library functionality): + 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate + 21: FASTEST -- deflate algorithm with only one, lowest compression level + 22,23: 0 (reserved) + + The sprintf variant used by gzprintf (zero is best): + 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format + 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! + 26: 0 = returns value, 1 = void -- 1 means inferred string length returned + + Remainder: + 27-31: 0 (reserved) + */ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least the value returned + by compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least the value returned by + compressBound(sourceLen). Upon exit, destLen is the actual size of the + compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +/* + compressBound() returns an upper bound on the compressed size after + compress() or compress2() on sourceLen bytes. It would be used before + a compress() or compress2() call to allocate the destination buffer. +*/ + +ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. +*/ + + +typedef voidp gzFile; + +ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h", or 'R' for run-length encoding + as in "wb1R". (See the description of deflateInit2 for more information + about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +ZEXTERN int ZEXPORT gzwrite OF((gzFile file, + voidpc buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). The number of + uncompressed bytes written is limited to 4095. The caller should assure that + this limit is not exceeded. If it is exceeded, then gzprintf() will return + return an error (0) with nothing written. In this case, there may also be a + buffer overflow with unpredictable consequences, which is possible only if + zlib was compiled with the insecure functions sprintf() or vsprintf() + because the secure snprintf() or vsnprintf() functions were not available. +*/ + +ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +/* + Writes the given null-terminated string to the compressed file, excluding + the terminating null character. + gzputs returns the number of characters written, or -1 in case of error. +*/ + +ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +/* + Reads bytes from the compressed file until len-1 characters are read, or + a newline character is read and transferred to buf, or an end-of-file + condition is encountered. The string is then terminated with a null + character. + gzgets returns buf, or Z_NULL in case of error. +*/ + +ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +/* + Push one character back onto the stream to be read again later. + Only one character of push-back is allowed. gzungetc() returns the + character pushed, or -1 on failure. gzungetc() will fail if a + character has been pushed but not read yet, or if c is -1. The pushed + character will be discarded if the stream is repositioned with gzseek() + or gzrewind(). +*/ + +ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, + z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the + given compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +/* + Returns 1 if file is being read directly without decompression, otherwise + zero. +*/ + +ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + +ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +/* + Clears the error and end-of-file flags for file. This is analogous to the + clearerr() function in stdio. This is useful for continuing to read a gzip + file that is being written concurrently. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, + z_off_t len2)); +/* + Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 + and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for + each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of + seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. +*/ + +ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running CRC-32 with the bytes buf[0..len-1] and return the + updated CRC-32. If buf is NULL, this function returns the required initial + value for the for the crc. Pre- and post-conditioning (one's complement) is + performed within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + +ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); + +/* + Combine two CRC-32 check values into one. For two sequences of bytes, + seq1 and seq2 with lengths len1 and len2, CRC-32 check values were + calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 + check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and + len2. +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size)); +ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) +#define inflateBackInit(strm, windowBits, window) \ + inflateBackInit_((strm), (windowBits), (window), \ + ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +ZEXTERN const char * ZEXPORT zError OF((int)); +ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); +ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* ZLIB_H */ diff --git a/desmume/src/windows/zlib123/zutil.h b/src/windows/zlib123/zutil.h similarity index 96% rename from desmume/src/windows/zlib123/zutil.h rename to src/windows/zlib123/zutil.h index 520d6041e..c0fb9c1f5 100644 --- a/desmume/src/windows/zlib123/zutil.h +++ b/src/windows/zlib123/zutil.h @@ -1,269 +1,269 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2005 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id: zutil.h,v 1.1 2008-08-03 18:36:13 mtabachenko Exp $ */ - -#ifndef ZUTIL_H -#define ZUTIL_H - -#define ZLIB_INTERNAL -#include "zlib.h" - -#ifdef STDC -# ifndef _WIN32_WCE -# include -# endif -# include -# include -#endif -#ifdef NO_ERRNO_H -# ifdef _WIN32_WCE - /* The Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. We rename it to - * avoid conflict with other libraries that use the same workaround. - */ -# define errno z_errno -# endif - extern int errno; -#else -# ifndef _WIN32_WCE -# include -# endif -#endif - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = (char*)ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) -# define OS_CODE 0x00 -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include -# endif -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -# ifdef M_I86 - #include -# endif -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#ifdef WIN32 -# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ -# define OS_CODE 0x0b -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0f -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# ifndef _PTRDIFF_T_DEFINED - typedef int ptrdiff_t; -# define _PTRDIFF_T_DEFINED -# endif -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - - /* common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#if defined(__CYGWIN__) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif -#ifndef HAVE_VSNPRINTF -# ifdef MSDOS - /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ -# define NO_vsnprintf -# endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif -# ifdef WIN32 - /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# define vsnprintf _vsnprintf -# endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -#endif -#ifdef VMS -# define NO_vsnprintf -#endif - -#if defined(pyr) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include - extern int z_verbose; - extern void z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - - -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); -void zcfree OF((voidpf opaque, voidpf ptr)); - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -#endif /* ZUTIL_H */ +/* zutil.h -- internal interface and configuration of the compression library + * Copyright (C) 1995-2005 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* WARNING: this file should *not* be used by applications. It is + part of the implementation of the compression library and is + subject to change. Applications should only use zlib.h. + */ + +/* @(#) $Id: zutil.h,v 1.1 2008-08-03 18:36:13 mtabachenko Exp $ */ + +#ifndef ZUTIL_H +#define ZUTIL_H + +#define ZLIB_INTERNAL +#include "zlib.h" + +#ifdef STDC +# ifndef _WIN32_WCE +# include +# endif +# include +# include +#endif +#ifdef NO_ERRNO_H +# ifdef _WIN32_WCE + /* The Microsoft C Run-Time Library for Windows CE doesn't have + * errno. We define it as a global variable to simplify porting. + * Its value is always 0 and should not be used. We rename it to + * avoid conflict with other libraries that use the same workaround. + */ +# define errno z_errno +# endif + extern int errno; +#else +# ifndef _WIN32_WCE +# include +# endif +#endif + +#ifndef local +# define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + +typedef unsigned char uch; +typedef uch FAR uchf; +typedef unsigned short ush; +typedef ush FAR ushf; +typedef unsigned long ulg; + +extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ +/* (size given to avoid silly warnings with Visual C++) */ + +#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] + +#define ERR_RETURN(strm,err) \ + return (strm->msg = (char*)ERR_MSG(err), (err)) +/* To be used only when the state is known to be valid */ + + /* common constants */ + +#ifndef DEF_WBITS +# define DEF_WBITS MAX_WBITS +#endif +/* default windowBits for decompression. MAX_WBITS is for compression only */ + +#if MAX_MEM_LEVEL >= 8 +# define DEF_MEM_LEVEL 8 +#else +# define DEF_MEM_LEVEL MAX_MEM_LEVEL +#endif +/* default memLevel */ + +#define STORED_BLOCK 0 +#define STATIC_TREES 1 +#define DYN_TREES 2 +/* The three kinds of block type */ + +#define MIN_MATCH 3 +#define MAX_MATCH 258 +/* The minimum and maximum match lengths */ + +#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ + + /* target dependencies */ + +#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) +# define OS_CODE 0x00 +# if defined(__TURBOC__) || defined(__BORLANDC__) +# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) + /* Allow compilation with ANSI keywords only enabled */ + void _Cdecl farfree( void *block ); + void *_Cdecl farmalloc( unsigned long nbytes ); +# else +# include +# endif +# else /* MSC or DJGPP */ +# include +# endif +#endif + +#ifdef AMIGA +# define OS_CODE 0x01 +#endif + +#if defined(VAXC) || defined(VMS) +# define OS_CODE 0x02 +# define F_OPEN(name, mode) \ + fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") +#endif + +#if defined(ATARI) || defined(atarist) +# define OS_CODE 0x05 +#endif + +#ifdef OS2 +# define OS_CODE 0x06 +# ifdef M_I86 + #include +# endif +#endif + +#if defined(MACOS) || defined(TARGET_OS_MAC) +# define OS_CODE 0x07 +# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include /* for fdopen */ +# else +# ifndef fdopen +# define fdopen(fd,mode) NULL /* No fdopen() */ +# endif +# endif +#endif + +#ifdef TOPS20 +# define OS_CODE 0x0a +#endif + +#ifdef WIN32 +# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ +# define OS_CODE 0x0b +# endif +#endif + +#ifdef __50SERIES /* Prime/PRIMOS */ +# define OS_CODE 0x0f +#endif + +#if defined(_BEOS_) || defined(RISCOS) +# define fdopen(fd,mode) NULL /* No fdopen() */ +#endif + +#if (defined(_MSC_VER) && (_MSC_VER > 600)) +# if defined(_WIN32_WCE) +# define fdopen(fd,mode) NULL /* No fdopen() */ +# ifndef _PTRDIFF_T_DEFINED + typedef int ptrdiff_t; +# define _PTRDIFF_T_DEFINED +# endif +# else +# define fdopen(fd,type) _fdopen(fd,type) +# endif +#endif + + /* common defaults */ + +#ifndef OS_CODE +# define OS_CODE 0x03 /* assume Unix */ +#endif + +#ifndef F_OPEN +# define F_OPEN(name, mode) fopen((name), (mode)) +#endif + + /* functions */ + +#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif +#if defined(__CYGWIN__) +# ifndef HAVE_VSNPRINTF +# define HAVE_VSNPRINTF +# endif +#endif +#ifndef HAVE_VSNPRINTF +# ifdef MSDOS + /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), + but for now we just assume it doesn't. */ +# define NO_vsnprintf +# endif +# ifdef __TURBOC__ +# define NO_vsnprintf +# endif +# ifdef WIN32 + /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ +# if !defined(vsnprintf) && !defined(NO_vsnprintf) +# define vsnprintf _vsnprintf +# endif +# endif +# ifdef __SASC +# define NO_vsnprintf +# endif +#endif +#ifdef VMS +# define NO_vsnprintf +#endif + +#if defined(pyr) +# define NO_MEMCPY +#endif +#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) + /* Use our own functions for small and medium model with MSC <= 5.0. + * You may have to use the same strategy for Borland C (untested). + * The __SC__ check is for Symantec. + */ +# define NO_MEMCPY +#endif +#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) +# define HAVE_MEMCPY +#endif +#ifdef HAVE_MEMCPY +# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ +# define zmemcpy _fmemcpy +# define zmemcmp _fmemcmp +# define zmemzero(dest, len) _fmemset(dest, 0, len) +# else +# define zmemcpy memcpy +# define zmemcmp memcmp +# define zmemzero(dest, len) memset(dest, 0, len) +# endif +#else + extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); + extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); + extern void zmemzero OF((Bytef* dest, uInt len)); +#endif + +/* Diagnostic functions */ +#ifdef DEBUG +# include + extern int z_verbose; + extern void z_error OF((char *m)); +# define Assert(cond,msg) {if(!(cond)) z_error(msg);} +# define Trace(x) {if (z_verbose>=0) fprintf x ;} +# define Tracev(x) {if (z_verbose>0) fprintf x ;} +# define Tracevv(x) {if (z_verbose>1) fprintf x ;} +# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} +# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} +#else +# define Assert(cond,msg) +# define Trace(x) +# define Tracev(x) +# define Tracevv(x) +# define Tracec(c,x) +# define Tracecv(c,x) +#endif + + +voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); +void zcfree OF((voidpf opaque, voidpf ptr)); + +#define ZALLOC(strm, items, size) \ + (*((strm)->zalloc))((strm)->opaque, (items), (size)) +#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) +#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} + +#endif /* ZUTIL_H */ diff --git a/desmume/src/windows/zziplib/README b/src/windows/zziplib/README similarity index 100% rename from desmume/src/windows/zziplib/README rename to src/windows/zziplib/README diff --git a/desmume/src/windows/zziplib/zzip/_msvc.h b/src/windows/zziplib/zzip/_msvc.h similarity index 96% rename from desmume/src/windows/zziplib/zzip/_msvc.h rename to src/windows/zziplib/zzip/_msvc.h index 81adb6a4a..4d3c50552 100644 --- a/desmume/src/windows/zziplib/zzip/_msvc.h +++ b/src/windows/zziplib/zzip/_msvc.h @@ -1,213 +1,213 @@ -#ifndef _ZZIP__MSVC_H -#define _ZZIP__MSVC_H 1 - -#define _zzip_calltype __cdecl - -/* zzip/_msvc.h. Generated automatically at end of configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -/* #undef ZZIP_HAVE_BYTESWAP_H */ - -/* Define to 1 if you have the header file. */ -#ifndef ZZIP_HAVE_DIRECT_H -#define ZZIP_HAVE_DIRECT_H 1 -#endif - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef ZZIP_HAVE_DIRENT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef ZZIP_HAVE_DLFCN_H */ - -/* Define to 1 if you have the header file. */ -/* #undef ZZIP_HAVE_FNMATCH_H */ - -/* Define to 1 if you have the header file. */ -/* #undef ZZIP_HAVE_INTTYPES_H */ - -/* Define to 1 if you have the header file. */ -#ifndef ZZIP_HAVE_IO_H -#define ZZIP_HAVE_IO_H 1 -#endif - -/* Define to 1 if you have the header file. */ -#ifndef ZZIP_HAVE_MEMORY_H -#define ZZIP_HAVE_MEMORY_H 1 -#endif - -/* Define to 1 if you have the header file, and it defines `DIR'. */ -/* #undef ZZIP_HAVE_NDIR_H */ - -/* Define to 1 if you have the header file. */ -/* #undef ZZIP_HAVE_STDINT_H */ - -/* Define to 1 if you have the header file. */ -#ifndef ZZIP_HAVE_STDLIB_H -#define ZZIP_HAVE_STDLIB_H 1 -#endif - -/* Define to 1 if you have the `strcasecmp' function. */ -/* #undef ZZIP_HAVE_STRCASECMP */ - -/* Define to 1 if you have the header file. */ -/* #undef ZZIP_HAVE_STRINGS_H */ - -/* Define to 1 if you have the header file. */ -#ifndef ZZIP_HAVE_STRING_H -#define ZZIP_HAVE_STRING_H 1 -#endif - -/* Define to 1 if you have the `strndup' function. */ -/* #undef ZZIP_HAVE_STRNDUP */ - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef ZZIP_HAVE_SYS_DIR_H */ - -/* Define to 1 if you have the header file. */ -/* #undef ZZIP_HAVE_SYS_INT_TYPES_H */ - -/* Define to 1 if you have the header file. */ -/* #undef ZZIP_HAVE_SYS_MMAN_H */ - -/* Define to 1 if you have the header file, and it defines `DIR'. - */ -/* #undef ZZIP_HAVE_SYS_NDIR_H */ - -/* Define to 1 if you have the header file. */ -/* #undef ZZIP_HAVE_SYS_PARAM_H */ - -/* Define to 1 if you have the header file. */ -#ifndef ZZIP_HAVE_SYS_STAT_H -#define ZZIP_HAVE_SYS_STAT_H 1 -#endif - -/* Define to 1 if you have the header file. */ -#ifndef ZZIP_HAVE_SYS_TYPES_H -#define ZZIP_HAVE_SYS_TYPES_H 1 -#endif - -/* Define to 1 if you have the header file. */ -/* #undef ZZIP_HAVE_UNISTD_H */ - -/* Define to 1 if you have the header file. */ -#ifndef ZZIP_HAVE_WINBASE_H -#define ZZIP_HAVE_WINBASE_H 1 /* hmm, is that win32 ? */ -#endif - -/* Define to 1 if you have the header file. */ -#ifndef ZZIP_HAVE_WINDOWS_H -#define ZZIP_HAVE_WINDOWS_H 1 /* yes, this is windows */ -#endif - -/* Define to 1 if you have the header file. */ -#ifndef ZZIP_HAVE_WINNT_H -#define ZZIP_HAVE_WINNT_H 1 /* is that always true? */ -#endif - -/* Define to 1 if you have the header file. */ -#ifndef ZZIP_HAVE_ZLIB_H -#define ZZIP_HAVE_ZLIB_H 1 /* you do have it, right? */ -#endif - -/* whether the system defaults to 32bit off_t but can do 64bit when requested - */ -/* #undef ZZIP_LARGEFILE_SENSITIVE */ - -/* Name of package */ -#ifndef ZZIP_PACKAGE -#define ZZIP_PACKAGE "zziplib-msvc" /* yes, make it known */ -#endif - -/* Define to the address where bug reports for this package should be sent. */ -/* #undef ZZIP_PACKAGE_BUGREPORT */ - -/* Define to the full name of this package. */ -/* #undef ZZIP_PACKAGE_NAME */ - -/* Define to the full name and version of this package. */ -/* #undef ZZIP_PACKAGE_STRING */ - -/* Define to the one symbol short name of this package. */ -/* #undef ZZIP_PACKAGE_TARNAME */ - -/* Define to the version of this package. */ -/* #undef ZZIP_PACKAGE_VERSION */ - -/* The number of bytes in type int */ -#ifndef ZZIP_SIZEOF_INT -#define ZZIP_SIZEOF_INT 4 -#endif - -/* The number of bytes in type long */ -#ifndef ZZIP_SIZEOF_LONG -#define ZZIP_SIZEOF_LONG 4 -#endif - -/* The number of bytes in type short */ -#ifndef ZZIP_SIZEOF_SHORT -#define ZZIP_SIZEOF_SHORT 2 -#endif - -/* Define to 1 if you have the ANSI C header files. */ -#ifndef ZZIP_STDC_HEADERS -#define ZZIP_STDC_HEADERS 1 -#endif - -/* Version number of package */ -#ifndef ZZIP_VERSION -#define ZZIP_VERSION "0.13.x" -#endif - -/* Define to 1 if your processor stores words with the most significant byte - first (like Motorola and SPARC, unlike Intel and VAX). */ -/* #undef ZZIP_WORDS_BIGENDIAN */ - -/* Number of bits in a file offset, on hosts where this is settable. */ -/* #undef ZZIP__FILE_OFFSET_BITS */ - -/* Define for large files, on AIX-style hosts. */ -/* #undef ZZIP__LARGE_FILES */ - -/* Define to `long long' if does not define. */ -/* #undef ZZIP___int64 */ - -/* Define to empty if `const' does not conform to ANSI C. */ -/* #undef _zzip_const */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#ifndef _zzip_inline -#define _zzip_inline __inline -#endif -#endif - -/* Define to `_zzip_off_t' if does not define. */ -#ifndef _zzip_off64_t -#define _zzip_off64_t __int64 -#endif - -/* Define to `long' if does not define. */ -#ifndef _zzip_off_t -#define _zzip_off_t long -#endif - -/* Define to equivalent of C99 restrict keyword, or to nothing if this is not - supported. Do not define if restrict is supported directly. */ -#ifndef _zzip_restrict -#define _zzip_restrict -#endif - -/* Define to `unsigned' if does not define. */ -/* #undef _zzip_size_t */ - -/* Define to `int' if does not define. */ -#ifndef _zzip_ssize_t -#define _zzip_ssize_t int -#endif - -/* once: _ZZIP__MSVC_H */ -#endif +#ifndef _ZZIP__MSVC_H +#define _ZZIP__MSVC_H 1 + +#define _zzip_calltype __cdecl + +/* zzip/_msvc.h. Generated automatically at end of configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +/* #undef ZZIP_HAVE_BYTESWAP_H */ + +/* Define to 1 if you have the header file. */ +#ifndef ZZIP_HAVE_DIRECT_H +#define ZZIP_HAVE_DIRECT_H 1 +#endif + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef ZZIP_HAVE_DIRENT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef ZZIP_HAVE_DLFCN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef ZZIP_HAVE_FNMATCH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef ZZIP_HAVE_INTTYPES_H */ + +/* Define to 1 if you have the header file. */ +#ifndef ZZIP_HAVE_IO_H +#define ZZIP_HAVE_IO_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#ifndef ZZIP_HAVE_MEMORY_H +#define ZZIP_HAVE_MEMORY_H 1 +#endif + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef ZZIP_HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef ZZIP_HAVE_STDINT_H */ + +/* Define to 1 if you have the header file. */ +#ifndef ZZIP_HAVE_STDLIB_H +#define ZZIP_HAVE_STDLIB_H 1 +#endif + +/* Define to 1 if you have the `strcasecmp' function. */ +/* #undef ZZIP_HAVE_STRCASECMP */ + +/* Define to 1 if you have the header file. */ +/* #undef ZZIP_HAVE_STRINGS_H */ + +/* Define to 1 if you have the header file. */ +#ifndef ZZIP_HAVE_STRING_H +#define ZZIP_HAVE_STRING_H 1 +#endif + +/* Define to 1 if you have the `strndup' function. */ +/* #undef ZZIP_HAVE_STRNDUP */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef ZZIP_HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef ZZIP_HAVE_SYS_INT_TYPES_H */ + +/* Define to 1 if you have the header file. */ +/* #undef ZZIP_HAVE_SYS_MMAN_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef ZZIP_HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +/* #undef ZZIP_HAVE_SYS_PARAM_H */ + +/* Define to 1 if you have the header file. */ +#ifndef ZZIP_HAVE_SYS_STAT_H +#define ZZIP_HAVE_SYS_STAT_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#ifndef ZZIP_HAVE_SYS_TYPES_H +#define ZZIP_HAVE_SYS_TYPES_H 1 +#endif + +/* Define to 1 if you have the header file. */ +/* #undef ZZIP_HAVE_UNISTD_H */ + +/* Define to 1 if you have the header file. */ +#ifndef ZZIP_HAVE_WINBASE_H +#define ZZIP_HAVE_WINBASE_H 1 /* hmm, is that win32 ? */ +#endif + +/* Define to 1 if you have the header file. */ +#ifndef ZZIP_HAVE_WINDOWS_H +#define ZZIP_HAVE_WINDOWS_H 1 /* yes, this is windows */ +#endif + +/* Define to 1 if you have the header file. */ +#ifndef ZZIP_HAVE_WINNT_H +#define ZZIP_HAVE_WINNT_H 1 /* is that always true? */ +#endif + +/* Define to 1 if you have the header file. */ +#ifndef ZZIP_HAVE_ZLIB_H +#define ZZIP_HAVE_ZLIB_H 1 /* you do have it, right? */ +#endif + +/* whether the system defaults to 32bit off_t but can do 64bit when requested + */ +/* #undef ZZIP_LARGEFILE_SENSITIVE */ + +/* Name of package */ +#ifndef ZZIP_PACKAGE +#define ZZIP_PACKAGE "zziplib-msvc" /* yes, make it known */ +#endif + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef ZZIP_PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef ZZIP_PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef ZZIP_PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef ZZIP_PACKAGE_TARNAME */ + +/* Define to the version of this package. */ +/* #undef ZZIP_PACKAGE_VERSION */ + +/* The number of bytes in type int */ +#ifndef ZZIP_SIZEOF_INT +#define ZZIP_SIZEOF_INT 4 +#endif + +/* The number of bytes in type long */ +#ifndef ZZIP_SIZEOF_LONG +#define ZZIP_SIZEOF_LONG 4 +#endif + +/* The number of bytes in type short */ +#ifndef ZZIP_SIZEOF_SHORT +#define ZZIP_SIZEOF_SHORT 2 +#endif + +/* Define to 1 if you have the ANSI C header files. */ +#ifndef ZZIP_STDC_HEADERS +#define ZZIP_STDC_HEADERS 1 +#endif + +/* Version number of package */ +#ifndef ZZIP_VERSION +#define ZZIP_VERSION "0.13.x" +#endif + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +/* #undef ZZIP_WORDS_BIGENDIAN */ + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef ZZIP__FILE_OFFSET_BITS */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef ZZIP__LARGE_FILES */ + +/* Define to `long long' if does not define. */ +/* #undef ZZIP___int64 */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef _zzip_const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#ifndef _zzip_inline +#define _zzip_inline __inline +#endif +#endif + +/* Define to `_zzip_off_t' if does not define. */ +#ifndef _zzip_off64_t +#define _zzip_off64_t __int64 +#endif + +/* Define to `long' if does not define. */ +#ifndef _zzip_off_t +#define _zzip_off_t long +#endif + +/* Define to equivalent of C99 restrict keyword, or to nothing if this is not + supported. Do not define if restrict is supported directly. */ +#ifndef _zzip_restrict +#define _zzip_restrict +#endif + +/* Define to `unsigned' if does not define. */ +/* #undef _zzip_size_t */ + +/* Define to `int' if does not define. */ +#ifndef _zzip_ssize_t +#define _zzip_ssize_t int +#endif + +/* once: _ZZIP__MSVC_H */ +#endif diff --git a/desmume/src/windows/zziplib/zzip/conf.h b/src/windows/zziplib/zzip/conf.h similarity index 92% rename from desmume/src/windows/zziplib/zzip/conf.h rename to src/windows/zziplib/zzip/conf.h index 640b0d9d0..7c3b2d89c 100644 --- a/desmume/src/windows/zziplib/zzip/conf.h +++ b/src/windows/zziplib/zzip/conf.h @@ -1,540 +1,540 @@ -/* - - * Here we postprocess autoconf generated prefix-config.h entries. - - * This is generally for things like "off_t" which is left undefined - - * in plain config.h if the host system does already have it but we do - - * need the prefix variant - so we add here a #define _zzip_off_t off_t - - * - - * This file is supposed to only carry '#define's. - - * See for definitions that might be seen by the compiler. - - * - - * Author: - - * Guido Draheim - - * - - * Copyright (c) 2001,2002,2003,2004 Guido Draheim - - * All rights reserved, - - * use under the restrictions of the - - * Lesser GNU General Public License - - * or alternatively the restrictions - - * of the Mozilla Public License 1.1 - - */ - - - -#ifndef _ZZIP_CONF_H - -#define _ZZIP_CONF_H 1 - - - -#if !defined ZZIP_OMIT_CONFIG_H - -# if defined _MSC_VER || defined __BORLANDC__ || defined __WATCOMC__ - -# include - -# elif defined ZZIP_1_H - -# include "zzip-1.h" - -# elif defined ZZIP_2_H - -# include "zzip-2.h" - -# elif defined ZZIP_3_H - -# include "zzip-3.h" - -# elif defined ZZIP_4_H - -# include "zzip-4.h" - -# elif defined ZZIP_5_H - -# include "zzip-5.h" - -# else /* autoconf generated */ - -# include - -# endif - -#endif - - - -/* especially win32 platforms do not declare off_t so far - see zzip-msvc.h */ - -#ifndef _zzip_off_t - -#ifdef ZZIP_off_t - -#define _zzip_off_t ZZIP_off_t - -#else - -#define _zzip_off_t off_t - -#endif - -#endif - - - -#ifndef _zzip_off64_t - -#ifdef ZZIP_off64_t - -#define _zzip_off64_t ZZIP_off64_t - -#else - -#define _zzip_off64_t off64_t - -#endif - -#endif - - - -/* currently unused, all current zziplib-users do have ansi-C94 compilers. */ - -#ifndef _zzip_const - -#ifdef ZZIP_const - -#define _zzip_const ZZIP_const - -#else - -#define _zzip_const const - -#endif - -#endif - -#ifndef _zzip_inline - -#ifdef ZZIP_inline - -#define _zzip_inline ZZIP_inline - -#else - -#define _zzip_inline inline - -#endif - -#endif - -#ifndef _zzip_restrict - -#ifdef ZZIP_restrict - -#define _zzip_restrict ZZIP_restrict - -#else - -#define _zzip_restrict restrict - -#endif - -#endif - -#if defined __linux__ && __GNUC__+0 >= 4 - -#define zzip__new__ __attribute__((malloc)) - -#elif defined __linux__ && __GNUC__+0 >= 3 && __GNUC_MINOR_+0 >= 3 - -#define zzip__new__ __attribute__((malloc)) - -#else - -#define zzip__new__ - -#endif - - - -#ifndef _zzip_size_t - -#ifdef ZZIP_size_t - -#define _zzip_size_t ZZIP_size_t - -#else - -#define _zzip_size_t size_t - -#endif - -#endif - -#ifndef _zzip_ssize_t - -#ifdef ZZIP_ssize_t - -#define _zzip_ssize_t ZZIP_ssize_t - -#else - -#define _zzip_ssize_t ssize_t - -#endif - -#endif - -#ifndef _zzip___int64 - -#ifdef ZZIP___int64 - -#define _zzip___int64 ZZIP___int64 - -#else - -#define _zzip___int64 long long - -#endif - -#endif - - - -/* whether this library shall use a 64bit off_t largefile variant in 64on32: */ - -/* (some exported names must be renamed to avoid bad calls after linking) */ - -#if defined ZZIP_LARGEFILE_SENSITIVE - -# if _FILE_OFFSET_BITS+0 == 64 - -# define ZZIP_LARGEFILE_RENAME - -# elif defined _LARGE_FILES /* used on older AIX to get at 64bit off_t */ - -# define ZZIP_LARGEFILE_RENAME - -# elif defined _ZZIP_LARGEFILE /* or simply use this one for zzip64 runs */ - -# define ZZIP_LARGEFILE_RENAME - -# endif - -#endif - - - -/* if the environment did not setup these for 64bit off_t largefile... */ - -#ifdef ZZIP_LARGEFILE_RENAME - -# ifndef _FILE_OFFSET_BITS - -# ifdef ZZIP__FILE_OFFSET_BITS /* == 64 */ - -# define _FILE_OFFSET_BITS ZZIP__FILE_OFFSET_BITS - -# endif - -# endif - -# ifndef _LARGE_FILES - -# ifdef ZZIP__LARGE_FILES /* == 1 */ - -# define _LARGE_FILES ZZIP__LARGE_FILES - -# endif - -# endif - -# ifndef _LARGEFILE_SOURCE - -# ifdef ZZIP__LARGEFILE_SOURCE /* == 1 */ - -# define _LARGEFILE_SOURCE ZZIP__LARGEFILE_SOURCE - -# endif - -# endif - -#endif - - - -#include - - - -/* mingw32msvc errno : would be in winsock.h */ - -#ifndef EREMOTE - -#define EREMOTE ESPIPE - -#endif - - - -#ifndef ELOOP - -#if defined EILSEQ - -#define ELOOP EILSEQ - -#else - -#define ELOOP ENOEXEC - -#endif - -#endif - - - -#if defined __WATCOMC__ - -#undef _zzip_inline - -#define _zzip_inline static - -#endif - - - -#if defined _MSC_VER || defined __WATCOMC__ - -#include - -#endif - - - -#ifdef _MSC_VER - -# if !__STDC__ - -# ifndef _zzip_lseek - -# define _zzip_lseek _lseek - -# endif - -# ifndef _zzip_read - -# define _zzip_read _read - -# endif - -# ifndef _zzip_write - -# define _zzip_write _write - -# endif - -# if 0 - -# ifndef _zzip_stat - -# define _zzip_stat _stat - -# endif - -# endif - -# endif /* !__STDC__ */ - -#endif - - /*MSVC*/ - - - -#if defined _MSC_VER || defined __WATCOMC__ - -# ifndef strcasecmp - -# define strcasecmp _stricmp - -# endif - -#endif - - - -# ifndef _zzip_lseek - -# define _zzip_lseek lseek - -# endif - - - -# ifndef _zzip_read - -# define _zzip_read read - -# endif - - - -# ifndef _zzip_write - -# define _zzip_write write - -# endif - - - -# if 0 - -# ifndef _zzip_stat - -# define _zzip_stat stat - -# endif - -# endif - - - - - -#if defined __GNUC__ || defined __attribute__ - -#define __zzip_attribute__(X) __attribute__(X) - -#else - -#define __zzip_attribute__(X) - -#endif - - - -#if defined ZZIP_EXPORTS || defined ZZIPLIB_EXPORTS - -# undef ZZIP_DLL - -#define ZZIP_DLL 1 - -#endif - - - -/* based on zconf.h : */ - -/* compile with -DZZIP_DLL for Windows DLL support */ - -#if defined ZZIP_DLL - -# if defined _WINDOWS || defined WINDOWS || defined _WIN32 - -/*# include */ - -# endif - -# if !defined _zzip_export && defined _MSC_VER && (defined WIN32 || defined _WIN32) - -# define _zzip_export __declspec(dllexport) /*WINAPI*/ - -# endif - -# if !defined _zzip_export && defined __BORLANDC__ - -# if __BORLANDC__ >= 0x0500 && defined WIN32 - -# include - -# define _zzip_export __declspec(dllexport) /*WINAPI*/ - -# else - -# if defined _Windows && defined __DLL__ - -# define _zzip_export _export - -# endif - -# endif - -# endif - -# if !defined _zzip_export && defined __GNUC__ - -# if defined __declspec - -# define _zzip_export extern __declspec(dllexport) - -# else - -# define _zzip_export extern - -# endif - -# endif - -# if !defined _zzip_export && defined __BEOS__ - -# define _zzip_export extern __declspec(export) - -# endif - -# if !defined _zzip_export && defined __WATCOMC__ - -# define _zzip_export extern __declspec(dllexport) - -# define ZEXPORT __syscall - -# define ZEXTERN extern - -# endif - -#endif - - - -#if !defined _zzip_export - -# if defined __GNUC__ /* || !defined HAVE_LIBZZIP */ - -# define _zzip_export extern - -# elif defined __declspec || (defined _MSC_VER && defined ZZIP_DLL) - -# define _zzip_export extern __declspec(dllimport) - -# else - -# define _zzip_export extern - -# endif - -#endif - - - -#endif - - - - - +/* + + * Here we postprocess autoconf generated prefix-config.h entries. + + * This is generally for things like "off_t" which is left undefined + + * in plain config.h if the host system does already have it but we do + + * need the prefix variant - so we add here a #define _zzip_off_t off_t + + * + + * This file is supposed to only carry '#define's. + + * See for definitions that might be seen by the compiler. + + * + + * Author: + + * Guido Draheim + + * + + * Copyright (c) 2001,2002,2003,2004 Guido Draheim + + * All rights reserved, + + * use under the restrictions of the + + * Lesser GNU General Public License + + * or alternatively the restrictions + + * of the Mozilla Public License 1.1 + + */ + + + +#ifndef _ZZIP_CONF_H + +#define _ZZIP_CONF_H 1 + + + +#if !defined ZZIP_OMIT_CONFIG_H + +# if defined _MSC_VER || defined __BORLANDC__ || defined __WATCOMC__ + +# include + +# elif defined ZZIP_1_H + +# include "zzip-1.h" + +# elif defined ZZIP_2_H + +# include "zzip-2.h" + +# elif defined ZZIP_3_H + +# include "zzip-3.h" + +# elif defined ZZIP_4_H + +# include "zzip-4.h" + +# elif defined ZZIP_5_H + +# include "zzip-5.h" + +# else /* autoconf generated */ + +# include + +# endif + +#endif + + + +/* especially win32 platforms do not declare off_t so far - see zzip-msvc.h */ + +#ifndef _zzip_off_t + +#ifdef ZZIP_off_t + +#define _zzip_off_t ZZIP_off_t + +#else + +#define _zzip_off_t off_t + +#endif + +#endif + + + +#ifndef _zzip_off64_t + +#ifdef ZZIP_off64_t + +#define _zzip_off64_t ZZIP_off64_t + +#else + +#define _zzip_off64_t off64_t + +#endif + +#endif + + + +/* currently unused, all current zziplib-users do have ansi-C94 compilers. */ + +#ifndef _zzip_const + +#ifdef ZZIP_const + +#define _zzip_const ZZIP_const + +#else + +#define _zzip_const const + +#endif + +#endif + +#ifndef _zzip_inline + +#ifdef ZZIP_inline + +#define _zzip_inline ZZIP_inline + +#else + +#define _zzip_inline inline + +#endif + +#endif + +#ifndef _zzip_restrict + +#ifdef ZZIP_restrict + +#define _zzip_restrict ZZIP_restrict + +#else + +#define _zzip_restrict restrict + +#endif + +#endif + +#if defined __linux__ && __GNUC__+0 >= 4 + +#define zzip__new__ __attribute__((malloc)) + +#elif defined __linux__ && __GNUC__+0 >= 3 && __GNUC_MINOR_+0 >= 3 + +#define zzip__new__ __attribute__((malloc)) + +#else + +#define zzip__new__ + +#endif + + + +#ifndef _zzip_size_t + +#ifdef ZZIP_size_t + +#define _zzip_size_t ZZIP_size_t + +#else + +#define _zzip_size_t size_t + +#endif + +#endif + +#ifndef _zzip_ssize_t + +#ifdef ZZIP_ssize_t + +#define _zzip_ssize_t ZZIP_ssize_t + +#else + +#define _zzip_ssize_t ssize_t + +#endif + +#endif + +#ifndef _zzip___int64 + +#ifdef ZZIP___int64 + +#define _zzip___int64 ZZIP___int64 + +#else + +#define _zzip___int64 long long + +#endif + +#endif + + + +/* whether this library shall use a 64bit off_t largefile variant in 64on32: */ + +/* (some exported names must be renamed to avoid bad calls after linking) */ + +#if defined ZZIP_LARGEFILE_SENSITIVE + +# if _FILE_OFFSET_BITS+0 == 64 + +# define ZZIP_LARGEFILE_RENAME + +# elif defined _LARGE_FILES /* used on older AIX to get at 64bit off_t */ + +# define ZZIP_LARGEFILE_RENAME + +# elif defined _ZZIP_LARGEFILE /* or simply use this one for zzip64 runs */ + +# define ZZIP_LARGEFILE_RENAME + +# endif + +#endif + + + +/* if the environment did not setup these for 64bit off_t largefile... */ + +#ifdef ZZIP_LARGEFILE_RENAME + +# ifndef _FILE_OFFSET_BITS + +# ifdef ZZIP__FILE_OFFSET_BITS /* == 64 */ + +# define _FILE_OFFSET_BITS ZZIP__FILE_OFFSET_BITS + +# endif + +# endif + +# ifndef _LARGE_FILES + +# ifdef ZZIP__LARGE_FILES /* == 1 */ + +# define _LARGE_FILES ZZIP__LARGE_FILES + +# endif + +# endif + +# ifndef _LARGEFILE_SOURCE + +# ifdef ZZIP__LARGEFILE_SOURCE /* == 1 */ + +# define _LARGEFILE_SOURCE ZZIP__LARGEFILE_SOURCE + +# endif + +# endif + +#endif + + + +#include + + + +/* mingw32msvc errno : would be in winsock.h */ + +#ifndef EREMOTE + +#define EREMOTE ESPIPE + +#endif + + + +#ifndef ELOOP + +#if defined EILSEQ + +#define ELOOP EILSEQ + +#else + +#define ELOOP ENOEXEC + +#endif + +#endif + + + +#if defined __WATCOMC__ + +#undef _zzip_inline + +#define _zzip_inline static + +#endif + + + +#if defined _MSC_VER || defined __WATCOMC__ + +#include + +#endif + + + +#ifdef _MSC_VER + +# if !__STDC__ + +# ifndef _zzip_lseek + +# define _zzip_lseek _lseek + +# endif + +# ifndef _zzip_read + +# define _zzip_read _read + +# endif + +# ifndef _zzip_write + +# define _zzip_write _write + +# endif + +# if 0 + +# ifndef _zzip_stat + +# define _zzip_stat _stat + +# endif + +# endif + +# endif /* !__STDC__ */ + +#endif + + /*MSVC*/ + + + +#if defined _MSC_VER || defined __WATCOMC__ + +# ifndef strcasecmp + +# define strcasecmp _stricmp + +# endif + +#endif + + + +# ifndef _zzip_lseek + +# define _zzip_lseek lseek + +# endif + + + +# ifndef _zzip_read + +# define _zzip_read read + +# endif + + + +# ifndef _zzip_write + +# define _zzip_write write + +# endif + + + +# if 0 + +# ifndef _zzip_stat + +# define _zzip_stat stat + +# endif + +# endif + + + + + +#if defined __GNUC__ || defined __attribute__ + +#define __zzip_attribute__(X) __attribute__(X) + +#else + +#define __zzip_attribute__(X) + +#endif + + + +#if defined ZZIP_EXPORTS || defined ZZIPLIB_EXPORTS + +# undef ZZIP_DLL + +#define ZZIP_DLL 1 + +#endif + + + +/* based on zconf.h : */ + +/* compile with -DZZIP_DLL for Windows DLL support */ + +#if defined ZZIP_DLL + +# if defined _WINDOWS || defined WINDOWS || defined _WIN32 + +/*# include */ + +# endif + +# if !defined _zzip_export && defined _MSC_VER && (defined WIN32 || defined _WIN32) + +# define _zzip_export __declspec(dllexport) /*WINAPI*/ + +# endif + +# if !defined _zzip_export && defined __BORLANDC__ + +# if __BORLANDC__ >= 0x0500 && defined WIN32 + +# include + +# define _zzip_export __declspec(dllexport) /*WINAPI*/ + +# else + +# if defined _Windows && defined __DLL__ + +# define _zzip_export _export + +# endif + +# endif + +# endif + +# if !defined _zzip_export && defined __GNUC__ + +# if defined __declspec + +# define _zzip_export extern __declspec(dllexport) + +# else + +# define _zzip_export extern + +# endif + +# endif + +# if !defined _zzip_export && defined __BEOS__ + +# define _zzip_export extern __declspec(export) + +# endif + +# if !defined _zzip_export && defined __WATCOMC__ + +# define _zzip_export extern __declspec(dllexport) + +# define ZEXPORT __syscall + +# define ZEXTERN extern + +# endif + +#endif + + + +#if !defined _zzip_export + +# if defined __GNUC__ /* || !defined HAVE_LIBZZIP */ + +# define _zzip_export extern + +# elif defined __declspec || (defined _MSC_VER && defined ZZIP_DLL) + +# define _zzip_export extern __declspec(dllimport) + +# else + +# define _zzip_export extern + +# endif + +#endif + + + +#endif + + + + + diff --git a/desmume/src/windows/zziplib/zzip/types.h b/src/windows/zziplib/zzip/types.h similarity index 97% rename from desmume/src/windows/zziplib/zzip/types.h rename to src/windows/zziplib/zzip/types.h index 6f9c6e6f9..0f570e2b4 100644 --- a/desmume/src/windows/zziplib/zzip/types.h +++ b/src/windows/zziplib/zzip/types.h @@ -1,57 +1,57 @@ -/* - * unlike in we are allowed to make up typedefs here, - * while over there only #defines are allowed - * - * Author: - * Guido Draheim - * - * Copyright (c) 2003,2004 Guido Draheim - * All rights reserved, - * usage allowed under the restrictions of the - * Lesser GNU General Public License - * or alternatively the restrictions - * of the Mozilla Public License 1.1 - * - * This file is usually the first to define some real symbols. If you do - * see some errors here then it is most likely the includepath is wrong - * or some includeheader is missing / unreadable on your system. - * (a) we include local headers with a "zzip/" prefix just to be sure - * to not actually get the wrong one. Consider to add `-I..` somewhere - * and especially VC/IDE users (who make up their own workspace files) - * should include the root source directory of this project. - * (b) size_t and ssize_t are sometimes found be `configure` but they are - * not in the usual places (ANSI C = stddef.h; UNIX = sys/types.h), so - * be sure to look for them and add the respective header as an #include. - */ - -#ifndef _ZZIP_TYPES_H_ -#define _ZZIP_TYPES_H_ - -#include -#include -#include /* size_t and friends */ -#ifdef ZZIP_HAVE_SYS_TYPES_H -#include /* bsd (mac) has size_t here */ -#endif -/* msvc6 has neither ssize_t (we assume "int") nor off_t (assume "long") */ - -typedef unsigned char zzip_byte_t; // especially zlib decoding data - -typedef _zzip_off64_t zzip_off64_t; -typedef _zzip_off_t zzip_off_t; -typedef _zzip_size_t zzip_size_t; /* Some error here? */ -typedef _zzip_ssize_t zzip_ssize_t; /* See notes above! */ - -/* in */ -typedef struct zzip_disk64_trailer ZZIP_DISK64_TRAILER; -typedef struct zzip_disk_trailer ZZIP_DISK_TRAILER; -typedef struct zzip_file_trailer ZZIP_FILE_TRAILER; -typedef struct zzip_root_dirent ZZIP_ROOT_DIRENT; -typedef struct zzip_file_header ZZIP_FILE_HEADER; -typedef struct zzip_disk_entry ZZIP_DISK_ENTRY; -typedef struct zzip_extra_block ZZIP_EXTRA_BLOCK; - - - -#endif - +/* + * unlike in we are allowed to make up typedefs here, + * while over there only #defines are allowed + * + * Author: + * Guido Draheim + * + * Copyright (c) 2003,2004 Guido Draheim + * All rights reserved, + * usage allowed under the restrictions of the + * Lesser GNU General Public License + * or alternatively the restrictions + * of the Mozilla Public License 1.1 + * + * This file is usually the first to define some real symbols. If you do + * see some errors here then it is most likely the includepath is wrong + * or some includeheader is missing / unreadable on your system. + * (a) we include local headers with a "zzip/" prefix just to be sure + * to not actually get the wrong one. Consider to add `-I..` somewhere + * and especially VC/IDE users (who make up their own workspace files) + * should include the root source directory of this project. + * (b) size_t and ssize_t are sometimes found be `configure` but they are + * not in the usual places (ANSI C = stddef.h; UNIX = sys/types.h), so + * be sure to look for them and add the respective header as an #include. + */ + +#ifndef _ZZIP_TYPES_H_ +#define _ZZIP_TYPES_H_ + +#include +#include +#include /* size_t and friends */ +#ifdef ZZIP_HAVE_SYS_TYPES_H +#include /* bsd (mac) has size_t here */ +#endif +/* msvc6 has neither ssize_t (we assume "int") nor off_t (assume "long") */ + +typedef unsigned char zzip_byte_t; // especially zlib decoding data + +typedef _zzip_off64_t zzip_off64_t; +typedef _zzip_off_t zzip_off_t; +typedef _zzip_size_t zzip_size_t; /* Some error here? */ +typedef _zzip_ssize_t zzip_ssize_t; /* See notes above! */ + +/* in */ +typedef struct zzip_disk64_trailer ZZIP_DISK64_TRAILER; +typedef struct zzip_disk_trailer ZZIP_DISK_TRAILER; +typedef struct zzip_file_trailer ZZIP_FILE_TRAILER; +typedef struct zzip_root_dirent ZZIP_ROOT_DIRENT; +typedef struct zzip_file_header ZZIP_FILE_HEADER; +typedef struct zzip_disk_entry ZZIP_DISK_ENTRY; +typedef struct zzip_extra_block ZZIP_EXTRA_BLOCK; + + + +#endif + diff --git a/desmume/src/windows/zziplib/zzip/zzip.h b/src/windows/zziplib/zzip/zzip.h similarity index 96% rename from desmume/src/windows/zziplib/zzip/zzip.h rename to src/windows/zziplib/zzip/zzip.h index 80cfc0cec..94adc49f7 100644 --- a/desmume/src/windows/zziplib/zzip/zzip.h +++ b/src/windows/zziplib/zzip/zzip.h @@ -1,268 +1,268 @@ -/* - * Author: - * Guido Draheim - * Tomi Ollila - * - * Copyright (c) 1999,2000,2001,2002,2003,2004 Guido Draheim - * All rights reserved, - * usage allowed under the restrictions of the - * Lesser GNU General Public License - * or alternatively the restrictions - * of the Mozilla Public License 1.1 - * - * if you see "unknown symbol" errors, check first that `-I ..` is part of - * your compiler options - a special hint to VC/IDE users who tend to make up - * their own workspace files. All includes look like #include , so - * you need to add an include path to the dir containing (!!) the ./zzip/ dir - */ - -#ifndef _ZZIP_ZZIP_H /* zziplib.h */ -#define _ZZIP_ZZIP_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* the zzip_error_t is also used to pass back ZLIB errors... */ -#define ZZIP_ERROR -4096 - -typedef enum -{ - ZZIP_NO_ERROR = 0, /* no error, may be used if user sets it. */ - ZZIP_OUTOFMEM = ZZIP_ERROR-20, /* out of memory */ - ZZIP_DIR_OPEN = ZZIP_ERROR-21, /* failed to open zipfile, see errno for details */ - ZZIP_DIR_STAT = ZZIP_ERROR-22, /* failed to fstat zipfile, see errno for details */ - ZZIP_DIR_SEEK = ZZIP_ERROR-23, /* failed to lseek zipfile, see errno for details */ - ZZIP_DIR_READ = ZZIP_ERROR-24, /* failed to read zipfile, see errno for details */ - ZZIP_DIR_TOO_SHORT = ZZIP_ERROR-25, - ZZIP_DIR_EDH_MISSING = ZZIP_ERROR-26, - ZZIP_DIRSIZE = ZZIP_ERROR-27, - ZZIP_ENOENT = ZZIP_ERROR-28, - ZZIP_UNSUPP_COMPR = ZZIP_ERROR-29, - ZZIP_CORRUPTED = ZZIP_ERROR-31, - ZZIP_UNDEF = ZZIP_ERROR-32, - ZZIP_DIR_LARGEFILE = ZZIP_ERROR-33 -} zzip_error_t; - -/* - * zzip_open flags. - */ -#define ZZIP_CASEINSENSITIVE O_APPEND /* do not use anymore. use CASLESS */ -#define ZZIP_IGNOREPATH O_TRUNC /* do not use anymore. use NOPATHS */ -#define ZZIP_EXTRAFLAGS (ZZIP_CASEINSENSITIVE|ZZIP_IGNOREPATH) - -/* zzip_open_ext_io o_modes flags : new style. use these from now on! */ -#define ZZIP_CASELESS (1<<12) /* ignore filename case inside zips */ -#define ZZIP_NOPATHS (1<<13) /* ignore subdir paths, just filename*/ -#define ZZIP_PREFERZIP (1<<14) /* try first zipped file, then real*/ -#define ZZIP_ONLYZIP (1<<16) /* try _only_ zipped file, skip real*/ -#define ZZIP_FACTORY (1<<17) /* old file handle is not closed */ -#define ZZIP_ALLOWREAL (1<<18) /* real files use default_io (magic) */ -#define ZZIP_THREADED (1<<19) /* try to be safe for multithreading */ - -/* - * zzip largefile renames - */ -#ifdef ZZIP_LARGEFILE_RENAME -#define zzip_telldir zzip_telldir64 -#define zzip_seekdir zzip_seekdir64 -#endif - -/* - * zzip typedefs - */ -/* zzip_strings_t ext[] = { ".zip", ".jar", ".pk3", 0 } */ -typedef char _zzip_const * _zzip_const zzip_strings_t; -typedef char _zzip_const zzip_char_t; -typedef struct zzip_dir ZZIP_DIR; -typedef struct zzip_file ZZIP_FILE; -typedef struct zzip_dirent ZZIP_DIRENT; -typedef struct zzip_dirent ZZIP_STAT; - -struct zzip_dirent -{ - int d_compr; /* compression method */ - int d_csize; /* compressed size */ - int st_size; /* file size / decompressed size */ - char * d_name; /* file name / strdupped name */ -}; - -/* - * Getting error strings - * zzip/err.c - */ -_zzip_export /* error in _opendir : */ -zzip_char_t* _zzip_calltype zzip_strerror(int errcode); -_zzip_export /* error in other functions : */ -zzip_char_t* _zzip_calltype zzip_strerror_of(ZZIP_DIR * dir); -_zzip_export /* error mapped to errno.h defines : */ -int zzip_errno(int errcode); - - -/* - * Functions to grab information from ZZIP_DIR/ZZIP_FILE structure - * (if ever needed) - * zzip/info.c - */ -_zzip_export -int _zzip_calltype zzip_error(ZZIP_DIR * dir); -_zzip_export -void _zzip_calltype zzip_seterror(ZZIP_DIR * dir, int errcode); -_zzip_export -zzip_char_t* zzip_compr_str(int compr); - -_zzip_export -ZZIP_DIR * _zzip_calltype zzip_dirhandle(ZZIP_FILE * fp); -_zzip_export -int _zzip_calltype zzip_dirfd(ZZIP_DIR * dir); -_zzip_export -int _zzip_calltype zzip_dir_real(ZZIP_DIR * dir); -_zzip_export -int _zzip_calltype zzip_file_real(ZZIP_FILE * fp); -_zzip_export -void* _zzip_calltype zzip_realdir(ZZIP_DIR * dir); -_zzip_export -int _zzip_calltype zzip_realfd(ZZIP_FILE * fp); - -/* - * zip handle management - * zzip/zip.c - */ -_zzip_export -ZZIP_DIR * _zzip_calltype zzip_dir_alloc(zzip_strings_t* fileext); -_zzip_export -int _zzip_calltype zzip_dir_free(ZZIP_DIR *); - -/* - * Opening/closing a zip archive - * zzip-zip.c - */ -_zzip_export -ZZIP_DIR * _zzip_calltype zzip_dir_fdopen(int fd, zzip_error_t * errcode_p); -_zzip_export -ZZIP_DIR * _zzip_calltype zzip_dir_open(zzip_char_t* filename, zzip_error_t * errcode_p); -_zzip_export -int _zzip_calltype zzip_dir_close(ZZIP_DIR * dir); -_zzip_export -int _zzip_calltype zzip_dir_read(ZZIP_DIR * dir, ZZIP_DIRENT * dirent); - - -/* - * Scanning files in zip archive - * zzip/dir.c - * zzip/zip.c - */ -_zzip_export -ZZIP_DIR * _zzip_calltype zzip_opendir(zzip_char_t* filename); -_zzip_export -int _zzip_calltype zzip_closedir(ZZIP_DIR * dir); -_zzip_export -ZZIP_DIRENT * _zzip_calltype zzip_readdir(ZZIP_DIR * dir); -_zzip_export -void _zzip_calltype zzip_rewinddir(ZZIP_DIR * dir); -_zzip_export -zzip_off_t _zzip_calltype zzip_telldir(ZZIP_DIR * dir); -_zzip_export -void _zzip_calltype zzip_seekdir(ZZIP_DIR * dir, zzip_off_t offset); - -/* - * 'opening', 'closing' and reading invidual files in zip archive. - * zzip/file.c - */ -_zzip_export -ZZIP_FILE * _zzip_calltype zzip_file_open(ZZIP_DIR * dir, zzip_char_t* name, int flags); -_zzip_export -int _zzip_calltype zzip_file_close(ZZIP_FILE * fp); -_zzip_export -zzip_ssize_t _zzip_calltype zzip_file_read(ZZIP_FILE * fp, void* buf, zzip_size_t len); - -_zzip_export -ZZIP_FILE * _zzip_calltype zzip_open(zzip_char_t* name, int flags); -_zzip_export -int _zzip_calltype zzip_close(ZZIP_FILE * fp); -_zzip_export -zzip_ssize_t _zzip_calltype zzip_read(ZZIP_FILE * fp, void * buf, zzip_size_t len); - -/* - * the stdc variant to open/read/close files. - Take note of the freopen() - * call as it may reuse an existing preparsed copy of a zip central directory - */ -_zzip_export -ZZIP_FILE* _zzip_calltype zzip_freopen(zzip_char_t* name, zzip_char_t* mode, ZZIP_FILE*); -_zzip_export -ZZIP_FILE* _zzip_calltype zzip_fopen(zzip_char_t* name, zzip_char_t* mode); -_zzip_export -zzip_size_t _zzip_calltype zzip_fread(void *ptr, zzip_size_t size, zzip_size_t nmemb, - ZZIP_FILE * file); -_zzip_export -int zzip_fclose(ZZIP_FILE * fp); - -/* - * seek and tell functions - */ -_zzip_export -int _zzip_calltype zzip_rewind(ZZIP_FILE *fp); -_zzip_export -zzip_off_t _zzip_calltype zzip_seek(ZZIP_FILE * fp, zzip_off_t offset, int whence); -_zzip_export -zzip_off_t _zzip_calltype zzip_tell(ZZIP_FILE * fp); - -/* - * reading info of a single file - * zzip/stat.c - */ -_zzip_export -int _zzip_calltype zzip_dir_stat(ZZIP_DIR * dir, zzip_char_t* name, - ZZIP_STAT * zs, int flags); -_zzip_export -int _zzip_calltype zzip_file_stat(ZZIP_FILE * fp, ZZIP_STAT * zs); -_zzip_export -int _zzip_calltype zzip_fstat(ZZIP_FILE * fp, ZZIP_STAT * zs); - -#ifdef ZZIP_LARGEFILE_RENAME -#define zzip_open_shared_io zzip_open_shared_io64 -#define zzip_open_ext_io zzip_open_ext_io64 -#define zzip_opendir_ext_io zzip_opendir_ext_io64 -#define zzip_dir_open_ext_io zzip_dir_open_ext_io64 -#define zzip_plugin_io_t zzip_plugin_io64_t -#endif - -/* - * all ext_io functions can be called with a default of ext/io == zero/zero - * which will default to a ".zip" extension and posix io of the system. - */ -typedef union _zzip_plugin_io _zzip_const * zzip_plugin_io_t; - -_zzip_export -ZZIP_FILE * _zzip_calltype zzip_open_shared_io(ZZIP_FILE* stream, - zzip_char_t* name, int o_flags, int o_modes, - zzip_strings_t* ext, zzip_plugin_io_t io); - -_zzip_export -ZZIP_FILE * _zzip_calltype zzip_open_ext_io(zzip_char_t* name, int o_flags, int o_modes, - zzip_strings_t* ext, zzip_plugin_io_t io); - -_zzip_export -ZZIP_DIR * _zzip_calltype zzip_opendir_ext_io(zzip_char_t* name, int o_modes, - zzip_strings_t* ext, zzip_plugin_io_t io); - -_zzip_export -ZZIP_DIR * _zzip_calltype zzip_dir_open_ext_io(zzip_char_t* filename, - zzip_error_t* errcode_p, - zzip_strings_t* ext, zzip_plugin_io_t io); - -/* zzip_file_open_ext_io => zzip_dir_open_ext_io + zzip_file_open */ - -#ifdef __cplusplus -}; -#endif - -#endif /* _ZZIPLIB_H */ - -/* - * Local variables: - * c-file-style: "stroustrup" - * End: - */ +/* + * Author: + * Guido Draheim + * Tomi Ollila + * + * Copyright (c) 1999,2000,2001,2002,2003,2004 Guido Draheim + * All rights reserved, + * usage allowed under the restrictions of the + * Lesser GNU General Public License + * or alternatively the restrictions + * of the Mozilla Public License 1.1 + * + * if you see "unknown symbol" errors, check first that `-I ..` is part of + * your compiler options - a special hint to VC/IDE users who tend to make up + * their own workspace files. All includes look like #include , so + * you need to add an include path to the dir containing (!!) the ./zzip/ dir + */ + +#ifndef _ZZIP_ZZIP_H /* zziplib.h */ +#define _ZZIP_ZZIP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* the zzip_error_t is also used to pass back ZLIB errors... */ +#define ZZIP_ERROR -4096 + +typedef enum +{ + ZZIP_NO_ERROR = 0, /* no error, may be used if user sets it. */ + ZZIP_OUTOFMEM = ZZIP_ERROR-20, /* out of memory */ + ZZIP_DIR_OPEN = ZZIP_ERROR-21, /* failed to open zipfile, see errno for details */ + ZZIP_DIR_STAT = ZZIP_ERROR-22, /* failed to fstat zipfile, see errno for details */ + ZZIP_DIR_SEEK = ZZIP_ERROR-23, /* failed to lseek zipfile, see errno for details */ + ZZIP_DIR_READ = ZZIP_ERROR-24, /* failed to read zipfile, see errno for details */ + ZZIP_DIR_TOO_SHORT = ZZIP_ERROR-25, + ZZIP_DIR_EDH_MISSING = ZZIP_ERROR-26, + ZZIP_DIRSIZE = ZZIP_ERROR-27, + ZZIP_ENOENT = ZZIP_ERROR-28, + ZZIP_UNSUPP_COMPR = ZZIP_ERROR-29, + ZZIP_CORRUPTED = ZZIP_ERROR-31, + ZZIP_UNDEF = ZZIP_ERROR-32, + ZZIP_DIR_LARGEFILE = ZZIP_ERROR-33 +} zzip_error_t; + +/* + * zzip_open flags. + */ +#define ZZIP_CASEINSENSITIVE O_APPEND /* do not use anymore. use CASLESS */ +#define ZZIP_IGNOREPATH O_TRUNC /* do not use anymore. use NOPATHS */ +#define ZZIP_EXTRAFLAGS (ZZIP_CASEINSENSITIVE|ZZIP_IGNOREPATH) + +/* zzip_open_ext_io o_modes flags : new style. use these from now on! */ +#define ZZIP_CASELESS (1<<12) /* ignore filename case inside zips */ +#define ZZIP_NOPATHS (1<<13) /* ignore subdir paths, just filename*/ +#define ZZIP_PREFERZIP (1<<14) /* try first zipped file, then real*/ +#define ZZIP_ONLYZIP (1<<16) /* try _only_ zipped file, skip real*/ +#define ZZIP_FACTORY (1<<17) /* old file handle is not closed */ +#define ZZIP_ALLOWREAL (1<<18) /* real files use default_io (magic) */ +#define ZZIP_THREADED (1<<19) /* try to be safe for multithreading */ + +/* + * zzip largefile renames + */ +#ifdef ZZIP_LARGEFILE_RENAME +#define zzip_telldir zzip_telldir64 +#define zzip_seekdir zzip_seekdir64 +#endif + +/* + * zzip typedefs + */ +/* zzip_strings_t ext[] = { ".zip", ".jar", ".pk3", 0 } */ +typedef char _zzip_const * _zzip_const zzip_strings_t; +typedef char _zzip_const zzip_char_t; +typedef struct zzip_dir ZZIP_DIR; +typedef struct zzip_file ZZIP_FILE; +typedef struct zzip_dirent ZZIP_DIRENT; +typedef struct zzip_dirent ZZIP_STAT; + +struct zzip_dirent +{ + int d_compr; /* compression method */ + int d_csize; /* compressed size */ + int st_size; /* file size / decompressed size */ + char * d_name; /* file name / strdupped name */ +}; + +/* + * Getting error strings + * zzip/err.c + */ +_zzip_export /* error in _opendir : */ +zzip_char_t* _zzip_calltype zzip_strerror(int errcode); +_zzip_export /* error in other functions : */ +zzip_char_t* _zzip_calltype zzip_strerror_of(ZZIP_DIR * dir); +_zzip_export /* error mapped to errno.h defines : */ +int zzip_errno(int errcode); + + +/* + * Functions to grab information from ZZIP_DIR/ZZIP_FILE structure + * (if ever needed) + * zzip/info.c + */ +_zzip_export +int _zzip_calltype zzip_error(ZZIP_DIR * dir); +_zzip_export +void _zzip_calltype zzip_seterror(ZZIP_DIR * dir, int errcode); +_zzip_export +zzip_char_t* zzip_compr_str(int compr); + +_zzip_export +ZZIP_DIR * _zzip_calltype zzip_dirhandle(ZZIP_FILE * fp); +_zzip_export +int _zzip_calltype zzip_dirfd(ZZIP_DIR * dir); +_zzip_export +int _zzip_calltype zzip_dir_real(ZZIP_DIR * dir); +_zzip_export +int _zzip_calltype zzip_file_real(ZZIP_FILE * fp); +_zzip_export +void* _zzip_calltype zzip_realdir(ZZIP_DIR * dir); +_zzip_export +int _zzip_calltype zzip_realfd(ZZIP_FILE * fp); + +/* + * zip handle management + * zzip/zip.c + */ +_zzip_export +ZZIP_DIR * _zzip_calltype zzip_dir_alloc(zzip_strings_t* fileext); +_zzip_export +int _zzip_calltype zzip_dir_free(ZZIP_DIR *); + +/* + * Opening/closing a zip archive + * zzip-zip.c + */ +_zzip_export +ZZIP_DIR * _zzip_calltype zzip_dir_fdopen(int fd, zzip_error_t * errcode_p); +_zzip_export +ZZIP_DIR * _zzip_calltype zzip_dir_open(zzip_char_t* filename, zzip_error_t * errcode_p); +_zzip_export +int _zzip_calltype zzip_dir_close(ZZIP_DIR * dir); +_zzip_export +int _zzip_calltype zzip_dir_read(ZZIP_DIR * dir, ZZIP_DIRENT * dirent); + + +/* + * Scanning files in zip archive + * zzip/dir.c + * zzip/zip.c + */ +_zzip_export +ZZIP_DIR * _zzip_calltype zzip_opendir(zzip_char_t* filename); +_zzip_export +int _zzip_calltype zzip_closedir(ZZIP_DIR * dir); +_zzip_export +ZZIP_DIRENT * _zzip_calltype zzip_readdir(ZZIP_DIR * dir); +_zzip_export +void _zzip_calltype zzip_rewinddir(ZZIP_DIR * dir); +_zzip_export +zzip_off_t _zzip_calltype zzip_telldir(ZZIP_DIR * dir); +_zzip_export +void _zzip_calltype zzip_seekdir(ZZIP_DIR * dir, zzip_off_t offset); + +/* + * 'opening', 'closing' and reading invidual files in zip archive. + * zzip/file.c + */ +_zzip_export +ZZIP_FILE * _zzip_calltype zzip_file_open(ZZIP_DIR * dir, zzip_char_t* name, int flags); +_zzip_export +int _zzip_calltype zzip_file_close(ZZIP_FILE * fp); +_zzip_export +zzip_ssize_t _zzip_calltype zzip_file_read(ZZIP_FILE * fp, void* buf, zzip_size_t len); + +_zzip_export +ZZIP_FILE * _zzip_calltype zzip_open(zzip_char_t* name, int flags); +_zzip_export +int _zzip_calltype zzip_close(ZZIP_FILE * fp); +_zzip_export +zzip_ssize_t _zzip_calltype zzip_read(ZZIP_FILE * fp, void * buf, zzip_size_t len); + +/* + * the stdc variant to open/read/close files. - Take note of the freopen() + * call as it may reuse an existing preparsed copy of a zip central directory + */ +_zzip_export +ZZIP_FILE* _zzip_calltype zzip_freopen(zzip_char_t* name, zzip_char_t* mode, ZZIP_FILE*); +_zzip_export +ZZIP_FILE* _zzip_calltype zzip_fopen(zzip_char_t* name, zzip_char_t* mode); +_zzip_export +zzip_size_t _zzip_calltype zzip_fread(void *ptr, zzip_size_t size, zzip_size_t nmemb, + ZZIP_FILE * file); +_zzip_export +int zzip_fclose(ZZIP_FILE * fp); + +/* + * seek and tell functions + */ +_zzip_export +int _zzip_calltype zzip_rewind(ZZIP_FILE *fp); +_zzip_export +zzip_off_t _zzip_calltype zzip_seek(ZZIP_FILE * fp, zzip_off_t offset, int whence); +_zzip_export +zzip_off_t _zzip_calltype zzip_tell(ZZIP_FILE * fp); + +/* + * reading info of a single file + * zzip/stat.c + */ +_zzip_export +int _zzip_calltype zzip_dir_stat(ZZIP_DIR * dir, zzip_char_t* name, + ZZIP_STAT * zs, int flags); +_zzip_export +int _zzip_calltype zzip_file_stat(ZZIP_FILE * fp, ZZIP_STAT * zs); +_zzip_export +int _zzip_calltype zzip_fstat(ZZIP_FILE * fp, ZZIP_STAT * zs); + +#ifdef ZZIP_LARGEFILE_RENAME +#define zzip_open_shared_io zzip_open_shared_io64 +#define zzip_open_ext_io zzip_open_ext_io64 +#define zzip_opendir_ext_io zzip_opendir_ext_io64 +#define zzip_dir_open_ext_io zzip_dir_open_ext_io64 +#define zzip_plugin_io_t zzip_plugin_io64_t +#endif + +/* + * all ext_io functions can be called with a default of ext/io == zero/zero + * which will default to a ".zip" extension and posix io of the system. + */ +typedef union _zzip_plugin_io _zzip_const * zzip_plugin_io_t; + +_zzip_export +ZZIP_FILE * _zzip_calltype zzip_open_shared_io(ZZIP_FILE* stream, + zzip_char_t* name, int o_flags, int o_modes, + zzip_strings_t* ext, zzip_plugin_io_t io); + +_zzip_export +ZZIP_FILE * _zzip_calltype zzip_open_ext_io(zzip_char_t* name, int o_flags, int o_modes, + zzip_strings_t* ext, zzip_plugin_io_t io); + +_zzip_export +ZZIP_DIR * _zzip_calltype zzip_opendir_ext_io(zzip_char_t* name, int o_modes, + zzip_strings_t* ext, zzip_plugin_io_t io); + +_zzip_export +ZZIP_DIR * _zzip_calltype zzip_dir_open_ext_io(zzip_char_t* filename, + zzip_error_t* errcode_p, + zzip_strings_t* ext, zzip_plugin_io_t io); + +/* zzip_file_open_ext_io => zzip_dir_open_ext_io + zzip_file_open */ + +#ifdef __cplusplus +}; +#endif + +#endif /* _ZZIPLIB_H */ + +/* + * Local variables: + * c-file-style: "stroustrup" + * End: + */ diff --git a/desmume/src/windows/zziplib/zziplib-2005-x32.lib b/src/windows/zziplib/zziplib-2005-x32.lib similarity index 100% rename from desmume/src/windows/zziplib/zziplib-2005-x32.lib rename to src/windows/zziplib/zziplib-2005-x32.lib diff --git a/desmume/src/windows/zziplib/zziplib-2005-x64.lib b/src/windows/zziplib/zziplib-2005-x64.lib similarity index 100% rename from desmume/src/windows/zziplib/zziplib-2005-x64.lib rename to src/windows/zziplib/zziplib-2005-x64.lib diff --git a/desmume/src/windows/zziplib/zziplib-2008-x32.lib b/src/windows/zziplib/zziplib-2008-x32.lib similarity index 100% rename from desmume/src/windows/zziplib/zziplib-2008-x32.lib rename to src/windows/zziplib/zziplib-2008-x32.lib diff --git a/desmume/src/windows/zziplib/zziplib-2008-x64.lib b/src/windows/zziplib/zziplib-2008-x64.lib similarity index 100% rename from desmume/src/windows/zziplib/zziplib-2008-x64.lib rename to src/windows/zziplib/zziplib-2008-x64.lib