portable documentation
authornotaz <notasas@gmail.com>
Fri, 5 Oct 2007 21:52:58 +0000 (21:52 +0000)
committernotaz <notasas@gmail.com>
Fri, 5 Oct 2007 21:52:58 +0000 (21:52 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@269 be3aeb3a-fb24-0410-a615-afba39da0efa

platform/base_readme.txt [moved from platform/readme.txt with 64% similarity]
platform/gizmondo/Makefile
platform/gp2x/Makefile
platform/gp2x/config.txt [deleted file]
tools/Makefile
tools/textfilter.c [new file with mode: 0644]

similarity index 64%
rename from platform/readme.txt
rename to platform/base_readme.txt
index 018d4db..5656e20 100644 (file)
@@ -1,26 +1,39 @@
+#ifdef GP2X\r
 For help / comments / questions visit GP32X boards at:\r
 http://www.gp32x.com/board/\r
 \r
+#endif\r
 \r
 About\r
 -----\r
 \r
 This is yet another Megadrive / Genesis / Sega CD / Mega CD emulator, which\r
 was written having ARM-based handheld devices in mind (such as PDAs,\r
-smartphones and handheld consoles like GP2X of course). The critical parts\r
-(renderer, 68K and Z80 cpu interpreters) and some other random code is\r
-written in ARM asm, other code is C. The base code originates from Dave's\r
-(fdave, finalburn) PicoDrive 0.30 for Pocket PC. The Sega/Mega CD code is\r
-roughly based on Stephane Dallongeville's Gens.\r
+smartphones and handheld consoles like GP2X and Gizmondo of course).\r
+The critical parts (renderer, 68K and Z80 cpu interpreters) and some other\r
+random code is written in ARM asm, other code is C. The base code originates\r
+from Dave's (fdave, finalburn) PicoDrive 0.30 for Pocket PC. The Sega/Mega CD\r
+code is roughly based on Stephane Dallongeville's Gens.\r
 \r
 \r
 How to make it run\r
 ------------------\r
 \r
+#ifdef GP2X\r
 Copy PicoDrive.gpe, pico940.bin and mmuhack.o to any place in your filesystem\r
 (all 3 files must be in the same directory) and run PicoDrive.gpe.\r
 Then load a ROM and enjoy! ROMs can be in .smd or .bin format and can be zipped.\r
 \r
+#endif\r
+#ifdef GIZ\r
+First make sure you have homebrew-enabled Service Pack installed. Then copy\r
+PicoDrive.exe and KGSDK.dll to any place in your filesystem (both files must\r
+be in the same directory) and run PicoDrive.exe using the launcher of your choice\r
+(some of them might require renaming PicoDrive.exe to Autorun.exe, placing it in\r
+the root of SD, etc). Then load a ROM and enjoy! ROMs can be placed anywhere, can\r
+be in .smd or .bin format and can be zipped (one ROM per zip).\r
+\r
+#endif\r
 If you have any problems (game does not boot, sound is glitchy, broken graphics),\r
 make sure you enable "Accurate timing", "Emulate Z80" and use "16bit accurate\r
 renderer". This way you will get the best compatibility this emulator can\r
@@ -31,7 +44,8 @@ How to run Sega/Mega CD games
 -----------------------------\r
 \r
 To play any game, you need BIOS files. These files must be copied to the same\r
-directory as PicoDrive.gpe. Files can be named as follows:\r
+directory as PicoDrive. Files can be named as follows:\r
+\r
 US: us_scd1_9210.bin us_scd2_9306.bin SegaCDBIOS9303.bin\r
 EU: eu_mcd1_9210.bin eu_mcd2_9303.bin eu_mcd2_9306.bin\r
 JP: jp_mcd1_9112.bin jp_mcd1_9111.bin\r
@@ -39,8 +53,8 @@ these files can also be zipped.
 \r
 The game must be dumped to ISO format, but BIN can be used too. If you want\r
 CD music, you must use ISO+mp3 files. Audio from BIN files won't be read at\r
-all due to SD access issues. Also BIN files are usually larger, so it's better\r
-to use ISO. ISO+mp3 files can be named similarly as for other emus.\r
+all. Also BIN files are usually larger, so it's better to use ISO. ISO+mp3\r
+files can be named similarly as for other emus.\r
 Here are some examples:\r
 \r
 SonicCD.iso             data track\r
@@ -63,37 +77,280 @@ SonicCD_02.mp3          audio track 1 (CD track 2)
 SonicCD_03.mp3\r
 ...\r
 \r
