From fb1190b4fd021a1d5457046d0b79ad4392176f53 Mon Sep 17 00:00:00 2001 From: dborth Date: Tue, 2 Sep 2008 01:55:56 +0000 Subject: [PATCH] source refactor 2 --- Makefile.gc.bat | 4 - Makefile.wii.bat | 4 - fceugc.pnproj | 1 - fceugc.pnps | 1 - fceugcv108x.txt | 229 ----- history.txt | 60 -- readme_big5.txt | 17 - source/mappers/000.c | 363 -------- source/mappers/112.c | 52 -- source/mappers/113.c | 50 -- source/mappers/114.c | 99 --- source/mappers/117.c | 70 -- source/mappers/15.c | 73 -- source/mappers/151.c | 41 - source/mappers/16.c | 305 ------- source/mappers/17.c | 74 -- source/mappers/18.c | 80 -- source/mappers/180.c | 14 - source/mappers/182.c | 48 -- source/mappers/184.c | 15 - source/mappers/187.c | 162 ---- source/mappers/189.c | 55 -- source/mappers/193.c | 20 - source/mappers/200.c | 36 - source/mappers/201.c | 44 - source/mappers/202.c | 39 - source/mappers/203.c | 36 - source/mappers/208.c | 139 --- source/mappers/21.c | 106 --- source/mappers/22.c | 63 -- source/mappers/225.c | 87 -- source/mappers/226.c | 105 --- source/mappers/227.c | 79 -- source/mappers/228.c | 53 -- source/mappers/229.c | 48 -- source/mappers/23.c | 102 --- source/mappers/230.c | 62 -- source/mappers/231.c | 41 - source/mappers/232.c | 50 -- source/mappers/234.c | 107 --- source/mappers/235.c | 53 -- source/mappers/240.c | 39 - source/mappers/241.c | 26 - source/mappers/242.c | 41 - source/mappers/244.c | 38 - source/mappers/246.c | 44 - source/mappers/248.c | 90 -- source/mappers/24and26.c | 369 -------- source/mappers/25.c | 100 --- source/mappers/255.c | 67 -- source/mappers/27.c | 69 -- source/mappers/32.c | 53 -- source/mappers/33.c | 79 -- source/mappers/40.c | 58 -- source/mappers/41.c | 57 -- source/mappers/42.c | 62 -- source/mappers/43.c | 75 -- source/mappers/46.c | 48 -- source/mappers/50.c | 75 -- source/mappers/51.c | 66 -- source/mappers/57.c | 49 -- source/mappers/58.c | 43 - source/mappers/59.c | 47 - source/mappers/6.c | 76 -- source/mappers/60.c | 40 - source/mappers/61.c | 54 -- source/mappers/62.c | 41 - source/mappers/65.c | 74 -- source/mappers/67.c | 78 -- source/mappers/68.c | 104 --- source/mappers/69.c | 252 ------ source/mappers/71.c | 41 - source/mappers/72.c | 37 - source/mappers/73.c | 60 -- source/mappers/75.c | 47 - source/mappers/76.c | 55 -- source/mappers/77.c | 54 -- source/mappers/79.c | 40 - source/mappers/8.c | 34 - source/mappers/80.c | 100 --- source/mappers/82.c | 62 -- source/mappers/83.c | 121 --- source/mappers/85.c | 195 ----- source/mappers/86.c | 38 - source/mappers/88.c | 62 -- source/mappers/89.c | 34 - source/mappers/91.c | 59 -- source/mappers/92.c | 45 - source/mappers/95.c | 136 --- source/mappers/97.c | 42 - source/mappers/99.c | 37 - source/mappers/emu2413.c | 1300 ---------------------------- source/mappers/emu2413.h | 134 --- source/mappers/emutypes.h | 44 - source/mappers/mapinc.h | 12 - source/mappers/mapshare.h | 5 - source/mappers/mmc2and4.c | 121 --- source/mappers/subor.c | 79 -- source/mappers/vrc7tone.h | 17 - source/mbshare/164.c | 117 --- source/mbshare/199.c | 95 --- source/mbshare/252.c | 95 --- source/mbshare/90.c | 343 -------- source/mbshare/deirom.c | 85 -- source/mbshare/mapinc.h | 10 - source/mbshare/mmc1.c | 444 ---------- source/mbshare/mmc3.c | 1613 ----------------------------------- source/mbshare/mmc3.h | 25 - source/mbshare/mmc5.c | 834 ------------------ source/mbshare/n106.c | 502 ----------- source/mbshare/tengen.c | 224 ----- source/palettes/palettes.h | 94 -- source/palettes/rp2c04001.h | 64 -- source/palettes/rp2c04002.h | 64 -- source/palettes/rp2c04003.h | 64 -- source/palettes/rp2c05004.h | 64 -- source/rom/ROM.NES | Bin 1048592 -> 0 bytes source/sz/7zAlloc.c | 70 -- source/sz/7zAlloc.h | 20 - source/sz/7zBuffer.c | 29 - source/sz/7zBuffer.h | 19 - source/sz/7zCrc.c | 76 -- source/sz/7zCrc.h | 24 - source/sz/7zDecode.c | 355 -------- source/sz/7zDecode.h | 37 - source/sz/7zExtract.c | 254 ------ source/sz/7zExtract.h | 60 -- source/sz/7zHeader.c | 5 - source/sz/7zHeader.h | 55 -- source/sz/7zIn.c | 1281 ---------------------------- source/sz/7zIn.h | 55 -- source/sz/7zItem.c | 133 --- source/sz/7zItem.h | 90 -- source/sz/7zMethodID.c | 14 - source/sz/7zMethodID.h | 18 - source/sz/7zTypes.h | 67 -- source/sz/LzmaDecode.c | 584 ------------- source/sz/LzmaDecode.h | 113 --- source/sz/LzmaTypes.h | 45 - 139 files changed, 16553 deletions(-) delete mode 100644 Makefile.gc.bat delete mode 100644 Makefile.wii.bat delete mode 100644 fceugc.pnproj delete mode 100644 fceugc.pnps delete mode 100644 fceugcv108x.txt delete mode 100644 history.txt delete mode 100644 readme_big5.txt delete mode 100644 source/mappers/000.c delete mode 100644 source/mappers/112.c delete mode 100644 source/mappers/113.c delete mode 100644 source/mappers/114.c delete mode 100644 source/mappers/117.c delete mode 100644 source/mappers/15.c delete mode 100644 source/mappers/151.c delete mode 100644 source/mappers/16.c delete mode 100644 source/mappers/17.c delete mode 100644 source/mappers/18.c delete mode 100644 source/mappers/180.c delete mode 100644 source/mappers/182.c delete mode 100644 source/mappers/184.c delete mode 100644 source/mappers/187.c delete mode 100644 source/mappers/189.c delete mode 100644 source/mappers/193.c delete mode 100644 source/mappers/200.c delete mode 100644 source/mappers/201.c delete mode 100644 source/mappers/202.c delete mode 100644 source/mappers/203.c delete mode 100644 source/mappers/208.c delete mode 100644 source/mappers/21.c delete mode 100644 source/mappers/22.c delete mode 100644 source/mappers/225.c delete mode 100644 source/mappers/226.c delete mode 100644 source/mappers/227.c delete mode 100644 source/mappers/228.c delete mode 100644 source/mappers/229.c delete mode 100644 source/mappers/23.c delete mode 100644 source/mappers/230.c delete mode 100644 source/mappers/231.c delete mode 100644 source/mappers/232.c delete mode 100644 source/mappers/234.c delete mode 100644 source/mappers/235.c delete mode 100644 source/mappers/240.c delete mode 100644 source/mappers/241.c delete mode 100644 source/mappers/242.c delete mode 100644 source/mappers/244.c delete mode 100644 source/mappers/246.c delete mode 100644 source/mappers/248.c delete mode 100644 source/mappers/24and26.c delete mode 100644 source/mappers/25.c delete mode 100644 source/mappers/255.c delete mode 100644 source/mappers/27.c delete mode 100644 source/mappers/32.c delete mode 100644 source/mappers/33.c delete mode 100644 source/mappers/40.c delete mode 100644 source/mappers/41.c delete mode 100644 source/mappers/42.c delete mode 100644 source/mappers/43.c delete mode 100644 source/mappers/46.c delete mode 100644 source/mappers/50.c delete mode 100644 source/mappers/51.c delete mode 100644 source/mappers/57.c delete mode 100644 source/mappers/58.c delete mode 100644 source/mappers/59.c delete mode 100644 source/mappers/6.c delete mode 100644 source/mappers/60.c delete mode 100644 source/mappers/61.c delete mode 100644 source/mappers/62.c delete mode 100644 source/mappers/65.c delete mode 100644 source/mappers/67.c delete mode 100644 source/mappers/68.c delete mode 100644 source/mappers/69.c delete mode 100644 source/mappers/71.c delete mode 100644 source/mappers/72.c delete mode 100644 source/mappers/73.c delete mode 100644 source/mappers/75.c delete mode 100644 source/mappers/76.c delete mode 100644 source/mappers/77.c delete mode 100644 source/mappers/79.c delete mode 100644 source/mappers/8.c delete mode 100644 source/mappers/80.c delete mode 100644 source/mappers/82.c delete mode 100644 source/mappers/83.c delete mode 100644 source/mappers/85.c delete mode 100644 source/mappers/86.c delete mode 100644 source/mappers/88.c delete mode 100644 source/mappers/89.c delete mode 100644 source/mappers/91.c delete mode 100644 source/mappers/92.c delete mode 100644 source/mappers/95.c delete mode 100644 source/mappers/97.c delete mode 100644 source/mappers/99.c delete mode 100644 source/mappers/emu2413.c delete mode 100644 source/mappers/emu2413.h delete mode 100644 source/mappers/emutypes.h delete mode 100644 source/mappers/mapinc.h delete mode 100644 source/mappers/mapshare.h delete mode 100644 source/mappers/mmc2and4.c delete mode 100644 source/mappers/subor.c delete mode 100644 source/mappers/vrc7tone.h delete mode 100644 source/mbshare/164.c delete mode 100644 source/mbshare/199.c delete mode 100644 source/mbshare/252.c delete mode 100644 source/mbshare/90.c delete mode 100644 source/mbshare/deirom.c delete mode 100644 source/mbshare/mapinc.h delete mode 100644 source/mbshare/mmc1.c delete mode 100644 source/mbshare/mmc3.c delete mode 100644 source/mbshare/mmc3.h delete mode 100644 source/mbshare/mmc5.c delete mode 100644 source/mbshare/n106.c delete mode 100644 source/mbshare/tengen.c delete mode 100644 source/palettes/palettes.h delete mode 100644 source/palettes/rp2c04001.h delete mode 100644 source/palettes/rp2c04002.h delete mode 100644 source/palettes/rp2c04003.h delete mode 100644 source/palettes/rp2c05004.h delete mode 100644 source/rom/ROM.NES delete mode 100644 source/sz/7zAlloc.c delete mode 100644 source/sz/7zAlloc.h delete mode 100644 source/sz/7zBuffer.c delete mode 100644 source/sz/7zBuffer.h delete mode 100644 source/sz/7zCrc.c delete mode 100644 source/sz/7zCrc.h delete mode 100644 source/sz/7zDecode.c delete mode 100644 source/sz/7zDecode.h delete mode 100644 source/sz/7zExtract.c delete mode 100644 source/sz/7zExtract.h delete mode 100644 source/sz/7zHeader.c delete mode 100644 source/sz/7zHeader.h delete mode 100644 source/sz/7zIn.c delete mode 100644 source/sz/7zIn.h delete mode 100644 source/sz/7zItem.c delete mode 100644 source/sz/7zItem.h delete mode 100644 source/sz/7zMethodID.c delete mode 100644 source/sz/7zMethodID.h delete mode 100644 source/sz/7zTypes.h delete mode 100644 source/sz/LzmaDecode.c delete mode 100644 source/sz/LzmaDecode.h delete mode 100644 source/sz/LzmaTypes.h diff --git a/Makefile.gc.bat b/Makefile.gc.bat deleted file mode 100644 index c3403c1..0000000 --- a/Makefile.gc.bat +++ /dev/null @@ -1,4 +0,0 @@ -cp Makefile.gc Makefile -make -rm Makefile -rm -d build/*.* \ No newline at end of file diff --git a/Makefile.wii.bat b/Makefile.wii.bat deleted file mode 100644 index b07feb4..0000000 --- a/Makefile.wii.bat +++ /dev/null @@ -1,4 +0,0 @@ -cp Makefile.wii Makefile -make -rm Makefile -rm build/*.* \ No newline at end of file diff --git a/fceugc.pnproj b/fceugc.pnproj deleted file mode 100644 index 870f659..0000000 --- a/fceugc.pnproj +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/fceugc.pnps b/fceugc.pnps deleted file mode 100644 index e8dfb1f..0000000 --- a/fceugc.pnps +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/fceugcv108x.txt b/fceugcv108x.txt deleted file mode 100644 index 7437b78..0000000 --- a/fceugcv108x.txt +++ /dev/null @@ -1,229 +0,0 @@ -¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤ - - - FCE Ultra GameCube Edition - - Version 1.0.8x - (Under GPL License) - Softdev, 2006 - -¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤ - --=[ Explanation ]=- - -FCE Ultra GC is a modified port of the FCE Ultra 0.98.12 Nintendo Entertainment -system for x86 (Windows/Linux) PC's. In English you can play NES games on your -GameCube using either a softmod and/or modchip from a DVD or via a networked -connection to your PC. If you're unfamiliar with what softmods/modchips please -visit the site listed at the bottom of this document. - --=[ What's New? ]=- - -* XenoGC Support (GC-Linux Homebrew DVD Compatibility) - --=[ Features ]=- - -* NES Compatibility Based on v0.98.12 -* Sound Filters -* Graphics Filters (GX Chipset, Cheesy and 2x) -* 1-2 Player Support -* Real Time Saving (RTS) from Memory Card -* Load Games from ISO9660 DVD -* Supports Joilet Filesystem w/Relaxed Options -* Fast Load from Qoob or Viper -* GX Graphic Filter Added - Super Fast/Smooth -* Joilet FileSystem Support for DVD -* Memory Card Idle Bug Fixed - --=[ Supported Mappers ]=- - -Mappers are the way the Nintendo handles switching from ROM/VROM so the more -that are supported the more games will work. - -000 . 112 . 113 . 114 . 117 . 15 . 151 . 16 . 17 . 18 . 180 . 182 . 184 . 187 -189 . 193 . 200 . 201 . 202 . 203 . 208 . 21 . 22 . 225 . 226 . 227 . 228 . 229 - 23 . 230 . 231 . 232 . 234 . 235 . 240 . 241 . 242 . 244 . 246 . 248 . 24 . 26 - 25 . 255 . 32 . 33 . 40 . 41 . 42 . 43 . 46 . 50 . 51 . 57 . 58 . 59 - 6 . 60 . 61 . 62 . 65 . 67 . 68 . 69 . 71 . 72 . 73 . 75 . 76 . 77 - 79 . 8 . 80 . 82 . 83 . 85 . 86 . 88 . 89 . 91 . 92 . 95 . 97 . 99 - --=[ Requirements ]=- - -* Softmod and/or Hardmod -* DVD Burner and/or Broad Band Adapter -* Some NES ROMS - http://www.pdroms.de - --=[ Usage - Preparation ]=- - -You can either put FCEU GC onto a DVD with various ROM files or inject the ROM(s) into -the emulator. Either way FCEU GC comes without a ROM file in it and you must first -inject one before you can burn a disc. I would suggest if you're using a SoftMod to -inject the ROM(s) and create many DOL files as it will cut down on the swapping of -discs. Note that the ROMS must be unzipped and be in the iNES format (.NES) - - -[ Injecting the ROM ]- - - These instructions are for Windows users and if you're running Linux I'm sure - you wont even need most of these instructions and can figure out how to work - it yourself. - - (a) Extract the FCEUGCv108.ZIP and ROMS archives into "C:\NES" - (a) Goto the Start Menu and pick "RUN" then type in "CMD" - (b) Type in "C:\" then press ENTER (Changes to the "C" drive) - (c) Type in "CD\NES" then press ENTER (Changes to the "C:\NES" Folder) - (d) Type in "DIR" then press ENTER (Lists all the files in the Folder) - (e) Type in "FCEUINJECT (rom_name.nes) (output_name.dol)" and press ENTER - Example - "FCEUINJECT Tetris.nes Tetris.dol" - (f) Put the Tetris.dol (or whatever you named it) on the media you use for - SoftMod Booting (SD Card, DVD, etc) - - If you're going to be creating a DVD for use with ModChips were you can use - the DVD loading selection menu then you'll only need to create ONE .DOL file, - but if you're using a softmod you may want to create more then one .DOL file. - - -[ Creating the DVD ]- - - (a) Load Nero Burning ROM and pick NEW then DVD then DVD-ROM (ISO) - (b) Make sure Multi-Session is set to NO - (c) Under the ISO tab set these following options: - File system: ISO 9660 Only or ISO 9660 + Joliet - File name length (ISO): Max. of 31 chars (Level 2) - Character set (ISO): ISO 9660 (Standard ISO CD-ROM) - Relax Restrictions: Check all except "Do not add the ';1' ISO file" - (d) Under the Label TAB enter in the DVD name (anything you want) - (e) Click the NEW button - (f) Put the ROMNAME.DOL*** file in the main directory (under the little CD) - (g) Right Click in the DVD Window and pick "Create Folder" - **(h) Make a Folder named "A", "B", "C", etc - (i) Drag and Drop the .NES roms into the main dir or **folders - (j) Pick "Recorder" then "Burn Compilation" - (k) Pick your speed and make sure to pick "Finalize DVD" - If "Finalize DVD" is grayed out don't worry - (l) Hit burn and wait a while - - * = You can chose ISO9660 by itself or with Joliet and it doesn't matter - if you're using a Viper GC or other solution - ** = Creating folders based on filenames makes for easier loading if you - have a bunch of roms on the DVD - *** = This is the DOL file you make with the injection method - --=[ Usage - Emulator ]=- - -To load the FCEUGC.DOL or any other DOL file(s) you've put NES roms into please -refer to the Mod That Cube -FAQ- (http://modthatcube.pxn-os.com) to see how to load -DOL files using your SoftMod and/or Modchip. - -Once you load FCEU GC the ROM injected into the emulator will automatically load so -you can play it. If you would like to load another ROM you're going to have to access -the "Configuration Menu" by pressing "Z" on the GameCube controller. - --=[ Usage - Controls ]=- - - Analog = UP / DOWN / LEFT / RIGHT - D-PAD = UP / DOWN / LEFT / RIGHT - Select = X - Start = START / PAUSE - A Button = A - B Button = B - - Z Button = Configuration Menu - L & R = Return to SDLOAD (SDLoad Users Only) - --=[ Usage - Configuration Menu ]=- - - To access the Configuration Menu simply press "Z" while the emulator is running. - To access any of the options press "A" and to press the B button to "Quick Exit" - the current sub-menu you may be in. - - -[ Emulator Options ]- - - Screen Scaler - How to scale the screen: GX, Cheesy or 2x - - Palette - The colors used while viewing the game: - Default . loopy . quor . chris . matt - pasofami . crashman . mess . zaphod-cv - zaphod-smb . vs-drmar . vs-cv . vs-smb - - Stop DVD Motor - If you're going to be playing a game for a while you might as - well stop the DVD motor to save the life of the DVD drive - - Timing - NTSC or PAL (Depends if you're running a PAL or NTSC game) - - Reset NES - This will RESET the Emulator - - -[ Save Game Manager ]- - - If you would like to save in your game simply pick which card to save to - and then save it. Later on if you would like to load your save just load - the game you had saved in and then pick "Load Game State". - - Save Game State CARD A - Will do a Real Time Save of your current position - Load Game State CARD A - Will load your previous Real Time Save - - Save Game State CARD B - Will do a Real Time Save of your current position - Load Game State CARD B - Will load your previous Real Time Save - - -[ Game Information ]- - - Displays various technical information about the game including: - ROM Size . VROM Size . iNES CRC . Mapper . Mirroring - - -[ Load New ROM ]- - - This will bring up a file browser showing the .NES files you have on - the DVD in the GameCube. If you're using a Qoob or Viper chip the - emulator will fastload the disc, otherwise you will have to swap - discs with an original one. After the file menu comes up simply select - you game and press "A" to load it. - - Controls in File Menu: - - A button - Play Selected ROM Image - D-Pad UP - Scroll Up Filename List - D-Pad DOWN - Scroll Down Filename List - D-Pad RIGHT - Skip List Page Forward - D-Pad LEFT - Skip List Page Backward - Analog Pad UP - Fast Scroll Up Filename List - Analog Pad DOWN - Fast Scroll Down Filename List - -¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤ - --=[ Credits ]=- - -GameCube Port/Coding - SoftDev - - Original FCE by BERO - FCE Ultra by Xodnizel - DevkitPPC / LibOGC by Wntrmute & Shagkur - DVD Codes Courtesy of The NinjaMod Team - ZLIB by Jean-loup Gailly - IPLFont by Qoob Team - -Beta Testers ... - - brakken - mithos - luciddream - -Special Thanks To ... - - HonkeyKong - -¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤ - - Disclaimer - Use at your own RISK! - -¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤ - - Documentation Written by Brakken (brakken@tehskeen.com) - -¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤ - - Official Homepage - http://www.tehskeen.net - - Official Help Forums - http://www.tehskeen.net/forums/forumdisplay.php?f=34 - - Mod That Cube -FAQ- - http://modthatcube.pxn-os.com - -¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø,¸,ø¤°`°¤ø,¸¸,ø¤ \ No newline at end of file diff --git a/history.txt b/history.txt deleted file mode 100644 index 20d28c6..0000000 --- a/history.txt +++ /dev/null @@ -1,60 +0,0 @@ -- FCE Ultra GameCube Edition - - -Hello again! This great emulator, for this great console was in "el olvido", -so, again, I've decided to add it some new changes to make it a little most complete, -please, keep source code when you made a change, this is an open source project. - -This new version have asako and _svpe_ lastest added options. - -Enjoy it! -Askot. - -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/readme_big5.txt b/readme_big5.txt deleted file mode 100644 index 77bcfe6..0000000 --- a/readme_big5.txt +++ /dev/null @@ -1,17 +0,0 @@ -====This is CP950 big5 code===== - - -§Ú·Q³o¤j·§¬O²Ä¤@­Ó¦bGAMECUBEªº¥D¾÷¤W¥i¥H¶]¹ï©¤¤¤°êªºµsª©ªº¥ô¤Ñ°ó¼ÒÀÀ¾¹¡C -°ò¥»¤W¬O­×§ï fceugc070607 ªº­ì©l½X¡AµM«á¼W¥[¤@¨Ç¹ï¤¤°êªºµsª©ROMªº¤ä´©¡C - -§Ú´ú¦¡¹L¤ÓªÅ¾Ô¤h1¡B2¡A¸ò¤T°ê»x-¤¤­ì¤§ÅQªÌ2¡B§]­¹¤Ñ¦a1¡A³o¨Ç¬O¥i¥H°õ¦æªº¡A -¦³³¡¥÷¤£¯à°õ¦æ¦p ¤¤­ì¤§ÅQªÌ1¡A¦³¨Ç©Ç©Çªº¦p «iªÌ°«´cÀs2¡B3¡B4(¥i¯à¬Orom¥» -¨­ªº°ÝÃD)³o¬O¨Ç¬O¦W§@ªº³¡¥÷¡A¨ä¥¦«D¦W§@ªº¤¤¤åROM¤j¦h¨S¤°»ò°ÝÃD¡C - -³Ì«á½Ð¤j®a¤ä«ù¥xÆW¥[¤JÁp¦X°ê¡AÁÂÁ¡C -¨ä¥¦¦³«ü±Ðªº½Ð - -Email:asakous@gmail.com - -========================== - diff --git a/source/mappers/000.c b/source/mappers/000.c deleted file mode 100644 index 5e09ad9..0000000 --- a/source/mappers/000.c +++ /dev/null @@ -1,363 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint8 latche; - -static DECLFW(Mapper2_write) -{ - latche=V; - ROM_BANK16(0x8000,V); -} - -void Mapper2_init(void) -{ - SetWriteHandler(0x8000,0xFFFF,Mapper2_write); - AddExState(&latche, 1, 0, "LATC"); -} - -static DECLFW(Mapper3_write) -{ - VROM_BANK8(V); - latche=V; -} - -void Mapper3_init(void) -{ - SetWriteHandler(0x8000,0xFFFF,Mapper3_write); - AddExState(&latche, 1, 0, "LATC"); -} - -static DECLFW(Mapper7_write) -{ - ROM_BANK32(V&0xF); - onemir((V>>4)&1); - latche=V; -} - -void Mapper7_init(void) -{ - onemir(0); - ROM_BANK32(0); - SetWriteHandler(0x8000,0xFFFF,Mapper7_write); - AddExState(&latche, 1, 0, "LATC"); -} - -void Mapper243_init(void) -{ - - -} - -static DECLFW(Mapper11_write) -{ - ROM_BANK32(V&0xF); - VROM_BANK8(V>>4); - latche=V; -} - -void Mapper11_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x8000,0xFFFF,Mapper11_write); - AddExState(&latche, 1, 0, "LATC"); -} -void Mapper144_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x8001,0xFFFF,Mapper11_write); - AddExState(&latche, 1, 0, "LATC"); - -} -static DECLFW(Mapper13_write) -{ - setchr4r(0x10,0x1000,V&3); - setprg32(0x8000,(V>>4)&3); - latche=V; -} - -static void Mapper13_StateRestore(int version) -{ - setchr4r(0x10,0x0000,0); - setchr4r(0x10,0x1000,latche&3); - setprg32(0x8000,(latche>>4)&3); -} - -void Mapper13_init(void) -{ - SetWriteHandler(0x8000,0xFFFF,Mapper13_write); - GameStateRestore=Mapper13_StateRestore; - AddExState(&latche, 1, 0, "LATC"); - AddExState(MapperExRAM, 16384, 0, "CHRR"); - SetupCartCHRMapping(0x10, MapperExRAM, 16384, 1); - - latche=0; - Mapper13_StateRestore(FCEU_VERSION_NUMERIC); -} - -static DECLFW(Mapper34_write) -{ - switch(A) - { - case 0x7FFD:ROM_BANK32(V);break; - case 0x7FFE:VROM_BANK4(0x0000,V);break; - case 0x7fff:VROM_BANK4(0x1000,V);break; - } - if(A>=0x8000) - ROM_BANK32(V); -} - -void Mapper34_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x7ffd,0xffff,Mapper34_write); -} - -DECLFW(Mapper66_write) -{ - VROM_BANK8(V&0xF); - ROM_BANK32((V>>4)); - latche=V; -} - -void Mapper66_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x6000,0xffff,Mapper66_write); - AddExState(&latche, 1, 0, "LATC"); -} - -DECLFW(Mapper152_write) -{ - ROM_BANK16(0x8000,(V>>4)&0x7); - VROM_BANK8(V&0xF); - onemir((V>>7)&1); /* Saint Seiya...hmm. */ - latche=V; -} - -void Mapper152_init(void) -{ - onemir(0); - SetWriteHandler(0x6000,0xffff,Mapper152_write); - AddExState(&latche, 1, 0, "LATC"); -} - -static DECLFW(Mapper70_write) -{ - ROM_BANK16(0x8000,V>>4); - VROM_BANK8(V&0xF); - latche=V; -} - -void Mapper70_init(void) -{ - SetWriteHandler(0x6000,0xffff,Mapper70_write); - AddExState(&latche, 1, 0, "LATC"); -} -/* Should be two separate emulation functions for this "mapper". Sigh. URGE TO KILL RISING. */ -static DECLFW(Mapper78_write) -{ - //printf("$%04x:$%02x\n",A,V&0x8); - ROM_BANK16(0x8000,V&0x7); - VROM_BANK8(V>>4); - onemir((V>>3)&1); - latche=V; -} - -void Mapper78_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper78_write); - AddExState(&latche, 1, 0, "LATC"); -} - -DECLFW(Mapper87_write) -{ - VROM_BANK8(V>>1); - latche=V; -} - -void Mapper87_init(void) -{ - SetWriteHandler(0x6000,0xffff,Mapper87_write); - AddExState(&latche, 1, 0, "LATC"); -} - -DECLFW(Mapper93_write) -{ - ROM_BANK16(0x8000,V>>4); - MIRROR_SET(V&1); - latche=V; -} - -void Mapper93_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper93_write); - AddExState(&latche, 1, 0, "LATC"); -} - - -DECLFW(Mapper94_write) -{ - ROM_BANK16(0x8000,V>>2); - latche=V; -} - -void Mapper94_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper94_write); - AddExState(&latche, 1, 0, "LATC"); -} - -/* I might want to add some code to the mapper 96 PPU hook function - to not change CHR banks if the attribute table is being accessed, - if I make emulation a little more accurate in the future. -*/ - -static uint8 M96LA; -static DECLFW(Mapper96_write) -{ - latche=V; - setprg32(0x8000,V&3); - setchr4r(0x10,0x0000,(latche&4)|M96LA); - setchr4r(0x10,0x1000,(latche&4)|3); -} - -static void FP_FASTAPASS(1) M96Hook(uint32 A) -{ - if((A&0x3000)!=0x2000) return; - //if((A&0x3ff)>=0x3c0) return; - M96LA=(A>>8)&3; - setchr4r(0x10,0x0000,(latche&4)|M96LA); -} - -static void M96Sync(int v) -{ - setprg32(0x8000,latche&3); - setchr4r(0x10,0x0000,(latche&4)|M96LA); - setchr4r(0x10,0x1000,(latche&4)|3); -} - -void Mapper96_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper96_write); - PPU_hook=M96Hook; - AddExState(&latche, 1, 0, "LATC"); - AddExState(&M96LA, 1, 0, "LAVA"); - SetupCartCHRMapping(0x10, MapperExRAM, 32768, 1); - latche=M96LA=0; - M96Sync(0); - setmirror(MI_0); - GameStateRestore=M96Sync; -} - -static DECLFW(Mapper140_write) -{ - VROM_BANK8(V&0xF); - ROM_BANK32((V>>4)&0xF); -} - -void Mapper140_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x6000,0x7FFF,Mapper140_write); -} - -static void M185Sync(int version) -{ - int x; - -// DumpMem("out",0x8000,0xFFFF); -// exit(1); -// if(mapbyte1[0]==0x15) - if(!(mapbyte1[0]&3)) -// if(!(mapbyte1[0]==0x21)) - { - for(x=0;x<8;x++) - setchr1r(0x10,x<<10,0); - } - else - setchr8(0); -} - -static DECLFW(Mapper185_write) -{ - mapbyte1[0]=V; - M185Sync(0); - //printf("Wr: $%04x:$%02x, $%04x\n",A,V,X.PC); -} - -void Mapper185_init(void) -{ - memset(MapperExRAM,0xFF,1024); - MapStateRestore=M185Sync; - mapbyte1[0]=0; - M185Sync(0); - - SetupCartCHRMapping(0x10,MapperExRAM,1024,0); - SetWriteHandler(0x8000,0xFFFF,Mapper185_write); -} - -static DECLFW(M156Write) -{ - if(A>=0xc000 && A<=0xC003) - VROM_BANK1((A&3)*1024,V); - else if(A>=0xc008 && A<=0xc00b) - VROM_BANK1(0x1000+(A&3)*1024,V); - if(A==0xc010) ROM_BANK16(0x8000,V); -// printf("$%04x:$%02x\n",A,V); -} - -void Mapper156_init(void) -{ - onemir(0); - SetWriteHandler(0xc000,0xc010,M156Write); -} -#ifdef moo -static DECLFW(Mapper157_write) -{ - printf("$%04x:$%02x\n",A,V); - if(A<0xc000) - setprg16(0xc000,V); -} -static DECLFR(m157rd) -{ - printf("Rd: $%04x\n",A); -} - -void Mapper157_init(void) -{ - SetWriteHandler(0x4020,0xffff,Mapper157_write); - SetReadHandler(0x4020,0x7fff,m157rd); -} -#endif - -static DECLFW(m107w) -{ - ROM_BANK32((V>>1)&0x3); - VROM_BANK8(V&0x7); -} - -void Mapper107_init(void) -{ - SetWriteHandler(0x8000,0xffff,m107w); -} - diff --git a/source/mappers/112.c b/source/mappers/112.c deleted file mode 100644 index 2a46f6f..0000000 --- a/source/mappers/112.c +++ /dev/null @@ -1,52 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -DECLFW(Mapper112_write) -{ -switch(A) -{ - case 0xe000:MIRROR_SET(V&1);break; - case 0x8000:mapbyte1[0]=V;break; - case 0xa000:switch(mapbyte1[0]) - { - case 0:ROM_BANK8(0x8000,V);break; - case 1:ROM_BANK8(0xA000,V);break; - case 2: V&=0xFE;VROM_BANK1(0,V); - VROM_BANK1(0x400,(V+1));break; - case 3: V&=0xFE;VROM_BANK1(0x800,V); - VROM_BANK1(0xC00,(V+1));break; - case 4:VROM_BANK1(0x1000,V);break; - case 5:VROM_BANK1(0x1400,V);break; - case 6:VROM_BANK1(0x1800,V);break; - case 7:VROM_BANK1(0x1c00,V);break; - } - break; - } -} - -void Mapper112_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper112_write); -} - diff --git a/source/mappers/113.c b/source/mappers/113.c deleted file mode 100644 index d935f47..0000000 --- a/source/mappers/113.c +++ /dev/null @@ -1,50 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -/* I'm getting the feeling this is another "jam two different bank - switching hardwares into one mapper". -*/ - -/* HES 4-in-1 */ -DECLFW(Mapper113_write) -{ - ROM_BANK32((V>>3)&7); - VROM_BANK8(V&7); - //printf("$%04x:$%02x\n",A,V); -} - - -/* Deathbots */ -DECLFW(Mapper113_writeh) -{ - //printf("$%04x:$%02x\n",A,V); - ROM_BANK32(V&0x7); - //VROM_BANK8((V>>4)&0x7); -} - - -void Mapper113_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x4020,0x7fff,Mapper113_write); - SetWriteHandler(0x8000,0xffff,Mapper113_writeh); -} diff --git a/source/mappers/114.c b/source/mappers/114.c deleted file mode 100644 index 290453b..0000000 --- a/source/mappers/114.c +++ /dev/null @@ -1,99 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define master mapbyte3[0] -#define incmd mapbyte3[1] - -static void dochr(void) -{ - VROM_BANK2(0x0000,(mapbyte2[0]>>1)); - VROM_BANK2(0x0800,(mapbyte2[2]>>1)); - VROM_BANK1(0x1000,mapbyte2[6]); - VROM_BANK1(0x1400,mapbyte2[1]); - VROM_BANK1(0x1800,mapbyte2[7]); - VROM_BANK1(0x1c00,mapbyte2[3]); -} - -void doprg() -{ - if(master&0x80) - { - ROM_BANK16(0x8000,master&0x1F); - } - else - { - ROM_BANK8(0x8000,mapbyte2[4]); - ROM_BANK8(0xa000,mapbyte2[5]); - } - -} - -static DECLFW(Mapper114_write) -{ - if(A<=0x7FFF) - { - master=V; - doprg(); - } - else if(A==0xe003) IRQCount=V; - else if(A==0xe002) X6502_IRQEnd(FCEU_IQEXT); - else switch(A&0xE000) - { - case 0x8000:MIRROR_SET(V&1);break; - case 0xa000:mapbyte1[0]=V;incmd=1;break; - case 0xc000: - if(!incmd) break; - mapbyte2[mapbyte1[0]&0x7]=V; - switch(mapbyte1[0]&0x7) - { - case 0x0: case 1: case 2: case 3: case 6: case 7: - dochr();break; - case 0x4: - case 0x5:doprg();break; - } - incmd=0; - break; - } - -} - -static void Mapper114_hb(void) -{ - if(IRQCount) - { - IRQCount--; - if(!IRQCount) - { - X6502_IRQBegin(FCEU_IQEXT); - //printf("IRQ: %d\n",scanline); - } - } - -} - -void Mapper114_init(void) -{ - GameHBIRQHook=Mapper114_hb; - SetWriteHandler(0x6000,0xffff,Mapper114_write); - SetReadHandler(0x4020,0x7fff,0); -} - diff --git a/source/mappers/117.c b/source/mappers/117.c deleted file mode 100644 index f7302b4..0000000 --- a/source/mappers/117.c +++ /dev/null @@ -1,70 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -DECLFW(Mapper117_write) -{ - //if(A>=0xc000) - //printf("$%04x:$%02x, %d,%d\n",A,V,scanline,timestamp); - switch(A) - { - case 0xc001:IRQLatch=V;break; - case 0xc003:IRQCount=IRQLatch;IRQa|=2;break; - case 0xe000:IRQa&=~1;IRQa|=V&1;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xc002:X6502_IRQEnd(FCEU_IQEXT);break; - case 0xa000:VROM_BANK1(0x0000,V);break; - case 0xa001:VROM_BANK1(0x0400,V);break; - case 0xa002:VROM_BANK1(0x0800,V);break; - case 0xa003:VROM_BANK1(0x0c00,V);break; - case 0xa004:VROM_BANK1(0x1000,V);break; - case 0xa005:VROM_BANK1(0x1400,V);break; - case 0xa006:VROM_BANK1(0x1800,V);break; - case 0xa007:VROM_BANK1(0x1c00,V);break; - case 0x8000:ROM_BANK8(0x8000,V);break; - case 0x8001:ROM_BANK8(0xa000,V);break; - case 0x8002:ROM_BANK8(0xc000,V);break; - case 0x8003:ROM_BANK8(0xe000,V);break; - } -} - -static void Mapper117_hb(void) -{ - //if(scanline==0x40) X6502_IRQBegin(FCEU_IQEXT); - //return; - if(IRQa==3 && IRQCount) - { - IRQCount--; - if(!IRQCount) - { - IRQa&=1; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -void Mapper117_init(void) -{ - GameHBIRQHook=Mapper117_hb; - SetWriteHandler(0x8000,0xffff,Mapper117_write); -} - diff --git a/source/mappers/15.c b/source/mappers/15.c deleted file mode 100644 index bc3c1aa..0000000 --- a/source/mappers/15.c +++ /dev/null @@ -1,73 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static void Sync(void) -{ - int x; - - setmirror(((mapbyte1[0]>>6)&1)^1); - switch(mapbyte1[1]&0x3) - { - case 0x0: - for(x=0;x<4;x++) - setprg8(0x8000+x*8192,(((mapbyte1[0]&0x7F)<<1)+x)^(mapbyte1[0]>>7)); - break; - case 0x2: - for(x=0;x<4;x++) - setprg8(0x8000+x*8192,((mapbyte1[0]&0x7F)<<1)+(mapbyte1[0]>>7)); - break; - case 0x1: - case 0x3: - for(x=0;x<4;x++) - { - unsigned int b; - - b=mapbyte1[0]&0x7F; - if(x>=2 && !(mapbyte1[1]&0x2)) - b=0x7F; - setprg8(0x8000+x*8192,(x&1)+((b<<1)^(mapbyte1[0]>>7))); - } - break; - } -} - - -static DECLFW(Mapper15_write) -{ - mapbyte1[0]=V; - mapbyte1[1]=A&3; - Sync(); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper15_init(void) -{ - mapbyte1[0]=mapbyte1[1]=0; - Sync(); - GameStateRestore=StateRestore; - SetWriteHandler(0x8000,0xFFFF,Mapper15_write); -} - diff --git a/source/mappers/151.c b/source/mappers/151.c deleted file mode 100644 index 5d2cb28..0000000 --- a/source/mappers/151.c +++ /dev/null @@ -1,41 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -DECLFW(Mapper151_write) -{ - switch(A&0xF000) - { - case 0x8000:ROM_BANK8(0x8000,V);break; - case 0xA000:ROM_BANK8(0xA000,V);break; - case 0xC000:ROM_BANK8(0xC000,V);break; - case 0xe000:VROM_BANK4(0x0000,V);break; - case 0xf000:VROM_BANK4(0x1000,V);break; - } -} - -void Mapper151_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper151_write); -} - diff --git a/source/mappers/16.c b/source/mappers/16.c deleted file mode 100644 index fd9d899..0000000 --- a/source/mappers/16.c +++ /dev/null @@ -1,305 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static void FP_FASTAPASS(1) BandaiIRQHook(int a) -{ - if(IRQa) - { - IRQCount-=a; - if(IRQCount<0) - { - X6502_IRQBegin(FCEU_IQEXT); - //printf("IRQ: %d, %d\n",scanline,timestamp); - IRQa=0; - IRQCount=0xFFFF; - } - } -} - -static DECLFW(Mapper16_write) -{ - A&=0xF; - - if(A<=0x7) - VROM_BANK1(A<<10,V); - else if(A==0x8) - ROM_BANK16(0x8000,V); - else switch(A) { - case 0x9: switch(V&3) { - case 0x00:MIRROR_SET2(1);break; - case 0x01:MIRROR_SET2(0);break; - case 0x02:onemir(0);break; - case 0x03:onemir(1);break; - } - break; - case 0xA:X6502_IRQEnd(FCEU_IQEXT); - IRQa=V&1; - IRQCount=IRQLatch; - break; - case 0xB:IRQLatch&=0xFF00; - IRQLatch|=V; - break; - case 0xC:IRQLatch&=0xFF; - IRQLatch|=V<<8; - break; - case 0xD: break;/* Serial EEPROM control port */ - } -} - -// Famicom jump 2: -// 0-7: Lower bit of data selects which 256KB PRG block is in use. -// This seems to be a hack on the developers' part, so I'll make emulation -// of it a hack(I think the current PRG block would depend on whatever the -// lowest bit of the CHR bank switching register that corresponds to the -// last CHR address read). - -static void PRGO(void) -{ - uint32 base=(mapbyte1[0]&1)<<4; - ROM_BANK16(0x8000,(mapbyte2[0]&0xF)|base); - ROM_BANK16(0xC000,base|0xF); -} - -static DECLFW(Mapper153_write) -{ - A&=0xF; - if(A<=0x7) - { - mapbyte1[A&7]=V; - PRGO(); - } - else if(A==0x8) - { - mapbyte2[0]=V; - PRGO(); - } - else switch(A) { - case 0x9: switch(V&3) { - case 0x00:MIRROR_SET2(1);break; - case 0x01:MIRROR_SET2(0);break; - case 0x02:onemir(0);break; - case 0x03:onemir(1);break; - } - break; - case 0xA:X6502_IRQEnd(FCEU_IQEXT); - IRQa=V&1; - IRQCount=IRQLatch; - break; - case 0xB:IRQLatch&=0xFF00; - IRQLatch|=V; - break; - case 0xC:IRQLatch&=0xFF; - IRQLatch|=V<<8; - break; - } -} - -void Mapper16_init(void) -{ - MapIRQHook=BandaiIRQHook; - SetWriteHandler(0x6000,0xFFFF,Mapper16_write); -} - -void Mapper153_init(void) -{ - MapIRQHook=BandaiIRQHook; - SetWriteHandler(0x8000,0xFFFF,Mapper153_write); - /* This mapper/board seems to have WRAM at $6000-$7FFF, so I'll let the - main ines code take care of that memory region. */ -} - - -static uint8 BarcodeData[256]; -static int BarcodeReadPos; -static int BarcodeCycleCount; -static uint32 BarcodeOut; - -int FCEUI_DatachSet(const uint8 *rcode) -{ - int prefix_parity_type[10][6] = { - {0,0,0,0,0,0}, {0,0,1,0,1,1}, {0,0,1,1,0,1}, {0,0,1,1,1,0}, - {0,1,0,0,1,1}, {0,1,1,0,0,1}, {0,1,1,1,0,0}, {0,1,0,1,0,1}, - {0,1,0,1,1,0}, {0,1,1,0,1,0} - }; - int data_left_odd[10][7] = { - {0,0,0,1,1,0,1}, {0,0,1,1,0,0,1}, {0,0,1,0,0,1,1}, {0,1,1,1,1,0,1}, - {0,1,0,0,0,1,1}, {0,1,1,0,0,0,1}, {0,1,0,1,1,1,1}, {0,1,1,1,0,1,1}, - {0,1,1,0,1,1,1}, {0,0,0,1,0,1,1} - }; - int data_left_even[10][7] = { - {0,1,0,0,1,1,1}, {0,1,1,0,0,1,1}, {0,0,1,1,0,1,1}, {0,1,0,0,0,0,1}, - {0,0,1,1,1,0,1}, {0,1,1,1,0,0,1}, {0,0,0,0,1,0,1}, {0,0,1,0,0,0,1}, - {0,0,0,1,0,0,1}, {0,0,1,0,1,1,1} - }; - int data_right[10][7] = { - {1,1,1,0,0,1,0}, {1,1,0,0,1,1,0}, {1,1,0,1,1,0,0}, {1,0,0,0,0,1,0}, - {1,0,1,1,1,0,0}, {1,0,0,1,1,1,0}, {1,0,1,0,0,0,0}, {1,0,0,0,1,0,0}, - {1,0,0,1,0,0,0}, {1,1,1,0,1,0,0} - }; - uint8 code[13+1]; - uint32 tmp_p=0; - int i, j; - int len; - - for(i=len=0;i<13;i++) - { - if(!rcode[i]) break; - - if((code[i]=rcode[i]-'0') > 9) - return(0); - len++; - } - if(len!=13 && len!=12 && len!=8 && len!=7) return(0); - - #define BS(x) BarcodeData[tmp_p]=x;tmp_p++ - - for(j=0;j<32;j++) - { - BS(0x00); - } - - /* Left guard bars */ - BS(1); BS(0); BS(1); - - if(len==13 || len==12) - { - uint32 csum; - - for(i=0;i<6;i++) - if(prefix_parity_type[code[0]][i]) - { - for(j=0;j<7;j++) - { - BS(data_left_even[code[i+1]][j]); - } - } - else - for(j=0;j<7;j++) - { - BS(data_left_odd[code[i+1]][j]); - } - - /* Center guard bars */ - BS(0); BS(1); BS(0); BS(1); BS(0); - - for(i=7;i<12;i++) - for(j=0;j<7;j++) - { - BS(data_right[code[i]][j]); - } - csum=0; - for(i=0;i<12;i++) csum+=code[i]*((i&1)?3:1); - csum=(10-(csum%10))%10; - //printf("%d\n",csum); - for(j=0;j<7;j++) - { - BS(data_right[csum][j]); - } - - } - else if(len==8 || len==7) - { - uint32 csum=0; - - for(i=0;i<7;i++) csum+=(i&1)?code[i]:(code[i]*3); - - csum=(10-(csum%10))%10; - - for(i=0;i<4;i++) - for(j=0;j<7;j++) - { - BS(data_left_odd[code[i]][j]); - } - - - /* Center guard bars */ - BS(0); BS(1); BS(0); BS(1); BS(0); - - for(i=4;i<7;i++) - for(j=0;j<7;j++) - { - BS(data_right[code[i]][j]); - } - - for(j=0;j<7;j++) - { BS(data_right[csum][j]);} - - } - - /* Right guard bars */ - BS(1); BS(0); BS(1); - - for(j=0;j<32;j++) - { - BS(0x00); - } - - BS(0xFF); - #undef BS - BarcodeReadPos=0; - BarcodeOut=0x8; - BarcodeCycleCount=0; - return(1); -} - -static void FP_FASTAPASS(1) BarcodeIRQHook(int a) -{ - BandaiIRQHook(a); - - BarcodeCycleCount+=a; - - if(BarcodeCycleCount >= 1000) - { - BarcodeCycleCount -= 1000; - if(BarcodeData[BarcodeReadPos]==0xFF) - { - BarcodeOut=0; - } - else - { - BarcodeOut=(BarcodeData[BarcodeReadPos]^1)<<3; - BarcodeReadPos++; - } - } -} - -static DECLFR(Mapper157_read) -{ - uint8 ret; - - ret=BarcodeOut; - return(ret); -} - -void Mapper157_init(void) -{ - FCEUGameInfo->cspecial = SIS_DATACH; - MapIRQHook=BarcodeIRQHook; - SetWriteHandler(0x6000,0xFFFF,Mapper16_write); - SetReadHandler(0x6000,0x7FFF,Mapper157_read); - - BarcodeData[0]=0xFF; - BarcodeReadPos=0; - BarcodeOut=0; - BarcodeCycleCount=0; -} diff --git a/source/mappers/17.c b/source/mappers/17.c deleted file mode 100644 index 182228c..0000000 --- a/source/mappers/17.c +++ /dev/null @@ -1,74 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -static void FP_FASTAPASS(1) FFEIRQHook(int a) -{ - if(IRQa) - { - IRQCount+=a; - - if(IRQCount>=0x10000) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - IRQCount=0; - } - } -} - - -DECLFW(Mapper17_write) -{ - switch(A){ - default: - break; - case 0x42FE: - onemir((V>>4)&1); - break; - case 0x42FF: - MIRROR_SET((V>>4)&1); - break; - case 0x4501:IRQa=V&1;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x4502:IRQCount&=0xFF00;IRQCount|=V;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x4503:IRQCount&=0x00FF;IRQCount|=V<<8;IRQa=1;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x4504: ROM_BANK8(0x8000,V);break; - case 0x4505: ROM_BANK8(0xA000,V);break; - case 0x4506: ROM_BANK8(0xC000,V);break; - case 0x4507: ROM_BANK8(0xE000,V);break; - case 0x4510: VROM_BANK1(0x0000,V);break; - case 0x4511: VROM_BANK1(0x0400,V);break; - case 0x4512: VROM_BANK1(0x0800,V);break; - case 0x4513: VROM_BANK1(0x0C00,V);break; - case 0x4514: VROM_BANK1(0x1000,V);break; - case 0x4515: VROM_BANK1(0x1400,V);break; - case 0x4516: VROM_BANK1(0x1800,V);break; - case 0x4517: VROM_BANK1(0x1C00,V);break; - } -} - -void Mapper17_init(void) -{ -MapIRQHook=FFEIRQHook; -SetWriteHandler(0x4020,0x5fff,Mapper17_write); -} diff --git a/source/mappers/18.c b/source/mappers/18.c deleted file mode 100644 index c4e03d2..0000000 --- a/source/mappers/18.c +++ /dev/null @@ -1,80 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define K4buf mapbyte2 -#define K4buf2 mapbyte3 - -void FP_FASTAPASS(1) JalecoIRQHook(int a) -{ - if(IRQa && IRQCount) - { - IRQCount-=a; - if(IRQCount<=0) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount=0; - IRQa=0; - } - } -} - -DECLFW(Mapper18_write) -{ - A&=0xF003; - if(A>=0x8000 && A<=0x9001) - { - int x=((A>>1)&1)|((A-0x8000)>>11); - - K4buf2[x]&=(0xF0)>>((A&1)<<2); - K4buf2[x]|=(V&0xF)<<((A&1)<<2); - ROM_BANK8(0x8000+(x<<13),K4buf2[x]); - } - else if(A>=0xa000 && A<=0xd003) - { - int x=((A>>1)&1)|((A-0xA000)>>11); - - K4buf[x]&=(0xF0)>>((A&1)<<2); - K4buf[x]|=(V&0xF)<<((A&1)<<2); - VROM_BANK1(x<<10,K4buf[x]); - } - else switch(A) - { - case 0xe000:IRQLatch&=0xFFF0;IRQLatch|=(V&0x0f);break; - case 0xe001:IRQLatch&=0xFF0F;IRQLatch|=(V&0x0f)<<4;break; - case 0xe002:IRQLatch&=0xF0FF;IRQLatch|=(V&0x0f)<<8;break; - case 0xe003:IRQLatch&=0x0FFF;IRQLatch|=(V&0x0f)<<12;break; - case 0xf000:IRQCount=IRQLatch; - break; - case 0xf001:IRQa=V&1; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xf002:MIRROR_SET2(V&1); - if(V&2) onemir(0); - break; - } -} - -void Mapper18_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper18_write); - MapIRQHook=JalecoIRQHook; -} diff --git a/source/mappers/180.c b/source/mappers/180.c deleted file mode 100644 index bd877c8..0000000 --- a/source/mappers/180.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "mapinc.h" - - - -DECLFW(Mapper180_write) -{ -ROM_BANK16(0xC000,V); -} - -void Mapper180_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper180_write); -} - diff --git a/source/mappers/182.c b/source/mappers/182.c deleted file mode 100644 index e0b8991..0000000 --- a/source/mappers/182.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "mapinc.h" - -static DECLFW(Mapper182_write) -{ - switch(A&0xf003) - { - case 0xe003:IRQCount=V;IRQa=1;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x8001:MIRROR_SET(V&1);break; - case 0xA000:mapbyte1[0]=V;break; - case 0xC000: - switch(mapbyte1[0]&7) - { - case 0:VROM_BANK2(0x0000,V>>1);break; - case 1:VROM_BANK1(0x1400,V);break; - case 2:VROM_BANK2(0x0800,V>>1);break; - case 3:VROM_BANK1(0x1c00,V);break; - case 4:ROM_BANK8(0x8000,V);break; - case 5:ROM_BANK8(0xA000,V);break; - case 6:VROM_BANK1(0x1000,V);break; - case 7:VROM_BANK1(0x1800,V);break; - } - break; - - - } -} - -void blop(void) -{ - if(IRQa) - { - if(IRQCount) - { - IRQCount--; - if(!IRQCount) - { - IRQa=0; - X6502_IRQBegin(FCEU_IQEXT); - } - } - } -} -void Mapper182_init(void) -{ - SetWriteHandler(0x8000,0xFFFF,Mapper182_write); - GameHBIRQHook=blop; -} - diff --git a/source/mappers/184.c b/source/mappers/184.c deleted file mode 100644 index 70fd6b1..0000000 --- a/source/mappers/184.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "mapinc.h" - - - -DECLFW(Mapper184_write) -{ -VROM_BANK4(0x0000,V); -VROM_BANK4(0x1000,(V>>4)); -} - -void Mapper184_init(void) -{ - SetWriteHandler(0x6000,0xffff,Mapper184_write); -} - diff --git a/source/mappers/187.c b/source/mappers/187.c deleted file mode 100644 index 25a4422..0000000 --- a/source/mappers/187.c +++ /dev/null @@ -1,162 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint8 LastWr; -static uint8 ExtMode; -static uint8 cmd; -static uint8 DRegs[8]; -static uint32 count=0; -static uint32 last=0; -static int safe=0; -static uint8 poofish; - -static void Sync(void) -{ - int x; - uint32 base=0; - - if(cmd&0x80) base=0x1000; - setchr2(0x0000^base,(0x100|DRegs[0])>>1); - setchr2(0x0800^base,(0x100|DRegs[1])>>1); - for(x=0;x<4;x++) - setchr1((0x1000^base)+x*0x400,DRegs[2+x]); - - if(ExtMode&0x80) - { - if(ExtMode&0x20) - setprg32(0x8000,(ExtMode&0x1F)>>1); - else - { - setprg16(0x8000,(ExtMode&0x1F)); - setprg16(0xc000,(ExtMode&0x1F)); - } - } - else - { - setprg8(0x8000,DRegs[6]); - setprg8(0xc000,~1); - setprg8(0xa000,DRegs[7]); - setprg8(0xe000,~0); - } -} - -static DECLFW(M187Write) -{ - LastWr=V; - if(A==0x5000) - ExtMode=V; - Sync(); -} - -static DECLFW(M187HWrite) -{ - //if(A==0x8003 && X.PC<0x800) FCEUI_DumpMem("dmp",0x0000,0xFFFF); - //printf("$%04x:$%02x, %04x\n",A,V,X.PC); - LastWr=V; - - if(A==0x8003) - { - if(V==0x28 || V==0x2A) - poofish=V; - } - else if(A==0x8000) poofish=0; - - switch(A) - { - case 0xc000:IRQLatch=IRQCount=V;break; - case 0xc001:IRQCount=IRQLatch;last=count=0;break; - case 0xe000:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xe001:IRQa=1;break; - case 0xa000:MIRROR_SET(V&1);break; - - case 0x8000:cmd=V;safe=1;break; - case 0x8001: - if(safe) - { - //printf("Cmd: %d, %02x, %04x\n",cmd&0x7,V,X.PC); - DRegs[cmd&7]=V; - Sync(); - safe=0; - } - if(poofish==0x28) setprg8(0xc000,0x17); - break; - - } -} - -static DECLFR(ProtRead) -{ - switch(LastWr&0x3) - { - case 0x1: - case 0x0: return(0x80); - case 0x2: return(0x42); - } - return(0); -} - -static void M187Power(void) -{ - SetWriteHandler(0x5000,0x5fff,M187Write); - SetWriteHandler(0x8000,0xFFFF,M187HWrite); - SetReadHandler(0x5000,0x5FFF,ProtRead); - SetWriteHandler(0x6000,0x7FFF,M187Write); - SetReadHandler(0x8000,0xffff,CartBR); - Sync(); -} - -static void sl(void) -{ - if(IRQa) - { - if(IRQCount>=0) - { - IRQCount--; - if(IRQCount<0) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } - } -} - -static void FP_FASTAPASS(1) foo(uint32 A) -{ - if((A&0x2000) && !(last&0x2000)) - { - count++; - if(count==42) - { - sl(); - count=0; - } - } - last=A; -} - -void Mapper187_Init(CartInfo *info) -{ - info->Power=M187Power; - //GameHBIRQHook=sl; - PPU_hook=foo; -} - diff --git a/source/mappers/189.c b/source/mappers/189.c deleted file mode 100644 index 8750d3e..0000000 --- a/source/mappers/189.c +++ /dev/null @@ -1,55 +0,0 @@ -/* Is this an MMC3 workalike piece of hardware, with the addition of - a register at $4120 or does it have only partial MMC3 functionality? - A good test would be to see if commands 6 and 7 can change PRG banks - and of course test the regs >=$c000, on the real cart. -*/ -#include "mapinc.h" - -#define cmd mapbyte1[0] -static DECLFW(Mapper189_write) -{ - //if(A>=0xc000) printf("$%04x:$%02x\n",A,V); - if((A&0xF100)==0x4100) ROM_BANK32(V>>4); - else if((A&0xF100)==0x6100) ROM_BANK32(V&3); - else switch(A&0xE001) - { - case 0xa000:MIRROR_SET(V&1);break; - case 0x8000:cmd=V;break; - case 0x8001:switch(cmd&7) - { - case 0:VROM_BANK2(0x0000,V>>1);break; - case 1:VROM_BANK2(0x0800,V>>1);break; - case 2:VROM_BANK1(0x1000,V);break; - case 3:VROM_BANK1(0x1400,V);break; - case 4:VROM_BANK1(0x1800,V);break; - case 5:VROM_BANK1(0x1C00,V);break; - } - case 0xc000:IRQLatch=V;break; - case 0xc001:IRQCount=IRQLatch;break; - case 0xe000:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xe001:IRQa=1;break; - break; - - } -} -void m189irq(void) -{ - if(IRQa) - { - if(IRQCount) - { - IRQCount--; - if(!IRQCount) X6502_IRQBegin(FCEU_IQEXT); - } - } - -} -void Mapper189_init(void) -{ - GameHBIRQHook=m189irq; - SetWriteHandler(0x4120,0xFFFF,Mapper189_write); - SetReadHandler(0x6000,0x7FFF,0); - ROM_BANK32(0); -} - - diff --git a/source/mappers/193.c b/source/mappers/193.c deleted file mode 100644 index 0afa247..0000000 --- a/source/mappers/193.c +++ /dev/null @@ -1,20 +0,0 @@ -#include "mapinc.h" - -static DECLFW(m193w) -{ - //printf("$%04x:$%02x\n",A,V); - switch(A&3) - { - case 0:VROM_BANK4(0x0000,V>>2);break; - case 1:VROM_BANK2(0x1000,V>>1);break; - case 2:VROM_BANK2(0x1800,V>>1);break; - case 3:ROM_BANK8(0x8000,V);break; - } -} - -void Mapper193_init(void) -{ - ROM_BANK32(~0); - SetWriteHandler(0x4018,0x7fff,m193w); - SetReadHandler(0x4018,0x7fff,0); -} diff --git a/source/mappers/200.c b/source/mappers/200.c deleted file mode 100644 index ec13308..0000000 --- a/source/mappers/200.c +++ /dev/null @@ -1,36 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static DECLFW(Mapper200_write) -{ -// FCEU_printf("%04x, %02x\n",A,V); - ROM_BANK16(0x8000,A&0x07); - ROM_BANK16(0xC000,A&0x07); - VROM_BANK8(A&0x07); - MIRROR_SET((A&0x08)>>3); -} - -void Mapper200_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper200_write); -} - diff --git a/source/mappers/201.c b/source/mappers/201.c deleted file mode 100644 index 90be429..0000000 --- a/source/mappers/201.c +++ /dev/null @@ -1,44 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static DECLFW(Mapper201_write) -{ -// FCEU_printf("%04x, %02x\n",A,V); - if (A&0x08) - { - ROM_BANK32(A&0x03); - VROM_BANK8(A&0x03); - } - else - { - ROM_BANK32(0); - VROM_BANK8(0); - } -} - -void Mapper201_init(void) -{ - ROM_BANK32(0); - VROM_BANK8(0); - SetWriteHandler(0x8000,0xffff,Mapper201_write); -} - diff --git a/source/mappers/202.c b/source/mappers/202.c deleted file mode 100644 index cac2a88..0000000 --- a/source/mappers/202.c +++ /dev/null @@ -1,39 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static DECLFW(Mapper202_write) -{ - int tmp=(A>>1)&0x7; - - MIRROR_SET(A&1); - ROM_BANK16(0x8000,tmp); - ROM_BANK16(0xc000,tmp+(((tmp&0x6)==0x6)?1:0)); - VROM_BANK8(tmp); -} - -void Mapper202_init(void) -{ - ROM_BANK16(0x8000,0); - ROM_BANK16(0xc000,0); - VROM_BANK8(0); - SetWriteHandler(0x8000,0xFFFF,Mapper202_write); -} diff --git a/source/mappers/203.c b/source/mappers/203.c deleted file mode 100644 index 6ab5d52..0000000 --- a/source/mappers/203.c +++ /dev/null @@ -1,36 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static DECLFW(Mapper203_write) -{ - ROM_BANK16(0x8000,(V>>2)&3); - ROM_BANK16(0xc000,(V>>2)&3); - VROM_BANK8(V&3); -} - -void Mapper203_init(void) -{ - ROM_BANK16(0x8000,0); - ROM_BANK16(0xc000,0); - VROM_BANK8(0); - SetWriteHandler(0x8000,0xFFFF,Mapper203_write); -} diff --git a/source/mappers/208.c b/source/mappers/208.c deleted file mode 100644 index 7780392..0000000 --- a/source/mappers/208.c +++ /dev/null @@ -1,139 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint8 PRGSel; -static uint8 PBuf[4],PSel; -static uint8 cmd; -static uint8 DRegs[8]; -static uint32 count=0; -static uint32 last=0; - -static DECLFW(M208Write1) -{ - PRGSel=(V&0x1)|((V>>3)&0x2); - setprg32(0x8000,PRGSel); -} - -static DECLFW(M208Write2) -{ - static uint8 lut[256]={ - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01, - 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x10, 0x40, 0x50, 0x00, 0x10, 0x40, 0x50,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x18, 0x48, 0x58, 0x08, 0x18, 0x48, 0x58,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x58, 0x48, 0x18, 0x08, 0x58, 0x48, 0x18, 0x08, - 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59,0x50, 0x40, 0x10, 0x00, 0x50, 0x40, 0x10, 0x00, - 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x11, 0x41, 0x51, 0x01, 0x11, 0x41, 0x51,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x09, 0x19, 0x49, 0x59, 0x09, 0x19, 0x49, 0x59,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - - }; - if(A<=0x57FF) PSel=V; - else - PBuf[(A&0x03)]=V^lut[PSel]; -} - -static DECLFR(M208Read) -{ - return(PBuf[(A&0x3)]); -} - -static void Sync(void) -{ - int x; - - setchr2(0x0000,DRegs[0]>>1); - setchr2(0x0800,DRegs[1]>>1); - for(x=0;x<4;x++) - setchr1(0x1000+x*0x400,DRegs[2+x]); -} - -static DECLFW(M208HWrite) -{ - switch(A&0xe001) - { - case 0xc000:IRQLatch=IRQCount=V;break; - case 0xc001:IRQCount=IRQLatch;last=count=0;break; - case 0xe000:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xe001:IRQa=1;break; - case 0x8000:cmd=V;break; - case 0x8001:DRegs[cmd&7]=V; - Sync(); - break; - - } -} - -static void M208Power(void) -{ - PRGSel=3; - setprg32(0x8000,3); - SetWriteHandler(0x4800,0x4FFF,M208Write1); - SetWriteHandler(0x5000,0x5fff,M208Write2); - SetWriteHandler(0x8000,0xFFFF,M208HWrite); - SetReadHandler(0x5800,0x5FFF,M208Read); - SetReadHandler(0x8000,0xffff,CartBR); -} - -static void sl(void) -{ - if(IRQa) - { - if(IRQCount>=0) - { - IRQCount--; - if(IRQCount<0) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } - } -} - -static void FP_FASTAPASS(1) foo(uint32 A) -{ - if((A&0x2000) && !(last&0x2000)) - { - count++; - if(count==42) - { - sl(); - count=0; - } - } - last=A; -} - -void Mapper208_Init(CartInfo *info) -{ - info->Power=M208Power; - //GameHBIRQHook=sl; - PPU_hook=foo; -} - diff --git a/source/mappers/21.c b/source/mappers/21.c deleted file mode 100644 index 85aac16..0000000 --- a/source/mappers/21.c +++ /dev/null @@ -1,106 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define K4buf mapbyte2 -#define K4IRQ mapbyte1[1] -#define K4sel mapbyte1[0] - -static int acount=0; - -DECLFW(Mapper21_write) -{ - A|=((A>>5)&0xF); - - if((A&0xF000)==0xA000) - ROM_BANK8(0xA000,V); - else if((A&0xF000)==0x8000) - { - if(K4sel&2) - ROM_BANK8(0xC000,V); - else - ROM_BANK8(0x8000,V); - } - else if(A>=0xb000 && A<=0xefff) - { - A&=0xF006; - { - int x=((A>>2)&1)|((A-0xB000)>>11); - - K4buf[x]&=(0xF0)>>((A&2)<<1); - K4buf[x]|=(V&0xF)<<((A&2)<<1); - VROM_BANK1(x<<10,K4buf[x]); - } - - } - else switch(A&0xF006) - { - case 0x9000: - switch(V&0x3) - { - case 0:MIRROR_SET(0);break; - case 1:MIRROR_SET(1);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - break; - case 0x9006: - case 0x9004: - case 0x9002:if((K4sel&2)!=(V&2)) - { - uint8 swa; - swa=PRGBankList[0]; - ROM_BANK8(0x8000,PRGBankList[2]); - ROM_BANK8(0xc000,swa); - } - K4sel=V; - break; - case 0xf000:IRQLatch&=0xF0;IRQLatch|=V&0xF;break; - case 0xf002:IRQLatch&=0x0F;IRQLatch|=V<<4;break; - case 0xf004:IRQCount=IRQLatch;acount=0; - IRQa=V&2;K4IRQ=V&1; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xf006:IRQa=K4IRQ;X6502_IRQEnd(FCEU_IQEXT);break; - } -} -static void FP_FASTAPASS(1) KonamiIRQHook(int a) -{ - #define LCYCS ((227*2)+1) - //#define LCYCS 341 - if(IRQa) - { -// acount+=a*3; - acount+=a*4; - if(acount>=LCYCS) - { - doagainbub:acount-=LCYCS;IRQCount++; - if(IRQCount&0x100) {X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch;} - if(acount>=LCYCS) goto doagainbub; - } - } -} - -void Mapper21_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper21_write); - MapIRQHook=KonamiIRQHook; -} diff --git a/source/mappers/22.c b/source/mappers/22.c deleted file mode 100644 index 00089b4..0000000 --- a/source/mappers/22.c +++ /dev/null @@ -1,63 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define K4buf mapbyte2 - - - -DECLFW(Mapper22_write) -{ - if(A<=0xAFFF) - { - switch(A&0xF000) - { - case 0x8000:ROM_BANK8(0x8000,V);break; - case 0xa000:ROM_BANK8(0xA000,V);break; - case 0x9000:switch(V&3) - { - case 0x00:MIRROR_SET2(1);break; - case 0x01:MIRROR_SET2(0);break; - case 0x02:onemir(0);break; - case 0x03:onemir(1);break; - } - break; - } - } - else - { - A&=0xF003; - if(A>=0xb000 && A<=0xe003) - { - int x=(A&1)|((A-0xB000)>>11); - - K4buf[x]&=(0xF0)>>((A&2)<<1); - K4buf[x]|=(V&0xF)<<((A&2)<<1); - VROM_BANK1(x<<10,K4buf[x]>>1); - } - } -} - - -void Mapper22_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper22_write); -} diff --git a/source/mappers/225.c b/source/mappers/225.c deleted file mode 100644 index 14e38f2..0000000 --- a/source/mappers/225.c +++ /dev/null @@ -1,87 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -#define reg1 mapbyte1[0] -#define reg2 mapbyte1[1] -#define reg3 mapbyte1[2] -#define reg4 mapbyte1[3] - -DECLFR(A110in1read) -{ -switch(A&0x3) - { - case 0:return reg1;break; - case 1:return reg2;break; - case 2:return reg3;break; - case 3:return reg4;break; - } -return 0xF; -} -DECLFW(A110in1regwr) -{ -switch(A&0x3) - { - case 0:reg1=V&0xF;break; - case 1:reg2=V&0xF;break; - case 2:reg3=V&0xF;break; - case 3:reg4=V&0xF;break; - } -} - -DECLFW(Mapper225_write) -{ - int banks=0; - - MIRROR_SET((A>>13)&1); - if(A&0x4000) - banks=1; - else - banks=0; - - VROM_BANK8(((A&0x003f)+(banks<<6))); - if(A&0x1000) - { - if(A&0x40) - { - ROM_BANK16(0x8000,((((((A>>7)&0x1F)+(banks<<5)))<<1)+1)); - ROM_BANK16(0xC000,((((((A>>7)&0x1F)+(banks<<5)))<<1)+1)); - } - else - { - ROM_BANK16(0x8000,(((((A>>7)&0x1F)+(banks<<5)))<<1)); - ROM_BANK16(0xC000,(((((A>>7)&0x1F)+(banks<<5)))<<1)); - } - } - else - { - ROM_BANK32(((((A>>7)&0x1F)+(banks<<5)))); - } -} - -void Mapper225_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper225_write); - SetReadHandler(0x5800,0x5fff,A110in1read); - SetWriteHandler(0x5800,0x5fff,A110in1regwr); -} - diff --git a/source/mappers/226.c b/source/mappers/226.c deleted file mode 100644 index 6468052..0000000 --- a/source/mappers/226.c +++ /dev/null @@ -1,105 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define rg mapbyte1 -static void DoPRG(void) -{ - int32 b=((rg[0]>>1)&0xF) | ((rg[0]>>3)&0x10) | ((rg[1]&1)<<5); - if(rg[0]&0x20) // 16 KB - { - ROM_BANK16(0x8000,(b<<1)|(rg[0]&1)); - ROM_BANK16(0xC000,(b<<1)|(rg[0]&1)); - } - else - ROM_BANK32(b); -} - -static DECLFW(Mapper226_write) -{ - rg[A&1]=V; - DoPRG(); - if(A&1) - { - if(rg[1]&2) - PPUCHRRAM=0; // Write protected. - else - PPUCHRRAM=0xFF; // Not write protected. - } - else - MIRROR_SET2((rg[0]>>6)&1); -} - -static void M26Reset(void) -{ - rg[0]=rg[1]=0; - DoPRG(); - PPUCHRRAM=0xFF; - MIRROR_SET2(0); -} - -static void M26Restore(int version) -{ - DoPRG(); - if(rg[1]&2) - PPUCHRRAM=0; // Write protected. - else - PPUCHRRAM=0xFF; // Not write protected. - MIRROR_SET2((rg[0]>>6)&1); -} - -void Mapper226_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper226_write); - MapperReset=M26Reset; - GameStateRestore=M26Restore; - M26Reset(); -} - -#ifdef OLD // What the heck is this?? -DECLFW(Mapper226_write) -{ - MIRROR_SET((A>>13)&1); - VROM_BANK8(A&0x7F); - if(A&0x1000) - { - if(A&0x40) - { - ROM_BANK16(0x8000,(((A>>7))<<1)+1); - ROM_BANK16(0xC000,(((A>>7))<<1)+1); - } - else - { - ROM_BANK16(0x8000,(((A>>7))<<1)); - ROM_BANK16(0xC000,(((A>>7))<<1)); - } - } - else - { - ROM_BANK32(A>>7); - } -} - -void Mapper226_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper226_write); -} -#endif diff --git a/source/mappers/227.c b/source/mappers/227.c deleted file mode 100644 index 6ddb57b..0000000 --- a/source/mappers/227.c +++ /dev/null @@ -1,79 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define rg mapbyte1 - -static void DoSync(uint32 A) -{ - int32 p=((A>>3)&0xF) | ((A>>4)&0x10); - - rg[0]=A; - rg[1]=A>>8; - - MIRROR_SET((A>>1)&1); - if(A&1) //32 KB - { - ROM_BANK32(p); - } - else //16 KB - { - ROM_BANK16(0x8000,(p<<1)|((A&4)>>2)); - ROM_BANK16(0xc000,(p<<1)|((A&4)>>2)); - } - if(A&0x80) - { - PPUCHRRAM=0; - } - else - { - PPUCHRRAM=0xFF; - if(A&0x200) - ROM_BANK16(0xC000,(p<<1)|7); - else - ROM_BANK16(0xC000,(p<<1)&(~7)); - } -} - -static DECLFW(Mapper227_write) -{ - rg[A&1]=V; - DoSync(A); -} - -static void M227Reset(void) -{ - rg[0]=rg[1]=0; - DoSync(0); -} - -static void M227Restore(int version) -{ - DoSync(rg[0]|(rg[1]<<8)); -} - -void Mapper227_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper227_write); - MapperReset=M227Reset; - GameStateRestore=M227Restore; - M227Reset(); -} diff --git a/source/mappers/228.c b/source/mappers/228.c deleted file mode 100644 index bfae3a6..0000000 --- a/source/mappers/228.c +++ /dev/null @@ -1,53 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static DECLFW(Mapper228_write) -{ - uint32 page,pagel,pageh; - - MIRROR_SET((A>>13)&1); - - page=(A>>7)&0x3F; - //printf("%04x\n",A); - if((page&0x30)==0x30) - page-=0x10; - - pagel=pageh=(page<<1) + (((A>>6)&1)&((A>>5)&1)); - pageh+=((A>>5)&1)^1; - - ROM_BANK16(0x8000,pagel); - ROM_BANK16(0xC000,pageh); - VROM_BANK8( (V&0x3) | ((A&0xF)<<2) ); -} - -static void A52Reset(void) -{ - Mapper228_write(0,0); -} - -void Mapper228_init(void) -{ - MapperReset=A52Reset; - A52Reset(); - SetWriteHandler(0x8000,0xffff,Mapper228_write); -} - diff --git a/source/mappers/229.c b/source/mappers/229.c deleted file mode 100644 index a78dd73..0000000 --- a/source/mappers/229.c +++ /dev/null @@ -1,48 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -DECLFW(Mapper229_write) -{ -if(A>=0x8000) -{ -MIRROR_SET((A>>5)&1); -if(!(A&0x1e)) - { - ROM_BANK32(0); - } -else - { - ROM_BANK16(0x8000,A&0x1f); - ROM_BANK16(0xC000,A&0x1f); - } - VROM_BANK8(A); -} - -} - -void Mapper229_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper229_write); -} - diff --git a/source/mappers/23.c b/source/mappers/23.c deleted file mode 100644 index a8c0fe8..0000000 --- a/source/mappers/23.c +++ /dev/null @@ -1,102 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define K4buf mapbyte2 -#define K4IRQ mapbyte1[1] -#define K4sel mapbyte1[0] -static int acount=0; -static DECLFW(Mapper23_write) -{ - if((A&0xF000)==0x8000) - { - if(K4sel&2) - ROM_BANK8(0xC000,V); - else - ROM_BANK8(0x8000,V); - } - else if((A&0xF000)==0xA000) - ROM_BANK8(0xA000,V); - else - { - A|=((A>>2)&0x3)|((A>>4)&0x3)|((A>>6)&0x3); - A&=0xF003; - if(A>=0xb000 && A<=0xe003) - { - int x=((A>>1)&1)|((A-0xB000)>>11); - - K4buf[x]&=(0xF0)>>((A&1)<<2); - K4buf[x]|=(V&0xF)<<((A&1)<<2); - VROM_BANK1(x<<10,K4buf[x]); - } - else - switch(A) - { - case 0xf000:X6502_IRQEnd(FCEU_IQEXT);IRQLatch&=0xF0;IRQLatch|=V&0xF;break; - case 0xf001:X6502_IRQEnd(FCEU_IQEXT);IRQLatch&=0x0F;IRQLatch|=V<<4;break; - case 0xf002:X6502_IRQEnd(FCEU_IQEXT);acount=0;IRQCount=IRQLatch;IRQa=V&2;K4IRQ=V&1;break; - case 0xf003:X6502_IRQEnd(FCEU_IQEXT);IRQa=K4IRQ;break; - case 0x9001: - case 0x9002: - case 0x9003: - if((K4sel&2)!=(V&2)) - { - uint8 swa; - swa=PRGBankList[0]; - ROM_BANK8(0x8000,PRGBankList[2]); - ROM_BANK8(0xc000,swa); - } - K4sel=V; - break; - case 0x9000: - switch(V&0x3) - { - case 0:MIRROR_SET(0);break; - case 1:MIRROR_SET(1);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - break; - } - } -} - -void FP_FASTAPASS(1) KonamiIRQHook2(int a) -{ - #define LCYCS 341 - if(IRQa) - { - acount+=a*3; - if(acount>=LCYCS) - { - doagainbub:acount-=LCYCS;IRQCount++; - if(IRQCount&0x100) {X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch;} - if(acount>=LCYCS) goto doagainbub; - } - } -} - -void Mapper23_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper23_write); - MapIRQHook=KonamiIRQHook2; -} - diff --git a/source/mappers/230.c b/source/mappers/230.c deleted file mode 100644 index 3786d65..0000000 --- a/source/mappers/230.c +++ /dev/null @@ -1,62 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define rom_sw mapbyte1[0] - -void Mapper230_Reset(void) -{ - rom_sw ^= 1; //1 - rom_sw; - - if( rom_sw ) { - ROM_BANK16(0x8000,0); - ROM_BANK16(0xc000,7); - } else { - ROM_BANK16(0x8000,8); - ROM_BANK16(0xc000,39); - } - MIRROR_SET2(1); -} - -static DECLFW(Mapper230_write) -{ - if( rom_sw ) { - ROM_BANK16( 0x8000, V&0x07 ); - } else { - if( V & 0x20 ) { - ROM_BANK16( 0x8000, (V&0x1F)+8 ); - ROM_BANK16( 0xc000, (V&0x1F)+8 ); - } else { - ROM_BANK32( ((V&0x1E) >> 1) + 4 ); - } - MIRROR_SET2( ((V & 0x40) >> 6) ); - } -} - -void Mapper230_init(void) -{ - ROM_BANK16(0x8000,0); - ROM_BANK16(0xc000,7); - SetWriteHandler(0x8000, 0xffff, Mapper230_write); - MapperReset = Mapper230_Reset; - rom_sw = 1; -} - diff --git a/source/mappers/231.c b/source/mappers/231.c deleted file mode 100644 index 9b8d1fc..0000000 --- a/source/mappers/231.c +++ /dev/null @@ -1,41 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static DECLFW(Mapper231_write) -{ - if(A&0x20) - ROM_BANK32((A>>1)&0xF); - else - { - ROM_BANK16(0x8000,(A&0x1E)); - ROM_BANK16(0xc000,(A&0x1E)); - } - MIRROR_SET((A>>7)&1); -} - -void Mapper231_init(void) -{ - ROM_BANK16(0x8000,0); - ROM_BANK16(0xc000,0); - SetWriteHandler(0x8000,0xffff,Mapper231_write); -} - diff --git a/source/mappers/232.c b/source/mappers/232.c deleted file mode 100644 index 83c1b8e..0000000 --- a/source/mappers/232.c +++ /dev/null @@ -1,50 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static void DoIt(void) -{ - ROM_BANK16(0x8000,(mapbyte1[1]&3) | ((mapbyte1[0]&0x18)>>1)); - ROM_BANK16(0xc000,3|(((mapbyte1[0])&0x18)>>1)); -} - -DECLFW(Mapper232_write) -{ - if(A<=0x9FFF) - mapbyte1[0]=V; - else - mapbyte1[1]=V; - DoIt(); -} - -static void QuattroReset(void) -{ - mapbyte1[0]=0x18; - DoIt(); -} - -void Mapper232_init(void) -{ - SetWriteHandler(0x6000,0xffff,Mapper232_write); - MapperReset=QuattroReset; - QuattroReset(); -} - diff --git a/source/mappers/234.c b/source/mappers/234.c deleted file mode 100644 index 163dd44..0000000 --- a/source/mappers/234.c +++ /dev/null @@ -1,107 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define r1 mapbyte1[0] -#define r2 mapbyte1[1] - -static void DoBS(void) -{ - if(r1&0x40) - { - ROM_BANK32((r1&0xE)|(r2&1)); - VROM_BANK8( ((r1&0xE)<<2) | ((r2>>4)&7) ); - } - else - { - ROM_BANK32(r1&0xF); - VROM_BANK8( ((r1&0xF)<<2) | ((r2>>4)&3) ); - } -} - -static void R1Set(uint8 V) -{ - if(r1) return; - r1=V; - MIRROR_SET(V>>7); - DoBS(); -} - -static void R2Set(uint8 V) -{ - r2=V; - DoBS(); -} - -DECLFW(R1W) -{ - R1Set(V); -} - -DECLFR(R1R) -{ - uint8 r=CartBR(A); - R1Set(r); - return r; -} - -DECLFW(R2W) -{ - R2Set(V); -} - -DECLFR(R2R) -{ - uint8 r=CartBR(A); - R2Set(r); - return r; -} - -static void M15Restore(int version) -{ - DoBS(); - MIRROR_SET(r1>>7); -} - -static void M15Reset(void) -{ - r1=r2=0; - DoBS(); - MIRROR_SET(0); -} - -void Mapper234_init(void) -{ - SetWriteHandler(0xff80,0xff9f,R1W); - SetReadHandler(0xff80,0xff9f,R1R); - - SetWriteHandler(0xffe8,0xfff7,R2W); - SetReadHandler(0xffe8,0xfff7,R2R); - - SetReadHandler(0x6000,0x7FFF,0); - SetWriteHandler(0x6000,0x7FFF,0); - - M15Reset(); - - GameStateRestore=M15Restore; - MapperReset=M15Reset; -} - diff --git a/source/mappers/235.c b/source/mappers/235.c deleted file mode 100644 index 57f54ad..0000000 --- a/source/mappers/235.c +++ /dev/null @@ -1,53 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static DECLFW(Mapper235_write) -{ - uint32 m; - int z; - - if(A&0x400) - onemir(0); - else - setmirror(((A>>13)&1)^1); - m=A&0x1f; - - z=(A>>8)&3; - - if(A&0x800) - { - setprg16r(0x10|z,0x8000,(m<<1)|((A>>12)&1)); - setprg16r(0x10|z,0xC000,(m<<1)|((A>>12)&1)); - } - else - setprg32r(0x10|z,0x8000,m); -} - -void Mapper235_init(void) -{ - /* Fixme: Possible crashy bug if header is bad. */ - SetupCartPRGMapping(0x10,PRGptr[0],1024*1024,0); - SetupCartPRGMapping(0x12,PRGptr[0]+1024*1024,1024,0); - setprg32r(0x10,0x8000,0); - SetReadHandler(0x8000,0xffff,CartBROB); - SetWriteHandler(0x8000,0xffff,Mapper235_write); -} diff --git a/source/mappers/240.c b/source/mappers/240.c deleted file mode 100644 index dbbfe19..0000000 --- a/source/mappers/240.c +++ /dev/null @@ -1,39 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -DECLFW(Mapper240_write) -{ - if(A<0x8000) - { - ROM_BANK32(V>>4); - VROM_BANK8(V&0xF); - } -} - -void Mapper240_init(void) -{ - SetWriteHandler(0x4020,0x5fff,Mapper240_write); - SetWriteHandler(0x8000,0xffff,Mapper240_write); -} - diff --git a/source/mappers/241.c b/source/mappers/241.c deleted file mode 100644 index 967f2b0..0000000 --- a/source/mappers/241.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "mapinc.h" - -static DECLFW(M241wr) -{ - if(A<0x8000) - { - // printf("$%04x:$%02x, $%04x\n",A,V,X.PC); - } - else - ROM_BANK32(V); -} - -static DECLFR(M241rd) -{ - //DumpMem("out",0x8000,0xffff); - //printf("Rd: $%04x, $%04x\n",A,X.PC); - return(0x50); -} - -void Mapper241_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x5000,0x5fff,M241wr); - SetWriteHandler(0x8000,0xFFFF,M241wr); - SetReadHandler(0x4020,0x5fff,M241rd); -} diff --git a/source/mappers/242.c b/source/mappers/242.c deleted file mode 100644 index aec4eba..0000000 --- a/source/mappers/242.c +++ /dev/null @@ -1,41 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -DECLFW(Mapper242_write) -{ - ROM_BANK32((A>>3)&0xF); - switch(V&3) - { - case 0:MIRROR_SET(0);break; - case 1:MIRROR_SET(1);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } -} - -void Mapper242_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x8000,0xffff,Mapper242_write); -} - diff --git a/source/mappers/244.c b/source/mappers/244.c deleted file mode 100644 index 13ea2c1..0000000 --- a/source/mappers/244.c +++ /dev/null @@ -1,38 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static DECLFW(Mapper244_write_1) -{ - ROM_BANK32((A-0x8065)&0x03); -} - -static DECLFW(Mapper244_write_2) -{ - VROM_BANK8((A-0x80A5)&0x07); -} - -void Mapper244_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x8065,0x80a4,Mapper244_write_1); - SetWriteHandler(0x80a5,0x80e4,Mapper244_write_2); -} diff --git a/source/mappers/246.c b/source/mappers/246.c deleted file mode 100644 index 8623233..0000000 --- a/source/mappers/246.c +++ /dev/null @@ -1,44 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -DECLFW(Mapper246_write) -{ - switch(A&0xF007) - { - case 0x6000:ROM_BANK8(0x8000,V);break; - case 0x6001:ROM_BANK8(0xA000,V);break; - case 0x6002:ROM_BANK8(0xC000,V);break; - case 0x6003:ROM_BANK8(0xE000,V);break; - case 0x6004:VROM_BANK2(0x0000,V);break; - case 0x6005:VROM_BANK2(0x0800,V);break; - case 0x6006:VROM_BANK2(0x1000,V);break; - case 0x6007:VROM_BANK2(0x1800,V);break; - } -} - -void Mapper246_init(void) -{ - SetWriteHandler(0x4020,0x67ff,Mapper246_write); - SetWriteHandler(0x8000,0xffff,Mapper246_write); -} - diff --git a/source/mappers/248.c b/source/mappers/248.c deleted file mode 100644 index 9615c82..0000000 --- a/source/mappers/248.c +++ /dev/null @@ -1,90 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define cmd mapbyte1[0] -#define lpa mapbyte1[1] -#define prgl mapbyte2 - -static void PRGSynco(void) -{ - if(lpa&0x80) - { - ROM_BANK16(0x8000,lpa&0xF); - } - else - { - ROM_BANK8(0x8000,prgl[0]&0x1F); - ROM_BANK8(0xa000,prgl[1]&0x1F); - } -} - -static DECLFW(Mapper248_writelow) -{ - lpa=V; - PRGSynco(); -} - -static DECLFW(Mapper248_write) -{ - switch(A&0xF001) - { - case 0xa000:MIRROR_SET(V&1);break; // Not sure if this is right. Mirroring may be hard wired... - case 0xc000:IRQLatch=V;break; - case 0xc001:IRQCount=IRQLatch;break; - case 0xe000:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xe001:IRQa=1;break; - case 0x8000:cmd=V;break; - case 0x8001:switch(cmd&7) - { - case 0:VROM_BANK2(0x000,V>>1);break; - case 1:VROM_BANK2(0x800,V>>1);break; - case 2:VROM_BANK1(0x1000,V);break; - case 3:VROM_BANK1(0x1400,V);break; - case 4:VROM_BANK1(0x1800,V);break; - case 5:VROM_BANK1(0x1c00,V);break; - case 6:prgl[0]=V;PRGSynco();break; - case 7:prgl[1]=V;PRGSynco();break; - } - break; - } -} - -static void Mapper248_hb(void) -{ - if(IRQa) - { - IRQCount--; - if(IRQCount<0) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount=IRQLatch; - } - } -} - -void Mapper248_init(void) -{ - SetWriteHandler(0x6000,0x6fff,Mapper248_writelow); - SetWriteHandler(0x8000,0xffff,Mapper248_write); - GameHBIRQHook=Mapper248_hb; -} - diff --git a/source/mappers/24and26.c b/source/mappers/24and26.c deleted file mode 100644 index 9c58b3c..0000000 --- a/source/mappers/24and26.c +++ /dev/null @@ -1,369 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static void (*sfun[3])(void); - -#define vrctemp mapbyte1[0] -#define VPSG2 mapbyte3 -#define VPSG mapbyte2 - -static void DoSQV1(void); -static void DoSQV2(void); -static void DoSawV(void); - -static int swaparoo; - -static int acount=0; - -static void FP_FASTAPASS(1) KonamiIRQHook(int a) -{ - #define LCYCS 341 -// #define LCYCS ((227*2)+1) - if(IRQa) - { - acount+=a*3; - if(acount>=LCYCS) - { - doagainbub:acount-=LCYCS;IRQCount++; - if(IRQCount==0x100) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQCount=IRQLatch; - } - if(acount>=LCYCS) goto doagainbub; - } - } -} - -static DECLFW(VRC6SW) -{ - A&=0xF003; - if(A>=0x9000 && A<=0x9002) - { - VPSG[A&3]=V; - if(sfun[0]) sfun[0](); - } - else if(A>=0xa000 && A<=0xa002) - { - VPSG[4|(A&3)]=V; - if(sfun[1]) sfun[1](); - } - else if(A>=0xb000 && A<=0xb002) - { - VPSG2[A&3]=V; - if(sfun[2]) sfun[2](); - } - -} - -static DECLFW(Mapper24_write) -{ - if(swaparoo) - A=(A&0xFFFC)|((A>>1)&1)|((A<<1)&2); - if(A>=0x9000 && A<=0xb002) - { - VRC6SW(A,V); - return; - } - A&=0xF003; -// if(A>=0xF000) printf("%d, %d, $%04x:$%02x\n",scanline,timestamp,A,V); - switch(A&0xF003) - { - case 0x8000:ROM_BANK16(0x8000,V);break; - case 0xB003: - switch(V&0xF) - { - case 0x0:MIRROR_SET2(1);break; - case 0x4:MIRROR_SET2(0);break; - case 0x8:onemir(0);break; - case 0xC:onemir(1);break; - } - break; - case 0xC000:ROM_BANK8(0xC000,V);break; - case 0xD000:VROM_BANK1(0x0000,V);break; - case 0xD001:VROM_BANK1(0x0400,V);break; - case 0xD002:VROM_BANK1(0x0800,V);break; - case 0xD003:VROM_BANK1(0x0c00,V);break; - case 0xE000:VROM_BANK1(0x1000,V);break; - case 0xE001:VROM_BANK1(0x1400,V);break; - case 0xE002:VROM_BANK1(0x1800,V);break; - case 0xE003:VROM_BANK1(0x1c00,V);break; - case 0xF000:IRQLatch=V; - //acount=0; - break; - case 0xF001:IRQa=V&2; - vrctemp=V&1; - if(V&2) - { - IRQCount=IRQLatch; - acount=0; - } - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xf002:IRQa=vrctemp; - X6502_IRQEnd(FCEU_IQEXT);break; - case 0xF003:break; - } -} - -static int32 CVBC[3]; -static int32 vcount[3]; -static int32 dcount[2]; - -static INLINE void DoSQV(int x) -{ - int32 V; - int32 amp=(((VPSG[x<<2]&15)<<8)*6/8)>>4; - int32 start,end; - - start=CVBC[x]; - end=(SOUNDTS<<16)/soundtsinc; - if(end<=start) return; - CVBC[x]=end; - - if(VPSG[(x<<2)|0x2]&0x80) - { - if(VPSG[x<<2]&0x80) - { - for(V=start;V>4]+=amp; - } - else - { - int32 thresh=(VPSG[x<<2]>>4)&7; - int32 freq=((VPSG[(x<<2)|0x1]|((VPSG[(x<<2)|0x2]&15)<<8))+1)<<17; - for(V=start;Vthresh) /* Greater than, not >=. Important. */ - Wave[V>>4]+=amp; - vcount[x]-=nesincsize; - while(vcount[x]<=0) /* Should only be <0 in a few circumstances. */ - { - vcount[x]+=freq; - dcount[x]=(dcount[x]+1)&15; - } - } - } - } -} - -static void DoSQV1(void) -{ - DoSQV(0); -} - -static void DoSQV2(void) -{ - DoSQV(1); -} - -static void DoSawV(void) -{ - int V; - int32 start,end; - - start=CVBC[2]; - end=(SOUNDTS<<16)/soundtsinc; - if(end<=start) return; - CVBC[2]=end; - - if(VPSG2[2]&0x80) - { - static int32 saw1phaseacc=0; - uint32 freq3; - static uint8 b3=0; - static int32 phaseacc=0; - static uint32 duff=0; - - freq3=(VPSG2[1]+((VPSG2[2]&15)<<8)+1); - - for(V=start;V>3)&0x1f)<<4)*6/8; - } - Wave[V>>4]+=duff; - } - } -} - -static INLINE void DoSQVHQ(int x) -{ - int32 V; - int32 amp=((VPSG[x<<2]&15)<<8)*6/8; - - if(VPSG[(x<<2)|0x2]&0x80) - { - if(VPSG[x<<2]&0x80) - { - for(V=CVBC[x];V>4)&7; - for(V=CVBC[x];Vthresh) /* Greater than, not >=. Important. */ - WaveHi[V]+=amp; - vcount[x]--; - if(vcount[x]<=0) /* Should only be <0 in a few circumstances. */ - { - vcount[x]=(VPSG[(x<<2)|0x1]|((VPSG[(x<<2)|0x2]&15)<<8))+1; - dcount[x]=(dcount[x]+1)&15; - } - } - } - } - CVBC[x]=SOUNDTS; -} - -static void DoSQV1HQ(void) -{ - DoSQVHQ(0); -} - -static void DoSQV2HQ(void) -{ - DoSQVHQ(1); -} - -static void DoSawVHQ(void) -{ - static uint8 b3=0; - static int32 phaseacc=0; - int32 V; - - if(VPSG2[2]&0x80) - { - for(V=CVBC[2];V>3)&0x1f)<<8)*6/8; - vcount[2]--; - if(vcount[2]<=0) - { - vcount[2]=(VPSG2[1]+((VPSG2[2]&15)<<8)+1)<<1; - phaseacc+=VPSG2[0]&0x3f; - b3++; - if(b3==7) - { - b3=0; - phaseacc=0; - } - - } - } - } - CVBC[2]=SOUNDTS; -} - - -void VRC6Sound(int Count) -{ - int x; - - DoSQV1(); - DoSQV2(); - DoSawV(); - for(x=0;x<3;x++) - CVBC[x]=Count; -} - -void VRC6SoundHQ(void) -{ - DoSQV1HQ(); - DoSQV2HQ(); - DoSawVHQ(); -} - -void VRC6SyncHQ(int32 ts) -{ - int x; - for(x=0;x<3;x++) CVBC[x]=ts; -} - -static void VRC6_ESI(void) -{ - GameExpSound.RChange=VRC6_ESI; - GameExpSound.Fill=VRC6Sound; - GameExpSound.HiFill=VRC6SoundHQ; - GameExpSound.HiSync=VRC6SyncHQ; - - memset(CVBC,0,sizeof(CVBC)); - memset(vcount,0,sizeof(vcount)); - memset(dcount,0,sizeof(dcount)); - if(FSettings.SndRate) - { - if(FSettings.soundq>=1) - { - sfun[0]=DoSQV1HQ; - sfun[1]=DoSQV2HQ; - sfun[2]=DoSawVHQ; - } - else - { - sfun[0]=DoSQV1; - sfun[1]=DoSQV2; - sfun[2]=DoSawV; - } - } - else - memset(sfun,0,sizeof(sfun)); -} - -void Mapper24_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper24_write); - VRC6_ESI(); - MapIRQHook=KonamiIRQHook; - swaparoo=0; -} - -void Mapper26_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper24_write); - VRC6_ESI(); - MapIRQHook=KonamiIRQHook; - swaparoo=1; -} - -void NSFVRC6_Init(void) -{ - VRC6_ESI(); - SetWriteHandler(0x8000,0xbfff,VRC6SW); -} diff --git a/source/mappers/25.c b/source/mappers/25.c deleted file mode 100644 index 4dbf138..0000000 --- a/source/mappers/25.c +++ /dev/null @@ -1,100 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define K4buf mapbyte2 -#define K4IRQ mapbyte1[1] -#define K4sel mapbyte1[0] - -static int acount=0; -static DECLFW(Mapper25_write) -{ - A=(A&0xF003)|((A&0xC)>>2); - - if((A&0xF000)==0xA000) - ROM_BANK8(0xA000,V); - else if(A>=0xB000 && A<=0xEFFF) - { - int x=(A&1)|((A-0xB000)>>11); - - K4buf[x]&=(0xF0)>>((A&2)<<1); - K4buf[x]|=(V&0xF)<<((A&2)<<1); - VROM_BANK1(x<<10,K4buf[x]); - } - else if((A&0xF000)==0x8000) - { - if(K4sel&2) - ROM_BANK8(0xC000,V); - else - ROM_BANK8(0x8000,V); - } - else switch(A) - { - case 0x9000:switch(V&0x3) - { - case 0:MIRROR_SET(0);break; - case 1:MIRROR_SET(1);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - break; - case 0x9001:if((K4sel&2)!=(V&2)) - { - uint8 swa; - swa=PRGBankList[0]; - ROM_BANK8(0x8000,PRGBankList[2]); - ROM_BANK8(0xc000,swa); - } - K4sel=V; - break; - case 0xf000:IRQLatch&=0xF0;IRQLatch|=V&0xF;break; - case 0xf002:IRQLatch&=0x0F;IRQLatch|=V<<4;break; - case 0xf001:IRQCount=IRQLatch;IRQa=V&2;K4IRQ=V&1;acount=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xf003:IRQa=K4IRQ;X6502_IRQEnd(FCEU_IQEXT);break; - } -} - -static void FP_FASTAPASS(1) KonamiIRQHook(int a) -{ -// #define LCYCS ((227*2)) - #define LCYCS 341 - if(IRQa) - { - acount+=a*3; - // acount+=a*4; - if(acount>=LCYCS) - { - doagainbub:acount-=LCYCS;IRQCount++; - if(IRQCount&0x100) - {//acount=0; - X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch; - } - if(acount>=LCYCS) goto doagainbub; - } - } -} - -void Mapper25_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper25_write); - MapIRQHook=KonamiIRQHook; -} - diff --git a/source/mappers/255.c b/source/mappers/255.c deleted file mode 100644 index ede7af3..0000000 --- a/source/mappers/255.c +++ /dev/null @@ -1,67 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -static DECLFW(Mapper255_write) -{ - uint32 pbank=(A>>7)&0x1F; - uint32 cbank=A&0x3F; - uint32 rbank=(A>>14)&1; - -// printf("$%04x:$%02x\n",A,V); -// printf("%2x:%2x:%2x,%2x\n",pbank,cbank,rbank,(A&0x40)>>6); - - if(A&0x1000) - { - ROM_BANK16(0x8000,((pbank|(rbank<<5))<<1)|((A&0x40)>>6)); - ROM_BANK16(0xc000,((pbank|(rbank<<5))<<1)|((A&0x40)>>6)); - } - else - { - ROM_BANK32(pbank|(rbank<<5)); - } - MIRROR_SET((A>>13)&1); - VROM_BANK8((rbank<<6)|cbank); -} - -static DECLFW(Mapper255_wl) -{ -// printf("Wr: $%04x:$%02x\n",A,V); - mapbyte1[A&3]=V&0xF; -} - -static DECLFR(Mapper255_read) -{ - //printf("Rd: $%04x\n",A); - return(mapbyte1[A&3]); //|(X.DB&0xF0)); -} - -void Mapper255_init(void) -{ - mapbyte1[0]=mapbyte1[1]=0xF; - ROM_BANK32(0); - VROM_BANK8(0); - SetWriteHandler(0x5800,0x5FFF,Mapper255_wl); - SetWriteHandler(0x8000,0xffff,Mapper255_write); - SetReadHandler(0x5800,0x5FFF,Mapper255_read); -} diff --git a/source/mappers/27.c b/source/mappers/27.c deleted file mode 100644 index c3b6b36..0000000 --- a/source/mappers/27.c +++ /dev/null @@ -1,69 +0,0 @@ -#include "mapinc.h" - -static uint32 regchr[9]; - -static DECLFW(Mapper27_write) -{ - A&=0xF00F; - int regnum; - if((A>=0xB000) && (A<=0xE003)) { - regnum=((((A>>12)+1)&0x03)<<1)|((A&0x02)>>1); - if(A&1) - regchr[regnum]=(regchr[regnum]&0x00F)|(V<<4); - else - regchr[regnum]=(regchr[regnum]&0x1F0)|(V&0xF); - VROM_BANK1(regnum<<10,regchr[regnum]); - } - switch(A) - { - case 0x8000: ROM_BANK8(0x8000|((regchr[8]&2)<<13),V); break; - case 0xA000: ROM_BANK8(0xa000,V); break; - case 0x9000: switch(V&3){ - case 0:setmirror(MI_V);break; - case 1:setmirror(MI_H);break; - case 2:setmirror(MI_0);break; - case 3:setmirror(MI_1);break; - } - case 0x9002: regchr[8]=V; break; - case 0xF000: //X6502_IRQEnd(FCEU_IQEXT); - IRQLatch=(IRQLatch&0xF0)|(V&0x0F); - break; - case 0xF001: //X6502_IRQEnd(FCEU_IQEXT); - IRQLatch=(IRQLatch&0x0F)|((V&0xF)<<4); - break; - case 0xF003: IRQa=((IRQa&0x1)<<1)|(IRQa&0x1); - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xF002: IRQa=V&3; - if(IRQa&0x02) IRQCount=IRQLatch-1; -// X6502_IRQEnd(FCEU_IQEXT); - break; - } -// if((A&0xF000)==0xF000) FCEU_printf("$%04x:$%02x, %d\n",A,V, scanline); -} - -static void Mapper27_hb(void) -{ -// FCEU_printf("%02x-%d,%d,%d\n",scanline,IRQa,IRQCount,IRQLatch); - if(IRQa&0x2){ - if(IRQCount==0xFF){ - X6502_IRQBegin(FCEU_IQEXT); - IRQCount=IRQLatch+1; - } else { - IRQCount++; - } - } -} - -void Mapper27_init(void) -{ - int i; - for (i=0; i<9; i++) { - regchr[i]=0; - } - IRQa=0; - IRQCount=IRQLatch=0; - SetWriteHandler(0x8000,0xffff,Mapper27_write); - GameHBIRQHook=Mapper27_hb; -} - diff --git a/source/mappers/32.c b/source/mappers/32.c deleted file mode 100644 index 4f440e6..0000000 --- a/source/mappers/32.c +++ /dev/null @@ -1,53 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -#define IREMCon mapbyte1[0] - -static DECLFW(Mapper32_write) -{ - switch(A>>12) - { - case 0x8: - mapbyte1[1]=V; - if(IREMCon) {ROM_BANK8(0xc000,V);ROM_BANK8(0x8000,~1);} - else {ROM_BANK8(0x8000,V);ROM_BANK8(0xc000,~1);} - break; - case 0x9:IREMCon=(V>>1)&1; - if(IREMCon) {ROM_BANK8(0xc000,mapbyte1[1]);ROM_BANK8(0x8000,~1);} - else {ROM_BANK8(0x8000,mapbyte1[1]); ROM_BANK8(0xc000,~1);} - MIRROR_SET(V&1); - break; - case 0xa:ROM_BANK8(0xA000,V); - break; - } - - if((A&0xF000)==0xb000) - VROM_BANK1((A&0x7)<<10,V); -} - -void Mapper32_init(void) -{ - ROM_BANK16(0x8000,0); - ROM_BANK16(0xc000,~0); - SetWriteHandler(0x8000,0xffff,Mapper32_write); -} diff --git a/source/mappers/33.c b/source/mappers/33.c deleted file mode 100644 index abd22e1..0000000 --- a/source/mappers/33.c +++ /dev/null @@ -1,79 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static int is48; - -static DECLFW(Mapper33_write) -{ - A&=0xF003; - - if(A>=0xA000 && A<=0xA003) - VROM_BANK1(0x1000+((A&3)<<10),V); - else switch(A) - { - case 0x8000:if(!is48) MIRROR_SET((V>>6)&1); - ROM_BANK8(0x8000,V); - break; - case 0x8001:ROM_BANK8(0xA000,V); break; - case 0x8002:VROM_BANK2(0x0000,V);break; - case 0x8003:VROM_BANK2(0x0800,V);break; - } -} - -static DECLFW(Mapper48_HiWrite) -{ - switch(A&0xF003) - { - case 0xc000:IRQLatch=V;break; - case 0xc001:IRQCount=IRQLatch;break; - case 0xc003:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xc002:IRQa=1;break; - case 0xe000:MIRROR_SET((V>>6)&1);break; - } -} - -static void heho(void) -{ - if(IRQa) - { - IRQCount++; - if(IRQCount==0x100) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - } - } -} - -void Mapper33_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper33_write); - is48=0; -} - -void Mapper48_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper33_write); - SetWriteHandler(0xc000,0xffff,Mapper48_HiWrite); - GameHBIRQHook=heho; - is48=1; -} diff --git a/source/mappers/40.c b/source/mappers/40.c deleted file mode 100644 index 78d51fd..0000000 --- a/source/mappers/40.c +++ /dev/null @@ -1,58 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -static DECLFW(Mapper40_write) -{ - switch(A&0xe000) - { - case 0x8000:IRQa=0;IRQCount=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xa000:IRQa=1;break; - case 0xe000:ROM_BANK8(0xc000,V&7);break; - } -} - -static void FP_FASTAPASS(1) Mapper40IRQ(int a) -{ - if(IRQa) - { - if(IRQCount<4096) - IRQCount+=a; - else - { - IRQa=0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -void Mapper40_init(void) -{ - ROM_BANK8(0x6000,(~0)-1); - ROM_BANK8(0x8000,(~0)-3); - ROM_BANK8(0xa000,(~0)-2); - SetWriteHandler(0x8000,0xffff,Mapper40_write); - SetReadHandler(0x6000,0x7fff,CartBR); - MapIRQHook=Mapper40IRQ; -} - - diff --git a/source/mappers/41.c b/source/mappers/41.c deleted file mode 100644 index dfb6908..0000000 --- a/source/mappers/41.c +++ /dev/null @@ -1,57 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -#define calreg mapbyte1[0] -#define calchr mapbyte1[1] - -DECLFW(Mapper41_write) -{ - if(A<0x8000) - { - ROM_BANK32(A&7); - MIRROR_SET((A>>5)&1); - calreg=A; - calchr&=0x3; - calchr|=(A>>1)&0xC; - VROM_BANK8(calchr); - } - else if(calreg&0x4) - { - calchr&=0xC; - calchr|=A&3; - VROM_BANK8(calchr); - } -} - -static void M41Reset(void) -{ - calreg=calchr=0; -} - -void Mapper41_init(void) -{ - MapperReset=M41Reset; - ROM_BANK32(0); - SetWriteHandler(0x8000,0xffff,Mapper41_write); - SetWriteHandler(0x6000,0x67ff,Mapper41_write); -} diff --git a/source/mappers/42.c b/source/mappers/42.c deleted file mode 100644 index 0303d62..0000000 --- a/source/mappers/42.c +++ /dev/null @@ -1,62 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -static DECLFW(Mapper42_write) -{ - switch(A&0xe003) - { - case 0xe000:mapbyte1[0]=V;ROM_BANK8(0x6000,V&0xF);break; - case 0xe001:MIRROR_SET((V>>3)&1);break; - case 0xe002:IRQa=V&2;if(!IRQa) IRQCount=0;X6502_IRQEnd(FCEU_IQEXT);break; - } -} - -static void FP_FASTAPASS(1) Mapper42IRQ(int a) -{ - if(IRQa) - { - IRQCount+=a; - if(IRQCount>=32768) IRQCount-=32768; - if(IRQCount>=24576) - X6502_IRQBegin(FCEU_IQEXT); - else - X6502_IRQEnd(FCEU_IQEXT); - } -} - -static void Mapper42_StateRestore(int version) -{ - ROM_BANK8(0x6000,mapbyte1[0]&0xF); -} - - -void Mapper42_init(void) -{ - ROM_BANK8(0x6000,0); - ROM_BANK32(~0); - SetWriteHandler(0x6000,0xffff,Mapper42_write); - SetReadHandler(0x6000,0x7fff,CartBR); - MapStateRestore=Mapper42_StateRestore; - MapIRQHook=Mapper42IRQ; -} - diff --git a/source/mappers/43.c b/source/mappers/43.c deleted file mode 100644 index 19bbd90..0000000 --- a/source/mappers/43.c +++ /dev/null @@ -1,75 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -static DECLFW(Mapper43_write) -{ - //printf("$%04x:$%02x\n",A,V); - if((A&0x8122)==0x8122) - { - X6502_IRQEnd(FCEU_IQEXT); - if(V&2) IRQa=1; - else - IRQCount=IRQa=0; - } -} - -static DECLFW(M43Low) -{ - int transo[8]={4,3,4,4,4,7,5,6}; - A&=0xF0FF; - if(A==0x4022) - setprg8(0x6000,transo[V&7]); - //printf("$%04x:$%02x\n",A,V); -} - -static void FP_FASTAPASS(1) M43Ho(int a) -{ - IRQCount+=a; - if(IRQa) - if(IRQCount>=4096) - { - X6502_IRQBegin(FCEU_IQEXT); - } -} - -//static DECLFR(boo) -//{ -// printf("$%04x\n",A); -// return( ROM[0x2000*8 +0x1000 +(A-0x5000)]); -//} - -void Mapper43_init(void) -{ - setprg4(0x5000,16); - setprg8(0x6000,2); - setprg8(0x8000,1); - setprg8(0xa000,0); - setprg8(0xc000,4); - setprg8(0xe000,9); - SetWriteHandler(0x8000,0xffff,Mapper43_write); - SetWriteHandler(0x4020,0x7fff,M43Low); - //SetReadHandler(0x5000,0x5fff,boo); - SetReadHandler(0x6000,0xffff,CartBR); - MapIRQHook=M43Ho; -} diff --git a/source/mappers/46.c b/source/mappers/46.c deleted file mode 100644 index 8c4ef6d..0000000 --- a/source/mappers/46.c +++ /dev/null @@ -1,48 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -#define A64reg mapbyte1[0] -#define A64wr mapbyte1[1] - -DECLFW(Mapper46_writel) -{ - A64reg=V; - ROM_BANK32((A64wr&1)+((A64reg&0xF)<<1)); - VROM_BANK8(((A64wr>>4)&7)+((A64reg&0xF0)>>1)); -} - -DECLFW(Mapper46_write) -{ - A64wr=V; - ROM_BANK32((V&1)+((A64reg&0xF)<<1)); - VROM_BANK8(((V>>4)&7)+((A64reg&0xF0)>>1)); -} - -void Mapper46_init(void) -{ - MIRROR_SET(0); - ROM_BANK32(0); - SetWriteHandler(0x8000,0xffff,Mapper46_write); - SetWriteHandler(0x6000,0x7fff,Mapper46_writel); -} diff --git a/source/mappers/50.c b/source/mappers/50.c deleted file mode 100644 index 609dc2b..0000000 --- a/source/mappers/50.c +++ /dev/null @@ -1,75 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -static void FP_FASTAPASS(1) Mapper50IRQ(int a) -{ - if(IRQa) - { - if(IRQCount<4096) - IRQCount+=a; - else - { - IRQa=0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void M50Restore(int version) -{ - setprg8(0xc000,mapbyte1[0]); -} - -static DECLFW(M50W) -{ - if((A&0xD060)==0x4020) - { - if(A&0x100) - { - IRQa=V&1; - if(!IRQa) IRQCount=0; - X6502_IRQEnd(FCEU_IQEXT); - } - else - { - V=((V&1)<<2)|((V&2)>>1)|((V&4)>>1)|(V&8); - mapbyte1[0]=V; - setprg8(0xc000,V); - } - } -} - -void Mapper50_init(void) -{ - SetWriteHandler(0x4020,0x5fff,M50W); - SetReadHandler(0x6000,0xffff,CartBR); - MapStateRestore=M50Restore; - MapIRQHook=Mapper50IRQ; - - setprg8(0x6000,0xF); - setprg8(0x8000,0x8); - setprg8(0xa000,0x9); - setprg8(0xc000,0x0); - setprg8(0xe000,0xB); -} - diff --git a/source/mappers/51.c b/source/mappers/51.c deleted file mode 100644 index cc1fbbd..0000000 --- a/source/mappers/51.c +++ /dev/null @@ -1,66 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define mode mapbyte1[0] -#define page mapbyte1[1] - -static uint32 Get8K(uint32 A) -{ - uint32 bank; - - bank=(page<<2)|((A>>13)&1); - - if(A&0x4000 && !(mode&1)) bank|=0xC; - if(!(A&0x8000)) bank|=0x20; - if(mode==2) bank|=2; - else bank|=(A>>13)&2; - return(bank); -} - -static void Synco(void) -{ - uint32 x; - if(mapbyte1[0]<=2) - MIRROR_SET2(1); - else - MIRROR_SET2(0); - for(x=0x6000;x<0x10000;x+=8192) - ROM_BANK8(x,Get8K(x)); -} - -static DECLFW(Write) -{ - if(A&0x8000) mapbyte1[1]=V&0xF; - else mapbyte1[0]=(mapbyte1[0]&2)|((V>>1)&1); - - if(A&0x4000) mapbyte1[0]=(mapbyte1[0]&1)|((V>>3)&2); - Synco(); -} - -void Mapper51_init(void) -{ - SetWriteHandler(0x6000,0xFFFF,Write); - SetReadHandler(0x6000,0xFFFF,CartBR); - mapbyte1[0]=1; - mapbyte1[1]=0; - Synco(); -} diff --git a/source/mappers/57.c b/source/mappers/57.c deleted file mode 100644 index b64d270..0000000 --- a/source/mappers/57.c +++ /dev/null @@ -1,49 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -static DECLFW(Mapper57_write) -{ - A&=0x8800; - if(A==0x8800) - { - mapbyte1[0]=V; - if(V&0x80) - ROM_BANK32(2|(V>>6)); - else - { - ROM_BANK16(0x8000,(V>>5)&3); - ROM_BANK16(0xc000,(V>>5)&3); - } - MIRROR_SET((V&0x8)>>3); - } - else - mapbyte1[1]=V; - VROM_BANK8((mapbyte1[1]&3)|(mapbyte1[0]&7)|((mapbyte1[0]&0x10)>>1)); - //printf("$%04x:$%02x\n",A,V); -} - -void Mapper57_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper57_write); -} diff --git a/source/mappers/58.c b/source/mappers/58.c deleted file mode 100644 index d3cc505..0000000 --- a/source/mappers/58.c +++ /dev/null @@ -1,43 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static DECLFW(M58Write) -{ - //printf("$%04x:$%02x\n",A,V); - if(A&0x40) - { - ROM_BANK16(0x8000,(A&0x07)); - ROM_BANK16(0xc000,(A&0x07)); - } - else - ROM_BANK32((A&0x06)>>1); - - VROM_BANK8((A&0x38)>>3); - MIRROR_SET2((V&2)>>1); -} - -void Mapper58_init(void) -{ - ROM_BANK32(0); - VROM_BANK8(0); - SetWriteHandler(0x8000,0xFFFF,M58Write); -} diff --git a/source/mappers/59.c b/source/mappers/59.c deleted file mode 100644 index 30ddb8b..0000000 --- a/source/mappers/59.c +++ /dev/null @@ -1,47 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static int ay; -static DECLFW(Mapper59_write) -{ - //printf("$%04x:$%02x\n",A,V); - setprg32(0x8000,(A&0x70)>>4); - setchr8(A&0x7); - //if(A&0x100) - // setprg32r(0x10,0x8000,0); - ay=A; - MIRROR_SET2((A&0x8)>>3); -} - -static DECLFR(m59rd) -{ - if(ay&0x100) return(0); - else - return(CartBR(A)); -} - -void Mapper59_init(void) -{ - setprg32(0x8000,0); - SetReadHandler(0x8000,0xffff,m59rd); - SetWriteHandler(0x8000,0xffff,Mapper59_write); -} diff --git a/source/mappers/6.c b/source/mappers/6.c deleted file mode 100644 index 7a1e324..0000000 --- a/source/mappers/6.c +++ /dev/null @@ -1,76 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -#define FVRAM_BANK8(A,V) {VPage[0]=VPage[1]=VPage[2]=VPage[3]=VPage[4]=VPage[5]=VPage[6]=VPage[7]=V?&MapperExRAM[(V)<<13]-(A):&CHRRAM[(V)<<13]-(A);CHRBankList[0]=((V)<<3);CHRBankList[1]=((V)<<3)+1;CHRBankList[2]=((V)<<3)+2;CHRBankList[3]=((V)<<3)+3;CHRBankList[4]=((V)<<3)+4;CHRBankList[5]=((V)<<3)+5;CHRBankList[6]=((V)<<3)+6;CHRBankList[7]=((V)<<3)+7;PPUCHRRAM=0xFF;} - -static void FP_FASTAPASS(1) FFEIRQHook(int a) -{ - if(IRQa) - { - IRQCount+=a; - if(IRQCount>=0x10000) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - IRQCount=0; - } - } -} - -DECLFW(Mapper6_write) -{ - if(A<0x8000) - { - switch(A){ - case 0x42FF:MIRROR_SET((V>>4)&1);break; - case 0x42FE:onemir((V>>3)&2);break; - case 0x4501:IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x4502:IRQCount&=0xFF00;IRQCount|=V;break; - case 0x4503:IRQCount&=0xFF;IRQCount|=V<<8;IRQa=1;break; - } - } else { - ROM_BANK16(0x8000,V>>2); - FVRAM_BANK8(0x0000,V&3); - } -} -void Mapper6_StateRestore(int version) -{ - int x; - for(x=0;x<8;x++) - if(PPUCHRRAM&(1<7) - VPage[x]=&MapperExRAM[(CHRBankList[x]&31)*0x400]-(x*0x400); - else VPage[x]=&CHRRAM[(CHRBankList[x]&7)*0x400]-(x*0x400); - } -} -void Mapper6_init(void) -{ -MapIRQHook=FFEIRQHook; -ROM_BANK16(0xc000,7); - -SetWriteHandler(0x4020,0x5fff,Mapper6_write); -SetWriteHandler(0x8000,0xffff,Mapper6_write); -MapStateRestore=Mapper6_StateRestore; -} - diff --git a/source/mappers/60.c b/source/mappers/60.c deleted file mode 100644 index fa97007..0000000 --- a/source/mappers/60.c +++ /dev/null @@ -1,40 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - - -#include "mapinc.h" - -#define mCount mapbyte1[0] - -static DECLFW(Mapper60_write) -{ - VROM_BANK8(mCount); - ROM_BANK16(0x8000,mCount); - ROM_BANK16(0xc000,mCount); - mCount++; - mCount&=0x03; -} - -void Mapper60_init(void) -{ - mCount=0; - SetWriteHandler(0x8000,0xFFFF,Mapper60_write); -} - diff --git a/source/mappers/61.c b/source/mappers/61.c deleted file mode 100644 index 3882947..0000000 --- a/source/mappers/61.c +++ /dev/null @@ -1,54 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -static DECLFW(Mapper61_write) -{ -// printf("$%04x:$%02x\n",A,V); - switch(A&0x30) - { - case 0x00: - case 0x30: - ROM_BANK32(A&0xF); - break; - case 0x20: - case 0x10: - ROM_BANK16(0x8000,((A&0xF)<<1)| (((A&0x20)>>4)) ); - ROM_BANK16(0xC000,((A&0xF)<<1)| (((A&0x20)>>4)) ); - break; - } - #ifdef moo - if(!(A&0x10)) - ROM_BANK32(A&0xF); - else - { - ROM_BANK16(0x8000,((A&0xF)<<1)| (((A&0x10)>>4)^1) ); - ROM_BANK16(0xC000,((A&0xF)<<1)| (((A&0x10)>>4)^1) ); - } - #endif - MIRROR_SET((A&0x80)>>7); -} - -void Mapper61_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper61_write); -} diff --git a/source/mappers/62.c b/source/mappers/62.c deleted file mode 100644 index b545349..0000000 --- a/source/mappers/62.c +++ /dev/null @@ -1,41 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2003 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static DECLFW(Mapper62_write) -{ - VROM_BANK8(((A&0x1F)<<2)|(V&0x03)); - if ((A&0x20)>>5) { - ROM_BANK16(0x8000,(A&0x40)|((A>>8)&0x3F)); - ROM_BANK16(0xc000,(A&0x40)|((A>>8)&0x3F)); - } - else - ROM_BANK32(((A&0x40)|((A>>8)&0x3F))>>1); - MIRROR_SET((A&0x80)>>7); -} - -void Mapper62_init(void) -{ - SetWriteHandler(0x8000,0xffff, Mapper62_write); - ROM_BANK32(0); -} - - diff --git a/source/mappers/65.c b/source/mappers/65.c deleted file mode 100644 index 18fa1be..0000000 --- a/source/mappers/65.c +++ /dev/null @@ -1,74 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -void FP_FASTAPASS(1) IREMIRQHook(int a) -{ - if(IRQa) - { - IRQCount-=a; - if(IRQCount<-4) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - IRQCount=0xFFFF; - } - } -} - -static DECLFW(Mapper65_write) -{ - //if(A>=0x9000 && A<=0x9006) - // printf("$%04x:$%02x, %d\n",A,V,scanline); - switch(A) - { - //default: printf("$%04x:$%02x\n",A,V); - // break; - case 0x8000:ROM_BANK8(0x8000,V);break; - // case 0x9000:printf("$%04x:$%02x\n",A,V);MIRROR_SET2((V>>6)&1);break; - case 0x9001:MIRROR_SET(V>>7);break; - case 0x9003:IRQa=V&0x80;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x9004:IRQCount=IRQLatch;break; - case 0x9005: IRQLatch&=0x00FF; - IRQLatch|=V<<8; - break; - case 0x9006: IRQLatch&=0xFF00;IRQLatch|=V; - break; - case 0xB000:VROM_BANK1(0x0000,V);break; - case 0xB001:VROM_BANK1(0x0400,V);break; - case 0xB002:VROM_BANK1(0x0800,V);break; - case 0xB003:VROM_BANK1(0x0C00,V);break; - case 0xB004:VROM_BANK1(0x1000,V);break; - case 0xB005:VROM_BANK1(0x1400,V);break; - case 0xB006:VROM_BANK1(0x1800,V);break; - case 0xB007:VROM_BANK1(0x1C00,V);break; - case 0xa000:ROM_BANK8(0xA000,V);break; - case 0xC000:ROM_BANK8(0xC000,V);break; - } - //MIRROR_SET2(1); -} - -void Mapper65_init(void) -{ - MapIRQHook=IREMIRQHook; - SetWriteHandler(0x8000,0xffff,Mapper65_write); -} diff --git a/source/mappers/67.c b/source/mappers/67.c deleted file mode 100644 index 616f320..0000000 --- a/source/mappers/67.c +++ /dev/null @@ -1,78 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -#define suntoggle mapbyte1[0] - -static DECLFW(Mapper67_write) -{ - A&=0xF800; - if((A&0x800) && A<=0xb800) - { - VROM_BANK2((A-0x8800)>>1,V); - } - else switch(A) - { - case 0xc800: - case 0xc000:if(!suntoggle) - { - IRQCount&=0xFF; - IRQCount|=V<<8; - } - else - { - IRQCount&=0xFF00; - IRQCount|=V; - } - suntoggle^=1; - break; - case 0xd800:suntoggle=0;IRQa=V&0x10;X6502_IRQEnd(FCEU_IQEXT);break; - - case 0xe800:switch(V&3) - { - case 0:MIRROR_SET2(1);break; - case 1:MIRROR_SET2(0);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - break; - case 0xf800:ROM_BANK16(0x8000,V);break; - } -} -static void FP_FASTAPASS(1) SunIRQHook(int a) -{ - if(IRQa) - { - IRQCount-=a; - if(IRQCount<=0) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - IRQCount=0xFFFF; - } - } -} -void Mapper67_init(void) -{ -SetWriteHandler(0x8000,0xffff,Mapper67_write); -MapIRQHook=SunIRQHook; -} diff --git a/source/mappers/68.c b/source/mappers/68.c deleted file mode 100644 index 0d911c2..0000000 --- a/source/mappers/68.c +++ /dev/null @@ -1,104 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static void Fixerit(void) -{ - switch(mapbyte2[0]&3) - { - case 0:vnapage[0]=vnapage[2]=CHRptr[0]+(((mapbyte1[0]|128)&CHRmask1[0])<<10); - vnapage[1]=vnapage[3]=CHRptr[0]+(((mapbyte1[1]|128)&CHRmask1[0])<<10); - break; - case 1:vnapage[0]=vnapage[1]=CHRptr[0]+(((mapbyte1[0]|128)&CHRmask1[0])<<10); - vnapage[2]=vnapage[3]=CHRptr[0]+(((mapbyte1[1]|128)&CHRmask1[0])<<10); - break; - case 2:vnapage[0]=vnapage[1]=vnapage[2]=vnapage[3]=CHRptr[0]+(((mapbyte1[0]|128)&CHRmask1[0])<<10); - break; - case 3:vnapage[0]=vnapage[1]=vnapage[2]=vnapage[3]=CHRptr[0]+(((mapbyte1[1]|128)&CHRmask1[0])<<10); - break; - } -} - -DECLFW(Mapper68_write) -{ - A&=0xF000; - - if(A>=0x8000 && A<=0xB000) - { - VROM_BANK2((A-0x8000)>>1,V); - } - else switch(A) - { - case 0xc000:mapbyte1[0]=V; - if(VROM_size && mapbyte2[0]&0x10) - Fixerit(); - break; - - case 0xd000:mapbyte1[1]=V; - if(VROM_size && mapbyte2[0]&0x10) - Fixerit(); - break; - - case 0xe000: mapbyte2[0]=V; - if(!(V&0x10)) - { - switch(V&3) - { - case 0:MIRROR_SET2(1);break; - case 1:MIRROR_SET2(0);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - } - else if(VROM_size) - { - Fixerit(); - PPUNTARAM=0; - } - break; - case 0xf000: ROM_BANK16(0x8000,V);break; - } -} - -static void Mapper68_StateRestore(int version) -{ - if(!(mapbyte2[0]&0x10)) - { - switch(mapbyte2[0]&3) - { - case 0:MIRROR_SET(0);break; - case 1:MIRROR_SET(1);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - } - else if(VROM_size) - { - Fixerit(); - PPUNTARAM=0; - } -} - -void Mapper68_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper68_write); - MapStateRestore=Mapper68_StateRestore; -} diff --git a/source/mappers/69.c b/source/mappers/69.c deleted file mode 100644 index 3a0d03f..0000000 --- a/source/mappers/69.c +++ /dev/null @@ -1,252 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static void AYSound(int Count); -static void AYSoundHQ(void); -static void DoAYSQ(int x); -static void DoAYSQHQ(int x); - -#define sunselect mapbyte1[0] -#define sungah mapbyte1[1] -static uint8 sunindex; - -static DECLFW(SUN5BWRAM) -{ - if((sungah&0xC0)==0xC0) - (WRAM-0x6000)[A]=V; -} - -static DECLFR(SUN5AWRAM) -{ - if((sungah&0xC0)==0x40) - return X.DB; - return CartBR(A); -} - -static DECLFW(Mapper69_SWL) -{ - sunindex=V%14; -} - -static DECLFW(Mapper69_SWH) -{ - int x; - GameExpSound.Fill=AYSound; - GameExpSound.HiFill=AYSoundHQ; - if(FSettings.SndRate); - switch(sunindex) - { - case 0: - case 1: - case 8:if(FSettings.soundq>=1) DoAYSQHQ(0); else DoAYSQ(0);break; - case 2: - case 3: - case 9:if(FSettings.soundq>=1) DoAYSQHQ(1); else DoAYSQ(1);break; - case 4: - case 5: - case 10:if(FSettings.soundq>=1) DoAYSQHQ(2); else DoAYSQ(2);break; - case 7: - for(x=0;x<2;x++) - if(FSettings.soundq>=1) DoAYSQHQ(x); else DoAYSQ(x); - break; - } - MapperExRAM[sunindex]=V; -} - -static DECLFW(Mapper69_write) -{ - switch(A&0xE000) - { - case 0x8000:sunselect=V;break; - case 0xa000: - sunselect&=0xF; - if(sunselect<=7) - VROM_BANK1(sunselect<<10,V); - else - switch(sunselect&0x0f) - { - case 8: - sungah=V; - if(V&0x40) - { - if(V&0x80) // Select WRAM - setprg8r(0x10,0x6000,0); - } - else - setprg8(0x6000,V); - break; - case 9:ROM_BANK8(0x8000,V);break; - case 0xa:ROM_BANK8(0xa000,V);break; - case 0xb:ROM_BANK8(0xc000,V);break; - case 0xc: - switch(V&3) - { - case 0:MIRROR_SET2(1);break; - case 1:MIRROR_SET2(0);break; - case 2:onemir(0);break; - case 3:onemir(1);break; - } - break; - case 0xd:IRQa=V;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xe:IRQCount&=0xFF00;IRQCount|=V;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xf:IRQCount&=0x00FF;IRQCount|=V<<8;X6502_IRQEnd(FCEU_IQEXT);break; - } - break; - } -} - -static int32 vcount[3]; -static int32 dcount[3]; -static int CAYBC[3]; - -static void DoAYSQ(int x) -{ - int32 freq=((MapperExRAM[x<<1]|((MapperExRAM[(x<<1)+1]&15)<<8))+1)<<(4+17); - int32 amp=(MapperExRAM[0x8+x]&15)<<2; - int32 start,end; - int V; - - amp+=amp>>1; - - start=CAYBC[x]; - end=(SOUNDTS<<16)/soundtsinc; - if(end<=start) return; - CAYBC[x]=end; - - if(amp) - for(V=start;V>4]+=amp; - vcount[x]-=nesincsize; - while(vcount[x]<=0) - { - dcount[x]^=1; - vcount[x]+=freq; - } - } -} - -static void DoAYSQHQ(int x) -{ - int32 V; - int32 freq=((MapperExRAM[x<<1]|((MapperExRAM[(x<<1)+1]&15)<<8))+1)<<4; - int32 amp=(MapperExRAM[0x8+x]&15)<<6; - - amp+=amp>>1; - - if(!(MapperExRAM[0x7]&(1<>3)&2);break; - } -} - -void Mapper71_init(void) -{ -SetWriteHandler(0x4020,0xffff,Mapper71_write); -} - diff --git a/source/mappers/72.c b/source/mappers/72.c deleted file mode 100644 index 480a035..0000000 --- a/source/mappers/72.c +++ /dev/null @@ -1,37 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -DECLFW(Mapper72_write) -{ - mapbyte1[0]=V; - if(V&0x80) - ROM_BANK16(0x8000,V&0xF); - if(V&0x40) - VROM_BANK8(V&0xF); -} - -void Mapper72_init(void) -{ - SetWriteHandler(0x6000,0xffff,Mapper72_write); -} - diff --git a/source/mappers/73.c b/source/mappers/73.c deleted file mode 100644 index 50a3d62..0000000 --- a/source/mappers/73.c +++ /dev/null @@ -1,60 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -static DECLFW(Mapper73_write) -{ - //if(A>=0xd000 && A<=0xdfff) - X6502_IRQEnd(FCEU_IQEXT); /* How are IRQs acknowledged on this chip? */ - switch(A&0xF000) - { - //default: printf("$%04x:$%02x\n",A,V);break; - case 0x8000:IRQCount&=0xFFF0;IRQCount|=(V&0xF);break; - case 0x9000:IRQCount&=0xFF0F;IRQCount|=(V&0xF)<<4;break; - case 0xa000:IRQCount&=0xF0FF;IRQCount|=(V&0xF)<<8;break; - case 0xb000:IRQCount&=0x0FFF;IRQCount|=(V&0xF)<<12;break; - case 0xc000:IRQa=V&2;break; - case 0xf000:ROM_BANK16(0x8000,V);break; - } -} - -static void FP_FASTAPASS(1) Mapper73IRQHook(int a) -{ - if(IRQa) - { - IRQCount+=a; - if(IRQCount>=0xFFFF) - { - IRQCount&=0xFFFF; - IRQa=0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -void Mapper73_init(void) -{ - SetWriteHandler(0x8000,0xffff,Mapper73_write); - MapIRQHook=Mapper73IRQHook; -} - diff --git a/source/mappers/75.c b/source/mappers/75.c deleted file mode 100644 index f2b00bd..0000000 --- a/source/mappers/75.c +++ /dev/null @@ -1,47 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -#define map75sel mapbyte1[0] -#define map75ar mapbyte2 - -DECLFW(Mapper75_write) -{ -switch(A&0xF000) - { - case 0x8000:ROM_BANK8(0x8000,V);break; - case 0x9000: - VROM_BANK4(0x0000,map75ar[0]|((V&2)<<3)); - VROM_BANK4(0x1000,map75ar[1]|((V&4)<<2)); - map75sel=V;MIRROR_SET(V&1);break; - case 0xa000:ROM_BANK8(0xa000,V);break; - case 0xc000:ROM_BANK8(0xc000,V);break; - case 0xe000:V&=0xF;map75ar[0]=V;V|=(map75sel&2)<<3;VROM_BANK4(0x0000,V);break; - case 0xf000:V&=0xF;map75ar[1]=V;V|=(map75sel&4)<<2;VROM_BANK4(0x1000,V);break; - } -} - -void Mapper75_init(void) -{ -SetWriteHandler(0x8000,0xffff,Mapper75_write); -} - diff --git a/source/mappers/76.c b/source/mappers/76.c deleted file mode 100644 index 7f231d3..0000000 --- a/source/mappers/76.c +++ /dev/null @@ -1,55 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -static DECLFW(Mapper76_write) -{ - switch(A&0xE001){ - case 0x8000: - MMC3_cmd = V; - break; - case 0x8001: - switch(MMC3_cmd&0x07){ - case 2: VROM_BANK2(0x000,V);break; - case 3: VROM_BANK2(0x800,V);break; - case 4: VROM_BANK2(0x1000,V);break; - case 5: VROM_BANK2(0x1800,V);break; - case 6: - if (MMC3_cmd&0x40) ROM_BANK8(0xC000,V); - else ROM_BANK8(0x8000,V); - break; - case 7: ROM_BANK8(0xA000,V); - break; - } - break; - case 0xA000: - MIRROR_SET(V&1); - break; - } -} - -void Mapper76_init(void) -{ -SetWriteHandler(0x8000,0xffff,Mapper76_write); -} - diff --git a/source/mappers/77.c b/source/mappers/77.c deleted file mode 100644 index 06f15cc..0000000 --- a/source/mappers/77.c +++ /dev/null @@ -1,54 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -/* Original code provided by LULU */ - -static DECLFW(Mapper77_write) -{ - mapbyte1[0]=V; - ROM_BANK32(V&0x7); - VROM_BANK2(0x0000, (V&0xf0)>>4); -} - -static void Mapper77_StateRestore(int version) -{ - int x; - - if(version>=7200) - { - ROM_BANK32(mapbyte1[0]&0x7); - VROM_BANK2(0x0000, (mapbyte1[0]&0xf0)>>4); - } - for(x=2;x<8;x++) - VRAM_BANK1(x*0x400,x); -} - -void Mapper77_init(void) -{ - int x; - - ROM_BANK32(0); - for(x=2;x<8;x++) - VRAM_BANK1(x*0x400,x); - SetWriteHandler(0x6000,0xffff,Mapper77_write); - MapStateRestore=Mapper77_StateRestore; -} diff --git a/source/mappers/79.c b/source/mappers/79.c deleted file mode 100644 index 9148eae..0000000 --- a/source/mappers/79.c +++ /dev/null @@ -1,40 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -DECLFW(Mapper79_write) -{ - if(A<0x8000 && ((A^0x4100)==0)) - { - ROM_BANK32((V>>3)&1); - } - VROM_BANK8(V); -} - -void Mapper79_init(void) -{ - ROM_BANK32(~0); - SetWriteHandler(0x8000,0xffff,Mapper79_write); - SetWriteHandler(0x4020,0x5fff,Mapper79_write); -} - diff --git a/source/mappers/8.c b/source/mappers/8.c deleted file mode 100644 index 529b264..0000000 --- a/source/mappers/8.c +++ /dev/null @@ -1,34 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static DECLFW(Mapper8_write) -{ - ROM_BANK16(0x8000,V>>3); - VROM_BANK8(V&7); -} - -void Mapper8_init(void) -{ - ROM_BANK32(0); - SetWriteHandler(0x8000,0xFFFF,Mapper8_write); -} - diff --git a/source/mappers/80.c b/source/mappers/80.c deleted file mode 100644 index 1e7982e..0000000 --- a/source/mappers/80.c +++ /dev/null @@ -1,100 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint32 lastA; -static int isfu; -static uint8 CCache[8]; - -static void FP_FASTAPASS(1) Fudou_PPU(uint32 A) -{ - static int last=-1; - static uint8 z; - - if(A>=0x2000) return; - - A>>=10; - lastA=A; - - z=CCache[A]; - if(z!=last) - { - onemir(z); - last=z; - } -} - -static void mira() -{ - if(isfu) - { - int x; - CCache[0]=CCache[1]=mapbyte2[0]>>7; - CCache[2]=CCache[3]=mapbyte2[1]>>7; - - for(x=0;x<4;x++) - CCache[4+x]=mapbyte2[2+x]>>7; - - onemir(CCache[lastA]); - } - else - MIRROR_SET2(mapbyte1[0]&1); -} - -static DECLFW(Mapper80_write) -{ - switch(A) - { - case 0x7ef0: mapbyte2[0]=V;VROM_BANK2(0x0000,(V>>1)&0x3F);mira();break; - case 0x7ef1: mapbyte2[1]=V;VROM_BANK2(0x0800,(V>>1)&0x3f);mira();break; - - case 0x7ef2: mapbyte2[2]=V;VROM_BANK1(0x1000,V);mira();break; - case 0x7ef3: mapbyte2[3]=V;VROM_BANK1(0x1400,V);mira();break; - case 0x7ef4: mapbyte2[4]=V;VROM_BANK1(0x1800,V);mira();break; - case 0x7ef5: mapbyte2[5]=V;VROM_BANK1(0x1c00,V);mira();break; - case 0x7ef6: mapbyte1[0]=V;mira();break; - case 0x7efa: - case 0x7efb: ROM_BANK8(0x8000,V);break; - case 0x7efd: - case 0x7efc: ROM_BANK8(0xA000,V);break; - case 0x7efe: - case 0x7eff: ROM_BANK8(0xC000,V);break; - } -} - -static void booga(int version) -{ - mira(); -} - -void Mapper80_init(void) -{ - SetWriteHandler(0x4020,0x7fff,Mapper80_write); - MapStateRestore=booga; - isfu=0; -} - -void Mapper207_init(void) -{ - Mapper80_init(); - isfu=1; - PPU_hook=Fudou_PPU; -} diff --git a/source/mappers/82.c b/source/mappers/82.c deleted file mode 100644 index 4b72c71..0000000 --- a/source/mappers/82.c +++ /dev/null @@ -1,62 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define ctrl mapbyte1[6] - -static void DoCHR(void) -{ - int x; - - for(x=0;x<2;x++) - VROM_BANK2((x<<11)|((ctrl&2)<<11),mapbyte1[x]>>1); - for(x=0;x<4;x++) - VROM_BANK1((x<<10) | (((ctrl&2)^2)<<11),mapbyte1[2+x]); -} - -static DECLFW(Mapper82_write) -{ - if(A<=0x7EF5) - { - mapbyte1[A&7]=V; - DoCHR(); - } - else - switch(A) - { - case 0x7ef6:ctrl=V&3; - MIRROR_SET2(V&1); - DoCHR(); - break; - case 0x7efa:V>>=2;mapbyte2[0]=V;ROM_BANK8(0x8000,V);break; - case 0x7efb:V>>=2;mapbyte2[1]=V;ROM_BANK8(0xa000,V);break; - case 0x7efc:V>>=2;mapbyte2[2]=V;ROM_BANK8(0xc000,V);break; - } -} - -void Mapper82_init(void) -{ - ROM_BANK8(0xE000,~0); - - /* external WRAM might end at $73FF */ - SetWriteHandler(0x7ef0,0x7efc,Mapper82_write); -} - diff --git a/source/mappers/83.c b/source/mappers/83.c deleted file mode 100644 index c8081e8..0000000 --- a/source/mappers/83.c +++ /dev/null @@ -1,121 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - -void Mapper83_init(void) -{ - -} -#ifdef MOOCOW -static void FP_FASTAPASS(1) m83IRQHook(int a) -{ - if(IRQa) - { - IRQCount-=a; - if(IRQCount<0) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - IRQCount=0xFFFF; - } - } -} - -static DECLFW(wrlow) -{ - mapbyte4[A&3]=V; -} - -static DECLFR(rdlow) -{ - return mapbyte4[A&3]; -} - -static void m83prg(void) -{ - ROM_BANK16(0x8000,(mapbyte1[0]&0x3F)); - ROM_BANK16(0xC000,(mapbyte1[0]&0x30)|0xF); -} - -static void m83chr(void) -{ - int x; - for(x=0;x<8;x++) - VROM_BANK1(x*0x400,mapbyte2[x]|((mapbyte1[0]&0x30)<<4)); -} - -static DECLFW(Mapper83_write) -{ - //printf("$%04x:$%02x\n",A,V); - switch(A) - { - case 0x8000: - case 0xB000: - case 0xB0FF: - case 0xB1FF: - { - mapbyte1[0]=V; - m83prg(); - m83chr(); - } - break; - case 0x8100: - switch(V&0x3) - { - case 0x00:MIRROR_SET2(1);break; - case 0x01:MIRROR_SET2(0);break; - case 0x02:onemir(0);break; - case 0x03:onemir(1);break; - } - break; - case 0x8200:IRQCount&=0xFF00;IRQCount|=V;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x8201:IRQa=1;IRQCount&=0xFF;IRQCount|=V<<8;break; - case 0x8300:ROM_BANK8(0x8000,V);break; - case 0x8301:ROM_BANK8(0xA000,V);break; - case 0x8302:ROM_BANK8(0xC000,V);break; - case 0x8310:mapbyte2[0]=V;m83chr();break; - case 0x8311:mapbyte2[1]=V;m83chr();break; - case 0x8312:mapbyte2[2]=V;m83chr();break; - case 0x8313:mapbyte2[3]=V;m83chr();break; - case 0x8314:mapbyte2[4]=V;m83chr();break; - case 0x8315:mapbyte2[5]=V;m83chr();break; - case 0x8316:mapbyte2[6]=V;m83chr();break; - case 0x8317:mapbyte2[7]=V;m83chr();break; - case 0x8318:mapbyte1[1]=V;m83prg();break; - } -// printf("$%04x:$%02x, $%04x\n",A,V,X.PC.W); - -} - -void Mapper83_init(void) -{ - ROM_BANK8(0xc000,0x1e); - ROM_BANK8(0xe000,0x1f); - -// MapIRQHook=m83IRQHook; - -// SetReadHandler(0x5100,0x5103,rdlow); -// SetWriteHandler(0x5100,0x5103,wrlow); - SetWriteHandler(0x8000,0xffff,Mapper83_write); - mapbyte1[1]=0xF; -} -#endif diff --git a/source/mappers/85.c b/source/mappers/85.c deleted file mode 100644 index 93abc78..0000000 --- a/source/mappers/85.c +++ /dev/null @@ -1,195 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define vrctemp mapbyte1[0] -static uint8 indox; - -#include "emu2413.h" - -static int acount=0; - -static OPLL *VRC7Sound=NULL; -static int dwave=0; - -void DoVRC7Sound(void) -{ - int32 z,a; - - if(FSettings.soundq>=1) return; - z=((SOUNDTS<<16)/soundtsinc)>>4; - a=z-dwave; - - moocow(VRC7Sound, &Wave[dwave], a, 1); - - dwave+=a; -} - -void UpdateOPLNEO(int32 *Wave, int Count) -{ - moocow(VRC7Sound, Wave, Count, 4); -} - -void UpdateOPL(int Count) -{ - int32 z,a; - - z=((SOUNDTS<<16)/soundtsinc)>>4; - a=z-dwave; - - if(VRC7Sound && a) - moocow(VRC7Sound, &Wave[dwave], a, 1); - - dwave=0; -} - -static INLINE void DaMirror(int V) -{ - int salpo[4]={MI_V,MI_H,MI_0,MI_1}; - setmirror(salpo[V&3]); -} - -DECLFW(Mapper85_write) -{ - A|=(A&8)<<1; - - if(A>=0xa000 && A<=0xDFFF) - { - // printf("$%04x, $%04x\n",X.PC,A); - A&=0xF010; - { - int x=((A>>4)&1)|((A-0xA000)>>11); - mapbyte3[x]=V; - setchr1(x<<10,V); - } - } - else if(A==0x9030) - { - if(FSettings.SndRate) - { - OPLL_writeReg(VRC7Sound, indox, V); - GameExpSound.Fill=UpdateOPL; - GameExpSound.NeoFill=UpdateOPLNEO; - } - } - else switch(A&0xF010) - { - case 0x8000:mapbyte2[0]=V;setprg8(0x8000,V);break; - case 0x8010:mapbyte2[1]=V;setprg8(0xa000,V);break; - case 0x9000:mapbyte2[2]=V;setprg8(0xc000,V);break; - case 0x9010:indox=V;break; - case 0xe000:mapbyte2[3]=V;DaMirror(V);break; - case 0xE010:IRQLatch=V; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xF000:IRQa=V&2; - vrctemp=V&1; - if(V&2) {IRQCount=IRQLatch;} - acount=0; - X6502_IRQEnd(FCEU_IQEXT); - break; - case 0xf010:if(vrctemp) IRQa=1; - else IRQa=0; - X6502_IRQEnd(FCEU_IQEXT); - break; - } -} - -static void FP_FASTAPASS(1) KonamiIRQHook(int a) -{ - #define ACBOO 341 -// #define ACBOO ((227*2)+1) - if(IRQa) - { - acount+=a*3; - - if(acount>=ACBOO) - { - doagainbub:acount-=ACBOO; - IRQCount++; - if(IRQCount&0x100) {X6502_IRQBegin(FCEU_IQEXT);IRQCount=IRQLatch;} - if(acount>=ACBOO) goto doagainbub; - } - } -} - -void Mapper85_StateRestore(int version) -{ - int x; - - if(version<7200) - { - for(x=0;x<8;x++) - mapbyte3[x]=CHRBankList[x]; - for(x=0;x<3;x++) - mapbyte2[x]=PRGBankList[x]; - mapbyte2[3]=(Mirroring<0x10)?Mirroring:Mirroring-0xE; - } - - for(x=0;x<8;x++) - setchr1(x*0x400,mapbyte3[x]); - for(x=0;x<3;x++) - setprg8(0x8000+x*8192,mapbyte2[x]); - DaMirror(mapbyte2[3]); - //LoadOPL(); -} - -static void M85SC(void) -{ - if(VRC7Sound) - OPLL_set_rate(VRC7Sound, FSettings.SndRate); -} - -static void M85SKill(void) -{ - if(VRC7Sound) - OPLL_delete(VRC7Sound); - VRC7Sound=NULL; -} - -static void VRC7SI(void) -{ - GameExpSound.RChange=M85SC; - GameExpSound.Kill=M85SKill; - - VRC7Sound=OPLL_new(3579545, FSettings.SndRate?FSettings.SndRate:44100); - OPLL_reset(VRC7Sound); - OPLL_reset(VRC7Sound); -} - -void NSFVRC7_Init(void) -{ - SetWriteHandler(0x9010,0x901F,Mapper85_write); - SetWriteHandler(0x9030,0x903F,Mapper85_write); - VRC7SI(); -} - -void Mapper85_init(void) -{ - MapIRQHook=KonamiIRQHook; - SetWriteHandler(0x8000,0xffff,Mapper85_write); - GameStateRestore=Mapper85_StateRestore; - if(!VROM_size) - SetupCartCHRMapping(0, CHRRAM, 8192, 1); - //AddExState(VRC7Instrument, 16, 0, "VC7I"); - //AddExState(VRC7Chan, sizeof(VRC7Chan), 0, "V7CH"); - VRC7SI(); -} diff --git a/source/mappers/86.c b/source/mappers/86.c deleted file mode 100644 index 555784a..0000000 --- a/source/mappers/86.c +++ /dev/null @@ -1,38 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -DECLFW(Mapper86_write) -{ - if(A>=0x6000 && A<=0x6fFF) - { - VROM_BANK8((V&3)|((V>>4)&4)); - ROM_BANK32((V>>4)&3); - } - else - //if(A!=0x6000) - printf("$%04x:$%02x\n",A,V); -} -void Mapper86_init(void) -{ - SetWriteHandler(0x6000,0x6fff,Mapper86_write); - SetWriteHandler(0x4020,0xffff,Mapper86_write); -} diff --git a/source/mappers/88.c b/source/mappers/88.c deleted file mode 100644 index b3a4849..0000000 --- a/source/mappers/88.c +++ /dev/null @@ -1,62 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static int mn; -static DECLFW(Mapper88_write) -{ - //if(A>=0x8002 || A<0x8000) - //if(A==0xc000) - // printf("$%04x:$%02x\n",A,V); - switch(A&0x8001) //&0xc001) - { - case 0x8000:mapbyte1[0]=V; - if(mn) - onemir((V>>6)&1); - break; - case 0x8001: - switch(mapbyte1[0]&7) - { - case 0:VROM_BANK2(0,V>>1);break; - case 1:VROM_BANK2(0x800,V>>1);break; - case 2:VROM_BANK1(0x1000,V|0x40);break; - case 3:VROM_BANK1(0x1400,V|0x40);break; - case 4:VROM_BANK1(0x1800,V|0x40);break; - case 5:VROM_BANK1(0x1c00,V|0x40);break; - case 6:ROM_BANK8(0x8000,V);break; - case 7:ROM_BANK8(0xA000,V);break; - } - break; - - } -} - -void Mapper88_init(void) -{ - mn=0; - SetWriteHandler(0x8000,0xffff,Mapper88_write); -} - -void Mapper154_init(void) -{ - mn=1; - SetWriteHandler(0x8000,0xffff,Mapper88_write); -} diff --git a/source/mappers/89.c b/source/mappers/89.c deleted file mode 100644 index a3a6f09..0000000 --- a/source/mappers/89.c +++ /dev/null @@ -1,34 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -DECLFW(Mapper89_write) -{ - VROM_BANK8((V&7)|((V>>4)&8)); - ROM_BANK16(0x8000,(V>>4)&7); - onemir((V>>3)&1); -} - -void Mapper89_init(void) -{ - Mirroring=0; - SetWriteHandler(0x8000,0xffff,Mapper89_write); -} diff --git a/source/mappers/91.c b/source/mappers/91.c deleted file mode 100644 index 8858103..0000000 --- a/source/mappers/91.c +++ /dev/null @@ -1,59 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static DECLFW(Mapper91_write) -{ -//if(A>=0x7001) -//printf("$%04x:$%02x, %d\n",A,V,scanline); - A&=0xF007; - - if(A>=0x6000 && A<=0x6003) VROM_BANK2((A&3)*2048,V); - else switch(A&0xF003) - { - case 0x7000: - case 0x7001:ROM_BANK8(0x8000+(A&1)*8192,V);break; - case 0x7002:IRQa=IRQCount=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x7003:IRQa=1;X6502_IRQEnd(FCEU_IQEXT);break; -// default: printf("Iyee: $%04x:$%02x\n",A,V);break; - } - //if(A>=0x7000) - // printf("$%04x:$%02x, %d\n",A,V,scanline); -} - -static void Mapper91_hb(void) -{ - if(IRQCount<8 && IRQa) - { - IRQCount++; - if(IRQCount>=8) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -void Mapper91_init(void) -{ - SetWriteHandler(0x4020,0xFFFF,Mapper91_write); - GameHBIRQHook=Mapper91_hb; -} - diff --git a/source/mappers/92.c b/source/mappers/92.c deleted file mode 100644 index e2ad374..0000000 --- a/source/mappers/92.c +++ /dev/null @@ -1,45 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -/* Original code provided by LULU */ - -static DECLFW(Mapper92_write) -{ - uint8 reg=(A&0xF0)>>4; - uint8 bank=A&0xF; - - if(A>=0x9000) - { - if(reg==0xD) ROM_BANK16(0xc000,bank); - else if(reg==0xE) VROM_BANK8(bank); - } - else - { - if(reg==0xB) ROM_BANK16(0xc000,bank); - else if(reg==0x7) VROM_BANK8(bank); - } -} - -void Mapper92_init(void) -{ - SetWriteHandler(0x8000,0xFFFF,Mapper92_write); -} diff --git a/source/mappers/95.c b/source/mappers/95.c deleted file mode 100644 index 87604b7..0000000 --- a/source/mappers/95.c +++ /dev/null @@ -1,136 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint8 lastA; -static uint8 DRegs[8]; -static uint8 cmd; -static uint8 MirCache[8]; - -static SFORMAT DB_StateRegs[]={ - {DRegs, 8, "DREG"}, - {&cmd, 1, "CMD"}, - {&lastA, 1, "LAST"}, - {0} -}; - -static void FP_FASTAPASS(1) dragonbust_ppu(uint32 A) -{ - static int last=-1; - static uint8 z; - - if(A>=0x2000) return; - - A>>=10; - - lastA=A; - - z=MirCache[A]; - if(z!=last) - { - onemir(z); - last=z; - } -} - -static void toot(void) -{ - int x; - - MirCache[0]=MirCache[1]=(DRegs[0]>>4)&1; - MirCache[2]=MirCache[3]=(DRegs[1]>>4)&1; - - for(x=0;x<4;x++) - MirCache[4+x]=(DRegs[2+x]>>5)&1; - onemir(MirCache[lastA]); -} - -static DECLFW(Mapper95_write) -{ - switch(A&0xF001) - { - - case 0x8000: - cmd = V; - break; - - case 0x8001: - switch(cmd&0x07) - { - case 0: DRegs[0]=(V&0x3F)>>1;toot();V>>=1;setchr2(0x0000,V&0x1F);break; - case 1: DRegs[1]=(V&0x3F)>>1;toot();V>>=1;setchr2(0x0800,V&0x1F);break; - case 2: DRegs[2]=V&0x3F;toot();setchr1(0x1000,V&0x1F); break; - case 3: DRegs[3]=V&0x3F;toot();setchr1(0x1400,V&0x1F); break; - case 4: DRegs[4]=V&0x3F;toot();setchr1(0x1800,V&0x1F); break; - case 5: DRegs[5]=V&0x3F;toot();setchr1(0x1C00,V&0x1F); break; - case 6: DRegs[6]=V&0x3F; - setprg8(0x8000,V); - break; - case 7: DRegs[7]=V&0x3F; - setprg8(0xA000,V); - break; - } - break; - } -} - -static void DBSync() -{ - int x; - - setchr2(0x0000,DRegs[0]); - setchr2(0x0800,DRegs[1]); - - for(x=0;x<4;x++) - setchr1(0x1000+x*0x400,DRegs[2+x]); - - setprg8(0x8000,DRegs[6]); - setprg8(0xa000,DRegs[7]); - toot(); -} - -static void DBPower(void) -{ - memset(DRegs,0x3F,8); - DRegs[0]=DRegs[1]=0x1F; - - DBSync(); - - setprg8(0xc000,0x3E); - setprg8(0xe000,0x3F); - - SetReadHandler(0x8000,0xffff,CartBR); - SetWriteHandler(0x8000,0xffff,Mapper95_write); -} - -static void StateRestore(int version) -{ - DBSync(); -} - -void Mapper95_Init(CartInfo *info) -{ - info->Power=DBPower; - AddExState(DB_StateRegs, ~0, 0, 0); - PPU_hook=dragonbust_ppu; - GameStateRestore=StateRestore; -} - diff --git a/source/mappers/97.c b/source/mappers/97.c deleted file mode 100644 index 2990c0e..0000000 --- a/source/mappers/97.c +++ /dev/null @@ -1,42 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - - - -DECLFW(Mapper97_write) -{ -ROM_BANK16(0xC000,V&15); -switch(V>>6) - { - case 0:break; - case 1:MIRROR_SET2(0);break; - case 2:MIRROR_SET2(1);break; - case 3:break; - } -} - -void Mapper97_init(void) -{ - ROM_BANK16(0x8000,~0); - SetWriteHandler(0x8000,0xffff,Mapper97_write); -} - diff --git a/source/mappers/99.c b/source/mappers/99.c deleted file mode 100644 index 03c0416..0000000 --- a/source/mappers/99.c +++ /dev/null @@ -1,37 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static writefunc oldmorko; - -static DECLFW(morko) -{ - VROM_BANK8((V>>2)&1); - oldmorko(A,V); - setprg8(0x8000,V&0x4); /* Special for VS Gumshoe */ -} - -void Mapper99_init(void) -{ - ROM_BANK32(0); - oldmorko=GetWriteHandler(0x4016); - SetWriteHandler(0x4016,0x4016,morko); -} diff --git a/source/mappers/emu2413.c b/source/mappers/emu2413.c deleted file mode 100644 index 67b35dc..0000000 --- a/source/mappers/emu2413.c +++ /dev/null @@ -1,1300 +0,0 @@ -/*********************************************************************************** - - emu2413.c -- YM2413 emulator written by Mitsutaka Okazaki 2001 - - 2001 01-08 : Version 0.10 -- 1st version. - 2001 01-15 : Version 0.20 -- semi-public version. - 2001 01-16 : Version 0.30 -- 1st public version. - 2001 01-17 : Version 0.31 -- Fixed bassdrum problem. - : Version 0.32 -- LPF implemented. - 2001 01-18 : Version 0.33 -- Fixed the drum problem, refine the mix-down method. - -- Fixed the LFO bug. - 2001 01-24 : Version 0.35 -- Fixed the drum problem, - support undocumented EG behavior. - 2001 02-02 : Version 0.38 -- Improved the performance. - Fixed the hi-hat and cymbal model. - Fixed the default percussive datas. - Noise reduction. - Fixed the feedback problem. - 2001 03-03 : Version 0.39 -- Fixed some drum bugs. - Improved the performance. - 2001 03-04 : Version 0.40 -- Improved the feedback. - Change the default table size. - Clock and Rate can be changed during play. - 2001 06-24 : Version 0.50 -- Improved the hi-hat and the cymbal tone. - Added VRC7 patch (OPLL_reset_patch is changed). - Fixed OPLL_reset() bug. - Added OPLL_setMask, OPLL_getMask and OPLL_toggleMask. - Added OPLL_writeIO. - 2001 09-28 : Version 0.51 -- Removed the noise table. - 2002 01-28 : Version 0.52 -- Added Stereo mode. - 2002 02-07 : Version 0.53 -- Fixed some drum bugs. - 2002 02-20 : Version 0.54 -- Added the best quality mode. - 2002 03-02 : Version 0.55 -- Removed OPLL_init & OPLL_close. - 2002 05-30 : Version 0.60 -- Fixed HH&CYM generator and all voice datas. - - 2004 01-24 : Modified by xodnizel to remove code not needed for the VRC7, among other things. - - References: - fmopl.c -- 1999,2000 written by Tatsuyuki Satoh (MAME development). - fmopl.c(fixed) -- (C) 2002 Jarek Burczynski. - s_opl.c -- 2001 written by Mamiya (NEZplug development). - fmgen.cpp -- 1999,2000 written by cisc. - fmpac.ill -- 2000 created by NARUTO. - MSX-Datapack - YMU757 data sheet - YM2143 data sheet - -**************************************************************************************/ -#include -#include -#include -#include -#include "emu2413.h" - -static const unsigned char default_inst[15][8] = { - #include "vrc7tone.h" -}; - -/* Size of Sintable ( 8 -- 18 can be used. 9 recommended.)*/ -#define PG_BITS 9 -#define PG_WIDTH (1<>(b)) - -/* Leave the lower b bit(s). */ -#define LOWBITS(c,b) ((c)&((1<<(b))-1)) - -/* Expand x which is s bits to d bits. */ -#define EXPAND_BITS(x,s,d) ((x)<<((d)-(s))) - -/* Expand x which is s bits to d bits and fill expanded bits '1' */ -#define EXPAND_BITS_X(x,s,d) (((x)<<((d)-(s)))|((1<<((d)-(s)))-1)) - -/* Adjust envelope speed which depends on sampling rate. */ -#define rate_adjust(x) (rate==49716?x:(e_uint32)((double)(x)*clk/72/rate + 0.5)) /* added 0.5 to round the value*/ - -#define MOD(o,x) (&(o)->slot[(x)<<1]) -#define CAR(o,x) (&(o)->slot[((x)<<1)|1]) - -#define BIT(s,b) (((s)>>(b))&1) - -/* Input clock */ -static e_uint32 clk = 844451141; -/* Sampling rate */ -static e_uint32 rate = 3354932; - -/* WaveTable for each envelope amp */ -static e_uint16 fullsintable[PG_WIDTH]; -static e_uint16 halfsintable[PG_WIDTH]; - -static e_uint16 *waveform[2] = { fullsintable, halfsintable }; - -/* LFO Table */ -static e_int32 pmtable[PM_PG_WIDTH]; -static e_int32 amtable[AM_PG_WIDTH]; - -/* Phase delta for LFO */ -static e_uint32 pm_dphase; -static e_uint32 am_dphase; - -/* dB to Liner table */ -static e_int16 DB2LIN_TABLE[(DB_MUTE + DB_MUTE) * 2]; - -/* Liner to Log curve conversion table (for Attack rate). */ -static e_uint16 AR_ADJUST_TABLE[1 << EG_BITS]; - -/* Definition of envelope mode */ -enum -{ SETTLE, ATTACK, DECAY, SUSHOLD, SUSTINE, RELEASE, FINISH }; - -/* Phase incr table for Attack */ -static e_uint32 dphaseARTable[16][16]; -/* Phase incr table for Decay and Release */ -static e_uint32 dphaseDRTable[16][16]; - -/* KSL + TL Table */ -static e_uint32 tllTable[16][8][1 << TL_BITS][4]; -static e_int32 rksTable[2][8][2]; - -/* Phase incr table for PG */ -static e_uint32 dphaseTable[512][8][16]; - -/*************************************************** - - Create tables - -****************************************************/ -INLINE static e_int32 -Min (e_int32 i, e_int32 j) -{ - if (i < j) - return i; - else - return j; -} - -/* Table for AR to LogCurve. */ -static void -makeAdjustTable (void) -{ - e_int32 i; - - AR_ADJUST_TABLE[0] = (1 << EG_BITS); - for (i = 1; i < 128; i++) - AR_ADJUST_TABLE[i] = (e_uint16) ((double) (1 << EG_BITS) - 1 - (1 << EG_BITS) * log (i) / log (128)); -} - - -/* Table for dB(0 -- (1<= DB_MUTE) DB2LIN_TABLE[i] = 0; - DB2LIN_TABLE[i + DB_MUTE + DB_MUTE] = (e_int16) (-DB2LIN_TABLE[i]); - } -} - -/* Liner(+0.0 - +1.0) to dB((1<> (20 - DP_BITS)); -} - -static void -makeTllTable (void) -{ -#define dB2(x) ((x)*2) - - static double kltable[16] = { - dB2 (0.000), dB2 (9.000), dB2 (12.000), dB2 (13.875), dB2 (15.000), dB2 (16.125), dB2 (16.875), dB2 (17.625), - dB2 (18.000), dB2 (18.750), dB2 (19.125), dB2 (19.500), dB2 (19.875), dB2 (20.250), dB2 (20.625), dB2 (21.000) - }; - - e_int32 tmp; - e_int32 fnum, block, TL, KL; - - for (fnum = 0; fnum < 16; fnum++) - for (block = 0; block < 8; block++) - for (TL = 0; TL < 64; TL++) - for (KL = 0; KL < 4; KL++) - { - if (KL == 0) - { - tllTable[fnum][block][TL][KL] = TL2EG (TL); - } - else - { - tmp = (e_int32) (kltable[fnum] - dB2 (3.000) * (7 - block)); - if (tmp <= 0) - tllTable[fnum][block][TL][KL] = TL2EG (TL); - else - tllTable[fnum][block][TL][KL] = (e_uint32) ((tmp >> (3 - KL)) / EG_STEP) + TL2EG (TL); - } - } -} - -#ifdef USE_SPEC_ENV_SPEED -static double attacktime[16][4] = { - {0, 0, 0, 0}, - {1730.15, 1400.60, 1153.43, 988.66}, - {865.08, 700.30, 576.72, 494.33}, - {432.54, 350.15, 288.36, 247.16}, - {216.27, 175.07, 144.18, 123.58}, - {108.13, 87.54, 72.09, 61.79}, - {54.07, 43.77, 36.04, 30.90}, - {27.03, 21.88, 18.02, 15.45}, - {13.52, 10.94, 9.01, 7.72}, - {6.76, 5.47, 4.51, 3.86}, - {3.38, 2.74, 2.25, 1.93}, - {1.69, 1.37, 1.13, 0.97}, - {0.84, 0.70, 0.60, 0.54}, - {0.50, 0.42, 0.34, 0.30}, - {0.28, 0.22, 0.18, 0.14}, - {0.00, 0.00, 0.00, 0.00} -}; - -static double decaytime[16][4] = { - {0, 0, 0, 0}, - {20926.60, 16807.20, 14006.00, 12028.60}, - {10463.30, 8403.58, 7002.98, 6014.32}, - {5231.64, 4201.79, 3501.49, 3007.16}, - {2615.82, 2100.89, 1750.75, 1503.58}, - {1307.91, 1050.45, 875.37, 751.79}, - {653.95, 525.22, 437.69, 375.90}, - {326.98, 262.61, 218.84, 187.95}, - {163.49, 131.31, 109.42, 93.97}, - {81.74, 65.65, 54.71, 46.99}, - {40.87, 32.83, 27.36, 23.49}, - {20.44, 16.41, 13.68, 11.75}, - {10.22, 8.21, 6.84, 5.87}, - {5.11, 4.10, 3.42, 2.94}, - {2.55, 2.05, 1.71, 1.47}, - {1.27, 1.27, 1.27, 1.27} -}; -#endif - -/* Rate Table for Attack */ -static void -makeDphaseARTable (void) -{ - e_int32 AR, Rks, RM, RL; -#ifdef USE_SPEC_ENV_SPEED - e_uint32 attacktable[16][4]; - - for (RM = 0; RM < 16; RM++) - for (RL = 0; RL < 4; RL++) - { - if (RM == 0) - attacktable[RM][RL] = 0; - else if (RM == 15) - attacktable[RM][RL] = EG_DP_WIDTH; - else - attacktable[RM][RL] = (e_uint32) ((double) (1 << EG_DP_BITS) / (attacktime[RM][RL] * 3579545 / 72000)); - - } -#endif - - for (AR = 0; AR < 16; AR++) - for (Rks = 0; Rks < 16; Rks++) - { - RM = AR + (Rks >> 2); - RL = Rks & 3; - if (RM > 15) - RM = 15; - switch (AR) - { - case 0: - dphaseARTable[AR][Rks] = 0; - break; - case 15: - dphaseARTable[AR][Rks] = 0;/*EG_DP_WIDTH;*/ - break; - default: -#ifdef USE_SPEC_ENV_SPEED - dphaseARTable[AR][Rks] = rate_adjust (attacktable[RM][RL]); -#else - dphaseARTable[AR][Rks] = rate_adjust ((3 * (RL + 4) << (RM + 1))); -#endif - break; - } - } -} - -/* Rate Table for Decay and Release */ -static void -makeDphaseDRTable (void) -{ - e_int32 DR, Rks, RM, RL; - -#ifdef USE_SPEC_ENV_SPEED - e_uint32 decaytable[16][4]; - - for (RM = 0; RM < 16; RM++) - for (RL = 0; RL < 4; RL++) - if (RM == 0) - decaytable[RM][RL] = 0; - else - decaytable[RM][RL] = (e_uint32) ((double) (1 << EG_DP_BITS) / (decaytime[RM][RL] * 3579545 / 72000)); -#endif - - for (DR = 0; DR < 16; DR++) - for (Rks = 0; Rks < 16; Rks++) - { - RM = DR + (Rks >> 2); - RL = Rks & 3; - if (RM > 15) - RM = 15; - switch (DR) - { - case 0: - dphaseDRTable[DR][Rks] = 0; - break; - default: -#ifdef USE_SPEC_ENV_SPEED - dphaseDRTable[DR][Rks] = rate_adjust (decaytable[RM][RL]); -#else - dphaseDRTable[DR][Rks] = rate_adjust ((RL + 4) << (RM - 1)); -#endif - break; - } - } -} - -static void -makeRksTable (void) -{ - - e_int32 fnum8, block, KR; - - for (fnum8 = 0; fnum8 < 2; fnum8++) - for (block = 0; block < 8; block++) - for (KR = 0; KR < 2; KR++) - { - if (KR != 0) - rksTable[fnum8][block][KR] = (block << 1) + fnum8; - else - rksTable[fnum8][block][KR] = block >> 1; - } -} - -/************************************************************ - - Calc Parameters - -************************************************************/ - -INLINE static e_uint32 -calc_eg_dphase (OPLL_SLOT * slot) -{ - - switch (slot->eg_mode) - { - case ATTACK: - return dphaseARTable[slot->patch.AR][slot->rks]; - - case DECAY: - return dphaseDRTable[slot->patch.DR][slot->rks]; - - case SUSHOLD: - return 0; - - case SUSTINE: - return dphaseDRTable[slot->patch.RR][slot->rks]; - - case RELEASE: - if (slot->sustine) - return dphaseDRTable[5][slot->rks]; - else if (slot->patch.EG) - return dphaseDRTable[slot->patch.RR][slot->rks]; - else - return dphaseDRTable[7][slot->rks]; - - case FINISH: - return 0; - - default: - return 0; - } -} - -/************************************************************* - - OPLL internal interfaces - -*************************************************************/ - -#define UPDATE_PG(S) (S)->dphase = dphaseTable[(S)->fnum][(S)->block][(S)->patch.ML] -#define UPDATE_TLL(S)\ -(((S)->type==0)?\ -((S)->tll = tllTable[((S)->fnum)>>5][(S)->block][(S)->patch.TL][(S)->patch.KL]):\ -((S)->tll = tllTable[((S)->fnum)>>5][(S)->block][(S)->volume][(S)->patch.KL])) -#define UPDATE_RKS(S) (S)->rks = rksTable[((S)->fnum)>>8][(S)->block][(S)->patch.KR] -#define UPDATE_WF(S) (S)->sintbl = waveform[(S)->patch.WF] -#define UPDATE_EG(S) (S)->eg_dphase = calc_eg_dphase(S) -#define UPDATE_ALL(S)\ - UPDATE_PG(S);\ - UPDATE_TLL(S);\ - UPDATE_RKS(S);\ - UPDATE_WF(S); \ - UPDATE_EG(S) /* EG should be updated last. */ - - -/* Slot key on */ -INLINE static void -slotOn (OPLL_SLOT * slot) -{ - slot->eg_mode = ATTACK; - slot->eg_phase = 0; - slot->phase = 0; -} - -/* Slot key on without reseting the phase */ -INLINE static void -slotOn2 (OPLL_SLOT * slot) -{ - slot->eg_mode = ATTACK; - slot->eg_phase = 0; -} - -/* Slot key off */ -INLINE static void -slotOff (OPLL_SLOT * slot) -{ - if (slot->eg_mode == ATTACK) - slot->eg_phase = EXPAND_BITS (AR_ADJUST_TABLE[HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS)], EG_BITS, EG_DP_BITS); - slot->eg_mode = RELEASE; -} - -/* Channel key on */ -INLINE static void -keyOn (OPLL * opll, e_int32 i) -{ - if (!opll->slot_on_flag[i * 2]) - slotOn (MOD(opll,i)); - if (!opll->slot_on_flag[i * 2 + 1]) - slotOn (CAR(opll,i)); - opll->key_status[i] = 1; -} - -/* Channel key off */ -INLINE static void -keyOff (OPLL * opll, e_int32 i) -{ - if (opll->slot_on_flag[i * 2 + 1]) - slotOff (CAR(opll,i)); - opll->key_status[i] = 0; -} - -/* Set sustine parameter */ -INLINE static void -setSustine (OPLL * opll, e_int32 c, e_int32 sustine) -{ - CAR(opll,c)->sustine = sustine; - if (MOD(opll,c)->type) - MOD(opll,c)->sustine = sustine; -} - -/* Volume : 6bit ( Volume register << 2 ) */ -INLINE static void -setVolume (OPLL * opll, e_int32 c, e_int32 volume) -{ - CAR(opll,c)->volume = volume; -} - -INLINE static void -setSlotVolume (OPLL_SLOT * slot, e_int32 volume) -{ - slot->volume = volume; -} - -/* Set F-Number ( fnum : 9bit ) */ -INLINE static void -setFnumber (OPLL * opll, e_int32 c, e_int32 fnum) -{ - CAR(opll,c)->fnum = fnum; - MOD(opll,c)->fnum = fnum; -} - -/* Set Block data (block : 3bit ) */ -INLINE static void -setBlock (OPLL * opll, e_int32 c, e_int32 block) -{ - CAR(opll,c)->block = block; - MOD(opll,c)->block = block; -} - -INLINE static void update_key_status (OPLL * opll) -{ - int ch; - - for (ch = 0; ch < 6; ch++) - opll->slot_on_flag[ch * 2] = opll->slot_on_flag[ch * 2 + 1] = (opll->HiFreq[ch]) & 0x10; -} - -/*********************************************************** - - Initializing - -***********************************************************/ - -static void -OPLL_SLOT_reset (OPLL_SLOT * slot, int type) -{ - slot->type = type; - slot->sintbl = waveform[0]; - slot->phase = 0; - slot->dphase = 0; - slot->output[0] = 0; - slot->output[1] = 0; - slot->feedback = 0; - slot->eg_mode = SETTLE; - slot->eg_phase = EG_DP_WIDTH; - slot->eg_dphase = 0; - slot->rks = 0; - slot->tll = 0; - slot->sustine = 0; - slot->fnum = 0; - slot->block = 0; - slot->volume = 0; - slot->pgout = 0; - slot->egout = 0; -} - -static void -internal_refresh (void) -{ - makeDphaseTable (); - makeDphaseARTable (); - makeDphaseDRTable (); - pm_dphase = (e_uint32) rate_adjust (PM_SPEED * PM_DP_WIDTH / (clk / 72)); - am_dphase = (e_uint32) rate_adjust (AM_SPEED * AM_DP_WIDTH / (clk / 72)); -} - -static void -maketables (e_uint32 c, e_uint32 r) -{ - if (c != clk) - { - clk = c; - makePmTable (); - makeAmTable (); - makeDB2LinTable (); - makeAdjustTable (); - makeTllTable (); - makeRksTable (); - makeSinTable (); - //makeDefaultPatch (); - } - - if (r != rate) - { - rate = r; - internal_refresh (); - } -} - -OPLL *OPLL_new (e_uint32 clk, e_uint32 rate) -{ - OPLL *opll; - - maketables (clk, rate); - - opll = (OPLL *) calloc (sizeof (OPLL), 1); - if (opll == NULL) - return NULL; - - opll->mask = 0; - - OPLL_reset (opll); - - return opll; -} - - -void -OPLL_delete (OPLL * opll) -{ - free (opll); -} - -/* Reset whole of OPLL except patch datas. */ -void -OPLL_reset (OPLL * opll) -{ - e_int32 i; - - if (!opll) - return; - - opll->adr = 0; - opll->out = 0; - - opll->pm_phase = 0; - opll->am_phase = 0; - - opll->mask = 0; - - for (i = 0; i < 12; i++) - OPLL_SLOT_reset(&opll->slot[i], i%2); - - for (i = 0; i < 6; i++) - { - opll->key_status[i] = 0; - //setPatch (opll, i, 0); - } - - for (i = 0; i < 0x40; i++) - OPLL_writeReg (opll, i, 0); - -#ifndef EMU2413_COMPACTION - opll->realstep = (e_uint32) ((1 << 31) / rate); - opll->opllstep = (e_uint32) ((1 << 31) / (clk / 72)); - opll->oplltime = 0; -#endif -} - -/* Force Refresh (When external program changes some parameters). */ -void -OPLL_forceRefresh (OPLL * opll) -{ - e_int32 i; - - if (opll == NULL) - return; - - for (i = 0; i < 12; i++) - { - UPDATE_PG (&opll->slot[i]); - UPDATE_RKS (&opll->slot[i]); - UPDATE_TLL (&opll->slot[i]); - UPDATE_WF (&opll->slot[i]); - UPDATE_EG (&opll->slot[i]); - } -} - -void -OPLL_set_rate (OPLL * opll, e_uint32 r) -{ - if (opll->quality) - rate = 49716; - else - rate = r; - internal_refresh (); - rate = r; -} - -void -OPLL_set_quality (OPLL * opll, e_uint32 q) -{ - opll->quality = q; - OPLL_set_rate (opll, rate); -} - -/********************************************************* - - Generate wave data - -*********************************************************/ -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 2PI). */ -#if ( SLOT_AMP_BITS - PG_BITS ) > 0 -#define wave2_2pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS )) -#else -#define wave2_2pi(e) ( (e) << ( PG_BITS - SLOT_AMP_BITS )) -#endif - -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 4PI). */ -#if ( SLOT_AMP_BITS - PG_BITS - 1 ) == 0 -#define wave2_4pi(e) (e) -#elif ( SLOT_AMP_BITS - PG_BITS - 1 ) > 0 -#define wave2_4pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS - 1 )) -#else -#define wave2_4pi(e) ( (e) << ( 1 + PG_BITS - SLOT_AMP_BITS )) -#endif - -/* Convert Amp(0 to EG_HEIGHT) to Phase(0 to 8PI). */ -#if ( SLOT_AMP_BITS - PG_BITS - 2 ) == 0 -#define wave2_8pi(e) (e) -#elif ( SLOT_AMP_BITS - PG_BITS - 2 ) > 0 -#define wave2_8pi(e) ( (e) >> ( SLOT_AMP_BITS - PG_BITS - 2 )) -#else -#define wave2_8pi(e) ( (e) << ( 2 + PG_BITS - SLOT_AMP_BITS )) -#endif - - - -/* Update AM, PM unit */ -static void -update_ampm (OPLL * opll) -{ - opll->pm_phase = (opll->pm_phase + pm_dphase) & (PM_DP_WIDTH - 1); - opll->am_phase = (opll->am_phase + am_dphase) & (AM_DP_WIDTH - 1); - opll->lfo_am = amtable[HIGHBITS (opll->am_phase, AM_DP_BITS - AM_PG_BITS)]; - opll->lfo_pm = pmtable[HIGHBITS (opll->pm_phase, PM_DP_BITS - PM_PG_BITS)]; -} - -/* PG */ -INLINE static void -calc_phase (OPLL_SLOT * slot, e_int32 lfo) -{ - if (slot->patch.PM) - slot->phase += (slot->dphase * lfo) >> PM_AMP_BITS; - else - slot->phase += slot->dphase; - - slot->phase &= (DP_WIDTH - 1); - - slot->pgout = HIGHBITS (slot->phase, DP_BASE_BITS); -} - -/* EG */ -static void -calc_envelope (OPLL_SLOT * slot, e_int32 lfo) -{ -#define S2E(x) (SL2EG((e_int32)(x/SL_STEP))<<(EG_DP_BITS-EG_BITS)) - - static e_uint32 SL[16] = { - S2E (0.0), S2E (3.0), S2E (6.0), S2E (9.0), S2E (12.0), S2E (15.0), S2E (18.0), S2E (21.0), - S2E (24.0), S2E (27.0), S2E (30.0), S2E (33.0), S2E (36.0), S2E (39.0), S2E (42.0), S2E (48.0) - }; - - e_uint32 egout; - - switch (slot->eg_mode) - { - - case ATTACK: - egout = AR_ADJUST_TABLE[HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS)]; - slot->eg_phase += slot->eg_dphase; - if((EG_DP_WIDTH & slot->eg_phase)||(slot->patch.AR==15)) - { - egout = 0; - slot->eg_phase = 0; - slot->eg_mode = DECAY; - UPDATE_EG (slot); - } - break; - - case DECAY: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - slot->eg_phase += slot->eg_dphase; - if (slot->eg_phase >= SL[slot->patch.SL]) - { - if (slot->patch.EG) - { - slot->eg_phase = SL[slot->patch.SL]; - slot->eg_mode = SUSHOLD; - UPDATE_EG (slot); - } - else - { - slot->eg_phase = SL[slot->patch.SL]; - slot->eg_mode = SUSTINE; - UPDATE_EG (slot); - } - } - break; - - case SUSHOLD: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - if (slot->patch.EG == 0) - { - slot->eg_mode = SUSTINE; - UPDATE_EG (slot); - } - break; - - case SUSTINE: - case RELEASE: - egout = HIGHBITS (slot->eg_phase, EG_DP_BITS - EG_BITS); - slot->eg_phase += slot->eg_dphase; - if (egout >= (1 << EG_BITS)) - { - slot->eg_mode = FINISH; - egout = (1 << EG_BITS) - 1; - } - break; - - case FINISH: - egout = (1 << EG_BITS) - 1; - break; - - default: - egout = (1 << EG_BITS) - 1; - break; - } - - if (slot->patch.AM) - egout = EG2DB (egout + slot->tll) + lfo; - else - egout = EG2DB (egout + slot->tll); - - if (egout >= DB_MUTE) - egout = DB_MUTE - 1; - - slot->egout = egout; -} - -/* CARRIOR */ -INLINE static e_int32 -calc_slot_car (OPLL_SLOT * slot, e_int32 fm) -{ - slot->output[1] = slot->output[0]; - - if (slot->egout >= (DB_MUTE - 1)) - { - slot->output[0] = 0; - } - else - { - slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout+wave2_8pi(fm))&(PG_WIDTH-1)] + slot->egout]; - } - - return (slot->output[1] + slot->output[0]) >> 1; -} - -/* MODULATOR */ -INLINE static e_int32 -calc_slot_mod (OPLL_SLOT * slot) -{ - e_int32 fm; - - slot->output[1] = slot->output[0]; - - if (slot->egout >= (DB_MUTE - 1)) - { - slot->output[0] = 0; - } - else if (slot->patch.FB != 0) - { - fm = wave2_4pi (slot->feedback) >> (7 - slot->patch.FB); - slot->output[0] = DB2LIN_TABLE[slot->sintbl[(slot->pgout + fm)&(PG_WIDTH-1)] + slot->egout]; - } - else - { - slot->output[0] = DB2LIN_TABLE[slot->sintbl[slot->pgout] + slot->egout]; - } - - slot->feedback = (slot->output[1] + slot->output[0]) >> 1; - - return slot->feedback; - -} - -static INLINE e_int16 calc (OPLL * opll) -{ - e_int32 inst = 0, out = 0; - e_int32 i; - - update_ampm (opll); - - for (i = 0; i < 12; i++) - { - calc_phase(&opll->slot[i],opll->lfo_pm); - calc_envelope(&opll->slot[i],opll->lfo_am); - } - - for (i = 0; i < 6; i++) - if (!(opll->mask & OPLL_MASK_CH (i)) && (CAR(opll,i)->eg_mode != FINISH)) - inst += calc_slot_car (CAR(opll,i), calc_slot_mod(MOD(opll,i))); - - out = inst; - return (e_int16) out; -} - -void moocow(OPLL* opll, e_int32 *buf, e_int32 len, int shift) -{ - while(len > 0) - { - *buf+=(calc(opll)+32768)<quality) - return calc (opll); - - while (opll->realstep > opll->oplltime) - { - opll->oplltime += opll->opllstep; - opll->prev = opll->next; - opll->next = calc (opll); - } - - opll->oplltime -= opll->realstep; - opll->out = (e_int16) (((double) opll->next * (opll->opllstep - opll->oplltime) - + (double) opll->prev * opll->oplltime) / opll->opllstep); - - return (e_int16) opll->out; -} -#endif - -e_uint32 -OPLL_setMask (OPLL * opll, e_uint32 mask) -{ - e_uint32 ret; - - if (opll) - { - ret = opll->mask; - opll->mask = mask; - return ret; - } - else - return 0; -} - -e_uint32 -OPLL_toggleMask (OPLL * opll, e_uint32 mask) -{ - e_uint32 ret; - - if (opll) - { - ret = opll->mask; - opll->mask ^= mask; - return ret; - } - else - return 0; -} - -/**************************************************** - - I/O Ctrl - -*****************************************************/ - -static void setInstrument(OPLL * opll, e_uint i, e_uint inst) -{ - const e_uint8 *src; - OPLL_PATCH *modp, *carp; - - opll->patch_number[i]=inst; - - if(inst) - src=default_inst[inst-1]; - else - src=opll->CustInst; - - modp=&MOD(opll,i)->patch; - carp=&CAR(opll,i)->patch; - - modp->AM=(src[0]>>7)&1; - modp->PM=(src[0]>>6)&1; - modp->EG=(src[0]>>5)&1; - modp->KR=(src[0]>>4)&1; - modp->ML=(src[0]&0xF); - - carp->AM=(src[1]>>7)&1; - carp->PM=(src[1]>>6)&1; - carp->EG=(src[1]>>5)&1; - carp->KR=(src[1]>>4)&1; - carp->ML=(src[1]&0xF); - - modp->KL=(src[2]>>6)&3; - modp->TL=(src[2]&0x3F); - - carp->KL = (src[3] >> 6) & 3; - carp->WF = (src[3] >> 4) & 1; - - modp->WF = (src[3] >> 3) & 1; - - modp->FB = (src[3]) & 7; - - modp->AR = (src[4]>>4)&0xF; - modp->DR = (src[4]&0xF); - - carp->AR = (src[5]>>4)&0xF; - carp->DR = (src[5]&0xF); - - modp->SL = (src[6]>>4)&0xF; - modp->RR = (src[6]&0xF); - - carp->SL = (src[7]>>4)&0xF; - carp->RR = (src[7]&0xF); -} - - -void -OPLL_writeReg (OPLL * opll, e_uint32 reg, e_uint32 data) -{ - - e_int32 i, v, ch; - - data = data & 0xff; - reg = reg & 0x3f; - - switch (reg) - { - case 0x00: - opll->CustInst[0]=data; - for (i = 0; i < 6; i++) - { - if (opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_PG (MOD(opll,i)); - UPDATE_RKS (MOD(opll,i)); - UPDATE_EG (MOD(opll,i)); - } - } - break; - - case 0x01: - opll->CustInst[1]=data; - for (i = 0; i < 6; i++) - { - if (opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_PG (CAR(opll,i)); - UPDATE_RKS (CAR(opll,i)); - UPDATE_EG (CAR(opll,i)); - } - } - break; - - case 0x02: - opll->CustInst[2]=data; - for (i = 0; i < 6; i++) - { - if (opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_TLL(MOD(opll,i)); - } - } - break; - - case 0x03: - opll->CustInst[3]=data; - for (i = 0; i < 6; i++) - { - if (opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_WF(MOD(opll,i)); - UPDATE_WF(CAR(opll,i)); - } - } - break; - - case 0x04: - opll->CustInst[4]=data; - for (i = 0; i < 6; i++) - { - if (opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_EG (MOD(opll,i)); - } - } - break; - - case 0x05: - opll->CustInst[5]=data; - for (i = 0; i < 6; i++) - { - if (opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_EG(CAR(opll,i)); - } - } - break; - - case 0x06: - opll->CustInst[6]=data; - for (i = 0; i < 6; i++) - { - if (opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_EG (MOD(opll,i)); - } - } - break; - - case 0x07: - opll->CustInst[7]=data; - for (i = 0; i < 6; i++) - { - if (opll->patch_number[i] == 0) - { - setInstrument(opll, i, 0); - UPDATE_EG (CAR(opll,i)); - } - } - break; - - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - ch = reg - 0x10; - opll->LowFreq[ch]=data; - setFnumber (opll, ch, data + ((opll->HiFreq[ch] & 1) << 8)); - UPDATE_ALL (MOD(opll,ch)); - UPDATE_ALL (CAR(opll,ch)); - break; - - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - ch = reg - 0x20; - opll->HiFreq[ch]=data; - - setFnumber (opll, ch, ((data & 1) << 8) + opll->LowFreq[ch]); - setBlock (opll, ch, (data >> 1) & 7); - setSustine (opll, ch, (data >> 5) & 1); - if (data & 0x10) - keyOn (opll, ch); - else - keyOff (opll, ch); - UPDATE_ALL (MOD(opll,ch)); - UPDATE_ALL (CAR(opll,ch)); - update_key_status (opll); - break; - - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - opll->InstVol[reg-0x30]=data; - i = (data >> 4) & 15; - v = data & 15; - setInstrument(opll, reg-0x30, i); - setVolume (opll, reg - 0x30, v << 2); - UPDATE_ALL (MOD(opll,reg - 0x30)); - UPDATE_ALL (CAR(opll,reg - 0x30)); - break; - - default: - break; - - } -} - -void -OPLL_writeIO (OPLL * opll, e_uint32 adr, e_uint32 val) -{ - if (adr & 1) - OPLL_writeReg (opll, opll->adr, val); - else - opll->adr = val; -} - diff --git a/source/mappers/emu2413.h b/source/mappers/emu2413.h deleted file mode 100644 index b5a9e34..0000000 --- a/source/mappers/emu2413.h +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef _EMU2413_H_ -#define _EMU2413_H_ - -#include "emutypes.h" - -#ifdef EMU2413_DLL_EXPORTS - #define EMU2413_API __declspec(dllexport) -#elif defined(EMU2413_DLL_IMPORTS) - #define EMU2413_API __declspec(dllimport) -#else - #define EMU2413_API -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define PI 3.14159265358979323846 - -enum {OPLL_VRC7_TONE=0} ; - -/* voice data */ -typedef struct { - e_uint32 TL,FB,EG,ML,AR,DR,SL,RR,KR,KL,AM,PM,WF ; -} OPLL_PATCH ; - -/* slot */ -typedef struct { - - OPLL_PATCH patch; - - e_int32 type ; /* 0 : modulator 1 : carrier */ - - /* OUTPUT */ - e_int32 feedback ; - e_int32 output[2] ; /* Output value of slot */ - - /* for Phase Generator (PG) */ - e_uint16 *sintbl ; /* Wavetable */ - e_uint32 phase ; /* Phase */ - e_uint32 dphase ; /* Phase increment amount */ - e_uint32 pgout ; /* output */ - - /* for Envelope Generator (EG) */ - e_int32 fnum ; /* F-Number */ - e_int32 block ; /* Block */ - e_int32 volume ; /* Current volume */ - e_int32 sustine ; /* Sustine 1 = ON, 0 = OFF */ - e_uint32 tll ; /* Total Level + Key scale level*/ - e_uint32 rks ; /* Key scale offset (Rks) */ - e_int32 eg_mode ; /* Current state */ - e_uint32 eg_phase ; /* Phase */ - e_uint32 eg_dphase ; /* Phase increment amount */ - e_uint32 egout ; /* output */ - -} OPLL_SLOT ; - -/* Mask */ -#define OPLL_MASK_CH(x) (1<<(x)) - -/* opll */ -typedef struct { - - e_uint32 adr ; - e_int32 out ; - -#ifndef EMU2413_COMPACTION - e_uint32 realstep ; - e_uint32 oplltime ; - e_uint32 opllstep ; - e_int32 prev, next ; -#endif - - /* Register */ - e_uint8 LowFreq[6]; - e_uint8 HiFreq[6]; - e_uint8 InstVol[6]; - - e_uint8 CustInst[8]; - - e_int32 slot_on_flag[6 * 2] ; - - /* Pitch Modulator */ - e_uint32 pm_phase ; - e_int32 lfo_pm ; - - /* Amp Modulator */ - e_int32 am_phase ; - e_int32 lfo_am ; - - e_uint32 quality; - - /* Channel Data */ - e_int32 patch_number[6]; - e_int32 key_status[6] ; - - /* Slot */ - OPLL_SLOT slot[6 * 2] ; - - e_uint32 mask ; - -} OPLL ; - -/* Create Object */ -EMU2413_API OPLL *OPLL_new(e_uint32 clk, e_uint32 rate) ; -EMU2413_API void OPLL_delete(OPLL *) ; - -/* Setup */ -EMU2413_API void OPLL_reset(OPLL *) ; -EMU2413_API void OPLL_set_rate(OPLL *opll, e_uint32 r) ; -EMU2413_API void OPLL_set_quality(OPLL *opll, e_uint32 q) ; - -/* Port/Register access */ -EMU2413_API void OPLL_writeIO(OPLL *, e_uint32 reg, e_uint32 val) ; -EMU2413_API void OPLL_writeReg(OPLL *, e_uint32 reg, e_uint32 val) ; - -/* Synthsize */ -EMU2413_API e_int16 OPLL_calc(OPLL *) ; - -/* Misc */ -EMU2413_API void OPLL_forceRefresh(OPLL *) ; - -/* Channel Mask */ -EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ; -EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ; - - -void moocow(OPLL* opll, e_int32 *buf, e_int32 len, int shift); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/source/mappers/emutypes.h b/source/mappers/emutypes.h deleted file mode 100644 index fdef420..0000000 --- a/source/mappers/emutypes.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _EMUTYPES_H_ -#define _EMUTYPES_H_ - -#ifndef INLINE - -#if defined(_MSC_VER) -#define INLINE __forceinline -#elif defined(__GNUC__) -#define INLINE __inline__ -#elif defined(_MWERKS_) -#define INLINE inline -#else -#define INLINE -#endif -#endif - -#if defined(EMU_DLL_IMPORTS) -#define EMU2149_DLL_IMPORTS -#define EMU2212_DLL_IMPORTS -#define EMU2413_DLL_IMPORTS -#define EMU8950_DLL_IMPORTS -#define EMU76489_DLL_IMPORTS -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef unsigned int e_uint; -typedef signed int e_int; - -typedef unsigned char e_uint8 ; -typedef signed char e_int8 ; - -typedef unsigned short e_uint16 ; -typedef signed short e_int16 ; - -typedef unsigned int e_uint32 ; -typedef signed int e_int32 ; - -#ifdef __cplusplus -} -#endif -#endif diff --git a/source/mappers/mapinc.h b/source/mappers/mapinc.h deleted file mode 100644 index 745213d..0000000 --- a/source/mappers/mapinc.h +++ /dev/null @@ -1,12 +0,0 @@ -#include "../types.h" -#include "../x6502.h" -#include "../fceu.h" -#include "../ppu.h" -#define INESPRIV -#include "../cart.h" -#include "../ines.h" -#include "../memory.h" -#include "../sound.h" -#include "../state.h" -#include "mapshare.h" -#include diff --git a/source/mappers/mapshare.h b/source/mappers/mapshare.h deleted file mode 100644 index 4853050..0000000 --- a/source/mappers/mapshare.h +++ /dev/null @@ -1,5 +0,0 @@ -void MMC3_hb(void); - -#define resetmode mapbyte1[0] -#define MMC3_cmd mapbyte1[1] - diff --git a/source/mappers/mmc2and4.c b/source/mappers/mmc2and4.c deleted file mode 100644 index 12ff38c..0000000 --- a/source/mappers/mmc2and4.c +++ /dev/null @@ -1,121 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -#define MMC4reg mapbyte1 -#define latcha1 mapbyte2[0] -#define latcha2 mapbyte2[1] - - -static void FP_FASTAPASS(1) latchcheck(uint32 VAddr) -{ - uint8 l,h; - - h=VAddr>>8; - - if(h>=0x20 || ((h&0xF)!=0xF)) - return; - - l=VAddr&0xF0; - - if(h<0x10) - { - if(l==0xD0) - { - VROM_BANK4(0x0000,MMC4reg[0]); - latcha1=0xFD; - } - else if(l==0xE0) - { - VROM_BANK4(0x0000,MMC4reg[1]); - latcha1=0xFE; - } - } - else - { - if(l==0xD0) - { - VROM_BANK4(0x1000,MMC4reg[2]); - latcha2=0xFD; - } - else if(l==0xE0) - { - VROM_BANK4(0x1000,MMC4reg[3]); - latcha2=0xFE; - } - } -} - -DECLFW(Mapper9_write) // $Axxx -{ - ROM_BANK8(0x8000,V); -} - -DECLFW(Mapper10_write) -{ - ROM_BANK16(0x8000,V); -} - -DECLFW(Mapper9and10_write) -{ - switch(A&0xF000) - { - case 0xB000: - if (latcha1==0xFD) { VROM_BANK4(0x0000,V);} - MMC4reg[0]=V; - break; - case 0xC000: - if (latcha1==0xFE) {VROM_BANK4(0x0000,V);} - MMC4reg[1]=V; - break; - case 0xD000: - if (latcha2==0xFD) {VROM_BANK4(0x1000,V);} - MMC4reg[2]=V; - break; - case 0xE000: - if (latcha2==0xFE) {VROM_BANK4(0x1000,V);} - MMC4reg[3]=V; - break; - case 0xF000: - MIRROR_SET(V&1); - break; - } -} - -void Mapper9_init(void) -{ - latcha1=0xFE; - latcha2=0xFE; - ROM_BANK8(0xA000,~2); - ROM_BANK8(0x8000,0); - SetWriteHandler(0xA000,0xAFFF,Mapper9_write); - SetWriteHandler(0xB000,0xFFFF,Mapper9and10_write); - PPU_hook=latchcheck; -} - -void Mapper10_init(void) -{ - latcha1=latcha2=0xFE; - SetWriteHandler(0xA000,0xAFFF,Mapper10_write); - SetWriteHandler(0xB000,0xFFFF,Mapper9and10_write); - PPU_hook=latchcheck; -} - diff --git a/source/mappers/subor.c b/source/mappers/subor.c deleted file mode 100644 index 9f0386d..0000000 --- a/source/mappers/subor.c +++ /dev/null @@ -1,79 +0,0 @@ -#include "mapinc.h" - -static uint8 mode; -static uint8 DRegs[4]; - -static SFORMAT StateRegs[]= -{ - {DRegs, 4, "DREG"}, - {0} -}; - -static void Sync(void) -{ - int base, bank; - base = ((DRegs[0]^DRegs[1])&0x10)<<1; - bank = (DRegs[2]^DRegs[3])&0x1f; - - if(DRegs[1]&0x08) - { - bank &= 0xfe; - if(mode==0) - { - setprg16(0x8000,base+bank+1); - setprg16(0xC000,base+bank+0); - } - else - { - setprg16(0x8000,base+bank+0); - setprg16(0xC000,base+bank+1); - } - } - else - { - if(DRegs[1]&0x04) - { - setprg16(0x8000,0x1f); - setprg16(0xC000,base+bank); - } - else - { - setprg16(0x8000,base+bank); - if(mode==0) - setprg16(0xC000,0x20); - else - setprg16(0xC000,0x07); - } - } -} - -static DECLFW(Mapper167_write) -{ - DRegs[(A>>13)&0x03]=V; - Sync(); -} - -static void StateRestore(int version) -{ - Sync(); -} - -void Mapper166_init(void) -{ - mode=1; - DRegs[0]=DRegs[1]=DRegs[2]=DRegs[3]=0; - Sync(); - SetWriteHandler(0x8000,0xFFFF,Mapper167_write); - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper167_init(void) -{ - mode=0; - DRegs[0]=DRegs[1]=DRegs[2]=DRegs[3]=0; - Sync(); - SetWriteHandler(0x8000,0xFFFF,Mapper167_write); - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/source/mappers/vrc7tone.h b/source/mappers/vrc7tone.h deleted file mode 100644 index d136307..0000000 --- a/source/mappers/vrc7tone.h +++ /dev/null @@ -1,17 +0,0 @@ -/* VRC7 instruments, January 17, 2004 update -Xodnizel */ - {0x03, 0x21, 0x04, 0x06, 0x8D, 0xF2, 0x42, 0x17}, - {0x13, 0x41, 0x05, 0x0E, 0x99, 0x96, 0x63, 0x12}, - {0x31, 0x11, 0x10, 0x0A, 0xF0, 0x9C, 0x32, 0x02}, - {0x21, 0x61, 0x1D, 0x07, 0x9F, 0x64, 0x20, 0x27}, - {0x22, 0x21, 0x1E, 0x06, 0xF0, 0x76, 0x08, 0x28}, - {0x02, 0x01, 0x06, 0x00, 0xF0, 0xF2, 0x03, 0x95}, - {0x21, 0x61, 0x1C, 0x07, 0x82, 0x81, 0x16, 0x07}, - {0x23, 0x21, 0x1A, 0x17, 0xEF, 0x82, 0x25, 0x15}, - {0x25, 0x11, 0x1F, 0x00, 0x86, 0x41, 0x20, 0x11}, - {0x85, 0x01, 0x1F, 0x0F, 0xE4, 0xA2, 0x11, 0x12}, - {0x07, 0xC1, 0x2B, 0x45, 0xB4, 0xF1, 0x24, 0xF4}, - {0x61, 0x23, 0x11, 0x06, 0x96, 0x96, 0x13, 0x16}, - {0x01, 0x02, 0xD3, 0x05, 0x82, 0xA2, 0x31, 0x51}, - {0x61, 0x22, 0x0D, 0x02, 0xC3, 0x7F, 0x24, 0x05}, - {0x21, 0x62, 0x0E, 0x00, 0xA1, 0xA0, 0x44, 0x17}, - diff --git a/source/mbshare/164.c b/source/mbshare/164.c deleted file mode 100644 index 60bda02..0000000 --- a/source/mbshare/164.c +++ /dev/null @@ -1,117 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint8 cmd; -static uint8 DRegs[8]; -static SFORMAT StateRegs[]= -{ - {&cmd, 1, "CMD"}, - {DRegs, 8, "DREG"}, - {0} -}; - -static void Sync(void) -{ - setprg32(0x8000,(DRegs[0]<<4)|(DRegs[1]&0xF)); - setchr8(0); -} - -static void StateRestore(int version) -{ - Sync(); -} - -static DECLFW(Write) -{ - switch (A&0x7300) - { - case 0x5100: DRegs[0]=V; Sync(); break; - case 0x5000: DRegs[1]=V; Sync(); break; - } -} - -static DECLFW(Write2) -{ -// FCEU_printf("bs %04x %02x\n",A,V); - switch (A&0x7300) - { - case 0x5200: DRegs[0]=V; Sync(); break; - case 0x5000: DRegs[1]=V; Sync(); break; - } -} - -static uint8 WRAM[8192]; -static DECLFR(AWRAM) -{ - return(WRAM[A-0x6000]); -} - -static DECLFW(BWRAM) -{ - WRAM[A-0x6000]=V; -} - -static void Power(void) -{ - memset(DRegs,0,8); - DRegs[1]=0xFF; - cmd=0; - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x4020,0x5FFF,Write); - SetReadHandler(0x6000,0x7FFF,AWRAM); - SetWriteHandler(0x6000,0x7FFF,BWRAM); - Sync(); -} - -static void M163HB(void) -{ - if(scanline==127&&DRegs[1]&0x80) - setchr4(0x0000,1); -} - - -static void Power2(void) -{ - memset(DRegs,0,8); - DRegs[1]=0xFF; - cmd=0; - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x4020,0x5FFF,Write2); - SetReadHandler(0x6000,0x7FFF,AWRAM); - SetWriteHandler(0x6000,0x7FFF,BWRAM); - Sync(); -} - -void Mapper164_Init(CartInfo *info) -{ - info->Power=Power; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} - -void Mapper163_Init(CartInfo *info) -{ - info->Power=Power2; - GameHBIRQHook=M163HB; - GameStateRestore=StateRestore; - AddExState(&StateRegs, ~0, 0, 0); -} diff --git a/source/mbshare/199.c b/source/mbshare/199.c deleted file mode 100644 index d4b0160..0000000 --- a/source/mbshare/199.c +++ /dev/null @@ -1,95 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Dragon Ball Z 2 - Gekishin Freeza! (C) - * Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C) - * San Guo Zhi 2 (C) - * - */ - -#include "mapinc.h" -#include "mmc3.h" - -static void M199PW(uint32 A, uint8 V) -{ - setprg8(A,V); - setprg8(0xC000,EXPREGS[0]); - setprg8(0xE000,EXPREGS[1]); -} - -static void M199CW(uint32 A, uint8 V) -{ - setchr1r((V<8)?0x10:0x00,A,V); - setchr1r((DRegBuf[0]<8)?0x10:0x00,0x0000,DRegBuf[0]); - setchr1r((EXPREGS[2]<8)?0x10:0x00,0x0400,EXPREGS[2]); - setchr1r((DRegBuf[1]<8)?0x10:0x00,0x0800,DRegBuf[1]); - setchr1r((EXPREGS[3]<8)?0x10:0x00,0x0c00,EXPREGS[3]); -} - -static void M199MW(uint8 V) -{ -// FCEU_printf("%02x\n",V); - switch(V&3) - { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(M199Write) -{ - if((A==0x8001)&&(MMC3_cmd&8)) - { -// FCEU_printf("%02x=>%02x\n",MMC3_cmd,V); - EXPREGS[MMC3_cmd&3]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } - else - if(A<0xC000) - MMC3_CMDWrite(A,V); - else - MMC3_IRQWrite(A,V); -} - -static void M199Power(void) -{ - EXPREGS[0]=~1; - EXPREGS[1]=~0; - EXPREGS[2]=1; - EXPREGS[3]=3; - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M199Write); -} - -void Mapper199_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M199CW; - pwrap=M199PW; - mwrap=M199MW; - info->Power=M199Power; - int CHRRAMSize=1024*8; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); - AddExState(EXPREGS, 4, 0, "EXPR"); -} diff --git a/source/mbshare/252.c b/source/mbshare/252.c deleted file mode 100644 index 7bffeee..0000000 --- a/source/mbshare/252.c +++ /dev/null @@ -1,95 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2006 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Dragon Ball Z 2 - Gekishin Freeza! (C) - * Dragon Ball Z Gaiden - Saiya Jin Zetsumetsu Keikaku (C) - * San Guo Zhi 2 (C) - * - */ - -#include "mapinc.h" -#include "mmc3.h" - -static void M252PW(uint32 A, uint8 V) -{ - setprg8(A,V); - setprg8(0xC000,EXPREGS[0]); - setprg8(0xE000,EXPREGS[1]); -} - -static void M252CW(uint32 A, uint8 V) -{ - setchr1r((V<8)?0x10:0x00,A,V); - setchr1r((DRegBuf[0]<8)?0x10:0x00,0x0000,DRegBuf[0]); - setchr1r((EXPREGS[2]<8)?0x10:0x00,0x0400,EXPREGS[2]); - setchr1r((DRegBuf[1]<8)?0x10:0x00,0x0800,DRegBuf[1]); - setchr1r((EXPREGS[3]<8)?0x10:0x00,0x0c00,EXPREGS[3]); -} - -static void M252MW(uint8 V) -{ -// FCEU_printf("%02x\n",V); - switch(V&3) - { - case 0: setmirror(MI_V); break; - case 1: setmirror(MI_H); break; - case 2: setmirror(MI_0); break; - case 3: setmirror(MI_1); break; - } -} - -static DECLFW(M252Write) -{ - if((A==0x8001)&&(MMC3_cmd&8)) - { -// FCEU_printf("%02x=>%02x\n",MMC3_cmd,V); - EXPREGS[MMC3_cmd&3]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } - else - if(A<0xC000) - MMC3_CMDWrite(A,V); - else - MMC3_IRQWrite(A,V); -} - -static void M252Power(void) -{ - EXPREGS[0]=~1; - EXPREGS[1]=~0; - EXPREGS[2]=1; - EXPREGS[3]=3; - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M252Write); -} - -void Mapper252_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 128, 8, info->battery); - cwrap=M252CW; - pwrap=M252PW; - mwrap=M252MW; - info->Power=M252Power; - int CHRRAMSize=1024*8; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); - AddExState(EXPREGS, 4, 0, "EXPR"); -} diff --git a/source/mbshare/90.c b/source/mbshare/90.c deleted file mode 100644 index 929f8fc..0000000 --- a/source/mbshare/90.c +++ /dev/null @@ -1,343 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static int is209; - -static uint8 IRQMode; // from $c001 -static uint8 IRQPre; // from $c004 -static uint8 IRQPreSize; // from $c007 -static uint8 IRQCount; // from $c005 -static uint8 IRQXOR; // Loaded from $C006 -static uint8 IRQa; // $c002, $c003, and $c000 - -static uint8 mul[2]; -static uint8 regie; - -static uint8 tkcom[4]; -static uint8 prgb[4]; -static uint8 chrlow[8]; -static uint8 chrhigh[8]; - -static uint16 names[4]; -static uint8 tekker; - -static SFORMAT Tek_StateRegs[]={ - {&IRQCount, 1, "IRQC"}, - {&IRQa, 1, "IRQa"}, - {mul, 2, "MUL"}, - {®ie, 1, "REGI"}, - {tkcom, 4, "TKCO"}, - {prgb, 4, "PRGB"}, - {chrlow, 4, "CHRL"}, - {chrhigh, 8, "CHRH"}, - {&names[0], 2|FCEUSTATE_RLSB, "NMS0"}, - {&names[1], 2|FCEUSTATE_RLSB, "NMS1"}, - {&names[2], 2|FCEUSTATE_RLSB, "NMS2"}, - {&names[3], 2|FCEUSTATE_RLSB, "NMS3"}, - {&tekker, 1, "TEKR"}, - {0} -}; - -static DECLFR(tekread) -{ - //FCEU_printf("READ READ READ: $%04x, $%04x\n",A,X.PC); - switch(A) - { - case 0x5000:return(tekker); - case 0x5800:return(mul[0]*mul[1]); - case 0x5801:return((mul[0]*mul[1])>>8); - case 0x5803:return(regie); - default:break; - } - return(X.DB); -} - -static void mira(void) -{ - if(tkcom[0]&0x20 && is209) - { - int x; - if(tkcom[0] & 0x40) // Name tables are ROM-only - { - for(x=0;x<4;x++) - setntamem(CHRptr[0]+(((names[x])&CHRmask1[0])<<10), 0, x); - } - else // Name tables can be RAM or ROM. - { - for(x=0;x<4;x++) - { - if((tkcom[2]&0x80) == (names[x]&0x80)) // RAM selected. - setntamem(NTARAM + ((names[x]&0x1)<<10),1,x); - else - setntamem(CHRptr[0]+(((names[x])&CHRmask1[0])<<10), 0, x); - } - } - } - else - { - switch(tkcom[1]&3){ - case 0:setmirror(MI_V);break; - case 1:setmirror(MI_H);break; - case 2:setmirror(MI_0);break; - case 3:setmirror(MI_1);break; - } - } -} - -static void tekprom(void) -{ - switch(tkcom[0]&3) - { - case 1: // 16 KB - setprg16(0x8000,prgb[0]); - setprg16(0xC000,prgb[2]); - break; - case 2: //2 = 8 KB ?? - if(tkcom[0]&0x4) - { - setprg8(0x8000,prgb[0]); - setprg8(0xa000,prgb[1]); - setprg8(0xc000,prgb[2]); - setprg8(0xe000,prgb[3]); - } - else - { - if(tkcom[0]&0x80) - setprg8(0x6000,prgb[3]); - setprg8(0x8000,prgb[0]); - setprg8(0xa000,prgb[1]); - setprg8(0xc000,prgb[2]); - setprg8(0xe000,~0); - } - break; - case 0: - case 3: - setprg8(0x8000,prgb[0]); - setprg8(0xa000,prgb[1]); - setprg8(0xc000,prgb[2]); - setprg8(0xe000,prgb[3]); - break; - } -} - -static void tekvrom(void) -{ - int x; - - switch(tkcom[0]&0x18) - { - case 0x00: // 8KB - setchr8(chrlow[0]|(chrhigh[0]<<8)); - break; - case 0x08: // 4KB - for(x=0;x<8;x+=4) - setchr4(x<<10,chrlow[x]|(chrhigh[x]<<8)); - break; - case 0x10: // 2KB - for(x=0;x<8;x+=2) - setchr2(x<<10,chrlow[x]|(chrhigh[x]<<8)); - break; - case 0x18: // 1KB - for(x=0;x<8;x++) - setchr1(x<<10,(chrlow[x]|(chrhigh[x]<<8))); - break; - } -} - -static DECLFW(Mapper90_write) -{ - //printf("$%04x:$%02x\n",A,V); - - if(A==0x5800) mul[0]=V; - else if(A==0x5801) mul[1]=V; - else if(A==0x5803) regie=V; - - - //if(A>=0xc000 && A<=0xc007) - // FCEU_printf("$%04x:$%02x $%04x, %d, %d\n",A,V,X.PC,scanline,timestamp); - - A&=0xF007; - if(A>=0x8000 && A<=0x8003) - { - prgb[A&3]=V; - tekprom(); - } - else if(A>=0x9000 && A<=0x9007) - { - chrlow[A&7]=V; - tekvrom(); - } - else if(A>=0xa000 && A<=0xa007) - { - chrhigh[A&7]=V; - tekvrom(); - } - else if(A>=0xb000 && A<=0xb007) - { - //printf("$%04x:$%02x\n",A,V); - if(A&4) - { - names[A&3]&=0x00FF; - names[A&3]|=V<<8; - } - else - { - names[A&3]&=0xFF00; - names[A&3]|=V; - } - mira(); - } - else if(A>=0xd000 && A<=0xdfff) - { - tkcom[A&3]=V; - tekprom(); - tekvrom(); - mira(); - } - else switch(A) - { - case 0xc000: IRQa=V&1;if(!(V&1)) X6502_IRQEnd(FCEU_IQEXT);break; - case 0xc002: IRQa=0;X6502_IRQEnd(FCEU_IQEXT);break; - case 0xc003: IRQa=1;break; - - case 0xc001: IRQMode=V;break; - case 0xc004: IRQPre=V^IRQXOR;break; - case 0xc005: IRQCount=V^IRQXOR;break; - case 0xc006: IRQXOR=V;break; - case 0xc007: IRQPreSize=V;break; - } - -} - -static void CCL(void) -{ - if((IRQMode>>6) == 1) // Count Up - { - IRQCount++; - if((IRQCount == 0) && IRQa) - X6502_IRQBegin(FCEU_IQEXT); - } - else if((IRQMode>>6) == 2) // Count down - { - IRQCount--; - if((IRQCount == 0xFF) && IRQa) - X6502_IRQBegin(FCEU_IQEXT); - } -} - -static void ClockCounter(void) -{ - uint8 premask; - - if(IRQMode & 0x4) premask = 0x7; - else premask = 0xFF; - - if((IRQMode>>6) == 1) // Count up - { - IRQPre++; - - if((IRQPre & premask) == 0) - CCL(); - } - else if((IRQMode>>6) == 2) // Count down - { - IRQPre--; - //printf("%d\n",IRQPre); - if((IRQPre & premask) == premask) - CCL(); - } -} - -static void SLWrap(void) -{ - int x; - for(x=0;x<8;x++) ClockCounter(); // 8 PPU A10 0->1 transitions per scanline(usually) -} -/* -static uint32 lasta; -static void FP_FASTAPASS(1) YARGH(uint32 A) -{ - if((A&0x1000) && !(lasta & 0x1000)) - ClockCounter(); - - lasta = A; -} -*/ - -static void togglie() -{ - tekker^=0xFF; -} - -static void m90rest(int version) -{ - mira(); -} - -static void M90Power(void) -{ - SetWriteHandler(0x5000,0xffff,Mapper90_write); - SetReadHandler(0x5000,0x5fff,tekread); - - SetReadHandler(0x6000,0xffff,CartBR); - - mul[0]=mul[1]=regie=0xFF; - - tkcom[0]=tkcom[1]=tkcom[2]=tkcom[3]=0xFF; - - memset(prgb,0xff,sizeof(prgb)); - memset(chrlow,0xff,sizeof(chrlow)); - memset(chrhigh,0xff,sizeof(chrhigh)); - memset(names,0x00,sizeof(names)); - - tekker=0; - - prgb[0]=0xFF; - prgb[1]=0xFF; - prgb[2]=0xFF; - prgb[3]=0xFF; - tekprom(); - tekvrom(); -} - -void Mapper90_Init(CartInfo *info) -{ - is209=0; - info->Reset=togglie; - info->Power=M90Power; - //PPU_hook = YARGH; - GameHBIRQHook2 = SLWrap; - GameStateRestore=m90rest; - AddExState(Tek_StateRegs, ~0, 0, 0); -} - -void Mapper209_Init(CartInfo *info) -{ - is209=1; - info->Reset=togglie; - info->Power=M90Power; - //PPU_hook = YARGH; - GameHBIRQHook2 = SLWrap; - GameStateRestore=m90rest; - AddExState(Tek_StateRegs, ~0, 0, 0); -} - diff --git a/source/mbshare/deirom.c b/source/mbshare/deirom.c deleted file mode 100644 index 5033e80..0000000 --- a/source/mbshare/deirom.c +++ /dev/null @@ -1,85 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint8 cmd; -static uint8 DRegs[8]; - -static SFORMAT DEI_StateRegs[]= -{ - {&cmd, 1, "CMD"}, - {DRegs, 8, "DREG"}, - {0} -}; - -static void Sync(void) -{ - int x; - - setchr2(0x0000,DRegs[0]); - setchr2(0x0800,DRegs[1]); - for(x=0;x<4;x++) - setchr1(0x1000+(x<<10),DRegs[2+x]); - setprg8(0x8000,DRegs[6]); - setprg8(0xa000,DRegs[7]); -} - -static void StateRestore(int version) -{ - Sync(); -} -static DECLFW(DEIWrite) -{ - switch(A&0x8001) - { - case 0x8000:cmd=V&0x07;break; - case 0x8001:if(cmd<=0x05) V&=0x3F; - else V&=0x0F; - if(cmd<=0x01) V>>=1; - DRegs[cmd&0x07]=V; - Sync(); - break; - } -} - -static void DEIPower(void) -{ - setprg8(0xc000,0xE); - setprg8(0xe000,0xF); - cmd=0; - memset(DRegs,0,8); - Sync(); - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xFFFF,DEIWrite); -} - - -void DEIROM_Init(CartInfo *info) -{ - info->Power=DEIPower; - GameStateRestore=StateRestore; - AddExState(&DEI_StateRegs, ~0, 0, 0); -} - -void Mapper206_Init(CartInfo *info) -{ - DEIROM_Init(info); -} diff --git a/source/mbshare/mapinc.h b/source/mbshare/mapinc.h deleted file mode 100644 index a10f496..0000000 --- a/source/mbshare/mapinc.h +++ /dev/null @@ -1,10 +0,0 @@ -#include "../types.h" -#include "../x6502.h" -#include "../fceu.h" -#include "../ppu.h" -#include "../cart.h" -#include "../memory.h" -#include "../sound.h" -#include "../state.h" -#include "../cheat.h" -#include diff --git a/source/mbshare/mmc1.c b/source/mbshare/mmc1.c deleted file mode 100644 index 8d4225a..0000000 --- a/source/mbshare/mmc1.c +++ /dev/null @@ -1,444 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static void GenMMC1Power(void); -static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery); - -static uint8 DRegs[4]; -static uint8 Buffer,BufferShift; - -static int mmc1opts; - -static void (*MMC1CHRHook4)(uint32 A, uint8 V); -static void (*MMC1PRGHook16)(uint32 A, uint8 V); - -static uint8 *WRAM=NULL; -static uint8 *CHRRAM=NULL; -static int is155; - -static DECLFW(MBWRAM) -{ - if(!(DRegs[3]&0x10) || is155) - Page[A>>11][A]=V; // WRAM is enabled. -} - -static DECLFR(MAWRAM) -{ - if((DRegs[3]&0x10) && !is155) - return X.DB; // WRAM is disabled - return(Page[A>>11][A]); -} - -static void MMC1CHR(void) -{ - if(mmc1opts&4) - { - if(DRegs[0]&0x10) - setprg8r(0x10,0x6000,(DRegs[1]>>4)&1); - else - setprg8r(0x10,0x6000,(DRegs[1]>>3)&1); - } - - if(MMC1CHRHook4) - { - if(DRegs[0]&0x10) - { - MMC1CHRHook4(0x0000,DRegs[1]); - MMC1CHRHook4(0x1000,DRegs[2]); - } - else - { - MMC1CHRHook4(0x0000,(DRegs[1]&0xFE)); - MMC1CHRHook4(0x1000,DRegs[1]|1); - } - } - else - { - if(DRegs[0]&0x10) - { - setchr4(0x0000,DRegs[1]); - setchr4(0x1000,DRegs[2]); - } - else - setchr8(DRegs[1]>>1); - } -} - -static void MMC1PRG(void) -{ - uint8 offs; - - offs=DRegs[1]&0x10; - if(MMC1PRGHook16) - { - switch(DRegs[0]&0xC) - { - case 0xC: MMC1PRGHook16(0x8000,(DRegs[3]+offs)); - MMC1PRGHook16(0xC000,0xF+offs); - break; - case 0x8: MMC1PRGHook16(0xC000,(DRegs[3]+offs)); - MMC1PRGHook16(0x8000,offs); - break; - case 0x0: - case 0x4: - MMC1PRGHook16(0x8000,((DRegs[3]&~1)+offs)); - MMC1PRGHook16(0xc000,((DRegs[3]&~1)+offs+1)); - break; - } - } - else - switch(DRegs[0]&0xC) - { - case 0xC: setprg16(0x8000,(DRegs[3]+offs)); - setprg16(0xC000,0xF+offs); - break; - case 0x8: setprg16(0xC000,(DRegs[3]+offs)); - setprg16(0x8000,offs); - break; - case 0x0: - case 0x4: - setprg16(0x8000,((DRegs[3]&~1)+offs)); - setprg16(0xc000,((DRegs[3]&~1)+offs+1)); - break; - } -} - -static void MMC1MIRROR(void) -{ - switch(DRegs[0]&3) - { - case 2: setmirror(MI_V);break; - case 3: setmirror(MI_H);break; - case 0: setmirror(MI_0);break; - case 1: setmirror(MI_1);break; - } -} - -static uint64 lreset; -static DECLFW(MMC1_write) -{ - int n=(A>>13)-4; - //FCEU_DispMessage("%016x",timestampbase+timestamp); - //printf("$%04x:$%02x, $%04x\n",A,V,X.PC); - //DumpMem("out",0xe000,0xffff); - - /* The MMC1 is busy so ignore the write. */ - /* As of version FCE Ultra 0.81, the timestamp is only - increased before each instruction is executed(in other words - precision isn't that great), but this should still work to - deal with 2 writes in a row from a single RMW instruction. - */ - if( (timestampbase+timestamp)<(lreset+2)) - return; - if (V&0x80) - { - DRegs[0]|=0xC; - BufferShift=Buffer=0; - MMC1PRG(); - lreset=timestampbase+timestamp; - return; - } - - Buffer|=(V&1)<<(BufferShift++); - - if (BufferShift==5) { - DRegs[n] = Buffer; - BufferShift = Buffer = 0; - - switch(n){ - case 0: - MMC1MIRROR(); - MMC1CHR(); - MMC1PRG(); - break; - case 1: - MMC1CHR(); - MMC1PRG(); - break; - case 2: - MMC1CHR(); - break; - case 3: - MMC1PRG(); - break; - } - } -} - -static void MMC1_Restore(int version) -{ - MMC1MIRROR(); - MMC1CHR(); - MMC1PRG(); - lreset=0; /* timestamp(base) is not stored in save states. */ -} - -static void MMC1CMReset(void) -{ - int i; - - for(i=0;i<4;i++) - DRegs[i]=0; - Buffer = BufferShift = 0; - DRegs[0]=0x1F; - - DRegs[1]=0; - DRegs[2]=0; // Should this be something other than 0? - DRegs[3]=0; - - MMC1MIRROR(); - MMC1CHR(); - MMC1PRG(); -} - -static int DetectMMC1WRAMSize(uint32 crc32) -{ - switch(crc32) - { - default:return(8); - case 0xc6182024: /* Romance of the 3 Kingdoms */ - case 0x2225c20f: /* Genghis Khan */ - case 0x4642dda6: /* Nobunaga's Ambition */ - case 0x29449ba9: /* "" "" (J) */ - case 0x2b11e0b0: /* "" "" (J) */ - FCEU_printf(" >8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); - return(16); - } -} - -static uint32 NWCIRQCount; -static uint8 NWCRec; -#define NWCDIP 0xE - -static void FP_FASTAPASS(1) NWCIRQHook(int a) -{ - if(!(NWCRec&0x10)) - { - NWCIRQCount+=a; - if((NWCIRQCount|(NWCDIP<<25))>=0x3e000000) - { - NWCIRQCount=0; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void NWCCHRHook(uint32 A, uint8 V) -{ - if((V&0x10)) // && !(NWCRec&0x10)) - { - NWCIRQCount=0; - X6502_IRQEnd(FCEU_IQEXT); - } - - NWCRec=V; - if(V&0x08) - MMC1PRG(); - else - setprg32(0x8000,(V>>1)&3); -} - -static void NWCPRGHook(uint32 A, uint8 V) -{ - if(NWCRec&0x8) - setprg16(A,8|(V&0x7)); - else - setprg32(0x8000,(NWCRec>>1)&3); -} - -static void NWCPower(void) -{ - GenMMC1Power(); - setchr8r(0,0); -} - -void Mapper105_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 256, 8, 0); - MMC1CHRHook4=NWCCHRHook; - MMC1PRGHook16=NWCPRGHook; - MapIRQHook=NWCIRQHook; - info->Power=NWCPower; -} - -static void GenMMC1Power(void) -{ - lreset=0; - if(mmc1opts&1) - { - FCEU_CheatAddRAM(8,0x6000,WRAM); - if(mmc1opts&4) - FCEU_dwmemset(WRAM,0,8192) - else if(!(mmc1opts&2)) - FCEU_dwmemset(WRAM,0,8192); - } - SetWriteHandler(0x8000,0xFFFF,MMC1_write); - SetReadHandler(0x8000,0xFFFF,CartBR); - - if(mmc1opts&1) - { - SetReadHandler(0x6000,0x7FFF,MAWRAM); - SetWriteHandler(0x6000,0x7FFF,MBWRAM); - setprg8r(0x10,0x6000,0); - } - - MMC1CMReset(); -} - -static void GenMMC1Close(void) -{ - if(CHRRAM) - FCEU_gfree(CHRRAM); - if(WRAM) - FCEU_gfree(WRAM); - CHRRAM=WRAM=NULL; -} - -static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery) -{ - is155=0; - - info->Close=GenMMC1Close; - MMC1PRGHook16=MMC1CHRHook4=0; - mmc1opts=0; - PRGmask16[0]&=(prg>>14)-1; - CHRmask4[0]&=(chr>>12)-1; - CHRmask8[0]&=(chr>>13)-1; - - if(wram) - { - WRAM=(uint8*)FCEU_gmalloc(wram*1024); - mmc1opts|=1; - if(wram>8) mmc1opts|=4; - SetupCartPRGMapping(0x10,WRAM,wram*1024,1); - AddExState(WRAM, wram*1024, 0, "WRAM"); - - if(battery) - { - mmc1opts|=2; - - info->SaveGame[0]=WRAM+((mmc1opts&4)?8192:0); - info->SaveGameLen[0]=8192; - } - } - if(!chr) - { - CHRRAM=(uint8*)FCEU_gmalloc(8192); - SetupCartCHRMapping(0, CHRRAM, 8192, 1); - AddExState(CHRRAM, 8192, 0, "CHRR"); - } - AddExState(DRegs, 4, 0, "DREG"); - info->Power=GenMMC1Power; - - GameStateRestore=MMC1_Restore; - AddExState(&lreset, 8, 1, "LRST"); -} - -void Mapper1_Init(CartInfo *info) -{ - int ws=DetectMMC1WRAMSize(info->CRC32); - GenMMC1Init(info, 512, 256, ws, info->battery); -} - -/* Same as mapper 1, without respect for WRAM enable bit. */ -void Mapper155_Init(CartInfo *info) -{ - GenMMC1Init(info,512,256,8,info->battery); - is155=1; -} - -//static void GenMMC1Init(int prg, int chr, int wram, int battery) -void SAROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 128, 64, 8, info->battery); -} - -void SBROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 128, 64, 0, 0); -} - -void SCROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 128, 128, 0, 0); -} - -void SEROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 32, 64, 0, 0); -} - -void SGROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 0, 0, 0); -} - -void SKROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 64, 8, info->battery); -} - -void SLROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 128, 0, 0); -} - -void SL1ROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 128, 128, 0, 0); -} - -/* Begin unknown - may be wrong - perhaps they use different MMC1s from the - similarly functioning boards? -*/ - -void SL2ROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 256, 0, 0); -} - -void SFROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 256, 0, 0); -} - -void SHROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 256, 0, 0); -} - -/* End unknown */ -/* */ -/* */ - -void SNROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 0, 8, info->battery); -} - -void SOROM_Init(CartInfo *info) -{ - GenMMC1Init(info, 256, 0, 16, info->battery); -} - - diff --git a/source/mbshare/mmc3.c b/source/mbshare/mmc3.c deleted file mode 100644 index 6eec042..0000000 --- a/source/mbshare/mmc3.c +++ /dev/null @@ -1,1613 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 1998 BERO - * Copyright (C) 2003 Xodnizel - * Mapper 12 code Copyright (C) 2003 CaH4e3 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* Code for emulating iNES mappers 4,12,44,45,47,49,52,74,114,115,116,118, - 119,148,165,205,214,215,245,249,250,254 -*/ - -#include "mapinc.h" -#include "mmc3.h" - -uint8 MMC3_cmd; -uint8 *WRAM; -uint8 *CHRRAM; -uint32 CHRRAMSize; -uint8 DRegBuf[8]; -uint8 EXPREGS[8]; /* For bootleg games, mostly. */ - -static uint8 A000B,A001B; - -#undef IRQCount -#undef IRQLatch -#undef IRQa -uint8 IRQCount,IRQLatch,IRQa; -uint8 IRQReload; - -static SFORMAT MMC3_StateRegs[]= -{ - {DRegBuf, 8, "REGS"}, - {&MMC3_cmd, 1, "CMD"}, - {&A000B, 1, "A000"}, - {&A001B, 1, "A001"}, - {&IRQReload, 1, "IRQR"}, - {&IRQCount, 1, "IRQC"}, - {&IRQLatch, 1, "IRQL"}, - {&IRQa, 1, "IRQA"}, - {0} -}; - -static int mmc3opts=0; -static int wrams; -static int isRevB=1; - -void (*pwrap)(uint32 A, uint8 V); -void (*cwrap)(uint32 A, uint8 V); -void (*mwrap)(uint8 V); - -void GenMMC3Power(void); -void FixMMC3PRG(int V); -void FixMMC3CHR(int V); - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery); - -// ---------------------------------------------------------------------- -// ------------------------- Generic MM3 Code --------------------------- -// ---------------------------------------------------------------------- - -void FixMMC3PRG(int V) -{ - if(V&0x40) - { - pwrap(0xC000,DRegBuf[6]); - pwrap(0x8000,~1); - } - else - { - pwrap(0x8000,DRegBuf[6]); - pwrap(0xC000,~1); - } - pwrap(0xA000,DRegBuf[7]); - pwrap(0xE000,~0); -} - -void FixMMC3CHR(int V) -{ - int cbase=(V&0x80)<<5; - - cwrap((cbase^0x000),DRegBuf[0]&(~1)); - cwrap((cbase^0x400),DRegBuf[0]|1); - cwrap((cbase^0x800),DRegBuf[1]&(~1)); - cwrap((cbase^0xC00),DRegBuf[1]|1); - - cwrap(cbase^0x1000,DRegBuf[2]); - cwrap(cbase^0x1400,DRegBuf[3]); - cwrap(cbase^0x1800,DRegBuf[4]); - cwrap(cbase^0x1c00,DRegBuf[5]); -} - -void MMC3RegReset(void) -{ - IRQCount=IRQLatch=IRQa=MMC3_cmd=0; - - DRegBuf[0]=0; - DRegBuf[1]=2; - DRegBuf[2]=4; - DRegBuf[3]=5; - DRegBuf[4]=6; - DRegBuf[5]=7; - DRegBuf[6]=0; - DRegBuf[7]=1; - - FixMMC3PRG(0); - FixMMC3CHR(0); -} - -DECLFW(MMC3_CMDWrite) -{ -// FCEU_printf("bs %04x %02x\n",A,V); - switch(A&0xE001) - { - case 0x8000: - if((V&0x40) != (MMC3_cmd&0x40)) - FixMMC3PRG(V); - if((V&0x80) != (MMC3_cmd&0x80)) - FixMMC3CHR(V); - MMC3_cmd = V; - break; - case 0x8001: - { - int cbase=(MMC3_cmd&0x80)<<5; - DRegBuf[MMC3_cmd&0x7]=V; - switch(MMC3_cmd&0x07) - { - case 0: cwrap((cbase^0x000),V&(~1)); - cwrap((cbase^0x400),V|1); - break; - case 1: cwrap((cbase^0x800),V&(~1)); - cwrap((cbase^0xC00),V|1); - break; - case 2: cwrap(cbase^0x1000,V); - break; - case 3: cwrap(cbase^0x1400,V); - break; - case 4: cwrap(cbase^0x1800,V); - break; - case 5: cwrap(cbase^0x1C00,V); - break; - case 6: - if(MMC3_cmd&0x40) - pwrap(0xC000,V); - else - pwrap(0x8000,V); - break; - case 7: - pwrap(0xA000,V); - break; - } - } - break; - case 0xA000: - if(mwrap) mwrap(V); - break; - case 0xA001: - A001B=V; - Write_IRQFM(0x4017,0x40); - break; - } -} - -DECLFW(MMC3_IRQWrite) -{ -// FCEU_printf("%04x:%04x\n",A,V); - switch(A&0xE001) - { - case 0xC000:IRQLatch=V;break; - case 0xC001:IRQReload=1;break; - case 0xE000:X6502_IRQEnd(FCEU_IQEXT);IRQa=0;break; - case 0xE001:IRQa=1;break; - } -} - -static void ClockMMC3Counter(void) -{ - int count = IRQCount; - if(!count || IRQReload) - { - IRQCount = IRQLatch; - IRQReload = 0; - } - else - IRQCount--; - if((count|isRevB) && !IRQCount) - { - if(IRQa) - { - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void MMC3_hb(void) -{ - ClockMMC3Counter(); -} - -static void MMC3_hb_KickMasterHack(void) -{ - if(scanline==238) ClockMMC3Counter(); - ClockMMC3Counter(); -} - -static void MMC3_hb_PALStarWarsHack(void) -{ - if(scanline==240) ClockMMC3Counter(); - ClockMMC3Counter(); -} - -void GenMMC3Restore(int version) -{ - if(mwrap) mwrap(A000B); - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void GENCWRAP(uint32 A, uint8 V) -{ - setchr1(A,V); -} - -static void GENPWRAP(uint32 A, uint8 V) -{ - setprg8(A,V&0x3F); -} - -static void GENMWRAP(uint8 V) -{ - A000B=V; - setmirror((V&1)^1); -} - -static void GENNOMWRAP(uint8 V) -{ - A000B=V; -} - -static DECLFW(MBWRAM) -{ - WRAM[A-0x6000]=V; -} - -static DECLFR(MAWRAM) -{ - return(WRAM[A-0x6000]); -} - -static DECLFW(MBWRAMMMC6) -{ - WRAM[A&0x3ff]=V; -} - -static DECLFR(MAWRAMMMC6) -{ - return(WRAM[A&0x3ff]); -} - -void GenMMC3Power(void) -{ - SetWriteHandler(0x8000,0xBFFF,MMC3_CMDWrite); - SetWriteHandler(0xC000,0xFFFF,MMC3_IRQWrite); - SetReadHandler(0x8000,0xFFFF,CartBR); - A001B=A000B=0; - setmirror(1); - if(mmc3opts&1) - { - if(wrams==1024) - { - FCEU_CheatAddRAM(1,0x7000,WRAM); - SetReadHandler(0x7000,0x7FFF,MAWRAMMMC6); - SetWriteHandler(0x7000,0x7FFF,MBWRAMMMC6); - } - else - { - FCEU_CheatAddRAM(wrams>>10,0x6000,WRAM); - SetReadHandler(0x6000,0x6000+wrams-1,MAWRAM); - SetWriteHandler(0x6000,0x6000+wrams-1,MBWRAM); - } - if(!(mmc3opts&2)) - FCEU_dwmemset(WRAM,0,wrams); - } - MMC3RegReset(); - if(CHRRAM) - FCEU_dwmemset(CHRRAM,0,CHRRAMSize); -} - -static void GenMMC3Close(void) -{ - if(CHRRAM) - FCEU_gfree(CHRRAM); - if(WRAM) - FCEU_gfree(WRAM); - CHRRAM=WRAM=NULL; -} - -//static uint16 _a12; -//static void FP_FASTAPASS(1) MMC3_PPU(uint32 A) -//{ -// if(A&0x2000)return; -// if((!_a12)&&(A&0x1000)) -// ClockMMC3Counter(); -// _a12=A&0x1000; -//} - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery) -{ - pwrap=GENPWRAP; - cwrap=GENCWRAP; - mwrap=GENMWRAP; - - wrams=wram<<10; - - PRGmask8[0]&=(prg>>13)-1; - CHRmask1[0]&=(chr>>10)-1; - CHRmask2[0]&=(chr>>11)-1; - - if(wram) - { - mmc3opts|=1; - WRAM=(uint8*)FCEU_gmalloc(wrams); - AddExState(WRAM, wrams, 0, "WRAM"); - } - - if(battery) - { - mmc3opts|=2; - info->SaveGame[0]=WRAM; - info->SaveGameLen[0]=wrams; - } - -// if(!chr) // duplicated CHR RAM set up -// { -// CHRRAM=(uint8*)FCEU_gmalloc(8192); -// CHRRAMSize=8192; -// SetupCartCHRMapping(0, CHRRAM, 8192, 1); -// AddExState(CHRRAM, 8192, 0, "CHRR"); -// } - - AddExState(MMC3_StateRegs, ~0, 0, 0); - - info->Power=GenMMC3Power; - info->Reset=MMC3RegReset; - info->Close=GenMMC3Close; - - if(info->CRC32 == 0x5104833e) // Kick Master - GameHBIRQHook = MMC3_hb_KickMasterHack; - else if(info->CRC32 == 0x5a6860f1 || info->CRC32 == 0xae280e20) // Shougi Meikan '92/'93 - GameHBIRQHook = MMC3_hb_KickMasterHack; - else if(info->CRC32 == 0xfcd772eb) // PAL Star Wars, similar problem as Kick Master. - GameHBIRQHook = MMC3_hb_PALStarWarsHack; - else - GameHBIRQHook=MMC3_hb; -// PPU_hook=MMC3_PPU; - GameStateRestore=GenMMC3Restore; -} - -// ---------------------------------------------------------------------- -// -------------------------- MMC3 Based Code --------------------------- -// ---------------------------------------------------------------------- - -// ---------------------------- Mapper 4 -------------------------------- - -static int hackm4=0;/* For Karnov, maybe others. BLAH. Stupid iNES format.*/ - -static void M4Power(void) -{ - GenMMC3Power(); - A000B=(hackm4^1)&1; - setmirror(hackm4); -} - -void Mapper4_Init(CartInfo *info) -{ - int ws=8; - - if((info->CRC32==0x93991433 || info->CRC32==0xaf65aa84)) - { - FCEU_printf("Low-G-Man can not work normally in the iNES format.\nThis game has been recognized by its CRC32 value, and the appropriate changes will be made so it will run.\nIf you wish to hack this game, you should use the UNIF format for your hack.\n\n"); - ws=0; - } - GenMMC3_Init(info,512,256,ws,info->battery); - info->Power=M4Power; - hackm4=info->mirror; -} - -// ---------------------------- Mapper 12 ------------------------------- - -static void M12CW(uint32 A, uint8 V) -{ - setchr1(A,(EXPREGS[(A&0x1000)>>12]<<8)+V); -} - -static DECLFW(M12Write) -{ - EXPREGS[0]=V&0x01; - EXPREGS[1]=(V&0x10)>>4; -} - -static void M12Power(void) -{ - EXPREGS[0]=EXPREGS[1]=0; - GenMMC3Power(); - SetWriteHandler(0x4100,0x5FFF,M12Write); -} - -void Mapper12_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M12CW; - info->Power=M12Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- Mapper 37 ------------------------------- - -static void M37PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]!=2) - V&=0x7; - else - V&=0xF; - V|=EXPREGS[0]<<3; - setprg8(A,V); -} - -static void M37CW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0x7F; - NV|=EXPREGS[0]<<6; - setchr1(A,NV); -} - -static DECLFW(M37Write) -{ - EXPREGS[0]=(V&6)>>1; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M37Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); -} - -static void M37Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M37Write); -} - -void Mapper37_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - pwrap=M37PW; - cwrap=M37CW; - info->Power=M37Power; - info->Reset=M37Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 44 ------------------------------- - -static void M44PW(uint32 A, uint8 V) -{ - uint32 NV=V; - if(EXPREGS[0]>=6) NV&=0x1F; - else NV&=0x0F; - NV|=EXPREGS[0]<<4; - setprg8(A,NV); -} - -static void M44CW(uint32 A, uint8 V) -{ - uint32 NV=V; - if(EXPREGS[0]<6) NV&=0x7F; - NV|=EXPREGS[0]<<7; - setchr1(A,NV); -} - -static DECLFW(M44Write) -{ - if(A&1) - { - EXPREGS[0]=V&7; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } - else - MMC3_CMDWrite(A,V); -} - -static void M44Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0xA000,0xBFFF,M44Write); -} - -void Mapper44_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M44CW; - pwrap=M44PW; - info->Power=M44Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 45 ------------------------------- - -static void M45CW(uint32 A, uint8 V) -{ - - uint32 NV=V; - if(EXPREGS[2]&8) - NV&=(1<<((EXPREGS[2]&7)+1))-1; -// else -// NV&=0; - NV|=EXPREGS[0]|((EXPREGS[2]&0xF0)<<4); - setchr1(A,NV); - -} - -static void M45PW(uint32 A, uint8 V) -{ - V&=(EXPREGS[3]&0x3F)^0x3F; - V|=EXPREGS[1]; - setprg8(A,V); -} - -static DECLFW(M45Write) -{ - if(EXPREGS[3]&0x40) - { - WRAM[A-0x6000]=V; - return; - } - EXPREGS[EXPREGS[4]]=V; - EXPREGS[4]=(EXPREGS[4]+1)&3; -// if(!EXPREGS[4]) -// { -// FCEU_printf("CHROR %02x, PRGOR %02x, CHRAND %02x, PRGAND %02x\n",EXPREGS[0],EXPREGS[1],EXPREGS[2],EXPREGS[3]); -// FCEU_printf("CHR0 %03x, CHR1 %03x, PRG0 %03x, PRG1 %03x\n", -// (0x00&((1<<((EXPREGS[2]&7)+1))-1))|(EXPREGS[0]|((EXPREGS[2]&0xF0)<<4)), -// (0xFF&((1<<((EXPREGS[2]&7)+1))-1))|(EXPREGS[0]|((EXPREGS[2]&0xF0)<<4)), -// (0x00&((EXPREGS[3]&0x3F)^0x3F))|(EXPREGS[1]), -// (0xFF&((EXPREGS[3]&0x3F)^0x3F))|(EXPREGS[1])); -// } - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M45Reset(void) -{ - EXPREGS[0]=EXPREGS[1]=EXPREGS[2]=EXPREGS[3]=EXPREGS[4]=0; - MMC3RegReset(); -} - -static void M45Power(void) -{ - setchr8(0); - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M45Write); -} - -void Mapper45_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M45CW; - pwrap=M45PW; - info->Reset=M45Reset; - info->Power=M45Power; - AddExState(EXPREGS, 5, 0, "EXPR"); -} - -// ---------------------------- Mapper 47 ------------------------------- - -static void M47PW(uint32 A, uint8 V) -{ - V&=0xF; - V|=EXPREGS[0]<<4; - setprg8(A,V); -} - -static void M47CW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0x7F; - NV|=EXPREGS[0]<<7; - setchr1(A,NV); -} - -static DECLFW(M47Write) -{ - EXPREGS[0]=V&1; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M47Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M47Write); -// SetReadHandler(0x6000,0x7FFF,0); -} - -void Mapper47_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - pwrap=M47PW; - cwrap=M47CW; - info->Power=M47Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 49 ------------------------------- - -static void M49PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&1) - { - V&=0xF; - V|=(EXPREGS[0]&0xC0)>>2; - setprg8(A,V); - } - else - setprg32(0x8000,(EXPREGS[0]>>4)&3); -} - -static void M49CW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0x7F; - NV|=(EXPREGS[0]&0xC0)<<1; - setchr1(A,NV); -} - -static DECLFW(M49Write) -{ - if(A001B&0x80) - { - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); - } -} - -static void M49Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); -} - -static void M49Power(void) -{ - M49Reset(); - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M49Write); - SetReadHandler(0x6000,0x7FFF,0); -} - -void Mapper49_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 0, 0); - cwrap=M49CW; - pwrap=M49PW; - info->Reset=M49Reset; - info->Power=M49Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 52 ------------------------------- - -static void M52PW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0x1F^((EXPREGS[0]&8)<<1); - NV|=((EXPREGS[0]&6)|((EXPREGS[0]>>3)&EXPREGS[0]&1))<<4; - setprg8(A,NV); -} - -static void M52CW(uint32 A, uint8 V) -{ - uint32 NV=V; - NV&=0xFF^((EXPREGS[0]&0x40)<<1); - NV|=(((EXPREGS[0]>>3)&4)|((EXPREGS[0]>>1)&2)|((EXPREGS[0]>>6)&(EXPREGS[0]>>4)&1))<<7; - setchr1(A,NV); -} - -static DECLFW(M52Write) -{ - if(EXPREGS[1]) - { - WRAM[A-0x6000]=V; - return; - } - EXPREGS[1]=1; - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M52Reset(void) -{ - EXPREGS[0]=EXPREGS[1]=0; - MMC3RegReset(); -} - -static void M52Power(void) -{ - M52Reset(); - GenMMC3Power(); - SetWriteHandler(0x6000,0x7FFF,M52Write); -} - -void Mapper52_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M52CW; - pwrap=M52PW; - info->Reset=M52Reset; - info->Power=M52Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- Mapper 74 ------------------------------- - -static void M74CW(uint32 A, uint8 V) -{ - if((V==8)||(V==9)) //Di 4 Ci - Ji Qi Ren Dai Zhan (As).nes, Ji Jia Zhan Shi (As).nes - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); -} - -void Mapper74_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M74CW; - CHRRAMSize=2048; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); -} - -// ---------------------------- Mapper 114 ------------------------------ - -static uint8 cmdin; -uint8 m114_perm[8] = {0, 3, 1, 5, 6, 7, 2, 4}; - -static void M114PWRAP(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - { - setprg16(0x8000,EXPREGS[0]&0xF); - setprg16(0xC000,EXPREGS[0]&0xF); - } - else - setprg8(A,V&0x3F); -} - -static DECLFW(M114Write) -{ - if(A==0xE003) - { - IRQa=1; - IRQLatch=V; - IRQReload=1; - } - else if(A==0xE002) - { - IRQa=0; - X6502_IRQEnd(FCEU_IQEXT); - } - else switch(A&0xE000) - { - case 0x8000: setmirror((V&1)^1); break; - case 0xA000: MMC3_CMDWrite(0x8000,(V&0xC0)|(m114_perm[V&7])); cmdin=1; break; - case 0xC000: if(!cmdin) break; - MMC3_CMDWrite(0x8001,V); - cmdin=0; - break; - } -} - -static DECLFW(M114ExWrite) -{ - if(A<=0x7FFF) - { - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - } -} - -static void M114Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M114Write); - SetWriteHandler(0x5000,0x7FFF,M114ExWrite); -} - -static void M114Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); -} - -void Mapper114_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - pwrap=M114PWRAP; - info->Power=M114Power; - info->Reset=M114Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDIN"); -} - -// ---------------------------- Mapper 115 ------------------------------ - -static void M115PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - setprg32(0x8000,(EXPREGS[0]&7)>>1); - else - setprg8(A,V); -} - -static void M115CW(uint32 A, uint8 V) -{ - setchr1(A,(uint32)V|((EXPREGS[1]&1)<<8)); -} - -static DECLFW(M115Write) -{ - if(A==0x6000) - EXPREGS[0]=V; - else if(A==0x6001) - EXPREGS[1]=V; - FixMMC3PRG(MMC3_cmd); -} - -static void M115Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x4100,0x7FFF,M115Write); - SetReadHandler(0x4100,0x7FFF,0); -} - -void Mapper115_Init(CartInfo *info) -{ - GenMMC3_Init(info, 128, 512, 0, 0); - cwrap=M115CW; - pwrap=M115PW; - info->Power=M115Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- Mapper 116 ------------------------------ - -static void M116CW(uint32 A, uint8 V) -{ -// setchr1(A,V|((EXPREGS[0]&0x4)<<6)); - if(EXPREGS[0]&2) - setchr8r(0x10,0); - else - setchr1(A,V); -} - -static DECLFW(M116Write) -{ - EXPREGS[0]=V; - FixMMC3CHR(MMC3_cmd); -} - -static void M116Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x4100,0x4100,M116Write); -} - -void Mapper116_Init(CartInfo *info) -{ - GenMMC3_Init(info, 128, 512, 0, 0); - cwrap=M116CW; - info->Power=M116Power; - CHRRAM = (uint8*)FCEU_gmalloc(8192); - SetupCartCHRMapping(0x10, CHRRAM, 8192, 1); - AddExState(EXPREGS, 4, 0, "EXPR"); -} - -// ---------------------------- Mapper 118 ------------------------------ - -static uint8 PPUCHRBus; -static uint8 TKSMIR[8]; - -static void FP_FASTAPASS(1) TKSPPU(uint32 A) -{ - A&=0x1FFF; - A>>=10; - PPUCHRBus=A; - setmirror(MI_0+TKSMIR[A]); -} - -static void TKSWRAP(uint32 A, uint8 V) -{ - TKSMIR[A>>10]=V>>7; - setchr1(A,V&0x7F); - if(PPUCHRBus==(A>>10)) - setmirror(MI_0+(V>>7)); -} - -void Mapper118_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=TKSWRAP; - mwrap=GENNOMWRAP; - PPU_hook=TKSPPU; - AddExState(&PPUCHRBus, 1, 0, "PPUC"); -} - -// ---------------------------- Mapper 119 ------------------------------ - -static void TQWRAP(uint32 A, uint8 V) -{ - setchr1r((V&0x40)>>2,A,V&0x3F); -} - -void Mapper119_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 64, 0, 0); - cwrap=TQWRAP; - CHRRAMSize=8192; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); -} - -// ---------------------------- Mapper 165 ------------------------------ - -static void M165CW(uint32 A, uint8 V) -{ - if(V==0) - setchr4r(0x10,A,0); - else - setchr4(A,V>>2); -} - -static void M165PPUFD(void) -{ - if(EXPREGS[0]==0xFD) - { - M165CW(0x0000,DRegBuf[0]); - M165CW(0x1000,DRegBuf[2]); - } -} - -static void M165PPUFE(void) -{ - if(EXPREGS[0]==0xFE) - { - M165CW(0x0000,DRegBuf[1]); - M165CW(0x1000,DRegBuf[4]); - } -} - -static void M165CWM(uint32 A, uint8 V) -{ - if(((MMC3_cmd&0x7)==0)||((MMC3_cmd&0x7)==2)) - M165PPUFD(); - if(((MMC3_cmd&0x7)==1)||((MMC3_cmd&0x7)==4)) - M165PPUFE(); -} - -static void FP_FASTAPASS(1) M165PPU(uint32 A) -{ - if((A&0x1FF0)==0x1FD0) - { - EXPREGS[0]=0xFD; - M165PPUFD(); - } else if((A&0x1FF0)==0x1FE0) - { - EXPREGS[0]=0xFE; - M165PPUFE(); - } -} - -static void M165Power(void) -{ - EXPREGS[0]=0xFD; - GenMMC3Power(); -} - -void Mapper165_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 128, 8, info->battery); - cwrap=M165CWM; - PPU_hook=M165PPU; - info->Power=M165Power; - CHRRAMSize = 4096; - CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); - AddExState(EXPREGS, 4, 0, "EXPR"); -} - -// ---------------------------- Mapper 182 ------------------------------ -// òàáëèöà ïåðìóòàöè àíàëîãè÷íà 114 ìàïïåðó, ðåãèñòðû ìàïïåðà ãîðàçäî ñëîæíåå, -// ÷åì èñïîëüçóþòñÿ çäåñü, õîòÿ âñå ïðåêðàñíî ðàáîòàåò. - -//static uint8 m182_perm[8] = {0, 3, 1, 5, 6, 7, 2, 4}; -static DECLFW(M182Write) -{ - switch(A&0xF003) - { - case 0x8001: setmirror((V&1)^1); break; - case 0xA000: MMC3_CMDWrite(0x8000,m114_perm[V&7]); break; - case 0xC000: MMC3_CMDWrite(0x8001,V); break; - case 0xE003: if(V) - { - IRQLatch=V; - IRQReload=1; - IRQa=1; - } - X6502_IRQEnd(FCEU_IQEXT); - break; - } -} - -static void M182Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M182Write); -} - -void Mapper182_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - info->Power=M182Power; -} - -// ---------------------------- Mapper 191 ------------------------------ - -static void M191CW(uint32 A, uint8 V) -{ - setchr1r((V&0x80)>>3,A,V); -} - -void Mapper191_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 8, info->battery); - cwrap=M191CW; - CHRRAMSize=2048; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); -} - -// ---------------------------- Mapper 192 ------------------------------- - -static void M192CW(uint32 A, uint8 V) -{ - if((V==8)||(V==9)||(V==0xA)||(V==0xB)) //Ying Lie Qun Xia Zhuan (Chinese), - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); -} - -void Mapper192_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M192CW; - CHRRAMSize=4096; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); -} - -// ---------------------------- Mapper 194 ------------------------------- - -static void M194CW(uint32 A, uint8 V) -{ - if(V<=1) //Dai-2-Ji - Super Robot Taisen (As).nes - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); -} - -void Mapper194_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M194CW; - CHRRAMSize=2048; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); -} - -// ---------------------------- Mapper 195 ------------------------------- -static uint8 *wramtw; -static uint16 wramsize; - -static void M195CW(uint32 A, uint8 V) -{ - if(V<=3) // Crystalis (c).nes, Captain Tsubasa Vol 2 - Super Striker (C) - setchr1r(0x10,A,V); - else - setchr1r(0,A,V); -} - -static void M195Power(void) -{ - GenMMC3Power(); - setprg4r(0x10,0x5000,0); - SetWriteHandler(0x5000,0x5fff,CartBW); - SetReadHandler(0x5000,0x5fff,CartBR); -} - -static void M195Close(void) -{ - if(wramtw) - FCEU_gfree(wramtw); - wramtw=NULL; -} - -void Mapper195_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M195CW; - info->Power=M195Power; - info->Close=M195Close; - CHRRAMSize=4096; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); - wramsize=4096; - wramtw=(uint8*)FCEU_gmalloc(wramsize); - SetupCartPRGMapping(0x10, wramtw, wramsize, 1); - AddExState(CHRRAM, CHRRAMSize, 0, "CHRR"); - AddExState(wramtw, wramsize, 0, "WRAMTW"); -} - -// ---------------------------- Mapper 198 ------------------------------- - -static void M198PW(uint32 A, uint8 V) -{ - if(V>=0x50) // Tenchi o Kurau II - Shokatsu Koumei Den (J) (C).nes - setprg8(A,V&0x4F); - else - setprg8(A,V); -} - -static void M198CW(uint32 A, uint8 V) -{ - if(A==0x0000) - setchr4(0x0000,V>>1); - else if(A==0x1000) - setchr2(0x1000,V); - else if(A==0x1400) - setchr2(0x1800,V); -} - -void Mapper198_Init(CartInfo *info) -{ - GenMMC3_Init(info, 1024, 256, 8, info->battery); - pwrap=M198PW; - cwrap=M198CW; - info->Power=M195Power; - info->Close=M195Close; - wramsize=4096; - wramtw=(uint8*)FCEU_gmalloc(wramsize); - SetupCartPRGMapping(0x10, wramtw, wramsize, 1); - AddExState(wramtw, wramsize, 0, "WRAMTW"); -} - -// ---------------------------- Mapper 205 ------------------------------ - -static void M205PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&2) - setprg8(A,(V&0x0f)|((EXPREGS[0]&3)<<4)); - else - setprg8(A,(V&0x1f)|((EXPREGS[0]&3)<<4)); -} - -static void M205CW(uint32 A, uint8 V) -{ - setchr1(A,V|((EXPREGS[0]&3)<<7)); -} - -static DECLFW(M205Write) -{ - if((A&0x6800)==0x6800) EXPREGS[0]= V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M205Reset(void) -{ - EXPREGS[0]=0; - MMC3RegReset(); -} - -static void M205Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x4020,0x7FFF,M205Write); -} - -void Mapper205_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, 0); - pwrap=M205PW; - cwrap=M205CW; - info->Power=M205Power; - info->Reset=M205Reset; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 215 ------------------------------ - -static uint8 m215_perm[8] = {0, 2, 5, 3, 6, 1, 7, 4}; -//static uint8 m215_perm[8] = {0, 1, 2, 3, 4, 5, 6, 7}; - -static void M215CW(uint32 A, uint8 V) -{ - if(EXPREGS[1]&0x04) - setchr1(A,V|0x100); - else - setchr1(A,(V&0x7F)|((EXPREGS[1]&0x10)<<3)); -} - -static void M215PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - { - setprg16(0x8000,(EXPREGS[0]&0x0F)|(EXPREGS[1]&0x10)); - setprg16(0xC000,(EXPREGS[0]&0x0F)|(EXPREGS[1]&0x10)); - } - else if(EXPREGS[1]&0x08) - setprg8(A,(V&0x1F)|0x20); - else - setprg8(A,(V&0x0F)|(EXPREGS[1]&0x10)); -} - -static DECLFW(M215Write) -{ -// FCEU_printf("bs %04x %02x\n",A,V); - if(!(EXPREGS[2])) - { - if(A >= 0xc000) - MMC3_IRQWrite(A,V); - else - MMC3_CMDWrite(A,V); - } - else switch(A&0xE001) - { - case 0xC001: IRQLatch=V; break; - case 0xA001: IRQReload=1; break; - case 0xE001: IRQa=1; break; - case 0xE000: X6502_IRQEnd(FCEU_IQEXT); IRQa=0; break; - case 0xC000: setmirror(((V|(V>>7))&1)^1); break; - case 0xA000: MMC3_CMDWrite(0x8000,(V&0xC0)|(m215_perm[V&7])); cmdin=1; break; - case 0x8001: if(!cmdin) break; - MMC3_CMDWrite(0x8001,V); - cmdin=0; - break; - } -} - -static DECLFW(M215ExWrite) -{ -// FCEU_printf("bs %04x %02x (%04x)\n",A,V,A&0x5007); - switch(A) - { - case 0x6000: - case 0x5000: - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - break; - case 0x6001: - case 0x5001: - EXPREGS[1]=V; - FixMMC3CHR(MMC3_cmd); - break; - case 0x6007: - case 0x5007: - EXPREGS[2]=V; - MMC3RegReset(); - break; - } -} - -static void M215Power(void) -{ - EXPREGS[0]=0; - EXPREGS[1]=0xFF; - EXPREGS[2]=4; - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M215Write); - SetWriteHandler(0x5000,0x7FFF,M215ExWrite); -} - -void Mapper215_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - cwrap=M215CW; - pwrap=M215PW; - info->Power=M215Power; - AddExState(EXPREGS, 3, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDIN"); -} - -// ---------------------------- Mapper 217 ------------------------------ - -static uint8 m217_perm[8] = {0, 6, 3, 7, 5, 2, 4, 1}; - -static void M217CW(uint32 A, uint8 V) -{ - if(EXPREGS[1]&0x08) - setchr1(A,V|((EXPREGS[1]&3)<<8)); - else - setchr1(A,(V&0x7F)|((EXPREGS[1]&3)<<8)|((EXPREGS[1]&0x10)<<3)); -} - -static void M217PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x80) - { - setprg16(0x8000,(EXPREGS[0]&0x0F)|((EXPREGS[1]&3)<<4)); - setprg16(0xC000,(EXPREGS[0]&0x0F)|((EXPREGS[1]&3)<<4)); - } - else if(EXPREGS[1]&0x08) - setprg8(A,(V&0x1F)|((EXPREGS[1]&3)<<5)); - else - setprg8(A,(V&0x0F)|((EXPREGS[1]&3)<<5)|(EXPREGS[1]&0x10)); -} - -static DECLFW(M217Write) -{ - if(!EXPREGS[2]) - { - if(A >= 0xc000) - MMC3_IRQWrite(A, V); - else - MMC3_CMDWrite(A,V); - } - else switch(A&0xE001) - { - case 0x8000: IRQCount=V; break; - case 0xE000: X6502_IRQEnd(FCEU_IQEXT);IRQa=0; break; - case 0xC001: IRQa=1; break; - case 0xA001: setmirror((V&1)^1); break; - case 0x8001: MMC3_CMDWrite(0x8000,(V&0xC0)|(m217_perm[V&7])); cmdin=1; break; - case 0xA000: if(!cmdin) break; - MMC3_CMDWrite(0x8001,V); - cmdin=0; - break; - } -} - -static DECLFW(M217ExWrite) -{ - switch(A) - { - case 0x5000: - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - break; - case 0x5001: - EXPREGS[1]=V; - FixMMC3PRG(MMC3_cmd); - break; - case 0x5007: - EXPREGS[2]=V; - break; - } -} - -static void M217Power(void) -{ - EXPREGS[0]=0; - EXPREGS[1]=0xFF; - EXPREGS[2]=3; - GenMMC3Power(); - SetWriteHandler(0x8000,0xFFFF,M217Write); - SetWriteHandler(0x5000,0x7FFF,M217ExWrite); -} - -void Mapper217_Init(CartInfo *info) -{ - GenMMC3_Init(info, 256, 256, 0, 0); - cwrap=M217CW; - pwrap=M217PW; - info->Power=M217Power; - AddExState(EXPREGS, 3, 0, "EXPR"); - AddExState(&cmdin, 1, 0, "CMDIN"); -} - -// ---------------------------- Mapper 245 ------------------------------ - -static void M245CW(uint32 A, uint8 V) -{ - setchr1(A,V&7); - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); -} - -static void M245PW(uint32 A, uint8 V) -{ - setprg8(A,(V&0x3F)|((EXPREGS[0]&2)<<5)); -} - -static void M245Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); -} - -void Mapper245_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M245CW; - pwrap=M245PW; - info->Power=M245Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 249 ------------------------------ - -static void M249PW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x2) - { - if(V<0x20) - V=(V&1)|((V>>3)&2)|((V>>1)&4)|((V<<2)&8)|((V<<2)&0x10); - else - { - V-=0x20; - V=(V&3)|((V>>1)&4)|((V>>4)&8)|((V>>2)&0x10)|((V<<3)&0x20)|((V<<2)&0xC0); - } - } - setprg8(A,V); -} - -static void M249CW(uint32 A, uint8 V) -{ - if(EXPREGS[0]&0x2) - V=(V&3)|((V>>1)&4)|((V>>4)&8)|((V>>2)&0x10)|((V<<3)&0x20)|((V<<2)&0xC0); - setchr1(A,V); -} - -static DECLFW(M249Write) -{ - EXPREGS[0]=V; - FixMMC3PRG(MMC3_cmd); - FixMMC3CHR(MMC3_cmd); -} - -static void M249Power(void) -{ - EXPREGS[0]=0; - GenMMC3Power(); - SetWriteHandler(0x5000,0x5000,M249Write); -} - -void Mapper249_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=M249CW; - pwrap=M249PW; - info->Power=M249Power; - AddExState(EXPREGS, 1, 0, "EXPR"); -} - -// ---------------------------- Mapper 250 ------------------------------ - -static DECLFW(M250Write) -{ - MMC3_CMDWrite((A&0xE000)|((A&0x400)>>10),A&0xFF); -} - -static DECLFW(M250IRQWrite) -{ - MMC3_IRQWrite((A&0xE000)|((A&0x400)>>10),A&0xFF); -} - -static void M250_Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x8000,0xBFFF,M250Write); - SetWriteHandler(0xC000,0xFFFF,M250IRQWrite); -} - -void Mapper250_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - info->Power=M250_Power; -} - -// ---------------------------- Mapper 254 ------------------------------ - -static DECLFR(MR254WRAM) -{ - if(EXPREGS[0]) - return WRAM[A-0x6000]; - else - return WRAM[A-0x6000]^EXPREGS[1]; -} - -static DECLFW(M254Write) -{ - switch (A) { - case 0x8000: EXPREGS[0]=0xff; - break; - case 0xA001: EXPREGS[1]=V; - } - MMC3_CMDWrite(A,V); -} - -static void M254_Power(void) -{ - GenMMC3Power(); - SetWriteHandler(0x8000,0xBFFF,M254Write); - SetReadHandler(0x6000,0x7FFF,MR254WRAM); -} - -void Mapper254_Init(CartInfo *info) -{ - GenMMC3_Init(info, 128, 128, 8, info->battery); - info->Power=M254_Power; - AddExState(EXPREGS, 2, 0, "EXPR"); -} - -// ---------------------------- UNIF Boards ----------------------------- - -void TEROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 32, 32, 0, 0); -} - -void TFROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 64, 0, 0); -} - -void TGROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 0, 0, 0); -} - -void TKROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); -} - -void TLROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 0, 0); -} - -void TSROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, 0); -} - -void TLSROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, 0); - cwrap=TKSWRAP; - mwrap=GENNOMWRAP; - PPU_hook=TKSPPU; - AddExState(&PPUCHRBus, 1, 0, "PPUC"); -} - -void TKSROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 256, 8, info->battery); - cwrap=TKSWRAP; - mwrap=GENNOMWRAP; - PPU_hook=TKSPPU; - AddExState(&PPUCHRBus, 1, 0, "PPUC"); -} - -void TQROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 64, 0, 0); - cwrap=TQWRAP; - CHRRAMSize=8192; - CHRRAM=(uint8*)FCEU_gmalloc(CHRRAMSize); - SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1); -} - -void HKROM_Init(CartInfo *info) -{ - GenMMC3_Init(info, 512, 512, 1, info->battery); -} diff --git a/source/mbshare/mmc3.h b/source/mbshare/mmc3.h deleted file mode 100644 index 937f80f..0000000 --- a/source/mbshare/mmc3.h +++ /dev/null @@ -1,25 +0,0 @@ -extern uint8 MMC3_cmd; -extern uint8 *WRAM; -extern uint8 *CHRRAM; -extern uint8 EXPREGS[8]; -extern uint8 DRegBuf[8]; - -#undef IRQCount -#undef IRQLatch -#undef IRQa -extern uint8 IRQCount,IRQLatch,IRQa; -extern uint8 IRQReload; - -extern void (*pwrap)(uint32 A, uint8 V); -extern void (*cwrap)(uint32 A, uint8 V); -extern void (*mwrap)(uint8 V); - -void GenMMC3Power(void); -void GenMMC3Restore(int version); -void MMC3RegReset(void); -void FixMMC3PRG(int V); -void FixMMC3CHR(int V); -DECLFW(MMC3_CMDWrite); -DECLFW(MMC3_IRQWrite); - -void GenMMC3_Init(CartInfo *info, int prg, int chr, int wram, int battery); diff --git a/source/mbshare/mmc5.c b/source/mbshare/mmc5.c deleted file mode 100644 index ce3fc9c..0000000 --- a/source/mbshare/mmc5.c +++ /dev/null @@ -1,834 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* None of this code should use any of the iNES bank switching wrappers. */ - -#include "mapinc.h" - -static void (*sfun)(int P); -static void (*psfun)(void); - -void MMC5RunSound(int Count); -void MMC5RunSoundHQ(void); - -static INLINE void MMC5SPRVROM_BANK1(uint32 A,uint32 V) -{ - if(CHRptr[0]) - { - V&=CHRmask1[0]; - MMC5SPRVPage[(A)>>10]=&CHRptr[0][(V)<<10]-(A); - } -} - -static INLINE void MMC5BGVROM_BANK1(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask1[0];MMC5BGVPage[(A)>>10]=&CHRptr[0][(V)<<10]-(A);}} - -static INLINE void MMC5SPRVROM_BANK2(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask2[0];MMC5SPRVPage[(A)>>10]=MMC5SPRVPage[((A)>>10)+1]=&CHRptr[0][(V)<<11]-(A);}} -static INLINE void MMC5BGVROM_BANK2(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask2[0];MMC5BGVPage[(A)>>10]=MMC5BGVPage[((A)>>10)+1]=&CHRptr[0][(V)<<11]-(A);}} - -static INLINE void MMC5SPRVROM_BANK4(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask4[0];MMC5SPRVPage[(A)>>10]=MMC5SPRVPage[((A)>>10)+1]= MMC5SPRVPage[((A)>>10)+2]=MMC5SPRVPage[((A)>>10)+3]=&CHRptr[0][(V)<<12]-(A);}} -static INLINE void MMC5BGVROM_BANK4(uint32 A,uint32 V) {if(CHRptr[0]){V&=CHRmask4[0];MMC5BGVPage[(A)>>10]=MMC5BGVPage[((A)>>10)+1]=MMC5BGVPage[((A)>>10)+2]=MMC5BGVPage[((A)>>10)+3]=&CHRptr[0][(V)<<12]-(A);}} - -static INLINE void MMC5SPRVROM_BANK8(uint32 V) {if(CHRptr[0]){V&=CHRmask8[0];MMC5SPRVPage[0]=MMC5SPRVPage[1]=MMC5SPRVPage[2]=MMC5SPRVPage[3]=MMC5SPRVPage[4]=MMC5SPRVPage[5]=MMC5SPRVPage[6]=MMC5SPRVPage[7]=&CHRptr[0][(V)<<13];}} -static INLINE void MMC5BGVROM_BANK8(uint32 V) {if(CHRptr[0]){V&=CHRmask8[0];MMC5BGVPage[0]=MMC5BGVPage[1]=MMC5BGVPage[2]=MMC5BGVPage[3]=MMC5BGVPage[4]=MMC5BGVPage[5]=MMC5BGVPage[6]=MMC5BGVPage[7]=&CHRptr[0][(V)<<13];}} - -static uint8 PRGBanks[4]; -static uint8 WRAMPage; -static uint8 CHRBanksA[8], CHRBanksB[4]; -static uint8 WRAMMaskEnable[2]; -static uint8 ABMode; /* A=0, B=1 */ - -static uint8 IRQScanline,IRQEnable; -static uint8 CHRMode, NTAMirroring, NTFill, ATFill; - -static uint8 MMC5IRQR; -static uint8 MMC5LineCounter; -static uint8 mmc5psize, mmc5vsize; -static uint8 mul[2]; - -static uint8 *WRAM=NULL; -static uint8 *MMC5fill=NULL; -static uint8 *ExRAM=NULL; - -static uint8 MMC5WRAMsize; -static uint8 MMC5WRAMIndex[8]; - -static uint8 MMC5ROMWrProtect[4]; -static uint8 MMC5MemIn[5]; - -static void MMC5CHRA(void); -static void MMC5CHRB(void); - -typedef struct __cartdata { - uint32 crc32; - uint8 size; -} cartdata; - - -// ETROM seems to have 16KB of WRAM, ELROM seems to have 8KB -// EWROM seems to have 32KB of WRAM - -#define MMC5_NOCARTS 14 -cartdata MMC5CartList[MMC5_NOCARTS]= -{ - {0x9c18762b,2}, /* L'Empereur */ - {0x26533405,2}, - {0x6396b988,2}, - - {0xaca15643,2}, /* Uncharted Waters */ - {0xfe3488d1,2}, /* Dai Koukai Jidai */ - - {0x15fe6d0f,2}, /* BKAC */ - {0x39f2ce4b,2}, /* Suikoden */ - - {0x8ce478db,2}, /* Nobunaga's Ambition 2 */ - {0xeee9a682,2}, - - {0x1ced086f,2}, /* Ishin no Arashi */ - - {0xf540677b,4}, /* Nobunaga...Bushou Fuuun Roku */ - - {0x6f4e4312,4}, /* Aoki Ookami..Genchou */ - - {0xf011e490,4}, /* Romance of the 3 Kingdoms 2 */ - {0x184c2124,4}, /* Sangokushi 2 */ -}; - - -int DetectMMC5WRAMSize(uint32 crc32) -{ - int x; - for(x=0;x8KB external WRAM present. Use UNIF if you hack the ROM image.\n"); - return(MMC5CartList[x].size*8); - } - return(8); -} - -static void BuildWRAMSizeTable(void) -{ - int x; - for(x=0;x<8;x++) - { - switch(MMC5WRAMsize) - { - case 0: MMC5WRAMIndex[x]=255; break; - case 1: MMC5WRAMIndex[x]=(x>3)?255:0; break; - case 2: MMC5WRAMIndex[x]=(x&4)>>2; break; - case 4: MMC5WRAMIndex[x]=(x>3)?255:(x&3); break; - } - } -} - -static void MMC5CHRA(void) -{ - int x; - switch(mmc5vsize&3) - { - case 0: setchr8(CHRBanksA[7]); - MMC5SPRVROM_BANK8(CHRBanksA[7]); - break; - case 1: setchr4(0x0000,CHRBanksA[3]); - setchr4(0x1000,CHRBanksA[7]); - MMC5SPRVROM_BANK4(0x0000,CHRBanksA[3]); - MMC5SPRVROM_BANK4(0x1000,CHRBanksA[7]); - break; - case 2: setchr2(0x0000,CHRBanksA[1]); - setchr2(0x0800,CHRBanksA[3]); - setchr2(0x1000,CHRBanksA[5]); - setchr2(0x1800,CHRBanksA[7]); - MMC5SPRVROM_BANK2(0x0000,CHRBanksA[1]); - MMC5SPRVROM_BANK2(0x0800,CHRBanksA[3]); - MMC5SPRVROM_BANK2(0x1000,CHRBanksA[5]); - MMC5SPRVROM_BANK2(0x1800,CHRBanksA[7]); - break; - case 3: for(x=0;x<8;x++) - { - setchr1(x<<10,CHRBanksA[x]); - MMC5SPRVROM_BANK1(x<<10,CHRBanksA[x]); - } - break; - } -} - -static void MMC5CHRB(void) -{ - int x; - switch(mmc5vsize&3) - { - case 0: setchr8(CHRBanksB[3]); - MMC5BGVROM_BANK8(CHRBanksB[3]); - break; - case 1: setchr4(0x0000,CHRBanksB[3]); - setchr4(0x1000,CHRBanksB[3]); - MMC5BGVROM_BANK4(0x0000,CHRBanksB[3]); - MMC5BGVROM_BANK4(0x1000,CHRBanksB[3]); - break; - case 2: setchr2(0x0000,CHRBanksB[1]); - setchr2(0x0800,CHRBanksB[3]); - setchr2(0x1000,CHRBanksB[1]); - setchr2(0x1800,CHRBanksB[3]); - MMC5BGVROM_BANK2(0x0000,CHRBanksB[1]); - MMC5BGVROM_BANK2(0x0800,CHRBanksB[3]); - MMC5BGVROM_BANK2(0x1000,CHRBanksB[1]); - MMC5BGVROM_BANK2(0x1800,CHRBanksB[3]); - break; - case 3: for(x=0;x<8;x++) - { - setchr1(x<<10,CHRBanksB[x&3]); - MMC5BGVROM_BANK1(x<<10,CHRBanksB[x&3]); - } - break; - } -} - -static void FASTAPASS(2) MMC5WRAM(uint32 A, uint32 V) -{ - //printf("%02x\n",V); - V=MMC5WRAMIndex[V&7]; - if(V!=255) - { - setprg8r(0x10,A,V); - MMC5MemIn[(A-0x6000)>>13]=1; - } - else - MMC5MemIn[(A-0x6000)>>13]=0; -} - -static void MMC5PRG(void) -{ - int x; - switch(mmc5psize&3) - { - case 0: MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]= - MMC5ROMWrProtect[2]=MMC5ROMWrProtect[3]=1; - setprg32(0x8000,((PRGBanks[1]&0x7F)>>2)); - for(x=0;x<4;x++) - MMC5MemIn[1+x]=1; - break; - case 1: if(PRGBanks[1]&0x80) - { - MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=1; - setprg16(0x8000,(PRGBanks[1]>>1)); - MMC5MemIn[1]=MMC5MemIn[2]=1; - } - else - { - MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=0; - MMC5WRAM(0x8000,PRGBanks[1]&7&0xFE); - MMC5WRAM(0xA000,(PRGBanks[1]&7&0xFE)+1); - } - MMC5MemIn[3]=MMC5MemIn[4]=1; - MMC5ROMWrProtect[2]=MMC5ROMWrProtect[3]=1; - setprg16(0xC000,(PRGBanks[3]&0x7F)>>1); - break; - case 2: if(PRGBanks[1]&0x80) - { - MMC5MemIn[1]=MMC5MemIn[2]=1; - MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=1; - setprg16(0x8000,(PRGBanks[1]&0x7F)>>1); - } - else - { - MMC5ROMWrProtect[0]=MMC5ROMWrProtect[1]=0; - MMC5WRAM(0x8000,PRGBanks[1]&7&0xFE); - MMC5WRAM(0xA000,(PRGBanks[1]&7&0xFE)+1); - } - if(PRGBanks[2]&0x80) - { - MMC5ROMWrProtect[2]=1; - MMC5MemIn[3]=1; - setprg8(0xC000,PRGBanks[2]&0x7F); - } - else - { - MMC5ROMWrProtect[2]=0; - MMC5WRAM(0xC000,PRGBanks[2]&7); - } - MMC5MemIn[4]=1; - MMC5ROMWrProtect[3]=1; - setprg8(0xE000,PRGBanks[3]&0x7F); - break; - case 3: for(x=0;x<3;x++) - if(PRGBanks[x]&0x80) - { - MMC5ROMWrProtect[x]=1; - setprg8(0x8000+(x<<13),PRGBanks[x]&0x7F); - MMC5MemIn[1+x]=1; - } - else - { - MMC5ROMWrProtect[x]=0; - MMC5WRAM(0x8000+(x<<13),PRGBanks[x]&7); - } - MMC5MemIn[4]=1; - MMC5ROMWrProtect[3]=1; - setprg8(0xE000,PRGBanks[3]&0x7F); - break; - } -} - -static DECLFW(Mapper5_write) -{ - if(A>=0x5120&&A<=0x5127) - { - ABMode = 0; - CHRBanksA[A&7]=V; - MMC5CHRA(); - } - else switch(A) - { - case 0x5105: { - int x; - for(x=0;x<4;x++) - { - switch((V>>(x<<1))&3) - { - case 0:PPUNTARAM|=1<>3)&0x1F;break; - case 0x5202: MMC5HackSPPage=V&0x3F;break; - case 0x5203: X6502_IRQEnd(FCEU_IQEXT);IRQScanline=V;break; - case 0x5204: X6502_IRQEnd(FCEU_IQEXT);IRQEnable=V&0x80;break; - case 0x5205: mul[0]=V;break; - case 0x5206: mul[1]=V;break; - } -} - -static DECLFR(MMC5_ReadROMRAM) -{ - if(MMC5MemIn[(A-0x6000)>>13]) - return Page[A>>11][A]; - else - return X.DB; -} - -static DECLFW(MMC5_WriteROMRAM) -{ - if(A>=0x8000) - if(MMC5ROMWrProtect[(A-0x8000)>>13]) return; - if(MMC5MemIn[(A-0x6000)>>13]) - if(((WRAMMaskEnable[0]&3)|((WRAMMaskEnable[1]&3)<<2)) == 6) Page[A>>11][A]=V; -} - -static DECLFW(MMC5_ExRAMWr) -{ - if(MMC5HackCHRMode!=3) - ExRAM[A&0x3ff]=V; -} - -static DECLFR(MMC5_ExRAMRd) -{ - /* Not sure if this is correct, so I'll comment it out for now. */ - //if(MMC5HackCHRMode>=2) - return ExRAM[A&0x3ff]; - //else - // return(X.DB); -} - -static DECLFR(MMC5_read) -{ - switch(A) - { - case 0x5204: X6502_IRQEnd(FCEU_IQEXT); - { - uint8 x; - x=MMC5IRQR; - if(!fceuindbg) - MMC5IRQR&=0x40; - return x; - } - case 0x5205: return (mul[0]*mul[1]); - case 0x5206: return ((mul[0]*mul[1])>>8); - } - return(X.DB); -} - -void MMC5Synco(void) -{ - int x; - - MMC5PRG(); - for(x=0;x<4;x++) - { - switch((NTAMirroring>>(x<<1))&3) - { - case 0:PPUNTARAM|=1<>4]+=MMC5Sound.raw<<1; -} - -static void Do5PCMHQ() -{ - int32 V; - if(!(MMC5Sound.rawcontrol&0x40) && MMC5Sound.raw) - for(V=MMC5Sound.BC[2];V>2); - MMC5Sound.env[A>>2]=V; - break; - case 0x2: - case 0x6: if(sfun) sfun(A>>2); - MMC5Sound.wl[A>>2]&=~0x00FF; - MMC5Sound.wl[A>>2]|=V&0xFF; - break; - case 0x3: - case 0x7://printf("%04x:$%02x\n",A,V>>3); - MMC5Sound.wl[A>>2]&=~0x0700; - MMC5Sound.wl[A>>2]|=(V&0x07)<<8; - MMC5Sound.running|=1<<(A>>2); - break; - case 0x15:if(sfun) - { - sfun(0); - sfun(1); - } - MMC5Sound.running&=V; - MMC5Sound.enable=V; - //printf("%02x\n",V); - break; - } -} - -static void Do5SQ(int P) -{ - static int tal[4]={1,2,4,6}; - int32 V,amp,rthresh,wl; - int32 start,end; - - start=MMC5Sound.BC[P]; - end=(SOUNDTS<<16)/soundtsinc; - if(end<=start) return; - MMC5Sound.BC[P]=end; - - wl=MMC5Sound.wl[P]+1; - amp=(MMC5Sound.env[P]&0xF)<<4; - rthresh=tal[(MMC5Sound.env[P]&0xC0)>>6]; - - if(wl>=8 && (MMC5Sound.running&(P+1))) - { - int dc,vc; - - wl<<=18; - dc=MMC5Sound.dcount[P]; - vc=MMC5Sound.vcount[P]; - - for(V=start;V>4]+=amp; - vc-=nesincsize; - while(vc<=0) - { - vc+=wl; - dc=(dc+1)&7; - } - } - MMC5Sound.dcount[P]=dc; - MMC5Sound.vcount[P]=vc; - } -} - -static void Do5SQHQ(int P) -{ - static int tal[4]={1,2,4,6}; - int32 V,amp,rthresh,wl; - - wl=MMC5Sound.wl[P]+1; - amp=((MMC5Sound.env[P]&0xF)<<8); - rthresh=tal[(MMC5Sound.env[P]&0xC0)>>6]; - - if(wl>=8 && (MMC5Sound.running&(P+1))) - { - int dc,vc; - - wl<<=1; - - dc=MMC5Sound.dcount[P]; - vc=MMC5Sound.vcount[P]; - for(V=MMC5Sound.BC[P];V=1) - { - sfun=Do5SQHQ; - psfun=Do5PCMHQ; - } - else - { - sfun=Do5SQ; - psfun=Do5PCM; - } - } - else - { - sfun=0; - psfun=0; - } - memset(MMC5Sound.BC,0,sizeof(MMC5Sound.BC)); - memset(MMC5Sound.vcount,0,sizeof(MMC5Sound.vcount)); - GameExpSound.HiSync=MMC5HiSync; -} - -void NSFMMC5_Init(void) -{ - memset(&MMC5Sound,0,sizeof(MMC5Sound)); - mul[0]=mul[1]=0; - ExRAM=(uint8*)FCEU_gmalloc(1024); - Mapper5_ESI(); - SetWriteHandler(0x5c00,0x5fef,MMC5_ExRAMWr); - SetReadHandler(0x5c00,0x5fef,MMC5_ExRAMRd); - MMC5HackCHRMode=2; - SetWriteHandler(0x5000,0x5015,Mapper5_SW); - SetWriteHandler(0x5205,0x5206,Mapper5_write); - SetReadHandler(0x5205,0x5206,MMC5_read); -} - -void NSFMMC5_Close(void) -{ - FCEU_gfree(ExRAM); - ExRAM=0; -} - -static void GenMMC5Reset(void) -{ - int x; - - for(x=0;x<4;x++) PRGBanks[x]=~0; - for(x=0;x<8;x++) CHRBanksA[x]=~0; - for(x=0;x<4;x++) CHRBanksB[x]=~0; - WRAMMaskEnable[0]=WRAMMaskEnable[1]=~0; - - mmc5psize=mmc5vsize=3; - CHRMode=0; - - NTAMirroring=NTFill=ATFill=0xFF; - - MMC5Synco(); - - SetWriteHandler(0x4020,0x5bff,Mapper5_write); - SetReadHandler(0x4020,0x5bff,MMC5_read); - - SetWriteHandler(0x5c00,0x5fff,MMC5_ExRAMWr); - SetReadHandler(0x5c00,0x5fff,MMC5_ExRAMRd); - - SetWriteHandler(0x6000,0xFFFF,MMC5_WriteROMRAM); - SetReadHandler(0x6000,0xFFFF,MMC5_ReadROMRAM); - - SetWriteHandler(0x5000,0x5015,Mapper5_SW); - SetWriteHandler(0x5205,0x5206,Mapper5_write); - SetReadHandler(0x5205,0x5206,MMC5_read); - - //GameHBIRQHook=MMC5_hb; - FCEU_CheatAddRAM(8,0x6000,WRAM); - FCEU_CheatAddRAM(1,0x5c00,ExRAM); -} - -static SFORMAT MMC5_StateRegs[]={ - { PRGBanks, 4, "PRGB"}, - { CHRBanksA, 8, "CHRA"}, - { CHRBanksB, 4, "CHRB"}, - { &WRAMPage, 1, "WRMP"}, - { WRAMMaskEnable, 2, "WRME"}, - { &ABMode, 1, "ABMD"}, - { &IRQScanline, 1, "IRQS"}, - { &IRQEnable, 1, "IRQE"}, - { &CHRMode, 1, "CHRM"}, - { &NTAMirroring, 1, "NTAM"}, - { &NTFill, 1, "NTFL"}, - { &ATFill, 1, "ATFL"}, - - { &MMC5Sound.wl[0], 2|FCEUSTATE_RLSB, "SDW0"}, - { &MMC5Sound.wl[1], 2|FCEUSTATE_RLSB, "SDW1"}, - { MMC5Sound.env, 2, "SDEV"}, - { &MMC5Sound.enable, 1, "SDEN"}, - { &MMC5Sound.running, 1, "SDRU"}, - { &MMC5Sound.raw, 1, "SDRW"}, - { &MMC5Sound.rawcontrol, 1, "SDRC"}, - {0} -}; - -static void GenMMC5_Init(CartInfo *info, int wsize, int battery) -{ - if(wsize) - { - WRAM=(uint8*)FCEU_gmalloc(wsize*1024); - SetupCartPRGMapping(0x10,WRAM,wsize*1024,1); - AddExState(WRAM, wsize*1024, 0, "WRAM"); - } - - MMC5fill=(uint8*)FCEU_gmalloc(1024); - ExRAM=(uint8*)FCEU_gmalloc(1024); - - AddExState(MMC5_StateRegs, ~0, 0, 0); - AddExState(WRAM, wsize*1024, 0, "WRAM"); - AddExState(ExRAM, 1024, 0, "ERAM"); - AddExState(&MMC5HackSPMode, 1, 0, "SPLM"); - AddExState(&MMC5HackSPScroll, 1, 0, "SPLS"); - AddExState(&MMC5HackSPPage, 1, 0, "SPLP"); - - MMC5WRAMsize=wsize/8; - BuildWRAMSizeTable(); - GameStateRestore=MMC5_StateRestore; - info->Power=GenMMC5Reset; - - if(battery) - { - info->SaveGame[0]=WRAM; - if(wsize<=16) - info->SaveGameLen[0]=8192; - else - info->SaveGameLen[0]=32768; - } - - MMC5HackVROMMask=CHRmask4[0]; - MMC5HackExNTARAMPtr=ExRAM; - MMC5Hack=1; - MMC5HackVROMPTR=CHRptr[0]; - MMC5HackCHRMode=0; - MMC5HackSPMode=MMC5HackSPScroll=MMC5HackSPPage=0; - Mapper5_ESI(); -} - -void Mapper5_Init(CartInfo *info) -{ - GenMMC5_Init(info, DetectMMC5WRAMSize(info->CRC32), info->battery); -} - -// ELROM seems to have 0KB of WRAM -// EKROM seems to have 8KB of WRAM -// ETROM seems to have 16KB of WRAM -// EWROM seems to have 32KB of WRAM - -// ETROM and EWROM are battery-backed, EKROM isn't. - -void ETROM_Init(CartInfo *info) -{ - GenMMC5_Init(info, 16,info->battery); -} - -void ELROM_Init(CartInfo *info) -{ - GenMMC5_Init(info,0,0); -} - -void EWROM_Init(CartInfo *info) -{ - GenMMC5_Init(info,32,info->battery); -} - -void EKROM_Init(CartInfo *info) -{ - GenMMC5_Init(info,8,info->battery); -} diff --git a/source/mbshare/n106.c b/source/mbshare/n106.c deleted file mode 100644 index 20bedf9..0000000 --- a/source/mbshare/n106.c +++ /dev/null @@ -1,502 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint16 IRQCount; -static uint8 IRQa; - -static uint8 WRAM[8192]; -static uint8 IRAM[128]; - -static DECLFR(AWRAM) -{ - return(WRAM[A-0x6000]); -} - -static DECLFW(BWRAM) -{ - WRAM[A-0x6000]=V; -} - -void Mapper19_ESI(void); - -static uint8 NTAPage[4]; - -static uint8 dopol; -static uint8 gorfus; -static uint8 gorko; - -static void NamcoSound(int Count); -static void NamcoSoundHack(void); -static void DoNamcoSound(int32 *Wave, int Count); -static void DoNamcoSoundHQ(void); -static void SyncHQ(int32 ts); - -static int is210; /* Lesser mapper. */ - -static uint8 PRG[3]; -static uint8 CHR[8]; - -static SFORMAT N106_StateRegs[]={ - {PRG,3,"PRG"}, - {CHR,8,"CHR"}, - {NTAPage,4,"NTA"}, - {0} -}; - -static void SyncPRG(void) -{ - setprg8(0x8000,PRG[0]); - setprg8(0xa000,PRG[1]); - setprg8(0xc000,PRG[2]); - setprg8(0xe000,0x3F); -} - -static void FP_FASTAPASS(1) NamcoIRQHook(int a) -{ - if(IRQa) - { - IRQCount+=a; - if(IRQCount>=0x7FFF) - { - X6502_IRQBegin(FCEU_IQEXT); - IRQa=0; - IRQCount=0x7FFF; //7FFF; - } - } -} - -static DECLFR(Namco_Read4800) -{ - uint8 ret=IRAM[dopol&0x7f]; - - //printf("Read: %02x, %02x\n",dopol&0x7f,IRAM[dopol&0x7f]); - - /* Maybe I should call NamcoSoundHack() here? */ - if(!fceuindbg) - if(dopol&0x80) - dopol=(dopol&0x80)|((dopol+1)&0x7f); - return ret; -} - -static DECLFR(Namco_Read5000) -{ - return(IRQCount); -} - -static DECLFR(Namco_Read5800) -{ - return(IRQCount>>8); -} - -static void FASTAPASS(2) DoNTARAMROM(int w, uint8 V) -{ - NTAPage[w]=V; - //if(V>=0xE0) - // setntamem(NTARAM+((V&1)<<10), 1, w); - - //printf("%d, %02x\n",w,V); - //printf("%02x, %02x\n",((gorko>>(6+(w>>1)))&1),V); - if(V>=0xE0) - setntamem(NTARAM+((V&1)<<10), 1, w); - else - { - V&=CHRmask1[0]; - setntamem(CHRptr[0]+(V<<10), 0, w); - } -} - -static void FixNTAR(void) -{ - int x; - - for(x=0;x<4;x++) - DoNTARAMROM(x,NTAPage[x]); -} - -static void FASTAPASS(2) DoCHRRAMROM(int x, uint8 V) -{ - CHR[x]=V; - - if(!is210 && !((gorfus>>((x>>2)+6))&1) && (V>=0xE0)) - { - // printf("BLAHAHA: %d, %02x\n",x,V); - //setchr1r(0x10,x<<10,V&7); - } - else - { -// printf("Noha: %d, %02x\n",x,V); - setchr1(x<<10,V); - } -} - -static void FixCRR(void) -{ - int x; - for(x=0;x<8;x++) - DoCHRRAMROM(x,CHR[x]); -} - -static DECLFW(Mapper19C0D8_write) -{ - DoNTARAMROM((A-0xC000)>>11,V); -} - -static uint32 FreqCache[8]; -static uint32 EnvCache[8]; -static uint32 LengthCache[8]; - -static void FixCache(int a,int V) -{ - int w=(a>>3)&0x7; - switch(a&0x07) - { - case 0x00:FreqCache[w]&=~0x000000FF;FreqCache[w]|=V;break; - case 0x02:FreqCache[w]&=~0x0000FF00;FreqCache[w]|=V<<8;break; - case 0x04:FreqCache[w]&=~0x00030000;FreqCache[w]|=(V&3)<<16; - LengthCache[w]=(8-((V>>2)&7))<<2; - break; - case 0x07:EnvCache[w]=(double)(V&0xF)*576716;break; - } - -} - -static DECLFW(Mapper19_write) -{ - A&=0xF800; - - if(A>=0x8000 && A<=0xb800) - DoCHRRAMROM((A-0x8000)>>11,V); - else switch(A) - { - case 0x4800: - //printf("Yahaoo: %02x, %02x\n",dopol&0x7F,V); - //puts("Hmm"); - if(dopol&0x40) - { - if(FSettings.SndRate) - { - NamcoSoundHack(); - GameExpSound.Fill=NamcoSound; - //GameExpSound.NeoFill=DoNamcoSound; - GameExpSound.HiFill=DoNamcoSoundHQ; - GameExpSound.HiSync=SyncHQ; - } - FixCache(dopol,V); - } - IRAM[dopol&0x7f]=V; - - if(dopol&0x80) - dopol=(dopol&0x80)|((dopol+1)&0x7f); - break; - - case 0xf800: dopol=V;break; - case 0x5000: IRQCount&=0xFF00;IRQCount|=V;X6502_IRQEnd(FCEU_IQEXT);break; - case 0x5800: IRQCount&=0x00ff;IRQCount|=(V&0x7F)<<8; - IRQa=V&0x80; - X6502_IRQEnd(FCEU_IQEXT); - //puts("IRQe"); - break; - - case 0xE000:gorko=V&0xC0; - PRG[0]=V&0x3F; - SyncPRG(); - break; - case 0xE800:gorfus=V&0xC0; - FixCRR(); - PRG[1]=V&0x3F; - SyncPRG(); - break; - case 0xF000:PRG[2]=V&0x3F; - SyncPRG(); - break; - } -} - -static int dwave=0; - -static void NamcoSoundHack(void) -{ - int32 z,a; - if(FSettings.soundq>=1) - { - DoNamcoSoundHQ(); - return; - } - z=((SOUNDTS<<16)/soundtsinc)>>4; - a=z-dwave; - if(a) - DoNamcoSound(&Wave[dwave], a); - dwave+=a; -} - -static void NamcoSound(int Count) -{ - int32 z,a; - - z=((SOUNDTS<<16)/soundtsinc)>>4; - a=z-dwave; - if(a) - DoNamcoSound(&Wave[dwave], a); - dwave=0; -} - -static uint32 PlayIndex[8]; -static int32 vcount[8]; -static int32 CVBC; - -#define TOINDEX (16+1) - -// 16:15 -static void SyncHQ(int32 ts) -{ - CVBC=ts; -} - - -/* Things to do: - 1 Read freq low - 2 Read freq mid - 3 Read freq high - 4 Read envelope - ...? -*/ - -static INLINE uint32 FetchDuff(uint32 P, uint32 envelope) -{ - uint32 duff; - duff=IRAM[((IRAM[0x46+(P<<3)]+(PlayIndex[P]>>TOINDEX))&0xFF)>>1]; - if((IRAM[0x46+(P<<3)]+(PlayIndex[P]>>TOINDEX))&1) - duff>>=4; - duff&=0xF; - duff=(duff*envelope)>>16; - return(duff); -} - -static void DoNamcoSoundHQ(void) -{ - int32 P,V; - int32 cyclesuck=(((IRAM[0x7F]>>4)&7)+1)*15; - - for(P=7;P>=(7-((IRAM[0x7F]>>4)&7));P--) - { - if((IRAM[0x44+(P<<3)]&0xE0) && (IRAM[0x47+(P<<3)]&0xF)) - { - uint32 freq; - int32 vco; - uint32 duff2,lengo,envelope; - - vco=vcount[P]; - freq=FreqCache[P]; - envelope=EnvCache[P]; - lengo=LengthCache[P]; - - duff2=FetchDuff(P,envelope); - for(V=CVBC<<1;V>1]+=duff2; - if(!vco) - { - PlayIndex[P]+=freq; - while((PlayIndex[P]>>TOINDEX)>=lengo) - PlayIndex[P]-=lengo<>4); - for(P=7;P>=7-((IRAM[0x7F]>>4)&7);P--) - { - if((IRAM[0x44+(P<<3)]&0xE0) && (IRAM[0x47+(P<<3)]&0xF)) - { - int32 inc; - uint32 freq; - int32 vco; - uint32 duff,duff2,lengo,envelope; - //uint64 ta; - - vco=vcount[P]; - freq=FreqCache[P]; - envelope=EnvCache[P]; - lengo=LengthCache[P]; - - if(!freq) {/*printf("Ack");*/ continue;} - - { - int c=((IRAM[0x7F]>>4)&7)+1; - - inc=(long double)(FSettings.SndRate<<15)/((long double)freq* - 21477272/((long double)0x400000*c*45)); - } - - duff=IRAM[(((IRAM[0x46+(P<<3)]+PlayIndex[P])&0xFF)>>1)]; - if((IRAM[0x46+(P<<3)]+PlayIndex[P])&1) - duff>>=4; - duff&=0xF; - duff2=(duff*envelope)>>19; - for(V=0;V=inc) - { - PlayIndex[P]++; - if(PlayIndex[P]>=lengo) - PlayIndex[P]=0; - vco-=inc; - duff=IRAM[(((IRAM[0x46+(P<<3)]+PlayIndex[P])&0xFF)>>1)]; - if((IRAM[0x46+(P<<3)]+PlayIndex[P])&1) - duff>>=4; - duff&=0xF; - duff2=(duff*envelope)>>19; - } - Wave[V>>4]+=duff2; - vco+=0x8000; - } - vcount[P]=vco; - } - } -} - -static void Mapper19_StateRestore(int version) -{ - int x; - - SyncPRG(); - FixNTAR(); - FixCRR(); - for(x=0x40;x<0x80;x++) - FixCache(x,IRAM[x]); -} - -static void M19SC(void) -{ - if(FSettings.SndRate) - Mapper19_ESI(); -} - -void Mapper19_ESI(void) -{ - GameExpSound.RChange=M19SC; - memset(vcount,0,sizeof(vcount)); - memset(PlayIndex,0,sizeof(PlayIndex)); - CVBC=0; -} - -void NSFN106_Init(void) -{ - SetWriteHandler(0xf800,0xffff,Mapper19_write); - SetWriteHandler(0x4800,0x4fff,Mapper19_write); - SetReadHandler(0x4800,0x4fff,Namco_Read4800); - Mapper19_ESI(); -} - -static int battery=0; - -static void N106_Power(void) -{ - int x; - - SetReadHandler(0x8000,0xFFFF,CartBR); - SetWriteHandler(0x8000,0xffff,Mapper19_write); - SetWriteHandler(0x4020,0x5fff,Mapper19_write); - - if(!is210) - { - SetWriteHandler(0xc000,0xdfff,Mapper19C0D8_write); - SetReadHandler(0x4800,0x4fff,Namco_Read4800); - SetReadHandler(0x5000,0x57ff,Namco_Read5000); - SetReadHandler(0x5800,0x5fff,Namco_Read5800); - NTAPage[0]=NTAPage[1]=NTAPage[2]=NTAPage[3]=0xFF; - FixNTAR(); - } - - SetReadHandler(0x6000,0x7FFF,AWRAM); - SetWriteHandler(0x6000,0x7FFF,BWRAM); - FCEU_CheatAddRAM(8,0x6000,WRAM); - - gorfus=0xFF; - SyncPRG(); - FixCRR(); - - if(!battery) - { - FCEU_dwmemset(WRAM,0,8192); - FCEU_dwmemset(IRAM,0,128); - } - for(x=0x40;x<0x80;x++) - FixCache(x,IRAM[x]); -} - -void Mapper19_Init(CartInfo *info) -{ - is210=0; - - battery=info->battery; - info->Power=N106_Power; - - MapIRQHook=NamcoIRQHook; - GameStateRestore=Mapper19_StateRestore; - GameExpSound.RChange=M19SC; - - if(FSettings.SndRate) - Mapper19_ESI(); - - AddExState(WRAM, 8192, 0, "WRAM"); - AddExState(IRAM, 128, 0, "WRAM"); - AddExState(N106_StateRegs, ~0, 0, 0); - - if(info->battery) - { - info->SaveGame[0]=WRAM; - info->SaveGameLen[0]=8192; - info->SaveGame[1]=IRAM; - info->SaveGameLen[1]=128; - } -} - -static void Mapper210_StateRestore(int version) -{ - SyncPRG(); - FixCRR(); -} - -void Mapper210_Init(CartInfo *info) -{ - is210=1; - - GameStateRestore=Mapper210_StateRestore; - info->Power=N106_Power; - - - AddExState(WRAM, 8192, 0, "WRAM"); -} diff --git a/source/mbshare/tengen.c b/source/mbshare/tengen.c deleted file mode 100644 index ec43bca..0000000 --- a/source/mbshare/tengen.c +++ /dev/null @@ -1,224 +0,0 @@ -/* FCE Ultra - NES/Famicom Emulator - * - * Copyright notice for this file: - * Copyright (C) 2002 Xodnizel - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "mapinc.h" - -static uint8 cmd,mir,rmode,IRQmode; -static uint8 DRegs[11]; -static uint8 IRQCount,IRQa,IRQLatch; - -static SFORMAT Rambo_StateRegs[]={ - {&cmd, 1, "CMD"}, - {&mir, 1, "MIR"}, - {&rmode, 1, "RMOD"}, - {&IRQmode, 1, "IRQM"}, - {&IRQCount, 1, "IRQC"}, - {&IRQa, 1, "IRQA"}, - {&IRQLatch, 1, "IRQL"}, - {DRegs, 11, "DREG"}, - {0} -}; - -static void FP_FASTAPASS(2) (*setchr1wrap)(unsigned int A, unsigned int V); -static int nomirror; - -static void FP_FASTAPASS(1) RAMBO1_IRQHook(int a) -{ - static int smallcount; - if(!IRQmode) return; - - smallcount+=a; - while(smallcount>=4) - { - smallcount-=4; - IRQCount--; - if(IRQCount==0xFF) - { - if(IRQa) - { - //printf("IRQ: %d\n",scanline); - //rmode = 1; - X6502_IRQBegin(FCEU_IQEXT); - } - } - } -} - -static void RAMBO1_hb(void) -{ - if(IRQmode) return; - if(scanline==240) return; /* hmm. Maybe that should be an mmc3-only - call in fce.c. */ - rmode=0; - IRQCount--; - if(IRQCount==0xFF) - { - if(IRQa) - { - rmode = 1; - X6502_IRQBegin(FCEU_IQEXT); - } - } -} - -static void Synco(void) -{ - int x; - - if(cmd&0x20) - { - setchr1wrap(0x0000,DRegs[0]); - setchr1wrap(0x0800,DRegs[1]); - setchr1wrap(0x0400,DRegs[8]); - setchr1wrap(0x0c00,DRegs[9]); - } - else - { - setchr1wrap(0x0000,(DRegs[0]&0xFE)); - setchr1wrap(0x0400,(DRegs[0]&0xFE)|1); - setchr1wrap(0x0800,(DRegs[1]&0xFE)); - setchr1wrap(0x0C00,(DRegs[1]&0xFE)|1); - } - - for(x=0;x<4;x++) - setchr1wrap(0x1000+x*0x400,DRegs[2+x]); - - setprg8(0x8000,DRegs[6]); - setprg8(0xA000,DRegs[7]); - - setprg8(0xC000,DRegs[10]); -} - - -static DECLFW(RAMBO1_write) -{ - //if(A>=0xC000 && A<=0xFFFF) printf("$%04x:$%02x, %d, %d\n",A,V,scanline,timestamp); - switch(A&0xF001) - { - case 0xa000:mir=V&1; - if(!nomirror) - setmirror(mir^1); - break; - case 0x8000:cmd = V; - break; - case 0x8001: - if((cmd&0xF)<10) - DRegs[cmd&0xF]=V; - else if((cmd&0xF)==0xF) - DRegs[10]=V; - Synco(); - break; - case 0xc000:IRQLatch=V; - if(rmode==1) - { - IRQCount=IRQLatch; - } - break; - case 0xc001:rmode=1; - IRQCount=IRQLatch; - IRQmode=V&1; - break; - case 0xE000:IRQa=0;X6502_IRQEnd(FCEU_IQEXT); - if(rmode==1) - {IRQCount=IRQLatch;} - break; - case 0xE001:IRQa=1; - if(rmode==1) - {IRQCount=IRQLatch;} - break; - } -} - -static void RAMBO1_Restore(int version) -{ - Synco(); - if(!nomirror) - setmirror(mir^1); -} - -static void RAMBO1_init(void) -{ - int x; - - for(x=0;x<11;x++) - DRegs[x]=~0; - cmd=0; - mir=0; - if(!nomirror) - setmirror(1); - Synco(); - GameHBIRQHook=RAMBO1_hb; - MapIRQHook=RAMBO1_IRQHook; - GameStateRestore=RAMBO1_Restore; - SetWriteHandler(0x8000,0xffff,RAMBO1_write); - - AddExState(Rambo_StateRegs, ~0, 0, 0); -} - -static void FP_FASTAPASS(2) CHRWrap(unsigned int A, unsigned int V) -{ - setchr1(A,V); -} - -void Mapper64_init(void) -{ - setchr1wrap=CHRWrap; - nomirror=0; - RAMBO1_init(); -} - -static int MirCache[8]; -static unsigned int PPUCHRBus; - -static void FP_FASTAPASS(2) MirWrap(unsigned int A, unsigned int V) -{ - MirCache[A>>10]=(V>>7)&1; - if(PPUCHRBus==(A>>10)) - setmirror(MI_0+((V>>7)&1)); - setchr1(A,V); -} - -static void FP_FASTAPASS(1) MirrorFear(uint32 A) -{ - A&=0x1FFF; - A>>=10; - PPUCHRBus=A; - setmirror(MI_0+MirCache[A]); -} - -void Mapper158_init(void) -{ - setchr1wrap=MirWrap; - PPU_hook=MirrorFear; - nomirror=1; - RAMBO1_init(); -} - - -static DECLFW(MIMIC1_Write) -{ - - -} - -void Mapper159_init(void) -{ - SetWriteHandler(0x8000,0xFFFF,MIMIC1_Write); -} diff --git a/source/palettes/palettes.h b/source/palettes/palettes.h deleted file mode 100644 index ed6c2db..0000000 --- a/source/palettes/palettes.h +++ /dev/null @@ -1,94 +0,0 @@ -pal rp2c04001[64] = { - #include "rp2c04001.h" -}; - -pal rp2c04002[64] = { - #include "rp2c04002.h" -}; - -pal rp2c04003[64] = { - #include "rp2c04003.h" -}; -pal rp2c05004[64] = { - #include "rp2c05004.h" -}; - -pal unvpalette[7] = { -{ 0x00<<2,0x00<<2,0x00<<2}, // Black -{ 0x3F<<2,0x3F<<2,0x34<<2}, // White -{ 0x00<<2,0x00<<2,0x00<<2}, // Black -{ 0x1d<<2,0x1d<<2,0x24<<2}, // Greyish -{ 190,0,0 }, // Redish -{ 51,255,51}, // Bright green -{ 49,14,200}, -}; - - -/* Default palette */ -pal palette[64] = { - - { 0x1D<<2, 0x1D<<2, 0x1D<<2 }, /* Value 0 */ - { 0x09<<2, 0x06<<2, 0x23<<2 }, /* Value 1 */ - { 0x00<<2, 0x00<<2, 0x2A<<2 }, /* Value 2 */ - { 0x11<<2, 0x00<<2, 0x27<<2 }, /* Value 3 */ - { 0x23<<2, 0x00<<2, 0x1D<<2 }, /* Value 4 */ - { 0x2A<<2, 0x00<<2, 0x04<<2 }, /* Value 5 */ - { 0x29<<2, 0x00<<2, 0x00<<2 }, /* Value 6 */ - { 0x1F<<2, 0x02<<2, 0x00<<2 }, /* Value 7 */ - { 0x10<<2, 0x0B<<2, 0x00<<2 }, /* Value 8 */ - { 0x00<<2, 0x11<<2, 0x00<<2 }, /* Value 9 */ - { 0x00<<2, 0x14<<2, 0x00<<2 }, /* Value 10 */ - { 0x00<<2, 0x0F<<2, 0x05<<2 }, /* Value 11 */ - { 0x06<<2, 0x0F<<2, 0x17<<2 }, /* Value 12 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 13 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 14 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 15 */ - { 0x2F<<2, 0x2F<<2, 0x2F<<2 }, /* Value 16 */ - { 0x00<<2, 0x1C<<2, 0x3B<<2 }, /* Value 17 */ - { 0x08<<2, 0x0E<<2, 0x3B<<2 }, /* Value 18 */ - { 0x20<<2, 0x00<<2, 0x3C<<2 }, /* Value 19 */ - { 0x2F<<2, 0x00<<2, 0x2F<<2 }, /* Value 20 */ - { 0x39<<2, 0x00<<2, 0x16<<2 }, /* Value 21 */ - { 0x36<<2, 0x0A<<2, 0x00<<2 }, /* Value 22 */ - { 0x32<<2, 0x13<<2, 0x03<<2 }, /* Value 23 */ - { 0x22<<2, 0x1C<<2, 0x00<<2 }, /* Value 24 */ - { 0x00<<2, 0x25<<2, 0x00<<2 }, /* Value 25 */ - { 0x00<<2, 0x2A<<2, 0x00<<2 }, /* Value 26 */ - { 0x00<<2, 0x24<<2, 0x0E<<2 }, /* Value 27 */ - { 0x00<<2, 0x20<<2, 0x22<<2 }, /* Value 28 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 29 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 30 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 31 */ - { 0x3F<<2, 0x3F<<2, 0x3F<<2 }, /* Value 32 */ - { 0x0F<<2, 0x2F<<2, 0x3F<<2 }, /* Value 33 */ - { 0x17<<2, 0x25<<2, 0x3F<<2 }, /* Value 34 */ - { 0x10<<2, 0x22<<2, 0x3F<<2 }, /* Value 35 */ - { 0x3D<<2, 0x1E<<2, 0x3F<<2 }, /* Value 36 */ - { 0x3F<<2, 0x1D<<2, 0x2D<<2 }, /* Value 37 */ - { 0x3F<<2, 0x1D<<2, 0x18<<2 }, /* Value 38 */ - { 0x3F<<2, 0x26<<2, 0x0E<<2 }, /* Value 39 */ - { 0x3C<<2, 0x2F<<2, 0x0F<<2 }, /* Value 40 */ - { 0x20<<2, 0x34<<2, 0x04<<2 }, /* Value 41 */ - { 0x13<<2, 0x37<<2, 0x12<<2 }, /* Value 42 */ - { 0x16<<2, 0x3E<<2, 0x26<<2 }, /* Value 43 */ - { 0x00<<2, 0x3A<<2, 0x36<<2 }, /* Value 44 */ - { 0x1E<<2, 0x1E<<2, 0x1E<<2 }, /* Value 45 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 46 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 47 */ - { 0x3F<<2, 0x3F<<2, 0x3F<<2 }, /* Value 48 */ - { 0x2A<<2, 0x39<<2, 0x3F<<2 }, /* Value 49 */ - { 0x31<<2, 0x35<<2, 0x3F<<2 }, /* Value 50 */ - { 0x35<<2, 0x32<<2, 0x3F<<2 }, /* Value 51 */ - { 0x3F<<2, 0x31<<2, 0x3F<<2 }, /* Value 52 */ - { 0x3F<<2, 0x31<<2, 0x36<<2 }, /* Value 53 */ - { 0x3F<<2, 0x2F<<2, 0x2C<<2 }, /* Value 54 */ - { 0x3F<<2, 0x36<<2, 0x2A<<2 }, /* Value 55 */ - { 0x3F<<2, 0x39<<2, 0x28<<2 }, /* Value 56 */ - { 0x38<<2, 0x3F<<2, 0x28<<2 }, /* Value 57 */ - { 0x2A<<2, 0x3C<<2, 0x2F<<2 }, /* Value 58 */ - { 0x2C<<2, 0x3F<<2, 0x33<<2 }, /* Value 59 */ - { 0x27<<2, 0x3F<<2, 0x3C<<2 }, /* Value 60 */ - { 0x31<<2, 0x31<<2, 0x31<<2 }, /* Value 61 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 62 */ - { 0x00<<2, 0x00<<2, 0x00<<2 }, /* Value 63 */ -}; diff --git a/source/palettes/rp2c04001.h b/source/palettes/rp2c04001.h deleted file mode 100644 index 8752b2e..0000000 --- a/source/palettes/rp2c04001.h +++ /dev/null @@ -1,64 +0,0 @@ -{0xfc, 0xc4, 0xd8}, -{0x40, 0x88, 0xfc}, -{0xd8, 0x28, 0x00}, -{0x5c, 0x94, 0xfc}, -{0x00, 0x80, 0x88}, -{0x00, 0x44, 0x00}, -{0x00, 0x00, 0x00}, -{0xe4, 0x00, 0x58}, -{0xfc, 0xfc, 0xfc}, -{0x74, 0x74, 0x74}, -{0xfc, 0x98, 0x38}, -{0xa8, 0x00, 0x10}, -{0x8c, 0x00, 0x74}, -{0xfc, 0x98, 0x38}, -{0x40, 0x2c, 0x00}, -{0xfc, 0xfc, 0xfc}, -{0x3c, 0xbc, 0xfc}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x80, 0xd0, 0x10}, -{0x9c, 0xfc, 0xf0}, -{0xc4, 0xd4, 0xfc}, -{0xfc, 0xbc, 0xb0}, -{0x20, 0x38, 0xec}, -{0x00, 0x00, 0x00}, -{0x58, 0xf8, 0x98}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0xfc, 0xfc, 0xfc}, -{0xbc, 0xbc, 0xbc}, -{0xf4, 0x78, 0xfc}, -{0x24, 0x18, 0x8c}, -{0x00, 0x00, 0x00}, -{0xa8, 0xe4, 0xfc}, -{0x00, 0x00, 0x00}, -{0x4c, 0xdc, 0x48}, -{0x00, 0xe8, 0xd8}, -{0x18, 0x3c, 0x5c}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x7c, 0x08, 0x00}, -{0xfc, 0xc4, 0xfc}, -{0xa4, 0x00, 0x00}, -{0x80, 0x00, 0xf0}, -{0x00, 0x00, 0xa8}, -{0xfc, 0x74, 0x60}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x94, 0x00}, -{0xbc, 0xbc, 0xbc}, -{0x00, 0x50, 0x00}, -{0xe0, 0xfc, 0xa0}, -{0x00, 0x00, 0x00}, -{0xfc, 0xd8, 0xa8}, -{0xc8, 0x4c, 0x0c}, -{0x00, 0x00, 0x00}, -{0x00, 0x70, 0xec}, -{0x00, 0x44, 0x00}, -{0x00, 0x00, 0x00}, -{0xe0, 0xfc, 0xa0}, -{0xfc, 0x74, 0xb4}, -{0x88, 0x70, 0x00}, -{0x00, 0x00, 0x00}, diff --git a/source/palettes/rp2c04002.h b/source/palettes/rp2c04002.h deleted file mode 100644 index d0f46b9..0000000 --- a/source/palettes/rp2c04002.h +++ /dev/null @@ -1,64 +0,0 @@ -{0x00, 0x00, 0x00}, -{0xfc, 0x98, 0x38}, -{0x88, 0x70, 0x00}, -{0x00, 0x00, 0x00}, -{0xa8, 0xf0, 0xbc}, -{0xfc, 0x74, 0xb4}, -{0x00, 0x00, 0x00}, -{0xa8, 0xe4, 0xfc}, -{0xd8, 0x28, 0x00}, -{0x80, 0x00, 0xf0}, -{0xfc, 0xe4, 0xa0}, -{0xfc, 0xc4, 0xfc}, -{0xfc, 0xfc, 0xfc}, -{0x40, 0x88, 0xfc}, -{0x00, 0x00, 0x00}, -{0x00, 0x3c, 0x14}, -{0x00, 0x00, 0x00}, -{0x3c, 0xbc, 0xfc}, -{0xa4, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x90, 0x38}, -{0x80, 0xd0, 0x10}, -{0x00, 0x00, 0x00}, -{0x5c, 0x94, 0xfc}, -{0x00, 0x00, 0x00}, -{0xf4, 0x78, 0xfc}, -{0x00, 0x00, 0x00}, -{0x58, 0xf8, 0x98}, -{0x00, 0x00, 0x00}, -{0x40, 0x2c, 0x00}, -{0x00, 0x00, 0x00}, -{0x44, 0x00, 0x9c}, -{0x00, 0x00, 0x00}, -{0xfc, 0xbc, 0xb0}, -{0xfc, 0x74, 0x60}, -{0xd4, 0xc8, 0xfc}, -{0x00, 0x70, 0xec}, -{0x00, 0x00, 0x00}, -{0xbc, 0xbc, 0xbc}, -{0x00, 0x00, 0xa8}, -{0xbc, 0x00, 0xbc}, -{0x00, 0x00, 0x00}, -{0x74, 0x74, 0x74}, -{0x00, 0x44, 0x00}, -{0x20, 0x38, 0xec}, -{0x00, 0x00, 0x00}, -{0xfc, 0xd8, 0xa8}, -{0xfc, 0xfc, 0xfc}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x4c, 0xdc, 0x48}, -{0xc8, 0x4c, 0x0c}, -{0x18, 0x3c, 0x5c}, -{0x24, 0x18, 0x8c}, -{0xe4, 0x00, 0x58}, -{0x00, 0x94, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0xe8, 0xd8}, -{0x7c, 0x08, 0x00}, -{0xfc, 0xd8, 0xa8}, -{0x00, 0x00, 0x00}, -{0xa8, 0x00, 0x10}, -{0x00, 0x50, 0x00}, -{0x74, 0x74, 0x74}, diff --git a/source/palettes/rp2c04003.h b/source/palettes/rp2c04003.h deleted file mode 100644 index 9a4717c..0000000 --- a/source/palettes/rp2c04003.h +++ /dev/null @@ -1,64 +0,0 @@ -{0x44, 0x00, 0x9c}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x74, 0x74, 0x74}, -{0x00, 0xa8, 0x00}, -{0xfc, 0xfc, 0xfc}, -{0xa8, 0xe4, 0xfc}, -{0x00, 0x44, 0x00}, -{0x24, 0x18, 0x8c}, -{0x00, 0x00, 0x00}, -{0xfc, 0xbc, 0xb0}, -{0x40, 0x2c, 0x00}, -{0xe4, 0x00, 0x58}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0xfc, 0xfc, 0xfc}, -{0x5c, 0x94, 0xfc}, -{0x00, 0x80, 0x88}, -{0x00, 0x00, 0x00}, -{0x20, 0x38, 0xec}, -{0x00, 0x94, 0x00}, -{0x88, 0x70, 0x00}, -{0xc8, 0x4c, 0x0c}, -{0x00, 0x90, 0x38}, -{0x74, 0x74, 0x74}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0xa8}, -{0xd8, 0x28, 0x00}, -{0xa4, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0xfc, 0xc4, 0xd8}, -{0x40, 0x88, 0xfc}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0xfc, 0xd8, 0xa8}, -{0x00, 0x00, 0x00}, -{0xfc, 0x98, 0x38}, -{0xfc, 0x74, 0x60}, -{0xfc, 0xfc, 0xfc}, -{0x80, 0xd0, 0x10}, -{0x00, 0x00, 0x00}, -{0x3c, 0xbc, 0xfc}, -{0xf4, 0x78, 0xfc}, -{0x00, 0x70, 0xec}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0xe8, 0xd8}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x7c, 0x08, 0x00}, -{0x4c, 0xdc, 0x48}, -{0xf0, 0xbc, 0x3c}, -{0x00, 0x00, 0x00}, -{0x00, 0x50, 0x00}, -{0x00, 0x00, 0x00}, -{0xc4, 0xd4, 0xfc}, -{0xfc, 0xd8, 0xa8}, -{0x80, 0x00, 0xf0}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x18, 0x3c, 0x5c}, diff --git a/source/palettes/rp2c05004.h b/source/palettes/rp2c05004.h deleted file mode 100644 index dc0a90a..0000000 --- a/source/palettes/rp2c05004.h +++ /dev/null @@ -1,64 +0,0 @@ -{0x88, 0x70, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x80, 0x88}, -{0xf0, 0xbc, 0x3c}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x24, 0x18, 0x8c}, -{0xc8, 0x4c, 0x0c}, -{0xbc, 0xbc, 0xbc}, -{0x00, 0x00, 0x00}, -{0x4c, 0xdc, 0x48}, -{0x00, 0x00, 0x00}, -{0xfc, 0xbc, 0xb0}, -{0xfc, 0xd8, 0xa8}, -{0x00, 0xa8, 0x00}, -{0x00, 0x00, 0x00}, -{0xfc, 0x74, 0xb4}, -{0x00, 0x00, 0x00}, -{0x20, 0x38, 0xec}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0xfc, 0x74, 0x60}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x5c, 0x94, 0xfc}, -{0x00, 0x94, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0xa8, 0xf0, 0xbc}, -{0x3c, 0xbc, 0xfc}, -{0xa8, 0x00, 0x10}, -{0x00, 0x50, 0x00}, -{0x7c, 0x08, 0x00}, -{0x00, 0x00, 0xa8}, -{0x80, 0x00, 0xf0}, -{0x00, 0x00, 0x00}, -{0x74, 0x74, 0x74}, -{0xe4, 0x00, 0x58}, -{0x18, 0x3c, 0x5c}, -{0x00, 0x00, 0x00}, -{0x00, 0x70, 0xec}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0xfc, 0xe4, 0xa0}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0x40, 0x2c, 0x00}, -{0xd8, 0x28, 0x00}, -{0x00, 0x00, 0x00}, -{0x00, 0x00, 0x00}, -{0xfc, 0xfc, 0xfc}, -{0x9c, 0xfc, 0xf0}, -{0x00, 0x00, 0x00}, -{0xfc, 0x98, 0x38}, -{0x00, 0x00, 0x00}, -{0xa8, 0xe4, 0xfc}, -{0x80, 0xd0, 0x10}, -{0x00, 0x00, 0x00}, -{0xfc, 0xfc, 0xfc}, -{0x00, 0x44, 0x00}, diff --git a/source/rom/ROM.NES b/source/rom/ROM.NES deleted file mode 100644 index ae87c0d3f1b325da0a38bc3d34466fdbd8a7fc10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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` diff --git a/source/sz/7zAlloc.c b/source/sz/7zAlloc.c deleted file mode 100644 index d5da81b..0000000 --- a/source/sz/7zAlloc.c +++ /dev/null @@ -1,70 +0,0 @@ -/* 7zAlloc.c */ - -#include -#include "7zAlloc.h" - -/* #define _SZ_ALLOC_DEBUG */ -/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ - -#ifdef _SZ_ALLOC_DEBUG - -#ifdef _WIN32 -#include -#endif -#include -int g_allocCount = 0; -int g_allocCountTemp = 0; -#endif - -void *SzAlloc(size_t size) -{ - if (size == 0) - return 0; - #ifdef _SZ_ALLOC_DEBUG - fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount); - g_allocCount++; - #endif - return malloc(size); -} - -void SzFree(void *address) -{ - #ifdef _SZ_ALLOC_DEBUG - if (address != 0) - { - g_allocCount--; - fprintf(stderr, "\nFree; count = %10d", g_allocCount); - } - #endif - free(address); -} - -void *SzAllocTemp(size_t size) -{ - if (size == 0) - return 0; - #ifdef _SZ_ALLOC_DEBUG - fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp); - g_allocCountTemp++; - #ifdef _WIN32 - return HeapAlloc(GetProcessHeap(), 0, size); - #endif - #endif - return malloc(size); -} - -void SzFreeTemp(void *address) -{ - #ifdef _SZ_ALLOC_DEBUG - if (address != 0) - { - g_allocCountTemp--; - fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp); - } - #ifdef _WIN32 - HeapFree(GetProcessHeap(), 0, address); - return; - #endif - #endif - free(address); -} diff --git a/source/sz/7zAlloc.h b/source/sz/7zAlloc.h deleted file mode 100644 index b02c1de..0000000 --- a/source/sz/7zAlloc.h +++ /dev/null @@ -1,20 +0,0 @@ -/* 7zAlloc.h */ - -#ifndef __7Z_ALLOC_H -#define __7Z_ALLOC_H - -#include - -typedef struct _ISzAlloc -{ - void *(*Alloc)(size_t size); - void (*Free)(void *address); /* address can be 0 */ -} ISzAlloc; - -void *SzAlloc(size_t size); -void SzFree(void *address); - -void *SzAllocTemp(size_t size); -void SzFreeTemp(void *address); - -#endif diff --git a/source/sz/7zBuffer.c b/source/sz/7zBuffer.c deleted file mode 100644 index 8bc8e06..0000000 --- a/source/sz/7zBuffer.c +++ /dev/null @@ -1,29 +0,0 @@ -/* 7zBuffer.c */ - -#include "7zBuffer.h" -#include "7zAlloc.h" - -void SzByteBufferInit(CSzByteBuffer *buffer) -{ - buffer->Capacity = 0; - buffer->Items = 0; -} - -int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size)) -{ - buffer->Capacity = newCapacity; - if (newCapacity == 0) - { - buffer->Items = 0; - return 1; - } - buffer->Items = (Byte *)allocFunc(newCapacity); - return (buffer->Items != 0); -} - -void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *)) -{ - freeFunc(buffer->Items); - buffer->Items = 0; - buffer->Capacity = 0; -} diff --git a/source/sz/7zBuffer.h b/source/sz/7zBuffer.h deleted file mode 100644 index afea3ca..0000000 --- a/source/sz/7zBuffer.h +++ /dev/null @@ -1,19 +0,0 @@ -/* 7zBuffer.h */ - -#ifndef __7Z_BUFFER_H -#define __7Z_BUFFER_H - -#include -#include "7zTypes.h" - -typedef struct _CSzByteBuffer -{ - size_t Capacity; - Byte *Items; -}CSzByteBuffer; - -void SzByteBufferInit(CSzByteBuffer *buffer); -int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size)); -void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *)); - -#endif diff --git a/source/sz/7zCrc.c b/source/sz/7zCrc.c deleted file mode 100644 index 6dc7dd3..0000000 --- a/source/sz/7zCrc.c +++ /dev/null @@ -1,76 +0,0 @@ -/* 7zCrc.c */ - -#include "7zCrc.h" - -#define kCrcPoly 0xEDB88320 - -UInt32 g_CrcTable[256]; - -void InitCrcTable() -{ - UInt32 i; - for (i = 0; i < 256; i++) - { - UInt32 r = i; - int j; - for (j = 0; j < 8; j++) - if (r & 1) - r = (r >> 1) ^ kCrcPoly; - else - r >>= 1; - g_CrcTable[i] = r; - } -} - -void CrcInit(UInt32 *crc) { *crc = 0xFFFFFFFF; } -UInt32 CrcGetDigest(UInt32 *crc) { return *crc ^ 0xFFFFFFFF; } - -void CrcUpdateByte(UInt32 *crc, Byte b) -{ - *crc = g_CrcTable[((Byte)(*crc)) ^ b] ^ (*crc >> 8); -} - -void CrcUpdateUInt16(UInt32 *crc, UInt16 v) -{ - CrcUpdateByte(crc, (Byte)v); - CrcUpdateByte(crc, (Byte)(v >> 8)); -} - -void CrcUpdateUInt32(UInt32 *crc, UInt32 v) -{ - int i; - for (i = 0; i < 4; i++) - CrcUpdateByte(crc, (Byte)(v >> (8 * i))); -} - -void CrcUpdateUInt64(UInt32 *crc, UInt64 v) -{ - int i; - for (i = 0; i < 8; i++) - { - CrcUpdateByte(crc, (Byte)(v)); - v >>= 8; - } -} - -void CrcUpdate(UInt32 *crc, const void *data, size_t size) -{ - UInt32 v = *crc; - const Byte *p = (const Byte *)data; - for (; size > 0 ; size--, p++) - v = g_CrcTable[((Byte)(v)) ^ *p] ^ (v >> 8); - *crc = v; -} - -UInt32 CrcCalculateDigest(const void *data, size_t size) -{ - UInt32 crc; - CrcInit(&crc); - CrcUpdate(&crc, data, size); - return CrcGetDigest(&crc); -} - -int CrcVerifyDigest(UInt32 digest, const void *data, size_t size) -{ - return (CrcCalculateDigest(data, size) == digest); -} diff --git a/source/sz/7zCrc.h b/source/sz/7zCrc.h deleted file mode 100644 index bac26b1..0000000 --- a/source/sz/7zCrc.h +++ /dev/null @@ -1,24 +0,0 @@ -/* 7zCrc.h */ - -#ifndef __7Z_CRC_H -#define __7Z_CRC_H - -#include - -#include "7zTypes.h" - -extern UInt32 g_CrcTable[256]; -void InitCrcTable(); - -void CrcInit(UInt32 *crc); -UInt32 CrcGetDigest(UInt32 *crc); -void CrcUpdateByte(UInt32 *crc, Byte v); -void CrcUpdateUInt16(UInt32 *crc, UInt16 v); -void CrcUpdateUInt32(UInt32 *crc, UInt32 v); -void CrcUpdateUInt64(UInt32 *crc, UInt64 v); -void CrcUpdate(UInt32 *crc, const void *data, size_t size); - -UInt32 CrcCalculateDigest(const void *data, size_t size); -int CrcVerifyDigest(UInt32 digest, const void *data, size_t size); - -#endif diff --git a/source/sz/7zDecode.c b/source/sz/7zDecode.c deleted file mode 100644 index 7b58319..0000000 --- a/source/sz/7zDecode.c +++ /dev/null @@ -1,355 +0,0 @@ -/* 7zDecode.c */ - -#include "7zDecode.h" -#ifdef _SZ_ONE_DIRECTORY -#include "LzmaDecode.h" -#else -#include "../../Compress/LZMA_C/LzmaDecode.h" -#endif - -#ifdef _LZMA_OUT_READ -#include // for memcpy -#endif - -CMethodID k_Copy = { { 0x0 }, 1 }; -CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 }; - -#ifdef _LZMA_IN_CB - -typedef struct _CLzmaInCallbackImp -{ - ILzmaInCallback InCallback; - ISzInStream *InStream; - size_t Size; -} CLzmaInCallbackImp; - -int LzmaReadImp(void *object, const unsigned char **buffer, SizeT *size) -{ - CLzmaInCallbackImp *cb = (CLzmaInCallbackImp *)object; - size_t processedSize; - SZ_RESULT res; - *size = 0; - res = cb->InStream->Read((void *)cb->InStream, (void **)buffer, cb->Size, &processedSize); - *size = (SizeT)processedSize; - if (processedSize > cb->Size) - return (int)SZE_FAIL; - cb->Size -= processedSize; - if (res == SZ_OK) - return 0; - return (int)res; -} - -#endif - -SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder, - #ifdef _LZMA_IN_CB - ISzInStream *inStream, - #else - const Byte *inBuffer, - #endif - Byte *outBuffer, size_t outSize, - size_t *outSizeProcessed, ISzAlloc *allocMain) -{ - UInt32 si; - size_t inSize = 0; - CCoderInfo *coder; - if (folder->NumPackStreams != 1) - return SZE_NOTIMPL; - if (folder->NumCoders != 1) - return SZE_NOTIMPL; - coder = folder->Coders; - *outSizeProcessed = 0; - - for (si = 0; si < folder->NumPackStreams; si++) - inSize += (size_t)packSizes[si]; - - if (AreMethodsEqual(&coder->MethodID, &k_Copy)) - { - size_t i; - if (inSize != outSize) - return SZE_DATA_ERROR; - #ifdef _LZMA_IN_CB - for (i = 0; i < inSize;) - { - size_t j; - Byte *inBuffer; - size_t bufferSize; - RINOK(inStream->Read((void *)inStream, (void **)&inBuffer, inSize - i, &bufferSize)); - if (bufferSize == 0) - return SZE_DATA_ERROR; - if (bufferSize > inSize - i) - return SZE_FAIL; - *outSizeProcessed += bufferSize; - for (j = 0; j < bufferSize && i < inSize; j++, i++) - outBuffer[i] = inBuffer[j]; - } - #else - for (i = 0; i < inSize; i++) - outBuffer[i] = inBuffer[i]; - *outSizeProcessed = inSize; - #endif - return SZ_OK; - } - - if (AreMethodsEqual(&coder->MethodID, &k_LZMA)) - { - #ifdef _LZMA_IN_CB - CLzmaInCallbackImp lzmaCallback; - #else - SizeT inProcessed; - #endif - - CLzmaDecoderState state; /* it's about 24-80 bytes structure, if int is 32-bit */ - int result; - SizeT outSizeProcessedLoc; - - #ifdef _LZMA_IN_CB - lzmaCallback.Size = inSize; - lzmaCallback.InStream = inStream; - lzmaCallback.InCallback.Read = LzmaReadImp; - #endif - - if (LzmaDecodeProperties(&state.Properties, coder->Properties.Items, - coder->Properties.Capacity) != LZMA_RESULT_OK) - return SZE_FAIL; - - state.Probs = (CProb *)allocMain->Alloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb)); - if (state.Probs == 0) - return SZE_OUTOFMEMORY; - - #ifdef _LZMA_OUT_READ - if (state.Properties.DictionarySize == 0) - state.Dictionary = 0; - else - { - state.Dictionary = (unsigned char *)allocMain->Alloc(state.Properties.DictionarySize); - if (state.Dictionary == 0) - { - allocMain->Free(state.Probs); - return SZE_OUTOFMEMORY; - } - } - LzmaDecoderInit(&state); - #endif - - result = LzmaDecode(&state, - #ifdef _LZMA_IN_CB - &lzmaCallback.InCallback, - #else - inBuffer, (SizeT)inSize, &inProcessed, - #endif - outBuffer, (SizeT)outSize, &outSizeProcessedLoc); - *outSizeProcessed = (size_t)outSizeProcessedLoc; - allocMain->Free(state.Probs); - #ifdef _LZMA_OUT_READ - allocMain->Free(state.Dictionary); - #endif - if (result == LZMA_RESULT_DATA_ERROR) - return SZE_DATA_ERROR; - if (result != LZMA_RESULT_OK) - return SZE_FAIL; - return SZ_OK; - } - return SZE_NOTIMPL; -} - -#ifdef _LZMA_OUT_READ -// like SzDecode but uses less memory -SZ_RESULT SzDecode2(const CFileSize *packSizes, const CFolder *folder, - ISzInStream *inStream, - Byte *outBuffer, size_t outSize, - size_t *outSizeProcessed, ISzAlloc *allocMain, - size_t *fileOffset, size_t *fileSize) -{ - UInt32 si; - size_t inSize = 0; - CCoderInfo *coder; - if (folder->NumPackStreams != 1) - return SZE_NOTIMPL; - if (folder->NumCoders != 1) - return SZE_NOTIMPL; - coder = folder->Coders; - *outSizeProcessed = 0; - - for (si = 0; si < folder->NumPackStreams; si++) - inSize += (size_t)packSizes[si]; - - if (AreMethodsEqual(&coder->MethodID, &k_Copy)) - { - size_t i; - if (inSize != outSize) - return SZE_DATA_ERROR; - #ifdef _LZMA_IN_CB - for (i = 0; i < inSize;) - { - size_t j; - Byte *inBuffer; - size_t bufferSize; - RINOK(inStream->Read((void *)inStream, (void **)&inBuffer, inSize - i, &bufferSize)); - if (bufferSize == 0) - return SZE_DATA_ERROR; - if (bufferSize > inSize - i) - return SZE_FAIL; - *outSizeProcessed += bufferSize; - for (j = 0; j < bufferSize && i < inSize; j++, i++) - outBuffer[i] = inBuffer[j]; - } - #else - for (i = 0; i < inSize; i++) - outBuffer[i] = inBuffer[i]; - *outSizeProcessed = inSize; - #endif - return SZ_OK; - } - - if (AreMethodsEqual(&coder->MethodID, &k_LZMA)) - { - #ifdef _LZMA_IN_CB - CLzmaInCallbackImp lzmaCallback; - #else - SizeT inProcessed; - #endif - - CLzmaDecoderState state; /* it's about 24-80 bytes structure, if int is 32-bit */ - int result; - SizeT outSizeProcessedLoc; - - #ifdef _LZMA_IN_CB - lzmaCallback.Size = inSize; - lzmaCallback.InStream = inStream; - lzmaCallback.InCallback.Read = LzmaReadImp; - #endif - - if (LzmaDecodeProperties(&state.Properties, coder->Properties.Items, - coder->Properties.Capacity) != LZMA_RESULT_OK) - return SZE_FAIL; - - state.Probs = (CProb *)allocMain->Alloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb)); - if (state.Probs == 0) - return SZE_OUTOFMEMORY; - - if (state.Properties.DictionarySize == 0) - state.Dictionary = 0; - else - { - state.Dictionary = (unsigned char *)allocMain->Alloc(state.Properties.DictionarySize); - if (state.Dictionary == 0) - { - allocMain->Free(state.Probs); - return SZE_OUTOFMEMORY; - } - } - 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; - - // 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 deleted file mode 100644 index 9506e59..0000000 --- a/source/sz/7zDecode.h +++ /dev/null @@ -1,37 +0,0 @@ -/* 7zDecode.h */ - -#if defined(_LZMA_OUT_READ) && !defined(_LZMA_IN_CB) -#error "Fixme: _LZMA_OUT_READ && _LZMA_IN_CB isn't currently possible!" -#endif - -#ifndef __7Z_DECODE_H -#define __7Z_DECODE_H - -#include "7zItem.h" -#include "7zAlloc.h" -#ifdef _LZMA_IN_CB -#include "7zIn.h" -#endif - -SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder, - #ifdef _LZMA_IN_CB - ISzInStream *stream, - #else - const Byte *inBuffer, - #endif - Byte *outBuffer, size_t outSize, - size_t *outSizeProcessed, ISzAlloc *allocMain); - -#ifdef _LZMA_OUT_READ -#ifndef _LZMA_TEMP_BUFFER_SIZE -#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, - size_t *outSizeProcessed, ISzAlloc *allocMain, - size_t *fileOffset, size_t *fileSize); -#endif // #ifdef _LZMA_OUT_READ - -#endif diff --git a/source/sz/7zExtract.c b/source/sz/7zExtract.c deleted file mode 100644 index 9a82ea4..0000000 --- a/source/sz/7zExtract.c +++ /dev/null @@ -1,254 +0,0 @@ -/* 7zExtract.c */ - -#include "7zExtract.h" -#include "7zDecode.h" -#include "7zCrc.h" - -SZ_RESULT SzExtract( - ISzInStream *inStream, - CArchiveDatabaseEx *db, - UInt32 fileIndex, - UInt32 *blockIndex, - Byte **outBuffer, - size_t *outBufferSize, - size_t *offset, - size_t *outSizeProcessed, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - UInt32 folderIndex = db->FileIndexToFolderIndexMap[fileIndex]; - SZ_RESULT res = SZ_OK; - *offset = 0; - *outSizeProcessed = 0; - if (folderIndex == (UInt32)-1) - { - allocMain->Free(*outBuffer); - *blockIndex = folderIndex; - *outBuffer = 0; - *outBufferSize = 0; - return SZ_OK; - } - - if (*outBuffer == 0 || *blockIndex != folderIndex) - { - CFolder *folder = db->Database.Folders + folderIndex; - CFileSize unPackSize = SzFolderGetUnPackSize(folder); - #ifndef _LZMA_IN_CB - CFileSize packSize = SzArDbGetFolderFullPackSize(db, folderIndex); - Byte *inBuffer = 0; - size_t processedSize; - #endif - *blockIndex = folderIndex; - allocMain->Free(*outBuffer); - *outBuffer = 0; - - RINOK(inStream->Seek(inStream, SzArDbGetFolderStreamPos(db, folderIndex, 0))); - - #ifndef _LZMA_IN_CB - if (packSize != 0) - { - inBuffer = (Byte *)allocTemp->Alloc((size_t)packSize); - if (inBuffer == 0) - return SZE_OUTOFMEMORY; - } - res = inStream->Read(inStream, inBuffer, (size_t)packSize, &processedSize); - if (res == SZ_OK && processedSize != (size_t)packSize) - res = SZE_FAIL; - #endif - if (res == SZ_OK) - { - *outBufferSize = (size_t)unPackSize; - if (unPackSize != 0) - { - *outBuffer = (Byte *)allocMain->Alloc((size_t)unPackSize); - if (*outBuffer == 0) - res = SZE_OUTOFMEMORY; - } - if (res == SZ_OK) - { - size_t outRealSize; - res = SzDecode(db->Database.PackSizes + - db->FolderStartPackStreamIndex[folderIndex], folder, - #ifdef _LZMA_IN_CB - inStream, - #else - inBuffer, - #endif - *outBuffer, (size_t)unPackSize, &outRealSize, allocTemp); - if (res == SZ_OK) - { - if (outRealSize == (size_t)unPackSize) - { - if (folder->UnPackCRCDefined) - { - if (!CrcVerifyDigest(folder->UnPackCRC, *outBuffer, (size_t)unPackSize)) - res = SZE_FAIL; - } - } - else - res = SZE_FAIL; - } - } - } - #ifndef _LZMA_IN_CB - allocTemp->Free(inBuffer); - #endif - } - if (res == SZ_OK) - { - 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; - if (*offset + *outSizeProcessed > *outBufferSize) - return SZE_FAIL; - { - if (fileItem->IsFileCRCDefined) - { - if (!CrcVerifyDigest(fileItem->FileCRC, *outBuffer + *offset, *outSizeProcessed)) - res = SZE_FAIL; - } - } - } - return res; -} - -#ifdef _LZMA_OUT_READ -// similar to SzExtract but needs less memory -SZ_RESULT SzExtract2( - ISzInStream *inStream, - CArchiveDatabaseEx *db, - UInt32 fileIndex, - UInt32 *blockIndex, - Byte **outBuffer, - size_t *outBufferSize, - size_t *offset, - size_t *outSizeProcessed, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - UInt32 folderIndex = db->FileIndexToFolderIndexMap[fileIndex]; - SZ_RESULT res = SZ_OK; - *offset = 0; - *outSizeProcessed = 0; - if (folderIndex == (UInt32)-1) - { - *blockIndex = folderIndex; - #ifndef NGC - allocMain->Free(*outBuffer); - *outBuffer = 0; - #endif - *outBufferSize = 0; - return SZ_OK; - } - -// if (*outBuffer == 0 || *blockIndex != folderIndex) -// { - CFolder *folder = db->Database.Folders + folderIndex; - CFileSize unPackSize = SzFolderGetUnPackSize(folder); - #ifndef _LZMA_IN_CB - CFileSize packSize = SzArDbGetFolderFullPackSize(db, folderIndex); - Byte *inBuffer = 0; - size_t processedSize; - #endif - *blockIndex = folderIndex; - #ifndef NGC - allocMain->Free(*outBuffer); - *outBuffer = 0; - #endif - - RINOK(inStream->Seek(inStream, SzArDbGetFolderStreamPos(db, folderIndex, 0))); - - #ifndef _LZMA_IN_CB - if (packSize != 0) - { - inBuffer = (Byte *)allocTemp->Alloc((size_t)packSize); - if (inBuffer == 0) - return SZE_OUTOFMEMORY; - } - res = inStream->Read(inStream, inBuffer, (size_t)packSize, &processedSize); - if (res == SZ_OK && processedSize != (size_t)packSize) - res = SZE_FAIL; - #endif - if (res == SZ_OK) - { - // calculate file offset and filesize - CFileItem *fileItem = db->Database.Files + fileIndex; - UInt32 i; - *offset = 0; - for(i = db->FolderStartFileIndex[folderIndex]; i < fileIndex; i++) - *offset += (UInt32)db->Database.Files[i].Size; - *outSizeProcessed = (size_t)fileItem->Size; - *outBufferSize = (size_t)fileItem->Size; - if (unPackSize != 0) - { - #ifndef NGC - *outBuffer = (Byte *)allocMain->Alloc((size_t)fileItem->Size); - if (*outBuffer == 0) - res = SZE_OUTOFMEMORY; - #endif - } - if (res == SZ_OK) - { - - size_t outRealSize; - res = SzDecode2(db->Database.PackSizes + - db->FolderStartPackStreamIndex[folderIndex], folder, - #ifdef _LZMA_IN_CB - inStream, - #else - inBuffer, - #endif - *outBuffer, (size_t)unPackSize, &outRealSize, allocTemp, - offset, outSizeProcessed - ); - *outSizeProcessed = outRealSize; -/* if (res == SZ_OK) // we can't validate the CRC of the whole data stream because we only extracted the wanted file - { - if (outRealSize == (size_t)unPackSize) - { - if (folder->UnPackCRCDefined) - { - if (!CrcVerifyDigest(folder->UnPackCRC, *outBuffer, (size_t)unPackSize)) - res = SZE_FAIL; - } - } - else - res = SZE_FAIL; - }*/ - } -// } - #ifndef _LZMA_IN_CB - allocTemp->Free(inBuffer); - #endif - } - if (res == SZ_OK) - { -/* 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; - 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? - } - } - } - - // 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 - // to 0 to ensure compatibility with SzExtract - *offset = 0; - return res; -} -#endif diff --git a/source/sz/7zExtract.h b/source/sz/7zExtract.h deleted file mode 100644 index 7f7e07e..0000000 --- a/source/sz/7zExtract.h +++ /dev/null @@ -1,60 +0,0 @@ -/* 7zExtract.h */ - -#if defined(_LZMA_OUT_READ) && !defined(_LZMA_IN_CB) -#error "Fixme: _LZMA_OUT_READ && _LZMA_IN_CB isn't currently possible!" -#endif - -#ifndef __7Z_EXTRACT_H -#define __7Z_EXTRACT_H - -#include "7zIn.h" - -/* - SzExtract extracts file from archive - - SzExtract2 does the same but needs less memory - - *outBuffer must be 0 before first call for each new archive. - - Extracting cache: - If you need to decompress more than one file, you can send - these values from previous call: - *blockIndex, - *outBuffer, - *outBufferSize - You can consider "*outBuffer" as cache of solid block. If your archive is solid, - it will increase decompression speed. - - If you use external function, you can declare these 3 cache variables - (blockIndex, outBuffer, outBufferSize) as static in that external function. - - Free *outBuffer and set *outBuffer to 0, if you want to flush cache. -*/ - -SZ_RESULT SzExtract( - ISzInStream *inStream, - CArchiveDatabaseEx *db, - UInt32 fileIndex, /* index of file */ - UInt32 *blockIndex, /* index of solid block */ - Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ - size_t *outBufferSize, /* buffer size for output buffer */ - size_t *offset, /* offset of stream for required file in *outBuffer */ - size_t *outSizeProcessed, /* size of file in *outBuffer */ - ISzAlloc *allocMain, - ISzAlloc *allocTemp); - -#ifdef _LZMA_OUT_READ -SZ_RESULT SzExtract2( - ISzInStream *inStream, - CArchiveDatabaseEx *db, - UInt32 fileIndex, /* index of file */ - UInt32 *blockIndex, /* index of solid block */ - Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ - size_t *outBufferSize, /* buffer size for output buffer */ - size_t *offset, /* offset of stream for required file in *outBuffer */ - size_t *outSizeProcessed, /* size of file in *outBuffer */ - ISzAlloc *allocMain, - ISzAlloc *allocTemp); -#endif - -#endif diff --git a/source/sz/7zHeader.c b/source/sz/7zHeader.c deleted file mode 100644 index e26c014..0000000 --- a/source/sz/7zHeader.c +++ /dev/null @@ -1,5 +0,0 @@ -/* 7zHeader.c */ - -#include "7zHeader.h" - -Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; diff --git a/source/sz/7zHeader.h b/source/sz/7zHeader.h deleted file mode 100644 index 7edf640..0000000 --- a/source/sz/7zHeader.h +++ /dev/null @@ -1,55 +0,0 @@ -/* 7zHeader.h */ - -#ifndef __7Z_HEADER_H -#define __7Z_HEADER_H - -#include "7zTypes.h" - -#define k7zSignatureSize 6 -extern Byte k7zSignature[k7zSignatureSize]; - -#define k7zMajorVersion 0 - -#define k7zStartHeaderSize 0x20 - -enum EIdEnum -{ - k7zIdEnd, - - k7zIdHeader, - - k7zIdArchiveProperties, - - k7zIdAdditionalStreamsInfo, - k7zIdMainStreamsInfo, - k7zIdFilesInfo, - - k7zIdPackInfo, - k7zIdUnPackInfo, - k7zIdSubStreamsInfo, - - k7zIdSize, - k7zIdCRC, - - k7zIdFolder, - - k7zIdCodersUnPackSize, - k7zIdNumUnPackStream, - - k7zIdEmptyStream, - k7zIdEmptyFile, - k7zIdAnti, - - k7zIdName, - k7zIdCreationTime, - k7zIdLastAccessTime, - k7zIdLastWriteTime, - k7zIdWinAttributes, - k7zIdComment, - - k7zIdEncodedHeader, - - k7zIdStartPos -}; - -#endif diff --git a/source/sz/7zIn.c b/source/sz/7zIn.c deleted file mode 100644 index b3e9ea2..0000000 --- a/source/sz/7zIn.c +++ /dev/null @@ -1,1281 +0,0 @@ -/* 7zIn.c */ - -#include "7zIn.h" -#include "7zCrc.h" -#include "7zDecode.h" - -#define RINOM(x) { if((x) == 0) return SZE_OUTOFMEMORY; } - -void SzArDbExInit(CArchiveDatabaseEx *db) -{ - SzArchiveDatabaseInit(&db->Database); - db->FolderStartPackStreamIndex = 0; - db->PackStreamStartPositions = 0; - db->FolderStartFileIndex = 0; - db->FileIndexToFolderIndexMap = 0; -} - -void SzArDbExFree(CArchiveDatabaseEx *db, void (*freeFunc)(void *)) -{ - freeFunc(db->FolderStartPackStreamIndex); - freeFunc(db->PackStreamStartPositions); - freeFunc(db->FolderStartFileIndex); - freeFunc(db->FileIndexToFolderIndexMap); - SzArchiveDatabaseFree(&db->Database, freeFunc); - SzArDbExInit(db); -} - -/* -CFileSize GetFolderPackStreamSize(int folderIndex, int streamIndex) const -{ - return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex]; -} - -CFileSize GetFilePackSize(int fileIndex) const -{ - int folderIndex = FileIndexToFolderIndexMap[fileIndex]; - if (folderIndex >= 0) - { - const CFolder &folderInfo = Folders[folderIndex]; - if (FolderStartFileIndex[folderIndex] == fileIndex) - return GetFolderFullPackSize(folderIndex); - } - return 0; -} -*/ - -#define MY_ALLOC(T, p, size, allocFunc) { if ((size) == 0) p = 0; else \ - if ((p = (T *)allocFunc((size) * sizeof(T))) == 0) return SZE_OUTOFMEMORY; } - -SZ_RESULT SzArDbExFill(CArchiveDatabaseEx *db, void * (*allocFunc)(size_t size)) -{ - UInt32 startPos = 0; - CFileSize startPosSize = 0; - UInt32 i; - UInt32 folderIndex = 0; - UInt32 indexInFolder = 0; - MY_ALLOC(UInt32, db->FolderStartPackStreamIndex, db->Database.NumFolders, allocFunc); - for(i = 0; i < db->Database.NumFolders; i++) - { - db->FolderStartPackStreamIndex[i] = startPos; - startPos += db->Database.Folders[i].NumPackStreams; - } - - MY_ALLOC(CFileSize, db->PackStreamStartPositions, db->Database.NumPackStreams, allocFunc); - - for(i = 0; i < db->Database.NumPackStreams; i++) - { - db->PackStreamStartPositions[i] = startPosSize; - startPosSize += db->Database.PackSizes[i]; - } - - MY_ALLOC(UInt32, db->FolderStartFileIndex, db->Database.NumFolders, allocFunc); - MY_ALLOC(UInt32, db->FileIndexToFolderIndexMap, db->Database.NumFiles, allocFunc); - - for (i = 0; i < db->Database.NumFiles; i++) - { - CFileItem *file = db->Database.Files + i; - int emptyStream = !file->HasStream; - if (emptyStream && indexInFolder == 0) - { - db->FileIndexToFolderIndexMap[i] = (UInt32)-1; - continue; - } - if (indexInFolder == 0) - { - /* - v3.13 incorrectly worked with empty folders - v4.07: Loop for skipping empty folders - */ - while(1) - { - if (folderIndex >= db->Database.NumFolders) - return SZE_ARCHIVE_ERROR; - db->FolderStartFileIndex[folderIndex] = i; - if (db->Database.Folders[folderIndex].NumUnPackStreams != 0) - break; - folderIndex++; - } - } - db->FileIndexToFolderIndexMap[i] = folderIndex; - if (emptyStream) - continue; - indexInFolder++; - if (indexInFolder >= db->Database.Folders[folderIndex].NumUnPackStreams) - { - folderIndex++; - indexInFolder = 0; - } - } - return SZ_OK; -} - - -CFileSize SzArDbGetFolderStreamPos(CArchiveDatabaseEx *db, UInt32 folderIndex, UInt32 indexInFolder) -{ - return db->ArchiveInfo.DataStartPosition + - db->PackStreamStartPositions[db->FolderStartPackStreamIndex[folderIndex] + indexInFolder]; -} - -CFileSize SzArDbGetFolderFullPackSize(CArchiveDatabaseEx *db, UInt32 folderIndex) -{ - UInt32 packStreamIndex = db->FolderStartPackStreamIndex[folderIndex]; - CFolder *folder = db->Database.Folders + folderIndex; - CFileSize size = 0; - UInt32 i; - for (i = 0; i < folder->NumPackStreams; i++) - size += db->Database.PackSizes[packStreamIndex + i]; - return size; -} - - -/* -SZ_RESULT SzReadTime(const CObjectVector &dataVector, - CObjectVector &files, UInt64 type) -{ - CBoolVector boolVector; - RINOK(ReadBoolVector2(files.Size(), boolVector)) - - CStreamSwitch streamSwitch; - RINOK(streamSwitch.Set(this, &dataVector)); - - for(int i = 0; i < files.Size(); i++) - { - CFileItem &file = files[i]; - CArchiveFileTime fileTime; - bool defined = boolVector[i]; - if (defined) - { - UInt32 low, high; - RINOK(SzReadUInt32(low)); - RINOK(SzReadUInt32(high)); - fileTime.dwLowDateTime = low; - fileTime.dwHighDateTime = high; - } - switch(type) - { - case k7zIdCreationTime: - file.IsCreationTimeDefined = defined; - if (defined) - file.CreationTime = fileTime; - break; - case k7zIdLastWriteTime: - file.IsLastWriteTimeDefined = defined; - if (defined) - file.LastWriteTime = fileTime; - break; - case k7zIdLastAccessTime: - file.IsLastAccessTimeDefined = defined; - if (defined) - file.LastAccessTime = fileTime; - break; - } - } - return SZ_OK; -} -*/ - -SZ_RESULT SafeReadDirect(ISzInStream *inStream, Byte *data, size_t size) -{ - #ifdef _LZMA_IN_CB - while (size > 0) - { - Byte *inBuffer; - size_t processedSize; - RINOK(inStream->Read(inStream, (void **)&inBuffer, size, &processedSize)); - if (processedSize == 0 || processedSize > size) - return SZE_FAIL; - size -= processedSize; - do - { - *data++ = *inBuffer++; - } - while (--processedSize != 0); - } - #else - size_t processedSize; - RINOK(inStream->Read(inStream, data, size, &processedSize)); - if (processedSize != size) - return SZE_FAIL; - #endif - return SZ_OK; -} - -SZ_RESULT SafeReadDirectByte(ISzInStream *inStream, Byte *data) -{ - return SafeReadDirect(inStream, data, 1); -} - -SZ_RESULT SafeReadDirectUInt32(ISzInStream *inStream, UInt32 *value) -{ - int i; - *value = 0; - for (i = 0; i < 4; i++) - { - Byte b; - RINOK(SafeReadDirectByte(inStream, &b)); - *value |= ((UInt32)b << (8 * i)); - } - return SZ_OK; -} - -SZ_RESULT SafeReadDirectUInt64(ISzInStream *inStream, UInt64 *value) -{ - int i; - *value = 0; - for (i = 0; i < 8; i++) - { - Byte b; - RINOK(SafeReadDirectByte(inStream, &b)); - *value |= ((UInt32)b << (8 * i)); - } - return SZ_OK; -} - -int TestSignatureCandidate(Byte *testBytes) -{ - size_t i; - for (i = 0; i < k7zSignatureSize; i++) - if (testBytes[i] != k7zSignature[i]) - return 0; - return 1; -} - -typedef struct _CSzState -{ - Byte *Data; - size_t Size; -}CSzData; - -SZ_RESULT SzReadByte(CSzData *sd, Byte *b) -{ - if (sd->Size == 0) - return SZE_ARCHIVE_ERROR; - sd->Size--; - *b = *sd->Data++; - return SZ_OK; -} - -SZ_RESULT SzReadBytes(CSzData *sd, Byte *data, size_t size) -{ - size_t i; - for (i = 0; i < size; i++) - { - RINOK(SzReadByte(sd, data + i)); - } - return SZ_OK; -} - -SZ_RESULT SzReadUInt32(CSzData *sd, UInt32 *value) -{ - int i; - *value = 0; - for (i = 0; i < 4; i++) - { - Byte b; - RINOK(SzReadByte(sd, &b)); - *value |= ((UInt32)(b) << (8 * i)); - } - return SZ_OK; -} - -SZ_RESULT SzReadNumber(CSzData *sd, UInt64 *value) -{ - Byte firstByte; - Byte mask = 0x80; - int i; - RINOK(SzReadByte(sd, &firstByte)); - *value = 0; - for (i = 0; i < 8; i++) - { - Byte b; - if ((firstByte & mask) == 0) - { - UInt64 highPart = firstByte & (mask - 1); - *value += (highPart << (8 * i)); - return SZ_OK; - } - RINOK(SzReadByte(sd, &b)); - *value |= ((UInt64)b << (8 * i)); - mask >>= 1; - } - return SZ_OK; -} - -SZ_RESULT SzReadSize(CSzData *sd, CFileSize *value) -{ - UInt64 value64; - RINOK(SzReadNumber(sd, &value64)); - *value = (CFileSize)value64; - return SZ_OK; -} - -SZ_RESULT SzReadNumber32(CSzData *sd, UInt32 *value) -{ - UInt64 value64; - RINOK(SzReadNumber(sd, &value64)); - if (value64 >= 0x80000000) - return SZE_NOTIMPL; - if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 2))) - return SZE_NOTIMPL; - *value = (UInt32)value64; - return SZ_OK; -} - -SZ_RESULT SzReadID(CSzData *sd, UInt64 *value) -{ - return SzReadNumber(sd, value); -} - -SZ_RESULT SzSkeepDataSize(CSzData *sd, UInt64 size) -{ - if (size > sd->Size) - return SZE_ARCHIVE_ERROR; - sd->Size -= (size_t)size; - sd->Data += (size_t)size; - return SZ_OK; -} - -SZ_RESULT SzSkeepData(CSzData *sd) -{ - UInt64 size; - RINOK(SzReadNumber(sd, &size)); - return SzSkeepDataSize(sd, size); -} - -SZ_RESULT SzReadArchiveProperties(CSzData *sd) -{ - while(1) - { - UInt64 type; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - break; - SzSkeepData(sd); - } - return SZ_OK; -} - -SZ_RESULT SzWaitAttribute(CSzData *sd, UInt64 attribute) -{ - while(1) - { - UInt64 type; - RINOK(SzReadID(sd, &type)); - if (type == attribute) - return SZ_OK; - if (type == k7zIdEnd) - return SZE_ARCHIVE_ERROR; - RINOK(SzSkeepData(sd)); - } -} - -SZ_RESULT SzReadBoolVector(CSzData *sd, size_t numItems, Byte **v, void * (*allocFunc)(size_t size)) -{ - Byte b = 0; - Byte mask = 0; - size_t i; - MY_ALLOC(Byte, *v, numItems, allocFunc); - for(i = 0; i < numItems; i++) - { - if (mask == 0) - { - RINOK(SzReadByte(sd, &b)); - mask = 0x80; - } - (*v)[i] = (Byte)(((b & mask) != 0) ? 1 : 0); - mask >>= 1; - } - return SZ_OK; -} - -SZ_RESULT SzReadBoolVector2(CSzData *sd, size_t numItems, Byte **v, void * (*allocFunc)(size_t size)) -{ - Byte allAreDefined; - size_t i; - RINOK(SzReadByte(sd, &allAreDefined)); - if (allAreDefined == 0) - return SzReadBoolVector(sd, numItems, v, allocFunc); - MY_ALLOC(Byte, *v, numItems, allocFunc); - for(i = 0; i < numItems; i++) - (*v)[i] = 1; - return SZ_OK; -} - -SZ_RESULT SzReadHashDigests( - CSzData *sd, - size_t numItems, - Byte **digestsDefined, - UInt32 **digests, - void * (*allocFunc)(size_t size)) -{ - size_t i; - RINOK(SzReadBoolVector2(sd, numItems, digestsDefined, allocFunc)); - MY_ALLOC(UInt32, *digests, numItems, allocFunc); - for(i = 0; i < numItems; i++) - if ((*digestsDefined)[i]) - { - RINOK(SzReadUInt32(sd, (*digests) + i)); - } - return SZ_OK; -} - -SZ_RESULT SzReadPackInfo( - CSzData *sd, - CFileSize *dataOffset, - UInt32 *numPackStreams, - CFileSize **packSizes, - Byte **packCRCsDefined, - UInt32 **packCRCs, - void * (*allocFunc)(size_t size)) -{ - UInt32 i; - RINOK(SzReadSize(sd, dataOffset)); - RINOK(SzReadNumber32(sd, numPackStreams)); - - RINOK(SzWaitAttribute(sd, k7zIdSize)); - - MY_ALLOC(CFileSize, *packSizes, (size_t)*numPackStreams, allocFunc); - - for(i = 0; i < *numPackStreams; i++) - { - RINOK(SzReadSize(sd, (*packSizes) + i)); - } - - while(1) - { - UInt64 type; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - break; - if (type == k7zIdCRC) - { - RINOK(SzReadHashDigests(sd, (size_t)*numPackStreams, packCRCsDefined, packCRCs, allocFunc)); - continue; - } - RINOK(SzSkeepData(sd)); - } - if (*packCRCsDefined == 0) - { - MY_ALLOC(Byte, *packCRCsDefined, (size_t)*numPackStreams, allocFunc); - MY_ALLOC(UInt32, *packCRCs, (size_t)*numPackStreams, allocFunc); - for(i = 0; i < *numPackStreams; i++) - { - (*packCRCsDefined)[i] = 0; - (*packCRCs)[i] = 0; - } - } - return SZ_OK; -} - -SZ_RESULT SzReadSwitch(CSzData *sd) -{ - Byte external; - RINOK(SzReadByte(sd, &external)); - return (external == 0) ? SZ_OK: SZE_ARCHIVE_ERROR; -} - -SZ_RESULT SzGetNextFolderItem(CSzData *sd, CFolder *folder, void * (*allocFunc)(size_t size)) -{ - UInt32 numCoders; - UInt32 numBindPairs; - UInt32 numPackedStreams; - UInt32 i; - UInt32 numInStreams = 0; - UInt32 numOutStreams = 0; - RINOK(SzReadNumber32(sd, &numCoders)); - folder->NumCoders = numCoders; - - MY_ALLOC(CCoderInfo, folder->Coders, (size_t)numCoders, allocFunc); - - for (i = 0; i < numCoders; i++) - SzCoderInfoInit(folder->Coders + i); - - for (i = 0; i < numCoders; i++) - { - Byte mainByte; - CCoderInfo *coder = folder->Coders + i; - { - RINOK(SzReadByte(sd, &mainByte)); - coder->MethodID.IDSize = (Byte)(mainByte & 0xF); - RINOK(SzReadBytes(sd, coder->MethodID.ID, coder->MethodID.IDSize)); - if ((mainByte & 0x10) != 0) - { - RINOK(SzReadNumber32(sd, &coder->NumInStreams)); - RINOK(SzReadNumber32(sd, &coder->NumOutStreams)); - } - else - { - coder->NumInStreams = 1; - coder->NumOutStreams = 1; - } - if ((mainByte & 0x20) != 0) - { - UInt64 propertiesSize = 0; - RINOK(SzReadNumber(sd, &propertiesSize)); - if (!SzByteBufferCreate(&coder->Properties, (size_t)propertiesSize, allocFunc)) - return SZE_OUTOFMEMORY; - RINOK(SzReadBytes(sd, coder->Properties.Items, (size_t)propertiesSize)); - } - } - while ((mainByte & 0x80) != 0) - { - RINOK(SzReadByte(sd, &mainByte)); - RINOK(SzSkeepDataSize(sd, (mainByte & 0xF))); - if ((mainByte & 0x10) != 0) - { - UInt32 n; - RINOK(SzReadNumber32(sd, &n)); - RINOK(SzReadNumber32(sd, &n)); - } - if ((mainByte & 0x20) != 0) - { - UInt64 propertiesSize = 0; - RINOK(SzReadNumber(sd, &propertiesSize)); - RINOK(SzSkeepDataSize(sd, propertiesSize)); - } - } - numInStreams += (UInt32)coder->NumInStreams; - numOutStreams += (UInt32)coder->NumOutStreams; - } - - numBindPairs = numOutStreams - 1; - folder->NumBindPairs = numBindPairs; - - - MY_ALLOC(CBindPair, folder->BindPairs, (size_t)numBindPairs, allocFunc); - - for (i = 0; i < numBindPairs; i++) - { - CBindPair *bindPair = folder->BindPairs + i;; - RINOK(SzReadNumber32(sd, &bindPair->InIndex)); - RINOK(SzReadNumber32(sd, &bindPair->OutIndex)); - } - - numPackedStreams = numInStreams - (UInt32)numBindPairs; - - folder->NumPackStreams = numPackedStreams; - MY_ALLOC(UInt32, folder->PackStreams, (size_t)numPackedStreams, allocFunc); - - if (numPackedStreams == 1) - { - UInt32 j; - UInt32 pi = 0; - for (j = 0; j < numInStreams; j++) - if (SzFolderFindBindPairForInStream(folder, j) < 0) - { - folder->PackStreams[pi++] = j; - break; - } - } - else - for(i = 0; i < numPackedStreams; i++) - { - RINOK(SzReadNumber32(sd, folder->PackStreams + i)); - } - return SZ_OK; -} - -SZ_RESULT SzReadUnPackInfo( - CSzData *sd, - UInt32 *numFolders, - CFolder **folders, /* for allocFunc */ - void * (*allocFunc)(size_t size), - ISzAlloc *allocTemp) -{ - UInt32 i; - RINOK(SzWaitAttribute(sd, k7zIdFolder)); - RINOK(SzReadNumber32(sd, numFolders)); - { - RINOK(SzReadSwitch(sd)); - - MY_ALLOC(CFolder, *folders, (size_t)*numFolders, allocFunc); - - for(i = 0; i < *numFolders; i++) - SzFolderInit((*folders) + i); - - for(i = 0; i < *numFolders; i++) - { - RINOK(SzGetNextFolderItem(sd, (*folders) + i, allocFunc)); - } - } - - RINOK(SzWaitAttribute(sd, k7zIdCodersUnPackSize)); - - for(i = 0; i < *numFolders; i++) - { - UInt32 j; - CFolder *folder = (*folders) + i; - UInt32 numOutStreams = SzFolderGetNumOutStreams(folder); - - MY_ALLOC(CFileSize, folder->UnPackSizes, (size_t)numOutStreams, allocFunc); - - for(j = 0; j < numOutStreams; j++) - { - RINOK(SzReadSize(sd, folder->UnPackSizes + j)); - } - } - - while(1) - { - UInt64 type; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - return SZ_OK; - if (type == k7zIdCRC) - { - SZ_RESULT res; - Byte *crcsDefined = 0; - UInt32 *crcs = 0; - res = SzReadHashDigests(sd, *numFolders, &crcsDefined, &crcs, allocTemp->Alloc); - if (res == SZ_OK) - { - for(i = 0; i < *numFolders; i++) - { - CFolder *folder = (*folders) + i; - folder->UnPackCRCDefined = crcsDefined[i]; - folder->UnPackCRC = crcs[i]; - } - } - allocTemp->Free(crcs); - allocTemp->Free(crcsDefined); - RINOK(res); - continue; - } - RINOK(SzSkeepData(sd)); - } -} - -SZ_RESULT SzReadSubStreamsInfo( - CSzData *sd, - UInt32 numFolders, - CFolder *folders, - UInt32 *numUnPackStreams, - CFileSize **unPackSizes, - Byte **digestsDefined, - UInt32 **digests, - ISzAlloc *allocTemp) -{ - UInt64 type = 0; - UInt32 i; - UInt32 si = 0; - UInt32 numDigests = 0; - - for(i = 0; i < numFolders; i++) - folders[i].NumUnPackStreams = 1; - *numUnPackStreams = numFolders; - - while(1) - { - RINOK(SzReadID(sd, &type)); - if (type == k7zIdNumUnPackStream) - { - *numUnPackStreams = 0; - for(i = 0; i < numFolders; i++) - { - UInt32 numStreams; - RINOK(SzReadNumber32(sd, &numStreams)); - folders[i].NumUnPackStreams = numStreams; - *numUnPackStreams += numStreams; - } - continue; - } - if (type == k7zIdCRC || type == k7zIdSize) - break; - if (type == k7zIdEnd) - break; - RINOK(SzSkeepData(sd)); - } - - if (*numUnPackStreams == 0) - { - *unPackSizes = 0; - *digestsDefined = 0; - *digests = 0; - } - else - { - *unPackSizes = (CFileSize *)allocTemp->Alloc((size_t)*numUnPackStreams * sizeof(CFileSize)); - RINOM(*unPackSizes); - *digestsDefined = (Byte *)allocTemp->Alloc((size_t)*numUnPackStreams * sizeof(Byte)); - RINOM(*digestsDefined); - *digests = (UInt32 *)allocTemp->Alloc((size_t)*numUnPackStreams * sizeof(UInt32)); - RINOM(*digests); - } - - for(i = 0; i < numFolders; i++) - { - /* - v3.13 incorrectly worked with empty folders - v4.07: we check that folder is empty - */ - CFileSize sum = 0; - UInt32 j; - UInt32 numSubstreams = folders[i].NumUnPackStreams; - if (numSubstreams == 0) - continue; - if (type == k7zIdSize) - for (j = 1; j < numSubstreams; j++) - { - CFileSize size; - RINOK(SzReadSize(sd, &size)); - (*unPackSizes)[si++] = size; - sum += size; - } - (*unPackSizes)[si++] = SzFolderGetUnPackSize(folders + i) - sum; - } - if (type == k7zIdSize) - { - RINOK(SzReadID(sd, &type)); - } - - for(i = 0; i < *numUnPackStreams; i++) - { - (*digestsDefined)[i] = 0; - (*digests)[i] = 0; - } - - - for(i = 0; i < numFolders; i++) - { - UInt32 numSubstreams = folders[i].NumUnPackStreams; - if (numSubstreams != 1 || !folders[i].UnPackCRCDefined) - numDigests += numSubstreams; - } - - - si = 0; - while(1) - { - if (type == k7zIdCRC) - { - int digestIndex = 0; - Byte *digestsDefined2 = 0; - UInt32 *digests2 = 0; - SZ_RESULT res = SzReadHashDigests(sd, numDigests, &digestsDefined2, &digests2, allocTemp->Alloc); - if (res == SZ_OK) - { - for (i = 0; i < numFolders; i++) - { - CFolder *folder = folders + i; - UInt32 numSubstreams = folder->NumUnPackStreams; - if (numSubstreams == 1 && folder->UnPackCRCDefined) - { - (*digestsDefined)[si] = 1; - (*digests)[si] = folder->UnPackCRC; - si++; - } - else - { - UInt32 j; - for (j = 0; j < numSubstreams; j++, digestIndex++) - { - (*digestsDefined)[si] = digestsDefined2[digestIndex]; - (*digests)[si] = digests2[digestIndex]; - si++; - } - } - } - } - allocTemp->Free(digestsDefined2); - allocTemp->Free(digests2); - RINOK(res); - } - else if (type == k7zIdEnd) - return SZ_OK; - else - { - RINOK(SzSkeepData(sd)); - } - RINOK(SzReadID(sd, &type)); - } -} - - -SZ_RESULT SzReadStreamsInfo( - CSzData *sd, - CFileSize *dataOffset, - CArchiveDatabase *db, - UInt32 *numUnPackStreams, - CFileSize **unPackSizes, /* allocTemp */ - Byte **digestsDefined, /* allocTemp */ - UInt32 **digests, /* allocTemp */ - void * (*allocFunc)(size_t size), - ISzAlloc *allocTemp) -{ - while(1) - { - UInt64 type; - RINOK(SzReadID(sd, &type)); - if ((UInt64)(int)type != type) - return SZE_FAIL; - switch((int)type) - { - case k7zIdEnd: - return SZ_OK; - case k7zIdPackInfo: - { - RINOK(SzReadPackInfo(sd, dataOffset, &db->NumPackStreams, - &db->PackSizes, &db->PackCRCsDefined, &db->PackCRCs, allocFunc)); - break; - } - case k7zIdUnPackInfo: - { - RINOK(SzReadUnPackInfo(sd, &db->NumFolders, &db->Folders, allocFunc, allocTemp)); - break; - } - case k7zIdSubStreamsInfo: - { - RINOK(SzReadSubStreamsInfo(sd, db->NumFolders, db->Folders, - numUnPackStreams, unPackSizes, digestsDefined, digests, allocTemp)); - break; - } - default: - return SZE_FAIL; - } - } -} - -Byte kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - -SZ_RESULT SzReadFileNames(CSzData *sd, UInt32 numFiles, CFileItem *files, - void * (*allocFunc)(size_t size)) -{ - UInt32 i; - for(i = 0; i < numFiles; i++) - { - UInt32 len = 0; - UInt32 pos = 0; - CFileItem *file = files + i; - while(pos + 2 <= sd->Size) - { - int numAdds; - UInt32 value = (UInt32)(sd->Data[pos] | (((UInt32)sd->Data[pos + 1]) << 8)); - pos += 2; - len++; - if (value == 0) - break; - if (value < 0x80) - continue; - if (value >= 0xD800 && value < 0xE000) - { - UInt32 c2; - if (value >= 0xDC00) - return SZE_ARCHIVE_ERROR; - if (pos + 2 > sd->Size) - return SZE_ARCHIVE_ERROR; - c2 = (UInt32)(sd->Data[pos] | (((UInt32)sd->Data[pos + 1]) << 8)); - pos += 2; - if (c2 < 0xDC00 || c2 >= 0xE000) - return SZE_ARCHIVE_ERROR; - value = ((value - 0xD800) << 10) | (c2 - 0xDC00); - } - for (numAdds = 1; numAdds < 5; numAdds++) - if (value < (((UInt32)1) << (numAdds * 5 + 6))) - break; - len += numAdds; - } - - MY_ALLOC(char, file->Name, (size_t)len, allocFunc); - - len = 0; - while(2 <= sd->Size) - { - int numAdds; - UInt32 value = (UInt32)(sd->Data[0] | (((UInt32)sd->Data[1]) << 8)); - SzSkeepDataSize(sd, 2); - if (value < 0x80) - { - file->Name[len++] = (char)value; - if (value == 0) - break; - continue; - } - if (value >= 0xD800 && value < 0xE000) - { - UInt32 c2 = (UInt32)(sd->Data[0] | (((UInt32)sd->Data[1]) << 8)); - SzSkeepDataSize(sd, 2); - value = ((value - 0xD800) << 10) | (c2 - 0xDC00); - } - for (numAdds = 1; numAdds < 5; numAdds++) - if (value < (((UInt32)1) << (numAdds * 5 + 6))) - break; - file->Name[len++] = (char)(kUtf8Limits[numAdds - 1] + (value >> (6 * numAdds))); - do - { - numAdds--; - file->Name[len++] = (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F)); - } - while(numAdds > 0); - - len += numAdds; - } - } - return SZ_OK; -} - -SZ_RESULT SzReadHeader2( - CSzData *sd, - CArchiveDatabaseEx *db, /* allocMain */ - CFileSize **unPackSizes, /* allocTemp */ - Byte **digestsDefined, /* allocTemp */ - UInt32 **digests, /* allocTemp */ - Byte **emptyStreamVector, /* allocTemp */ - Byte **emptyFileVector, /* allocTemp */ - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - UInt64 type; - UInt32 numUnPackStreams = 0; - UInt32 numFiles = 0; - CFileItem *files = 0; - UInt32 numEmptyStreams = 0; - UInt32 i; - - RINOK(SzReadID(sd, &type)); - - if (type == k7zIdArchiveProperties) - { - RINOK(SzReadArchiveProperties(sd)); - RINOK(SzReadID(sd, &type)); - } - - - if (type == k7zIdMainStreamsInfo) - { - RINOK(SzReadStreamsInfo(sd, - &db->ArchiveInfo.DataStartPosition, - &db->Database, - &numUnPackStreams, - unPackSizes, - digestsDefined, - digests, allocMain->Alloc, allocTemp)); - db->ArchiveInfo.DataStartPosition += db->ArchiveInfo.StartPositionAfterHeader; - RINOK(SzReadID(sd, &type)); - } - - if (type == k7zIdEnd) - return SZ_OK; - if (type != k7zIdFilesInfo) - return SZE_ARCHIVE_ERROR; - - RINOK(SzReadNumber32(sd, &numFiles)); - db->Database.NumFiles = numFiles; - - MY_ALLOC(CFileItem, files, (size_t)numFiles, allocMain->Alloc); - - db->Database.Files = files; - for(i = 0; i < numFiles; i++) - SzFileInit(files + i); - - while(1) - { - UInt64 type; - UInt64 size; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - break; - RINOK(SzReadNumber(sd, &size)); - - if ((UInt64)(int)type != type) - { - RINOK(SzSkeepDataSize(sd, size)); - } - else - switch((int)type) - { - case k7zIdName: - { - RINOK(SzReadSwitch(sd)); - RINOK(SzReadFileNames(sd, numFiles, files, allocMain->Alloc)) - break; - } - case k7zIdEmptyStream: - { - RINOK(SzReadBoolVector(sd, numFiles, emptyStreamVector, allocTemp->Alloc)); - numEmptyStreams = 0; - for (i = 0; i < numFiles; i++) - if ((*emptyStreamVector)[i]) - numEmptyStreams++; - break; - } - case k7zIdEmptyFile: - { - RINOK(SzReadBoolVector(sd, numEmptyStreams, emptyFileVector, allocTemp->Alloc)); - break; - } - default: - { - RINOK(SzSkeepDataSize(sd, size)); - } - } - } - - { - UInt32 emptyFileIndex = 0; - UInt32 sizeIndex = 0; - for(i = 0; i < numFiles; i++) - { - CFileItem *file = files + i; - file->IsAnti = 0; - if (*emptyStreamVector == 0) - file->HasStream = 1; - else - file->HasStream = (Byte)((*emptyStreamVector)[i] ? 0 : 1); - if(file->HasStream) - { - file->IsDirectory = 0; - file->Size = (*unPackSizes)[sizeIndex]; - file->FileCRC = (*digests)[sizeIndex]; - file->IsFileCRCDefined = (Byte)(*digestsDefined)[sizeIndex]; - sizeIndex++; - } - else - { - if (*emptyFileVector == 0) - file->IsDirectory = 1; - else - file->IsDirectory = (Byte)((*emptyFileVector)[emptyFileIndex] ? 0 : 1); - emptyFileIndex++; - file->Size = 0; - file->IsFileCRCDefined = 0; - } - } - } - return SzArDbExFill(db, allocMain->Alloc); -} - -SZ_RESULT SzReadHeader( - CSzData *sd, - CArchiveDatabaseEx *db, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - CFileSize *unPackSizes = 0; - Byte *digestsDefined = 0; - UInt32 *digests = 0; - Byte *emptyStreamVector = 0; - Byte *emptyFileVector = 0; - SZ_RESULT res = SzReadHeader2(sd, db, - &unPackSizes, &digestsDefined, &digests, - &emptyStreamVector, &emptyFileVector, - allocMain, allocTemp); - allocTemp->Free(unPackSizes); - allocTemp->Free(digestsDefined); - allocTemp->Free(digests); - allocTemp->Free(emptyStreamVector); - allocTemp->Free(emptyFileVector); - return res; -} - -SZ_RESULT SzReadAndDecodePackedStreams2( - ISzInStream *inStream, - CSzData *sd, - CSzByteBuffer *outBuffer, - CFileSize baseOffset, - CArchiveDatabase *db, - CFileSize **unPackSizes, - Byte **digestsDefined, - UInt32 **digests, - #ifndef _LZMA_IN_CB - Byte **inBuffer, - #endif - ISzAlloc *allocTemp) -{ - - UInt32 numUnPackStreams = 0; - CFileSize dataStartPos; - CFolder *folder; - #ifndef _LZMA_IN_CB - CFileSize packSize = 0; - UInt32 i = 0; - #endif - CFileSize unPackSize; - size_t outRealSize; - SZ_RESULT res; - - RINOK(SzReadStreamsInfo(sd, &dataStartPos, db, - &numUnPackStreams, unPackSizes, digestsDefined, digests, - allocTemp->Alloc, allocTemp)); - - dataStartPos += baseOffset; - if (db->NumFolders != 1) - return SZE_ARCHIVE_ERROR; - - folder = db->Folders; - unPackSize = SzFolderGetUnPackSize(folder); - - RINOK(inStream->Seek(inStream, dataStartPos)); - - #ifndef _LZMA_IN_CB - for (i = 0; i < db->NumPackStreams; i++) - packSize += db->PackSizes[i]; - - MY_ALLOC(Byte, *inBuffer, (size_t)packSize, allocTemp->Alloc); - - RINOK(SafeReadDirect(inStream, *inBuffer, (size_t)packSize)); - #endif - - if (!SzByteBufferCreate(outBuffer, (size_t)unPackSize, allocTemp->Alloc)) - return SZE_OUTOFMEMORY; - - res = SzDecode(db->PackSizes, folder, - #ifdef _LZMA_IN_CB - inStream, - #else - *inBuffer, - #endif - outBuffer->Items, (size_t)unPackSize, - &outRealSize, allocTemp); - RINOK(res) - if (outRealSize != (UInt32)unPackSize) - return SZE_FAIL; - if (folder->UnPackCRCDefined) - if (!CrcVerifyDigest(folder->UnPackCRC, outBuffer->Items, (size_t)unPackSize)) - return SZE_FAIL; - return SZ_OK; -} - -SZ_RESULT SzReadAndDecodePackedStreams( - ISzInStream *inStream, - CSzData *sd, - CSzByteBuffer *outBuffer, - CFileSize baseOffset, - ISzAlloc *allocTemp) -{ - CArchiveDatabase db; - CFileSize *unPackSizes = 0; - Byte *digestsDefined = 0; - UInt32 *digests = 0; - #ifndef _LZMA_IN_CB - Byte *inBuffer = 0; - #endif - SZ_RESULT res; - SzArchiveDatabaseInit(&db); - res = SzReadAndDecodePackedStreams2(inStream, sd, outBuffer, baseOffset, - &db, &unPackSizes, &digestsDefined, &digests, - #ifndef _LZMA_IN_CB - &inBuffer, - #endif - allocTemp); - SzArchiveDatabaseFree(&db, allocTemp->Free); - allocTemp->Free(unPackSizes); - allocTemp->Free(digestsDefined); - allocTemp->Free(digests); - #ifndef _LZMA_IN_CB - allocTemp->Free(inBuffer); - #endif - return res; -} - -SZ_RESULT SzArchiveOpen2( - ISzInStream *inStream, - CArchiveDatabaseEx *db, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - Byte signature[k7zSignatureSize]; - Byte version; - UInt32 crcFromArchive; - UInt64 nextHeaderOffset; - UInt64 nextHeaderSize; - UInt32 nextHeaderCRC; - UInt32 crc; - CFileSize pos = 0; - CSzByteBuffer buffer; - CSzData sd; - SZ_RESULT res; - - RINOK(SafeReadDirect(inStream, signature, k7zSignatureSize)); - - if (!TestSignatureCandidate(signature)) - return SZE_ARCHIVE_ERROR; - - /* - db.Clear(); - db.ArchiveInfo.StartPosition = _arhiveBeginStreamPosition; - */ - RINOK(SafeReadDirectByte(inStream, &version)); - if (version != k7zMajorVersion) - return SZE_ARCHIVE_ERROR; - RINOK(SafeReadDirectByte(inStream, &version)); - - RINOK(SafeReadDirectUInt32(inStream, &crcFromArchive)); - - CrcInit(&crc); - RINOK(SafeReadDirectUInt64(inStream, &nextHeaderOffset)); - CrcUpdateUInt64(&crc, nextHeaderOffset); - RINOK(SafeReadDirectUInt64(inStream, &nextHeaderSize)); - CrcUpdateUInt64(&crc, nextHeaderSize); - RINOK(SafeReadDirectUInt32(inStream, &nextHeaderCRC)); - CrcUpdateUInt32(&crc, nextHeaderCRC); - - pos = k7zStartHeaderSize; - db->ArchiveInfo.StartPositionAfterHeader = pos; - - if (CrcGetDigest(&crc) != crcFromArchive) - return SZE_ARCHIVE_ERROR; - - if (nextHeaderSize == 0) - return SZ_OK; - - RINOK(inStream->Seek(inStream, (CFileSize)(pos + nextHeaderOffset))); - - if (!SzByteBufferCreate(&buffer, (size_t)nextHeaderSize, allocTemp->Alloc)) - return SZE_OUTOFMEMORY; - - res = SafeReadDirect(inStream, buffer.Items, (size_t)nextHeaderSize); - if (res == SZ_OK) - { - if (CrcVerifyDigest(nextHeaderCRC, buffer.Items, (UInt32)nextHeaderSize)) - { - while (1) - { - UInt64 type; - sd.Data = buffer.Items; - sd.Size = buffer.Capacity; - res = SzReadID(&sd, &type); - if (res != SZ_OK) - break; - if (type == k7zIdHeader) - { - res = SzReadHeader(&sd, db, allocMain, allocTemp); - break; - } - if (type != k7zIdEncodedHeader) - { - res = SZE_ARCHIVE_ERROR; - break; - } - { - CSzByteBuffer outBuffer; - res = SzReadAndDecodePackedStreams(inStream, &sd, &outBuffer, - db->ArchiveInfo.StartPositionAfterHeader, - allocTemp); - if (res != SZ_OK) - { - SzByteBufferFree(&outBuffer, allocTemp->Free); - break; - } - SzByteBufferFree(&buffer, allocTemp->Free); - buffer.Items = outBuffer.Items; - buffer.Capacity = outBuffer.Capacity; - } - } - } - } - SzByteBufferFree(&buffer, allocTemp->Free); - return res; -} - -SZ_RESULT SzArchiveOpen( - ISzInStream *inStream, - CArchiveDatabaseEx *db, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - SZ_RESULT res = SzArchiveOpen2(inStream, db, allocMain, allocTemp); - if (res != SZ_OK) - SzArDbExFree(db, allocMain->Free); - return res; -} diff --git a/source/sz/7zIn.h b/source/sz/7zIn.h deleted file mode 100644 index 8ded0ec..0000000 --- a/source/sz/7zIn.h +++ /dev/null @@ -1,55 +0,0 @@ -/* 7zIn.h */ - -#ifndef __7Z_IN_H -#define __7Z_IN_H - -#include "7zHeader.h" -#include "7zItem.h" -#include "7zAlloc.h" - -typedef struct _CInArchiveInfo -{ - CFileSize StartPositionAfterHeader; - CFileSize DataStartPosition; -}CInArchiveInfo; - -typedef struct _CArchiveDatabaseEx -{ - CArchiveDatabase Database; - CInArchiveInfo ArchiveInfo; - UInt32 *FolderStartPackStreamIndex; - CFileSize *PackStreamStartPositions; - UInt32 *FolderStartFileIndex; - UInt32 *FileIndexToFolderIndexMap; -}CArchiveDatabaseEx; - -void SzArDbExInit(CArchiveDatabaseEx *db); -void SzArDbExFree(CArchiveDatabaseEx *db, void (*freeFunc)(void *)); -CFileSize SzArDbGetFolderStreamPos(CArchiveDatabaseEx *db, UInt32 folderIndex, UInt32 indexInFolder); -CFileSize SzArDbGetFolderFullPackSize(CArchiveDatabaseEx *db, UInt32 folderIndex); - -typedef struct _ISzInStream -{ - #ifdef _LZMA_IN_CB - SZ_RESULT (*Read)( - void *object, /* pointer to ISzInStream itself */ - void **buffer, /* out: pointer to buffer with data */ - size_t maxRequiredSize, /* max required size to read */ - size_t *processedSize); /* real processed size. - processedSize can be less than maxRequiredSize. - If processedSize == 0, then there are no more - bytes in stream. */ - #else - SZ_RESULT (*Read)(void *object, void *buffer, size_t size, size_t *processedSize); - #endif - SZ_RESULT (*Seek)(void *object, CFileSize pos); -} ISzInStream; - - -int SzArchiveOpen( - ISzInStream *inStream, - CArchiveDatabaseEx *db, - ISzAlloc *allocMain, - ISzAlloc *allocTemp); - -#endif diff --git a/source/sz/7zItem.c b/source/sz/7zItem.c deleted file mode 100644 index 5f9a37f..0000000 --- a/source/sz/7zItem.c +++ /dev/null @@ -1,133 +0,0 @@ -/* 7zItem.c */ - -#include "7zItem.h" -#include "7zAlloc.h" - -void SzCoderInfoInit(CCoderInfo *coder) -{ - SzByteBufferInit(&coder->Properties); -} - -void SzCoderInfoFree(CCoderInfo *coder, void (*freeFunc)(void *p)) -{ - SzByteBufferFree(&coder->Properties, freeFunc); - SzCoderInfoInit(coder); -} - -void SzFolderInit(CFolder *folder) -{ - folder->NumCoders = 0; - folder->Coders = 0; - folder->NumBindPairs = 0; - folder->BindPairs = 0; - folder->NumPackStreams = 0; - folder->PackStreams = 0; - folder->UnPackSizes = 0; - folder->UnPackCRCDefined = 0; - folder->UnPackCRC = 0; - folder->NumUnPackStreams = 0; -} - -void SzFolderFree(CFolder *folder, void (*freeFunc)(void *p)) -{ - UInt32 i; - for (i = 0; i < folder->NumCoders; i++) - SzCoderInfoFree(&folder->Coders[i], freeFunc); - freeFunc(folder->Coders); - freeFunc(folder->BindPairs); - freeFunc(folder->PackStreams); - freeFunc(folder->UnPackSizes); - SzFolderInit(folder); -} - -UInt32 SzFolderGetNumOutStreams(CFolder *folder) -{ - UInt32 result = 0; - UInt32 i; - for (i = 0; i < folder->NumCoders; i++) - result += folder->Coders[i].NumOutStreams; - return result; -} - -int SzFolderFindBindPairForInStream(CFolder *folder, UInt32 inStreamIndex) -{ - UInt32 i; - for(i = 0; i < folder->NumBindPairs; i++) - if (folder->BindPairs[i].InIndex == inStreamIndex) - return i; - return -1; -} - - -int SzFolderFindBindPairForOutStream(CFolder *folder, UInt32 outStreamIndex) -{ - UInt32 i; - for(i = 0; i < folder->NumBindPairs; i++) - if (folder->BindPairs[i].OutIndex == outStreamIndex) - return i; - return -1; -} - -CFileSize SzFolderGetUnPackSize(CFolder *folder) -{ - int i = (int)SzFolderGetNumOutStreams(folder); - if (i == 0) - return 0; - for (i--; i >= 0; i--) - if (SzFolderFindBindPairForOutStream(folder, i) < 0) - return folder->UnPackSizes[i]; - /* throw 1; */ - return 0; -} - -/* -int FindPackStreamArrayIndex(int inStreamIndex) const -{ - for(int i = 0; i < PackStreams.Size(); i++) - if (PackStreams[i] == inStreamIndex) - return i; - return -1; -} -*/ - -void SzFileInit(CFileItem *fileItem) -{ - fileItem->IsFileCRCDefined = 0; - fileItem->HasStream = 1; - fileItem->IsDirectory = 0; - fileItem->IsAnti = 0; - fileItem->Name = 0; -} - -void SzFileFree(CFileItem *fileItem, void (*freeFunc)(void *p)) -{ - freeFunc(fileItem->Name); - SzFileInit(fileItem); -} - -void SzArchiveDatabaseInit(CArchiveDatabase *db) -{ - db->NumPackStreams = 0; - db->PackSizes = 0; - db->PackCRCsDefined = 0; - db->PackCRCs = 0; - db->NumFolders = 0; - db->Folders = 0; - db->NumFiles = 0; - db->Files = 0; -} - -void SzArchiveDatabaseFree(CArchiveDatabase *db, void (*freeFunc)(void *)) -{ - UInt32 i; - for (i = 0; i < db->NumFolders; i++) - SzFolderFree(&db->Folders[i], freeFunc); - for (i = 0; i < db->NumFiles; i++) - SzFileFree(&db->Files[i], freeFunc); - freeFunc(db->PackSizes); - freeFunc(db->PackCRCsDefined); - freeFunc(db->PackCRCs); - freeFunc(db->Folders); - freeFunc(db->Files); - SzArchiveDatabaseInit(db); -} diff --git a/source/sz/7zItem.h b/source/sz/7zItem.h deleted file mode 100644 index e59b73f..0000000 --- a/source/sz/7zItem.h +++ /dev/null @@ -1,90 +0,0 @@ -/* 7zItem.h */ - -#ifndef __7Z_ITEM_H -#define __7Z_ITEM_H - -#include "7zMethodID.h" -#include "7zHeader.h" -#include "7zBuffer.h" - -typedef struct _CCoderInfo -{ - UInt32 NumInStreams; - UInt32 NumOutStreams; - CMethodID MethodID; - CSzByteBuffer Properties; -}CCoderInfo; - -void SzCoderInfoInit(CCoderInfo *coder); -void SzCoderInfoFree(CCoderInfo *coder, void (*freeFunc)(void *p)); - -typedef struct _CBindPair -{ - UInt32 InIndex; - UInt32 OutIndex; -}CBindPair; - -typedef struct _CFolder -{ - UInt32 NumCoders; - CCoderInfo *Coders; - UInt32 NumBindPairs; - CBindPair *BindPairs; - UInt32 NumPackStreams; - UInt32 *PackStreams; - CFileSize *UnPackSizes; - int UnPackCRCDefined; - UInt32 UnPackCRC; - - UInt32 NumUnPackStreams; -}CFolder; - -void SzFolderInit(CFolder *folder); -CFileSize SzFolderGetUnPackSize(CFolder *folder); -int SzFolderFindBindPairForInStream(CFolder *folder, UInt32 inStreamIndex); -UInt32 SzFolderGetNumOutStreams(CFolder *folder); -CFileSize SzFolderGetUnPackSize(CFolder *folder); - -/* #define CArchiveFileTime UInt64 */ - -typedef struct _CFileItem -{ - /* - CArchiveFileTime LastWriteTime; - CFileSize StartPos; - UInt32 Attributes; - */ - CFileSize Size; - UInt32 FileCRC; - char *Name; - - Byte IsFileCRCDefined; - Byte HasStream; - Byte IsDirectory; - Byte IsAnti; - /* - int AreAttributesDefined; - int IsLastWriteTimeDefined; - int IsStartPosDefined; - */ -}CFileItem; - -void SzFileInit(CFileItem *fileItem); - -typedef struct _CArchiveDatabase -{ - UInt32 NumPackStreams; - CFileSize *PackSizes; - Byte *PackCRCsDefined; - UInt32 *PackCRCs; - UInt32 NumFolders; - CFolder *Folders; - UInt32 NumFiles; - CFileItem *Files; -}CArchiveDatabase; - -void SzArchiveDatabaseInit(CArchiveDatabase *db); -void SzArchiveDatabaseFree(CArchiveDatabase *db, void (*freeFunc)(void *)); - - -#endif diff --git a/source/sz/7zMethodID.c b/source/sz/7zMethodID.c deleted file mode 100644 index 9daf39c..0000000 --- a/source/sz/7zMethodID.c +++ /dev/null @@ -1,14 +0,0 @@ -/* 7zMethodID.c */ - -#include "7zMethodID.h" - -int AreMethodsEqual(CMethodID *a1, CMethodID *a2) -{ - int i; - if (a1->IDSize != a2->IDSize) - return 0; - for (i = 0; i < a1->IDSize; i++) - if (a1->ID[i] != a2->ID[i]) - return 0; - return 1; -} diff --git a/source/sz/7zMethodID.h b/source/sz/7zMethodID.h deleted file mode 100644 index 4d88689..0000000 --- a/source/sz/7zMethodID.h +++ /dev/null @@ -1,18 +0,0 @@ -/* 7zMethodID.h */ - -#ifndef __7Z_METHOD_ID_H -#define __7Z_METHOD_ID_H - -#include "7zTypes.h" - -#define kMethodIDSize 15 - -typedef struct _CMethodID -{ - Byte ID[kMethodIDSize]; - Byte IDSize; -} CMethodID; - -int AreMethodsEqual(CMethodID *a1, CMethodID *a2); - -#endif diff --git a/source/sz/7zTypes.h b/source/sz/7zTypes.h deleted file mode 100644 index 817d921..0000000 --- a/source/sz/7zTypes.h +++ /dev/null @@ -1,67 +0,0 @@ -/* 7zTypes.h */ - -#ifndef __COMMON_TYPES_H -#define __COMMON_TYPES_H - -#ifndef _7ZIP_BYTE_DEFINED -#define _7ZIP_BYTE_DEFINED -typedef unsigned char Byte; -#endif - -#ifndef _7ZIP_UINT16_DEFINED -#define _7ZIP_UINT16_DEFINED -typedef unsigned short UInt16; -#endif - -#ifndef _7ZIP_UINT32_DEFINED -#define _7ZIP_UINT32_DEFINED -#ifdef _LZMA_UINT32_IS_ULONG -typedef unsigned long UInt32; -#else -typedef unsigned int UInt32; -#endif -#endif - -/* #define _SZ_NO_INT_64 */ -/* define it your compiler doesn't support long long int */ - -#ifndef _7ZIP_UINT64_DEFINED -#define _7ZIP_UINT64_DEFINED -#ifdef _SZ_NO_INT_64 -typedef unsigned long UInt64; -#else -#ifdef _MSC_VER -typedef unsigned __int64 UInt64; -#else -typedef unsigned long long int UInt64; -#endif -#endif -#endif - - -/* #define _SZ_FILE_SIZE_64 */ -/* Use _SZ_FILE_SIZE_64 if you need support for files larger than 4 GB*/ - -#ifndef CFileSize -#ifdef _SZ_FILE_SIZE_64 -typedef UInt64 CFileSize; -#else -typedef UInt32 CFileSize; -#endif -#endif - -#define SZ_RESULT int - -#define SZ_OK (0) -#define SZE_DATA_ERROR (1) -#define SZE_OUTOFMEMORY (2) -#define SZE_CRC_ERROR (3) - -#define SZE_NOTIMPL (4) -#define SZE_FAIL (5) - -#define SZE_ARCHIVE_ERROR (6) - -#define RINOK(x) { int __result_ = (x); if(__result_ != 0) return __result_; } - -#endif diff --git a/source/sz/LzmaDecode.c b/source/sz/LzmaDecode.c deleted file mode 100644 index 71c62c4..0000000 --- a/source/sz/LzmaDecode.c +++ /dev/null @@ -1,584 +0,0 @@ -/* - LzmaDecode.c - LZMA Decoder (optimized for Speed version) - - LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01) - http://www.7-zip.org/ - - LZMA SDK is licensed under two licenses: - 1) GNU Lesser General Public License (GNU LGPL) - 2) Common Public License (CPL) - It means that you can select one of these two licenses and - follow rules of that license. - - SPECIAL EXCEPTION: - Igor Pavlov, as the author of this Code, expressly permits you to - statically or dynamically link your Code (or bind by name) to the - interfaces of this file without subjecting your linked Code to the - terms of the CPL or GNU LGPL. Any modifications or additions - to this file, however, are subject to the LGPL or CPL terms. -*/ - -#include "LzmaDecode.h" - -#define kNumTopBits 24 -#define kTopValue ((UInt32)1 << kNumTopBits) - -#define kNumBitModelTotalBits 11 -#define kBitModelTotal (1 << kNumBitModelTotalBits) -#define kNumMoveBits 5 - -#define RC_READ_BYTE (*Buffer++) - -#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \ - { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }} - -#ifdef _LZMA_IN_CB - -#define RC_TEST { if (Buffer == BufferLim) \ - { SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) return result; \ - BufferLim = Buffer + size; if (size == 0) return LZMA_RESULT_DATA_ERROR; }} - -#define RC_INIT Buffer = BufferLim = 0; RC_INIT2 - -#else - -#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; } - -#define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2 - -#endif - -#define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; } - -#define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound) -#define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits; -#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits; - -#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \ - { UpdateBit0(p); mi <<= 1; A0; } else \ - { UpdateBit1(p); mi = (mi + mi) + 1; A1; } - -#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;) - -#define RangeDecoderBitTreeDecode(probs, numLevels, res) \ - { int i = numLevels; res = 1; \ - do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \ - res -= (1 << numLevels); } - - -#define kNumPosBitsMax 4 -#define kNumPosStatesMax (1 << kNumPosBitsMax) - -#define kLenNumLowBits 3 -#define kLenNumLowSymbols (1 << kLenNumLowBits) -#define kLenNumMidBits 3 -#define kLenNumMidSymbols (1 << kLenNumMidBits) -#define kLenNumHighBits 8 -#define kLenNumHighSymbols (1 << kLenNumHighBits) - -#define LenChoice 0 -#define LenChoice2 (LenChoice + 1) -#define LenLow (LenChoice2 + 1) -#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) -#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) -#define kNumLenProbs (LenHigh + kLenNumHighSymbols) - - -#define kNumStates 12 -#define kNumLitStates 7 - -#define kStartPosModelIndex 4 -#define kEndPosModelIndex 14 -#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) - -#define kNumPosSlotBits 6 -#define kNumLenToPosStates 4 - -#define kNumAlignBits 4 -#define kAlignTableSize (1 << kNumAlignBits) - -#define kMatchMinLen 2 - -#define IsMatch 0 -#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) -#define IsRepG0 (IsRep + kNumStates) -#define IsRepG1 (IsRepG0 + kNumStates) -#define IsRepG2 (IsRepG1 + kNumStates) -#define IsRep0Long (IsRepG2 + kNumStates) -#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) -#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) -#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) -#define LenCoder (Align + kAlignTableSize) -#define RepLenCoder (LenCoder + kNumLenProbs) -#define Literal (RepLenCoder + kNumLenProbs) - -#if Literal != LZMA_BASE_SIZE -StopCompilingDueBUG -#endif - -int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size) -{ - unsigned char prop0; - if (size < LZMA_PROPERTIES_SIZE) - return LZMA_RESULT_DATA_ERROR; - prop0 = propsData[0]; - if (prop0 >= (9 * 5 * 5)) - return LZMA_RESULT_DATA_ERROR; - { - for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5)); - for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9); - propsRes->lc = prop0; - /* - unsigned char remainder = (unsigned char)(prop0 / 9); - propsRes->lc = prop0 % 9; - propsRes->pb = remainder / 5; - propsRes->lp = remainder % 5; - */ - } - - #ifdef _LZMA_OUT_READ - { - int i; - propsRes->DictionarySize = 0; - for (i = 0; i < 4; i++) - propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8); - if (propsRes->DictionarySize == 0) - propsRes->DictionarySize = 1; - } - #endif - return LZMA_RESULT_OK; -} - -#define kLzmaStreamWasFinishedId (-1) - -int LzmaDecode(CLzmaDecoderState *vs, - #ifdef _LZMA_IN_CB - ILzmaInCallback *InCallback, - #else - const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, - #endif - unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed) -{ - CProb *p = vs->Probs; - SizeT nowPos = 0; - Byte previousByte = 0; - UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1; - UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1; - int lc = vs->Properties.lc; - - #ifdef _LZMA_OUT_READ - - UInt32 Range = vs->Range; - UInt32 Code = vs->Code; - #ifdef _LZMA_IN_CB - const Byte *Buffer = vs->Buffer; - const Byte *BufferLim = vs->BufferLim; - #else - const Byte *Buffer = inStream; - const Byte *BufferLim = inStream + inSize; - #endif - int state = vs->State; - UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3]; - int len = vs->RemainLen; - UInt32 globalPos = vs->GlobalPos; - UInt32 distanceLimit = vs->DistanceLimit; - - Byte *dictionary = vs->Dictionary; - UInt32 dictionarySize = vs->Properties.DictionarySize; - UInt32 dictionaryPos = vs->DictionaryPos; - - Byte tempDictionary[4]; - - #ifndef _LZMA_IN_CB - *inSizeProcessed = 0; - #endif - *outSizeProcessed = 0; - if (len == kLzmaStreamWasFinishedId) - return LZMA_RESULT_OK; - - if (dictionarySize == 0) - { - dictionary = tempDictionary; - dictionarySize = 1; - tempDictionary[0] = vs->TempDictionary[0]; - } - - if (len == kLzmaNeedInitId) - { - { - UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp)); - UInt32 i; - for (i = 0; i < numProbs; i++) - p[i] = kBitModelTotal >> 1; - rep0 = rep1 = rep2 = rep3 = 1; - state = 0; - globalPos = 0; - distanceLimit = 0; - dictionaryPos = 0; - dictionary[dictionarySize - 1] = 0; - #ifdef _LZMA_IN_CB - RC_INIT; - #else - RC_INIT(inStream, inSize); - #endif - } - len = 0; - } - while(len != 0 && nowPos < outSize) - { - UInt32 pos = dictionaryPos - rep0; - if (pos >= dictionarySize) - pos += dictionarySize; - outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos]; - if (++dictionaryPos == dictionarySize) - dictionaryPos = 0; - len--; - } - if (dictionaryPos == 0) - previousByte = dictionary[dictionarySize - 1]; - else - previousByte = dictionary[dictionaryPos - 1]; - - #else /* if !_LZMA_OUT_READ */ - - int state = 0; - UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1; - int len = 0; - const Byte *Buffer; - const Byte *BufferLim; - UInt32 Range; - UInt32 Code; - - #ifndef _LZMA_IN_CB - *inSizeProcessed = 0; - #endif - *outSizeProcessed = 0; - - { - UInt32 i; - UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp)); - for (i = 0; i < numProbs; i++) - p[i] = kBitModelTotal >> 1; - } - - #ifdef _LZMA_IN_CB - RC_INIT; - #else - RC_INIT(inStream, inSize); - #endif - - #endif /* _LZMA_OUT_READ */ - - while(nowPos < outSize) - { - CProb *prob; - UInt32 bound; - int posState = (int)( - (nowPos - #ifdef _LZMA_OUT_READ - + globalPos - #endif - ) - & posStateMask); - - prob = p + IsMatch + (state << kNumPosBitsMax) + posState; - IfBit0(prob) - { - int symbol = 1; - UpdateBit0(prob) - prob = p + Literal + (LZMA_LIT_SIZE * - ((( - (nowPos - #ifdef _LZMA_OUT_READ - + globalPos - #endif - ) - & literalPosMask) << lc) + (previousByte >> (8 - lc)))); - - if (state >= kNumLitStates) - { - int matchByte; - #ifdef _LZMA_OUT_READ - UInt32 pos = dictionaryPos - rep0; - if (pos >= dictionarySize) - pos += dictionarySize; - matchByte = dictionary[pos]; - #else - matchByte = outStream[nowPos - rep0]; - #endif - do - { - int bit; - CProb *probLit; - matchByte <<= 1; - bit = (matchByte & 0x100); - probLit = prob + 0x100 + bit + symbol; - RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break) - } - while (symbol < 0x100); - } - while (symbol < 0x100) - { - CProb *probLit = prob + symbol; - RC_GET_BIT(probLit, symbol) - } - previousByte = (Byte)symbol; - - outStream[nowPos++] = previousByte; - #ifdef _LZMA_OUT_READ - if (distanceLimit < dictionarySize) - distanceLimit++; - - dictionary[dictionaryPos] = previousByte; - if (++dictionaryPos == dictionarySize) - dictionaryPos = 0; - #endif - if (state < 4) state = 0; - else if (state < 10) state -= 3; - else state -= 6; - } - else - { - UpdateBit1(prob); - prob = p + IsRep + state; - IfBit0(prob) - { - UpdateBit0(prob); - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - state = state < kNumLitStates ? 0 : 3; - prob = p + LenCoder; - } - else - { - UpdateBit1(prob); - prob = p + IsRepG0 + state; - IfBit0(prob) - { - UpdateBit0(prob); - prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState; - IfBit0(prob) - { - #ifdef _LZMA_OUT_READ - UInt32 pos; - #endif - UpdateBit0(prob); - - #ifdef _LZMA_OUT_READ - if (distanceLimit == 0) - #else - if (nowPos == 0) - #endif - return LZMA_RESULT_DATA_ERROR; - - state = state < kNumLitStates ? 9 : 11; - #ifdef _LZMA_OUT_READ - pos = dictionaryPos - rep0; - if (pos >= dictionarySize) - pos += dictionarySize; - previousByte = dictionary[pos]; - dictionary[dictionaryPos] = previousByte; - if (++dictionaryPos == dictionarySize) - dictionaryPos = 0; - #else - previousByte = outStream[nowPos - rep0]; - #endif - outStream[nowPos++] = previousByte; - #ifdef _LZMA_OUT_READ - if (distanceLimit < dictionarySize) - distanceLimit++; - #endif - - continue; - } - else - { - UpdateBit1(prob); - } - } - else - { - UInt32 distance; - UpdateBit1(prob); - prob = p + IsRepG1 + state; - IfBit0(prob) - { - UpdateBit0(prob); - distance = rep1; - } - else - { - UpdateBit1(prob); - prob = p + IsRepG2 + state; - IfBit0(prob) - { - UpdateBit0(prob); - distance = rep2; - } - else - { - UpdateBit1(prob); - distance = rep3; - rep3 = rep2; - } - rep2 = rep1; - } - rep1 = rep0; - rep0 = distance; - } - state = state < kNumLitStates ? 8 : 11; - prob = p + RepLenCoder; - } - { - int numBits, offset; - CProb *probLen = prob + LenChoice; - IfBit0(probLen) - { - UpdateBit0(probLen); - probLen = prob + LenLow + (posState << kLenNumLowBits); - offset = 0; - numBits = kLenNumLowBits; - } - else - { - UpdateBit1(probLen); - probLen = prob + LenChoice2; - IfBit0(probLen) - { - UpdateBit0(probLen); - probLen = prob + LenMid + (posState << kLenNumMidBits); - offset = kLenNumLowSymbols; - numBits = kLenNumMidBits; - } - else - { - UpdateBit1(probLen); - probLen = prob + LenHigh; - offset = kLenNumLowSymbols + kLenNumMidSymbols; - numBits = kLenNumHighBits; - } - } - RangeDecoderBitTreeDecode(probLen, numBits, len); - len += offset; - } - - if (state < 4) - { - int posSlot; - state += kNumLitStates; - prob = p + PosSlot + - ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << - kNumPosSlotBits); - RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot); - if (posSlot >= kStartPosModelIndex) - { - int numDirectBits = ((posSlot >> 1) - 1); - rep0 = (2 | ((UInt32)posSlot & 1)); - if (posSlot < kEndPosModelIndex) - { - rep0 <<= numDirectBits; - prob = p + SpecPos + rep0 - posSlot - 1; - } - else - { - numDirectBits -= kNumAlignBits; - do - { - RC_NORMALIZE - Range >>= 1; - rep0 <<= 1; - if (Code >= Range) - { - Code -= Range; - rep0 |= 1; - } - } - while (--numDirectBits != 0); - prob = p + Align; - rep0 <<= kNumAlignBits; - numDirectBits = kNumAlignBits; - } - { - int i = 1; - int mi = 1; - do - { - CProb *prob3 = prob + mi; - RC_GET_BIT2(prob3, mi, ; , rep0 |= i); - i <<= 1; - } - while(--numDirectBits != 0); - } - } - else - rep0 = posSlot; - if (++rep0 == (UInt32)(0)) - { - /* it's for stream version */ - len = kLzmaStreamWasFinishedId; - break; - } - } - - len += kMatchMinLen; - #ifdef _LZMA_OUT_READ - if (rep0 > distanceLimit) - #else - if (rep0 > nowPos) - #endif - return LZMA_RESULT_DATA_ERROR; - - #ifdef _LZMA_OUT_READ - if (dictionarySize - distanceLimit > (UInt32)len) - distanceLimit += len; - else - distanceLimit = dictionarySize; - #endif - - do - { - #ifdef _LZMA_OUT_READ - UInt32 pos = dictionaryPos - rep0; - if (pos >= dictionarySize) - pos += dictionarySize; - previousByte = dictionary[pos]; - dictionary[dictionaryPos] = previousByte; - if (++dictionaryPos == dictionarySize) - dictionaryPos = 0; - #else - previousByte = outStream[nowPos - rep0]; - #endif - len--; - outStream[nowPos++] = previousByte; - } - while(len != 0 && nowPos < outSize); - } - } - RC_NORMALIZE; - - #ifdef _LZMA_OUT_READ - vs->Range = Range; - vs->Code = Code; - vs->DictionaryPos = dictionaryPos; - vs->GlobalPos = globalPos + (UInt32)nowPos; - vs->DistanceLimit = distanceLimit; - vs->Reps[0] = rep0; - vs->Reps[1] = rep1; - vs->Reps[2] = rep2; - vs->Reps[3] = rep3; - vs->State = state; - vs->RemainLen = len; - vs->TempDictionary[0] = tempDictionary[0]; - #endif - - #ifdef _LZMA_IN_CB - vs->Buffer = Buffer; - vs->BufferLim = BufferLim; - #else - *inSizeProcessed = (SizeT)(Buffer - inStream); - #endif - *outSizeProcessed = nowPos; - return LZMA_RESULT_OK; -} diff --git a/source/sz/LzmaDecode.h b/source/sz/LzmaDecode.h deleted file mode 100644 index 8382fa8..0000000 --- a/source/sz/LzmaDecode.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - LzmaDecode.h - LZMA Decoder interface - - LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01) - http://www.7-zip.org/ - - LZMA SDK is licensed under two licenses: - 1) GNU Lesser General Public License (GNU LGPL) - 2) Common Public License (CPL) - It means that you can select one of these two licenses and - follow rules of that license. - - SPECIAL EXCEPTION: - Igor Pavlov, as the author of this code, expressly permits you to - statically or dynamically link your code (or bind by name) to the - interfaces of this file without subjecting your linked code to the - terms of the CPL or GNU LGPL. Any modifications or additions - to this file, however, are subject to the LGPL or CPL terms. -*/ - -#ifndef __LZMADECODE_H -#define __LZMADECODE_H - -#include "LzmaTypes.h" - -/* #define _LZMA_IN_CB */ -/* Use callback for input data */ - -/* #define _LZMA_OUT_READ */ -/* Use read function for output data */ - -/* #define _LZMA_PROB32 */ -/* It can increase speed on some 32-bit CPUs, - but memory usage will be doubled in that case */ - -/* #define _LZMA_LOC_OPT */ -/* Enable local speed optimizations inside code */ - -#ifdef _LZMA_PROB32 -#define CProb UInt32 -#else -#define CProb UInt16 -#endif - -#define LZMA_RESULT_OK 0 -#define LZMA_RESULT_DATA_ERROR 1 - -#ifdef _LZMA_IN_CB -typedef struct _ILzmaInCallback -{ - int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize); -} ILzmaInCallback; -#endif - -#define LZMA_BASE_SIZE 1846 -#define LZMA_LIT_SIZE 768 - -#define LZMA_PROPERTIES_SIZE 5 - -typedef struct _CLzmaProperties -{ - int lc; - int lp; - int pb; - #ifdef _LZMA_OUT_READ - UInt32 DictionarySize; - #endif -}CLzmaProperties; - -int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size); - -#define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp))) - -#define kLzmaNeedInitId (-2) - -typedef struct _CLzmaDecoderState -{ - CLzmaProperties Properties; - CProb *Probs; - - #ifdef _LZMA_IN_CB - const unsigned char *Buffer; - const unsigned char *BufferLim; - #endif - - #ifdef _LZMA_OUT_READ - unsigned char *Dictionary; - UInt32 Range; - UInt32 Code; - UInt32 DictionaryPos; - UInt32 GlobalPos; - UInt32 DistanceLimit; - UInt32 Reps[4]; - int State; - int RemainLen; - unsigned char TempDictionary[4]; - #endif -} CLzmaDecoderState; - -#ifdef _LZMA_OUT_READ -#define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; } -#endif - -int LzmaDecode(CLzmaDecoderState *vs, - #ifdef _LZMA_IN_CB - ILzmaInCallback *inCallback, - #else - const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed, - #endif - unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed); - -#endif diff --git a/source/sz/LzmaTypes.h b/source/sz/LzmaTypes.h deleted file mode 100644 index 4a1f7db..0000000 --- a/source/sz/LzmaTypes.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -LzmaTypes.h - -Types for LZMA Decoder - -This file written and distributed to public domain by Igor Pavlov. -This file is part of LZMA SDK 4.40 (2006-05-01) -*/ - -#ifndef __LZMATYPES_H -#define __LZMATYPES_H - -#ifndef _7ZIP_BYTE_DEFINED -#define _7ZIP_BYTE_DEFINED -typedef unsigned char Byte; -#endif - -#ifndef _7ZIP_UINT16_DEFINED -#define _7ZIP_UINT16_DEFINED -typedef unsigned short UInt16; -#endif - -#ifndef _7ZIP_UINT32_DEFINED -#define _7ZIP_UINT32_DEFINED -#ifdef _LZMA_UINT32_IS_ULONG -typedef unsigned long UInt32; -#else -typedef unsigned int UInt32; -#endif -#endif - -/* #define _LZMA_SYSTEM_SIZE_T */ -/* Use system's size_t. You can use it to enable 64-bit sizes supporting */ - -#ifndef _7ZIP_SIZET_DEFINED -#define _7ZIP_SIZET_DEFINED -#ifdef _LZMA_SYSTEM_SIZE_T -#include -typedef size_t SizeT; -#else -typedef UInt32 SizeT; -#endif -#endif - -#endif