From 6527dba71088fd3fcf47bb95ef74d7211586128e Mon Sep 17 00:00:00 2001 From: dborth Date: Thu, 16 Oct 2008 01:43:28 +0000 Subject: [PATCH] [What's New 2.0.1 - September 6, 2008] * Zapper support! Turn this on in the Controller Settings - most games require you to have the Zapper on Port 2. Thanks go to aksommerville whose previous work on the Zapper helped, and michniewski's cursor code * RAM game save support! Now you can save your games just like the NES did. By default game saves are saved/loaded automatically. This can be changed in the Preferences menu * Start/Select reversed mapping fixed for Wii controllers * Small bug fixes / improvements / tweaks --- Makefile.gc | 24 +- Makefile.wii | 22 +- readme.txt | 158 ++- source/fceultra/1.bat | 4 + source/fceultra/TODO.TXT | 8 + source/fceultra/fceu.c | 8 +- source/fceultra/fceu.dev | 1579 +++++++++++++++++++++++++ source/fceultra/fceu.layout | 506 ++++++++ source/fceultra/fds.c | 84 +- source/fceultra/file.c | 6 + source/fceultra/file.h | 6 - source/fceultra/ines.c | 159 ++- source/fceultra/input/cursor.c | 43 +- source/fceultra/linux/bits/wchar.h | 26 + source/fceultra/linux/bits/wordsize.h | 19 + source/fceultra/linux/features.h | 340 ++++++ source/fceultra/linux/gnu/stubs-32.h | 24 + source/fceultra/linux/gnu/stubs.h | 12 + source/fceultra/linux/inttypes.h | 461 ++++++++ source/fceultra/linux/stdint.h | 320 +++++ source/fceultra/state.c | 28 +- source/fceultra/unif.c | 28 +- source/fceultra/video.c | 4 +- source/ngc/button_mapping.c | 2 +- source/ngc/common.h | 2 +- source/ngc/dvd.c | 362 ++---- source/ngc/dvd.h | 9 +- source/ngc/fceuconfig.c | 16 +- source/ngc/fceuconfig.h | 5 +- source/ngc/fceugc.c | 32 +- source/ngc/fceuload.c | 104 +- source/ngc/fceuload.h | 2 +- source/ngc/fceuram.c | 40 +- source/ngc/fceustate.c | 29 +- source/ngc/fileop.c | 132 +-- source/ngc/fileop.h | 7 +- source/ngc/filesel.c | 235 +--- source/ngc/filesel.h | 15 +- source/ngc/gcaudio.c | 108 +- source/ngc/gcunzip.c | 581 ++++----- source/ngc/gcunzip.h | 9 +- source/ngc/gcvideo.c | 38 +- source/ngc/gcvideo.h | 1 - source/ngc/memcardop.c | 2 +- source/ngc/menu.c | 99 +- source/ngc/menudraw.c | 4 +- source/ngc/nesrom.s | 7 + source/ngc/pad.c | 133 +-- source/ngc/pad.h | 6 +- source/ngc/preferences.c | 19 +- source/ngc/rom/ROM.NES | Bin 0 -> 1048592 bytes source/ngc/smbop.c | 107 +- source/ngc/smbop.h | 11 +- source/sz/7zDecode.c | 236 ++-- source/sz/7zDecode.h | 6 +- source/sz/7zExtract.c | 58 +- source/sz/7zTypes.h | 14 +- 57 files changed, 4586 insertions(+), 1714 deletions(-) create mode 100644 source/fceultra/1.bat create mode 100644 source/fceultra/TODO.TXT create mode 100644 source/fceultra/fceu.dev create mode 100644 source/fceultra/fceu.layout create mode 100644 source/fceultra/linux/bits/wchar.h create mode 100644 source/fceultra/linux/bits/wordsize.h create mode 100644 source/fceultra/linux/features.h create mode 100644 source/fceultra/linux/gnu/stubs-32.h create mode 100644 source/fceultra/linux/gnu/stubs.h create mode 100644 source/fceultra/linux/inttypes.h create mode 100644 source/fceultra/linux/stdint.h create mode 100644 source/ngc/nesrom.s create mode 100644 source/ngc/rom/ROM.NES diff --git a/Makefile.gc b/Makefile.gc index 2786675f..217293b4 100644 --- a/Makefile.gc +++ b/Makefile.gc @@ -18,21 +18,23 @@ include $(DEVKITPPC)/gamecube_rules TARGET := fceugx_gc TARGETDIR := executables BUILD := build_gc -SOURCES := source/fceultra source/fceultra/boards \ - source/fceultra/drivers/common source/fceultra/input \ - source/fceultra/mappers source/fceultra/mbshare \ - source/ngc source/sz -DATA := data +SOURCES := source/fceultra \ + source/fceultra/boards source/fceultra/mappers source/fceultra/input \ + source/fceultra/mbshare source/fceultra/drivers/common source/fceultra/roms \ + source/ngc +DATA := data INCLUDES := source/fceultra source/ngc -LANG := ENGLISH # Supported languages: ENGLISH +# Specify language in all capitals +# Supported languages: ENGLISH +LANG := ENGLISH #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- -CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) -DNGC \ - -DHAVE_ASPRINTF -DSTDC -DFCEU_VERSION_NUMERIC=9812 \ - -D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \ - -DLANG_$(LANG) +CFLAGS = -g -Os -Wall $(MACHDEP) $(INCLUDE) -DFCEU_VERSION_NUMERIC=9812 -DNGC=1 \ + -DZLIB -DBIG_ENDIAN -DHAVE_ASPRINTF=1 -DSTDC \ + -D_SZ_ONE_DIRECTORY=1 -D_LZMA_IN_CB=1 -D_LZMA_OUT_READ \ + -DINTL_$(LANG) CXXFLAGS = $(CFLAGS) LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref @@ -40,7 +42,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lmxml -lbba -ltinysmb -lfat -lz -logc -lm -lfreetype +LIBS := -lpng -lmxml -lbba -ltinysmb -lfat -lz -logc -lm -lfreetype #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing diff --git a/Makefile.wii b/Makefile.wii index 874ade77..a58db79c 100644 --- a/Makefile.wii +++ b/Makefile.wii @@ -18,21 +18,23 @@ include $(DEVKITPPC)/wii_rules TARGET := fceugx_wii TARGETDIR := executables BUILD := build_wii -SOURCES := source/fceultra source/fceultra/boards \ - source/fceultra/drivers/common source/fceultra/input \ - source/fceultra/mappers source/fceultra/mbshare \ - source/ngc source/sz +SOURCES := source/fceultra \ + source/fceultra/boards source/fceultra/mappers source/fceultra/input \ + source/fceultra/mbshare source/fceultra/drivers/common source/fceultra/roms \ + source/ngc DATA := data INCLUDES := source/fceultra source/ngc -LANG := ENGLISH # Supported languages: ENGLISH +# Specify language in all capitals +# Supported languages: ENGLISH +LANG := ENGLISH #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- -CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) -DNGC -DWII_DVD \ - -DHAVE_ASPRINTF -DSTDC -DFCEU_VERSION_NUMERIC=9812 \ - -D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ \ - -DLANG_$(LANG) +CFLAGS = -g -Os -Wall $(MACHDEP) $(INCLUDE) -DFCEU_VERSION_NUMERIC=9812 -DNGC=1 \ + -DZLIB -DBIG_ENDIAN -DWORDS_BIGENDIAN -DHAVE_ASPRINTF=1 -DSTDC \ + -DWII_DVD -D_SZ_ONE_DIRECTORY=1 -D_LZMA_IN_CB=1 -D_LZMA_OUT_READ \ + -DINTL_$(LANG) CXXFLAGS = $(CFLAGS) LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref @@ -40,7 +42,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -ldi -lmxml -lfat -lwiiuse -lz -lbte -logc -lm -lfreetype -ltinysmb +LIBS := -ldi -lpng -lmxml -lfat -lwiiuse -lz -lbte -logc -lm -lfreetype -ltinysmb #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing diff --git a/readme.txt b/readme.txt index bd8e4771..4ce8e113 100644 --- a/readme.txt +++ b/readme.txt @@ -1,26 +1,25 @@ ¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤ - FCE Ultra GX - - Version 2.0.4 - http://code.google.com/p/fceugc + Version 2.0.1 (Under GPL License) ¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤ - + +-=[ Explanation ]=- + FCE Ultra GX is a modified port of the FCE Ultra 0.98.12 Nintendo Entertainment system for x86 (Windows/Linux) PC's. With it you can play NES games on your Wii/GameCube. Version 2 is a complete rewrite based on code from the -SNES9x GX project. +SNES9x GX and Genesis Plus GX projects. -=[ Features ]=- * Wiimote, Nunchuk, Classic, and Gamecube controller support -* iNES, FDS, VS, UNIF, and NSF ROM support -* 1-4 Player Support -* Zapper support +* 1-2 Player Support * RAM and State saving * Custom controller configurations -* SD, USB, DVD, SMB, GC Memory Card, Zip, and 7z support +* SD, USB, DVD, SMB, GC Memory Card, and Zip support * NES Compatibility Based on v0.98.12 * Sound Filters * Graphics Filters (GX Chipset, Cheesy and 2x) @@ -29,32 +28,7 @@ SNES9x GX project. |0O×øo· UPDATE HISTORY ·oø×O0| `¨•¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨' -[What's New 2.0.4 - October 15, 2008] -* Wii DVD fixed -* FDS BIOS loading works now -* FDS disk switching now consistently works with one button press -* FDS saving implemented -* 7z support -* Faster SD/USB (readahead cache enabled) -* VS coin now mapped to 1 button for VS zapper games -* Changed GC controller mappings - Select - Z, Start - Start, - Home - Start+A, Special - L - -[What's New 2.0.3 - October 1, 2008] -* Complete rewrite of loading code - FDS / UNIF / NSF support added! -* VS games work (coin insert submitted by pakitovic) -* Mapping of 'Special' commands - VS coin insert, FDS switch disk (default A) -* 480p and DVD now available for GameCube -* Improved stability - less crashes! - -[What's New 2.0.2 - September 19, 2008] -* Fixed network freeze-up problem -* Zapper now mapped to A and B -* Fixed auto-save feature -* Performance slowdowns on Gamecube should be fixed -* Will now attempt to load old save states with CRC filename - -[What's New 2.0.1 - September 6, 2008] +[What's New 2.0.1] * Zapper support! Turn this on in the Controller Settings - most games require you to have the Zapper on Port 2. Thanks go to aksommerville whose previous work on the Zapper helped, and michniewski's cursor code @@ -64,7 +38,7 @@ SNES9x GX project. * Start/Select reversed mapping fixed for Wii controllers * Small bug fixes / improvements / tweaks -[What's New 2.0.0 - September 1, 2008] +[What's New 2.0.0] * Complete rewrite based on code from SNES9x GX and Genesis Plus GX * Wiimote, Nunchuk, and Classic controller support @@ -98,34 +72,22 @@ executables Contains Gamecube / Wii DOL files fceugx Contains the directory structure required for storing roms and saves (see below) ------------------------------- -Loading / Running the Emulator: ------------------------------- - -Wii - Via Homebrew Channel: --------------------- -The most popular method of running homebrew on the Wii is through the Homebrew -Channel. If you already have the channel installed, just copy over the apps -folder included in the archive into the root of your SD card. - -Remember to also create the fceugx directory structure required. See above. - -If you haven't installed the Homebrew Channel yet, read about how to here: -http://hbc.hackmii.com/ - -Gamecube: ---------- -You can load FCEUGX via sdload and an SD card in slot A, or by streaming -it to your Gamecube, or by booting a bootable DVD with FCEUGX on it. -This document doesn't cover how to do any of that. A good source for information -on these topics is the tehskeen forums: http://www.tehskeen.com/forums/ - ---------------------------- -ROMS, Preferences, and Saves: +Directory Structure Setup ---------------------------- By default, roms are loaded from "fceugx/roms/" and saves / preferences are stored in "fceugx/saves/". +Therefore you should have the following folder structure at the root +of your load device (SD/USB/SMB): + + fceugx/ + roms/ + saves/ + +---------------------------- +ROMS, Preferences, and Saves: +---------------------------- Wii ---------- @@ -144,14 +106,27 @@ You can load roms from DVD or SD card. If you create a bootable DVD of FCEUGX you can put roms on the same DVD. You may save preferences and game data to SD or Memory Card. --=[ Famicom Disk System (FDS) ]=- +------------------------------ +Loading / Running the Emulator: +------------------------------ -FCE Ultra GX supports loading FDS games. The FDS BIOS is required - put it -in your roms folder, and name it disksys.rom (should be 8 KB in size). -You can switch disks using the A button (by default). The mapped button -can be changed under Controller Configuration ('Special' button). -Compatibility is limited, so check that the game in question works on -FCE Ultra 0.98.12 for Windows before asking for help. +Wii - Via Homebrew Channel: +-------------------- +The most popular method of running homebrew on the Wii is through the Homebrew +Channel. If you already have the channel installed, just copy over the apps folder +included in the archive into the root of your SD card. + +Remember to also create the fceugx directory structure required. See above. + +If you haven't installed the Homebrew Channel yet, read about how to here: +http://hbc.hackmii.com/ + +Gamecube: +--------- +You can load FCEUGX via sdload and an SD card in slot A, or by streaming +it to your Gamecube, or by booting a bootable DVD with FCEUGX on it. +This document doesn't cover how to do any of that. A good source for information +on these topics is the tehskeen forums: http://www.tehskeen.com/forums/ -=[ Supported Mappers ]=- @@ -175,6 +150,59 @@ Palette - The colors used while viewing the game: zaphod-smb . vs-drmar . vs-cv . vs-smb Timing - NTSC or PAL (Depends if you're running a PAL or NTSC game) + +×—–­—–­—–­—–­ –­—–­—–­—–­—–­—–­—–­—–­—–­—–­— ­—–­—–­—–­—–­—–­—–­—–­—-­—–­-–•¬ +|0O×øo· UPDATE HISTORY (1.0.x) ·oø×O0| +`¨•¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨ ¨¨¨¨¨¨¨¨¨¨¨¨¨' + +What's new [20080331] + ++[Askot] +- Fixed/changed SDCARD slot selection for searching roms, at + start you will be prompted for this option. +- Code cleanup. + ++[dsbomb] +- Added Wii mode support. +- Give a "Bad cartridge" error instead of locking up. +- Joystick fixes due to libogc r14's changed stick values +- Rearranged menu to make more sense, and consistent with Snes9x +- Add "Reboot" menu option +- Removed "." directory from SD card listing, it's pointless +- Expand DVD reading to DVD9 size (once DVDs are working again) +- Added option to go back a menu by pressing B. + +What's new? Askot [20080326] +- Added saving state in SD Card (State files will be saved in root of SDCARD). + *Note: I can't make it work to save in root:\fceu\saves, so help needed. +- Added SDCARD slot selection for searching roms, meaning, you can search roms + from SDCARD SLOT A & SLOT B (Beta, meaning, buggy, but works). +- For standarization, you must create folders root:\fceu\roms to read NES + roms files from SDCARD. +- Added C-Left to call Menu. +- Reading files from SD Card it's faster, now they're called from cache + after first reading. +- Menu in saving STATE file changed to choose SLOT, DEVICE, Save STATE, + Load STATE, Return to previous. +- Added option PSO/SD Reload to menu, still works (START+B+X) +- Modified controls when going into the rom selection menu (DVD or + SDCARD): + + Use B to quit selection list. + + Use L/R triggrers or Pad Left/Right to go down/up one full page. +- Some menu rearrangment and a little of sourcecode cleanup: + + Everytime you pressed B button on any option, playgame started, not anymore + until you select Play Game option. + +What's new? asako [20070831] +- modify mmc3 code for Chinese pirated rom +- add some Chinese pirated rom mappers + +What's new? _svpe_ [20070607] +- Wii support (PAL50 fix, 1.35GiB restriction removed) +- 7zip ROM loading support from the DVD (not from a SD card!!) +- dvd_read fix (the read data was always copied to readbuffer instead of *dst) +- slower file selection when using the D-Pad (I didn't like the selection to go +as fast as in the latest release) ¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤ diff --git a/source/fceultra/1.bat b/source/fceultra/1.bat new file mode 100644 index 00000000..81f658e7 --- /dev/null +++ b/source/fceultra/1.bat @@ -0,0 +1,4 @@ +del C:\devkitPro\devkitPPC\Fc\build\ines*.* +del C:\devkitPro\devkitPPC\Fc\build\mmc3*.* +del C:\devkitPro\devkitPPC\Fc\build\unif*.* +del C:\devkitPro\devkitPPC\Fc\build\simple*.* \ No newline at end of file diff --git a/source/fceultra/TODO.TXT b/source/fceultra/TODO.TXT new file mode 100644 index 00000000..ef94ff29 --- /dev/null +++ b/source/fceultra/TODO.TXT @@ -0,0 +1,8 @@ + FCEU-GC +--------- + +TODO + +1. Remove ZLIB Dependencies +2. Remove NetPlay Dependencies +3. Remove all File I/O diff --git a/source/fceultra/fceu.c b/source/fceultra/fceu.c index 6fe6db9d..4f2c856f 100644 --- a/source/fceultra/fceu.c +++ b/source/fceultra/fceu.c @@ -424,7 +424,7 @@ FCEUS FSettings; void FCEU_printf(char *format, ...) { - /*char temp[2048]; + char temp[2048]; va_list ap; @@ -432,12 +432,12 @@ void FCEU_printf(char *format, ...) vsprintf(temp,format,ap); FCEUD_Message(temp); - va_end(ap);*/ + va_end(ap); } void FCEU_PrintError(char *format, ...) { -/* char temp[2048]; + char temp[2048]; va_list ap; @@ -445,7 +445,7 @@ void FCEU_PrintError(char *format, ...) vsprintf(temp,format,ap); FCEUD_PrintError(temp); - va_end(ap);*/ + va_end(ap); } void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall) diff --git a/source/fceultra/fceu.dev b/source/fceultra/fceu.dev new file mode 100644 index 00000000..c962c1cc --- /dev/null +++ b/source/fceultra/fceu.dev @@ -0,0 +1,1579 @@ +[Project] +FileName=fceu.dev +Name=fceu +UnitCount=152 +Type=1 +Ver=1 +ObjFiles= +Includes= +Libs= +PrivateResource= +ResourceIncludes= +MakeIncludes= +Compiler=-DFCEU_VERSION_NUMERIC=9812_@@_-DZLIB=1_@@_-DNETWORK=0_@@_-DLSB_FIRST_@@_ +CppCompiler= +Linker=_@@_../../Dev-Cpp/lib/libz.lib_@@_ +IsCpp=0 +Icon= +ExeOutput= +ObjectOutput= +OverrideOutput=0 +OverrideOutputName=fceu.exe +HostApplication= +Folders=boards,drivers,fceu,input,mappers,mbshare,palettes +CommandLine= +UseCustomMakefile=0 +CustomMakefile= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000000000000000100 + +[Unit1] +FileName=drivers\Minimal\main.c +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=boards\8237.c +CompileCpp=0 +Folder=boards +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit3] +FileName=boards\h2288.c +CompileCpp=0 +Folder=boards +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit4] +FileName=boards\malee.c +CompileCpp=0 +Folder=boards +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit5] +FileName=boards\novel.c +CompileCpp=0 +Folder=boards +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit6] +FileName=boards\sachen.c +CompileCpp=0 +Folder=boards +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit7] +FileName=boards\simple.c +CompileCpp=0 +Folder=boards +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit8] +FileName=boards\super24.c +CompileCpp=0 +Folder=boards +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit9] +FileName=boards\supervision.c +CompileCpp=0 +Folder=boards +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit10] +FileName=mappers\6.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit11] +FileName=mappers\8.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit12] +FileName=mappers\15.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit13] +FileName=mappers\16.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit14] +FileName=mappers\17.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit15] +FileName=mappers\18.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit16] +FileName=mappers\21.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit17] +FileName=mappers\22.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit18] +FileName=mappers\23.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit19] +FileName=mappers\24and26.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit20] +FileName=mappers\25.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit21] +FileName=mappers\32.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit22] +FileName=mappers\33.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit23] +FileName=mappers\40.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit24] +FileName=mappers\41.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit25] +FileName=mappers\42.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit26] +FileName=mappers\43.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit27] +FileName=mappers\46.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit28] +FileName=mappers\50.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit29] +FileName=mappers\51.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit30] +FileName=mappers\57.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit31] +FileName=mappers\58.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit32] +FileName=mappers\59.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit33] +FileName=mappers\60.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit34] +FileName=mappers\61.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit35] +FileName=mappers\62.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit36] +FileName=mappers\65.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit37] +FileName=mappers\67.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit38] +FileName=mappers\68.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit39] +FileName=mappers\69.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit40] +FileName=mappers\71.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit41] +FileName=mappers\72.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit42] +FileName=mappers\73.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit43] +FileName=mappers\75.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit44] +FileName=mappers\76.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit45] +FileName=mappers\77.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit46] +FileName=mappers\79.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit47] +FileName=mappers\80.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit48] +FileName=mappers\82.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit49] +FileName=mappers\83.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit50] +FileName=mappers\85.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit51] +FileName=mappers\86.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit52] +FileName=mappers\88.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit53] +FileName=mappers\89.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit54] +FileName=mappers\91.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit55] +FileName=mappers\92.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit56] +FileName=mappers\95.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit57] +FileName=mappers\97.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit58] +FileName=mappers\99.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit59] +FileName=mappers\112.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit60] +FileName=mappers\113.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit61] +FileName=mappers\114.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit62] +FileName=mappers\117.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit63] +FileName=mappers\151.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit64] +FileName=mappers\180.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit65] +FileName=mappers\182.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit66] +FileName=mappers\184.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit67] +FileName=mappers\187.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit68] +FileName=mappers\189.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit69] +FileName=mappers\193.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit70] +FileName=mappers\200.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit71] +FileName=mappers\201.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit72] +FileName=mappers\202.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit73] +FileName=mappers\203.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit74] +FileName=mappers\208.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit75] +FileName=mappers\225.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit76] +FileName=mappers\226.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit77] +FileName=mappers\227.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit78] +FileName=mappers\228.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit79] +FileName=mappers\229.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit80] +FileName=mappers\230.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit81] +FileName=mappers\231.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit82] +FileName=mappers\232.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit83] +FileName=mappers\234.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit84] +FileName=mappers\235.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit85] +FileName=mappers\240.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit86] +FileName=mappers\241.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit87] +FileName=mappers\242.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit88] +FileName=mappers\244.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit89] +FileName=mappers\246.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit90] +FileName=mappers\248.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit91] +FileName=mappers\255.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit92] +FileName=mappers\emu2413.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit93] +FileName=mappers\mmc2and4.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit94] +FileName=mappers\simple.c +CompileCpp=0 +Folder=mappers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit95] +FileName=input\arkanoid.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit96] +FileName=input\bworld.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit97] +FileName=input\cursor.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit98] +FileName=input\fkb.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit99] +FileName=input\ftrainer.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit100] +FileName=input\hypershot.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit101] +FileName=input\mahjong.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit102] +FileName=input\oekakids.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit103] +FileName=input\powerpad.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit104] +FileName=input\quiz.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit105] +FileName=input\shadow.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit106] +FileName=input\toprider.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit107] +FileName=input\zapper.c +CompileCpp=0 +Folder=input +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit108] +FileName=drivers\common\args.c +CompileCpp=0 +Folder=drivers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit109] +FileName=drivers\common\cheat.c +CompileCpp=0 +Folder=drivers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit111] +FileName=drivers\common\hq3x.c +CompileCpp=0 +Folder=drivers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit112] +FileName=drivers\common\scale2x.c +CompileCpp=0 +Folder=drivers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit113] +FileName=drivers\common\scale3x.c +CompileCpp=0 +Folder=drivers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit114] +FileName=drivers\common\scalebit.c +CompileCpp=0 +Folder=drivers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit115] +FileName=drivers\common\vidblit.c +CompileCpp=0 +Folder=drivers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit116] +FileName=mbshare\90.c +CompileCpp=0 +Folder=mbshare +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit117] +FileName=mbshare\164.c +CompileCpp=0 +Folder=mbshare +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit118] +FileName=mbshare\deirom.c +CompileCpp=0 +Folder=mbshare +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit119] +FileName=mbshare\mmc1.c +CompileCpp=0 +Folder=mbshare +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit120] +FileName=mbshare\mmc3.c +CompileCpp=0 +Folder=mbshare +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit121] +FileName=mbshare\mmc5.c +CompileCpp=0 +Folder=mbshare +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit122] +FileName=mbshare\n106.c +CompileCpp=0 +Folder=mbshare +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit123] +FileName=mbshare\tengen.c +CompileCpp=0 +Folder=mbshare +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit125] +FileName=cheat.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +AutoIncBuildNr=0 + +[Unit110] +FileName=drivers\common\hq2x.c +CompileCpp=0 +Folder=drivers +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit126] +FileName=crc32.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit127] +FileName=debug.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit128] +FileName=endian.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit129] +FileName=fceu.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit130] +FileName=fceustr.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit131] +FileName=fds.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit132] +FileName=file.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit133] +FileName=filter.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit134] +FileName=general.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit135] +FileName=ines.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit136] +FileName=input.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit137] +FileName=md5.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit138] +FileName=memory.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit139] +FileName=movie.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit140] +FileName=netplay.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit141] +FileName=nsf.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit142] +FileName=palette.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit143] +FileName=ppu.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit144] +FileName=sound.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit145] +FileName=state.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit148] +FileName=vsuni.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit149] +FileName=wave.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit150] +FileName=x6502.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit151] +FileName=unzip.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit152] +FileName=drivers\Minimal\common.h +CompileCpp=0 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit153] +FileName=x6502.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit146] +FileName=unif.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit124] +FileName=cart.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit147] +FileName=video.c +CompileCpp=0 +Folder=fceu +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/source/fceultra/fceu.layout b/source/fceultra/fceu.layout new file mode 100644 index 00000000..d0ceccd9 --- /dev/null +++ b/source/fceultra/fceu.layout @@ -0,0 +1,506 @@ +[Editor_109] +CursorCol=1 +CursorRow=1 +TopLine=1 +LeftChar=1 +Open=0 +Top=0 +[Editors] +Focused=-1 +Order=132,-1 +[Editor_0] +Open=1 +Top=1 +CursorCol=2 +CursorRow=101 +TopLine=72 +LeftChar=1 +[Editor_1] +Open=0 +Top=0 +CursorCol=1 +CursorRow=21 +TopLine=1 +LeftChar=1 +[Editor_2] +Open=0 +Top=0 +[Editor_3] +Open=0 +Top=0 +[Editor_4] +Open=0 +Top=0 +[Editor_5] +Open=0 +Top=0 +[Editor_6] +Open=0 +Top=0 +[Editor_7] +Open=0 +Top=0 +[Editor_8] +Open=0 +Top=0 +[Editor_9] +Open=0 +Top=0 +[Editor_10] +Open=0 +Top=0 +[Editor_11] +Open=0 +Top=0 +[Editor_12] +Open=0 +Top=0 +[Editor_13] +Open=0 +Top=0 +[Editor_14] +Open=0 +Top=0 +[Editor_15] +Open=0 +Top=0 +[Editor_16] +Open=0 +Top=0 +[Editor_17] +Open=0 +Top=0 +[Editor_18] +Open=0 +Top=0 +[Editor_19] +Open=0 +Top=0 +[Editor_20] +Open=0 +Top=0 +[Editor_21] +Open=0 +Top=0 +[Editor_22] +Open=0 +Top=0 +[Editor_23] +Open=0 +Top=0 +[Editor_24] +Open=0 +Top=0 +[Editor_25] +Open=0 +Top=0 +[Editor_26] +Open=0 +Top=0 +[Editor_27] +Open=0 +Top=0 +[Editor_28] +Open=0 +Top=0 +[Editor_29] +Open=0 +Top=0 +[Editor_30] +Open=0 +Top=0 +[Editor_31] +Open=0 +Top=0 +[Editor_32] +Open=0 +Top=0 +[Editor_33] +Open=0 +Top=0 +[Editor_34] +Open=0 +Top=0 +[Editor_35] +Open=0 +Top=0 +[Editor_36] +Open=0 +Top=0 +[Editor_37] +Open=0 +Top=0 +[Editor_38] +Open=0 +Top=0 +[Editor_39] +Open=0 +Top=0 +[Editor_40] +Open=0 +Top=0 +[Editor_41] +Open=0 +Top=0 +[Editor_42] +Open=0 +Top=0 +[Editor_43] +Open=0 +Top=0 +[Editor_44] +Open=0 +Top=0 +[Editor_45] +Open=0 +Top=0 +[Editor_46] +Open=0 +Top=0 +[Editor_47] +Open=0 +Top=0 +[Editor_48] +Open=0 +Top=0 +[Editor_49] +Open=0 +Top=0 +[Editor_50] +Open=0 +Top=0 +[Editor_51] +Open=0 +Top=0 +[Editor_52] +Open=0 +Top=0 +[Editor_53] +Open=0 +Top=0 +[Editor_54] +Open=0 +Top=0 +[Editor_55] +Open=0 +Top=0 +[Editor_56] +Open=0 +Top=0 +[Editor_57] +Open=0 +Top=0 +[Editor_58] +Open=0 +Top=0 +[Editor_59] +Open=0 +Top=0 +[Editor_60] +Open=0 +Top=0 +[Editor_61] +Open=0 +Top=0 +[Editor_62] +Open=0 +Top=0 +[Editor_63] +Open=0 +Top=0 +[Editor_64] +Open=0 +Top=0 +[Editor_65] +Open=0 +Top=0 +[Editor_66] +Open=0 +Top=0 +[Editor_67] +Open=0 +Top=0 +[Editor_68] +Open=0 +Top=0 +[Editor_69] +Open=0 +Top=0 +[Editor_70] +Open=0 +Top=0 +[Editor_71] +Open=0 +Top=0 +[Editor_72] +Open=0 +Top=0 +[Editor_73] +Open=0 +Top=0 +[Editor_74] +Open=0 +Top=0 +[Editor_75] +Open=0 +Top=0 +[Editor_76] +Open=0 +Top=0 +[Editor_77] +Open=0 +Top=0 +[Editor_78] +Open=0 +Top=0 +[Editor_79] +Open=0 +Top=0 +[Editor_80] +Open=0 +Top=0 +[Editor_81] +Open=0 +Top=0 +[Editor_82] +Open=0 +Top=0 +[Editor_83] +Open=0 +Top=0 +[Editor_84] +Open=0 +Top=0 +[Editor_85] +Open=0 +Top=0 +[Editor_86] +Open=0 +Top=0 +[Editor_87] +Open=0 +Top=0 +[Editor_88] +Open=0 +Top=0 +[Editor_89] +Open=0 +Top=0 +[Editor_90] +Open=0 +Top=0 +[Editor_91] +Open=0 +Top=0 +[Editor_92] +Open=0 +Top=0 +[Editor_93] +Open=0 +Top=0 +CursorCol=2 +CursorRow=106 +TopLine=90 +LeftChar=1 +[Editor_94] +Open=0 +Top=0 +[Editor_95] +Open=0 +Top=0 +[Editor_96] +Open=0 +Top=0 +[Editor_97] +Open=0 +Top=0 +[Editor_98] +Open=0 +Top=0 +[Editor_99] +Open=0 +Top=0 +[Editor_100] +Open=0 +Top=0 +[Editor_101] +Open=0 +Top=0 +[Editor_102] +Open=0 +Top=0 +[Editor_103] +Open=0 +Top=0 +[Editor_104] +Open=0 +Top=0 +[Editor_105] +Open=0 +Top=0 +[Editor_106] +Open=0 +Top=0 +[Editor_107] +Open=0 +Top=0 +[Editor_108] +Open=0 +Top=0 +[Editor_110] +Open=0 +Top=0 +[Editor_111] +Open=0 +Top=0 +CursorCol=1 +CursorRow=1 +TopLine=1 +LeftChar=1 +[Editor_112] +Open=0 +Top=0 +[Editor_113] +Open=0 +Top=0 +CursorCol=1 +CursorRow=1 +TopLine=358 +LeftChar=1 +[Editor_114] +Open=0 +Top=0 +CursorCol=1 +CursorRow=1 +TopLine=816 +LeftChar=1 +[Editor_115] +Open=0 +Top=0 +[Editor_116] +Open=0 +Top=0 +[Editor_117] +Open=0 +Top=0 +[Editor_118] +Open=0 +Top=0 +[Editor_119] +Open=0 +Top=0 +[Editor_120] +Open=0 +Top=0 +[Editor_121] +Open=0 +Top=0 +[Editor_122] +Open=0 +Top=0 +[Editor_123] +Open=0 +Top=0 +[Editor_124] +Open=0 +Top=0 +[Editor_125] +Open=0 +Top=0 +[Editor_126] +Open=0 +Top=0 +[Editor_127] +Open=0 +Top=0 +[Editor_128] +Open=0 +Top=0 +[Editor_129] +Open=0 +Top=0 +[Editor_130] +Open=0 +Top=0 +[Editor_131] +Open=0 +Top=0 +[Editor_132] +Open=1 +Top=0 +CursorCol=20 +CursorRow=8 +TopLine=1 +LeftChar=1 +[Editor_133] +Open=0 +Top=0 +CursorCol=34 +CursorRow=15 +TopLine=1 +LeftChar=1 +[Editor_134] +Open=0 +Top=0 +[Editor_135] +Open=0 +Top=0 +[Editor_136] +Open=0 +Top=0 +[Editor_137] +Open=0 +Top=0 +[Editor_138] +Open=0 +Top=0 +[Editor_139] +Open=0 +Top=0 +[Editor_140] +Open=0 +Top=0 +[Editor_141] +Open=0 +Top=0 +[Editor_142] +Open=0 +Top=0 +[Editor_143] +Open=0 +Top=0 +[Editor_144] +Open=0 +Top=0 +[Editor_145] +Open=0 +Top=0 +CursorCol=1 +CursorRow=3 +TopLine=1 +LeftChar=1 +[Editor_146] +Open=0 +Top=0 +[Editor_147] +Open=0 +Top=0 +[Editor_148] +Open=0 +Top=0 +[Editor_149] +Open=0 +Top=0 +[Editor_150] +Open=0 +Top=0 +[Editor_151] +Open=1 +Top=0 +CursorCol=26 +CursorRow=11 +TopLine=2 +LeftChar=1 +[Editor_152] +Open=0 +Top=0 diff --git a/source/fceultra/fds.c b/source/fceultra/fds.c index 66c5e8a4..5a98d6b5 100644 --- a/source/fceultra/fds.c +++ b/source/fceultra/fds.c @@ -67,7 +67,7 @@ static int32 IRQLatch,IRQCount; static uint8 IRQa; static void FDSClose(void); -uint8 FDSBIOS[8192]; +static uint8 FDSBIOS[8192]; /* Original disk data backup, to help in creating save states. */ static uint8 *diskdatao[8]={0,0,0,0,0,0,0,0}; @@ -93,7 +93,7 @@ void FDSGI(int h) } static void FDSStateRestore(int version) -{ +{ int x; setmirror(((FDSRegs[5]&8)>>3)^1); @@ -132,7 +132,7 @@ static void FDSInit(void) SetReadHandler(0x4032,0x4032,FDSRead4032); SetReadHandler(0x4033,0x4033,FDSRead4033); - SetWriteHandler(0x4020,0x4025,FDSWrite); + SetWriteHandler(0x4020,0x4025,FDSWrite); SetWriteHandler(0x6000,0xdfff,FDSRAMWrite); SetReadHandler(0x6000,0xdfff,FDSRAMRead); @@ -148,10 +148,10 @@ void FCEU_FDSInsert(int oride) { if(InDisk==255) { - FCEU_DispMessage("Disk %d Side %s Inserted",SelectDisk>>1,(SelectDisk&1)?"B":"A"); + FCEU_DispMessage("Disk %d Side %s Inserted",SelectDisk>>1,(SelectDisk&1)?"B":"A"); InDisk=SelectDisk; } - else + else { FCEU_DispMessage("Disk %d Side %s Ejected",SelectDisk>>1,(SelectDisk&1)?"B":"A"); InDisk=255; @@ -187,14 +187,14 @@ static void FP_FASTAPASS(1) FDSFix(int a) IRQCount=IRQLatch=0; } else - IRQCount=IRQLatch; + IRQCount=IRQLatch; //IRQCount=IRQLatch; //0xFFFF; X6502_IRQBegin(FCEU_IQEXT); //printf("IRQ: %d\n",timestamp); // printf("IRQ: %d\n",scanline); } } - if(DiskSeekIRQ>0) + if(DiskSeekIRQ>0) { DiskSeekIRQ-=a; if(DiskSeekIRQ<=0) @@ -239,14 +239,14 @@ static DECLFR(FDSRead4031) return z; } static DECLFR(FDSRead4032) -{ +{ uint8 ret; ret=X.DB&~7; if(InDisk==255) ret|=5; - if(InDisk==255 || !(FDSRegs[5]&1) || (FDSRegs[5]&2)) + if(InDisk==255 || !(FDSRegs[5]&1) || (FDSRegs[5]&2)) ret|=2; return ret; } @@ -345,7 +345,7 @@ static DECLFW(FDSSWrite) A-=0x4080; switch(A) { - case 0x0: + case 0x0: case 0x4: if(V&0x80) amplitude[(A&0xF)>>2]=V&0x3F; //)>0x20?0x20:(V&0x3F); break; @@ -361,7 +361,7 @@ static DECLFW(FDSSWrite) break; } //if(A>=0x7 && A!=0x8 && A<=0xF) - //if(A==0xA || A==0x9) + //if(A==0xA || A==0x9) //printf("$%04x:$%02x\n",A,V); SPSG[A]=V; } @@ -428,7 +428,7 @@ static INLINE void ClockRise(void) b19shiftreg60=(SPSG[0x2]|((SPSG[0x3]&0xF)<<8)); b17latch76=(SPSG[0x6]|((SPSG[0x07]&0xF)<<8))+b17latch76; - if(!(SPSG[0x7]&0x80)) + if(!(SPSG[0x7]&0x80)) { int t=fdso.mwave[(b17latch76>>13)&0x1F]&7; int t2=amplitude[1]; @@ -448,13 +448,13 @@ static INLINE void ClockRise(void) b8shiftreg88=0x80 + adj; } else - { + { b8shiftreg88=0x80; } } else { - b19shiftreg60<<=1; + b19shiftreg60<<=1; b8shiftreg88>>=1; } // b24adder66=(b24latch68+b19shiftreg60)&0x3FFFFFF; @@ -484,7 +484,7 @@ static INLINE int32 FDSDoSound(void) if(fdso.envcount<=0) { fdso.envcount+=SPSG[0xA]*3; - DoEnv(); + DoEnv(); } } if(fdso.count>=32768) goto dogk; @@ -523,7 +523,7 @@ static void RenderSound(void) static void RenderSoundHQ(void) { int32 x; - + if(!(SPSG[0x9]&0x80)) for(x=FBC;xtype=GIT_FDS; @@ -815,7 +817,7 @@ int FDSLoad(const char *name, FCEUFILE *fp) for(x=0;x>4); + MapperNo|=(head.ROM_type2&0xF0); + Mirroring = (head.ROM_type&1); + + if(head.ROM_type&8) Mirroring=2; + + if(!(ROM=(uint8 *)FCEU_malloc(ROM_size<<14))) + return 0; + + if (VROM_size) + if(!(VROM=(uint8 *)FCEU_malloc(VROM_size<<13))) + { + free(ROM); + return 0; + } + + memset(ROM,0xFF,ROM_size<<14); + if(VROM_size) memset(VROM,0xFF,VROM_size<<13); + if(head.ROM_type&4) /* Trainer */ + { + trainerpoo=(uint8 *)FCEU_gmalloc(512); + memcpy(trainerpoo, &nesrom[memoffs], 512); + memoffs+=512; + //FCEU_fread(trainerpoo,512,1,fp); + } + + ResetCartMapping(); + ResetExState(0,0); + + SetupCartPRGMapping(0,ROM,ROM_size*0x4000,0); + SetupCartPRGMapping(1,WRAM,8192,1); + + //FCEU_fread(ROM,0x4000,head.ROM_size,fp); + memcpy(ROM, &nesrom[memoffs], head.ROM_size * 0x4000); + memoffs += ( head.ROM_size * 0x4000 ); + + if(VROM_size){ + //FCEU_fread(VROM,0x2000,head.VROM_size,fp); + memcpy(VROM, &nesrom[memoffs], 0x2000 * head.VROM_size); + memoffs += ( head.VROM_size * 0x2000 ); + } + + md5_starts(&md5); + md5_update(&md5,ROM,ROM_size<<14); + + iNESGameCRC32=CalcCRC32(0,ROM,ROM_size<<14); + + if(VROM_size) + { + iNESGameCRC32=CalcCRC32(iNESGameCRC32,VROM,VROM_size<<13); + md5_update(&md5,VROM,VROM_size<<13); + } + + md5_finish(&md5,iNESCart.MD5); + memcpy(FCEUGameInfo->MD5,iNESCart.MD5,sizeof(iNESCart.MD5)); + + iNESCart.CRC32=iNESGameCRC32; + + SetInput(); + CheckHInfo(); + + { + int x; + uint64 partialmd5=0; + + for(x=0;x<8;x++) + { + partialmd5 |= (uint64)iNESCart.MD5[7-x] << (x*8); + } + + FCEU_VSUniCheck(partialmd5, &MapperNo, &Mirroring); + } + + /* Must remain here because above functions might change value of + VROM_size and free(VROM). + */ + if(VROM_size) + SetupCartCHRMapping(0,VROM,VROM_size*0x2000,0); + + if(Mirroring==2) + SetupCartMirroring(4,1,ExtraNTARAM); + else if(Mirroring>=0x10) + SetupCartMirroring(2+(Mirroring&1),1,0); + else + SetupCartMirroring(Mirroring&1,(Mirroring&4)>>2,0); + + iNESCart.battery=(head.ROM_type&2)?1:0; + iNESCart.mirror=Mirroring; + + if(NewiNES_Init(MapperNo)) + { + + } + else + { + iNESCart.Power=iNESPower; + if(head.ROM_type&2) + { + iNESCart.SaveGame[0]=WRAM; + iNESCart.SaveGameLen[0]=8192; + } + } + + GameInterface=iNESGI; + return 1; +} + diff --git a/source/fceultra/input/cursor.c b/source/fceultra/input/cursor.c index 47db6d8b..f7a5b875 100644 --- a/source/fceultra/input/cursor.c +++ b/source/fceultra/input/cursor.c @@ -1,5 +1,4 @@ #include "share.h" -#include "fceuconfig.h" static uint8 GunSight[]={ 0,0,0,0,0,0,1,0,0,0,0,0,0, @@ -39,27 +38,29 @@ static uint8 FCEUcursor[11*19]= 0,0,0,0,0,0,0,1,1,0,0, }; -void FCEU_DrawGunSight(uint8 *buf, int xc, int yc) { - if (GCSettings.crosshair) { - int x, y; - int c, d; +void FCEU_DrawGunSight(uint8 *buf, int xc, int yc) +{ + int x,y; + int c,d; - for (y = 0; y < 13; y++) - for (x = 0; x < 13; x++) { - uint8 a; - a = GunSight[y * 13 + x]; - if (a) { - c = (yc + y - 7); - d = (xc + x - 7); - if (c >= 0 && d >= 0 && d < 256 && c < 240) { - if (a == 3) - buf[c * 256 + d] = 0xBF - (buf[c * 256 + d] & 0x3F); - else - buf[c * 256 + d] = a - 1; - } - } - } - } + for(y=0;y<13;y++) + for(x=0;x<13;x++) + { + uint8 a; + a=GunSight[y*13+x]; + if(a) + { + c=(yc+y-7); + d=(xc+x-7); + if(c>=0 && d>=0 && d<256 && c<240) + { + if(a==3) + buf[c*256+d]=0xBF-(buf[c*256+d]&0x3F); + else + buf[c*256+d]=a-1; + } + } + } } diff --git a/source/fceultra/linux/bits/wchar.h b/source/fceultra/linux/bits/wchar.h new file mode 100644 index 00000000..442a4621 --- /dev/null +++ b/source/fceultra/linux/bits/wchar.h @@ -0,0 +1,26 @@ +/* wchar_t type related definitions. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _BITS_WCHAR_H +#define _BITS_WCHAR_H 1 + +#define __WCHAR_MIN (-2147483647l - 1l) +#define __WCHAR_MAX (2147483647l) + +#endif /* bits/wchar.h */ diff --git a/source/fceultra/linux/bits/wordsize.h b/source/fceultra/linux/bits/wordsize.h new file mode 100644 index 00000000..ba643b60 --- /dev/null +++ b/source/fceultra/linux/bits/wordsize.h @@ -0,0 +1,19 @@ +/* Copyright (C) 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#define __WORDSIZE 32 diff --git a/source/fceultra/linux/features.h b/source/fceultra/linux/features.h new file mode 100644 index 00000000..a191d803 --- /dev/null +++ b/source/fceultra/linux/features.h @@ -0,0 +1,340 @@ +/* Copyright (C) 1991-1993,1995-2003,2004,2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _FEATURES_H +#define _FEATURES_H 1 + +/* These are defined by the user (or the compiler) + to specify the desired environment: + + __STRICT_ANSI__ ISO Standard C. + _ISOC99_SOURCE Extensions to ISO C89 from ISO C99. + _POSIX_SOURCE IEEE Std 1003.1. + _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2; + if >=199309L, add IEEE Std 1003.1b-1993; + if >=199506L, add IEEE Std 1003.1c-1995; + if >=200112L, all of IEEE 1003.1-2004 + _XOPEN_SOURCE Includes POSIX and XPG things. Set to 500 if + Single Unix conformance is wanted, to 600 for the + upcoming sixth revision. + _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions. + _LARGEFILE_SOURCE Some more functions for correct standard I/O. + _LARGEFILE64_SOURCE Additional functionality from LFS for large files. + _FILE_OFFSET_BITS=N Select default filesystem interface. + _BSD_SOURCE ISO C, POSIX, and 4.3BSD things. + _SVID_SOURCE ISO C, POSIX, and SVID things. + _GNU_SOURCE All of the above, plus GNU extensions. + _REENTRANT Select additionally reentrant object. + _THREAD_SAFE Same as _REENTRANT, often used by other systems. + _FORTIFY_SOURCE If set to numeric value > 0 additional security + measures are defined, according to level. + + The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__. + If none of these are defined, the default is to have _SVID_SOURCE, + _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to + 199506L. If more than one of these are defined, they accumulate. + For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE + together give you ISO C, 1003.1, and 1003.2, but nothing else. + + These are defined by this file and are used by the + header files to decide what to declare or define: + + __USE_ISOC99 Define ISO C99 things. + __USE_POSIX Define IEEE Std 1003.1 things. + __USE_POSIX2 Define IEEE Std 1003.2 things. + __USE_POSIX199309 Define IEEE Std 1003.1, and .1b things. + __USE_POSIX199506 Define IEEE Std 1003.1, .1b, .1c and .1i things. + __USE_XOPEN Define XPG things. + __USE_XOPEN_EXTENDED Define X/Open Unix things. + __USE_UNIX98 Define Single Unix V2 things. + __USE_XOPEN2K Define XPG6 things. + __USE_LARGEFILE Define correct standard I/O things. + __USE_LARGEFILE64 Define LFS things with separate names. + __USE_FILE_OFFSET64 Define 64bit interface as default. + __USE_BSD Define 4.3BSD things. + __USE_SVID Define SVID things. + __USE_MISC Define things common to BSD and System V Unix. + __USE_GNU Define GNU extensions. + __USE_REENTRANT Define reentrant/thread-safe *_r functions. + __USE_FORTIFY_LEVEL Additional security measures used, according to level. + __FAVOR_BSD Favor 4.3BSD things in cases of conflict. + + The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are + defined by this file unconditionally. `__GNU_LIBRARY__' is provided + only for compatibility. All new code should use the other symbols + to test for features. + + All macros listed above as possibly being defined by this file are + explicitly undefined if they are not explicitly defined. + Feature-test macros that are not defined by the user or compiler + but are implied by the other feature-test macros defined (or by the + lack of any definitions) are defined by the file. */ + + +/* Undefine everything, so we get a clean slate. */ +#undef __USE_ISOC99 +#undef __USE_POSIX +#undef __USE_POSIX2 +#undef __USE_POSIX199309 +#undef __USE_POSIX199506 +#undef __USE_XOPEN +#undef __USE_XOPEN_EXTENDED +#undef __USE_UNIX98 +#undef __USE_XOPEN2K +#undef __USE_LARGEFILE +#undef __USE_LARGEFILE64 +#undef __USE_FILE_OFFSET64 +#undef __USE_BSD +#undef __USE_SVID +#undef __USE_MISC +#undef __USE_GNU +#undef __USE_REENTRANT +#undef __USE_FORTIFY_LEVEL +#undef __FAVOR_BSD +#undef __KERNEL_STRICT_NAMES + +/* Suppress kernel-name space pollution unless user expressedly asks + for it. */ +#ifndef _LOOSE_KERNEL_NAMES +# define __KERNEL_STRICT_NAMES +#endif + +/* Always use ISO C things. */ +#define __USE_ANSI 1 + +/* Convenience macros to test the versions of glibc and gcc. + Use them like this: + #if __GNUC_PREREQ (2,8) + ... code requiring gcc 2.8 or later ... + #endif + Note - they won't work for gcc1 or glibc1, since the _MINOR macros + were not defined then. */ +#if defined __GNUC__ && defined __GNUC_MINOR__ +# define __GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define __GNUC_PREREQ(maj, min) 0 +#endif + + +/* If _BSD_SOURCE was defined by the user, favor BSD over POSIX. */ +#if defined _BSD_SOURCE && \ + !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \ + defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \ + defined _GNU_SOURCE || defined _SVID_SOURCE) +# define __FAVOR_BSD 1 +#endif + +/* If _GNU_SOURCE was defined by the user, turn on all the other features. */ +#ifdef _GNU_SOURCE +# undef _ISOC99_SOURCE +# define _ISOC99_SOURCE 1 +# undef _POSIX_SOURCE +# define _POSIX_SOURCE 1 +# undef _POSIX_C_SOURCE +# define _POSIX_C_SOURCE 199506L +# undef _XOPEN_SOURCE +# define _XOPEN_SOURCE 600 +# undef _XOPEN_SOURCE_EXTENDED +# define _XOPEN_SOURCE_EXTENDED 1 +# undef _LARGEFILE64_SOURCE +# define _LARGEFILE64_SOURCE 1 +# undef _BSD_SOURCE +# define _BSD_SOURCE 1 +# undef _SVID_SOURCE +# define _SVID_SOURCE 1 +#endif + +/* If nothing (other than _GNU_SOURCE) is defined, + define _BSD_SOURCE and _SVID_SOURCE. */ +#if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \ + !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \ + !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \ + !defined _BSD_SOURCE && !defined _SVID_SOURCE) +# define _BSD_SOURCE 1 +# define _SVID_SOURCE 1 +#endif + +/* This is to enable the ISO C99 extension. Also recognize the old macro + which was used prior to the standard acceptance. This macro will + eventually go away and the features enabled by default once the ISO C99 + standard is widely adopted. */ +#if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) +# define __USE_ISOC99 1 +#endif + +/* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2 + (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */ +#if ((!defined __STRICT_ANSI__ || (_XOPEN_SOURCE - 0) >= 500) && \ + !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE) +# define _POSIX_SOURCE 1 +# if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500 +# define _POSIX_C_SOURCE 2 +# else +# define _POSIX_C_SOURCE 199506L +# endif +#endif + +#if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE +# define __USE_POSIX 1 +#endif + +#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE +# define __USE_POSIX2 1 +#endif + +#if (_POSIX_C_SOURCE - 0) >= 199309L +# define __USE_POSIX199309 1 +#endif + +#if (_POSIX_C_SOURCE - 0) >= 199506L +# define __USE_POSIX199506 1 +#endif + +#if (_POSIX_C_SOURCE - 0) >= 200112L +# define __USE_XOPEN2K 1 +#endif + +#ifdef _XOPEN_SOURCE +# define __USE_XOPEN 1 +# if (_XOPEN_SOURCE - 0) >= 500 +# define __USE_XOPEN_EXTENDED 1 +# define __USE_UNIX98 1 +# undef _LARGEFILE_SOURCE +# define _LARGEFILE_SOURCE 1 +# if (_XOPEN_SOURCE - 0) >= 600 +# define __USE_XOPEN2K 1 +# undef __USE_ISOC99 +# define __USE_ISOC99 1 +# endif +# else +# ifdef _XOPEN_SOURCE_EXTENDED +# define __USE_XOPEN_EXTENDED 1 +# endif +# endif +#endif + +#ifdef _LARGEFILE_SOURCE +# define __USE_LARGEFILE 1 +#endif + +#ifdef _LARGEFILE64_SOURCE +# define __USE_LARGEFILE64 1 +#endif + +#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 +# define __USE_FILE_OFFSET64 1 +#endif + +#if defined _BSD_SOURCE || defined _SVID_SOURCE +# define __USE_MISC 1 +#endif + +#ifdef _BSD_SOURCE +# define __USE_BSD 1 +#endif + +#ifdef _SVID_SOURCE +# define __USE_SVID 1 +#endif + +#ifdef _GNU_SOURCE +# define __USE_GNU 1 +#endif + +#if defined _REENTRANT || defined _THREAD_SAFE +# define __USE_REENTRANT 1 +#endif + +#if _FORTIFY_SOURCE > 0 && __OPTIMIZE__ > 0 \ + && (__GNUC_PREREQ (4, 1) \ + || (defined __GNUC_RH_RELEASE__ && __GNUC_PREREQ (4, 0)) \ + || (defined __GNUC_RH_RELEASE__ && __GNUC_PREREQ (3, 4) \ + && __GNUC_MINOR__ == 4 \ + && (__GNUC_PATCHLEVEL__ > 2 \ + || (__GNUC_PATCHLEVEL__ == 2 && __GNUC_RH_RELEASE__ >= 8)))) +# if _FORTIFY_SOURCE == 1 +# define __USE_FORTIFY_LEVEL 1 +# elif _FORTIFY_SOURCE > 1 +# define __USE_FORTIFY_LEVEL 2 +# endif +#endif + +/* We do support the IEC 559 math functionality, real and complex. */ +#define __STDC_IEC_559__ 1 +#define __STDC_IEC_559_COMPLEX__ 1 + +/* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.1. */ +#define __STDC_ISO_10646__ 200009L + +/* This macro indicates that the installed library is the GNU C Library. + For historic reasons the value now is 6 and this will stay from now + on. The use of this variable is deprecated. Use __GLIBC__ and + __GLIBC_MINOR__ now (see below) when you want to test for a specific + GNU C library version and use the values in to get + the sonames of the shared libraries. */ +#undef __GNU_LIBRARY__ +#define __GNU_LIBRARY__ 6 + +/* Major and minor version number of the GNU C library package. Use + these macros to test for features in specific releases. */ +#define __GLIBC__ 2 +#define __GLIBC_MINOR__ 3 + +#define __GLIBC_PREREQ(maj, min) \ + ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min)) + +/* Decide whether a compiler supports the long long datatypes. */ +#if defined __GNUC__ \ + || (defined __PGI && defined __i386__ ) \ + || (defined __INTEL_COMPILER && (defined __i386__ || defined __ia64__)) \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) +# define __GLIBC_HAVE_LONG_LONG 1 +#endif + +/* This is here only because every header file already includes this one. */ +#ifndef __ASSEMBLER__ +# ifndef _SYS_CDEFS_H +# include +# endif + +/* If we don't have __REDIRECT, prototypes will be missing if + __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */ +# if defined __USE_FILE_OFFSET64 && !defined __REDIRECT +# define __USE_LARGEFILE 1 +# define __USE_LARGEFILE64 1 +# endif + +#endif /* !ASSEMBLER */ + +/* Decide whether we can define 'extern inline' functions in headers. */ +#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \ + && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ +# define __USE_EXTERN_INLINES 1 +#endif + + +/* This is here only because every header file already includes this one. + Get the definitions of all the appropriate `__stub_FUNCTION' symbols. + contains `#define __stub_FUNCTION' when FUNCTION is a stub + that will always return failure (and set errno to ENOSYS). */ +#include + + +#endif /* features.h */ diff --git a/source/fceultra/linux/gnu/stubs-32.h b/source/fceultra/linux/gnu/stubs-32.h new file mode 100644 index 00000000..1404dcd2 --- /dev/null +++ b/source/fceultra/linux/gnu/stubs-32.h @@ -0,0 +1,24 @@ +/* This file is automatically generated. + It defines a symbol `__stub_FUNCTION' for each function + in the C library which is a stub, meaning it will fail + every time called, usually setting errno to ENOSYS. */ + +#ifdef _LIBC + #error Applications may not define the macro _LIBC +#endif + +#define __stub___kernel_cosl +#define __stub___kernel_sinl +#define __stub___kernel_tanl +#define __stub_chflags +#define __stub_fattach +#define __stub_fchflags +#define __stub_fdetach +#define __stub_gtty +#define __stub_lchmod +#define __stub_lutimes +#define __stub_revoke +#define __stub_setlogin +#define __stub_sigreturn +#define __stub_sstk +#define __stub_stty diff --git a/source/fceultra/linux/gnu/stubs.h b/source/fceultra/linux/gnu/stubs.h new file mode 100644 index 00000000..fc086bd8 --- /dev/null +++ b/source/fceultra/linux/gnu/stubs.h @@ -0,0 +1,12 @@ +/* This file selects the right generated file of `__stub_FUNCTION' macros + based on the architecture being compiled for. */ + +#include + +#if __WORDSIZE == 32 +# include +#elif __WORDSIZE == 64 +# include +#else +# error "unexpected value for __WORDSIZE macro" +#endif diff --git a/source/fceultra/linux/inttypes.h b/source/fceultra/linux/inttypes.h new file mode 100644 index 00000000..13abb149 --- /dev/null +++ b/source/fceultra/linux/inttypes.h @@ -0,0 +1,461 @@ +/* Copyright (C) 1997-2001, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99: 7.8 Format conversion of integer types + */ + +#ifndef _INTTYPES_H +#define _INTTYPES_H 1 + +#include +/* Get the type definitions. */ +#include + +/* Get a definition for wchar_t. But we must not define wchar_t itself. */ +#ifndef ____gwchar_t_defined +# ifdef __cplusplus +# define __gwchar_t wchar_t +# elif defined __WCHAR_TYPE__ +typedef __WCHAR_TYPE__ __gwchar_t; +# else +# define __need_wchar_t +# include +typedef wchar_t __gwchar_t; +# endif +# define ____gwchar_t_defined 1 +#endif + + +/* The ISO C99 standard specifies that these macros must only be + defined if explicitly requested. */ +#if !defined __cplusplus || defined __STDC_FORMAT_MACROS + +# if __WORDSIZE == 64 +# define __PRI64_PREFIX "l" +# define __PRIPTR_PREFIX "l" +# else +# define __PRI64_PREFIX "ll" +# define __PRIPTR_PREFIX +# endif + +/* Macros for printing format specifiers. */ + +/* Decimal notation. */ +# define PRId8 "d" +# define PRId16 "d" +# define PRId32 "d" +# define PRId64 __PRI64_PREFIX "d" + +# define PRIdLEAST8 "d" +# define PRIdLEAST16 "d" +# define PRIdLEAST32 "d" +# define PRIdLEAST64 __PRI64_PREFIX "d" + +# define PRIdFAST8 "d" +# define PRIdFAST16 __PRIPTR_PREFIX "d" +# define PRIdFAST32 __PRIPTR_PREFIX "d" +# define PRIdFAST64 __PRI64_PREFIX "d" + + +# define PRIi8 "i" +# define PRIi16 "i" +# define PRIi32 "i" +# define PRIi64 __PRI64_PREFIX "i" + +# define PRIiLEAST8 "i" +# define PRIiLEAST16 "i" +# define PRIiLEAST32 "i" +# define PRIiLEAST64 __PRI64_PREFIX "i" + +# define PRIiFAST8 "i" +# define PRIiFAST16 __PRIPTR_PREFIX "i" +# define PRIiFAST32 __PRIPTR_PREFIX "i" +# define PRIiFAST64 __PRI64_PREFIX "i" + +/* Octal notation. */ +# define PRIo8 "o" +# define PRIo16 "o" +# define PRIo32 "o" +# define PRIo64 __PRI64_PREFIX "o" + +# define PRIoLEAST8 "o" +# define PRIoLEAST16 "o" +# define PRIoLEAST32 "o" +# define PRIoLEAST64 __PRI64_PREFIX "o" + +# define PRIoFAST8 "o" +# define PRIoFAST16 __PRIPTR_PREFIX "o" +# define PRIoFAST32 __PRIPTR_PREFIX "o" +# define PRIoFAST64 __PRI64_PREFIX "o" + +/* Unsigned integers. */ +# define PRIu8 "u" +# define PRIu16 "u" +# define PRIu32 "u" +# define PRIu64 __PRI64_PREFIX "u" + +# define PRIuLEAST8 "u" +# define PRIuLEAST16 "u" +# define PRIuLEAST32 "u" +# define PRIuLEAST64 __PRI64_PREFIX "u" + +# define PRIuFAST8 "u" +# define PRIuFAST16 __PRIPTR_PREFIX "u" +# define PRIuFAST32 __PRIPTR_PREFIX "u" +# define PRIuFAST64 __PRI64_PREFIX "u" + +/* lowercase hexadecimal notation. */ +# define PRIx8 "x" +# define PRIx16 "x" +# define PRIx32 "x" +# define PRIx64 __PRI64_PREFIX "x" + +# define PRIxLEAST8 "x" +# define PRIxLEAST16 "x" +# define PRIxLEAST32 "x" +# define PRIxLEAST64 __PRI64_PREFIX "x" + +# define PRIxFAST8 "x" +# define PRIxFAST16 __PRIPTR_PREFIX "x" +# define PRIxFAST32 __PRIPTR_PREFIX "x" +# define PRIxFAST64 __PRI64_PREFIX "x" + +/* UPPERCASE hexadecimal notation. */ +# define PRIX8 "X" +# define PRIX16 "X" +# define PRIX32 "X" +# define PRIX64 __PRI64_PREFIX "X" + +# define PRIXLEAST8 "X" +# define PRIXLEAST16 "X" +# define PRIXLEAST32 "X" +# define PRIXLEAST64 __PRI64_PREFIX "X" + +# define PRIXFAST8 "X" +# define PRIXFAST16 __PRIPTR_PREFIX "X" +# define PRIXFAST32 __PRIPTR_PREFIX "X" +# define PRIXFAST64 __PRI64_PREFIX "X" + + +/* Macros for printing `intmax_t' and `uintmax_t'. */ +# define PRIdMAX __PRI64_PREFIX "d" +# define PRIiMAX __PRI64_PREFIX "i" +# define PRIoMAX __PRI64_PREFIX "o" +# define PRIuMAX __PRI64_PREFIX "u" +# define PRIxMAX __PRI64_PREFIX "x" +# define PRIXMAX __PRI64_PREFIX "X" + + +/* Macros for printing `intptr_t' and `uintptr_t'. */ +# define PRIdPTR __PRIPTR_PREFIX "d" +# define PRIiPTR __PRIPTR_PREFIX "i" +# define PRIoPTR __PRIPTR_PREFIX "o" +# define PRIuPTR __PRIPTR_PREFIX "u" +# define PRIxPTR __PRIPTR_PREFIX "x" +# define PRIXPTR __PRIPTR_PREFIX "X" + + +/* Macros for scanning format specifiers. */ + +/* Signed decimal notation. */ +# define SCNd8 "hhd" +# define SCNd16 "hd" +# define SCNd32 "d" +# define SCNd64 __PRI64_PREFIX "d" + +# define SCNdLEAST8 "hhd" +# define SCNdLEAST16 "hd" +# define SCNdLEAST32 "d" +# define SCNdLEAST64 __PRI64_PREFIX "d" + +# define SCNdFAST8 "hhd" +# define SCNdFAST16 __PRIPTR_PREFIX "d" +# define SCNdFAST32 __PRIPTR_PREFIX "d" +# define SCNdFAST64 __PRI64_PREFIX "d" + +/* Signed decimal notation. */ +# define SCNi8 "hhi" +# define SCNi16 "hi" +# define SCNi32 "i" +# define SCNi64 __PRI64_PREFIX "i" + +# define SCNiLEAST8 "hhi" +# define SCNiLEAST16 "hi" +# define SCNiLEAST32 "i" +# define SCNiLEAST64 __PRI64_PREFIX "i" + +# define SCNiFAST8 "hhi" +# define SCNiFAST16 __PRIPTR_PREFIX "i" +# define SCNiFAST32 __PRIPTR_PREFIX "i" +# define SCNiFAST64 __PRI64_PREFIX "i" + +/* Unsigned decimal notation. */ +# define SCNu8 "hhu" +# define SCNu16 "hu" +# define SCNu32 "u" +# define SCNu64 __PRI64_PREFIX "u" + +# define SCNuLEAST8 "hhu" +# define SCNuLEAST16 "hu" +# define SCNuLEAST32 "u" +# define SCNuLEAST64 __PRI64_PREFIX "u" + +# define SCNuFAST8 "hhu" +# define SCNuFAST16 __PRIPTR_PREFIX "u" +# define SCNuFAST32 __PRIPTR_PREFIX "u" +# define SCNuFAST64 __PRI64_PREFIX "u" + +/* Octal notation. */ +# define SCNo8 "hho" +# define SCNo16 "ho" +# define SCNo32 "o" +# define SCNo64 __PRI64_PREFIX "o" + +# define SCNoLEAST8 "hho" +# define SCNoLEAST16 "ho" +# define SCNoLEAST32 "o" +# define SCNoLEAST64 __PRI64_PREFIX "o" + +# define SCNoFAST8 "hho" +# define SCNoFAST16 __PRIPTR_PREFIX "o" +# define SCNoFAST32 __PRIPTR_PREFIX "o" +# define SCNoFAST64 __PRI64_PREFIX "o" + +/* Hexadecimal notation. */ +# define SCNx8 "hhx" +# define SCNx16 "hx" +# define SCNx32 "x" +# define SCNx64 __PRI64_PREFIX "x" + +# define SCNxLEAST8 "hhx" +# define SCNxLEAST16 "hx" +# define SCNxLEAST32 "x" +# define SCNxLEAST64 __PRI64_PREFIX "x" + +# define SCNxFAST8 "hhx" +# define SCNxFAST16 __PRIPTR_PREFIX "x" +# define SCNxFAST32 __PRIPTR_PREFIX "x" +# define SCNxFAST64 __PRI64_PREFIX "x" + + +/* Macros for scanning `intmax_t' and `uintmax_t'. */ +# define SCNdMAX __PRI64_PREFIX "d" +# define SCNiMAX __PRI64_PREFIX "i" +# define SCNoMAX __PRI64_PREFIX "o" +# define SCNuMAX __PRI64_PREFIX "u" +# define SCNxMAX __PRI64_PREFIX "x" + +/* Macros for scaning `intptr_t' and `uintptr_t'. */ +# define SCNdPTR __PRIPTR_PREFIX "d" +# define SCNiPTR __PRIPTR_PREFIX "i" +# define SCNoPTR __PRIPTR_PREFIX "o" +# define SCNuPTR __PRIPTR_PREFIX "u" +# define SCNxPTR __PRIPTR_PREFIX "x" + +#endif /* C++ && format macros */ + + +__BEGIN_DECLS + +#if __WORDSIZE == 64 + +/* We have to define the `uintmax_t' type using `ldiv_t'. */ +typedef struct + { + long int quot; /* Quotient. */ + long int rem; /* Remainder. */ + } imaxdiv_t; + +#else + +/* We have to define the `uintmax_t' type using `lldiv_t'. */ +typedef struct + { + long long int quot; /* Quotient. */ + long long int rem; /* Remainder. */ + } imaxdiv_t; + +#endif + + +/* Compute absolute value of N. */ +extern intmax_t imaxabs (intmax_t __n) __THROW __attribute__ ((__const__)); + +/* Return the `imaxdiv_t' representation of the value of NUMER over DENOM. */ +extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom) + __THROW __attribute__ ((__const__)); + +/* Like `strtol' but convert to `intmax_t'. */ +extern intmax_t strtoimax (__const char *__restrict __nptr, + char **__restrict __endptr, int __base) __THROW; + +/* Like `strtoul' but convert to `uintmax_t'. */ +extern uintmax_t strtoumax (__const char *__restrict __nptr, + char ** __restrict __endptr, int __base) __THROW; + +/* Like `wcstol' but convert to `intmax_t'. */ +extern intmax_t wcstoimax (__const __gwchar_t *__restrict __nptr, + __gwchar_t **__restrict __endptr, int __base) + __THROW; + +/* Like `wcstoul' but convert to `uintmax_t'. */ +extern uintmax_t wcstoumax (__const __gwchar_t *__restrict __nptr, + __gwchar_t ** __restrict __endptr, int __base) + __THROW; + +#ifdef __USE_EXTERN_INLINES + +# if __WORDSIZE == 64 + +/* Like `strtol' but convert to `intmax_t'. */ +# ifndef __strtol_internal_defined +extern long int __strtol_internal (__const char *__restrict __nptr, + char **__restrict __endptr, + int __base, int __group) __THROW; +# define __strtol_internal_defined 1 +# endif +extern __inline intmax_t +(strtoimax (__const char *__restrict nptr, char **__restrict endptr, + int base)) +{ + return __strtol_internal (nptr, endptr, base, 0); +} + +/* Like `strtoul' but convert to `uintmax_t'. */ +# ifndef __strtoul_internal_defined +extern unsigned long int __strtoul_internal (__const char * + __restrict __nptr, + char ** __restrict __endptr, + int __base, int __group) __THROW; +# define __strtoul_internal_defined 1 +# endif +extern __inline uintmax_t +(strtoumax (__const char *__restrict nptr, char **__restrict endptr, + int base)) +{ + return __strtoul_internal (nptr, endptr, base, 0); +} + +/* Like `wcstol' but convert to `intmax_t'. */ +# ifndef __wcstol_internal_defined +extern long int __wcstol_internal (__const __gwchar_t * __restrict __nptr, + __gwchar_t **__restrict __endptr, + int __base, int __group) __THROW; +# define __wcstol_internal_defined 1 +# endif +extern __inline intmax_t +(wcstoimax (__const __gwchar_t *__restrict nptr, + __gwchar_t **__restrict endptr, int base)) +{ + return __wcstol_internal (nptr, endptr, base, 0); +} + + +/* Like `wcstoul' but convert to `uintmax_t'. */ +# ifndef __wcstoul_internal_defined +extern unsigned long int __wcstoul_internal (__const __gwchar_t * + __restrict __nptr, + __gwchar_t ** + __restrict __endptr, + int __base, int __group) __THROW; +# define __wcstoul_internal_defined 1 +# endif +extern __inline uintmax_t +(wcstoumax (__const __gwchar_t *__restrict nptr, + __gwchar_t **__restrict endptr, int base)) +{ + return __wcstoul_internal (nptr, endptr, base, 0); +} + +# else /* __WORDSIZE == 32 */ + +/* Like `strtol' but convert to `intmax_t'. */ +# ifndef __strtoll_internal_defined +__extension__ +extern long long int __strtoll_internal (__const char *__restrict __nptr, + char **__restrict __endptr, + int __base, int __group) __THROW; +# define __strtoll_internal_defined 1 +# endif +extern __inline intmax_t +(strtoimax (__const char *__restrict nptr, char **__restrict endptr, + int base)) +{ + return __strtoll_internal (nptr, endptr, base, 0); +} + +/* Like `strtoul' but convert to `uintmax_t'. */ +# ifndef __strtoull_internal_defined +__extension__ +extern unsigned long long int __strtoull_internal (__const char * + __restrict __nptr, + char ** + __restrict __endptr, + int __base, + int __group) __THROW; +# define __strtoull_internal_defined 1 +# endif +extern __inline uintmax_t +(strtoumax (__const char *__restrict nptr, char **__restrict endptr, + int base)) +{ + return __strtoull_internal (nptr, endptr, base, 0); +} + +/* Like `wcstol' but convert to `intmax_t'. */ +# ifndef __wcstoll_internal_defined +__extension__ +extern long long int __wcstoll_internal (__const __gwchar_t * + __restrict __nptr, + __gwchar_t **__restrict __endptr, + int __base, int __group) __THROW; +# define __wcstoll_internal_defined 1 +# endif +extern __inline intmax_t +(wcstoimax (__const __gwchar_t *__restrict nptr, + __gwchar_t **__restrict endptr, int base)) +{ + return __wcstoll_internal (nptr, endptr, base, 0); +} + + +/* Like `wcstoul' but convert to `uintmax_t'. */ +# ifndef __wcstoull_internal_defined +__extension__ +extern unsigned long long int __wcstoull_internal (__const __gwchar_t * + __restrict __nptr, + __gwchar_t ** + __restrict __endptr, + int __base, + int __group) __THROW; +# define __wcstoull_internal_defined 1 +# endif +extern __inline uintmax_t +(wcstoumax (__const __gwchar_t *__restrict nptr, + __gwchar_t **__restrict endptr, int base)) +{ + return __wcstoull_internal (nptr, endptr, base, 0); +} + +# endif /* __WORDSIZE == 32 */ +#endif /* Use extern inlines. */ + +__END_DECLS + +#endif /* inttypes.h */ diff --git a/source/fceultra/linux/stdint.h b/source/fceultra/linux/stdint.h new file mode 100644 index 00000000..c8600304 --- /dev/null +++ b/source/fceultra/linux/stdint.h @@ -0,0 +1,320 @@ +/* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * ISO C99: 7.18 Integer types + */ + +#ifndef _STDINT_H +#define _STDINT_H 1 + +#include +#include +#include + +/* Exact integral types. */ + +/* Signed. */ + +/* There is some amount of overlap with as known by inet code */ +#ifndef __int8_t_defined +# define __int8_t_defined +typedef signed char int8_t; +typedef short int int16_t; +typedef int int32_t; +# if __WORDSIZE == 64 +typedef long int int64_t; +# else +__extension__ +typedef long long int int64_t; +# endif +#endif + +/* Unsigned. */ +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +#ifndef __uint32_t_defined +typedef unsigned int uint32_t; +# define __uint32_t_defined +#endif +#if __WORDSIZE == 64 +typedef unsigned long int uint64_t; +#else +__extension__ +typedef unsigned long long int uint64_t; +#endif + + +/* Small types. */ + +/* Signed. */ +typedef signed char int_least8_t; +typedef short int int_least16_t; +typedef int int_least32_t; +#if __WORDSIZE == 64 +typedef long int int_least64_t; +#else +__extension__ +typedef long long int int_least64_t; +#endif + +/* Unsigned. */ +typedef unsigned char uint_least8_t; +typedef unsigned short int uint_least16_t; +typedef unsigned int uint_least32_t; +#if __WORDSIZE == 64 +typedef unsigned long int uint_least64_t; +#else +__extension__ +typedef unsigned long long int uint_least64_t; +#endif + + +/* Fast types. */ + +/* Signed. */ +typedef signed char int_fast8_t; +#if __WORDSIZE == 64 +typedef long int int_fast16_t; +typedef long int int_fast32_t; +typedef long int int_fast64_t; +#else +typedef int int_fast16_t; +typedef int int_fast32_t; +__extension__ +typedef long long int int_fast64_t; +#endif + +/* Unsigned. */ +typedef unsigned char uint_fast8_t; +#if __WORDSIZE == 64 +typedef unsigned long int uint_fast16_t; +typedef unsigned long int uint_fast32_t; +typedef unsigned long int uint_fast64_t; +#else +typedef unsigned int uint_fast16_t; +typedef unsigned int uint_fast32_t; +__extension__ +typedef unsigned long long int uint_fast64_t; +#endif + + +/* Types for `void *' pointers. */ +#if __WORDSIZE == 64 +# ifndef __intptr_t_defined +typedef long int intptr_t; +# define __intptr_t_defined +# endif +typedef unsigned long int uintptr_t; +#else +# ifndef __intptr_t_defined +typedef int intptr_t; +# define __intptr_t_defined +# endif +typedef unsigned int uintptr_t; +#endif + + +/* Largest integral types. */ +#if __WORDSIZE == 64 +typedef long int intmax_t; +typedef unsigned long int uintmax_t; +#else +__extension__ +typedef long long int intmax_t; +__extension__ +typedef unsigned long long int uintmax_t; +#endif + + +/* The ISO C99 standard specifies that in C++ implementations these + macros should only be defined if explicitly requested. */ +#if !defined __cplusplus || defined __STDC_LIMIT_MACROS + +# if __WORDSIZE == 64 +# define __INT64_C(c) c ## L +# define __UINT64_C(c) c ## UL +# else +# define __INT64_C(c) c ## LL +# define __UINT64_C(c) c ## ULL +# endif + +/* Limits of integral types. */ + +/* Minimum of signed integral types. */ +# define INT8_MIN (-128) +# define INT16_MIN (-32767-1) +# define INT32_MIN (-2147483647-1) +# define INT64_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum of signed integral types. */ +# define INT8_MAX (127) +# define INT16_MAX (32767) +# define INT32_MAX (2147483647) +# define INT64_MAX (__INT64_C(9223372036854775807)) + +/* Maximum of unsigned integral types. */ +# define UINT8_MAX (255) +# define UINT16_MAX (65535) +# define UINT32_MAX (4294967295U) +# define UINT64_MAX (__UINT64_C(18446744073709551615)) + + +/* Minimum of signed integral types having a minimum size. */ +# define INT_LEAST8_MIN (-128) +# define INT_LEAST16_MIN (-32767-1) +# define INT_LEAST32_MIN (-2147483647-1) +# define INT_LEAST64_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum of signed integral types having a minimum size. */ +# define INT_LEAST8_MAX (127) +# define INT_LEAST16_MAX (32767) +# define INT_LEAST32_MAX (2147483647) +# define INT_LEAST64_MAX (__INT64_C(9223372036854775807)) + +/* Maximum of unsigned integral types having a minimum size. */ +# define UINT_LEAST8_MAX (255) +# define UINT_LEAST16_MAX (65535) +# define UINT_LEAST32_MAX (4294967295U) +# define UINT_LEAST64_MAX (__UINT64_C(18446744073709551615)) + + +/* Minimum of fast signed integral types having a minimum size. */ +# define INT_FAST8_MIN (-128) +# if __WORDSIZE == 64 +# define INT_FAST16_MIN (-9223372036854775807L-1) +# define INT_FAST32_MIN (-9223372036854775807L-1) +# else +# define INT_FAST16_MIN (-2147483647-1) +# define INT_FAST32_MIN (-2147483647-1) +# endif +# define INT_FAST64_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum of fast signed integral types having a minimum size. */ +# define INT_FAST8_MAX (127) +# if __WORDSIZE == 64 +# define INT_FAST16_MAX (9223372036854775807L) +# define INT_FAST32_MAX (9223372036854775807L) +# else +# define INT_FAST16_MAX (2147483647) +# define INT_FAST32_MAX (2147483647) +# endif +# define INT_FAST64_MAX (__INT64_C(9223372036854775807)) + +/* Maximum of fast unsigned integral types having a minimum size. */ +# define UINT_FAST8_MAX (255) +# if __WORDSIZE == 64 +# define UINT_FAST16_MAX (18446744073709551615UL) +# define UINT_FAST32_MAX (18446744073709551615UL) +# else +# define UINT_FAST16_MAX (4294967295U) +# define UINT_FAST32_MAX (4294967295U) +# endif +# define UINT_FAST64_MAX (__UINT64_C(18446744073709551615)) + + +/* Values to test for integral types holding `void *' pointer. */ +# if __WORDSIZE == 64 +# define INTPTR_MIN (-9223372036854775807L-1) +# define INTPTR_MAX (9223372036854775807L) +# define UINTPTR_MAX (18446744073709551615UL) +# else +# define INTPTR_MIN (-2147483647-1) +# define INTPTR_MAX (2147483647) +# define UINTPTR_MAX (4294967295U) +# endif + + +/* Minimum for largest signed integral type. */ +# define INTMAX_MIN (-__INT64_C(9223372036854775807)-1) +/* Maximum for largest signed integral type. */ +# define INTMAX_MAX (__INT64_C(9223372036854775807)) + +/* Maximum for largest unsigned integral type. */ +# define UINTMAX_MAX (__UINT64_C(18446744073709551615)) + + +/* Limits of other integer types. */ + +/* Limits of `ptrdiff_t' type. */ +# if __WORDSIZE == 64 +# define PTRDIFF_MIN (-9223372036854775807L-1) +# define PTRDIFF_MAX (9223372036854775807L) +# else +# define PTRDIFF_MIN (-2147483647-1) +# define PTRDIFF_MAX (2147483647) +# endif + +/* Limits of `sig_atomic_t'. */ +# define SIG_ATOMIC_MIN (-2147483647-1) +# define SIG_ATOMIC_MAX (2147483647) + +/* Limit of `size_t' type. */ +# if __WORDSIZE == 64 +# define SIZE_MAX (18446744073709551615UL) +# else +# define SIZE_MAX (4294967295U) +# endif + +/* Limits of `wchar_t'. */ +# ifndef WCHAR_MIN +/* These constants might also be defined in . */ +# define WCHAR_MIN __WCHAR_MIN +# define WCHAR_MAX __WCHAR_MAX +# endif + +/* Limits of `wint_t'. */ +# define WINT_MIN (0u) +# define WINT_MAX (4294967295u) + +#endif /* C++ && limit macros */ + + +/* The ISO C99 standard specifies that in C++ implementations these + should only be defined if explicitly requested. */ +#if !defined __cplusplus || defined __STDC_CONSTANT_MACROS + +/* Signed. */ +# define INT8_C(c) c +# define INT16_C(c) c +# define INT32_C(c) c +# if __WORDSIZE == 64 +# define INT64_C(c) c ## L +# else +# define INT64_C(c) c ## LL +# endif + +/* Unsigned. */ +# define UINT8_C(c) c ## U +# define UINT16_C(c) c ## U +# define UINT32_C(c) c ## U +# if __WORDSIZE == 64 +# define UINT64_C(c) c ## UL +# else +# define UINT64_C(c) c ## ULL +# endif + +/* Maximal type. */ +# if __WORDSIZE == 64 +# define INTMAX_C(c) c ## L +# define UINTMAX_C(c) c ## UL +# else +# define INTMAX_C(c) c ## LL +# define UINTMAX_C(c) c ## ULL +# endif + +#endif /* C++ && constant macros */ + +#endif /* stdint.h */ diff --git a/source/fceultra/state.c b/source/fceultra/state.c index b225ab42..619bf0b1 100644 --- a/source/fceultra/state.c +++ b/source/fceultra/state.c @@ -41,8 +41,8 @@ #include "video.h" -void (*SPreSave)(void); -void (*SPostSave)(void); +static void (*SPreSave)(void); +static void (*SPostSave)(void); static int SaveStateStatus[10]; static int StateShow; @@ -113,15 +113,15 @@ static int SubWrite(FILE *st, SFORMAT *sf) if(sf->s&RLSB) FlipByteOrder(sf->v,sf->s&(~RLSB)); #endif - + fwrite((uint8 *)sf->v,1,sf->s&(~RLSB),st); /* Now restore the original byte order. */ #ifndef LSB_FIRST - if(sf->s&RLSB) + if(sf->s&RLSB) FlipByteOrder(sf->v,sf->s&(~RLSB)); #endif } - sf++; + sf++; } return(acc); @@ -132,9 +132,9 @@ static int WriteStateChunk(FILE *st, int type, SFORMAT *sf) int bsize; fputc(type,st); - + bsize=SubWrite(0,sf); - write32le(bsize,st); + write32le(bsize,st); if(!SubWrite(st,sf)) return(0); return (bsize+5); @@ -235,11 +235,11 @@ int FCEUSS_SaveFP(FILE *st) { static uint32 totalsize; static uint8 header[16]="FCS"; - + memset(header+4,0,13); header[3]=0xFF; FCEU_en32lsb(header + 8, FCEU_VERSION_NUMERIC); - fwrite(header,1,16,st); + fwrite(header,1,16,st); FCEUPPU_SaveState(); FCEUSND_SaveState(); totalsize=WriteStateChunk(st,1,SFCPU); @@ -305,12 +305,12 @@ int FCEUSS_LoadFP(FILE *st) x=ReadStateChunks(st,*(uint32*)(header+4)); if(stateversion<9500) X.IRQlow=0; - + if(GameStateRestore) GameStateRestore(stateversion); if(x) { FCEUPPU_LoadState(stateversion); - FCEUSND_LoadState(stateversion); + FCEUSND_LoadState(stateversion); } return(x); } @@ -348,7 +348,7 @@ int FCEUSS_Load(char *fname) SaveStateStatus[CurrentState]=1; fclose(st); return(1); - } + } else { SaveStateStatus[CurrentState]=1; @@ -418,7 +418,7 @@ void FCEUI_SelectState(int w) CurrentState=w; StateShow=180; FCEU_DispMessage("-select state-"); -} +} void FCEUI_SaveState(char *fname) { @@ -448,7 +448,7 @@ void FCEUI_LoadState(char *fname) if(FCEUSS_SaveFP(fp)) { fclose(fp); - FCEUNET_SendFile(FCEUNPCMD_LOADSTATE, fn); + FCEUNET_SendFile(FCEUNPCMD_LOADSTATE, fn); } else fclose(fp); /*** REMOVED GC V1.0 diff --git a/source/fceultra/unif.c b/source/fceultra/unif.c index 888693ad..a6bfd6a7 100644 --- a/source/fceultra/unif.c +++ b/source/fceultra/unif.c @@ -57,7 +57,7 @@ typedef struct { int (*init)(FCEUFILE *fp); } BFMAPPING; -CartInfo UNIFCart; +static CartInfo UNIFCart; static int vramo; static int mirrortodo; @@ -130,7 +130,7 @@ static int DoMirroring(FCEUFILE *fp) { uint8 t; t=FCEU_fgetc(fp); - mirrortodo=t; + mirrortodo=t; { static char *stuffo[6]={"Horizontal","Vertical","$2000","$2400","\"Four-screen\"","Controlled by Mapper Hardware"}; @@ -268,7 +268,7 @@ static int LoadPRG(FCEUFILE *fp) else FCEU_printf("\n"); - SetupCartPRGMapping(z,malloced[z],t,0); + SetupCartPRGMapping(z,malloced[z],t,0); return(1); } @@ -371,14 +371,14 @@ static BMAPPING bmap[] = { { "CPROM", CPROM_Init,0}, { "CNROM", CNROM_Init,0}, - + //{ "GNROM", GNROM_Init,0}, //{ "NROM", NROM256_Init,0 }, //{ "RROM", NROM128_Init,0 }, //{ "RROM-128", NROM128_Init,0 }, //{ "NROM-128", NROM128_Init,0 }, //{ "NROM-256", NROM256_Init,0 }, - + { "MHROM", MHROM_Init,0}, { "UNROM", UNROM_Init,0}, { "MARIO1-MALEE2", MALEE_Init,0}, @@ -410,13 +410,13 @@ int LoadUNIFChunks(FCEUFILE *fp) for(;;) { t=FCEU_fread(&uchead,1,4,fp); - if(t<4) + if(t<4) { if(t>0) - return 0; + return 0; return 1; } - if(!(FCEU_read32le(&uchead.info,fp))) + if(!(FCEU_read32le(&uchead.info,fp))) return 0; t=0; x=0; @@ -428,7 +428,7 @@ int LoadUNIFChunks(FCEUFILE *fp) if(!bfunc[x].init(fp)) return 0; t=1; - break; + break; } x++; } @@ -484,7 +484,7 @@ static void UNIFGI(int h) if(UNIFchrrama) memset(UNIFchrrama,0,8192); break; case GI_CLOSE: - //FCEU_SaveGameSave(&UNIFCart); + FCEU_SaveGameSave(&UNIFCart); if(UNIFCart.Close) UNIFCart.Close(); FreeUNIF(); @@ -497,7 +497,7 @@ int UNIFLoad(const char *name, FCEUFILE *fp) FCEU_fseek(fp,0,SEEK_SET); FCEU_fread(&unhead,1,4,fp); if(memcmp(&unhead,"UNIF",4)) - return 0; + return 0; ResetCartMapping(); @@ -512,7 +512,7 @@ int UNIFLoad(const char *name, FCEUFILE *fp) { int x; struct md5_context md5; - + md5_starts(&md5); for(x=0;x<32;x++) @@ -531,10 +531,10 @@ int UNIFLoad(const char *name, FCEUFILE *fp) if(!InitializeBoard()) goto aborto; - //FCEU_LoadGameSave(&UNIFCart); + FCEU_LoadGameSave(&UNIFCart); GameInterface=UNIFGI; return 1; - + aborto: FreeUNIF(); diff --git a/source/fceultra/video.c b/source/fceultra/video.c index e0913937..96981f6d 100644 --- a/source/fceultra/video.c +++ b/source/fceultra/video.c @@ -144,13 +144,13 @@ void FCEU_PutImage(void) void FCEU_DispMessage(char *format, ...) { -/* va_list ap; + va_list ap; va_start(ap,format); vsprintf(errmsg,format,ap); va_end(ap); - howlong=180;*/ + howlong=180; } void FCEU_ResetMessages(void) diff --git a/source/ngc/button_mapping.c b/source/ngc/button_mapping.c index 2e0bf7d6..c6958e7d 100644 --- a/source/ngc/button_mapping.c +++ b/source/ngc/button_mapping.c @@ -84,7 +84,7 @@ CtrlrMap ctrlr_def[4] = { {PAD_BUTTON_B, "B"}, {PAD_BUTTON_X, "X"}, {PAD_BUTTON_Y, "Y"}, - {PAD_BUTTON_MENU, "START"}, + {PAD_BUTTON_MENU, "MENU"}, {PAD_BUTTON_START, "START"}, {PAD_TRIGGER_L, "L TRIG"}, {PAD_TRIGGER_R, "R TRIG"}, diff --git a/source/ngc/common.h b/source/ngc/common.h index f88a3ea0..22a06336 100644 --- a/source/ngc/common.h +++ b/source/ngc/common.h @@ -35,4 +35,4 @@ extern int eoptions; #define EO_FORCEISCALE 16384 #define EO_NOFOURSCORE 32768 -extern unsigned char * nesrom; +extern unsigned char * nesromptr; diff --git a/source/ngc/dvd.c b/source/ngc/dvd.c index 05f0b19f..765e8a2d 100644 --- a/source/ngc/dvd.c +++ b/source/ngc/dvd.c @@ -14,7 +14,6 @@ #include #include #include -#include #ifdef WII_DVD #include @@ -22,204 +21,77 @@ #include "menudraw.h" #include "gcunzip.h" -#include "fceuconfig.h" -u64 dvddir = 0; // offset of currently selected file or folder -int dvddirlength = 0; // length of currently selected file or folder -u64 dvdrootdir = 0; // offset of DVD root -bool isWii = false; +extern bool isWii; +extern int offset; +extern int selection; +extern FILEENTRIES filelist[MAXFILES]; +extern int maxfiles; +u64 dvddir = 0; +u64 dvdrootdir = 0; +int dvddirlength = 0; #ifdef HW_DOL /** DVD I/O Address base **/ volatile unsigned long *dvd = (volatile unsigned long *) 0xCC006000; #endif -/**************************************************************************** - * dvd_read - * - * Main DVD function, everything else uses this! - * returns: 1 - ok ; 0 - error - ***************************************************************************/ -#define ALIGN_FORWARD(x,align) ((typeof(x))((((uint32_t)(x)) + (align) - 1) & (~(align-1)))) -#define ALIGN_BACKWARD(x,align) ((typeof(x))(((uint32_t)(x)) & (~(align-1)))) + /** Due to lack of memory, we'll use this little 2k keyhole for all DVD operations **/ +unsigned char DVDreadbuffer[2048] ATTRIBUTE_ALIGN (32); +unsigned char dvdbuffer[2048]; + + /** + * dvd_read + * + * The only DVD function we need - you gotta luv gc-linux self-boots! + * returns: 1 - ok ; 0 - error + */ int dvd_read (void *dst, unsigned int len, u64 offset) { + + unsigned char *buffer = (unsigned char *) (unsigned int) DVDreadbuffer; + if (len > 2048) return 0; /*** We only allow 2k reads **/ - // don't read past the end of the DVD (1.5 GB for GC DVD, 4.7 GB for DVD) - if((offset < 0x57057C00) || (isWii && (offset < 0x118244F00LL))) + DCInvalidateRange ((void *) buffer, len); + + if(offset < 0x57057C00 || (isWii == true && offset < 0x118244F00LL)) // don't read past the end of the DVD { - u8 * buffer = (u8 *)memalign(32, 0x8000); - u32 off_size = 0; - DCInvalidateRange ((void *) buffer, len); + #ifdef HW_DOL - #ifdef HW_DOL - dvd[0] = 0x2E; - dvd[1] = 0; - dvd[2] = 0xA8000000; - dvd[3] = (u32)(offset >> 2); - dvd[4] = len; - dvd[5] = (u32) buffer; - dvd[6] = len; - dvd[7] = 3; - - // Enable reading with DMA - while (dvd[7] & 1); - - // Ensure it has completed - if (dvd[0] & 0x4) - return 0; - #else - off_size = offset - ALIGN_BACKWARD(offset,0x800); - if (DI_ReadDVD( - buffer, - (ALIGN_FORWARD(offset + len,0x800) - ALIGN_BACKWARD(offset,0x800)) >> 11, - (u32)(ALIGN_BACKWARD(offset, 0x800) >> 11) - )) - return 0; - #endif + dvd[0] = 0x2E; + dvd[1] = 0; + dvd[2] = 0xA8000000; + dvd[3] = (u32)(offset >> 2); + dvd[4] = len; + dvd[5] = (u32) buffer; + dvd[6] = len; + dvd[7] = 3; /*** Enable reading with DMA ***/ + while (dvd[7] & 1); + memcpy (dst, buffer, len); + + if (dvd[0] & 0x4) /* Ensure it has completed */ + return 0; - memcpy (dst, buffer+off_size, len); - free(buffer); return 1; + + #elif WII_DVD + int ret = 1; + ret = DI_ReadDVD(dst, len >> 11, (u32)(offset >> 11)); + if (ret==0) + return 1; + else + return 0; + #endif } return 0; } -/**************************************************************************** - * dvd_buffered_read - * - * the GC's dvd drive only supports offsets and length which are a multiple - * of 32 bytes additionally the max length of a read is 2048 bytes - * this function removes these limitations - * additionally the 7zip SDK does often read data in 1 byte parts from the - * DVD even when it could read 32 bytes. the dvdsf_buffer has been added to - * avoid having to read the same sector over and over again - ***************************************************************************/ - -#define DVD_LENGTH_MULTIPLY 32 -#define DVD_OFFSET_MULTIPLY 32 -#define DVD_MAX_READ_LENGTH 2048 -#define DVD_SECTOR_SIZE 2048 - -unsigned char dvdsf_buffer[DVD_SECTOR_SIZE]; -u64 dvdsf_last_offset = 0; -u64 dvdsf_last_length = 0; - -int dvd_buffered_read(void *dst, u32 len, u64 offset) -{ - int ret = 0; - - // only read data if the data inside dvdsf_buffer cannot be used - if(offset != dvdsf_last_offset || len > dvdsf_last_length) - { - memset(&dvdsf_buffer, '\0', DVD_SECTOR_SIZE); - ret = dvd_read(&dvdsf_buffer, len, offset); - dvdsf_last_offset = offset; - dvdsf_last_length = len; - } - - memcpy(dst, &dvdsf_buffer, len); - return ret; -} - -int dvd_safe_read(void *dst_v, u32 len, u64 offset) -{ - unsigned char buffer[DVD_SECTOR_SIZE]; // buffer for one dvd sector - - // if read size and length are a multiply of DVD_(OFFSET,LENGTH)_MULTIPLY and length < DVD_MAX_READ_LENGTH - // we don't need to fix anything - if(len % DVD_LENGTH_MULTIPLY == 0 && offset % DVD_OFFSET_MULTIPLY == 0 && len <= DVD_MAX_READ_LENGTH) - { - int ret = dvd_buffered_read(buffer, len, offset); - memcpy(dst_v, &buffer, len); - return ret; - } - else - { - // no errors yet -> ret = 0 - // the return value of dvd_read will be OR'd with ret - // because dvd_read does return 1 on error and 0 on success and - // because 0 | 1 = 1 ret will also contain 1 if at least one error - // occured and 0 otherwise ;) - int ret = 0; // return value of dvd_read - - // we might need to fix all 3 issues - unsigned char *dst = (unsigned char *)dst_v; // gcc will not allow to use var[num] on void* types - u64 bytesToRead; // the number of bytes we still need to read & copy to the output buffer - u64 currentOffset; // the current dvd offset - u64 bufferOffset; // the current buffer offset - u64 i, j, k; // temporary variables which might be used for different stuff - // unsigned char buffer[DVD_SECTOR_SIZE]; // buffer for one dvd sector - - currentOffset = offset; - bytesToRead = len; - bufferOffset = 0; - - // fix first issue (offset is not a multiply of 32) - if(offset % DVD_OFFSET_MULTIPLY) - { - // calculate offset of the prior 32 byte position - i = currentOffset - (currentOffset % DVD_OFFSET_MULTIPLY); - - // calculate the offset from which the data of the dvd buffer will be copied - j = currentOffset % DVD_OFFSET_MULTIPLY; - - // calculate the number of bytes needed to reach the next DVD_OFFSET_MULTIPLY byte mark - k = DVD_OFFSET_MULTIPLY - j; - - // maybe we'll only need to copy a few bytes and we therefore don't even reach the next sector - if(k > len) - { - k = len; - } - - // read 32 bytes from the last 32 byte position - ret |= dvd_buffered_read(buffer, DVD_OFFSET_MULTIPLY, i); - - // copy the bytes to the output buffer and update currentOffset, bufferOffset and bytesToRead - memcpy(&dst[bufferOffset], &buffer[j], k); - currentOffset += k; - bufferOffset += k; - bytesToRead -= k; - } - - // fix second issue (more than 2048 bytes are needed) - if(bytesToRead > DVD_MAX_READ_LENGTH) - { - // calculate the number of 2048 bytes sector needed to get all data - i = (bytesToRead - (bytesToRead % DVD_MAX_READ_LENGTH)) / DVD_MAX_READ_LENGTH; - - // read data in 2048 byte sector - for(j = 0; j < i; j++) - { - ret |= dvd_buffered_read(buffer, DVD_MAX_READ_LENGTH, currentOffset); // read sector - memcpy(&dst[bufferOffset], buffer, DVD_MAX_READ_LENGTH); // copy to output buffer - - // update currentOffset, bufferOffset and bytesToRead - currentOffset += DVD_MAX_READ_LENGTH; - bufferOffset += DVD_MAX_READ_LENGTH; - bytesToRead -= DVD_MAX_READ_LENGTH; - } - } - - // fix third issue (length is not a multiply of 32) - if(bytesToRead) - { - ret |= dvd_buffered_read(buffer, DVD_MAX_READ_LENGTH, currentOffset); // read 32 byte from the dvd - memcpy(&dst[bufferOffset], buffer, bytesToRead); // copy bytes to output buffer - } - - //free(tmp); - return ret; - } -} - /** Minimal ISO Directory Definition **/ #define RECLEN 0 /* Record length */ #define EXTENT 6 /* Extent */ @@ -232,18 +104,17 @@ int dvd_safe_read(void *dst_v, u32 len, u64 offset) #define PVDROOT 0x9c static int IsJoliet = 0; -/**************************************************************************** +/** * Primary Volume Descriptor * * The PVD should reside between sector 16 and 31. * This is for single session DVD only. - ***************************************************************************/ + */ int getpvd () { int sector = 16; u32 rootdir32; - unsigned char dvdbuffer[2048]; dvddir = dvddirlength = 0; IsJoliet = -1; @@ -301,7 +172,7 @@ getpvd () * TestDVD() * * Tests if a ISO9660 DVD is inserted and available - ***************************************************************************/ + ****************************************************************************/ bool TestDVD() { @@ -320,15 +191,15 @@ bool TestDVD() return true; } -/**************************************************************************** +/** * getentry * * Support function to return the next file entry, if any * Declared static to avoid accidental external entry. - ***************************************************************************/ + */ static int diroffset = 0; static int -getentry (int entrycount, unsigned char dvdbuffer[]) +getentry (int entrycount) { char fname[512]; /* Huge, but experience has determined this */ char *ptr; @@ -431,7 +302,7 @@ getentry (int entrycount, unsigned char dvdbuffer[]) return 0; } -/**************************************************************************** +/** * parseDVDdirectory * * This function will parse the directory tree. @@ -439,7 +310,7 @@ getentry (int entrycount, unsigned char dvdbuffer[]) * getpvd, a previous parse or a menu selection. * * The return value is number of files collected, or 0 on failure. - ***************************************************************************/ + */ int ParseDVDdirectory () { @@ -448,7 +319,6 @@ ParseDVDdirectory () u64 rdoffset; int len = 0; int filecount = 0; - unsigned char dvdbuffer[2048]; // initialize selection selection = offset = 0; @@ -468,7 +338,7 @@ ParseDVDdirectory () diroffset = 0; - while (getentry (filecount, dvdbuffer)) + while (getentry (filecount)) { if(strlen(filelist[filecount].filename) > 0 && filecount < MAXFILES) filecount++; @@ -484,12 +354,12 @@ ParseDVDdirectory () return filecount; } -/**************************************************************************** - * DirectorySearch - * - * Searches for the directory name specified within the current directory - * Returns the index of the directory, or -1 if not found - ***************************************************************************/ +/** +* DirectorySearch +* +* Searches for the directory name specified within the current directory +* Returns the index of the directory, or -1 if not found +*/ int DirectorySearch(char dir[512]) { int i; @@ -499,14 +369,14 @@ int DirectorySearch(char dir[512]) return -1; } -/**************************************************************************** - * SwitchDVDFolder - * - * Recursively searches for any directory path 'dir' specified - * Also loads the directory contents via ParseDVDdirectory() - * It relies on dvddir, dvddirlength, and filelist being pre-populated - ***************************************************************************/ -bool SwitchDVDFolderR(char * dir, int maxDepth) +/** +* SwitchDVDFolder +* +* Recursively searches for any directory path 'dir' specified +* Also loads the directory contents via ParseDVDdirectory() +* It relies on dvddir, dvddirlength, and filelist being pre-populated +*/ +bool DoSwitchDVDFolder(char * dir, int maxDepth) { if(maxDepth > 8) // only search to a max depth of 8 levels return false; @@ -533,7 +403,7 @@ bool SwitchDVDFolderR(char * dir, int maxDepth) if(lastdir) return true; else - return SwitchDVDFolderR(nextdir, maxDepth++); + return DoSwitchDVDFolder(nextdir, maxDepth++); } return false; } @@ -553,20 +423,20 @@ bool SwitchDVDFolder(char origdir[]) if(dir[strlen(dir)-1] == '/') dir[strlen(dir)-1] = 0; - return SwitchDVDFolderR(dirptr, 0); + return DoSwitchDVDFolder(dirptr, 0); } /**************************************************************************** * LoadDVDFile - * This function will load a file from DVD + * This function will load a file from DVD, in BIN, SMD or ZIP format. * The values for offset and length are inherited from dvddir and * dvddirlength. * - * The buffer parameter should re-use the initial ROM buffer - ***************************************************************************/ + * The buffer parameter should re-use the initial ROM buffer. + ****************************************************************************/ int -LoadDVDFile (unsigned char *buffer, int length) +LoadDVDFile (unsigned char *buffer) { int offset; int blocks; @@ -574,46 +444,35 @@ LoadDVDFile (unsigned char *buffer, int length) u64 discoffset; char readbuffer[2048]; - dvddir = filelist[selection].offset; - dvddirlength = filelist[selection].length; - // How many 2k blocks to read blocks = dvddirlength / 2048; offset = 0; discoffset = dvddir; ShowAction ((char*) "Loading..."); + dvd_read (readbuffer, 2048, discoffset); - if(length > 0) // do a partial read (eg: to check file header) - { - dvd_read (buffer, length, discoffset); - } - else // load whole file + if (!IsZipFile (readbuffer)) { - dvd_read (readbuffer, 2048, discoffset); - - if (IsZipFile (readbuffer)) + for (i = 0; i < blocks; i++) { - return UnZipBuffer (buffer, METHOD_DVD); // unzip from dvd + dvd_read (readbuffer, 2048, discoffset); + memcpy (buffer + offset, readbuffer, 2048); + offset += 2048; + discoffset += 2048; } - else - { - for (i = 0; i < blocks; i++) - { - dvd_read (readbuffer, 2048, discoffset); - memcpy (buffer + offset, readbuffer, 2048); - offset += 2048; - discoffset += 2048; - } - /*** And final cleanup ***/ - if (dvddirlength % 2048) - { - i = dvddirlength % 2048; - dvd_read (readbuffer, 2048, discoffset); - memcpy (buffer + offset, readbuffer, i); - } + /*** And final cleanup ***/ + if (dvddirlength % 2048) + { + i = dvddirlength % 2048; + dvd_read (readbuffer, 2048, discoffset); + memcpy (buffer + offset, readbuffer, i); } } + else + { + return UnZipDVDFile (buffer, discoffset); // unzip from dvd + } return dvddirlength; } @@ -625,7 +484,7 @@ LoadDVDFile (unsigned char *buffer, int length) * memcard interface. * * libOGC tends to foul up if you don't, and sometimes does if you do! - ***************************************************************************/ + ****************************************************************************/ #ifdef HW_DOL void uselessinquiry () { @@ -641,11 +500,7 @@ void uselessinquiry () while (dvd[7] & 1); } -/**************************************************************************** - * dvd_motor_off( ) - * Turns off DVD drive motor so it doesn't make noise (Gamecube only) - ***************************************************************************/ -void dvd_motor_off () +void dvd_motor_off( ) { dvd[0] = 0x2e; dvd[1] = 0; @@ -662,11 +517,11 @@ void dvd_motor_off () dvd[1] = 0; } -/**************************************************************************** - * dvd_driveid - * - * Gets and returns the dvd driveid - ***************************************************************************/ +/** + * dvd_driveid + * + * Gets and returns the dvd driveid +**/ int dvd_driveid() { @@ -690,20 +545,3 @@ int dvd_driveid() #endif -/**************************************************************************** - * SetDVDDriveType() - * - * Sets the DVD drive ID for use to determine disc size (1.5 GB or 4.7 GB) - ***************************************************************************/ -void SetDVDDriveType() -{ - #ifdef HW_RVL - isWii = true; - #else - int drvid = dvd_driveid (); - if ( drvid == 4 || drvid == 6 || drvid == 8 ) - isWii = false; - else - isWii = true; - #endif -} diff --git a/source/ngc/dvd.h b/source/ngc/dvd.h index 2eb6bb48..20d52a29 100644 --- a/source/ngc/dvd.h +++ b/source/ngc/dvd.h @@ -14,16 +14,9 @@ int getpvd (); int ParseDVDdirectory (); -int LoadDVDFile (unsigned char *buffer, int length); +int LoadDVDFile (unsigned char *buffer); bool TestDVD(); int dvd_read (void *dst, unsigned int len, u64 offset); -int dvd_safe_read (void *dst, unsigned int len, u64 offset); bool SwitchDVDFolder(char dir[]); -#ifdef HW_DOL -void dvd_motor_off (); -#endif - -extern u64 dvddir; -extern int dvddirlength; #endif diff --git a/source/ngc/fceuconfig.c b/source/ngc/fceuconfig.c index c0fba05f..c9da6481 100644 --- a/source/ngc/fceuconfig.c +++ b/source/ngc/fceuconfig.c @@ -26,7 +26,6 @@ DefaultSettings () GCSettings.timing = 0; GCSettings.FSDisable = 1; GCSettings.zapper = 0; - GCSettings.crosshair = 1; GCSettings.slimit = 1; GCSettings.screenscaler = 2; @@ -38,16 +37,11 @@ DefaultSettings () GCSettings.AutoLoad = 1; // Auto Load RAM GCSettings.AutoSave = 1; // Auto Save RAM - // custom SMB settings - strncpy (GCSettings.smbip, "", 15); // IP Address of share server - strncpy (GCSettings.smbuser, "", 19); // Your share user - strncpy (GCSettings.smbpwd, "", 19); // Your share user password - strncpy (GCSettings.smbshare, "", 19); // Share name on server - - GCSettings.smbip[15] = 0; - GCSettings.smbuser[19] = 0; - GCSettings.smbpwd[19] = 0; - GCSettings.smbshare[19] = 0; + // default SMB settings + strncpy (GCSettings.smbip, "192.168.0.1", 15); // IP Address of share server + strncpy (GCSettings.smbuser, "Wiiuser", 19); // Your share user + strncpy (GCSettings.smbpwd, "password", 19); // Your share user password + strncpy (GCSettings.smbshare, "NES", 19); // Share name on server GCSettings.gcip[0] = 0; GCSettings.gwip[0] = 0; diff --git a/source/ngc/fceuconfig.h b/source/ngc/fceuconfig.h index 720686d9..69cf64a8 100644 --- a/source/ngc/fceuconfig.h +++ b/source/ngc/fceuconfig.h @@ -15,8 +15,8 @@ void DefaultSettings (); -#define VERSIONNUM "2.0.4" -#define VERSIONSTR "FCE Ultra GX 2.0.4" +#define VERSIONNUM "2.0.1" +#define VERSIONSTR "FCE Ultra GX 2.0.1" #define NOTSILENT 0 #define SILENT 1 @@ -53,7 +53,6 @@ struct SGCSettings{ int timing; int FSDisable; int zapper; - int crosshair; int slimit; int screenscaler; }; diff --git a/source/ngc/fceugc.c b/source/ngc/fceugc.c index 09efb314..22b3fd01 100644 --- a/source/ngc/fceugc.c +++ b/source/ngc/fceugc.c @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -34,7 +33,6 @@ #include #endif -unsigned char * nesrom = NULL; extern bool romLoaded; bool isWii; @@ -42,7 +40,6 @@ uint8 *xbsave=NULL; extern int cleanSFMDATA(); extern void ResetNES(void); -extern uint8 FDSBIOS[8192]; void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); @@ -72,14 +69,11 @@ int main(int argc, char *argv[]) } InitialiseSound(); - fatInit (8, false); + fatInitDefault(); #ifndef HW_RVL DVD_Init(); #endif - // allocate memory to store rom - nesrom = (unsigned char *)malloc(1024*1024*3); // 3 MB should be plenty - /*** Minimal Emulation Loop ***/ if ( !FCEUI_Initialize() ) { printf("Unable to initialize system\n"); @@ -89,8 +83,9 @@ int main(int argc, char *argv[]) FCEUI_SetVidSystem(0); // 0 - NTSC, 1 - PAL FCEUI_SetGameGenie(0); // 0 - OFF, 1 - ON - memset(FDSBIOS, 0, sizeof(FDSBIOS)); // clear FDS BIOS memory cleanSFMDATA(); // clear state data + GCMemROM(); // load color test ROM + romLoaded = false; // we start off with only the color test rom // Set Defaults DefaultSettings(); @@ -123,14 +118,15 @@ int main(int argc, char *argv[]) /**************************************************************************** * FCEU Support Functions to be written ****************************************************************************/ -// File Control +/*** File Control ***/ + + FILE *FCEUD_UTF8fopen(const char *n, const char *m) { - return NULL; - //return(fopen(n,m)); + return(fopen(n,m)); } -// General Logging +/*** General Logging ***/ void FCEUD_PrintError(char *s) { } @@ -139,15 +135,15 @@ void FCEUD_Message(char *text) { } -// main interface to FCE Ultra -void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int32 Count) +/*** VIDEO ***/ +void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count) { - PlaySound(Buffer, Count); // play sound - RenderFrame( (char *)XBuf, GCSettings.screenscaler); // output video frame - GetJoy(); // check controller input + PlaySound(Buffer, Count); + RenderFrame( (char *)XBuf, GCSettings.screenscaler ); + GetJoy(); } -// Netplay +/*** Netplay ***/ int FCEUD_SendData(void *data, uint32 len) { return 1; diff --git a/source/ngc/fceuload.c b/source/ngc/fceuload.c index cce6c2d2..6cb603fe 100644 --- a/source/ngc/fceuload.c +++ b/source/ngc/fceuload.c @@ -22,58 +22,25 @@ #include "palette.h" #include "fceu.h" #include "sound.h" -#include "file.h" #include "common.h" #include "pad.h" #include "menudraw.h" -#include "fceuconfig.h" -#include "fileop.h" -#include "filesel.h" -#include "smbop.h" -unsigned char *nesrom; +unsigned char *nesromptr; bool romLoaded = false; extern FCEUGI *FCEUGameInfo; +extern int iNESMemLoad( char *rom ); -#define SAMPLERATE 48000 +extern unsigned char nesrom[]; -FCEUFILE *fceufp = NULL; -MEMWRAP *fceumem = NULL; -unsigned char * fceuFileData = NULL; +#define SAMPLERATE 48000 -void MakeFCEUFile(char * membuffer, int length) +int GCMemROM() { - if(fceufp != NULL) - { - free(fceuFileData); - free(fceumem); - free(fceufp); - fceuFileData = NULL; - fceumem = NULL; - fceufp = NULL; - } - - fceufp =(FCEUFILE *)malloc(sizeof(FCEUFILE)); - fceufp->type=3; - fceumem = (MEMWRAP *)malloc(sizeof(MEMWRAP)); - fceumem->location=0; - fceumem->size=length; - fceuFileData = (unsigned char *)malloc(length); - memcpy(fceuFileData, membuffer, length); - fceumem->data=fceuFileData; - fceufp->fp = fceumem; -} - -extern int FDSLoad(const char *name, FCEUFILE *fp); -extern int iNESLoad(const char *name, FCEUFILE *fp); -extern int UNIFLoad(const char *name, FCEUFILE *fp); -extern int NSFLoad(FCEUFILE *fp); -extern uint8 FDSBIOS[8192]; + nesromptr = &nesrom[0]; -int GCMemROM(int method, int size) -{ ResetGameLoaded(); /*** Allocate and clear GameInfo ***/ @@ -94,63 +61,12 @@ int GCMemROM(int method, int size) /*** Set internal sound information ***/ FCEUI_Sound(SAMPLERATE); FCEUI_SetSoundVolume(100); // 0-100 - FCEUI_SetSoundQuality(0); // 0 - low, 1 - high + FCEUI_SetSoundQuality(1); // 0 - low, 1 - high FCEUI_SetLowPass(0); InitialisePads(); - MakeFCEUFile((char *)nesrom, size); - - nesGameType = 0; - - if(iNESLoad(NULL, fceufp)) - nesGameType = 1; - else if(UNIFLoad(NULL,fceufp)) - nesGameType = 2; - else if(NSFLoad(fceufp)) - nesGameType = 3; - else - { - // read FDS BIOS into FDSBIOS - should be 8192 bytes - if(FDSBIOS[1] == 0) - { - int biosSize = 0; - char * tmpbuffer = (char *)malloc(64 * 1024); - - char filepath[1024]; - - switch (method) - { - case METHOD_SD: - case METHOD_USB: - sprintf(filepath, "%s/%s/disksys.rom", ROOTFATDIR, GCSettings.LoadFolder); - biosSize = LoadBufferFromFAT(tmpbuffer, filepath, NOTSILENT); - break; - case METHOD_SMB: - sprintf(filepath, "%s/disksys.rom", GCSettings.LoadFolder); - biosSize = LoadBufferFromSMB(tmpbuffer, filepath, 0, NOTSILENT); - break; - } - - if(biosSize == 8192) - { - memcpy(FDSBIOS, tmpbuffer, 8192); - } - else - { - if(biosSize > 0) - WaitPrompt("FDS BIOS file is invalid!"); - - return 0; // BIOS not loaded, do not load game - } - free(tmpbuffer); - } - // load game - if(FDSLoad(NULL,fceufp)) - nesGameType = 4; - } - - if (nesGameType > 0) + if ( iNESMemLoad( (char *)nesromptr ) ) { FCEU_ResetVidSys(); PowerNES(); @@ -158,7 +74,6 @@ int GCMemROM(int method, int size) FCEU_ResetMessages(); // Save state, status messages, etc. SetSoundVariables(); romLoaded = true; - return 1; } else { @@ -166,4 +81,7 @@ int GCMemROM(int method, int size) romLoaded = false; return 0; } + + return 1; } + diff --git a/source/ngc/fceuload.h b/source/ngc/fceuload.h index 6b44b809..138a10d7 100644 --- a/source/ngc/fceuload.h +++ b/source/ngc/fceuload.h @@ -9,4 +9,4 @@ * NES Memory Load Game ****************************************************************************/ -int GCMemROM(int method, int size); +int GCMemROM(); diff --git a/source/ngc/fceuram.c b/source/ngc/fceuram.c index 59fdd7a2..d53e4aee 100644 --- a/source/ngc/fceuram.c +++ b/source/ngc/fceuram.c @@ -41,7 +41,9 @@ extern u32 iNESGameCRC32; extern CartInfo iNESCart; -extern CartInfo UNIFCart; + +extern unsigned char savebuffer[SAVEBUFFERSIZE]; +extern char romFilename[]; int NGCFCEU_GameSave(CartInfo *LocalHWInfo, int operation) { @@ -71,13 +73,6 @@ int NGCFCEU_GameSave(CartInfo *LocalHWInfo, int operation) bool SaveRAM (int method, bool silent) { - if(nesGameType == 4) - { - if(!silent) - WaitPrompt((char *)"Saving is not available for FDS games!"); - return false; - } - ShowAction ((char*) "Saving..."); if(method == METHOD_AUTO) @@ -85,14 +80,10 @@ bool SaveRAM (int method, bool silent) bool retval = false; char filepath[1024]; - int datasize = 0; + int datasize; int offset = 0; - // save game save to savebuffer - if(nesGameType == 1) - datasize = NGCFCEU_GameSave(&iNESCart, 0); - else if(nesGameType == 2) - datasize = NGCFCEU_GameSave(&UNIFCart, 0); + datasize = NGCFCEU_GameSave(&iNESCart, 0); // save game save to savebuffer if ( datasize ) { @@ -136,13 +127,6 @@ bool SaveRAM (int method, bool silent) bool LoadRAM (int method, bool silent) { - if(nesGameType == 4) - { - if(!silent) - WaitPrompt((char *)"Saving is not available for FDS games!"); - return false; - } - ShowAction ((char*) "Loading..."); if(method == METHOD_AUTO) @@ -153,11 +137,9 @@ bool LoadRAM (int method, bool silent) if(method == METHOD_SD || method == METHOD_USB) { - if(ChangeFATInterface(method, NOTSILENT)) - { - sprintf (filepath, "%s/%s/%s.sav", ROOTFATDIR, GCSettings.SaveFolder, romFilename); - offset = LoadSaveBufferFromFAT (filepath, silent); - } + ChangeFATInterface(method, NOTSILENT); + sprintf (filepath, "%s/%s/%s.sav", ROOTFATDIR, GCSettings.SaveFolder, romFilename); + offset = LoadBufferFromFAT (filepath, silent); } else if(method == METHOD_SMB) { @@ -176,11 +158,7 @@ bool LoadRAM (int method, bool silent) if (offset > 0) { - if(nesGameType == 1) - NGCFCEU_GameSave(&iNESCart, 1); - else if(nesGameType == 2) - NGCFCEU_GameSave(&UNIFCart, 1); - + NGCFCEU_GameSave(&iNESCart, 1); // load game save from savebuffer ResetNES(); return 1; } diff --git a/source/ngc/fceustate.c b/source/ngc/fceustate.c index 170d9889..f6261485 100644 --- a/source/ngc/fceustate.c +++ b/source/ngc/fceustate.c @@ -52,6 +52,9 @@ extern u32 iNESGameCRC32; int sboffset; /*** Used as a basic fileptr ***/ int mcversion = 0x981211; +extern unsigned char savebuffer[SAVEBUFFERSIZE]; +extern char romFilename[]; + /**************************************************************************** * Memory based file functions ****************************************************************************/ @@ -59,7 +62,7 @@ int mcversion = 0x981211; /*** Open a file ***/ void memopen() { sboffset = 0; - memset(savebuffer, 0, SAVEBUFFERSIZE); + memset(savebuffer, 0, sizeof(savebuffer)); } /*** Close a file ***/ @@ -69,7 +72,7 @@ void memclose() { /*** Write to the file ***/ void memfwrite( void *buffer, int len ) { - if ( (sboffset + len ) > SAVEBUFFERSIZE) + if ( (sboffset + len ) > sizeof(savebuffer)) WaitPrompt("Buffer Exceeded"); if ( len > 0 ) { @@ -81,7 +84,7 @@ void memfwrite( void *buffer, int len ) { /*** Read from a file ***/ void memfread( void *buffer, int len ) { - if ( ( sboffset + len ) > SAVEBUFFERSIZE) + if ( ( sboffset + len ) > sizeof(savebuffer)) WaitPrompt("Buffer exceeded"); if ( len > 0 ) { @@ -221,9 +224,6 @@ int GCSaveChunk(int chunkid, SFORMAT *sf) { * It uses memory for it's I/O and has an added CHNK block. * The file is terminated with CHNK length of 0. ****************************************************************************/ -extern void (*SPreSave)(void); -extern void (*SPostSave)(void); - int GCFCEUSS_Save() { int totalsize = 0; @@ -247,7 +247,6 @@ int GCFCEUSS_Save() /*** And Comments ***/ strncpy (Comment[1],romFilename,31); // we only have 32 chars to work with! - Comment[1][31] = 0; memfwrite(&Comment[0], 64); totalsize += 64; @@ -259,15 +258,8 @@ int GCFCEUSS_Save() totalsize += GCSaveChunk(3, FCEUPPU_STATEINFO); totalsize += GCSaveChunk(4, FCEUCTRL_STATEINFO); totalsize += GCSaveChunk(5, FCEUSND_STATEINFO); - - if(nesGameType == 4) // FDS - SPreSave(); - totalsize += GCSaveChunk(0x10, SFMDATA); - if(nesGameType == 4) // FDS - SPostSave(); - /*** Add terminating CHNK ***/ memfwrite(&chunk,4); memfwrite(&zero,4); @@ -342,14 +334,7 @@ bool LoadState (int method, bool silent) { ChangeFATInterface(method, NOTSILENT); sprintf (filepath, "%s/%s/%s.fcs", ROOTFATDIR, GCSettings.SaveFolder, romFilename); - offset = LoadSaveBufferFromFAT (filepath, silent); - - if(offset == 0) // file not found - { - // look for CRC save - sprintf (filepath, "%08x.fcs", iNESGameCRC32); - offset = LoadSaveBufferFromFAT (filepath, silent); - } + offset = LoadBufferFromFAT (filepath, silent); } else if(method == METHOD_SMB) { diff --git a/source/ngc/fileop.c b/source/ngc/fileop.c index 42ce9baa..9ad57728 100644 --- a/source/ngc/fileop.c +++ b/source/ngc/fileop.c @@ -23,8 +23,14 @@ #include "menudraw.h" #include "filesel.h" -// FAT file pointer - the only one we should ever use! -FILE * fatfile; +FILE * filehandle; + +extern unsigned char savebuffer[]; +extern char output[16384]; +extern int offset; +extern int selection; +extern char currentdir[MAXPATHLEN]; +extern FILEENTRIES filelist[MAXFILES]; /**************************************************************************** * fat_is_mounted @@ -60,7 +66,6 @@ bool ChangeFATInterface(int method, bool silent) { devFound = true; fatSetDefaultInterface(PI_INTERNAL_SD); - fatEnableReadAhead (PI_INTERNAL_SD, 6, 64); } #endif @@ -87,7 +92,6 @@ bool ChangeFATInterface(int method, bool silent) { devFound = true; fatSetDefaultInterface(PI_USBSTORAGE); - fatEnableReadAhead (PI_USBSTORAGE, 6, 64); } else { @@ -148,7 +152,6 @@ ParseFATdirectory(int method) strncpy(filelist[nbfiles].displayname, filename, MAXDISPLAY+1); // crop name for display filelist[nbfiles].length = filestat.st_size; filelist[nbfiles].flags = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir - filelist[nbfiles].offset = 0; nbfiles++; } } @@ -164,49 +167,44 @@ ParseFATdirectory(int method) /**************************************************************************** * LoadFATFile - * length > 0 - partial file read (starting from start) - * length = 0 - full read - ***************************************************************************/ + ****************************************************************************/ int -LoadFATFile (char * rbuffer, int length) +LoadFATFile (char *filename, int length) { char zipbuffer[2048]; char filepath[MAXPATHLEN]; + FILE *handle; u32 size; - if (!MakeROMPath(filepath, METHOD_SD)) + /* Check filename length */ + if ((strlen(currentdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN) + sprintf(filepath, "%s/%s",currentdir,filelist[selection].filename); + else { WaitPrompt((char*) "Maximum filepath length reached!"); return -1; } - fatfile = fopen (filepath, "rb"); - if (fatfile > 0) + handle = fopen (filepath, "rb"); + if (handle > 0) { - if(length > 0) // do a partial read (eg: to check file header) + fread (zipbuffer, 1, 2048, handle); + + if (IsZipFile (zipbuffer)) { - fread (rbuffer, 1, length, fatfile); - size = length; + size = UnZipFATFile (nesromptr, handle); // unzip from FAT } - else // load whole file + else { - fread (zipbuffer, 1, 2048, fatfile); - - if (IsZipFile (zipbuffer)) - { - size = UnZipBuffer ((unsigned char *)rbuffer, METHOD_SD); // unzip from FAT - } - else - { - // Just load the file up - fseek(fatfile, 0, SEEK_END); - size = ftell(fatfile); // get filesize - fseek(fatfile, 2048, SEEK_SET); // seek back to point where we left off - memcpy (rbuffer, zipbuffer, 2048); // copy what we already read - fread (rbuffer + 2048, 1, size - 2048, fatfile); - } + // Just load the file up + fseek(handle, 0, SEEK_END); + length = ftell(handle); // get filesize + fseek(handle, 2048, SEEK_SET); // seek back to point where we left off + memcpy (nesromptr, zipbuffer, 2048); // copy what we already read + fread (nesromptr + 2048, 1, length - 2048, handle); + size = length; } - fclose (fatfile); + fclose (handle); return size; } else @@ -214,50 +212,25 @@ LoadFATFile (char * rbuffer, int length) WaitPrompt((char*) "Error opening file"); return 0; } -} -/**************************************************************************** - * LoadFATSzFile - * Loads the selected file # from the specified 7z into rbuffer - * Returns file size - ***************************************************************************/ -int -LoadFATSzFile(char * filepath, unsigned char * rbuffer) -{ - u32 size; - fatfile = fopen (filepath, "rb"); - if (fatfile > 0) - { - size = SzExtractFile(filelist[selection].offset, rbuffer); - fclose (fatfile); - return size; - } - else - { - WaitPrompt((char*) "Error opening file"); - return 0; - } + return 0; } /**************************************************************************** * Load savebuffer from FAT file - ***************************************************************************/ - -// no buffer is specified - so use savebuffer + ****************************************************************************/ int -LoadSaveBufferFromFAT (char *filepath, bool silent) +LoadBufferFromFAT (char *filepath, bool silent) { - return LoadBufferFromFAT((char *)savebuffer, filepath, silent); -} + FILE *handle; + int boffset = 0; + int read = 0; -int -LoadBufferFromFAT (char * sbuffer, char *filepath, bool silent) -{ - int size = 0; + ClearSaveBuffer (); - fatfile = fopen (filepath, "rb"); + handle = fopen (filepath, "rb"); - if (fatfile <= 0) + if (handle <= 0) { if ( !silent ) { @@ -268,14 +241,15 @@ LoadBufferFromFAT (char * sbuffer, char *filepath, bool silent) return 0; } - // Just load the file up - fseek(fatfile, 0, SEEK_END); // go to end of file - size = ftell(fatfile); // get filesize - fseek(fatfile, 0, SEEK_SET); // go to start of file - fread (sbuffer, 1, size, fatfile); - fclose (fatfile); + /*** This is really nice, just load the file and decode it ***/ + while ((read = fread (savebuffer + boffset, 1, 1024, handle)) > 0) + { + boffset += read; + } + + fclose (handle); - return size; + return boffset; } /**************************************************************************** @@ -284,11 +258,13 @@ LoadBufferFromFAT (char * sbuffer, char *filepath, bool silent) int SaveBufferToFAT (char *filepath, int datasize, bool silent) { + FILE *handle; + if (datasize) { - fatfile = fopen (filepath, "wb"); + handle = fopen (filepath, "wb"); - if (fatfile <= 0) + if (handle <= 0) { char msg[100]; sprintf(msg, "Couldn't save %s", filepath); @@ -296,8 +272,10 @@ SaveBufferToFAT (char *filepath, int datasize, bool silent) return 0; } - fwrite (savebuffer, 1, datasize, fatfile); - fclose (fatfile); + fwrite (savebuffer, 1, datasize, handle); + fclose (handle); } + + ClearSaveBuffer (); return datasize; } diff --git a/source/ngc/fileop.h b/source/ngc/fileop.h index 754fa58d..2c6c1848 100644 --- a/source/ngc/fileop.h +++ b/source/ngc/fileop.h @@ -24,13 +24,10 @@ bool ChangeFATInterface(int method, bool silent); int ParseFATdirectory(int method); -int LoadFATFile (char * fbuffer, int length); -int LoadFATSzFile(char * filepath, unsigned char * rbuffer); +int LoadFATFile (char *filename, int length); int SaveBufferToFAT (char *filepath, int datasize, bool silent); -int LoadSaveBufferFromFAT (char *filepath, bool silent); -int LoadBufferFromFAT (char * buffer, char *filepath, bool silent); +int LoadBufferFromFAT (char *filepath, bool silent); extern char currFATdir[MAXPATHLEN]; -extern FILE * fatfile; #endif diff --git a/source/ngc/filesel.c b/source/ngc/filesel.c index f06cf5b8..8a2cc96f 100644 --- a/source/ngc/filesel.c +++ b/source/ngc/filesel.c @@ -29,22 +29,24 @@ #include "memcardop.h" #include "pad.h" #include "fceuload.h" -#include "gcunzip.h" int offset; int selection; char currentdir[MAXPATHLEN]; -char szpath[MAXPATHLEN]; char romFilename[200]; -int nesGameType; int maxfiles; extern int screenheight; +int havedir = -1; +extern u64 dvddir; +extern int dvddirlength; + +int hasloaded = 0; + // Global file entry table FILEENTRIES filelist[MAXFILES]; -bool inSz = false; -unsigned char savebuffer[SAVEBUFFERSIZE]; +unsigned char savebuffer[SAVEBUFFERSIZE] ATTRIBUTE_ALIGN (32); /**************************************************************************** * Clear the savebuffer @@ -163,28 +165,6 @@ int UpdateDirName(int method) } } -bool MakeROMPath(char filepath[], int method) -{ - char temppath[MAXPATHLEN]; - - // Check filename length - if ((strlen(currentdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN) - { - sprintf(temppath, "%s/%s",currentdir,filelist[selection].filename); - - if(method == METHOD_SMB) - strcpy(filepath, SMBPath(temppath)); - else - strcpy(filepath, temppath); - return true; - } - else - { - filepath[0] = 0; - return false; - } -} - /*************************************************************************** * FileSortCallback * @@ -212,83 +192,6 @@ int FileSortCallback(const void *f1, const void *f2) return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename); } -/**************************************************************************** - * IsValidROM - * - * Checks if the specified file is a valid ROM - * For now we will just check the file extension and file size - * If the file is a zip, we will check the file extension / file size of the - * first file inside - ***************************************************************************/ - -bool IsValidROM(int method) -{ - // file size should be between 10K and 3MB - if(filelist[selection].length < (1024*10) || - filelist[selection].length > (1024*1024*3)) - { - WaitPrompt((char *)"Invalid file size!"); - return false; - } - - if (strlen(filelist[selection].filename) > 4) - { - char * p = strrchr(filelist[selection].filename, '.'); - - if (p != NULL) - { - if(stricmp(p, ".zip") == 0 && !inSz) - { - // we need to check the file extension of the first file in the archive - char * zippedFilename = GetFirstZipFilename (method); - - if(zippedFilename == NULL) // we don't want to run strlen on NULL - p = NULL; - else if(strlen(zippedFilename) > 4) - p = strrchr(zippedFilename, '.'); - else - p = NULL; - } - - if(p != NULL) - { - if ( - stricmp(p, ".nes") == 0 || - stricmp(p, ".fds") == 0 || - stricmp(p, ".nsf") == 0 || - stricmp(p, ".unf") == 0 || - stricmp(p, ".nez") == 0 || - stricmp(p, ".unif") == 0 - ) - { - return true; - } - } - } - } - WaitPrompt((char *)"Unknown file type!"); - return false; -} - -/**************************************************************************** - * IsSz - * - * Checks if the specified file is a 7z - ***************************************************************************/ - -bool IsSz() -{ - if (strlen(filelist[selection].filename) > 4) - { - char * p = strrchr(filelist[selection].filename, '.'); - - if (p != NULL) - if(stricmp(p, ".7z") == 0) - return true; - } - return false; -} - /**************************************************************************** * StripExt * @@ -360,30 +263,10 @@ int FileSelector (int method) { if ( selectit ) selectit = 0; - if (filelist[selection].flags) // This is directory { /* update current directory and set new entry list if directory has changed */ - - int status; - - if(inSz && selection == 0) // inside a 7z, requesting to leave - { - if(method == METHOD_DVD) - { - // go to directory the 7z was in - dvddir = filelist[0].offset; - dvddirlength = filelist[0].length; - } - inSz = false; - status = 1; - SzClose(); - } - else - { - status = UpdateDirName(method); - } - + int status = UpdateDirName(method); if (status == 1) // ok, open directory { switch (method) @@ -413,77 +296,44 @@ int FileSelector (int method) haverom = 1; // quit menu } } - else // this is a file + else // this is a file { - // 7z file - let's open it up to select a file inside - if(IsSz()) + // store the filename (w/o ext) - used for state saving + StripExt(romFilename, filelist[selection].filename); + + ShowAction ((char *)"Loading..."); + + switch (method) { - // we'll store the 7z filepath for extraction later - if(!MakeROMPath(szpath, method)) - { - WaitPrompt((char*) "Maximum filepath length reached!"); - return -1; - } - int szfiles = SzParse(szpath, method); - if(szfiles) - { - maxfiles = szfiles; - inSz = true; - } - else - WaitPrompt((char*) "Error opening archive!"); + case METHOD_SD: + case METHOD_USB: + LoadFATFile (filelist[selection].filename, + filelist[selection].length); + break; + + case METHOD_DVD: + dvddir = filelist[selection].offset; + dvddirlength = filelist[selection].length; + LoadDVDFile (nesromptr); + break; + + case METHOD_SMB: + LoadSMBFile (filelist[selection].filename, + filelist[selection].length); + break; + } + + if (GCMemROM() >= 0) + { + //hasloaded = 1; // indicator for memmap.cpp + //Memory.LoadROM ("BLANK.SMC"); + //Memory.LoadSRAM ("BLANK"); + //haverom = 1; + return 1; } else { - // check that this is a valid ROM - if(!IsValidROM(method)) - return 0; - - // store the filename (w/o ext) - used for state saving - StripExt(romFilename, filelist[selection].filename); - - ShowAction ((char *)"Loading..."); - - int size = 0; - - switch (method) - { - case METHOD_SD: - case METHOD_USB: - if(inSz) - size = LoadFATSzFile(szpath, nesrom); - else - size = LoadFATFile((char *)nesrom, 0); - break; - - case METHOD_DVD: - if(inSz) - size = SzExtractFile(filelist[selection].offset, nesrom); - else - size = LoadDVDFile(nesrom, 0); - break; - - case METHOD_SMB: - if(inSz) - size = LoadSMBSzFile(szpath, nesrom); - else - size = LoadSMBFile((char *)nesrom, 0); - break; - } - inSz = false; - - if (size > 0) - { - if(GCMemROM(method, size) > 0) - return 1; - else - return 0; - } - else - { - WaitPrompt((char*) "Error loading ROM!"); - return 0; - } + WaitPrompt((char*) "Error loading ROM!"); } } redraw = 1; @@ -504,8 +354,7 @@ int FileSelector (int method) else if ( strcmp(filelist[1].filename,"..") == 0 ) { selection = selectit = 1; - } else - { + } else { return 0; } } // End of B diff --git a/source/ngc/filesel.h b/source/ngc/filesel.h index 7205807f..c5925dab 100644 --- a/source/ngc/filesel.h +++ b/source/ngc/filesel.h @@ -12,11 +12,9 @@ #ifndef _NGCFILESEL_ #define _NGCFILESEL_ -#include - -#define SAVEBUFFERSIZE (512 * 1024) +#define SAVEBUFFERSIZE (64 * 1024) #define MAXJOLIET 255 -#define MAXDISPLAY 50 +#define MAXDISPLAY 54 typedef struct { @@ -29,17 +27,8 @@ typedef struct #define MAXFILES 2000 // Restrict to 2000 files per dir extern FILEENTRIES filelist[MAXFILES]; -extern bool isWii; -extern int offset; -extern int selection; -extern char currentdir[MAXPATHLEN]; -extern int maxfiles; -extern unsigned char savebuffer[]; -extern char romFilename[]; -extern int nesGameType; void ClearSaveBuffer (); -bool MakeROMPath(char filepath[], int method); int OpenROM (int method); int autoLoadMethod(); int autoSaveMethod(); diff --git a/source/ngc/gcaudio.c b/source/ngc/gcaudio.c index d17dcb5f..f491f98c 100644 --- a/source/ngc/gcaudio.c +++ b/source/ngc/gcaudio.c @@ -10,7 +10,6 @@ ****************************************************************************/ #include -#include #define SAMPLERATE 48000 unsigned char audiobuffer[2][64 * 1024] ATTRIBUTE_ALIGN(32); @@ -27,47 +26,46 @@ static int whichab = 0; /*** Which Audio Buffer is in use ***/ static int isPlaying; /*** Is Playing ***/ static void AudioSwitchBuffers() { - if ( buffSize[whichab] ) - { - AUDIO_StopDMA(); - AUDIO_InitDMA((u32)audiobuffer[whichab], buffSize[whichab]); - DCFlushRange(audiobuffer[whichab], buffSize[whichab]); - AUDIO_StartDMA(); - isPlaying = 0; - } - - whichab ^= 1; - buffSize[whichab] = 0; + if ( buffSize[whichab] ) { + AUDIO_StopDMA(); + AUDIO_InitDMA((u32)audiobuffer[whichab], buffSize[whichab]); + DCFlushRange(audiobuffer[whichab], buffSize[whichab]); + AUDIO_StartDMA(); + isPlaying = 0; + } + + whichab ^= 1; + buffSize[whichab] = 0; } void InitialiseSound() { - AUDIO_Init(NULL); /*** Start audio subsystem ***/ - AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); - AUDIO_RegisterDMACallback( AudioSwitchBuffers ); - memset(audiobuffer, 0, (64 * 1024 * 2)); - buffSize[0] = buffSize[1] = 0; + AUDIO_Init(NULL); /*** Start audio subsystem ***/ + AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); + AUDIO_RegisterDMACallback( AudioSwitchBuffers ); + + buffSize[0] = buffSize[1] = 0; } void StartAudio() { - AUDIO_StartDMA(); + AUDIO_StartDMA(); } void StopAudio() { - AUDIO_StopDMA(); - buffSize[0] = buffSize[1] = 0; + AUDIO_StopDMA(); + buffSize[0] = buffSize[1] = 0; } static inline unsigned short FLIP16(unsigned short b) { - return((b<<8)|((b>>8)&0xFF)); + return((b<<8)|((b>>8)&0xFF)); } static inline u32 FLIP32(u32 b) { - return( (b<<24) | ((b>>8)&0xFF00) | ((b<<8)&0xFF0000) | ((b>>24)&0xFF) ); + return( (b<<24) | ((b>>8)&0xFF00) | ((b<<8)&0xFF0000) | ((b>>24)&0xFF) ); } /**************************************************************************** @@ -81,37 +79,37 @@ static short MBuffer[ 8 * 96000 / 50 ]; void PlaySound( unsigned int *Buffer, int count ) { - int P; - unsigned short *s = (unsigned short *)&MBuffer[0]; - unsigned int *d = (unsigned int *)&audiobuffer[whichab][buffSize[whichab]]; - unsigned int c; - int ms; - - isWriting = 1; - - for ( P = 0; P < count; P++ ) - { - MBuffer[P] = Buffer[P]; - } - - /*** Now do Mono - Stereo Conversion ***/ - ms = count; - do - { - c = 0xffff & *s++; - *d++ = (c | (c<<16)); - } while(--ms); - - buffSize[whichab] += ( count << 2 ); - /*** This is the kicker for the entire audio loop ***/ - if ( isPlaying == 0 ) - { - if ( buffSize[whichab] > AUDIOBUFFER ) - { - isPlaying = 1; - AudioSwitchBuffers(); - } - } - - isWriting = 0; + int P; + unsigned short *s = (unsigned short *)&MBuffer[0]; + unsigned int *d = (unsigned int *)&audiobuffer[whichab][buffSize[whichab]]; + unsigned int c; + int ms; + + isWriting = 1; + + for ( P = 0; P < count; P++ ) { + MBuffer[P] = Buffer[P]; + } + + /*** Now do Mono - Stereo Conversion ***/ + ms = count; + do + { + c = 0xffff & *s++; + *d++ = (c | (c<<16)); + } while(--ms); + + buffSize[whichab] += ( count << 2 ); + /*** This is the kicker for the entire audio loop ***/ + if ( isPlaying == 0 ) + { + if ( buffSize[whichab] > AUDIOBUFFER ) + { + isPlaying = 1; + AudioSwitchBuffers(); + } + } + + isWriting = 0; + } diff --git a/source/ngc/gcunzip.c b/source/ngc/gcunzip.c index 95f8eb47..1b629ce2 100644 --- a/source/ngc/gcunzip.c +++ b/source/ngc/gcunzip.c @@ -14,21 +14,14 @@ #include #include #include - -#include "../sz/7zCrc.h" -#include "../sz/7zIn.h" -#include "../sz/7zExtract.h" - -#include "fceuconfig.h" #include "dvd.h" -#include "smbop.h" -#include "fileop.h" #include "menudraw.h" #include "gcunzip.h" /* * PKWare Zip Header - adopted into zip standard */ +#define PKZIPID 0x504b0304 #define MAXROM 0x500000 #define ZIPCHUNK 2048 @@ -63,28 +56,32 @@ FLIP16 (u16 b) /**************************************************************************** * IsZipFile * - * Returns 1 when Zip signature is found + * Returns TRUE when PKZIPID is first four characters of buffer ****************************************************************************/ int IsZipFile (char *buffer) { unsigned int *check; + check = (unsigned int *) buffer; - if (check[0] == 0x504b0304) // ZIP file + if (check[0] == PKZIPID) return 1; return 0; } /***************************************************************************** - * UnZipBuffer + * unzip * * It should be noted that there is a limit of 5MB total size for any ROM ******************************************************************************/ +FILE* fatfile; // FAT +u64 discoffset; // DVD +SMBFILE smbfile; // SMB int -UnZipBuffer (unsigned char *outbuffer, int method) +UnZipBuffer (unsigned char *outbuffer, short where) { PKZIPHEADER pkzip; int zipoffset = 0; @@ -97,25 +94,22 @@ UnZipBuffer (unsigned char *outbuffer, int method) int have = 0; char readbuffer[ZIPCHUNK]; char msg[128]; - u64 discoffset = 0; - // Read Zip Header - switch (method) + /*** Read Zip Header ***/ + switch (where) { - case METHOD_SD: - case METHOD_USB: - fseek(fatfile, 0, SEEK_SET); - fread (readbuffer, 1, ZIPCHUNK, fatfile); - break; - - case METHOD_DVD: - discoffset = dvddir; - dvd_read (readbuffer, ZIPCHUNK, discoffset); - break; - - case METHOD_SMB: - SMB_ReadFile(readbuffer, ZIPCHUNK, 0, smbfile); - break; + case 0: // SD Card + fseek(fatfile, 0, SEEK_SET); + fread (readbuffer, 1, ZIPCHUNK, fatfile); + break; + + case 1: // DVD + dvd_read (readbuffer, ZIPCHUNK, discoffset); + break; + + case 2: // From SMB + SMB_ReadFile(readbuffer, ZIPCHUNK, 0, smbfile); + break; } /*** Copy PKZip header to local, used as info ***/ @@ -175,26 +169,25 @@ UnZipBuffer (unsigned char *outbuffer, int method) } while (zs.avail_out == 0); - // Readup the next 2k block + /*** Readup the next 2k block ***/ zipoffset = 0; zipchunk = ZIPCHUNK; - switch (method) + switch (where) { - case METHOD_SD: - case METHOD_USB: - fread (readbuffer, 1, ZIPCHUNK, fatfile); - break; - - case METHOD_DVD: - readoffset += ZIPCHUNK; - dvd_read (readbuffer, ZIPCHUNK, discoffset+readoffset); - break; - - case METHOD_SMB: - readoffset += ZIPCHUNK; - SMB_ReadFile(readbuffer, ZIPCHUNK, readoffset, smbfile); - break; + case 0: // SD Card + fread (readbuffer, 1, ZIPCHUNK, fatfile); + break; + + case 1: // DVD + readoffset += ZIPCHUNK; + dvd_read (readbuffer, ZIPCHUNK, discoffset+readoffset); + break; + + case 2: // From SMB + readoffset += ZIPCHUNK; + SMB_ReadFile(readbuffer, ZIPCHUNK, readoffset, smbfile); + break; } } while (res != Z_STREAM_END); @@ -211,49 +204,36 @@ UnZipBuffer (unsigned char *outbuffer, int method) return 0; } - -/**************************************************************************** - * GetFirstZipFilename - * - * Returns the filename of the first file in the zipped archive - * The idea here is to do the least amount of work required - ***************************************************************************/ - -char * -GetFirstZipFilename (int method) +// Reading from FAT +int +UnZipFATFile (unsigned char *outbuffer, FILE* infile) { - char * firstFilename = NULL; - char tempbuffer[ZIPCHUNK]; - - // read start of ZIP - switch (method) - { - case METHOD_SD: // SD Card - case METHOD_USB: // USB - LoadFATFile (tempbuffer, ZIPCHUNK); - break; - - case METHOD_DVD: // DVD - LoadDVDFile ((unsigned char *)tempbuffer, ZIPCHUNK); - break; - - case METHOD_SMB: // From SMB - LoadSMBFile (tempbuffer, ZIPCHUNK); - break; - } + fatfile = infile; + return UnZipBuffer(outbuffer, 0); +} +// Reading from DVD +int +UnZipDVDFile (unsigned char *outbuffer, u64 inoffset) +{ + discoffset = inoffset; + return UnZipBuffer(outbuffer, 1); +} +// Reading from SMB +int +UnZipSMBFile (unsigned char *outbuffer, SMBFILE infile) +{ + smbfile = infile; + return UnZipBuffer(outbuffer, 2); +} - tempbuffer[28] = 0; // truncate - filename length is 2 bytes long (bytes 26-27) - int namelength = tempbuffer[26]; // filename length starts 26 bytes in +/* + * 7-zip functions are below. Have to be written to work with above. - firstFilename = &tempbuffer[30]; // first filename of a ZIP starts 31 bytes in - firstFilename[namelength] = 0; // truncate at filename length - return firstFilename; -} -/**************************************************************************** - * 7z functions - ***************************************************************************/ +#include "7zCrc.h" +#include "7zIn.h" +#include "7zExtract.h" typedef struct _SzFileInStream { @@ -263,6 +243,9 @@ typedef struct _SzFileInStream u64 pos; // current position of the file pointer } SzFileInStream; + + + // 7zip error list char szerrormsg[][30] = { "7z: Data error", @@ -270,8 +253,7 @@ char szerrormsg[][30] = { "7z: CRC Error", "7z: Not implemented", "7z: Fail", - "7z: Archive error", - "7z: Dictionary too large", + "7z: Archive error" }; SZ_RESULT SzRes; @@ -285,66 +267,159 @@ size_t SzBufferSize; size_t SzOffset; size_t SzOutSizeProcessed; CFileItem *SzF; - char sz_buffer[2048]; -int szMethod = 0; - -/**************************************************************************** - * Is7ZipFile - * - * Returns 1 when 7z signature is found - ****************************************************************************/ -int -Is7ZipFile (char *buffer) -{ - unsigned int *check; - check = (unsigned int *) buffer; - // 7z signature - static Byte Signature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; - - int i; - for(i = 0; i < 6; i++) - if(buffer[i] != Signature[i]) - return 0; +// needed because there are no header files -.- +//#include +#define MAXFILES 1000 +#define MAXJOLIET 256 + +extern FILEENTRIES filelist[MAXFILES]; + +extern int selection; +extern int maxfiles; +extern int offset; + +// the GC's dvd drive only supports offsets and length which are a multiply of 32 bytes +// additionally the max length of a read is 2048 bytes +// this function removes these limitations +// additionally the 7zip SDK does often read data in 1 byte parts from the DVD even when +// it could read 32 bytes. the dvdsf_buffer has been added to avoid having to read the same sector +// over and over again +unsigned char dvdsf_buffer[DVD_SECTOR_SIZE]; +u64 dvdsf_last_offset = 0; +u64 dvdsf_last_length = 0; + +int dvd_buffered_read(void *dst, u32 len, u64 offset) { + int ret = 0; + + // only read data if the data inside dvdsf_buffer cannot be used + if(offset != dvdsf_last_offset || len > dvdsf_last_length) { + char msg[1024]; + sprintf(msg, "buff_read: len=%d, offset=%llX, UseSD=%d", len, offset, UseSDCARD); + //WaitPrompt(msg); + memset(&dvdsf_buffer, '\0', DVD_SECTOR_SIZE); + if (UseSDCARD) { + if (filehandle == NULL) + GetSDInfo(); + + fseek(filehandle, offset, SEEK_SET); + fread(&dvdsf_buffer, len, 1, filehandle); + } else if (!UseWiiSDCARD) + ret = dvd_read(&dvdsf_buffer, len, offset); + dvdsf_last_offset = offset; + dvdsf_last_length = len; + } - return 1; // 7z archive found + memcpy(dst, &dvdsf_buffer, len); + return ret; } -// display an error message -void SzDisplayError(SZ_RESULT res) -{ - WaitPrompt(szerrormsg[(res - 1)]); +int dvd_safe_read(void *dst_v, u32 len, u64 offset) { + unsigned char buffer[DVD_SECTOR_SIZE]; // buffer for one dvd sector + + // if read size and length are a multiply of DVD_(OFFSET,LENGTH)_MULTIPLY and length < DVD_MAX_READ_LENGTH + // we don't need to fix anything + if(len % DVD_LENGTH_MULTIPLY == 0 && offset % DVD_OFFSET_MULTIPLY == 0 && len <= DVD_MAX_READ_LENGTH) { + char msg[1024]; + sprintf(msg, "simple_safe_read: len=%d, offset=%llX, UseSD=%d", len, offset, UseSDCARD); + //WaitPrompt(msg); + int ret = dvd_buffered_read(buffer, len, offset); + memcpy(dst_v, &buffer, len); + return ret; + } else { + char msg[1024]; + sprintf(msg, "complex_safe_read: len=%d, offset=%llX, UseSD=%d", len, offset, UseSDCARD); + //WaitPrompt(msg); + // no errors yet -> ret = 0 + // the return value of dvd_read will be OR'd with ret + // because dvd_read does return 1 on error and 0 on success and + // because 0 | 1 = 1 ret will also contain 1 if at least one error + // occured and 0 otherwise ;) + int ret = 0; // return value of dvd_read + + // we might need to fix all 3 issues + unsigned char *dst = (unsigned char *)dst_v; // gcc will not allow to use var[num] on void* types + u64 bytesToRead; // the number of bytes we still need to read & copy to the output buffer + u64 currentOffset; // the current dvd offset + u64 bufferOffset; // the current buffer offset + u64 i, j, k; // temporary variables which might be used for different stuff + // unsigned char buffer[DVD_SECTOR_SIZE]; // buffer for one dvd sector + + currentOffset = offset; + bytesToRead = len; + bufferOffset = 0; + + // fix first issue (offset is not a multiply of 32) + if(offset % DVD_OFFSET_MULTIPLY) { + // calcualte offset of the prior 32 byte position + i = currentOffset - (currentOffset % DVD_OFFSET_MULTIPLY); + + // calculate the offset from which the data of the dvd buffer will be copied + j = currentOffset % DVD_OFFSET_MULTIPLY; + + // calculate the number of bytes needed to reach the next DVD_OFFSET_MULTIPLY byte mark + k = DVD_OFFSET_MULTIPLY - j; + + // maybe we'll only need to copy a few bytes and we therefore don't even reach the next sector + if(k > len) { + k = len; + } + + // read 32 bytes from the last 32 byte position + ret |= dvd_buffered_read(buffer, DVD_OFFSET_MULTIPLY, i); + + // copy the bytes to the output buffer and update currentOffset, bufferOffset and bytesToRead + memcpy(&dst[bufferOffset], &buffer[j], k); + currentOffset += k; + bufferOffset += k; + bytesToRead -= k; + } + + // fix second issue (more than 2048 bytes are needed) + if(bytesToRead > DVD_MAX_READ_LENGTH) { + // calculate the number of 2048 bytes sector needed to get all data + i = (bytesToRead - (bytesToRead % DVD_MAX_READ_LENGTH)) / DVD_MAX_READ_LENGTH; + + // read data in 2048 byte sector + for(j = 0; j < i; j++) { + ret |= dvd_buffered_read(buffer, DVD_MAX_READ_LENGTH, currentOffset); // read sector + memcpy(&dst[bufferOffset], buffer, DVD_MAX_READ_LENGTH); // copy to output buffer + + // update currentOffset, bufferOffset and bytesToRead + currentOffset += DVD_MAX_READ_LENGTH; + bufferOffset += DVD_MAX_READ_LENGTH; + bytesToRead -= DVD_MAX_READ_LENGTH; + } + } + + // fix third issue (length is not a multiply of 32) + if(bytesToRead) { + ret |= dvd_buffered_read(buffer, DVD_MAX_READ_LENGTH, currentOffset); // read 32 byte from the dvd + memcpy(&dst[bufferOffset], buffer, bytesToRead); // copy bytes to output buffer + } + + //free(tmp); + return ret; + } } -// function used by the 7zip SDK to read data from SD/USB/DVD/SMB -SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxRequiredSize, size_t *processedSize) +// function used by the 7zip SDK to read data from the DVD (fread) +SZ_RESULT SzDvdFileReadImp(void *object, void **buffer, size_t maxRequiredSize, size_t *processedSize) { // the void* object is a SzFileInStream SzFileInStream *s = (SzFileInStream *)object; - // calculate offset + // calculate dvd sector offset u64 offset = (u64)(s->offset + s->pos); - if(maxRequiredSize > 2048) - maxRequiredSize = 2048; + if(maxRequiredSize > 2048) + { + maxRequiredSize = 2048; + } // read data - switch(szMethod) - { - case METHOD_SD: - case METHOD_USB: - fseek(fatfile, offset, SEEK_SET); - fread (sz_buffer, 1, maxRequiredSize, fatfile); - break; - case METHOD_DVD: - dvd_safe_read(sz_buffer, maxRequiredSize, offset); - break; - case METHOD_SMB: - SMB_ReadFile(sz_buffer, maxRequiredSize, offset, smbfile); - break; - } - + dvd_safe_read(sz_buffer, maxRequiredSize, offset); *buffer = sz_buffer; *processedSize = maxRequiredSize; s->pos += *processedSize; @@ -352,8 +427,8 @@ SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxRequiredSize, siz return SZ_OK; } -// function used by the 7zip SDK to change the filepointer -SZ_RESULT SzFileSeekImp(void *object, CFileSize pos) +// function used by the 7zip SDK to change the filepointer (fseek(object, pos, SEEK_SET)) +SZ_RESULT SzDvdFileSeekImp(void *object, CFileSize pos) { // the void* object is a SzFileInStream SzFileInStream *s = (SzFileInStream *)object; @@ -370,158 +445,126 @@ SZ_RESULT SzFileSeekImp(void *object, CFileSize pos) return SZ_OK; } -/**************************************************************************** - * SzParse - * - * Opens a 7z file, and parses it - * Right now doesn't parse 7z, since we'll always use the first file - * But it could parse the entire 7z for full browsing capability - ***************************************************************************/ - -int SzParse(char * filepath, int method) -{ - int nbfiles = 0; - - // save the offset and the length of this file inside the archive stream structure - SzArchiveStream.offset = filelist[selection].offset; - SzArchiveStream.len = filelist[selection].length; - SzArchiveStream.pos = 0; - - // open file - switch (method) - { - case METHOD_SD: - case METHOD_USB: - fatfile = fopen (filepath, "rb"); - if(!fatfile) - return 0; - break; - case METHOD_SMB: - smbfile = OpenSMBFile(filepath); - if(!smbfile) - return 0; - break; - } +SZ_RESULT SzDvdIsArchive(u64 dvd_offset) { + // 7z signautre + static Byte Signature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; + Byte Candidate[6]; - // set szMethod to current chosen load method - szMethod = method; + // read the data from the DVD + int res = dvd_safe_read (&Candidate, 6, dvd_offset); + char msg[1024]; - // set handler functions for reading data from FAT/SMB/DVD - SzArchiveStream.InStream.Read = SzFileReadImp; - SzArchiveStream.InStream.Seek = SzFileSeekImp; + size_t i; + for(i = 0; i < 6; i++) { + if(Candidate[i] != Signature[i]) { + return SZE_FAIL; + } + } - // set default 7Zip SDK handlers for allocation and freeing memory - SzAllocImp.Alloc = SzAlloc; - SzAllocImp.Free = SzFree; - SzAllocTempImp.Alloc = SzAllocTemp; - SzAllocTempImp.Free = SzFreeTemp; + return SZ_OK; +} - // prepare CRC and 7Zip database structures - InitCrcTable(); - SzArDbExInit(&SzDb); +// display an error message +void SzDisplayError(SZ_RESULT res) +{ + WaitPrompt(szerrormsg[(res - 1)]); +} - // open the archive - SzRes = SzArchiveOpen(&SzArchiveStream.InStream, &SzDb, &SzAllocImp, - &SzAllocTempImp); +static u64 rootdir; +static int rootdirlength; - if (SzRes != SZ_OK) - { - SzDisplayError(SzRes); - // free memory used by the 7z SDK - SzClose(); - } - else // archive opened successfully - { - if(SzDb.Database.NumFiles > 0) - { - // Parses the 7z into a full file listing +void SzParse(void) { + // save the offset and the length of this file inside the archive stream structure + SzArchiveStream.offset = filelist[selection].offset; + SzArchiveStream.len = filelist[selection].length; + SzArchiveStream.pos = 0; - // erase all previous entries - memset(&filelist, 0, sizeof(FILEENTRIES) * MAXFILES); + // set handler functions for reading data from DVD and setting the position + SzArchiveStream.InStream.Read = SzDvdFileReadImp; + SzArchiveStream.InStream.Seek = SzDvdFileSeekImp; - // add '..' folder in case the user wants exit the 7z - strncpy(filelist[0].displayname, "..", 2); - filelist[0].flags = 1; - filelist[0].offset = dvddir; - filelist[0].length = dvddirlength; + // set default 7Zip SDK handlers for allocation and freeing memory + SzAllocImp.Alloc = SzAlloc; + SzAllocImp.Free = SzFree; + SzAllocTempImp.Alloc = SzAllocTemp; + SzAllocTempImp.Free = SzFreeTemp; - // get contents and parse them into file list structure - unsigned int SzI, SzJ; - SzJ = 1; - for (SzI = 0; SzI < SzDb.Database.NumFiles; SzI++) - { - SzF = SzDb.Database.Files + SzI; - - // skip directories - if (SzF->IsDirectory) - continue; - - // do not exceed MAXFILES to avoid possible buffer overflows - if (SzJ == (MAXFILES - 1)) - break; - - // parse information about this file to the dvd file list structure - strncpy(filelist[SzJ].filename, SzF->Name, MAXJOLIET); // copy joliet name (useless...) - filelist[SzJ].filename[MAXJOLIET] = 0; // terminate string - strncpy(filelist[SzJ].displayname, SzF->Name, MAXDISPLAY+1); // crop name for display - filelist[SzJ].length = SzF->Size; // filesize - filelist[SzJ].offset = SzI; // the extraction function identifies the file with this number - filelist[SzJ].flags = 0; // only files will be displayed (-> no flags) - SzJ++; - } + // prepare CRC and 7Zip database structures + InitCrcTable(); + SzArDbExInit(&SzDb); - // update maxfiles and select the first entry - offset = selection = 0; - nbfiles = SzJ; - } - else - { - SzArDbExFree(&SzDb, SzAllocImp.Free); - } - } + // open the archive + SzRes = SzArchiveOpen(&SzArchiveStream.InStream, &SzDb, &SzAllocImp, &SzAllocTempImp); - // close file - switch (method) - { - case METHOD_SD: - case METHOD_USB: - fclose(fatfile); - break; - case METHOD_SMB: - SMB_CloseFile (smbfile); - break; - } - return nbfiles; + if(SzRes != SZ_OK) + { + // free memory used by the 7z SDK + SzArDbExFree(&SzDb, SzAllocImp.Free); + return; + } + else + { + // archive opened successfully + + // erase all previous entries + memset(&filelist, 0, sizeof(FILEENTRIES) * MAXFILES); + + // add '../' folder + strncpy(filelist[0].filename, "../", 3); + filelist[0].length = rootdirlength; // store rootdir in case the user wants to go one folder up + filelist[0].offset = rootdir; // -''- rootdir length -''- + filelist[0].flags = 0; + + // get contents and parse them into the dvd file list structure + unsigned int SzI, SzJ; + SzJ = 1; + for(SzI = 0; SzI < SzDb.Database.NumFiles; SzI++) + { + SzF = SzDb.Database.Files + SzI; + + // skip directories + if(SzF->IsDirectory) + { + continue; + } + + // do not exceed MAXFILES to avoid possible buffer overflows + if(SzJ == (MAXFILES - 1)) + { + break; + } + + // parse information about this file to the dvd file list structure + strncpy(filelist[SzJ].filename, SzF->Name, MAXJOLIET); // copy joliet name (useless...) + filelist[SzJ].filename[MAXJOLIET] = 0; // terminate string + filelist[SzJ].length = SzF->Size; // filesize + filelist[SzJ].offset = SzI; // the extraction function identifies the file with this number + filelist[SzJ].flags = 0; // only files will be displayed (-> no flags) + SzJ++; + } + + // update maxfiles and select the first entry + maxfiles = SzJ; + offset = selection = 0; + return; + } } -/**************************************************************************** - * SzClose - * - * Closes a 7z file - ***************************************************************************/ - -void SzClose() +void SzClose(void) { - if(SzDb.Database.NumFiles > 0) - SzArDbExFree(&SzDb, SzAllocImp.Free); + SzArDbExFree(&SzDb, SzAllocImp.Free); } -/**************************************************************************** - * SzExtractFile - * - * Extracts the given file # into the buffer specified - * Must parse the 7z BEFORE running this function - ***************************************************************************/ - -int SzExtractFile(int i, unsigned char *buffer) +bool SzExtractROM(int i, unsigned char *buffer) { + // prepare some variables SzBlockIndex = 0xFFFFFFFF; SzOffset = 0; // Unzip the file - ShowAction("Unzipping file. Please wait..."); - + //ShowAction("Un7zipping file. Please wait..."); + WaitPrompt("Un7zipping file. Please wait..."); SzRes = SzExtract2( &SzArchiveStream.InStream, &SzDb, @@ -534,18 +577,18 @@ int SzExtractFile(int i, unsigned char *buffer) &SzAllocImp, &SzAllocTempImp); - // close 7Zip archive and free memory - SzClose(); - // check for errors if(SzRes != SZ_OK) { - // display error message - SzDisplayError(SzRes); - return 0; + // display error message + WaitPrompt(szerrormsg[(SzRes - 1)]); + return false; } else { - return SzOutSizeProcessed; + // close 7Zip archive and free memory + SzArDbExFree(&SzDb, SzAllocImp.Free); + return true; } } +*/ diff --git a/source/ngc/gcunzip.h b/source/ngc/gcunzip.h index 89b8f5f7..907f59d4 100644 --- a/source/ngc/gcunzip.h +++ b/source/ngc/gcunzip.h @@ -15,11 +15,10 @@ #include extern int IsZipFile (char *buffer); -char * GetFirstZipFilename(int method); -int UnZipBuffer (unsigned char *outbuffer, int method); -int SzParse(char * filepath, int method); -int SzExtractFile(int i, unsigned char *buffer); -void SzClose(); + +int UnZipFATFile (unsigned char *outbuffer, FILE* infile); // Reading from FAT +int UnZipDVDFile (unsigned char *outbuffer, u64 inoffset); // Reading from DVD +int UnZipSMBFile (unsigned char *outbuffer, SMBFILE infile); // Reading from SMB /* * Zip file header definition diff --git a/source/ngc/gcvideo.c b/source/ngc/gcvideo.c index dcc75113..1a7eda72 100644 --- a/source/ngc/gcvideo.c +++ b/source/ngc/gcvideo.c @@ -16,14 +16,12 @@ #include #include -#include "driver.h" - #include "gcvideo.h" #include "images/nesback.h" extern unsigned int SMBTimer; -int FDSTimer = 0; -int FDSSwitchRequested; + +//#define FORCE_PAL50 1 #define TEX_WIDTH 256 #define TEX_HEIGHT 512 @@ -62,29 +60,6 @@ static void copy_to_xfb() { copynow = GX_FALSE; } SMBTimer++; - - // FDS switch disk requested - need to eject, select, and insert - // but not all at once! - if(FDSSwitchRequested) - { - switch(FDSSwitchRequested) - { - case 1: - FCEUI_FDSEject(); // eject disk - FDSSwitchRequested++; - break; - case 2: - if(FDSTimer > 60) - { - FCEUI_FDSSelect(); // select other side - FCEUI_FDSInsert(0); // insert disk - FDSSwitchRequested = 0; - FDSTimer = 0; - } - break; - } - FDSTimer++; - } } /**************************************************************************** @@ -241,15 +216,6 @@ void initDisplay() { VIDEO_Init(); vmode = VIDEO_GetPreferredMode(NULL); - -#ifdef HW_DOL -/* we have component cables, but the preferred mode is interlaced - * why don't we switch into progressive? - * on the Wii, the user can do this themselves on their Wii Settings */ - if(VIDEO_HaveComponentCable() && vmode == &TVNtsc480IntDf) - vmode = &TVNtsc480Prog; -#endif - VIDEO_Configure(vmode); screenheight = vmode->xfbHeight; diff --git a/source/ngc/gcvideo.h b/source/ngc/gcvideo.h index 1dcc0656..aafd71b1 100644 --- a/source/ngc/gcvideo.h +++ b/source/ngc/gcvideo.h @@ -26,6 +26,5 @@ struct st_palettes { }; extern struct st_palettes palettes[]; -extern int FDSSwitchRequested; #endif diff --git a/source/ngc/memcardop.c b/source/ngc/memcardop.c index 4f623cc9..5301e567 100644 --- a/source/ngc/memcardop.c +++ b/source/ngc/memcardop.c @@ -22,10 +22,10 @@ #include "menu.h" #include "memcardop.h" #include "fileop.h" -#include "filesel.h" #define VERIFBUFFERSIZE 65536 static u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32); +extern unsigned char savebuffer[]; unsigned char verifbuffer[VERIFBUFFERSIZE] ATTRIBUTE_ALIGN (32); card_dir CardDir; card_file CardFile; diff --git a/source/ngc/menu.c b/source/ngc/menu.c index 4db8a43b..2710f192 100644 --- a/source/ngc/menu.c +++ b/source/ngc/menu.c @@ -76,6 +76,9 @@ LoadManager () if ( loadROM == 1 ) // if ROM was loaded { + if(!GCMemROM()) // ROM was not valid + return 0; + // load the RAM if (GCSettings.AutoLoad == 1) LoadRAM(GCSettings.SaveMethod, SILENT); @@ -84,6 +87,7 @@ LoadManager () ResetNES(); } + return loadROM; } @@ -223,6 +227,12 @@ PreferencesMenu () GCSettings.SaveMethod++; #endif + // check if DVD access in Wii mode is disabled + #ifndef WII_DVD + if(GCSettings.LoadMethod == METHOD_DVD) + GCSettings.LoadMethod++; + #endif + // saving to DVD is impossible if(GCSettings.SaveMethod == METHOD_DVD) GCSettings.SaveMethod++; @@ -241,10 +251,6 @@ PreferencesMenu () GCSettings.SaveMethod++; if(GCSettings.SaveMethod == METHOD_MC_SLOTB) GCSettings.SaveMethod++; - prefmenu[6][0] = '\0'; - #else - sprintf (prefmenu[6], "Verify MC Saves %s", - GCSettings.VerifySaves == true ? " ON" : "OFF"); #endif // correct load/save methods out of bounds @@ -283,6 +289,9 @@ PreferencesMenu () else if (GCSettings.AutoSave == 2) sprintf (prefmenu[5],"Auto Save STATE"); else if (GCSettings.AutoSave == 3) sprintf (prefmenu[5],"Auto Save BOTH"); + sprintf (prefmenu[6], "Verify MC Saves %s", + GCSettings.VerifySaves == true ? " ON" : "OFF"); + ret = RunMenu (prefmenu, prefmenuCount, (char*)"Preferences", 16, -1); switch (ret) @@ -355,16 +364,6 @@ GameMenu () while (quit == 0) { - if(nesGameType == 4) // FDS game - { - // disable RAM saving/loading - gamemenu[3][0] = '\0'; - gamemenu[4][0] = '\0'; - - // disable ROM Information - gamemenu[2][0] = '\0'; - } - // disable RAM/STATE saving/loading if AUTO is on if (GCSettings.AutoLoad == 1) // Auto Load RAM gamemenu[3][0] = '\0'; @@ -534,17 +533,16 @@ GetButtonMap(u16 ctrlr_type, char* btn_name) return pressed; } // end getButtonMap() -int cfg_btns_count = 10; +int cfg_btns_count = 9; char cfg_btns_menu[][50] = { - "B - ", - "A - ", - "SELECT - ", - "START - ", - "UP - ", - "DOWN - ", - "LEFT - ", - "RIGHT - ", - "SPECIAL - ", + "B - ", + "A - ", + "SELECT - ", + "START - ", + "UP - ", + "DOWN - ", + "LEFT - ", + "RIGHT - ", "Return to previous" }; @@ -591,7 +589,7 @@ ConfigureButtons (u16 ctrlr_type) while (quit == 0) { /*** Update Menu with Current ButtonMap ***/ - for (i=0; i 0) - { - J |= nespadmap[i]; - } - else - { - if(nesGameType == 4) // FDS - { - /* the commands shouldn't be issued in parallel so - * we'll delay them so the virtual FDS has a chance - * to process them - */ - FDSSwitchRequested = 1; - } - else - FCEUI_VSUniCoin(); // insert coin for VS Games - } - } - } + J |= nespadmap[i]; } + // zapper enabled if(GCSettings.zapper) { @@ -414,8 +383,6 @@ unsigned char DecodeJoy( unsigned short pad ) if ( (jp & PAD_BUTTON_A) // gamecube controller #ifdef HW_RVL || (wp & WPAD_BUTTON_A) // wiimote - || (wp & WPAD_BUTTON_B) - || (wp & WPAD_CLASSIC_BUTTON_A) // classic controller #endif ) { @@ -423,16 +390,6 @@ unsigned char DecodeJoy( unsigned short pad ) myzappers[z][2] |= 2; } - // VS zapper games - if ( (jp & PAD_BUTTON_B) // gamecube controller - #ifdef HW_RVL - || (wp & WPAD_BUTTON_1) // wiimote - #endif - ) - { - FCEUI_VSUniCoin(); // insert coin for VS zapper games - } - // cursor position UpdateCursorPosition(0); // update cursor for wiimote 1 myzappers[z][0] = pos_x; @@ -447,8 +404,7 @@ unsigned char DecodeJoy( unsigned short pad ) void GetJoy() { - JSReturn = 0; // reset buttons pressed - unsigned char pad[4]; + unsigned char pad[4]; short i; s8 gc_px = PAD_SubStickX (0); @@ -460,7 +416,7 @@ void GetJoy() #endif // request to go back to menu - if ((gc_px < -70) || ((jp & PAD_BUTTON_START) && (jp & PAD_BUTTON_A)) + if ((gc_px < -70) || (jp & PAD_BUTTON_START) #ifdef HW_RVL || (wm_pb & WPAD_BUTTON_HOME) || (wm_pb & WPAD_CLASSIC_BUTTON_HOME) @@ -470,19 +426,8 @@ void GetJoy() { StopAudio(); - if (GCSettings.AutoSave == 1) - { - SaveRAM(GCSettings.SaveMethod, SILENT); - } - else if (GCSettings.AutoSave == 2) - { - SaveState(GCSettings.SaveMethod, SILENT); - } - else if(GCSettings.AutoSave == 3) - { - SaveRAM(GCSettings.SaveMethod, SILENT); + if (GCSettings.AutoLoad == 1) SaveState(GCSettings.SaveMethod, SILENT); - } MainMenu(4); } diff --git a/source/ngc/pad.h b/source/ngc/pad.h index 4573b4f1..01e4282a 100644 --- a/source/ngc/pad.h +++ b/source/ngc/pad.h @@ -16,7 +16,7 @@ #define PI 3.14159265f #define PADCAL 50 -#define MAXJP 9 +#define MAXJP 8 extern unsigned int gcpadmap[]; extern unsigned int wmpadmap[]; @@ -27,8 +27,8 @@ s8 WPAD_StickX(u8 chan,u8 right); s8 WPAD_StickY(u8 chan, u8 right); void InitialisePads(); void GetJoy(); -void ToggleFourScore(int set, bool loaded); -void ToggleZapper(int set, bool loaded); +void ToggleFourScore(int set); +void ToggleZapper(int set); void DrawCursor(); #endif diff --git a/source/ngc/preferences.c b/source/ngc/preferences.c index 43d70287..e990e7da 100644 --- a/source/ngc/preferences.c +++ b/source/ngc/preferences.c @@ -171,7 +171,6 @@ preparePrefsData (int method) createXMLSetting("FSDisable", "Four Score", toStr(GCSettings.FSDisable)); createXMLSetting("zapper", "Zapper", toStr(GCSettings.zapper)); - createXMLSetting("crosshair", "Zapper Crosshair", toStr(GCSettings.crosshair)); createXMLController(gcpadmap, "gcpadmap", "GameCube Pad"); createXMLController(wmpadmap, "wmpadmap", "Wiimote"); createXMLController(ccpadmap, "ccpadmap", "Classic Controller"); @@ -248,17 +247,6 @@ decodePrefsData (int method) else // version # not found, must be invalid return false; - // this code assumes version in format X.X.X - // XX.X.X, X.XX.X, or X.X.XX will NOT work - char verMajor = version[13]; - char verMinor = version[15]; - char verPoint = version[17]; - - if(verMajor == '2' && verPoint < '3') // less than version 2.0.3 - return false; // reset settings - else if(verMajor > '2' || verMinor > '0' || verPoint > '4') // some future version - return false; // reset settings - // File Settings loadXMLSettingInt(&GCSettings.AutoLoad, "AutoLoad"); @@ -285,7 +273,6 @@ decodePrefsData (int method) loadXMLSettingInt(&GCSettings.slimit, "slimit"); loadXMLSettingInt(&GCSettings.screenscaler, "screenscaler"); loadXMLSettingInt(&GCSettings.zapper, "zapper"); - loadXMLSettingInt(&GCSettings.crosshair, "crosshair"); // Controller Settings loadXMLController(gcpadmap, "gcpadmap"); @@ -304,9 +291,7 @@ decodePrefsData (int method) bool SavePrefs (int method, bool silent) { - // there's no point in saving SMB settings TO SMB, because then we'll have no way to load them the next time! - // so instead we'll save using whatever other method is available (eg: SD) - if(method == METHOD_AUTO || method == METHOD_SMB) + if(method == METHOD_AUTO) method = autoSaveMethod(); char filepath[1024]; @@ -365,7 +350,7 @@ LoadPrefsFromMethod (int method) if(ChangeFATInterface(method, NOTSILENT)) { sprintf (filepath, "%s/%s/%s", ROOTFATDIR, GCSettings.SaveFolder, PREFS_FILE_NAME); - offset = LoadSaveBufferFromFAT (filepath, SILENT); + offset = LoadBufferFromFAT (filepath, SILENT); } } else if(method == METHOD_SMB) diff --git a/source/ngc/rom/ROM.NES b/source/ngc/rom/ROM.NES new file mode 100644 index 0000000000000000000000000000000000000000..ae87c0d3f1b325da0a38bc3d34466fdbd8a7fc10 GIT binary patch literal 1048592 zcmeI$L2F#s6#(Ejrg7S0idV*jQUt;aAxgdULQsLp!c|f)`UkowhC+UT7sjLvDxD6J zR)x})(V)d+P(}a2l#n5HY^0xHFb*~D^ewV6sVeu3>{sr&rrUtaHyZ2t=-hYbp6}fE z{N$g1_=^uNG?$zI^?LQ@RpPFKauim&Culr4Zyf^>B#@#1p zO@F+9>FUPC`Mst;{&3@yM`xEVHU05)c6xD{?~fb5oSn`i?vH2lOINR7zuxr6dy!n` zi{t%^m+mg(^W%+A=JT`pyy=gp^ZD}K^v8`mv)Sy3FSO4QzuRgo~dJAv7K5V|((EagE=s88_ZHyFI?<7Wp42hWPQn;f-eKH^CkznC6Po|fa=obTGBG=DdlEU!y#9iB_^(~^FoUhj39<|Sl^KWl$ZQU;750|eZzJ2rdtui0+%`%R&Z{94& z-^%$oJIx=X^Z2bQU(Xl$tz!O(cz)>eD=ay~@|~MLzX^eKAh`U3;F^w}^UjzFPlU zH!Axd^{Q)W2HBarSCef67PwY5o|U$FEoUdcMe4^{?mpo~QLi{Z&3z zQ1*MRTPy32t84uyMLw?nYuAc6uI9BeAMt7#$K7LfwH)8(d|Z8L{B`y=Yl_y1wnmif54^ZkF^P161!<$Tni z=8yXG_;Ho5=Zkz*|1{V4JgsjL_2hiD{!y3i|FOH${*2w9_J8c=w7()w`#-Lpw4YAC;a{V%G|`Fg&{r~X&>zo;hlcMS~UykEz9-s=BRaX*au4-Ser>TSz> z#FH{!_J2~2kN%hWW&cwg{ZHegzbRkO7x`&1e{_F(Sj16(T3^&(<*W5a|J&mH`GT#mN^7G$#Z6y-|7nA5W*LKcC0%Ke_)$$@e&Z|H=J7%KdC}{3WKWV>At9<5Qp4|Ux{qg%x?tk_Czg<255943((tDVn@8j&; z&r#0D*;W6m=l^k)ujh+=?tk_CKdPSp$JO)ys9Jx-W&dOL@m^71RKLAl#8J(t%tt&d z<7NHBa(vWZ=9l%Sc=$ArkNQ%+o-gv_V*aRpyi>$cOkL@Z{_E zJhL3p{%F5>@ZH__SAKW$&EKDV=j7`f&j%;}h)>&$;SW!~Y2!0i+Ggjym3W^|y+7E! zviUIn{C047W%Flu-hBV_mCe`T@7D(J4Yn_Q@B8t&&4Z@h+-|;VPEMD94le8rR@$GQ zFKzeY${*t+etkK8`yzfE?}I@M{OHka^DPoTAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0^g#*A7;&L z@Yiqg1AP<$0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 z2oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N z0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBly zK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF z5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk z1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs z0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZ zfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&U zAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C7 V2oNAZfB*pk1PBlyK;ZvU;6Jjf3Pu0` literal 0 HcmV?d00001 diff --git a/source/ngc/smbop.c b/source/ngc/smbop.c index 68dd79fb..a2e2b8e6 100644 --- a/source/ngc/smbop.c +++ b/source/ngc/smbop.c @@ -31,12 +31,17 @@ bool networkShareInit = false; unsigned int SMBTimer = 0; #define SMBTIMEOUT ( 3600 ) // Some implementations timeout in 10 minutes -// SMB connection/file handles - the only ones we should ever use! SMBCONN smbconn; -SMBFILE smbfile; - #define ZIPCHUNK 16384 +extern unsigned char savebuffer[]; +extern char output[16384]; +extern int offset; +extern int selection; +extern char currentdir[MAXPATHLEN]; +extern FILEENTRIES filelist[MAXFILES]; + + /**************************************************************************** * InitializeNetwork * Initializes the Wii/GameCube network interface @@ -82,19 +87,6 @@ ConnectShare (bool silent) return false; #endif - ShowAction ((char*) "Connecting..."); - - // check that all parameter have been set - if(strlen(GCSettings.smbuser) == 0 || - strlen(GCSettings.smbpwd) == 0 || - strlen(GCSettings.smbshare) == 0 || - strlen(GCSettings.smbip) == 0) - { - if(!silent) - WaitPrompt((char*) "Invalid network settings. Check FCEUGX.xml."); - return false; - } - if(!networkInit) networkInit = InitializeNetwork(silent); @@ -204,7 +196,6 @@ ParseSMBdirectory () filelist[filecount].displayname[MAXDISPLAY] = 0; strcpy (filelist[filecount].filename, smbdir.name); - filelist[filecount].offset = 0; filecount++; } } while (SMB_FindNext (&smbdir, smbconn) == SMB_SUCCESS); @@ -218,58 +209,24 @@ ParseSMBdirectory () return filecount; } -/**************************************************************************** - * Open SMB file - ***************************************************************************/ - -SMBFILE OpenSMBFile(char * filepath) -{ - return SMB_OpenFile (SMBPath(filepath), SMB_OPEN_READING, SMB_OF_OPEN, smbconn); -} - /**************************************************************************** * Load SMB file - * rom - pointer to memory where ROM will be stored - * length - # bytes to read (0 for all) - ***************************************************************************/ + ****************************************************************************/ int -LoadSMBFile (char * rom, int length) +LoadSMBFile (char *filename, int length) { char filepath[MAXPATHLEN]; /* Check filename length */ - if (!MakeROMPath(filepath, METHOD_SMB)) + if ((strlen(currentdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN) + sprintf(filepath, "%s/%s",currentdir,filelist[selection].filename); + else { WaitPrompt((char*) "Maximum filepath length reached!"); return -1; } - return LoadBufferFromSMB(rom, filepath, length, NOTSILENT); -} - -/**************************************************************************** - * LoadSMBSzFile - * Loads the selected file # from the specified 7z into rbuffer - * Returns file size - ***************************************************************************/ -int -LoadSMBSzFile(char * filepath, unsigned char * rbuffer) -{ - if(!ConnectShare (NOTSILENT)) - return 0; - smbfile = OpenSMBFile(filepath); - - if (smbfile) - { - u32 size = SzExtractFile(filelist[selection].offset, rbuffer); - SMB_CloseFile (smbfile); - return size; - } - else - { - WaitPrompt((char*) "Error opening file"); - return 0; - } + return LoadBufferFromSMB((char *)nesromptr, SMBPath(filepath), NOTSILENT); } /**************************************************************************** @@ -281,6 +238,7 @@ SaveBufferToSMB (char *filepath, int datasize, bool silent) if(!ConnectShare (NOTSILENT)) return 0; + SMBFILE smbfile; int dsize = datasize; int wrote = 0; int boffset = 0; @@ -318,25 +276,29 @@ SaveBufferToSMB (char *filepath, int datasize, bool silent) /**************************************************************************** * Load up a buffer from SMB file - ***************************************************************************/ + ****************************************************************************/ // no buffer is specified - so use savebuffer int LoadSaveBufferFromSMB (char *filepath, bool silent) { - return LoadBufferFromSMB((char *)savebuffer, filepath, 0, silent); + ClearSaveBuffer (); + return LoadBufferFromSMB((char *)savebuffer, filepath, silent); } int -LoadBufferFromSMB (char * sbuffer, char *filepath, int length, bool silent) +LoadBufferFromSMB (char * sbuffer, char *filepath, bool silent) { if(!ConnectShare (NOTSILENT)) return 0; - smbfile = OpenSMBFile(filepath); + SMBFILE smbfile; int ret; int boffset = 0; + smbfile = + SMB_OpenFile (SMBPath(filepath), SMB_OPEN_READING, SMB_OF_OPEN, smbconn); + if (!smbfile) { if(!silent) @@ -348,24 +310,17 @@ LoadBufferFromSMB (char * sbuffer, char *filepath, int length, bool silent) return 0; } - if(length > 0) // do a partial read (eg: to check file header) + ret = SMB_ReadFile (sbuffer, 1024, boffset, smbfile); + + if (IsZipFile (sbuffer)) { - boffset = SMB_ReadFile (sbuffer, length, 0, smbfile); + boffset = UnZipSMBFile ((unsigned char *)sbuffer, smbfile); // unzip from SMB } - else // load whole file + else { - ret = SMB_ReadFile (sbuffer, 1024, boffset, smbfile); - - if (IsZipFile (sbuffer)) - { - boffset = UnZipBuffer ((unsigned char *)sbuffer, METHOD_SMB); // unzip from SMB - } - else - { - // Just load the file up - while ((ret = SMB_ReadFile (sbuffer + boffset, 1024, boffset, smbfile)) > 0) - boffset += ret; - } + // Just load the file up + while ((ret = SMB_ReadFile (sbuffer + boffset, 1024, boffset, smbfile)) > 0) + boffset += ret; } SMB_CloseFile (smbfile); diff --git a/source/ngc/smbop.h b/source/ngc/smbop.h index e356707b..033ca1c6 100644 --- a/source/ngc/smbop.h +++ b/source/ngc/smbop.h @@ -10,22 +10,17 @@ ****************************************************************************/ #ifndef _SMBOP_H_ -#define _SMBOP_H_ -#include +#define _SMBOP_H_ bool InitializeNetwork(bool silent); bool ConnectShare (bool silent); char * SMBPath(char * path); int UpdateSMBdirname(); int ParseSMBdirectory (); -SMBFILE OpenSMBFile(char * filepath); -int LoadSMBFile (char * fbuffer, int length); -int LoadSMBSzFile(char * filepath, unsigned char * rbuffer); +int LoadSMBFile (char *filename, int length); int LoadSaveBufferFromSMB (char *filepath, bool silent); -int LoadBufferFromSMB (char * sbuffer, char *filepath, int length, bool silent); +int LoadBufferFromSMB (char * sbuffer, char *filepath, bool silent); int SaveBufferToSMB (char *filepath, int datasize, bool silent); -extern SMBFILE smbfile; - #endif diff --git a/source/sz/7zDecode.c b/source/sz/7zDecode.c index 12198eea..7b583196 100644 --- a/source/sz/7zDecode.c +++ b/source/sz/7zDecode.c @@ -47,7 +47,7 @@ SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder, #else const Byte *inBuffer, #endif - Byte *outBuffer, size_t outSize, + Byte *outBuffer, size_t outSize, size_t *outSizeProcessed, ISzAlloc *allocMain) { UInt32 si; @@ -109,7 +109,7 @@ SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder, lzmaCallback.InCallback.Read = LzmaReadImp; #endif - if (LzmaDecodeProperties(&state.Properties, coder->Properties.Items, + if (LzmaDecodeProperties(&state.Properties, coder->Properties.Items, coder->Properties.Capacity) != LZMA_RESULT_OK) return SZE_FAIL; @@ -126,7 +126,7 @@ SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder, if (state.Dictionary == 0) { allocMain->Free(state.Probs); - return SZE_OUTOFMEMORYDIC; + return SZE_OUTOFMEMORY; } } LzmaDecoderInit(&state); @@ -157,7 +157,7 @@ SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder, // like SzDecode but uses less memory SZ_RESULT SzDecode2(const CFileSize *packSizes, const CFolder *folder, ISzInStream *inStream, - Byte *outBuffer, size_t outSize, + Byte *outBuffer, size_t outSize, size_t *outSizeProcessed, ISzAlloc *allocMain, size_t *fileOffset, size_t *fileSize) { @@ -220,7 +220,7 @@ SZ_RESULT SzDecode2(const CFileSize *packSizes, const CFolder *folder, lzmaCallback.InCallback.Read = LzmaReadImp; #endif - if (LzmaDecodeProperties(&state.Properties, coder->Properties.Items, + if (LzmaDecodeProperties(&state.Properties, coder->Properties.Items, coder->Properties.Capacity) != LZMA_RESULT_OK) return SZE_FAIL; @@ -240,122 +240,116 @@ SZ_RESULT SzDecode2(const CFileSize *packSizes, const CFolder *folder, } } LzmaDecoderInit(&state); - + // allocate memory for the temporary buffer Byte *tmpBuffer = (Byte *)allocMain->Alloc(_LZMA_TEMP_BUFFER_SIZE); - + // variables containing the number of the first and the last bytes of the buffer - size_t bufferStart, bufferEnd; - bufferStart = bufferEnd = 0; - - // integers contains the offset, the size and the already copied data which will be - // copied from the tmpBuffer to outBuffer - size_t copyOffset, copySize, copyDone; - copyOffset = copySize = copyDone = 0; - - UInt32 i = 0; - int bytesToCopy = 0; - - // decompress data in _LZMA_TEMP_BUFFER_SIZE byte steps and copy the wanted file to outBuffer - do - { - if((*fileSize - copyDone) >= _LZMA_TEMP_BUFFER_SIZE) - bytesToCopy = _LZMA_TEMP_BUFFER_SIZE; - else - bytesToCopy = (*fileSize - copyDone); - - // decompress next bytes - result = LzmaDecode(&state, - #ifdef _LZMA_IN_CB - &lzmaCallback.InCallback, - #else - //inBuffer, (SizeT)inSize, &inProcessed, //TODO! - #endif - tmpBuffer, bytesToCopy, &outSizeProcessedLoc - ); - - // check result - if(result == LZMA_RESULT_DATA_ERROR) - { - return SZE_DATA_ERROR; - } - if(result != LZMA_RESULT_OK) - { - return SZE_FAIL; - } - - // normally this should never happen - if(outSizeProcessedLoc > _LZMA_TEMP_BUFFER_SIZE) - { - return SZE_FAIL; - } - - // update bufferStart and bufferEnd - bufferStart = _LZMA_TEMP_BUFFER_SIZE * i; - bufferEnd = bufferStart + outSizeProcessedLoc; - i++; - - // calculate copy offset and size - if(*fileOffset > bufferEnd) - { - // we haven't reached the start of the file yet - continue; - } - - // calculate offset - if(*fileOffset < bufferStart) - { - // the file has already started before this decompression step - copyOffset = 0; - } - else - { - // the file starts somewhere inside this buffer - copyDone = 0; - copyOffset = _LZMA_TEMP_BUFFER_SIZE - (bufferEnd - *fileOffset); - } - - // calculate size - if((*fileOffset + *fileSize) > bufferEnd) - { - // we'll need the whole buffer after copyOffset - copySize = _LZMA_TEMP_BUFFER_SIZE - copyOffset; - } - else - { - // we'll stop somewhere inside the buffer - copySize = (*fileOffset + *fileSize) - (bufferStart + copyOffset); - } - - // copy bytes to the real output buffer - if(copySize == 0) - { - continue; - } - // printf("memcpy(outBuffer + %d, tmpBuffer + %d, %d)\n", copyDone, copyOffset, copySize); - memcpy(outBuffer + copyDone, tmpBuffer + copyOffset, copySize); - copyDone += copySize; - } - while((*fileOffset + *fileSize) > bufferEnd); - - /* result = LzmaDecode(&state, - #ifdef _LZMA_IN_CB - &lzmaCallback.InCallback, - #else - inBuffer, (SizeT)inSize, &inProcessed, - #endif - outBuffer, (SizeT)outSize, &outSizeProcessedLoc);*/ - //*outSizeProcessed = (size_t)outSizeProcessedLoc; - *outSizeProcessed = copyDone; - allocMain->Free(tmpBuffer); // free the temporary buffer again - allocMain->Free(state.Probs); - allocMain->Free(state.Dictionary); - /* if (result == LZMA_RESULT_DATA_ERROR) - return SZE_DATA_ERROR; - if (result != LZMA_RESULT_OK) - return SZE_FAIL;*/ - return SZ_OK; - } - return SZE_NOTIMPL; - } - #endif + size_t bufferStart, bufferEnd; + bufferStart = bufferEnd = 0; + + // integers contains the offset, the size and the already copied data which will be + // copied from the tmpBuffer to outBuffer + size_t copyOffset, copySize, copyDone; + copyOffset = copySize = copyDone = 0; + + UInt32 i = 0; + + // decompress data in _LZMA_TEMP_BUFFER_SIZE byte steps and copy the wanted file to outBuffer + do + { + // decompress next bytes + result = LzmaDecode(&state, + #ifdef _LZMA_IN_CB + &lzmaCallback.InCallback, + #else + //inBuffer, (SizeT)inSize, &inProcessed, //TODO! + #endif + tmpBuffer, _LZMA_TEMP_BUFFER_SIZE, &outSizeProcessedLoc + ); + + // check result + if(result == LZMA_RESULT_DATA_ERROR) + { + return SZE_DATA_ERROR; + } + if(result != LZMA_RESULT_OK) + { + return SZE_FAIL; + } + + // normally this should never happen + if(outSizeProcessedLoc > _LZMA_TEMP_BUFFER_SIZE) + { + return SZE_FAIL; + } + + // update bufferStart and bufferEnd + bufferStart = _LZMA_TEMP_BUFFER_SIZE * i; + bufferEnd = bufferStart + outSizeProcessedLoc; + i++; + + // calculate copy offset and size + if(*fileOffset > bufferEnd) + { + // we haven't reached the start of the file yet + continue; + } + + // calculate offset + if(*fileOffset < bufferStart) + { + // the file has already started before this decompression step + copyOffset = 0; + } + else + { + // the file starts somewhere inside this buffer + copyDone = 0; + copyOffset = _LZMA_TEMP_BUFFER_SIZE - (bufferEnd - *fileOffset); + } + + // calculate size + if((*fileOffset + *fileSize) > bufferEnd) + { + // we'll need the whole buffer after copyOffset + copySize = _LZMA_TEMP_BUFFER_SIZE - copyOffset; + } + else + { + // we'll stop somewhere inside the buffer + copySize = (*fileOffset + *fileSize) - (bufferStart + copyOffset); + } + + // copy bytes to the real output buffer + if(copySize == 0) + { + continue; + } + // printf("memcpy(outBuffer + %d, tmpBuffer + %d, %d)\n", copyDone, copyOffset, copySize); + memcpy(outBuffer + copyDone, tmpBuffer + copyOffset, copySize); + copyDone += copySize; + } + while((*fileOffset + *fileSize) > bufferEnd); + +/* result = LzmaDecode(&state, + #ifdef _LZMA_IN_CB + &lzmaCallback.InCallback, + #else + inBuffer, (SizeT)inSize, &inProcessed, + #endif + outBuffer, (SizeT)outSize, &outSizeProcessedLoc);*/ + //*outSizeProcessed = (size_t)outSizeProcessedLoc; + *outSizeProcessed = copyDone; + allocMain->Free(tmpBuffer); // free the temporary buffer again + allocMain->Free(state.Probs); + allocMain->Free(state.Dictionary); +/* if (result == LZMA_RESULT_DATA_ERROR) + return SZE_DATA_ERROR; + if (result != LZMA_RESULT_OK) + return SZE_FAIL;*/ + return SZ_OK; + } + return SZE_NOTIMPL; +} +#endif diff --git a/source/sz/7zDecode.h b/source/sz/7zDecode.h index 9f15ba16..9506e59d 100644 --- a/source/sz/7zDecode.h +++ b/source/sz/7zDecode.h @@ -19,17 +19,17 @@ SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder, #else const Byte *inBuffer, #endif - Byte *outBuffer, size_t outSize, + Byte *outBuffer, size_t outSize, size_t *outSizeProcessed, ISzAlloc *allocMain); #ifdef _LZMA_OUT_READ #ifndef _LZMA_TEMP_BUFFER_SIZE -#define _LZMA_TEMP_BUFFER_SIZE (2048) // size of the temporary buffer in bytes +#define _LZMA_TEMP_BUFFER_SIZE (1 << 15) // size of the temporary buffer in bytes #endif SZ_RESULT SzDecode2(const CFileSize *packSizes, const CFolder *folder, ISzInStream *stream, - Byte *outBuffer, size_t outSize, + Byte *outBuffer, size_t outSize, size_t *outSizeProcessed, ISzAlloc *allocMain, size_t *fileOffset, size_t *fileSize); #endif // #ifdef _LZMA_OUT_READ diff --git a/source/sz/7zExtract.c b/source/sz/7zExtract.c index 13ba62ce..9a82ea42 100644 --- a/source/sz/7zExtract.c +++ b/source/sz/7zExtract.c @@ -5,14 +5,14 @@ #include "7zCrc.h" SZ_RESULT SzExtract( - ISzInStream *inStream, + ISzInStream *inStream, CArchiveDatabaseEx *db, UInt32 fileIndex, UInt32 *blockIndex, - Byte **outBuffer, + Byte **outBuffer, size_t *outBufferSize, - size_t *offset, - size_t *outSizeProcessed, + size_t *offset, + size_t *outSizeProcessed, ISzAlloc *allocMain, ISzAlloc *allocTemp) { @@ -41,9 +41,9 @@ SZ_RESULT SzExtract( *blockIndex = folderIndex; allocMain->Free(*outBuffer); *outBuffer = 0; - + RINOK(inStream->Seek(inStream, SzArDbGetFolderStreamPos(db, folderIndex, 0))); - + #ifndef _LZMA_IN_CB if (packSize != 0) { @@ -67,12 +67,12 @@ SZ_RESULT SzExtract( if (res == SZ_OK) { size_t outRealSize; - res = SzDecode(db->Database.PackSizes + - db->FolderStartPackStreamIndex[folderIndex], folder, + res = SzDecode(db->Database.PackSizes + + db->FolderStartPackStreamIndex[folderIndex], folder, #ifdef _LZMA_IN_CB inStream, #else - inBuffer, + inBuffer, #endif *outBuffer, (size_t)unPackSize, &outRealSize, allocTemp); if (res == SZ_OK) @@ -96,7 +96,7 @@ SZ_RESULT SzExtract( } if (res == SZ_OK) { - UInt32 i; + UInt32 i; CFileItem *fileItem = db->Database.Files + fileIndex; *offset = 0; for(i = db->FolderStartFileIndex[folderIndex]; i < fileIndex; i++) @@ -118,14 +118,14 @@ SZ_RESULT SzExtract( #ifdef _LZMA_OUT_READ // similar to SzExtract but needs less memory SZ_RESULT SzExtract2( - ISzInStream *inStream, + ISzInStream *inStream, CArchiveDatabaseEx *db, UInt32 fileIndex, UInt32 *blockIndex, - Byte **outBuffer, + Byte **outBuffer, size_t *outBufferSize, - size_t *offset, - size_t *outSizeProcessed, + size_t *offset, + size_t *outSizeProcessed, ISzAlloc *allocMain, ISzAlloc *allocTemp) { @@ -158,9 +158,9 @@ SZ_RESULT SzExtract2( allocMain->Free(*outBuffer); *outBuffer = 0; #endif - + RINOK(inStream->Seek(inStream, SzArDbGetFolderStreamPos(db, folderIndex, 0))); - + #ifndef _LZMA_IN_CB if (packSize != 0) { @@ -176,7 +176,7 @@ SZ_RESULT SzExtract2( { // calculate file offset and filesize CFileItem *fileItem = db->Database.Files + fileIndex; - UInt32 i; + UInt32 i; *offset = 0; for(i = db->FolderStartFileIndex[folderIndex]; i < fileIndex; i++) *offset += (UInt32)db->Database.Files[i].Size; @@ -192,14 +192,14 @@ SZ_RESULT SzExtract2( } if (res == SZ_OK) { - + size_t outRealSize; - res = SzDecode2(db->Database.PackSizes + - db->FolderStartPackStreamIndex[folderIndex], folder, + res = SzDecode2(db->Database.PackSizes + + db->FolderStartPackStreamIndex[folderIndex], folder, #ifdef _LZMA_IN_CB inStream, #else - inBuffer, + inBuffer, #endif *outBuffer, (size_t)unPackSize, &outRealSize, allocTemp, offset, outSizeProcessed @@ -226,24 +226,24 @@ SZ_RESULT SzExtract2( } if (res == SZ_OK) { -/* UInt32 i; +/* UInt32 i; CFileItem *fileItem = db->Database.Files + fileIndex; *offset = 0; for(i = db->FolderStartFileIndex[folderIndex]; i < fileIndex; i++) *offset += (UInt32)db->Database.Files[i].Size; *outSizeProcessed = (size_t)fileItem->Size;*/ - //CFileItem *fileItem = db->Database.Files + fileIndex; + CFileItem *fileItem = db->Database.Files + fileIndex; if (/**offset +*/ *outSizeProcessed > *outBufferSize) return SZE_FAIL; { - //if (fileItem->IsFileCRCDefined) - //{ - // if (!CrcVerifyDigest(fileItem->FileCRC, *outBuffer/* + *offset*/, *outSizeProcessed)) - // res = SZE_CRC_ERROR; // why does SzExtract return SZE_FAIL when we can return SZE_CRC_ERROR? - //} + if (fileItem->IsFileCRCDefined) + { + if (!CrcVerifyDigest(fileItem->FileCRC, *outBuffer/* + *offset*/, *outSizeProcessed)) + res = SZE_CRC_ERROR; // why does SzExtract return SZE_FAIL when we can return SZE_CRC_ERROR? + } } } - + // change *offset to 0 because SzExtract normally decompresses the whole solid block // and sets *offset to the offset of the wanted file. // SzDecode2 does only copy the needed file to the output buffer and has to set *offset diff --git a/source/sz/7zTypes.h b/source/sz/7zTypes.h index fa4c5c3c..817d9215 100644 --- a/source/sz/7zTypes.h +++ b/source/sz/7zTypes.h @@ -5,15 +5,13 @@ #ifndef _7ZIP_BYTE_DEFINED #define _7ZIP_BYTE_DEFINED -#ifndef ZCONF_H typedef unsigned char Byte; -#endif -#endif +#endif #ifndef _7ZIP_UINT16_DEFINED #define _7ZIP_UINT16_DEFINED typedef unsigned short UInt16; -#endif +#endif #ifndef _7ZIP_UINT32_DEFINED #define _7ZIP_UINT32_DEFINED @@ -22,7 +20,7 @@ typedef unsigned long UInt32; #else typedef unsigned int UInt32; #endif -#endif +#endif /* #define _SZ_NO_INT_64 */ /* define it your compiler doesn't support long long int */ @@ -46,9 +44,9 @@ typedef unsigned long long int UInt64; #ifndef CFileSize #ifdef _SZ_FILE_SIZE_64 -typedef UInt64 CFileSize; +typedef UInt64 CFileSize; #else -typedef UInt32 CFileSize; +typedef UInt32 CFileSize; #endif #endif @@ -64,8 +62,6 @@ typedef UInt32 CFileSize; #define SZE_ARCHIVE_ERROR (6) -#define SZE_OUTOFMEMORYDIC (7) - #define RINOK(x) { int __result_ = (x); if(__result_ != 0) return __result_; } #endif