-Notes:\r
-If the game hangs after Sega logo, you may need to enable "better sync"\r
-and/or "Scale/Rot. fx" options, found in "Sega/Mega CD options" submenu, and\r
-then reset the game.\r
-If FMV game performance is poor, try adjusting "ReadAhead buffer" to something\r
-like 2048K.\r
-\r
-\r
-Configuration\r
--------------\r
-\r
-See config.txt file.\r
-\r
 \r
 Other important stuff\r
 ---------------------\r
 \r
+* If your Genesis/MD game hangs or has glitches, this is most likely because\r
+  "Accurate timing" option is not enabled, or 8bit fast renderer is used\r
+  (try the 16 bit one), or Z80 is disabled in "advanced options".\r
+* Sega/Mega CD: If the game hangs after Sega logo, you may need to enable\r
+  "better sync" and/or "Scale/Rot. fx" options, found in "Sega/Mega CD options"\r
+  submenu, and then reset the game. Some other games may also require\r
+  "CDDA audio" and "PCM audio" to work.\r
+#ifdef GP2X\r
+* Sega/Mega CD: if FMV game performance is poor, try adjusting\r
+  "ReadAhead buffer" to something like 2048K.\r
 * When you use both GP2X CPUs, keep in mind that you can't overclock as high as\r
   when using ARM920 only. For example my GP2X when run singlecore can reach\r
   280MHz, but with both cores it's about 250MHz. When overclocked too much,\r
   it may start hanging and producing random noise, or causing ARM940 crashes\r
   ("940 crashed" message displayed).\r
+#endif\r
 * PicoDrive is not a mp3 player, so all mp3s MUST be encoded at 44.1kHz stereo.\r
   Badly encoded mp3s can cause various kind of problems, like noises, incorrect\r
   playback speeds, not repeating music or even prevent game from starting.\r
 * Use lower bitrate for better performance (96 or 128kbps CBRs recommended).\r
+#ifdef GP2X\r
 * Due to internal implementation mp3s must not be larger that 12MB\r
   (12582912 bytes). Larger mp3s will not be fully loaded.\r
 * RAM timings option is good for dualcore operation (it is disabled by\r
   default because it doesn't work on every GP2X, so enable it in advanced\r
   options).\r
+#endif\r
+\r
+\r
+Configuration\r
+-------------\r
+\r
+@@0. "Renderer"\r
+#ifdef GP2X\r
+8bit fast:\r
+This enables alternative heavily optimized tile-based renderer, which renders\r
+pixels not line-by-line (this is what accurate renderers do), but in 8x8 tiles,\r
+which is much faster. But because of the way it works it can't render any\r
+mid-frame image changes (raster effects), so it is useful only with some games.\r
+\r
+Other two are accurate line-based renderers. The 8bit is faster but does not\r
+run well with some games like Street Racer.\r
+#endif\r
+#ifdef GIZ\r
+This option allows to switch between 16bit and 8bit renderers. The 8bit one is\r
+a bit faster for some games, but not much, because colors still need to be\r
+converted to 16bit, as this is what Gizmondo requires. It also introduces\r
+graphics problems for some games, so it's best to use 16bit one.\r
+#endif\r
+\r
+#ifdef GIZ\r
+@@0. "Interlaced rendering"\r
+This option was designed to work around slow framebuffer access (the Gizmondo's\r
+main bottleneck) by drawing every other line (odd numbered lines during odd\r
+numbered frames and even numbered lines during even frames). This improves\r
+performance greatly, but introduces artifacts for fast scrolling games.\r
+\r
+#endif\r
+#ifdef GP2X\r
+@@0. "Scaling"\r
+"hw" means GP2X hardware scaler, which causes no performance loss, but scaled\r
+image looks a bit blocky. "sw" means software scaling, which uses pixel\r
+averaging and may look a bit nicer, but blurry. Horizontal scaling is only for\r
+games which use so called "32 column mode" (256x224 or 256x240), and scales\r
+image width to 320 pixels. Vertical scales height to 240 for games which use\r
+height 224 (most of them).\r
+#endif\r
+#ifdef GIZ\r
+@@0. "Scale low res mode"\r
+The Genesis/Megadrive had several graphics modes, some of which were only 256\r
+pixels wide. This option scales their width to 320 by using simple\r
+pixel averaging scaling. Works only when 16bit renderer is enabled.\r
+#endif\r
+\r
+@@0. "Accurate timing"\r
+This adds some more emulation precision, but slows the emulation down. Without\r
+this option some games do not boot (Red Zone for example), others have sound\r
+problems. This options has no effect for Sega/Mega CD emulation.\r
+\r
+@@0. "Accurate sprites"\r
+This option improves emulation of sprite priorities, it also enables emulation\r
+of sprite collision bit. If you see one sprite being drawn incorrectly above\r
+the other (often seen in Sonic 3D Blast), you can enable this to fix the problem.\r
+This only works with the accurate renderers (see first option).\r
+\r
+@@0. "Show FPS"\r
+Self-explanatory. Format is XX/YY, where XX is the number of rendered frames and\r
+YY is the number of emulated frames per second.\r
+\r
+@@0. "Frameskip"\r
+How many frames to skip rendering before displaying another.\r
+"Auto" is recommended.\r
+\r
+@@0. "Enable sound"\r
+Does what it says. You must enable at least YM2612 or SN76496 (in advanced options,\r
+see below) for this to make sense (already done by default).\r
+\r
+@@0. "Sound Quality"\r
+Sound rate and stereo mode. Mono is not available in Sega/Mega CD mode.\r
+#ifdef GP2X\r
+If you want 44100Hz sound, it is recommended to enable the second core (next option).\r
+\r
+@@0. "Use ARM940 core for sound"\r
+This option causes PicoDrive to use ARM940T core (GP2X's second CPU) for sound \r
+(i.e. to generate YM2612 samples) to improve performance noticeably.\r
+#endif\r
+\r
+@@0. "6 button pad"\r
+If you enable this, games will think that 6 button gamepad is connected. If you\r
+go and reconfigure your keys, you will be able to bind X,Y,Z and mode actions.\r
+\r
+@@0. "Region"\r
+This option lets you force the game to think it is running on machine from the\r
+specified region, or just to set autodetection order. Also affects Sega/Mega CD.\r
+\r
+@@0. "Use SRAM/BRAM savestates"\r
+This will automatically read/write SRAM (or BRAM for Sega/Mega CD) savestates for\r
+games which are using them. SRAM is saved whenever you pause your game or exit the\r
+emulator.\r
+\r
+@@0. "Confirm savestate"\r
+Allows to enable confirmation on savestate saving (to prevent savestate overwrites),\r
+on loading (to prevent destroying current game progress), and on both or none, when\r
+using shortcut buttons (not menu) for saving/loading.\r
+\r
+@@0. "Save slot"\r
+This is a slot number to use for savestates. This can also be configured to be\r
+changed with a button (see "key configuration").\r
+\r
+#ifdef GP2X\r
+@@0. "GP2X CPU clocks"\r
+Here you can change clocks of both GP2X's CPUs. Larger values increase performance.\r
+There is no separate option for the second CPU because both CPUs use the same clock\r
+source. Setting this option to 200 will cause PicoDrive NOT to change GP2X's clocks\r
+at all (this is if you use external program to set clock).\r
+\r
+#endif\r
+@@0. "[Sega/Mega CD options]"\r
+Enters Sega/Mega CD options menu (see below).\r
+\r
+@@0. "[advanced options]"\r
+Enters advanced options menu (see below).\r
+\r
+@@0. "Save cfg as default"\r
+If you save your config here it will be loaded on next ROM load, but only if there\r
+is no game specific config saved (which will be loaded in that case).\r
+You can press left/right to switch to a different config profile.\r
+\r
+@@0. "Save cfg for current game only"\r
+Whenever you load current ROM again these settings will be loaded\r
+#ifdef GP2X\r
+(squidgehack and RAM settings will not take effect until emulator is restarted).\r
+#endif\r
+\r
+\r
+Advanced configuration\r
+----------------------\r
+\r
+Enter [advanced options] in config menu to see these options.\r
+\r
+#ifdef GP2X\r
+@@1. "Gamma correction"\r
+Alters image gamma through GP2X hardware. Larger values make image to look brighter,\r
+lower - darker (default is 1.0).\r
+\r
+@@1. "A_SN's gamma curve"\r
+If this is enabled, different gamma adjustment method will be used (suggested by A_SN\r
+from gp32x boards). Basically it makes difference for dark and bright colors.\r
+\r
+@@1. "Perfect vsync"\r
+This one adjusts the LCD refresh rate to better match game's refresh rate and starts\r
+synchronizing rendering with it. Should make scrolling smoother and eliminate tearing.\r
+\r
+#endif\r
+@@1. "Emulate Z80"\r
+Enables emulation of Z80 chip, which was mostly used to drive the other sound chips.\r
+Some games do complex sync with it, so you must enable it even if you don't use\r
+sound to be able to play them.\r
+\r
+@@1. "Emulate YM2612 (FM)"\r
+This enables emulation of six-channel FM sound synthesizer chip, which was used to\r
+produce sound effects and music.\r
+\r
+@@1. "Emulate SN76496 (PSG)"\r
+This enables emulation of additional sound chip for additional effects.\r
+\r
+Note: if you change sound settings AFTER loading a ROM, you may need to reset\r
+game to get sound. This is because most games initialize sound chips on\r
+startup, and this data is lost when sound chips are being enabled/disabled.\r
+\r
+#ifdef GIZ\r
+@@1. "Wait for V-sync"\r
+Waits for vertical sync before drawing. This option doesn't eliminate tearing\r
+problems, because full framebuffer update takes much more time then the blanking\r
+period lasts on Gizmondo..\r
+\r
+#endif\r
+@@1. "gzip savestates"\r
+This will always apply gzip compression on your savestates, allowing you to\r
+save some space and load/save time.\r
+\r
+@@1. "Don't save last used ROM"\r
+This will disable writing last used ROM to config on exit (what might cause SD\r
+card corruption according to DaveC).\r
+\r
+#ifdef GP2X\r
+@@1. "craigix's RAM timings"\r
+This overclocks the GP2X RAM chips, but may cause instability. Recommended if you\r
+use the second core for sound. Needs emulator restart to take effect.\r
+See this thread:\r
+http://www.gp32x.com/board/index.php?showtopic=32319\r
+\r
+@@1. "squidgehack"\r
+Well known way to improve the GP2X performance. You must restart the emulator\r
+for the change of this option to take effect.\r
+\r
+#endif\r
+\r
+Sega/Mega CD options \r
+--------------------\r
+\r
+@@2,@@2,@@2. "USA/EUR/JAP BIOS"\r
+These options just show if your BIOS files were correctly detected by the\r
+emulator (it shows the filename it is using). If so, you can press Start to\r
+test your BIOS.\r
+\r
+@@2. "CD LEDs"\r
+The Sega/Mega CD unit had two blinking LEDs (red and green) on it. This option\r
+will display them on top-left corner of the screen.\r
+\r
+@@2. "CDDA audio (using mp3s)"\r
+This option enables CD audio playback.\r
+\r
+@@2. "PCM audio"\r
+This enables 8 channel PCM sound source. It is required for some games to run,\r
+because they monitor state of this audio chip.\r
+\r
+@@2. "ReadAhead buffer"\r
+#ifdef GP2X\r
+This option is for dealing with slow SD card access in GP2X, which makes FMV\r
+games unplayable. It will allow emulator not to access SD card for longer periods\r
+of time, but it will take more time to fill the buffer.\r
+#endif\r
+#ifdef GIZ\r
+This option can prefetch more data from the CD then read by the game - not really\r
+useful for Gizmondo (this is a workaround for SD access problems on GP2X port).\r
+#endif\r
+\r
+@@2. "Save RAM cart"\r
+Here you can enable 64K RAM cart. Format it in BIOS if you do.\r
+\r
+@@2. "Scale/Rot. fx"\r
+The Sega/Mega CD had scaling/rotation chip, which allows effects similar to\r
+"Mode 7" effects in SNES. Unfortunately emulating it is slow, and very few games\r
+used it, so it's better to disable this option, unless game really needs it.\r
+\r
+@@2. "Better sync"\r
+This option is similar to "Perfect synchro" in Gens. Some games require it to run,\r
+for example most (all?) Wolfteam games, and some other ones. Don't use it for\r
+games which don't need it, it will just slow them down.\r
+\r
+\r
+Key configuration\r
+-----------------\r
+\r
+Select "Configure controls" from the main menu. Then select "Player 1" and you will\r
+see two columns. The left column lists names of Genesis/MD controller buttons, and\r
+the right GP2X ones, which are assigned to them. If you bind 2 different GP2X buttons\r
+to the same action, you will get a combo (which means that you will have to press\r
+both buttons for that action to happen.\r
 \r
 \r
 Cheat support\r
@@ -167,13 +424,15 @@ Credits
 \r
 This emulator uses code from these people/projects:\r
 \r
+notaz\r
+GP2X, UIQ, Gizmondo ports, Cyclone 68000 hacks,\r
+lots of additional coding (see changelog).\r
+Homepage: http://notaz.gp2x.de/\r
+\r
 Dave\r
 Cyclone 68000 core, Pico emulation library\r
 Homepage: http://www.finalburn.com/\r
 \r
-notaz\r
-GP2X port, Cyclone 68000 hacks, lots of additional coding (see changelog).\r
-\r
 Reesy & FluBBa\r
 DrZ80, the Z80 emulator written in ARM assembly.\r
 Homepage: http://reesy.gp32x.de/\r
@@ -201,9 +460,8 @@ Additional thanks
 * Bart Trzynadlowski for his SSFII and 68000 docs.\r
 * Haze for his research (http://haze.mameworld.info).\r
 * Mark and Jean-loup for zlib library.\r
-* Anyone else I forgot. You know who you are.\r
-\r
-GP2X:\r
+* ketchupgun for the skin.\r
+#ifdef GP2X\r
 * rlyeh and all the other people behind the minimal library.\r
 * Squidge for his famous squidgehack(tm).\r
 * Dzz for his ARM940 sample code.\r
@@ -212,10 +470,13 @@ GP2X:
 * A_SN for his gamma code.\r
 * craigix for supplying the GP2X hardware and making this port possible.\r
 * Alex for the icon.\r
-* ketchupgun for the skin.\r
 * All the people from gp32x boards for their support.\r
-\r
-Symbian:\r
+#endif\r
+#ifdef GIZ\r
+* Kingcdr's for the SDK and Reesy for the DLL and sound code.\r
+* jens.l for supplying the Gizmondo hardware and making this port possible.\r
+#endif\r
+#ifdef UIQ\r
 * Peter van Sebille for his various open-source Symbian projects to learn from.\r
 * Steve Fischer for his open-source Motorola projects.\r
 * The development team behind "Symbian GCC Improvement Project"\r
@@ -223,11 +484,14 @@ Symbian:
   compile tools.\r
 * AnotherGuest for all his Symbian stuff and support.\r
 * Inder for the icons.\r
+#endif\r
+* Anyone else I forgot. You know who you are.\r
 \r
 \r
 Changelog\r
 ---------\r
 1.34\r
+  + Gizmondo port added.\r
   + Some new optimizations in memory handlers, and for shadow/hilight mode.\r
   + Added some hacks to make more games work without enabling "accurate timing".\r
   * Adjusted timing for "accurate timing" mode and added preliminary VDP FIFO\r
index b5eaaac..6581e4f 100644 (file)
@@ -101,7 +101,7 @@ DEFINC += -D_USE_DRZ80
 OBJS += ../../cpu/DrZ80/drz80.o\r
 \r
 \r
-all: PicoDrive.exe\r
+all: PicoDrive.exe readme.txt\r
 \r
 PicoDrive.exe : $(OBJS) ../common/helix/helix_mp3.a\r
        @echo ">>>" $@\r
@@ -148,7 +148,7 @@ endif
        @$(AS) $(ASFLAGS) $< -o $@\r
 \r
 # build Cyclone\r
-../../cpu/Cyclone/proj/Cyclone.s :\r
+../../cpu/Cyclone/proj/Cyclone.s:\r
        @echo building Cyclone...\r
        @make -C ../../cpu/Cyclone/proj CONFIG_FILE=config_pico.h\r
 \r
@@ -156,6 +156,12 @@ endif
 ../common/helix/helix_mp3.a:\r
        make -C ../common/helix\r
 \r
+readme.txt: ../../tools/textfilter ../base_readme.txt\r
+       ../../tools/textfilter ../base_readme.txt $@ GIZ\r
+\r
+../../tools/textfilter: ../../tools/textfilter.c\r
+       make -C ../../tools/ textfilter\r
+\r
 \r
 # cleanup\r
 clean: tidy\r
@@ -184,7 +190,7 @@ $(error need VER)
 endif\r
 endif\r
 \r
-rel: PicoDrive.exe kgsdk/ARMV4IRel/KGSDK.dll # ../readme.txt config.txt\r
+rel: PicoDrive.exe kgsdk/ARMV4IRel/KGSDK.dll readme.txt\r
        zip -9 -j ../../PicoDrive_$(VER).zip $^\r
        ln -s ../gp2x/skin skin\r
        zip -9 -r ../../PicoDrive_$(VER).zip skin -i \*.png -i \*.txt\r
index 5c903b1..595db53 100644 (file)
@@ -208,6 +208,12 @@ testrefr.gpe : test.o gp2x.o
 ../common/helix/helix_mp3.a:\r
        make -C ../common/helix\r
 \r
+readme.txt: ../../tools/textfilter ../base_readme.txt\r
+       ../../tools/textfilter ../base_readme.txt $@ GP2X\r
+\r
+../../tools/textfilter: ../../tools/textfilter.c\r
+       make -C ../../tools/ textfilter\r
+\r
 \r
 # cleanup\r
 clean: tidy\r
@@ -228,7 +234,7 @@ $(error need VER)
 endif\r
 endif\r
 \r
-rel: PicoDrive.gpe code940/pico940.bin ../readme.txt config.txt PicoDrive.man.txt PicoDrive.png\r
+rel: PicoDrive.gpe code940/pico940.bin readme.txt PicoDrive.man.txt PicoDrive.png\r
        zip -9 -j ../../PicoDrive_$(VER).zip $^ mmuhack.o\r
        zip -9 -r ../../PicoDrive_$(VER).zip skin -i \*.png -i \*.txt\r
 \r
diff --git a/platform/gp2x/config.txt b/platform/gp2x/config.txt
deleted file mode 100644 (file)
index 8be5239..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-As PicoDrive is multiplatform emulator, this is GP2X specific part of readme\r
-about configuration.\r
-\r
-If you have questions, you can use GP32X to ask for help.\r
-http://www.gp32x.com/board/index.php?showforum=48\r
-\r
-\r
-Configuration\r
--------------\r
-\r
-1. "Renderer"\r
-8bit fast:\r
-This enables alternative heavily optimized tile-based renderer, which renders\r
-pixels not line-by-line (this is what accurate renderers do), but in 8x8 tiles,\r
-which is much faster. But because of the way it works it can't render any\r
-mid-frame image changes (raster effects), so it is useful only with some games.\r
-\r
-Other two are accurate line-based renderers. The 8bit is faster but does not\r
-run well with some games like Street Racer.\r
-\r
-2. "Scaling"\r
-"hw" means GP2X hardware scaler, which causes no performance loss, but scaled\r
-image looks a bit blocky. "sw" means software scaling, which uses pixel\r
-averaging and may look a bit nicer, but blurry. Horizontal scaling is only for\r
-games which use so called "32 column mode" (256x224 or 256x240), and scales\r
-image width to 320 pixels. Vertical scales height to 240 for games which use\r
-height 224 (most of them).\r
-\r
-3. "Accurate timing"\r
-This adds some more emulation precision, but slows the emulation down. Without\r
-this option some games do not boot (Red Zone for example), others have sound\r
-problems. This options has no effect for Sega/Mega CD emulation.\r
-\r
-4. "Accurate sprites"\r
-This option improves emulation of sprite priorities, it also enables emulation\r
-of sprite collision bit. If you see one sprite being drawn incorrectly above\r
-the other (often seen in Sonic 3D Blast), you can enable this to fix the problem.\r
-This only works with the accurate renderers (see first option).\r
-\r
-5. "Show FPS"\r
-Self-explanatory. Format is XX/YY, where XX is the number of rendered frames and\r
-YY is the number of emulated frames per second.\r
-\r
-6. "Frameskip"\r
-How many frames to skip rendering before displaying another.\r
-"Auto" is recommended.\r
-\r
-7. "Enable sound"\r
-Does what it says. You must enable at least YM2612 or SN76496 (in advanced options,\r
-see below) for this to make sense.\r
-\r
-8. "Sound Quality"\r
-Sound rate and stereo mode. If you want 44100Hz sound, it is recommended to enable\r
-the second core (next option).\r
-\r
-9. "Use ARM940 core for sound"\r
-This option causes PicoDrive to use ARM940T core (GP2X's second CPU) for sound \r
-(i.e. to generate YM2612 samples) to improve performance noticeably.\r
-\r
-10. "6 button pad"\r
-If you enable this, games will think that 6 button gamepad is connected. If you\r
-go and reconfigure your keys, you will be able to bind X,Y,Z and mode actions.\r
-\r
-11. "Region"\r
-This option lets you force the game to think it is running on machine from the\r
-specified region, or just to set autodetection order. Also affects Sega/Mega CD.\r
-\r
-12. "Use SRAM/BRAM savestates"\r
-This will automatically read/write SRAM (or BRAM for Sega/Mega CD) savestates for\r
-games which are using them. SRAM is saved whenever you pause your game or exit the\r
-emulator.\r
-\r
-13. "Confirm savestate"\r
-Allows to enable confirmation on savestate saving (to prevent savestate overwrites),\r
-on loading (to prevent destroying current game progress), and on both or none.\r
-\r
-14. "Save slot"\r
-This is a slot number to use for savestates. This can also be configured to be\r
-changed with a button (see "key configuration").\r
-\r
-15. "GP2X CPU clocks"\r
-Here you can change clocks of both GP2X's CPUs. Larger values increase performance.\r
-There is no separate option for the second CPU because both CPUs use the same clock\r
-source. Setting this option to 200 will cause PicoDrive NOT to change GP2X's clocks\r
-at all (this is if you use external program to set clock).\r
-\r
-16. "[Sega/Mega CD options]"\r
-Enters Sega/Mega CD options menu (see below).\r
-\r
-17. "[advanced options]"\r
-Enters advanced options menu (see below).\r
-\r
-18. "Save cfg as default"\r
-If you save your config here it will be loaded on next ROM load, but only if there\r
-is no game specific config saved (which will be loaded in that case).\r
-You can press left/right to switch to a different config profile.\r
-\r
-19. "Save cfg for current game only"\r
-Whenever you load current ROM again these settings will be loaded (squidgehack and\r
-RAM settings will not take effect until emulator is restarted).\r
-\r
-\r
-Advanced configuration\r
-----------------------\r
-\r
-Enter [advanced options] in config menu to see these options.\r
-\r
-1. "Gamma correction"\r
-Alters image gamma through GP2X hardware. Larger values make image to look brighter,\r
-lower - darker (default is 1.0).\r
-\r
-2. "A_SN's gamma curve"\r
-If this is enabled, different gamma adjustment method will be used (suggested by A_SN\r
-from gp32x boards). Basically it makes difference for dark and bright colors.\r
-\r
-3. "Perfect vsync"\r
-This one adjusts the LCD refresh rate to better match game's refresh rate and starts\r
-synchronizing rendering with it. Should make scrolling smoother and eliminate tearing.\r
-\r
-4. "Emulate Z80"\r
-Enables emulation of Z80 chip, which was mostly used to drive the other sound chips.\r
-Some games do complex sync with it, so you must enable it even if you don't use\r
-sound to be able to play them.\r
-\r
-5. "Emulate YM2612 (FM)"\r
-This enables emulation of six-channel FM sound synthesizer chip, which was used to\r
-produce sound effects and music.\r
-\r
-6. "Emulate SN76496 (PSG)"\r
-This enables emulation of additional sound chip for additional effects.\r
-\r
-Note: if you change sound settings AFTER loading a ROM, you may need to reset\r
-game to get sound. This is because most games initialize sound chips on\r
-startup, and this data is lost when sound chips are being enabled/disabled.\r
-\r
-7. "gzip savestates"\r
-This will always apply gzip compression on your savestates, allowing you to\r
-save some space and load/save time.\r
-\r
-8. "Don't save last used ROM"\r
-This will disable writing last used ROM to config on exit (what might cause SD\r
-card corruption according to DaveC).\r
-\r
-9. "craigix's RAM timings"\r
-This overclocks the GP2X RAM chips, but may cause instability. Recommended if you\r
-use the second core for sound. Needs emulator restart to take effect.\r
-See this thread:\r
-http://www.gp32x.com/board/index.php?showtopic=32319\r
-\r
-10. "squidgehack"\r
-Well known way to improve the GP2X performance. You must restart the emulator\r
-for the change of this option to take effect.\r
-\r
-\r
-Sega/Mega CD options \r
---------------------\r
-\r
-1,2,3. "USA/EUR/JAP BIOS"\r
-These options just show if your BIOS files were correctly detected by the\r
-emulator (it shows the filename it is using). If so, you can press Start to\r
-test your BIOS.\r
-\r
-4. "CD LEDs"\r
-The Sega/Mega CD unit had two blinking LEDs (red and green) on it. This option\r
-will display them on top-left corner of the screen.\r
-\r
-5. "CDDA audio (using mp3s)"\r
-This option enables CD audio playback.\r
-\r
-6. "PCM audio"\r
-This enables 8 channel PCM sound source. It is required for some games to run,\r
-because they monitor state of this audio chip.\r
-\r
-7. "ReadAhead buffer"\r
-This option is for dealing with slow SD card access in GP2X, which makes FMV\r
-games unplayable. It will allow emulator not to access SD card for longer periods\r
-of time, but it will take more time to fill the buffer.\r
-\r
-8. "Save RAM cart"\r
-Here you can enable 64K RAM cart. Format it in BIOS if you do.\r
-\r
-9. "Scale/Rot. fx"\r
-The Sega/Mega CD had scaling/rotation chip, which allows effects similar to\r
-"Mode 7" effects in SNES. Unfortunately emulating it is slow, and very few games\r
-used it, so it's better to disable this option, unless game really needs it.\r
-\r
-10. "Better sync"\r
-This option is similar to "Perfect synchro" in Gens. Some games require it to run,\r
-for example most (all?) Wolfteam games, and some other ones. Don't use it for\r
-games which don't need it, it will just slow them down.\r
-\r
-\r
-Key configuration\r
------------------\r
-\r
-Select "Configure controls" from the main menu. Then select "Player 1" and you will\r
-see two columns. The left column lists names of Genesis/MD controller buttons, and\r
-the right GP2X ones, which are assigned to them. If you bind 2 different GP2X buttons\r
-to the same action, you will get a combo (which means that you will have to press\r
-both buttons for that action to happen.\r
-\r
index 6582fbe..0c126cc 100644 (file)
@@ -1,10 +1,10 @@
 CFLAGS = -Wall -ggdb
 
-TARGET = amalgamate
-OBJS = amalgamate.o
+TARGETS = amalgamate textfilter
+OBJS = $(addsuffix .o,$(TARGETS))
 
-all: $(TARGET)
+all: $(TARGETS)
 
 clean:
-       $(RM) $(TARGET) $(OBJS)
+       $(RM) $(TARGETS) $(OBJS)
 
diff --git a/tools/textfilter.c b/tools/textfilter.c
new file mode 100644 (file)
index 0000000..7a58e80
--- /dev/null
@@ -0,0 +1,114 @@
+#include <stdio.h>
+#include <string.h>
+
+
+static int check_defines(const char **defs, int defcount, char *tdef)
+{
+       int i, len;
+
+       len = strlen(tdef);
+       for (i = 0; i < len; i++)
+               if (tdef[i] == ' ' || tdef[i] == '\r' || tdef[i] == '\n') break;
+       tdef[i] = 0;
+
+       for (i = 0; i < defcount; i++)
+       {
+               if (strcmp(defs[i], tdef) == 0)
+                       return 1;
+       }
+
+       return 0;
+}
+
+
+static void do_counters(char *str)
+{
+       static int counters[4] = { 1, 1, 1, 1 };
+       char buff[1024];
+       int counter;
+       char *s = str;
+
+       while ((s = strstr(s, "@@")))
+       {
+               if (s[2] < '0' || s[2] > '3') { s++; continue; }
+
+               counter = s[2] - '0';
+               snprintf(buff, sizeof(buff), "%i%s", counters[counter]++, s + 3);
+               strcpy(s, buff);
+       }
+}
+
+
+int main(int argc, char *argv[])
+{
+       char buff[1024];
+       FILE *fi, *fo;
+       int skip_mode = 0, ifdef_level = 0, line = 0;
+
+       if (argc < 3)
+       {
+               printf("usage:\n%s <file_in> <file_out> [defines...]\n", argv[0]);
+               return 1;
+       }
+
+       fi = fopen(argv[1], "r");
+       if (fi == NULL)
+       {
+               printf("failed to open: %s\n", argv[1]);
+               return 2;
+       }
+
+       fo = fopen(argv[2], "w");
+       if (fo == NULL)
+       {
+               printf("failed to open: %s\n", argv[2]);
+               return 3;
+       }
+
+       for (++line; !feof(fi); line++)
+       {
+               char *fgs;
+
+               fgs = fgets(buff, sizeof(buff), fi);
+               if (fgs == NULL) break;
+
+               if (buff[0] == '#')
+               {
+                       /* control char */
+                       if (strncmp(buff, "#ifdef ", 7) == 0)
+                       {
+                               if (!check_defines((void *) &argv[3], argc-3, buff + 7)) skip_mode = 1;
+                               ifdef_level++;
+                       }
+                       else if (strncmp(buff, "#ifndef ", 8) == 0)
+                       {
+                               if ( check_defines((void *) &argv[3], argc-3, buff + 7)) skip_mode = 1;
+                               ifdef_level++;
+                       }
+                       else if (strncmp(buff, "#endif", 6) == 0)
+                       {
+                               ifdef_level--;
+                               if (ifdef_level == 0) skip_mode = 0;
+                               if (ifdef_level < 0)
+                               {
+                                       printf("%i: warning: #endif without #ifdef, ignoring\n", line);
+                                       ifdef_level = 0;
+                               }
+                       }
+
+                       /* skip line */
+                       continue;
+               }
+               if (!skip_mode)
+               {
+                       do_counters(buff);
+                       fputs(buff, fo);
+               }
+       }
+
+       fclose(fi);
+       fclose(fo);
+
+       return 0;
+}
+